From: admin Date: Fri, 16 May 2003 10:27:43 +0000 (+0000) Subject: Initialisation de la base KERNEL avec la version operationnelle de KERNEL_SRC issue... X-Git-Tag: V1_0~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4655b0b0eb5345da6a86852021014b0cbae2ad30;p=modules%2Fkernel.git Initialisation de la base KERNEL avec la version operationnelle de KERNEL_SRC issue de SalomePro1.1a. --- 4655b0b0eb5345da6a86852021014b0cbae2ad30 diff --git a/build_configure b/build_configure new file mode 100755 index 000000000..6f7bd3309 --- /dev/null +++ b/build_configure @@ -0,0 +1,196 @@ +#!/bin/bash + +# +# Tool for updating list of .in file for the SALOME project +# and regenerating configure script +# +# Author : Marc Tajchman - CEA +# Date : 10/10/2002 +# $Header$ +# + +ORIG_DIR=`pwd` +CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"` + +######################################################################## +# find_in - utility function +# +# usage : +# find_in directory filename +# +# Finds files following the *.in pattern, recursively in the +# directory (first argument). +# Results are appended into the file (second argument) +# +# Difference from the standard unix find is that files are tested +# before directories +# + +find_in() +{ + local i + local f=$2 + +# if the first argument is not a directory, returns + + if [ ! -d "$1" ] ; then + return + fi + +# dont look in the CVS directories + + case $1 in + */CVS) return ;; + *) ;; + esac + +# for each regular file contained in the directory +# test if it's a .in file + + for i in "$1"/* + do + if [ -f "$i" ] ; then + case $i in + *.in) echo " "$i" \\" >> $f;; + *) ;; + esac + fi + done + +# for each subdirectory of the first argument, proceeds recursively + + for i in "$1"/* + do + if [ -d "$i" ] ; then + find_in "$i" "$f" + fi + done +} + + +####################################################################### +# Generate list of .in files (Makefile.in, config.h.in, etc) +# appending it in file configure.in + +cd ${CONF_DIR} +ABS_CONF_DIR=`pwd` + +# +# Common part of the configure.in file +# +chmod u+w configure.in.base +if ! \cp -f configure.in.base configure.in_tmp1 +then + echo + echo "error : can't create files in" ${CONF_DIR} + echo "aborting ..." + chmod u-w configure.in.base + exit +fi +chmod u-w configure.in.base + +############################################# +echo '' >> configure.in_tmp1 +echo 'export TEMPO=${KERNEL_ROOT_DIR}' >> configure.in_tmp1 +echo 'export KERNEL_ROOT_DIR=${ROOT_SRCDIR}' >> configure.in_tmp1 +############################################# + +echo "" >> configure.in_tmp1 +echo "AC_OUTPUT([ \\" >> configure.in_tmp1 + +# +# List of .in files in the adm/unix directory +# These files MUST be on top of AC_OUTPUT list so we +# put them "manually" +# + +echo " ./salome_adm/unix/SALOMEconfig.h \\" >> configure.in_tmp1 +echo " ./salome_adm/unix/F77config.h \\" >> configure.in_tmp1 +echo " ./salome_adm/unix/sstream \\" >> configure.in_tmp1 +echo " ./salome_adm/unix/depend \\" >> configure.in_tmp1 +echo " ./salome_adm/unix/make_omniorb \\" >> configure.in_tmp1 +echo " ./salome_adm/unix/envScript \\" >> configure.in_tmp1 +echo " ./salome_adm/unix/make_commence \\" >> configure.in_tmp1 +echo " ./salome_adm/unix/make_conclude \\" >> configure.in_tmp1 +echo " ./salome_adm/unix/make_module \\" >> configure.in_tmp1 +echo " ./salome_adm/Makefile \\" >> configure.in_tmp1 + +\rm -f configure.in_tmp2 configure.in_tmp3 +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 's/.in / /' configure.in_tmp2 >> configure.in_tmp1 + +echo "])" >> configure.in_tmp1 + +############################################# +echo 'export KERNEL_ROOT_DIR=${TEMPO}' >> configure.in_tmp1 +############################################# + +\mv configure.in_tmp1 configure.in_new +\rm -f configure.in_tmp2 configure.in_tmp3 + + +######################################################################## +# Create new (or replace old) configure.in file +# Print a message if the file is write protected +# + +echo +if test ! -f configure.in +then + echo -n "Creating new file 'configure.in' ... " + if \mv configure.in_new configure.in >& /dev/null + then + echo "done" + else + echo "error, check your file permissions" + fi +else + echo -n "Updating 'configure.in' file ... " + if ! \cp configure.in configure.in_old >& /dev/null + then + echo + echo + echo "Can't backup previous configure.in" + echo -n "Continue (you will not be able to revert) - (Y/N) ? " + read R + case "x$R" in + xn*) exit;; + xN*) exit;; + esac + echo + echo -n " " + fi + if \cp configure.in_new configure.in >& /dev/null + then + echo "done" + else + echo + echo "error, can't update previous configure.in" + fi +fi + +######################################################################## +# Use autoconf to rebuild the configure script +# + +if test -f configure +then + echo -n "Updating 'configure' script ... " +else + echo -n "Creating 'configure' script ... " +fi + +aclocal --acdir=salome_adm/unix/config_files +if autoconf +then + echo "done" +else + echo "failed (check file permissions and/or user quotas ...)" +fi + +cd ${ORIG_DIR} + +echo diff --git a/configure.in.base b/configure.in.base new file mode 100644 index 000000000..8e3ab92de --- /dev/null +++ b/configure.in.base @@ -0,0 +1,384 @@ +# +# PLEASE DO NOT MODIFY configure.in FILE +# +# ALL CHANGES WILL BE DISCARDED BY THE NEXT +# build_configure COMMAND +# +# CHANGES MUST BE MADE IN configure.in.base FILE +# +# +# Author : Marc Tajchman (CEA) +# Date : 28/06/2001 +# Modified by : Patrick GOLDBRONN (CEA) +# Modified by : Marc Tajchman (CEA) +# +# Created from configure.in.base +# + +AC_INIT(src) +AC_CONFIG_AUX_DIR(salome_adm/unix/config_files) +AC_CANONICAL_HOST + +PACKAGE=salome +AC_SUBST(PACKAGE) + +VERSION=0.0.1 +AC_SUBST(VERSION) + +dnl +dnl Initialize source and build root directories +dnl + +ROOT_BUILDDIR=`pwd` +ROOT_SRCDIR=`echo $0 | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` +cd $ROOT_SRCDIR +ROOT_SRCDIR=`pwd` +cd $ROOT_BUILDDIR + +AC_SUBST(ROOT_SRCDIR) +AC_SUBST(ROOT_BUILDDIR) +dnl ########################################################## +AC_SUBST(KERNEL_ROOT_DIR) +dnl ########################################################## + +echo +echo Source root directory : $ROOT_SRCDIR +echo Build root directory : $ROOT_BUILDDIR +echo +echo + +if test -z "$AR"; then + AC_CHECK_PROGS(AR,ar xar,:,$PATH) +fi +AC_SUBST(AR) + +dnl Export the AR macro so that it will be placed in the libtool file +dnl correctly. +export AR + +echo +echo --------------------------------------------- +echo testing make +echo --------------------------------------------- +echo + +AC_PROG_MAKE_SET +AC_PROG_INSTALL +dnl +dnl libtool macro check for CC, LD, NM, LN_S, RANLIB, STRIP + pour les librairies dynamiques ! + +AC_ENABLE_DEBUG(yes) +AC_DISABLE_PRODUCTION + +echo --------------------------------------------- +echo testing libtool +echo --------------------------------------------- + +dnl first, we set static to no! +dnl if we want it, use --enable-static +AC_ENABLE_STATIC(no) + +AC_LIBTOOL_DLOPEN +AC_PROG_LIBTOOL + +dnl Fix up the INSTALL macro if it s a relative path. We want the +dnl full-path to the binary instead. +case "$INSTALL" in + *install-sh*) + INSTALL='\${top_srcdir}'/salome_adm/unix/config_files/install-sh + ;; +esac + +echo +echo --------------------------------------------- +echo testing C/C++ +echo --------------------------------------------- +echo + +cc_ok=no +dnl inutil car libtool +dnl AC_PROG_CC +AC_PROG_CXX +AC_DEPEND_FLAG +# AC_CC_WARNINGS([ansi]) +cc_ok=yes + +dnl Library libdl : +AC_CHECK_LIB(dl,dlopen) + +dnl add library libm : +AC_CHECK_LIB(m,ceil) + +dnl +dnl Well we use sstream which is not in gcc pre-2.95.3 +dnl We must test if it exists. If not, add it in include ! +dnl + +AC_CXX_HAVE_SSTREAM + +dnl +dnl --------------------------------------------- +dnl testing MPICH +dnl --------------------------------------------- +dnl + +CHECK_MPICH + +echo +echo --------------------------------------------- +echo testing LEX \& YACC +echo --------------------------------------------- +echo + +lex_yacc_ok=no +AC_PROG_YACC +AC_PROG_LEX +lex_yacc_ok=yes + +echo +echo --------------------------------------------- +echo testing python +echo --------------------------------------------- +echo + +CHECK_PYTHON + +dnl echo +dnl echo --------------------------------------------- +dnl echo testing java +dnl echo --------------------------------------------- +dnl echo + +dnl CHECK_JAVA + +echo +echo --------------------------------------------- +echo testing swig +echo --------------------------------------------- +echo + +CHECK_SWIG + +echo +echo --------------------------------------------- +echo testing threads +echo --------------------------------------------- +echo + +ENABLE_PTHREADS + +echo +echo --------------------------------------------- +echo testing omniORB +echo --------------------------------------------- +echo + +CHECK_OMNIORB + +dnl echo +dnl echo --------------------------------------------- +dnl echo testing mico +dnl echo --------------------------------------------- +dnl echo + +dnl CHECK_MICO + +echo +echo --------------------------------------------- +echo default ORB : omniORB +echo --------------------------------------------- +echo + +DEFAULT_ORB=omniORB +CHECK_CORBA + +AC_SUBST_FILE(CORBA) +corba=make_$ORB +CORBA=salome_adm/unix/$corba + +echo +echo --------------------------------------------- +echo testing openGL +echo --------------------------------------------- +echo + +CHECK_OPENGL + +echo +echo --------------------------------------------- +echo testing QT +echo --------------------------------------------- +echo + +CHECK_QT + +echo +echo --------------------------------------------- +echo testing VTK +echo --------------------------------------------- +echo + +CHECK_VTK + +echo +echo --------------------------------------------- +echo testing HDF5 +echo --------------------------------------------- +echo + +CHECK_HDF5 + +echo +echo --------------------------------------------- +echo testing MED2 +echo --------------------------------------------- +echo + +CHECK_MED2 + +echo +echo --------------------------------------------- +echo Testing OpenCascade +echo --------------------------------------------- +echo + +CHECK_CAS + +echo +echo --------------------------------------------- +echo Testing sip +echo --------------------------------------------- +echo + +CHECK_SIP + +echo +echo --------------------------------------------- +echo Testing pyqt +echo --------------------------------------------- +echo + +CHECK_PYQT + +echo +echo --------------------------------------------- +echo Testing qwt +echo --------------------------------------------- +echo + +CHECK_QWT + +echo +echo --------------------------------------------- +echo Testing html generators +echo --------------------------------------------- +echo + +CHECK_HTML_GENERATORS + +echo +echo --------------------------------------------- +echo Summary +echo --------------------------------------------- +echo + +echo Configure +variables="cc_ok lex_yacc_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok occ_ok sip_ok pyqt_ok qwt_ok doxygen_ok graphviz_ok" + +for var in $variables +do + printf " %10s : " `echo \$var | sed -e "s,_ok,,"` + eval echo \$$var +done + +echo +echo "Default ORB : $DEFAULT_ORB" +echo + +dnl generals files which could be included in every makefile + +AC_SUBST_FILE(COMMENCE) COMMENCE=salome_adm/unix/make_commence +AC_SUBST_FILE(CONCLUDE) CONCLUDE=salome_adm/unix/make_conclude +AC_SUBST_FILE(MODULE) MODULE=salome_adm/unix/make_module + +dnl les dependences +AC_SUBST_FILE(DEPEND) DEPEND=salome_adm/unix/depend + +dnl We don t need to say when we re entering directories if we re using +dnl GNU make becuase make does it for us. +if test "X$GMAKE" = "Xyes"; then + AC_SUBST(SETX) SETX=":" +else + AC_SUBST(SETX) SETX="set -x" +fi + +# make other build directories +for rep in salome_adm adm_local doc bin/salome include/salome lib/salome share/salome/resources share/salome/doc idl +do +# if test ! -d $rep ; then +# eval mkdir $rep +# fi + $INSTALL -d $rep +done + +echo +echo --------------------------------------------- +echo copying resource files, shell scripts, and +echo xml files +echo --------------------------------------------- +echo + + +dnl copy resources directories + +#for i in `find $ROOT_SRCDIR -name 'resources' -print` +#do +# local_res=`echo $i | sed -e "s,$ROOT_SRCDIR,.,"` +# local_res_dir=`echo $local_res | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` +# mkdir -p $local_res_dir +# cd $local_res_dir +# ln -fs $i +# echo $local_res +# cd $ROOT_BUILDDIR +#done + +dnl copy shells and utilities contained in the bin directory +dnl excluding .in files (treated in AC-OUTPUT below) and CVS +dnl directory + +cd bin +for i in $ROOT_SRCDIR/bin/* +do + local_bin=`echo $i | sed -e "s,$ROOT_SRCDIR,.,"` + case "$local_bin" in + *.in | *~) ;; + ./bin/CVS) ;; + *) ln -fs $i; echo $local_bin ;; + esac +done +cd $ROOT_BUILDDIR + +AC_SUBST_FILE(ENVSCRIPT) ENVSCRIPT=salome_adm/unix/envScript + +dnl copy xml files to the build tree (lib directory) +dnl pourquoi ???? + +#cd lib +#for i in `find $ROOT_SRCDIR -name "*.xml" -print` +#do +# ln -fs $i +# echo `echo $i | sed -e "s,$ROOT_SRCDIR,.,"` +#done +#cd $ROOT_BUILDDIR + +echo +echo --------------------------------------------- +echo generating Makefiles and configure files +echo --------------------------------------------- +echo + +AC_OUTPUT_COMMANDS([ \ + chmod +x ./bin/* \ +]) + +## do not delete this line diff --git a/idl/Logger.idl b/idl/Logger.idl new file mode 100644 index 000000000..57be3a2f2 --- /dev/null +++ b/idl/Logger.idl @@ -0,0 +1,24 @@ +//============================================================================= +// File : Logger.idl +// Created : nov 18 10:28:17 2002 +// Author : Vasily Rusyaev +// Project : SALOME/PRO +//============================================================================= + +#ifndef SALOME_LOGGER_IDL +#define SALOME_LOGGER_IDL + +#pragma prefix "opencascade.com" + +module SALOME_Logger +{ + interface Logger + { + //put message into one special place for all servers using Logger + oneway void putMessage (in string message); + }; +}; + + + +#endif diff --git a/idl/MPIContainer.idl b/idl/MPIContainer.idl new file mode 100644 index 000000000..3e9ee2287 --- /dev/null +++ b/idl/MPIContainer.idl @@ -0,0 +1,15 @@ +#ifndef _SALOME_MPICONTAINER_IDL_ +#define _SALOME_MPICONTAINER_IDL_ + +#include "SALOME_Component.idl" +#include "MPIObject.idl" + +module Engines +{ + interface MPIContainer:Container,MPIObject + { + } ; +} ; + +#endif + diff --git a/idl/MPIObject.idl b/idl/MPIObject.idl new file mode 100644 index 000000000..ea82c2f03 --- /dev/null +++ b/idl/MPIObject.idl @@ -0,0 +1,13 @@ +#ifndef _SALOME_MPIOBJECT_IDL_ +#define _SALOME_MPIOBJECT_IDL_ + +module Engines +{ + typedef sequence IORTab; + interface MPIObject + { + attribute IORTab tior; + } ; +} ; + +#endif diff --git a/idl/Makefile.in b/idl/Makefile.in new file mode 100644 index 000000000..68cb40756 --- /dev/null +++ b/idl/Makefile.in @@ -0,0 +1,78 @@ +# +# generate dependencies for idl file : +# + +# source path +top_srcdir=@top_srcdir@ +top_builddir=.. +srcdir=@srcdir@ +VPATH=.:$(srcdir) + +@COMMENCE@ + +IDL_FILES = \ + SALOME_Exception.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_DataTypeCatalog.idl \ + SALOME_RessourcesCatalog.idl \ + SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_Session.idl \ + SALOME_Component.idl \ + SALOME_TestComponent.idl \ + SALOME_Registry.idl \ + TypeData.idl \ + MPIObject.idl \ + MPIContainer.idl \ + Logger.idl + +PY_CLIENT_IDL = $(IDL_FILES) + +# we copy all idl file in $(top_builddir)/idl +inc: $(IDL_FILES:%=$(top_builddir)/idl/%) + +$(IDL_FILES:%=$(top_builddir)/idl/%):$(top_builddir)/idl/%:% +# $(CP) $< $@ + cp -f $< $@ + + +lib: pyidl + +PYTHON_BUILD_SITE=$(top_builddir)/lib/python$(PYTHON_VERSION)/site-packages/@PACKAGE@ + +pyidl: $(PYTHON_BUILD_SITE) $(IDL_FILES:%.idl=$(PYTHON_BUILD_SITE)/%_idl.py) + +$(PYTHON_BUILD_SITE): + $(INSTALL) -d $@ + +$(PYTHON_BUILD_SITE)/%_idl.py: %.idl + $(OMNIORB_IDL) $(OMNIORB_IDLPYFLAGS) -C$(PYTHON_BUILD_SITE) $< + + +# install python client (generated from idl file +install: install-pyidl install-idl + +# create directory $(idldir) and copy idl files into it +install-idl: $(IDL_FILES) + $(INSTALL) -d $(idldir) + $(INSTALL_DATA) $^ $(idldir) + + +install-pyidl: $(IDL_FILES) + $(INSTALL) -d $(PYTHON_SITE_INSTALL) + @for file in $^ dummy; do \ + if [ $$file != "dummy" ]; then \ + $(OMNIORB_IDL) $(OMNIORB_IDLPYFLAGS) -C$(PYTHON_SITE_INSTALL) $$file ; \ + fi ; \ + done ; + +#@ CONCLUDE @ + +cleandep: + -$(RM) .dep* + +distclean: + -$(RM) *.py + -$(RM) $(IDL_FILES:%=$(top_builddir)/idl/%) + -$(RM) Makefile + diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl new file mode 100644 index 000000000..9558fdf08 --- /dev/null +++ b/idl/SALOMEDS.idl @@ -0,0 +1,1476 @@ +//===================================================== +// File : SALOMEDS.idl +// Created : Thu Nov 29 21:25:39 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Copyright : Open CASCADE 2001 +// $Header$ +//===================================================== + + +/*! \mainpage + \image html Application-About.png + +*/ +/*! \page page1 Mapping of IDL definitions to Python language. +\section Intro Introduction +%SALOME PRO is a distributed client/server application using the Common Object Request Broker Architecture (CORBA). +CORBA architecture uses the Interface Definition Language (IDL), which specifies interfaces between CORBA objects. So with help of IDL +CORBA's language independence is ensured . Because interfaces described in IDL can be mapped to the most of currently used programming languages, CORBA applications and components are thus +independent of the language(s) used to implement them. In other words, a client written in C++ can communicate with a server written in Java, which in turn can communicate with +another server written in COBOL, and so forth. + +One important thing to remember about IDL is that it is not an implementation language. That is, applications can't be written in IDL. The sole purpose of IDL is to define interfaces; +providing implementations for these interfaces is performed using some other language. + +This page contains an abridged reference manual for mapping of IDL definitions to Python language. It will be useful for Python programmers who are not familiar +with IDL language. All examples are taken from %SALOME PRO source files. +The complete version of Python Language Mapping Specification can be found here. + +
CONTENTS: +- \ref subsection1 +- \ref subsection2 +- \ref subsection3 +- \ref subsection4 +- \ref subsection5 +- \ref subsection6 +- \ref subsection7 + +\subsection subsection1 Using Scoped Names + +Python implements a module concept that is similar to the IDL scoping mechanisms, +except that it does not allow for nested modules. In addition, Python requires each +object to be implemented in a module; globally visible objects are not supported. + +Because of these constraints, scoped names are translated into Python using the +following rules: + +• An IDL module mapped into a Python module. Modules containing modules are +mapped to packages (i.e., directories with an __init__ module containing all +definitions excluding the nested modules). An implementation can chose to map toplevel +definitions (including the module CORBA) to modules in an implementationdefined +package, to allow concurrent installations of different CORBA runtime +libraries. In that case, the implementation must provide additional modules so that +toplevel modules can be used without importing them from a package. + +• For all other scopes, a Python class is introduced that contains all the definitions +inside this scope. + +• Other global definitions (except modules) appear in a module whose name is +implementation dependent. Implementations are encouraged to use the name of the +IDL file when defining the name of that module. + +For instance, + +\verbatim +module SALOMEDS { + interface StudyManager { + void Close(in Study aStudy); + }; +}; +\endverbatim + +would introduce a module SALOMEDS.py, which contains the following definitions: + +\verbatim +# module SALOMEDS.py +class StudyManager: + def _Close(self,aStudy): + pass #interfaces are discussed later +\endverbatim + +To avoid conflicts, IDL names that are also Python identifiers are prefixed with an underscore (‘_’). + +\subsection subsection2 Mapping for Template and Array Types + +Both the bounded and the unbounded string type of IDL are mapped to the Python +string type. Wide strings are represented by an implementation-defined type with the +following properties: + +• For the wide string X and the integer n, X[n] returns the nth character, which is a +wide string of length 1. + +• len(X) returns the number of characters of wide string X. + +• CORBA.wstr(c) returns a wide character with the code point c in an +implementation-defined encoding. + +• X+Y returns the concatenation of wide strings X and Y. + +• CORBA.word(CORBA.wstr(c)) == c + +The sequence template is mapped to sequence objects (e.g., tuples or lists). +Applications should not assume that values of a sequence type are mutable. Sequences +and arrays of octets and characters are mapped to the string type for efficiency reasons. + +For example, given the IDL definitions + +\verbatim +module SALOMEDS { + typedef sequence StringSeq; + + interface AttributeTableOfInteger : GenericAttribute { + + void SetRowTitles(in StringSeq theTitles) raises(IncorrectArgumentLength); + }; +}; +\endverbatim + +a client could invoke the operation + +\verbatim +print My_AttributeTableOfInteger.SetRowTitles(["X","F"]) +\endverbatim + +Array types are mapped like sequence templates. The application in this example also expects an +IncorrectArgumentLength exception if it passes sequences that violate the bounds constraint or +arrays of wrong size. + +Another example with arrays. The following IDL definition + +\verbatim +module SALOMEDS { + typedef sequence ListOfAttributes; + interface SObject { + ListOfAttributes GetAllAttributes(); + }; +}; +\endverbatim + +is equal to + +\verbatim +import SALOMEDS + +attributes=[] + +attributes = My_SObject.GetAllAttributes() + +length = len(attributes) + +print "Attributes number = ", length +print attributes +\endverbatim + +\subsection subsection3 Mapping for Objects and Operations + +A CORBA object reference is represented as a Python object at run-time. This object +provides all the operations that are available on the interface of the object. Although +this specification does not mandate the use of classes for stub objects, the following +discussion uses classes to indicate the interface. + +The nil object is represented by None. + +If an operation expects parameters of the IDL Object type, any Python object +representing an object reference might be passed as actual argument. + +If an operation expects a parameter of an abstract interface, either an object +implementing that interface, or a value supporting this interface may be passed as +actual argument. The semantics of abstract values then define whether the argument is +passed by value or by reference. + +Operations of an interface map to methods available on the object references. +Parameters with a parameter attribute of in or inout +are passed from left to right tothe method, skipping out parameters. +The return value of a method depends on the number of out parameters +and the return type. If the operation returns a value, this +value forms the first result value. All inout or out +parameters form consecutive result values. The method result depends then on the number +of result values: + +• If there is no result value, the method returns None. + +• If there is exactly one result value, it is returned as a single value. + +• If there is more than one result value, all of them are packed into a tuple, and this +tuple is returned. + +Assuming the IDL definition + +\verbatim +module SALOMEDS{ + interface StudyBuilder{ + boolean FindAttribute ( in SObject anObject, + out GenericAttribute anAttribute, + in string aTypeOfAttribute ); + }; +}; +\endverbatim + +a client could write + +\verbatim +from SALOMEDS import StudyBuilder; +my_StudyBuilder=... + + res,A=my_StudyBuilder.FindAttribute(Sobj, "AttributeSequenceOfReal") +\endverbatim + +In this example A corresponds to the return value anAttribute and +res to the boolean return value. + +If an interface defines an attribute name, for example, the attribute is mapped into an +operation _get_name. If the attribute is not readonly, there is an +additional operation _set_name. + +The IDL definition + +\verbatim +module SALOMEDS{ + interface Study{ + attribute string Name; + }; +}; +\endverbatim + +is equal to the following + +\verbatim +from SALOMEDS import Study +My_Study=... + Name=My_Study._get_name(); + Name=My_Study._set_name(); +\endverbatim + +\subsection subsection4 Narrowing Object References + +Python objects returned from CORBA operations or pseudo-operations (such as +string_to_object) might have a dynamic type, which is more specific than the +static type as defined in the operation signature. + +Since there is no efficient and reliable way of automatically creating the most specific +type, explicit narrowing is necessary. To narrow an object reference A to an interface +class AttributeSequenceOfReal, the client can use the following operation + +\verbatim +A = A._narrow(SALOMEDS.AttributeSequenceOfReal) +\endverbatim + +\subsection subsection5 Mapping for Exceptions + +An IDL exception is translated into a Python class derived from +CORBA.UserException. System exceptions are derived from CORBA.SystemException. +Both base classes are derived from CORBA.Exception. The parameters of the +exception are mapped in the same way as the fields of a struct definition. When +raising an exception, a new instance of the class is created; the constructor +expects the exception parameters. For example, the definition + +\verbatim +module SALOMEDS{ + interface StudyBuilder{ + exception LockProtection {}; + void CommitCommand() raises(LockProtection); + }; +}; +\endverbatim + +could be used caught as + +\verbatim +from SALOMEDS import StudyBuilder; +my_StudyBuilder=... +try: + my_StudyBuilder.CommitCommand(); +except StudyBuilder.LockProtection,value: + print "Error! Study is locked for modifications" +\endverbatim + + +\subsection subsection6 Mapping for Enumeration Types + +An enumeration is mapped into a number of constant objects in the name space where +the enumeration is defined. An application may only test for equivalence of two +enumeration values, and not assume that they behave like numbers. +For example, the definition + +\verbatim +module VISU { + interface PrsObject{ + + enum PrsObjType{ TCURVE, TTABLE, TMESH, TCONTAINER, + TSCALARMAP, TISOSURFACE, TDEFORMEDSHAPE, + TCUTPLANES, TVECTORS }; + }; +}; +\endverbatim + +introduces the objects + +\verbatim +from VISU import PrsObject +VISU.PrsObjType.TCURVE,VISU.PrsObjType.TTABLE,VISU.PrsObjType.TMESH,VISU.PrsObjType.TCONTAINER, +VISU.PrsObjType.TSCALARMAP,VISU.PrsObjType.TISOSURFACE,VISU.PrsObjType.TDEFORMEDSHAPE,VISU.PrsObjType.TCUTPLANES, +VISU.PrsObjType.TVECTORS +\endverbatim + +\subsection subsection7 Mapping for Structured Types + +An IDL struct definition is mapped into a Python class or type. For each field in the +struct, there is a corresponding attribute in the class with the same name as the field. +The constructor of the class expects the field values, from left to right. +For example, the IDL definition + +\verbatim +struct SDate { + short Second; + short Minute; + short Hour; + short Day; + short Month; + short Year; + }; +\endverbatim + +could be used in the Python statements + +\verbatim +Date=SDate(30, 12, 15, 26, 1, 79) +print Date.Second,Date.Minute,Date.Hour,Date.Day,Date.Month,Date.Year +\endverbatim +*/ +/*! \page page2 Mapping of SALOME IDL definitions to Python language. + + + - %SALOME STUDY module + - Mapping of %SALOMEDS functions + - Mapping of SALOMEDS_Attributes functions + - %SAlOME KERNEL module + - Mapping of %Med_Gen functions + - Mapping of %SALOME_Session functions + - Mapping of %SALOME_ModuleCatalog functions + - Mapping of %SALOME_Exception functions + - Mapping of %SALOME_Component functions + - %SALOME MED component + - Mapping of %Med functions + - %SALOME SUPERVISION module + - Mapping of %SUPERV functions + - %SALOME %VISU module + - Mapping of %VISU_Gen functions + +*/ + +/*! \defgroup Study SALOME STUDY module +*/ + +/*! + \file SALOMEDS.idl This file contains a set of interfaces used for creation, managment + and modification of the %Study +*/ + +#ifndef _SALOMEDS_IDL_ +#define _SALOMEDS_IDL_ + +#include "SALOME_Exception.idl" + +/*! \ingroup Study + This package contains the interfaces used for creation, managment + and modification of the %Study +*/ +module SALOMEDS +{ + const string SALOMEDS__doc__ = "This package contains the interfaces used for creation, \nmanagment and modification of the study."; +/*! \typedef URL + Name of the file in which the %Study is saved. + +*/ + typedef string URL; + +/*! Main identifier of an object in %SALOME application +*/ + typedef string ID; + +/*! While saving the data, IOR is transformed into persistent reference +*/ + typedef string PersistentReference; + +/*! IOR of the study in %SALOME application +*/ + typedef string SalomeReference; +/*! List of names of open studies in a %SALOME session +*/ + typedef sequence ListOfOpenStudies; +/*! List of file names +*/ + typedef sequence ListOfFileNames; +/*! List of modification dates of the study +*/ + typedef sequence ListOfDates ; +/*! An unbounded sequence of strings +*/ + typedef sequence ListOfStrings ; +/*! A byte stream which is used for binary data transfer between components +*/ + typedef sequence TMPFile; + + // Reference to other objects is treated with function AddReference + // and ReferencedObject + // All other type of attributes defined in AttributeType enum are + // treated with AddAdttribute and GetAttribute + // The difference is made because Reference attribute don't contain + // strings but reference to ID of other objects + + interface GenericAttribute; + interface Study; + interface StudyManager; + interface StudyBuilder; + interface SObject; + interface SComponent; + interface SComponentIterator; + interface ChildIterator; + interface Driver; + interface AttributeStudyProperties; + interface UseCaseIterator; + interface UseCaseBuilder; + interface Callback; +/*! List of attributes +*/ + typedef sequence ListOfAttributes; +/*! Exception indicating that this feature hasn't been implemented +*/ + exception NotImplemented {}; + + + //=========================================================================== + /*! \brief %Study Interface + + The purpose of the %Study is to manage the data produced by various components of %SALOME platform. + Most of the %Study operations are handled by the StudyManager and the StudyBuilder. + What is left in the %Study interface are elementary inquiries. + (Incidentally, we recall that a CORBA attribute is implemented as a pair of get + and set methods.) A %Study is explored by a set of tools, mainly iterators + , which are described further. Nevertheless, the %Study + interface allows the search of an object by name or by ID. + \note +
The Path of an object in %SALOME application is much alike a standard path of a file. + In general it's a string of names of directories divided by a slash '/'. +
The Context is the current directory of an object.

+*/ + + interface Study + { + exception StudyInvalidContext {}; + exception StudyInvalidComponent {}; +/*! Invalid directory of the %study exception +*/ + exception StudyInvalidDirectory {}; +/*! Exception pointing that this name of the study has already been used. +*/ + exception StudyNameAlreadyUsed {}; + exception StudyObjectAlreadyExists {}; +/*! Invalid name of the %study exception +*/ + exception StudyNameError {}; + exception StudyCommentError {}; +/*! \brief The name of the %Study + + This is equivalent to the methods setName() & getName() +*/ + attribute string Name; // equivalent to setName() & getName() +/*! \brief The ID of the %Study + + This is equivalent to the methods setID() & getID() +*/ + attribute short StudyId; +/*! Sequence containing %SObjects +*/ + typedef sequence ListOfSObject; +/*! + Gets a persistent reference to the %Study. +*/ + PersistentReference GetPersistentReference(); + const string GetPersistentReference__doc__ = "Gets a persistent reference to the study."; +/*! + Gets a transient reference to the %Study. +*/ + SalomeReference GetTransientReference(); + const string GetTransientReference__doc__ = "Gets a transient reference to the study."; + +/*! + Returns True if the %Study is empty +*/ + boolean IsEmpty(); + const string IsEmpty__doc__ = "Returns True if the study is empty."; +/*! + Allows to find a %SComponent by its name. + \param aComponentName It's a string value in the Comment Attribute of the Component, + which is looked for, defining the data type of this Component. + +
See also an example of this method usage in batchmode of %SALOME application. +*/ + SComponent FindComponent (in string aComponentName); + const string FindComponent__doc__ = "Allows to find a SComponent by its name."; +/*! + Allows to find a %SComponent by ID of the according %SObject +*/ + SComponent FindComponentID(in ID aComponentID); + const string FindComponentID__doc__ = "Allows to find a SComponent by ID of the according SObject."; +/*! + Allows to find a %SObject by the Name Attribute of this %SObject +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + SObject FindObject (in string anObjectName); + const string FindObject__doc__ = "Allows to find a SObject by the Name Attribute of this SObject."; +/*! + Allows to find a %SObject by its ID +*/ + SObject FindObjectID (in ID aObjectID); + const string FindObjectID__doc__ = "Allows to find a SObject by its ID"; +/*! + Allows to find a %SObject by IOR of the object belonging to this %SObject. +*/ + SObject FindObjectIOR (in ID aObjectIOR); + const string FindObjectIOR__doc__ = "Allows to find a SObject by IOR of the object belonging to this SObject."; +/*! + Returns a list of %SObjects belonging to this %Component. The Name Attribute + of these %SObjects should correspond to anObjectName. +*/ + ListOfSObject FindObjectByName(in string anObjectName, in string aComponentName); + const string FindObjectByName__doc__ = "Returns a list of SObjects belonging to this Component."; +/*! + Allows to find a %SObject by the path to it. +*/ + SObject FindObjectByPath(in string thePath); + const string FindObjectByPath__doc__ = "Allows to find a SObject by the path to it."; +/*! + Returns the path to the %SObject. +*/ + string GetObjectPath(in Object theObject); + const string GetObjectPath__doc__ = "Returns the path to the SObject"; + +/*! + Sets the context of the %Study. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void SetContext(in string thePath); + const string SetContext__doc__ = "Sets the context of the study"; +/*! + Gets the context of the %Study +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + string GetContext(); + const string GetContext__doc__ = "Gets the context of the study"; +/*! + Returns a list of names of objects corresponding to the context. + \note If the parameter theContext is empty, then the current context will be used. +*/ + ListOfStrings GetObjectNames(in string theContext); + const string GetObjectNames__doc__ = "Returns a list of names of objects corresponding to the context."; +/*! + Returns a list of names of directories and subdirectories corresponding to the context. + \note If the parameter theContext is empty, then the current context will be used. +*/ + ListOfStrings GetDirectoryNames(in string theContext); + const string GetDirectoryNames__doc__ = "Returns a list of names of directories and subdirectories corresponding to the context."; +/*! + Returns a list of names of Files corresponding to the context. + \note If the parameter theContext is empty, then the current context will be used. +*/ + ListOfStrings GetFileNames(in string theContext); + const string GetFileNames__doc__ = "Returns a list of names of Files corresponding to the context."; +/*! + Returns a list of names of Components corresponding to the context. + \note If the parameter theContext is empty, then the current context will be used. +*/ + ListOfStrings GetComponentNames(in string theContext); + const string GetComponentNames__doc__ = "Returns a list of names of Components corresponding to the context."; +/*! \brief Creation of a new iterator of child levels + + Creates a new iterator of child levels of the %SObject +*/ + ChildIterator NewChildIterator(in SObject aSO); + const string NewChildIterator__doc__ = "Creates a new iterator of child levels of the SObject"; +/*! \brief Creation of a new iterator of the %SComponent + + Creates a new iterator of the %SComponent. +*/ + SComponentIterator NewComponentIterator(); + const string NewComponentIterator__doc__ = "Creates a new iterator of the SComponent."; +/*! \brief Creation of a %StudyBuilder + + Creates a new %StudyBuilder to add or modify an object in the study. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + StudyBuilder NewBuilder() ; + const string NewBuilder__doc__ = "Creates a new StudyBuilder to add or modify an object in the study."; +/*! \brief Labels dependency + + Updates the map with IOR attribute. It's an inner method used for optimization. +*/ + void UpdateIORLabelMap(in string anIOR, in string anEntry); + const string UpdateIORLabelMap__doc__ = "Updates the map with IOR attribute. It's an inner method used for optimization."; + +/*! \brief Getting properties of the study + + Returns the attriubte, which contains the properties of this study. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + AttributeStudyProperties GetProperties(); + const string GetProperties__doc__ = "Returns the attriubte, which contains the properties of this study."; +/*! + Determines whether the %study has been saved +*/ + attribute boolean IsSaved; + const string IsSaved__doc__ = "Determines whether the study has been saved."; +/*! + Returns True if the %study has been modified and not saved. +*/ + boolean IsModified(); + const string IsModified__doc__ = "Returns True if the study has been modified and not saved."; +/*! + Determines the file where the %study has been saved +*/ + attribute string URL; + +/*! \brief List of %SObjects + + Returns the list of %SObjects which refers to %anObject. +*/ + ListOfSObject FindDependances(in SObject anObject); + const string FindDependances__doc__ = "Returns the list of SObjects which refers to anObject."; + +/*! \brief The date of the last saving of the study + + Returns the date of the last saving of study with format: "DD/MM/YYYY HH:MM" +*/ + string GetLastModificationDate(); + const string GetLastModificationDate__doc__ = "Returns the date of the last saving of study with format: DD/MM/YYYY HH:MM"; +/*! \brief The list of modification dates of the study + + Returns the list of modification dates (without creation date) with format "DD/MM/YYYY HH:MM". + Note : the first modification begins the list. +*/ + ListOfDates GetModificationsDate(); + const string GetModificationsDate__doc__ = "Returns the list of modification dates (without creation date) with format DD/MM/YYYY HH:MM."; +/*! \brief Object conversion. + + Converts an object into IOR. + \return IOR +*/ + string ConvertObjectToIOR(in Object theObject); + const string ConvertObjectToIOR__doc__ = "Converts an object into IOR."; +/*! \brief Object conversion. + + Converts IOR into an object. + \return An object +*/ + Object ConvertIORToObject(in string theIOR); + const string ConvertIORToObject__doc__ = "Converts IOR into an object."; +/*! + Gets a new %UseCaseBuilder. +*/ + UseCaseBuilder GetUseCaseBuilder(); + const string GetUseCaseBuilder__doc__ = "Gets a new UseCaseBuilder."; + +/*! + Closes the components in the study, removes itself from the %StudyManager. +*/ + void Close(); + const string Close__doc__ = "Closes the components in the study, removes itself from the StudyManager."; + +/*! + Enables(if isEnabled = True)/disables automatic addition of new %SObjects to the use case. +*/ + void EnableUseCaseAutoFilling(in boolean isEnabled); + const string EnableUseCaseAutoFilling__doc__ = "Enables(if isEnabled = True)/disables automatic addition of new SObjects to the use case."; + }; + const string Study__doc__ = "The Study interface contains a set of mrthods used for management of \nthe data produced by various components of SALOME platform."; + + //========================================================================== +/*! \brief %Study Builder Interface + + The purpose of the Builder is to add and/or remove objects and attributes. + A %StudyBuilder is linked to a %Study. A + command management is provided for the undo/redo functionalities. + \note +
The Tag of an item in %SALOME application is a symbolic description of + item's position in the tree-type structure of the browser. In general it has the following + form: 0:2:1:1 +*/ + //========================================================================== + + interface StudyBuilder + { +/*! \brief %LockProtection Exception + + This exception is raised while attempting to modify a locked %study. +*/ + exception LockProtection {}; +/*! \brief Creation of a new %SComponent. + + Creates a new %SComponent + \param ComponentDataType Data type of the %SComponent which will be created. + +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + SComponent NewComponent(in string ComponentDataType); + const string NewComponent__doc__ = "Creates a new SComponent."; +/*! \brief Definition of the instance to the %SComponent + + Defines the instance to the %SComponent. +*/ + void DefineComponentInstance (in SComponent aComponent,in Object ComponentIOR); + const string DefineComponentInstance__doc__ = "Defines the instance to the SComponent."; +/*! \brief Deletion of the %SComponent + + Removes the %SComponent. +*/ + void RemoveComponent(in SComponent aComponent); + const string RemoveComponent__doc__ = "Removes the SComponent."; + +/*! \brief Creation of a new %SObject + + Creates a new %SObject. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + SObject NewObject (in SObject theFatherObject); + const string NewObject__doc__ = "Creates a new SObject."; +/*! \brief Creation of a new %SObject with a definite %tag + + Creates a new %SObject with a definite %tag. +*/ + SObject NewObjectToTag (in SObject theFatherObject, in long atag); + const string NewObjectToTag__doc__ = "Creates a new SObject with a definite tag."; +/*! \brief Deletion of the %SObject + + Removes a %SObject from the %StudyBuilder. +*/ + void RemoveObject (in SObject anObject); + const string RemoveObject__doc__ = "Removes a SObject from the StudyBuilder."; +/*! \brief Deletion of the %SObject with all his child objects. + + Removes the %SObject with all his child objects. +*/ + void RemoveObjectWithChildren(in SObject anObject); + const string RemoveObjectWithChildren__doc__ = "Removes the SObject with all his child objects."; + +/*! + Loads a %SComponent. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void LoadWith (in SComponent sco, in Driver Engine) raises (SALOME::SALOME_Exception); + const string LoadWith__doc__ = "Loads a SComponent."; +/*! + Loads a %SObject. +*/ + void Load (in SObject sco); + const string Load__doc__ = "Loads a SObject."; + +/*! \brief Looking for or creating an attribute assigned to the %SObject + + Allows to find or create an attribute of a specific type which is assigned to the object. + \param anObject The %SObject corresponding to the attribute which is looked for. + \param aTypeOfAttribute Type of the attribute. + +
See also an example of this method usage in batchmode of %SALOME application. +*/ + + GenericAttribute FindOrCreateAttribute(in SObject anObject, + in string aTypeOfAttribute); + const string FindOrCreateAttribute__doc__ = "Allows to find or create an attribute of a specific type which is assigned to the object."; + +/*! \brief Looking for an attribute assigned to %SObject + + Allows to find an attribute of a specific type which is assigned to the object. + \param anObject The %SObject corresponding to the attribute which is looked for. + \param aTypeOfAttribute Type of the attribute. + \param anAttribute Where the attribute is placed if it's found. + \return True if it finds an attribute. + */ + + boolean FindAttribute(in SObject anObject, + out GenericAttribute anAttribute, + in string aTypeOfAttribute); + const string FindAttribute__doc__ = "Allows to find an attribute of a specific type which is assigned to the object."; +/*! \brief Deleting the attribute assigned to the %SObject + + Removes the attribute of a specific type which is assigned to the object. + \param anObject The %SObject corresponding to the attribute. + \param aTypeOfAttribute Type of the attribute. + +
See also an example of this method usage in batchmode of %SALOME application. +*/ + void RemoveAttribute(in SObject anObject, + in string aTypeOfAttribute); + const string RemoveAttribute__doc__ = "Removes the attribute of a specific type which is assigned to the object."; +/*! \brief Addition of a reference + + Adds a reference between %anObject and %theReferencedObject. +*/ + + void Addreference(in SObject anObject, + in SObject theReferencedObject) ; + const string Addreference__doc__ = "Adds a reference between anObject and theReferencedObject."; +/*! + Adds a directory in the %Study. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void AddDirectory(in string theName); + const string AddDirectory__doc__ = "Adds a directory in the Study."; + +/*! \brief Identification of the %SObject's substructure. + + Identification of the %SObject's substructure by GUID. + It has the following format "00000000-0000-0000-0000-000000000000" +*/ + + void SetGUID(in SObject anObject, in string theGUID); + const string SetGUID__doc__ = "Identification of the %SObject's substructure by GUID. \nIt has the following format: 00000000-0000-0000-0000-000000000000."; +/*! + + Returns True if the %SObject has GUID. +*/ + boolean IsGUID(in SObject anObject, in string theGUID); + const string IsGUID__doc__ = "Returns True if the SObject has GUID."; + +/*! \brief Creation of a new command + + Creates a new command which can contain several different actions. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void NewCommand(); // command management + const string NewCommand__doc__ = "Creates a new command which can contain several different actions."; +/*! \brief Execution of the command + + Commits all actions declared within this command. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void CommitCommand() raises(LockProtection); // command management + const string CommitCommand__doc__ = "Commits all actions declared within this command."; +/*! + Returns True if at this moment there is a command under execution. +*/ + boolean HasOpenCommand(); + const string HasOpenCommand__doc__ = "Returns True if at this moment there is a command under execution."; +/*! \brief Cancelation of the command + + Cancels all actions declared within the command. +
See also an example of this method usage in batchmode of %SALOME application. +*/ + void AbortCommand(); // command management + const string AbortCommand__doc__ = "Cancels all actions declared within the command."; +/*! \brief Undolimit + + The number of actions which can be undone +*/ + attribute long UndoLimit; +/*! \brief Undo method + + Cancels all actions of the last command. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void Undo() raises (LockProtection); + const string Undo__doc__ = "Cancels all actions of the last command."; +/*! \brief Redo method + + Redoes all actions of the last command. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void Redo() raises (LockProtection); + const string Redo__doc__ = "Redoes all actions of the last command."; +/*! + Returns True if at this moment there are any actions which can be canceled. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + boolean GetAvailableUndos(); + const string GetAvailableUndos__doc__ = "Returns True if at this moment there are any actions which can be canceled."; +/*! + Returns True if at this moment there are any actions which can be redone. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + boolean GetAvailableRedos(); + const string GetAvailableRedos__doc__ = "Returns True if at this moment there are any actions which can be redone."; +/*! + Sets the callback for addition of the given %SObject. Returns the previous callback. +*/ + Callback SetOnAddSObject(in Callback theCallback); + const string SetOnAddSObject__doc__ = "Sets the callback for addition of the given SObject."; +/*! + Sets the callback for removal of the given %SObject. Returns the previous callback. +*/ + Callback SetOnRemoveSObject(in Callback theCallback); + const string SetOnRemoveSObject__doc__ = " Sets the callback for removal of the given SObject."; + + }; + const string StudyBuilder__doc__ = "The Study Builder Interface contains a set of methods used for adding and/or removing objects and attributes."; + + //========================================================================== +/*! \brief %Study Manager interface + + The purpose of the Manager is to manipulate the %Studies. You will find in this + interface the methods to create, open, + close, and save a %Study. Since a %SALOME session is multi-document, you will + also find the methods allowing to navigate + through the collection of studies present in a session. +*/ + //========================================================================== + + interface StudyManager + { +/*! + Determines whether the server has already been loaded or not. +*/ + void ping(); + const string ping__doc__ = "Determines whether the server has already been loaded or not."; + +/*! \brief Creation of a new %Study + + Creates a new %Study with a definite name. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + Study NewStudy(in string study_name); + const string NewStudy__doc__ = "Creates a new study with a definite name."; + +/*! \brief Open a study + + Reads and activates the structure of the study %Objects. + \warning This method doesn't activate the corba objects. Only a component can do it. +
See also an example of this method usage in batchmode of %SALOME application. +*/ + Study Open (in URL aStudyUrl) raises (SALOME::SALOME_Exception); + const string Open__doc__ = "Reads and activates the structure of the study objects."; + +/*! \brief Closing the study + + Closes the study. +*/ + void Close(in Study aStudy); + const string Close__doc__ = "Closes the study."; +/*! \brief Saving the study + + Saves the study. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void Save(in Study aStudy, in boolean theMultiFile); + const string Save__doc__ = "Saves the study."; +/*! \brief Saving the study in a file + + Saves the study in a specified file. +
See also an example of this method usage in batchmode of %SALOME application. +*/ + void SaveAs(in URL aUrl, // if the file already exists + in Study aStudy, + in boolean theMultiFile); // overwrite (as option) + const string SaveAs__doc__ = "Saves the study in a specified file."; +/*! \brief List of open studies. + + Returns the list of open studies in the current session. +*/ + ListOfOpenStudies GetOpenStudies(); + const string GetOpenStudies__doc__ = "Returns the list of open studies in the current session."; + +/*! \brief Getting a particular %Study picked by name + + Activates a particular %Study + amongst the session collection picking it by name. +*/ + Study GetStudyByName (in string aStudyName); + const string GetStudyByName__doc__ = "Activates a particular study amongst the session collection picking it by name."; + +/*! \brief Getting a particular %Study picked by ID + + Activates a particular %Study + amongst the session collection picking it by ID. +*/ + Study GetStudyByID (in short aStudyID); + const string GetStudyByID__doc__ = "Activates a particular study amongst the session collection picking it by ID."; + + // copy/paste methods + +/*! + Returns True, if the given %SObject can be copied to the clipboard. +*/ + boolean CanCopy(in SObject theObject); + const string CanCopy__doc__ = "Returns True, if the given SObject can be copied to the clipboard."; +/*! + Returns True, if the given %SObject is copied to the clipboard. +*/ + boolean Copy(in SObject theObject); + const string Copy__doc__ = "Returns True, if the given SObject is copied to the clipboard."; +/*! + Returns True, if the object from the clipboard can be pasted to the given %SObject. +*/ + boolean CanPaste(in SObject theObject); + const string CanPaste__doc__ = "Returns True, if the object from the clipboard can be pasted to the given SObject."; +/*! + Returns the %SObject in which the object from the clipboard was pasted to. +*/ + SObject Paste(in SObject theObject) raises (SALOMEDS::StudyBuilder::LockProtection); + const string Paste__doc__ = "Returns the SObject in which the object from the clipboard was pasted to."; + }; + const string StudyManager__doc__ = "The purpose of the Manager is to manipulate the studies. \nThe StudyManager interface contains a set of methods to create, open,close and save a study."; + + + //========================================================================== +/*! \brief %SObject interface + + The objects in the %study are built by the %StudyBuilder. The %SObject interface + provides methods for elementary inquiries, like getting an object %ID or its attribuites. + \note +
Tag of an item in %SALOME application is an integer value uniquely defining an item + in the tree-type data structure. +
ID of an item is a description of item's position in the tree-type data structure. + ID is a list of tags and it has the following form: 0:2:1:1. +*/ + //========================================================================== + + interface SObject + { +/*! Name of the %SObject +*/ + attribute string Name; // equivalent to setName() & getName() +/*! \brief Getting an object %ID + + Returns ID of the %SObject. +*/ + ID GetID(); + const string GetID__doc__ = "Returns ID of the SObject."; +/*! \brief Acquisition of the father %Component of the %SObject + + Returns the father %Component of the %SObject. +*/ + SComponent GetFatherComponent(); + const string GetFatherComponent__doc__ = "Returns the father Component of the SObject."; +/*! \brief Acquisition of the father %SObject of the %SObject + + Returns the father %SObject of the given %SObject. +*/ + SObject GetFather(); + const string GetFather__doc__ = "Returns the father SObject of the given SObject."; +/*! \brief %Tag of %SObject + + Returns the %tag of the %SObject. +*/ + short Tag(); + const string Tag__doc__ = "Returns the tag of the SObject."; +/*! \brief Looking for subobjects of an object. + + Returns True if it finds a subobject of the %SObject with a definite tag. +*/ + + boolean FindSubObject (in long atag, out SObject obj); + const string FindSubObject__doc__ = "Returns True if it finds a subobject of the SObject with a definite tag."; +/*! \brief Looking for attributes of the %SObject + + Returns True if it finds an attribute of a definite type of the %SObject. +
See also an example of this method usage in batchmode of %SALOME application. +*/ + boolean FindAttribute(out GenericAttribute anAttribute, + in string aTypeOfAttribute); + const string FindAttribute__doc__ = "Returns True if it finds an attribute of a definite type of the given SObject."; +/*! + Returns the object which this %SObject refers to. It also returns True if it finds + this object. +*/ + boolean ReferencedObject(out SObject obj); // A REVOIR + const string ReferencedObject__doc__ = "Returns the object which this given SObject refers to. \nIt also returns True if it finds this object."; +/*! \brief Getting all attributes of the %SObject + + Returns the list of all attributes of the %SObject. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + ListOfAttributes GetAllAttributes(); + const string GetAllAttributes__doc__ = "Returns the list of all attributes of the given SObject."; +/*! \brief Returning the study + + Returns the study containing the given %SObject. +*/ + Study GetStudy(); + const string GetStudy__doc__ = "Returns the study containing the given SObject."; + }; + const string SObject__doc__ = "The objects in the study are built by the StudyBuilder. \nThe SObject interface provides methods for elementary inquiries, \nlike getting an object ID or its attribuites."; + + + //========================================================================== +/*! \brief %Generic attribute interface + + %Generic attribute is a base interface for all attributes which inherit + its methods. +*/ + //========================================================================== + interface GenericAttribute + { +/*! \brief Exception locking all changes + + This exception locks all modifications in attributes. +*/ + exception LockProtection {}; +/*! \brief Method CheckLocked + + Checks whether the %Study is protected for modifications. + \note
This exception is raised only outside the transaction. +*/ + void CheckLocked() raises (LockProtection); + const string CheckLocked__doc__ = "Checks whether the study is protected for modifications."; + }; + const string GenericAttribute__doc__ = "GenericAttribute is a base interface for all attributes which inherit its methods."; + + + + //========================================================================== +/*! \brief %SComponent interface + + The %SComponent interface is a specialization of the %SObject interface. + It inherits the most of its methods from the %SObject interface. +*/ + //========================================================================== + interface SComponent : SObject + { +/*! \brief Data type of the %SComponent + + Returns the data type of the %SComponent. +*/ + string ComponentDataType(); + const string ComponentDataType__doc__ = "Returns the data type of the SComponent."; +/*! + Returns IOR of the according component. +*/ + boolean ComponentIOR (out ID theID); //returns True if there is an instance + //In this case ID identifies this one + const string ComponentIOR__doc__ = "Returns IOR of the according component."; + }; + const string SComponent__doc__ = "The SComponent interface is a specialization of the SObject interface. \nIt inherits the most of its methods from the SObject interface."; + + + //========================================================================== +/*! \brief %SComponentIterator interface + + This interface contains the methods allowing to iterate over all components in the list. + The search is started from the first %SComponent in the list. +*/ + //========================================================================== + interface SComponentIterator + { +/*! \brief Initialization of the Iterator + +Activates the %SComponentIterator. +*/ + void Init(); + const string Init__doc__ = "Activates the SComponentIterator."; +/*! \brief Method More + + Returns True if there is one more %SComponent in the list. +*/ + boolean More(); + const string More__doc__ = "Returns True if there is one more SComponent in the list."; +/*! \brief Moving the iterator to the next %SComponent + +Moves the iterator to the next %SComponent in the list. +*/ + void Next(); + const string Next__doc__ = "Moves the iterator to the next SComponent in the list."; +/*! + Returns the %SComponent corresponding to the current %SComponent found by the iterator. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + SComponent Value(); + const string Value__doc__ = "Returns the SComponent corresponding to the current SComponent found by the iterator."; + }; + const string SComponentIterator__doc__ = "This interface contains the methods allowing to iterate over all components in the list. \nThe search is started from the first SComponent in the list."; + + //========================================================================== +/*! \brief %ChildIterator interface + + This interface contains methods which allow to iterate over all child + levels. +*/ + //========================================================================== + interface ChildIterator + { +/*! \brief Initialization of the Iterator. + +Activates the %ChildIterator. +*/ + void Init(); + const string Init__doc__ = "Activates the ChildIterator."; +/*! \brief Initialization of the Iterator for all child levels. + +Activates the %ChildIterator (if True) for all child levels. +*/ + void InitEx(in boolean allLevels); + const string InitEx__doc__ = "Activates the ChildIterator (if True) for all child levels."; +/*! \brief Method More + + Returns True if the %ChildIterator finds one more child level. +*/ + boolean More(); + const string More__doc__ = "Returns True if the ChildIterator finds one more child level."; +/*! + Passes the iterator to the next level. +*/ + void Next(); + const string Next__doc__ = "Passes the iterator to the next level."; +/*! + Returns the %SObject corresponding to the current object found by the iterator. +*/ + SObject Value(); + const string Value__doc__ = "Returns the SObject corresponding to the current object found by the iterator."; + }; + const string ChildIterator__doc__ = "This interface contains methods which allow to iterate over all child levels."; + + //========================================================================== + //========================================================================== +/*! \brief Interface of the %UseCaseIterator. + + This interface contains a set of methods used for iteration over the objects in the use case. +*/ + interface UseCaseIterator + { +/*! \brief Initialization of the Iterator. + +Activates the %UseCaseIterator. If allLevels is True the Iterator is activated for all subobjects. +*/ + void Init(in boolean allLevels); + const string Init__doc__ = "Activates the UseCaseIterator. \nIf the value of the parameter allLevels is True the Iterator is activated for all subobjects."; +/*! \brief Method More + + Returns True if the %UseCaseIterator finds one more object. +*/ + boolean More(); + const string More__doc__ = "Returns True if the UseCaseIterator finds one more object."; +/*! + Passes the iterator to the next object. +*/ + void Next(); + const string Next__doc__ = "Passes the iterator to the next object."; +/*! + Returns the %SObject corresponding to the current object found by the Iterator. +*/ + SObject Value(); + const string Value__doc__ = "Returns the SObject corresponding to the current object found by the Iterator."; + }; + const string UseCaseIterator__doc__ = "This interface contains a set of methods used for \niteration over the objects in the use case."; + + //========================================================================== + //========================================================================== +/*! \brief Interface of the %UseCaseBuilder + + Use case in the study represents a user-managed subtree, containing all or some of the objects which exist in the study. + The %UseCaseBuilder interface contains a set of methods used for management of the use case in the study. +*/ + interface UseCaseBuilder + { +/*! + Adds to the use case an object theObject as a child of the current object of the use case. +*/ + boolean Append(in SObject theObject); + const string Append__doc__ = "Adds to the use case an object as a child of the current object of the use case."; +/*! + Removes an object theObject from the use case. +*/ + boolean Remove(in SObject theObject); + const string Remove__doc__ = "Removes an object from the use case."; +/*! + Adds a child object theObject to the given father theFather object in the use case. +*/ + boolean AppendTo(in SObject theFather, in SObject theObject); + const string AppendTo__doc__ = "Adds a child object to the given father object in the use case."; +/*! + Inserts in the use case the object theFirst before the object theNext. +*/ + boolean InsertBefore(in SObject theFirst, in SObject theNext); + const string InsertBefore__doc__ = "Inserts in the use case an object before another object."; +/*! + Sets the current object of the use case. +*/ + boolean SetCurrentObject(in SObject theObject); + const string SetCurrentObject__doc__ = "Sets the current object of the use case."; +/*! + Makes the root object to be the current object of the use case. +*/ + boolean SetRootCurrent(); + const string SetRootCurrent__doc__ = "Makes the root object to be the current object of the use case."; +/*! + Returns True if the given object theObject of the use case has child objects. +*/ + boolean HasChildren(in SObject theObject); + const string HasChildren__doc__ = "Returns True if the given object of the use case has child objects."; +/*! + Sets the name of the use case. +*/ + boolean SetName(in string theName); + const string SetName__doc__ = "Sets the name of the use case."; +/*! + Gets the name of the use case. +*/ + string GetName(); + const string GetName__doc__ = "Gets the name of the use case."; +/*! + Returns True if the given object theObject represents a use case. +*/ + boolean IsUseCase(in SObject theObject); + const string IsUseCase__doc__ = "Returns True if the given object represents a use case."; +/*! + Gets the current object of the use case. +*/ + SObject GetCurrentObject(); + const string GetCurrentObject__doc__ = "Gets the current object of the use case."; +/*! + Creates a new use case in the use case browser. +*/ + SObject AddUseCase(in string theName); + const string AddUseCase__doc__ = "Creates a new use case in the use case browser."; +/*! + Returns the %UseCaseIterator for the given object theObject in the use case. +*/ + UseCaseIterator GetUseCaseIterator(in SObject theObject); + const string GetUseCaseIterator__doc__ = "Returns the UseCaseIterator for the given object in the use case."; + }; + const string UseCaseBuilder__doc__ = "The UseCaseBuilder interface contains a set of methods \nused for management of the use case in the study."; + //========================================================================== + //========================================================================== +/*! \brief The callback interface + + The %StudyBuilder can be created with the method NewBuilder. While invocation of this method a new object of the class Callback is created + and this object is assigned to the newly created Builder as callback which should be called when adding and removing of the ojects. +*/ + interface Callback + { +/*! + Invokes the corresponding method Append of the %UseCaseBuilder. +*/ + void OnAddSObject(in SObject theObject); + const string OnAddSObject__doc__ = "Invokes the corresponding method Append of the UseCaseBuilder."; +/*! + Invokes the corresponding method Remove of the %UseCaseBuilder. +*/ + void OnRemoveSObject(in SObject theObject); + const string OnRemoveSObject__doc__ = "Invokes the corresponding method Remove of the UseCaseBuilder."; + }; + const string Callback__doc__ = "The callback interface contains a set of methods which are called \nwhen adding or removing of the objects by the StudyBuilder."; + + //========================================================================== +/*! \brief %Driver interface + + This interface contains a set of methods used for the management + of the object produced in the %study by a component. +*/ + //========================================================================== + interface Driver + { + + /*! \brief Saving the data. + + This method is called by the StudyManager when saving a study. + \param theComponent %SComponent corresponding to this Component + \return A byte stream TMPFile that contains all saved data + +
See also an example of this method usage in batchmode of %SALOME application. + + */ + + + TMPFile Save(in SComponent theComponent, in string theURL, in boolean isMultiFile); + const string Save__doc__ = "This method is called by the StudyManager when saving a study."; + + + /*! \brief Loading the data. + + This method is called by the StudyManager when opening a study. + \param theComponent %SComponent corresponding to this Component + \param theStream The file which contains all data saved by the component on Save method + */ + + boolean Load(in SComponent theComponent, in TMPFile theStream, in string theURL, in boolean isMultiFile); + const string Load__doc__ = "This method is called by the StudyManager when opening a study."; + + + /*! \brief Closing of the study + + This method Close is called by the StudyManager when closing a study. + + */ + + void Close (in SComponent aSComponent); + const string Close__doc__ = "This method Close is called by the StudyManager when closing a study."; + //void Close ( in string aIORSComponent); + + /*! \brief The type of the data + + Returns the type of data produced by the Component in the study. + */ + + string ComponentDataType(); + const string ComponentDataType__doc__ = "Returns the type of data produced by the Component in the study."; + + // Driver Transient -> persistent called for each object in study +/*! + Transforms IOR into PersistentID of the object. It is called for each + object in the %study. +*/ + string IORToLocalPersistentID (in SObject theSObject, in string IORString, in boolean isMultiFile); + const string IORToLocalPersistentID__doc__ = "Transforms IOR into PersistentID of the object."; +/*! + Transforms PersistentID into IOR of the object. It is called for each + object in the %study. +*/ + string LocalPersistentIDToIOR (in SObject theSObject, in string aLocalPersistentID, in boolean isMultiFile) + raises (SALOME::SALOME_Exception); + const string LocalPersistentIDToIOR__doc__ = "Transforms PersistentID into IOR of the object."; + + // Publishing in the study +/*! \brief Publishing in the study + + Returns True if the given %Component can publish the %object in the %study. +*/ + boolean CanPublishInStudy(in Object theIOR) raises (SALOME::SALOME_Exception); + const string CanPublishInStudy__doc__ = "Returns True if the given Component can publish the object in the study."; +/*! \brief Publishing in the study + + Publishes the given object in the %study, using the algorithm of this component. + \param theStudy The %study in which the object is published + \param theSObject If this parameter is null the object is published for the first time. Otherwise + this parameter should contain a reference to the object published earlier + \param theObject The object which is published + \param theName The name of the published object. If this parameter is empty, the name is generated + automatically by the component. +*/ + SObject PublishInStudy(in Study theStudy, in SObject theSObject, in Object theObject, in string theName); + const string PublishInStudy__doc__ = "Publishes the given object in the study, using the algorithm of this component."; + + // copy/paste methods + +/*! + Returns True, if the given %SObject can be copied to the clipboard. +*/ + boolean CanCopy(in SObject theObject); + const string CanCopy__doc__ = "Returns True, if the given SObject can be copied to the clipboard."; +/*! + Returns the object %ID and the %TMPFile of the object from the given %SObject. +*/ + TMPFile CopyFrom(in SObject theObject, out long theObjectID); + const string CopyFrom__doc__ = "Returns the object ID and the TMPFile of the object from the given SObject."; +/*! + Returns True, if the component can paste the object with given %ID of the component with name theComponentName. +*/ + boolean CanPaste(in string theComponentName, in long theObjectID); + const string CanPaste__doc__ = "Returns True, if the component can paste the object with given ID of the component with name theComponentName."; +/*! + Returns the %SObject of the pasted object. +*/ + SObject PasteInto(in TMPFile theStream, in long theObjectID, in SObject theObject); + const string PasteInto__doc__ = "Returns the SObject of the pasted object."; + + }; + const string Driver__doc__ = "This interface contains a set of methods used for the management \nof the object produced in the study by a component."; +}; + +#endif diff --git a/idl/SALOMEDS_Attributes.idl b/idl/SALOMEDS_Attributes.idl new file mode 100644 index 000000000..c87838610 --- /dev/null +++ b/idl/SALOMEDS_Attributes.idl @@ -0,0 +1,1356 @@ +//===================================================== +// File : SALOMEDS.idl +// Created : Thu Jul 4 19:25:39 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Copyright : Open CASCADE 2002 +// $Header$ +//===================================================== +//The following attributes can be assigned to SObject +//===================================================== +/*! \file SALOMEDS_Attributes.idl This file contains a set of interfaces + for the attributes which can be assigned to %SObject +*/ +#ifndef _SALOMEDS_AttributesIDL_ +#define _SALOMEDS_AttributesIDL_ + +#include "SALOMEDS.idl" + +module SALOMEDS +{ +/*! Sequence of double values +*/ + typedef sequence DoubleSeq; +/*! Sequence of long values +*/ + typedef sequence LongSeq; +/*! Sequence of string values +*/ + typedef sequence StringSeq; +/*! \struct Color + This structure stores a set of elements defining the color based on RGB. +*/ + struct Color { +/*! Red color +*/ + double R; +/*! Green color +*/ + double G; +/*! Blue color +*/ + double B; + }; + //========================================================================== +/*! \brief Attribute allowing to store a real value + + Attribute allowing to store a real value +*/ + //========================================================================== + interface AttributeReal : GenericAttribute + { +/*! + Returns the value of this attribute. +
See also an example of this method usage in batchmode of %SALOME application. +*/ + double Value(); + const string Value__doc__ = "Returns the value of this attribute."; +/*! + Sets the value of this attribute. +
See also an example of this method usage in batchmode of %SALOME application. +*/ + void SetValue(in double value); + const string SetValue__doc__ = "Sets the value of this attribute."; + }; + const string AttributeReal__doc__ = "Attribute allowing to store a real value."; + //========================================================================== +/*! \brief Attribute allowing to store an integer value + + Attribute allowing to store an integer value +*/ + //========================================================================== + interface AttributeInteger : GenericAttribute + { +/*! + Returns the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. +*/ + long Value(); + const string Value__doc__ = "Returns the value of this attribute."; +/*! + Sets the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. +*/ + void SetValue(in long value); + const string SetValue__doc__ = "Sets the value of this attribute."; + }; + const string AttributeInteger__doc__ = "Attribute allowing to store an integer value."; + //========================================================================== +/*! \brief Attribute - sequence of real values + + Attribute - sequence of real values, indexing from 1 (like in CASCADE). +*/ + //========================================================================== + interface AttributeSequenceOfReal : GenericAttribute + { +/*! + Initialization of the attribute with initial data. + \param other Initially assigned sequence of real numbers. +*/ + void Assign (in DoubleSeq other); + const string Assign__doc__ = "Initialization of the attribute with initial data."; +/*! + Returns the sequence of real numbers stored in the attribute. +*/ + DoubleSeq CorbaSequence(); + const string CorbaSequence__doc__ = "Returns the sequence of real numbers stored in the attribute."; +/*! + Adds to the end of the sequence a real number. + \param value A real number added to the sequence. + +
See also an example of this method usage in batchmode of %SALOME application. +*/ + void Add (in double value); + const string Add__doc__ = "Adds to the end of the sequence a real number."; +/*! + Removes a real number with a definite index + from the sequence of real numbers stored in the Attribute. +*/ + void Remove(in long index); + const string Remove__doc__ = "Removes a real number with a definite index from the sequence of real numbers stored in the attribute."; +/*! + Substitutes a real number with a definite index for another real number. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void ChangeValue(in long index, in double value); + const string ChangeValue__doc__ = "Substitutes a real number with a definite index for another real number."; +/*! + Returns a real number with a definite index + in the sequence of real numbers stored in the Attribute. +
See also an example of this method usage in batchmode of %SALOME application. +*/ + double Value(in short index); + const string Value__doc__ = "Returns a real number with a definite index in the \nsequence of real numbers stored in the attribute."; +/*! + Returns the length of the sequence of real numbers stored in the Attribute. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + long Length(); + const string Length__doc__ = "Returns the length of the sequence of real numbers stored in the attribute."; + }; + const string AttributeSequenceOfReal__doc__ = "Attribute - sequence of real values."; + //========================================================================== +/*! \brief Attribute - sequence of integer + + Attribute - sequence of integer, indexing from 1 (like in CASCADE) +*/ + //========================================================================== + interface AttributeSequenceOfInteger : GenericAttribute + { +/*! + Initialization of the attribute with initial data. + \param other Initially assigned sequence of integer numbers. +*/ + void Assign (in LongSeq other); + const string Assign__doc__ = "Initialization of the attribute with initial data."; +/*! + Returns the sequence of integer numbers stored in the Attribute. +*/ + LongSeq CorbaSequence(); + const string CorbaSequence__doc__ = "Returns the sequence of integer numbers stored in the attribute."; +/*! + Adds to the end of the sequence an integer number. + \param value An integer number added to the sequence. + +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void Add (in long value); + const string Add__doc__ = "Adds to the end of the sequence an integer number."; +/*! + Removes an integer number with a definite index + from the sequence of integer numbers stored in the Attribute. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void Remove(in long index); + const string Remove__doc__ = "Removes an integer number with a definite index from the sequence of integer numbers stored in the attribute."; +/*! + Substitutes an integer number with a definite index for another integer number. +*/ + void ChangeValue(in long index, in long value); + const string ChangeValue__doc__ = "Substitutes an integer number with a definite index for another integer number."; +/*! + Returns an integer number with a definite index + in the sequence of integer numbers stored in the Attribute. +
See also an example of this method usage in batchmode of %SALOME application. +*/ + long Value(in short index); + const string Value__doc__ = "Returns an integer number with a definite index in the \nsequence of integer numbers stored in the attribute."; +/*! + Returns the length of the sequence of integer numbers stored in the Attribute. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + long Length(); + const string Length__doc__ = "Returns the length of the sequence of integer numbers stored in the attribute."; + }; + + //========================================================================== +/*! \brief Name attribute + + This attribute stores a string value, which corresponds to the name of the %SObject + or to the name of corresponding object. +*/ + //========================================================================== + + interface AttributeName : GenericAttribute + { +/*! + Returns the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. +*/ + string Value(); + const string Value__doc__ = "Returns the value of this attribute."; +/*! + Sets the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. +*/ + void SetValue(in string value); + const string SetValue__doc__ = "Sets the value of this attribute."; + }; + const string AttributeName__doc__ = "This attribute stores a string value, which corresponds to the name of the SObject \nor to the name of corresponding object."; + + //========================================================================== +/*! \brief Comment attribute + + This attribute stores a string value containing supplementary information about + the %SObject. In particular it contains the data type of the %SComponent. +*/ + //========================================================================== + interface AttributeComment : GenericAttribute + { +/*! + Returns the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. +*/ + string Value(); + const string Value__doc__ = "Returns the value of this attribute."; +/*! + Sets the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. +*/ + void SetValue(in string value); + const string SetValue__doc__ = "Sets the value of this attribute."; + }; + const string AttributeComment__doc__ = "This attribute stores a string value containing supplementary information about \nthe SObject. In particular it contains the data type of the SComponent."; + //========================================================================== +/*! \brief IOR attribute + + This attribute stores a string value identifying a runtime object.In particular + it contains CORBA Interoperable Object Reference. +*/ + //========================================================================== + interface AttributeIOR : GenericAttribute + { +/*! + Returns the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. +*/ + string Value(); + const string Value__doc__ = "Returns the value of this attribute."; +/*! + Sets the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. +*/ + void SetValue(in string value); + const string SetValue__doc__ = "Sets the value of this attribute."; + }; + const string AttributeIOR__doc__ = "This attribute stores a string value identifying a runtime object.\nIn particular it contains CORBA Interoperable Object Reference."; + + //========================================================================== +/*! \brief Persistent reference attribute + + This attribute stores a persistent identifier of the object. +*/ + //========================================================================== + interface AttributePersistentRef : GenericAttribute + { +/*! + Returns the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. +*/ + string Value(); + const string Value__doc__ = "Returns the value of this attribute."; +/*! + Sets the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. +*/ + void SetValue(in string value); + const string SetValue__doc__ = "Sets the value of this attribute."; + }; + const string AttributePersistentRef__doc__ = "This attribute stores a persistent identifier of the object."; + + //========================================================================== + //Below the list of presentation attributes for display study tree in browser + //========================================================================== + + + //========================================================================== +/*! \brief Drawable flag Attribute. + + This is a presentation attribute necessary for display of the study tree in the browser. + The item associated to SObject is created/displayed if TRUE. +*/ + //========================================================================== + interface AttributeDrawable : GenericAttribute + { +/*! + Returns TRUE if the item is drawable (as it is by default) and FALSE if it isn't. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + boolean IsDrawable(); + const string IsDrawable__doc__ = "Returns TRUE if the item is drawable (as it is by default) and FALSE if it isn't."; +/*! +Sets the items to be drawable if value is TRUE (the default) or not to be selectable if valueis FALSE. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void SetDrawable(in boolean value); + const string SetDrawable__doc__ = "Sets the items to be drawable if value is TRUE (the default) or not to be selectable if value is FALSE."; + }; + const string AttributeDrawable__doc__ = "This is a presentation attribute necessary for display of the study tree in the browser. \nThe item associated to SObject is created/displayed if TRUE."; + + //========================================================================== +/*! \brief Selectable flag Attribute. + + This is a presentation attribute necessary for display of the study tree in the browser. + The item is selectable by %SALOME selection mechanism if TRUE. +*/ + //========================================================================== + interface AttributeSelectable : GenericAttribute + { +/*! + Returns TRUE if the item is selectable (as it is by default) and FALSE if it isn't. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + boolean IsSelectable(); + const string IsSelectable__doc__ = "Returns TRUE if the item is selectable (as it is by default) and FALSE if it isn't."; +/*! +Sets the items to be selectable if value is TRUE (the default) or not to be selectable if valueis FALSE. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void SetSelectable(in boolean value); + const string SetSelectable__doc__ = "Sets the items to be selectable if value is TRUE (the default) or not to be selectable if value is FALSE."; + }; + const string AttributeSelectable__doc__ = "This is a presentation attribute necessary for display of the study tree in the browser. \nThe item is selectable by SALOME selection mechanism if TRUE."; + + //========================================================================== +/*! \brief Expandable flag Attribute. + + This is a presentation attribute necessary for display of the study tree in the browser. + It sets this item to be expandable even if it has no children if value is TRUE. If value is FALSE + expandable only if it has children. +*/ + //========================================================================== + interface AttributeExpandable : GenericAttribute + { +/*! + Returns TRUE if this item is expandable even when it has no children. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + boolean IsExpandable(); + const string IsExpandable__doc__ = "Returns TRUE if this item is expandable even when it has no children."; +/*! + Sets this item to be expandable even if it has no children if value is TRUE, and to be + expandable only if it has children if value is FALSE (the default). +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void SetExpandable(in boolean value); + const string SetExpandable__doc__ = "Sets this item to be expandable even if it has no children if value is TRUE, and to be \nexpandable only if it has children if value is FALSE (the default)."; + }; + const string AttributeExpandable__doc__ = "This is a presentation attribute necessary for display of the study tree in the browser. \nIt sets this item to be expandable even if it has no children if value is TRUE. \nIf value is FALSE expandable only if it has children."; + + //========================================================================== +/*! \brief Opened flag Attribute. + + This is a presentation attribute necessary for display of the study tree in the browser. + It sets this item to be open (its children are visible) if bool is TRUE, and to be closed (its children + are not visible) if bool is FALSE. +*/ + //========================================================================== + interface AttributeOpened : GenericAttribute + { +/*! + Returns TRUE if this item is open (its children are visible) and FALSE if it isn't. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + boolean IsOpened(); + const string IsOpened__doc__ = "Returns TRUE if this item is open (its children are visible) and FALSE if it isn't."; +/*! + Sets this item to be open (its children are visible) if value is TRUE, and to be closed +(its children are not visible) if value is FALSE. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void SetOpened(in boolean value); + const string SetOpened__doc__ = "Sets this item to be open (its children are visible) if value is TRUE, and to be closed \n(its children are not visible) if value is FALSE."; + }; + const string AttributeOpened__doc__ = "This is a presentation attribute necessary for display of the study tree in the browser. \nIt sets this item to be open (its children are visible) if bool is TRUE, and to be closed (its children \nare not visible) if bool is FALSE."; + //========================================================================== +/*! \brief TextColorAttribute. + + This attribute sets the color of an item. +*/ + //========================================================================== + interface AttributeTextColor : GenericAttribute + { +/*! + Returns the color of an item. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + Color TextColor(); + const string TextColor__doc__ = "Returns the color of an item."; +/*! + Sets the color of an item. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void SetTextColor(in Color value); + const string SetTextColor__doc__ = "Sets the color of an item."; + }; + const string AttributeTextColor__doc__ = "This attribute sets the color of an item."; + + //========================================================================== + /*! \brief TextHighlightColorAttribute. + + This attribute sets the highlight color of an item. +*/ + //========================================================================== + interface AttributeTextHighlightColor : GenericAttribute + { +/*! + Returns the highlight color of an item. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + Color TextHighlightColor(); + const string TextHighlightColor__doc__ = "Returns the highlight color of an item."; +/*! + Sets the highlight color of an item. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void SetTextHighlightColor(in Color value); + const string SetTextHighlightColor__doc__ = "Sets the highlight color of an item."; + }; + const string AttributeTextHighlightColor__doc__ = "This attribute sets the highlight color of an item."; + //========================================================================== +/*! \brief PixMapAttribute. + + This attribute stores an icon which is put before the name of an item. +*/ + //========================================================================== + interface AttributePixMap : GenericAttribute + { +/*! + Returns True if there is an icon before the name of the item. +*/ + boolean HasPixMap(); + const string HasPixMap__doc__ = "Returns True if there is an icon before the name of the item."; +/*! + Returns the name of the icon. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + string GetPixMap(); + const string GetPixMap__doc__ = "Returns the name of the icon."; +/*! + Sets the name of the icon. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void SetPixMap(in string value); + const string SetPixMap__doc__ = "Sets the name of the icon."; + }; + const string AttributePixMap__doc__ = "This attribute stores an icon which is put before the name of an item."; + + //========================================================================== +/*! \brief TreeNodeAttribute. + + A set of these attributes on the %SObjects of the %study forms an inner auxiliary + tree whith its own structure and identifier. The quantity of such trees with different + identifiers can be arbitrary. +
See also an example of usage of the methods of this interface in batchmode of %SALOME application. + +*/ + //========================================================================== + interface AttributeTreeNode : GenericAttribute + { +/*! + Sets the father TreeNode to this TreeNode. +*/ + void SetFather(in AttributeTreeNode value); + const string SetFather__doc__ = "Sets the father TreeNode to this TreeNode."; +/*! + Returns True if there is the father TreeNode of this TreeNode. +*/ + boolean HasFather(); + const string HasFather__doc__ = "Returns True if there is the father TreeNode of this TreeNode."; +/*! + Returns the father Treenode of this TreeNode. +*/ + AttributeTreeNode GetFather(); + const string GetFather__doc__ = "Returns the father Treenode of this TreeNode."; +/*! + Sets the previous brother TreeNode to this treeNode. +*/ + void SetPrevious(in AttributeTreeNode value); + const string SetPrevious__doc__ = "Sets the previous brother TreeNode to this treeNode."; +/*! + Returns True if there is the previous brother TreeNode of this TreeNode. +*/ + boolean HasPrevious(); + const string HasPrevious__doc__ = "Returns True if there is the previous brother TreeNode of this TreeNode."; +/*! + Returns the previous brother TreeNode of this TreeNode. +*/ + AttributeTreeNode GetPrevious(); + const string GetPrevious__doc__ = "Returns the previous brother TreeNode of this TreeNode."; +/*! + Sets the next brother TreeNode to this treeNode. +*/ + void SetNext(in AttributeTreeNode value); + const string SetNext__doc__ = "Sets the next brother TreeNode to this treeNode."; +/*! + Returns True if there is the next brother TreeNode of this TreeNode. +*/ + boolean HasNext(); + const string HasNext__doc__ = "Returns True if there is the next brother TreeNode of this TreeNode."; +/*! + Returns the previous brother TreeNode of this TreeNode. +*/ + AttributeTreeNode GetNext(); + const string GetNext__doc__ = "Returns the previous brother TreeNode of this TreeNode."; +/*! + Sets the first child TreeNode to this treeNode. +*/ + void SetFirst(in AttributeTreeNode value); + const string SetFirst__doc__ = "Sets the first child TreeNode to this treeNode."; +/*! + Returns True if there is the first child TreeNode of this TreeNode. +*/ + boolean HasFirst(); + const string HasFirst__doc__ = "Returns True if there is the first child TreeNode of this TreeNode."; +/*! + Returns the first child TreeNode of this TreeNode. +*/ + AttributeTreeNode GetFirst(); + const string GetFirst__doc__ = "Returns the first child TreeNode of this TreeNode."; +/*! + Sets ID of the tree. TreeNodes of one tree have the same ID. +*/ + void SetTreeID(in string value); + const string SetTreeID__doc__ = "Sets ID of the tree. TreeNodes of one tree have the same ID."; +/*! + Gets ID of the tree. +*/ + string GetTreeID(); + const string GetTreeID__doc__ = "Gets ID of the tree."; + +/*! + Adds a child TreeNode to the end of the list of children of this Treenode. +*/ + void Append(in AttributeTreeNode value); + const string Append__doc__ = "Adds a child TreeNode to the end of the list of children of this Treenode."; +/*! + Adds a child TreeNode to the beginning of the list of children of this Treenode. + +*/ + void Prepend(in AttributeTreeNode value); + const string Prepend__doc__ = "Adds a child TreeNode to the beginning of the list of children of this Treenode."; +/*! + Adds a brother TreeNode before this Treenode. + In this case the both TreeNodes will belong to the same father. +*/ + void InsertBefore(in AttributeTreeNode value); + const string InsertBefore__doc__ = "Adds a brother TreeNode before this Treenode. In this case the both TreeNodes will belong to the same father."; +/*! + Adds a brother TreeNode after this Treenode. + In this case the both TreeNodes will belong to the same father. +*/ + void InsertAfter(in AttributeTreeNode value); + const string InsertAfter__doc__ = "Adds a brother TreeNode after this Treenode. In this case the both TreeNodes will belong to the same father."; +/*! + Deletes a TreeNode. +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void Remove(); + const string Remove__doc__ = "Deletes a TreeNode."; + +/*! + Returns the depth of the TreeNode in the + structure, it means the number of fathers of the given TreeNode. + (i.e.: the depth of the root TreeNode is 0). +*/ + long Depth(); + const string Depth__doc__ = "Returns the depth of the TreeNode in the structure, it means the number of fathers of the given TreeNode. \n(i.e.: the depth of the root TreeNode is 0)."; +/*! + Returns True if it is a root TreeNode. +*/ + boolean IsRoot(); + const string IsRoot__doc__ = "Returns True if it is a root TreeNode."; +/*! + Returns True if this TreeNode is a descendant of the TreeNode. +*/ + boolean IsDescendant(in AttributeTreeNode value); + const string IsDescendant__doc__ = "Returns True if this TreeNode is a descendant of the TreeNode."; +/*! + Returns True if this TreeNode is the father of the TreeNode. +*/ + boolean IsFather(in AttributeTreeNode value); + const string IsFather__doc__ = "Returns True if this TreeNode is the father of the TreeNode."; +/*! + Returns True if this TreeNode is a child of the TreeNode. +*/ + boolean IsChild(in AttributeTreeNode value); + const string IsChild__doc__ = "Returns True if this TreeNode is a child of the TreeNode."; +/*! + Returns ID of the according %SObject. +*/ + string Label(); + const string Label__doc__ = "Returns ID of the according SObject."; + }; + const string AttributeTreeNode__doc__ = "A set of these attributes on the SObjects of the study forms an inner auxiliary \ntree whith its own structure and identifier. The quantity of such trees with different \nidentifiers can be arbitrary."; + //========================================================================== +/*! \brief LocalID attribute + + Attribute describing the link between a %SObject and a local object in the component. +*/ + //========================================================================== + interface AttributeLocalID : GenericAttribute + { +/*! + Returns the value of this attribute. +
See also an example of this method usage in batchmode of %SALOME application. +*/ + long Value(); + const string Value__doc__ = "Returns the value of this attribute."; +/*! + Sets the value of this attribute. +
See also an example of this method usage in batchmode of %SALOME application. +*/ + void SetValue(in long value); + const string SetValue__doc__ = "Sets the value of this attribute."; + }; + const string AttributeLocalID__doc__ = "Attribute describing the link between a SObject and a local object in the component."; + + //========================================================================== +/*! \brief Attribute storing GUID + + Attribute allowing to store GUID +*/ + //========================================================================== + interface AttributeUserID : GenericAttribute + { +/*! + Returns the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. +*/ + string Value(); + const string Value__doc__ = "Returns the value of this attribute."; +/*! + Sets the value of this attribute +
See also an example of this method usage in batchmode of %SALOME application. +*/ + void SetValue(in string value); + const string SetValue__doc__ = "Sets the value of this attribute."; + }; + const string AttributeUserID__doc__ = "Attribute allowing to store GUID."; + + //========================================================================== +/*! \brief %AttributeTarget iterface + + This attribute stores the list of all %SObjects that refer + to this %SObject. This attribute is used for inner purposes of the application. + It is also needed for optimization. +*/ + //========================================================================== + + interface AttributeTarget : GenericAttribute + { +/*! + Adds a %SObject to the list of %SObjects which refer to this %SObject. + +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void Add(in SObject anObject); + const string Add__doc__ = "Adds a SObject to the list of SObjects which refer to this SObject."; +/*! + Returns the list of %SObjects which refer to this %SObject. +*/ + SALOMEDS::Study::ListOfSObject Get(); + const string Get__doc__ = "Returns the list of SObjects which refer to this SObject."; +/*! + Deletes a %SObject from the list of %SObjects which refer to this %SObject. + +
See also an example of this method usage in batchmode of %SALOME application. + +*/ + void Remove(in SObject anObject); + const string Remove__doc__ = "Deletes a SObject from the list of SObjects which refer to this SObject."; + }; + const string AttributeTarget__doc__ = "Adds a SObject to the list of SObjects which refer to this SObject."; + //========================================================================== + /*! \brief %AttributeTableOfInteger interface + + This attribute allows to store a table of integers (indexing from 1 like in CASCADE) + and string titles of this table, of each row, of each column. +
See also an example of usage of these methods in batchmode of %SALOME application. + +*/ + //========================================================================== + + interface AttributeTableOfInteger : GenericAttribute + { +/*! + This exception is raised when an incorrect index is passed as parameter. +*/ + exception IncorrectIndex {}; +/*! + This exception is raised when an incorrect length of the argument is passed as parameter. +*/ + exception IncorrectArgumentLength {}; + + // titles: for table, for each row, for each column +/*! + Sets the title of the table. +*/ + void SetTitle(in string theTitle); + const string SetTitle__doc__ = "Sets the title of the table."; +/*! + Returns the title of the table. +*/ + string GetTitle(); + const string GetTitle__doc__ = "Returns the title of the table."; +/*! + Sets the title of a row with a definite index. +*/ + void SetRowTitle(in long theIndex, in string theTitle) raises(IncorrectIndex); + const string SetRowTitle__doc__ = "Sets the title of a row with a definite index."; +/*! + Sets the titles for all rows of the table. +*/ + void SetRowTitles(in StringSeq theTitles) raises(IncorrectArgumentLength); + const string SetRowTitles__doc__ = "Sets the titles for all rows of the table."; +/*! + Returns the titles of all rows of the table. +*/ + StringSeq GetRowTitles(); + const string GetRowTitles__doc__ = "Returns the titles of all rows of the table."; +/*! + Sets the title of a column with a definite index. +*/ + void SetColumnTitle(in long theIndex, in string theTitle) raises(IncorrectIndex); + const string SetColumnTitle__doc__ = "Sets the title of a column with a definite index."; +/*! + Sets the titles for all columns of the table. +*/ + void SetColumnTitles(in StringSeq theTitles) raises(IncorrectArgumentLength); + const string SetColumnTitles__doc__ = "Sets the titles for all columns of the table."; +/*! + Returns the titles of all columns of the table. +*/ + StringSeq GetColumnTitles(); + const string GetColumnTitles__doc__ = "Returns the titles of all columns of the table."; + + //Rows units +/*! + Sets the unit of a row with a definite index. +*/ + void SetRowUnit(in long theIndex, in string theUnit) raises(IncorrectIndex); + const string SetRowUnit__doc__ = "Sets the unit of a row with a definite index."; +/*! + Sets the units for all rows of the table. +*/ + void SetRowUnits(in StringSeq theUnits) raises(IncorrectArgumentLength); + const string SetRowUnits__doc__ = "Sets the units for all rows of the table."; +/*! + Returns the units of all rows of the table. +*/ + StringSeq GetRowUnits(); + const string GetRowUnits__doc__ = "Returns the units of all rows of the table."; + + // table information +/*! + Returns the number of rows of the table. +*/ + long GetNbRows(); + const string GetNbRows__doc__ = "Returns the number of rows of the table."; +/*! + Returns the number of columns of the table. +*/ + long GetNbColumns(); + const string GetNbColumns__doc__ = "Returns the number of columns of the table."; + + // operations with rows +/*! + Adds a row to the end of the table. +*/ + void AddRow(in LongSeq theData) raises(IncorrectArgumentLength); + const string AddRow__doc__ = "Adds a row to the end of the table."; +/*! + Sets the values of all elements of the row. +*/ + void SetRow(in long theRow, in LongSeq theData) raises(IncorrectArgumentLength, IncorrectIndex); + const string SetRow__doc__ = "Sets the values of all elements of the row."; +/*! + Returns the row of the table. +*/ + LongSeq GetRow(in long theRow) raises(IncorrectIndex); + const string GetRow__doc__ = "Returns the row of the table."; + + // operations with columns +/*! + Adds a column to the end of the table. +*/ + void AddColumn(in LongSeq theData) raises(IncorrectArgumentLength); + const string AddColumn__doc__ = "Adds a column to the end of the table."; +/*! + Sets the values of all elements of the column. +*/ + void SetColumn(in long theColumn, in LongSeq theData) raises(IncorrectArgumentLength, IncorrectIndex); + const string SetColumn__doc__ = "Sets the values of all elements of the column."; +/*! + Returns the column of the table. +*/ + LongSeq GetColumn(in long theColumn) raises(IncorrectIndex); + const string GetColumn__doc__ = "Returns the column of the table."; + + // operations with elements +/*! + Puts a value in the table. + \param theRow The row, where the value will be placed. + \param theColumn The column, where the value will be placed. +*/ + void PutValue(in long theValue, in long theRow, in long theColumn) raises(IncorrectIndex); + const string PutValue__doc__ = "Puts a value in a definite row theRow and column theColumn of the table."; +/*! + Returns True if there is a value in the table. + \param theRow The row containing the value + \param theColumn The column containing the value +*/ + boolean HasValue(in long theRow, in long theColumn); + const string HasValue__doc__ = "Returns True if there is a value in a definite row and column of the table."; +/*! + Returns the value from the table. + \param theRow The row containing the value + \param theColumn The column containing the value +*/ + long GetValue(in long theRow, in long theColumn) raises(IncorrectIndex); + const string GatValue__doc__ = "Returns the value from a definite row and column of the table."; + +/*! + Sets the max number of colums in the table. + \note It'd better to set it before filling the table. +*/ + void SetNbColumns(in long theNbColumns); + const string SetNbColumns__doc__ = "Sets the max number of colums in the table. "; + +/*! + Returns the indices of the row where the values are defined. +*/ + LongSeq GetRowSetIndices(in long theRow) raises(IncorrectIndex); + const string GetRowSetIndices__doc__ = "Returns the indices of the row where the values are defined."; + // operations with files +/*! + Reads a table from a file. +*/ + boolean ReadFromFile(in SALOMEDS::TMPFile theStream); + const string ReadFromFile__doc__ = "Reads a table from a file."; +/*! + Saves a table into a file. +*/ + SALOMEDS::TMPFile SaveToFile(); + const string SaveToFile__doc__ = "Saves a table into a file."; + }; + const string AttributeTableOfInteger__doc__ = "This attribute allows to store a table of integers (indexing from 1 like in CASCADE) \nand string titles of this table, of each row, of each column."; + + //========================================================================== +/*! \brief %AttributeTableOfReal interface + + This attribute allows to store a table of reals (indexing from 1 like in CASCADE) + and string titles of this table, of each row, of each column. +
See also an example of usage of these methods in batchmode of %SALOME application. + +*/ + //========================================================================== + + interface AttributeTableOfReal : GenericAttribute + { +/*! + This exception is raised when an incorrect index is passed as parameter. +*/ + exception IncorrectIndex {}; +/*! + This exception is raised when an incorrect length of the argument is passed as parameter. +*/ + exception IncorrectArgumentLength {}; + + // titles: for table, for each row, for each column +/*! + Sets the title of the table. +*/ + void SetTitle(in string theTitle); + const string SetTitle__doc__ = "Sets the title of the table."; +/*! + Returns the title of the table. +*/ + string GetTitle(); + const string GetTitle__doc__ = "Returns the title of the table."; +/*! + Sets the title of a row with a definite index. +*/ + void SetRowTitle(in long theIndex, in string theTitle) raises(IncorrectIndex); + const string SetRowTitle__doc__ = "Sets the title of a row with a definite index."; +/*! + Sets the titles for all rows of the table. +*/ + void SetRowTitles(in StringSeq theTitles) raises(IncorrectArgumentLength); + const string SetRowTitles__doc__ = "Sets the titles for all rows of the table."; +/*! + Returns the titles of all rows of the table. +*/ + StringSeq GetRowTitles(); + const string GetRowTitles__doc__ = "Returns the titles of all rows of the table."; +/*! + Sets the title of a column with a definite index. +*/ + void SetColumnTitle(in long theIndex, in string theTitle) raises(IncorrectIndex); + const string SetColumnTitle__doc__ = "Sets the title of a column with a definite index."; +/*! + Sets the titles for all columns of the table. +*/ + void SetColumnTitles(in StringSeq theTitles) raises(IncorrectArgumentLength); + const string SetColumnTitles__doc__ = "Sets the titles for all columns of the table."; +/*! + Returns the titles of all columns of the table. +*/ + StringSeq GetColumnTitles(); + const string GetColumnTitles__doc__ = "Returns the titles of all columns of the table."; + + //Rows units +/*! + Sets the unit of a row with a definite index. +*/ + void SetRowUnit(in long theIndex, in string theUnit) raises(IncorrectIndex); + const string SetRowUnit__doc__ = "Sets the unit of a row with a definite index."; +/*! + Sets the units for all rows of the table. +*/ + void SetRowUnits(in StringSeq theUnits) raises(IncorrectArgumentLength); + const string SetRowUnits__doc__ = "Sets the units for all rows of the table."; +/*! + Returns the units of all rows of the table. +*/ + StringSeq GetRowUnits(); + const string GetRowUnits__doc__ = "Returns the units of all rows of the table."; + + // table information +/*! + Returns the number of rows of the table. +*/ + long GetNbRows(); + const string GetNbRows__doc__ = "Returns the number of rows of the table."; +/*! + Returns the number of columns of the table. +*/ + long GetNbColumns(); + const string GetNbColumns__doc__ = "Returns the number of columns of the table."; + + // operations with rows +/*! + Adds a row to the end of the table. +*/ + void AddRow(in DoubleSeq theData) raises(IncorrectArgumentLength); + const string AddRow__doc__ = "Adds a row to the end of the table."; +/*! + Sets the values of all elements of the row. +*/ + void SetRow(in long theRow, in DoubleSeq theData) raises(IncorrectArgumentLength, IncorrectIndex); + const string SetRow__doc__ = "Sets the values of all elements of the row."; +/*! + Returns the row of the table. +*/ + DoubleSeq GetRow(in long theRow) raises(IncorrectIndex); + const string GetRow__doc__ = "Returns the row of the table."; + + // operations with columns +/*! + Adds a column to the end of the table. +*/ + void AddColumn(in DoubleSeq theData) raises(IncorrectArgumentLength); + const string AddColumn__doc__ = "Adds a column to the end of the table."; +/*! + Sets the values of all elements of the column. +*/ + void SetColumn(in long theColumn, in DoubleSeq theData) raises(IncorrectArgumentLength, IncorrectIndex); + const string SetColumn__doc__ = "Sets the values of all elements of the column."; +/*! + Returns the column of the table. +*/ + DoubleSeq GetColumn(in long theColumn) raises(IncorrectIndex); + const string GetColumn__doc__ = "Returns the column of the table."; + + // operations with elements +/*! + Puts a value in the table. + \param theRow The row, where the value will be placed. + \param theColumn The column, where the value will be placed. +*/ + void PutValue(in double theValue, in long theRow, in long theColumn) raises(IncorrectIndex); + const string PutValue__doc__ = "Puts a value in a definite row theRow and column theColumn of the table."; +/*! + Returns True if there is a value in the table. + \param theRow The row containing the value + \param theColumn The column containing the value +*/ + boolean HasValue(in long theRow, in long theColumn); + const string HasValue__doc__ = "Returns True if there is a value in a definite row and column of the table."; +/*! + Returns the value from the table. + \param theRow The row containing the value + \param theColumn The column containing the value +*/ + double GetValue(in long theRow, in long theColumn) raises(IncorrectIndex); + const string GatValue__doc__ = "Returns the value from a definite row and column of the table."; + +/*! + Sets the max number of colums in the table. + \note It'd better to set it before filling the table. +*/ + void SetNbColumns(in long theNbColumns); + const string SetNbColumns__doc__ = "Sets the max number of colums in the table. "; + +/*! + Returns the indices of the row where the values are defined. +*/ + LongSeq GetRowSetIndices(in long theRow) raises(IncorrectIndex); + const string GetRowSetIndices__doc__ = "Returns the indices of the row where the values are defined."; + // operations with files +/*! + Reads a table from a file. +*/ + boolean ReadFromFile(in SALOMEDS::TMPFile theStream); + const string ReadFromFile__doc__ = "Reads a table from a file."; +/*! + Saves a table into a file. +*/ + SALOMEDS::TMPFile SaveToFile(); + const string SaveToFile__doc__ = "Saves a table into a file."; + }; + const string AttributeTableOfReal__doc__ = "This attribute allows to store a table of reals (indexing from 1 like in CASCADE) \nand string titles of this table, of each row, of each column."; + + + + //========================================================================== +/*! \brief %AttributeTableOfString interface + + This attribute allows to store a table of strings (indexing from 1 like in CASCADE) + and string titles of this table, of each row, of each column. +
See also an example of usage of these methods in batchmode of %SALOME application. + +*/ + //========================================================================== + + interface AttributeTableOfString : GenericAttribute + { +/*! + This exception is raised when an incorrect index is passed as parameter. +*/ + exception IncorrectIndex {}; +/*! + This exception is raised when an incorrect length of the argument is passed as parameter. +*/ + exception IncorrectArgumentLength {}; + + // titles: for table, for each row, for each column +/*! + Sets the title of the table. +*/ + void SetTitle(in string theTitle); + const string SetTitle__doc__ = "Sets the title of the table."; +/*! + Returns the title of the table. +*/ + string GetTitle(); + const string GetTitle__doc__ = "Returns the title of the table."; +/*! + Sets the title of a row with a definite index. +*/ + void SetRowTitle(in long theIndex, in string theTitle) raises(IncorrectIndex); + const string SetRowTitle__doc__ = "Sets the title of a row with a definite index."; +/*! + Sets the titles for all rows of the table. +*/ + void SetRowTitles(in StringSeq theTitles) raises(IncorrectArgumentLength); + const string SetRowTitles__doc__ = "Sets the titles for all rows of the table."; +/*! + Returns the titles of all rows of the table. +*/ + StringSeq GetRowTitles(); + const string GetRowTitles__doc__ = "Returns the titles of all rows of the table."; +/*! + Sets the title of a column with a definite index. +*/ + void SetColumnTitle(in long theIndex, in string theTitle) raises(IncorrectIndex); + const string SetColumnTitle__doc__ = "Sets the title of a column with a definite index."; +/*! + Sets the titles for all columns of the table. +*/ + void SetColumnTitles(in StringSeq theTitles) raises(IncorrectArgumentLength); + const string SetColumnTitles__doc__ = "Sets the titles for all columns of the table."; +/*! + Returns the titles of all columns of the table. +*/ + StringSeq GetColumnTitles(); + const string GetColumnTitles__doc__ = "Returns the titles of all columns of the table."; + + //Rows units +/*! + Sets the unit of a row with a definite index. +*/ + void SetRowUnit(in long theIndex, in string theUnit) raises(IncorrectIndex); + const string SetRowUnit__doc__ = "Sets the unit of a row with a definite index."; +/*! + Sets the units for all rows of the table. +*/ + void SetRowUnits(in StringSeq theUnits) raises(IncorrectArgumentLength); + const string SetRowUnits__doc__ = "Sets the units for all rows of the table."; +/*! + Returns the units of all rows of the table. +*/ + StringSeq GetRowUnits(); + const string GetRowUnits__doc__ = "Returns the units of all rows of the table."; + + // table information +/*! + Returns the number of rows of the table. +*/ + long GetNbRows(); + const string GetNbRows__doc__ = "Returns the number of rows of the table."; +/*! + Returns the number of columns of the table. +*/ + long GetNbColumns(); + const string GetNbColumns__doc__ = "Returns the number of columns of the table."; + + // operations with rows +/*! + Adds a row to the end of the table. +*/ + void AddRow(in StringSeq theData) raises(IncorrectArgumentLength); + const string AddRow__doc__ = "Adds a row to the end of the table."; +/*! + Sets the values of all elements of the row. +*/ + void SetRow(in long theRow, in StringSeq theData) raises(IncorrectArgumentLength, IncorrectIndex); + const string SetRow__doc__ = "Sets the values of all elements of the row."; +/*! + Returns the row of the table. +*/ + StringSeq GetRow(in long theRow) raises(IncorrectIndex); + const string GetRow__doc__ = "Returns the row of the table."; + + // operations with columns +/*! + Adds a column to the end of the table. +*/ + void AddColumn(in StringSeq theData) raises(IncorrectArgumentLength); + const string AddColumn__doc__ = "Adds a column to the end of the table."; +/*! + Sets the values of all elements of the column. +*/ + void SetColumn(in long theColumn, in StringSeq theData) raises(IncorrectArgumentLength, IncorrectIndex); + const string SetColumn__doc__ = "Sets the values of all elements of the column."; +/*! + Returns the column of the table. +*/ + StringSeq GetColumn(in long theColumn) raises(IncorrectIndex); + const string GetColumn__doc__ = "Returns the column of the table."; + + // operations with elements +/*! + Puts a value in the table. + \param theRow The row, where the value will be placed. + \param theColumn The column, where the value will be placed. +*/ + void PutValue(in string theValue, in long theRow, in long theColumn) raises(IncorrectIndex); + const string PutValue__doc__ = "Puts a value in a definite row theRow and column theColumn of the table."; +/*! + Returns True if there is a value in the table. + \param theRow The row containing the value + \param theColumn The column containing the value +*/ + boolean HasValue(in long theRow, in long theColumn); + const string HasValue__doc__ = "Returns True if there is a value in a definite row and column of the table."; +/*! + Returns the value from the table. + \param theRow The row containing the value + \param theColumn The column containing the value +*/ + string GetValue(in long theRow, in long theColumn) raises(IncorrectIndex); + const string GatValue__doc__ = "Returns the value from a definite row and column of the table."; + +/*! + Sets the max number of colums in the table. + \note It'd better to set it before filling the table. +*/ + void SetNbColumns(in long theNbColumns); + const string SetNbColumns__doc__ = "Sets the max number of colums in the table. "; + +/*! + Returns the indices of the row where the values are defined. +*/ + LongSeq GetRowSetIndices(in long theRow) raises(IncorrectIndex); + const string GetRowSetIndices__doc__ = "Returns the indices of the row where the values are defined."; + // operations with files +/*! + Reads a table from a file. +*/ + boolean ReadFromFile(in SALOMEDS::TMPFile theStream); + const string ReadFromFile__doc__ = "Reads a table from a file."; +/*! + Saves a table into a file. +*/ + SALOMEDS::TMPFile SaveToFile(); + const string SaveToFile__doc__ = "Saves a table into a file."; + }; + const string AttributeTableOfString__doc__ = "This attribute allows to store a table of string (indexing from 1 like in CASCADE) \nand string titles of this table, of each row, of each column."; + + + //========================================================================== +/*! \brief %AttributeStudyProperties interface + + This attribute allows to store study properties: user name, creation date, creation + mode, modified flag, locked flag. +
See also an example of usage of these methods in batchmode of %SALOME application. + +*/ + //========================================================================== + + interface AttributeStudyProperties : GenericAttribute + { +/*! + Sets the name of the author of the %Study +*/ + void SetUserName(in string theName); + const string SetUserName__doc__ = "Sets the name of the author of the study."; +/*! + Returns the name of the user of the %Study. + \note
It returns a null string, if user name is not set +*/ + string GetUserName(); + const string GetUserName__doc__ = "Returns the name of the user of the study."; +/*! + Sets creation date of the %Study. +*/ + void SetCreationDate(in long theMinute, in long theHour, in long theDay, in long theMonth, in long theYear); + const string SetCreationDate__doc__ = "Sets creation date of the study."; +/*! + Returns creation date of the %Study and True if creation date is set. +*/ + boolean GetCreationDate(out long theMinute, out long theHour, out long theDay, out long theMonth, out long theYear); + const string GetCreationDate__doc__ = "Returns creation date of the study and True if creation date is set."; +/*! + Sets creation mode of the %Study. + \note
Creation mode must be: "from scratch" or "copy from". +*/ + void SetCreationMode(in string theMode); + const string SetCreationMode__doc__ = "Sets creation mode of the study. Creation mode must be: from scratch or copy from."; +/*! + Returns creation mode: "from scratch", "copy from", or null string + if creation mode is not set +*/ + string GetCreationMode(); + const string GetCreationMode__doc__ = "Returns creation mode of the study."; +/*! + Sets the number of transactions executed after the last saving of the document. +*/ + void SetModified(in long theModified); + const string SetModified__doc__ = "Sets the number of transactions executed after the last saving of the document."; +/*! + Returns True, if the document has been modified and not saved. +*/ + boolean IsModified(); + const string IsModified__doc__ = "Returns True, if the document has been modified and not saved."; +/*! + Returns the number of transactions executed after the last saving of the document. +*/ + long GetModified(); + const string GetModified__doc__ = "Returns the number of transactions executed after the last saving of the document."; +/*! + Sets the document locked for modifications if theLocked is True. +*/ + void SetLocked(in boolean theLocked); + const string SetLocked__doc__ = "Sets the document locked for modifications if theLocked is True."; +/*! + Returns True if the document is locked for modifications. +*/ + boolean IsLocked(); + const string IsLocked__doc__ = "Returns True if the document is locked for modifications."; +/*! + Appends modification parameters to the modifications list. +*/ + void SetModification(in string theName, in long theMinute, in long theHour, in long theDay, in long theMonth, in long theYear); + const string SetModification__doc__ = "Appends modification parameters to the modifications list."; +/*! + Returns a list of mosdifiers user names, modification dates. + /note
If theWithCreator is True, then the output list will also contain the name of the author and the date of creation. +*/ + void GetModificationsList(out StringSeq theNames, out LongSeq theMinutes, out LongSeq theHours, out LongSeq theDays, out LongSeq theMonths, out LongSeq theYears, in boolean theWithCreator); + const string GetModificationsList__doc__ = "Returns a list of mosdifiers user names, modification dates."; + }; + const string AttributeStudyProperties__doc__ = "This attribute allows to store properties of the study : user name, creation date, \ncreation mode, modified flag, locked flag."; + //========================================================================== +/*! \brief %AttributePythonObject interface + + Attribute allowing to store pyton objects as a sequence of chars. +*/ + //========================================================================== + + interface AttributePythonObject : GenericAttribute + { +/*! + Sets in the attribute a Python object converted into a sequence of chars. + \param theSequence A sequence of chars. + \param IsScript Defines (if True) whether this sequence of chars is a Python script. +*/ + void SetObject(in string theSequence, in boolean IsScript); + const string SetObject__doc__ = "Sets in the attribute a Python object converted into a sequence of chars."; +/*! + Returns a Python object stored in the attribute as a sequence of chars. +*/ + string GetObject(); + const string GetObject__doc__ = "Returns a Python object stored in the attribute as a sequence of chars."; +/*! + Returns True if the sequence of bytes stored in the attribute corresponds + to a Python script. +*/ + boolean IsScript(); + const string IsScript__doc__ = "Returns True if the sequence of bytes stored in the attribute corresponds to a Python script."; + }; + const string AttributePythonObject__doc__ = "Attribute allowing to store pyton objects as a sequence of chars."; +}; +#endif diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl new file mode 100644 index 000000000..f5fe50f56 --- /dev/null +++ b/idl/SALOME_Component.idl @@ -0,0 +1,117 @@ +//============================================================================= +// File : SALOME_Component.idl +// Created : jeu jui 12 08:11:23 CEST 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header: /dn05/salome/CVS/SALOME_ROOT/idl/SALOME_Component.idl +//============================================================================= + +#ifndef _SALOME_COMPONENT_IDL_ +#define _SALOME_COMPONENT_IDL_ +/*! \ingroup Kernel + +This is a package of interfaces used for connecting new components to %SALOME application. It also contains a set of interfaces used +for management of %MED component in %SALOME application. +*/ +module Engines +{ + interface Component ; + +/*! \brief Interface of the %Container + + This interface defines the process of loading and registration + of new components in SALOME application +*/ + interface Container + { +/*! + Initializes the %container with a definite name. +*/ + Container start_impl( in string ContainerName ) ; + +/*! + Loads into the container a new component, registers it and starts it's CORBA servant. + \param nameToRegister Name of the component which will be registered in Registry (or Name Service) + \param componentName Name of the constructed library of the %component +*/ + Component load_impl(in string nameToRegister, in string componentName); + +/*! + Stops the component servant, and deletes all related objects +*/ + void remove_impl(in Component component_i); + +/*! + Discharges all components from the container. +*/ + void finalize_removal() ; +/*! + Determines whether the server has been loaded or not. +*/ + + void ping(); +/*! + Name of the %container +*/ + readonly attribute string name ; +/*! + Name of the machine containing this container (location of the container). +*/ + readonly attribute string machineName ; +/*! + Returns True if the %container has been killed +*/ + boolean Kill_impl() ; + }; +/*! \brief Interface of the %component + + This interface is used for interaction between the %container and the %component and between + the components inside the container. +*/ + interface Component + { +/*! + The name of the instance of the %Component +*/ + readonly attribute string instanceName ; +/*! + The name of the interface of the %Component +*/ + readonly attribute string interfaceName ; +/*! + Determines whether the server has already been loaded or not. +*/ + void ping(); +/*! + Deactivates the %Component. +*/ + void destroy() ; +/*! + Returns the container that the %Component refers to. +*/ + Container GetContainerRef() ; +/*! + This method is used by the %SUPERVISOR component. It sets the names of the graph and of the node. +*/ + void Names( in string aGraphName , in string aNodeName ) ; +/*! + Returns True if the %Component has been killed. +*/ + boolean Kill_impl() ; +/*! + Returns True if the activity of the %Component has been stopped. (It's action can't be resumed) +*/ + boolean Stop_impl() ; +/*! + Returns True if the activity of the %Component has been suspended. (It's action can be resumed) +*/ + boolean Suspend_impl() ; +/*! + Returns True if the activity of the %Component has been resumed. +*/ + boolean Resume_impl() ; + } ; +} ; + +#endif diff --git a/idl/SALOME_DataTypeCatalog.idl b/idl/SALOME_DataTypeCatalog.idl new file mode 100644 index 000000000..34b4edc57 --- /dev/null +++ b/idl/SALOME_DataTypeCatalog.idl @@ -0,0 +1,31 @@ +// File: SALOME_DataTypeCatalog.idl +// Created: Mon August 08 2001 +// Author: Estelle Deville, Paul Rascle +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + +module SALOME_DataTypeCatalog{ +// Type definitions + +// List of Data Type Names + typedef sequence ListOfDataTypeName ; + + // Exception thrown if a DataType is not found in the catalog + exception NotFound {}; +//-------------------------------------------------------------------------- +// Interfaces + +// Catalog interface : +// methods to : +// - obtain the data type names of the catalog +// - test the compatibility between two type names +interface DataCatalog +{ + ListOfDataTypeName GetDataTypeList() ; + boolean isDerivedFrom(in string type_in, in string type_out) raises(NotFound); + string GetDataInterfaceRead(in string type) raises(NotFound); + string GetDataInterfaceWrite(in string type)raises(NotFound); + ListOfDataTypeName GetDataTypeParents(in string type) raises(NotFound); +} ; +}; diff --git a/idl/SALOME_Exception.idl b/idl/SALOME_Exception.idl new file mode 100644 index 000000000..5c491e65a --- /dev/null +++ b/idl/SALOME_Exception.idl @@ -0,0 +1,51 @@ +//============================================================================= +// File : SALOME_Exception.idl +// Created : mar déc 18 17:57:27 CET 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +/*! \file SALOME_Exception.idl This file contains the objects defining the main exception used +in %SALOME application. +*/ +#ifndef _SALOME_EXCEPTION_IDL_ +#define _SALOME_EXCEPTION_IDL_ + +/*! +Module SALOME regroups all idl definitions for SALOME Kernel +*/ + +module SALOME +{ +/*! +This enumeration contains the elements indicating the type of the exception. +*/ + enum ExceptionType + { + COMM, /*!< Communication problem */ + BAD_PARAM, /*!< Bad User parameters */ + INTERNAL_ERROR /*!< SALOME Bug, irrecoverable */ + }; +/*! +This struct contains a set of fields defining the structure of the exception. +*/ + struct ExceptionStruct + { + ExceptionType type; /*! ListOfServicesParameter; +/*! +This struct contains fields completely defining each service. +*/ + + struct Service + { + string ServiceName; /*! ListOfInterfaceService; +/*! +List of services. +*/ + typedef sequence ListOfServices ; +/*! +This struct contains fields defining each interface. +*/ + struct DefinitionInterface + { + string interfacename ; /*! ListOfDefInterface ; +/*! +List of interfaces. +*/ + typedef sequence ListOfInterfaces ; +/*! +List of names of components. +*/ + typedef sequence ListOfComponents ; +/*! +List of names of computers. +*/ + typedef sequence ListOfComputers ; +/*! +This struct contains GUI elements used for representation of the module in %IAPP component. +*/ + struct IAPP_Affich + { + string modulename; /*! ListOfIAPP_Affich ; + +/*! + This exception is raised when a %component, a %service or a % pathPrefix is not found. +*/ + exception NotFound + { + string what ; /*!If the specified interface doesn't exist, Notfound exception is thrown + \param interfacename Name of the interface + \return Required interface + */ + DefinitionInterface GetInterface(in string interfacename) raises(NotFound); + + // GetServiceList : operation to get a list of the services name of + // an interface of a component + /*! + Gets a list of names of services of a definite interface belonging to the component. + \note
If the specified interface doesn't exist, Notfound exception is thrown. + \param interfacename Name of the interface + \return List of services of the required interface + */ + ListOfServices GetServiceList(in string interfacename) raises(NotFound); + + + // GetService : operation to get one service of an interface of a component + + /*! + Gets a definite service of an interface of the component. + \note
If the required service or the specified interface don't exist, Notfound exception is thrown. + \param interfacename Name of the interface + \param servicename Name of the service + \return Required service + */ + + Service GetService(in string interfacename, + in string servicename) raises(NotFound); + + // GetDefaultService : operation to get the default service + // of an interface of a component +/*! + Gets the default service of an interface of the component. + \note
If the required service or the specified interface don't exist, Notfound exception is thrown. + \param interfacename Name of the interface + \return Required service + */ + + Service GetDefaultService(in string interfacename) raises(NotFound); + + // GetPathPrefix : operation to get the PathPrefix of a computer + /*! + Gets the prefix path of the computer containing the %component. + \note
If the required computer doesn't exist, Notfound exception is thrown + \param machinename Name of the machine + \return Prefix path + */ + + string GetPathPrefix(in string machinename) raises(NotFound); + +/*! + Sets/gets the constraint affected to the component + (to be resolved by LifeCycle for the computer choice) +*/ + readonly attribute string constraint ; + +/*! +Sets/gets the name of the component +*/ + readonly attribute string componentname; + +/*! +Defines whether the component can be multistudy or not +*/ + readonly attribute boolean multistudy; + +/*! +Defines the type of the component +*/ + readonly attribute ComponentType component_type ; + +/*! +Sets/gets the icone of the component (for IAPP) +*/ + readonly attribute string component_icone; + } ; +/*! \brief %Module catalog interface + +This interface is used for creation of the module catalog in %SALOME application. +*/ + interface ModuleCatalog + { + void ping(); + +/*! + Gets a list of names of computers of the catalog +*/ + ListOfComputers GetComputerList(); + +/*! +Gets the %PathPrefix of a computer +*/ + string GetPathPrefix(in string machinename) raises(NotFound); +/*! + Gets a list of names of components of the catalog +*/ + ListOfComponents GetComponentList(); +/*! +Gets a list of pair GUI elements (component name, component icone) +used for representation of the module in %IAPP component. +*/ + + ListOfIAPP_Affich GetComponentIconeList(); +/*! +Gets a list of names of components of a particular type, which belong to this catalog. +*/ + // GetComponentList : operation to get a list of the components name of + // a particular type of the catalog + ListOfComponents GetTypedComponentList(in ComponentType _component_type); + +/*! +Gets one component of the catalog. +*/ + Acomponent GetComponent(in string componentname) raises(NotFound); + } ; +}; diff --git a/idl/SALOME_Registry.idl b/idl/SALOME_Registry.idl new file mode 100644 index 000000000..d3e7a7fed --- /dev/null +++ b/idl/SALOME_Registry.idl @@ -0,0 +1,38 @@ +# ifndef __registry_idl__ +# define __registry_idl__ + +module Registry +{ + struct Infos + { + string name; + long pid; + string machine; + string adip; + long uid; + string pwname; + long tc_start; + long tc_hello; + long tc_end; + long difftime; + string cdir; + long status; + string ior; // client + }; + + typedef sequence AllInfos; + + interface Components + { + void ping(); + unsigned long add ( in Infos lesInfos ) ; + void remove ( in unsigned long id ) ; + unsigned long size() ; + AllInfos getall () ; + AllInfos history () ; + oneway void end() ; + oneway void hello( in unsigned long id ) ; + } ; +} ; + +# endif diff --git a/idl/SALOME_RessourcesCatalog.idl b/idl/SALOME_RessourcesCatalog.idl new file mode 100755 index 000000000..be518177f --- /dev/null +++ b/idl/SALOME_RessourcesCatalog.idl @@ -0,0 +1,46 @@ +// File: SALOME_RessourcesCatalog.idl +// Created: Mon Sep 10 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + +module SALOME_RessourcesCatalog{ + // Type Definitions + + //Proc_info : information about a processor + struct proc_info{ + long number; + string model_name; + float cpu_mhz; + float cache_size; + }; + + typedef sequence ListOfProc; + + //Computer_info : information about a computer + // Os and informations about processors + struct computer_info{ + string name; + string OS; + string OS_version; + ListOfProc procs; + }; + + enum ContainerType {Cpp, python, NP}; + typedef sequence ListOfContainerType; + + typedef sequence ListOfComputer; + + // exception thrown if a computer is not found in the catalog + + exception NotFound {}; + + //------------------------------------------------------------------ + //Interface + interface RessourcesCatalog { + ListOfComputer GetComputerList(); + ListOfContainerType GetContainerTypeList (in string computer) raises(NotFound); + computer_info GetComputerInfo(in string computer) raises(NotFound); + }; +}; diff --git a/idl/SALOME_Session.idl b/idl/SALOME_Session.idl new file mode 100644 index 000000000..81c95996c --- /dev/null +++ b/idl/SALOME_Session.idl @@ -0,0 +1,88 @@ +//============================================================================= +// File : SALOME_Session.idl +// Created : mar jun 19 09:15:07 CEST 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + + +//***//#include "VISU_Gen.idl" +/*! \defgroup Kernel SALOME KERNEL module +*/ + +/*! \ingroup Kernel + + This package contains interfaces used for management of the session in %SALOME application. +*/ +module SALOME +{ +/*! \brief State of the session + + This enumeration contains values defining the state of the session + +*/ + enum SessionState {asleep, running} ; + +/*! \brief %Session State and Statistics + + + This struct contains a field list with general information about the session +*/ + + struct StatSession + { +/*! \brief State of the session + + It can be: + * -# asleep : no running study + * -# running : one or more running studies +*/ + SessionState state ; +/*! Number of running studies +*/ + short runningStudies ; +/*! It is True if GUI is active in the session +*/ + boolean activeGUI ; + } ; +/*! \brief Interface of the session + + The %session Server launches and stops GUI (Graphical User Interface). + The %session can be active without GUI (It can contain one or more running studies) +*/ + + interface Session + { +/*! + This exception is raised when trying to stop the %session with active GUI +*/ + exception GUIActive {} ; +/*! + This exception is raised when trying to stop the %session with a number of running studies. +*/ + exception RunningStudies {} ; + +/*! + Launches GUI in the session +*/ + void GetInterface(); + //***// VISU::VISU_Gen GetVisuGen(); + +/*! + Stops the %Session (It must be idle) +*/ + void StopSession() raises(GUIActive, RunningStudies) ; + +/*! + Gets Session State +*/ + StatSession GetStatSession() ; +/*! + Determines whether the server has already been loaded or not. +*/ + void ping(); + } ; + +} ; diff --git a/idl/SALOME_TestComponent.idl b/idl/SALOME_TestComponent.idl new file mode 100644 index 000000000..212093652 --- /dev/null +++ b/idl/SALOME_TestComponent.idl @@ -0,0 +1,20 @@ +//============================================================================= +// File : SALOME_TestComponent.idl +// Created : jeu jui 12 12:08:17 CEST 2001 +// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA +// Project : SALOME +// Copyright : EDF 2001 - CEA 2001 +// $Header$ +//============================================================================= + +#include "SALOME_Component.idl" + +module Engines +{ + + interface TestComponent : Component + { + string Coucou(in long L); + }; + +}; diff --git a/idl/TestNotif.idl b/idl/TestNotif.idl new file mode 100644 index 000000000..b251e71ed --- /dev/null +++ b/idl/TestNotif.idl @@ -0,0 +1,10 @@ +# ifndef __TESTNOTIF_IDL_ +# define __TESTNOTIF_IDL_ + +interface Solver +{ + boolean Connect(); + oneway void Start() ; + oneway void ReStart() ; +} ; +# endif diff --git a/idl/TypeData.idl b/idl/TypeData.idl new file mode 100644 index 000000000..d4f20adea --- /dev/null +++ b/idl/TypeData.idl @@ -0,0 +1,21 @@ +#ifndef _SALOME_TYPEDATA_IDL_ +#define _SALOME_TYPEDATA_IDL_ + +module Engines +{ + + typedef sequence DoubleVec ; + typedef sequence IntVec; + + typedef struct CSR { + unsigned long nbpos; + unsigned long nbval; + IntVec pos; + IntVec col; + DoubleVec data; + } CSRMatStruct; + +} ; + +#endif + diff --git a/resources/Application-About.png b/resources/Application-About.png new file mode 100644 index 000000000..4ab6ecba5 Binary files /dev/null and b/resources/Application-About.png differ diff --git a/resources/Application-Logo.png b/resources/Application-Logo.png new file mode 100644 index 000000000..8781eff05 Binary files /dev/null and b/resources/Application-Logo.png differ diff --git a/resources/Application-Splash.png b/resources/Application-Splash.png new file mode 100644 index 000000000..5c3d74767 Binary files /dev/null and b/resources/Application-Splash.png differ diff --git a/resources/CatalogDataType.xml b/resources/CatalogDataType.xml new file mode 100644 index 000000000..c7d9cded4 --- /dev/null +++ b/resources/CatalogDataType.xml @@ -0,0 +1,121 @@ + + + + + + + Matrice + Matrice + read_matrice + write_matrice + + + + Vector + Vecteur + read_vector + write_vector + + + + MatriceCarree + Matrice carrée + read_matrice_carree + write_matrice_carree + + Matrice + + + + + MatriceStockagePlein + Matrice stockage plein + read_matrice_sp + write_matrice_sp + + Matrice + + + + + MatriceCarreeStockagePlein + Matrice carree stockage plein + read_matrice_carree_sp + write_matrice_carree_sp + + MatriceCarree + MatriceStockagePlein + + + + + MatriceTriangleStockageU + Matrice triangle stockage U + read_matrice_triangle_U + write_matrice_triangle_U + + MatriceCarree + + + + + MatriceTriangleStockageL + Matrice triangle stockage L + read_matrice_triangle_L + write_matrice_triangle_L + + MatriceCarree + + + + + MatriceSDP + Matrice SDP + read_matrice_sdp + write_matrice_sdp + + MatriceCarree + + + + + MatriceSDPStockagePlein + Matrice SDP stockage plein + read_matrice_sdp_sp + write_matrice_sdp_sp + + MatriceSDP + MatriceStockagePlein + + + + + MatriceSDPStockageU + Matrice SDP stockage U + read_matrice_sdp_U + write_matrice_sdp_U + + MatriceTriangleStockageU + MatriceSDP + + + + + DataDiodore + Data generees pour Diodore + read_DataDiodore + write_DataDiodore + + + + MatriceSDPStockageL + Matrice SDP stockage L + read_matrice_sdp_L + write_matrice_sdp_L + + MatriceTriangleStockageL + MatriceSDP + + + + diff --git a/resources/CatalogModuleGeneral.xml b/resources/CatalogModuleGeneral.xml new file mode 100644 index 000000000..66f2d6776 --- /dev/null +++ b/resources/CatalogModuleGeneral.xml @@ -0,0 +1,1815 @@ + + + + + + + + + + + + + + + Salome + Other + NRI + 1.0 + GUI Neutral Context + 1 + + hostname = muna + + + + Geometry + Geom + NRI + 1.0 + Geom component - Open CASCADE + 1 + ModuleGeom.png + + + + + Geometry + No comment + + + + + InitGeomEngine + + + + 1 + + + long + StudyID + + + + + + Engines::GEOM_Gen + geomEngine + + + + + + MakeAxisStruct + + + + 1 + + + double + x + + + + double + y + + + + double + z + + + + double + vx + + + + double + vy + + + + double + vz + + + + + + AxisStruct + axis + + + + + + MakePointStruct + + + + 1 + + + double + x + + + + double + y + + + + double + z + + + + + + PointStruct + point + + + + + + + MakeBox + NRI + 1.0 + test XML + 1 + + + + double + x1 + X coordinate + + + double + y1 + Y coordinate + + + double + z1 + Z coordinate + + + double + x2 + X coordinate + + + double + y2 + Y coordinate + + + double + z2 + Z coordinate + + + + + GEOM_Shape + shape + boite + + + + + + MakeSphere + NRI + 1.0 + test XML + 1 + + + + double + x1 + X coordinate + + + double + y1 + Y coordinate + + + double + z1 + Z coordinate + + + double + radius + Sphere Radius + + + + + GEOM_Shape + shape + sphere + + + + + + MakeTranslation + NRI + 1.0 + test XML + 1 + + + + GEOM_Shape + shape1 + Shape + + + double + x1 + .. + + + double + y1 + .. + + + double + z1 + .. + + + + + GEOM_Shape + shape + Result + + + + + + MakeCopy + NRI + 1.0 + test XML + 1 + + + + GEOM_Shape + shape1 + Shape + + + + + GEOM_Shape + shape + Result + + + + + + MakeBoolean + NRI + 1.0 + test XML + 1 + + + + GEOM_Shape + shape1 + Shape + + + GEOM_Shape + shape2 + Tools + + + long + operation + Operation Type + + + + + GEOM_Shape + shape + Result + + + + + + MakeFuse + NRI + 1.0 + test XML + 1 + + + + GEOM_Shape + shape1 + Shape + + + GEOM_Shape + shape2 + Tools + + + + + GEOM_Shape + shape + Result + + + + + + hostname = localhost + + + + SMESH + Mesh + NRI + 1.0 + New Mesh component + 1 + ModuleMesh.png + + + SMESH + + + + CreateHypothesis + + + + 1 + + + string + anHyp + + + + long + studyId + + + + + + SMESH_Hypothesis + aHyp + + + + + + Init + + + + 1 + + + GEOM_Gen + geomEngine + + + + long + studyId + + + + GEOM_Shape + aShape + + + + + + SMESH_Mesh + aMesh + + + + + + Compute + + + + 1 + + + SMESH_Mesh + aMesh + + + + GEOM_Shape + aSubShape + + + + + + boolean + res + Result + + + + + IsReadyToCompute + + + + 1 + + + SMESH_Mesh + aMesh + + + + GEOM_Shape + aSubShape + + + + + boolean + res + Result + + + + SMESH_Mesh + + + + AddHypothesis + + + + 1 + + + GEOM_Shape + aSubShape + + + + SMESH_Hypothesis + aHyp + + + + + + boolean + res + Result + + + + + + hostname = localhost + + + + Visu + VISU + NRI + 1.0 + Visu component - Maquette septembre + 1 + ModuleVisu.png + hostname = localhost + + + + Supervision + Supervision + ARS + 1.0 + Supervision control GUI + 1 + ModuleSupervision.png + hostname = localhost + + SuperG + SupervisionEngine + + + + + Med + Mesh + Patrick GOLDBRONN + 1.0 + MED memoire + 1 + ModuleMed.png + + + + + MED + No comment + + + + + + + + + + + AddComponent + SuperVisionTest + MTJ + 1.0 + Test SuperVision SALOME/src/SALOME_SWIG/supervisionexample[1].py + 0 + + + AddComponent + + ... + + + + + Addition + MTJ + 1.0 + Floating add + 1 + + + + + + Adder + Adder + Adder object + + + + + + Add + MTJ + 1.0 + Floating add + 1 + + + + double + x + First number + + + double + y + Second number + + + + + double + FuncValue + Substract result + + + double + z + Addition result + + + + + Adder + + ... + + + + + Add + MTJ + 1.0 + Floating add + 1 + + + + Adder + Adder + Adder Object + + + double + x + First number + + + double + y + Second number + + + + + double + FuncValue + Substract result + + + double + z + Addition result + + + + + + AddAndCompare + MTJ + 1.0 + Floating add + 1 + + + + Adder + Adder + Adder Object + + + double + x + First number + + + double + y + Second number + + + Adder + anOtherAdder + Adder Object + + + + + double + FuncValue + Substract result + + + double + z + Addition result + + + + + + SetLastResult + MTJ + 1.0 + set the last result field + 1 + + + + Adder + Adder + Adder Object + + + double + z + number + + + + + + + + LastResult + MTJ + 1.0 + get the last result field + 1 + + + + Adder + Adder + Adder Object + + + + + double + z + number + + + + + + + + + + SubComponent + SuperVisionTest + MTJ + 1.0 + Test SuperVision SALOME/src/SALOME_SWIG/supervisionexample[1].py + 0 + + + SubComponent + - ... + + + + + Sub + MTJ + 1.0 + Floating substract + 1 + + + + double + x + First number + + + double + y + Second number + + + + + double + z + Substraction result + + + + + + + + + + MulComponent + SuperVisionTest + MTJ + 1.0 + Test SuperVision SALOME/src/SALOME_SWIG/supervisionexample[1].py + 0 + + + MulComponent + * ... + + + + + Mul + MTJ + 1.0 + Float multiply + 1 + + + + double + x + First number + + + double + y + Second number + + + + + double + z + Multiplication result + + + + + + + + + + DivComponent + SuperVisionTest + MTJ + 1.0 + Test SuperVision SALOME/src/SALOME_SWIG/supervisionexample[1].py + 0 + + + DivComponent + / ... + + + + + Div + MTJ + 1.0 + Floating divide + 1 + + + + double + x + First number + + + double + y + Second number + + + + + double + z + Division result + + + + + + + + + SyrComponent + SuperVisionTest + JR + + SuperVisionTest + 1 + + + + SyrComponent + + + + C_ISEVEN + + + + 0 + + + long + anInteger + + + + + + long + BoolEven + + + + + + C_ISONE + + + + 0 + + + long + anInteger + + + + + + long + BoolOne + + + + + + C_M3 + + + + 0 + + + long + anOddInteger + + + + + + long + anInteger + + + + + + C_M3P1 + + + + 0 + + + long + anOddInteger + + + + + + long + anEvenInteger + + + + + + C_DIV2 + + + + 0 + + + long + anEvenInteger + + + + + + long + anInteger + + + + + + C_INCR + + + + 0 + + + long + aCount + + + + + + long + aNewCount + + + + + + C_MIN + + + + 0 + + + long + aMinVal + + + + long + anInteger + + + + + + long + aNewMinVal + + + + + + C_MAX + + + + 0 + + + long + aMaxVal + + + + long + anInteger + + + + + + long + aNewMaxVal + + + + + + C_LISTOFSYR + + + + 0 + + + + + ListOfSyr + aListOfSyr + + + + + + C_AVERAGE + + + + 0 + + + ListOfSyr + aListOfSyr + + + + long + anInteger + + + + long + aCount + + + + + + ListOfSyr + aNewListOfSyr + + + + double + anAverage + + + + + + Init + + + + 0 + + + long + anOddInteger + + + + + + Syr + aSyracuse + + + + + + Syr + + + + Count + + + + 0 + + + Syr + aSyracuse + + + + + + long + aCount + + + + + + Current + + + + 0 + + + Syr + aSyracuse + + + + + + long + aCurrent + + + + + + IsEven + + + + 0 + + + Syr + aSyracuse + + + + + + long + BoolEven + + + + + + IsOne + + + + 0 + + + Syr + aSyracuse + + + + + + long + BoolOne + + + + + + M3p1 + + + + 0 + + + Syr + aSyracuse + + + + + + + + Div2 + + + + 0 + + + Syr + aSyracuse + + + + + + + + Incr + + + + 0 + + + Syr + aSyracuse + + + + + + + + + + + + + FactorialComponent + SuperVisionTest + Malvagi, Tajchman + 1.0 + Factorial + 0 + + + FactorialComponent + No comment + + + + + eval + MT-FM + 1.0 + Factorial + 1 + + + + long + n + + + + + + long + f + result + + + + + + + + + SyrControlComponent + SuperVisionTest + JR + + SuperVisionTest + 1 + + + + SyrControlComponent + + + + L_OneEven + + + + 0 + + + long + ValOne + + + + long + ValEven + + + + + + long + Finished + + + + long + Incr + + + + long + Even + + + + long + Odd + + + + + + C_NotOneIsEven + + + + 0 + + + + long + ValOne + + + + long + ValEven + + + + + + LOOPN + + + + 0 + + + long + InLoop + + + + long + NN + + + + long + KK + + + + long + min + + + + long + max + + + + + + long + OutLoop + + + + long + N + + + + long + K + + + + + + WHILENOTONE + + + + 0 + + + long + N + + + + + + long + OutLoop + + + + + + IFNOTEVEN + + + + 0 + + + long + N + + + + + + long + Odd + + + + long + Even + + + + + + LOOPi + + + + 0 + + + long + InLoop + + + + long + ii + + + + + + long + OutLoop + + + + long + i + + + + + + WHILEEVEN + + + + 0 + + + long + N + + + + + + long + OutLoop + + + + + + + + + + + Calculator + SOLVER + LD + 1.0 + Test component (Arithmetic operations with MED_Field) - SALOME component + 0 + hostname = localhost + + + Calculator + No comment + + + + + Mul + LD + 1.0 + Multiplication of 2 fields of double + 1 + + + + FIELDDOUBLE + field1 + initial field of double + + + double + x1 + multiplicator + + + + + FIELDDOUBLE + return + result + + + + + + Add + LD + 1.0 + Addition of 2 fields of double + 1 + + + + FIELDDOUBLE + field1 + first field of double + + + FIELDDOUBLE + field2 + second field of double + + + + + FIELDDOUBLE + return + result + + + + + + Constant + LD + 1.0 + Build a constant field of doubles + 1 + + + + FIELDDOUBLE + field1 + allows to build the support + + + double + x1 + the constant + + + + + FIELDDOUBLE + return + result based on first field support + + + + + + writeMEDfile + LD + 1.0 + write a field in a Med file + 1 + + + + FIELDDOUBLE + field1 + transient Med field + + + string + filename + Med filename + + + + + + + + + CalculatorPy + SOLVER + NB + 1.0 + Test component (Arithmetic operations with MED_Field) - SALOME component + 0 + hostname = localhost + + + CalculatorPy + No comment + + + + + Mul + NB + 1.0 + Multiplication of 2 fields of double + 1 + + + + FIELDDOUBLE + field1 + initial field of double + + + double + x1 + multiplicator + + + + + FIELDDOUBLE + return + result + + + + + + Add + NB + 1.0 + Addition of 2 fields of double + 1 + + + + FIELDDOUBLE + field1 + first field of double + + + FIELDDOUBLE + field2 + second field of double + + + + + FIELDDOUBLE + return + result + + + + + + Constant + NB + 1.0 + Build a constant field of doubles + 1 + + + + FIELDDOUBLE + field1 + allows to build the support + + + double + x1 + the constant + + + + + FIELDDOUBLE + return + result based on first field support + + + + + + writeMEDfile + NB + 1.0 + write a field in a Med file + 1 + + + + FIELDDOUBLE + field1 + transient Med field + + + string + filename + Med filename + + + + + + + + diff --git a/resources/CatalogModulePersonnel.xml_skel b/resources/CatalogModulePersonnel.xml_skel new file mode 100644 index 000000000..b5a892ba0 --- /dev/null +++ b/resources/CatalogModulePersonnel.xml_skel @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/CatalogRessources.xml b/resources/CatalogRessources.xml new file mode 100644 index 000000000..2200b4171 --- /dev/null +++ b/resources/CatalogRessources.xml @@ -0,0 +1,43 @@ + + + eri + Linux + 2.2.14-6.1.1smp + + + 0 + Pentium III (Coppermine) + 860.946775 + 256 + + + 1 + Pentium III (Coppermine) + 860.946775 + 256 + + + + C++ + python + NP + + + + omote + Linux + 2.4.3-12smp + + + 0 + Pentium II (Deschutes) + 398.780 + 512 + + + + C++ + python + + + diff --git a/resources/Plugin b/resources/Plugin new file mode 100644 index 000000000..82126243f --- /dev/null +++ b/resources/Plugin @@ -0,0 +1,10 @@ +! Description of available plugins +! ******************************** +! +a148e300-5740-11d1-a904-080036aaa103.Location: FWOSPlugin +! +! standard attribute drivers plugin +! +ad696000-5b34-11d1-b5ba-00a0c9064368.Location: PAppStdPlugin +ad696001-5b34-11d1-b5ba-00a0c9064368.Location: PAppStdPlugin +ad696002-5b34-11d1-b5ba-00a0c9064368.Location: PAppStdPlugin diff --git a/resources/SALOMEDS_Resources b/resources/SALOMEDS_Resources new file mode 100644 index 000000000..8aec5d87d --- /dev/null +++ b/resources/SALOMEDS_Resources @@ -0,0 +1,10 @@ +formatlist:SALOME_STUDY + +SALOME_STUDY.Description: Stars Document Version 1.0 +SALOME_STUDY.FileExtension: std +SALOME_STUDY.StoragePlugin: ad696000-5b34-11d1-b5ba-00a0c9064368 +SALOME_STUDY.RetrievalPlugin: ad696001-5b34-11d1-b5ba-00a0c9064368 +SALOME_STUDY-StandardSchema: ad696002-5b34-11d1-b5ba-00a0c9064368 +SALOME_STUDY-Standard.AttributeStoragePlugin: 47b0b826-d931-11d1-b5da-00a0c9064368 +SALOME_STUDY-Standard.AttributeRetrievalPlugin: 47b0b827-d931-11d1-b5da-00a0c9064368 + diff --git a/resources/Tools_en.xml b/resources/Tools_en.xml new file mode 100644 index 000000000..7457ddc90 --- /dev/null +++ b/resources/Tools_en.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + diff --git a/resources/Tools_fr.xml b/resources/Tools_fr.xml new file mode 100644 index 000000000..7457ddc90 --- /dev/null +++ b/resources/Tools_fr.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + diff --git a/resources/back.xpm b/resources/back.xpm new file mode 100644 index 000000000..7dc5b72cb --- /dev/null +++ b/resources/back.xpm @@ -0,0 +1,27 @@ +/* XPM */ +/* Drawn by Mark Donohoe for the K Desktop Environment */ +/* See http://www.kde.org */ +static char*back[]={ +"16 16 5 1", +"# c #000000", +"a c #ffffff", +"c c #808080", +"b c #c0c0c0", +". c None", +"................", +".......#........", +"......##........", +".....#a#........", +"....#aa########.", +"...#aabaaaaaaa#.", +"..#aabbbbbbbbb#.", +"...#abbbbbbbbb#.", +"...c#ab########.", +"....c#a#ccccccc.", +".....c##c.......", +"......c#c.......", +".......cc.......", +"........c.......", +"................", +"......................"}; + diff --git a/resources/cascade.png b/resources/cascade.png new file mode 100644 index 000000000..9cd171538 Binary files /dev/null and b/resources/cascade.png differ diff --git a/resources/channel.cfg b/resources/channel.cfg new file mode 100755 index 000000000..afe59a75c --- /dev/null +++ b/resources/channel.cfg @@ -0,0 +1,278 @@ +# ================================================================= +# PARAM SETTINGS +# +# ** standard.cfg : +# sets up the daemon with default params as given +# in the CosNotification specification. +# +# ** channel.cfg : +# sets up daemon with default params which we prefer. +# +# You can choose which one to use, or copy one and edit it +# to suit your needs. +# +# There are only a couple of differences: +# +# standard.cfg channel.cfg +# +# PacingInterval 0 1000 (1 second) +# MaximumBatchSize 1 8 +# + +# ================================================================= +# omniNotify Configuration (Startup) Properties +# +# You can modify startup properties in one of 3 ways +# +# 1. copy this file to create your own .cfg file and edit it. Use +# promp> notifd -i -c myconfig.cfg +# to start notifd using the config file myconfig.cfg +# +# 2. set an environment variable; this will override any +# config file settings. e.g., for tcsh, +# promp> setenv LocalClockTDF 0 +# promp> notifd -i -c channel.cfg +# This uses channel.cfg but changes the time zone to GMT +# +# 3. use explicit command-line param definitions +# these override both the config file and any env variable settings +# promp> setenv LocalClockTDF 0 +# promp> notifd -i -c channel.cfg -DLocalClockTDF=-60 +# This would set the time zone to 1 hour earlier than GMT +# +# omniNotify manages 3 kinds of properties +# +# * ServerQOS properties are properties that all channels share; +# they cannot be changed on a per-channel basis. +# +# * AdminQoS properties are properties that can only be +# set at the channel factory / channel level. +# +# * NotifQoS properties are properties that can be set at +# many levels: channel factory, channel, admin, proxy; +# some of these can also be changed on a per-event basis. +# +# The channel factory's AdminQoS and NotifQoS property settings +# are used as defaults: when creating a channel these property +# values are used unless specific overrides are provided in +# with the channel creation request. Once a channel is created, +# its AdminQoS and NotifQoS properties can be modified; the +# factory's properties can also be modified. Note that once a +# channel is created, its properties are independent of the +# factory -- modifications to the channel properties do not affect +# the factory defaults, and modifications to the factory defaults +# do not affect the properties of already-created channels. +# +# The settings specified in config files, environment +# variables and/or command line param definitions are used to +# set the initial values for the server's ServerQoS properties and +# for the channel factory's AdminQoS and NotifQoS +# default properties. Since the default channel is created on startup, +# it also takes its AdminQoS and NotifQoS properties from +# these initial settings. +# +#================================================================== + +#================================================================== +# Misc Startup Properties +# -- these are essentially ServerQoS properties, +# but are not currently implemented that way +#================================================================== + +# Names to be assigned to the channel factory and channel created by +# the notifd channel daemon + +ChannelFactoryName ChannelFactory +DefaultChannelName EventChannel + +# Path names of the files used to store the string representation of +# the above channel factory IOR and channel object IOR + +FactoryIORFileName /tmp/rdifact.ior +ChannelIORFileName /tmp/rdichan.ior + +# If a file path is given for the following parameter, the file is +# used for storing debugging information. 'stderr' and 'stdout' can be +# used to direct output to standard error / standard output. + +#DebugLogFile ./debug.log +DebugLogFile stderr + +# If a file path is given for the following parameter, the file is +# used for storing report information. 'stderr' and 'stdout' can be +# used to direct output to standard error / standard output. + +#ReportLogFile ./report.log +ReportLogFile stdout + +# debug flags -- 0 is "off", 1 is "on" +DebugDaemon 0 +DebugChannelFactory 0 +DebugFilter 0 +DebugChannel 0 +DebugConsumerAdmin 0 +DebugSupplireAdmin 0 +DebugConsumerProxy 0 +DebugSupplierProxy 0 +DebugEventQueue 0 +DebugRDIEvent 0 +DebugFilterAdmin 0 +DebugFilterEval 0 +DebugCosConsumerProxies 0 +DebugCosSupplierProxies 0 +DebugNotifQoS 0 +DebugAdminQoS 0 +DebugNotifQueue 0 + +# report flags -- 0 is "off", 1 is "on" +ReportChannelStats 1 +ReportQueueSizeStats 1 +ReportConnectedConsumers 1 +ReportConnectedSuppliers 1 +ReportConnectedFilters 1 +ReportUnconnectedFilters 1 +ReportEventRejections 1 +ReportEventDrops 1 +ReportNotifQoS 1 +ReportAdminQoS 1 +ReportServerQoS 1 + +#================================================================== +# Initial ServerQoS Properties +#================================================================== + +# Each ConsumerAdmin and SupplierAdmin object is assigned to a group +# and each group is processed by only one thread. The number of such +# groups and the number of threads that handle the groups have to be +# at least 1. In addition, the number of threads should not exceed +# the number of groups + +NumAdminGroups 2 +NumAdminThreads 2 + +# notifd may split the filter evaluation processing in two stages. In +# this case, a second thread pool is used for evaluating proxy-level +# filters. The size of the pool is controled by the following + +NumProxyThreads 0 + +# The following variables control the number of threads created for +# pushing matched events to push-style consumers and pulling events +# from pull-style suppliers. If these values are 0, each consumer +# and supplier is assigned its own thread. + +NumPushThreads 4 +NumPullThreads 2 + +# The following variables control the number of threads created for +# notifying suppliers of subscription changes (using subscription_change) +# and for notifying consumers of offer changes (using offer_change). +# CAREFUL: Setting NumSChangeThreads to zero DISABLES +# the sending of subscription_change messages! +# CAREFUL: Setting NumOChangeThreads to zero DISABLES +# the sending of offer_change messages + +NumOChangeThreads 1 +NumSChangeThreads 1 + +# For pull style suppliers, the time period (milliseconds) between +# pulls is controlled by the following variable. +# A value of 0 corresponds to continuous pulling + +PullEventPeriod 100 + +# Period in seconds used by the garbage collector of the event queue +# The minimum number that can be used is 1 + +QueueGCPeriod 300 + +# The next entry specifies the time period (in seconds) between +# each 'report' (the Report.. flags above control what gets reported). +# The channel may have a built-in minimum, e.g, even if you say 0, +# the channel may choose a 10 second period. (300 seconds = 5 mins) + +ReportingInterval 300 + +# Description of local clock values returned from omnithread::get_time. +# These values are here because we do not know a portable way to get +# the clock accuracy and the time zone across all Unix flavors and +# Windows. Let us know if you have a portable approach. +# +# LocalClockInaccLo/Hi: local clock inaccuracy in units of 100ns +# (must fit in 48 bits, 32 for Lo, 16 for Hi) +# LocalClockTDF: local time zone expressed in minutes west of +# greenwhich meridian; 300=Eastern time zone, USA +LocalClockInaccLo 0 +LocalClockInaccHi 0 +LocalClockTDF 300 + +#================================================================== +# Initial Default AdminQoS Properties +#================================================================== + +# Maximum number of events that will be queued by the Channel before +# before it begins discarding events or rejecting new ones. A value +# of 0 does not place any upper limit. + +MaxQueueLength 0 + +# The maximum number of Consumers that can be connected to a Channel +# at any given time. A value of 0 does not place any upper limit. + +MaxConsumers 0 + +# The maximum number of Suppliers that can be connected to a Channel +# at any given time. A value of 0 does not place any upper limit. + +MaxSuppliers 0 + +# If 1, newly announced events will be discarded when the number of +# undelivered events in a Channel is equal to 'MaxQueueLength'. If +# 0, newly announced events cause existing events to be discarded +# according to the 'DiscardPolicy' QoS. + +RejectNewEvents 1 + +#================================================================== +# Initial Default NotifQoS Properties +#================================================================== + +# EventReliability and ConnectionReliability can take the values: +# 0 --> CosNotification::BestEffort +# 1 --> CosNotification::Persistent +# OrderPolicy can take the values: +# 0 --> CosNotification::AnyOrder +# 1 --> CosNotification::FifoOrder +# 2 --> CosNotification::PriorityOrder +# 3 --> CosNotification::DeadlineOrder +# DiscardPolicy can take any of the above values and, in addition, +# 4 --> CosNotification::LifoOrder +# StartTimeSupported and StopTimeSupported are boolean and can take +# the values +# 0 --> FALSE +# 1 --> TRUE +# +# NOTE: the current notifd implementation does NOT support all QoS +# settings. In particular, it only supports the following: +# EventReliability 0 +# ConnectionReliability 0 +# StartTimeSupported 0 +# StopTimeSupported 0 + +# Note -- PacingInterval can be set programmatically to any +# TimeBase::TimeT value (units = 100s of nanoseconds). Here you +# set number of MILLISECONDS, e.g., a value of 1000 means send a batch +# roughly every 1 second (or when MaxBatchSize is reached). + +EventReliability 0 +ConnectionReliability 0 +Priority 0 +Timeout 0 +StartTimeSupported 0 +StopTimeSupported 0 +OrderPolicy 0 +DiscardPolicy 0 +PacingInterval 1000 +MaxEventsPerConsumer 0 +MaximumBatchSize 8 + diff --git a/resources/close.png b/resources/close.png new file mode 100644 index 000000000..b7126e002 Binary files /dev/null and b/resources/close.png differ diff --git a/resources/config b/resources/config new file mode 100644 index 000000000..692539760 --- /dev/null +++ b/resources/config @@ -0,0 +1 @@ +language=en \ No newline at end of file diff --git a/resources/copy.png b/resources/copy.png new file mode 100644 index 000000000..1ba2eca28 Binary files /dev/null and b/resources/copy.png differ diff --git a/resources/default.png b/resources/default.png new file mode 100644 index 000000000..fdc199ae1 Binary files /dev/null and b/resources/default.png differ diff --git a/resources/dl_delete.png b/resources/dl_delete.png new file mode 100644 index 000000000..a7a0ad8f9 Binary files /dev/null and b/resources/dl_delete.png differ diff --git a/resources/dl_insert.png b/resources/dl_insert.png new file mode 100644 index 000000000..54e108a88 Binary files /dev/null and b/resources/dl_insert.png differ diff --git a/resources/dl_movedown.png b/resources/dl_movedown.png new file mode 100644 index 000000000..9c872192d Binary files /dev/null and b/resources/dl_movedown.png differ diff --git a/resources/dl_moveup.png b/resources/dl_moveup.png new file mode 100644 index 000000000..45b275007 Binary files /dev/null and b/resources/dl_moveup.png differ diff --git a/resources/forward.xpm b/resources/forward.xpm new file mode 100644 index 000000000..2ed813482 --- /dev/null +++ b/resources/forward.xpm @@ -0,0 +1,28 @@ +/* XPM */ +/* Drawn by Mark Donohoe for the K Desktop Environment */ +/* See http://www.kde.org */ +static char*forward[]={ +"16 16 5 1", +"# c #000000", +"a c #ffffff", +"c c #808080", +"b c #c0c0c0", +". c None", +"................", +"................", +".........#......", +".........##.....", +".........#a#....", +"..########aa#...", +"..#aaaaaaabaa#..", +"..#bbbbbbbbbaa#.", +"..#bbbbbbbbba#..", +"..########ba#c..", +"..ccccccc#a#c...", +"........c##c....", +"........c#c.....", +"........cc......", +"........c.......", +"................", +"................"}; + diff --git a/resources/help.png b/resources/help.png new file mode 100644 index 000000000..e57336285 Binary files /dev/null and b/resources/help.png differ diff --git a/resources/home.xpm b/resources/home.xpm new file mode 100644 index 000000000..9c1369d9f --- /dev/null +++ b/resources/home.xpm @@ -0,0 +1,27 @@ +/* XPM */ +/* Drawn by Mark Donohoe for the K Desktop Environment */ +/* See http://www.kde.org */ +static char*home[]={ +"16 16 4 1", +"# c #000000", +"a c #ffffff", +"b c #c0c0c0", +". c None", +"........... ....", +" ....##.......", +"..#...####......", +"..#..#aabb#.....", +"..#.#aaaabb#....", +"..##aaaaaabb#...", +"..#aaaaaaaabb#..", +".#aaaaaaaaabbb#.", +"###aaaaaaaabb###", +"..#aaaaaaaabb#..", +"..#aaa###aabb#..", +"..#aaa#.#aabb#..", +"..#aaa#.#aabb#..", +"..#aaa#.#aabb#..", +"..#aaa#.#aabb#..", +"..#####.######..", +"................"}; + diff --git a/resources/new.png b/resources/new.png new file mode 100644 index 000000000..953757a62 Binary files /dev/null and b/resources/new.png differ diff --git a/resources/open.png b/resources/open.png new file mode 100644 index 000000000..d9953b6a7 Binary files /dev/null and b/resources/open.png differ diff --git a/resources/paste.png b/resources/paste.png new file mode 100644 index 000000000..d86ece38b Binary files /dev/null and b/resources/paste.png differ diff --git a/resources/plot2d_dump.png b/resources/plot2d_dump.png new file mode 100644 index 000000000..e8bec70ca Binary files /dev/null and b/resources/plot2d_dump.png differ diff --git a/resources/plot2d_fitall.png b/resources/plot2d_fitall.png new file mode 100644 index 000000000..9a70952a1 Binary files /dev/null and b/resources/plot2d_fitall.png differ diff --git a/resources/plot2d_fitarea.png b/resources/plot2d_fitarea.png new file mode 100644 index 000000000..f54ae7783 Binary files /dev/null and b/resources/plot2d_fitarea.png differ diff --git a/resources/plot2d_legend.png b/resources/plot2d_legend.png new file mode 100644 index 000000000..cdcc1e0d8 Binary files /dev/null and b/resources/plot2d_legend.png differ diff --git a/resources/plot2d_linear.png b/resources/plot2d_linear.png new file mode 100644 index 000000000..d79f21426 Binary files /dev/null and b/resources/plot2d_linear.png differ diff --git a/resources/plot2d_linear_y.png b/resources/plot2d_linear_y.png new file mode 100644 index 000000000..e396eac2e Binary files /dev/null and b/resources/plot2d_linear_y.png differ diff --git a/resources/plot2d_lines.png b/resources/plot2d_lines.png new file mode 100644 index 000000000..6baf57344 Binary files /dev/null and b/resources/plot2d_lines.png differ diff --git a/resources/plot2d_log.png b/resources/plot2d_log.png new file mode 100644 index 000000000..aecca8c13 Binary files /dev/null and b/resources/plot2d_log.png differ diff --git a/resources/plot2d_log_y.png b/resources/plot2d_log_y.png new file mode 100644 index 000000000..4e1e21147 Binary files /dev/null and b/resources/plot2d_log_y.png differ diff --git a/resources/plot2d_pan.png b/resources/plot2d_pan.png new file mode 100644 index 000000000..786d9cb3e Binary files /dev/null and b/resources/plot2d_pan.png differ diff --git a/resources/plot2d_points.png b/resources/plot2d_points.png new file mode 100644 index 000000000..4847c4e8b Binary files /dev/null and b/resources/plot2d_points.png differ diff --git a/resources/plot2d_settings.png b/resources/plot2d_settings.png new file mode 100644 index 000000000..d291da9dc Binary files /dev/null and b/resources/plot2d_settings.png differ diff --git a/resources/plot2d_splines.png b/resources/plot2d_splines.png new file mode 100644 index 000000000..c39d4321c Binary files /dev/null and b/resources/plot2d_splines.png differ diff --git a/resources/plot2d_zoom.png b/resources/plot2d_zoom.png new file mode 100644 index 000000000..35e185b06 Binary files /dev/null and b/resources/plot2d_zoom.png differ diff --git a/resources/print.png b/resources/print.png new file mode 100644 index 000000000..37ca7c24d Binary files /dev/null and b/resources/print.png differ diff --git a/resources/redo.png b/resources/redo.png new file mode 100644 index 000000000..ac72e5c27 Binary files /dev/null and b/resources/redo.png differ diff --git a/resources/reset.png b/resources/reset.png new file mode 100644 index 000000000..ccda81cb1 Binary files /dev/null and b/resources/reset.png differ diff --git a/resources/salomeCommonModel.spml b/resources/salomeCommonModel.spml new file mode 100644 index 000000000..09b4d901f --- /dev/null +++ b/resources/salomeCommonModel.spml @@ -0,0 +1,49 @@ +#definition of the model +salomeCommonModel = Model(id="salomeCommonModel") + +# Description of all intrinsic types +dataString = Intrinsic(id='Datastring', + modelOwner=salomeCommonModel, + relatedType='STRING') +identification = Intrinsic(id='Identification', + modelOwner=salomeCommonModel, + relatedType='STRING') +salomeRef = Intrinsic(id='SalomeRef', + modelOwner=salomeCommonModel, + relatedType='SALOME_OBJECT_REFERENCE') +dataReal = Intrinsic(id='Datareal', + modelOwner=salomeCommonModel, + relatedType='REAL') +dataInteger = Intrinsic(id='Datainteger', + modelOwner=salomeCommonModel, + relatedType='INTEGER') + +# Description of units. +units = Entity(id='Units', + modelOwner=salomeCommonModel, + stereotype='CONCRETE') +units_name = SimpleField(id='name', + relatedType=dataString, + definitionMode='FORCED', + stereotype='IDENTIFICATION', + uiInformation=AttributeUi(defaultLabel='Name', + defaultComment='Name of the unit', + reentrantMode='NOT_REENTRANT'), + datatype='PERSISTENT', + evaluationMode='NONE') +units_abreviation = SimpleField(id='abreviation', + relatedType=dataString, + definitionMode='FORCED', + stereotype='AGREGATION', + uiInformation=AttributeUi(defaultLabel='abreviation', + defaultComment='Abreviation', + reentrantMode='NOT_REENTRANT'), + datatype='PERSISTENT', + evaluationMode='NONE') + +units.fields = [units_name,units_abreviation] + +units.uiInformation = EntityUi(defaultLabel='Units definition', + defaultComment='Definition of units', + reentrantMode='REENTRANT') + diff --git a/resources/save.png b/resources/save.png new file mode 100644 index 000000000..330493fa2 Binary files /dev/null and b/resources/save.png differ diff --git a/resources/select1.png b/resources/select1.png new file mode 100644 index 000000000..a1a4ee1d5 Binary files /dev/null and b/resources/select1.png differ diff --git a/resources/tile.png b/resources/tile.png new file mode 100644 index 000000000..b3e6d7b5a Binary files /dev/null and b/resources/tile.png differ diff --git a/resources/uc_add.png b/resources/uc_add.png new file mode 100644 index 000000000..c36d70820 Binary files /dev/null and b/resources/uc_add.png differ diff --git a/resources/uc_clear.png b/resources/uc_clear.png new file mode 100644 index 000000000..8abb8917f Binary files /dev/null and b/resources/uc_clear.png differ diff --git a/resources/uc_current.png b/resources/uc_current.png new file mode 100644 index 000000000..1c1e61fe3 Binary files /dev/null and b/resources/uc_current.png differ diff --git a/resources/uc_del.png b/resources/uc_del.png new file mode 100644 index 000000000..ed6c97cee Binary files /dev/null and b/resources/uc_del.png differ diff --git a/resources/uc_new.png b/resources/uc_new.png new file mode 100644 index 000000000..ae849de92 Binary files /dev/null and b/resources/uc_new.png differ diff --git a/resources/undo.png b/resources/undo.png new file mode 100644 index 000000000..61b19777e Binary files /dev/null and b/resources/undo.png differ diff --git a/resources/view_back.png b/resources/view_back.png new file mode 100644 index 000000000..436f2da15 Binary files /dev/null and b/resources/view_back.png differ diff --git a/resources/view_bottom.png b/resources/view_bottom.png new file mode 100644 index 000000000..a18011c47 Binary files /dev/null and b/resources/view_bottom.png differ diff --git a/resources/view_camera_dump.png b/resources/view_camera_dump.png new file mode 100644 index 000000000..8eb63e09b Binary files /dev/null and b/resources/view_camera_dump.png differ diff --git a/resources/view_fitall.png b/resources/view_fitall.png new file mode 100644 index 000000000..c09ff94ad Binary files /dev/null and b/resources/view_fitall.png differ diff --git a/resources/view_fitarea.png b/resources/view_fitarea.png new file mode 100644 index 000000000..5b79594e7 Binary files /dev/null and b/resources/view_fitarea.png differ diff --git a/resources/view_front.png b/resources/view_front.png new file mode 100644 index 000000000..c5dfc00d5 Binary files /dev/null and b/resources/view_front.png differ diff --git a/resources/view_glpan.png b/resources/view_glpan.png new file mode 100644 index 000000000..c23322a4a Binary files /dev/null and b/resources/view_glpan.png differ diff --git a/resources/view_left.png b/resources/view_left.png new file mode 100644 index 000000000..dbc06cc6e Binary files /dev/null and b/resources/view_left.png differ diff --git a/resources/view_pan.png b/resources/view_pan.png new file mode 100644 index 000000000..038fba118 Binary files /dev/null and b/resources/view_pan.png differ diff --git a/resources/view_reset.png b/resources/view_reset.png new file mode 100644 index 000000000..12850643e Binary files /dev/null and b/resources/view_reset.png differ diff --git a/resources/view_right.png b/resources/view_right.png new file mode 100644 index 000000000..598def41d Binary files /dev/null and b/resources/view_right.png differ diff --git a/resources/view_rotate.png b/resources/view_rotate.png new file mode 100644 index 000000000..80926c545 Binary files /dev/null and b/resources/view_rotate.png differ diff --git a/resources/view_top.png b/resources/view_top.png new file mode 100644 index 000000000..ebbf34da5 Binary files /dev/null and b/resources/view_top.png differ diff --git a/resources/view_triedre.png b/resources/view_triedre.png new file mode 100644 index 000000000..3eed48db8 Binary files /dev/null and b/resources/view_triedre.png differ diff --git a/resources/view_zoom.png b/resources/view_zoom.png new file mode 100644 index 000000000..b46573914 Binary files /dev/null and b/resources/view_zoom.png differ diff --git a/salome_adm/unix/Doxyfile b/salome_adm/unix/Doxyfile new file mode 100644 index 000000000..82aa83c66 --- /dev/null +++ b/salome_adm/unix/Doxyfile @@ -0,0 +1,808 @@ +# Doxyfile 1.2.8.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# General configuration options +#--------------------------------------------------------------------------- + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Brazilian, Chinese, Croatian, Czech, Danish, Dutch, Finnish, French, +# German, Hungarian, Italian, Japanese, Korean, Norwegian, Polish, +# Portuguese, Romanian, Russian, Slovak, Slovene, Spanish and Swedish. + +OUTPUT_LANGUAGE = English + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = YES + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = YES + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these class will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. It is allowed to use relative paths in the argument list. + +STRIP_FROM_PATH = + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a class diagram (in Html and LaTeX) for classes with base or +# super classes. Setting the tag to NO turns the diagrams off. + +CLASS_DIAGRAMS = YES + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = YES + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower case letters. If set to YES upper case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# users are adviced to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like the Qt-style comments (thus requiring an +# explict @brief command for a brief description. + +JAVADOC_AUTOBRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# reimplements. + +INHERIT_DOCS = YES + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consist of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources +# only. Doxygen will then generate output that is more tailored for C. +# For instance some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. + +WARN_FORMAT = + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = /home01/prascle/devSalome/rootsrc + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +FILE_PATTERNS = *idl *.cxx *.hxx *.hh *.h *.c *.cc *.py + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. + +EXCLUDE_PATTERNS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. + +INPUT_FILTER = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse. + +FILTER_SOURCE_FILES = NO + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = /home01/prascle/devSalome/doc/html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet + +HTML_STYLESHEET = + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the Html help documentation and to the tree view. + +TOC_EXPAND = NO + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# This tag can be used to set the number of enum values (range [1..20]) +# that doxygen will group on one line in the generated HTML documentation. + +ENUM_VALUES_PER_LINE = 4 + +# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be +# generated containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript and frames is required (for instance Netscape 4.0+ +# or Internet explorer 4.0+). + +GENERATE_TREEVIEW = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = /home01/prascle/devSalome/doc/latex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, a4wide, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = NO + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = NO + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimised for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assigments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_PREDEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# in the INCLUDE_PATH (see below) will be search if a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_PREDEF_ONLY tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition. + +EXPAND_AS_DEFINED = + +#--------------------------------------------------------------------------- +# Configuration::addtions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES tag can be used to specify one or more tagfiles. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found on the path. + +DOT_PATH = + +# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_WIDTH = 1024 + +# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height +# (in pixels) of the graphs generated by dot. If a graph becomes larger than +# this value, doxygen will try to truncate the graph, so that it fits within +# the specified constraint. Beware that most browsers cannot cope with very +# large images. + +MAX_DOT_GRAPH_HEIGHT = 1024 + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermedate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + +#--------------------------------------------------------------------------- +# Configuration::addtions related to the search engine +#--------------------------------------------------------------------------- + +# The SEARCHENGINE tag specifies whether or not a search engine should be +# used. If set to NO the values of all tags below this one will be ignored. + +SEARCHENGINE = NO + +# The CGI_NAME tag should be the name of the CGI script that +# starts the search engine (doxysearch) with the correct parameters. +# A script with this name will be generated by doxygen. + +CGI_NAME = + +# The CGI_URL tag should be the absolute URL to the directory where the +# cgi binaries are located. See the documentation of your http daemon for +# details. + +CGI_URL = + +# The DOC_URL tag should be the absolute URL to the directory where the +# documentation is located. If left blank the absolute path to the +# documentation, with file:// prepended to it, will be used. + +DOC_URL = + +# The DOC_ABSPATH tag should be the absolute path to the directory where the +# documentation is located. If left blank the directory on the local machine +# will be used. + +DOC_ABSPATH = + +# The BIN_ABSPATH tag must point to the directory where the doxysearch binary +# is installed. + +BIN_ABSPATH = + +# The EXT_DOC_PATHS tag can be used to specify one or more paths to +# documentation generated for other projects. This allows doxysearch to search +# the documentation for these projects as well. + +EXT_DOC_PATHS = diff --git a/salome_adm/unix/F77config.h.in b/salome_adm/unix/F77config.h.in new file mode 100644 index 000000000..77b6c51f5 --- /dev/null +++ b/salome_adm/unix/F77config.h.in @@ -0,0 +1,8 @@ + +#ifndef F77_FUNC + +#define F77_FUNC(name,NAME) @F77_FUNC_NAME@ +#define F77_FUNC_(name,NAME) @F77_FUNC_NAME_@ + +#endif + diff --git a/salome_adm/unix/SALOMEconfig.h.in b/salome_adm/unix/SALOMEconfig.h.in new file mode 100644 index 000000000..0bf652556 --- /dev/null +++ b/salome_adm/unix/SALOMEconfig.h.in @@ -0,0 +1,6 @@ +#define DEBUG + +#define QUOTE(x) #x +#define CORBA_CLIENT_HEADER(x) QUOTE(x@IDL_CLN_H@) +#define CORBA_SERVER_HEADER(x) QUOTE(x@IDL_SRV_H@) + diff --git a/salome_adm/unix/config_files/ac_cc_warnings.m4 b/salome_adm/unix/config_files/ac_cc_warnings.m4 new file mode 100644 index 000000000..5de987e57 --- /dev/null +++ b/salome_adm/unix/config_files/ac_cc_warnings.m4 @@ -0,0 +1,104 @@ +dnl Synopsis +dnl +dnl AC_CC_WARNINGS([ANSI]) +dnl +dnl Version +dnl +dnl 1.1 (2000/12/31) +dnl +dnl Author +dnl +dnl Ville Laurikari +dnl +dnl Description +dnl +dnl Enables a reasonable set of warnings for the C compiler. +dnl Optionally, if the first argument is nonempty, turns on +dnl flags which enforce and/or enable proper ANSI C if such +dnl flags are known to the compiler used. +dnl +dnl Currently this macro knows about GCC, Solaris C compiler, +dnl Digital Unix C compiler, C for AIX Compiler, HP-UX C +dnl compiler, and IRIX C compiler. + +AC_DEFUN([AC_CC_WARNINGS], [ + ansi=$1 + if test -z "$ansi"; then + msg="for C compiler warning flags" + else + msg="for C compiler warning and ANSI conformance flags" + fi + AC_CACHE_CHECK($msg, ac_cv_prog_cc_warnings, [ + if test -n "$CC"; then + cat > conftest.c <&1 | grep "Xc.*strict ANSI C" > /dev/null 2>&1 && + $CC -c -v -Xc conftest.c > /dev/null 2>&1 && + test -f conftest.o; then + if test -z "$ansi"; then + ac_cv_prog_cc_warnings="-v" + else + ac_cv_prog_cc_warnings="-v -Xc" + fi + + dnl HP-UX C compiler + elif $CC > /dev/null 2>&1 && + $CC -c -Aa +w1 conftest.c > /dev/null 2>&1 && + test -f conftest.o; then + if test -z "$ansi"; then + ac_cv_prog_cc_warnings="+w1" + else + ac_cv_prog_cc_warnings="+w1 -Aa" + fi + + dnl Digital Unix C compiler + elif ! $CC > /dev/null 2>&1 && + $CC -c -verbose -w0 -warnprotos -std1 conftest.c > /dev/null 2>&1 && + test -f conftest.o; then + if test -z "$ansi"; then + ac_cv_prog_cc_warnings="-verbose -w0 -warnprotos" + else + ac_cv_prog_cc_warnings="-verbose -w0 -warnprotos -std1" + fi + + dnl C for AIX Compiler + elif $CC > /dev/null 2>&1 | grep AIX > /dev/null 2>&1 && + $CC -c -qlanglvl=ansi -qinfo=all conftest.c > /dev/null 2>&1 && + test -f conftest.o; then + if test -z "$ansi"; then + ac_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" + else + ac_cv_prog_cc_warnings="-qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd -qlanglvl=ansi" + fi + + dnl IRIX C compiler + elif $CC -fullwarn -ansi -ansiE > /dev/null 2>&1 && + test -f conftest.o; then + if test -z "$ansi"; then + ac_cv_prog_cc_warnings="-fullwarn" + else + ac_cv_prog_cc_warnings="-fullwarn -ansi -ansiE" + fi + + fi + rm -f conftest.* + fi + if test -n "$ac_cv_prog_cc_warnings"; then + CFLAGS="$CFLAGS $ac_cv_prog_cc_warnings" + CXXFLAGS="$CXXFLAGS $ac_cv_prog_cc_warnings" + else + ac_cv_prog_cc_warnings="unknown" + fi + ]) +]) \ No newline at end of file diff --git a/salome_adm/unix/config_files/ac_cxx_bool.m4 b/salome_adm/unix/config_files/ac_cxx_bool.m4 new file mode 100644 index 000000000..c17ac0b28 --- /dev/null +++ b/salome_adm/unix/config_files/ac_cxx_bool.m4 @@ -0,0 +1,27 @@ +dnl @synopsis AC_CXX_BOOL +dnl +dnl If the compiler recognizes bool as a separate built-in type, +dnl define HAVE_BOOL. Note that a typedef is not a separate +dnl type since you cannot overload a function such that it accepts either +dnl the basic type or the typedef. +dnl +dnl @version $Id$ +dnl @author Luc Maisonobe +dnl +AC_DEFUN(AC_CXX_BOOL, +[AC_CACHE_CHECK(whether the compiler recognizes bool as a built-in type, +ac_cv_cxx_bool, +[AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([ +int f(int x){return 1;} +int f(char x){return 1;} +int f(bool x){return 1;} +],[bool b = true; return f(b);], + ac_cv_cxx_bool=yes, ac_cv_cxx_bool=no) + AC_LANG_RESTORE +]) +if test "$ac_cv_cxx_bool" = yes; then + AC_DEFINE(HAVE_BOOL,,[define if bool is a built-in type]) +fi +]) diff --git a/salome_adm/unix/config_files/ac_cxx_depend_flag.m4 b/salome_adm/unix/config_files/ac_cxx_depend_flag.m4 new file mode 100644 index 000000000..4d8e06081 --- /dev/null +++ b/salome_adm/unix/config_files/ac_cxx_depend_flag.m4 @@ -0,0 +1,100 @@ +dnl @synopsis AC_C_DEPEND_FLAG +dnl +dnl define C_DEPEND_FLAG +dnl define CXX_DEPEND_FLAG +dnl +dnl @version $Id$ +dnl @author Marc Tajchman +dnl +AC_DEFUN(AC_DEPEND_FLAG, +[AC_CACHE_CHECK(which flag for dependency information generation, +ac_cv_depend_flag, +[AC_LANG_SAVE + AC_LANG_C + echo "conftest.o: conftest.c" > conftest.verif + echo "int main() { return 0; }" > conftest.c + + C_DEPEND_FLAG= + for ac_C_DEPEND_FLAG in -xM -MM -M ; do + + rm -f conftest.d conftest.err + ${CC-cc} ${ac_C_DEPEND_FLAG} -c conftest.c 1> conftest.d 2> conftest.err + if test -f conftest.u ; then + mv conftest.u conftest.d + fi + + rm -f conftest + diff -b -B conftest.d conftest.verif > conftest + if test ! -s conftest ; then + C_DEPEND_FLAG=${ac_C_DEPEND_FLAG} + break + fi + done + +dnl use gcc option -MG : asume unknown file will be construct later + rm -f conftest.d conftest.err + ${CC-cc} ${C_DEPEND_FLAG} -MG -c conftest.c 1> conftest.d 2> conftest.err + if test -f conftest.u ; then + mv conftest.u conftest.d + fi + rm -f conftest + diff -b -B conftest.d conftest.verif > conftest + if test ! -s conftest ; then + C_DEPEND_FLAG=${C_DEPEND_FLAG}" -MG" + fi + + rm -f conftest* + if test "x${C_DEPEND_FLAG}" = "x" ; then + echo "cannot determine flag (C language)" + exit + fi + + echo -n " C : " ${C_DEPEND_FLAG} + + AC_LANG_CPLUSPLUS + echo "conftest.o: conftest.cxx" > conftest.verif + echo "int main() { return 0; }" > conftest.cxx + + CXX_DEPEND_FLAG= + for ac_CXX_DEPEND_FLAG in -xM -MM -M ; do + + rm -f conftest.d conftest.err + ${CXX-c++} ${ac_CXX_DEPEND_FLAG} -c conftest.cxx 1> conftest.d 2> conftest.err + if test -f conftest.u ; then + mv conftest.u conftest.d + fi + + rm -f conftest + diff -b -B conftest.d conftest.verif > conftest + if test ! -s conftest ; then + CXX_DEPEND_FLAG=${ac_CXX_DEPEND_FLAG} + break + fi + done + +dnl use g++ option -MG : asume unknown file will be construct later + rm -f conftest.d conftest.err + ${CXX-c++} ${CXX_DEPEND_FLAG} -MG -c conftest.cxx 1> conftest.d 2> conftest.err + if test -f conftest.u ; then + mv conftest.u conftest.d + fi + rm -f conftest + diff -b -B conftest.d conftest.verif > conftest + if test ! -s conftest ; then + CXX_DEPEND_FLAG=${CXX_DEPEND_FLAG}" -MG" + fi + + + rm -f conftest* + if test "x${CXX_DEPEND_FLAG}" = "x" ; then + echo "cannot determine flag (C++ language)" + exit + fi + + echo -n " C++ : " ${CXX_DEPEND_FLAG} + AC_LANG_RESTORE + + AC_SUBST(C_DEPEND_FLAG) + AC_SUBST(CXX_DEPEND_FLAG) +]) +]) diff --git a/salome_adm/unix/config_files/ac_cxx_have_sstream.m4 b/salome_adm/unix/config_files/ac_cxx_have_sstream.m4 new file mode 100644 index 000000000..8ddbe5727 --- /dev/null +++ b/salome_adm/unix/config_files/ac_cxx_have_sstream.m4 @@ -0,0 +1,24 @@ +dnl @synopsis AC_CXX_HAVE_SSTREAM +dnl +dnl If the C++ library has a working stringstream, define HAVE_SSTREAM. +dnl +dnl @author Ben Stanley +dnl @version $Id$ +dnl +dnl modified by Marc Tajchman (CEA) - 10/10/2002 +dnl +AC_DEFUN([AC_CXX_HAVE_SSTREAM], +[AC_CACHE_CHECK(whether the compiler has stringstream, +HAVE_SSTREAM, +[AC_REQUIRE([AC_CXX_NAMESPACES]) + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([#include +#ifdef HAVE_NAMESPACES +using namespace std; +#endif],[stringstream message; message << "Hello"; return 0;], + HAVE_SSTREAM=yes, HAVE_SSTREAM=no) + AC_LANG_RESTORE +]) +AC_SUBST(HAVE_SSTREAM) +]) diff --git a/salome_adm/unix/config_files/ac_cxx_mutable.m4 b/salome_adm/unix/config_files/ac_cxx_mutable.m4 new file mode 100644 index 000000000..b0ce3c032 --- /dev/null +++ b/salome_adm/unix/config_files/ac_cxx_mutable.m4 @@ -0,0 +1,27 @@ +dnl @synopsis AC_CXX_MUTABLE +dnl +dnl If the compiler allows modifying class data members flagged with +dnl the mutable keyword even in const objects (for example in the +dnl body of a const member function), define HAVE_MUTABLE. +dnl +dnl @version $Id$ +dnl @author Luc Maisonobe +dnl +AC_DEFUN(AC_CXX_MUTABLE, +[AC_CACHE_CHECK(whether the compiler supports the mutable keyword, +ac_cv_cxx_mutable, +[AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([ +class A { mutable int i; + public: + int f (int n) const { i = n; return i; } + }; +],[A a; return a.f (1);], + ac_cv_cxx_mutable=yes, ac_cv_cxx_mutable=no) + AC_LANG_RESTORE +]) +if test "$ac_cv_cxx_mutable" = yes; then + AC_DEFINE(HAVE_MUTABLE,,[define if the compiler supports the mutable keyword]) +fi +]) diff --git a/salome_adm/unix/config_files/ac_cxx_namespaces.m4 b/salome_adm/unix/config_files/ac_cxx_namespaces.m4 new file mode 100644 index 000000000..ca26c7d30 --- /dev/null +++ b/salome_adm/unix/config_files/ac_cxx_namespaces.m4 @@ -0,0 +1,22 @@ +dnl @synopsis AC_CXX_NAMESPACES +dnl +dnl If the compiler can prevent names clashes using namespaces, define +dnl HAVE_NAMESPACES. +dnl +dnl @version $Id$ +dnl @author Luc Maisonobe +dnl +AC_DEFUN(AC_CXX_NAMESPACES, +[AC_CACHE_CHECK(whether the compiler implements namespaces, +ac_cv_cxx_namespaces, +[AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}], + [using namespace Outer::Inner; return i;], + ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no) + AC_LANG_RESTORE +]) +if test "$ac_cv_cxx_namespaces" = yes; then + AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces]) +fi +]) diff --git a/salome_adm/unix/config_files/ac_cxx_partial_specialization.m4 b/salome_adm/unix/config_files/ac_cxx_partial_specialization.m4 new file mode 100644 index 000000000..6711debc0 --- /dev/null +++ b/salome_adm/unix/config_files/ac_cxx_partial_specialization.m4 @@ -0,0 +1,26 @@ +dnl @synopsis AC_CXX_PARTIAL_SPECIALIZATION +dnl +dnl If the compiler supports partial specialization, +dnl define HAVE_PARTIAL_SPECIALIZATION. +dnl +dnl @version $Id$ +dnl @author Luc Maisonobe +dnl +AC_DEFUN(AC_CXX_PARTIAL_SPECIALIZATION, +[AC_CACHE_CHECK(whether the compiler supports partial specialization, +ac_cv_cxx_partial_specialization, +[AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([ +template class A { public : enum e { z = 0 }; }; +template class A { public : enum e { z = 1 }; }; +template class A { public : enum e { z = 2 }; }; +],[return (A::z == 0) && (A::z == 1) && (A::z == 2);], + ac_cv_cxx_partial_specialization=yes, ac_cv_cxx_partial_specialization=no) + AC_LANG_RESTORE +]) +if test "$ac_cv_cxx_partial_specialization" = yes; then + AC_DEFINE(HAVE_PARTIAL_SPECIALIZATION,, + [define if the compiler supports partial specialization]) +fi +]) diff --git a/salome_adm/unix/config_files/ac_cxx_typename.m4 b/salome_adm/unix/config_files/ac_cxx_typename.m4 new file mode 100644 index 000000000..8604c4374 --- /dev/null +++ b/salome_adm/unix/config_files/ac_cxx_typename.m4 @@ -0,0 +1,21 @@ +dnl @synopsis AC_CXX_TYPENAME +dnl +dnl If the compiler recognizes the typename keyword, define HAVE_TYPENAME. +dnl +dnl @version $Id$ +dnl @author Luc Maisonobe +dnl +AC_DEFUN(AC_CXX_TYPENAME, +[AC_CACHE_CHECK(whether the compiler recognizes typename, +ac_cv_cxx_typename, +[AC_LANG_SAVE + AC_LANG_CPLUSPLUS + AC_TRY_COMPILE([templateclass X {public:X(){}};], +[X z; return 0;], + ac_cv_cxx_typename=yes, ac_cv_cxx_typename=no) + AC_LANG_RESTORE +]) +if test "$ac_cv_cxx_typename" = yes; then + AC_DEFINE(HAVE_TYPENAME,,[define if the compiler recognizes typename]) +fi +]) diff --git a/salome_adm/unix/config_files/check_Salome.m4 b/salome_adm/unix/config_files/check_Salome.m4 new file mode 100644 index 000000000..3db8d66d5 --- /dev/null +++ b/salome_adm/unix/config_files/check_Salome.m4 @@ -0,0 +1,58 @@ +# Check availability of Salome binary distribution +# +# Author : Marc Tajchman (CEA, 2002) +# + +AC_DEFUN([CHECK_SALOME],[ + +AC_CHECKING(for Salome) + +Salome_ok=no + +AC_ARG_WITH(salome, + --with-salome=DIR root directory path of SALOME installation, + SALOME_DIR="$withval",SALOME_DIR="") + +if test "x$SALOME_DIR" == "x" ; then + +# no --with-salome-dir option used + + if test "x$SALOME_ROOT_DIR" != "x" ; then + + # SALOME_ROOT_DIR environment variable defined + SALOME_DIR=$SALOME_ROOT_DIR + + else + + # search Salome binaries in PATH variable + AC_PATH_PROG(TEMP, libMEDMEM_Swig.py) + if test "x$TEMP" != "x" ; then + SALOME_BIN_DIR=`dirname $TEMP` + SALOME_DIR=`dirname $SALOME_BIN_DIR` + fi + + fi +# +fi + +if test -f ${SALOME_DIR}/bin/libMEDMEM_Swig.py ; then + Salome_ok=yes + AC_MSG_RESULT(Using Salome distribution in ${SALOME_DIR}) + + if test "x$SALOME_ROOT_DIR" == "x" ; then + SALOME_ROOT_DIR=${SALOME_DIR} + fi + if test "x$SALOME_SITE_DIR" == "x" ; then + SALOME_SITE_DIR=${SALOME_ROOT_DIR} + fi + AC_SUBST(SALOME_ROOT_DIR) + AC_SUBST(SALOME_SITE_DIR) + +else + AC_MSG_WARN("Cannot find compiled Salome distribution") +fi + +AC_MSG_RESULT(for Salome: $Salome_ok) + +])dnl + diff --git a/salome_adm/unix/config_files/check_cas.m4 b/salome_adm/unix/config_files/check_cas.m4 new file mode 100644 index 000000000..a1efcefc7 --- /dev/null +++ b/salome_adm/unix/config_files/check_cas.m4 @@ -0,0 +1,107 @@ +AC_DEFUN([CHECK_CAS],[ +AC_REQUIRE([AC_PROG_CXX])dnl +AC_REQUIRE([AC_PROG_CXXCPP])dnl + +AC_CHECKING(for OpenCascade) + +AC_LANG_SAVE +AC_LANG_CPLUSPLUS + +AC_SUBST(CAS_CPPFLAGS) +AC_SUBST(CAS_CXXFLAGS) +AC_SUBST(CAS_LDFLAGS) + +CAS_CPPFLAGS="" +CAS_CXXFLAGS="" +CAS_LDFLAGS="" + +occ_ok=no + +dnl libraries directory location +case $host_os in + linux*) + casdir=Linux + ;; + freebsd*) + casdir=Linux + ;; + irix5.*) + casdir=Linux + ;; + irix6.*) + casdir=Linux + ;; + osf4.*) + casdir=Linux + ;; + solaris2.*) + casdir=Linux + ;; + *) + casdir=Linux + ;; +esac + +dnl were is OCC ? +if test -z $CASROOT; then + AC_MSG_WARN(You must provide CASROOT variable : see OCC installation manual) +else + occ_ok=yes +fi + +if test "x$occ_ok" = "xyes"; then + +dnl cascade headers + + CPPFLAGS_old="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -DLIN -DLINTEL -DCSFDB -DNO_CXX_EXCEPTION -DNo_exception -I$CASROOT/inc" + CXXFLAGS_old="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS -funsigned-char" + + AC_CHECK_HEADER(Standard_Type.hxx,occ_ok=yes ,occ_ok=no) + + CPPFLAGS="$CPPFLAGS_old" + CXXFLAGS="$CXXFLAGS_old" +fi + +if test "x$occ_ok" = xyes ; then + + CAS_CPPFLAGS="-DLIN -DLINTEL -DCSFDB -DNO_CXX_EXCEPTION -DNo_exception -I$CASROOT/inc" + CAS_CXXFLAGS="-funsigned-char" + + AC_MSG_CHECKING(for OpenCascade libraries) + + CPPFLAGS_old="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $CAS_CPPFLAGS" + CXXFLAGS_old="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $CAS_CXXFLAGS" + LIBS_old="$LIBS" + LIBS="$LIBS -L$CASROOT/$casdir/lib -lTKernel" + + AC_CACHE_VAL(salome_cv_lib_occ,[ + AC_TRY_LINK( +#include +, size_t size; + const Standard_CString aName="toto"; + Standard_Type myST(aName) ; + myST.Find(aName);, + eval "salome_cv_lib_occ=yes",eval "salome_cv_lib_occ=no") + ]) + occ_ok="$salome_cv_lib_occ" + + CPPFLAGS="$CPPFLAGS_old" + CXXFLAGS="$CXXFLAGS_old" + LIBS="$LIBS_old" +fi + +if test "x$occ_ok" = xno ; then + AC_MSG_RESULT(no) + AC_MSG_WARN(Opencascade libraries not found) +else + AC_MSG_RESULT(yes) + CAS_LDFLAGS="-L$CASROOT/$casdir/lib -lTKPAppStd -lTKFillet -lTKService -lFWOSPlugin -lTKG2d -lTKShHealing -lTKShHealingStd -lTKOpenGl -lTKG3d -lTKTopAlgo -lTKGeomAlgo -lTKV2d -lPAppStdPlugin -lTKGeomBase -lTKV3d -lPTKernel -lTKHLR -lTKVRML -lTKShapeSchema -lTKIGES -lTKXSBase -lTKStdSchema -lTKMath -lTKBRep -lTKOffset -lTKernel -lTKBool -lTKPCAF -lTKCAF -lTKPShape -lTKCDF -lTKPrim -lTKSTEP -lTKFeat -lTKSTL" +fi + +AC_LANG_RESTORE + +])dnl diff --git a/salome_adm/unix/config_files/check_corba.m4 b/salome_adm/unix/config_files/check_corba.m4 new file mode 100644 index 000000000..38112ed31 --- /dev/null +++ b/salome_adm/unix/config_files/check_corba.m4 @@ -0,0 +1,49 @@ +AC_DEFUN([CHECK_CORBA],[ + +if test x"$DEFAULT_ORB" = x"omniORB" +then + + # Contient le nom de l'ORB + ORB=omniorb + + AC_MSG_RESULT(default orb : omniORB) + IDL=$OMNIORB_IDL + AC_SUBST(IDL) + + CORBA_ROOT=$OMNIORB_ROOT + CORBA_INCLUDES=$OMNIORB_INCLUDES + CORBA_CXXFLAGS=$OMNIORB_CXXFLAGS + CORBA_LIBS=$OMNIORB_LIBS + IDLCXXFLAGS=$OMNIORB_IDLCXXFLAGS + IDLPYFLAGS=$OMNIORB_IDLPYFLAGS + + AC_SUBST(CORBA_ROOT) + AC_SUBST(CORBA_INCLUDES) + AC_SUBST(CORBA_CXXFLAGS) + AC_SUBST(CORBA_LIBS) + AC_SUBST(IDLCXXFLAGS) + AC_SUBST(IDLPYFLAGS) + + IDL_CLN_H=$OMNIORB_IDL_CLN_H + IDL_CLN_CXX=$OMNIORB_IDL_CLN_CXX + IDL_CLN_OBJ=$OMNIORB_IDL_CLN_OBJ + + AC_SUBST(IDL_CLN_H) + AC_SUBST(IDL_CLN_CXX) + AC_SUBST(IDL_CLN_OBJ) + + IDL_SRV_H=$OMNIORB_IDL_SRV_H + IDL_SRV_CXX=$OMNIORB_IDL_SRV_CXX + IDL_SRV_OBJ=$OMNIORB_IDL_SRV_OBJ + + AC_SUBST(IDL_SRV_H) + AC_SUBST(IDL_SRV_CXX) + AC_SUBST(IDL_SRV_OBJ) + +else + AC_MSG_RESULT($DEFAULT_ORB unknown orb) + +fi + +])dnl +dnl diff --git a/salome_adm/unix/config_files/check_f77.m4 b/salome_adm/unix/config_files/check_f77.m4 new file mode 100644 index 000000000..0509aa40a --- /dev/null +++ b/salome_adm/unix/config_files/check_f77.m4 @@ -0,0 +1,8 @@ +AC_DEFUN([CHECK_F77],[ + +AC_PROG_F77 + +AC_F77_LIBRARY_LDFLAGS +AC_F77_WRAPPERS + +])dnl diff --git a/salome_adm/unix/config_files/check_hdf5.m4 b/salome_adm/unix/config_files/check_hdf5.m4 new file mode 100644 index 000000000..2f2da10b5 --- /dev/null +++ b/salome_adm/unix/config_files/check_hdf5.m4 @@ -0,0 +1,63 @@ +AC_DEFUN([CHECK_HDF5],[ +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CPP])dnl + +AC_CHECKING(for HDF5) + +AC_ARG_WITH(hdf5, + [ --with-hdf5=DIR root directory path to hdf5 installation ], + [HDF5HOME="$withval" + AC_MSG_RESULT("select $withval as path to hdf5") + ]) + +AC_SUBST(HDF5_INCLUDES) +AC_SUBST(HDF5_LIBS) +AC_SUBST(HDF5_MT_LIBS) + +HDF5_INCLUDES="" +HDF5_LIBS="" +HDF5_MT_LIBS="" + +hdf5_ok=no + +LOCAL_INCLUDES="" +LOCAL_LIBS="" + +if test -z $HDF5HOME +then + AC_MSG_WARN(undefined HDF5HOME variable which specify hdf5 installation directory) +else + LOCAL_INCLUDES="-I$HDF5HOME/include" + LOCAL_LIBS="-L$HDF5HOME/lib" +fi + +dnl hdf5 headers + +CPPFLAGS_old="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES" +AC_CHECK_HEADER(hdf5.h,hdf5_ok=yes ,hdf5_ok=no) +CPPFLAGS="$CPPFLAGS_old" + + +if test "x$hdf5_ok" = "xyes" +then + +dnl hdf5 library + + LIBS_old="$LIBS" + LIBS="$LIBS $LOCAL_LIBS" + AC_CHECK_LIB(hdf5,H5open,hdf5_ok=yes,hdf5_ok=no) + LIBS="$LIBS_old" + +fi + +if test "x$hdf5_ok" = "xyes" +then + HDF5_INCLUDES="$LOCAL_INCLUDES" + HDF5_LIBS="$LOCAL_LIBS -lhdf5" + HDF5_MT_LIBS="$LOCAL_LIBS -lhdf5" +fi + +AC_MSG_RESULT(for hdf5: $hdf5_ok) + +])dnl diff --git a/salome_adm/unix/config_files/check_htmlgen.m4 b/salome_adm/unix/config_files/check_htmlgen.m4 new file mode 100644 index 000000000..6a3f49819 --- /dev/null +++ b/salome_adm/unix/config_files/check_htmlgen.m4 @@ -0,0 +1,39 @@ +AC_DEFUN([CHECK_HTML_GENERATORS],[ + +#AC_CHECKING(for html generators) +AC_CHECKING(for doxygen) + +doxygen_ok=yes + +dnl were is doxygen ? + +AC_PATH_PROG(DOXYGEN,doxygen) + +if test "x$DOXYGEN" = "x" +then + doxygen_ok=no + AC_MSG_RESULT(no) + AC_MSG_WARN(doxygen not found) +else + dnl AC_SUBST(DOXYGEN) + AC_MSG_RESULT(yes) +fi + +AC_CHECKING(for graphviz) + +graphviz_ok=yes + +dnl were is graphviz ? + +AC_PATH_PROG(DOT,dot) + +if test "x$DOT" = "x" ; then + graphviz_ok=no + AC_MSG_RESULT(no) + AC_MSG_WARN(graphviz not found) +else + AC_MSG_RESULT(yes) +fi + +])dnl +dnl diff --git a/salome_adm/unix/config_files/check_java.m4 b/salome_adm/unix/config_files/check_java.m4 new file mode 100644 index 000000000..e24f304fa --- /dev/null +++ b/salome_adm/unix/config_files/check_java.m4 @@ -0,0 +1,90 @@ +AC_DEFUN([CHECK_JAVA],[ +dnl AC_REQUIRE([AC_CANONICAL_SYSTEM])dnl +dnl AC_REQUIRE([AC_PROG_CPP])dnl + +AC_CHECKING(for JAVA) + +JAVA_INCLUDES="" +JAVA_LIBS="" +JAVA_LDPATH="" + +java_ok=no + +if test -z $JAVAHOME +then + AC_MSG_WARN(define JAVAHOME variable to use Java) +else + java_ok=yes +fi + +if test "x$java_ok" = "xyes" +then + AC_EXEEXT + AC_CHECK_PROG(JAVA, java$EXEEXT,found) + if test "x$JAVA" = "x" + then + java_ok=no + fi + + AC_CHECK_PROG(JAVAC, javac$EXEEXT,found) + if test "x$JAVAC" = "x" + then + java_ok=no + fi +fi + +if test "x$java_ok" = "xyes" +then + version=`$JAVA -version 2>&1 | grep "java version"` + case "$version" in + *1.1.*) + AC_MSG_RESULT(using jdk1.1 version - jdk1.4 required) + java_ok=no;; + *1.2*) + AC_MSG_RESULT(using jdk1.2 version - jdk1.4 required) + java_ok=no;; + *1.3*) + AC_MSG_RESULT(using jdk1.3 version - jdk1.4 required) + java_ok=no;; + *1.4*) + AC_MSG_RESULT(using jdk1.4 version) ;; + esac +fi + +if test "x$java_ok" = "xyes" +then +dnl java headers + LOCAL_INCLUDES=" -I${JAVAHOME}/include -I${JAVAHOME}/include/linux" + CPPFLAGS_old="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES" + AC_CHECK_HEADER(jni.h,java_ok=yes ,java_ok=no) + + CPPFLAGS="$CPPFLAGS_old" +fi + +if test "x$java_ok" = "xyes" +then +dnl libjava library + LOCAL_LIBS="-L${JAVAHOME}/jre/lib/i386 -ljava -L${JAVAHOME}/jre/lib/i386/client -ljvm -lverify" + LIBS_old="$LIBS" + LIBS="$LIBS $LOCAL_LIBS" + + AC_CHECK_LIB(jvm,JNI_CreateJavaVM,java_ok=yes,java_ok=no) + + LIBS="$LIBS_old" +fi + +if test "x$java_ok" = "xyes" +then + JAVA_INCLUDES="$LOCAL_INCLUDES" + JAVA_LIBS="$LOCAL_LIBS" +fi + +AC_SUBST(JAVA_INCLUDES) +AC_SUBST(JAVA_LIBS) +AC_SUBST(JAVA_LDPATH) + +AC_MSG_RESULT(for java: $java_ok) + +])dnl +dnl diff --git a/salome_adm/unix/config_files/check_med2.m4 b/salome_adm/unix/config_files/check_med2.m4 new file mode 100644 index 000000000..916906068 --- /dev/null +++ b/salome_adm/unix/config_files/check_med2.m4 @@ -0,0 +1,64 @@ +AC_DEFUN([CHECK_MED2],[ +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_REQUIRE([CHECK_HDF5])dnl + +AC_CHECKING(for MED2) + +AC_ARG_WITH(med2, + [ --with-med2=DIR root directory path to med2 installation ], + [MED2HOME="$withval" + AC_MSG_RESULT("select $withval as path to med2") + ]) + +AC_SUBST(MED2_INCLUDES) +AC_SUBST(MED2_LIBS) +AC_SUBST(MED2_MT_LIBS) + +MED2_INCLUDES="" +MED2_LIBS="" +MED2_MT_LIBS="" + +med2_ok=no + +LOCAL_INCLUDES="$HDF5_INCLUDES" +LOCAL_LIBS="-lmed $HDF5_LIBS" + +if test -z $MED2HOME +then + AC_MSG_WARN(undefined MED2HOME variable which specify med2 installation directory) +else + LOCAL_INCLUDES="$LOCAL_INCLUDES -I$MED2HOME/include" + LOCAL_LIBS="-L$MED2HOME/lib $LOCAL_LIBS" +fi + +dnl check med2 header + +CPPFLAGS_old="$CPPFLAGS" +dnl we must test system : linux = -DPCLINUX +CPPFLAGS="$CPPFLAGS -DPCLINUX $LOCAL_INCLUDES" +AC_CHECK_HEADER(med.h,med2_ok=yes ,med2_ok=no) +CPPFLAGS="$CPPFLAGS_old" + +if test "x$med2_ok" = "xyes" +then + +dnl check med2 library + + LIBS_old="$LIBS" + LIBS="$LIBS $LOCAL_LIBS" + AC_CHECK_LIB(med,MEDouvrir,med2_ok=yes,med2_ok=no) + LIBS="$LIBS_old" + +fi + +if test "x$med2_ok" = "xyes" +then + MED2_INCLUDES="-DPCLINUX $LOCAL_INCLUDES" + MED2_LIBS="$LOCAL_LIBS" + MED2_MT_LIBS="$LOCAL_LIBS" +fi + +AC_MSG_RESULT(for med2: $med2_ok) + +])dnl diff --git a/salome_adm/unix/config_files/check_mico.m4 b/salome_adm/unix/config_files/check_mico.m4 new file mode 100644 index 000000000..92bb8d2f0 --- /dev/null +++ b/salome_adm/unix/config_files/check_mico.m4 @@ -0,0 +1,133 @@ + +AC_DEFUN([CHECK_MICO],[ +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CXX])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_REQUIRE([AC_PROG_CXXCPP])dnl + +AC_CHECKING(for mico) +mico_ok=yes + +AC_LANG_SAVE +AC_LANG_CPLUSPLUS + +AC_PATH_PROG(MICOD, micod) +if test "x$MICOD" = "x" +then + mico_ok=no + AC_MSG_RESULT(mico binaries not in PATH variable) +else + mico_ok=yes +fi + +if test "x$mico_ok" = "xyes" +then + AC_SUBST(MICO_IDL) + + MICO_BIN=`echo ${MICOD} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + MICO_LIB=`echo ${MICO_BIN} | sed -e "s,bin,lib,"` + MICO_ROOT=`echo ${MICO_BIN} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + AC_SUBST(MICO_ROOT) + + MICO_IDL=${MICO_BIN}/idl + AC_SUBST(MICO_IDL) + + MICO_INCLUDES="-I$MICO_ROOT/include" + AC_SUBST(MICO_INCLUDES) + + MICO_VERSION=`sed -n -e 's/.define *MICO_VERSION *\"\([[^\"]]*\)\"/\1/p' $MICO_ROOT/include/mico/version.h` + AC_SUBST(MICO_VERSION) + AC_MSG_RESULT(using mico version $MICO_VERSION) + + MICO_CXXFLAGS="-ftemplate-depth-42 -fpermissive" + AC_SUBST(MICO_CXXFLAGS) + + CXXFLAGS_old=$CXXFLAGS + CXXFLAGS="$CXXFLAGS $MICO_CXXFLAGS $MICO_INCLUDES" + + AC_MSG_CHECKING(include of CORBA.h) + AC_TRY_COMPILE( +#include "CORBA.h" +, ,mico_ok=yes ,mico_ok=no) + + if test "x$mico_ok" = "xno" + then + AC_MSG_RESULT(CORBA.h not found in mico installation) + else + AC_MSG_RESULT(yes) + fi + + CXXFLAGS=$CXXFLAGS_old + +fi + +if test "x$mico_ok" = "xyes" +then + MICO_LDFLAGS="-L$MICO_LIB" + + LIBS_old=$LIBS + MICO_LIBS="$MICO_LDFLAGS -lmico$MICO_VERSION -ldl" + AC_SUBST(MICO_LIBS) + + LIBS="$MICO_LIBS $LIBS" + CXXFLAGS_old=$CXXFLAGS + CXXFLAGS="$CXXFLAGS $MICO_CXXFLAGS $MICO_INCLUDES" + + AC_MSG_CHECKING(whether we can link with mico) + AC_TRY_LINK( +#include "CORBA.h" +,CORBA::ORB_var orb, + mico_ok=yes,mico_ok=no) + + if test "x$mico_ok" = "xno" + then + AC_MSG_RESULT(mico library linking failed) + mico_ok=no + else + AC_MSG_RESULT(yes) + fi + + CXXFLAGS=$CXXFLAGS_old + LIBS=$LIBS_old +fi + + +if test "x$mico_ok" = "xyes" +then + + MICO_IDLCXXFLAGS="-bcxx -I$MICO_ROOT/idl" + AC_SUBST(MICO_IDLCXXFLAGS) + AC_SUBST(MICO_IDLPYFLAGS) + + MICO_IDL_CLN_H=.hh + MICO_IDL_CLN_CXX=SK.cc + MICO_IDL_CLN_OBJ=SK.o + AC_SUBST(MICO_IDL_CLN_H) + AC_SUBST(MICO_IDL_CLN_CXX) + AC_SUBST(MICO_IDL_CLN_OBJ) + + MICO_IDL_SRV_H=.hh + MICO_IDL_SRV_CXX=SK.cc + MICO_IDL_SRV_OBJ=SK.o + AC_SUBST(MICO_IDL_SRV_H) + AC_SUBST(MICO_IDL_SRV_CXX) + AC_SUBST(MICO_IDL_SRV_OBJ) + + MICO_IDL_TIE_H= + MICO_IDL_TIE_CXX= + AC_SUBST(MICO_IDL_TIE_H) + AC_SUBST(MICO_IDL_TIE_CXX) + + AC_DEFINE(MICO) + + CORBA_HAVE_POA=1 + AC_DEFINE(CORBA_HAVE_POA) + +fi + +AC_LANG_RESTORE + +AC_MSG_RESULT(for mico: $mico_ok) + +])dnl +dnl diff --git a/salome_adm/unix/config_files/check_mpich.m4 b/salome_adm/unix/config_files/check_mpich.m4 new file mode 100644 index 000000000..be85c485a --- /dev/null +++ b/salome_adm/unix/config_files/check_mpich.m4 @@ -0,0 +1,46 @@ +AC_DEFUN([CHECK_MPICH],[ + +AC_REQUIRE([AC_PROG_CC])dnl + +AC_ARG_WITH(mpich, + --with-mpich=DIR root directory path of MPICH installation, + WITHMPICH="yes",WITHMPICH="no") + +MPICH_INCLUDES="" +MPICH_LIBS="" +if test "$WITHMPICH" = yes; then + + echo + echo --------------------------------------------- + echo testing mpich + echo --------------------------------------------- + echo + MPICH_HOME=$withval + + if test "$MPICH_HOME"; then + MPICH_INCLUDES="-I$MPICH_HOME/include" + MPICH_LIBS="-L$MPICH_HOME/lib" + fi + + CPPFLAGS_old="$CPPFLAGS" + CPPFLAGS="$MPICH_INCLUDES $CPPFLAGS" + AC_CHECK_HEADER(mpi.h,WITHMPICH="yes",WITHMPICH="no") + CPPFLAGS="$CPPFLAGS_old" + + if test "$WITHMPICH" = "yes";then + LDFLAGS_old="$LDFLAGS" + LDFLAGS="$MPICH_LIBS $LDFLAGS" + AC_CHECK_LIB(mpich,MPI_Init, + AC_CHECK_LIB(pmpich, PMPI_Init,WITHMPICH="yes",WITHMPICH="no"), + WITHMPICH="no") + LDFLAGS="$LDFLAGS_old" + fi + + MPICH_LIBS="$MPICH_LIBS -lpmpich -lmpich" + +fi +AC_SUBST(MPICH_INCLUDES) +AC_SUBST(MPICH_LIBS) +AC_SUBST(WITHMPICH) + +])dnl diff --git a/salome_adm/unix/config_files/check_omniorb.m4 b/salome_adm/unix/config_files/check_omniorb.m4 new file mode 100644 index 000000000..1763d719d --- /dev/null +++ b/salome_adm/unix/config_files/check_omniorb.m4 @@ -0,0 +1,207 @@ + +AC_DEFUN([CHECK_OMNIORB],[ +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CXX])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_REQUIRE([AC_PROG_CXXCPP])dnl + +AC_CHECKING(for omniORB) +omniORB_ok=yes + +if test "x$PYTHON" = "x" +then + CHECK_PYTHON +fi + +AC_LANG_SAVE +AC_LANG_CPLUSPLUS + +AC_PATH_PROG(OMNIORB_IDL, omniidl) +if test "xOMNIORB_IDL" = "x" +then + omniORB_ok=no + AC_MSG_RESULT(omniORB binaries not in PATH variable) +else + omniORB_ok=yes +fi + +if test "x$omniORB_ok" = "xyes" +then + AC_SUBST(OMNIORB_IDL) + + OMNIORB_BIN=`echo ${OMNIORB_IDL} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + OMNIORB_LIB=`echo ${OMNIORB_BIN} | sed -e "s,bin,lib,"` + + OMNIORB_ROOT=`echo ${OMNIORB_BIN} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + OMNIORB_ROOT=`echo ${OMNIORB_ROOT} | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + AC_SUBST(OMNIORB_ROOT) + + OMNIORB_INCLUDES="-I$OMNIORB_ROOT/include -I$OMNIORB_ROOT/include/omniORB3 -I$OMNIORB_ROOT/include/COS" + AC_SUBST(OMNIORB_INCLUDES) + + ENABLE_PTHREADS + + OMNIORB_CXXFLAGS= + case $build_cpu in + sparc*) + AC_DEFINE(__sparc__) + OMNIORB_CXXFLAGS="$OMNIORB_CXXFLAGS -D__sparc__" + ;; + *86*) + AC_DEFINE(__x86__) + OMNIORB_CXXFLAGS="$OMNIORB_CXXFLAGS -D__x86__" + ;; + esac + case $build_os in + solaris*) + AC_DEFINE(__sunos__) + __OSVERSION__=5 + AC_DEFINE(__OSVERSION__) + OMNIORB_CXXFLAGS="$OMNIORB_CXXFLAGS -D__sunos__" + ;; + linux*) + AC_DEFINE(__linux__) + __OSVERSION__=2 + AC_DEFINE(__OSVERSION__) + OMNIORB_CXXFLAGS="$OMNIORB_CXXFLAGS -D__linux__" + ;; + esac + AC_SUBST(OMNIORB_CXXFLAGS) + + CPPFLAGS_old=$CPPFLAGS + CPPFLAGS="$CPPFLAGS $OMNIORB_CXXFLAGS $OMNIORB_INCLUDES" + + AC_LANG_CPLUSPLUS + AC_CHECK_HEADER(CORBA.h,omniORB_ok="yes",omniORB_ok="no") + + CPPFLAGS=$CPPFLAGS_old + +fi + +if test "x$omniORB_ok" = "xyes" +then + OMNIORB_LDFLAGS="-L$OMNIORB_LIB" + + LIBS_old=$LIBS + LIBS="$LIBS $OMNIORB_LDFLAGS -lomnithread" + + CXXFLAGS_old=$CXXFLAGS + CXXFLAGS="$CXXFLAGS $OMNIORB_CXXFLAGS $OMNIORB_INCLUDES" + + AC_MSG_CHECKING(whether we can link with omnithreads) + AC_CACHE_VAL(salome_cv_lib_omnithreads,[ + AC_TRY_LINK( +#include +, omni_mutex my_mutex, + eval "salome_cv_lib_omnithreads=yes",eval "salome_cv_lib_omnithreads=no") + ]) + + omniORB_ok="$salome_cv_lib_omnithreads" + if test "x$omniORB_ok" = "xno" + then + AC_MSG_RESULT(omnithreads not found) + else + AC_MSG_RESULT(yes) + fi + + LIBS=$LIBS_old + CXXFLAGS=$CXXFLAGS_old +fi + +if test "x$omniORB_ok" = "xyes" +then + + AC_CHECK_LIB(socket,socket, LIBS="-lsocket $LIBS",,) + AC_CHECK_LIB(nsl,gethostbyname, LIBS="-lnsl $LIBS",,) + + LIBS_old=$LIBS + OMNIORB_LIBS="$OMNIORB_LDFLAGS -lomniORB3 -ltcpwrapGK -lomniDynamic3 -lomnithread -lCOS3 -lCOSDynamic3" + AC_SUBST(OMNIORB_LIBS) + + LIBS="$OMNIORB_LIBS $LIBS" + CXXFLAGS_old=$CXXFLAGS + CXXFLAGS="$CXXFLAGS $OMNIORB_CXXFLAGS $OMNIORB_INCLUDES" + + AC_MSG_CHECKING(whether we can link with omniORB3) + AC_CACHE_VAL(salome_cv_lib_omniorb3,[ + AC_TRY_LINK( +#include +, CORBA::ORB_var orb, + eval "salome_cv_lib_omniorb3=yes",eval "salome_cv_lib_omniorb3=no") + ]) + omniORB_ok="$salome_cv_lib_omniorb3" + + if test "x$omniORB_ok" = "xno" + then + AC_MSG_RESULT(omniORB library linking failed) + omniORB_ok=no + else + AC_MSG_RESULT(yes) + fi + LIBS="$LIBS_old" + CXXFLAGS=$CXXFLAGS_old +fi + + +if test "x$omniORB_ok" = "xyes" +then + + OMNIORB_IDLCXXFLAGS="-bcxx -I$OMNIORB_ROOT/idl" + OMNIORB_IDLPYFLAGS="-bpython -I$OMNIORB_ROOT/idl" + AC_SUBST(OMNIORB_IDLCXXFLAGS) + AC_SUBST(OMNIORB_IDLPYFLAGS) + + OMNIORB_IDL_CLN_H=.hh + OMNIORB_IDL_CLN_CXX=SK.cc + OMNIORB_IDL_CLN_OBJ=SK.o + AC_SUBST(OMNIORB_IDL_CLN_H) + AC_SUBST(OMNIORB_IDL_CLN_CXX) + AC_SUBST(OMNIORB_IDL_CLN_OBJ) + + OMNIORB_IDL_SRV_H=.hh + OMNIORB_IDL_SRV_CXX=SK.cc + OMNIORB_IDL_SRV_OBJ=SK.o + AC_SUBST(OMNIORB_IDL_SRV_H) + AC_SUBST(OMNIORB_IDL_SRV_CXX) + AC_SUBST(OMNIORB_IDL_SRV_OBJ) + + OMNIORB_IDL_TIE_H= + OMNIORB_IDL_TIE_CXX= + AC_SUBST(OMNIORB_IDL_TIE_H) + AC_SUBST(OMNIORB_IDL_TIE_CXX) + + AC_DEFINE(OMNIORB) + + CORBA_HAVE_POA=1 + AC_DEFINE(CORBA_HAVE_POA) + + CORBA_ORB_INIT_HAVE_3_ARGS=1 + AC_DEFINE(CORBA_ORB_INIT_HAVE_3_ARGS) + CORBA_ORB_INIT_THIRD_ARG='"omniORB3"' + AC_DEFINE(CORBA_ORB_INIT_THIRD_ARG, "omniORB3") + +fi + +omniORBpy_ok=no +if test "x$omniORB_ok" = "xyes" +then + AC_MSG_CHECKING(omniORBpy (CORBA.py file available)) + if test -f ${OMNIORB_ROOT}/lib/python/CORBA.py + then + omniORBpy_ok=yes + PYTHONPATH=${OMNIORB_ROOT}/lib/python:${OMNIORB_LIB}:${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}:${PYTHONPATH} + AC_SUBST(PYTHONPATH) + AC_MSG_RESULT(yes) + fi +fi + +AC_LANG_RESTORE + +AC_MSG_RESULT(for omniORBpy: $omniORBpy_ok) +AC_MSG_RESULT(for omniORB: $omniORB_ok) + +# Save cache +AC_CACHE_SAVE + +])dnl +dnl diff --git a/salome_adm/unix/config_files/check_opengl.m4 b/salome_adm/unix/config_files/check_opengl.m4 new file mode 100644 index 000000000..4311d12e3 --- /dev/null +++ b/salome_adm/unix/config_files/check_opengl.m4 @@ -0,0 +1,107 @@ +AC_DEFUN([CHECK_OPENGL],[ +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_ARG_WITH(opengl, + [ --with-opengl=DIR root directory path of OpenGL installation ], + [ + opengl_dir="$withval" + local_opengl=yes + ], [ + dirs="/usr/lib /usr/local/lib /opt/graphics/OpenGL/lib /usr/openwin/lib /usr/X11R6/lib" + ])dnl + +AC_CHECKING(for OpenGL) + +AC_SUBST(OGL_INCLUDES) +AC_SUBST(OGL_LIBS) + +OGL_INCLUDES="" +OGL_LIBS="" + +OpenGL_ok=no + +dnl openGL headers + +# by default + +if test "x$local_opengl" = "xyes" ; then + if test -f "${opengl_dir}/include/GL/gl.h" ; then + OpenGL_ok=yes + OGL_INCLUDES="-I${opengl_dir}/include" + OGL_LIBS="-L${opengl_dir}/lib" + AC_MSG_RESULT(select OpenGL distribution in ${opengl_dir}) + else + AC_MSG_RESULT(no gl.h header file in ${opengl_dir}/include/GL) + fi +fi + +if test "x$OpenGL_ok" = "xno" +then + AC_CHECK_HEADERS(GL/gl.h, [OpenGL_ok=yes]) +fi + +if test "x$OpenGL_ok" = "xno" +then +# under SunOS ? + AC_CHECK_HEADERS(/usr/openwin/share/include/GL/glxmd.h, + [OpenGL_ok=yes] + OGL_INCLUDES="-I/usr/openwin/share/include/") +fi + +if test "x$OpenGL_ok" = "xno" +then +# under IRIX ? + AC_CHECK_HEADERS(/opt/graphics/OpenGL/include/GL/glxmd.h, + [OpenGL_ok=yes] + OGL_INCLUDES="-I/opt/graphics/OpenGL/include") +fi +if test "x$OpenGL_ok" = "xno" +then +# some linux OpenGL servers hide the includes in /usr/X11R6/include/GL + AC_CHECK_HEADERS(/usr/X11R6/include/GL/gl.h, + [OpenGL_ok=yes] + OGL_INCLUDES="-I/usr/X11R6/include") +fi + +if test "x$OpenGL_ok" = "xyes" +then + AC_CHECKING(for OpenGL library) + OpenGL_ok=no + for i in $dirs; do + if test -r "$i/libGL.so"; then +dnl AC_MSG_RESULT(in $i) + OGL_LIBS="-L$i" + break + fi +# under IRIX ? + if test -r "$i/libGL.sl"; then +dnl AC_MSG_RESULT(in $i) + OGL_LIBS="-L$i" + break + fi + done + LDFLAGS_old="$LDFLAGS" + LDFLAGS="$LDFLAGS $OGL_LIBS" + AC_CHECK_LIB(GL,glBegin,OpenGL_ok=yes,OpenGL_ok=no) + LDFLAGS="$LDFLAGS_old" +fi + +if test "x$OpenGL_ok" = "xyes" ; then + OGL_LIBS="$OGL_LIBS -lGL" +fi + + +OpenGLU_ok=no +LDFLAGS_old="$LDFLAGS" +LDFLAGS="$LDFLAGS $OGL_LIBS" +AC_CHECK_LIB(GLU,gluBeginSurface,OpenGLU_ok=yes,OpenGLU_ok=no) +LDFLAGS="$LDFLAGS_old" + +if test "x$OpenGLU_ok" = "xyes" ; then + OGL_LIBS="$OGL_LIBS -lGLU" +fi + +# Save cache +AC_CACHE_SAVE + +])dnl diff --git a/salome_adm/unix/config_files/check_pthreads.m4 b/salome_adm/unix/config_files/check_pthreads.m4 new file mode 100644 index 000000000..4e9b131b5 --- /dev/null +++ b/salome_adm/unix/config_files/check_pthreads.m4 @@ -0,0 +1,30 @@ +#@synonpsis CHECK_PTHREADS +dnl check for pthreads system interfaces. +dnl set CFLAGS_PTHREADS, CXXFLAGS_PTHREADS and LIBS_PTHREADS to +dnl flags to compiler flags for multithread program compilation (if exists), +dnl and library, if one required. +dnl +dnl@author (C) Ruslan Shevchenko , 1998 +dnl@id $Id$ +dnl ---------------------------------------------------------------- +dnl CHECK_PTHREADS +AC_DEFUN(CHECK_PTHREADS,[ +AC_REQUIRE([AC_CANONICAL_SYSTEM])dnl +AC_CHECK_HEADER(pthread.h,AC_DEFINE(HAVE_PTHREAD_H)) +AC_CHECK_LIB(posix4,nanosleep, LIBS_PTHREADS="-lposix4",LIBS_PTHREADS="") +AC_CHECK_LIB(pthread,pthread_mutex_lock, + LIBS_PTHREADS="-lpthread $LIBS_PTHREADS") +AC_MSG_CHECKING([parameters for using pthreads]) +case $build_os in + freebsd*) + CFLAGS_PTHREADS="-pthread" + CXXFLAGS_PTHREADS="-pthread" + ;; + *) + ;; +esac +AC_MSG_RESULT(["flags: $CFLAGS_PTHREADS\;libs: $LIBS_PTHREADS"]) +threads_ok=yes +])dnl +dnl +dnl diff --git a/salome_adm/unix/config_files/check_pyqt.m4 b/salome_adm/unix/config_files/check_pyqt.m4 new file mode 100644 index 000000000..ec915a4ad --- /dev/null +++ b/salome_adm/unix/config_files/check_pyqt.m4 @@ -0,0 +1,71 @@ + +AC_DEFUN([CHECK_PYQT],[ +AC_REQUIRE([CHECK_PYTHON])dnl + +AC_CHECKING(for pyqt) + +pyqt_ok=no + +dnl were is pyqt ? + +if test -z $PYQTDIR; then + AC_MSG_WARN(You must provide PYQTDIR variable) +else + pyqt_ok=yes +fi + +if test "x$pyqt_ok" = xno -o ! -d "$PYQTDIR" -o ! -d "$PYQTDIR"/sip ; then + AC_MSG_RESULT(no) + AC_MSG_WARN(pyqt not found) +else + AC_CHECK_FILES("$PYQTDIR"/qt.py "$PYQTDIR"/libqtcmodule.so,pyqt_ok=yes,pyqt_ok=no) + if test "x$pyqt_ok" = xno ; then + AC_MSG_RESULT(no) + AC_MSG_WARN(pyqt not found) + else + PYQT_ROOT=$PYQTDIR + PYQT_INCLUDES="-I$PYQTDIR/sip" + PYQT_LIBS="-L$PYQTDIR -lqtcmodule" + + AC_SUBST(PYQT_ROOT) + AC_SUBST(PYQT_INCLUDES) + AC_SUBST(PYQT_LIBS) + + AC_MSG_RESULT(yes) + fi +fi + +AC_ARG_WITH(pyuic, + [ --with-pyuic=EXEC pyuic executable ], + [PYUIC="$withval" + AC_MSG_RESULT("select $withval as pyqt executable") + ], [ + AC_PATH_PROG(PYUIC, pyuic) + ]) + +if test "x$PYUIC" = "x" +then + pyqt_ok=no + AC_MSG_RESULT(pyuic not in PATH variable) +else + if test -z $PYQT_SIPS; then + AC_MSG_WARN(You must provide PYQT_SIPS variable) + pyqt_ok=no + else + PYQT_SIPS=${PYQT_SIPS} + fi + PYQT_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages ${PYQT_LIBS}" +fi + +AC_SUBST(PYUIC) +AC_SUBST(PYQT_SIPS) +AC_SUBST(PYQT_LIBS) + + + +AC_MSG_RESULT(for pyqt: $pyqt_ok) + +])dnl +dnl + + diff --git a/salome_adm/unix/config_files/check_qt.m4 b/salome_adm/unix/config_files/check_qt.m4 new file mode 100644 index 000000000..36d0636cf --- /dev/null +++ b/salome_adm/unix/config_files/check_qt.m4 @@ -0,0 +1,134 @@ + +AC_DEFUN([CHECK_QT],[ +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CXX])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_REQUIRE([AC_PROG_CXXCPP])dnl +AC_REQUIRE([CHECK_OPENGL])dnl + +AC_CHECKING(for QT) +qt_ok=yes + +AC_LANG_SAVE +AC_LANG_CPLUSPLUS + +if test "x$QTDIR" = "x" +then + AC_MSG_RESULT(please define QTDIR variable) + qt_ok=no +fi + +if test "x$qt_ok" = "xyes" +then + if test -f ${QTDIR}/bin/moc + then + MOC=${QTDIR}/bin/moc + else + AC_PATH_PROG(MOC, moc) + fi + if test "x$MOC" = "x" + then + qt_ok=no + AC_MSG_RESULT(moc qt-compiler not in PATH variable) + else + qt_ok=yes + AC_MSG_RESULT(moc found) + fi +fi + +if test "x$qt_ok" = "xyes" +then + if test -f ${QTDIR}/bin/uic + then + UIC=${QTDIR}/bin/uic + else + AC_PATH_PROG(UIC, uic) + fi + if test "x$UIC" = "x" + then + qt_ok=no + AC_MSG_RESULT(uic qt-interface compiler not in PATH variable) + else + qt_ok=yes + AC_MSG_RESULT(uic found) + fi +fi + +AC_SUBST(QTDIR) +QT_ROOT=$QTDIR + +if test "x$qt_ok" = "xyes" +then + AC_MSG_CHECKING(include of qt headers) + + CPPFLAGS_old=$CPPFLAGS + CPPFLAGS="$CPPFLAGS -I$QTDIR/include" + + AC_LANG_CPLUSPLUS + AC_CHECK_HEADER(qaction.h,qt_ok=yes ,qt_ok=no) + + CPPFLAGS=$CPPFLAGS_old + + if test "x$qt_ok" = "xno" + then + AC_MSG_RESULT(qt headers not found, or too old qt version, in $QTDIR/include) + AC_MSG_RESULT(QTDIR environment variable may be wrong) + else + AC_MSG_RESULT(yes) + QT_INCLUDES="-I${QT_ROOT}/include -DQT_THREAD_SUPPORT" + QT_MT_INCLUDES="-I${QT_ROOT}/include -DQT_THREAD_SUPPORT" + fi +fi + +if test "x$qt_ok" = "xyes" +then + AC_MSG_CHECKING(linking qt library) + LIBS_old=$LIBS + LIBS="$LIBS -L$QTDIR/lib -lqt-mt $OGL_LIBS" + + CXXFLAGS_old=$CXXFLAGS + CXXFLAGS="$CXXFLAGS -I$QTDIR/include" + + AC_CACHE_VAL(salome_cv_lib_qt,[ + AC_TRY_LINK( +#include +, int n; + char **s; + QApplication a(n, s); + a.exec();, + eval "salome_cv_lib_qt=yes",eval "salome_cv_lib_qt=no") + ]) + qt_ok="$salome_cv_lib_qt" + + if test "x$qt_ok" = "xno" + then + AC_MSG_RESULT(unable to link with qt library) + AC_MSG_RESULT(QTDIR environment variable may be wrong) + else + AC_MSG_RESULT(yes) + QT_LIBS="-L$QTDIR/lib -lqt-mt" + QT_MT_LIBS="-L$QTDIR/lib -lqt-mt" + fi + + LIBS=$LIBS_old + CXXFLAGS=$CXXFLAGS_old + +fi + +AC_SUBST(MOC) +AC_SUBST(UIC) + +AC_SUBST(QT_ROOT) +AC_SUBST(QT_INCLUDES) +AC_SUBST(QT_LIBS) +AC_SUBST(QT_MT_LIBS) + +AC_LANG_RESTORE + +AC_MSG_RESULT(for qt: $qt_ok) + +# Save cache +AC_CACHE_SAVE + +])dnl +dnl diff --git a/salome_adm/unix/config_files/check_qwt.m4 b/salome_adm/unix/config_files/check_qwt.m4 new file mode 100644 index 000000000..54336cb6b --- /dev/null +++ b/salome_adm/unix/config_files/check_qwt.m4 @@ -0,0 +1,86 @@ +AC_DEFUN([CHECK_QWT],[ +AC_REQUIRE([CHECK_QT])dnl + +AC_CHECKING(for qwt) + +qwt_ok=no + +dnl were is qwt ? +if test -z $QWTHOME; then + AC_MSG_WARN(You must provide QWTHOME variable) +else + qwt_ok=yes +fi + +if test "x$qwt_ok" = xno -o ! -d "$QWTHOME" ; then + AC_MSG_RESULT(no) + AC_MSG_WARN(qwt not found) +else + + AC_LANG_SAVE + AC_LANG_CPLUSPLUS + CPPFLAGS_old=$CPPFLAGS + CPPFLAGS="$CPPFLAGS -I$QWTHOME/include" + CPPFLAGS="$CPPFLAGS -I$QTDIR/include" + + AC_CHECK_HEADER(qwt.h,qwt_ok=yes,qwt_ok=no) + + CPPFLAGS=$CPPFLAGS_old + + if test "x$qwt_ok" = xno ; then + AC_MSG_RESULT(no) + AC_MSG_WARN(qwt not found) + else + qwt_ok=yes + fi + +if test "x$qwt_ok" = "xyes" +then + AC_MSG_CHECKING(linking qwt library) + LIBS_old=$LIBS + LIBS="$LIBS -L$QTDIR/lib -lqt-mt -L$QWTHOME/lib -lqwt" + + CXXFLAGS_old=$CXXFLAGS + CXXFLAGS="$CXXFLAGS -I$QTDIR/include -I$QWTHOME/include" + + AC_CACHE_VAL(salome_cv_lib_qwt,[ + AC_TRY_LINK( +#include +#include +, int n; + char **s; + QApplication a(n, s); + QwtPlot* p; + a.setMainWidget(p); + a.exec();, + eval "salome_cv_lib_qwt=yes",eval "salome_cv_lib_qwt=no") + ]) + qwt_ok="$salome_cv_lib_qwt" + + if test "x$qwt_ok" = "xno" + then + AC_MSG_RESULT(unable to link with qwt library) + AC_MSG_RESULT(QWTHOME environment variable may be wrong) + else + QWT_INCLUDES="-I$QWTHOME/include" + QWT_LIBS="-L$QWTHOME/lib -lqwt" + + AC_SUBST(QWT_INCLUDES) + AC_SUBST(QWT_LIBS) + + AC_MSG_RESULT(yes) + fi + + LIBS=$LIBS_old + CXXFLAGS=$CXXFLAGS_old + +fi + + + AC_LANG_RESTORE + +fi + + +])dnl +dnl diff --git a/salome_adm/unix/config_files/check_sip.m4 b/salome_adm/unix/config_files/check_sip.m4 new file mode 100644 index 000000000..7808c3e67 --- /dev/null +++ b/salome_adm/unix/config_files/check_sip.m4 @@ -0,0 +1,32 @@ + +AC_DEFUN([CHECK_SIP],[ +AC_REQUIRE([CHECK_PYTHON])dnl + +sip_ok=yes + +AC_ARG_WITH(sip, + [ --with-sip=EXEC sip executable ], + [SIP="$withval" + AC_MSG_RESULT("select $withval as sip executable") + ], [ + AC_PATH_PROG(SIP, sip) + ]) + +if test "x$SIP" = "x" +then + sip_ok=no + AC_MSG_RESULT(sip not in PATH variable) +else + SIP_ROOT="$SIPDIR" + SIP_INCLUDES="${PYTHON_INCLUDES} -I${SIPDIR}" + SIP_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/site-packages -L${SIPDIR} -lsip" +fi + +AC_SUBST(SIP) +AC_SUBST(SIP_INCLUDES) +AC_SUBST(SIP_LIBS) + +AC_MSG_RESULT(for sip: $sip_ok) + +])dnl +dnl diff --git a/salome_adm/unix/config_files/check_swig.m4 b/salome_adm/unix/config_files/check_swig.m4 new file mode 100644 index 000000000..9a127cbf9 --- /dev/null +++ b/salome_adm/unix/config_files/check_swig.m4 @@ -0,0 +1,45 @@ + +AC_DEFUN([CHECK_SWIG],[ +AC_REQUIRE([CHECK_PYTHON])dnl + +swig_ok=yes + +AC_ARG_WITH(swig, + [ --with-swig=EXEC swig executable ], + [SWIG="$withval" + AC_MSG_RESULT("select $withval as swig executable") + ], [ + AC_PATH_PROG(SWIG, swig) + ]) + +if test "x$SWIG" = "x" +then + swig_ok=no + AC_MSG_RESULT(swig not in PATH variable) +fi + +if test "x$swig_ok" = "xyes" +then + AC_MSG_CHECKING(python wrapper generation with swig) + cat > conftest.h << EOF +int f(double); +EOF + + $SWIG -module conftest -python conftest.h >/dev/null 2>&1 + if test -f conftest_wrap.c + then + SWIG_FLAGS="-c++ -python -shadow" + else + swig_ok=no + fi + rm -f conftest* + AC_MSG_RESULT($swig_ok) +fi + +AC_SUBST(SWIG_FLAGS) +AC_SUBST(SWIG) + +AC_MSG_RESULT(for swig: $swig_ok) + +])dnl +dnl diff --git a/salome_adm/unix/config_files/check_vtk.m4 b/salome_adm/unix/config_files/check_vtk.m4 new file mode 100644 index 000000000..c66d795f8 --- /dev/null +++ b/salome_adm/unix/config_files/check_vtk.m4 @@ -0,0 +1,96 @@ +AC_DEFUN([CHECK_VTK],[ +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CXX])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_REQUIRE([AC_PROG_CXXCPP])dnl + +AC_CHECKING(for VTK) + +AC_LANG_SAVE +AC_LANG_CPLUSPLUS + +AC_SUBST(VTK_INCLUDES) +AC_SUBST(VTK_LIBS) +AC_SUBST(VTKPY_MODULES) + +VTK_INCLUDES="" +VTK_LIBS="" +VTKPY_MODULES="" + +vtk_ok=no + +AC_PATH_X + +if test "x$OpenGL_ok" != "xyes" +then + AC_MSG_WARN(vtk needs OpenGL correct configuration, check configure output) +fi + + +LOCAL_INCLUDES="$OGL_INCLUDES" +LOCAL_LIBS="-lVTKCommon -lVTKGraphics -lVTKImaging -lVTKContrib $OGL_LIBS -L$x_libraries -lX11 -lXt" +TRY_LINK_LIBS="-lVTKCommon $OGL_LIBS -L$x_libraries -lX11 -lXt" + +if test -z $VTKHOME +then + AC_MSG_WARN(undefined VTKHOME variable which specify where vtk was compiled) +else + LOCAL_INCLUDES="-I$VTKHOME/common -I$VTKHOME/imaging -I$VTKHOME/graphics -I$VTKHOME/contrib $LOCAL_INCLUDES" + LOCAL_LIBS="-L$VTKHOME/lib -L$VTKHOME/common -L$VTKHOME/graphics -L$VTKHOME/imaging -L$VTKHOME/contrib $LOCAL_LIBS" + TRY_LINK_LIBS="-L$VTKHOME/lib -L$VTKHOME/common $TRY_LINK_LIBS" +fi + +dnl vtk headers +CPPFLAGS_old="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES" + +AC_CHECK_HEADER(vtk.h,vtk_ok="yes",vtk_ok="no") + +CPPFLAGS="$CPPFLAGS_old" + +if test "x$vtk_ok" = "xyes" +then + VTK_INCLUDES="$LOCAL_INCLUDES" + +dnl vtk libraries + + AC_MSG_CHECKING(linking VTK library) + + LIBS_old="$LIBS" +# LIBS="$LIBS $TRY_LINK_LIBS" + LIBS="$LIBS $LOCAL_LIBS" + CPPFLAGS_old="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $VTK_INCLUDES" + +dnl VTKPY_MODULES="$VTKHOME/python" + + AC_CACHE_VAL(salome_cv_lib_vtk,[ + AC_TRY_LINK( +#include +, vtkPlane *p = vtkPlane::New();, + eval "salome_cv_lib_vtk=yes",eval "salome_cv_lib_vtk=no") + ]) + vtk_ok="$salome_cv_lib_vtk" + LIBS="$LIBS_old" + CPPFLAGS="$CPPFLAGS_old" + +fi + +if test "x$vtk_ok" = "xno" +then + AC_MSG_RESULT("no") + AC_MSG_WARN(unable to link with vtk library) +else + AC_MSG_RESULT("yes") + VTK_LIBS="$LOCAL_LIBS" + VTK_MT_LIBS="$LOCAL_LIBS" +fi + +AC_MSG_RESULT("for vtk: $vtk_ok") + +AC_LANG_RESTORE + +# Save cache +AC_CACHE_SAVE + +])dnl diff --git a/salome_adm/unix/config_files/config.guess b/salome_adm/unix/config_files/config.guess new file mode 100755 index 000000000..0ce538bb8 --- /dev/null +++ b/salome_adm/unix/config_files/config.guess @@ -0,0 +1,1183 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 +# Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Written by Per Bothner . +# Please send patches to . +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit system type (host/target name). +# +# Only a few systems have been added to this list; please add others +# (but try to keep the structure clean). +# + +# Use $HOST_CC if defined. $CC may point to a cross-compiler +if test x"$CC_FOR_BUILD" = x; then + if test x"$HOST_CC" != x; then + CC_FOR_BUILD="$HOST_CC" + else + if test x"$CC" != x; then + CC_FOR_BUILD="$CC" + else + CC_FOR_BUILD=cc + fi + fi +fi + + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 8/24/94.) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +dummy=dummy-$$ +trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15 + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # Netbsd (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # Determine the machine/vendor (is the vendor relevant). + case "${UNAME_MACHINE}" in + amiga) machine=m68k-cbm ;; + arm32) machine=arm-unknown ;; + atari*) machine=m68k-atari ;; + sun3*) machine=m68k-sun ;; + mac68k) machine=m68k-apple ;; + macppc) machine=powerpc-apple ;; + hp3[0-9][05]) machine=m68k-hp ;; + ibmrt|romp-ibm) machine=romp-ibm ;; + *) machine=${UNAME_MACHINE}-unknown ;; + esac + # The Operating System including object format. + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + # The OS release + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + cat <$dummy.s + .data +\$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text + .globl main + .align 4 + .ent main +main: + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit + .end main +EOF + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null + if test "$?" = 0 ; then + case `./$dummy` in + 0-0) + UNAME_MACHINE="alpha" + ;; + 1-0) + UNAME_MACHINE="alphaev5" + ;; + 1-1) + UNAME_MACHINE="alphaev56" + ;; + 1-101) + UNAME_MACHINE="alphapca56" + ;; + 2-303) + UNAME_MACHINE="alphaev6" + ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; + esac + fi + rm -f $dummy.s $dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-cbm-sysv4 + exit 0;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + SR2?01:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + atari*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; + sun3*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy \ + && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i?86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:4) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=4.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` + rm -f $dummy.c $dummy + esac + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + *9??*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i?86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + hppa*:OpenBSD:*:*) + echo hppa-unknown-openbsd + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:*:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3E:*:*:*) + echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + F300:UNIX_System_V:*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + F301:UNIX_System_V:*:*) + echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i386-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + *:Linux:*:*) + + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + ld_help_string=`cd /; ld --help 2>&1` + ld_supported_emulations=`echo $ld_help_string \ + | sed -ne '/supported emulations:/!d + s/[ ][ ]*/ /g + s/.*supported emulations: *// + s/ .*// + p'` + case "$ld_supported_emulations" in + *ia64) + echo "${UNAME_MACHINE}-unknown-linux" + exit 0 + ;; + i?86linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 + ;; + elf_i?86) + echo "${UNAME_MACHINE}-pc-linux" + exit 0 + ;; + i?86coff) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 + ;; + sparclinux) + echo "${UNAME_MACHINE}-unknown-linux-gnuaout" + exit 0 + ;; + armlinux) + echo "${UNAME_MACHINE}-unknown-linux-gnuaout" + exit 0 + ;; + elf32arm*) + echo "${UNAME_MACHINE}-unknown-linux-gnuoldld" + exit 0 + ;; + armelf_linux*) + echo "${UNAME_MACHINE}-unknown-linux-gnu" + exit 0 + ;; + m68klinux) + echo "${UNAME_MACHINE}-unknown-linux-gnuaout" + exit 0 + ;; + elf32ppc | elf32ppclinux) + # Determine Lib Version + cat >$dummy.c < +#if defined(__GLIBC__) +extern char __libc_version[]; +extern char __libc_release[]; +#endif +main(argc, argv) + int argc; + char *argv[]; +{ +#if defined(__GLIBC__) + printf("%s %s\n", __libc_version, __libc_release); +#else + printf("unkown\n"); +#endif + return 0; +} +EOF + LIBC="" + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null + if test "$?" = 0 ; then + ./$dummy | grep 1\.99 > /dev/null + if test "$?" = 0 ; then + LIBC="libc1" + fi + fi + rm -f $dummy.c $dummy + echo powerpc-unknown-linux-gnu${LIBC} + exit 0 + ;; + esac + + if test "${UNAME_MACHINE}" = "alpha" ; then + cat <$dummy.s + .data + \$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text + .globl main + .align 4 + .ent main + main: + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit + .end main +EOF + LIBC="" + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null + if test "$?" = 0 ; then + case `./$dummy` in + 0-0) + UNAME_MACHINE="alpha" + ;; + 1-0) + UNAME_MACHINE="alphaev5" + ;; + 1-1) + UNAME_MACHINE="alphaev56" + ;; + 1-101) + UNAME_MACHINE="alphapca56" + ;; + 2-303) + UNAME_MACHINE="alphaev6" + ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; + esac + + objdump --private-headers $dummy | \ + grep ld.so.1 > /dev/null + if test "$?" = 0 ; then + LIBC="libc1" + fi + fi + rm -f $dummy.s $dummy + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 + elif test "${UNAME_MACHINE}" = "mips" ; then + cat >$dummy.c < /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif +#ifdef __MIPSEB__ + printf ("%s-unknown-linux-gnu\n", argv[1]); +#endif +#ifdef __MIPSEL__ + printf ("%sel-unknown-linux-gnu\n", argv[1]); +#endif + return 0; +} +EOF + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + elif test "${UNAME_MACHINE}" = "s390"; then + echo s390-ibm-linux && exit 0 + else + # Either a pre-BFD a.out linker (linux-gnuoldld) + # or one that does not give us useful --help. + # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. + # If ld does not provide *any* "supported emulations:" + # that means it is gnuoldld. + echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" + test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 + + case "${UNAME_MACHINE}" in + i?86) + VENDOR=pc; + ;; + *) + VENDOR=unknown; + ;; + esac + # Determine whether the default compiler is a.out or elf + cat >$dummy.c < +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif +#ifdef __ELF__ +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +#else + printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); +#endif + return 0; +} +EOF + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + fi ;; +# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions +# are messed up and put the nodename in both sysname and nodename. + i?86:DYNIX/ptx:4*:*) + echo i386-sequent-sysv4 + exit 0 ;; + i?86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit 0 ;; + i?86:*:5:7*) + # Fixed at (any) Pentium or better + UNAME_MACHINE=i586 + if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then + echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} + fi + exit 0 ;; + i?86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + i?86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:*:6*) + echo mips-sony-newsos6 + exit 0 ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + echo `uname -p`-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + if test "${UNAME_MACHINE}" = "x86pc"; then + UNAME_MACHINE=pc + fi + echo `uname -p`-${UNAME_MACHINE}-nto-qnx + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-W:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +#if !defined (ultrix) + printf ("vax-dec-bsd\n"); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0 +rm -f $dummy.c $dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +#echo '(Unable to guess system type)' 1>&2 + +exit 1 diff --git a/salome_adm/unix/config_files/config.sub b/salome_adm/unix/config_files/config.sub new file mode 100755 index 000000000..c8e77851e --- /dev/null +++ b/salome_adm/unix/config_files/config.sub @@ -0,0 +1,1268 @@ +#! /bin/sh +# Configuration validation subroutine script, version 1.1. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 +# Free Software Foundation, Inc. +# +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Written by Per Bothner . +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +if [ x$1 = x ] +then + echo Configuration name missing. 1>&2 + echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 + echo "or $0 ALIAS" 1>&2 + echo where ALIAS is a recognized configuration type. 1>&2 + exit 1 +fi + +# First pass through any local machine types. +case $1 in + *local*) + echo $1 + exit 0 + ;; + *) + ;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ + | arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \ + | 580 | i960 | h8300 \ + | x86 | ppcbe | mipsbe | mipsle | shbe | shle | armbe | armle \ + | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \ + | hppa64 \ + | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \ + | alphaev6[78] \ + | we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \ + | 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \ + | mips64orion | mips64orionel | mipstx39 | mipstx39el \ + | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \ + | mips64vr5000 | miprs64vr5000el | mcore \ + | sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \ + | thumb | d10v | fr30 | avr) + basic_machine=$basic_machine-unknown + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i[34567]86) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + # FIXME: clean up the formatting here. + vax-* | tahoe-* | i[34567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \ + | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ + | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ + | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \ + | xmp-* | ymp-* \ + | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* | armbe-* | armle-* \ + | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \ + | hppa2.0n-* | hppa64-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \ + | alphaev6[78]-* \ + | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \ + | clipper-* | orion-* \ + | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ + | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \ + | mips64el-* | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \ + | mipstx39-* | mipstx39el-* | mcore-* \ + | f301-* | armv*-* | s390-* | sv1-* | t3e-* \ + | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \ + | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \ + | bs2000-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-cbm + ;; + amigaos | amigados) + basic_machine=m68k-cbm + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-cbm + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [ctj]90-cray) + basic_machine=c90-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i[34567]86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i[34567]86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i[34567]86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i[34567]86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + i386-go32 | go32) + basic_machine=i386-unknown + os=-go32 + ;; + i386-mingw32 | mingw32) + basic_machine=i386-unknown + os=-mingw32 + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + msdos) + basic_machine=i386-unknown + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexen) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexen-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=rs6000-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sparclite-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=t3e-cray + os=-unicos + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sparc | sparcv9) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + c4x*) + basic_machine=c4x-none + os=-coff + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i[34567]86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto*) + os=-nto-qnx + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -*MiNT) + os=-mint + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f301-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -*MiNT) + vendor=atari + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os diff --git a/salome_adm/unix/config_files/enable_pthreads.m4 b/salome_adm/unix/config_files/enable_pthreads.m4 new file mode 100644 index 000000000..6c1073b0a --- /dev/null +++ b/salome_adm/unix/config_files/enable_pthreads.m4 @@ -0,0 +1,20 @@ +dnl@synopsis ENABLE_PTHREADS +dnl +dnl modify CFLAGS, CXXFLAGS and LIBS for compiling pthread-based programs. +dnl +dnl@author (C) Ruslan Shevchenko , 1998, 2000 +dnl@id $Id$ +dnl +dnl +AC_DEFUN([ENABLE_PTHREADS],[ +AC_REQUIRE([CHECK_PTHREADS]) + +if test -z "$enable_pthreads_done" +then + CFLAGS="$CFLAGS $CFLAGS_PTHREADS" + CXXFLAGS="$CXXFLAGS $CXXFLAGS_PTHREADS" + LIBS="$LIBS $LIBS_PTHREADS" +fi +enable_pthreads_done=yes +])dnl +dnl diff --git a/salome_adm/unix/config_files/install-sh b/salome_adm/unix/config_files/install-sh new file mode 100755 index 000000000..e9de23842 --- /dev/null +++ b/salome_adm/unix/config_files/install-sh @@ -0,0 +1,251 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/salome_adm/unix/config_files/libtool.m4 b/salome_adm/unix/config_files/libtool.m4 new file mode 100644 index 000000000..8c5cd7d5a --- /dev/null +++ b/salome_adm/unix/config_files/libtool.m4 @@ -0,0 +1,439 @@ +## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*- +## Copyright (C) 1996-1999, 2000 Free Software Foundation, Inc. +## Originally by Gordon Matzigkeit , 1996 +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 2 of the License, or +## (at your option) any later version. +## +## This program 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 +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +## +## As a special exception to the GNU General Public License, if you +## distribute this file as part of a program that contains a +## configuration script generated by Autoconf, you may include it under +## the same distribution terms that you use for the rest of that program. + +# serial 40 AC_PROG_LIBTOOL +AC_DEFUN(AC_PROG_LIBTOOL, +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl + +# Save cache, so that ltconfig can load it +AC_CACHE_SAVE + +# Actually configure libtool. ac_aux_dir is where install-sh is found. +CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags $ac_aux_dir/ltmain.sh $lt_target \ +|| AC_MSG_ERROR([libtool configure failed]) + +# Reload cache, that may have been modified by ltconfig +AC_CACHE_LOAD + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Redirect the config.log output again, so that the ltconfig log is not +# clobbered by the next message. +exec 5>>./config.log +]) + +AC_DEFUN(AC_LIBTOOL_SETUP, +[AC_PREREQ(2.13)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_RANLIB])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_NM])dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +dnl + +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac + +# Check for any special flags to pass to ltconfig. +# +# the following will cause an existing older ltconfig to fail, so +# we ignore this at the expense of the cache file... Checking this +# will just take longer ... bummer! +#libtool_flags="--cache-file=$cache_file" +# +test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" +test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" +test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc" +test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], +[libtool_flags="$libtool_flags --enable-dlopen"]) +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[libtool_flags="$libtool_flags --enable-win32-dll"]) +AC_ARG_ENABLE(libtool-lock, + [ --disable-libtool-lock avoid locking (might break parallel builds)]) +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case "$lt_target" in +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +]) +esac +]) + +# AC_LIBTOOL_DLOPEN - enable checks for dlopen support +AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) + +# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's +AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) + +# AC_ENABLE_SHARED - implement the --enable-shared flag +# Usage: AC_ENABLE_SHARED[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_SHARED, [dnl +define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(shared, +changequote(<<, >>)dnl +<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl +]) + +# AC_DISABLE_SHARED - set the default shared flag to --disable-shared +AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no)]) + +# AC_ENABLE_STATIC - implement the --enable-static flag +# Usage: AC_ENABLE_STATIC[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_STATIC, [dnl +define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(static, +changequote(<<, >>)dnl +<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_static=yes ;; +no) enable_static=no ;; +*) + enable_static=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_static=AC_ENABLE_STATIC_DEFAULT)dnl +]) + +# AC_DISABLE_STATIC - set the default static flag to --disable-static +AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no)]) + + +# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag +# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl +define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(fast-install, +changequote(<<, >>)dnl +<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_fast_install=yes ;; +no) enable_fast_install=no ;; +*) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl +]) + +# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install +AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no)]) + +# AC_PROG_LD - find the path to the GNU or non-GNU linker +AC_DEFUN(AC_PROG_LD, +[AC_ARG_WITH(gnu-ld, +[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], +test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +ac_prog=ld +if test "$ac_cv_prog_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. +changequote(,)dnl + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' +changequote([,])dnl + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(ac_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + ac_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + ac_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$ac_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_PROG_LD_GNU +]) + +AC_DEFUN(AC_PROG_LD_GNU, +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + ac_cv_prog_gnu_ld=yes +else + ac_cv_prog_gnu_ld=no +fi]) +]) + +# AC_PROG_NM - find the path to a BSD-compatible name lister +AC_DEFUN(AC_PROG_NM, +[AC_MSG_CHECKING([for BSD-compatible nm]) +AC_CACHE_VAL(ac_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + ac_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -p" + break + else + ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm +fi]) +NM="$ac_cv_path_NM" +AC_MSG_RESULT([$NM]) +]) + +# AC_CHECK_LIBM - check for math library +AC_DEFUN(AC_CHECK_LIBM, +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case "$lt_target" in +*-*-beos* | *-*-cygwin*) + # These system don't have libm + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, main, LIBM="-lm") + ;; +esac +]) + +# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl convenience library and INCLTDL to the include flags for +# the libltdl header and adds --enable-ltdl-convenience to the +# configure arguments. Note that LIBLTDL and INCLTDL are not +# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not +# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed +# with '${top_builddir}/' and INCLTDL will be prefixed with +# '${top_srcdir}/' (note the single quotes!). If your package is not +# flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case "$enable_ltdl_convenience" in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la + INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) +]) + +# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl installable library and INCLTDL to the include flags for +# the libltdl header and adds --enable-ltdl-install to the configure +# arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is +# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed +# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will +# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed +# with '${top_srcdir}/' (note the single quotes!). If your package is +# not flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, main, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la + INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + INCLTDL= + fi +]) + +dnl old names +AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl +AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl +AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl +AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl +AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl +AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl +AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl + +dnl This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL])dnl diff --git a/salome_adm/unix/config_files/ltconfig b/salome_adm/unix/config_files/ltconfig new file mode 100755 index 000000000..c14d83c16 --- /dev/null +++ b/salome_adm/unix/config_files/ltconfig @@ -0,0 +1,3114 @@ +#! /bin/sh + +# ltconfig - Create a system-specific libtool. +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A lot of this script is taken from autoconf-2.10. + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} +echo=echo +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec "$SHELL" "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null`} + case X$UNAME in + *-DOS) PATH_SEPARATOR=';' ;; + *) PATH_SEPARATOR=':' ;; + esac +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if (echo_test_string="`eval $cmd`") 2>/dev/null && + echo_test_string="`eval $cmd`" && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null; then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" != 'X\t' || + test "X`($echo "$echo_test_string") 2>/dev/null`" != X"$echo_test_string"; then + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH /usr/ucb; do + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + test "X`($dir/echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + test "X`(print -r "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running ltconfig again with it. + ORIGINAL_CONFIG_SHELL="${CONFIG_SHELL-/bin/sh}" + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" --no-reexec ${1+"$@"} + else + # Try using printf. + echo='printf "%s\n"' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + test "X`($echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + # Cool, printf works + : + elif test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' && + test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + CONFIG_SHELL="$ORIGINAL_CONFIG_SHELL" + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL $0 --fallback-echo" + elif test "X`("$CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' && + test "X`("$CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + echo="$CONFIG_SHELL $0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null; then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "$0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec "${ORIGINAL_CONFIG_SHELL}" "$0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# The name of this program. +progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'` + +# Constants: +PROGRAM=ltconfig +PACKAGE=libtool +VERSION=1.3.5 +TIMESTAMP=" (1.385.2.206 2000/05/27 11:12:27)" +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +rm="rm -f" + +help="Try \`$progname --help' for more information." + +# Global variables: +default_ofile=libtool +can_build_shared=yes +enable_shared=yes +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +enable_static=yes +enable_fast_install=yes +enable_dlopen=unknown +enable_win32_dll=no +ltmain= +silent= +srcdir= +ac_config_guess= +ac_config_sub= +host= +nonopt= +ofile="$default_ofile" +verify_host=yes +with_gcc=no +with_gnu_ld=no +need_locks=yes +ac_ext=c +objext=o +libext=a +exeext= +cache_file= + +old_AR="$AR" +old_CC="$CC" +old_CFLAGS="$CFLAGS" +old_CPPFLAGS="$CPPFLAGS" +old_LDFLAGS="$LDFLAGS" +old_LD="$LD" +old_LN_S="$LN_S" +old_LIBS="$LIBS" +old_NM="$NM" +old_RANLIB="$RANLIB" +old_DLLTOOL="$DLLTOOL" +old_OBJDUMP="$OBJDUMP" +old_AS="$AS" + +# Parse the command line options. +args= +prev= +for option +do + case "$option" in + -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + eval "$prev=\$option" + prev= + continue + fi + + case "$option" in + --help) cat <&2 + echo "$help" 1>&2 + exit 1 + ;; + + *) + if test -z "$ltmain"; then + ltmain="$option" + elif test -z "$host"; then +# This generates an unnecessary warning for sparc-sun-solaris4.1.3_U1 +# if test -n "`echo $option| sed 's/[-a-z0-9.]//g'`"; then +# echo "$progname: warning \`$option' is not a valid host type" 1>&2 +# fi + host="$option" + else + echo "$progname: too many arguments" 1>&2 + echo "$help" 1>&2 + exit 1 + fi ;; + esac +done + +if test -z "$ltmain"; then + echo "$progname: you must specify a LTMAIN file" 1>&2 + echo "$help" 1>&2 + exit 1 +fi + +if test ! -f "$ltmain"; then + echo "$progname: \`$ltmain' does not exist" 1>&2 + echo "$help" 1>&2 + exit 1 +fi + +# Quote any args containing shell metacharacters. +ltconfig_args= +for arg +do + case "$arg" in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ltconfig_args="$ltconfig_args '$arg'" ;; + *) ltconfig_args="$ltconfig_args $arg" ;; + esac +done + +# A relevant subset of AC_INIT. + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 5 compiler messages saved in config.log +# 6 checking for... messages and results +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>>./config.log + +# NLS nuisances. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +if test "X${LC_ALL+set}" = Xset; then LC_ALL=C; export LC_ALL; fi +if test "X${LANG+set}" = Xset; then LANG=C; export LANG; fi + +if test -n "$cache_file" && test -r "$cache_file"; then + echo "loading cache $cache_file within ltconfig" + . $cache_file +fi + +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + +if test -z "$srcdir"; then + # Assume the source directory is the same one as the path to LTMAIN. + srcdir=`$echo "X$ltmain" | $Xsed -e 's%/[^/]*$%%'` + test "$srcdir" = "$ltmain" && srcdir=. +fi + +trap "$rm conftest*; exit 1" 1 2 15 +if test "$verify_host" = yes; then + # Check for config.guess and config.sub. + ac_aux_dir= + for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/config.guess; then + ac_aux_dir=$ac_dir + break + fi + done + if test -z "$ac_aux_dir"; then + echo "$progname: cannot find config.guess in $srcdir $srcdir/.. $srcdir/../.." 1>&2 + echo "$help" 1>&2 + exit 1 + fi + ac_config_guess=$ac_aux_dir/config.guess + ac_config_sub=$ac_aux_dir/config.sub + + # Make sure we can run config.sub. + if $SHELL $ac_config_sub sun4 >/dev/null 2>&1; then : + else + echo "$progname: cannot run $ac_config_sub" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + + echo $ac_n "checking host system type""... $ac_c" 1>&6 + + host_alias=$host + case "$host_alias" in + "") + if host_alias=`$SHELL $ac_config_guess`; then : + else + echo "$progname: cannot guess host type; you must specify one" 1>&2 + echo "$help" 1>&2 + exit 1 + fi ;; + esac + host=`$SHELL $ac_config_sub $host_alias` + echo "$ac_t$host" 1>&6 + + # Make sure the host verified. + test -z "$host" && exit 1 + +elif test -z "$host"; then + echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2 + echo "$help" 1>&2 + exit 1 +else + host_alias=$host +fi + +# Transform linux* to *-*-linux-gnu*, to support old configure scripts. +case "$host_os" in +linux-gnu*) ;; +linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` +esac + +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +case "$host_os" in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR cru $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +# Set a sane default for `AR'. +test -z "$AR" && AR=ar + +# Set a sane default for `OBJDUMP'. +test -z "$OBJDUMP" && OBJDUMP=objdump + +# If RANLIB is not set, then run the test. +if test "${RANLIB+set}" != "set"; then + result=no + + echo $ac_n "checking for ranlib... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/ranlib || test -f $dir/ranlib$ac_exeext; then + RANLIB="ranlib" + result="ranlib" + break + fi + done + IFS="$save_ifs" + + echo "$ac_t$result" 1>&6 +fi + +if test -n "$RANLIB"; then + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" +fi + +# Set sane defaults for `DLLTOOL', `OBJDUMP', and `AS', used on cygwin. +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$AS" && AS=as + +# Check to see if we are using GCC. +if test "$with_gcc" != yes || test -z "$CC"; then + # If CC is not set, then try to find GCC or a usable CC. + if test -z "$CC"; then + echo $ac_n "checking for gcc... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/gcc || test -f $dir/gcc$ac_exeext; then + CC="gcc" + break + fi + done + IFS="$save_ifs" + + if test -n "$CC"; then + echo "$ac_t$CC" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + fi + + # Not "gcc", so try "cc", rejecting "/usr/ucb/cc". + if test -z "$CC"; then + echo $ac_n "checking for cc... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + cc_rejected=no + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/cc || test -f $dir/cc$ac_exeext; then + if test "$dir/cc" = "/usr/ucb/cc"; then + cc_rejected=yes + continue + fi + CC="cc" + break + fi + done + IFS="$save_ifs" + if test $cc_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same name, so the bogon will be chosen + # first if we set CC to just the name; use the full file name. + shift + set dummy "$dir/cc" "$@" + shift + CC="$@" + fi + fi + + if test -n "$CC"; then + echo "$ac_t$CC" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + + if test -z "$CC"; then + echo "$progname: error: no acceptable cc found in \$PATH" 1>&2 + exit 1 + fi + fi + + # Now see if the compiler is really GCC. + with_gcc=no + echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6 + echo "$progname:581: checking whether we are using GNU C" >&5 + + $rm conftest.c + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + with_gcc=yes + fi + $rm conftest.c + echo "$ac_t$with_gcc" 1>&6 +fi + +# Allow CC to be a program name with arguments. +set dummy $CC +compiler="$2" + +echo $ac_n "checking for object suffix... $ac_c" 1>&6 +$rm conftest* +echo 'int i = 1;' > conftest.c +echo "$progname:603: checking for object suffix" >& 5 +if { (eval echo $progname:604: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; }; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + for ac_file in conftest.*; do + case $ac_file in + *.c) ;; + *) objext=`echo $ac_file | sed -e s/conftest.//` ;; + esac + done +else + cat conftest.err 1>&5 + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 +fi +$rm conftest* +echo "$ac_t$objext" 1>&6 + +echo $ac_n "checking for executable suffix... $ac_c" 1>&6 +if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_exeext="no" + $rm conftest* + echo 'main () { return 0; }' > conftest.c + echo "$progname:629: checking for executable suffix" >& 5 + if { (eval echo $progname:630: \"$ac_link\") 1>&5; (eval $ac_link) 2>conftest.err; }; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + for ac_file in conftest.*; do + case $ac_file in + *.c | *.err | *.$objext ) ;; + *) ac_cv_exeext=.`echo $ac_file | sed -e s/conftest.//` ;; + esac + done + else + cat conftest.err 1>&5 + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + $rm conftest* +fi +if test "X$ac_cv_exeext" = Xno; then + exeext="" +else + exeext="$ac_cv_exeext" +fi +echo "$ac_t$ac_cv_exeext" 1>&6 + +echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6 +pic_flag= +special_shlib_compile_flags= +wl= +link_static_flag= +no_builtin_flag= + +if test "$with_gcc" = yes; then + wl='-Wl,' + link_static_flag='-static' + + case "$host_os" in + beos* | irix5* | irix6* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + aix*) + # Below there is a dirty hack to force normal static linking with -ldl + # The problem is because libdl dynamically linked with both libc and + # libC (AIX C++ library), which obviously doesn't included in libraries + # list by gcc. This cause undefined symbols with -static flags. + # This hack allows C programs to be linked with "-static -ldl", but + # we not sure about C++ programs. + link_static_flag="$link_static_flag ${wl}-lC" + ;; + cygwin* | mingw* | os2*) + # We can build DLLs from non-PIC. + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + pic_flag='-m68020 -resident32 -malways-restore-a4' + ;; + sysv4*MP*) + if test -d /usr/nec; then + pic_flag=-Kconform_pic + fi + ;; + *) + pic_flag='-fPIC' + ;; + esac +else + # PORTME Check for PIC flags for the system compiler. + case "$host_os" in + aix3* | aix4*) + # All AIX code is PIC. + link_static_flag='-bnso -bI:/lib/syscalls.exp' + ;; + + hpux9* | hpux10* | hpux11*) + # Is there a better link_static_flag that works with the bundled CC? + wl='-Wl,' + link_static_flag="${wl}-a ${wl}archive" + pic_flag='+Z' + ;; + + irix5* | irix6*) + wl='-Wl,' + link_static_flag='-non_shared' + # PIC (with -KPIC) is the default. + ;; + + cygwin* | mingw* | os2*) + # We can build DLLs from non-PIC. + ;; + + osf3* | osf4* | osf5*) + # All OSF/1 code is PIC. + wl='-Wl,' + link_static_flag='-non_shared' + ;; + + sco3.2v5*) + pic_flag='-Kpic' + link_static_flag='-dn' + special_shlib_compile_flags='-belf' + ;; + + solaris*) + pic_flag='-KPIC' + link_static_flag='-Bstatic' + wl='-Wl,' + ;; + + sunos4*) + pic_flag='-PIC' + link_static_flag='-Bstatic' + wl='-Qoption ld ' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + pic_flag='-KPIC' + link_static_flag='-Bstatic' + wl='-Wl,' + ;; + + uts4*) + pic_flag='-pic' + link_static_flag='-Bstatic' + ;; + sysv4*MP*) + if test -d /usr/nec ;then + pic_flag='-Kconform_pic' + link_static_flag='-Bstatic' + fi + ;; + *) + can_build_shared=no + ;; + esac +fi + +if test -n "$pic_flag"; then + echo "$ac_t$pic_flag" 1>&6 + + # Check to make sure the pic_flag actually works. + echo $ac_n "checking if $compiler PIC flag $pic_flag works... $ac_c" 1>&6 + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $pic_flag -DPIC" + echo "$progname:776: checking if $compiler PIC flag $pic_flag works" >&5 + if { (eval echo $progname:777: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.$objext; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + case "$host_os" in + hpux9* | hpux10* | hpux11*) + # On HP-UX, both CC and GCC only warn that PIC is supported... then they + # create non-PIC objects. So, if there were any warnings, we assume that + # PIC is not supported. + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + can_build_shared=no + pic_flag= + else + echo "$ac_t"yes 1>&6 + pic_flag=" $pic_flag" + fi + ;; + *) + echo "$ac_t"yes 1>&6 + pic_flag=" $pic_flag" + ;; + esac + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + can_build_shared=no + pic_flag= + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* +else + echo "$ac_t"none 1>&6 +fi + +# Check to see if options -o and -c are simultaneously supported by compiler +echo $ac_n "checking if $compiler supports -c -o file.o... $ac_c" 1>&6 +$rm -r conftest 2>/dev/null +mkdir conftest +cd conftest +$rm conftest* +echo "int some_variable = 0;" > conftest.c +mkdir out +# According to Tom Tromey, Ian Lance Taylor reported there are C compilers +# that will create temporary files in the current directory regardless of +# the output directory. Thus, making CWD read-only will cause this test +# to fail, enabling locking or at least warning the user not to do parallel +# builds. +chmod -w . +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -o out/conftest2.o" +echo "$progname:829: checking if $compiler supports -c -o file.o" >&5 +if { (eval echo $progname:830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.o; then + + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s out/conftest.err; then + echo "$ac_t"no 1>&6 + compiler_c_o=no + else + echo "$ac_t"yes 1>&6 + compiler_c_o=yes + fi +else + # Append any errors to the config.log. + cat out/conftest.err 1>&5 + compiler_c_o=no + echo "$ac_t"no 1>&6 +fi +CFLAGS="$save_CFLAGS" +chmod u+w . +$rm conftest* out/* +rmdir out +cd .. +rmdir conftest +$rm -r conftest 2>/dev/null + +if test x"$compiler_c_o" = x"yes"; then + # Check to see if we can write to a .lo + echo $ac_n "checking if $compiler supports -c -o file.lo... $ac_c" 1>&6 + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -c -o conftest.lo" + echo "$progname:862: checking if $compiler supports -c -o file.lo" >&5 +if { (eval echo $progname:863: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.lo; then + + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + compiler_o_lo=no + else + echo "$ac_t"yes 1>&6 + compiler_o_lo=yes + fi + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + compiler_o_lo=no + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* +else + compiler_o_lo=no +fi + +# Check to see if we can do hard links to lock some files if needed +hard_links="nottested" +if test "$compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo $ac_n "checking if we can lock with hard links... $ac_c" 1>&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$ac_t$hard_links" 1>&6 + $rm conftest* + if test "$hard_links" = no; then + echo "*** WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2 + need_locks=warn + fi +else + need_locks=no +fi + +if test "$with_gcc" = yes; then + # Check to see if options -fno-rtti -fno-exceptions are supported by compiler + echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions ... $ac_c" 1>&6 + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.c" + echo "$progname:914: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 + if { (eval echo $progname:915: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then + + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + compiler_rtti_exceptions=no + else + echo "$ac_t"yes 1>&6 + compiler_rtti_exceptions=yes + fi + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + compiler_rtti_exceptions=no + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* + + if test "$compiler_rtti_exceptions" = "yes"; then + no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' + else + no_builtin_flag=' -fno-builtin' + fi + +fi + +# Check for any special shared library compilation flags. +if test -n "$special_shlib_compile_flags"; then + echo "$progname: warning: \`$CC' requires \`$special_shlib_compile_flags' to build shared libraries" 1>&2 + if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$special_shlib_compile_flags[ ]" >/dev/null; then : + else + echo "$progname: add \`$special_shlib_compile_flags' to the CC or CFLAGS env variable and reconfigure" 1>&2 + can_build_shared=no + fi +fi + +echo $ac_n "checking if $compiler static flag $link_static_flag works... $ac_c" 1>&6 +$rm conftest* +echo 'main(){return(0);}' > conftest.c +save_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS $link_static_flag" +echo "$progname:958: checking if $compiler static flag $link_static_flag works" >&5 +if { (eval echo $progname:959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + echo "$ac_t$link_static_flag" 1>&6 +else + echo "$ac_t"none 1>&6 + link_static_flag= +fi +LDFLAGS="$save_LDFLAGS" +$rm conftest* + +if test -z "$LN_S"; then + # Check to see if we can use ln -s, or we need hard links. + echo $ac_n "checking whether ln -s works... $ac_c" 1>&6 + $rm conftest.dat + if ln -s X conftest.dat 2>/dev/null; then + $rm conftest.dat + LN_S="ln -s" + else + LN_S=ln + fi + if test "$LN_S" = "ln -s"; then + echo "$ac_t"yes 1>&6 + else + echo "$ac_t"no 1>&6 + fi +fi + +# Make sure LD is an absolute path. +if test -z "$LD"; then + ac_prog=ld + if test "$with_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6 + echo "$progname:991: checking for ld used by GCC" >&5 + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we are not using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac + elif test "$with_gnu_ld" = yes; then + echo $ac_n "checking for GNU ld... $ac_c" 1>&6 + echo "$progname:1015: checking for GNU ld" >&5 + else + echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 + echo "$progname:1018: checking for non-GNU ld" >&5 + fi + + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" + fi + + if test -n "$LD"; then + echo "$ac_t$LD" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + + if test -z "$LD"; then + echo "$progname: error: no acceptable ld found in \$PATH" 1>&2 + exit 1 + fi +fi + +# Check to see if it really is or is not GNU ld. +echo $ac_n "checking if the linker ($LD) is GNU ld... $ac_c" 1>&6 +# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + with_gnu_ld=yes +else + with_gnu_ld=no +fi +echo "$ac_t$with_gnu_ld" 1>&6 + +# See if the linker supports building shared libraries. +echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6 + +allow_undefined_flag= +no_undefined_flag= +need_lib_prefix=unknown +need_version=unknown +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +archive_cmds= +archive_expsym_cmds= +old_archive_from_new_cmds= +export_dynamic_flag_spec= +whole_archive_flag_spec= +thread_safe_flag_spec= +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no +hardcode_shlibpath_var=unsupported +runpath_var= +always_export_symbols=no +export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' +# include_expsyms should be a list of space-separated symbols to be *always* +# included in the symbol list +include_expsyms= +# exclude_expsyms can be an egrep regular expression of symbols to exclude +# it will be wrapped by ` (' and `)$', so one must not match beginning or +# end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', +# as well as any symbol that contains `d'. +exclude_expsyms="_GLOBAL_OFFSET_TABLE_" +# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out +# platforms (ab)use it in PIC code, but their linkers get confused if +# the symbol is explicitly referenced. Since portable code cannot +# rely on this symbol name, it's probably fine to never include it in +# preloaded symbol tables. + +case "$host_os" in +cygwin* | mingw*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$with_gcc" != yes; then + with_gnu_ld=no + fi + ;; + +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case "$host_os" in + aix3* | aix4*) + # On AIX, the GNU linker is very broken + ld_shlibs=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + ;; + + amigaos*) + archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can use + # them. + ld_shlibs=no + ;; + + beos*) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + allow_undefined_flag=unsupported + always_export_symbols=yes + + # Extract the symbol export list from an `--export-all' def file, + # then regenerate the def file from the symbol export list, so that + # the compiled dll only exports the symbol export list. + # Be careful not to strip the DATA tag left by newer dlltools. + export_symbols_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ + test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~ + $DLLTOOL --export-all --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --output-def $objdir/$soname-def $objdir/$soname-ltdll.$objext $libobjs $convenience~ + sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $objdir/$soname-def > $export_symbols' + + # If DATA tags from a recent dlltool are present, honour them! + archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~ + _lt_hint=1; + cat $export_symbols | while read symbol; do + set dummy \$symbol; + case \$# in + 2) echo " \$2 @ \$_lt_hint ; " >> $objdir/$soname-def;; + *) echo " \$2 @ \$_lt_hint \$3 ; " >> $objdir/$soname-def;; + esac; + _lt_hint=`expr 1 + \$_lt_hint`; + done~ + test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ + test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~ + $CC -Wl,--base-file,$objdir/$soname-base -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ + $CC -Wl,--base-file,$objdir/$soname-base $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ + $CC $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts' + + old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $objdir/$soname-def --output-lib $objdir/$libname.a' + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + archive_cmds='$LD -Bshareable $libobjs $deplibs $linkopts -o $lib' + # can we support soname and/or expsyms with a.out? -oliva + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linkopts' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + *) + if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = yes; then + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + case $host_os in + cygwin* | mingw*) + # dlltool doesn't understand --whole-archive et. al. + whole_archive_flag_spec= + ;; + *) + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + ;; + esac + fi +else + # PORTME fill in a description of your system's linker (not GNU ld) + case "$host_os" in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $objdir/$soname $libobjs $deplibs $linkopts -bE:$export_symbols -T512 -H512 -bM:SRE~$AR cru $lib $objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$with_gcc" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix4*) + hardcode_libdir_flag_spec='${wl}-b ${wl}nolibpath ${wl}-b ${wl}libpath:$libdir:/usr/lib:/lib' + hardcode_libdir_separator=':' + if test "$with_gcc" = yes; then + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct=yes + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + shared_flag='-shared' + else + shared_flag='${wl}-bM:SRE' + hardcode_direct=yes + fi + allow_undefined_flag=' ${wl}-berok' + archive_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bexpall ${wl}-bnoentry${allow_undefined_flag}' + archive_expsym_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}' + case "$host_os" in aix4.[01]|aix4.[01].*) + # According to Greg Wooledge, -bexpall is only supported from AIX 4.2 on + always_export_symbols=yes ;; + esac + ;; + + amigaos*) + archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + + cygwin* | mingw*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $linkopts `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_from_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib /OUT:$oldlib$oldobjs' + fix_srcfile_path='`cygpath -w $srcfile`' + ;; + + freebsd1*) + ld_shlibs=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd*) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9* | hpux10* | hpux11*) + case "$host_os" in + hpux9*) archive_cmds='$rm $objdir/$soname~$LD -b +b $install_libdir -o $objdir/$soname $libobjs $deplibs $linkopts~test $objdir/$soname = $lib || mv $objdir/$soname $lib' ;; + *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linkopts' ;; + esac + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + hardcode_minus_L=yes # Not in the search PATH, but as the default + # location of the library. + export_dynamic_flag_spec='${wl}-E' + ;; + + irix5* | irix6*) + if test "$with_gcc" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + archive_cmds='$LD -shared $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linkopts' # ELF + fi + hardcode_libdir_flag_spec='${wl}-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + openbsd*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def~$echo DATA >> $objdir/$libname.def~$echo " SINGLE NONSHARED" >> $objdir/$libname.def~$echo EXPORTS >> $objdir/$libname.def~emxexp $libobjs >> $objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $linkopts $objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def' + ;; + + osf3*) + if test "$with_gcc" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # As osf3* with the addition of the -msym flag + if test "$with_gcc" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + rhapsody*) + archive_cmds='$CC -bundle -undefined suppress -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flags_spec='-L$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + sco3.2v5*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ;; + + solaris*) + no_undefined_flag=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case "$host_os" in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; + esac + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $linkopts' + else + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + fi + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv5*) + no_undefined_flag=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp' + hardcode_libdir_flag_spec= + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4.2uw2*) + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linkopts' + hardcode_direct=yes + hardcode_minus_L=no + hardcode_shlibpath_var=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + unixware7*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac +fi +echo "$ac_t$ld_shlibs" 1>&6 +test "$ld_shlibs" = no && can_build_shared=no + +if test -z "$NM"; then + echo $ac_n "checking for BSD-compatible nm... $ac_c" 1>&6 + case "$NM" in + [\\/]* | [A-Za-z]:[\\/]*) ;; # Let the user override the test with a path. + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for ac_dir in $PATH /usr/ucb /usr/ccs/bin /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + NM="$ac_dir/nm -p" + break + else + NM=${NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$NM" && NM=nm + ;; + esac + echo "$ac_t$NM" 1>&6 +fi + +# Check for command to grab the raw symbol name followed by C symbol from nm. +echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6 + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Transform the above into a raw symbol and a C symbol. +symxfrm='\1 \2\3 \3' + +# Transform an extracted symbol line into a proper C declaration +global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" + +# Define system-specific variables. +case "$host_os" in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw*) + symcode='[ABCDGISTW]' + ;; +hpux*) # Its linker distinguishes data from code symbols + global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'" + ;; +irix*) + symcode='[BCDEGRST]' + ;; +solaris*) + symcode='[BDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then + symcode='[ABCDGISTW]' +fi + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Write the raw and C identifiers. + global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode\)[ ][ ]*\($ac_symprfx\)$sympat$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + $rm conftest* + cat > conftest.c <&5 + if { (eval echo $progname:1654: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.$objext; then + # Now try to grab the symbols. + nlist=conftest.nm + if { echo "$progname:1657: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then + + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if egrep ' nm_test_var$' "$nlist" >/dev/null; then + if egrep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.c +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$global_symbol_to_cdecl"' < "$nlist" >> conftest.c' + + cat <> conftest.c +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[] = +{ +EOF + sed 's/^. \(.*\) \(.*\)$/ {"\2", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c + cat <<\EOF >> conftest.c + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$objext conftstm.$objext + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="conftstm.$objext" + CFLAGS="$CFLAGS$no_builtin_flag" + if { (eval echo $progname:1709: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + pipe_works=yes + else + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + LIBS="$save_LIBS" + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + $rm conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + global_symbol_pipe= + fi +done +if test "$pipe_works" = yes; then + echo "${ac_t}ok" 1>&6 +else + echo "${ac_t}failed" 1>&6 +fi + +if test -z "$global_symbol_pipe"; then + global_symbol_to_cdecl= +fi + +# Check hardcoding attributes. +echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6 +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test -n "$runpath_var"; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$hardcode_shlibpath_var" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +echo "$ac_t$hardcode_action" 1>&6 + + +reload_flag= +reload_cmds='$LD$reload_flag -o $output$reload_objs' +echo $ac_n "checking for $LD option to reload object files... $ac_c" 1>&6 +# PORTME Some linkers may need a different reload flag. +reload_flag='-r' +echo "$ac_t$reload_flag" 1>&6 +test -n "$reload_flag" && reload_flag=" $reload_flag" + +# PORTME Fill in your ld.so characteristics +library_names_spec= +libname_spec='lib$name' +soname_spec= +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +file_magic_cmd= +file_magic_test_file= +deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [regex]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given egrep regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. +echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6 +case "$host_os" in +aix3*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}.so$major' + ;; + +aix4*) + version_type=linux + # AIX has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + # We preserve .a as extension for shared libraries though AIX4.2 + # and later linker supports .so + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.a' + shlibpath_var=LIBPATH + deplibs_check_method=pass_all + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}.so' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + deplibs_check_method=pass_all + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + +bsdi4*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + file_magic_cmd=/usr/bin/file + file_magic_test_file=/shlib/libc.so + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + export_dynamic_flag_spec=-rdynamic + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw*) + version_type=windows + need_version=no + need_lib_prefix=no + if test "$with_gcc" = yes; then + library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.a' + else + library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib' + fi + dynamic_linker='Win32 ld.exe' + deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + file_magic_cmd='${OBJDUMP} -f' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case "$version_type" in + freebsd-elf*) + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object' + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /usr/lib/libc.so*` + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + deplibs_check_method=unknown + library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case "$host_os" in + freebsd2* | freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + dynamic_linker="$host_os dld.sl" + version_type=sunos + need_lib_prefix=no + need_version=no + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' + soname_spec='${libname}${release}.sl$major' + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + case "$host_os" in + hpux10.20*) + # TODO: Does this work for hpux-11 too? + deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' + file_magic_cmd=/usr/bin/file + file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +irix5* | irix6*) + version_type=irix + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}.so.$major' + library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major ${libname}${release}.so $libname.so' + case "$host_os" in + irix5*) + libsuff= shlibsuff= + # this will be overridden with pass_all, but let us keep it just in case + deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" + ;; + *) + case "$LD" in # libtool.m4 will add one of these switches to LD + *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /lib${libsuff}/libc.so*` + deplibs_check_method='pass_all' + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux-gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + deplibs_check_method=pass_all + + if test -f /lib/ld.so.1; then + dynamic_linker='GNU ld.so' + else + # Only the GNU ld.so supports shared libraries on MkLinux. + case "$host_cpu" in + powerpc*) dynamic_linker=no ;; + *) dynamic_linker='Linux ld.so' ;; + esac + fi + ;; + +netbsd*) + version_type=sunos + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' + soname_spec='${libname}${release}.so$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + ;; + +openbsd*) + version_type=sunos + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + need_version=no + fi + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + ;; + +os2*) + libname_spec='$name' + need_lib_prefix=no + library_names_spec='$libname.dll $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_version=no + soname_spec='${libname}${release}.so' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + shlibpath_var=LD_LIBRARY_PATH + # this will be overridden with pass_all, but let us keep it just in case + deplibs_check_method='file_magic COFF format alpha shared library' + file_magic_cmd=/usr/bin/file + file_magic_test_file=/shlib/libc.so + deplibs_check_method='pass_all' + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rhapsody*) + version_type=sunos + library_names_spec='${libname}.so' + soname_spec='${libname}.so' + shlibpath_var=DYLD_LIBRARY_PATH + deplibs_check_method=pass_all + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}.so$major' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + deplibs_check_method="file_magic ELF [0-9][0-9]-bit [LM]SB dynamic lib" + file_magic_cmd=/usr/bin/file + file_magic_test_file=/lib/libc.so + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + case "$host_vendor" in + sequent) + file_magic_cmd='/bin/file' + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + ncr) + deplibs_check_method='pass_all' + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + esac + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' + soname_spec='$libname.so.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$ac_t$dynamic_linker" 1>&6 +test "$dynamic_linker" = no && can_build_shared=no + +# Report the final consequences. +echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6 + +# Only try to build win32 dlls if AC_LIBTOOL_WIN32_DLL was used in +# configure.in, otherwise build static only libraries. +case "$host_os" in +cygwin* | mingw* | os2*) + if test x$can_build_shared = xyes; then + test x$enable_win32_dll = xno && can_build_shared=no + echo "checking if package supports dlls... $can_build_shared" 1>&6 + fi +;; +esac + +if test -n "$file_magic_test_file" && test -n "$file_magic_cmd"; then + case "$deplibs_check_method" in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + egrep "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac +fi + +echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6 +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4*) + test "$enable_shared" = yes && enable_static=no + ;; +esac + +echo "$ac_t$enable_shared" 1>&6 + +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes + +echo "checking whether to build static libraries... $enable_static" 1>&6 + +if test "$hardcode_action" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +echo $ac_n "checking for objdir... $ac_c" 1>&6 +rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + objdir=_libs +fi +rmdir .libs 2>/dev/null +echo "$ac_t$objdir" 1>&6 + +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else +if eval "test \"`echo '$''{'lt_cv_dlopen'+set}'`\" != set"; then + lt_cv_dlopen=no lt_cv_dlopen_libs= +echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 +echo "$progname:2248: checking for dlopen in -ldl" >&5 +ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldl $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for dlopen""... $ac_c" 1>&6 +echo "$progname:2288: checking for dlopen" >&5 +if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_dlopen) || defined (__stub___dlopen) +choke me +#else +dlopen(); +#endif + +; return 0; } +EOF +if { (eval echo $progname:2318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_dlopen=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_dlopen=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dlopen" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6 +echo "$progname:2335: checking for dld_link in -ldld" >&5 +ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldld $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for shl_load""... $ac_c" 1>&6 +echo "$progname:2375: checking for shl_load" >&5 +if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char shl_load(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_shl_load) || defined (__stub___shl_load) +choke me +#else +shl_load(); +#endif + +; return 0; } +EOF +if { (eval echo $progname:2405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_shl_load=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_shl_load=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="shl_load" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6 +echo "$progname:2423: checking for shl_load in -ldld" >&5 +ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldld $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" +else + echo "$ac_t""no" 1>&6 +fi + + +fi + + +fi + + +fi + + +fi + +fi + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + fi + + case "$lt_cv_dlopen" in + dlopen) +for ac_hdr in dlfcn.h; do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "$progname:2488: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +int fnord = 0; +EOF +ac_try="$ac_compile >/dev/null 2>conftest.out" +{ (eval echo $progname:2498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi +done + + if test "x$ac_cv_header_dlfcn_h" = xyes; then + CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + fi + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + LIBS="$lt_cv_dlopen_libs $LIBS" + + echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6 +echo "$progname:2526: checking whether a program can dlopen itself" >&5 +if test "${lt_cv_dlopen_self+set}" = set; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + lt_cv_dlopen_self=cross + else + cat > conftest.c < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LTDL_GLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LTDL_GLOBAL DL_GLOBAL +# else +# define LTDL_GLOBAL 0 +# endif +#endif + +/* We may have to define LTDL_LAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LTDL_LAZY_OR_NOW +# ifdef RTLD_LAZY +# define LTDL_LAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LTDL_LAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LTDL_LAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LTDL_LAZY_OR_NOW DL_NOW +# else +# define LTDL_LAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +fnord() { int i=42;} +main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW); + if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord"); + if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } + +EOF +if { (eval echo $progname:2580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + lt_cv_dlopen_self=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + lt_cv_dlopen_self=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$lt_cv_dlopen_self" 1>&6 + + if test "$lt_cv_dlopen_self" = yes; then + LDFLAGS="$LDFLAGS $link_static_flag" + echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6 +echo "$progname:2599: checking whether a statically linked program can dlopen itself" >&5 +if test "${lt_cv_dlopen_self_static+set}" = set; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + lt_cv_dlopen_self_static=cross + else + cat > conftest.c < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LTDL_GLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LTDL_GLOBAL DL_GLOBAL +# else +# define LTDL_GLOBAL 0 +# endif +#endif + +/* We may have to define LTDL_LAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LTDL_LAZY_OR_NOW +# ifdef RTLD_LAZY +# define LTDL_LAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LTDL_LAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LTDL_LAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LTDL_LAZY_OR_NOW DL_NOW +# else +# define LTDL_LAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +fnord() { int i=42;} +main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW); + if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord"); + if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } + +EOF +if { (eval echo $progname:2653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + lt_cv_dlopen_self_static=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + lt_cv_dlopen_self_static=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6 +fi + ;; + esac + + case "$lt_cv_dlopen_self" in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case "$lt_cv_dlopen_self_static" in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + +# Copy echo and quote the copy, instead of the original, because it is +# used later. +ltecho="$echo" +if test "X$ltecho" = "X$CONFIG_SHELL $0 --fallback-echo"; then + ltecho="$CONFIG_SHELL \$0 --fallback-echo" +fi +LTSHELL="$SHELL" + +LTCONFIG_VERSION="$VERSION" + +# Only quote variables if we're using ltmain.sh. +case "$ltmain" in +*.sh) + # Now quote all the things that may contain metacharacters. + for var in ltecho old_CC old_CFLAGS old_CPPFLAGS \ + old_LD old_LDFLAGS old_LIBS \ + old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS \ + AR CC LD LN_S NM LTSHELL LTCONFIG_VERSION \ + reload_flag reload_cmds wl \ + pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ + thread_safe_flag_spec whole_archive_flag_spec libname_spec \ + library_names_spec soname_spec \ + RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ + old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds postuninstall_cmds \ + file_magic_cmd export_symbols_cmds deplibs_check_method allow_undefined_flag no_undefined_flag \ + finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ + hardcode_libdir_flag_spec hardcode_libdir_separator \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do + + case "$var" in + reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case "$ltecho" in + *'\$0 --fallback-echo"') + ltecho=`$echo "X$ltecho" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + + trap "$rm \"$ofile\"; exit 1" 1 2 15 + echo "creating $ofile" + $rm "$ofile" + cat < "$ofile" +#! $SHELL + +# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltconfig or ltmain.sh. +# +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="sed -e s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi + +### BEGIN LIBTOOL CONFIG +EOF + cfgfile="$ofile" + ;; + +*) + # Double-quote the variables that need it (for aesthetics). + for var in old_CC old_CFLAGS old_CPPFLAGS \ + old_LD old_LDFLAGS old_LIBS \ + old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS; do + eval "$var=\\\"\$var\\\"" + done + + # Just create a config file. + cfgfile="$ofile.cfg" + trap "$rm \"$cfgfile\"; exit 1" 1 2 15 + echo "creating $cfgfile" + $rm "$cfgfile" + cat < "$cfgfile" +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Libtool configuration file. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +EOF + ;; +esac + +cat <> "$cfgfile" +# Libtool was configured as follows, on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# CC=$old_CC CFLAGS=$old_CFLAGS CPPFLAGS=$old_CPPFLAGS \\ +# LD=$old_LD LDFLAGS=$old_LDFLAGS LIBS=$old_LIBS \\ +# NM=$old_NM RANLIB=$old_RANLIB LN_S=$old_LN_S \\ +# DLLTOOL=$old_DLLTOOL OBJDUMP=$old_OBJDUMP AS=$old_AS \\ +# $0$ltconfig_args +# +# Compiler and other test output produced by $progname, useful for +# debugging $progname, is in ./config.log if it exists. + +# The version of $progname that generated this script. +LTCONFIG_VERSION=$LTCONFIG_VERSION + +# Shell to use when invoking shell scripts. +SHELL=$LTSHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$ltecho + +# The archiver. +AR=$AR + +# The default C compiler. +CC=$CC + +# The linker used to build libraries. +LD=$LD + +# Whether we need hard or soft links. +LN_S=$LN_S + +# A BSD-compatible nm program. +NM=$NM + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$reload_flag +reload_cmds=$reload_cmds + +# How to pass a linker flag through the compiler. +wl=$wl + +# Object file suffix (normally "o"). +objext="$objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$pic_flag + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$compiler_c_o + +# Can we write directly to a .lo ? +compiler_o_lo=$compiler_o_lo + +# Must we lock files when doing compilation ? +need_locks=$need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$link_static_flag + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$no_builtin_flag + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$whole_archive_flag_spec + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$thread_safe_flag_spec + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$RANLIB +old_archive_cmds=$old_archive_cmds +old_postinstall_cmds=$old_postinstall_cmds +old_postuninstall_cmds=$old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$old_archive_from_new_cmds + +# Commands used to build and install a shared archive. +archive_cmds=$archive_cmds +archive_expsym_cmds=$archive_expsym_cmds +postinstall_cmds=$postinstall_cmds +postuninstall_cmds=$postuninstall_cmds + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$allow_undefined_flag + +# Flag that forces no undefined symbols. +no_undefined_flag=$no_undefined_flag + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$global_symbol_to_cdecl + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$hardcode_libdir_flag_spec + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$hardcode_libdir_separator + +# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$export_symbols_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$include_expsyms + +EOF + +case "$ltmain" in +*.sh) + echo '### END LIBTOOL CONFIG' >> "$ofile" + echo >> "$ofile" + case "$host_os" in + aix3*) + cat <<\EOF >> "$ofile" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + # Append the ltmain.sh script. + sed '$q' "$ltmain" >> "$ofile" || (rm -f "$ofile"; exit 1) + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + + chmod +x "$ofile" + ;; + +*) + # Compile the libtool program. + echo "FIXME: would compile $ltmain" + ;; +esac + +test -n "$cache_file" || exit 0 + +# AC_CACHE_SAVE +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/salome_adm/unix/config_files/ltmain.sh b/salome_adm/unix/config_files/ltmain.sh new file mode 100644 index 000000000..251394b4d --- /dev/null +++ b/salome_adm/unix/config_files/ltmain.sh @@ -0,0 +1,4028 @@ +# ltmain.sh - Provide generalized library-building support services. +# NOTE: Changing this file will not affect anything until you rerun ltconfig. +# +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Check that we have a working $echo. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell, and then maybe $echo will work. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 +fi + +if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + echo "$modename: not configured to build any kind of library" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 +fi + +# Global variables. +mode=$default_mode +nonopt= +prev= +prevopt= +run= +show="$echo" +show_help= +execute_dlfiles= +lo2o="s/\\.lo\$/.${objext}/" +o2lo="s/\\.${objext}\$/.lo/" + +# Parse our command line options once, thoroughly. +while test $# -gt 0 +do + arg="$1" + shift + + case "$arg" in + -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case "$prev" in + execute_dlfiles) + eval "$prev=\"\$$prev \$arg\"" + ;; + *) + eval "$prev=\$arg" + ;; + esac + + prev= + prevopt= + continue + fi + + # Have we seen a non-optional argument yet? + case "$arg" in + --help) + show_help=yes + ;; + + --version) + echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" + exit 0 + ;; + + --config) + sed -e '1,/^### BEGIN LIBTOOL CONFIG/d' -e '/^### END LIBTOOL CONFIG/,$d' $0 + exit 0 + ;; + + --debug) + echo "$progname: enabling shell trace mode" + set -x + ;; + + --dry-run | -n) + run=: + ;; + + --features) + echo "host: $host" + if test "$build_libtool_libs" = yes; then + echo "enable shared libraries" + else + echo "disable shared libraries" + fi + if test "$build_old_libs" = yes; then + echo "enable static libraries" + else + echo "disable static libraries" + fi + exit 0 + ;; + + --finish) mode="finish" ;; + + --mode) prevopt="--mode" prev=mode ;; + --mode=*) mode="$optarg" ;; + + --quiet | --silent) + show=: + ;; + + -dlopen) + prevopt="-dlopen" + prev=execute_dlfiles + ;; + + -*) + $echo "$modename: unrecognized option \`$arg'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + + *) + nonopt="$arg" + break + ;; + esac +done + +if test -n "$prevopt"; then + $echo "$modename: option \`$prevopt' requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 +fi + +if test -z "$show_help"; then + + # Infer the operation mode. + if test -z "$mode"; then + case "$nonopt" in + *cc | *++ | gcc* | *-gcc*) + mode=link + for arg + do + case "$arg" in + -c) + mode=compile + break + ;; + esac + done + ;; + *db | *dbx | *strace | *truss) + mode=execute + ;; + *install*|cp|mv) + mode=install + ;; + *rm) + mode=uninstall + ;; + *) + # If we have no mode, but dlfiles were specified, then do execute mode. + test -n "$execute_dlfiles" && mode=execute + + # Just use the default operation mode. + if test -z "$mode"; then + if test -n "$nonopt"; then + $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 + else + $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 + fi + fi + ;; + esac + fi + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + $echo "$modename: unrecognized option \`-dlopen'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$modename --help --mode=$mode' for more information." + + # These modes are in order of execution frequency so that they run quickly. + case "$mode" in + # libtool compile mode + compile) + modename="$modename: compile" + # Get the compilation command and the source file. + base_compile= + lastarg= + srcfile="$nonopt" + suppress_output= + + user_target=no + for arg + do + # Accept any command-line options. + case "$arg" in + -o) + if test "$user_target" != "no"; then + $echo "$modename: you cannot specify \`-o' more than once" 1>&2 + exit 1 + fi + user_target=next + ;; + + -static) + build_old_libs=yes + continue + ;; + esac + + case "$user_target" in + next) + # The next one is the -o target name + user_target=yes + continue + ;; + yes) + # We got the output file + user_target=set + libobj="$arg" + continue + ;; + esac + + # Accept the current argument as the source file. + lastarg="$srcfile" + srcfile="$arg" + + # Aesthetically quote the previous argument. + + # Backslashify any backslashes, double quotes, and dollar signs. + # These are the only characters that are still specially + # interpreted inside of double-quoted scrings. + lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` + + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly in scan + # sets, so we specify it separately. + case "$lastarg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + lastarg="\"$lastarg\"" + ;; + esac + + # Add the previous argument to base_compile. + if test -z "$base_compile"; then + base_compile="$lastarg" + else + base_compile="$base_compile $lastarg" + fi + done + + case "$user_target" in + set) + ;; + no) + # Get the name of the library object. + libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` + ;; + *) + $echo "$modename: you must specify a target with \`-o'" 1>&2 + exit 1 + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + xform='[cCFSfmso]' + case "$libobj" in + *.ada) xform=ada ;; + *.adb) xform=adb ;; + *.ads) xform=ads ;; + *.asm) xform=asm ;; + *.c++) xform=c++ ;; + *.cc) xform=cc ;; + *.cpp) xform=cpp ;; + *.cxx) xform=cxx ;; + *.f90) xform=f90 ;; + *.for) xform=for ;; + esac + + libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` + + case "$libobj" in + *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; + *) + $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 + exit 1 + ;; + esac + + if test -z "$base_compile"; then + $echo "$modename: you must specify a compilation command" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + removelist="$obj $libobj" + else + removelist="$libobj" + fi + + $run $rm $removelist + trap "$run $rm $removelist; exit 1" 1 2 15 + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test "$compiler_c_o" = no; then + output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\..*$%%'`.${objext} + lockfile="$output_obj.lock" + removelist="$removelist $output_obj $lockfile" + trap "$run $rm $removelist; exit 1" 1 2 15 + else + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test "$need_locks" = yes; then + until ln "$0" "$lockfile" 2>/dev/null; do + $show "Waiting for $lockfile to be removed" + sleep 2 + done + elif test "$need_locks" = warn; then + if test -f "$lockfile"; then + echo "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + echo $srcfile > "$lockfile" + fi + + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi + + # Only build a PIC object if we are building libtool libraries. + if test "$build_libtool_libs" = yes; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + # All platforms use -DPIC, to notify preprocessed assembler code. + command="$base_compile $srcfile $pic_flag -DPIC" + if test "$build_old_libs" = yes; then + lo_libobj="$libobj" + dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$libobj"; then + dir="$objdir" + else + dir="$dir/$objdir" + fi + libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` + + if test -d "$dir"; then + $show "$rm $libobj" + $run $rm $libobj + else + $show "$mkdir $dir" + $run $mkdir $dir + status=$? + if test $status -ne 0 && test ! -d $dir; then + exit $status + fi + fi + fi + if test "$compiler_o_lo" = yes; then + output_obj="$libobj" + command="$command -o $output_obj" + elif test "$compiler_c_o" = yes; then + output_obj="$obj" + command="$command -o $output_obj" + fi + + $run $rm "$output_obj" + $show "$command" + if $run eval "$command"; then : + else + test -n "$output_obj" && $run $rm $removelist + exit 1 + fi + + if test "$need_locks" = warn && + test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then + echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + + # Just move the object if needed, then go on to compile the next one + if test x"$output_obj" != x"$libobj"; then + $show "$mv $output_obj $libobj" + if $run $mv $output_obj $libobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # If we have no pic_flag, then copy the object into place and finish. + if test -z "$pic_flag" && test "$build_old_libs" = yes; then + # Rename the .lo from within objdir to obj + if test -f $obj; then + $show $rm $obj + $run $rm $obj + fi + + $show "$mv $libobj $obj" + if $run $mv $libobj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"` + libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` + # Now arrange that obj and lo_libobj become the same file + $show "(cd $xdir && $LN_S $baseobj $libobj)" + if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then + exit 0 + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Allow error messages only from the first compilation. + suppress_output=' >/dev/null 2>&1' + fi + + # Only build a position-dependent object if we build old libraries. + if test "$build_old_libs" = yes; then + command="$base_compile $srcfile" + if test "$compiler_c_o" = yes; then + command="$command -o $obj" + output_obj="$obj" + fi + + # Suppress compiler output if we already did a PIC compilation. + command="$command$suppress_output" + $run $rm "$output_obj" + $show "$command" + if $run eval "$command"; then : + else + $run $rm $removelist + exit 1 + fi + + if test "$need_locks" = warn && + test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then + echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + + # Just move the object if needed + if test x"$output_obj" != x"$obj"; then + $show "$mv $output_obj $obj" + if $run $mv $output_obj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Create an invalid libtool object if no PIC, so that we do not + # accidentally link it into a program. + if test "$build_libtool_libs" != yes; then + $show "echo timestamp > $libobj" + $run eval "echo timestamp > \$libobj" || exit $? + else + # Move the .lo from within objdir + $show "$mv $libobj $lo_libobj" + if $run $mv $libobj $lo_libobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + fi + + # Unlock the critical section if it was locked + if test "$need_locks" != no; then + $rm "$lockfile" + fi + + exit 0 + ;; + + # libtool link mode + link) + modename="$modename: link" + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # which system we are compiling for in order to pass an extra + # flag for every libtool invokation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll which has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + + # This is a source program that is used to create dlls on Windows + # Don't remove nor modify the starting and closing comments +# /* ltdll.c starts here */ +# #define WIN32_LEAN_AND_MEAN +# #include +# #undef WIN32_LEAN_AND_MEAN +# #include +# +# #ifndef __CYGWIN__ +# # ifdef __CYGWIN32__ +# # define __CYGWIN__ __CYGWIN32__ +# # endif +# #endif +# +# #ifdef __cplusplus +# extern "C" { +# #endif +# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); +# #ifdef __cplusplus +# } +# #endif +# +# #ifdef __CYGWIN__ +# #include +# DECLARE_CYGWIN_DLL( DllMain ); +# #endif +# HINSTANCE __hDllInstance_base; +# +# BOOL APIENTRY +# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) +# { +# __hDllInstance_base = hInst; +# return TRUE; +# } +# /* ltdll.c ends here */ + # This is a source program that is used to create import libraries + # on Windows for dlls which lack them. Don't remove nor modify the + # starting and closing comments +# /* impgen.c starts here */ +# /* Copyright (C) 1999 Free Software Foundation, Inc. +# +# This file is part of GNU libtool. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# */ +# +# #include /* for printf() */ +# #include /* for open(), lseek(), read() */ +# #include /* for O_RDONLY, O_BINARY */ +# #include /* for strdup() */ +# +# static unsigned int +# pe_get16 (fd, offset) +# int fd; +# int offset; +# { +# unsigned char b[2]; +# lseek (fd, offset, SEEK_SET); +# read (fd, b, 2); +# return b[0] + (b[1]<<8); +# } +# +# static unsigned int +# pe_get32 (fd, offset) +# int fd; +# int offset; +# { +# unsigned char b[4]; +# lseek (fd, offset, SEEK_SET); +# read (fd, b, 4); +# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); +# } +# +# static unsigned int +# pe_as32 (ptr) +# void *ptr; +# { +# unsigned char *b = ptr; +# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); +# } +# +# int +# main (argc, argv) +# int argc; +# char *argv[]; +# { +# int dll; +# unsigned long pe_header_offset, opthdr_ofs, num_entries, i; +# unsigned long export_rva, export_size, nsections, secptr, expptr; +# unsigned long name_rvas, nexp; +# unsigned char *expdata, *erva; +# char *filename, *dll_name; +# +# filename = argv[1]; +# +# dll = open(filename, O_RDONLY|O_BINARY); +# if (!dll) +# return 1; +# +# dll_name = filename; +# +# for (i=0; filename[i]; i++) +# if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') +# dll_name = filename + i +1; +# +# pe_header_offset = pe_get32 (dll, 0x3c); +# opthdr_ofs = pe_header_offset + 4 + 20; +# num_entries = pe_get32 (dll, opthdr_ofs + 92); +# +# if (num_entries < 1) /* no exports */ +# return 1; +# +# export_rva = pe_get32 (dll, opthdr_ofs + 96); +# export_size = pe_get32 (dll, opthdr_ofs + 100); +# nsections = pe_get16 (dll, pe_header_offset + 4 +2); +# secptr = (pe_header_offset + 4 + 20 + +# pe_get16 (dll, pe_header_offset + 4 + 16)); +# +# expptr = 0; +# for (i = 0; i < nsections; i++) +# { +# char sname[8]; +# unsigned long secptr1 = secptr + 40 * i; +# unsigned long vaddr = pe_get32 (dll, secptr1 + 12); +# unsigned long vsize = pe_get32 (dll, secptr1 + 16); +# unsigned long fptr = pe_get32 (dll, secptr1 + 20); +# lseek(dll, secptr1, SEEK_SET); +# read(dll, sname, 8); +# if (vaddr <= export_rva && vaddr+vsize > export_rva) +# { +# expptr = fptr + (export_rva - vaddr); +# if (export_rva + export_size > vaddr + vsize) +# export_size = vsize - (export_rva - vaddr); +# break; +# } +# } +# +# expdata = (unsigned char*)malloc(export_size); +# lseek (dll, expptr, SEEK_SET); +# read (dll, expdata, export_size); +# erva = expdata - export_rva; +# +# nexp = pe_as32 (expdata+24); +# name_rvas = pe_as32 (expdata+32); +# +# printf ("EXPORTS\n"); +# for (i = 0; i&2 + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + else + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + fi + build_libtool_libs=no + build_old_libs=yes + prefer_static_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test $# -gt 0; do + arg="$1" + shift + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case "$prev" in + output) + compile_command="$compile_command @OUTPUT@" + finalize_command="$finalize_command @OUTPUT@" + ;; + esac + + case "$prev" in + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$finalize_command @SYMFILE@" + preload=yes + fi + case "$arg" in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + else + dlprefiles="$dlprefiles $arg" + fi + prev= + ;; + esac + ;; + expsyms) + export_symbols="$arg" + if test ! -f "$arg"; then + $echo "$modename: symbol file \`$arg' does not exist" + exit 1 + fi + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + release) + release="-$arg" + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case "$arg" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit 1 + ;; + esac + if test "$prev" = rpath; then + case "$rpath " in + *" $arg "*) ;; + *) rpath="$rpath $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) xrpath="$xrpath $arg" ;; + esac + fi + prev= + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi + + prevarg="$arg" + + case "$arg" in + -all-static) + if test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 + continue + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: not more than one -exported-symbols argument allowed" + exit 1 + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -L*) + dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` + # We need an absolute path. + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + absdir="$dir" + fi + dir="$absdir" + ;; + esac + case " $deplibs " in + *" $arg "*) ;; + *) deplibs="$deplibs $arg";; + esac + case " $lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir";; + esac + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2*) + dllsearchdir=`cd "$dir" && pwd || echo "$dir"` + case ":$dllsearchpath:" in + ::) dllsearchpath="$dllsearchdir";; + *":$dllsearchdir:"*) ;; + *) dllsearchpath="$dllsearchpath:$dllsearchdir";; + esac + ;; + esac + ;; + + -l*) + if test "$arg" = "-lc"; then + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*) + # These systems don't actually have c library (as such) + continue + ;; + esac + elif test "$arg" = "-lm"; then + case "$host" in + *-*-cygwin* | *-*-beos*) + # These systems don't actually have math library (as such) + continue + ;; + esac + fi + deplibs="$deplibs $arg" + ;; + + -module) + module=yes + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -o) prev=output ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` + # We need an absolute path. + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit 1 + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -static) + # If we have no pic_flag, then this is the same as -all-static. + if test -z "$pic_flag" && test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + + # Some other compiler flag. + -* | +*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + ;; + + *.o | *.obj | *.a | *.lib) + # A standard object. + objs="$objs $arg" + ;; + + *.lo) + # A library object. + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + if test "$build_libtool_libs" = yes && test "$dlopen" = yes; then + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"` + prev= + fi + libobjs="$libobjs $arg" + ;; + + *.la) + # A libtool-controlled library. + + dlname= + libdir= + library_names= + old_library= + + # Check to see that this really is a libtool archive. + if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2 + exit 1 + fi + + # If the library was installed with an old release of libtool, + # it will not redefine variable installed. + installed=yes + + # Read the .la file + # If there is no directory component, then add one. + case "$arg" in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + + if test -z "$linklib"; then + $echo "$modename: cannot find name of link library for \`$arg'" 1>&2 + exit 1 + fi + + # Find the relevant object directory and library name. + name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'` + + if test "X$installed" = Xyes; then + dir="$libdir" + else + dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$arg"; then + dir="$objdir" + else + dir="$dir/$objdir" + fi + fi + + if test -n "$dependency_libs"; then + # Extract -R and -L from dependency_libs + temp_deplibs= + for deplib in $dependency_libs; do + case "$deplib" in + -R*) temp_xrpath=`$echo "X$deplib" | $Xsed -e 's/^-R//'` + case " $rpath $xrpath " in + *" $temp_xrpath "*) ;; + *) xrpath="$xrpath $temp_xrpath";; + esac;; + -L*) case "$compile_command $temp_deplibs " in + *" $deplib "*) ;; + *) temp_deplibs="$temp_deplibs $deplib";; + esac + temp_dir=`$echo "X$deplib" | $Xsed -e 's/^-L//'` + case " $lib_search_path " in + *" $temp_dir "*) ;; + *) lib_search_path="$lib_search_path $temp_dir";; + esac + ;; + *) temp_deplibs="$temp_deplibs $deplib";; + esac + done + dependency_libs="$temp_deplibs" + fi + + if test -z "$libdir"; then + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $dir/$old_library" + old_convenience="$old_convenience $dir/$old_library" + deplibs="$deplibs$dependency_libs" + compile_command="$compile_command $dir/$old_library$dependency_libs" + finalize_command="$finalize_command $dir/$old_library$dependency_libs" + continue + fi + + # This library was specified with -dlopen. + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + if test -z "$dlname" || test "$dlopen" != yes || test "$build_libtool_libs" = no; then + # If there is no dlname, no dlopen support or we're linking statically, + # we need to preload. + prev=dlprefiles + else + # We should not create a dependency on this library, but we + # may need any libraries it requires. + compile_command="$compile_command$dependency_libs" + finalize_command="$finalize_command$dependency_libs" + prev= + continue + fi + fi + + # The library was specified with -dlpreopen. + if test "$prev" = dlprefiles; then + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + dlprefiles="$dlprefiles $dir/$old_library" + else + dlprefiles="$dlprefiles $dir/$linklib" + fi + prev= + fi + + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + link_against_libtool_libs="$link_against_libtool_libs $arg" + if test -n "$shlibpath_var"; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + *" $dir "*) ;; + *) temp_rpath="$temp_rpath $dir" ;; + esac + fi + + # We need an absolute path. + case "$dir" in + [\\/] | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + absdir="$dir" + fi + ;; + esac + + # This is the magic to use -rpath. + # Skip directories that are in the system default run-time + # search path, unless they have been requested with -R. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + + lib_linked=yes + case "$hardcode_action" in + immediate | unsupported) + if test "$hardcode_direct" = no; then + compile_command="$compile_command $dir/$linklib" + deplibs="$deplibs $dir/$linklib" + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2*) + dllsearchdir=`cd "$dir" && pwd || echo "$dir"` + if test -n "$dllsearchpath"; then + dllsearchpath="$dllsearchpath:$dllsearchdir" + else + dllsearchpath="$dllsearchdir" + fi + ;; + esac + elif test "$hardcode_minus_L" = no; then + case "$host" in + *-*-sunos*) + compile_shlibpath="$compile_shlibpath$dir:" + ;; + esac + case "$compile_command " in + *" -L$dir "*) ;; + *) compile_command="$compile_command -L$dir";; + esac + compile_command="$compile_command -l$name" + deplibs="$deplibs -L$dir -l$name" + elif test "$hardcode_shlibpath_var" = no; then + case ":$compile_shlibpath:" in + *":$dir:"*) ;; + *) compile_shlibpath="$compile_shlibpath$dir:";; + esac + compile_command="$compile_command -l$name" + deplibs="$deplibs -l$name" + else + lib_linked=no + fi + ;; + + relink) + if test "$hardcode_direct" = yes; then + compile_command="$compile_command $absdir/$linklib" + deplibs="$deplibs $absdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + case "$compile_command " in + *" -L$absdir "*) ;; + *) compile_command="$compile_command -L$absdir";; + esac + compile_command="$compile_command -l$name" + deplibs="$deplibs -L$absdir -l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case ":$compile_shlibpath:" in + *":$absdir:"*) ;; + *) compile_shlibpath="$compile_shlibpath$absdir:";; + esac + compile_command="$compile_command -l$name" + deplibs="$deplibs -l$name" + else + lib_linked=no + fi + ;; + + *) + lib_linked=no + ;; + esac + + if test "$lib_linked" != yes; then + $echo "$modename: configuration error: unsupported hardcode properties" + exit 1 + fi + + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes; then + finalize_command="$finalize_command $libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + case "$finalize_command " in + *" -L$libdir "*) ;; + *) finalize_command="$finalize_command -L$libdir";; + esac + finalize_command="$finalize_command -l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case ":$finalize_shlibpath:" in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:";; + esac + finalize_command="$finalize_command -l$name" + else + # We cannot seem to hardcode it, guess we'll fake it. + case "$finalize_command " in + *" -L$dir "*) ;; + *) finalize_command="$finalize_command -L$libdir";; + esac + finalize_command="$finalize_command -l$name" + fi + else + # Transform directly to old archives if we don't build new libraries. + if test -n "$pic_flag" && test -z "$old_library"; then + $echo "$modename: cannot find static library for \`$arg'" 1>&2 + exit 1 + fi + + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_command="$compile_command $dir/$linklib" + finalize_command="$finalize_command $dir/$linklib" + else + case "$compile_command " in + *" -L$dir "*) ;; + *) compile_command="$compile_command -L$dir";; + esac + compile_command="$compile_command -l$name" + case "$finalize_command " in + *" -L$dir "*) ;; + *) finalize_command="$finalize_command -L$dir";; + esac + finalize_command="$finalize_command -l$name" + fi + fi + + # Add in any libraries that this one depends upon. + compile_command="$compile_command$dependency_libs" + finalize_command="$finalize_command$dependency_libs" + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + ;; + esac + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + done + + if test -n "$prev"; then + $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` + libobjs_save="$libobjs" + + case "$output" in + "") + $echo "$modename: you must specify an output file" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + + *.a | *.lib) + if test -n "$link_against_libtool_libs"; then + $echo "$modename: error: cannot link libtool libraries into archives" 1>&2 + exit 1 + fi + + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 + fi + + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 + fi + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs="$output" + ;; + + *.la) + # Make sure we only generate libraries of the form `libNAME.la'. + case "$outputname" in + lib*) + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + eval libname=\"$libname_spec\" + ;; + *) + if test "$module" = no; then + $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + eval libname=\"$libname_spec\" + else + libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + fi + ;; + esac + + output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` + if test "X$output_objdir" = "X$output"; then + output_objdir="$objdir" + else + output_objdir="$output_objdir/$objdir" + fi + + if test -n "$objs"; then + $echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1 + exit 1 + fi + + # How the heck are we supposed to write a wrapper for a shared library? + if test -n "$link_against_libtool_libs"; then + $echo "$modename: error: cannot link shared libraries into libtool libraries" 1>&2 + exit 1 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for libtool libraries" 1>&2 + fi + + set dummy $rpath + if test $# -gt 2; then + $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 + fi + install_libdir="$2" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; then + # Building a libtool convenience library. + libext=al + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + dependency_libs="$deplibs" + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 + fi + else + + # Parse the version information argument. + IFS="${IFS= }"; save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + IFS="$save_ifs" + + if test -n "$8"; then + $echo "$modename: too many parameters to \`-version-info'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + current="$2" + revision="$3" + age="$4" + + # Check that each of the things are valid numbers. + case "$current" in + [0-9]*) ;; + *) + $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case "$revision" in + [0-9]*) ;; + *) + $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case "$age" in + [0-9]*) ;; + *) + $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + if test $age -gt $current; then + $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case "$version_type" in + none) ;; + + irix) + major=`expr $current - $age + 1` + versuffix="$major.$revision" + verstring="sgi$major.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test $loop != 0; do + iface=`expr $revision - $loop` + loop=`expr $loop - 1` + verstring="sgi$major.$iface:$verstring" + done + ;; + + linux) + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + ;; + + osf) + major=`expr $current - $age` + versuffix=".$current.$age.$revision" + verstring="$current.$age.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test $loop != 0; do + iface=`expr $current - $loop` + loop=`expr $loop - 1` + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current"; + ;; + + windows) + # Like Linux, but with '-' rather than '.', since we only + # want one extension on Windows 95. + major=`expr $current - $age` + versuffix="-$major-$age-$revision" + ;; + + *) + $echo "$modename: unknown library version type \`$version_type'" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + verstring="0.0" + if test "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + + dependency_libs="$deplibs" + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody*) + # rhapsody is a little odd... + deplibs="$deplibs -framework System" + ;; + *) + # Add libc to deplibs on all other systems. + deplibs="$deplibs -lc" + ;; + esac + fi + + # Create the output directory, or remove our outputs if we need to. + if test -d $output_objdir; then + $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*" + $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.* + else + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + status=$? + if test $status -ne 0 && test ! -d $output_objdir; then + exit $status + fi + fi + + # Now set the variables for building old libraries. + if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + oldlibs="$oldlibs $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` + fi + + if test "$build_libtool_libs" = yes; then + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release="" + versuffix="" + major="" + newdeplibs= + droppeddeps=no + case "$deplibs_check_method" in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behaviour. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $rm conftest.c + cat > conftest.c </dev/null` + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null \ + | grep " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib="$potent_lib" + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | sed 's/.* -> //'` + case "$potliblink" in + [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; + *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ + | sed 10q \ + | egrep "$file_magic_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + if test -n "$a_deplib" ; then + droppeddeps=yes + echo + echo "*** Warning: This library needs some functionality provided by $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ + -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' | + grep . >/dev/null; then + echo + if test "X$deplibs_check_method" = "Xnone"; then + echo "*** Warning: inter-library dependencies are not supported in this platform." + else + echo "*** Warning: inter-library dependencies are not known to be supported." + fi + echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + fi + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + if test "$droppeddeps" = yes; then + if test "$module" = yes; then + echo + echo "*** Warning: libtool could not satisfy all declared inter-library" + echo "*** dependencies of module $libname. Therefore, libtool will create" + echo "*** a static module, that should work as long as the dlopening" + echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + echo "*** The inter-library dependencies that have been dropped here will be" + echo "*** automatically added whenever a program is linked with this library" + echo "*** or is declared to -dlopen it." + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test "$build_libtool_libs" = yes; then + # Get the real and link names of the library. + eval library_names=\"$library_names_spec\" + set dummy $library_names + realname="$2" + shift; shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + lib="$output_objdir/$realname" + for link + do + linknames="$linknames $link" + done + + # Ensure that we have .o objects for linkers which dislike .lo + # (e.g. aix) in case we are running --disable-static + for obj in $libobjs; do + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` + if test ! -f $xdir/$oldobj; then + $show "(cd $xdir && ${LN_S} $baseobj $oldobj)" + $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $? + fi + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + eval cmds=\"$export_symbols_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + if test -n "$export_symbols_regex"; then + $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" + $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + $show "$mv \"${export_symbols}T\" \"$export_symbols\"" + $run eval '$mv "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' + fi + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + for xlib in $convenience; do + # Extract the objects. + case "$xlib" in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` + done + fi + fi + + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + linkopts="$linkopts $flag" + fi + + # Do each of the archive commands. + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval cmds=\"$archive_expsym_cmds\" + else + eval cmds=\"$archive_cmds\" + fi + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + *.lo | *.o | *.obj) + if test -n "$link_against_libtool_libs"; then + $echo "$modename: error: cannot link libtool libraries into objects" 1>&2 + exit 1 + fi + + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 + fi + + case "$output" in + *.lo) + if test -n "$objs"; then + $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 + exit 1 + fi + libobj="$output" + obj=`$echo "X$output" | $Xsed -e "$lo2o"` + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $run $rm $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # reload_cmds runs $LD directly, so let us get rid of + # -Wl from whole_archive_flag_spec + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${obj}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + for xlib in $convenience; do + # Extract the objects. + case "$xlib" in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` + done + fi + fi + + # Create the old-style object. + reload_objs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" + + output="$obj" + eval cmds=\"$reload_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit 0 + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + $show "echo timestamp > $libobj" + $run eval "echo timestamp > $libobj" || exit $? + exit 0 + fi + + if test -n "$pic_flag"; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output="$libobj" + eval cmds=\"$reload_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + else + # Just create a symlink. + $show $rm $libobj + $run $rm $libobj + xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$libobj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` + oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` + $show "(cd $xdir && $LN_S $oldobj $baseobj)" + $run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $? + fi + + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit 0 + ;; + + # Anything else should be a program. + *) + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 + fi + + if test "$preload" = yes; then + if test "$dlopen" = unknown && test "$dlopen_self" = unknown && + test "$dlopen_self_static" = unknown; then + $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." + fi + fi + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$compile_rpath " in + *" $libdir "*) ;; + *) compile_rpath="$compile_rpath $libdir" ;; + esac + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath="$rpath" + + output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` + if test "X$output_objdir" = "X$output"; then + output_objdir="$objdir" + else + output_objdir="$output_objdir/$objdir" + fi + + # Create the binary in the object directory, then wrap it. + if test ! -d $output_objdir; then + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + status=$? + if test $status -ne 0 && test ! -d $output_objdir; then + exit $status + fi + fi + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + fi + + dlsyms= + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + dlsyms="${outputname}S.c" + else + $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 + fi + fi + + if test -n "$dlsyms"; then + case "$dlsyms" in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${outputname}.nm" + + $show "$rm $nlist ${nlist}S ${nlist}T" + $run $rm "$nlist" "${nlist}S" "${nlist}T" + + # Parse the name list into a source file. + $show "creating $output_objdir/$dlsyms" + + test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ +/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ +/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* Prevent the only kind of declaration conflicts we can make. */ +#define lt_preloaded_symbols some_other_symbol + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + $show "generating symbol list for \`$output'" + + test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$echo "X$objs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + for arg in $progfiles; do + $show "extracting global C symbols from \`$arg'" + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + if test -n "$export_symbols_regex"; then + $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$output.exp" + $run $rm $export_symbols + $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + else + $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' + $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' + $run eval 'mv "$nlist"T "$nlist"' + fi + fi + + for arg in $dlprefiles; do + $show "extracting global C symbols from \`$arg'" + name=`echo "$arg" | sed -e 's%^.*/%%'` + $run eval 'echo ": $name " >> "$nlist"' + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -z "$run"; then + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $mv "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then + : + else + grep -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' + else + echo '/* NONE */' >> "$output_objdir/$dlsyms" + fi + + $echo >> "$output_objdir/$dlsyms" "\ + +#undef lt_preloaded_symbols + +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[] = +{\ +" + + sed -n -e 's/^: \([^ ]*\) $/ {\"\1\", (lt_ptr_t) 0},/p' \ + -e 's/^. \([^ ]*\) \([^ ]*\)$/ {"\2", (lt_ptr_t) \&\2},/p' \ + < "$nlist" >> "$output_objdir/$dlsyms" + + $echo >> "$output_objdir/$dlsyms" "\ + {0, (lt_ptr_t) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + fi + + pic_flag_for_symtable= + case "$host" in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";; + esac;; + *-*-hpux*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DPIC";; + esac + esac + + # Now compile the dynamic symbol file. + $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + + # Clean up the generated files. + $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" + $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" + + # Transform the symbol file into the correct name. + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + ;; + *) + $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 + exit 1 + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi + + if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + $show "$link_command" + $run eval "$link_command" + status=$? + + # Delete the generated files. + if test -n "$dlsyms"; then + $show "$rm $output_objdir/${outputname}S.${objext}" + $run $rm "$output_objdir/${outputname}S.${objext}" + fi + + exit $status + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 + $echo "$modename: \`$output' will be relinked during installation" 1>&2 + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname + + $show "$link_command" + $run eval "$link_command" || exit $? + + # Now create the wrapper script. + $show "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $echo for shipping. + if test "X$echo" = "X$SHELL $0 --fallback-echo"; then + case "$0" in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; + *) qecho="$SHELL `pwd`/$0 --fallback-echo";; + esac + qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) output=`echo $output|sed 's,.exe$,,'` ;; + esac + $rm $output + trap "$rm $output; exit 1" 1 2 15 + + $echo > $output "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variable: + link_against_libtool_libs='$link_against_libtool_libs' +else + # When we are sourced in execute mode, \$file and \$echo are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + echo=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$echo works! + : + else + # Restart under the correct shell, and then maybe \$echo will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $echo >> $output "\ + + # Find the directory that this script lives in. + thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` + done + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + echo >> $output "\ + program=lt-'$outputname' + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $mkdir \"\$progdir\" + else + $rm \"\$progdir/\$file\" + fi" + + echo >> $output "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if (cd \"\$thisdir\" && eval \$relink_command); then : + else + $rm \"\$progdir/\$file\" + exit 1 + fi + fi + + $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $rm \"\$progdir/\$program\"; + $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $rm \"\$progdir/\$file\" + fi" + else + echo >> $output "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + echo >> $output "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $echo >> $output "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $echo >> $output "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $echo >> $output "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + # win32 systems need to use the prog path for dll + # lookup to work + *-*-cygwin*) + $echo >> $output "\ + exec \$progdir/\$program \${1+\"\$@\"} +" + ;; + + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2*) + $echo >> $output "\ + exec \$progdir\\\\\$program \${1+\"\$@\"} +" + ;; + + *) + $echo >> $output "\ + # Export the path to the program. + PATH=\"\$progdir:\$PATH\" + export PATH + + exec \$program \${1+\"\$@\"} +" + ;; + esac + $echo >> $output "\ + \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" + exit 1 + fi + else + # The program doesn't exist. + \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 + \$echo \"This script is just a wrapper for \$program.\" 1>&2 + echo \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" + chmod +x $output + fi + exit 0 + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$objs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP` + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + # Add in members from convenience archives. + for xlib in $addlibs; do + # Extract the objects. + case "$xlib" in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` + done + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + eval cmds=\"$old_archive_from_new_cmds\" + else + # Ensure that we have .o objects in place in case we decided + # not to build a shared library, and have fallen back to building + # static libs even though --disable-static was passed! + for oldobj in $oldobjs; do + if test ! -f $oldobj; then + xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$oldobj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'` + obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` + $show "(cd $xdir && ${LN_S} $obj $baseobj)" + $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $? + fi + done + + eval cmds=\"$old_archive_cmds\" + fi + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$generated"; then + $show "${rm}r$generated" + $run ${rm}r$generated + fi + + # Now create the libtool archive. + case "$output" in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + $show "creating $output" + + if test -n "$xrpath"; then + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + done + dependency_libs="$temp_xrpath $dependency_libs" + fi + + # Only create the output if not a dry run. + if test -z "$run"; then + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + fi + $rm $output + $echo > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$dlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Directory that this library needs to be installed in: +libdir='$install_libdir'\ +" + done + fi + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" + $run eval "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" || exit $? + ;; + esac + exit 0 + ;; + + # libtool install mode + install) + modename="$modename: install" + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh; then + # Aesthetically quote it. + arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$arg " + arg="$1" + shift + else + install_prog= + arg="$nonopt" + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog$arg" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest="$arg" + continue + fi + + case "$arg" in + -d) isdir=yes ;; + -f) prev="-f" ;; + -g) prev="-g" ;; + -m) prev="-m" ;; + -o) prev="-o" ;; + -s) + stripme=" -s" + continue + ;; + -*) ;; + + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest="$arg" + continue + fi + ;; + esac + + # Aesthetically quote the argument. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog $arg" + done + + if test -z "$install_prog"; then + $echo "$modename: you must specify an install program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -n "$prev"; then + $echo "$modename: the \`$prev' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -z "$files"; then + if test -z "$dest"; then + $echo "$modename: no file or destination specified" 1>&2 + else + $echo "$modename: you must specify a destination" 1>&2 + fi + $echo "$help" 1>&2 + exit 1 + fi + + # Strip any trailing slash from the destination. + dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` + test "X$destdir" = "X$dest" && destdir=. + destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test $# -gt 2; then + $echo "$modename: \`$dest' is not a directory" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + fi + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case "$file" in + *.lo) ;; + *) + $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case "$file" in + *.a | *.lib) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + library_names= + old_library= + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/" + test "X$dir" = "X$file/" && dir= + dir="$dir$objdir" + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$realname $destdir/$realname" + $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $? + + if test $# -gt 0; then + # Delete the old symlinks, and create new ones. + for linkname + do + if test "$linkname" != "$realname"; then + $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + fi + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + eval cmds=\"$postinstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + instname="$dir/$name"i + $show "$install_prog $instname $destdir/$name" + $run eval "$install_prog $instname $destdir/$name" || exit $? + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case "$destfile" in + *.lo) + staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` + ;; + *.o | *.obj) + staticdest="$destfile" + destfile= + ;; + *) + $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run eval "$install_prog $file $destfile" || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` + + $show "$install_prog $staticobj $staticdest" + $run eval "$install_prog \$staticobj \$staticdest" || exit $? + fi + exit 0 + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + link_against_libtool_libs= + relink_command= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Check the variables that should have been set. + if test -z "$link_against_libtool_libs"; then + $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 + exit 1 + fi + + finalize=yes + for lib in $link_against_libtool_libs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case "$lib" in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`" + if test -n "$libdir" && test ! -f "$libfile"; then + $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + done + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + if test "$finalize" = yes && test -z "$run"; then + tmpdir="/tmp" + test -n "$TMPDIR" && tmpdir="$TMPDIR" + tmpdir=`mktemp -d $tmpdir/libtool-XXXXXX 2> /dev/null` + if test $? = 0 ; then : + else + tmpdir="$tmpdir/libtool-$$" + fi + if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : + else + $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 + continue + fi + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` + + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + ${rm}r "$tmpdir" + continue + fi + file="$outputname" + else + $echo "$modename: warning: cannot relink \`$file'" 1>&2 + fi + else + # Install the binary that we compiled earlier. + file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + $show "$install_prog$stripme $file $destfile" + $run eval "$install_prog\$stripme \$file \$destfile" || exit $? + test -n "$outputname" && ${rm}r "$tmpdir" + ;; + esac + done + + for file in $staticlibs; do + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run eval "$install_prog \$file \$oldlib" || exit $? + + # Do each command in the postinstall commands. + eval cmds=\"$old_postinstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec $SHELL $0 --finish$current_libdirs + exit 1 + fi + + exit 0 + ;; + + # libtool finish mode + finish) + modename="$modename: finish" + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + eval cmds=\"$finish_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || admincmds="$admincmds + $cmd" + done + IFS="$save_ifs" + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $run eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + test "$show" = : && exit 0 + + echo "----------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + echo " $libdir" + done + echo + echo "If you ever happen to want to link against installed libraries" + echo "in a given directory, LIBDIR, you must either use libtool, and" + echo "specify the full pathname of the library, or use \`-LLIBDIR'" + echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the \`$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + echo " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + echo " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + echo + echo "See any operating system documentation about shared libraries for" + echo "more information, such as the ld(1) and ld.so(8) manual pages." + echo "----------------------------------------------------------------------" + exit 0 + ;; + + # libtool execute mode + execute) + modename="$modename: execute" + + # The first argument is the command name. + cmd="$nonopt" + if test -z "$cmd"; then + $echo "$modename: you must specify a COMMAND" 1>&2 + $echo "$help" + exit 1 + fi + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test ! -f "$file"; then + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + dir= + case "$file" in + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 + exit 1 + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case "$file" in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved enviroment variables + if test "${save_LC_ALL+set}" = set; then + LC_ALL="$save_LC_ALL"; export LC_ALL + fi + if test "${save_LANG+set}" = set; then + LANG="$save_LANG"; export LANG + fi + + # Now actually exec the command. + eval "exec \$cmd$args" + + $echo "$modename: cannot exec \$cmd$args" + exit 1 + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" + $echo "export $shlibpath_var" + fi + $echo "$cmd$args" + exit 0 + fi + ;; + + # libtool uninstall mode + uninstall) + modename="$modename: uninstall" + rm="$nonopt" + files= + + for arg + do + case "$arg" in + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + rmfiles="$file" + + case "$name" in + *.la) + # Possibly a libtool archive, so verify it. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + . $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $dir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library" + + $show "$rm $rmfiles" + $run $rm $rmfiles + + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + eval cmds=\"$postuninstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + eval cmds=\"$old_postuninstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + + # FIXME: should reinstall the best remaining shared library. + fi + ;; + + *.lo) + if test "$build_old_libs" = yes; then + oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` + rmfiles="$rmfiles $dir/$oldobj" + fi + $show "$rm $rmfiles" + $run $rm $rmfiles + ;; + + *) + $show "$rm $rmfiles" + $run $rm $rmfiles + ;; + esac + done + exit 0 + ;; + + "") + $echo "$modename: you must specify a MODE" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 + ;; + esac + + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 +fi # test -z "$show_help" + +# We need to display help for each of the modes. +case "$mode" in +"") $echo \ +"Usage: $modename [OPTION]... [MODE-ARG]... + +Provide generalized library-building support services. + + --config show all configuration variables + --debug enable verbose shell tracing +-n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --finish same as \`--mode=finish' + --help display this help message and exit + --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] + --quiet same as \`--silent' + --silent don't print informational messages + --version print version information + +MODE must be one of the following: + + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for +a more detailed description of MODE." + exit 0 + ;; + +compile) + $echo \ +"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -static always build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + +execute) + $echo \ +"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + +finish) + $echo \ +"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + +install) + $echo \ +"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + +link) + $echo \ +"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -static do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + +uninstall) + $echo \ +"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + +*) + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; +esac + +echo +$echo "Try \`$modename --help' for more information about other modes." + +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/salome_adm/unix/config_files/missing b/salome_adm/unix/config_files/missing new file mode 100644 index 000000000..7789652e8 --- /dev/null +++ b/salome_adm/unix/config_files/missing @@ -0,0 +1,190 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. +# Copyright (C) 1996, 1997 Free Software Foundation, Inc. +# Franc,ois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program 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 General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +case "$1" in + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + yacc create \`y.tab.[ch]', if possible, from existing .[ch]" + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing - GNU libit 0.0" + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + + aclocal) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acinclude.m4' or \`configure.in'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`configure.in'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acconfig.h' or \`configure.in'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + fi + touch $file + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and you do not seem to have it handy on your + system. You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequirements for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 diff --git a/salome_adm/unix/config_files/mkinstalldirs b/salome_adm/unix/config_files/mkinstalldirs new file mode 100755 index 000000000..6b3b5fc5d --- /dev/null +++ b/salome_adm/unix/config_files/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# $Id$ + +errstatus=0 + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/salome_adm/unix/config_files/production.m4 b/salome_adm/unix/config_files/production.m4 new file mode 100644 index 000000000..bca533f8d --- /dev/null +++ b/salome_adm/unix/config_files/production.m4 @@ -0,0 +1,77 @@ +dnl define macros : +dnl AC_ENABLE_PRODUCTION AC_DISABLE_PRODUCTION +dnl and +dnl AC_ENABLE_DEBUG AC_DISABLE_DEBUG +dnl +dnl version $Id$ +dnl author Patrick GOLDBRONN +dnl + +# AC_ENABLE_PRODUCTION +AC_DEFUN(AC_ENABLE_PRODUCTION, [dnl +define([AC_ENABLE_PRODUCTION_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(production, +changequote(<<, >>)dnl +<< --enable-production[=PKGS] build without debug information [default=>>AC_ENABLE_PRODUCTION_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_production=yes ;; +no) enable_production=no ;; +*) + enable_production=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_production=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_production=AC_ENABLE_PRODUCTION_DEFAULT)dnl + +if test "X$enable_production" = "Xyes"; then + CFLAGS="$CFLAGS -O" + CXXFLAGS="$CXXFLAGS -O" +fi +]) + +# AC_DISABLE_PRODUCTION - set the default flag to --disable-production +AC_DEFUN(AC_DISABLE_PRODUCTION, [AC_ENABLE_PRODUCTION(no)]) + +# AC_ENABLE_DEBUG +AC_DEFUN(AC_ENABLE_DEBUG, [dnl +define([AC_ENABLE_DEBUG_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(debug, +changequote(<<, >>)dnl +<< --enable-debug[=PKGS] build without debug information [default=>>AC_ENABLE_DEBUG_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_debug=yes ;; +no) enable_debug=no ;; +*) + enable_debug=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_debug=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_debug=AC_ENABLE_DEBUG_DEFAULT)dnl + +if test "X$enable_debug" = "Xyes"; then + CFLAGS="$CFLAGS -g -D_DEBUG_ " + CXXFLAGS="$CXXFLAGS -g -D_DEBUG_ " +fi +]) + +# AC_DISABLE_DEBUG - set the default flag to --disable-debug +AC_DEFUN(AC_DISABLE_DEBUG, [AC_ENABLE_DEBUG(no)]) + diff --git a/salome_adm/unix/config_files/pyembed.m4 b/salome_adm/unix/config_files/pyembed.m4 new file mode 100644 index 000000000..aa016668f --- /dev/null +++ b/salome_adm/unix/config_files/pyembed.m4 @@ -0,0 +1,90 @@ +dnl This macro defines the PYTHON_EMBED_{CFLAGS,LDFLAGS,LIBS} substitutions +dnl that should be used when embedding the python interpreter into a program. +dnl AM_INIT_PYTHON_EMBED +AC_DEFUN(AM_INIT_PYTHON_EMBED, +[AC_REQUIRE([AM_PATH_PYTHON]) +AC_REQUIRE([AM_INIT_PYEXEC_MOD]) + +AC_MSG_CHECKING(for flags used to embed python interpreter) +changequote(,)dnl +py_makefile="`$PYTHON -c ' +import sys +print \"%s/lib/python%s/config/Makefile\"%(sys.exec_prefix, sys.version[:3])'`" +changequote([,])dnl +if test ! -f "$py_makefile"; then + AC_MSG_ERROR([*** Couldn't find the python config makefile. Maybe you are +*** missing the development portion of the python installation]) +fi + +changequote(,)dnl +py_lib="`$PYTHON -c ' +import sys +ver = sys.version[:3] +pre = sys.exec_prefix +print \"-L%s/lib/python%s/config\" % (pre, ver), +if ver == \"1.4\": + print \"-lPython -lObjects -lParser\" +else: + print \"-lpython\" + ver + +changequote([,])dnl + +py_ldflags=`sed -n -e 's/^LDFLAGS=\(.*\)/\1/p' $py_makefile` +py_linkforshared=`sed -n -e 's/^LINKFORSHARED=\(.*\)/\1/p' $py_makefile` + +PYTHON_EMBED_LDFLAGS="$py_ldflags $py_linkforshared" + +py_localmodlibs=`sed -n -e 's/^LOCALMODLIBS=\(.*\)/\1/p' $py_makefile` +py_basemodlibs=`sed -n -e 's/^BASEMODLIBS=\(.*\)/\1/p' $py_makefile` +py_other_libs=`sed -n -e 's/^LIBS=\(.*\)/\1/p' $py_makefile` + +PYTHON_EMBED_LIBS="$py_lib $py_localmodlibs $py_basemodlibs $py_other_libs" + +PYTHON_EMBED_CFLAGS="$PYTHON_INCLUDES" + +AC_MSG_RESULT(done) + +AC_SUBST(PYTHON_EMBED_CFLAGS) +AC_SUBST(PYTHON_EMBED_LDFLAGS) +AC_SUBST(PYTHON_EMBED_LIBS) +]) + +dnl creates a config.c file, which holds the builtin module initialisation +dnl table for python. The first argument should be the output filename. +dnl The second argument gives the names of all the modules you want to build +dnl into the executable. +dnl AM_PYTHON_CREATE_CONFIG_C(CONFIG_C, MODULE ...) +AC_DEFUN(AM_PYTHON_CREATE_CONFIG_C, +[AC_REQUIRE([AM_INIT_PYTHON_EMBED]) +AC_MSG_CHECKING(for config.c.in) +changequote(,)dnl +py_config_in="`$PYTHON -c ' +import sys +print \"%s/lib/python%s/config/config.c.in\"%(sys.exec_prefix, sys.version[:3])'`" +changequote([,])dnl +if test ! -f "$py_config_in"; then + AC_MSG_ERROR([*** Couldn't find the config.c.in file. Maybe you are +*** missing the development portion of the python installation]) +fi + +py_cnf_decls="" +py_cnf_inits="" +py_nl='\ +' +for mod in . $2; do + if test "$mod" != .; then + py_cnf_decls="${py_cnf_decls}extern void init$mod();$py_nl" + py_cnf_inits="${py_cnf_inits} {\"$mod\", init$mod},$py_nl" + fi +done +sed -e " + /MARKER 1/i$py_nl$py_cnf_decls + /MARKER 2/i$py_nl$py_cnf_inits +" $py_config_in > $1 +AC_MSG_RESULT(created $1) +]) + +s page was automatically generated Contact Matt Wilson with any comments +the LXR engine written by Arne or questions about LXR on gnome.org. +rg Gleditsch and Per Kristian Do not contact Matt Wilson concerning +rmshus. any software on this site. diff --git a/salome_adm/unix/config_files/python.m4 b/salome_adm/unix/config_files/python.m4 new file mode 100644 index 000000000..ce4b99ff5 --- /dev/null +++ b/salome_adm/unix/config_files/python.m4 @@ -0,0 +1,142 @@ +## ------------------------ +## Python file handling +## From Andrew Dalke +## Modified by Marc Tajchman (06/2001) +## ------------------------ + +dnl CHECK_PYTHON([module, classes]) +dnl +dnl Adds support for distributing Python modules or classes. +dnl Python library files distributed as a `module' are installed +dnl under PYTHON_SITE_PACKAGE (eg, ./python1.5/site-package/package-name) +dnl while those distributed as `classes' are installed under PYTHON_SITE +dnl (eg, ./python1.5/site-packages). The default is to install as +dnl a `module'. + +AC_DEFUN(CHECK_PYTHON, + [ + AC_ARG_WITH(python, + [ --with-python=DIR root directory path of python installation ], + [PYTHON="$withval/bin/python" + AC_MSG_RESULT("select python distribution in $withval") + ], [ + AC_PATH_PROG(PYTHON, python) + ]) + + AC_CHECKING([local Python configuration]) + PYTHON_PREFIX=`echo $PYTHON | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + PYTHON_PREFIX=`echo $PYTHON_PREFIX | sed -e "s,[[^/]]*$,,;s,/$,,;s,^$,.,"` + PYTHONHOME=$PYTHON_PREFIX + + AC_SUBST(PYTHON_PREFIX) + AC_SUBST(PYTHONHOME) + + changequote(<<, >>)dnl + PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[:3]"` + changequote([, ])dnl + AC_SUBST(PYTHON_VERSION) + + PY_MAKEFILE=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/config/Makefile + if test ! -f "$PY_MAKEFILE"; then + AC_MSG_ERROR([*** Couldn't find ${PY_MAKEFILE}. Maybe you are +*** missing the development portion of the python installation]) + fi + + AC_SUBST(PYTHON_INCLUDES) + AC_SUBST(PYTHON_LIBS) + + PYTHON_INCLUDES=-I$PYTHON_PREFIX/include/python$PYTHON_VERSION + PYTHON_LIBS="-L${PYTHON_PREFIX}/lib/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}" + PYTHON_LIB=$PYTHON_LIBS + PYTHON_LIBA=$PYTHON_PREFIX/lib/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a + + dnl At times (like when building shared libraries) you may want + dnl to know which OS Python thinks this is. + + AC_SUBST(PYTHON_PLATFORM) + PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"` + + AC_SUBST(PYTHON_SITE) + AC_ARG_WITH(python-site, +[ --with-python-site=DIR Use DIR for installing platform independent + Python site-packages], + +dnl modification : by default, we install python script in salome root tree + +dnl [PYTHON_SITE="$withval" +dnl python_site_given=yes], +dnl [PYTHON_SITE=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/site-packages +dnl python_site_given=no]) + +[PYTHON_SITE="$withval" +python_site_given=yes], +[PYTHON_SITE=$prefix"/lib/python"$PYTHON_VERSION/site-packages +python_site_given=no]) + + AC_SUBST(PYTHON_SITE_PACKAGE) + PYTHON_SITE_PACKAGE=$PYTHON_SITE/$PACKAGE + + + dnl Get PYTHON_SITE from --with-python-site-exec or from + dnl --with-python-site or from running Python + + AC_SUBST(PYTHON_SITE_EXEC) + AC_ARG_WITH(python-site-exec, +[ --with-python-site-exec=DIR Use DIR for installing platform dependent + Python site-packages], +[PYTHON_SITE_EXEC="$withval"], +[if test "$python_site_given" = yes; then + PYTHON_SITE_EXEC=$PYTHON_SITE +else + PYTHON_SITE_EXEC=$PYTHON_EXEC_PREFIX"/lib/python"$PYTHON_VERSION/site-packages +fi]) + + dnl Set up the install directory + ifelse($1, classes, +[PYTHON_SITE_INSTALL=$PYTHON_SITE], +[PYTHON_SITE_INSTALL=$PYTHON_SITE_PACKAGE]) + AC_SUBST(PYTHON_SITE_INSTALL) + + dnl Also lets automake think PYTHON means something. + + pythondir=$PYTHON_PREFIX"/lib/python"$PYTHON_VERSION/ + AC_SUBST(pythondir) + + AC_MSG_CHECKING([if we need libdb]) + PY_NEEDOPENDB=`nm $PYTHON_LIBA | grep dbopen | grep U` + if test "x$PY_NEEDOPENDB" != "x"; then + PYTHON_LIBS="$PYTHON_LIBS -ldb" + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + + AC_MSG_CHECKING([if we need libdl]) + PY_NEEDOPENDL=`nm $PYTHON_LIBA | grep dlopen | grep U` + if test "x$PY_NEEDOPENDL" != "x"; then + PYTHON_LIBS="$PYTHON_LIBS -ldl" + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + + AC_MSG_CHECKING([if we need libutil]) + PY_NEEDOPENPTY=`nm $PYTHON_LIBA | grep openpty | grep U` + if test "x$PY_NEEDOPENPTY" != "x"; then + PYTHON_LIBS="$PYTHON_LIBS -lutil" + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + + AC_MSG_CHECKING([if we need tcltk]) + PY_NEEDTCLTK=`nm $PYTHON_LIBA | grep Tcl_Init | grep U` + if test "x$PY_NEEDTCLTK" != "x"; then + PYTHON_LIBS="$PYTHON_LIBS -ltcl -ltk" + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + + python_ok=yes + AC_MSG_RESULT(looks good)]) diff --git a/salome_adm/unix/depend.in b/salome_adm/unix/depend.in new file mode 100644 index 000000000..4117d1440 --- /dev/null +++ b/salome_adm/unix/depend.in @@ -0,0 +1,83 @@ +## -*- makefile -*- + +## We keep a list of dependencies in `.depend' for each of the source +## files on which it depends. When one of the source files is modified +## we remove its record from .depend and regenerate its dependencies, +## tacking them onto the end of .depend. By including the .depend file +## into the makefile, we're telling make that the makefile depends on +## the dependency list in the .depend file. +## +## This is as fast as the `.d' method described in the GNU make manual +## for automatic dependencies, but has the added advantage that all +## dependencies are stored in one place. The advantage over the +## `makedepend' program is that only those files that are out of date +## have dependency information rebuilt, and the Makefile is not +## modified. +## +## This is also where tracing information is updated. The $(TRACE) +## program is run on each source file to make sure that the H5TRACE() +## macros are up to date. If they are then the file is not modified, +## otherwise the file is changed and a backup is saved by appending a +## tilde to the file name. +## +$(srcdir)/Dependencies: .depend + @if test "$(srcdir)" != "."; then \ + echo '## This file is machine generated on GNU systems.' >$@; \ + echo '## Only temporary changes may be made here.' >>$@; \ + echo >>$@; \ + perl -p $(top_srcdir)/bin/salome/distdep .depend >>$@; \ + else \ + echo 'Dependencies cannot be built when $$srcdir == $$builddir'; \ + fi + +depend:.depend + +# we had Makefile target, because we want Makefile rebuild before include .depend +.depend: $(LIB_DEP) $(TEST_SRC) $(BIN_DEP) + @touch .depend + @for dep in X $? ; do \ + if [ $$dep != "X" ]; then \ + if [ $$dep != "Makefile" ]; then \ + case "$$dep" in \ + *.c) \ + echo Building dependencies for $$dep; \ + obj=`basename $$dep .c`.lo; \ + sed '\%^'"$$obj"':%,\%[^\\]$$%d' <$@ >$@- && mv $@- $@; \ + $(CC) $(C_DEPEND_FLAG) $(CPPFLAGS) $$dep 2>/dev/null | \ + sed 's% $(srcdir)/% $$(srcdir)/%g' | \ + sed 's% $(top_srcdir)/% $$(top_srcdir)/%g' | \ + sed 's% $(top_builddir)/% $$(top_builddir)/%g' | \ + sed 's/\.o/.lo/' >>$@; \ + ;; \ + *.cc) \ + echo Building dependencies for $$dep; \ + obj=`basename $$dep .cc`.lo; \ + sed '\%^'"$$obj"':%,\%[^\\]$$%d' <$@ >$@- && mv $@- $@; \ + $(CXX) $(CXX_DEPEND_FLAG) $(CXXFLAGS) $(CPPFLAGS) $$dep 2>/dev/null | \ + sed 's% $(srcdir)/% $$(srcdir)/%g' | \ + sed 's% $(top_srcdir)/% $$(top_srcdir)/%g' | \ + sed 's% $(top_builddir)/% $$(top_builddir)/%g' | \ + sed 's/\.o/.lo/' >>$@; \ + ;; \ + *.cxx) \ + echo Building dependencies for $$dep; \ + obj=`basename $$dep .cxx`.lo; \ + sed '\%^'"$$obj"':%,\%[^\\]$$%d' <$@ >$@- && mv $@- $@; \ + $(CXX) $(CXX_DEPEND_FLAG) $(CXXFLAGS) $(CPPFLAGS) $$dep 2>/dev/null | \ + sed 's% $(srcdir)/% $$(srcdir)/%g' | \ + sed 's% $(top_srcdir)/% $$(top_srcdir)/%g' | \ + sed 's% $(top_builddir)/% $$(top_builddir)/%g' | \ + sed 's/\.o/.lo/' >>$@; \ + ;; \ + esac; \ + fi; \ + fi; \ + done; + + +-include .depend + +# idl depend +-include $(top_builddir)/idl/.depidl + + diff --git a/salome_adm/unix/envScript.in b/salome_adm/unix/envScript.in new file mode 100644 index 000000000..1db824c1c --- /dev/null +++ b/salome_adm/unix/envScript.in @@ -0,0 +1,20 @@ + +DIR=`pwd` +EXEC_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"` +cd $EXEC_DIR/.. +SALOME_HOME_DIR=`pwd` +cd $EXEC_DIR + +export SALOME_HOME_DIR +export SALOME_SRC_DIR=@ROOT_SRCDIR@ +export ORB_HOME_DIR=@CORBA_ROOT@ + +export LD_LIBRARY_PATH=${SALOME_HOME_DIR}/lib/salome:${LD_LIBRARY_PATH} + +# echo $SALOME_HOME_DIR = SALOME_HOME_DIR +# echo $SALOME_SRC_DIR = SALOME_SRC_DIR + +PYVTK_PATH=@VTKPY_MODULES@ +export PYTHONPATH=${PYTHONPATH}:${SALOME_HOME_DIR}/idl:${SALOME_HOME_DIR}/bin/salome:${SALOME_HOME_DIR}/lib/salome:${PYVTK_PATH}:${EXEC_DIR} + +export MICORC=/dev/null diff --git a/salome_adm/unix/make_commence.in b/salome_adm/unix/make_commence.in new file mode 100644 index 000000000..eea295092 --- /dev/null +++ b/salome_adm/unix/make_commence.in @@ -0,0 +1,244 @@ +# common directories to put headerfiles +inc_builddir=$(top_builddir)/include/salome + +@SET_MAKE@ +SHELL=/bin/sh + +# header missing + +HAVE_SSTREAM=@HAVE_SSTREAM@ + + +LIBS=@LIBS@ +LDFLAGS=@LDFLAGS@ -L$(top_builddir)/lib/salome -Xlinker -rpath-link -Xlinker $(top_builddir)/lib/salome +# add libstdc++ to link c++ library with libtool ! +LDFLAGS+= -lstdc++ + +CP=@CP@ + +# CPP + +CPP=@CPP@ +CXXCPP=@CXXCPP@ +CPPFLAGS=@CPPFLAGS@ -I$(inc_builddir) -I$(srcdir) -I. + +# C + +CC = @CC@ +CFLAGS = @CFLAGS@ +C_DEPEND_FLAG = @C_DEPEND_FLAG@ + +# C++ + +CXX = @CXX@ +CXXFLAGS = @CXXFLAGS@ +CXX_DEPEND_FLAG = @CXX_DEPEND_FLAG@ + +# JAVA + +JAVA_INCLUDES = @JAVA_INCLUDES@ +JAVA_LIBS = @JAVA_LIBS@ +JAVA_LDPATH = @JAVA_LDPATH@ + +# PYTHON + +PYTHON = @PYTHON@ +PYTHONHOME = @PYTHONHOME@ +PYTHON_INCLUDES = @PYTHON_INCLUDES@ +PYTHON_LIBS = @PYTHON_LIBS@ +PYTHON_VERSION = @PYTHON_VERSION@ +PYTHON_SITE = @PYTHON_SITE@ +PYTHON_SITE_INSTALL = @PYTHON_SITE_INSTALL@ + +# QT + +QT_ROOT = @QT_ROOT@ +QT_INCLUDES = @QT_INCLUDES@ +QT_MT_INCLUDES = @QT_INCLUDES@ -DQT_THREAD_SUPPORT +QT_LIBS = @QT_LIBS@ +QT_MT_LIBS = @QT_MT_LIBS@ + +MOC = @MOC@ +UIC = @UIC@ + + +#QWT + +QWT_INCLUDES=@QWT_INCLUDES@ +QWT_LIBS=@QWT_LIBS@ + +# SIP +SIP = @SIP@ +SIP_INCLUDES = @SIP_INCLUDES@ +SIP_LIBS = @SIP_LIBS@ + +# PYQT +PYQT_SIPS = @PYQT_SIPS@ +PYQT_LIBS = @PYQT_LIBS@ + +# openGL +OGL_INCLUDES=@OGL_INCLUDES@ +OGL_LIBS=@OGL_LIBS@ + +# VTK +VTK_INCLUDES=@VTK_INCLUDES@ +VTK_LIBS=@VTK_LIBS@ + +# HDF5 + +HDF5_INCLUDES=@HDF5_INCLUDES@ +HDF5_LIBS=@HDF5_LIBS@ +HDF5_MT_LIBS=@HDF5_MT_LIBS@ + +# MED2 + +MED2_INCLUDES=@MED2_INCLUDES@ +MED2_LIBS=@MED2_LIBS@ +MED2_MT_LIBS=@MED2_MT_LIBS@ + +# OpenCasCade + +OCC_INCLUDES=@CAS_CPPFLAGS@ +OCC_CXXFLAGS=@CAS_CXXFLAGS@ +OCC_LIBS=@CAS_LDFLAGS@ + +# MPICH + +MPICH_INCLUDES=@MPICH_INCLUDES@ +MPICH_LIBS=@MPICH_LIBS@ + +# Swig C++ Python + +SWIG = @SWIG@ +SWIG_FLAGS = @SWIG_FLAGS@ -I$(inc_builddir) -I$(srcdir) -I. + +# OMNIORB + +OMNIORB_ROOT = @OMNIORB_ROOT@ +OMNIORB_INCLUDES = @OMNIORB_INCLUDES@ +OMNIORB_LIBS = @OMNIORB_LIBS@ +OMNIORB_CXXFLAGS = @OMNIORB_CXXFLAGS@ + +OMNIORB_IDL = @OMNIORB_IDL@ +OMNIORB_IDLCXXFLAGS = @OMNIORB_IDLCXXFLAGS@ +OMNIORB_IDLPYFLAGS = @OMNIORB_IDLPYFLAGS@ -I$(top_builddir)/idl + +OMNIORB_IDL_CLN_H = @OMNIORB_IDL_CLN_H@ +OMNIORB_IDL_CLN_CXX = @OMNIORB_IDL_CLN_CXX@ +OMNIORB_IDL_CLN_OBJ = @OMNIORB_IDL_CLN_OBJ@ + +OMNIORB_IDL_SRV_H = @OMNIORB_IDL_SRV_H@ +OMNIORB_IDL_SRV_CXX = @OMNIORB_IDL_SRV_CXX@ +OMNIORB_IDL_SRV_OBJ = @OMNIORB_IDL_SRV_OBJ@ + +# Default ORB + +CORBA_ROOT = @CORBA_ROOT@ +CORBA_INCLUDES = @CORBA_INCLUDES@ +CORBA_LIBS = @CORBA_LIBS@ +CORBA_CXXFLAGS = @CORBA_CXXFLAGS@ + +IDLCXXFLAGS = @IDLCXXFLAGS@ -I$(top_builddir)/idl +IDLPYFLAGS = @IDLPYFLAGS@ + +IDL = @IDL@ + +IDL_CLN_H = @IDL_CLN_H@ +IDL_CLN_CXX = @IDL_CLN_CXX@ +IDL_CLN_OBJ = @IDL_CLN_OBJ@ + +IDL_SRV_H = @IDL_SRV_H@ +IDL_SRV_CXX = @IDL_SRV_CXX@ +IDL_SRV_OBJ = @IDL_SRV_OBJ@ + +CPPFLAGS+= $(CORBA_INCLUDES) +CXXFLAGS+= $(CORBA_CXXFLAGS) + +# add corba libs when link salome application ! +#LDFLAGS+= $(CORBA_LIBS) +LIBS+=$(CORBA_LIBS) + +## Shared libraries +LT_STATIC_EXEC=@LT_STATIC_EXEC@ +DYNAMIC_DIRS=@DYNAMIC_DIRS@ +LT_LIB=libtool +LT=$(top_builddir)/libtool +LT_COMPILE=$(LT) --mode=compile $(CC) +LT_LINK_LIB=$(LT_LIB) --mode=link $(CC) -rpath $(libdir) +LT_LINK_EXE=$(LT) --mode=link $(CC) $(LT_STATIC_EXEC) -dlopen self -rpath $(bindir) $(DYNAMIC_DIRS) +LT_RUN=$(LT) --mode=execute +LT_INSTALL_PROG=$(LT) --mode=install $(INSTALL_PROGRAM) +LT_INSTALL_LIB=$(LT) --mode=install $(INSTALL_DATA) +LT_UNINSTALL=$(LT) --mode=uninstall $(RM) + +INSTALL=@INSTALL@ +INSTALL_PROGRAM=@INSTALL_PROGRAM@ +INSTALL_DATA=@INSTALL_DATA@ + +# create a symbolic link (or a copie ?) +LN_S=@LN_S@ + +## Installation points +prefix=@prefix@ +exec_prefix=@exec_prefix@ +bindir=@bindir@/salome +libdir=@libdir@/salome +# warning : if user give this path in configure we could have salome/salome :-( +includedir=@includedir@/salome +datadir=@datadir@/salome +idldir=$(datadir)/idl/salome +sharedpydir=@libdir@/python$(PYTHON_VERSION)/site-packages/salome/shared_modules + +docdir=$(datadir)/doc + +# +# begin of package rules +# + +.PHONY: all lib bin inc resources tests install uninstall dep depend depend_idl cleandep mostlyclean clean distclean + +.SUFFIXES: .cxx .cc .c .f .o .lo .idl .py .i .ui .po .qm + +all: + $(MAKE) inc + $(MAKE) depend_idl + $(MAKE) depend + $(MAKE) lib + $(MAKE) bin + $(MAKE) resources + +# +# add target to build administrative files +# + +Makefile: $(top_builddir)/config.status $(srcdir)/Makefile.in + cd $(top_builddir) ; ./config.status + +$(top_builddir)/config.status: $(top_srcdir)/configure + cd $(top_builddir) ; ./config.status --recheck + +# VPATH contain $(srcdir), so make configure is good in top_srcdir and we must add target configure otherwise :-) +ifneq ($(top_srcdir),$(srcdir)) +configure: $(top_srcdir)/configure +endif + +$(top_srcdir)/configure: $(top_srcdir)/configure.in $(top_srcdir)/aclocal.m4 + cd $(top_srcdir) ; autoconf + +$(top_srcdir)/configure.in: $(top_srcdir)/configure.in.base + cd $(top_srcdir) && ./build_configure + + +ACLOCAL_SRC = \ +ac_cxx_bool.m4 check_corba.m4 check_vtk.m4 \ +ac_cxx_depend_flag.m4 check_hdf5.m4 enable_pthreads.m4 \ +ac_cxx_mutable.m4 check_mico.m4 libtool.m4 \ +ac_cxx_namespaces.m4 check_omniorb.m4 pyembed.m4 \ +ac_cxx_partial_specialization.m4 check_opengl.m4 python.m4 \ +ac_cxx_typename.m4 check_pthreads.m4 check_cas.m4 \ +ac_cc_warnings.m4 check_qt.m4 check_med2.m4 \ +check_swig.m4 + +$(top_srcdir)/aclocal.m4: $(ACLOCAL_SRC:%=@KERNEL_ROOT_DIR@/salome_adm/unix/config_files/%) + cd $(top_srcdir) ; aclocal --acdir=@KERNEL_ROOT_DIR@/salome_adm/unix/config_files + diff --git a/salome_adm/unix/make_conclude.in b/salome_adm/unix/make_conclude.in new file mode 100644 index 000000000..e8400bcaf --- /dev/null +++ b/salome_adm/unix/make_conclude.in @@ -0,0 +1,346 @@ +#======================================================================= +# This section of this makefile comes from the file +# 'adm/unix/make_conclude' which was generated with config.status +# from file adm/unix/make_conclude.in +#======================================================================= +# -* Makefile *- +# +# Authors : Patrick GOLDBRONN (CEA) - Marc Tajchman (CEA) +# Date : 6/07/2001 +# $Header$ +# + +# ORB Specifics rules +@CORBA@ + +# transform idl reference in appropriate obj file +LIB_CLIENT_SRC = $(LIB_CLIENT_IDL:%.idl=%$(IDL_CLN_CXX)) +LIB_SERVER_SRC = $(LIB_SERVER_IDL:%.idl=%$(IDL_SRV_CXX)) +LIB_MOC_SRC = $(LIB_MOC:%.h=%_moc.cxx) +LIB_SRC+=$(LIB_MOC_SRC) +LIB_SWIG_SRC = $(SWIG_DEF:%.i=%_wrap.cxx) +LIB_DEP= $(LIB_SRC) $(LIB_CLIENT_SRC) $(LIB_SERVER_SRC) $(LIB_SWIG_SRC) + +LIB_CLIENT_OBJ = $(LIB_CLIENT_IDL:%.idl=%$(IDL_CLN_OBJ)) +LIB_SERVER_OBJ = $(LIB_SERVER_IDL:%.idl=%$(IDL_SRV_OBJ)) + + +# transform c file in appropriate libtool obj file (.c, .cc and .cxx) +LIB_OBJ_C = $(patsubst %.c, %.lo, $(filter %.c, $(LIB_SRC))) +LIB_OBJ_CC = $(patsubst %.cc, %.lo, $(filter %.cc, $(LIB_SRC))) +LIB_OBJ_CXX = $(patsubst %.cxx, %.lo, $(filter %.cxx, $(LIB_SRC))) +LIB_SWIG_OBJ = $(LIB_SWIG_SRC:%.cxx=%.lo) +LIB_OBJ_F = $(patsubst %.f, %.lo, $(filter %.f, $(LIB_SRC))) + +# all libtool obj file in library +LIB_OBJ = $(LIB_OBJ_CXX) $(LIB_OBJ_CC) $(LIB_OBJ_C) $(LIB_CLIENT_OBJ:%.o=%.lo) $(LIB_SERVER_OBJ:%.o=%.lo) $(LIB_SWIG_OBJ) $(LIB_OBJ_F) + +# LIB_BUILD = $(LIB:%.la=$(top_builddir)/lib/salome/%.la) +LIB_BUILD = $(patsubst %.la, $(top_builddir)/lib/salome/%.la, $(filter %.la, $(LIB))) +LIB_BUILD_A = $(patsubst %.a, $(top_builddir)/lib/salome/%.a, $(filter %.a, $(LIB))) + +ifneq ($(findstring cmodule.la,$(filter %.la, $(LIB))),) +LIB_SWIG = $(patsubst %cmodule.la,%.so, $(filter %.la, $(LIB))) +else +LIB_SWIG = +endif + +lib: $(LIB_BUILD) $(LIB_CLIENT_PY) +# we don't build static library ! + +$(LIB_BUILD): $(top_builddir)/lib/salome/%.la: %.la + -$(RM) $@ + -$(RM) $(patsubst %.la, %.so, $@) + -$(RM) $(patsubst %.la, %.a, $@) + ln -s $(CURDIR)/$< $@ || true + ln -s $(patsubst %.la, %.so, $(CURDIR)/.libs/$<) \ + $(patsubst %.la, %.so, $@) || true + ln -s $(patsubst %.la, %.so, $(CURDIR)/.libs/$<).0 \ + $(patsubst %.la, %.so, $@).0 || true + + if ! test -z $(LIB_SWIG) ; then \ + ln -s $(patsubst %.la,%.so, $(CURDIR)/.libs/$<) $(top_builddir)/lib/salome/_$(LIB_SWIG) || true;\ + fi; + +$(LIB_BUILD_A): $(top_builddir)/lib/salome/%.a: %.a + -$(RM) $@ + ln -s $(CURDIR)/$< $@ || true + +$(LIB): $(LIB_OBJ) + @$(LT) --mode=link $(CXX) -rpath $(libdir) -o $@ $(CXXFLAGS) $(LIB_OBJ) $(LDFLAGS) $(LIBS) + +# transform idl reference in appropriate obj file +BIN_CLIENT_SRC = $(BIN_CLIENT_IDL:%.idl=%$(IDL_CLN_CXX)) +BIN_SERVER_SRC = $(BIN_SERVER_IDL:%.idl=%$(IDL_SRV_CXX)) +BIN_MOC_SRC = $(BIN_MOC:%.h=%_moc.cxx) +BIN_SRC+=$(BIN_MOC_SRC) +BIN_DEP=$(BIN:%=%.cxx) $(BIN_SRC) $(BIN_CLIENT_SRC) $(BIN_SERVER_SRC) + +BIN_CLIENT_OBJ = $(BIN_CLIENT_IDL:%.idl=%$(IDL_CLN_OBJ)) +BIN_SERVER_OBJ = $(BIN_SERVER_IDL:%.idl=%$(IDL_SRV_OBJ)) +# transform c file in appropriate libtool obj file (.c) +BIN_OBJ_C = $(patsubst %.c, %.o, $(filter %.c, $(BIN_SRC))) +# transform c++ file in appropriate libtool obj file (.cc and .cxx) +BIN_OBJ_CC = $(patsubst %.cc, %.o, $(filter %.cc, $(BIN_SRC))) +BIN_OBJ_CXX = $(patsubst %.cxx, %.o, $(filter %.cxx, $(BIN_SRC))) +# all obj file in bin target +BIN_OBJ = $(BIN_OBJ_CC) $(BIN_OBJ_CXX) $(BIN_OBJ_C) $(BIN_CLIENT_OBJ) $(BIN_SERVER_OBJ) + +bin: $(BIN:%=$(top_builddir)/bin/salome/%) $(BIN) $(LIB) pyscripts sharedpyscripts + +BIN_LIB=$(LIB:lib%.la=-l%) + +$(BIN:%=$(top_builddir)/bin/salome/%) $(TEST_PROGS:%=$(top_builddir)/bin/salome/%): $(top_builddir)/bin/salome/%: % + -$(RM) $@ + ln -s $(CURDIR)/$< $@ + +$(BIN) $(TEST_PROGS): %: %.lo $(BIN_OBJ) + $(CXX) $(CXXFLAGS) -o $@ $^ $(BIN_LIB) $(LDFLAGS) $(LIBS) + +# copy python scripts in $(top_builddir)/bin/salome +# +DEST_PYSCRIPTS = $(EXPORT_PYSCRIPTS:%=$(top_builddir)/bin/salome/%) +pyscripts: $(DEST_PYSCRIPTS) +$(DEST_PYSCRIPTS): $(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 + +$(PYTHON_SHARED_SITE): + $(INSTALL) -d $@ + +DEST_SHAREDPYSCRIPTS = $(EXPORT_SHAREDPYSCRIPTS:%=$(PYTHON_SHARED_SITE)/%) +sharedpyscripts: $(PYTHON_SHARED_SITE) $(DEST_SHAREDPYSCRIPTS) +$(DEST_SHAREDPYSCRIPTS): $(PYTHON_SHARED_SITE)/%: % + cp -f $< $@ + +check: test + +tests: test + +test: $(LIB) $(TEST_PROGS:%=$(top_builddir)/bin/salome/%) + + +# copy header file in $(inc_builddir) +# +DEST_HEADERS = $(EXPORT_HEADERS:%=$(inc_builddir)/%) +inc: $(DEST_HEADERS) +$(DEST_HEADERS): $(inc_builddir)/%: % + cp -f $< $@ + +# build resources file (icons and messages) : .qm file from .po file +resources: $(PO_FILES:%.po=$(top_builddir)/share/salome/resources/%.qm) + +# Make installation directories if they don't exist. +$(libdir) $(includedir) $(bindir) $(datadir) $(idldir) $(sharedpydir): + $(INSTALL) -d $@ && chmod 755 $@ + +# Install the library, the public header files, and programs. +install: $(LIB) $(BIN) $(TEST_PROGS) $(libdir) $(includedir) $(bindir) $(datadir) $(idldir) install-python install-sharedpyqt install-qm + @for f in X $(LIB); do \ + if test $$f != X; then \ + ($(LT_INSTALL_LIB) $$f $(libdir)/. || exit 1); \ + fi; \ + done + @if ! test -z $(LIB_SWIG) ; then \ + (cd $(libdir); ln -s $(patsubst %.so, %cmodule.so, $(LIB_SWIG)) _$(LIB_SWIG) || true); \ + fi; + @for f in X $(BIN); do \ + if test $$f != X; then \ + ($(LT_INSTALL_PROG) $$f $(bindir)/. || exit 1); \ + fi; \ + done +# Install tests programmes in bindir + @for f in X $(TEST_PROGS); do \ + if test $$f != X; then \ + ($(LT_INSTALL_PROG) $$f $(bindir)/. || exit 1); \ + fi; \ + done +# Install exported includes in includedir + @for f in X $(EXPORT_HEADERS:%=$(srcdir)/%); do \ + if test $$f != X; then \ + ($(INSTALL_DATA) $$f $(includedir)/. || exit 1); \ + fi; \ + done + +# Install python script in $(bindir) +install-python: $(bindir) $(EXPORT_PYSCRIPTS:%=install-%) + +$(EXPORT_PYSCRIPTS:%=install-%): install-%: % + $(INSTALL_PROGRAM) $< $(bindir)/. + +#install-python: $(bindir) $(EXPORT_PYSCRIPTS) +# @for f in X $(EXPORT_PYSCRIPTS); do \ +# if test $$f != X; then \ +# ($(INSTALL_PROGRAM) $$f $(bindir)/. || exit 1); \ +# fi; \ +# done + +# Install pyqt script in $(install-sharedpyqt) +install-sharedpyqt: $(sharedpydir) $(EXPORT_SHAREDPYSCRIPTS:%=install-%) + +$(EXPORT_SHAREDPYSCRIPTS:%=install-%): install-%: % + $(INSTALL_PROGRAM) $< $(sharedpydir)/. + + +# generic rule to install .qm files : +install-qm: resources + $(INSTALL) -d $(datadir)/resources + @for f in X $(PO_FILES:%.po=$(top_builddir)/share/salome/resources/%.qm); do \ + if test $$f != X; then \ + ($(INSTALL_DATA) $$f $(datadir)/resources/. || exit 1); \ + fi; \ + done + +# Removes those things that `make install' (would have) installed. +uninstall: + @if test "X$(LIB)" != X; then \ + for f in $(LIB); do \ + $(LT_UNINSTALL) $(libdir)/$$f; \ + done; \ + fi + @if test "X$(BIN)" != X; then \ + for f in $(BIN); do \ + $(LT_UNINSTALL) $(bindir)/$$f; \ + done; \ + fi + @for f in X $(TEST_PROGS); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(bindir)/$$f; \ + fi; \ + done +# Uninstall exported includes in includedir + @for f in X $(EXPORT_HEADERS); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(includedir)/$$f; \ + fi; \ + done +# Uninstall python script in $(bindir) + @for f in X $(EXPORT_PYSCRIPTS); 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 \ + $(LT_UNINSTALL) $(sharedpydir)/$$f ; \ + fi; \ + done + +# Uninstall qm files + @for f in X $(PO_FILES:%.po=%.qm); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(datadir)/resources/$$f ; \ + fi; \ + done + +# remove all dependencies files +# +cleandep: + -$(RM) .dep* + +# Removes temporary files without removing the final target files. That is, +# remove things like object files but not libraries or executables. +# +mostlyclean: cleandep + -$(RM) $(LIB_OBJ) $(LIB_OBJ:.lo=.o) + -$(RM) $(BIN_OBJ) $(BIN:%=%.o) + -$(RM) $(TEST_OBJ) $(TEST_OBJ:.lo=.o) + -$(RM) $(PROG_OBJ) $(PROG_OBJ:.lo=.o) $(MOSTLYCLEAN) + +# Like `mostlyclean' except it also removes the final targets: things like +# libraries and executables. This target doesn't remove any file that +# is part of the SALOME distribution. +# +clean: mostlyclean + -$(RM) $(LIB) $(TEST_PROGS) $(BIN) $(CLEAN) + -$(RM) TAGS *~ *# core *.core + -$(RM) -r .libs + -$(RM) $(top_builddir)/lib/salome/$(LIB) + -$(RM) $(patsubst %,$(top_builddir)/bin/salome/%, $(BIN)) + -$(RM) $(patsubst %.la, %.so, $(top_builddir)/lib/salome/$(LIB)) + -$(RM) $(patsubst %.la, %.a, $(top_builddir)/lib/salome/$(LIB)) +# remove idl generated files (sources) + -$(RM) $(LIB_CLIENT_SRC) $(LIB_SERVER_SRC) $(BIN_CLIENT_SRC) $(BIN_SERVER_SRC) +# remove idl generated files (headers) + -$(RM) $(LIB_CLIENT_IDL:%.idl=%$(IDL_CLN_H)) $(LIB_SERVER_IDL:%.idl=%$(IDL_SRV_H)) + -$(RM) $(BIN_CLIENT_IDL:%.idl=%$(IDL_CLN_H)) $(BIN_SERVER_IDL:%.idl=%$(IDL_SRV_H)) + -$(RM) $(LIB_MOC_SRC) $(BIN_MOC_SRC) + -$(RM) $(LIB_SWIG_SRC) + +# Like `clean' except it also removes files that were created by running +# configure. If you've unpacked the source and built without creating +# any other files, then `make distclean' will leave only the files that were +# in the distribution. +# +distclean: clean + #remove qm file ! + -$(RM) $(PO_FILES:%.po=%.qm) $(PO_FILES:%.po=$(top_builddir)/share/salome/resources/%.qm) + #remove include files + -$(RM) $(DEST_HEADERS) + -$(RM) $(DISTCLEAN) *.bak *.old *.new .dep* + @if test -f $(srcdir)/Makefile.in; then \ + (@SETX@; $(RM) Makefile); \ + fi + + +#implicits rules +.cc.o: + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< + +.cc.lo: + $(LT) --mode=compile $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< + +.cxx.o: + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< + +.cxx.lo: + $(LT) --mode=compile $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< + +.c.o: + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< + +.c.lo: + $(LT_COMPILE) $(CFLAGS) $(CPPFLAGS) -c $< + +.f.o: + $(FC) $(FFLAGS) -c $< -o $@ + +.f.lo: + $(LT) --mode=compile $(FC) $(FFLAGS) -c $< + +.ui.h: + $(UIC) -o $@ $< + +.ui.cxx: + $(UIC) -o $@ -i $*.h $< + +#pattern rules +%_moc.cxx : %.h + $(MOC) $< -o $@ + +%_wrap.cxx : %.i + $(SWIG) $(SWIG_FLAGS) -o $@ $< + +$(top_builddir)/share/salome/resources/%.qm: %.po + if test -e ${KERNEL_ROOT_DIR}/bin/salome/msg2qm ; then \ + ${KERNEL_ROOT_DIR}/bin/salome/msg2qm $< $@ ; \ + else \ + $(top_builddir)/bin/salome/msg2qm $< $@ ; \ + fi + +#------------------------------------------------------------------------------ +# The following section of this makefile contains dependencies between the +# source files and the header files. If GNU make and GCC are being used then +# the dependencies are in the form of rules that cause the information to +# be kept updated automatically. Otherwise the dependencies are listed +# explicitly and come from the `.distdep' files in the various directories. +# These files are part of the distribution and are generated automatically on +# GNU/GCC systems. +#------------------------------------------------------------------------------ + +@DEPEND@ diff --git a/salome_adm/unix/make_module.in b/salome_adm/unix/make_module.in new file mode 100644 index 000000000..315ad68e7 --- /dev/null +++ b/salome_adm/unix/make_module.in @@ -0,0 +1,109 @@ +# generic rule to put in top module Makefile +# (for example with module SALOME, SALOME/Makefile.in and SALOME/src/Makefile.in) + +# build all lib in all subdir +lib:$(SUBDIRS:%=lib_%) + +$(SUBDIRS:%=lib_%):lib_%:% + cd $< ; $(MAKE) lib + +# build all bin in all subdir +bin: + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + +# launch check in all subdir +check: tests +tests: + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + +# copy all header files in common directory +inc: + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + +exportinc: + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + +# copy all idl files in common directory +idl: + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + +dep: depend + +depend: + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + +# copy all resources files in common directory +resources: $(RESOURCES_FILES:%=$(top_builddir)/share/salome/resources/%) + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + +$(RESOURCES_FILES:%=$(top_builddir)/share/salome/resources/%): $(top_builddir)/share/salome/resources/% : % + cp -f $< $@ + + +install: install-resources + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + @if test "X$(top_builddir)" = "X."; then \ + $(LT) --mode=finish $(libdir) ; \ + fi + +uninstall: uninstall-resources + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + +cleandep: + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + +mostlyclean: + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + +clean: + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + -$(RM) .depend *~ *% core *.core *.bak *.new *.old + +distclean: clean + @@SETX@; for d in $(SUBDIRS); do \ + (cd $$d && $(MAKE) $@) || exit 1; \ + done + -$(RM) $(RESOURCES_FILES:%=$(top_builddir)/share/salome/resources/%) + -$(RM) Makefile + +install-resources: +# one resources directory for all salome modules + $(INSTALL) -d $(datadir)/resources + for f in X $(RESOURCES_FILES:%=$(srcdir)/resources/%); do \ + if test $$f != X; then \ + ($(INSTALL_DATA) $$f $(datadir)/resources/. || exit 1); \ + fi; \ + done + +# Uninstall resources files +uninstall-resources: + @for f in X $(RESOURCES_FILES); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(datadir)/resources/$$f ; \ + fi; \ + done + diff --git a/salome_adm/unix/make_omniorb.in b/salome_adm/unix/make_omniorb.in new file mode 100644 index 000000000..c92e682e6 --- /dev/null +++ b/salome_adm/unix/make_omniorb.in @@ -0,0 +1,50 @@ +#======================================================================= +# Begin specific part to omniorb +# (include from file adm/unix/make_omniorb generated by +# adm/unix/make_omniorb.in) +#======================================================================= +# -* Makefile *- +# +# Author : Patrick GOLDBRONN (CEA) +# Date : 29/06/2001 +# $Header$ +# + +# Client and server object are the same with omniorb +# There are one header file and one source file generate + +#IDLOBJ=$(IDLSRC:%.idl=%$(IDL_CLN_OBJ)) + +# dependancies between idl and it's generated files +%$(OMNIORB_IDL_CLN_CXX) %$(OMNIORB_IDL_CLN_H): ${top_builddir}/idl/%.idl + $(OMNIORB_IDL) $(IDLCXXFLAGS) $(OMNIORB_IDLCXXFLAGS) $< + +# dependncies between idl files +depend_idl: .depidl + +# we use cpp to generate dependencies between idl files. +# we change cpp output to keep only idl file and transform it to get a suitable rule +.depidl: $(IDL_FILES) + @touch $@ + @for dep in $? dummy; do \ + if [ $$dep != "dummy" ]; then \ + echo Building dependencies for $$dep; \ + basedep=`basename $$dep .idl`; \ + header="$$basedep"$(IDL_CLN_H); \ + sed '\%^'"$$header"':%,\%[^\\]$$%d' <$@ >$@- && mv $@- $@; \ + $(CPP) $(C_DEPEND_FLAG) -I$(srcdir) $$dep 2>/dev/null | \ + sed `echo "s%$$basedep\\.idl%$$header:%g"` | \ + sed 's% $(srcdir)/% %g' | \ + sed 's% $(top_srcdir)/% %g' | \ + sed 's% $(top_builddir)/% %g' | \ + sed 's%^.*:\.o: *%%' | sed 's%^ *\\ *%%'| sed 's%^ *\(.*\):%\1:%' | \ + sed 's/\.idl/$(IDL_CLN_H)/' >>$@; \ + echo '' >>$@; \ + fi; \ + done ; + +-include .depidl + +#======================================================================= +# End specific part to omniorb +#======================================================================= diff --git a/salome_adm/unix/sstream.in b/salome_adm/unix/sstream.in new file mode 100644 index 000000000..323bbed45 --- /dev/null +++ b/salome_adm/unix/sstream.in @@ -0,0 +1,225 @@ +/* This is part of libio/iostream, providing -*- C++ -*- input/output. +Copyright (C) 2000 Free Software Foundation + +This file is part of the GNU IO Library. This library is free +software; you can redistribute it and/or modify it under the +terms of the GNU General Public License as published by the +Free Software Foundation; either version 2, or (at your option) +any later version. + +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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this library; see the file COPYING. If not, write to the Free +Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +As a special exception, if you link this library with files +compiled with a GNU compiler to produce an executable, this does not cause +the resulting executable to be covered by the GNU General Public License. +This exception does not however invalidate any other reasons why +the executable file might be covered by the GNU General Public License. */ + +/* Written by Magnus Fromreide (magfr@lysator.liu.se). */ + +#ifndef __SSTREAM__ +#define __SSTREAM__ + +#include +#include +#include + +namespace std +{ + class stringbuf : public streambuf + { + public: + typedef char char_type; + typedef int int_type; + typedef streampos pos_type; + typedef streamoff off_type; + + explicit stringbuf(int which=ios::in|ios::out) : + streambuf(which), buf(), mode(static_cast(which)), + rpos(0), bufsize(1) + { } + + explicit stringbuf(const std::string &s, int which=ios::in|ios::out) : + streambuf(which), buf(s), mode(static_cast(which)), + bufsize(1) + { + if(mode & ios::in) + { + setg(&defbuf, &defbuf + bufsize, &defbuf + bufsize); + } + if(mode & ios::out) + { + setp(&defbuf, &defbuf + bufsize); + } + rpos = (mode & ios::ate ? s.size() : 0); + } + + std::string str() const + { + const_cast(this)->sync(); // Sigh, really ugly hack + return buf; + }; + + void str(const std::string& s) + { + buf = s; + if(mode & ios::in) + { + gbump(egptr() - gptr()); + } + if(mode & ios::out) + { + pbump(pbase() - pptr()); + } + rpos = (mode & ios::ate ? s.size() : 0); + } + + protected: + inline virtual int sync(); + inline virtual int overflow(int = EOF); + inline virtual int underflow(); + private: + std::string buf; + ios::open_mode mode; + std::string::size_type rpos; + streamsize bufsize; + char defbuf; + }; + + class stringstreambase : virtual public ios { + protected: + stringbuf __my_sb; + public: + std::string str() const + { + return dynamic_cast(_strbuf)->str(); + } + void str(const std::string& s) + { + clear(); + dynamic_cast(_strbuf)->str(s); + } + + stringbuf* rdbuf() + { + return &__my_sb; + } + protected: + stringstreambase(int which) : + __my_sb(which) + { + init (&__my_sb); + } + + stringstreambase(const std::string& s, int which) : + __my_sb(s, which) + { + init (&__my_sb); + } + }; + + class istringstream : public stringstreambase, public istream { + public: + istringstream(int which=ios::in) : + stringstreambase(which) + { } + + istringstream(const std::string& s, int which=ios::in) : + stringstreambase(s, which) + { } + }; + + class ostringstream : public stringstreambase, public ostream { + public: + ostringstream(int which=ios::out) : + stringstreambase(which) + { } + + ostringstream(const std::string& s, int which=ios::out) : + stringstreambase(s, which) + { } + }; + + class stringstream : public stringstreambase, public iostream { + public: + stringstream(int which=ios::in|ios::out) : + stringstreambase(which) + { } + + stringstream(const std::string &s, int which=ios::in|ios::out) : + stringstreambase(s, which) + { } + }; +} + +inline int std::stringbuf::sync() +{ + if((mode & ios::out) == 0) + return EOF; + + streamsize n = pptr() - pbase(); + if(n) + { + buf.replace(rpos, std::string::npos, pbase(), n); + if(buf.size() - rpos != n) + return EOF; + rpos += n; + pbump(-n); + gbump(egptr() - gptr()); + } + return 0; +} + +inline int std::stringbuf::overflow(int ch) +{ + if((mode & ios::out) == 0) + return EOF; + + streamsize n = pptr() - pbase(); + + if(n && sync()) + return EOF; + + if(ch != EOF) + { + std::string::size_type oldSize = buf.size(); + + buf.replace(rpos, std::string::npos, ch); + if(buf.size() - oldSize != 1) + return EOF; + ++rpos; + } + return 0; +} + +inline int std::stringbuf::underflow() +{ + sync(); + if((mode & ios::in) == 0) + { + return EOF; + } + if(rpos >= buf.size()) + { + return EOF; + } + + std::string::size_type n = egptr() - eback(); + std::string::size_type s; + + s = buf.copy(eback(), n, rpos); + pbump(pbase() - pptr()); + gbump(eback() - gptr()); + int res = (0377 & buf[rpos]); + rpos += s; + return res; +} + +#endif /* not __STRSTREAM__ */ diff --git a/src/A_LIRE_SALOME b/src/A_LIRE_SALOME new file mode 100644 index 000000000..892bf1293 --- /dev/null +++ b/src/A_LIRE_SALOME @@ -0,0 +1,73 @@ +Environnement +------------- +repertoire de construction (build) : + variables d'environement, a passer plutot dans les Makefile + + export BUILD_SALOME=${HOME}/devSalome/build + export SALOME_LIB_DIR=${BUILD_SALOME}/lib + export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${BUILD_SALOME}/lib + +naming Service : cf. plus bas. + +IAPP_XML (exemple N. Rejneri adapté) +-------- + +- options de compilation revues (Qt avec threads) +- creation de librairie +- initialiser tous les membres de classe pointeurs à NULL dans le constructeur + (plantage à la 2° execution de mainWindow sur handler non nul) +- utilisation de getenv pour trouver le path des ressources (xml, librairies, icones) +- utilisation "extern C" pour l'appel de methode ds librairie dynamique + +Naming Service +-------------- +- creation librairie avec la classe d'implementation de SALOME_NamingService +- environnement + +export OMNIORB_CONFIG=${HOME}/.omniORB.cfg + +1 line in file ${HOME}/.omniORB.cfg +ORBInitRef NameService=corbaname::localhost + +(replace localhost by internet address to access Naming Service from other machines) + +# environnement Mico2.3.5 + +export MICODIR=/opt/mico2.3.5 +export MICOVERSION=` sed -n '/MICO_VERSION/ { y/b/./; s#^[^"]*"\([^"]*\)".*$#\1#p; }' \ + "$MICODIR/include/mico/version.h" ` +export PATH=${PATH}:${MICODIR}/bin +export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MICODIR}/lib +export MANPATH=${MANPATH}:${MICODIR}/man +export LIBPATH=${LIBPATH}:${MICODIR}/lib +export SHLIB_PATH=${SHLIB_PATH}:${MICODIR}/lib +export LIBRARY_PATH=${MICODIR}/lib +export CPLUS_INCLUDE_PATH=${MICODIR}/include + +------------------------------------------------------------------------------- +TODO LIST +------------------------------------------------------------------------------- + +Utils +----- + - CPU&Memory measurements + - Makefile : library, includes + - Doxygen comments + +Session +------- + +Server : + - test only one mainWindow (mutex) + +Loader : + - get stats to know if Server is OK before get interface + +Session stats : + - write the code + +Session Kill : + - write the code + - get stats to know if there is one or more active sessions before kill. + +Launch script for everything : diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx new file mode 100644 index 000000000..eeed8aed1 --- /dev/null +++ b/src/Container/Component_i.cxx @@ -0,0 +1,254 @@ +using namespace std; +//============================================================================= +// File : Component_i.cxx +// Created : jeu jui 12 08:04:40 CEST 2001 +// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA +// Project : SALOME +// Copyright : EDF 2001 - CEA 2001 +// $Header$ +//============================================================================= + +#include "SALOME_Component_i.hxx" +#include "RegistryConnexion.hxx" +#include "OpUtil.hxx" +#include +#include +#include "utilities.h" + +extern bool _Sleeping ; + +Engines_Component_i::Engines_Component_i() +{ +// MESSAGE("Component constructor"); +} + +Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName, + bool notif) : + _instanceName(instanceName), _interfaceName(interfaceName), + _myConnexionToRegistry(0), _ThreadId(0) , _graphName("") , _nodeName("") { + MESSAGE("Component constructor with instanceName "<< _instanceName); + _orb = CORBA::ORB::_duplicate(orb); + _poa = PortableServer::POA::_duplicate(poa); + _contId = contId ; + CORBA::Object_var o = _poa->id_to_reference(*contId); // container ior... + const CORBA::String_var ior = _orb->object_to_string(o); + _myConnexionToRegistry = new RegistryConnexion(0, 0, ior, "theSession", _instanceName.c_str()); + + _notifSupplier = new NOTIFICATION_Supplier(instanceName, notif); +} + +// Constructeur pour composant parallele: ne pas faire appel au registry!! +Engines_Component_i::Engines_Component_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName, + int flag, + bool notif ) + : _instanceName(instanceName), + _interfaceName(interfaceName), + _myConnexionToRegistry(0), + _ThreadId(0) +{ +// MESSAGE("Component constructor with instanceName "<< _instanceName); + _orb = CORBA::ORB::_duplicate(orb); + _poa = PortableServer::POA::_duplicate(poa); + _contId = contId ; + // CORBA::Object_var myself = this->_this(); //appel a _this = increment reference + + _notifSupplier = new NOTIFICATION_Supplier(instanceName, notif); +} + +Engines_Component_i::~Engines_Component_i() +{ + MESSAGE("Component destructor"); +// delete _myConnexionToRegistry; +// _myConnexionToRegistry = 0 ; +} + +char* Engines_Component_i::instanceName() { + return CORBA::string_dup(_instanceName.c_str()) ; +} + +char* Engines_Component_i::interfaceName() { + return CORBA::string_dup(_interfaceName.c_str()) ; +} + +void Engines_Component_i::ping() +{ + MESSAGE("Engines_Component_i::ping() pid "<< getpid() << " threadid " + << pthread_self()); +} + +void Engines_Component_i::destroy() +{ + MESSAGE("Engines_Component_i::destroy()"); + + delete _notifSupplier; + _notifSupplier = 0; + + delete _myConnexionToRegistry; + _myConnexionToRegistry = 0 ; + _poa->deactivate_object(*_id) ; + CORBA::release(_poa) ; + delete(_id) ; + _thisObj->_remove_ref(); + MESSAGE("Engines_Component_i::destroyed") ; +} + +Engines::Container_ptr Engines_Component_i::GetContainerRef() +{ + MESSAGE("Engines_Component_i::GetContainerRef"); + CORBA::Object_ptr o = _poa->id_to_reference(*_contId) ; + return Engines::Container::_narrow(o); +} + +PortableServer::ObjectId * Engines_Component_i::getId() +{ +// MESSAGE("PortableServer::ObjectId * Engines_Component_i::getId()"); + return _id ; +} + +void Engines_Component_i::beginService(const char *serviceName) +{ + MESSAGE("Send BeginService notification for " << serviceName << endl + << "Component instance : " << _instanceName << endl << endl); + _ThreadId = pthread_self() ; + _serviceName = serviceName ; + if ( pthread_setcanceltype( PTHREAD_CANCEL_ASYNCHRONOUS , NULL ) ) { + perror("pthread_setcanceltype ") ; + exit(0) ; + } + if ( pthread_setcancelstate( PTHREAD_CANCEL_ENABLE , NULL ) ) { + perror("pthread_setcancelstate ") ; + exit(0) ; + } + MESSAGE("Return from BeginService for " << serviceName + << " ThreadId " << _ThreadId + << " _graphName " << _graphName << " _nodeName " << _nodeName ); +} + +void Engines_Component_i::endService(const char *serviceName) +{ + MESSAGE("Send EndService notification for " << serviceName << endl + << "Component instance : " << _instanceName << endl << endl); + _ThreadId = 0 ; +} + +void Engines_Component_i::Names( const char * graphName , + const char * nodeName ) { + _graphName = graphName ; + _nodeName = nodeName ; +// MESSAGE("Engines_Component_i::Names( '" << _graphName << "' , '" +// << _nodeName << "' )"); +} + +char* Engines_Component_i::graphName() { + return CORBA::string_dup( _graphName.c_str() ) ; +} + +char* Engines_Component_i::nodeName() { + return CORBA::string_dup( _nodeName.c_str() ) ; +} + +bool Killer( int ThreadId , int signum ) { + if ( ThreadId ) { + if ( signum == 0 ) { + if ( pthread_cancel( ThreadId ) ) { + perror("Killer pthread_cancel error") ; + return false ; + } + else { + MESSAGE("Killer : ThreadId " << ThreadId << " pthread_cancel") ; + } + } + else { + if ( pthread_kill( ThreadId , signum ) == -1 ) { + perror("Killer pthread_kill error") ; + return false ; + } + else { + MESSAGE("Killer : ThreadId " << ThreadId << " pthread_killed(" + << signum << ")") ; + } + } + } + return true ; +} + +bool Engines_Component_i::Kill_impl() { + MESSAGE("Engines_Component_i::Kill_i() pthread_t "<< pthread_self() + << " pid " << getpid() << " instanceName " + << _instanceName.c_str() << " interface " << _interfaceName.c_str() + << " machineName " << GetHostname().c_str()<< " _id " << hex << _id + << dec << " _ThreadId " << _ThreadId << " this " << hex << this + << dec ) ; + bool RetVal = false ; + if ( _ThreadId > 0 && pthread_self() != _ThreadId ) { + RetVal = Killer( _ThreadId , 0 ) ; + _ThreadId = (pthread_t ) -1 ; + } + return RetVal ; +} + +bool Engines_Component_i::Stop_impl() { + MESSAGE("Engines_Component_i::Stop_i() pthread_t "<< pthread_self() + << " pid " << getpid() << " instanceName " + << _instanceName.c_str() << " interface " << _interfaceName.c_str() + << " machineName " << GetHostname().c_str()<< " _id " << hex << _id + << dec << " _ThreadId " << _ThreadId ); + bool RetVal = false ; + if ( _ThreadId > 0 && pthread_self() != _ThreadId ) { + RetVal = Killer( _ThreadId , 0 ) ; + _ThreadId = (pthread_t ) -1 ; + } + return RetVal ; +} + +bool Engines_Component_i::Suspend_impl() { + MESSAGE("Engines_Component_i::Suspend_i() pthread_t "<< pthread_self() + << " pid " << getpid() << " instanceName " + << _instanceName.c_str() << " interface " << _interfaceName.c_str() + << " machineName " << GetHostname().c_str()<< " _id " << hex << _id + << dec << " _ThreadId " << _ThreadId ); + bool RetVal = false ; + if ( _ThreadId > 0 && pthread_self() != _ThreadId ) { + if ( _Sleeping ) { + return false ; + } + else { + RetVal = Killer( _ThreadId ,SIGINT ) ; + } + } + return RetVal ; +} + +bool Engines_Component_i::Resume_impl() { + MESSAGE("Engines_Component_i::Resume_i() pthread_t "<< pthread_self() + << " pid " << getpid() << " instanceName " + << _instanceName.c_str() << " interface " << _interfaceName.c_str() + << " machineName " << GetHostname().c_str()<< " _id " << hex << _id + << dec << " _ThreadId " << _ThreadId ); + bool RetVal = false ; + if ( _ThreadId > 0 && pthread_self() != _ThreadId ) { + if ( _Sleeping ) { + _Sleeping = false ; + RetVal = true ; + } + else { + RetVal = false ; + } + } + return RetVal ; + +} + +// Send message to event channel + +void Engines_Component_i::sendMessage(const char *event_type, const char *message) { + _notifSupplier->Send(graphName(), nodeName(), event_type, message); +} diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx new file mode 100644 index 000000000..d1ed7f09d --- /dev/null +++ b/src/Container/Container_i.cxx @@ -0,0 +1,446 @@ +using namespace std; +//============================================================================= +// File : Container_i.cxx +// Created : jeu jui 12 08:04:40 CEST 2001 +// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA +// Project : SALOME +// Copyright : EDF 2001 - CEA 2001 +// $Header$ +//============================================================================= + +#include +#include CORBA_SERVER_HEADER(SALOME_Component) +#include "SALOME_Container_i.hxx" +#include "SALOME_NamingService.hxx" +#include "Utils_SINGLETON.hxx" +#include "OpUtil.hxx" +#include +#include +#include + +#include "utilities.h" + +bool _Sleeping = false ; + +// Containers with name FactoryServer are started via rsh in LifeCycleCORBA +// Other Containers are started via start_impl of FactoryServer + +extern "C" {void ActSigIntHandler() ; } +extern "C" {void SigIntHandler(int, siginfo_t *, void *) ; } + +Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + char *containerName , + int argc , char* argv[] ) : + _numInstance(0) +{ + + ActSigIntHandler() ; + + _argc = argc ; + _argv = argv ; + int i = strlen( _argv[ 0 ] ) - 1 ; + while ( i >= 0 ) { + if ( _argv[ 0 ][ i ] == '/' ) { + _argv[ 0 ][ i+1 ] = '\0' ; + break ; + } + i -= 1 ; + } + string hostname = GetHostname(); + MESSAGE(hostname << " " << getpid() << " Engines_Container_i starting argc " + << _argc) ; + i = 0 ; + while ( _argv[ i ] ) { + MESSAGE(" argv" << i << " " << _argv[ i ]) ; + i++ ; + } + if ( argc != 4 ) { + MESSAGE("SALOME_Container usage : SALOME_Container ServerName -ORBInitRef NameService=corbaname::hostname:tcpipPortNumber") ; +// exit(0) ; + } + + SCRUTE(hostname); + + _containerName = "/Containers/"; + if (strlen(containerName)== 0) + { + _containerName += hostname; + } + else + { + _containerName += hostname; + _containerName += "/" ; + _containerName += containerName; + } + + _orb = CORBA::ORB::_duplicate(orb) ; + _poa = PortableServer::POA::_duplicate(poa) ; + MESSAGE("activate object"); + _id = _poa->activate_object(this); + +// _NS = new SALOME_NamingService(_orb); + _NS = SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + _NS->init_orb( orb ) ; + + Engines::Container_ptr pCont + = Engines::Container::_narrow(_this()); + SCRUTE(_containerName); + _NS->Register(pCont, _containerName.c_str()); +} + +// Constructeur pour composant parallele : ne pas faire appel au naming service +Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + char *containerName, + int flag ) + : _numInstance(0) +{ + string hostname = GetHostname(); + SCRUTE(hostname); + + _containerName = "/Containers/"; + if (strlen(containerName)== 0) + { + _containerName += hostname; + } + else + { + _containerName += containerName; + } + + _orb = CORBA::ORB::_duplicate(orb) ; + _poa = PortableServer::POA::_duplicate(poa) ; + +} + +Engines_Container_i::~Engines_Container_i() +{ + MESSAGE("Container_i::~Container_i()"); +} + +char* Engines_Container_i::name() +{ + return CORBA::string_dup(_containerName.c_str()) ; +} + +char* Engines_Container_i::machineName() +{ + string s = GetHostname(); + MESSAGE("Engines_Container_i::machineName " << s); + return CORBA::string_dup(s.c_str()) ; +} + +void Engines_Container_i::ping() +{ + MESSAGE("Engines_Container_i::ping() pid "<< getpid()); +} + +bool Engines_Container_i::Kill_impl() { + MESSAGE("Engines_Container_i::Kill() pid "<< getpid() << " containerName " + << _containerName.c_str() << " machineName " + << GetHostname().c_str()); + exit( 0 ) ; +} + +Engines::Container_ptr Engines_Container_i::start_impl( + const char* ContainerName ) { + MESSAGE("start_impl argc " << _argc << " ContainerName " << ContainerName + << hex << this << dec) ; + _numInstanceMutex.lock() ; // lock on the instance number + + CORBA::Object_var obj = Engines::Container::_nil() ; + bool nilvar = true ; + try { + string cont("/Containers/"); + cont += machineName() ; + cont += "/" ; + cont += ContainerName; + INFOS(machineName() << " start_impl unknown container " << cont.c_str() + << " try to Resolve" ); + obj = _NS->Resolve( cont.c_str() ); + nilvar = CORBA::is_nil( obj ) ; + if ( nilvar ) { + INFOS(machineName() << " start_impl unknown container " + << ContainerName); + } + } + catch (ServiceUnreachable&) { + INFOS(machineName() << "Caught exception: Naming Service Unreachable"); + } + catch (...) { + INFOS(machineName() << "Caught unknown exception."); + } + if ( !nilvar ) { + _numInstanceMutex.unlock() ; + MESSAGE("start_impl container found without runSession") ; + return Engines::Container::_narrow(obj); + } + int i = 0 ; + while ( _argv[ i ] ) { + MESSAGE(" argv" << i << " " << _argv[ i ]) ; + i++ ; + } +// string shstr( "rsh -n " ) ; +// shstr += machineName() ; +// shstr += " " ; +// shstr += _argv[ 0 ] ; +// string shstr( _argv[ 0 ] ) ; + string shstr( "./runSession SALOME_Container " ) ; + shstr += ContainerName ; + if ( _argc == 4 ) { + shstr += " " ; + shstr += _argv[ 2 ] ; + shstr += " " ; + shstr += _argv[ 3 ] ; + } + shstr += " > /tmp/" ; + shstr += ContainerName ; + shstr += ".log 2>&1 &" ; + MESSAGE("system(" << shstr << ")") ; + int status = system( shstr.c_str() ) ; + if (status == -1) { + INFOS("Engines_Container_i::start_impl runSession(SALOME_Container) failed (system command status -1)") ; + } + else if (status == 217) { + INFOS("Engines_Container_i::start_impl runSession(SALOME_Container) failed (system command status 217)") ; + } + INFOS(machineName() << " Engines_Container_i::start_impl runSession(SALOME_Container) done"); +#if 0 + pid_t pid = fork() ; + if ( pid == 0 ) { + string anExe( _argv[ 0 ] ) ; + anExe += "runSession" ; + char * args[ 6 ] ; + args[ 0 ] = "runSession" ; + args[ 1 ] = "SALOME_Container" ; + args[ 2 ] = strdup( ContainerName ) ; + args[ 3 ] = strdup( _argv[ 2 ] ) ; + args[ 4 ] = strdup( _argv[ 3 ] ) ; + args[ 5 ] = NULL ; + MESSAGE("execl(" << anExe.c_str() << " , " << args[ 0 ] << " , " + << args[ 1 ] << " , " << args[ 2 ] << " , " << args[ 3 ] + << " , " << args[ 4 ] << ")") ; + int status = execv( anExe.c_str() , args ) ; + if (status == -1) { + INFOS("Engines_Container_i::start_impl execl failed (system command status -1)") ; + perror( "Engines_Container_i::start_impl execl error ") ; + } + else { + INFOS(machineName() << " Engines_Container_i::start_impl execl done"); + } + exit(0) ; + } +#endif + + obj = Engines::Container::_nil() ; + try { + string cont("/Containers/"); + cont += machineName() ; + cont += "/" ; + cont += ContainerName; + nilvar = true ; + int count = 20 ; + while ( nilvar && count >= 0) { + sleep( 1 ) ; + obj = _NS->Resolve(cont.c_str()); + nilvar = CORBA::is_nil( obj ) ; + if ( nilvar ) { + INFOS(count << ". " << machineName() + << " start_impl unknown container " << cont.c_str()); + count -= 1 ; + } + } + _numInstanceMutex.unlock() ; + if ( !nilvar ) { + MESSAGE("start_impl container found after runSession(SALOME_Container)") ; + } + return Engines::Container::_narrow(obj); + } + catch (ServiceUnreachable&) { + INFOS(machineName() << "Caught exception: Naming Service Unreachable"); + } + catch (...) { + INFOS(machineName() << "Caught unknown exception."); + } + _numInstanceMutex.unlock() ; + MESSAGE("start_impl container not found after runSession(SALOME_Container)") ; + return Engines::Container::_nil() ; +} + +Engines::Component_ptr Engines_Container_i::load_impl + (const char* nameToRegister, + const char* componentName) +{ + BEGIN_OF("Container_i::load_impl"); + + _numInstanceMutex.lock() ; // lock on the instance number + _numInstance++ ; + char _aNumI[12]; + sprintf(_aNumI,"%d",_numInstance) ; + + string _impl_name = componentName; + string _nameToRegister = nameToRegister; + string instanceName = _nameToRegister + "_inst_" + _aNumI ; + //SCRUTE(instanceName); + + //string absolute_impl_name = _library_path + "lib" + _impl_name + ".so"; + string absolute_impl_name(_impl_name); + // SCRUTE(absolute_impl_name); + void* handle; + handle = dlopen(absolute_impl_name.c_str(), RTLD_LAZY); + if (!handle) + { + INFOS("Can't load shared library : " << absolute_impl_name); + INFOS("error dlopen: " << dlerror()); + _numInstanceMutex.unlock() ; + return Engines::Component::_nil() ; + } + + string factory_name = _nameToRegister + string("Engine_factory"); + // SCRUTE(factory_name) ; + + typedef PortableServer::ObjectId * (*FACTORY_FUNCTION) + (CORBA::ORB_ptr, + PortableServer::POA_ptr, + PortableServer::ObjectId *, + const char *, + const char *) ; +// typedef PortableServer::ObjectId * (*FACTORY_FUNCTION_SUPERV) +// (CORBA::ORB_ptr, +// PortableServer::POA_ptr, +// PortableServer::ObjectId *, +// const char *, +// const char * , +// int , char ** ) ; + + FACTORY_FUNCTION Component_factory = (FACTORY_FUNCTION) dlsym(handle, factory_name.c_str()); +// FACTORY_FUNCTION_SUPERV Component_factory_superv = (FACTORY_FUNCTION_SUPERV) Component_factory ; + +// PortableServer::ObjectId * (*Component_factory) (CORBA::ORB_ptr, +// PortableServer::POA_ptr, +// PortableServer::ObjectId *, +// const char *, +// const char *) = +// (PortableServer::ObjectId * (*) (CORBA::ORB_ptr, +// PortableServer::POA_ptr, +// PortableServer::ObjectId *, +// const char *, +// const char *)) +// dlsym(handle, factory_name.c_str()); + + char *error ; + if ((error = dlerror()) != NULL) + { + INFOS("Can't resolve symbol: " + factory_name); + SCRUTE(error); + _numInstanceMutex.unlock() ; + return Engines::Component::_nil() ; + } + + // Instanciate required CORBA object + PortableServer::ObjectId * id ; +// if ( factory_name == "SupervisionEngine_factory" ) { // for Python ... +// id = (Component_factory_superv) (_orb, _poa, _id, instanceName.c_str(), +// _nameToRegister.c_str(), _argc , _argv ); +// } +// else { + id = (Component_factory) (_orb, _poa, _id, instanceName.c_str(), + _nameToRegister.c_str()); +// } + // get reference from id + CORBA::Object_var o = _poa->id_to_reference(*id); + Engines::Component_var iobject = Engines::Component::_narrow(o) ; + +// _numInstanceMutex.lock() ; // lock on the add on handle_map (necessary ?) + // register the engine under the name containerName.dir/nameToRegister.object + string component_registerName = _containerName + "/" + _nameToRegister; + _NS->Register(iobject, component_registerName.c_str()) ; + +//Jr _numInstanceMutex.lock() ; // lock on the add on handle_map (necessary ?) + handle_map[instanceName] = handle; + _numInstanceMutex.unlock() ; +// END_OF("Container_i::load_impl"); + return Engines::Component::_duplicate(iobject); +} + +void Engines_Container_i::remove_impl(Engines::Component_ptr component_i) +{ + ASSERT(! CORBA::is_nil(component_i)); + string instanceName = component_i->instanceName() ; + MESSAGE("unload component " << instanceName); + component_i->destroy() ; + MESSAGE("test key handle_map"); + _numInstanceMutex.lock() ; // lock on the remove on handle_map + if (handle_map[instanceName]) // if key does not exist, created & initialized null + { + remove_map[instanceName] = handle_map[instanceName] ; + } + else MESSAGE("pas d'entree handle_map"); + handle_map.erase(instanceName) ; + _numInstanceMutex.unlock() ; + MESSAGE("contenu handle_map"); + map::iterator im ; + for (im = handle_map.begin() ; im != handle_map.end() ; im ++) + { + MESSAGE("reste " << (*im).first); + } +} + +void Engines_Container_i::finalize_removal() +{ + MESSAGE("finalize unload : dlclose"); + map::iterator im ; + _numInstanceMutex.lock() ; // lock on the explore remove_map & dlclose + for (im = remove_map.begin() ; im != remove_map.end() ; im ++) + { + void * handle = (*im).second ; + dlclose(handle) ; + MESSAGE("dlclose " << (*im).first); + } + remove_map.clear() ; + _numInstanceMutex.unlock() ; + MESSAGE("remove_map.clear()"); +} + +void ActSigIntHandler() { + struct sigaction SigIntAct ; + SigIntAct.sa_sigaction = &SigIntHandler ; + SigIntAct.sa_flags = SA_SIGINFO ; + if ( sigaction( SIGINT , &SigIntAct, NULL ) ) { + perror("SALOME_Container main ") ; + exit(0) ; + } + else { + INFOS("SigIntHandler activated") ; + } +} + +void SigIntHandler(int what , siginfo_t * siginfo , + void * toto ) { + MESSAGE("SigIntHandler what " << what << endl + << " si_signo " << siginfo->si_signo << endl + << " si_code " << siginfo->si_code << endl + << " si_pid " << siginfo->si_pid) ; + if ( _Sleeping ) { + _Sleeping = false ; + INFOS("SigIntHandler END sleeping.") + MESSAGE("SigIntHandler END sleeping.") ; + return ; + } + else { + ActSigIntHandler() ; + _Sleeping = true ; + INFOS("SigIntHandler BEGIN sleeping.") + MESSAGE("SigIntHandler BEGIN sleeping.") ; + int count = 0 ; + while( _Sleeping ) { + sleep( 1 ) ; + count += 1 ; + } + INFOS("SigIntHandler LEAVE sleeping after " << count << " s.") + MESSAGE("SigIntHandler LEAVE sleeping after " << count << " s.") ; + return ; + } +} diff --git a/src/Container/Makefile.in b/src/Container/Makefile.in new file mode 100644 index 000000000..1d52e5ffa --- /dev/null +++ b/src/Container/Makefile.in @@ -0,0 +1,42 @@ +#============================================================================== +# File : Makefile.in +# Created : mar jui 3 12:58:13 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_PYSCRIPTS = SALOME_ComponentPy.py SALOME_ContainerPy.py + +EXPORT_HEADERS = \ + SALOME_Component_i.hxx \ + SALOME_Container_i.hxx + +# Libraries targets + +LIB = libSalomeContainer.la +LIB_SRC = Component_i.cxx Container_i.cxx +LIB_SERVER_IDL = SALOME_Registry.idl SALOME_Component.idl + +# Executables targets +BIN = SALOME_Container +BIN_SRC = +BIN_SERVER_IDL = SALOME_Component.idl + +CPPFLAGS+= $(PYTHON_INCLUDES) -I../Logger + +LDFLAGS+= -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSalomeLoggerServer + +LIBS += -Xlinker -export-dynamic $(PYTHON_LIBS) + +@CONCLUDE@ diff --git a/src/Container/SALOME_ComponentPy.py b/src/Container/SALOME_ComponentPy.py new file mode 100755 index 000000000..3dd4dd5a0 --- /dev/null +++ b/src/Container/SALOME_ComponentPy.py @@ -0,0 +1,159 @@ +#! /usr/bin/env python + +#============================================================================= +# File : SALOME_ComponentPy.py +# Created : lun sep 3 17:54:13 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================= + +import os +import sys +from omniORB import CORBA, PortableServer +import Engines, Engines__POA +import Registry +from Utils_Identity import * +from SALOME_NamingServicePy import * +from libNOTIFICATION import * + +from SALOME_utilities import * + +#============================================================================= + +#define an implementation of the component interface + +class SALOME_ComponentPy_i (Engines__POA.Component): + _orb = None + _poa = None + + #------------------------------------------------------------------------- + + def __init__ (self, orb, poa, contID, containerName, + instanceName, interfaceName, notif): + # Notif for notification services + # NOT YET IMPLEMENTED + MESSAGE( "SALOME_ComponentPy_i::__init__" + " " + str (containerName) + " " + str(instanceName) + " " + str(interfaceName) ) + self._orb = orb + self._poa = poa + self._instanceName = instanceName + self._interfaceName = interfaceName + self._containerName = containerName + self._notif = notif + self._myConnexionToRegistry = 0 + self._graphName = '' + self._nodeName = '' + self._ThreadId = 0 + + naming_service = SALOME_NamingServicePy_i(self._orb) + Component_path = "/Containers/" + os.getenv( "HOSTNAME" ) + "/" + self._containerName + "/" + self._interfaceName + MESSAGE( 'SALOME_ComponentPy_i Register' + str( Component_path ) ) + naming_service.Register(self._this(), Component_path) + + # Add componentinstance to registry + obj = naming_service.Resolve('/Registry') + if obj is None: + MESSAGE( "Registry Reference is invalid" ) + else: + regist = obj._narrow(Registry.Components) + if regist is None: + MESSAGE( "Registry Reference is invalid" ) + else: + ior = orb.object_to_string(contID) + MESSAGE( ior ) + + lesInfos = Identity(self._instanceName) + infos = Registry.Infos(lesInfos._name, + lesInfos._pid, + lesInfos._machine, + lesInfos._adip, + lesInfos._uid, + lesInfos._pwname, + int(lesInfos._tc_start), + 0,0,0, + lesInfos._cdir, + -1, + ior) + + res = regist.add(infos) + + self._notifSupplier = NOTIFICATION_Supplier_Swig(instanceName, notif) + + #------------------------------------------------------------------------- + + def _get_instanceName(self): + MESSAGE( "SALOME_ComponentPy_i::_get_instanceName" ) + return self._instanceName + + #------------------------------------------------------------------------- + + def ping(self): + MESSAGE( "SALOME_ComponentPy_i::ping" ) + + #------------------------------------------------------------------------- + + def destroy(self): + MESSAGE( "SALOME_ComponentPy_i::destroy" ) + poa.deactivate_object(self) + CORBA.release(_poa) + + #------------------------------------------------------------------------- + + def GetContainerRef(self): + MESSAGE( "SALOME_ComponentPy_i::GetContainerRef" ) + + #------------------------------------------------------------------------- + + def beginService(self , serviceName ): + MESSAGE( "Send BeginService notification for " + str(serviceName) + "for graph/node" + str(self._graphName) + str(self._nodeName) ) + MESSAGE( "Component instance : " + str ( self._instanceName ) ) + + #------------------------------------------------------------------------- + + def endService(self , serviceName ): + MESSAGE( "Send EndService notification for " + str(serviceName) + "for graph/node" + str(self._graphName) + str(self._nodeName) ) + MESSAGE( "Component instance : " + str(self._instanceName) ) + + #------------------------------------------------------------------------- + + def sendMessage(self , event_type , message ): + self._notifSupplier.Send(self.graphName(), self.nodeName(), event_type, message) + + #------------------------------------------------------------------------- + + def Names(self , GraphName , NodeName ): + MESSAGE( "SALOME_ComponentPy_i::Names" + str(GraphName) + str(NodeName) ) + self._graphName = GraphName + self._nodeName = NodeName + + #------------------------------------------------------------------------- + + def graphName(self): + return self._graphName + + #------------------------------------------------------------------------- + + def nodeName(self): + return self._nodeName + + #------------------------------------------------------------------------- + + def Kill(self): + MESSAGE( "SALOME_ComponentPy_i::Kill not yet implemented" ) + + #------------------------------------------------------------------------- + + def Stop(self): + MESSAGE( "SALOME_ComponentPy_i::Stop not yet implemented" ) + + #------------------------------------------------------------------------- + + def Suspend(self): + MESSAGE( "SALOME_ComponentPy_i::Suspend not yet implemented" ) + + #------------------------------------------------------------------------- + + def Resume(self): + MESSAGE( "SALOME_ComponentPy_i::Resume not yet implemented" ) + diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx new file mode 100644 index 000000000..b57a53005 --- /dev/null +++ b/src/Container/SALOME_Component_i.hxx @@ -0,0 +1,86 @@ +//============================================================================= +// File : SALOME_Component_i.hxx +// Created : jeu jui 12 08:04:40 CEST 2001 +// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA +// Project : SALOME +// Copyright : EDF 2001 - CEA 2001 +// $Header$ +//============================================================================= + +#ifndef _SALOME_COMPONENT_I_HXX_ +#define _SALOME_COMPONENT_I_HXX_ + +#include +#include +#include +#include +#include +#include +#include +#include CORBA_SERVER_HEADER(SALOME_Component) +#include "NOTIFICATION.hxx" + +class RegistryConnexion; + +class Engines_Component_i: public virtual POA_Engines::Component, + public virtual PortableServer::RefCountServantBase +{ +public: + Engines_Component_i(); + Engines_Component_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName, + bool notif = false); + // Consructeur pour composant parallele: ne pas faire appel au registry + Engines_Component_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName, + int flag, + bool notif = false); + + virtual ~Engines_Component_i(); + + char* instanceName(); + char* interfaceName(); + + void destroy(); + void ping(); + + Engines::Container_ptr GetContainerRef(); + PortableServer::ObjectId * getId(); + + void beginService(const char *serviceName); + void endService(const char *serviceName); + void sendMessage(const char *event_type, const char *message); + + void Names( const char * graphName , const char * nodeName ) ; + char * graphName() ; + char * nodeName() ; + bool Kill_impl(); + bool Stop_impl(); + bool Suspend_impl(); + bool Resume_impl(); + +protected: + string _instanceName ; + string _interfaceName ; + string _serviceName ; + string _graphName ; + string _nodeName ; + CORBA::ORB_ptr _orb; + PortableServer::POA_ptr _poa; + PortableServer::ObjectId * _id; + PortableServer::ObjectId * _contId; + Engines_Component_i * _thisObj ; + RegistryConnexion *_myConnexionToRegistry; + NOTIFICATION_Supplier* _notifSupplier; + +private: + pthread_t _ThreadId ; +}; + +#endif diff --git a/src/Container/SALOME_Container.cxx b/src/Container/SALOME_Container.cxx new file mode 100644 index 000000000..3ae29bacc --- /dev/null +++ b/src/Container/SALOME_Container.cxx @@ -0,0 +1,121 @@ +using namespace std; +//============================================================================= +// File : SALOME_Container.cxx +// Created : jeu jui 12 08:04:40 CEST 2001 +// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA +// Project : SALOME +// Copyright : EDF 2001 - CEA 2001 +// $Header$ +//============================================================================= +using namespace std; +#include + +# include "Utils_ORB_INIT.hxx" +# include "Utils_SINGLETON.hxx" + +#include "SALOME_Container_i.hxx" +#include +#include +#include "utilities.h" + +#include + +static PyMethodDef MethodPyVoidMethod[] = { + { NULL, NULL } +}; + +int main(int argc, char* argv[]) +{ + INFOS_COMPILATION; + BEGIN_OF(argv[0]) + + Py_Initialize() ; + PySys_SetArgv( argc , argv ) ; + Py_InitModule( "InitPyRunMethod" , MethodPyVoidMethod ) ; + + try { + + // Initialise the ORB. +// CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + CORBA::ORB_var &orb = init( argc , argv ) ; + + // Obtain a reference to the root POA. + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); + + // obtain the root poa manager + PortableServer::POAManager_var pman = root_poa->the_POAManager(); + + // 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(); + + orb->run(); + + 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.") + } + END_OF(argv[0]); +} + diff --git a/src/Container/SALOME_ContainerPy.py b/src/Container/SALOME_ContainerPy.py new file mode 100755 index 000000000..a5d96eda5 --- /dev/null +++ b/src/Container/SALOME_ContainerPy.py @@ -0,0 +1,162 @@ +#! /usr/bin/env python + +#============================================================================= +# File : SALOME_ContainerPy.py +# Created : lun sep 3 17:54:13 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================= + +import os +import sys +import string +from omniORB import CORBA, PortableServer +# import SALOMEDS before other SALOME modules +# (if not, incomplete import done by SALOME module: no load of SALOMEDS_attributes) +import SALOMEDS +import Engines, Engines__POA +from SALOME_NamingServicePy import * +from SALOME_ComponentPy import * + +from SALOME_utilities import * + +#============================================================================= + +#define an implementation of the container interface + +class SALOME_ContainerPy_i (Engines__POA.Container): + _orb = None + _poa = None + _numInstance = 0 + + #------------------------------------------------------------------------- + + def __init__(self, orb, poa, containerName): + MESSAGE( "SALOME_ContainerPy_i::__init__" ) + self._orb = orb + self._poa = poa + self._containerName = containerName + + myMachine=string.split(os.getenv( "HOSTNAME" ),'.') + naming_service = SALOME_NamingServicePy_i(self._orb) + self._naming_service = naming_service + Container_path = "/Containers/" + myMachine[0] + "/" + self._containerName + MESSAGE( str(Container_path) ) + naming_service.Register(self._this(), Container_path) + + #------------------------------------------------------------------------- + + def start_impl(self, ContainerName): + MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(ContainerName) ) + myMachine=string.split(os.getenv( "HOSTNAME" ),'.') + theContainer = "/Containers/" + myMachine[0] + "/" + ContainerName + try: + obj = self._naming_service.Resolve(theContainer) + except : + obj = None + MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(ContainerName) + ".object not found in Naming Service" ) + if obj is None: + container = None + else: + container = obj._narrow(Engines.Container) + if container is None: + MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(containerName) + ".object exists but is not a Container" ) + else : + MESSAGE( "SALOME_ContainerPy_i::start_impl " + str(ContainerName) + ".object found without runSession" ) + return container + shstr = os.getenv( "PWD" ) + "/" + shstr += "runSession ./SALOME_ContainerPy.py " + shstr += ContainerName + shstr += " > /tmp/" + shstr += ContainerName + shstr += ".log 2>&1 &" + MESSAGE( "SALOME_ContainerPy_i::start_impl " + "os.system(" + str(shstr) + ")" ) + os.system( shstr ) + count = 21 + while container is None : + time.sleep(1) + count = count - 1 + MESSAGE( str(count) + ". Waiting for " + str(theContainer) ) + try : + obj = self._naming_service.Resolve(theContainer) + except : + obj = None + if obj is None: + container = None + else: + container = obj._narrow(Engines.Container) + if container is None: + MESSAGE( str(containerName) + ".object exists but is not a Container" ) + return container + if count == 0 : + return container + + #------------------------------------------------------------------------- + + def load_impl(self, nameToRegister, componentName): + MESSAGE( "SALOME_ContainerPy_i::load_impl " + str(nameToRegister) + ' ' + str(componentName) ) + self._numInstance = self._numInstance +1 + instanceName = nameToRegister + "_inst_" + `self._numInstance` + interfaceName = nameToRegister + the_command = "import " + nameToRegister + "\n" + the_command = the_command + "comp_i = " + nameToRegister + "." + nameToRegister + the_command = the_command + "(self._orb, self._poa, self._this(), self._containerName, instanceName, interfaceName)\n" + MESSAGE( "SALOME_ContainerPy_i::load_impl :" + str (the_command) ) + exec the_command + comp_o = comp_i._this() + return comp_o + + #------------------------------------------------------------------------- + + def remove_impl(self, component): + MESSAGE( "SALOME_ContainerPy_i::remove_impl" ) + + #------------------------------------------------------------------------- + + def finalize_removal(self): + MESSAGE( "SALOME_ContainerPy_i::finalize_removal" ) + + #------------------------------------------------------------------------- + + def ping(self): + MESSAGE( "SALOME_ContainerPy_i::ping" ) + + #------------------------------------------------------------------------- + + def _get_name(self): + MESSAGE( "SALOME_ContainerPy_i::_get_name" ) + + #------------------------------------------------------------------------- + + def _get_machineName(self): + MESSAGE( "SALOME_ContainerPy_i::_get_MachineName" ) + self._machineName = "localhost" + return self._machineName + +#============================================================================= + +#initialise the ORB and find the root POA +orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) +poa = orb.resolve_initial_references("RootPOA") + +#create an instance of SALOME_ContainerPy_i and a Container reference +#containerName = "FactoryServerPy" +MESSAGE( str(sys.argv) ) +containerName = sys.argv[1] +cpy_i = SALOME_ContainerPy_i(orb, poa, containerName) +cpy_o = cpy_i._this() + +#activate the POA +poaManager = poa._get_the_POAManager() +poaManager.activate() + +#Block for ever +orb.run() + + + + + + diff --git a/src/Container/SALOME_Container_i.hxx b/src/Container/SALOME_Container_i.hxx new file mode 100644 index 000000000..6db4d5d8d --- /dev/null +++ b/src/Container/SALOME_Container_i.hxx @@ -0,0 +1,76 @@ +//============================================================================= +// File : SALOME_Container_i.hxx +// Created : jeu jui 12 08:04:44 CEST 2001 +// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA +// Project : SALOME +// Copyright : EDF 2001 - CEA 2001 +// $Header$ +//============================================================================= + +#ifndef _SALOME_CONTAINER_I_HXX_ +#define _SALOME_CONTAINER_I_HXX_ + +#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 +{ +public: + Engines_Container_i(); + Engines_Container_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + char * containerName , + int argc, char* argv[]); +// Constructeur pour composant parallele : ne pas faire appel au naming service + Engines_Container_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + char * containerName, + int flag); + virtual ~Engines_Container_i(); + + + Engines::Container_ptr start_impl(const char* ContainerName); + + Engines::Component_ptr load_impl(const char* nameToRegister, + const char* componentName); + void remove_impl(Engines::Component_ptr component_i); + void finalize_removal(); + + char* name(); + char* machineName(); + void ping(); + bool Kill_impl() ; + +protected: + + SALOME_NamingService *_NS ; + string _library_path; + string _containerName; + CORBA::ORB_var _orb; + PortableServer::POA_var _poa; + PortableServer::ObjectId * _id ; + int _numInstance ; + map handle_map ; + map remove_map ; + omni_mutex _numInstanceMutex ; // if several threads on the same object + +private: + + int _argc ; + char** _argv ; + +}; + +#endif + diff --git a/src/DataTypeCatalog/Makefile.in b/src/DataTypeCatalog/Makefile.in new file mode 100644 index 000000000..aa946fccd --- /dev/null +++ b/src/DataTypeCatalog/Makefile.in @@ -0,0 +1,41 @@ +#============================================================================== +# File : Makefile.in +# Created : mer jui 11 06:50:44 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_HEADERS = \ + SALOME_DataTypeCatalog_impl.hxx \ + SALOME_DataTypeCatalog_Parser.hxx \ + SALOME_DataTypeCatalog_Handler.hxx + +# Libraries targets +LIB = libSalomeDataTypeCatalog.la +LIB_SRC = \ + SALOME_DataTypeCatalog_Handler.cxx \ + SALOME_DataTypeCatalog_impl.cxx + +# Executables targets +# trouble we have client and serveur and build don't known about this with rule +# in fact client is a test ! So it may go away BIN ! +BIN = SALOME_DataTypeCatalog_Server SALOME_DataTypeCatalog_Client +BIN_SRC = +BIN_SERVER_IDL = SALOME_DataTypeCatalog.idl + +CPPFLAGS+= $(QT_MT_INCLUDES) +CXXFLAGS+= +LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSalomeLoggerServer + +@CONCLUDE@ diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Client.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Client.cxx new file mode 100644 index 000000000..00c25e2cd --- /dev/null +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Client.cxx @@ -0,0 +1,102 @@ +using namespace std; +/* $Header$ */ + +#include +#include "SALOME_NamingService.hxx" +#include "SALOME_DataTypeCatalog.hh" +#include +#include "utilities.h" + +int main(int argc,char **argv) +{ + CORBA::ORB_var orb; + CosNaming::NamingContext_var _rootContext; + CORBA::Object_var objVar, objVarN; + try { + + // initialize the ORB + + orb = CORBA::ORB_init (argc, argv); + + + // Get CORBA reference of the catalog + SALOME_NamingService NS(orb); + CORBA::Object_var objVarN = NS.Resolve("/Kernel/DataTypeCatalog"); + + SALOME_DataTypeCatalog::DataCatalog_var Catalogue = SALOME_DataTypeCatalog::DataCatalog::_narrow(objVarN); + MESSAGE("Distant catalog of data type found") + + // Get component list + SALOME_DataTypeCatalog::ListOfDataTypeName_var list_data_type = Catalogue->GetDataTypeList(); + int indice =-1; + for (unsigned int ind = 0; ind < list_data_type->length();ind++) + { + MESSAGE("Data Type list : " << list_data_type[ind]); + } + + + + // obtain interface_read of the first data type defined in the catalog + char* interf; + interf =Catalogue->GetDataInterfaceRead(list_data_type[0]); + MESSAGE("Interface read pour " << list_data_type[0] << " : " << interf); + + + + // obtain interface_read of the last data type defined in the catalog + interf =Catalogue->GetDataInterfaceRead(list_data_type[list_data_type->length() -1]); + MESSAGE("Interface read pour " << list_data_type[list_data_type->length() -1] << " : " << interf); + + // obtain interface_write of the first data type defined in the catalog + interf =Catalogue->GetDataInterfaceWrite(list_data_type[0]); + MESSAGE("Interface write pour " << list_data_type[0] << " : " << interf); + + + + // obtain interface_read of the last data type defined in the catalog + interf =Catalogue->GetDataInterfaceWrite(list_data_type[list_data_type->length() -1]); + MESSAGE("Interface write pour " << list_data_type[list_data_type->length() -1] << " : " << interf); + + //obtain parents name of the last data type defined in the catalog + SALOME_DataTypeCatalog::ListOfDataTypeName_var list_data_type1 = Catalogue->GetDataTypeParents(list_data_type[list_data_type->length() -1]); + + // Test derivation + if (Catalogue->isDerivedFrom(list_data_type[0],list_data_type[list_data_type->length() -1])) + { + MESSAGE("The type " << list_data_type[list_data_type->length() -1] << " derived from " << list_data_type[0] ); + } + else + { + MESSAGE("The type " << list_data_type[list_data_type->length() -1] << " is not derived from " << list_data_type[0]); + } + + } + catch(SALOME_DataTypeCatalog::NotFound &){ + INFOS("SALOME_DataTypeCatalog::NotFound"); + } + catch(CORBA::SystemException&) { + INFOS("Caught CORBA::SystemException.") + } + catch (CosNaming::NamingContext::CannotProceed &) { + INFOS("CosNaming::NamingContext::CannotProceed") + } + catch (CosNaming::NamingContext::NotFound &) { + INFOS("CosNaming::NamingContext::NotFound") + } + catch (CosNaming::NamingContext::InvalidName &) { + INFOS("CosNaming::NamingContext::InvalidName") + } + catch (CosNaming::NamingContext::AlreadyBound &) { + INFOS("CosNaming::NamingContext::AlreadyBound") + } + catch (CosNaming::NamingContext::NotEmpty &) { + INFOS("CosNaming::NamingContext::NotEmpty") + } + + catch(CORBA::Exception &sysEx) { + INFOS("Caught CORBA::Exception.") + } + + + return 0; +} diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.cxx new file mode 100644 index 000000000..f9288bb39 --- /dev/null +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.cxx @@ -0,0 +1,166 @@ +using namespace std; +// File: SALOME_DataTypeCatalog_Handler.cxx +// Created: Mon Aug 08 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + +#define WRITE_CATA_DATA_TYPE +#include "SALOME_DataTypeCatalog_Handler.hxx" + +//---------------------------------------------------------------------- +// Function : SALOME_DataTypeCatalog_Handler +// Purpose : Constructor +//---------------------------------------------------------------------- +SALOME_DataTypeCatalog_Handler::SALOME_DataTypeCatalog_Handler() +{ + MESSAGE("SALOME_DataTypeCatalog_Handler creation"); + // XML Tags initialisation + // Used in the function endElement + test_data_type_name = "DataType-name"; + test_data_type_interf_read = "DataType-interface-read"; + test_data_type_interf_write = "DataType-interface-write"; + test_data_type_parent_name = "Parent-name" ; + test_data_type_parents = "DataType-Parents-list"; + test_data_type = "DataType"; +} + +//---------------------------------------------------------------------- +// Function : ~SALOME_DataTypeCatalog_Handler +// Purpose : Destructor +//---------------------------------------------------------------------- +SALOME_DataTypeCatalog_Handler::~SALOME_DataTypeCatalog_Handler() +{ + MESSAGE("SALOME_DataTypeCatalog_Handler destruction"); +} + +//---------------------------------------------------------------------- +// Function : startDocument +// Purpose : overload handler function +//---------------------------------------------------------------------- +bool SALOME_DataTypeCatalog_Handler::startDocument() +{ + MESSAGE("Begin parse document") + // Empty the private elements + _datatypelist.resize(0); + _a_data_parents_list.resize(0); + return true; +} + +//---------------------------------------------------------------------- +// Function : startElement +// Purpose : overload handler function +//---------------------------------------------------------------------- +bool SALOME_DataTypeCatalog_Handler::startElement(const QString&, + const QString &, + const QString& qName, + const QXmlAttributes& atts) +{ + return true; +} + +//---------------------------------------------------------------------- +// Function : endElement +// Purpose : overload handler function +//---------------------------------------------------------------------- +bool SALOME_DataTypeCatalog_Handler::endElement(const QString&, + const QString &, + const QString& qName) +{ + // DataType + + // tag test_data_type_name + if((qName.compare(QString(test_data_type_name))==0)) + _a_data_type.Parserdata_name = content; + // tag test_data_type_interf_read + if((qName.compare(QString(test_data_type_interf_read))==0)) + _a_data_type.Parserdata_interface_read = content; + // tag test_data_type_interf_write + if((qName.compare(QString(test_data_type_interf_write))==0)) + _a_data_type.Parserdata_interface_write = content; + + // tag test_data_type_parent_name + if((qName.compare(QString(test_data_type_parent_name))==0)) + _a_data_parents_list.push_back(content); + + // tag test_data_type_parents + if((qName.compare(QString(test_data_type_parents))==0)) + { + _a_data_type.Parserdata_parents = _a_data_parents_list; + _a_data_parents_list.resize(0);; + } + + // tag test_data_type + if((qName.compare(QString(test_data_type))==0)) + { + _datatypelist.push_back(_a_data_type); + + // Empty temporary structures + _a_data_type.Parserdata_name = ""; + _a_data_type.Parserdata_interface_read = ""; + _a_data_type.Parserdata_interface_write = ""; + _a_data_type.Parserdata_parents.resize(0); + } + + + + return true; +} + +//---------------------------------------------------------------------- +// Function : characters +// Purpose : overload handler function +//---------------------------------------------------------------------- +bool SALOME_DataTypeCatalog_Handler::characters(const QString& chars) +{ + content = chars ; + return true; +} + +//---------------------------------------------------------------------- +// Function : endDocument +// Purpose : overload handler function +// Print all informations find in the catalog +// (only in DEBUG mode!!) +//---------------------------------------------------------------------- +bool SALOME_DataTypeCatalog_Handler::endDocument() +{ + //_datatypelist + for (unsigned int ind = 0; ind < _datatypelist.size(); ind++) + { + MESSAGE("DataType Name :"<<_datatypelist[ind].Parserdata_name); + MESSAGE("DataType interface read :"<<_datatypelist[ind].Parserdata_interface_read); + MESSAGE("DataType interface write :"<<_datatypelist[ind].Parserdata_interface_write); + + for (unsigned int i = 0; i < _datatypelist[ind].Parserdata_parents.size(); i++) + MESSAGE("Parent name :" << _datatypelist[ind].Parserdata_parents[i]); + } + + MESSAGE("Document parsed"); + return true; +} + +//---------------------------------------------------------------------- +// Function : errorProtocol +// Purpose : overload handler function +//---------------------------------------------------------------------- +QString SALOME_DataTypeCatalog_Handler::errorProtocol() +{ + return errorProt ; +} + + +//---------------------------------------------------------------------- +// Function : fatalError +// Purpose : overload handler function +//---------------------------------------------------------------------- +bool SALOME_DataTypeCatalog_Handler::fatalError(const QXmlParseException& exception) +{ + errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) + .arg( exception.message() ) + .arg( exception.lineNumber() ) + .arg( exception.columnNumber() ); + + return QXmlDefaultHandler::fatalError( exception ); +} diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.hxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.hxx new file mode 100644 index 000000000..060049299 --- /dev/null +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Handler.hxx @@ -0,0 +1,100 @@ +// File: SALOME_DataTypeCatalog_Handler.hxx +// Created: Mon Aug 08 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + +#ifndef SALOME_DATA_CATALOG_HANDLER_H +#define SALOME_DATA_CATALOG_HANDLER_H + +#include "utilities.h" +#include "SALOME_DataTypeCatalog_Parser.hxx" +#include +#include +#include + +class SALOME_DataTypeCatalog_Handler : public QXmlDefaultHandler +{ +public: + //! standard constructor + SALOME_DataTypeCatalog_Handler(); + + //! standard destructor + virtual ~SALOME_DataTypeCatalog_Handler(); + + + //! method to overload handler function startDocument + /*! Is called before a xml file is parsed + \return true if no error was detected + */ + virtual bool startDocument(); + + + //! method to overload handler function startElement + /*! + \param Qstring argument by value + \param Qstring argument by value + \param Qstring argument by value + \param QXmlAttributes argument by value + \return true if no error was detected + */ + virtual bool startElement(const QString&, const QString &, + const QString& qName, const QXmlAttributes& atts); + + //! method to overload handler function endElement + /*! + \param Qstring argument by value + \param Qstring argument by value + \param Qstring argument by value + \return true if no error was detected + \sa _Find + */ + virtual bool endElement(const QString&, const QString &, + const QString& qName); + + + //! method to overload handler function characters + /*! + \param Qstring argument by value + \return true if no error was detected + */ + virtual bool characters(const QString& chars); + + //! method to overload handler function endDocument + /*! Is called at the end of the parsing + \return true if no error was detected + */ + virtual bool endDocument(); + + //! method to overload handler function errorProtocol + /*! + \return the error message + */ + virtual QString errorProtocol(); + + //! method to overload handler function fatalError + /*! + \param QXmlParseExecption argument by value + \return true if no error was detected + */ + virtual bool fatalError(const QXmlParseException& exception); + +private: + QString errorProt ; + + string content; + + const char* test_data_type_name ; + const char* test_data_type_interf_read ; + const char* test_data_type_interf_write ; + const char* test_data_type_parent_name ; + const char* test_data_type_parents ; + const char* test_data_type; + + ParserDataType _a_data_type; + + ListOfParserDataTypeName _a_data_parents_list ; +}; + +#endif // SALOME_DATA_CATALOG_HANDLER_H diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Parser.hxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Parser.hxx new file mode 100644 index 000000000..9dcabac55 --- /dev/null +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Parser.hxx @@ -0,0 +1,33 @@ +// File: SALOME_DataTypeCatalog_Parser.hxx +// Created: Mon Aug 08 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + +#ifndef SALOME_DATA_CATALOG_PARSER_H +#define SALOME_DATA_CATALOG_PARSER_H + +#include +#include + +// Type Definitions +typedef vector ListOfParserDataTypeName; + +struct ParserDataType{ + string Parserdata_name ; + string Parserdata_interface_read; + string Parserdata_interface_write; + ListOfParserDataTypeName Parserdata_parents ; +}; + +typedef 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/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx new file mode 100644 index 000000000..0971a23e1 --- /dev/null +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx @@ -0,0 +1,60 @@ +using namespace std; +// File: SALOME_DataTypeCatalog_Server.cxx +// Created: Mon Aug 08 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ +#include +#include "SALOME_NamingService.hxx" +#include "SALOME_DataTypeCatalog_impl.hxx" +#include "utilities.h" + +int main(int argc,char **argv) +{ + try { + CosNaming::NamingContext_var _rootContext, catalogContext; + + // initialize the ORB + + CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); + + // initialize POA + + CORBA::Object_var poaobj = orb->resolve_initial_references ("RootPOA"); + + PortableServer::POA_var poa = PortableServer::POA::_narrow (poaobj); + PortableServer::POAManager_var mgr = poa->the_POAManager(); + + // Active catalog + + SALOME_DataTypeCatalogImpl* Catalogue_i = new SALOME_DataTypeCatalogImpl(argc, argv); + poa->activate_object (Catalogue_i); + + mgr->activate(); + + + CORBA::Object_ptr myCata = Catalogue_i->_this(); + + // initialise Naming Service + SALOME_NamingService *_NS; + _NS = new SALOME_NamingService(orb); + // register Catalog in Naming Service + _NS->Register(myCata ,"/Kernel/DataTypeCatalog"); + + MESSAGE("Running DataType Catalog Server.") + + orb->run(); + + poa->destroy(1,1); + + } + catch(CORBA::SystemException&) { + INFOS("Caught CORBA::SystemException.") + } + catch(CORBA::Exception&) { + INFOS("Caught CORBA::Exception.") + } + + return 0; +} diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx new file mode 100644 index 000000000..c1292cb07 --- /dev/null +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.cxx @@ -0,0 +1,350 @@ +using namespace std; +// File: SALOME_DataTypeCatalog_impl.cxx +// Created: Mon Aug 08 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + +#include "SALOME_DataTypeCatalog_impl.hxx" +#include + +//---------------------------------------------------------------------- +// Function : SALOME_DataTypeCatalogImpl +// Purpose : Constructor +//---------------------------------------------------------------------- +SALOME_DataTypeCatalogImpl::SALOME_DataTypeCatalogImpl(int argc, char** argv) +{ + MESSAGE("DataType Catalog creation"); + + // Empty used variables + _datatype_list.resize(0); + + // Parse the arguments given at server run + if (!_parseArguments(argc, argv,&_path_datatype)) + MESSAGE( "Error while argument parsing" ) + + // Test existency of files + if (_path_datatype == NULL) + MESSAGE( "Error the data type catalog should be indicated" ) + else + { + MESSAGE("Parse data type catalog"); + // Affect the variable _datatype_list + _parse_xml_file(_path_datatype,_datatype_list); + + // Verification of _datatype_list content + if(!_verify_data_type(_datatype_list)) + MESSAGE( "Error while parsing the data type list" ) + else MESSAGE("Data Type list OK"); + } +} + +//---------------------------------------------------------------------- +// Function : ~SALOME_DataTypeCatalogImpl +// Purpose : Destructor +//---------------------------------------------------------------------- +SALOME_DataTypeCatalogImpl::~SALOME_DataTypeCatalogImpl() +{ + MESSAGE("DataType Catalog Destruction"); +} + + +//---------------------------------------------------------------------- +// Function : GetDataTypeList +// Purpose : get a data type name list +//---------------------------------------------------------------------- +SALOME_DataTypeCatalog::ListOfDataTypeName* +SALOME_DataTypeCatalogImpl::GetDataTypeList() +{ + MESSAGE("Begin of GetDataTypeList"); + SALOME_DataTypeCatalog::ListOfDataTypeName_var _list_data = + new SALOME_DataTypeCatalog::ListOfDataTypeName; + + _list_data->length(_datatype_list.size()); + + // Duplicate each data type name defined in the catalog + for (unsigned int ind=0; ind < _datatype_list.size();ind++) + { + _list_data[ind]=CORBA::string_dup(_datatype_list[ind].Parserdata_name.c_str()); + // SCRUTE(_list_data[ind]) ; + } + + return _list_data._retn(); +} + +//---------------------------------------------------------------------- +// Function : isDerivedFrom +// Purpose : return true if type_out is derived from type_in +//---------------------------------------------------------------------- +CORBA::Boolean +SALOME_DataTypeCatalogImpl::isDerivedFrom(const char* type_in, + const char* type_out) + throw(SALOME_DataTypeCatalog::NotFound) +{ + + CORBA::Boolean _return_value = false ; + bool _found_in = false; + bool _found_out = false; + for (unsigned int ind=0; ind < _datatype_list.size();ind++) + { + if (strcmp((_datatype_list[ind].Parserdata_name).c_str(),type_out) == 0) + { + //type_out found + _found_out = true; + // Looking if type_in is indicated in the parents list + _return_value = _explore_parents(type_in,_datatype_list[ind]); + } + if (strcmp((_datatype_list[ind].Parserdata_name).c_str(),type_in) == 0) + _found_in = true; + } + + if(!_found_in) + { + MESSAGE("The data type " << type_in << " was not found in the data type catalog") + throw SALOME_DataTypeCatalog::NotFound() ; + } + if(!_found_out) + { + MESSAGE( "The data type " << type_out << " was not found in the data type catalog") + throw SALOME_DataTypeCatalog::NotFound() ; + } + + return _return_value; + +} + +//---------------------------------------------------------------------- +// Function : GetDataInterfaceRead +// Purpose : get the read interface name +//---------------------------------------------------------------------- +char* +SALOME_DataTypeCatalogImpl::GetDataInterfaceRead(const char* type) + throw(SALOME_DataTypeCatalog::NotFound) +{ + char* return_value = NULL; + bool _find = false; + for (unsigned int ind=0; ind < _datatype_list.size();ind++) + { + if (strcmp((_datatype_list[ind].Parserdata_name).c_str(),type) == 0) + { + _find = true; + return_value = CORBA::string_dup(_datatype_list[ind].Parserdata_interface_read.c_str()); + } + } + + // NotFound Exceptin is thrown if the data type indicated is not found in the catalog + if(!_find) + { + MESSAGE( "The data type " << type << " was not found in the data type catalog") + throw SALOME_DataTypeCatalog::NotFound() ; + } + + return return_value; +} + +//---------------------------------------------------------------------- +// Function : GetDataInterfaceWrite +// Purpose : get the write interface name +//---------------------------------------------------------------------- +char* +SALOME_DataTypeCatalogImpl::GetDataInterfaceWrite(const char* type) + throw(SALOME_DataTypeCatalog::NotFound) +{ + char* return_value = NULL; + bool _find = false; + for (unsigned int ind=0; ind < _datatype_list.size();ind++) + { + if (strcmp((_datatype_list[ind].Parserdata_name).c_str(),type) == 0) + { + _find = true; + return_value = CORBA::string_dup(_datatype_list[ind].Parserdata_interface_write.c_str()); + } + } + + // NotFound Exceptin is thrown if the data type indicated is not found in the catalog + if(!_find) + { + MESSAGE( "The data type " << type << " was not found in the data type catalog") + throw SALOME_DataTypeCatalog::NotFound() ; + } + return return_value; +} + +//---------------------------------------------------------------------- +// Function : GetDataTypeParents +// Purpose : get Parents data type name list +//---------------------------------------------------------------------- +SALOME_DataTypeCatalog::ListOfDataTypeName* +SALOME_DataTypeCatalogImpl::GetDataTypeParents(const char* type) throw(SALOME_DataTypeCatalog::NotFound) +{ + bool _find = false ; + + SALOME_DataTypeCatalog::ListOfDataTypeName_var _list_data = + new SALOME_DataTypeCatalog::ListOfDataTypeName; + + for (unsigned int ind=0; ind < _datatype_list.size();ind++) + { + if (strcmp((_datatype_list[ind].Parserdata_name).c_str(),type) == 0) + { + // Wanted type is found + // Get all the parents data type name of the type + _find = true; + _list_data->length(_datatype_list[ind].Parserdata_parents.size()); + for (unsigned int ind1=0; ind1 < _datatype_list[ind].Parserdata_parents.size();ind1++) + { + _list_data[ind1]=CORBA::string_dup(_datatype_list[ind].Parserdata_parents[ind1].c_str()); + // SCRUTE(_list_data[ind1]) ; + } + } + } + + // NotFound Exception is thrown if the data type indicated is not found + // in the catalog + if(!_find) + { + MESSAGE( "The data type " << type << " was not found in the data type catalog") + throw SALOME_DataTypeCatalog::NotFound() ; + } + + return _list_data._retn(); +} + +//---------------------------------------------------------------------- +// Function : _explore_parents +// Purpose : return true if type_out is derived from type_in +//---------------------------------------------------------------------- +CORBA::Boolean +SALOME_DataTypeCatalogImpl::_explore_parents(const char* type_in, + ParserDataType& data_out) +{ + + MESSAGE( "Begin of _explore_parents with data_out_name " << data_out.Parserdata_name); + + CORBA::Boolean found = false ; + if (data_out.Parserdata_name == type_in) + found = true ; + else + if (data_out.Parserdata_parents.size() >0) + for (unsigned int ind=0; ind < data_out.Parserdata_parents.size();ind++) + { + if (data_out.Parserdata_parents[ind] == type_in) + found = true ; + else + for (unsigned ip =0; ip < _datatype_list.size();ip++) + { + // run _explore_parents for each parent data of data_out + if (_datatype_list[ip].Parserdata_name == data_out.Parserdata_parents[ind]) + found = _explore_parents(type_in, _datatype_list[ip]); + } + } + return found ; +} + +//---------------------------------------------------------------------- +// Function : _parse_xml_file +// Purpose : parse one module catalog +//---------------------------------------------------------------------- +void +SALOME_DataTypeCatalogImpl::_parse_xml_file(const char* file, + ListOfParserDataType& datatypelist) +{ + SALOME_DataTypeCatalog_Handler* handler = new SALOME_DataTypeCatalog_Handler(); + QFile xmlFile(file); + + QXmlInputSource source(xmlFile); + + QXmlSimpleReader reader; + reader.setContentHandler( handler ); + reader.setErrorHandler( handler ); + reader.parse( source ); + xmlFile.close(); + datatypelist = _datatypelist; +} + + +//---------------------------------------------------------------------- +// Function : _verify_data_type +// Purpose : verify the data type structures from the catalog parsing +// Verify that the parents type associated to a type are defined +// in the catalog +//---------------------------------------------------------------------- +bool +SALOME_DataTypeCatalogImpl::_verify_data_type(ListOfParserDataType datatypelist) +{ + bool _return_value = true; + bool _bool = false ; + vector _data_name_list; + + _data_name_list.resize(0);; + for (unsigned int ind = 0; ind < _datatype_list.size(); ind++) + _data_name_list.push_back(_datatype_list[ind].Parserdata_name) ; + + // Parse if parents data type name of a data type are defined in the + // datatype catalog + for (unsigned int ind = 0; ind < _datatype_list.size(); ind++) + { + // Scrute data type parents + // MESSAGE("Treatment of " << _datatype_list[ind].Parserdata_name); + for (unsigned int ind1 = 0 ; ind1 < _datatype_list[ind].Parserdata_parents.size(); ind1++) + { + // MESSAGE("Looking for " << _datatype_list[ind].Parserdata_parents[ind1] << " in the catalog data type"); + _bool = false; + // Compare parent data type name to all data type names defined in the catalog + for (unsigned int ind2 = 0 ; ind2 < _data_name_list.size(); ind2++) + { + if(_datatype_list[ind].Parserdata_parents[ind1].compare(_data_name_list[ind2]) == 0) + { + // Type found : OK + MESSAGE("The parents data type " << _datatype_list[ind].Parserdata_parents[ind1] << " of " << _datatype_list[ind].Parserdata_name << " was found in the catalog type"); + _bool = true; + } + } + if(!_bool) + { + MESSAGE( "The parents data type " << _datatype_list[ind].Parserdata_parents[ind1] << " of " << _datatype_list[ind].Parserdata_name << " is not defined in the data type catalog" ) + _return_value = false ; + } + } + } + return _return_value; +} + + +//---------------------------------------------------------------------- +// Function : _parseArguments +// Purpose : parse arguments to get general and personal catalog files +//---------------------------------------------------------------------- +bool +SALOME_DataTypeCatalogImpl::_parseArguments(int argc, char **argv, + char **_path_data) +{ + bool _return_value = true; + *_path_data = NULL; + for (int ind = 0; ind < argc ; ind++) + { + + if (strcmp(argv[ind],"-help") == 0) + { + INFOS( "Usage: " << argv[0] << " -common 'path to data type catalog' -ORBInitRef NameService=corbaname::localhost"); + _return_value = false ; + } + if (strcmp(argv[ind],"-common") == 0) + { + if (ind + 1 <= argc) + { + // General catalog file + *_path_data = argv[ind + 1] ; + ifstream _path_data_file(*_path_data); + if (!_path_data_file) + { + MESSAGE( "Sorry the file " << *_path_data << " can't be open" ) + *_path_data = NULL; + _return_value = false; + } + } + } + + } + return _return_value; +} diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.hxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.hxx new file mode 100644 index 000000000..5da4f18de --- /dev/null +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_impl.hxx @@ -0,0 +1,111 @@ +// File: SALOME_DataTypeCatalog_impl.hxx +// Created: Mon Aug 08 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + + +#ifndef DATATYPECATALOG_IMPL_H +#define DATATYPECATALOG_IMPL_H + +#include "utilities.h" +#include "SALOME_DataTypeCatalog_Handler.hxx" +#include +#include CORBA_SERVER_HEADER(SALOME_DataTypeCatalog) + +class SALOME_DataTypeCatalogImpl: public POA_SALOME_DataTypeCatalog::DataCatalog, + public PortableServer::RefCountServantBase +{ +public: + //! standard constructor + SALOME_DataTypeCatalogImpl(int argc, char** argv); + + //! standard destructor + virtual ~SALOME_DataTypeCatalogImpl(); + + //! method to get a data type list + /*! + \return a data type list + */ + virtual SALOME_DataTypeCatalog::ListOfDataTypeName* GetDataTypeList(); + + //! method to know if type_out is derived from type_in + /*! + \param type_in const char* arguments + \param type_out const char* arguments + \return a boolean (true if type_out is derived from type_in) + */ + virtual CORBA::Boolean isDerivedFrom(const char* type_in, const char* type_out) throw(SALOME_DataTypeCatalog::NotFound); + + //! method to get the name of the interface to acces the data in read mode + /*! + \param type const char* arguments + \return the read interface name + */ + virtual char* GetDataInterfaceRead(const char* type) throw(SALOME_DataTypeCatalog::NotFound); + + + //! method to get the name of the interface to acces the data in write mode + /*! + \param type const char* arguments + \return the write interface name + */ + virtual char* GetDataInterfaceWrite(const char* type) throw(SALOME_DataTypeCatalog::NotFound); + + //! method to get parents data type list + /*! + \param type const char* arguments + \return a data type list + */ + virtual SALOME_DataTypeCatalog::ListOfDataTypeName* + GetDataTypeParents(const char* type) throw(SALOME_DataTypeCatalog::NotFound); + + +private: + //! method to know if parents type of data_out derived from type_in + /*! + \param type_in const char* arguments + \param data_out const ParserDataType arguments (by value) + \return a boolean (true if type_out is derived from type_in) + */ + virtual CORBA::Boolean _explore_parents(const char* type_in, + ParserDataType& data_out); + + + //! method to parse the data type catalog + /*! + \param file const char* arguments + \param datatypelist ListOfParserDataType arguments + */ + virtual void _parse_xml_file(const char* file, + ListOfParserDataType& datatypelist); + + + //! method to verify data type content + /*! + \param datatypelist ListOfParserDataType arguments + \return true if verfication is OK + */ + virtual bool _verify_data_type(ListOfParserDataType datatypelist); + + + //! method to parse arguments to get general and personal catalog files + /*! + \param argc int arguments + \param argv char** arguments + \param _path_data char** arguments + \return true if parsing is OK + */ + virtual bool _parseArguments(int argc, char **argv, char **_path_data); + + + // will contain the path to the data type catalog + char* _path_datatype; + + + //will contain the informations on the data type catalog(after parsing) + ListOfParserDataType _datatype_list ; +}; + +#endif // DATATYPECATALOG_IMPL_H diff --git a/src/HDFPersist/HDFOI.hxx b/src/HDFPersist/HDFOI.hxx new file mode 100644 index 000000000..4938a9aab --- /dev/null +++ b/src/HDFPersist/HDFOI.hxx @@ -0,0 +1,17 @@ +extern "C" +{ +#include "HDFtypes.h" +} + +#include "HDFattribute.hxx" +#include "HDFfile.hxx" +#include "HDFgroup.hxx" +#include "HDFdataset.hxx" + +#include "HDFexception.hxx" + +#include "HDFexplorer.hxx" + +#include "HDFinternalObject.hxx" + +#include "HDFconvert.hxx" diff --git a/src/HDFPersist/HDFattrClose.c b/src/HDFPersist/HDFattrClose.c new file mode 100644 index 000000000..df23b9392 --- /dev/null +++ b/src/HDFPersist/HDFattrClose.c @@ -0,0 +1,20 @@ +#include "hdfi.h" + +/* + * - Name: HDFattrClose + * - Description : close a HDF attribute + * - Parameters : + * - id (IN) : attribute ID + * - Result : + * - if success : 0 + * - if failure : -1 + */ +hdf_err HDFattrClose(hdf_idt id) +{ + hdf_err ret; + + if ((ret = H5Aclose(id)) < 0) + return -1; + + return 0; +} diff --git a/src/HDFPersist/HDFattrCreate.c b/src/HDFPersist/HDFattrCreate.c new file mode 100644 index 000000000..4d7a29015 --- /dev/null +++ b/src/HDFPersist/HDFattrCreate.c @@ -0,0 +1,54 @@ +#include "hdfi.h" + +/* + * - Name : HDFattrCreate + * - Description : create a HDF attribute + * - Parameters : + * - pid (IN) : father ID + * - name (IN) : attribute name + * - type (IN) : attribute type + * - Result: + * - if success : attribute ID + * - if failure : -1 + */ +hdf_idt HDFattrCreate(hdf_idt pid,char *name,hdf_type type) +{ + hdf_idt aid,attr; + hdf_err ret; + int type_hdf; + + switch(type) { + case HDF_FLOAT64 : + type_hdf = H5T_IEEE_F64LE; + break; + + case HDF_INT32 : + type_hdf = H5T_STD_I32LE; + break; + + case HDF_INT64 : + type_hdf = H5T_STD_I64LE; + break; + + case HDF_STRING : + if((type_hdf = H5Tcopy(H5T_C_S1)) < 0) + return -1; + if((ret = H5Tset_size(type_hdf,1)) < 0) + return -1; + break; + + default : + return -1; + } + + if ((aid = H5Screate(H5S_SCALAR)) < 0) + return -1; + + if ((attr = H5Acreate(pid,name,type_hdf,aid,H5P_DEFAULT)) < 0) + return -1; + + if ((ret = H5Sclose(aid)) < 0) + return -1; + + return attr; +} diff --git a/src/HDFPersist/HDFattrOpen.c b/src/HDFPersist/HDFattrOpen.c new file mode 100644 index 000000000..bc4b5fba9 --- /dev/null +++ b/src/HDFPersist/HDFattrOpen.c @@ -0,0 +1,21 @@ +#include "hdfi.h" + +/* + * - Name: HDFattrOpen + * - Description : open a HDF attribute + * - Parameters : + * - pid (IN) : father ID + * - name (IN) : attribute name + * - Result : + * - if success : attribute ID + * - if failure : -1 + */ +hdf_idt HDFattrOpen(hdf_idt pid,char * name) +{ + hdf_idt aid; + + if ((aid = H5Aopen_name(pid,name)) < 0) + return -1; + + return aid; +} diff --git a/src/HDFPersist/HDFattrRead.c b/src/HDFPersist/HDFattrRead.c new file mode 100644 index 000000000..5c8e108bf --- /dev/null +++ b/src/HDFPersist/HDFattrRead.c @@ -0,0 +1,25 @@ +#include "hdfi.h" + +/* + * - Name : HDFattrWrite + * - Description : write a value to a HDF attribute + * - Parameters : + * - id (IN) : attribute ID + * - val (OUT) : attribute value + * - Result : + * - if success : 0 + * - if failure : -1 + */ +hdf_err HDFattrRead(hdf_idt id,void *val) +{ + hdf_err ret; + int type_hdf; + + if ((type_hdf = H5Aget_type(id)) < 0) + return -1; + + if ((ret = H5Aread(id,type_hdf,val)) < 0) + return -1; + + return 0; +} diff --git a/src/HDFPersist/HDFattrWrite.c b/src/HDFPersist/HDFattrWrite.c new file mode 100644 index 000000000..cb588c902 --- /dev/null +++ b/src/HDFPersist/HDFattrWrite.c @@ -0,0 +1,25 @@ +#include "hdfi.h" + +/* + * - Name : HDFattrWrite + * - Description : write a value to a HDF attribute + * - Parameters : + * - id (IN) : attribute ID + * - val (IN) : attribute value + * - Result : + * - if success : 0 + * - if failure : -1 + */ +hdf_err HDFattrWrite(hdf_idt id,void *val) +{ + hdf_err ret; + int type_hdf; + + if ((type_hdf = H5Aget_type(id)) < 0) + return -1; + + if ((ret = H5Awrite(id,type_hdf,val)) < 0) + return ret; + + return 0; +} diff --git a/src/HDFPersist/HDFattribute.cc b/src/HDFPersist/HDFattribute.cc new file mode 100644 index 000000000..5187463f3 --- /dev/null +++ b/src/HDFPersist/HDFattribute.cc @@ -0,0 +1,60 @@ +using namespace std; +extern "C" +{ +#include "hdfi.h" +} +#include "HDFexception.hxx" +#include "HDFattribute.hxx" +#include "HDFinternalObject.hxx" + +HDFattribute::HDFattribute(char *name,HDFinternalObject *father,hdf_type type) + : HDFobject(name) +{ + _father = father; + _fid = _father->GetId(); + _type = type; +} + +void HDFattribute::CreateOnDisk() +{ + if ((_id = HDFattrCreate(_fid,_name,_type)) < 0) + throw HDFexception("Can't create attribute"); +} +void HDFattribute::OpenOnDisk() +{ + if ((_id = HDFattrOpen(_fid,_name)) < 0) + throw HDFexception("Can't open attribute"); +} +void HDFattribute::CloseOnDisk() +{ + hdf_err ret; + + if ((ret = HDFattrClose(_id)) < 0) + throw HDFexception("Can't close dataset"); +} + +void HDFattribute::WriteOnDisk(void *values) +{ + hdf_err ret; + + if ((ret = HDFattrWrite(_id,values)) < 0) + throw HDFexception("Can't create group"); +} + +void HDFattribute::ReadFromDisk(void *values) +{ + hdf_err ret; + + if ((ret = HDFattrRead(_id,values)) < 0) + throw HDFexception("Can't read attribute"); +} + +HDFinternalObject * HDFattribute::GetFather() +{ + return _father; +} + +hdf_type HDFattribute::GetType() +{ + return _type; +} diff --git a/src/HDFPersist/HDFattribute.hxx b/src/HDFPersist/HDFattribute.hxx new file mode 100644 index 000000000..d23d7b6f6 --- /dev/null +++ b/src/HDFPersist/HDFattribute.hxx @@ -0,0 +1,31 @@ +#ifndef HDFATTRIBUTE_HXX +#define HDFATTRIBUTE_HXX + +extern "C" +{ +#include "HDFtypes.h" +} +#include "HDFinternalObject.hxx" +#include "HDFcontainerObject.hxx" + +class HDFattribute : public HDFobject +{ +private : + HDFinternalObject *_father; + hdf_idt _fid; + hdf_type _type; +public : + HDFattribute(char *name,HDFinternalObject *father,hdf_type type); + + void CreateOnDisk(); + void OpenOnDisk(); + void CloseOnDisk(); + + void WriteOnDisk(void *values); + void ReadFromDisk(void *values); + + HDFinternalObject *GetFather(); + hdf_type GetType(); +}; + +#endif diff --git a/src/HDFPersist/HDFcontainerObject.cc b/src/HDFPersist/HDFcontainerObject.cc new file mode 100644 index 000000000..2ef6a68d9 --- /dev/null +++ b/src/HDFPersist/HDFcontainerObject.cc @@ -0,0 +1,77 @@ +using namespace std; +extern "C" +{ +#include "hdfi.h" +} +#include "HDFcontainerObject.hxx" +#include "HDFexception.hxx" +#include "utilities.h" + +HDFcontainerObject::HDFcontainerObject(char *name) + : HDFinternalObject(name) +{ + _nsons = 0; + _firstson = NULL; + _lastson = NULL; +} + +HDFcontainerObject::~HDFcontainerObject() +{ + HDFinternalObject *sonToDelete = 0; + while(_firstson) + { + sonToDelete = _firstson; + _firstson = _firstson->GetNextBrother(); +// MESSAGE("son to delete: " << sonToDelete); + delete sonToDelete; + } +// MESSAGE("destruction: " << this); +} + +int HDFcontainerObject::nInternalObjects() +{ + return 0; +} + +void HDFcontainerObject::InternalObjectIndentify(int rank, char *object_name) +{ + object_name = NULL; +} + +void HDFcontainerObject::AddSon(HDFinternalObject *son) +{ +// MESSAGE("add son ") MESSAGE("add to this" << this); +// MESSAGE("add son " << son); +// MESSAGE("firstson " << _firstson); +// MESSAGE("lastson " << _lastson); + + if (_nsons == 0) + { + _firstson = son; + _lastson = _firstson; + } + else + { + _lastson->SetNextBrother(son); + son->SetPreviousBrother(_lastson); + _lastson = son; + } + _nsons ++; +// MESSAGE("firstson " << _firstson); +// MESSAGE("lastson " << _lastson); +} + +HDFinternalObject *HDFcontainerObject::GetFirstSon() +{ + return _firstson; +} + +HDFinternalObject *HDFcontainerObject::GetLastSon() +{ + return _lastson; +} + +int HDFcontainerObject::nSons() +{ + return _nsons; +} diff --git a/src/HDFPersist/HDFcontainerObject.hxx b/src/HDFPersist/HDFcontainerObject.hxx new file mode 100644 index 000000000..63c304a42 --- /dev/null +++ b/src/HDFPersist/HDFcontainerObject.hxx @@ -0,0 +1,29 @@ +#ifndef HDFCONTAINEROBJECT_HXX +#define HDFCONTAINEROBJECT_HXX + +extern "C" +{ +#include "HDFtypes.h" +} +#include "HDFobject.hxx" +#include "HDFinternalObject.hxx" + +class HDFcontainerObject : public HDFinternalObject +{ +private : + HDFinternalObject *_firstson; + HDFinternalObject *_lastson; + int _nsons; +public : + HDFcontainerObject(char *name); + virtual ~HDFcontainerObject(); + + virtual int nInternalObjects(); + virtual void InternalObjectIndentify(int rank, char *object_name); + + void AddSon(HDFinternalObject *son); + HDFinternalObject *GetFirstSon(); + HDFinternalObject *GetLastSon(); + int nSons(); +}; +#endif diff --git a/src/HDFPersist/HDFconvert.cc b/src/HDFPersist/HDFconvert.cc new file mode 100644 index 000000000..970404c7d --- /dev/null +++ b/src/HDFPersist/HDFconvert.cc @@ -0,0 +1,76 @@ +using namespace std; +#include "HDFconvert.hxx" + +int HDFConvert::FromAscii(const string& file, const HDFcontainerObject & hdf_container, const string& nomdataset) +{ + + HDFdataset * hdf_dataset; + char * buffer; + int fd; + struct stat status; + size_t length; + hdf_size length_long; + + // Ouverture du fichier source + if ( (fd = open(file.c_str(),O_RDONLY)) <0) { + perror("HDFConvert::FromAscii"); + return -1; + }; + + // Lit l'état du fichier + if ( fstat(fd,&status) < 0) { + perror("HDFConvert::FromAscii"); + return -1; + }; + + length = status.st_size; //Calcul la taille du fichier en octets + length_long = length; + +#ifdef _POSIX_MAPPED_FILES + + // Map le fichier en mémoire + if ( (buffer = (char *) mmap(0,length,PROT_READ,MAP_SHARED,fd,0)) == MAP_FAILED ) { + perror("HDFConvert::FromAscii"); + return -1; + }; + +#else + + // Sort de la compilation +#error Necessite l''utilisation de la primitive mmap + +#endif + + // Creation du Dataset utilisateur + hdf_dataset = new HDFdataset::HDFdataset( (char *) nomdataset.c_str(), /*discard const */ + (HDFcontainerObject*) &hdf_container, /*discard const, pas de constructeur par référence */ + HDF_STRING, + &length_long,1); + // Cree le Dataset sur le disk + hdf_dataset->CreateOnDisk(); + + // Effectue la copie + hdf_dataset->WriteOnDisk(buffer); + + // Ferme le fichier hdf + hdf_dataset->CloseOnDisk(); + + // Memory Clean + delete hdf_dataset; + +#ifdef _POSIX_MAPPED_FILES + + // Desalloue le mapping + if (munmap(buffer,length) < 0 ) { + perror("HDFConvert::FromAscii"); + return -1; + }; +#endif + + // Ferme le fichier ASCII + if (close(fd) <0) { + perror("HDFConvert::FromAscii"); + return -1; + }; + +}; diff --git a/src/HDFPersist/HDFconvert.hxx b/src/HDFPersist/HDFconvert.hxx new file mode 100644 index 000000000..1160dd4a9 --- /dev/null +++ b/src/HDFPersist/HDFconvert.hxx @@ -0,0 +1,33 @@ +#ifndef HDFCONVERT_HXX +#define HDFCONVERT_HXX + +extern "C" +{ +#include "HDFtypes.h" +#include +#include +#include +#include +#include +#include +#include +} +#include "HDFcontainerObject.hxx" +#include "HDFdataset.hxx" +#include "HDFfile.hxx" +#include + +class HDFConvert +{ +private: + + HDFConvert(); + ~HDFConvert(); + +public: + +static int FromAscii(const string& file, const HDFcontainerObject& hdf_container, const string& nomdataset); + +}; + +#endif /* HDFCONVERT_HXX */ diff --git a/src/HDFPersist/HDFdataset.cc b/src/HDFPersist/HDFdataset.cc new file mode 100644 index 000000000..a59c04ecc --- /dev/null +++ b/src/HDFPersist/HDFdataset.cc @@ -0,0 +1,168 @@ +using namespace std; +extern "C" +{ +#include "hdfi.h" +#include +} +#include "HDFdataset.hxx" +#include "HDFcontainerObject.hxx" +#include "HDFexception.hxx" + +#include + +HDFdataset::HDFdataset(char *name, HDFcontainerObject *father,hdf_type type, + hdf_size dim[], int dimsize) + : HDFinternalObject(name) +{ + int i; + + _father = father; + _fid = _father->GetId(); + _father->AddSon(this); + _type = type; + _ndim = dimsize; + _dim = new hdf_size[dimsize]; + _size = 1; + for (i=0;iGetId(); + _father->AddSon(this); + _type = HDF_NONE; + _ndim = -1; + _dim = 0; + _size = -1; +} + +HDFdataset::~HDFdataset() +{ + delete [] _dim; +} + +void HDFdataset::CreateOnDisk() +{ + if ((_id = HDFdatasetCreate(_fid,_name,_type,_dim,_ndim)) < 0) + throw HDFexception("Can't create dataset"); +} + +void HDFdataset::OpenOnDisk() +{ + if ((_id = HDFdatasetOpen(_fid,_name)) < 0) + throw HDFexception("Can't open dataset"); +} + +void HDFdataset::CloseOnDisk() +{ + hdf_err ret; + + if ((ret = HDFdatasetClose(_id)) < 0) + throw HDFexception("Can't close dataset"); + _id = -1; +} + +void HDFdataset::WriteOnDisk(void *values) +{ + hdf_err ret; + + if ((ret = HDFdatasetWrite(_id,values)) < 0) + throw HDFexception("Can't write dataset"); + +} + +void HDFdataset::ReadFromDisk(void *values) +{ + hdf_err ret; + + if ((ret = HDFdatasetRead(_id,values)) < 0) + throw HDFexception("Can't read dataset"); +} + +HDFcontainerObject *HDFdataset::GetFather() +{ + return _father; +} + +hdf_type HDFdataset::GetType() +{ + if (_type == HDF_NONE) + if ((_type = HDFdatasetGetType(_id)) == HDF_NONE) + throw HDFexception("Can't determine the type of data in the dataset"); + + return _type; +} + +int HDFdataset::nDim() +{ + if (_ndim == -1) + if ((_ndim = HDFdatasetGetnDim(_id)) < 0) + throw HDFexception("Can't determine the dataset dimensions number"); + + return _ndim; +} + +void HDFdataset::GetDim(hdf_size dim[]) +{ + int i; + int ndim; + hdf_err ret; + + if (_dim == 0) + { + if (_ndim == -1) + ndim = HDFdatasetGetnDim(_id); + else + ndim = _ndim; + _dim = new hdf_size[ndim]; + if ((ret == HDFdatasetGetDim(_id,_dim)) < 0) + throw HDFexception("Can't determine the size dimensions of the dataset "); + } + + for (i=0;i<_ndim;i++) + dim[i] = _dim[i]; +} + +int HDFdataset::GetSize() +{ + int size_type; + + if (_size == -1) + { + if ((_size = HDFdatasetGetSize(_id)) < 0) + throw HDFexception("Can't determine the size of the dataset"); + + if (_type == HDF_NONE) + if ((_type = HDFdatasetGetType(_id)) == HDF_NONE) + throw HDFexception("Can't determine the size of the dataset"); + + switch (_type) + { + case HDF_INT32 : + size_type = 4; + break; + + case HDF_INT64 : + case HDF_FLOAT64 : + size_type = 8; + break; + + default : + size_type = 1; + } + _size = _size / size_type; + } + + return _size; +} + +hdf_object_type HDFdataset::GetObjectType() +{ + return HDF_DATASET; +} diff --git a/src/HDFPersist/HDFdataset.hxx b/src/HDFPersist/HDFdataset.hxx new file mode 100644 index 000000000..cc49878d9 --- /dev/null +++ b/src/HDFPersist/HDFdataset.hxx @@ -0,0 +1,42 @@ +#ifndef HDFDATASET_HXX +#define HDFDATASET_HXX + +extern "C" +{ +#include "HDFtypes.h" +} +#include "HDFinternalObject.hxx" +#include "HDFcontainerObject.hxx" + +class HDFdataset : public HDFinternalObject +{ +private : + HDFcontainerObject *_father; + hdf_idt _fid; + hdf_type _type; + hdf_size *_dim; + int _size; + int _ndim; + +public: + HDFdataset(char *name, HDFcontainerObject *father,hdf_type type, + hdf_size dim[],int dimsize); + HDFdataset(char *name,HDFcontainerObject *father); + virtual ~HDFdataset(); + + void CreateOnDisk(); + void OpenOnDisk(); + void CloseOnDisk(); + + void WriteOnDisk(void *values); + void ReadFromDisk(void *values); + + HDFcontainerObject *GetFather(); + hdf_type GetType(); + int nDim(); + void GetDim(hdf_size dim[]); + int GetSize(); + hdf_object_type GetObjectType(); +}; + +#endif diff --git a/src/HDFPersist/HDFdatasetClose.c b/src/HDFPersist/HDFdatasetClose.c new file mode 100644 index 000000000..e66a67d77 --- /dev/null +++ b/src/HDFPersist/HDFdatasetClose.c @@ -0,0 +1,22 @@ +#include "hdfi.h" + +/* + * - Name : HDFdatasetClose + * - Description : close a HDF datset + * - Parameters : + * - id (IN) : dateset ID + * - Result : + * - if success : returns 0 + * - if failure : returns -1 + */ + +hdf_err +HDFdatasetClose(hdf_idt id) +{ + hdf_err ret; + + if ((ret = H5Dclose(id)) < 0) + return -1; + + return 0; +} diff --git a/src/HDFPersist/HDFdatasetCreate.c b/src/HDFPersist/HDFdatasetCreate.c new file mode 100644 index 000000000..0deb8fe0a --- /dev/null +++ b/src/HDFPersist/HDFdatasetCreate.c @@ -0,0 +1,63 @@ +#include "hdfi.h" + +/* + * - Name : HDFdatasetCreate + * - Description : creates a HDF dataset + * - Parameters : + * - pid (IN) : father ID + * - name (IN) : dataset name + * - type (IN) : dataset type (HDF_STRING,HDF_INT32,HDF_INT64,HDF_FLOAT64) + * - dimd (IN) : dataset size + * - Result : + * - if success : returns dataset ID + * - if failure : -1 + */ +hdf_idt HDFdatasetCreate(hdf_idt pid,char *name,hdf_type type, + hdf_size *dimd, int ndim) +{ + hdf_idt dataset, dataspace = 0; + hdf_err ret; + int type_hdf; + + switch(type) + { + case HDF_FLOAT64 : + type_hdf = H5T_IEEE_F64LE; + break; + + case HDF_INT32 : + type_hdf = H5T_STD_I32LE; + break; + + case HDF_INT64 : + type_hdf = H5T_STD_I64LE; + break; + + case HDF_STRING : + if((type_hdf = H5Tcopy(H5T_C_S1)) < 0) + return -1; + if((ret = H5Tset_size(type_hdf,1)) < 0) + return -1; + break; + + default : + return -1; + } + +if ((dataset = H5Dopen(pid,name)) < 0) + { + + if ((dataspace = H5Screate_simple(ndim,dimd,NULL)) < 0) + return -1; + if ((dataset = H5Dcreate(pid,name,type_hdf,dataspace, + H5P_DEFAULT)) < 0) + return -1; + } + else + return -1; + + if ((ret = H5Sclose(dataspace)) < 0) + return -1; + + return dataset; +} diff --git a/src/HDFPersist/HDFdatasetGetDim.c b/src/HDFPersist/HDFdatasetGetDim.c new file mode 100644 index 000000000..1b4dfe809 --- /dev/null +++ b/src/HDFPersist/HDFdatasetGetDim.c @@ -0,0 +1,28 @@ +#include +#include "hdfi.h" +#include + +hdf_err +HDFdatasetGetDim(hdf_idt id,hdf_size dim[]) +{ + hdf_err ret = 0; + hdf_size *tmp; + int ndim; + hdf_idt space_id; + + if ((space_id = H5Dget_space(id)) < 0) + return -1; + + if ((ndim = H5Sget_simple_extent_ndims(space_id)) < 0) + return -1; + + tmp = (hdf_size *) malloc(sizeof(hdf_size)*ndim); + ret = H5Sget_simple_extent_dims(space_id, dim, tmp); + ret = H5Sclose(space_id); + + free (tmp); + + return ret; +} + + diff --git a/src/HDFPersist/HDFdatasetGetSize.c b/src/HDFPersist/HDFdatasetGetSize.c new file mode 100644 index 000000000..161e74762 --- /dev/null +++ b/src/HDFPersist/HDFdatasetGetSize.c @@ -0,0 +1,12 @@ +#include +#include "hdfi.h" + +int HDFdatasetGetSize(hdf_idt id) +{ + hdf_size size; + + if ((size = H5Dget_storage_size(id)) < 0) + return -1; + + return (int) size; +} diff --git a/src/HDFPersist/HDFdatasetGetType.c b/src/HDFPersist/HDFdatasetGetType.c new file mode 100644 index 000000000..dfee7019a --- /dev/null +++ b/src/HDFPersist/HDFdatasetGetType.c @@ -0,0 +1,39 @@ +#include "hdfi.h" +#include + +hdf_type +HDFdatasetGetType(hdf_idt id) +{ + hdf_idt type_id; + hdf_type type; + hdf_class_type hdf_type; + hdf_size_type size; + + if ((type_id = H5Dget_type(id)) < 0) + return HDF_NONE; + + hdf_type = H5Tget_class(type_id); + switch (hdf_type) + { + case H5T_INTEGER : + size = H5Tget_size(type_id); + if (size == 4) + type = HDF_INT32; + else + type = HDF_INT64; + break; + + case H5T_FLOAT : + type = HDF_FLOAT64; + break; + + case H5T_STRING : + type = HDF_STRING; + break; + + default : + type = HDF_NONE; + } + + return type; +} diff --git a/src/HDFPersist/HDFdatasetGetnDim.c b/src/HDFPersist/HDFdatasetGetnDim.c new file mode 100644 index 000000000..d0e9cf505 --- /dev/null +++ b/src/HDFPersist/HDFdatasetGetnDim.c @@ -0,0 +1,21 @@ +#include "hdfi.h" +#include + +int +HDFdatasetGetnDim(hdf_idt id) +{ + int ndim; + hdf_idt space_id; + hdf_err ret; + + if ((space_id = H5Dget_space(id)) < 0) + return -1; + + if ((ndim = H5Sget_simple_extent_ndims(space_id)) < 0) + return -1; + + if ((ret = H5Sclose(space_id)) < 0) + return -1; + + return ndim; +} diff --git a/src/HDFPersist/HDFdatasetOpen.c b/src/HDFPersist/HDFdatasetOpen.c new file mode 100644 index 000000000..8aeeffc7d --- /dev/null +++ b/src/HDFPersist/HDFdatasetOpen.c @@ -0,0 +1,23 @@ +#include "hdfi.h" + +/* + * - Name : HDFdatasetOpen + * - Description : open a HDF datset + * - Parameters : + * - pid (IN) : father ID + * - name (IN) : dataset name + * - Result : + * - if success : returns dateset ID + * - if failure : returns -1 + */ + +hdf_idt +HDFdatasetOpen(hdf_idt pid,char *name) +{ + hdf_idt id; + + if ((id = H5Dopen(pid,name)) < 0) + return -1; + + return id; +} diff --git a/src/HDFPersist/HDFdatasetRead.c b/src/HDFPersist/HDFdatasetRead.c new file mode 100644 index 000000000..86e01f16d --- /dev/null +++ b/src/HDFPersist/HDFdatasetRead.c @@ -0,0 +1,26 @@ +#include "hdfi.h" + +/* + * - Name : _MEDdatasetRead + * - Description : writes a HDF dataset + * - Parameters : + * - id (IN) : dataset ID + * - val (OUT) : datset values + * - Result : + * - if success : 0 + * - if failure : -1 + */ +hdf_err HDFdatasetRead(hdf_idt id, void *val) +{ + hdf_idt datatype; + hdf_err ret; + + if ((datatype = H5Dget_type(id)) < 0) + return -1; + + if ((ret = H5Dread(id,datatype,H5S_ALL,H5S_ALL, + H5P_DEFAULT, val)) < 0) + return -1; + + return 0; +} diff --git a/src/HDFPersist/HDFdatasetWrite.c b/src/HDFPersist/HDFdatasetWrite.c new file mode 100644 index 000000000..18261b235 --- /dev/null +++ b/src/HDFPersist/HDFdatasetWrite.c @@ -0,0 +1,26 @@ +#include "hdfi.h" + +/* + * - Name : _MEDdatasetWrite + * - Description : writes a HDF dataset + * - Parameters : + * - id (IN) : dataset ID + * - val (IN) : datset values + * - Result : + * - if success : 0 + * - if failure : -1 + */ +hdf_err HDFdatasetWrite(hdf_idt id, void *val) +{ + hdf_idt datatype; + hdf_err ret; + + if ((datatype = H5Dget_type(id)) < 0) + return -1; + + if ((ret = H5Dwrite(id,datatype,H5S_ALL,H5S_ALL, + H5P_DEFAULT, val)) < 0) + return -1; + + return 0; +} diff --git a/src/HDFPersist/HDFerrorModeLock.c b/src/HDFPersist/HDFerrorModeLock.c new file mode 100644 index 000000000..d698ec822 --- /dev/null +++ b/src/HDFPersist/HDFerrorModeLock.c @@ -0,0 +1,12 @@ +#include "hdfi.h" + +/* + * - Name : HDFerrorModeLock + * - Description : lock HDF error mode + * - Parameters : + * - Result : aucun + */ +void HDFerrorModeLock() +{ + H5Eset_auto(NULL,NULL); +} diff --git a/src/HDFPersist/HDFexception.hxx b/src/HDFPersist/HDFexception.hxx new file mode 100644 index 000000000..be0f6095b --- /dev/null +++ b/src/HDFPersist/HDFexception.hxx @@ -0,0 +1,10 @@ +/* Exception */ +#include + +class HDFexception +{ +public : + HDFexception(const char *message) { + cerr << message << endl; + } +}; diff --git a/src/HDFPersist/HDFexplorer.cc b/src/HDFPersist/HDFexplorer.cc new file mode 100644 index 000000000..825406f83 --- /dev/null +++ b/src/HDFPersist/HDFexplorer.cc @@ -0,0 +1,50 @@ +using namespace std; +#include "HDFcontainerObject.hxx" +#include "HDFexception.hxx" +#include "HDFinternalObject.hxx" +#include "HDFexplorer.hxx" + +HDFexplorer::HDFexplorer(HDFcontainerObject *container) +{ + _container = container; + _size = _container->nSons(); + _head = _container->GetFirstSon(); + _queue = _container->GetLastSon(); + _current = _head; +} + +HDFexplorer::~HDFexplorer() +{ +} + +void HDFexplorer::Init() +{ + _current = _head; +} + +void HDFexplorer::Next() +{ + _current = _current->GetNextBrother(); +} + +int HDFexplorer::More() +{ + if (_current != NULL) + return 1; + else + return 0; +} + +HDFinternalObject *HDFexplorer::Value() +{ + return _current; +} + +void HDFexplorer::Reset(HDFcontainerObject *new_container) +{ + _container = new_container; + _size = _container->nSons(); + _head = _container->GetFirstSon(); + _queue = _container->GetLastSon(); + _current = _head; +} diff --git a/src/HDFPersist/HDFexplorer.hxx b/src/HDFPersist/HDFexplorer.hxx new file mode 100644 index 000000000..f107c2420 --- /dev/null +++ b/src/HDFPersist/HDFexplorer.hxx @@ -0,0 +1,25 @@ +#ifndef HDFEXPLORER_HXX +#define HDFEXPLORER_HXX + +#include "HDFinternalObject.hxx" +#include "HDFcontainerObject.hxx" + +class HDFexplorer { +private : + int _size; + HDFcontainerObject *_container; + HDFinternalObject *_head; + HDFinternalObject *_queue; + HDFinternalObject *_current; +public : + HDFexplorer(HDFcontainerObject *container); + ~HDFexplorer(); + + void Reset(HDFcontainerObject *new_container); + void Init(); + void Next(); + int More(); + HDFinternalObject *Value(); +}; + +#endif diff --git a/src/HDFPersist/HDFfile.cc b/src/HDFPersist/HDFfile.cc new file mode 100644 index 000000000..7c7307ab9 --- /dev/null +++ b/src/HDFPersist/HDFfile.cc @@ -0,0 +1,116 @@ +using namespace std; +extern "C" +{ +#include "hdfi.h" +#include +#include +} +#include +#include "HDFfile.hxx" +#include "HDFexception.hxx" + +HDFfile::HDFfile(char *name) + : HDFcontainerObject(name) +{} + +void HDFfile::CreateOnDisk() +{ + if ((_id = HDFfileCreate(_name)) < 0) + throw HDFexception("Can't create HDF file"); +} + +void HDFfile::OpenOnDisk(hdf_access_mode access_mode) +{ + _access_mode = access_mode; + + switch (_access_mode) + { + case HDF_RDWR : + if (access(_name,F_OK)) + { + if ((_id = HDFfileCreate(_name)) < 0) + throw HDFexception("Can't open HDF file"); + } + else + if ((_id = HDFfileOpen(_name,_access_mode)) < 0) + throw HDFexception("Can't open HDF file"); + break; + + case HDF_RDONLY : + if ((_id = HDFfileOpen(_name,_access_mode)) < 0) + throw HDFexception("Can't open HDF file"); + break; + + default : + throw HDFexception("Can't open HDF file : bad acces option"); + } +} + +void HDFfile::CloseOnDisk() +{ + hdf_err ret; + + if ((ret = HDFfileClose(_id)) < 0) + throw HDFexception("Can't close HDF file"); + _id = -1; +} + + +hdf_access_mode HDFfile::GetAccessMode() +{ + return _access_mode; +} + +hdf_object_type HDFfile::GetObjectType() +{ + return HDF_FILE; +} + +int HDFfile::nInternalObjects() +{ + int n; + hdf_err ret; + + if ((ret = HDFnObjects(_id,"/",&n)) < 0) + throw HDFexception("Can't determine the number of internal objects"); + + return n; +} + +void HDFfile::InternalObjectIndentify(int rank, char *object_name) +{ + hdf_err ret; + + if ((ret = HDFobjectIdentify(_id,"/",rank,object_name)) < 0) + throw HDFexception("Can't identify an internal object"); +} + +int HDFfile::ExistInternalObject(char *object_name) +{ + int n,i; + int ret = 0; + char name[HDF_NAME_MAX_LEN+1]; + + n = this->nInternalObjects(); + for (i=0;iInternalObjectIndentify(i,name); + if (!strcmp(name,object_name)) + { + ret = 1; + break; + } + } + return ret; +} + +hdf_object_type HDFfile::InternalObjectType(char *object_name) +{ + hdf_object_type type; + hdf_err ret; + + if ((ret = HDFobjectType(_id,object_name,&type)) < 0) + throw HDFexception("Can't determine internal object type"); + + return type; +} diff --git a/src/HDFPersist/HDFfile.hxx b/src/HDFPersist/HDFfile.hxx new file mode 100644 index 000000000..c8ddfbb71 --- /dev/null +++ b/src/HDFPersist/HDFfile.hxx @@ -0,0 +1,32 @@ +#ifndef HDFFILE_HXX +#define HDFFILE_HXX + +extern "C" +{ +#include "HDFtypes.h" +} +#include "HDFcontainerObject.hxx" + +class HDFfile : public HDFcontainerObject +{ +private : + hdf_access_mode _access_mode; +public : + HDFfile(char *name); + + void CreateOnDisk(); + void OpenOnDisk(hdf_access_mode acess_mode); + void CloseOnDisk(); + + hdf_access_mode GetAccessMode(); + hdf_object_type GetObjectType(); + + int nInternalObjects(); + void InternalObjectIndentify(int rank, char *object_name); + int ExistInternalObject(char *object_name); + hdf_object_type InternalObjectType(char *object_name); +}; + +#endif /* HDFFILE_HXX */ + + diff --git a/src/HDFPersist/HDFfileClose.c b/src/HDFPersist/HDFfileClose.c new file mode 100644 index 000000000..450b9d67f --- /dev/null +++ b/src/HDFPersist/HDFfileClose.c @@ -0,0 +1,23 @@ +#include "hdfi.h" + +/* + * - Name : HDFfileClose + * - Description : closes a HDF file + * - Parameters : + * - fid (IN) : file ID + * - Result : + * - success : 0 + * - failure : -1 + */ + +hdf_err HDFfileClose(hdf_idt fid) +{ + hdf_err ret; + + H5Fflush(fid,H5F_SCOPE_GLOBAL); + + if ((ret = H5Fclose(fid)) < 0) + return -1; + + return 0; +} diff --git a/src/HDFPersist/HDFfileCreate.c b/src/HDFPersist/HDFfileCreate.c new file mode 100644 index 000000000..23ed25418 --- /dev/null +++ b/src/HDFPersist/HDFfileCreate.c @@ -0,0 +1,21 @@ +#include "hdfi.h" + +/* + * - Name : HDFfileCreate + * - Description : creates a HDF file + * - Parameters : + * - name (IN) : file name + * - Result : + * - success : file ID + * - failure : -1 + */ +hdf_idt HDFfileCreate(char *name) +{ + hdf_idt fid; + + if ((fid = H5Fcreate(name,H5F_ACC_TRUNC, + H5P_DEFAULT,H5P_DEFAULT)) < 0) + return -1; + + return fid; +} diff --git a/src/HDFPersist/HDFfileMount.c b/src/HDFPersist/HDFfileMount.c new file mode 100644 index 000000000..e210e463e --- /dev/null +++ b/src/HDFPersist/HDFfileMount.c @@ -0,0 +1,12 @@ +#include +#include "hdfi.h" + +hdf_err +HDFfileMount(hdf_idt id,const char *name,hdf_idt fid) +{ + hdf_err ret = 0; + + ret = H5Fmount(id, name, fid,H5P_DEFAULT); + + return ret; +} diff --git a/src/HDFPersist/HDFfileOpen.c b/src/HDFPersist/HDFfileOpen.c new file mode 100644 index 000000000..ca80dfb96 --- /dev/null +++ b/src/HDFPersist/HDFfileOpen.c @@ -0,0 +1,36 @@ +#include "hdfi.h" +/* + * - Name : HDFfileOpen + * - Description : open an existing HDF file + * - Parameters : + * - name (IN) : file name + * - access_mode (IN) : file access mode + * - Result : + * - success : file ID + * - failure : -1 + */ + +hdf_idt HDFfileOpen(char *name,hdf_access_mode access_mode) +{ + hdf_idt fid; + int mode; + + switch(access_mode) + { + case HDF_RDONLY: + mode = H5F_ACC_RDONLY; + break; + + case HDF_RDWR : + mode = H5F_ACC_RDWR; + break; + + default : + return -1; + } + + if ((fid = H5Fopen(name,mode,H5P_DEFAULT)) < 0) + return -1; + + return fid; +} diff --git a/src/HDFPersist/HDFfileUmount.c b/src/HDFPersist/HDFfileUmount.c new file mode 100644 index 000000000..7c79b4630 --- /dev/null +++ b/src/HDFPersist/HDFfileUmount.c @@ -0,0 +1,12 @@ +#include +#include "hdfi.h" + +hdf_err +HDFfileUmount(hdf_idt id,const char *name) +{ + hdf_err ret; + + ret = H5Funmount(id,name); + + return ret; +} diff --git a/src/HDFPersist/HDFgroup.cc b/src/HDFPersist/HDFgroup.cc new file mode 100644 index 000000000..9acf62836 --- /dev/null +++ b/src/HDFPersist/HDFgroup.cc @@ -0,0 +1,124 @@ +using namespace std; +extern "C" +{ +#include "hdfi.h" +#include +} +#include "HDFgroup.hxx" +#include "HDFexception.hxx" + +HDFgroup::HDFgroup(char *name, HDFcontainerObject *father) + : HDFcontainerObject(name) +{ + _father = father; + _fid = _father->GetId(); + _father->AddSon(this); + _mid = -1; +}; + +void HDFgroup::CreateOnDisk() +{ + if ((_id = HDFgroupCreate(_fid,_name)) < 0) + throw HDFexception("Can't create group"); +} + +void HDFgroup::OpenOnDisk() +{ + if ((_id = HDFgroupOpen(_fid,_name)) < 0) + throw HDFexception("Can't open group"); +} + +void HDFgroup::CloseOnDisk() +{ + hdf_err ret; + + if ((ret = HDFgroupClose(_id)) < 0) + throw HDFexception("Can't close group"); + _id = -1; +} + +HDFcontainerObject *HDFgroup::GetFather() +{ + return _father; +} + +hdf_object_type HDFgroup::GetObjectType() +{ + return HDF_GROUP; +} + +int HDFgroup::nInternalObjects() +{ + int n = 0; + hdf_err ret; + + if ((ret = HDFnObjects(_fid,_name,&n)) < 0) + throw HDFexception("Can't determine the number of internal objects"); + + return n; +} + +void HDFgroup::InternalObjectIndentify(int rank, char *object_name) +{ + hdf_err ret; + + if ((ret = HDFobjectIdentify(_fid,_name,rank,object_name)) < 0) + throw HDFexception("Can't identify an internal object"); +} + +int HDFgroup::ExistInternalObject(char *object_name) +{ + int n,i; + int ret = 0; + char name[HDF_NAME_MAX_LEN+1]; + + n = this->nInternalObjects(); + for (i=0;iInternalObjectIndentify(i,name); + if (!strcmp(name,object_name)) + { + ret = 1; + break; + } + } + return ret; +} + +hdf_object_type HDFgroup::InternalObjectType(char *object_name) +{ + hdf_object_type type; + hdf_err ret; + + if ((ret = HDFobjectType(_id,object_name,&type)) < 0) + throw HDFexception("Can't determine internal object type"); + + return type; +} + +void HDFgroup::FileMount(char *file,hdf_access_mode mode) +{ + hdf_err ret; + + if (_mid != -1) + throw HDFexception("Can't mount the file"); + + if ((_mid = HDFfileOpen(file,mode)) < 0) + throw HDFexception("Can't mount the file"); + + if ((ret = HDFfileMount(_fid,_name,_mid)) < 0) + throw HDFexception("Can't mount the file"); +} + +void HDFgroup::FileUnMount() +{ + hdf_err ret; + + if ((ret = HDFfileUmount(_fid,_name)) < 0) + throw HDFexception("Can't unmount the file"); + + if ((ret = HDFfileClose(_mid)) < 0) + throw HDFexception("Can't unmount the file"); + + _mid = -1; +} diff --git a/src/HDFPersist/HDFgroup.hxx b/src/HDFPersist/HDFgroup.hxx new file mode 100644 index 000000000..843ab0bd7 --- /dev/null +++ b/src/HDFPersist/HDFgroup.hxx @@ -0,0 +1,35 @@ +#ifndef HDFGROUP_HXX +#define HDFGROUP_HXX + +extern "C" +{ +#include "HDFtypes.h" +} +#include "HDFcontainerObject.hxx" + +class HDFgroup : public HDFcontainerObject +{ +private : + HDFcontainerObject *_father; + hdf_idt _fid; + hdf_idt _mid; +public : + HDFgroup(char *name, HDFcontainerObject *father); + + void CreateOnDisk(); + void OpenOnDisk(); + void CloseOnDisk(); + + void FileMount(char *file,hdf_access_mode mode); + void FileUnMount(); + + HDFcontainerObject *GetFather(); + hdf_object_type GetObjectType(); + + int nInternalObjects(); + void InternalObjectIndentify(int rank, char *object_name); + int ExistInternalObject(char *object_name); + hdf_object_type InternalObjectType(char *object_name); +}; + +#endif /* HDFGROUP_HXX */ diff --git a/src/HDFPersist/HDFgroupClose.c b/src/HDFPersist/HDFgroupClose.c new file mode 100644 index 000000000..59578aedb --- /dev/null +++ b/src/HDFPersist/HDFgroupClose.c @@ -0,0 +1,22 @@ +#include "hdfi.h" + +/* + * - Name : HDFgroupClose + * - Description : close a HDF group + * - Parameters : + * - id (IN) : group ID + * - Result : + * - if success : returns 0 + * - if failure : returns -1 + */ + +hdf_err +HDFgroupClose(hdf_idt id) +{ + hdf_err ret; + + if ((ret = H5Gclose(id)) < 0) + return -1; + + return 0; +} diff --git a/src/HDFPersist/HDFgroupCreate.c b/src/HDFPersist/HDFgroupCreate.c new file mode 100644 index 000000000..2458f4787 --- /dev/null +++ b/src/HDFPersist/HDFgroupCreate.c @@ -0,0 +1,23 @@ +#include "hdfi.h" + +/* + * - Name : HDFgroupCreate + * - Description : create a HDF group + * - Parameters : + * - pid (IN) : father ID + * - name (IN) : group name + * - Result : + * - if success : returns group ID + * - if failure : returns -1 + */ + +hdf_idt +HDFgroupCreate(hdf_idt pid, char *name) +{ + hdf_idt id; + + if ((id = H5Gcreate(pid,name,0)) < 0) + return -1; + + return id; +} diff --git a/src/HDFPersist/HDFgroupOpen.c b/src/HDFPersist/HDFgroupOpen.c new file mode 100644 index 000000000..98c49c89c --- /dev/null +++ b/src/HDFPersist/HDFgroupOpen.c @@ -0,0 +1,23 @@ +#include "hdfi.h" + +/* + * - Name : HDFgroupOpen + * - Description : open an existing HDF group + * - Parameters : + * - pid (IN) : father ID + * - name (IN) : group name + * - Result : + * - if success : returns group ID + * - if failure : returns -1 + */ + +hdf_idt +HDFgroupOpen(hdf_idt pid, char *name) +{ + hdf_idt id; + + if ((id = H5Gopen(pid,name)) < 0) + return -1; + + return id; +} diff --git a/src/HDFPersist/HDFinternalObject.cc b/src/HDFPersist/HDFinternalObject.cc new file mode 100644 index 000000000..d384bfce3 --- /dev/null +++ b/src/HDFPersist/HDFinternalObject.cc @@ -0,0 +1,34 @@ +using namespace std; +extern "C" +{ +#include "hdfi.h" +} +#include "HDFinternalObject.hxx" + +HDFinternalObject::HDFinternalObject(char *name) + : HDFobject(name) +{ + _previousbrother = NULL; + _nextbrother = NULL; +} + +HDFinternalObject *HDFinternalObject::GetPreviousBrother() +{ + return _previousbrother; +} + +HDFinternalObject *HDFinternalObject::GetNextBrother() +{ + return _nextbrother; +} + +void HDFinternalObject::SetPreviousBrother(HDFinternalObject *previous) +{ + _previousbrother = previous; +} + +void HDFinternalObject::SetNextBrother(HDFinternalObject *next) +{ + _nextbrother = next; +} + diff --git a/src/HDFPersist/HDFinternalObject.hxx b/src/HDFPersist/HDFinternalObject.hxx new file mode 100644 index 000000000..0c6855988 --- /dev/null +++ b/src/HDFPersist/HDFinternalObject.hxx @@ -0,0 +1,23 @@ +#ifndef HDFINTERNALOBJECT_HXX +#define HDFINTERNALOBJECT_HXX + +extern "C" +{ +#include "HDFtypes.h" +} +#include "HDFobject.hxx" + +class HDFinternalObject : public HDFobject +{ +private : + HDFinternalObject *_previousbrother; + HDFinternalObject *_nextbrother; +public : + HDFinternalObject(char *name); + + HDFinternalObject *GetPreviousBrother(); + HDFinternalObject *GetNextBrother(); + void SetPreviousBrother(HDFinternalObject *previous); + void SetNextBrother(HDFinternalObject *next); +}; +#endif diff --git a/src/HDFPersist/HDFnObjects.c b/src/HDFPersist/HDFnObjects.c new file mode 100644 index 000000000..1015b4737 --- /dev/null +++ b/src/HDFPersist/HDFnObjects.c @@ -0,0 +1,40 @@ +#include "hdfi.h" +#include + +/* + * - Name : HDFnObjects + * - Description : returns the number of HDF objets in a HDF group + * - Parameters : + * - fid (IN) : HDF file ID + * - path (IN) : acces path to the HDF group in the HDF file + * - Results : + * - if success : number of objects + * - if failure : -1 + */ + +hdf_err Num(hdf_idt id,const char *name, void *data); + +hdf_err +HDFnObjects(hdf_idt fid,char *path,int *n) +{ + int idx; + int m = 0; + + if ((idx = H5Giterate(fid,path,NULL,Num,(void*)&m)) < 0) + return -1; + + *n = (int) m; + + return 0; +} + +hdf_err Num(hdf_idt id,const char *name, void *data) +{ + int *count; + + count = (int *) data; + (*count)++; + + return 0; +} + diff --git a/src/HDFPersist/HDFobject.cc b/src/HDFPersist/HDFobject.cc new file mode 100644 index 000000000..7a40ccc8b --- /dev/null +++ b/src/HDFPersist/HDFobject.cc @@ -0,0 +1,39 @@ +using namespace std; +#include "HDFobject.hxx" +extern "C" +{ +#include "hdfi.h" +#include +} +#include "utilities.h" + +HDFobject::HDFobject(char *name) +{ + // MESSAGE("-------- constructor " << name << " " << this); + HDFerrorModeLock(); + _name = new char[strlen(name)+1]; + strcpy(_name,name); + _id = -1; +} + +HDFobject::~HDFobject() +{ + //delete [] _name; + delete _name; + // MESSAGE("-------- destructor ------" << this); +} + +hdf_idt HDFobject::GetId() +{ + return _id; +} + +char *HDFobject::GetName() +{ + return _name; +} + +hdf_object_type HDFobject::GetObjectType() +{ + return HDF_OBJECT; +} diff --git a/src/HDFPersist/HDFobject.hxx b/src/HDFPersist/HDFobject.hxx new file mode 100644 index 000000000..19e39fa7f --- /dev/null +++ b/src/HDFPersist/HDFobject.hxx @@ -0,0 +1,24 @@ +#ifndef HDFOBJECT_HXX +#define HDFOBJECT_HXX + +extern "C" +{ +#include "HDFtypes.h" +} + +class HDFobject { +protected : + char *_name; + hdf_idt _id; +public : + HDFobject(char *name); + virtual ~HDFobject(); + + hdf_idt GetId(); + char *GetName(); + virtual hdf_object_type GetObjectType(); + +}; + +#endif /* HDFOBJECT_HXX */ + diff --git a/src/HDFPersist/HDFobjectIdentify.c b/src/HDFPersist/HDFobjectIdentify.c new file mode 100644 index 000000000..e5446c69e --- /dev/null +++ b/src/HDFPersist/HDFobjectIdentify.c @@ -0,0 +1,39 @@ +#include "hdfi.h" + +/* + * - Name: HDFobjectIdentify + * - Description : find the name of the HDF object of rank "i" in the HDF + * group "path" + * - Parameters : + * - fid (IN) : l'ID du fichier o + * - path (IN) : group access path + * - i (IN) : access rank + * - name (OUT) : expected name + * - Result : + * - if sucess : 0 + * - if failure : -1 + */ + +hdf_err RankInfo(hdf_idt id, const char *name, void *data); + +hdf_err HDFobjectIdentify(hdf_idt fid,char *path,int i,char *name) +{ + int idx; + + if ((idx = H5Giterate(fid,path,&i,RankInfo, + name)) < 0) + return -1; + + return 0; +} + + +hdf_err RankInfo(hdf_idt id, const char *name, void *data) +{ + if (data != NULL) + strcpy(data,name); + else + return -1; + + return 1; +} diff --git a/src/HDFPersist/HDFobjectType.c b/src/HDFPersist/HDFobjectType.c new file mode 100644 index 000000000..e31234bf6 --- /dev/null +++ b/src/HDFPersist/HDFobjectType.c @@ -0,0 +1,29 @@ +#include "hdfi.h" + +hdf_err +HDFobjectType(hdf_idt id, char *name, hdf_object_type *type) +{ + hdf_object_type rep; + hdf_bool follow = 1; + H5G_stat_t buf; + hdf_err ret; + + if ((ret = H5Gget_objinfo(id,name,follow,&buf) < 0)) + return -1; + + switch(buf.type) + { + case H5G_GROUP : + *type = HDF_GROUP; + break; + + case H5G_DATASET : + *type = HDF_DATASET; + break; + + default : + return -1; + } + + return 0; +} diff --git a/src/HDFPersist/HDFtypes.h b/src/HDFPersist/HDFtypes.h new file mode 100644 index 000000000..398b4d87c --- /dev/null +++ b/src/HDFPersist/HDFtypes.h @@ -0,0 +1,36 @@ +#ifndef HDFTYPES_H +#define HDFTYPES_H + +#include + +/* max length of a HDF object */ +#define HDF_NAME_MAX_LEN 100 + +/* HDF 5 types */ +typedef size_t hdf_size_type; +typedef H5T_class_t hdf_class_type; +typedef hsize_t hdf_size; +typedef hid_t hdf_idt; +typedef herr_t hdf_err; +typedef hbool_t hdf_bool; + +typedef int hdf_int32; +typedef long hdf_int64; +typedef double hdf_float64; + +/* Access Mode */ +typedef enum {HDF_RDONLY,HDF_RDWR} hdf_access_mode; + +/* Values types for HDF datasets and attributes */ +typedef enum {HDF_NONE,HDF_STRING, HDF_INT32, HDF_INT64, HDF_FLOAT64} hdf_type; +/* - HDF_STRING : C string + - HDF_INT32 : 32 bits integer + - HDF_INT64 : 64 bits integer + - HDF_FLOAT64 : IEEE 64 bits float +*/ + +/* HDF object types */ +typedef enum {HDF_OBJECT,HDF_FILE,HDF_GROUP,HDF_DATASET, + HDF_ATTRIBUTE} hdf_object_type; + +#endif /* HDFTYPES_H */ diff --git a/src/HDFPersist/Makefile.in b/src/HDFPersist/Makefile.in new file mode 100644 index 000000000..f486da165 --- /dev/null +++ b/src/HDFPersist/Makefile.in @@ -0,0 +1,80 @@ +#============================================================================== +# File : Makefile.in +# Created : mar aug 10 12:58:13 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_HEADERS = \ + HDFattribute.hxx \ + HDFcontainerObject.hxx \ + HDFdataset.hxx \ + HDFexplorer.hxx \ + HDFexception.hxx \ + HDFfile.hxx \ + HDFgroup.hxx \ + HDFinternalObject.hxx \ + HDFobject.hxx \ + HDFOI.hxx \ + HDFtypes.h \ + HDFconvert.hxx \ + hdfi.h + +# Libraries targets + +LIB = libSalomeHDFPersist.la +LIB_SRC = \ + HDFfileCreate.c \ + HDFfileClose.c \ + HDFfileOpen.c \ + HDFfileMount.c \ + HDFfileUmount.c \ + HDFgroupCreate.c \ + HDFgroupOpen.c \ + HDFgroupClose.c \ + HDFdatasetOpen.c \ + HDFdatasetClose.c \ + HDFdatasetCreate.c \ + HDFdatasetWrite.c \ + HDFdatasetRead.c \ + HDFdatasetGetDim.c \ + HDFdatasetGetSize.c \ + HDFdatasetGetType.c \ + HDFdatasetGetnDim.c \ + HDFattrOpen.c \ + HDFattrClose.c \ + HDFattrWrite.c \ + HDFattrCreate.c \ + HDFattrRead.c \ + HDFerrorModeLock.c \ + HDFnObjects.c \ + HDFobjectIdentify.c \ + HDFobjectType.c \ + HDFobject.cc \ + HDFinternalObject.cc \ + HDFattribute.cc \ + HDFcontainerObject.cc \ + HDFdataset.cc \ + HDFfile.cc \ + HDFgroup.cc \ + HDFexplorer.cc \ + HDFconvert.cc + +#BIN = test9 test8 + +CPPFLAGS+=-c -ansi $(HDF5_INCLUDES) +LDFLAGS+= $(HDF5_LIBS) + + +@CONCLUDE@ diff --git a/src/HDFPersist/hdfi.h b/src/HDFPersist/hdfi.h new file mode 100644 index 000000000..ebd133e27 --- /dev/null +++ b/src/HDFPersist/hdfi.h @@ -0,0 +1,93 @@ +#ifndef HDFI_H +#define HDFI_H + +#include "HDFtypes.h" + +/* HDF C INTERFACE */ + +/* File Interface */ +extern +hdf_idt HDFfileCreate(char *name); + +extern +hdf_err HDFfileClose(hdf_idt fid); + +extern +hdf_idt HDFfileOpen(char *name,hdf_access_mode access_mode); + +extern +hdf_err HDFfileMount(hdf_idt id,const char *name,hdf_idt fid); + +extern +hdf_err HDFfileUmount(hdf_idt id,const char *name); + +/* Group Interface */ +extern +hdf_idt HDFgroupCreate(hdf_idt pid, char *name); + +extern +hdf_idt HDFgroupOpen(hdf_idt pid, char *name); + +extern +hdf_err HDFgroupClose(hdf_idt id); + +/* DataSet Interface */ +extern +hdf_idt HDFdatasetOpen(hdf_idt pid,char *name); + +extern +hdf_err HDFdatasetClose(hdf_idt id); + +extern +hdf_idt HDFdatasetCreate(hdf_idt pid,char *name,hdf_type type, + hdf_size *dimd, int ndim); + +extern +hdf_err HDFdatasetWrite(hdf_idt id, void *val); + +extern +hdf_err HDFdatasetRead(hdf_idt id, void *val); + +extern +hdf_type HDFdatasetGetType(hdf_idt id); + +extern +int HDFdatasetGetnDim(hdf_idt id); + +extern +hdf_err HDFdatasetGetDim(hdf_idt id,hdf_size dim[]); + +extern +int HDFdatasetGetSize(hdf_idt id); + +/* Attribute interface */ +extern +hdf_idt HDFattrOpen(hdf_idt pid,char *name); + +extern +hdf_err HDFattrClose(hdf_idt id); + +extern +hdf_idt HDFattrCreate(hdf_idt pid,char *name,hdf_type type); + +extern +hdf_err HDFattrWrite(hdf_idt id,void *val); + +extern +hdf_err HDFattrRead(hdf_idt id,void *val); + +/* HDF Tools */ +extern +void HDFerrorModeLock(); + +extern +hdf_err +HDFnObjects(hdf_idt fid,char *path,int *n); + +extern +hdf_err HDFobjectIdentify(hdf_idt fid,char *path,int i,char *name); + +extern +hdf_err HDFobjectType(hdf_idt id, char *name, hdf_object_type *type); + +#endif /* HDFI_H */ diff --git a/src/HDFPersist/test1.c b/src/HDFPersist/test1.c new file mode 100644 index 000000000..f89638b78 --- /dev/null +++ b/src/HDFPersist/test1.c @@ -0,0 +1,66 @@ +#include"hdfi.h" +#include + +int main() { + hdf_idt fid,gid,did,atid; + hdf_err ret; + hdf_size size[1]; + hdf_int32 data[10] = { 1,2,3,4,5,6,7,8,9,10}; + hdf_int32 attr_val = 2; + + system("rm titi.HDF"); + + HDFerrorModeLock(); + + if ((fid = HDFfileCreate("titi.HDF")) < 0) + return -1; + MESSAGE("Creation du fichier") + + if ((gid = HDFgroupCreate(fid,"GROUP")) < 0) + return -1; + MESSAGE("Creation d'un groupe") + + if ((atid = HDFattrCreate(gid,"ATTR",HDF_INT32))< 0) + return -1; + MESSAGE("Creation d'un attribut") + + if ((ret = HDFattrWrite(atid,&attr_val)) < 0) + return -1; + MESSAGE("Ecriture de l'attribut") + + if ((ret = HDFattrClose(atid)) < 0) + return -1; + MESSAGE("Fermeture de l'attribut") + + size[0] = 10; + if ((did = HDFdatasetCreate(gid,"DATASET",HDF_INT32,size)) < 0) + return -1; + MESSAGE("Creation d'un dataset") + + if ((ret = HDFdatasetWrite(did,data)) < 0) + return -1; + MESSAGE("Ecriture du dataset") + + if ((ret = HDFdatasetClose(did)) < 0) + return -1; + MESSAGE("Fermeture du datset") + + if ((ret = HDFgroupClose(gid)) < 0) + return -1; + MESSAGE("Fermeture du groupe") + + if ((ret = HDFfileClose(fid)) < 0) + return ret; + MESSAGE("Fermeture du fichier") + + if ((fid = HDFfileCreate("toto.HDF")) < 0) + return -1; + MESSAGE("Creation du fichier") + + if ((ret = HDFfileClose(fid)) < 0) + return ret; + MESSAGE("Fermeture du fichier") + + + return 0; +} diff --git a/src/HDFPersist/test2.c b/src/HDFPersist/test2.c new file mode 100644 index 000000000..e29a5557a --- /dev/null +++ b/src/HDFPersist/test2.c @@ -0,0 +1,57 @@ +#include"hdfi.h" +#include + +int main() { + hdf_idt fid,gid,did,atid; + hdf_err ret; + hdf_size size[1]; + hdf_int32 data[10]; + int attr_val; + int i; + + HDFerrorModeLock(); + + if ((fid = HDFfileOpen("titi.HDF",HDF_RDONLY)) < 0) + return -1; + MESSAGE("Ouverture du fichier") + + if ((gid = HDFgroupOpen(fid,"GROUP")) < 0) + return -1; + MESSAGE("Ouverture du goupe") + + if ((atid = HDFattrOpen(gid,"ATTR"))< 0) + return -1; + MESSAGE("Ouverture de l'attribut du goupe") + + if ((ret = HDFattrRead(atid,&attr_val)) < 0) + return -1; + MESSAGE("Lecture de l'attribut du goupe : " << attr_val) + + if ((ret = HDFattrClose(atid)) < 0) + return -1; + MESSAGE("Fermeture de l'attribut du goupe") + + if ((did = HDFdatasetOpen(gid,"DATASET")) < 0) + return -1; + MESSAGE("Ouverture du dataset") + + if ((ret = HDFdatasetRead(did,data)) < 0) + return -1; + MESSAGE("Lecture du dataset") + for (i=0;i<10;i++) + MESSAGE(data[i]) + + if ((ret = HDFdatasetClose(did)) < 0) + return -1; + MESSAGE("Fermeture du dataset") + + if ((ret = HDFgroupClose(gid)) < 0) + return -1; + MESSAGE("Fermeture du groupe") + + if ((ret = HDFfileClose(fid)) < 0) + return ret; + MESSAGE("Fermeture du fichier") + + return 0; +} diff --git a/src/HDFPersist/test3.cxx b/src/HDFPersist/test3.cxx new file mode 100644 index 000000000..2daacd250 --- /dev/null +++ b/src/HDFPersist/test3.cxx @@ -0,0 +1,168 @@ +using namespace std; +#include +#include "HDFOI.hxx" +#include + + +int main() +{ + HDFfile *hdf_file; + HDFgroup *hdf_group; + HDFdataset *hdf_dataset; + HDFdataset *hdf_dataset2; + HDFattribute *hdf_attribute; + hdf_size size[1]; + hdf_float64 coordinates[3] = {5.,-6.9,4.2}; + hdf_int32 unit[3] = {0,0,0}; + char message[HDF_NAME_MAX_LEN+1] = "MESSAGE"; + hdf_int32 attribute = 3; + HDFexplorer *explorer; + HDFinternalObject *object; + + system("rm file_test3.hdf"); + + try + { + // a new HDFfile object + hdf_file = new HDFfile("file_test3.hdf"); + MESSAGE( ">> A HDFfile object is created" ); + + hdf_file->CreateOnDisk(); + MESSAGE( ">> The HDF file is created on Disk " ); + + // Inside the HDF file + + // A new HDF group object + hdf_group = new HDFgroup("MESH",hdf_file); + MESSAGE( ">> A HDFgroup object 'MESH' is created" ); + + hdf_group->CreateOnDisk(); + MESSAGE( ">> The HDF group is created on Disk " ); + + // Inside the HDF group + + // A new HDF dataset object + // size of each dimension, only one in the example + size[0] = 3; + hdf_dataset = new HDFdataset("COORDINATES",hdf_group,HDF_FLOAT64,size,1); + MESSAGE( ">> A HDFdataset object 'COORDINATES' is created" ); + + hdf_dataset->CreateOnDisk(); + MESSAGE( ">> The HDF dataset is created on Disk " ); + + // a HDFattribute object inside the dataset + hdf_attribute = new HDFattribute("ATTRIBUTE",hdf_dataset,HDF_INT32); + MESSAGE( ">> A HDF attribute object is created for the dataset " ); + + hdf_dataset->WriteOnDisk(coordinates); + MESSAGE( ">> The HDF dataset is written on Disk " ); + + hdf_attribute->CreateOnDisk(); + MESSAGE( ">> The HDF attribute is created on Disk " ); + + hdf_attribute->WriteOnDisk(&attribute); + MESSAGE( ">> The HDF attribute is written on Disk " ); + + hdf_attribute->CloseOnDisk(); + MESSAGE( ">> The HDF attribute closed on Disk " ); + + hdf_dataset->CloseOnDisk(); + MESSAGE( ">> The HDF dataset is closed on Disk " ); + + // A new dataset is created + size[0] = 3; + hdf_dataset2 = new HDFdataset("UNIT",hdf_group,HDF_INT32,size,1); + MESSAGE( ">> A second HDFdataset object 'UNIT' is created" ); + + hdf_dataset2->CreateOnDisk(); + MESSAGE( ">> The HDF dataset is created on Disk " ); + + hdf_dataset2->WriteOnDisk(unit); + MESSAGE( ">> The HDF dataset is written on Disk " ); + + hdf_dataset2->CloseOnDisk(); + MESSAGE( ">> The HDF dataset is closed on Disk " ); + + // The HDF group is built, it can be closed + hdf_group->CloseOnDisk(); + MESSAGE( ">> The HDF group is closed on Disk " ); + + // The HDF file is built, it can be closed + hdf_file->CloseOnDisk(); + MESSAGE( ">> The HDF file is closed on disk" ); + + // Explorer + explorer = new HDFexplorer(hdf_file); + MESSAGE( ">> A HDF explorer object is created" ); + + MESSAGE( ">> File Exploration " ); + for (explorer->Init();explorer->More();explorer->Next()) + { + object = explorer->Value(); + MESSAGE( "--> Name of the object : " << object->GetName() ); + switch (object->GetObjectType()) + { + case HDF_FILE : + MESSAGE( "--> Type of the object : HDF_FILE : " ); + break; + + case HDF_GROUP : + MESSAGE( "--> Type of the object : HDF_GROUP : " ); + break; + + case HDF_DATASET : + MESSAGE( "--> Type of the object : HDF_DATASET : " ); + break; + + default : + MESSAGE( "--> PANIC !!! : " ); + } + } + + MESSAGE( ">> Group exploration" ); + explorer->Reset(hdf_group); + for (explorer->Init();explorer->More();explorer->Next()) + { + object = explorer->Value(); + MESSAGE( "--> Name of the object : " << object->GetName() ); + switch (object->GetObjectType()) + { + case HDF_FILE : + MESSAGE( "--> Type of the object : HDF_FILE : " ); + break; + + case HDF_GROUP : + MESSAGE( "--> Type of the object : HDF_GROUP : " ); + break; + + case HDF_DATASET : + MESSAGE( "--> Type of the object : HDF_DATASET : " ); + break; + + default : + MESSAGE( "--> !!! PANIC !!! : " ); + } + } + + // memory clean + MESSAGE( ">> MEMORY CLEAN " ); + delete explorer; + MESSAGE( ">> The HDF eplorer object is deleted" ); + delete hdf_attribute; + MESSAGE( ">> The HDF attribute object is deleted" ); + delete hdf_dataset; + MESSAGE( ">> The first HDF dataset object is deleted" ); + delete hdf_dataset2; + MESSAGE( ">> The second HDF dataset object is deleted" ); + delete hdf_group; + MESSAGE( ">> The HDF group object is deleted" ); + delete hdf_file; + MESSAGE( ">> The HDF file object is deleted" ); + } + catch (HDFexception) + { + MESSAGE( "!!!! HDFexception" ) + } + + return 0; +} diff --git a/src/HDFPersist/test4.cxx b/src/HDFPersist/test4.cxx new file mode 100644 index 000000000..bf4f24b71 --- /dev/null +++ b/src/HDFPersist/test4.cxx @@ -0,0 +1,193 @@ +using namespace std; +#include +#include "HDFOI.hxx" +#include + + +int main() +{ + HDFfile *hdf_file; + HDFgroup *hdf_group; + HDFdataset *hdf_dataset1, *hdf_dataset2; + int n,i; + char name[HDF_NAME_MAX_LEN+1]; + hdf_object_type type; + hdf_type data_type; + int ndim, size; + hdf_size *dim; + hdf_float64 *val1; + hdf_int32 *val2; + + try + { + // a new HDFfile object + hdf_file = new HDFfile("file_test3.hdf"); + MESSAGE( ">> A HDFfile object is created" ); + + hdf_file->OpenOnDisk(HDF_RDONLY); + MESSAGE(">> The HDF file is opened on Disk with HDF_RDONLY access mode") + // It is possible to read the name of all (objects) sons in the file + n = hdf_file->nInternalObjects(); + for (i=0;iInternalObjectIndentify(i,name); + MESSAGE( "--> First Level Internal Object Name : " << name ); + } + + // Or it is possible to ask if an object is in the file + if (hdf_file->ExistInternalObject("MESH")) + MESSAGE( "--> The object naming 'MESH' is in the file " ); + + // it is possible to determine the type of an object + type = hdf_file->InternalObjectType("MESH"); + switch (type) + { + case HDF_GROUP : + MESSAGE( "--> Its type is HDF_GROUP" ); + break; + + case HDF_DATASET : + MESSAGE( "--> Its type is HDF_DATASET" ); + break; + + default : + MESSAGE( "--> !!!! PANIC !!!" ); + } + + hdf_group = new HDFgroup(name,hdf_file); + MESSAGE( ">> A new HDF group object " << name << " is created in memory") + + hdf_group->OpenOnDisk(); + MESSAGE( ">> The group " << name << " is opened on disk" ); + + // object inside the group ? + n = hdf_group->nInternalObjects(); + MESSAGE( ">> There are " << n << " objects in this group " ); + for (i=0;iInternalObjectIndentify(i,name); + type = hdf_group->InternalObjectType(name); + MESSAGE( "--> First Level Internal Object Name : " << name ); + switch (type) + { + case HDF_GROUP : + MESSAGE( "--> Its type is HDF_GROUP" ); + break; + + case HDF_DATASET : + MESSAGE( "--> Its type is HDF_DATASET" ); + break; + + default : + MESSAGE( "--> !!!! PANIC !!!" ); + } + } + + // The first dataset object 'COORDINATES' + hdf_dataset1 = new HDFdataset("COORDINATES",hdf_group); + MESSAGE( ">> The dataset object 'COORDINATES' is created in memory " ); + + hdf_dataset1->OpenOnDisk(); + MESSAGE( ">> The dataset object 'COORDINATES' is opened on disk " ); + + data_type = hdf_dataset1->GetType(); + switch(data_type) + { + case HDF_INT32 : + MESSAGE( "--> Type of data : HDF_INT32 " ); + break; + case HDF_INT64 : + MESSAGE( "--> Type of data : HDF_INT64 " ); + break; + case HDF_FLOAT64 : + MESSAGE( "--> Type of data : HDF_FLOAT64 " ); + break; + default : + MESSAGE( "--> Type of data : HDF_STRING " ); + } + + ndim = hdf_dataset1->nDim(); + MESSAGE( "--> Number of dimensions : " << ndim ); + + dim = new hdf_size[ndim]; + hdf_dataset1->GetDim(dim); + for (i=0;i Dimension " << i+1 << " of size : " << dim[i] ); + delete dim; + + size = hdf_dataset1->GetSize(); + val1 = new hdf_float64[size]; + hdf_dataset1->ReadFromDisk(val1); + MESSAGE( "--> The values are : "); + for (i=0;iCloseOnDisk(); + MESSAGE( ">> The dataset object 'COORDINATES' is closed on disk " ); + + // The second dataset 'UNIT' + hdf_dataset2 = new HDFdataset("UNIT",hdf_group); + MESSAGE( ">> The dataset object 'UNIT' is created in memory " ); + + hdf_dataset2->OpenOnDisk(); + MESSAGE( ">> The dataset object 'UNIT' is opened on disk " ); + + data_type = hdf_dataset2->GetType(); + switch(data_type) + { + case HDF_INT32 : + MESSAGE( "--> Type of data : HDF_INT32 " ); + break; + case HDF_INT64 : + MESSAGE( "--> Type of data : HDF_INT64 " ); + break; + case HDF_FLOAT64 : + MESSAGE( "--> Type of data : HDF_FLOAT64 " ); + break; + default : + MESSAGE( "--> Type of data : HDF_STRING " ); + } + + ndim = hdf_dataset2->nDim(); + MESSAGE( "--> Number of dimensions : " << ndim ); + + dim = new hdf_size[ndim]; + hdf_dataset2->GetDim(dim); + for (i=0;i Dimension " << i+1 << " of size : " << dim[i] ); + delete dim; + + size = hdf_dataset2->GetSize(); + val2 = new hdf_int32[size]; + hdf_dataset2->ReadFromDisk(val2); + MESSAGE( "--> The values are : "); + for (i=0;iCloseOnDisk(); + MESSAGE( ">> The dataset object 'UNIT' is closed on disk " ); + + hdf_group->CloseOnDisk(); + MESSAGE( ">> The group is closed on file" ); + + hdf_file->CloseOnDisk(); + MESSAGE(">> The HDF file is closed on Disk" ) + + // Memory clean + delete hdf_dataset1; + delete hdf_dataset2; + delete hdf_group; + delete hdf_file; + MESSAGE( ">> MEMORY CLEAN : all HDF objects have been deleted" ); + } + catch (HDFexception) + { + MESSAGE( "!!! HDFexception !!! " ) + } + + return 0; +} diff --git a/src/HDFPersist/test5.cxx b/src/HDFPersist/test5.cxx new file mode 100644 index 000000000..0884e7f3f --- /dev/null +++ b/src/HDFPersist/test5.cxx @@ -0,0 +1,95 @@ +using namespace std; +#include +#include "HDFOI.hxx" +#include + + +int main() +{ + HDFfile *hdf_file; + HDFgroup *hdf_group; + + try + { + // A file study.hdf with 2 groups : MESH and GEOM + hdf_file = new HDFfile("study.hdf"); + + hdf_file->CreateOnDisk(); + + hdf_group = new HDFgroup("GEOM",hdf_file); + + hdf_group->CreateOnDisk(); + + hdf_group->CloseOnDisk(); + + delete hdf_group; + + hdf_group = new HDFgroup("MESH",hdf_file); + + hdf_group->CreateOnDisk(); + + hdf_group->CloseOnDisk(); + + delete hdf_group; + + hdf_file->CloseOnDisk(); + + delete hdf_file; + + // a file mesh.hdf with 2 groups MESH_1 and MESH_2 + hdf_file = new HDFfile("mesh.hdf"); + + hdf_file->CreateOnDisk(); + + hdf_group = new HDFgroup("MESH_1",hdf_file); + + hdf_group->CreateOnDisk(); + + hdf_group->CloseOnDisk(); + + delete hdf_group; + + hdf_group = new HDFgroup("MESH_2",hdf_file); + + hdf_group->CreateOnDisk(); + + hdf_group->CloseOnDisk(); + + delete hdf_group; + + hdf_file->CloseOnDisk(); + + delete hdf_file; + + // a file geom.hdf with 2 groups GEOM_1 and GEOM_2 + hdf_file = new HDFfile("geom.hdf"); + + hdf_file->CreateOnDisk(); + + hdf_group = new HDFgroup("GEOM_1",hdf_file); + + hdf_group->CreateOnDisk(); + + hdf_group->CloseOnDisk(); + + delete hdf_group; + + hdf_group = new HDFgroup("GEOM_2",hdf_file); + + hdf_group->CreateOnDisk(); + + hdf_group->CloseOnDisk(); + + delete hdf_group; + + hdf_file->CloseOnDisk(); + + delete hdf_file; + } + catch (HDFexception) + { + MESSAGE( "!!!! HDFexception !!!" ) + } + + return 0; +} diff --git a/src/HDFPersist/test6.cxx b/src/HDFPersist/test6.cxx new file mode 100644 index 000000000..e208ee1b2 --- /dev/null +++ b/src/HDFPersist/test6.cxx @@ -0,0 +1,112 @@ +using namespace std; +#include +#include "HDFOI.hxx" +#include + +int main() +{ + HDFfile *study; + HDFgroup *geom, *mesh; + HDFgroup *geom1, *geom2, *mesh1, *mesh2; + int n,m,i; + char name[HDF_NAME_MAX_LEN+1]; + + try + { + // the groups 'GEOM' and 'MESH' become mounted points for + // the files 'geom.hdf' and 'mesh.hdf' in the 'study.hdf' file + + study = new HDFfile("study.hdf"); + MESSAGE( ">> The HDFfile object for 'study.hdf' is created" ); + + study->OpenOnDisk(HDF_RDONLY); + MESSAGE( "--> The file is opened" ); + + geom = new HDFgroup("GEOM",study); + MESSAGE( ">> The HDFgroup object for 'GEOM' is created" ); + + geom->FileMount("geom.hdf",HDF_RDONLY); + MESSAGE( ">> 'GEOM' becomes a mounted point for the file 'geom.hdf'" ); + + geom->OpenOnDisk(); + MESSAGE( "--> The group is opened" ); + + m = geom->nInternalObjects(); + MESSAGE( "--> There are " << m << " objects in the group" ); + + for (i=0;iInternalObjectIndentify(i,name); + MESSAGE( "--> First Level Internal Object Name : " << name ); + } + + geom1 = new HDFgroup("GEOM_1",geom); + MESSAGE( ">> The HDF group object is created for 'GEOM_1' with 'GEOM' as father" ); + MESSAGE( "--> This group is in fact in the file 'geom.hdf'"); + + geom1->OpenOnDisk(); + MESSAGE( "-> The group 'GEOM_1' is opened" ); + + geom1->CloseOnDisk(); + MESSAGE( "-> The group 'GEOM_1' is closed" ); + + geom2 = new HDFgroup("GEOM_2",geom); + MESSAGE( ">> The HDF group object is created for 'GEOM_2' with 'GEOM' as father" ); + MESSAGE( "--> This group is in fact in the file 'geom.hdf'"); + + geom2->OpenOnDisk(); + MESSAGE( "-> The group 'GEOM_2' is opened" ); + + geom2->CloseOnDisk(); + MESSAGE( "-> The group 'GEOM_2' is closed" ); + + geom->CloseOnDisk(); + MESSAGE( "-> The group 'GEOM' is closed" ); + + geom->FileUnMount(); + MESSAGE( ">> The file 'geom.hdf' is unmounted from 'GEOM' " ); + + mesh = new HDFgroup("MESH",study); + + mesh->FileMount("mesh.hdf",HDF_RDONLY); + + mesh->OpenOnDisk(); + + mesh1 = new HDFgroup("MESH_1",mesh); + + mesh1->OpenOnDisk(); + + mesh1->CloseOnDisk(); + + mesh2 = new HDFgroup("MESH_2",mesh); + + mesh2->OpenOnDisk(); + + mesh2->CloseOnDisk(); + + mesh->CloseOnDisk(); + + mesh->FileUnMount(); + + MESSAGE( ">> The same operations have been done for the file 'mesh.hdf'" ) + MESSAGE( " and the groups MESH_1 and MESH_2" ) + MESSAGE( "--> This file has been mounted on the group 'MESH' of the file 'study.hdf' ") + + study->CloseOnDisk(); + MESSAGE( ">> The study.hdf file is closed" ); + + MESSAGE( ">> Memory clean" ); + delete mesh1; + delete mesh2; + delete mesh; + delete geom1; + delete geom2; + delete geom; + delete study; + } + catch(HDFexception) + { + MESSAGE( "!!! HDFexception !!! ") + } + return 0; +} diff --git a/src/HDFPersist/test7.cxx b/src/HDFPersist/test7.cxx new file mode 100644 index 000000000..123d66b63 --- /dev/null +++ b/src/HDFPersist/test7.cxx @@ -0,0 +1,10 @@ +using namespace std; +#include "HDFIO.hxx" +#include + +int main() +{ + + + return 0; +} diff --git a/src/HDFPersist/test8.cxx b/src/HDFPersist/test8.cxx new file mode 100644 index 000000000..222d839eb --- /dev/null +++ b/src/HDFPersist/test8.cxx @@ -0,0 +1,60 @@ +using namespace std; +#include +#include "HDFOI.hxx" +#include + + +int main() +{ + HDFfile *hdf_file; + HDFgroup *hdf_group; + HDFdataset *hdf_dataset; + hdf_size size[1]; + char message[HDF_NAME_MAX_LEN+1] = "MESSAGE"; + hdf_int32 attribute = 3; + + system("rm file_ascii.hdf"); + + try + { + // a new HDFfile object + hdf_file = new HDFfile("file_ascii.hdf"); + MESSAGE( ">> A HDFfile object is created" ); + + hdf_file->CreateOnDisk(); + MESSAGE( ">> The HDF file is created on Disk " ); + + // Inside the HDF file + + // A new HDF group object + hdf_group = new HDFgroup("ASCII GROUP",hdf_file); + MESSAGE( ">> A HDFgroup object 'ASCII' is created" ); + + hdf_group->CreateOnDisk(); + MESSAGE( ">> The HDF group is created on Disk " ); + + // Transfert d'un fichier ASCII dans un groupe HDF + HDFConvert::FromAscii("ascii.txt",*hdf_group,"ASCII DATASET"); + MESSAGE( ">> The Ascii file is transfered " ); + + // The HDF group is built, it can be closed + hdf_group->CloseOnDisk(); + MESSAGE( ">> The HDF group is closed on Disk " ); + + // The HDF file is built, it can be closed + hdf_file->CloseOnDisk(); + MESSAGE( ">> The HDF file is closed on disk" ); + + + delete hdf_group; + MESSAGE( ">> The HDF group object is deleted" ); + delete hdf_file; + MESSAGE( ">> The HDF file object is deleted" ); + } + catch (HDFexception) + { + MESSAGE( "!!!! HDFexception" ) + } + + return 0; +} diff --git a/src/HDFPersist/test9.cxx b/src/HDFPersist/test9.cxx new file mode 100644 index 000000000..3cd1a5e48 --- /dev/null +++ b/src/HDFPersist/test9.cxx @@ -0,0 +1,116 @@ +using namespace std; +#include +#include "HDFOI.hxx" +#include + + +int main() +{ + HDFfile *hdf_file; + HDFgroup *hdf_group; + HDFdataset *hdf_dataset1; + int fd; + size_t size; + char * buffer; + off_t pos; + + system("rm ascii_hdf.txt"); + + try { + + // a new HDFfile object + hdf_file = new HDFfile("file_ascii.hdf"); + MESSAGE( ">> A HDFfile object is created" ); + + hdf_file->OpenOnDisk(HDF_RDONLY); + MESSAGE( ">> The HDF file is opened on Disk with HDF_RDONLY access mode" ) + + hdf_group = new HDFgroup("ASCII GROUP",hdf_file); + MESSAGE(">> A new HDF group object ASCII GROUP" << " is created in memory") + + hdf_group->OpenOnDisk(); + MESSAGE( ">> The group ASCII GROUP is opened on disk" ); + + // The dataset object 'ASCII DATASET' + hdf_dataset1 = new HDFdataset("ASCII DATASET",hdf_group); + MESSAGE( ">> The dataset object 'ASCII DATASET' is created in memory " ); + + hdf_dataset1->OpenOnDisk(); + MESSAGE( ">> The dataset object 'ASCII DATASET' is opened on disk " ); + + size = (size_t) hdf_dataset1->GetSize(); + + // Open the target file + + if ( (fd = open("ascii_hdf.txt",O_RDWR|O_CREAT,00666)) <0) { + perror("open : test9"); + return -1; + }; + + // if ( (pos = lseek(fd,(off_t) size-3,SEEK_SET)) <0) { +// perror("lseek : test9"); +// return -1; +// }; + +// if ( write(fd,"END",3) <0) { +// perror("write : test9"); +// return -1; +// }; + +#ifdef _POSIX_MAPPED_FILES + // Map le fichier en mémoire + // if ((buffer = (char *) mmap(0,size,PROT_WRITE,MAP_SHARED,fd,0)) == MAP_FAILED ) { + // perror("mmap : test9"); + //return -1; + //}; + buffer = new char[size]; +#else + // Sort de la compilation +#error Necessite l''utilisation de la primitive mmap +#endif + + // Transfert les informations dans le fichier destination + hdf_dataset1->ReadFromDisk(buffer); + + if ( write(fd,buffer,size) <0) { + perror("write : test9"); + return -1; + }; + + // Desalloue le mapping +// if (munmap(buffer,size) < 0 ) { +// perror("munmap : test9"); +// return -1; +// }; + + // Close the target file + if (close(fd) <0) { + perror("close : test9"); + return -1; + } + + hdf_dataset1->CloseOnDisk(); + MESSAGE( ">> The dataset is closed on disk " ); + + hdf_group->CloseOnDisk(); + MESSAGE( ">> The group is closed on file" ); + + hdf_file->CloseOnDisk(); + MESSAGE( ">> The HDF file is closed on Disk" ) + + // Memory clean + delete hdf_dataset1; + delete hdf_group; + delete hdf_file; + delete buffer; + MESSAGE( ">> MEMORY CLEAN : all HDF objects have been deleted" ); + + } + catch (HDFexception) { + return -1; + MESSAGE( "!!! HDFexception !!! " ) + } + + return 0; +} + diff --git a/src/LifeCycleCORBA/LifeCycleCORBA.py b/src/LifeCycleCORBA/LifeCycleCORBA.py new file mode 100644 index 000000000..b7784156c --- /dev/null +++ b/src/LifeCycleCORBA/LifeCycleCORBA.py @@ -0,0 +1,226 @@ +#============================================================================== +# File : LifeCycleCORBA.py +# Created : mer oct 17 08:42:01 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +import os +import sys +import time +from omniORB import CORBA +import CosNaming +import Engines +import SALOME_ModuleCatalog + +from SALOME_utilities import * + +class LifeCycleCORBA: + _orb = None + _rootcontext = None + _containerRootContext = None + _catalog = None + + #------------------------------------------------------------------------- + + def __init__(self, orb): + MESSAGE( "LifeCycleCORBA::__init__" ) + self._orb = orb + + obj = self._orb.resolve_initial_references("NameService") + self._rootContext = obj._narrow(CosNaming.NamingContext) + + if self._rootContext is None: + MESSAGE( "Name Service Reference is invalid" ) + + name = [CosNaming.NameComponent("Containers","dir")] + try: + self._containerRootContext = self._rootContext.bind_new_context(name) + + except CosNaming.NamingContext.AlreadyBound, ex: + MESSAGE( "/Containers.dir Context already exists" ) + obj = self._rootContext.resolve(name) + self._containerRootContext = obj._narrow(CosNaming.NamingContext) + if self._containerRootContext is None: + MESSAGE( "Containers.dir exists but it is not a NamingContext" ) + + name = [CosNaming.NameComponent("Kernel","dir"), + CosNaming.NameComponent("ModulCatalog","object")] + try: + obj = self._rootContext.resolve(name) + except CosNaming.NamingContext.NotFound, ex: + MESSAGE( "/Kernel.dir/ModulCatalog.object not found in Naming Service" ) + + self._catalog = obj._narrow(SALOME_ModuleCatalog.ModuleCatalog) + if self._catalog is None: + MESSAGE( "/Kernel.dir/ModulCatalog.object exists but is not a ModulCatalog" ) + + #------------------------------------------------------------------------- + + def ContainerName(self, containerName): + try: + theComputer , theContainer = containerName.split('/') + except: + theComputer = "" + theContainer = containerName + if theComputer == "" : + theComputer = os.getenv("HOSTNAME") + if theComputer == "localhost" : + theComputer = os.getenv("HOSTNAME") + computerSplitName = theComputer.split('.') + theComputer = computerSplitName[0] + MESSAGE( theComputer + theContainer ) + return theComputer,theContainer + + #------------------------------------------------------------------------- + + def ComputerPath(self, ComputerName ): + try: + path = self._catalog.GetPathPrefix( ComputerName ) + except SALOME_ModuleCatalog.NotFound, ex: + path = "" + return path + + #------------------------------------------------------------------------- + + def FindContainer(self, containerName): + theComputer,theContainer = self.ContainerName( containerName ) + name = [CosNaming.NameComponent(theComputer,"dir"), + CosNaming.NameComponent(theContainer,"object")] + obj = None + try: + obj = self._containerRootContext.resolve(name) + MESSAGE( containerName + ".object found in Naming Service" ) + + except CosNaming.NamingContext.NotFound, ex: + MESSAGE( containerName + ".object not found in Naming Service" ) + + if obj is None: + container = None + else: + container = obj._narrow(Engines.Container) + if container is None: + MESSAGE( containerName + ".object exists but is not a Container" ) + return container + + #------------------------------------------------------------------------- + + def FindOrStartContainer(self, theComputer , theContainer ): + MESSAGE( "FindOrStartContainer" + theComputer + theContainer ) + aContainer = self.FindContainer( theComputer + "/" + theContainer ) + if aContainer is None : + if (theContainer == "FactoryServer") | (theContainer == "FactoryServerPy") : + if theComputer == os.getenv("HOSTNAME") : + rshstr = "" + else : + rshstr = "rsh -n " + theComputer + " " + path = self.ComputerPath( theComputer ) + if path != "" : + rshstr = rshstr + path + "/../bin/" + else : + rshstr = rshstr + os.getenv( "PWD" ) + "/" + if theContainer == "FactoryServer" : + rshstr = rshstr + "./runSession ./SALOME_Container " + else : + rshstr = rshstr + "./runSession ./SALOME_ContainerPy.py '" + rshstr = rshstr + theContainer + " -" + omniORBcfg = os.getenv( "HOME" ) + "/omniORB.cfg" +# omniORBcfg = os.getenv( "HOME" ) + "/.omniORB.cfg" + file = os.open( omniORBcfg , os.O_RDONLY ) + ORBInitRef = os.read(file,132) + if ORBInitRef[len(ORBInitRef)-1] == '\n' : + ORBInitRef,bsn = ORBInitRef.split('\n') + os.close( file ) + rshstr = rshstr + ORBInitRef + if theContainer == "FactoryServerPy" : + rshstr = rshstr + "'" + rshstr = rshstr + " > /tmp/" + theContainer + "_" + rshstr = rshstr + theComputer + rshstr = rshstr + ".log 2>&1 &" + os.system( rshstr ) + MESSAGE( "FindOrStartContainer" + rshstr + " done" ) + else : + if theContainer.find('Py') == -1 : + aContainer = self.FindContainer( theComputer + "/" + "FactoryServer" ) + else : + aContainer = self.FindContainer( theComputer + "/" + "FactoryServerPy" ) + aContainer = aContainer.start_impl( theContainer ) + + count = 21 + while aContainer is None : + time.sleep(1) + count = count - 1 + MESSAGE( count + ". Waiting for " + theComputer + "/" + theContainer ) + aContainer = self.FindContainer( theComputer + "/" + theContainer ) + if count == 0 : + return aContainer + + return aContainer + #os.system("rsh -n dm2s0017 /export/home/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515") + + #------------------------------------------------------------------------- + + def FindOrLoadComponent(self, containerName, componentName): + + theComputer,theContainer = self.ContainerName( containerName ) + name = [CosNaming.NameComponent(theComputer,"dir"), + CosNaming.NameComponent(theContainer,"dir"), + CosNaming.NameComponent(componentName,"object")] + try: + obj = self._containerRootContext.resolve(name) + except CosNaming.NamingContext.NotFound, ex: + MESSAGE( "component " + componentName + " not found, trying to load" ) + container = self.FindContainer(theComputer + "/" + theContainer) + if container is None: + MESSAGE( "container " + theComputer + "/" + theContainer + " not found in Naming Service, trying to start" ) + if (theContainer != "FactoryServer") & (theContainer != "FactoryServerPy") : + if theContainer.find('Py') == -1 : + theFactorycontainer = "FactoryServer" + else : + theFactorycontainer = "FactoryServerPy" + Factorycontainer = self.FindContainer(theComputer + "/" + theFactorycontainer) + if Factorycontainer is None: + MESSAGE( "container " + theComputer + "/" + theFactorycontainer + " not found in Naming Service, trying to start" ) + Factorycontainer = self.FindOrStartContainer(theComputer,theFactorycontainer) + else: + Factorycontainer = self.FindOrStartContainer(theComputer,theContainer) + if Factorycontainer != None : + container = self.FindOrStartContainer(theComputer,theContainer) + + if container != None: + compoinfo = self._catalog.GetComponent(componentName) + if compoinfo is None: + MESSAGE( "component " + componentName + " not found in Module Catalog" ) + else: + try: + machineName = theComputer + path = compoinfo.GetPathPrefix(machineName) + "/" + except SALOME_ModuleCatalog.NotFound, ex: + MESSAGE( "machine " + machineName + " not found in Module Catalog" ) + MESSAGE( "trying localhost" ) + try: + path = compoinfo.GetPathPrefix("localhost") + "/" + except SALOME_ModuleCatalog.NotFound, ex: + path = "" + implementation = path + "lib" + componentName + "Engine.so" + MESSAGE( "Trying to load " + implementation ) + try: + component = container.load_impl(componentName, implementation) + MESSAGE( "component " + component._get_instanceName() + " launched !" ) + return component + except: + MESSAGE( "component " + componentName + " NOT launched !" ) + + else: + try: + component = obj._narrow(Engines.Component) + if component is None: + MESSAGE( componentName + " is not a component !" ) + else: + MESSAGE( "component " + component._get_instanceName() + " found !" ) + return component + except: + MESSAGE( componentName + " failure" ) + return None diff --git a/src/LifeCycleCORBA/Makefile.in b/src/LifeCycleCORBA/Makefile.in new file mode 100644 index 000000000..14acc36d3 --- /dev/null +++ b/src/LifeCycleCORBA/Makefile.in @@ -0,0 +1,40 @@ +#============================================================================== +# File : Makefile.in +# Created : lun jui 2 20:32:24 CEST 2001 +# Author : Paul RASCLE, EDF - Marc Tajchman, CEA +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_HEADERS = SALOME_LifeCycleCORBA.hxx + +EXPORT_PYSCRIPTS = LifeCycleCORBA.py + +# Libraries targets + +LIB = libSalomeLifeCycleCORBA.la +LIB_SRC = SALOME_LifeCycleCORBA.cxx +LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl \ + SALOME_ModuleCatalog.idl + +# Executables targets +BIN = TestLifeCycleCORBA +BIN_SRC = +BIN_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl \ + SALOME_ModuleCatalog.idl + +LDFLAGS += -lSalomeNS -lOpUtil -lSalomeLoggerServer +CPPFLAGS += -I ../Logger + +@CONCLUDE@ + diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx new file mode 100644 index 000000000..bf562002b --- /dev/null +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -0,0 +1,403 @@ +using namespace std; +//============================================================================= +// File : SALOME_LifeCycleCORBA.cxx +// Created : jeu jui 12 14:55:50 CEST 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#include +#include +#include +#include + +#include "OpUtil.hxx" +#include "utilities.h" + +#include + +#include "SALOME_LifeCycleCORBA.hxx" +#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) +#include "SALOME_NamingService.hxx" + +SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA() +{ + _NS = NULL; + _FactoryServer = NULL ; +} + +SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns) +{ + _NS = ns; + _FactoryServer = NULL ; +} + +SALOME_LifeCycleCORBA::~SALOME_LifeCycleCORBA() +{ +} + +string SALOME_LifeCycleCORBA::ContainerName( + const char * aComputerContainer , + string * theComputer , + string * theContainer ) { + char * ContainerName = new char [ strlen( aComputerContainer ) + 1 ] ; + strcpy( ContainerName , aComputerContainer ) ; + string theComputerContainer("/Containers/"); + char * slash = strchr( ContainerName , '/' ) ; + if ( !slash ) { + *theComputer = GetHostname() ; + theComputerContainer += *theComputer ; + theComputerContainer += "/" ; + *theContainer = ContainerName ; + theComputerContainer += *theContainer ; + } + else { + slash[ 0 ] = '\0' ; + slash += 1 ; + *theContainer = slash ; + if ( !strcmp( ContainerName , "localhost" ) ) { + *theComputer = GetHostname() ; + } + else { + *theComputer = ContainerName ; + } + theComputerContainer += *theComputer ; + theComputerContainer += "/" ; + theComputerContainer += *theContainer ; + } + return theComputerContainer ; +} + +string SALOME_LifeCycleCORBA::ComputerPath( + const char * theComputer ) { + CORBA::String_var path; + CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog"); + SALOME_ModuleCatalog::ModuleCatalog_var Catalog = + SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ; + try { + path = Catalog->GetPathPrefix( theComputer ); + } + catch (SALOME_ModuleCatalog::NotFound&) { + MESSAGE("GetPathPrefix(" << theComputer << ") not found!"); + path = "" ; + } + SCRUTE( path ) ; + return CORBA::string_dup( path ) ; +} + +Engines::Container_var SALOME_LifeCycleCORBA::FindContainer(const char *containerName ) { + ASSERT(_NS != NULL); + string cont ; + if ( strncmp( containerName , "/Containers/" , 12 ) ) { // Compatibility ... + string theComputer ; + string theContainer ; + cont = ContainerName( containerName , &theComputer , &theContainer ) ; + } + else { + cont = containerName ; + } + try { + + SCRUTE( cont ); + + CORBA::Object_var obj = _NS->Resolve( cont.c_str() ); + if( !CORBA::is_nil( obj ) ) { + return Engines::Container::_narrow( obj ) ; + } + } + catch (ServiceUnreachable&) { + INFOS("Caught exception: Naming Service Unreachable"); + } + catch (...) { + INFOS("Caught unknown exception."); + } + return Engines::Container::_nil(); +} + +Engines::Container_var SALOME_LifeCycleCORBA::FindOrStartContainer( + const string aComputerContainer , + const string theComputer , + const string theContainer ) { + Engines::Container_var aContainer = FindContainer( aComputerContainer.c_str() ) ; + Engines::Container_var aFactoryServer ; + SCRUTE( aComputerContainer ) ; + SCRUTE( theComputer ) ; + SCRUTE( theContainer ) ; + bool pyCont = false ; + int len = theContainer.length() ; + if ( !strcmp( &theContainer.c_str()[len-2] , "Py" ) ) { + pyCont = true ; + } + if ( !CORBA::is_nil( aContainer ) ) { + return aContainer ; + } + else { + string FactoryServer = theComputer ; + if ( pyCont ) { + FactoryServer += "/FactoryServerPy" ; + } + else { + FactoryServer += "/FactoryServer" ; + } + aFactoryServer = FindContainer( FactoryServer.c_str() ) ; + if ( CORBA::is_nil( aFactoryServer ) ) { +// rsh -n ikkyo /export/home/rahuel/SALOME_ROOT/bin/runSession SALOME_Container -ORBInitRef NameService=corbaname::dm2s0017:1515 & + string rsh( "" ) ; + if ( theComputer!= GetHostname() ) { + rsh += "rsh -n " ; + rsh += theComputer ; + rsh += " " ; + } + string path = ComputerPath( theComputer.c_str() ) ; + SCRUTE( path ) ; + if ( path[0] != '\0' ) { + rsh += path ; + rsh += "/../bin/" ; + } + rsh += "runSession " ; + if ( pyCont ) { + rsh += "SALOME_ContainerPy.py " ; + rsh += "FactoryServerPy -" ; + } + else { + rsh += "SALOME_Container " ; + rsh += "FactoryServer -" ; + } + string omniORBcfg( getenv( "HOME" ) ) ; + omniORBcfg += "/.omniORB.cfg" ; + ifstream omniORBfile( omniORBcfg.c_str() ) ; + char ORBInitRef[12] ; + char nameservice[132] ; + omniORBfile >> ORBInitRef ; + rsh += ORBInitRef ; + rsh += " " ; + omniORBfile >> nameservice ; + omniORBfile.close() ; + char * bsn = strchr( nameservice , '\n' ) ; + if ( bsn ) { + bsn[ 0 ] = '\0' ; + } + rsh += nameservice ; + if ( pyCont ) { + rsh += " > /tmp/FactoryServerPy_" ; + } + else { + rsh += " > /tmp/FactoryServer_" ; + } + rsh += theComputer ; + rsh += ".log 2>&1 &" ; + SCRUTE( rsh ); + int status = system( rsh.c_str() ) ; + if (status == -1) { + INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status -1)") ; + } + else if (status == 217) { + INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed (system command status 217)") ; + } + else { + int count = 21 ; + while ( CORBA::is_nil( aFactoryServer ) && count ) { + sleep( 1 ) ; + count-- ; + if ( count != 10 ) + MESSAGE( count << ". Waiting for FactoryServer on " << theComputer) + aFactoryServer = FindContainer( FactoryServer.c_str() ) ; + } + if ( CORBA::is_nil( aFactoryServer ) ) { + INFOS("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed") ; + } + else if ( strcmp( theComputer.c_str() , GetHostname().c_str() ) ) { + _FactoryServer = aFactoryServer ; + } + } + } + if ( !CORBA::is_nil( aFactoryServer ) ) { + if ( strcmp( theContainer.c_str() , "FactoryServer" ) || + strcmp( theContainer.c_str() , "FactoryServerPy" ) ) { + MESSAGE("Container not found ! trying to start " << aComputerContainer); + Engines::Container_var myContainer = aFactoryServer->start_impl( theContainer.c_str() ) ; + if ( !CORBA::is_nil( myContainer ) ) { + MESSAGE("Container " << aComputerContainer << " started"); + return myContainer ; + } + else { + MESSAGE("Container " << aComputerContainer << " NOT started"); + } + } + else { + MESSAGE("Container " << aComputerContainer << " started"); + return aFactoryServer ; + } + } + } + return Engines::Container::_nil(); +} + +Engines::Component_var SALOME_LifeCycleCORBA::FindOrLoad_Component + (const char *containerName, + const char *componentName, + const char *implementation) +{ + BEGIN_OF("FindOrLoad_Component(1)"); + ASSERT(_NS != NULL); + string theComputer ; + string theContainer ; + string theComputerContainer = ContainerName( containerName , + &theComputer , + &theContainer ) ; + Engines::Container_var cont = FindOrStartContainer( theComputerContainer , + theComputer , + theContainer ) ; +// ASSERT(!CORBA::is_nil(cont)); + + string path( theComputerContainer ); + path = path + "/"; + path = path + componentName; + SCRUTE(path); + try + { + CORBA::Object_var obj = _NS->Resolve(path.c_str()); + if (CORBA::is_nil(obj)) + { + MESSAGE("Component not found ! trying to load " << path); + Engines::Component_var compo + = cont->load_impl(componentName, implementation); +// ASSERT(!CORBA::is_nil(compo)); + MESSAGE("Component launched !" << path); + return compo; + } + else + { + MESSAGE("Component found !" << path); + Engines::Component_var compo = Engines::Component::_narrow(obj); +// ASSERT(!CORBA::is_nil(compo)); + try + { + compo->ping(); + } + catch (CORBA::COMM_FAILURE&) + { + INFOS("Caught CORBA::SystemException CommFailure. Engine " + << path << "does not respond" ); + } + return compo; + } + } + catch (ServiceUnreachable&) + { + INFOS("Caught exception: Naming Service Unreachable"); + } + catch (...) + { + INFOS("Caught unknown exception."); + } + return Engines::Component::_nil(); +} + +Engines::Component_var SALOME_LifeCycleCORBA::FindOrLoad_Component + (const char *containerName, + const char *componentName) +{ +// BEGIN_OF("FindOrLoad_Component(2)"); + ASSERT(_NS != NULL); + string theComputer ; + string theContainer ; + string theComputerContainer = ContainerName( containerName , + &theComputer , + &theContainer ) ; + Engines::Container_var cont = FindOrStartContainer( theComputerContainer , + theComputer , + theContainer ) ; + + if ( CORBA::is_nil( cont ) ) { + MESSAGE("Container not found ! " << theComputerContainer ); + return Engines::Component::_nil(); + } + +// char * machine = cont->machineName() ; + const char * machine = theComputer.c_str() ; + + string path( theComputerContainer ); + path += "/"; + path += componentName; + SCRUTE(path); + + try { + CORBA::Object_var obj = _NS->Resolve(path.c_str()); + if ( CORBA::is_nil( obj ) ) { + MESSAGE("Component not found ! trying to load " << path); + CORBA::Object_var obj2 = _NS->Resolve("/Kernel/ModulCatalog"); + SALOME_ModuleCatalog::ModuleCatalog_var Catalog = + SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj2); + + SALOME_ModuleCatalog::Acomponent_ptr compoInfo = + Catalog->GetComponent(componentName); + if (CORBA::is_nil (compoInfo)) + { + INFOS("Catalog Error : Component not found in the catalog") + return Engines::Component::_nil(); +// exit (-1); + } + + string path; + try + { + path = compoInfo->GetPathPrefix( machine ) ; + path += "/" ; + } + catch (SALOME_ModuleCatalog::NotFound&) + { + MESSAGE("GetPathPrefix(" << machine << ") not found!" + << "trying localhost"); + try { + path = compoInfo->GetPathPrefix("localhost") ; + path += "/" ; + } + catch (SALOME_ModuleCatalog::NotFound&) { + MESSAGE("GetPathPrefix(localhost) not found!") ; + path = "" ; + } + } + + SCRUTE(path); + string implementation(path); + implementation += "lib"; + implementation += componentName; + implementation += "Engine.so"; + + Engines::Component_var compo + = cont->load_impl(componentName, implementation.c_str()); + +// ASSERT(!CORBA::is_nil(compo)); +// MESSAGE("Component launched !" << path); + return compo; + } + else + { + MESSAGE("Component found !" << path); + Engines::Component_var compo = Engines::Component::_narrow(obj); +// ASSERT(!CORBA::is_nil(compo)); + try + { + string instanceName = compo->instanceName(); + } + catch (CORBA::COMM_FAILURE&) + { + INFOS("Caught CORBA::SystemException CommFailure. Engine " + << path << "does not respond" ); + } + return compo; + } + } + catch (ServiceUnreachable&) + { + INFOS("Caught exception: Naming Service Unreachable"); + } + catch (...) + { + INFOS("Caught unknown exception."); + } + return Engines::Component::_nil(); +} diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx new file mode 100644 index 000000000..beeed25b0 --- /dev/null +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -0,0 +1,50 @@ +//============================================================================= +// File : SALOME_LifeCycleCORBA.hxx +// Created : jeu jui 12 14:55:45 CEST 2001 +// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#ifndef _SALOME_LIFECYCLECORBA_HXX_ +#define _SALOME_LIFECYCLECORBA_HXX_ + +#include +#include +#include + +#include +#include CORBA_CLIENT_HEADER(SALOME_Component) + +class SALOME_NamingService; + +class SALOME_LifeCycleCORBA +{ +public: + SALOME_LifeCycleCORBA(); + SALOME_LifeCycleCORBA(SALOME_NamingService *ns); + virtual ~SALOME_LifeCycleCORBA(); + + Engines::Container_var FindContainer(const char *containerName); + Engines::Component_var FindOrLoad_Component(const char *containerName, + const char *componentName, + const char *implementationPath); + Engines::Component_var FindOrLoad_Component(const char *containerName, + const char *componentName); +protected: + SALOME_NamingService *_NS; + Engines::Container_var _FactoryServer ; + +private: + string ContainerName( const char * aComputerContainer , + string * theComputer , + string * theContainer ) ; + string ComputerPath( const char * theComputer ) ; + Engines::Container_var FindOrStartContainer(const string aComputerContainer , + const string theComputer , + const string theContainer ) ; + +} ; + +#endif diff --git a/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx b/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx new file mode 100644 index 000000000..24b614216 --- /dev/null +++ b/src/LifeCycleCORBA/TestLifeCycleCORBA.cxx @@ -0,0 +1,92 @@ +using namespace std; +//============================================================================= +// File : TestLifeCycleCORBA.cxx +// Created : jeu jui 12 13:11:27 CEST 2001 +// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#include "utilities.h" +#include +#include +#include +#include CORBA_CLIENT_HEADER(SALOME_Component) +#include CORBA_CLIENT_HEADER(SALOME_TestComponent) +#include "SALOME_NamingService.hxx" +#include "SALOME_LifeCycleCORBA.hxx" +#include + +int main (int argc, char * argv[]) +{ + + try + { + // Initializing omniORB + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + + // Obtain a reference to the root POA + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ; + PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ; + + SALOME_NamingService _NS(orb) ; + + SALOME_LifeCycleCORBA _LCC(&_NS) ; + + // get a local container (with a name based on local hostname), + // load an engine, and invoque methods on that engine + + string containerName = GetHostname(); + + Engines::Component_var mycompo = + _LCC.FindOrLoad_Component(containerName.c_str(),"SalomeTestComponent"); + + ASSERT(!CORBA::is_nil(mycompo)); + + Engines::TestComponent_var m1; + m1 = Engines::TestComponent::_narrow(mycompo); + + ASSERT(!CORBA::is_nil(m1)); + + SCRUTE(m1->instanceName()); + MESSAGE("Coucou " << m1->Coucou(1L)); + + // get another container (with a fixed name), + // load an engine, and invoque methods on that engine + + string containerName2 = "FactoryServerPy"; + + Engines::Component_var mycompo2 = + _LCC.FindOrLoad_Component(containerName2.c_str(),"SALOME_TestComponentPy"); + + ASSERT(!CORBA::is_nil(mycompo2)); + + Engines::TestComponent_var m2; + m2 = Engines::TestComponent::_narrow(mycompo2); + + ASSERT(!CORBA::is_nil(m2)); + + SCRUTE(m2->instanceName()); + MESSAGE("Coucou " << m2->Coucou(1L)); + } + 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::Exception&) + { + INFOS("Caught CORBA::Exception."); + } + catch(...) + { + INFOS("Caught unknown exception."); + } + + return 0; +} + diff --git a/src/Logger/Makefile.in b/src/Logger/Makefile.in new file mode 100644 index 000000000..9d7e48553 --- /dev/null +++ b/src/Logger/Makefile.in @@ -0,0 +1,39 @@ +#============================================================================== +# File : Makefile.in +# Created : mar jui 3 12:59:20 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= \ + SALOME_Trace.hxx + +# Libraries targets +LIB = libSalomeLoggerServer.la +LIB_SRC=\ + SALOME_Trace.cxx \ + SALOME_Logger_Server.cxx +LIB_SERVER_IDL = Logger.idl + +EXPORT_PYSCRIPTS = SALOME_Trace.py + +# Executables targets +BIN = SALOME_Logger_Server +BIN_SRC = +BIN_SERVER_IDL = Logger.idl +BIN_CLIENT_IDL = Logger.idl + +@CONCLUDE@ + diff --git a/src/Logger/SALOME_Logger_Server.cxx b/src/Logger/SALOME_Logger_Server.cxx new file mode 100644 index 000000000..3f5cc1152 --- /dev/null +++ b/src/Logger/SALOME_Logger_Server.cxx @@ -0,0 +1,128 @@ +using namespace std; +//============================================================================= +// File : SALOME_Logger_Server.cxx +// Created : nov 18 10:28:17 2002 +// Author : Vasily Rusyaev +// Project : SALOME/PRO +//============================================================================= + +// SALOME_Logger_Server.cxx: implementation of the SALOME_Logger_Server class. +// +////////////////////////////////////////////////////////////////////// + +#include +#include "SALOME_Logger_Server.hxx" + +omni_mutex Logger::myLock; + +///////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +Logger::Logger() +{ + m_putIntoFile = false; +} + +Logger::Logger(const char *filename) +{ + // m_outputFile.open( filename, ios::out | ios::trunc , filebuf::openprot); + m_outputFile.open( filename, ios::out | ios::trunc); + if (m_outputFile.is_open()) + m_putIntoFile = true; + else + m_putIntoFile = false; +} + +Logger::~Logger() +{ + if (m_putIntoFile) + m_outputFile.close(); +} + +void Logger::putMessage(const char* message) +{ + myLock.lock(); + if (m_putIntoFile) + m_outputFile << message << flush; + else + cout << message; + myLock.unlock(); +} + +int main(int argc, char **argv) +{ + if (argc > 2) + { + cout << "usage: SALOME_Logger_Server [output_file]" << endl; + exit(1); + } + try + { + //Initialize the ORB + CORBA::ORB_var orb = CORBA::ORB_init(argc,argv) ; + + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ; + PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ; + + // NB. You can activate the POA before or after + // activating objects in that POA. + PortableServer::POAManager_var pman = poa->the_POAManager(); + pman->activate(); + + Logger* myLogger; + if (argc == 1) + myLogger = new Logger(); + else + myLogger = new Logger(argv[1]); + + + // This activates the object in the root POA (by default), and + // returns a reference to it. + SALOME_Logger::Logger_var myLoggerRef = myLogger->_this(); + + //NB. You can't use SALOME_NamingService class because it uses MESSAGE macro + //Otherwise, you will get segmentation fault. + + //Get initial naming context + CORBA::Object_var theObj = orb->resolve_initial_references("NameService"); + //Narrow to NamingContext + CosNaming::NamingContext_var inc = CosNaming::NamingContext::_narrow(theObj); + + CosNaming::Name name; + name.length(1); + name[0].id = CORBA::string_dup("Logger"); + + inc->bind(name,myLoggerRef); + + myLogger->_remove_ref(); + + orb->run() ; + + orb->destroy() ; + } + catch(CORBA::COMM_FAILURE& ex) + { + cerr << "Caught system exception COMM_FAILURE -- unable to contact the " + << "object." << endl; + } + catch(CORBA::SystemException&) + { + cerr << "Caught CORBA::SystemException." << endl; + } + catch(CORBA::Exception&) + { + cerr << "Caught CORBA::Exception." << endl; + } + catch(omniORB::fatalException& fe) + { + cerr << "Caught omniORB::fatalException:" << endl; + cerr << " file: " << fe.file() << endl; + cerr << " line: " << fe.line() << endl; + cerr << " mesg: " << fe.errmsg() << endl; + } + catch(...) + { + cerr << "Caught unknown exception." << endl; + } +} diff --git a/src/Logger/SALOME_Logger_Server.hxx b/src/Logger/SALOME_Logger_Server.hxx new file mode 100644 index 000000000..08f33cff0 --- /dev/null +++ b/src/Logger/SALOME_Logger_Server.hxx @@ -0,0 +1,43 @@ +//============================================================================= +// File : SALOME_Logger_Server.hxx +// Created : nov 18 10:28:17 2002 +// Author : Vasily Rusyaev +// Project : SALOME/PRO +//============================================================================= + +// SALOME_Logger_Server.hxx: interface for the SALOME_Logger_Server class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined SALOME_Logger_Server_include +#define SALOME_Logger_Server_include + +#include +#include +#include "Logger.hh" + +class Logger : + public POA_SALOME_Logger::Logger, + public PortableServer::RefCountServantBase +{ +public: + //constructor w/o parameters + //all messages will be put into terminal via cout + Logger(); + //constructor with parameter, filename is output file + //all messages will be put into special file passed as parameter + Logger(const char *filename); + virtual ~Logger(); + //put message into one special place for all servers + void putMessage(const char* message); +private: + //if m_putIntoFile is true all messages will be put into special + //otherwise all messages will be put into terminal via cout + bool m_putIntoFile; + //ofstream class specialized for disk file output + ofstream m_outputFile; + //synchronisation object + static omni_mutex myLock; +}; + +#endif // !defined(SALOME_Logger_Server_include) diff --git a/src/Logger/SALOME_Trace.cxx b/src/Logger/SALOME_Trace.cxx new file mode 100644 index 000000000..f07b9e578 --- /dev/null +++ b/src/Logger/SALOME_Trace.cxx @@ -0,0 +1,106 @@ +using namespace std; +//============================================================================= +// File : SALOME_Logger.cxx +// Created : nov 18 10:28:17 2002 +// Author : Vasily Rusyaev +// Project : SALOME/PRO +//============================================================================= + +// SALOME_Trace.cxx: implementation of the SALOME_Logger class. +// +////////////////////////////////////////////////////////////////////// + +#include "SALOME_Trace.hxx" +#include +#include +//#include +#include +#include + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +SALOME_Trace::SALOME_Trace() +{ + //get reference on object reference from NS + //and initialize m_pInterfaceLogger + + int argc = 1; + char* argv[1] = {"application"}; + try + { + //NB. You can't use SALOME_NamingService class because it uses MESSAGE macro + //Otherwise, you will get segmentation fault. + + //Initialize the ORB + CORBA::ORB_var orb = CORBA::ORB_init(argc,argv) ; + //Get initial naming context + CORBA::Object_var theObj = orb->resolve_initial_references("NameService"); + //Narrow to NamingContext + CosNaming::NamingContext_var inc = CosNaming::NamingContext::_narrow(theObj); + + CosNaming::Name name; + name.length(1); + name[0].id = CORBA::string_dup("Logger"); + + CORBA::Object_var obj; + obj = inc->resolve(name); + + m_pInterfaceLogger = SALOME_Logger::Logger::_narrow(obj) ; + + } + catch (const CosNaming::NamingContext::NotFound&) + { +// cout << "Caught exception: Naming Service can't found Logger"; + } + catch (CORBA::COMM_FAILURE&) + { +// cout << "Caught CORBA::SystemException CommFailure."; + } + catch (CORBA::SystemException&) + { +// cout << "Caught CORBA::SystemException."; + } + catch (CORBA::Exception&) + { +// cout << "Caught CORBA::Exception."; + } + catch (...) + { +// cout << "Caught unknown exception."; + } + //cerr << "-----SALOME_Trace::SALOME_Trace----"<freeze(false); + //rdbuf()->sync(); // problem with gcc3.2 + seekp(0); + + if (CORBA::is_nil(m_pInterfaceLogger)) + cout << LogMsg; + else + m_pInterfaceLogger-> putMessage (LogMsg) ; +} + diff --git a/src/Logger/SALOME_Trace.hxx b/src/Logger/SALOME_Trace.hxx new file mode 100644 index 000000000..0ba300e68 --- /dev/null +++ b/src/Logger/SALOME_Trace.hxx @@ -0,0 +1,63 @@ +//============================================================================= +// File : SALOME_Trace.cxx +// Created : nov 18 10:28:17 2002 +// Author : Vasily Rusyaev +// Project : SALOME/PRO +//============================================================================= + +// SALOME_Trace.hxx: interface for the SALOME_Trace class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_LOGGER_H__96F2A3AB_F6F8_11D6_BFA6_000476A0958C__INCLUDED_) +#define AFX_LOGGER_H__96F2A3AB_F6F8_11D6_BFA6_000476A0958C__INCLUDED_ + +//these declarations for files don't using OCC includes (for example HDF) +# ifdef WNT + +# ifndef Standard_EXPORT +# define Standard_EXPORT __declspec( dllexport ) +// For global variables : +# define Standard_EXPORTEXTERN __declspec( dllexport ) extern +# define Standard_EXPORTEXTERNC extern "C" __declspec( dllexport ) +# endif /* Standard_EXPORT */ + +# ifndef Standard_IMPORT +# define Standard_IMPORT __declspec( dllimport ) extern +# define Standard_IMPORTC extern "C" __declspec( dllimport ) +# endif /* Standard_IMPORT */ + +# else /* WNT */ + +# ifndef Standard_EXPORT +# define Standard_EXPORT +// For global variables : +# define Standard_EXPORTEXTERN extern +# define Standard_EXPORTEXTERNC extern "C" +# endif /* Standard_EXPORT */ + +# ifndef Standard_IMPORT +# define Standard_IMPORT extern +# define Standard_IMPORTC extern "C" +# endif /* Standard_IMPORT */ + +# endif /* WNT */ + +#include +#include "Logger.hh" + +class SALOME_Trace : public ostrstream +{ +public: + virtual ~SALOME_Trace(); + static Standard_EXPORT SALOME_Trace& Instance(); + Standard_EXPORT void putMessage(ostream& msg); +protected: + //disable creation of instances. It's necessary to use static SALOME_Logger& Instance() + SALOME_Trace(); + SALOME_Logger::Logger_var m_pInterfaceLogger;// object reference on Logger server. +}; + +#define GLogger SALOME_Trace::Instance() + +#endif // !defined(AFX_LOGGER_H__96F2A3AB_F6F8_11D6_BFA6_000476A0958C__INCLUDED_) diff --git a/src/Logger/SALOME_Trace.py b/src/Logger/SALOME_Trace.py new file mode 100644 index 000000000..9bc870744 --- /dev/null +++ b/src/Logger/SALOME_Trace.py @@ -0,0 +1,36 @@ +import sys +import CosNaming +from omniORB import CORBA +import SALOME_Logger + +class SALOME_Trace : + def __init__(self): + self.m_pInterfaceLogger = None + try: + orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) + theObj = orb.resolve_initial_references("NameService") + inc = theObj._narrow(CosNaming.NamingContext) + name = [CosNaming.NameComponent("Logger","")] + obj = inc.resolve(name); + + self.m_pInterfaceLogger = obj._narrow(SALOME_Logger.Logger) + + except CosNaming.NamingContext.NotFound, e : + print "Caught exception: Naming Service can't found Logger" + except CORBA.COMM_FAILURE, e: + print "Caught CORBA::SystemException CommFailure" + except CORBA.SystemException, e: + print "Caught CORBA::SystemException." + except CORBA.Exception, e: + print "Caught CORBA::Exception." + except Exception, e: + print "Caught unknown exception." + + + def putMessage ( self, LogMsg ) : + + if (CORBA.is_nil(self.m_pInterfaceLogger)): + print LogMsg; + else: + self.m_pInterfaceLogger.putMessage (LogMsg) + diff --git a/src/MPIContainer/MPIContainer_i.cxx b/src/MPIContainer/MPIContainer_i.cxx new file mode 100644 index 000000000..17c0d12e7 --- /dev/null +++ b/src/MPIContainer/MPIContainer_i.cxx @@ -0,0 +1,192 @@ +using namespace std; +#include +#include +#include +#include "MPIContainer_i.hxx" +#include "utilities.h" + +MPIContainer_i::MPIContainer_i(int nbproc, int numproc, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + char * containerName) + : Engines_Container_i(orb,poa,containerName,0), MPIObject_i(nbproc,numproc) +{ + _id = _poa->activate_object(this); + + MESSAGE("[" << _numproc << "] containerName=" << _containerName); + if( _numproc == 0 ){ + _NS = SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + _NS->init_orb( orb ) ; + + Engines::Container_ptr pCont + = Engines::Container::_narrow(POA_Engines::MPIContainer::_this()); + _NS->Register(pCont, _containerName.c_str()); + } + + // Root recupere les ior des container des autre process + Engines::MPIObject_var pobj = POA_Engines::MPIContainer::_this(); + BCastIOR(_orb,pobj,true); +} + +MPIContainer_i::~MPIContainer_i(void) +{ + if( !handle_map.empty() ){ + MESSAGE("[" << _numproc << "] MPIContainer_i::~MPIContainer_i: warning destroy a not empty container"); + } +} + +// Load component +Engines::Component_ptr MPIContainer_i::load_impl(const char* nameToRegister, + const char* componentName) +{ + int ip; + Engines::Component_var iobject; + Engines::MPIObject_var pobj; + char cproc[4]; + + if( _numproc == 0 ){ + // Invocation du chargement du composant dans les autres process + for(ip= 1;ip<_nbproc;ip++) + (Engines::MPIContainer::_narrow((*_tior)[ip]))->load_impl(nameToRegister, + componentName); + } + + sprintf(cproc,"_%d",_numproc); + + BEGIN_OF("[" << _numproc << "] MPIContainer_i::load_impl"); + + _numInstanceMutex.lock() ; // lock on the instance number + _numInstance++ ; + char _aNumI[12]; + sprintf(_aNumI,"%d",_numInstance) ; + _numInstanceMutex.unlock() ; + + string _impl_name = componentName; + string instanceName = string(nameToRegister) + "_inst_" + _aNumI + cproc; + + string absolute_impl_name(_impl_name); + MESSAGE("[" << _numproc << "] absolute_impl_name=" << absolute_impl_name); + void * handle = dlopen(absolute_impl_name.c_str(), RTLD_LAZY); + if(!handle){ + INFOS("[" << _numproc << "] Can't load shared library : " << absolute_impl_name); + INFOS("[" << _numproc << "] error dlopen: " << dlerror()); + return Engines::Component::_nil() ; + } + + string factory_name = string(nameToRegister) + string("Engine_factory"); + MESSAGE("[" << _numproc << "] factory_name=" << factory_name) ; + + PortableServer::ObjectId * (*MPIComponent_factory) (int,int, + CORBA::ORB_ptr, + PortableServer::POA_ptr, + PortableServer::ObjectId *, + const char *, + const char *) = + (PortableServer::ObjectId * (*) (int,int, + CORBA::ORB_ptr, + PortableServer::POA_ptr, + PortableServer::ObjectId *, + const char *, + const char *)) + dlsym(handle, factory_name.c_str()); + + char *error ; + if ((error = dlerror()) != NULL){ + // Try to load a sequential component + MESSAGE("[" << _numproc << "] Try to load a sequential component"); + iobject = Engines_Container_i::load_impl(nameToRegister,componentName); + if( CORBA::is_nil(iobject) ) return Engines::Component::_duplicate(iobject); + } + else{ + // Instanciation du composant parallele + MESSAGE("[" << _numproc << "] Try to load a parallel component"); + PortableServer::ObjectId * id = (MPIComponent_factory) + (_nbproc,_numproc,_orb, _poa, _id, instanceName.c_str(), nameToRegister); + // get reference from id + CORBA::Object_var o = _poa->id_to_reference(*id); + pobj = Engines::MPIObject::_narrow(o) ; + iobject = Engines::Component::_narrow(pobj) ; + } + + // Root recupere les ior des composants des autre process + BCastIOR(_orb,pobj,false); + + if( _numproc == 0 ){ + // utiliser + tard le registry ici : + // register the engine under the name containerName.dir/nameToRegister.object + string component_registerName = _containerName + "/" + nameToRegister; + _NS->Register(iobject, component_registerName.c_str()) ; + } + + _numInstanceMutex.lock() ; // lock on the add on handle_map (necessary ?) + handle_map[instanceName] = handle; + _numInstanceMutex.unlock() ; + END_OF("[" <<_numproc << "] MPIContainer_i::load_impl"); + return Engines::Component::_duplicate(iobject); + +} + +void MPIContainer_i::remove_impl(Engines::Component_ptr component_i) +{ + int ip; + Engines::Component_ptr cptr; + Engines::MPIObject_ptr pcptr; + Engines::MPIObject_ptr spcptr; + + ASSERT(! CORBA::is_nil(component_i)); + + if( _numproc == 0 ){ + // Invocation de la destruction du composant dans les autres process + pcptr = (Engines::MPIObject_ptr)component_i; + for(ip= 1;ip<_nbproc;ip++){ + spcptr = Engines::MPIObject::_narrow((*(pcptr->tior()))[ip]); + cptr = (Engines::Component_ptr)spcptr; + (Engines::MPIContainer::_narrow((*_tior)[ip]))->remove_impl(cptr); + } + } + + string instanceName = component_i->instanceName() ; + MESSAGE("[" << _numproc << "] unload component " << instanceName); + component_i->destroy() ; + MESSAGE("[" << _numproc << "] test key handle_map"); + _numInstanceMutex.lock() ; // lock on the remove on handle_map + if (handle_map[instanceName]) // if key does not exist, created & initialized null + { + remove_map[instanceName] = handle_map[instanceName] ; + } + else MESSAGE("[" << _numproc << "] no key handle_map"); + handle_map.erase(instanceName) ; + _numInstanceMutex.unlock() ; + MESSAGE("[" << _numproc << "] list handle_map"); + map::iterator im ; + for (im = handle_map.begin() ; im != handle_map.end() ; im ++) + { + MESSAGE("[" << _numproc << "] stay " << (*im).first); + } +} + +void MPIContainer_i::finalize_removal() +{ + int ip; + + MESSAGE("[" << _numproc << "] finalize unload : dlclose"); + + if( _numproc == 0 ){ + // Invocation de la destruction du composant dans les autres process + for(ip= 1;ip<_nbproc;ip++) + (Engines::MPIContainer::_narrow((*_tior)[ip]))->finalize_removal(); + } + + map::iterator im ; + _numInstanceMutex.lock() ; // lock on the explore remove_map & dlclose + for (im = remove_map.begin() ; im != remove_map.end() ; im ++) + { + void * handle = (*im).second ; + dlclose(handle) ; + MESSAGE("[" << _numproc << "] dlclose " << (*im).first); + } + remove_map.clear() ; + _numInstanceMutex.unlock() ; + MESSAGE("[" << _numproc << "] remove_map.clear()"); +} diff --git a/src/MPIContainer/MPIContainer_i.hxx b/src/MPIContainer/MPIContainer_i.hxx new file mode 100644 index 000000000..b5430134d --- /dev/null +++ b/src/MPIContainer/MPIContainer_i.hxx @@ -0,0 +1,35 @@ +#ifndef _SALOME_PCONTAINER_ +#define _SALOME_PCONTAINER_ + +#include +#include CORBA_SERVER_HEADER(MPIContainer) +#include "SALOME_Container_i.hxx" +#include "SALOME_NamingService.hxx" +#include "Utils_SINGLETON.hxx" +#include "OpUtil.hxx" +#include "MPIObject_i.hxx" + +class MPIContainer_i : public POA_Engines::MPIContainer, + public Engines_Container_i, + public MPIObject_i +{ + + public: + // Constructor + MPIContainer_i( int nbproc, int numproc, + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + char * containerName); + // Destructor + ~MPIContainer_i(); + + // Load a component + Engines::Component_ptr load_impl(const char* nameToRegister, + const char* componentName); + + // Unload a component + void remove_impl(Engines::Component_ptr component_i); + void finalize_removal(); + +}; +#endif diff --git a/src/MPIContainer/MPIObject_i.cxx b/src/MPIContainer/MPIObject_i.cxx new file mode 100644 index 000000000..431b5142a --- /dev/null +++ b/src/MPIContainer/MPIObject_i.cxx @@ -0,0 +1,100 @@ +using namespace std; +#include "MPIObject_i.hxx" +#include "utilities.h" +#include + +MPIObject_i::MPIObject_i() +{ + _nbproc = 1; + _numproc = 0; + _tior=NULL; +} + +MPIObject_i::MPIObject_i(int nbproc, int numproc) +{ + _nbproc = nbproc; + _numproc = numproc; + _tior=NULL; +} + +MPIObject_i::~MPIObject_i() +{ + if(_tior) delete _tior; +} + +Engines::IORTab* MPIObject_i::tior() +{ + Engines::IORTab* tior = new Engines::IORTab; + tior->length(_tior->length()); + for(unsigned int ip=0;iplength();ip++) + (*tior)[ip] = (*_tior)[ip]; + return tior; +}; + +void MPIObject_i::tior(const Engines::IORTab& ior) +{ + _tior = new Engines::IORTab; + _tior->length(ior.length()); + for(unsigned int ip=0;ipobject_to_string(pobj)); + + if( _numproc == 0 ){ + + //Allocation du tableau des IOR + Engines::IORTab *iort = new Engines::IORTab; + iort->length(_nbproc); + + (*iort)[0] = pobj; + + // Process 0 recupere les ior de l'object sur les autres process + for(ip=1;ip<_nbproc;ip++){ + err = MPI_Recv(&n,1,MPI_INTEGER,ip,ip,MPI_COMM_WORLD,&status); + if(err){ + MESSAGE("[" << _numproc << "] MPI_RECV error"); + exit(1); + } + // Allocation de la chaine de longueur n + ior = (char*)calloc(n,sizeof(char)); + err = MPI_Recv(ior,n,MPI_CHARACTER,ip,2*ip,MPI_COMM_WORLD,&status); + if(err){ + MESSAGE("[" << _numproc << "] MPI_RECV error"); + exit(1); + } + (*iort)[ip] = Engines::MPIObject::_narrow(orb->string_to_object(ior)); + free(ior); + } + // On donne le tableau des ior a l'objet Corba du process 0 + if( amiCont ) + tior(*iort); + else + pobj->tior(*iort); + + } + else{ + // On envoie l'IOR au process 0 + n = strlen((char*)sior); + err = MPI_Send(&n,1,MPI_INTEGER,0,_numproc,MPI_COMM_WORLD); + if(err){ + MESSAGE("[" << _numproc << "] MPI_SEND error"); + exit(1); + } + err = MPI_Send((char*)sior,n,MPI_CHARACTER,0,2*_numproc,MPI_COMM_WORLD); + if(err){ + MESSAGE("[" << _numproc << "] MPI_SEND error"); + exit(1); + } + } + +} + diff --git a/src/MPIContainer/MPIObject_i.hxx b/src/MPIContainer/MPIObject_i.hxx new file mode 100644 index 000000000..fb59d9e8c --- /dev/null +++ b/src/MPIContainer/MPIObject_i.hxx @@ -0,0 +1,28 @@ +#ifndef _SALOME_POBJECT_I_H_ +#define _SALOME_POBJECT_I_H_ + +#include +#include CORBA_SERVER_HEADER(MPIObject) + +class MPIObject_i: public POA_Engines::MPIObject +{ + public: + MPIObject_i(); + MPIObject_i(int nbproc, int numproc); + ~MPIObject_i(); + + Engines::IORTab* tior(); + void tior(const Engines::IORTab& ior); + + protected: + // Numero du processus + int _numproc; + // Nombre de processus + int _nbproc; + // IOR des objets paralleles sur tous les process mpi + Engines::IORTab* _tior; + // Echange des IOR de l'objet entre process + void BCastIOR(CORBA::ORB_ptr orb,Engines::MPIObject_var pobj,bool amiCont); +} ; + +#endif diff --git a/src/MPIContainer/Makefile.in b/src/MPIContainer/Makefile.in new file mode 100644 index 000000000..66034c694 --- /dev/null +++ b/src/MPIContainer/Makefile.in @@ -0,0 +1,40 @@ +#============================================================================== +# File : Makefile.in +# Created : mar jui 3 12:58:13 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_PYSCRIPTS = + +EXPORT_HEADERS = \ + MPIObject_i.hxx \ + MPIContainer_i.hxx + +# Libraries targets + +LIB = libSalomeMPIContainer.la +LIB_SRC = MPIObject_i.cxx MPIContainer_i.cxx +LIB_SERVER_IDL = TypeData.idl MPIObject.idl MPIContainer.idl + +# Executables targets +BIN = SALOME_MPIContainer +BIN_SRC = +BIN_SERVER_IDL = TypeData.idl MPIObject.idl MPIContainer.idl + +CXXFLAGS+=${MPICH_INCLUDES} +CXX_DEPEND_FLAG+=${MPICH_INCLUDES} +LDFLAGS+= -lSalomeContainer -lSalomeNS -lRegistry -lOpUtil ${MPICH_LIBS} + +@CONCLUDE@ diff --git a/src/MPIContainer/SALOME_MPIContainer.cxx b/src/MPIContainer/SALOME_MPIContainer.cxx new file mode 100644 index 000000000..518849e26 --- /dev/null +++ b/src/MPIContainer/SALOME_MPIContainer.cxx @@ -0,0 +1,94 @@ +using namespace std; +#include +#include "MPIContainer_i.hxx" +#include "utilities.h" +#include + +int main(int argc, char* argv[]) +{ + int nbproc, numproc; + MPIContainer_i * myContainer; + + BEGIN_OF(argv[0]) + try { + + MESSAGE("Connection MPI"); + + MPI_Init(&argc,&argv); + MPI_Comm_size(MPI_COMM_WORLD,&nbproc); + MPI_Comm_rank(MPI_COMM_WORLD,&numproc); + + MESSAGE("Initialisation CORBA"); + // Initialise the ORB. + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + + // Obtain a reference to the root POA. + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); + + // obtain the root poa manager + PortableServer::POAManager_var pman = root_poa->the_POAManager(); + + // 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] ; + } + + MESSAGE("Chargement container sur proc: " << numproc); + myContainer = new MPIContainer_i(nbproc,numproc,orb,factory_poa, containerName); + MESSAGE("Fin chargement container"); + + pman->activate(); + + orb->run(); + orb->destroy(); + + delete myContainer; + MPI_Finalize(); + } + 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.") + } + END_OF(argv[0]); +} + diff --git a/src/MSG2QM/Makefile.in b/src/MSG2QM/Makefile.in new file mode 100644 index 000000000..07bf2ed64 --- /dev/null +++ b/src/MSG2QM/Makefile.in @@ -0,0 +1,17 @@ +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + +@COMMENCE@ + +# Executables targets +BIN = msg2qm +BIN_SRC = + +CPPFLAGS+=$(QT_INCLUDES) $(OGL_INCLUDES) +LDFLAGS+=$(QT_MT_LIBS) $(OGL_LIBS) + + +@CONCLUDE@ diff --git a/src/MSG2QM/msg2qm.cxx b/src/MSG2QM/msg2qm.cxx new file mode 100644 index 000000000..e36cd1cdf --- /dev/null +++ b/src/MSG2QM/msg2qm.cxx @@ -0,0 +1,212 @@ +using namespace std; +/**************************************************************************** +** $Id$ +** +** This is a utility program for converting findtr msgfiles to +** qtranslator message files +** +** +** Copyright (C) 1998 by Trolltech AS. All rights reserved. +** +*****************************************************************************/ +#include +#include +#include +#include + +#include +#include + +static QString* defaultScope = 0; + +bool hasHandle( const QString& line, const QString& handle) +{ + return line.left(handle.length()) == handle; +} + + +QString extractContents( const QString& line ) +{ + QString contents; + if ( line.contains('\"') < 2) + return contents; + int pos = 0; + while ( pos < int(line.length()) && line[pos] != '\"' ) + pos++; + pos++; + while ( pos < int(line.length()) && line[pos] != '\"' ) { + if ( line[pos] == '\\') { + pos++; + switch (char(line[pos]) ) { + case 'n': + contents += '\n'; + break; + case 't': + contents += '\t'; + break; + case 'r': + contents += '\r'; + break; + case 'a': + contents += '\a'; + break; + case 'f': + contents += '\f'; + break; + case 'v': + contents += '\v'; + break; + case 'b': + contents += '\b'; + break; + default: + contents += char(line[pos]); + break; + } + } + else + contents += line[pos]; + pos++; + } + return contents; +} + + +void addTranslation( QTranslator* translator, const QString& msgid, const QString& msgstr) +{ + if (!msgid.isNull() && !msgstr.isNull() ) { + QString scope = ""; + QString id = msgid; + int coloncolon = msgid.find("::"); + if (coloncolon != -1) { + scope = msgid.left( coloncolon ); + id = msgid.right( msgid.length() - scope.length() - 2 ); + } + else if (defaultScope) + scope = *defaultScope; + + if (translator->contains( scope.ascii(), id.ascii() ) ) { + qWarning("Error: \"%s\" already in use", msgid.ascii() ); + } + else { + translator->insert( scope.latin1(), id.latin1(), msgstr ); + } + } +} + + + +void translate( const QString& filename, const QString& qmfile ) +{ + QFile f(filename); + if ( !f.open( IO_ReadOnly) ) + return; + QTranslator* translator = new QTranslator(0); + QTextCodec *codec = 0; + for (int pass = 0; pass < 2; pass++) { + f.at(0); + QTextStream t( &f ); + QString line; + QString msgid; + QString msgstr; + if ( codec != 0 ) { + t.setCodec( codec ); + } + while ( !t.atEnd() || !line.isEmpty() ) { + if (line.isEmpty()) { + t.skipWhiteSpace(); + line = t.readLine(); + } + if ( hasHandle( line, "msgid") ) { + msgstr = QString::null; + msgid = extractContents( line ); + if (!t.atEnd()) { + t.skipWhiteSpace(); + line = t.readLine(); + } + else + line = QString::null; + while ( hasHandle( line, "\"") ) { + msgid += extractContents( line ); + if (!t.atEnd()) { + t.skipWhiteSpace(); + line = t.readLine(); + } + else + line = QString::null; + } + } + else if ( hasHandle( line, "msgstr") ) { + msgstr = extractContents( line ); + if (!t.atEnd()) { + t.skipWhiteSpace(); + line = t.readLine(); + } + else + line = QString::null; + while ( hasHandle( line, "\"") ) { + msgstr += extractContents( line ); + if (!t.atEnd()) { + t.skipWhiteSpace(); + line = t.readLine(); + } + else + line = QString::null; + } + if ( pass == 1 ) + addTranslation( translator, msgid, msgstr); + + if ( pass == 0 && msgid.isEmpty() ) { + // Check for the encoding. + int cpos = msgstr.find( "charset=" ); + if ( cpos >= 0 ) { + cpos = cpos + 8; //skip "charset=" + int i = cpos; + int len = msgstr.length(); + while ( i < len && !msgstr[i].isSpace() ) + i++; + QString charset = msgstr.mid( cpos, i-cpos ); + codec = QTextCodec::codecForName( charset.ascii() ); + if ( codec ) { + debug( "PO file character set: %s. Codec: %s", + charset.ascii(), codec->name() ); + } else { + debug( "No codec for %s", charset.ascii() ); + } + } + break; + } + } + else + line = QString::null; + } + } + f.close(); + translator->save( qmfile ); +} + + +// workaround for BCC problem, qtranslator.h includes qwindowdefs.h via qobject.h, see NEEDS_QMAIN +#if defined(main) +#undef main +#endif + +int main( int argc, char* argv[] ) +{ + + int infile = 1; + if (argc > 1) { + if ( QString("-scope") == argv[1] ) { + defaultScope = new QString(argv[2]); + infile += 2; + } + } + + if ( argc <= infile ) { + printf("usage: %s [-scope default] infile [outfile]\n", argv[0]); + exit(1); + } + + translate(argv[infile], argc > infile+1 ? argv[infile+1] : "tr.qm"); + return 0; +} diff --git a/src/Makefile.in b/src/Makefile.in new file mode 100644 index 000000000..db35cc85f --- /dev/null +++ b/src/Makefile.in @@ -0,0 +1,27 @@ +# -* Makefile *- +# +# Author : Patrick GOLDBRONN (CEA) +# Date : 28/06/2001 +# $Header$ +# + +# source path +top_srcdir=@top_srcdir@ +top_builddir=.. +srcdir=@srcdir@ +VPATH=.:@srcdir@ + + +@COMMENCE@ + +SUBDIRS = MSG2QM Logger Utils PatchQt NamingService Registry ModuleCatalog DataTypeCatalog \ + RessourcesCatalog Notification NOTIFICATION_SWIG Container TestContainer LifeCycleCORBA \ + HDFPersist OBJECT SALOMEDS SALOMEGUI Plot2d VTKViewer OCCViewer SUPERVGraph Session \ + SALOME_SWIG TOOLSGUI SALOME_PY RegistryDisplay ModuleGenerator \ + SALOME_PYQT + +ifeq (@WITHMPICH@,yes) + SUBDIRS+= MPIContainer +endif + +@MODULE@ diff --git a/src/ModuleCatalog/Makefile.in b/src/ModuleCatalog/Makefile.in new file mode 100644 index 000000000..c45684e34 --- /dev/null +++ b/src/ModuleCatalog/Makefile.in @@ -0,0 +1,44 @@ +#============================================================================== +# File : Makefile.in +# Created : mer jui 11 06:50:44 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_HEADERS = \ + SALOME_ModuleCatalog_impl.hxx \ + SALOME_ModuleCatalog_Acomponent_impl.hxx \ + PathPrefix.hxx \ + SALOME_ModuleCatalog_Parser.hxx \ + SALOME_ModuleCatalog_Handler.hxx + +# Libraries targets +LIB = libSalomeCatalog.la +LIB_SRC = \ + SALOME_ModuleCatalog_Handler.cxx \ + SALOME_ModuleCatalog_impl.cxx \ + SALOME_ModuleCatalog_Acomponent_impl.cxx + +# Executables targets +# trouble we have client and serveur and build don't known about this with rule +# in fact client is a test ! So it may go away BIN ! +BIN = SALOME_ModuleCatalog_Server SALOME_ModuleCatalog_Client +BIN_SRC = +BIN_SERVER_IDL = SALOME_ModuleCatalog.idl + +CPPFLAGS+= $(QT_MT_INCLUDES) +CXXFLAGS+= -ftemplate-depth-42 +LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSalomeLoggerServer + +@CONCLUDE@ diff --git a/src/ModuleCatalog/PathPrefix.hxx b/src/ModuleCatalog/PathPrefix.hxx new file mode 100644 index 000000000..d2ed608d3 --- /dev/null +++ b/src/ModuleCatalog/PathPrefix.hxx @@ -0,0 +1,22 @@ +// File: PathPrefix.hxx +// Created: Thu Jul 05 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + +#ifndef PATH_PREFIX_H +#define PATH_PREFIX_H + +#include +#include + +struct PathPrefix +{ + string path ; + vector ListOfComputer ; +} ; + +typedef vector ListOfPathPrefix ; + +#endif // PATH_PREFIX_H diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx new file mode 100644 index 000000000..8ba33793a --- /dev/null +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx @@ -0,0 +1,437 @@ +using namespace std; +// File: SALOME_ModuleCatalog_Acomponent_impl.cxx +// Created: Tue June 28 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + + +#include "SALOME_ModuleCatalog_Acomponent_impl.hxx" + +//---------------------------------------------------------------------- +// Function : SALOME_ModuleCatalog_AcomponentImpl +// Purpose : Constructor +// Affect the component name, type,icone, a bool to define +// if it's multistudy or not. +// Affect too the constraint and the interfaces of the component +// and the pathes prefixes for all computers +//---------------------------------------------------------------------- +SALOME_ModuleCatalog_AcomponentImpl::SALOME_ModuleCatalog_AcomponentImpl( + const char* name, + const char* constraint, + SALOME_ModuleCatalog::ComponentType componenttype, + CORBA::Boolean componentmultistudy, + const char* icone, + SALOME_ModuleCatalog::ListOfDefInterface list_interfaces, + ListOfPathPrefix pathes) +{ + MESSAGE("Component creation") + // Affect component name + _component_name = new char[strlen(name)+1]; + strcpy(_component_name, name); + + // Affect constraint + _constraint =new char[strlen(constraint)+1]; + strcpy(_constraint, constraint); + + // Affect component type + _componenttype = componenttype; + + // Affect component multistudy + _componentmultistudy = componentmultistudy; + + // Affect icone + _icone =new char[strlen(icone)+1]; + strcpy(_icone, icone); + + //Affect interfaces + _list_interfaces.length(list_interfaces.length()); + _list_interfaces = list_interfaces; + + // affect path prefixes + _pathes.resize(pathes.size()); + _pathes = pathes ; +} + +//---------------------------------------------------------------------- +// Function : ~SALOME_ModuleCatalog_AcomponentImpl +// Purpose : Destructor +//---------------------------------------------------------------------- +SALOME_ModuleCatalog_AcomponentImpl::~SALOME_ModuleCatalog_AcomponentImpl() +{ + MESSAGE("Component destruction") + // empty memory + delete [] _component_name; + delete [] _constraint; +} + +//---------------------------------------------------------------------- +// Function : GetInterfaceList +// Purpose : get a list of the interfaces name of a component +//---------------------------------------------------------------------- +SALOME_ModuleCatalog::ListOfInterfaces* +SALOME_ModuleCatalog_AcomponentImpl::GetInterfaceList() +{ + SALOME_ModuleCatalog::ListOfInterfaces_var _list = new SALOME_ModuleCatalog::ListOfInterfaces; + + // All the interfaces are defined in _list_interfaces affected at the + // component creation + unsigned int _length_interfaces =_list_interfaces.length(); + + _list->length(_length_interfaces); + + // Parse all the interfaces to get their name + for (unsigned int ind = 0; ind < _length_interfaces; ind++) + { + _list[ind] = CORBA::string_dup(_list_interfaces[ind].interfacename); + MESSAGE("The component " << _component_name << " contains " << _list[ind] << " as interface") + } + + return _list._retn(); +} + +//---------------------------------------------------------------------- +// Function : GetInterface +// Purpose : get one interface of a component +//---------------------------------------------------------------------- +SALOME_ModuleCatalog::DefinitionInterface* +SALOME_ModuleCatalog_AcomponentImpl::GetInterface(const char* interfacename) + throw(SALOME_ModuleCatalog::NotFound) +{ + SALOME_ModuleCatalog::DefinitionInterface_var _interface = new SALOME_ModuleCatalog::DefinitionInterface; + SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; + // Variables initialisation + _interface->interfaceservicelist.length(0); + int _length = 0; + bool _find = false ; + + // looking for the specified interface + for (unsigned int ind = 0; ind < _list_interfaces.length(); ind++) + { + if (strcmp(interfacename, _list_interfaces[ind].interfacename) == 0) + { + // wanted interface + _find = true ; + + // Affect the name of the interface + _interface->interfacename = interfacename; + + // Affect each service of the wanted interface + for (unsigned int ind1 = 0; ind1 < _list_interfaces[ind].interfaceservicelist.length() ; ind1++) + { + _interface->interfaceservicelist.length(_length+1); + _service = _duplicate_service(_list_interfaces[ind].interfaceservicelist[ind1]); + _interface->interfaceservicelist[_length] = _service; + + _length++; + } + + } + } + + if (!_find) + { + // The interface was not found, the exception should be thrown + char * message = new char[100]; + strcpy(message, "The interface "); + strcat(message,interfacename); + strcat(message, " of the component "); + strcat(message,_component_name); + strcat(message, " was not found") ; + MESSAGE("The interface " << interfacename << " of the component " << _component_name << " was not found") + throw SALOME_ModuleCatalog::NotFound(message); + delete [] message; + } + + return _interface._retn(); +} + + + +//---------------------------------------------------------------------- +// Function : GetServiceList +// Purpose : get a list of the services name of an interface +// of a component +//---------------------------------------------------------------------- +SALOME_ModuleCatalog::ListOfServices* +SALOME_ModuleCatalog_AcomponentImpl::GetServiceList(const char* interfacename) + throw(SALOME_ModuleCatalog::NotFound) +{ + SALOME_ModuleCatalog::ListOfServices_var _list = new SALOME_ModuleCatalog::ListOfServices; + + // Variables initialisation + _list->length(0); + bool _find = false ; + + // looking for the specified interface + for (unsigned int ind = 0; ind < _list_interfaces.length(); ind++) + { + if (strcmp(interfacename, _list_interfaces[ind].interfacename) == 0) + { + _find = true ; + // wanted interface + // Get the list of services name for this interface + unsigned int _length_services = _list_interfaces[ind].interfaceservicelist.length(); + _list->length(_length_services); + for (unsigned int ind1 = 0; ind1 < _length_services ; ind1++) + { + _list[ind1] = CORBA::string_dup(_list_interfaces[ind].interfaceservicelist[ind1].ServiceName); + MESSAGE("The interface " << interfacename << " of the component " << _component_name << " contains " << _list[ind1] << " as a service") + } + } + } + + if (!_find) + { + // The interface was not found, the exception should be thrown + char * message = new char[100]; + strcpy(message, "The interface "); + strcat(message,interfacename); + strcat(message, " of the component "); + strcat(message,_component_name); + strcat(message, " was not found") ; + MESSAGE("The interface " << interfacename << " of the component " << _component_name << " was not found") + throw SALOME_ModuleCatalog::NotFound(message); + delete [] message; + } + + return _list._retn(); +} + + +//---------------------------------------------------------------------- +// Function : GetService +// Purpose : get one service of an interface of a component +//---------------------------------------------------------------------- +SALOME_ModuleCatalog::Service* +SALOME_ModuleCatalog_AcomponentImpl::GetService(const char* interfacename, + const char* servicename) + throw(SALOME_ModuleCatalog::NotFound) +{ + SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; + // Varaibles initialisation + bool _find = false ; + + // looking for the specified interface + for (unsigned int ind = 0; ind < _list_interfaces.length(); ind++) + { + if (strcmp(interfacename, _list_interfaces[ind].interfacename) == 0) + { + // wanted interface + // looking for the specified service + for (unsigned int ind1 = 0; ind1 < _list_interfaces[ind].interfaceservicelist.length() ; ind1++) + { + if (strcmp(servicename, _list_interfaces[ind].interfaceservicelist[ind1].ServiceName) == 0) + { + // Wanted Service + // Affect the service to be returned + _find = true ; + _service = _duplicate_service(_list_interfaces[ind].interfaceservicelist[ind1]); + } + } + + } + } + + if (!_find) + { + // The service was not found, the exception should be thrown + char * message = new char[100]; + strcpy(message, "The service "); + strcat(message, servicename); + strcat(message," of the interface "); + strcat(message,interfacename); + strcat(message, " of the component "); + strcat(message,_component_name); + strcat(message, " was not found") ; + MESSAGE("The service " << servicename << " of the interface " << interfacename << " of the component " << _component_name << " was not found") + throw SALOME_ModuleCatalog::NotFound(message); + delete [] message; + } + + return _service._retn(); +} + +//---------------------------------------------------------------------- +// Function : GetDefaultService +// Purpose : get the default service of the interface +//---------------------------------------------------------------------- +SALOME_ModuleCatalog::Service* +SALOME_ModuleCatalog_AcomponentImpl::GetDefaultService(const char* interfacename) + throw(SALOME_ModuleCatalog::NotFound) +{ + SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; + + // Variables initialisation + bool _find = false ; + + // looking for the specified interface + for (unsigned int ind = 0; ind < _list_interfaces.length(); ind++) + { + if (strcmp(interfacename, _list_interfaces[ind].interfacename) == 0) + { + // wanted interface + // looking for the defautl service of the wanted interface + for (unsigned int ind1 = 0; ind1 < _list_interfaces[ind].interfaceservicelist.length() ; ind1++) + { + if (_list_interfaces[ind].interfaceservicelist[ind1].Servicebydefault) + { + // Default Service + // affect the service to be returned + _find = true ; + _service = _duplicate_service(_list_interfaces[ind].interfaceservicelist[ind1]); + } + } + + } + } + + if (!_find) + { + // The service was not found, the exception should be thrown + char * message = new char[100]; + strcpy(message, "The default service of the interface "); + strcat(message,interfacename); + strcat(message, " of the component "); + strcat(message,_component_name); + strcat(message, " was not found") ; + MESSAGE("The default service of the interface " << interfacename << " of the component " << _component_name << " was not found") + throw SALOME_ModuleCatalog::NotFound(message); + delete [] message; + } + + return _service._retn(); +} + +//---------------------------------------------------------------------- +// Function : GetPathPrefix +// Purpose : get the PathPrefix of a computer +//---------------------------------------------------------------------- +char* +SALOME_ModuleCatalog_AcomponentImpl::GetPathPrefix(const char* machinename) + throw(SALOME_ModuleCatalog::NotFound) +{ + MESSAGE("Begin of GetPathPrefix") + // Variables initialisation + char* _path = NULL; + bool _find = false ; + + // Parse all the path prefixes + // looking for the wanted computer + for (unsigned int ind = 0 ; ind < _pathes.size() ; ind++) + { + for (unsigned int ind1 = 0 ; ind1 < _pathes[ind].ListOfComputer.size() ; ind1++) + { + if (strcmp(machinename, _pathes[ind].ListOfComputer[ind1].c_str()) == 0) + { + _find = true ; + // Wanted computer + // affect the path to be returned + const char* _temp = _pathes[ind].path.c_str() ; + _path = new char[strlen(_temp)+1]; + strcpy(_path,_temp); + } + } + } + + if (!_find) + { + // The computer was not found, the exception should be thrown + char * message = new char[100]; + strcpy(message, "The computer "); + strcat(message,machinename); + strcat(message, " was not found in the catalog associated to the component ") ; + strcat(message,_component_name); + MESSAGE("The computer " << machinename << " was not found in the catalog associated to the component " << _component_name) + throw SALOME_ModuleCatalog::NotFound(message); + delete [] message; + } + + return _path; +} + +//---------------------------------------------------------------------- +// Function : constraint +// Purpose : obtain the constraint affected to a component +//---------------------------------------------------------------------- +char* SALOME_ModuleCatalog_AcomponentImpl::constraint() +{ + return CORBA::string_dup(_constraint); +} + +//---------------------------------------------------------------------- +// Function : componentname +// Purpose : obtain the componentname +//---------------------------------------------------------------------- +char* SALOME_ModuleCatalog_AcomponentImpl::componentname() +{ + return CORBA::string_dup(_component_name); +} + +//---------------------------------------------------------------------- +// Function : multistudy +// Purpose : define if a component can be multistudy or not +//---------------------------------------------------------------------- +CORBA::Boolean SALOME_ModuleCatalog_AcomponentImpl::multistudy() +{ + return _componentmultistudy ; +} + +//---------------------------------------------------------------------- +// Function : component_type +// Purpose : define the type of the component +//---------------------------------------------------------------------- +SALOME_ModuleCatalog::ComponentType +SALOME_ModuleCatalog_AcomponentImpl::component_type() +{ + return _componenttype; +} + +//---------------------------------------------------------------------- +// Function : icone +// Purpose : obtain the icone affected to a component (for IAPP) +//---------------------------------------------------------------------- +char* SALOME_ModuleCatalog_AcomponentImpl::component_icone() +{ + return CORBA::string_dup(_icone); +} + +//---------------------------------------------------------------------- +// Function : _duplicate_service +// Purpose : duplicate a service +//---------------------------------------------------------------------- +SALOME_ModuleCatalog::Service_var +SALOME_ModuleCatalog_AcomponentImpl::_duplicate_service(SALOME_ModuleCatalog::Service service) +{ + SALOME_ModuleCatalog::Service_var _service = new SALOME_ModuleCatalog::Service; + + // service name + _service->ServiceName = CORBA::string_dup(service.ServiceName); + // service by default + _service->Servicebydefault = service.Servicebydefault; + + // in Parameters service + unsigned int _length_in_param = service.ServiceinParameter.length(); + for(unsigned int ind = 0; ind < _length_in_param; ind++) + { + _service->ServiceinParameter.length(_length_in_param); + // in Parameter type + _service->ServiceinParameter[ind].Parametertype = CORBA::string_dup(service.ServiceinParameter[ind].Parametertype); + // in Parameter name + _service->ServiceinParameter[ind].Parametername = CORBA::string_dup(service.ServiceinParameter[ind].Parametername); + } + + // out Parameters service + unsigned int _length_out_param = service.ServiceoutParameter.length(); + for(unsigned int ind = 0; ind < _length_out_param; ind++) + { + _service->ServiceoutParameter.length(_length_out_param); + // out Parameter type + _service->ServiceoutParameter[ind].Parametertype = CORBA::string_dup(service.ServiceoutParameter[ind].Parametertype); + // out Parameter name + _service->ServiceoutParameter[ind].Parametername = CORBA::string_dup(service.ServiceoutParameter[ind].Parametername); + } + + return _service; +} diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx new file mode 100644 index 000000000..3d9fe1fa1 --- /dev/null +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx @@ -0,0 +1,135 @@ +// File: SALOME_ModuleCatalog_Acomponent_impl.hxx +// Created: Tue June 28 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + + +#ifndef ACOMPONENT_IMPL_H +#define ACOMPONENT_IMPL_H + +#include "utilities.h" +#include "PathPrefix.hxx" +#include +#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) + +class SALOME_ModuleCatalog_AcomponentImpl: public POA_SALOME_ModuleCatalog::Acomponent, + public PortableServer::RefCountServantBase +{ +public: + //! standard constructor + SALOME_ModuleCatalog_AcomponentImpl(const char* name, + const char* constraint, + SALOME_ModuleCatalog::ComponentType componenttype, + CORBA::Boolean componentmultistudy, + const char* icone, + SALOME_ModuleCatalog::ListOfDefInterface list_interfaces, + ListOfPathPrefix pathes); + + //! standard destructor + virtual ~SALOME_ModuleCatalog_AcomponentImpl(); + + //! method to get a list of the interfaces name of a component + /*! + \return a list of the interfaces of a component + */ + virtual SALOME_ModuleCatalog::ListOfInterfaces* GetInterfaceList() ; + + //! method to get one interface of a component + /*! If the specified interface doesn't exist, the Notfound exception is thrown + \param interface name const car* arguments + \return the wanted interface + */ + virtual SALOME_ModuleCatalog::DefinitionInterface* + GetInterface(const char* interfacename) + throw(SALOME_ModuleCatalog::NotFound); + + //! method to get a list of the services name of an interface of a component + /*!If the specified interface doesn't exist, the Notfound exception is thrown + \param interfacename const char* arguments + \return a list of the services of the wanted interface + */ + virtual SALOME_ModuleCatalog::ListOfServices* + GetServiceList(const char* interfacename) + throw(SALOME_ModuleCatalog::NotFound); + + + //! method to get one service of an interface of a component + /*! If the wanted service or the specified interface don't exist, + * the Notfound exception is thrown + \param interfacename const char* arguments + \param servicename const char* arguments + \return the wanted service + */ + virtual SALOME_ModuleCatalog::Service* + GetService(const char* interfacename, + const char* servicename) + throw(SALOME_ModuleCatalog::NotFound); + + //! method to get the default service of an interface of a component + /*! If the specified interface doesn't exist, the Notfound exception is thrown + \param interfacename const char* arguments + \return the default service of the interface + */ + virtual SALOME_ModuleCatalog::Service* + GetDefaultService(const char* interfacename) + throw(SALOME_ModuleCatalog::NotFound); + + //! method to get the PathPrefix of a computer + /*! If the wanted computer doesn't exist, the Notfound exception is thrown + \param machinename const char* arguments + \return the prefix path + */ + virtual char* GetPathPrefix(const char* machinename) + throw(SALOME_ModuleCatalog::NotFound); + + //! method to obtain the constraint affected to a component + /*! to be resolved by LifeCycle for the computer choice + \return the constraint + */ + virtual char* constraint() ; + + //! method to obtain the componentname + /*! + \return the component name + */ + virtual char* componentname(); + + //! method to define if a component can be multistudy or not + /*! + \return true if the component supports multistudy + */ + virtual CORBA::Boolean multistudy(); + + //! method to define the type of the component + /*! + \return the component type + */ + virtual SALOME_ModuleCatalog::ComponentType component_type() ; + + //! method to obtain the component icone (for IAPP) + /*! + \return the component icone + */ + virtual char* component_icone(); + +private : + char* _component_name ; + char* _constraint; + char* _icone; + SALOME_ModuleCatalog::ComponentType _componenttype; + CORBA::Boolean _componentmultistudy; + SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces; + ListOfPathPrefix _pathes ; + + + //! method to duplicate a service + /*! + \param service SALOME_ModuleCatalog::Service arguments + \return the service + */ + virtual SALOME_ModuleCatalog::Service_var _duplicate_service(SALOME_ModuleCatalog::Service service); +}; + +#endif // ACOMPONENT_IMPL_H diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx new file mode 100644 index 000000000..edba3fe03 --- /dev/null +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Client.cxx @@ -0,0 +1,220 @@ +using namespace std; +/* $Header$ */ + +#include +#include "SALOME_NamingService.hxx" +#include "SALOME_ModuleCatalog.hh" +#include +#include "utilities.h" + +int main(int argc,char **argv) +{ + char* name_to_find = "Geometry"; + + CORBA::ORB_var orb; + CosNaming::NamingContext_var _rootContext; + CORBA::Object_var objVar, objVarN; + try { + + // initialize the ORB + + orb = CORBA::ORB_init (argc, argv); + + + // Get CORBA reference of the catalog + SALOME_NamingService NS(orb); + CORBA::Object_var objVarN = NS.Resolve("/Kernel/ModulCatalog"); + + SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN); + MESSAGE("Distant catalog of component found") + + // Get component list + SALOME_ModuleCatalog::ListOfComponents_var list_composants = Catalogue->GetComponentList(); + + + // Typed component list + MESSAGE("Get Typed Component list (GEOM Type)"); + SALOME_ModuleCatalog::ListOfComponents_var list_typed_composants = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::GEOM); + for (unsigned int ind = 0; ind < list_typed_composants->length();ind++) + MESSAGE("Component GEOM list : " << list_typed_composants[ind]); + + MESSAGE("Get Typed Component list (SUPERV Type)"); + SALOME_ModuleCatalog::ListOfComponents_var list_styped_composants = Catalogue->GetTypedComponentList(SALOME_ModuleCatalog::SUPERV); + for (unsigned int ind = 0; ind < list_styped_composants->length();ind++) + MESSAGE("Component SUPERV list : " << list_styped_composants[ind]); + + // Get list of couple (component name, component icone) + SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants_icone = Catalogue->GetComponentIconeList(); + for (unsigned int ind = 0; ind < list_composants_icone->length();ind++) + { + MESSAGE("Component name: " << list_composants_icone[ind].modulename); + MESSAGE("Component icone: " << list_composants_icone[ind].moduleicone); + } + + // obtain a component (specified as parameter of the client) + SALOME_ModuleCatalog::Acomponent_ptr Geom = Catalogue->GetComponent("Geometry"); + if (CORBA::is_nil (Geom)) + { + INFOS("Catalog Error : Component Geometry not found in the catalog") + exit (-1); + } + + MESSAGE("Component of name : " << Geom->componentname() << " created "); + MESSAGE("Component type : " << Geom->component_type() << " multistudy : " <multistudy()); + MESSAGE("Component constraint : " << Geom->constraint()); + MESSAGE("Component icone : " << Geom->component_icone()); + + // Obtain another component + SALOME_ModuleCatalog::Acomponent_ptr Superv = Catalogue->GetComponent("Supervision"); + if (CORBA::is_nil (Superv)) + { + INFOS("Catalog Error : Component Supervision not found in the catalog") + exit (-1); + } + + MESSAGE("Component of name : " << Superv->componentname() << " created "); + MESSAGE("Component type : " << Superv->component_type() << " multistudy : " <multistudy()); + MESSAGE("Component constraint : " << Superv->constraint()); + MESSAGE("Component icone : " << Superv->component_icone()); + + // obtain prefix path for a computer + char* path; + path =Superv->GetPathPrefix("omote"); + MESSAGE("Path prefix pour omote : " << path); + + // obtain prefix path for a computer + path =Geom->GetPathPrefix("eri"); + MESSAGE("Path prefix pour eri : " << path); + + // obtain interfaces list of the component + SALOME_ModuleCatalog::ListOfInterfaces_var _list = new SALOME_ModuleCatalog::ListOfInterfaces; + _list = Geom->GetInterfaceList(); + for (unsigned int ind = 0; ind < _list->length();ind++) + MESSAGE("Interface name : " << _list[ind]); + + // obtain interfaces list of the component + SALOME_ModuleCatalog::ListOfInterfaces_var _list1 = new SALOME_ModuleCatalog::ListOfInterfaces; + _list1 = Superv->GetInterfaceList(); + for (unsigned int ind = 0; ind < _list1->length();ind++) + MESSAGE("Interface name : " << _list1[ind]) + + + // Obtain one interface of a component + SALOME_ModuleCatalog::DefinitionInterface_var _interf = new SALOME_ModuleCatalog::DefinitionInterface; + _interf = Geom->GetInterface("Geometry"); + MESSAGE ("Interface " << _interf->interfacename << " getted") + for (unsigned int ind = 0; ind < _interf->interfaceservicelist.length();ind++) + MESSAGE("Service name : " << _interf->interfaceservicelist[ind].ServiceName) + + + // obtain services list of the component + + SALOME_ModuleCatalog::ListOfServices_var list_services_component = new SALOME_ModuleCatalog::ListOfServices; + list_services_component = Geom->GetServiceList("Geometry"); + for (unsigned int ind = 0; ind < list_services_component->length();ind++) + MESSAGE("Service name : " << list_services_component[ind]) + + + // Get a service of the component + + SALOME_ModuleCatalog::Service_var second_service = new SALOME_ModuleCatalog::Service; + second_service = Geom->GetDefaultService("Geometry"); + + MESSAGE("Default Service name: " << second_service->ServiceName) + for (unsigned int ind1 = 0; ind1 ServiceinParameter.length();ind1++) + { + MESSAGE("Type of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametertype) + MESSAGE("Name of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametername) + } + for (unsigned int ind1 = 0; ind1 ServiceoutParameter.length();ind1++) + { + MESSAGE("Type of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametertype) + MESSAGE("Name of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametername) + } + + + + second_service = Geom->GetDefaultService("Geometry"); + + MESSAGE("Default Service name: " << second_service->ServiceName) + for (unsigned int ind1 = 0; ind1 ServiceinParameter.length();ind1++) + { + MESSAGE("Type of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametertype) + MESSAGE("Name of the in Parameter of this service : " << second_service->ServiceinParameter[ind1].Parametername) + } + for (unsigned int ind1 = 0; ind1 ServiceoutParameter.length();ind1++) + { + MESSAGE("Type of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametertype) + MESSAGE("Name of the out Parameter of this service : " << second_service->ServiceoutParameter[ind1].Parametername) + } + + + + // Get service of the component + + SALOME_ModuleCatalog::Service_var service_1 = new SALOME_ModuleCatalog::Service; + + service_1 = Geom->GetService("Geometry","MakeSphere") ; + + MESSAGE("Service name: " << service_1->ServiceName) + for (unsigned int ind1 = 0; ind1 ServiceinParameter.length();ind1++) + { + MESSAGE("Type of the in Parameter of this service : " << service_1->ServiceinParameter[ind1].Parametertype) + MESSAGE("Name of the in Parameter of this service : " << service_1->ServiceinParameter[ind1].Parametername) + } + + for (unsigned int ind1 = 0; ind1 ServiceoutParameter.length();ind1++) + { + MESSAGE("Type of the out Parameter of this service : " << service_1->ServiceoutParameter[ind1].Parametertype) + MESSAGE("Name of the out Parameter of this service : " << service_1->ServiceoutParameter[ind1].Parametername) + } + + // Test levée exception + service_1 = Geom->GetService("BOX","makeBox") ; + + + } + catch(SALOME_ModuleCatalog::NotFound &ex){ + INFOS("SALOME_ModuleCatalog::NotFound") + cerr << ex.what << endl; + } + catch(CORBA::SystemException&) { + INFOS("Caught CORBA::SystemException.") + } + catch (CosNaming::NamingContext::CannotProceed &) { + INFOS("CosNaming::NamingContext::CannotProceed") + } + catch (CosNaming::NamingContext::NotFound &) { + INFOS("CosNaming::NamingContext::NotFound") + } + catch (CosNaming::NamingContext::InvalidName &) { + INFOS("CosNaming::NamingContext::InvalidName") + } + catch (CosNaming::NamingContext::AlreadyBound &) { + INFOS("CosNaming::NamingContext::AlreadyBound") + } + catch (CosNaming::NamingContext::NotEmpty &) { + INFOS("CosNaming::NamingContext::NotEmpty") + } + + catch(CORBA::Exception &sysEx) { + INFOS("Caught CORBA::Exception.") + } + + + return 0; +} + + + + + + + + + + + + + + diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx new file mode 100644 index 000000000..77b9d298d --- /dev/null +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx @@ -0,0 +1,368 @@ +using namespace std; +// File: SALOME_ModuleCatalog_Handler.cxx +// Created: Tue June 27 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + +#define WRITE_CATA_COMPONENT +#include "SALOME_ModuleCatalog_Handler.hxx" + +//---------------------------------------------------------------------- +// Function : SALOME_ModuleCatalog_Handler +// Purpose : Constructor +//---------------------------------------------------------------------- +SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler() +{ + MESSAGE("SALOME_ModuleCatalog_Handler creation") + // XML Tags initialisation + // Used in the function endElement + test_path_prefix_name = "path-prefix-name"; + test_computer_name = "computer-name" ; + test_path_prefix = "path-prefix" ; + + test_component_name = "component-name"; + test_component_type = "component-type" ; + test_component_multistudy="component-multistudy"; + test_component_icone="component-icone" ; + + test_interface_name = "component-interface-name" ; + + test_service_name = "service-name"; + test_defaultservice = "service-by-default"; + + test_inParameter_type="inParameter-type"; + test_inParameter_name="inParameter-name"; + test_inParameter="inParameter"; + test_inParameter_list="inParameter-list"; + + test_outParameter_type="outParameter-type"; + test_outParameter_name="outParameter-name"; + test_outParameter="outParameter"; + test_outParameter_list="outParameter-list"; + + test_service= "component-service"; + test_service_list="component-service-list"; + test_interface_list="component-interface-list"; + + test_constraint="constraint"; + + test_component="component"; +} + +//---------------------------------------------------------------------- +// Function : ~SALOME_ModuleCatalog_Handler +// Purpose : Destructor +//---------------------------------------------------------------------- +SALOME_ModuleCatalog_Handler::~SALOME_ModuleCatalog_Handler() +{ + MESSAGE("SALOME_ModuleCatalog_Handler destruction") +} + +//---------------------------------------------------------------------- +// Function : startDocument +// Purpose : overload handler function +//---------------------------------------------------------------------- +bool SALOME_ModuleCatalog_Handler::startDocument() +{ + MESSAGE("Begin parse document") + // Empty the private elements + _pathlist.resize(0); + _path_prefix.ListOfComputer.resize(0); + _servicelist.resize(0); + _interfacelist.resize(0); + _modulelist.resize(0); + _inparamlist.resize(0); + _outparamlist.resize(0); + return true; +} + +//---------------------------------------------------------------------- +// Function : startElement +// Purpose : overload handler function +//---------------------------------------------------------------------- +bool SALOME_ModuleCatalog_Handler::startElement(const QString&, + const QString &, + const QString& qName, + const QXmlAttributes& atts) +{ + return true; +} + +//---------------------------------------------------------------------- +// Function : endElement +// Purpose : overload handler function +//---------------------------------------------------------------------- +bool SALOME_ModuleCatalog_Handler::endElement(const QString&, + const QString &, + const QString& qName) +{ + // Path prefix + + // tag test_path_prefix_name + if((qName.compare(QString(test_path_prefix_name))==0)) + _path_prefix.path = content; + // tag test_computer_name + if((qName.compare(QString(test_computer_name))==0)) + _path_prefix.ListOfComputer.push_back(content); + + // tag test_path_prefix + if((qName.compare(QString(test_path_prefix))==0)) + { + _pathlist.push_back(_path_prefix); + _path_prefix.ListOfComputer.resize(0); + } + + // Component identification + + // tag test_component_name + if((qName.compare(QString(test_component_name))==0)) + _amodule.Parsercomponentname = content ; + // tag test_component_type + if((qName.compare(QString(test_component_type))==0)) + { + if ((content.compare("MESH") == 0) || + (content.compare("Mesh") == 0) || + (content.compare("mesh") == 0)) + _amodule.Parsercomponenttype = MESH ; + else if((content.compare("MED") == 0) || + (content.compare("Med") == 0) || + (content.compare("med") == 0)) + _amodule.Parsercomponenttype = Med ; + else if((content.compare("GEOM") == 0) || + (content.compare("Geom") == 0) || + (content.compare("geom") == 0)) + _amodule.Parsercomponenttype = GEOM ; + else if((content.compare("SOLVER") == 0) || + (content.compare("Solver") == 0) || + (content.compare("solver") == 0)) + _amodule.Parsercomponenttype = SOLVER ; + else if((content.compare("SUPERV") == 0) || + (content.compare("Superv") == 0) || + (content.compare("Supervision") == 0) || + (content.compare("superv") == 0)) + _amodule.Parsercomponenttype = SUPERV ; + else if((content.compare("DATA") == 0) || + (content.compare("Data") == 0) || + (content.compare("data") == 0)) + _amodule.Parsercomponenttype = DATA ; + else if((content.compare("VISU") == 0) || + (content.compare("Visu") == 0) || + (content.compare("visu") == 0)) + _amodule.Parsercomponenttype = VISU ; + else if((content.compare("OTHER") == 0) || + (content.compare("Other") == 0) || + (content.compare("other") == 0)) + _amodule.Parsercomponenttype = OTHER ; + else + // If it'not in all theses cases, the type is affected to OTHER + _amodule.Parsercomponenttype = OTHER ; + } + + // tag test_component_multistudy + if((qName.compare(QString(test_component_multistudy))==0)) + _amodule.Parsercomponentmultistudy = atoi(content.c_str()) ; + + // tag test_component_icone + if((qName.compare(QString(test_component_icone))==0)) + _amodule.Parsercomponenticone = content ; + + // interface identification + + // tag test_interface_name + if((qName.compare(QString(test_interface_name))==0)) + _aInterface.Parserinterfacename = content ; + + // Service identification + + // tag test_service_name + if((qName.compare(QString(test_service_name))==0)) + _aService.ParserServiceName = content ; + + //tag test_defaultservice + if((qName.compare(QString(test_defaultservice))==0)) + _aService.ParserServicebydefault = atoi(content.c_str()) ; + + // Parameter in + + // tag test_inParameter_type + if((qName.compare(QString(test_inParameter_type))==0)) + _inparam.ParserParamtype = content ; + //tag test_inParameter_name + if((qName.compare(QString(test_inParameter_name))==0)) + _inparam.ParserParamname = content ; + + //tag test_inParameter + if((qName.compare(QString(test_inParameter))==0)) + { + _inparamlist.push_back(_inparam) ; + + // Empty temporary structures + _inparam.ParserParamtype = ""; + _inparam.ParserParamname = ""; + } + + //tag test_inParameter_list + if((qName.compare(QString(test_inParameter_list))==0)) + { + _aService.ParserServiceinParameter = _inparamlist; + _inparamlist.resize(0); + } + + // Parameter out + + // tag test_outParameter_type + if((qName.compare(QString(test_outParameter_type))==0)) + _outparam.ParserParamtype = content ; + //tag test_outParameter_name + if((qName.compare(QString(test_outParameter_name))==0)) + _outparam.ParserParamname = content ; + + //tag test_outParameter + if((qName.compare(QString(test_outParameter))==0)) + { + _outparamlist.push_back(_outparam) ; + + // Empty temporary structures + _outparam.ParserParamtype = ""; + _outparam.ParserParamname = ""; + } + //tag test_outParameter_list + if((qName.compare(QString(test_outParameter_list))==0)) + { + _aService.ParserServiceoutParameter=_outparamlist; + _outparamlist.resize(0); + } + + + // tag test_service + if((qName.compare(QString(test_service))==0)) + { + _servicelist.push_back(_aService); + + // Empty temporary structures + _aService.ParserServiceName = ""; + _aService.ParserServiceinParameter.resize(0); + _aService.ParserServiceoutParameter.resize(0); + } + + // tag test_service_list + if((qName.compare(QString(test_service_list))==0)) + { + _aInterface.Parserinterfaceservicelist = _servicelist ; + + // Empty temporary structures + _servicelist.resize(0); + _interfacelist.push_back(_aInterface); + _aInterface.Parserinterfacename =""; + _aInterface.Parserinterfaceservicelist.resize(0); + + } + + //tag test_interface_list + if((qName.compare(QString(test_interface_list))==0)) + { + _amodule.ParserListInterface = _interfacelist ; + _interfacelist.resize(0); + } + + //tag test_constraint + if((qName.compare(QString(test_constraint))==0)) + _amodule.Parserconstraint = content ; + + // tag test_component + if((qName.compare(QString(test_component))==0)) + { + _modulelist.push_back(_amodule) ; + + // Empty temporary structures + _amodule.Parsercomponentname = ""; + _amodule.Parserconstraint = ""; + _amodule.Parsercomponenticone=""; + _amodule.ParserListInterface.resize(0); + } + + return true; +} + +//---------------------------------------------------------------------- +// Function : characters +// Purpose : overload handler function +//---------------------------------------------------------------------- +bool SALOME_ModuleCatalog_Handler::characters(const QString& chars) +{ + content = chars ; + return true; +} + +//---------------------------------------------------------------------- +// Function : endDocument +// Purpose : overload handler function +// Print all informations find in the catalog +// (only in DEBUG mode!!) +//---------------------------------------------------------------------- +bool SALOME_ModuleCatalog_Handler::endDocument() +{ + //_pathlist + for (unsigned int ind = 0; ind < _pathlist.size(); ind++) + { + MESSAGE("Path :"<<_pathlist[ind].path) + for (unsigned int i = 0; i < _pathlist[ind].ListOfComputer.size(); i++) + MESSAGE("Computer name :" << _pathlist[ind].ListOfComputer[i]) + } + + // _modulelist + for (unsigned int ind = 0; ind < _modulelist.size(); ind++) + { + MESSAGE("Component name : " << _modulelist[ind].Parsercomponentname); + // MESSAGE("Component type : " <<_modulelist[ind].Parsercomponenttype); +// MESSAGE("Component constraint : " << _modulelist[ind].Parserconstraint); +// MESSAGE("Component icone : " << _modulelist[ind].Parsercomponenticone); +// for (unsigned int i = 0; i < _modulelist[ind].ParserListInterface.size(); i++) +// { +// MESSAGE("Component interface name : " << _modulelist[ind].ParserListInterface[i].Parserinterfacename); +// for (unsigned int j=0; j< _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist.size(); j++) +// { +// MESSAGE("Service name : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceName); +// MESSAGE("Service default : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServicebydefault); +// for (unsigned int k=0; k< _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceinParameter.size() ; k++) +// { +// MESSAGE("Service Parameter in name : " <<_modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceinParameter[k].ParserParamname); +// MESSAGE("Service Parameter in type : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceinParameter[k].ParserParamtype); +// } +// for (unsigned int k=0; k< _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceoutParameter.size() ; k++) +// { +// MESSAGE("Service Parameter out name : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceoutParameter[k].ParserParamname); +// MESSAGE("Service Parameter out type : " << _modulelist[ind].ParserListInterface[i].Parserinterfaceservicelist[j].ParserServiceoutParameter[k].ParserParamtype); +// } +// } + } +// } + //MESSAGE("Document parsed"); + return true; +} + +//---------------------------------------------------------------------- +// Function : errorProtocol +// Purpose : overload handler function +//---------------------------------------------------------------------- +QString SALOME_ModuleCatalog_Handler::errorProtocol() +{ + return errorProt ; +} + + +//---------------------------------------------------------------------- +// Function : fatalError +// Purpose : overload handler function +//---------------------------------------------------------------------- +bool SALOME_ModuleCatalog_Handler::fatalError(const QXmlParseException& exception) +{ + errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) + .arg( exception.message() ) + .arg( exception.lineNumber() ) + .arg( exception.columnNumber() ); + + return QXmlDefaultHandler::fatalError( exception ); +} diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx new file mode 100644 index 000000000..3efd15826 --- /dev/null +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx @@ -0,0 +1,133 @@ +// File: SALOME_ModuleCatalog_Handler.hxx +// Created: Tue June 27 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + +#ifndef SALOME_CATALOG_HANDLER_H +#define SALOME_CATALOG_HANDLER_H + +#include "utilities.h" +#include "SALOME_ModuleCatalog_Parser.hxx" +#include +#include +#include + +class SALOME_ModuleCatalog_Handler : public QXmlDefaultHandler +{ +public: + //! standard constructor + SALOME_ModuleCatalog_Handler(); + + //! standard destructor + virtual ~SALOME_ModuleCatalog_Handler(); + + + //! method to overload handler function startDocument + /*! Is called before a xml file is parsed + \return true if no error was detected + */ + virtual bool startDocument(); + + + //! method to overload handler function startElement + /*! + \param Qstring argument by value + \param Qstring argument by value + \param Qstring argument by value + \param QXmlAttributes argument by value + \return true if no error was detected + */ + virtual bool startElement(const QString&, const QString &, + const QString& qName, const QXmlAttributes& atts); + + //! method to overload handler function endElement + /*! + \param Qstring argument by value + \param Qstring argument by value + \param Qstring argument by value + \return true if no error was detected + \sa _Find + */ + virtual bool endElement(const QString&, const QString &, + const QString& qName); + + + //! method to overload handler function characters + /*! + \param Qstring argument by value + \return true if no error was detected + */ + virtual bool characters(const QString& chars); + + //! method to overload handler function endDocument + /*! Is called at the end of the parsing + \return true if no error was detected + */ + virtual bool endDocument(); + + //! method to overload handler function errorProtocol + /*! + \return the error message + */ + virtual QString errorProtocol(); + + //! method to overload handler function fatalError + /*! + \param QXmlParseExecption argument by value + \return true if no error was detected + */ + virtual bool fatalError(const QXmlParseException& exception); + +private: + QString errorProt ; + + string content; + + const char* test_path_prefix_name ; + const char* test_computer_name ; + const char* test_path_prefix ; + + const char* test_component_name; + const char* test_component_type ; + const char* test_component_multistudy ; + const char* test_component_icone ; + + const char* test_interface_name; + + const char* test_service_name; + const char* test_defaultservice; + + const char* test_inParameter_type; + const char* test_inParameter_name; + const char* test_inParameter; + const char* test_inParameter_list; + const char* test_outParameter_type; + const char* test_outParameter_name; + const char* test_outParameter; + const char* test_outParameter_list; + + const char* test_service; + const char* test_service_list; + const char* test_interface_list; + const char* test_constraint; + + const char* test_component; + + ParserPathPrefix _path_prefix; + + ParserComponent _amodule; + + + ListOfDefinitionInterface _interfacelist; + ParserDefInterface _aInterface; + ListOfParserServices _servicelist; + ParserService _aService; + ParserServParam _inparam; + ParserServParam _outparam; + ListOfParserServicesParameter _inparamlist; + ListOfParserServicesParameter _outparamlist; +}; + +#endif // SALOME_CATALOG_HANDLER_H diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx new file mode 100644 index 000000000..050ecfdee --- /dev/null +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx @@ -0,0 +1,76 @@ +// File: SALOME_ModuleCatalog_Parser.hxx +// Created: Tue June 25 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + +#ifndef SALOME_CATALOG_PARSER_H +#define SALOME_CATALOG_PARSER_H + +#include +#include + +// Type Definitions +struct ParserPathPrefix +{ + string path; + vector ListOfComputer ; +}; + +typedef vector ListOfParserPathPrefix ; + +enum ParserComponentType {GEOM, MESH, Med, SOLVER, DATA, VISU, SUPERV, OTHER} ; + +struct ParserServParam +{ + string ParserParamtype; + string ParserParamname; +} ; + +typedef vector ListOfParserServicesParameter; + +struct ParserService +{ + string ParserServiceName; + ListOfParserServicesParameter ParserServiceinParameter; + ListOfParserServicesParameter ParserServiceoutParameter; + bool ParserServicebydefault; +} ; + +typedef vector ListOfParserServices ; + +struct ParserDefInterface +{ + string Parserinterfacename ; + ListOfParserServices Parserinterfaceservicelist ; +} ; + +typedef vector ListOfDefinitionInterface; + +struct ParserComponent +{ + string Parsercomponentname; + ParserComponentType Parsercomponenttype; + bool Parsercomponentmultistudy ; + string Parsercomponenticone; + ListOfDefinitionInterface ParserListInterface; + string Parserconstraint ; +}; + +typedef vector ListOfParserComponent ; + +#ifdef WRITE_CATA_COMPONENT +// contains all the paths and the computers defined in the catalog +ListOfParserPathPrefix _pathlist; + +// contains all the modules defined in the catalog +ListOfParserComponent _modulelist; +#else +extern ListOfParserPathPrefix _pathlist; +extern ListOfParserComponent _modulelist; +#endif + + + +#endif // SALOME_CATALOG_PARSER_H diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx new file mode 100644 index 000000000..32ebd9489 --- /dev/null +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx @@ -0,0 +1,55 @@ +using namespace std; +/* $Header$ */ +#include +#include "SALOME_NamingService.hxx" +#include "SALOME_ModuleCatalog_impl.hxx" +#include "utilities.h" + +int main(int argc,char **argv) +{ + try { + CosNaming::NamingContext_var _rootContext, catalogContext; + + // initialize the ORB + + CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); + + // initialize POA + + CORBA::Object_var poaobj = orb->resolve_initial_references ("RootPOA"); + + PortableServer::POA_var poa = PortableServer::POA::_narrow (poaobj); + PortableServer::POAManager_var mgr = poa->the_POAManager(); + + // Active catalog + + SALOME_ModuleCatalogImpl* Catalogue_i = new SALOME_ModuleCatalogImpl(argc, argv); + poa->activate_object (Catalogue_i); + + mgr->activate(); + + + CORBA::Object_ptr myCata = Catalogue_i->_this(); + + // initialise Naming Service + SALOME_NamingService *_NS; + _NS = new SALOME_NamingService(orb); + // register Catalog in Naming Service + _NS->Register(myCata ,"/Kernel/ModulCatalog"); + + MESSAGE("Running CatalogServer.") + + orb->run(); + + poa->destroy(1,1); + + } + catch(CORBA::SystemException&) { + INFOS("Caught CORBA::SystemException.") + } + catch(CORBA::Exception&) { + INFOS("Caught CORBA::Exception.") + } + + return 0; +} diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx new file mode 100644 index 000000000..9cf8efc5b --- /dev/null +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -0,0 +1,749 @@ +using namespace std; +// File: SALOME_ModuleCatalog_impl.cxx +// Created: Tue June 28 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + +#include "SALOME_ModuleCatalog_impl.hxx" +#include "SALOME_ModuleCatalog_Acomponent_impl.hxx" +#include + +#include +#include + +static const char* SEPARATOR = ":"; + +//---------------------------------------------------------------------- +// Function : SALOME_ModuleCatalogImpl +// Purpose : Constructor +//---------------------------------------------------------------------- +SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv) +{ + MESSAGE("Catalog creation"); + + // Empty used variables + _general_module_list.resize(0); + _general_path_list.resize(0); + + _personal_module_list.resize(0); + _personal_path_list.resize(0); + + // Parse the arguments given at server run + if (!_parseArguments(argc, argv,&_general_path,&_personal_path)) + MESSAGE( "Error while argument parsing" ) + + // Test existency of files + if (_general_path == NULL) + MESSAGE( "Error the general catalog should be indicated" ) + else + { + //MESSAGE("Parse general catalog"); + // Affect the variables _general_module_list and _general_path_list + // 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 pathes are associated to one computer, the first will be choosen" ) + else MESSAGE("General path list OK"); + + if(_personal_path != NULL) + { + //MESSAGE("Parse personal catalog"); + // Affect the variables _personal_module_list and _personal_path_list + // with the personal catalog + _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 pathes are associated to one computer, the first will be choosen" ) + else MESSAGE("Personal path list OK"); + } + else MESSAGE("No personal catalog indicated or error while opening the personal catalog"); + } +} + +//---------------------------------------------------------------------- +// Function : ~SALOME_ModuleCatalogImpl +// Purpose : Destructor +//---------------------------------------------------------------------- +SALOME_ModuleCatalogImpl::~SALOME_ModuleCatalogImpl() +{ + MESSAGE("Catalog Destruction"); +} + + +//---------------------------------------------------------------------- +// Function : GetComputerList +// Purpose : get a computer list +//---------------------------------------------------------------------- +SALOME_ModuleCatalog::ListOfComputers* +SALOME_ModuleCatalogImpl::GetComputerList() +{ + SALOME_ModuleCatalog::ListOfComputers_var _list_computers = + new SALOME_ModuleCatalog::ListOfComputers; + return _list_computers._retn(); +} + +//---------------------------------------------------------------------- +// Function : GetPathPrefix +// Purpose : get the PathPrefix of a computer +//---------------------------------------------------------------------- +char* +SALOME_ModuleCatalogImpl::GetPathPrefix(const char* machinename) { + MESSAGE("Begin of GetPathPrefix") + // Variables initialisation + char* _path = NULL; + bool _find = false ; + + // Parse all the path prefixes + // looking for the wanted computer + for (unsigned int ind = 0 ; ind < _personal_path_list.size() ; ind++) + { + for (unsigned int ind1 = 0 ; ind1 < _personal_path_list[ind].ListOfComputer.size() ; ind1++) + { + if (strcmp(machinename, _personal_path_list[ind].ListOfComputer[ind1].c_str()) == 0) + { + _find = true ; + // Wanted computer + // affect the path to be returned + const char* _temp = _personal_path_list[ind].path.c_str() ; + _path = new char[strlen(_temp)+1]; + strcpy(_path,_temp); + } + } + } + + if (!_find) + { + for (unsigned int ind = 0 ; ind < _general_path_list.size() ; ind++) + { + for (unsigned int ind1 = 0 ; ind1 < _general_path_list[ind].ListOfComputer.size() ; ind1++) + { + if (strcmp(machinename, _general_path_list[ind].ListOfComputer[ind1].c_str()) == 0) + { + _find = true ; + // Wanted computer + // affect the path to be returned + const char* _temp = _general_path_list[ind].path.c_str() ; + _path = new char[strlen(_temp)+1]; + strcpy(_path,_temp); + } + } + } + } + + return _path; +} + +//---------------------------------------------------------------------- +// Function : GetComponentList +// Purpose : get a component list +// If a component is defined in the personal catalog and +// in the general catalog (same name), the component defined +// in the personal catalog is used +//---------------------------------------------------------------------- +SALOME_ModuleCatalog::ListOfComponents* +SALOME_ModuleCatalogImpl::GetComponentList() +{ + 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].Parsercomponentname).c_str(); + //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].Parsercomponentname.compare(_personal_module_list[ind1].Parsercomponentname)) == 0) + _find = true; + } + if (!_find) + { + //MESSAGE("A new component " << _general_module_list[ind].Parsercomponentname << " 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].Parsercomponentname).c_str(); + //SCRUTE(_list_components[indice]) ; + + indice++; + } + // else + //MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog") ; + } + + return _list_components._retn(); +} + + +//---------------------------------------------------------------------- +// Function : GetComponentIconeList +// Purpose : get a component list of component name and component icone +// If a component is defined in the personal catalog and +// in the general catalog (same name), the component defined +// in the personal catalog is used +//---------------------------------------------------------------------- +SALOME_ModuleCatalog::ListOfIAPP_Affich* +SALOME_ModuleCatalogImpl::GetComponentIconeList() +{ + MESSAGE("Begin of GetComponentIconeList"); + + SALOME_ModuleCatalog::ListOfIAPP_Affich_var _list_components_icone = + new SALOME_ModuleCatalog::ListOfIAPP_Affich; + + _list_components_icone->length(_personal_module_list.size()); + + // All the components defined in the personal catalog are taken + for (unsigned int ind=0; ind < _personal_module_list.size();ind++) + { + _list_components_icone[ind].modulename=(_personal_module_list[ind].Parsercomponentname).c_str(); + _list_components_icone[ind].moduleicone=(_personal_module_list[ind].Parsercomponenticone).c_str(); + //SCRUTE(_list_components_icone[ind].modulename); + //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].Parsercomponentname.compare(_personal_module_list[ind1].Parsercomponentname)) == 0) + _find = true; + } + if (!_find) + { + // MESSAGE("A new component " << _general_module_list[ind].Parsercomponentname << " 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].Parsercomponentname).c_str(); + _list_components_icone[indice].moduleicone=(_general_module_list[ind].Parsercomponenticone).c_str(); + //SCRUTE(_list_components_icone[indice].modulename) ; + //SCRUTE(_list_components_icone[indice].moduleicone); + + indice++; + } + // else + //MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog"); + } + + return _list_components_icone._retn() ; +} + +//---------------------------------------------------------------------- +// Function : GetTypedComponentList +// Purpose : get a component list of a wanted type +// If a component is defined in the personal catalog and +// in the general catalog (same name), the component defined +// in the personal catalog is used +//---------------------------------------------------------------------- +SALOME_ModuleCatalog::ListOfComponents* +SALOME_ModuleCatalogImpl::GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type) +{ + MESSAGE("Begin of GetTypedComponentList"); + SALOME_ModuleCatalog::ListOfComponents_var _list_typed_component = + new SALOME_ModuleCatalog::ListOfComponents; + int _j = 0; + + _list_typed_component->length(0); + // Transform SALOME_ModuleCatalog::ComponentType in ParserComponentType + ParserComponentType _temp_component_type; + switch(component_type){ + case SALOME_ModuleCatalog::GEOM: + _temp_component_type = GEOM ; + break; + case SALOME_ModuleCatalog::MESH: + _temp_component_type = MESH; + break; + case SALOME_ModuleCatalog::Med: + _temp_component_type = Med; + break; + case SALOME_ModuleCatalog::SOLVER: + _temp_component_type = SOLVER; + break; + case SALOME_ModuleCatalog::DATA: + _temp_component_type = DATA; + break; + case SALOME_ModuleCatalog::VISU: + _temp_component_type = VISU; + break; + case SALOME_ModuleCatalog::SUPERV: + _temp_component_type = SUPERV; + break; + case SALOME_ModuleCatalog::OTHER: + _temp_component_type = OTHER; + break; + } + + // All the components in the personal catalog are taken + for (unsigned int ind=0; ind < _personal_module_list.size();ind++) + { + if (_personal_module_list[ind].Parsercomponenttype == _temp_component_type) + { + _list_typed_component->length(_j + 1); + _list_typed_component[_j] = (_modulelist[ind].Parsercomponentname).c_str(); + //SCRUTE(_list_typed_component[_j]) + _j++; + } + } + + int indice = _list_typed_component->length() ; + 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; + + if(_general_module_list[ind].Parsercomponenttype == _temp_component_type) + { + 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].Parsercomponentname.compare(_personal_module_list[ind1].Parsercomponentname)) == 0) + _find = true; + } + if (!_find) + { + //MESSAGE("A new component " << _general_module_list[ind].Parsercomponentname << " 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].Parsercomponentname).c_str(); + //SCRUTE(_list_typed_component[indice]) ; + + indice++; + } + //else + //MESSAGE("The component " <<_general_module_list[ind].Parsercomponentname << " was already defined in the personal catalog") ; + } + } + + + return _list_typed_component._retn(); +} + +//---------------------------------------------------------------------- +// Function : GetComponent +// Purpose : get a component +// If a component is defined in the personal catalog and +// in the general catalog (same name), the component defined +// in the personal catalog is used +//---------------------------------------------------------------------- +SALOME_ModuleCatalog::Acomponent_ptr +SALOME_ModuleCatalogImpl::GetComponent(const char* componentname) +{ + SALOME_ModuleCatalog::Acomponent_ptr compo; + SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces; + _list_interfaces.length(0); + char* _constraint = NULL; + char* _icone = NULL; + SALOME_ModuleCatalog::ComponentType _componenttype = SALOME_ModuleCatalog::OTHER; // default initialisation + CORBA::Boolean _componentmultistudy = false ; // default initialisation + ListOfPathPrefix _pathes ; + _pathes.resize(0); + + + bool find = false ; + + // Looking for component named "componentname" in the personal catalog + // If found, get name, interfaces and constraint + // If not found, looking for component named "componentname" in + // the general catalog + // If found, get name, interfaces and constraint + // If not found, NULL pointer is returned + + for (unsigned int ind=0; ind < _personal_module_list.size();ind++) + { + if (strcmp((_personal_module_list[ind].Parsercomponentname).c_str(),componentname) == 0) + { + //MESSAGE("Component named " << componentname << " found in the personal catalog"); + find = true; + + // get constraint + _constraint = new char[strlen(_personal_module_list[ind].Parserconstraint.c_str()) + 1]; + _constraint = CORBA::string_dup(_personal_module_list[ind].Parserconstraint.c_str()); + + // get component type + switch(_personal_module_list[ind].Parsercomponenttype){ + case GEOM: + _componenttype = SALOME_ModuleCatalog::GEOM; + break; + case MESH: + _componenttype = SALOME_ModuleCatalog::MESH; + break; + case Med: + _componenttype = SALOME_ModuleCatalog::Med; + break; + case SOLVER: + _componenttype = SALOME_ModuleCatalog::SOLVER; + break; + case DATA: + _componenttype = SALOME_ModuleCatalog::DATA; + break; + case VISU: + _componenttype = SALOME_ModuleCatalog::VISU; + break; + case SUPERV: + _componenttype = SALOME_ModuleCatalog::SUPERV; + break; + case OTHER: + _componenttype = SALOME_ModuleCatalog::OTHER; + break; + } + + // get component multistudy + _componentmultistudy = _personal_module_list[ind].Parsercomponentmultistudy ; + + // get component icone + _icone = CORBA::string_dup(_personal_module_list[ind].Parsercomponenticone.c_str()); + + // get component interfaces + _list_interfaces = duplicate_interfaces(_personal_module_list[ind].ParserListInterface); + + // get pathes prefix + _pathes = duplicate_pathes(_personal_path_list); + + } + } + + if (find) + { + SALOME_ModuleCatalog_AcomponentImpl* aComponentImpl = + new SALOME_ModuleCatalog_AcomponentImpl(componentname, + _constraint, + _componenttype, + _componentmultistudy, + _icone, + _list_interfaces, + _pathes); + + compo = aComponentImpl->_this(); + } + else + // Not found in the personal catalog => searching in the general catalog + { + for (unsigned int ind=0; ind < _general_module_list.size();ind++) + { + if (strcmp((_general_module_list[ind].Parsercomponentname).c_str(),componentname) == 0) + { + //MESSAGE("Component named " << componentname << " found in the general catalog"); + find = true; + + // get constraint + _constraint = new char[strlen(_general_module_list[ind].Parserconstraint.c_str()) + 1]; + _constraint = CORBA::string_dup(_general_module_list[ind].Parserconstraint.c_str()); + + + // get component type + switch(_general_module_list[ind].Parsercomponenttype){ + case GEOM: + _componenttype = SALOME_ModuleCatalog::GEOM; + break; + case MESH: + _componenttype = SALOME_ModuleCatalog::MESH; + break; + case Med: + _componenttype = SALOME_ModuleCatalog::Med; + break; + case SOLVER: + _componenttype = SALOME_ModuleCatalog::SOLVER; + break; + case DATA: + _componenttype = SALOME_ModuleCatalog::DATA; + break; + case VISU: + _componenttype = SALOME_ModuleCatalog::VISU; + break; + case SUPERV: + _componenttype = SALOME_ModuleCatalog::SUPERV; + break; + case OTHER: + _componenttype = SALOME_ModuleCatalog::OTHER; + break; + } + + + // get component multistudy + _componentmultistudy = _general_module_list[ind].Parsercomponentmultistudy ; + + // get component icone + _icone = CORBA::string_dup(_general_module_list[ind].Parsercomponenticone.c_str()); + + // get component interfaces + _list_interfaces = duplicate_interfaces(_general_module_list[ind].ParserListInterface); + + // get pathes prefix + _pathes = duplicate_pathes(_general_path_list); + } + } + + if (find) + { + SALOME_ModuleCatalog_AcomponentImpl* aComponentImpl = + new SALOME_ModuleCatalog_AcomponentImpl(componentname, + _constraint, + _componenttype, + _componentmultistudy, + _icone, + _list_interfaces, + _pathes); + + compo = aComponentImpl->_this(); + } + else + // Not found in the personal catalog and in the general catalog + // return NULL object + { + MESSAGE("Component with name " << componentname << " not found in catalog"); + compo = NULL; + } + } + return compo; +} + +//---------------------------------------------------------------------- +// Function : _parse_xml_file +// Purpose : parse one module catalog +//---------------------------------------------------------------------- +void +SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file, + ListOfParserComponent& modulelist, + ListOfParserPathPrefix& pathlist) +{ + SALOME_ModuleCatalog_Handler* handler = new SALOME_ModuleCatalog_Handler(); + QFile xmlFile(file); + + QXmlInputSource source(xmlFile); + + QXmlSimpleReader reader; + reader.setContentHandler( handler ); + reader.setErrorHandler( handler ); + reader.parse( source ); + xmlFile.close(); + unsigned int ind; + for ( ind = 0; ind < _modulelist.size(); ind++) + modulelist.push_back(_modulelist[ind]) ; + for ( ind = 0; ind < _pathlist.size(); ind++) + pathlist.push_back(_pathlist[ind]) ; +} + +//---------------------------------------------------------------------- +// Function : duplicate_interfaces +// Purpose : create a list of interfaces from the parsing of the catalog +//---------------------------------------------------------------------- +SALOME_ModuleCatalog::ListOfDefInterface +SALOME_ModuleCatalogImpl::duplicate_interfaces(ListOfDefinitionInterface list_interface) +{ + SALOME_ModuleCatalog::ListOfDefInterface _list_interfaces; + unsigned int _length_interfaces = list_interface.size(); + _list_interfaces.length(_length_interfaces); + + for (unsigned int ind = 0; ind < _length_interfaces; ind++) + { + //duplicate interface name + _list_interfaces[ind].interfacename = CORBA::string_dup(list_interface[ind].Parserinterfacename.c_str()); + + // duplicate service list + unsigned int _length_services = list_interface[ind].Parserinterfaceservicelist.size(); + _list_interfaces[ind].interfaceservicelist.length(_length_services); + + for (unsigned int ind1 = 0; ind1 < _length_services ; ind1 ++) + { + // duplicate service name + _list_interfaces[ind].interfaceservicelist[ind1].ServiceName = + CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceName.c_str()); + + // duplicate service by default + _list_interfaces[ind].interfaceservicelist[ind1].Servicebydefault = + list_interface[ind].Parserinterfaceservicelist[ind1].ParserServicebydefault; + + // duplicate in Parameters + unsigned int _length_in_param = list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter.size(); + _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter.length(_length_in_param); + for (unsigned int ind2 = 0; ind2 < _length_in_param ; ind2 ++) + { + // duplicate parameter type + _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter[ind2].Parametertype = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter[ind2].ParserParamtype.c_str()); + + // duplicate parameter name + _list_interfaces[ind].interfaceservicelist[ind1].ServiceinParameter[ind2].Parametername = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceinParameter[ind2].ParserParamname.c_str()); + } + + // duplicate out Parameters + unsigned int _length_out_param = list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter.size(); + _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter.length(_length_out_param); + for (unsigned int ind2 = 0; ind2 < _length_out_param ; ind2 ++) + { + // duplicate parameter type + _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter[ind2].Parametertype = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter[ind2].ParserParamtype.c_str()); + + // duplicate parameter name + _list_interfaces[ind].interfaceservicelist[ind1].ServiceoutParameter[ind2].Parametername = CORBA::string_dup(list_interface[ind].Parserinterfaceservicelist[ind1].ParserServiceoutParameter[ind2].ParserParamname.c_str()); + } + + } + } + return _list_interfaces; +} + + +//---------------------------------------------------------------------- +// Function : duplicate_pathes +// Purpose : create the path prefix structures from the catalog parsing +//---------------------------------------------------------------------- +ListOfPathPrefix +SALOME_ModuleCatalogImpl::duplicate_pathes(ListOfParserPathPrefix pathes) +{ + ListOfPathPrefix _pathes ; + + unsigned int _length = pathes.size() ; + _pathes.resize(_length); + unsigned int _length_comput = 0; + + for (unsigned int ind = 0; ind < _length ; ind++) + { + // duplicate path + _pathes[ind].path = CORBA::string_dup(pathes[ind].path.c_str()) ; + //MESSAGE("Prefix : " << _pathes[ind].path); + + _length_comput = pathes[ind].ListOfComputer.size() ; + _pathes[ind].ListOfComputer.resize(_length_comput); + for (unsigned int ind1 = 0; ind1 <_length_comput ; ind1++) + { + // duplicate computer name + _pathes[ind].ListOfComputer[ind1] = CORBA::string_dup(pathes[ind].ListOfComputer[ind1].c_str()); + //MESSAGE("Computer associated to the prefix : " <<_pathes[ind].ListOfComputer[ind1]); + } + } + return _pathes ; +} + + +//---------------------------------------------------------------------- +// Function : _verify_path_prefix +// Purpose : verify the path prefix structures from the catalog parsing +// Verify that there only one path prefix associated to a +// particular computer +//---------------------------------------------------------------------- +bool +SALOME_ModuleCatalogImpl::_verify_path_prefix(ListOfParserPathPrefix pathlist) +{ + bool _return_value = true; + vector _machine_list; + _machine_list.resize(0); + + // Fill a list of all computers indicated in the path list + for (unsigned int ind = 0; ind < pathlist.size(); ind++) + { + for (unsigned int ind1 = 0 ; ind1 < pathlist[ind].ListOfComputer.size(); ind1++) + { + _machine_list.push_back(pathlist[ind].ListOfComputer[ind1]); + } + } + + // Parse if a computer name is twice in the list of computers + for (unsigned int ind = 0; ind < _machine_list.size(); ind++) + { + for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++) + { + if(_machine_list[ind].compare(_machine_list[ind1]) == 0) + { + MESSAGE( "The computer " << _machine_list[ind] << " is indicated more than once in the path list") + _return_value = false; + } + } + } + return _return_value; +} + + +//---------------------------------------------------------------------- +// Function : _parseArguments +// Purpose : parse arguments to get general and personal catalog files +//---------------------------------------------------------------------- +bool +SALOME_ModuleCatalogImpl::_parseArguments(int argc, char **argv, + char **_general, + char** _personal) +{ + bool _return_value = true; + *_general = NULL; + *_personal = NULL ; + for (int ind = 0; ind < argc ; ind++) + { + + if (strcmp(argv[ind],"-help") == 0) + { + INFOS( "Usage: " << argv[0] << " -common 'path to general catalog' -personal 'path to personal catalog' -ORBInitRef NameService=corbaname::localhost"); + _return_value = false ; + } + if (strcmp(argv[ind],"-common") == 0) + { + if (ind + 1 < argc) + { + // General catalog file + *_general = argv[ind + 1] ; +/* ifstream _general_file(*_general); + if (!_general_file) + { + MESSAGE( "Sorry the file " << *_general << " can't be open" ) + *_general = NULL; + _return_value = false; + } +*/ + } + } + else if (strcmp(argv[ind],"-personal") == 0) + { + if (ind + 1 < argc) + { + // Personal catalog file + *_personal = argv[ind + 1] ; +/* ifstream _personal_file(*_personal); + if (!_personal_file) + { + MESSAGE("Sorry the file " << *_personal << " can't be open" ) + *_personal = NULL; + _return_value = false; + } +*/ + } + } + } + return _return_value; +} + + diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx new file mode 100644 index 000000000..ff3f71df9 --- /dev/null +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx @@ -0,0 +1,130 @@ +// File: SALOME_ModuleCatalog_impl.hxx +// Created: Tue June 28 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + + +#ifndef MODULECATALOG_IMPL_H +#define MODULECATALOG_IMPL_H + +#include "utilities.h" +#include "SALOME_ModuleCatalog_Handler.hxx" +#include "PathPrefix.hxx" +#include +#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) + +class SALOME_ModuleCatalogImpl: public POA_SALOME_ModuleCatalog::ModuleCatalog, + public PortableServer::RefCountServantBase +{ +public: + //! standard constructor + SALOME_ModuleCatalogImpl(int artgc, char** argv); + + //! standard destructor + virtual ~SALOME_ModuleCatalogImpl(); + + //! method to get a component list + /*! + \return a component list + */ + virtual SALOME_ModuleCatalog::ListOfComputers* GetComputerList(); + + //! method to get the PathPrefix of a computer + /*! If the wanted computer doesn't exist, the Notfound exception is thrown + \param machinename const char* arguments + \return the prefix path + */ + virtual char* GetPathPrefix(const char* machinename); + + //! method to get a component list + /*! + \return a component list + */ + virtual SALOME_ModuleCatalog::ListOfComponents* GetComponentList(); + + //! method to get a component list of component name and component icone + /*! + \return a list of couple (component name, component icone) + */ + virtual SALOME_ModuleCatalog::ListOfIAPP_Affich* GetComponentIconeList(); + + //! method to get a component list of a wanted type + /*! + \return a component list + */ + virtual SALOME_ModuleCatalog::ListOfComponents* + GetTypedComponentList(SALOME_ModuleCatalog::ComponentType component_type); + + //! method to get a component + /*! + \param componentname const char* arguments + \return the wanted component + */ + virtual SALOME_ModuleCatalog::Acomponent_ptr + GetComponent(const char* componentname); + + void ping(){}; + +private: + //! method to parse one module catalog + /*! + \param file const char* arguments + \param modulelist ListOfParserComponent arguments + \param pathlist ListOfParserPathPrefix arguments + */ + virtual void _parse_xml_file(const char* file, + ListOfParserComponent& modulelist, + ListOfParserPathPrefix& pathlist); + + //! method to create a list of interfaces from the parsing of the catalog + /*! + \param list_interface ListOfDefinitionInterface arguments + \return the interfaces list + */ + virtual SALOME_ModuleCatalog::ListOfDefInterface + duplicate_interfaces(ListOfDefinitionInterface list_interface); + + //! method to create the path prefix structures from the catalog parsing + /*! + \param pathes ListOfParserPathPrefix arguments + \return the pathes + */ + virtual ListOfPathPrefix duplicate_pathes(ListOfParserPathPrefix pathes); + + //! method to verify path prefix content + /*! + \param pathlist ListOfParserPathPrefix arguments + \return true if verfication is OK + */ + virtual bool _verify_path_prefix(ListOfParserPathPrefix pathlist); + + + //! method to parse arguments to get general and personal catalog files + /*! + \param argc int arguments + \param argv char** arguments + \param _general char** arguments + \return true if parsing is OK + */ + virtual bool _parseArguments(int argc, char **argv, + char **_general, char** _personal); + + + // Theses variables will contain the path to the general and personal catalogs + char* _general_path; + char* _personal_path; + + + // These variables will contain the informations on the general common catalog + ListOfParserComponent _general_module_list ; + ListOfParserPathPrefix _general_path_list ; + + // These variables will contain the informations on the personal catalog + ListOfParserComponent _personal_module_list ; + ListOfParserPathPrefix _personal_path_list ; + +}; + +#endif // MODULECATALOG_IMPL_H diff --git a/src/ModuleGenerator/IDLparser.py b/src/ModuleGenerator/IDLparser.py new file mode 100644 index 000000000..8900a9f9a --- /dev/null +++ b/src/ModuleGenerator/IDLparser.py @@ -0,0 +1,715 @@ +import string, sys, fpformat, re, os +import xml.sax +import pdb + +from xml.sax.handler import * +from omniidl import idlast, idltype, idlvisitor, idlutil, output + +#values of this map are used in some nodes defenition +common_data={"AUTHOR" : "", + "ICON" : "", + "VERSION" : "", + "COMP_TYPE": "", + "COMP_NAME": "", + "COMP_MULT": "1" + } + +#-------------------------------------------------- +# print error message +#-------------------------------------------------- +def error (message): + print "ERROR : ", message + + +#-------------------------------------------------- +# base class implementing tree +#-------------------------------------------------- +class Tree: + + def __init__(self, name = '', content = ''): + self.name = name + self.content = content + self.parent = None + self.childs = [] + + def addChild(self, tree): + if tree is not None: + self.childs.append(tree) + tree.parent = self + return tree + + def addNamedChild(self, name, content = ''): + return self.addChild(Tree(name, content)) + + def replaceChild(self, tree): + if tree is not None: + pos = 0 + for i in self.childs: + if i.name == tree.name: + self.childs.pop(pos) + self.childs.insert(pos, tree) + return tree + pos += 1 + + return self.addChild(tree) + + def insertFirstChild(self, tree): + if tree is not None: + self.childs.insert(0, tree) + return tree + + def insertFirstNamedChild(self, name, content = ''): + return self.insertFirstChild(Tree(name, content)) + + def output_xml(self, f, depth=0): + d = depth + if self.name != '': + s = string.ljust('', 4*depth) + s += '<' + self.name + '>' + if self.content != '': + s += self.content + else: + if len(self.childs) > 0: + s += '\n' + f.write(s) + d += 1 + + for i in self.childs: + i.output_xml(f, d) + + if self.name != '': + s = '\n' + if len(self.childs) > 0 : + s = string.ljust('', 4*depth) + s + f.write(s) + + def Dump(self, levels=-1, depth=0): + #Dumps the tree contents + + if levels == 0: return + + s = string.ljust('', 4*depth) + print s, self, self.content + for i in self.childs: + i.Dump(levels-1, depth+1) + + def parents(self): + #Returns list of the parents + l = [] + p = self.parent + while p: + l.append(p) + l.append(p.name) + p = p.parent + return l + + def getChild(self, name, content=None): + + # content == None, don't compare content + for i in self.childs: + if (i.name == name): + if (content is None) | (i.content == content): + return i + return None + + def getNode(self, name, content='', depth=-1): + + # recursive search + # content == None, don't compare content + if (self.name == name): + if (content is None) | (self.content == content): + return self + + if (depth != 0): + for i in self.childs: + n = i.getNode(name, content, depth-1) + if n: return n #return a value + + return None + + def __repr__(self): + s = '<' + if self.name != '': + s += self.name + else: + s += 'None' + s += '>' + return s + + def merge(self, t): + pass + +#-------------------------------------------------- +# implements inParameter tree +#-------------------------------------------------- +class inParameter(Tree): + + def __init__(self, name=None, type='', comment=''): + Tree.__init__(self, 'inParameter') + if name is None: return + + self.addNamedChild('inParameter-type', type) + self.addNamedChild('inParameter-name', name) + self.addNamedChild('inParameter-comment', comment) + + def merge(self, P): + + T = P.getChild('inParameter-type') + self.replaceChild(T) + +#-------------------------------------------------- +# implements outParameter tree +#-------------------------------------------------- +class outParameter(Tree): + + def __init__(self, name=None, type='', comment = ''): + + Tree.__init__(self, 'outParameter') + if name is None: return + + self.addNamedChild('outParameter-type', type) + self.addNamedChild('outParameter-name', name) + self.addNamedChild('outParameter-comment', comment) + + def merge(self, P): + + T = P.getChild('outParameter-type') + self.replaceChild(T) + +#-------------------------------------------------- +# implements service tree +#-------------------------------------------------- +class Service(Tree): + + def __init__(self, name=None): + + Tree.__init__(self, 'component-service') + if name is None: return + + self.addNamedChild('service-name', name) + self.addNamedChild('service-author',common_data["AUTHOR"]) + self.addNamedChild('service-version',common_data["VERSION"]) + self.addNamedChild('service-comment') + self.addNamedChild('service-by-default', "0") + self.addNamedChild('inParameter-list') + self.addNamedChild('outParameter-list') + + def createInParameter(self, name, type): + L = self.getChild('inParameter-list') + if L is None: + error ("Service.createInParameter() : 'inParameter-list' is not found"); return None; + p = inParameter(name, type) + L.addChild(p) + return p + + def createOutParameter(self, name, type): + L = self.getChild('outParameter-list') + if L is None: + error ("Service.createOutParameter() : 'outParameter-list' is not found"); return None; + p = outParameter(name, type) + L.addChild(p) + return p + + + def merge(self, S): + + L_ext = S.getChild('inParameter-list') + L_int = self.getChild('inParameter-list') + + if L_ext is not None and L_int is not None: + + L_merge = Tree('inParameter-list') + + for i_ext in L_ext.childs: + # i_ext = + n_ext = i_ext.getChild('inParameter-name') + if n_ext is None: continue + present = 0 + + for i_int in L_int.childs: + # i_int = + n_int = i_int.getChild('inParameter-name') + + if n_int is None: continue + + if (n_int.content == n_ext.content): + present = 1 + break; + + if present : + i_int.merge(i_ext) + L_merge.addChild(i_int) + else: + L_merge.addChild(i_ext) + + self.replaceChild(L_merge) + + else : error("Service.merge(): 'inParameter-list' is not found") #either L_ext or L_int is None + + L_ext = S.getChild('outParameter-list') + L_int = self.getChild('outParameter-list') + + if L_ext is None or L_int is None: + error ("Service.merge() : 'outParameter-list' is not found") + + L_merge = Tree('outParameter-list') + + for i_ext in L_ext.childs: + #i_ext = + present = 0 + n_ext = i_ext.getChild('outParameter-name') + if n_ext is None: continue + for i_int in L_int.childs: + n_int = i_int.getChild('outParameter-name') + if n_int is None: continue + if (n_int.content == n_ext.content): + present = 1 + break; + + if present : + i_int.merge(i_ext) + L_merge.addChild(i_int) + else: + L_merge.addChild(i_ext) + + self.replaceChild(L_merge) + + +#-------------------------------------------------- +# implements interface tree +#-------------------------------------------------- +class Interface(Tree): + + def __init__(self, name=None): + + Tree.__init__(self) + + if name is None: return + + self.addNamedChild('component-interface-name', name) + self.addNamedChild('component-interface-comment'); + self.addNamedChild('component-service-list') + + def createService(self, name): + L = self.getChild('component-service-list') + + if L is None: + error ("Interface.createService() : 'component-service-list' is not found") + return None + + s = Service(name) + L.addChild(s) + return s + + def merge(self, I): + + L_ext = I.getChild('component-service-list') + L_int = self.getChild('component-service-list') + + if L_ext is None or L_int is None: + error("Interface.merge() : 'component-service-list' is not found!") + return + + L_merge = Tree('component-service-list') + + for i_ext in L_ext.childs: + + present = 0 + n_ext = i_ext.getChild('service-name') + if n_ext is None: continue + + for i_int in L_int.childs: + n_int = i_int.getChild('service-name') + if n_int is None: continue + if (n_int.content == n_ext.content): + present = 1 + break; + + if present == 0: + i_int.merge(i_ext) + L_merge.addChild(i_int) + else: + L_merge.addChild(i_ext) + + self.replaceChild(L_merge) + + +#-------------------------------------------------- +# implements Component tree +#-------------------------------------------------- +class Component(Tree): + def __init__(self, name=None): + Tree.__init__(self, 'component') + + if name is None: return + + self.addNamedChild('component-name', name) + self.addNamedChild('component-type',common_data["COMP_TYPE"]) + self.addNamedChild('component-author',common_data["AUTHOR"]) + self.addNamedChild('component-version',common_data["VERSION"]) + self.addNamedChild('component-comment') + self.addNamedChild('component-multistudy', common_data["COMP_MULT"]) + self.addNamedChild('component-icone',common_data["ICON"]) + self.addNamedChild('constraint') + self.addNamedChild('component-interface-list') + + def createInterface(self, name): + L = self.getChild('component-interface-list') + if L is None: + error("createInterface: No component-interface-list is found") + return None + i = Interface(name) + L.addChild(i) + return i + + def merge(self, C): + ext=C.getChild('component-author') + int=self.getChild('component-author') + if int is not None and ext is not None and len(ext.content): + int.content = ext.content + + ext=C.getChild('component-type') + int=self.getChild('component-type') + if int is not None and ext is not None and len(ext.content): + int.content = ext.content + + ext=C.getChild('component-icone') + int=self.getChild('component-icone') + if int is not None and ext is not None and len(ext.content): + int.content = ext.content + + ext=C.getChild('component-version') + int=self.getChild('component-version') + if int is not None and ext is not None and len(ext.content): + int.content = ext.content + + ext=C.getChild('component-comment') + int=self.getChild('component-comment') + if int is not None and ext is not None and len(ext.content): + int.content = ext.content + + ext=C.getChild('component-multistudy') + int=self.getChild('component-multistudy') + if int is not None and ext is not None and len(ext.content): + int.content = ext.content + + ext=C.getChild('constraint') + int=self.getChild('constraint') + if int is not None and ext is not None and len(ext.content): + int.content = ext.content + + L_ext = C.getChild('component-interface-list') + L_int = self.getChild('component-interface-list') + if L_ext is None or L_int is None: + error("Component.merge : No component-interface-list is found") + return + L_merge = Tree('component-interface-list') + + for i_ext in L_ext.childs: + present = 0 + n_ext = i_ext.getChild('component-interface-name') + + if n_ext is None: continue + + for i_int in L_int.childs: + n_int = i_int.getChild('component-interface-name') + if n_int is None: continue + if (n_int.content == n_ext.content): + present = 1 + break; + + if present : + i_int.merge(i_ext) + L_merge.addChild(i_int) + else: + L_merge.addChild(i_ext) + + self.replaceChild(L_merge) + +#-------------------------------------------------- +# implements document tree +#-------------------------------------------------- +class Catalog(ContentHandler, Tree): + def __init__(self, filename = None): + Tree.__init__(self) + self.buffer = '' + self.list = [] + if (filename): + parser = xml.sax.make_parser() + parser.setContentHandler(self) + parser.parse(filename) + else: + t = self.addNamedChild('begin-catalog') + t.addNamedChild('component-list') + + n = self.getChild('begin-catalog') + if n is None: + error("Catalog.__init__ : No 'begin-catalog' is found!") + return + if n.getChild('path-prefix-list') is None: + n.insertFirstNamedChild('path-prefix-list') + if n.getChild('component-list') is None: + n.addNamedChild('component-list') + + def removeComponent(self, name): + complist = self.getNode('component-list') + idx = 0 + if complist is None: + print "Catalog.removeComponent() : 'component-list' is not found" + return + for comp in complist.childs: + cname = comp.getChild('component-name') + if cname is not None: + if cname.content == name: + complist.childs.pop(idx) + print "Component " + name + " is removed" + idx += 1 + + def startDocument(self): + self.list.append(self) + + def startElement(self, name, attrs): + p = self.list[len(self.list)-1] + + if name == 'component': + e = p.addChild(Component()) + elif name == 'component-interface-name': + e = p.addNamedChild(name) + elif name == 'component-service': + e = p.addChild(Service()) + elif name == 'inParameter': + e = p.addChild(inParameter()) + elif name == 'outParameter': + e = p.addChild(outParameter()) + else: + e = p.addNamedChild(name) + self.list.append(e) + self.buffer = '' + + def endElement(self, name): + self.buffer = string.join(string.split(self.buffer), ' ') + p = self.list[len(self.list)-1] + p.content = self.buffer + self.buffer = '' + e = self.list.pop() + + + def characters(self, ch): + self.buffer += ch + + def mergeComponent(self, comp): + + L_int = self.getNode('component-list') + if L_int is None: + error("Catalog.mergeComponent : 'component-list' is not found") + return + + i_ext = comp + present = 0 + n_ext = i_ext.getChild('component-name') + if n_ext is None: + error("Catalog.mergeComponent : 'component-name' is not found") + return + for i_int in L_int.childs: + n_int = i_int.getChild('component-name') + if n_int is None: continue + + if (n_int.content == n_ext.content): + present = 1 + break; + + if present == 0: + print ' add component', n_ext.content + L_int.addChild(i_ext) + else: + print ' replace component', n_ext.content + i_int.merge(i_ext) + + + + +# IDL file reader + +ttsMap = { + idltype.tk_void: "void", + idltype.tk_short: "short", + idltype.tk_long: "long", + idltype.tk_ushort: "unsigned short", + idltype.tk_ulong: "unsigned long", + idltype.tk_float: "float", + idltype.tk_double: "double", + idltype.tk_boolean: "boolean", + idltype.tk_char: "char", + idltype.tk_octet: "octet", + idltype.tk_any: "any", + idltype.tk_TypeCode: "CORBA::TypeCode", + idltype.tk_Principal: "CORBA::Principal", + idltype.tk_longlong: "long long", + idltype.tk_ulonglong: "unsigned long long", + idltype.tk_longdouble: "long double", + idltype.tk_wchar: "wchar" + } + + +#-------------------------------------------------- +# class ModuleCatalogVisitor +#-------------------------------------------------- +class ModuleCatalogVisitor (idlvisitor.AstVisitor): + + def __init__(self, catalog): + self.catalog = catalog + self.EngineType = 0 + + def visitAST(self, node): + for n in node.declarations(): + n.accept(self) + + def visitModule(self, node): + for n in node.definitions(): + n.accept(self) + + def visitInterface(self, node): + if node.mainFile(): + + self.EngineType = 0 + + for i in node.inherits(): + s = i.scopedName(); + if ((s[0] == "Engines") & (s[1] == "Component")): + self.EngineType = 1; break + + if common_data["COMP_NAME"] : Comp = Component(common_data["COMP_NAME"]) + else : Comp = Component(node.identifier()) + + self.currentInterface = Comp.createInterface(node.identifier()) + + for c in node.callables(): + if isinstance(c, idlast.Operation): + c.accept(self) + + if (self.EngineType): + self.catalog.mergeComponent(Comp) + + self.EngineType = 0 + + def visitOperation(self, node): + + self.currentService = self.currentInterface.createService \ + (node.identifier()) + + for c in node.parameters(): + c.accept(self) + + node.returnType().accept(self) + if (self.currentType != "void"): + self.currentService.createOutParameter \ + ("return", self.currentType) + + + def visitDeclaredType(self, type): + self.currentType = type.name() + + def visitBaseType(self, type): + self.currentType = ttsMap[type.kind()] + + def visitStringType(self, type): + self.currentType = "string" + + def visitParameter(self, node): + node.paramType().accept(self) + if node.is_in(): + self.currentService.createInParameter \ + (node.identifier(), self.currentType) + if node.is_out(): + self.currentService.createOutParameter \ + (node.identifier(), self.currentType) + +#-------------------------------------------------- +# extract value of from list +# it's proposed that the matching item +# looks like =, for example, +# catalog=/tmp/myxml.xml +#-------------------------------------------------- +def getParamValue( param_name, args ): + pattern="^"+param_name+"=" + + res = "" #initial value + for opt in args: + s = re.compile(pattern).search(opt) + if s: + res = opt[s.end():] + break #found + + return res + +#-------------------------------------------------- +# parse idl and store xml file +#-------------------------------------------------- +def run(tree, args): + CatalogFileName=getParamValue("catalog",args) + if CatalogFileName is None: + CatalogFileName = 'CatalogModulePersonnel.xml' + + if (re.compile(".*?.xml$").match(CatalogFileName, 1) is None): + CatalogFileName = CatalogFileName + '.xml' + + #========= Read parameters ====================== + common_data["ICON"] = getParamValue("icon",args) # get icon file + + common_data["AUTHOR"] = getParamValue("author",args) # get author name + if common_data["AUTHOR"] is None: common_data["AUTHOR"] = os.getenv("USER"); + + common_data["VERSION"] = getParamValue("version",args) # get version + + common_data["COMP_NAME"] = getParamValue("name",args) # get icon file + + val = getParamValue("type",args) # get icon file + if val: common_data["COMP_TYPE"] = val + + val = getParamValue("multistudy",args) # get icon file + if val : common_data["COMP_MULT"] = val + + remove_comp = getParamValue("remove", args) + + #================================================== + + if (os.path.exists(CatalogFileName)): + print "Importing", CatalogFileName + C = Catalog(CatalogFileName) + else: + print "Warning : ",CatalogFileName, " was not found." + C = Catalog() + + print "Reading idl file" + + visitor = ModuleCatalogVisitor(C) + tree.accept(visitor) + + if remove_comp : + C.removeComponent(remove_comp) + + if (os.path.exists(CatalogFileName)): + print "Updating", CatalogFileName + CatalogFileName_old = CatalogFileName + '_old' + os.rename(CatalogFileName, CatalogFileName_old) + else: + CatalogFileName_old = "" + print "Writing", CatalogFileName + + CatalogFileName_new = CatalogFileName + '_new' + f=open(CatalogFileName_new, 'w') + f.write("\n\n") + C.output_xml(f) + f.close() + + os.rename(CatalogFileName_new, CatalogFileName) + if ((CatalogFileName_old != "") & os.path.exists(CatalogFileName_old)): + os.unlink(CatalogFileName_old) + + print + + +if __name__ == "__main__": + print + print "Usage : omniidl -bIDLparser -Wbcatalog=[,icon=][,version=][,author=][,name=][,multistudy=][,remove=component_name] " + print diff --git a/src/ModuleGenerator/Makefile.in b/src/ModuleGenerator/Makefile.in new file mode 100644 index 000000000..6c9a11abf --- /dev/null +++ b/src/ModuleGenerator/Makefile.in @@ -0,0 +1,21 @@ +#============================================================================== +# File : Makefile.in +# Created : 24 apr 2002 +# Author : Marc Tajchman +# Project : SALOME +# Copyright : CEA +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_PYSCRIPTS = IDLparser.py + +@CONCLUDE@ diff --git a/src/ModuleGenerator/README b/src/ModuleGenerator/README new file mode 100644 index 000000000..c5b46c91f --- /dev/null +++ b/src/ModuleGenerator/README @@ -0,0 +1,77 @@ +Outil de generation du catalogue de module +a partir des fichiers idl corba. +version 0.1 (12/4/2002) + +Marc Tajchman (CEA) + +______________________________________________________________________ +Etat : + + Version initiale + +______________________________________________________________________ +A faire : + + Tests supplementaires pour l'ajout et le remplacement + de composants + + Implementation du retrait de composant + + Gestion des champs du catalogue de modules non presents + dans les fichiers idl + + Autres generations (wrappers divers ...) + +______________________________________________________________________ +Utilisation : + + Une seule commande dans tous les cas de figure : + + runIDLparser -Wbcatalog=my_catalog.xml + + (appel de runIDLparser pour interpreter et + mettre a jour le catalogue de module my_catalog.xml) + +______________________________________________________________________ +Tests d'utilisation : + +Pour lancer les tests, utiliser le script 'testIDLparser' depuis +le repertoire /SALOME/src/ModuleGenerator : + + sh testIDLparser + +ou vaut 1, 1b, 2, 3, 4, 5 + + _________________________________________ +1. Creation d'un nouveau catalogue de composants my_catalog.xml + a partir d'un fichier idl + Le fichier idl contient un seul composant Salome. + + _________________________________________ +1b. Creation d'un nouveau catalogue de composants my_catalog.xml + a partir d'un fichier idl + Le fichier idl contient un composant et une interface CORBA + qui n'est pas un composant Salome (i.e. ne derive pas de + Engines::Component). + + _________________________________________ +2. Un meme fichier idl est lu deux fois + + _________________________________________ +3. Deux fichiers idl differents sont lus, puis le premier est relu + + _________________________________________ +4. Deux fichiers idl contenant deux versions differentes du meme + composant sont lus. Teste aussi la 'persistance' des champs + 'commentaires' + + _________________________________________ +5. Test global sur les idl de Salome + + +Les scripts de test se trouvent dans le repertoire + /SALOME/src/ModuleGenerator/tests + +Les fichiers idl servant aux tests se trouvent dans les repertoires + /idl + /SALOME/src/ModuleGenerator/tests diff --git a/src/ModuleGenerator/testIDLparser.in b/src/ModuleGenerator/testIDLparser.in new file mode 100755 index 000000000..5daf6da85 --- /dev/null +++ b/src/ModuleGenerator/testIDLparser.in @@ -0,0 +1,7 @@ +#!/bin/bash + +export ROOT_SRCDIR=@ROOT_SRCDIR@ +export ROOT_BUILDDIR=@ROOT_BUILDDIR@ +export SRCDIR=${ROOT_SRCDIR}/SALOME/src/ModuleGenerator + +${SRCDIR}/tests/test$1.sh diff --git a/src/ModuleGenerator/tests/Truc2Component.idl b/src/ModuleGenerator/tests/Truc2Component.idl new file mode 100644 index 000000000..4e919d804 --- /dev/null +++ b/src/ModuleGenerator/tests/Truc2Component.idl @@ -0,0 +1,22 @@ +//============================================================================= +// File : AddComponent.idl +// Created : jeu jui 12 12:08:17 CEST 2001 +// Author : +// Project : SALOME +// /export/home/CVS/SALOME_ROOT/idl/AddComponent.idl,v 1.2 2001/12/11 16:27:31 rahuel Exp +//============================================================================= + +#ifndef _ADDCOMPONENT_IDL +#define _ADDCOMPONENT_IDL + +#include "SALOME_Component.idl" + +interface AddComponent : Engines::Component +{ + double Add( in double x , in double y , out double z ) ; + double XXX( in double x , out double y , out double z ) ; +}; + + + +#endif diff --git a/src/ModuleGenerator/tests/TrucComponent.idl b/src/ModuleGenerator/tests/TrucComponent.idl new file mode 100644 index 000000000..b63efad9b --- /dev/null +++ b/src/ModuleGenerator/tests/TrucComponent.idl @@ -0,0 +1,25 @@ +//============================================================================= +// File : AddComponent.idl +// Created : jeu jui 12 12:08:17 CEST 2001 +// Author : +// Project : SALOME +// /export/home/CVS/SALOME_ROOT/idl/AddComponent.idl,v 1.2 2001/12/11 16:27:31 rahuel Exp +//============================================================================= + +#ifndef _ADDCOMPONENT_IDL +#define _ADDCOMPONENT_IDL + +#include "SALOME_Component.idl" + +interface AddComponent +{ + double Add( in double x , in double y , out double z ) ; +}; + +interface TrucComponent : Engines::Component +{ + double Add( in double x , in double y , out double z ) ; +}; + + +#endif diff --git a/src/ModuleGenerator/tests/test1.sh b/src/ModuleGenerator/tests/test1.sh new file mode 100755 index 000000000..25e5451ec --- /dev/null +++ b/src/ModuleGenerator/tests/test1.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +echo "test1: + + creation d'un nouveau catalogue avec un composant unique + dans un fichier idl + " + +\rm -f my_catalog.xml* + +${ROOT_BUILDDIR}/bin/runIDLparser \ + -Wbcatalog=my_catalog.xml \ + ${ROOT_SRCDIR}/idl/AddComponent.idl + diff --git a/src/ModuleGenerator/tests/test1b.sh b/src/ModuleGenerator/tests/test1b.sh new file mode 100755 index 000000000..53825f7a2 --- /dev/null +++ b/src/ModuleGenerator/tests/test1b.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +echo "test6: + + test derivation Engine::Component + " + +\rm -f my_catalog.xml* + + +echo " +--> creation d'un nouveau catalogue avec un composant +" + +${ROOT_BUILDDIR}/bin/runIDLparser \ + -Wbcatalog=my_catalog.xml \ + ${SRCDIR}/tests/TrucComponent.idl + diff --git a/src/ModuleGenerator/tests/test2.sh b/src/ModuleGenerator/tests/test2.sh new file mode 100755 index 000000000..6ff0261d9 --- /dev/null +++ b/src/ModuleGenerator/tests/test2.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +echo "test2: + + ajout dans un catalogue existant d'un nouveau composant + d'un fichier idl + remplacement d'un composant par une + nouvelle version + " + +\rm -f my_catalog.xml* + +echo " +--> creation d'un nouveau catalogue avec un composant +" + +${ROOT_BUILDDIR}/bin/runIDLparser \ + -Wbcatalog=my_catalog.xml \ + ${ROOT_SRCDIR}/idl/AddComponent.idl + + +echo " +--> ajout d'un nouveau composant dans le catalogue +" + +${ROOT_BUILDDIR}/bin/runIDLparser \ + -Wbcatalog=my_catalog.xml \ + ${ROOT_SRCDIR}/idl/SubComponent.idl + + +echo " +--> remplacement du premier composant dans le catalogue +" + +${ROOT_BUILDDIR}/bin/runIDLparser \ + -Wbcatalog=my_catalog.xml \ + ${ROOT_SRCDIR}/idl/AddComponent.idl + diff --git a/src/ModuleGenerator/tests/test3.sh b/src/ModuleGenerator/tests/test3.sh new file mode 100755 index 000000000..15faa9581 --- /dev/null +++ b/src/ModuleGenerator/tests/test3.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +echo "test3: + + remplacement dans un catalogue existant d'un composant existant + (meme idl) + " + +\rm -f my_catalog.xml* + + +echo " +--> creation d'un nouveau catalogue avec un composant +" + +${ROOT_BUILDDIR}/bin/runIDLparser \ + -Wbcatalog=my_catalog.xml \ + ${ROOT_SRCDIR}/idl/AddComponent.idl + +echo " +--> remplacement du composant dans le catalogue (meme idl) +" + +${ROOT_BUILDDIR}/bin/runIDLparser \ + -Wbcatalog=my_catalog.xml \ + ${ROOT_SRCDIR}/idl/AddComponent.idl diff --git a/src/ModuleGenerator/tests/test4.sh b/src/ModuleGenerator/tests/test4.sh new file mode 100755 index 000000000..4d8051a99 --- /dev/null +++ b/src/ModuleGenerator/tests/test4.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +echo "test4: + + remplacement dans un catalogue existant d'un composant existant + (l'idl du composant a ete modifie) + " + +\rm -f my_catalog.xml* + +echo " +--> creation d'un nouveau catalogue avec un composant +" + +${ROOT_BUILDDIR}/bin/runIDLparser \ + -Wbcatalog=my_catalog.xml \ + ${ROOT_SRCDIR}/idl/AddComponent.idl + + +mv my_catalog.xml C1 +sed -e 's/arameter-comment>aaa C2 +sed -e 's/service-comment>bbb C1 +sed -e 's/interface-comment>ccc C2 +sed -e 's/component-comment>ddd C1 +mv C1 my_catalog.xml +\rm -f C2 + + echo " + --> remplacement du composant dans le catalogue (autre idl) +" + +${ROOT_BUILDDIR}/bin/runIDLparser \ + -Wbcatalog=my_catalog.xml \ + ${SRCDIR}/tests/Truc2Component.idl + diff --git a/src/ModuleGenerator/tests/test5.sh b/src/ModuleGenerator/tests/test5.sh new file mode 100755 index 000000000..1e0370047 --- /dev/null +++ b/src/ModuleGenerator/tests/test5.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +echo "test4: + + creation d'un catalogue avec tous les idl de Salome + (au 29/3/2002) + " + +\rm -f my_catalog.xml* + +for i in ${ROOT_SRCDIR}/idl/*.idl +do + echo + echo " processing " `basename $i` + echo + ${ROOT_BUILDDIR}/bin/runIDLparser \ + -Wbcatalog=my_catalog.xml $i +done diff --git a/src/NOTIFICATION_SWIG/Makefile.in b/src/NOTIFICATION_SWIG/Makefile.in new file mode 100644 index 000000000..8a1202359 --- /dev/null +++ b/src/NOTIFICATION_SWIG/Makefile.in @@ -0,0 +1,33 @@ +#============================================================================== +# File : Makefile.in +# Created : mar jui 3 12:58:13 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + +@COMMENCE@ + +# Libraries targets + +EXPORT_HEADERS = + +LIB = libNOTIFICATIONcmodule.la +LIB_SRC = NOTIFICATION_Swig.cxx + +SWIG_DEF = NOTIFICATION.i +EXPORT_PYSCRIPTS = libNOTIFICATION.py +SWIG_FLAGS += -I$(srcdir) + +CPPFLAGS+=$(PYTHON_INCLUDES) -DHAVE_CONFIG_H +LIBS+= $(PYTHON_LIBS) +LDFLAGS+= -lSalomeNotification + +@CONCLUDE@ diff --git a/src/NOTIFICATION_SWIG/NOTIFICATION.i b/src/NOTIFICATION_SWIG/NOTIFICATION.i new file mode 100644 index 000000000..6145ba023 --- /dev/null +++ b/src/NOTIFICATION_SWIG/NOTIFICATION.i @@ -0,0 +1,15 @@ +// File : NOTIFICATION.i +// Created : 10 Juin 2002 +// Author : Francis KLOSS +// Project : SALOME +// Module : Notification +// Copyright : Open CASCADE + +%module libNOTIFICATION + +%{ +#include "NOTIFICATION_Swig.hxx" +%} + +%include NOTIFICATION.hxx +%include NOTIFICATION_Swig.hxx diff --git a/src/NOTIFICATION_SWIG/NOTIFICATION_Swig.cxx b/src/NOTIFICATION_SWIG/NOTIFICATION_Swig.cxx new file mode 100644 index 000000000..f7a8ea54e --- /dev/null +++ b/src/NOTIFICATION_SWIG/NOTIFICATION_Swig.cxx @@ -0,0 +1,39 @@ +using namespace std; +// File : NOTIFICATION_Swig.cxx +// Created : 10 Juin 2002 +// Author : Francis KLOSS +// Project : SALOME +// Module : Notification Swig +// Copyright : Open CASCADE + +#include "NOTIFICATION_Swig.hxx" + +// Swig notification supplier +// -------------------------- + +NOTIFICATION_Supplier_Swig::NOTIFICATION_Supplier_Swig(const char* instanceName, bool notif) { + _supplier = new NOTIFICATION_Supplier(instanceName, notif); +} + +NOTIFICATION_Supplier_Swig::~NOTIFICATION_Supplier_Swig() { + delete _supplier; +} + +void NOTIFICATION_Supplier_Swig::Send(const char* graph, const char* node, const char* type, const char* message) { + _supplier->Send(graph, node, type, message); +} + +// Swig notification consumer +// -------------------------- + +NOTIFICATION_Consumer_Swig::NOTIFICATION_Consumer_Swig() { + _consumer = new NOTIFICATION_Consumer(); +} + +NOTIFICATION_Consumer_Swig::~NOTIFICATION_Consumer_Swig() { + delete _consumer; +} + +bool NOTIFICATION_Consumer_Swig::Receive(char** graph, char** node, char** type, char** message, char** sender, long* counter, char** date, long* stamp) { + return(_consumer->Receive(graph, node, type, message, sender, counter, date, stamp)); +} diff --git a/src/NOTIFICATION_SWIG/NOTIFICATION_Swig.hxx b/src/NOTIFICATION_SWIG/NOTIFICATION_Swig.hxx new file mode 100644 index 000000000..f554d7eef --- /dev/null +++ b/src/NOTIFICATION_SWIG/NOTIFICATION_Swig.hxx @@ -0,0 +1,29 @@ +// File : NOTIFICATION_Swig.hxx +// Created : 10 Juin 2002 +// Author : Francis KLOSS +// Project : SALOME +// Module : Notification Swig +// Copyright : Open CASCADE +using namespace std; + +#include "NOTIFICATION.hxx" + +class NOTIFICATION_Supplier_Swig { + public: + NOTIFICATION_Supplier_Swig(const char* instanceName, bool notif); + ~NOTIFICATION_Supplier_Swig(); + void Send(const char* graph, const char* node, const char* type, const char* message); + + private: + NOTIFICATION_Supplier* _supplier; +}; + +class NOTIFICATION_Consumer_Swig { + public: + NOTIFICATION_Consumer_Swig(); + ~NOTIFICATION_Consumer_Swig(); + bool Receive(char** graph, char** node, char** type, char** message, char** sender, long* counter, char** date, long* stamp); + + private: + NOTIFICATION_Consumer* _consumer; +}; diff --git a/src/NamingService/Makefile.in b/src/NamingService/Makefile.in new file mode 100644 index 000000000..ab8cc086e --- /dev/null +++ b/src/NamingService/Makefile.in @@ -0,0 +1,31 @@ +#============================================================================== +# File : Makefile.in +# Created : mar jui 3 12:58:13 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_PYSCRIPTS = SALOME_NamingServicePy.py + +EXPORT_HEADERS = \ + SALOME_NamingService.hxx \ + ServiceUnreachable.hxx +# Libraries targets + +LIB = libSalomeNS.la +LIB_SRC = SALOME_NamingService.cxx ServiceUnreachable.cxx + +LDFLAGS+= -lOpUtil + +@CONCLUDE@ diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx new file mode 100644 index 000000000..b4a4ebb2e --- /dev/null +++ b/src/NamingService/SALOME_NamingService.cxx @@ -0,0 +1,1288 @@ +using namespace std; +// File: SALOME_NamingService.cxx +// Created: Tue June 12 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + +//---------------------------------------------------------------------- +#include "SALOME_NamingService.hxx" +#include "ServiceUnreachable.hxx" +#include +#include + +//---------------------------------------------------------------------- +/*! Function : SALOME_NamingService + * Purpose : Constructor and Initialisation of _root_context + */ +//---------------------------------------------------------------------- + +SALOME_NamingService::SALOME_NamingService() +{ + MESSAGE("SALOME_NamingService default constructor"); + _orb = CORBA::ORB::_nil(); +} + +//---------------------------------------------------------------------- +/*! Function : SALOME_NamingService + * \param orb CORBA::ORB_ptr arguments + */ +//---------------------------------------------------------------------- + +SALOME_NamingService::SALOME_NamingService(CORBA::ORB_ptr orb) +{ + MESSAGE("SALOME_NamingService creation"); + _orb = orb ; + _initialize_root_context(); +} + +//---------------------------------------------------------------------- +/*! Function : ~SALOME_NamingService + * Purpose : Destructor + */ +//---------------------------------------------------------------------- + +SALOME_NamingService::~SALOME_NamingService() +{ + MESSAGE("SALOME_NamingService destruction"); +} + +//---------------------------------------------------------------------- +/*! Function : init_orb + * initialize ORB reference after default constructor + */ +//---------------------------------------------------------------------- + +void SALOME_NamingService::init_orb(CORBA::ORB_ptr orb) +{ + // MESSAGE("SALOME_NamingService initialisation"); + _orb = orb ; + _initialize_root_context(); +} + + +//---------------------------------------------------------------------- +/*! Function : Register + * Method to create an association in the NamingService between ObjRef + * and Path. + * If the NamingService is out, the exception ServiceUnreachable is thrown + * \param ObjRef CORBA::Object_ptr arguments + * \param Path const char* arguments + */ +//---------------------------------------------------------------------- + +void SALOME_NamingService::Register(CORBA::Object_ptr ObjRef, + const char* Path) + throw(ServiceUnreachable) +{ + // MESSAGE("BEGIN OF Register: "<< Path); + int dimension_Path = strlen(Path) + 1; + char** resultat_resolve_Path = new char* [dimension_Path]; + + // _current_context is replaced to the _root_context + // if the Path begins whith '/' + if (Path[0]=='/') { + _current_context = _root_context; + // MESSAGE("Gone to the _root_context"); + } + + //the resolution of the directory path has to be done + //to place the currect_context to the correct node + int dimension_resultat = 0; + _result_resolve_Path (Path, dimension_resultat, resultat_resolve_Path); + + CosNaming::Name _context_name; + CORBA::Boolean _not_exist = false ; + CosNaming::NamingContext_var _temp_context; + + if(dimension_resultat>1) + { + // A directory is treated (not only an object name) + // We had to test if the directory where ObjRef should be recorded + // is already done + // If not, the new context has to be created + + // MESSAGE("A complet Path has to be treated, not only an object name"); + _context_name.length(dimension_resultat-1); + + _create_context_name_dir(resultat_resolve_Path,dimension_resultat-1, + _context_name); + + try + { + CORBA::Object_var _obj = _current_context->resolve(_context_name); + _current_context = CosNaming::NamingContext::_narrow(_obj); + } + catch (CosNaming::NamingContext::NotFound &) + { + // failed to resolve, therefore assume cold start + _not_exist = true; + } + catch (CosNaming::NamingContext::InvalidName &) + { + INFOS("!!!Register() : CosNaming::NamingContext::InvalidName"); + } + catch (CosNaming::NamingContext::CannotProceed &) + { + INFOS("!!!Register() : CosNaming::NamingContext::CannotProceed"); + } + catch(CORBA::COMM_FAILURE&) + { + INFOS("!!!Register() : CORBA::COMM_FAILURE : unable to contact" + << " the naming service"); + throw ServiceUnreachable(); + } + if(_not_exist) + { + try + { + _context_name.length(1); + // MESSAGE("The Path indicated is not yet created. It will soon be done"); + for (int i = 0 ; i resolve(_context_name); + _current_context = + CosNaming::NamingContext::_narrow(_obj); + //MESSAGE("This context was already created"); + } + catch (CosNaming::NamingContext::NotFound &) + { + // This context is not created. It will be done + _temp_context = + _current_context->bind_new_context(_context_name); + _current_context = _temp_context; + //MESSAGE("This context was'nt created, it's now done"); + } + } + } + catch (CosNaming::NamingContext::AlreadyBound&) + { + INFOS("!!!Register() : CosNaming::NamingContext::AlreadyBound"); + } + catch(CosNaming::NamingContext::NotFound& ex) + { + CosNaming::Name n = ex.rest_of_name; + if (ex.why == CosNaming::NamingContext::missing_node) + INFOS("Register() : " << (char *) n[0].id + << " (" << (char *) n[0].kind << ") not found"); + if (ex.why == CosNaming::NamingContext::not_context) + INFOS("Register() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not a context"); + if (ex.why == CosNaming::NamingContext::not_object) + INFOS("Register() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not an object"); + } + catch(CosNaming::NamingContext::CannotProceed&) + { + INFOS("!!!Register() : CosNaming::NamingContext::CannotProceed"); + } + catch(CosNaming::NamingContext::InvalidName&) + { + INFOS("!!!Register() : CosNaming::NamingContext::InvalidName"); + } + catch(CORBA::COMM_FAILURE&) + { + INFOS("!!!Register() :CORBA::COMM_FAILURE : unable to contact" + << " the naming service"); + throw ServiceUnreachable(); + } + } + } + + // The current directory is now the directory where the object should + // be recorded + _context_name.length(1); + try + { + // the last element is an object an not a directory + _context_name[0].id = + CORBA::string_dup(resultat_resolve_Path[dimension_resultat -1]); + _context_name[0].kind = CORBA::string_dup("object"); + //SCRUTE(_context_name[0].id); + + _current_context->bind(_context_name, ObjRef); + // MESSAGE("A new element " << _context_name[0].id + // << " is recorded in the _current_context"); + } + catch(CosNaming::NamingContext::NotFound& ex) + { + CosNaming::Name n = ex.rest_of_name; + if (ex.why == CosNaming::NamingContext::missing_node) + INFOS("Register() : " << (char *) n[0].id + << " (" << (char *) n[0].kind << ") not found"); + if (ex.why == CosNaming::NamingContext::not_context) + INFOS("Register() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not a context"); + if (ex.why == CosNaming::NamingContext::not_object) + INFOS("Register() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not an object"); + } + catch(CosNaming::NamingContext::CannotProceed&) + { + INFOS("!!!Register() : CosNaming::NamingContext::CannotProceed"); + } + catch(CosNaming::NamingContext::InvalidName&) + { + INFOS("!!!Register() : CosNaming::NamingContext::InvalidName"); + } + catch(CosNaming::NamingContext::AlreadyBound&) + { + INFOS("!!!Register() : CosNaming::NamingContext::AlreadyBound, object will be rebind"); + _current_context->rebind(_context_name, ObjRef); + } + catch(CORBA::COMM_FAILURE&) + { + INFOS("!!!Register() :CORBA::COMM_FAILURE : unable to contact" + << " the naming service"); + throw ServiceUnreachable(); + } + + + // Memory destruction + for (int i = 0 ; i resolve(_context_name); + } + catch(CosNaming::NamingContext::NotFound& ex) + { + CosNaming::Name n = ex.rest_of_name; + if (ex.why == CosNaming::NamingContext::missing_node) + INFOS("Resolve() : " << (char *) n[0].id + << " (" << (char *) n[0].kind << ") not found"); + if (ex.why == CosNaming::NamingContext::not_context) + INFOS("Resolve() : " + << (char *) n[0].id << " (" << (char *) n[0].kind + << ") is not a context"); + if (ex.why == CosNaming::NamingContext::not_object) + INFOS("Resolve() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not an object"); + } + catch(CosNaming::NamingContext::CannotProceed&) + { + INFOS("!!!Resolve() : CosNaming::NamingContext::CannotProceed"); + } + catch(CosNaming::NamingContext::InvalidName&) + { + INFOS("!!!Resolve() : CosNaming::NamingContext::InvalidName"); + } + catch(CORBA::COMM_FAILURE&) + { + INFOS("!!!Resolve() :CORBA::COMM_FAILURE : unable to contact" + << "the naming service"); + throw ServiceUnreachable(); + } + // Memory destruction + for (int i = 0 ; i resolve(_context_name); + _current_context = + CosNaming::NamingContext::_narrow(_obj); + MESSAGE("This context was already created"); + } + catch (CosNaming::NamingContext::NotFound &) + { + // This context is not created. It will be done + _temp_context = + _current_context->bind_new_context(_context_name); + _current_context = _temp_context; + MESSAGE("This context was'nt created, it's now done"); + } + } + } + catch (CosNaming::NamingContext::AlreadyBound&) + { + INFOS("!!! Create_Directory() CosNaming::NamingContext::AlreadyBound"); + _return_code = false; + } + catch(CosNaming::NamingContext::NotFound& ex) + { + _return_code = false; + CosNaming::Name n = ex.rest_of_name; + if (ex.why == CosNaming::NamingContext::missing_node) + INFOS("Create_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind << ") not found"); + if (ex.why == CosNaming::NamingContext::not_context) + INFOS("Create_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not a context"); + if (ex.why == CosNaming::NamingContext::not_object) + INFOS("Create_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not an object"); + } + catch(CosNaming::NamingContext::CannotProceed&) + { + _return_code = false; + INFOS("!!!Create_Directory():CosNaming::NamingContext::CannotProceed"); + } + catch(CosNaming::NamingContext::InvalidName&) + { + _return_code = false; + INFOS("!!!Create_Directory():CosNaming::NamingContext::InvalidName"); + } + catch(CORBA::COMM_FAILURE&) + { + _return_code = false; + INFOS("!!!Register() :CORBA::COMM_FAILURE : unable to contact" + << " the naming service"); + throw ServiceUnreachable(); + } + // Memory destruction + for (int i = 0 ; i resolve(_context_name); + _current_context = CosNaming::NamingContext::_narrow(_obj); + ASSERT(!CORBA::is_nil(_current_context)) + } + catch(CosNaming::NamingContext::NotFound& ex) + { + _return_code = false; + CosNaming::Name n = ex.rest_of_name; + if (ex.why == CosNaming::NamingContext::missing_node) + MESSAGE( "Change_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind << ") not found") + if (ex.why == CosNaming::NamingContext::not_context) + MESSAGE("Change_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not a context" ) + if (ex.why == CosNaming::NamingContext::not_object) + MESSAGE( "Change_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not an object" ) + } + catch(CosNaming::NamingContext::CannotProceed&) + { + _return_code = false; + MESSAGE( "!!!Change_Directory() : CosNaming::NamingContext::CannotProceed" ) + } + catch(CosNaming::NamingContext::InvalidName&) + { + _return_code = false; + MESSAGE( "!!!Change_Directory() : CosNaming::NamingContext::InvalidName" ) + } + catch(CORBA::COMM_FAILURE&) + { + _return_code = false; + MESSAGE( "!!!Change_Directory() :CORBA::COMM_FAILURE : unable to contact" + << "the naming service") + throw ServiceUnreachable(); + } + // Memory destruction + for (int i = 0 ; i list(nb, _binding_list, _binding_iterator) ; + + while (_binding_iterator->next_one(_binding)) { + CosNaming::Name _bindingName = _binding->binding_name; + if (_binding->binding_type == CosNaming::ncontext) { + MESSAGE( "Context : " << _bindingName[0].id ); + try + { + Change_Directory(_bindingName[0].id); + } + catch (ServiceUnreachable&) + { + MESSAGE( "!!!list(): ServiceUnreachable" ) + throw ServiceUnreachable(); + } + + list(); + _current_context = _ref_context ; + } + else if (_binding->binding_type == CosNaming::nobject) { + MESSAGE( "Object : " << _bindingName[0].id ); + } + } + _binding_iterator->destroy(); +} + +//---------------------------------------------------------------------- +/*! Function : list_directory + * Purpose : method to get all the contexts contained in the current + * directory + * Get only objects, isn't iterative + * If the NamingService is out, the exception ServiceUnreachable is thrown + */ +//---------------------------------------------------------------------- +vector SALOME_NamingService::list_directory() + throw(ServiceUnreachable) +{ + vector _list ; + _list.resize(0); + CosNaming::BindingList_var _binding_list; + CosNaming::BindingIterator_var _binding_iterator; + unsigned long nb=0 ; // for using only the BindingIterator to access the bindings + CosNaming::Binding_var _binding ; + CosNaming::NamingContext_var _ref_context = _current_context; + _current_context->list(nb, _binding_list, _binding_iterator) ; + + while (_binding_iterator->next_one(_binding)) { + CosNaming::Name _bindingName = _binding->binding_name; + if (_binding->binding_type == CosNaming::nobject) { + _list.push_back(CORBA::string_dup(_bindingName[0].id)); + } + } + //for (unsigned int ind = 0; ind < _list.size(); ind++) + // MESSAGE("list_directory : Object : " << _list[ind]); + + _binding_iterator->destroy(); + return _list; +} + + +//---------------------------------------------------------------------- +/*! Function : Destroy_Name + * Purpose : method to destroy an association Path-Object Reference. + * WARNING : The complete Path should be given. + * If the NamingService is out, the exception ServiceUnreachable is thrown + * \param Path const char* arguments + */ +//---------------------------------------------------------------------- + +void SALOME_NamingService::Destroy_Name(const char* Path) + throw(ServiceUnreachable) +{ + MESSAGE("BEGIN OF Destroy_Name"); + int dimension_Path = strlen(Path) + 1; + char** resultat_resolve_Path = new char* [dimension_Path]; + + // _current_context is replaced to the _root_context + // if the Path begins whith '/' + if (Path[0]=='/') _current_context = _root_context; + + + //the resolution of the directory path has to be done + //to place the currect_context to the correct node + int dimension_resultat = 0; + _result_resolve_Path (Path, dimension_resultat, resultat_resolve_Path); + + CosNaming::Name _context_name; + if (dimension_resultat>1) + { + // We go in the directory where the object to destroy is + _context_name.length(dimension_resultat-1); + + _create_context_name_dir(resultat_resolve_Path,dimension_resultat -1, + _context_name); + try + { + CORBA::Object_var _obj = _current_context->resolve(_context_name); + _current_context = CosNaming::NamingContext::_narrow(_obj); + } + catch (CosNaming::NamingContext::NotFound& ex) + { + CosNaming::Name n = ex.rest_of_name; + if (ex.why == CosNaming::NamingContext::missing_node) + MESSAGE( "Destroy_Name() : " << (char *) n[0].id + << " (" << (char *) n[0].kind << ") not found" ) + if (ex.why == CosNaming::NamingContext::not_context) + MESSAGE( "Destroy_Name() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not a context" ) + if (ex.why == CosNaming::NamingContext::not_object) + MESSAGE( "Destroy_Name() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not an object" ) + } + catch (CosNaming::NamingContext::InvalidName &) + { + MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName" ) + } + catch (CosNaming::NamingContext::CannotProceed &) + { + MESSAGE( "!!!Destroy_Name(): CosNaming::NamingContext::CannotProceed" ) + } + catch(CORBA::COMM_FAILURE&) + { + MESSAGE( "!!!Destroy_Name() : CORBA::COMM_FAILURE : unable to contact" + << " the naming service") + throw ServiceUnreachable(); + } + } + + // the last element is the object to destroy + _context_name.length(1); + _context_name[0].id = + CORBA::string_dup(resultat_resolve_Path[dimension_resultat -1]); + _context_name[0].kind = CORBA::string_dup("object"); + SCRUTE(_context_name[0].id); + ASSERT(!CORBA::is_nil(_current_context)); + // Object destruction + try + { + _current_context->unbind(_context_name); + MESSAGE( "The object " << _context_name[0].id << " has been deleted" ) + } + catch(CosNaming::NamingContext::NotFound& ex) + { + CosNaming::Name n = ex.rest_of_name; + if (ex.why == CosNaming::NamingContext::missing_node) + MESSAGE( "Destroy_Name() : " << (char *) n[0].id + << " (" << (char *) n[0].kind << ") not found" ) + if (ex.why == CosNaming::NamingContext::not_context) + MESSAGE( "Destroy_Name() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not a context" ) + if (ex.why == CosNaming::NamingContext::not_object) + MESSAGE( "Destroy_Name() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not an object" ) + } + catch(CosNaming::NamingContext::CannotProceed&) + { + MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::CannotProceed") + } + catch(CosNaming::NamingContext::InvalidName&) + { + MESSAGE( "!!!Destroy_Name() : CosNaming::NamingContext::InvalidName") + } + catch(CORBA::COMM_FAILURE&) + { + MESSAGE( "!!!Destroy_Name() :CORBA::COMM_FAILURE : unable to contact" + << " the naming service") + throw ServiceUnreachable(); + } + // Memory destruction + for (int i = 0 ; i 1) + { + // We go in the directory where the context to destroy is + _context_name.length(dimension_resultat-1); + + _create_context_name_dir(resultat_resolve_Path,dimension_resultat -1, + _context_name); + try + { + CORBA::Object_var _obj = _current_context->resolve(_context_name); + _current_context = CosNaming::NamingContext::_narrow(_obj); + _ref_context = _current_context ; + } + catch (CosNaming::NamingContext::NotFound& ex) + { + CosNaming::Name n = ex.rest_of_name; + if (ex.why == CosNaming::NamingContext::missing_node) + MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind << ") not found") + if (ex.why == CosNaming::NamingContext::not_context) + MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not a context" ) + if (ex.why == CosNaming::NamingContext::not_object) + MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not an object" ) + } + catch (CosNaming::NamingContext::InvalidName &) + { + MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" ) + } + catch (CosNaming::NamingContext::CannotProceed &) + { + MESSAGE("!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" ) + } + catch(CORBA::COMM_FAILURE&) + { + MESSAGE( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact" + << " the naming service" ) + throw ServiceUnreachable(); + } + } + + // the last element is the context to destroy + _context_name.length(1); + _context_name[0].id = + CORBA::string_dup(resultat_resolve_Path[dimension_resultat -1]); + _context_name[0].kind = CORBA::string_dup("dir"); + SCRUTE(_context_name[0].id); + + try + { + // We go in the context to destroy + CORBA::Object_var _obj = _current_context->resolve(_context_name); + _current_context = CosNaming::NamingContext::_narrow(_obj); + } + catch (CosNaming::NamingContext::NotFound& ex) + { + CosNaming::Name n = ex.rest_of_name; + if (ex.why == CosNaming::NamingContext::missing_node) + MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind << ") not found" ) + if (ex.why == CosNaming::NamingContext::not_context) + MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not a context" ) + if (ex.why == CosNaming::NamingContext::not_object) + MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not an object" ) + } + catch (CosNaming::NamingContext::InvalidName &) + { + MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName" ) + } + catch (CosNaming::NamingContext::CannotProceed &) + { + MESSAGE( "!!!Destroy_Directory(): CosNaming::NamingContext::CannotProceed" ) + } + catch(CORBA::COMM_FAILURE&) + { + MESSAGE( "!!!Destroy_Directory() : CORBA::COMM_FAILURE : unable to contact" + << " the naming service" ) + throw ServiceUnreachable(); + } + + ASSERT(!CORBA::is_nil(_current_context)); + // Context Destruction + try + { + _current_context->destroy(); + MESSAGE( "The context " << _context_name[0].id << " has been deleted" ) + } + catch(CosNaming::NamingContext::NotEmpty&) + { + MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::NoEmpty " + << Path << " is not empty" ) + } + catch(CORBA::COMM_FAILURE&) + { + MESSAGE( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : " + << "unable to contact the naming service") + throw ServiceUnreachable(); + } + // We go to the directory just before the context to delete + _current_context = _ref_context ; + try + { + _current_context->unbind(_context_name); + MESSAGE( "The bind to the context " << _context_name[0].id << " has been deleted" ) + } + catch(CosNaming::NamingContext::NotFound& ex) + { + CosNaming::Name n = ex.rest_of_name; + if (ex.why == CosNaming::NamingContext::missing_node) + MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind << ") not found" ) + if (ex.why == CosNaming::NamingContext::not_context) + MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not a context" ) + if (ex.why == CosNaming::NamingContext::not_object) + MESSAGE( "Destroy_Directory() : " << (char *) n[0].id + << " (" << (char *) n[0].kind + << ") is not an object" ) + } + catch(CosNaming::NamingContext::CannotProceed&) + { + MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::CannotProceed") + } + catch(CosNaming::NamingContext::InvalidName&) + { + MESSAGE( "!!!Destroy_Directory() : CosNaming::NamingContext::InvalidName") + } + catch(CORBA::COMM_FAILURE&) + { + MESSAGE( "!!!Destroy_Directory() :CORBA::COMM_FAILURE : unable to contact" + << " the naming service") + throw ServiceUnreachable(); + } + // Memory destruction + for (int i = 0 ; i resolve_initial_references("NameService"); + _root_context = CosNaming::NamingContext::_narrow(obj); + _current_context = _root_context ; + ASSERT(!CORBA::is_nil(_root_context)); + } + + catch(CORBA::COMM_FAILURE&) + { + INFOS("CORBA::COMM_FAILURE: unable to contact the naming service"); + throw ServiceUnreachable(); + } + catch(...) + { + INFOS("Unknown Exception: unable to contact the naming service"); + throw ServiceUnreachable(); + } +} + +//---------------------------------------------------------------------- +/*! Function : _resolve_Path + * Purpose : method to decompose a Path : /Kernel/Services/Sessions. + * + * \return a char* containing the first char between '/' (in this case Kernel) + */ +//---------------------------------------------------------------------- + +char* SALOME_NamingService::_resolve_Path(char* Path) +{ + int i = 0 ; + int length = strlen(Path); + char *resultat; + + if (length==0) return NULL; + else + { + while ((i0) + { + // temp[j] contains the characters to be treated : + // (Path - characters already treted) + // tempslash[j] = temp[j] if the string temp[j] doesn't begin whith '/' + // tempslash[j] = temp[j] without '/' if the string begins whith '/' + int length_temp = strlen(temp[j]); + if (temp[j][0]=='/') + { + // the characters to be treated begin whith '/' + // we don't have to take the '/' + tempslash[j] = new char [length_temp] ; + for (int k = 0; k < length_temp-1; k++) + tempslash[j][k] = temp[j][k+1]; + tempslash[j][length_temp-1]='\0'; + } + else + { + //the characters to be trated don't begin with '/' + // Nothing to be done on the char + tempslash[j] = new char [length_temp+1] ; + strcpy(tempslash[j],temp[j]); + } + // decomposition of the Path + resultat_resolve_Path[j]= _resolve_Path(tempslash[j]); + //SCRUTE(resultat_resolve_Path[j]); + + int length_resultat = strlen(resultat_resolve_Path[j]) ; + int dimension_temp = length_temp -length_resultat ; + j++; + temp[j] = new char[dimension_temp +1]; + for (int i = 0 ; i list(nb, _binding_list, _binding_iterator) ; + + while (_binding_iterator->next_one(_binding)) { + CosNaming::Name _bindingName = _binding->binding_name; + if (_binding->binding_type == CosNaming::ncontext) { + // We work on a directory, the search should be done in this directory + Change_Directory(_bindingName[0].id); + _Find(name,occurence_number); + // We'll go back to the initial context + _current_context = _ref_context ; + } + else if (_binding->binding_type == CosNaming::nobject) { + // We work on an object... + if (!strcmp( _bindingName[0].id,name)) + { + //MESSAGE("One occurence was found"); + occurence_number++; + // We keep in memory the directory where one occurence was found + _found_context = _current_context ; + } + } + } + _binding_iterator->destroy(); + // We go to the last directory where an occurence was found + _current_context = _found_context ; + //SCRUTE(occurence_number); +} + +//---------------------------------------------------------------------- +/*! Function : _create_context_name_dir. + * Purpose : method to create a Context_name from an array of char. + * The number of elements to be copied are indicated + * with lenth_copy. + * + * \param resultat_resolve_Path char** arguments + * \param length_copy int arguments + * \param _context_name CosNaming::Name arguments (by value) + */ +//---------------------------------------------------------------------- + +void +SALOME_NamingService::_create_context_name_dir(char** resultat_resolve_Path + ,int length_copy, + CosNaming::Name& _context_name) +{ + //MESSAGE("BEGIN OF _create_context_name_dir"); + for (int i = 0 ; i < length_copy;i++) + { + _context_name[i].id = CORBA::string_dup(resultat_resolve_Path[i]); + _context_name[i].kind = CORBA::string_dup("dir"); + //SCRUTE(_context_name[i].id); + } +} + +//---------------------------------------------------------------------- +/*! Function : _current_directory. + * Purpose : method to parse the naming service tree to find a context + * and determine the path to go to this context from the + * _root_context. + * \param result_path char** arguments + * \param length_result int arguments by value + * \param context_to_found CosNaming::NamingContext_var arguments + * \param _continue boolean arguments + */ +//---------------------------------------------------------------------- + +void +SALOME_NamingService::_current_directory(char** result_path, + int& length_result, + CosNaming::NamingContext_var context_to_found, + CORBA::Boolean& _continue) +{ + //MESSAGE("BEGIN OF _current_Directory"); + CosNaming::BindingList_var _binding_list; + CosNaming::BindingIterator_var _binding_iterator; + unsigned long nb=0 ; //for using only the BindingIterator + // to access the bindings + CosNaming::Binding_var _binding ; + CosNaming::NamingContext_var _ref_context = _current_context; + CosNaming::NamingContext_var _temp_context = _current_context; + + _current_context->list(nb, _binding_list, _binding_iterator) ; + + while ((_binding_iterator->next_one(_binding)) && _continue) { + CosNaming::Name _bindingName = _binding->binding_name; + if (_binding->binding_type == CosNaming::ncontext) + { + // We work on a directory, the search should be done in this directory + + result_path[length_result] = new char(strlen(_bindingName[0].id) + 1); + strcpy(result_path[length_result],_bindingName[0].id); + //SCRUTE(result_path[length_result]) + length_result++; + + CORBA::Object_var _obj =_current_context->resolve(_bindingName); + _temp_context = CosNaming::NamingContext::_narrow(_obj); + + if (_temp_context->_is_equivalent(context_to_found)) + { + //MESSAGE("The context is found, we stop the search"); + _continue = false; + //SCRUTE(_continue); + } + if(_continue) + { + //SCRUTE(_bindingName[0].id); + Change_Directory(_bindingName[0].id); + _current_directory(result_path,length_result, + context_to_found, _continue ); + if (_continue) + { + // We'll go back to the initial context + _current_context = _ref_context ; + //MESSAGE("Just before the delete of ") + //SCRUTE(result_path[length_result-1]); + delete result_path[length_result-1]; + length_result--; + } + } + } + } + _binding_iterator->destroy(); + // We go to the last directory where an occurence was found + _current_context = _ref_context ; +} +//---------------------------------------------------------------------- diff --git a/src/NamingService/SALOME_NamingService.hxx b/src/NamingService/SALOME_NamingService.hxx new file mode 100644 index 000000000..72cbd4727 --- /dev/null +++ b/src/NamingService/SALOME_NamingService.hxx @@ -0,0 +1,104 @@ +// File: SALOME_NamingService.hxx +// Created: Tue June 12 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + +#ifndef SALOME_NAMINGSERVICE_H +#define SALOME_NAMINGSERVICE_H + +#include "utilities.h" +#include +#include +#include + +//class ServiceUnreachable; +#include "ServiceUnreachable.hxx" + +class SALOME_NamingService +{ +public: + //! default constructor + SALOME_NamingService(); + + //! standard constructor + SALOME_NamingService(CORBA::ORB_ptr orb); + + //! standard destructor + virtual ~SALOME_NamingService(); + + //! initialize ORB reference after default constructor + void init_orb(CORBA::ORB_ptr orb); + + //! method to create an association in the NamingService between an object reference and a path + void Register(CORBA::Object_ptr ObjRef, const char* Path) + throw(ServiceUnreachable); + + //! method to get the ObjRef of a symbolic name + CORBA::Object_ptr Resolve(const char* Path) + throw( ServiceUnreachable); + + //! method to research a name from the naming service's current directory + int Find(const char* name) + throw(ServiceUnreachable); + + //! method to create a directory from the current directory + bool Create_Directory(const char* Path) + throw(ServiceUnreachable); + + //! method to change the current directory to the directory Path indicated in "in" Parameter + bool Change_Directory(const char* Path) + throw(ServiceUnreachable); + + //!method to get the current directory + char* Current_Directory() + throw(ServiceUnreachable); + + //!method to print all the contexts contained from the current directory + void list() + throw(ServiceUnreachable); + + //!method to get all the contexts contained in the current direcotry + // Get only objects, isn't iterative + vector list_directory() + throw(ServiceUnreachable); + + //! method to destroy an association Path-Object Reference + void Destroy_Name(const char* Path) + throw(ServiceUnreachable); + + //! method to destroy a directory if it is empty + virtual void Destroy_Directory(const char* Path) + throw(ServiceUnreachable); + +protected: + CORBA::ORB_ptr _orb; + CosNaming::NamingContext_var _root_context, _current_context; + + //! method called by constructor to initialize _root_context + void _initialize_root_context(); + + //! method to decompose a Path : /Kernel/Services/Sessions + char* _resolve_Path(char* Path); + + //! method to decompose a Path : /Kernel/Services/Sessions + void _result_resolve_Path(const char* Path, int& j, + char ** resultat_resolve_Path); + + //! internal method called by Find to research a name from the naming service's current directory + void _Find(const char* name, CORBA::Long& occurence_number); + + //! internal method to create a context name from a Path + void _create_context_name_dir(char** resultat_resolve_Path, + int length_copy, + CosNaming::Name& _context_name); + + //! internal method to create a parse the naming service tree + void _current_directory(char** result_path, + int& length_result, + CosNaming::NamingContext_var context_to_found, + CORBA::Boolean& _continue); +}; + +#endif // SALOME_NAMINGSERVICE_H diff --git a/src/NamingService/SALOME_NamingService.i b/src/NamingService/SALOME_NamingService.i new file mode 100644 index 000000000..67fe8623a --- /dev/null +++ b/src/NamingService/SALOME_NamingService.i @@ -0,0 +1,79 @@ +//============================================================================= +// File : SALOME_NamingService.i +// Created : mer aoû 29 11:26:49 CEST 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +//%module SALOME_NamingService +%{ +#include "SALOME_NamingService.hxx" +#include +#include "ServiceUnreachable.hxx" +%} + +%except(python) +{ + try + { + $function + } + catch (ServiceUnreachable) + { + PyErr_SetString(PyExc_IndexError,"Naming Service Unreacheable"); + return NULL; + } +} + +class SALOME_NamingService +{ +public: + + //! standard constructor + SALOME_NamingService(); + + //! standard destructor + virtual ~SALOME_NamingService(); + + //! initialize ORB reference after default constructor + void init_orb(CORBA::ORB_ptr orb); + + //! method to create an association in the NamingService between an object reference and a path + void Register(CORBA::Object_ptr ObjRef, const char* Path) + throw(ServiceUnreachable); + + //! method to get the ObjRef of a symbolic name + CORBA::Object_ptr Resolve(const char* Path) + throw( ServiceUnreachable); + + //! method to research a name from the naming service's current directory + int Find(const char* name) + throw(ServiceUnreachable); + + //! method to create a directory from the current directory + bool Create_Directory(const char* Path) + throw(ServiceUnreachable); + + //! method to change the current directory to the directory Path indicated in "in" Parameter + bool Change_Directory(const char* Path) + throw(ServiceUnreachable); + + //!method to get the current directory + char* Current_Directory() + throw(ServiceUnreachable); + + //!method to print all the contexts contained from the current directory + void list() + throw(ServiceUnreachable); + + //! method to destroy an association Path-Object Reference + void Destroy_Name(const char* Path) + throw(ServiceUnreachable); + + //! method to destroy a directory if it is empty + virtual void Destroy_Directory(const char* Path) + throw(ServiceUnreachable); +}; + diff --git a/src/NamingService/SALOME_NamingServicePy.py b/src/NamingService/SALOME_NamingServicePy.py new file mode 100644 index 000000000..9b46f5c2f --- /dev/null +++ b/src/NamingService/SALOME_NamingServicePy.py @@ -0,0 +1,166 @@ +#! /usr/bin/env python + +#============================================================================= +# File : SALOME_NamingServicePy.py +# Created : lun oct 15 14:55 CEST 2001 +# Author : Estelle Deville, CEA +# Project : SALOME +# Copyright : CEA 2001 +# $Header$ +#============================================================================= + +import sys +from omniORB import CORBA +import CosNaming +from string import * + +from SALOME_utilities import * +#============================================================================= + +class SALOME_NamingServicePy_i: + _orb = None + _root_context=None + _current_context=None + _obj=None + + #------------------------------------------------------------------------- + + def __init__(self, orb): + MESSAGE ( "SALOME_NamingServicePy_i::__init__" ) + self._orb = orb + # initialize root context and current context + obj =self._orb.resolve_initial_references("NameService") + self._root_context =obj._narrow(CosNaming.NamingContext) + self._current_context = self._root_context + + + if self._root_context is None : + MESSAGE ( "Name Service Reference is invalid" ) + sys.exit(1) + + #------------------------------------------------------------------------- + def Register(self,ObjRef, Path): + MESSAGE ( "SALOME_NamingServicePy_i::Register" ) + _not_exist = 0 + path_list = list(Path) + if path_list[0]=='/': + self._current_context = self._root_context + #delete first '/' before split + Path=Path[1:] + + result_resolve_path = split(Path,'/') + if len(result_resolve_path)>1: + # A directory is treated (not only an object name) + # We had to test if the directory where ObjRef should be recorded + # is already done + # If not, the new context has to be created + _context_name = [] + for i in range(len(result_resolve_path)-1): + _context_name.append(CosNaming.NameComponent(result_resolve_path[i],"dir")) + + try: + obj = self._current_context.resolve(_context_name) + self._current_context = obj._narrow(CosNaming.NamingContext) + except CosNaming.NamingContext.NotFound, ex: + _not_exist = 1 + except CosNaming.NamingContext.InvalidName, ex: + MESSAGE ( "Register : CosNaming.NamingContext.InvalidName" ) + except CosNaming.NamingContext.CannotProceed, ex: + MESSAGE ( "Register : CosNaming.NamingContext.CannotProceed" ) + except CORBA.COMM_FAILURE, ex: + MESSAGE ( "Register : CORBA.COMM_FAILURE" ) + + if _not_exist: + # at least one context of the complete path is not created, we had + # to create it or them + _context_name = [] + for i in range(len(result_resolve_path)-1): + _context_name = [CosNaming.NameComponent(result_resolve_path[i],"dir")] + + try: + obj = self._current_context.resolve(_context_name) + self._current_context = obj._narrow(CosNaming.NamingContext) + except CosNaming.NamingContext.NotFound, ex: + #This context is not created. It will be done + self._current_context = self._current_context.bind_new_context(_context_name) + + #The current directory is now the directory where the object should + #be recorded + + _context_name = [CosNaming.NameComponent(result_resolve_path[len(result_resolve_path)-1],"object")] + try: + self._current_context.bind(_context_name,ObjRef) + except CosNaming.NamingContext.NotFound, ex: + MESSAGE ( "Register : CosNaming.NamingContext.NotFound" ) + except CosNaming.NamingContext.InvalidName, ex: + MESSAGE ( "Register : CosNaming.NamingContext.InvalidName" ) + except CosNaming.NamingContext.CannotProceed, ex: + MESSAGE ( "Register : CosNaming.NamingContext.CannotProceed" ) + except CosNaming.NamingContext.AlreadyBound, ex: + MESSAGE ( "Register : CosNaming.NamingContext.AlreadyBound, object will be rebind" ) + self._current_context.rebind(_context_name,ObjRef) + except CORBA.COMM_FAILURE, ex: + MESSAGE ( "Register : CORBA.COMM_FAILURE" ) + + + #------------------------------------------------------------------------- + def Resolve(self, Path): + MESSAGE ( "SALOME_NamingServicePy_i::Resolve" ) + path_list = list(Path) + if path_list[0]=='/': + self._current_context = self._root_context + #delete first '/' before split + Path=Path[1:] + + result_resolve_path = split(Path,'/') + _context_name=[] + for i in range(len(result_resolve_path)-1): + _context_name.append(CosNaming.NameComponent(result_resolve_path[i],"dir")) + _context_name.append(CosNaming.NameComponent(result_resolve_path[len(result_resolve_path)-1],"object")) + try: + self._obj = self._current_context.resolve(_context_name) + except CosNaming.NamingContext.NotFound, ex: + MESSAGE ( "Resolve : CosNaming.NamingContext.NotFound" ) + self._obj = None + except CosNaming.NamingContext.InvalidName, ex: + MESSAGE ( "Resolve : CosNaming.NamingContext.InvalidName" ) + self._obj = None + except CosNaming.NamingContext.CannotProceed, ex: + MESSAGE ( "Resolve : CosNaming.NamingContext.CannotProceed" ) + self._obj = None + except CORBA.COMM_FAILURE, ex: + MESSAGE ( "Resolve : CORBA.COMM_FAILURE" ) + self._obj = None + return self._obj + + + + #------------------------------------------------------------------------- + def Create_Directory(self,ObjRef, Path): + MESSAGE ( "SALOME_NamingServicePy_i::Create_Directory" ) + _not_exist = 0 + path_list = list(Path) + if path_list[0]=='/': + self._current_context = self._root_context + #delete first '/' before split + Path=Path[1:] + + result_resolve_path = split(Path,'/') + _context_name = [] + for i in range(len(result_resolve_path)): + _context_name[CosNaming.NameComponent(result_resolve_path[i],"dir")] + try: + obj = self._current_context.resolve(_context_name) + self._current_context = obj._narrow(CosNaming.NamingContext) + except CosNaming.NamingContext.NotFound, ex: + self._current_context = self._current_context.bind_new_context(_context_name) + except CosNaming.NamingContext.InvalidName, ex: + MESSAGE ( "Create_Directory : CosNaming.NamingContext.InvalidName" ) + except CosNaming.NamingContext.CannotProceed, ex: + MESSAGE ( "Create_Directory : CosNaming.NamingContext.CannotProceed" ) + except CORBA.COMM_FAILURE, ex: + MESSAGE ( "Create_Directory : CORBA.COMM_FAILURE" ) + + + + diff --git a/src/NamingService/ServiceUnreachable.cxx b/src/NamingService/ServiceUnreachable.cxx new file mode 100644 index 000000000..32b459dff --- /dev/null +++ b/src/NamingService/ServiceUnreachable.cxx @@ -0,0 +1,11 @@ +using namespace std; +#include "ServiceUnreachable.hxx" + +ServiceUnreachable::ServiceUnreachable( void ): SALOME_Exception( "ServiceUnreachable" ) +{ + ; +} +ServiceUnreachable::ServiceUnreachable( const ServiceUnreachable &ex ): SALOME_Exception( ex ) +{ + ; +} diff --git a/src/NamingService/ServiceUnreachable.hxx b/src/NamingService/ServiceUnreachable.hxx new file mode 100644 index 000000000..10caf5edd --- /dev/null +++ b/src/NamingService/ServiceUnreachable.hxx @@ -0,0 +1,24 @@ +//============================================================================= +// File : ServiceUnreachable.hxx +// Created : mer jun 27 16:20:39 CEST 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#if !defined ( SERVICEUNREACHABLE_H ) +#define SERVICEUNREACHABLE_H + +#include "Utils_SALOME_Exception.hxx" + +//! exception class for NamingService : ServiceUnreachable + +class ServiceUnreachable : public SALOME_Exception +{ +public : + ServiceUnreachable( void ); + ServiceUnreachable( const ServiceUnreachable &ex ); +} ; + +#endif /* #if ( !defined SERVICEUNREACHABLE_H ) */ diff --git a/src/Notification/CosNotifyShorthands.h b/src/Notification/CosNotifyShorthands.h new file mode 100644 index 000000000..508bf3435 --- /dev/null +++ b/src/Notification/CosNotifyShorthands.h @@ -0,0 +1,245 @@ +// -*- Mode: C++; -*- + +// This file includes the four relevant .hh files and shorthands +// for the 4 module names and the elts of the modules. + +// The shortdhands allow us to avoid the use of M::x to name elt +// x of module M (we use M_x instead). This is needed to deal with +// compilers that do not support namespaces. + +#ifndef _COS_NOTIFY_H_ +#define _COS_NOTIFY_H_ + +#ifndef COS_USES_BOA +#include +#include +#include +#include +#include +#else +#include +#include +#include +#include +#include +#endif + +#define CosN CosNotification +#define CosNC CosNotifyComm +#define CosNA CosNotifyChannelAdmin +#define CosNF CosNotifyFilter + +// XXX TODO: need typedefs and defines for +// XXX compilers that do not support M::x syntax + +typedef CosN::AdminProperties CosN_AdminProperties; +typedef CosN::AdminPropertiesAdmin CosN_AdminPropertiesAdmin; +#define CosN_AnyOrder CosN::AnyOrder +#define CosN_BAD_PROPERTY CosN::BAD_PROPERTY +#define CosN_BAD_TYPE CosN::BAD_TYPE +#define CosN_BAD_VALUE CosN::BAD_VALUE +#define CosN_BestEffort CosN::BestEffort +#define CosN_ConnectionReliability CosN::ConnectionReliability +#define CosN_DeadlineOrder CosN::DeadlineOrder +#define CosN_DefaultPriority CosN::DefaultPriority +#define CosN_DiscardPolicy CosN::DiscardPolicy +typedef CosN::EventBatch CosN_EventBatch; +#define CosN_EventReliability CosN::EventReliability +typedef CosN::EventType CosN_EventType; +typedef CosN::EventTypeSeq CosN_EventTypeSeq; +#define CosN_FifoOrder CosN::FifoOrder +#define CosN_HighestPriority CosN::HighestPriority +#define CosN_LifoOrder CosN::LifoOrder +#define CosN_LowestPriority CosN::LowestPriority +#define CosN_MaxEventsPerConsumer CosN::MaxEventsPerConsumer +#define CosN_MaximumBatchSize CosN::MaximumBatchSize +#define CosN_NamedPropertyRangeSeq CosN::NamedPropertyRangeSeq +#define CosN_OrderPolicy CosN::OrderPolicy +#define CosN_PacingInterval CosN::PacingInterval +#define CosN_Persistent CosN::Persistent +#define CosN_Priority CosN::Priority +#define CosN_PriorityOrder CosN::PriorityOrder +typedef CosN::Property CosN_Property; +typedef CosN::PropertyError CosN_PropertyError; +typedef CosN::PropertyErrorSeq CosN_PropertyErrorSeq; +typedef CosN::PropertyRange CosN_PropertyRange; +typedef CosN::PropertySeq CosN_PropertySeq; +typedef CosN::QoSAdmin CosN_QoSAdmin; +typedef CosN::QoSError_code CosN_QoSError_code; +typedef CosN::QoSProperties CosN_QoSProperties; +#define CosN_RejectNewEvents CosN::RejectNewEvents +#define CosN_StartTimeSupported CosN::StartTimeSupported +#define CosN_StopTimeSupported CosN::StopTimeSupported +typedef CosN::StructuredEvent CosN_StructuredEvent; +#define CosN_Timeout CosN::Timeout +#define CosN_UNAVAILABLE_PROPERTY CosN::UNAVAILABLE_PROPERTY +#define CosN_UNAVAILABLE_VALUE CosN::UNAVAILABLE_VALUE +#define CosN_UNSUPPORTED_PROPERTY CosN::UNSUPPORTED_PROPERTY +#define CosN_UNSUPPORTED_VALUE CosN::UNSUPPORTED_VALUE +typedef CosN::UnsupportedAdmin CosN_UnsupportedAdmin; +typedef CosN::UnsupportedQoS CosN_UnsupportedQoS; + +#define CosNA_ALL_NOW_UPDATES_OFF CosNA::ALL_NOW_UPDATES_OFF +#define CosNA_ALL_NOW_UPDATES_ON CosNA::ALL_NOW_UPDATES_ON +#define CosNA_AND_OP CosNA::AND_OP +#define CosNA_ANY_EVENT CosNA::ANY_EVENT +typedef CosNA::AdminID CosNA_AdminID; +typedef CosNA::AdminIDSeq CosNA_AdminIDSeq; +typedef CosNA::AdminLimit CosNA_AdminLimit; +typedef CosNA::AdminLimitExceeded CosNA_AdminLimitExceeded; +typedef CosNA::AdminNotFound CosNA_AdminNotFound; +typedef CosNA::ChannelID CosNA_ChannelID; +typedef CosNA::ChannelIDSeq CosNA_ChannelIDSeq; +typedef CosNA::ChannelNotFound CosNA_ChannelNotFound; +typedef CosNA::ClientType CosNA_ClientType; +typedef CosNA::ConnectionAlreadyActive CosNA_ConnectionAlreadyActive; +typedef CosNA::ConnectionAlreadyInactive CosNA_ConnectionAlreadyInactive; +typedef CosNA::ConsumerAdmin CosNA_ConsumerAdmin; +typedef CosNA::ConsumerAdmin_ptr CosNA_ConsumerAdmin_ptr; +typedef CosNA::ConsumerAdmin_var CosNA_ConsumerAdmin_var; +typedef CosNA::EventChannel CosNA_EventChannel; +typedef CosNA::EventChannelFactory CosNA_EventChannelFactory; +typedef CosNA::EventChannelFactory_ptr CosNA_EventChannelFactory_ptr; +typedef CosNA::EventChannelFactory_var CosNA_EventChannelFactory_var; +typedef CosNA::EventChannel_ptr CosNA_EventChannel_ptr; +typedef CosNA::EventChannel_var CosNA_EventChannel_var; +typedef CosNA::InterFilterGroupOperator CosNA_InterFilterGroupOperator; +#define CosNA_NONE_NOW_UPDATES_OFF CosNA::NONE_NOW_UPDATES_OFF +#define CosNA_NONE_NOW_UPDATES_ON CosNA::NONE_NOW_UPDATES_ON +typedef CosNA::NotConnected CosNA_NotConnected; +#define CosNA_OR_OP CosNA::OR_OP +typedef CosNA::ObtainInfoMode CosNA_ObtainInfoMode; +#define CosNA_PULL_ANY CosNA::PULL_ANY +#define CosNA_PULL_SEQUENCE CosNA::PULL_SEQUENCE +#define CosNA_PULL_STRUCTURED CosNA::PULL_STRUCTURED +#define CosNA_PUSH_ANY CosNA::PUSH_ANY +#define CosNA_PUSH_SEQUENCE CosNA::PUSH_SEQUENCE +#define CosNA_PUSH_STRUCTURED CosNA::PUSH_STRUCTURED +#define CosNA_PUSH_TYPED CosNA::PUSH_TYPED +#define CosNA_PULL_TYPED CosNA::PULL_TYPED +typedef CosNA::ProxyConsumer CosNA_ProxyConsumer; +typedef CosNA::ProxyConsumer_ptr CosNA_ProxyConsumer_ptr; +typedef CosNA::ProxyConsumer_var CosNA_ProxyConsumer_var; +typedef CosNA::ProxyID CosNA_ProxyID; +typedef CosNA::ProxyIDSeq CosNA_ProxyIDSeq; +typedef CosNA::ProxyNotFound CosNA_ProxyNotFound; +typedef CosNA::ProxyPullConsumer CosNA_ProxyPullConsumer; +typedef CosNA::ProxyPullConsumer_ptr CosNA_ProxyPullConsumer_ptr; +typedef CosNA::ProxyPullConsumer_var CosNA_ProxyPullConsumer_var; +typedef CosNA::ProxyPullSupplier CosNA_ProxyPullSupplier; +typedef CosNA::ProxyPullSupplier_ptr CosNA_ProxyPullSupplier_ptr; +typedef CosNA::ProxyPullSupplier_var CosNA_ProxyPullSupplier_var; +typedef CosNA::ProxyPushConsumer CosNA_ProxyPushConsumer; +typedef CosNA::ProxyPushConsumer_ptr CosNA_ProxyPushConsumer_ptr; +typedef CosNA::ProxyPushConsumer_var CosNA_ProxyPushConsumer_var; +typedef CosNA::ProxyPushSupplier CosNA_ProxyPushSupplier; +typedef CosNA::ProxyPushSupplier_ptr CosNA_ProxyPushSupplier_ptr; +typedef CosNA::ProxyPushSupplier_var CosNA_ProxyPushSupplier_var; +typedef CosNA::ProxySupplier CosNA_ProxySupplier; +typedef CosNA::ProxySupplier_ptr CosNA_ProxySupplier_ptr; +typedef CosNA::ProxySupplier_var CosNA_ProxySupplier_var; +typedef CosNA::ProxyType CosNA_ProxyType; +#define CosNA_SEQUENCE_EVENT CosNA::SEQUENCE_EVENT +#define CosNA_STRUCTURED_EVENT CosNA::STRUCTURED_EVENT +typedef CosNA::SequenceProxyPullConsumer CosNA_SequenceProxyPullConsumer; +typedef CosNA::SequenceProxyPullConsumer_ptr CosNA_SequenceProxyPullConsumer_ptr; +typedef CosNA::SequenceProxyPullConsumer_var CosNA_SequenceProxyPullConsumer_var; +typedef CosNA::SequenceProxyPullSupplier CosNA_SequenceProxyPullSupplier; +typedef CosNA::SequenceProxyPullSupplier_ptr CosNA_SequenceProxyPullSupplier_ptr; +typedef CosNA::SequenceProxyPullSupplier_var CosNA_SequenceProxyPullSupplier_var; +typedef CosNA::SequenceProxyPushConsumer CosNA_SequenceProxyPushConsumer; +typedef CosNA::SequenceProxyPushConsumer_ptr CosNA_SequenceProxyPushConsumer_ptr; +typedef CosNA::SequenceProxyPushConsumer_var CosNA_SequenceProxyPushConsumer_var; +typedef CosNA::SequenceProxyPushSupplier CosNA_SequenceProxyPushSupplier; +typedef CosNA::SequenceProxyPushSupplier_ptr CosNA_SequenceProxyPushSupplier_ptr; +typedef CosNA::SequenceProxyPushSupplier_var CosNA_SequenceProxyPushSupplier_var; +typedef CosNA::StructuredProxyPullConsumer CosNA_StructuredProxyPullConsumer; +typedef CosNA::StructuredProxyPullConsumer_ptr CosNA_StructuredProxyPullConsumer_ptr; +typedef CosNA::StructuredProxyPullConsumer_var CosNA_StructuredProxyPullConsumer_var; +typedef CosNA::StructuredProxyPullSupplier CosNA_StructuredProxyPullSupplier; +typedef CosNA::StructuredProxyPullSupplier_ptr CosNA_StructuredProxyPullSupplier_ptr; +typedef CosNA::StructuredProxyPullSupplier_var CosNA_StructuredProxyPullSupplier_var; +typedef CosNA::StructuredProxyPushConsumer CosNA_StructuredProxyPushConsumer; +typedef CosNA::StructuredProxyPushConsumer_ptr CosNA_StructuredProxyPushConsumer_ptr; +typedef CosNA::StructuredProxyPushConsumer_var CosNA_StructuredProxyPushConsumer_var; +typedef CosNA::StructuredProxyPushSupplier CosNA_StructuredProxyPushSupplier; +typedef CosNA::StructuredProxyPushSupplier_ptr CosNA_StructuredProxyPushSupplier_ptr; +typedef CosNA::StructuredProxyPushSupplier_var CosNA_StructuredProxyPushSupplier_var; +typedef CosNA::SupplierAdmin CosNA_SupplierAdmin; +typedef CosNA::SupplierAdmin_ptr CosNA_SupplierAdmin_ptr; +typedef CosNA::SupplierAdmin_var CosNA_SupplierAdmin_var; + +typedef CosNC::InvalidEventType CosNC_InvalidEventType; +typedef CosNC::NotifyPublish CosNC_NotifyPublish; +typedef CosNC::NotifyPublish_ptr CosNC_NotifyPublish_ptr; +typedef CosNC::NotifyPublish_var CosNC_NotifyPublish_var; +typedef CosNC::NotifySubscribe CosNC_NotifySubscribe; +typedef CosNC::NotifySubscribe_ptr CosNC_NotifySubscribe_ptr; +typedef CosNC::NotifySubscribe_var CosNC_NotifySubscribe_var; +typedef CosNC::PullConsumer CosNC_PullConsumer; +typedef CosNC::PullConsumer_ptr CosNC_PullConsumer_ptr; +typedef CosNC::PullConsumer_var CosNC_PullConsumer_var; +typedef CosNC::PullSupplier CosNC_PullSupplier; +typedef CosNC::PullSupplier_ptr CosNC_PullSupplier_ptr; +typedef CosNC::PullSupplier_var CosNC_PullSupplier_var; +typedef CosNC::PushConsumer CosNC_PushConsumer; +typedef CosNC::PushConsumer_ptr CosNC_PushConsumer_ptr; +typedef CosNC::PushConsumer_var CosNC_PushConsumer_var; +typedef CosNC::PushSupplier CosNC_PushSupplier; +typedef CosNC::PushSupplier_ptr CosNC_PushSupplier_ptr; +typedef CosNC::PushSupplier_var CosNC_PushSupplier_var; +typedef CosNC::SequencePullConsumer CosNC_SequencePullConsumer; +typedef CosNC::SequencePullConsumer_ptr CosNC_SequencePullConsumer_ptr; +typedef CosNC::SequencePullConsumer_var CosNC_SequencePullConsumer_var; +typedef CosNC::SequencePullSupplier CosNC_SequencePullSupplier; +typedef CosNC::SequencePullSupplier_ptr CosNC_SequencePullSupplier_ptr; +typedef CosNC::SequencePullSupplier_var CosNC_SequencePullSupplier_var; +typedef CosNC::SequencePushConsumer CosNC_SequencePushConsumer; +typedef CosNC::SequencePushConsumer_ptr CosNC_SequencePushConsumer_ptr; +typedef CosNC::SequencePushConsumer_var CosNC_SequencePushConsumer_var; +typedef CosNC::SequencePushSupplier CosNC_SequencePushSupplier; +typedef CosNC::SequencePushSupplier_ptr CosNC_SequencePushSupplier_ptr; +typedef CosNC::SequencePushSupplier_var CosNC_SequencePushSupplier_var; +typedef CosNC::StructuredPullConsumer CosNC_StructuredPullConsumer; +typedef CosNC::StructuredPullConsumer_ptr CosNC_StructuredPullConsumer_ptr; +typedef CosNC::StructuredPullConsumer_var CosNC_StructuredPullConsumer_var; +typedef CosNC::StructuredPullSupplier CosNC_StructuredPullSupplier; +typedef CosNC::StructuredPullSupplier_ptr CosNC_StructuredPullSupplier_ptr; +typedef CosNC::StructuredPullSupplier_var CosNC_StructuredPullSupplier_var; +typedef CosNC::StructuredPushConsumer CosNC_StructuredPushConsumer; +typedef CosNC::StructuredPushConsumer_ptr CosNC_StructuredPushConsumer_ptr; +typedef CosNC::StructuredPushConsumer_var CosNC_StructuredPushConsumer_var; +typedef CosNC::StructuredPushSupplier CosNC_StructuredPushSupplier; +typedef CosNC::StructuredPushSupplier_ptr CosNC_StructuredPushSupplier_ptr; +typedef CosNC::StructuredPushSupplier_var CosNC_StructuredPushSupplier_var; + +typedef CosNF::CallbackID CosNF_CallbackID; +typedef CosNF::CallbackIDSeq CosNF_CallbackIDSeq; +typedef CosNF::ConstraintExp CosNF_ConstraintExp; +typedef CosNF::ConstraintExpSeq CosNF_ConstraintExpSeq; +typedef CosNF::ConstraintID CosNF_ConstraintID; +typedef CosNF::ConstraintIDSeq CosNF_ConstraintIDSeq; +typedef CosNF::ConstraintInfoSeq CosNF_ConstraintInfoSeq; +typedef CosNF::ConstraintInfoSeq_var CosNF_ConstraintInfoSeq_var; +typedef CosNF::ConstraintNotFound CosNF_ConstraintNotFound; +typedef CosNF::Filter CosNF_Filter; +typedef CosNF::FilterAdmin CosNF_FilterAdmin; +typedef CosNF::FilterAdmin_ptr CosNF_FilterAdmin_ptr; +typedef CosNF::FilterFactory CosNF_FilterFactory; +typedef CosNF::FilterFactory_ptr CosNF_FilterFactory_ptr; +typedef CosNF::FilterFactory_var CosNF_FilterFactory_var; +typedef CosNF::FilterID CosNF_FilterID; +typedef CosNF::FilterIDSeq CosNF_FilterIDSeq; +typedef CosNF::FilterNotFound CosNF_FilterNotFound; +typedef CosNF::Filter_ptr CosNF_Filter_ptr; +typedef CosNF::Filter_var CosNF_Filter_var; +typedef CosNF::InvalidConstraint CosNF_InvalidConstraint; +typedef CosNF::InvalidGrammar CosNF_InvalidGrammar; +typedef CosNF::MappingConstraintInfoSeq CosNF_MappingConstraintInfoSeq; +typedef CosNF::MappingConstraintPairSeq CosNF_MappingConstraintPairSeq; +typedef CosNF::MappingFilter CosNF_MappingFilter; +typedef CosNF::MappingFilter_ptr CosNF_MappingFilter_ptr; +typedef CosNF::MappingFilter_var CosNF_MappingFilter_var; + +#endif + diff --git a/src/Notification/Makefile.in b/src/Notification/Makefile.in new file mode 100644 index 000000000..fe1c271ff --- /dev/null +++ b/src/Notification/Makefile.in @@ -0,0 +1,35 @@ +#============================================================================== +# File : Makefile.in +# Created : mar jui 3 12:58:13 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_HEADERS = NOTIFICATION.hxx \ + NOTIFICATION_Supplier.hxx \ + NOTIFICATION_Consumer.hxx \ + CosNotifyShorthands.h + +# Libraries targets + +LIB = libSalomeNotification.la + +LIB_SRC = NOTIFICATION.cxx \ + NOTIFICATION_Supplier.cxx \ + NOTIFICATION_Consumer.cxx + +LDFLAGS+= -lOpUtil +OMNIORB_IDLCXXFLAGS+= -Wbtp + +@CONCLUDE@ diff --git a/src/Notification/NOTIFICATION.cxx b/src/Notification/NOTIFICATION.cxx new file mode 100644 index 000000000..2923c4bf7 --- /dev/null +++ b/src/Notification/NOTIFICATION.cxx @@ -0,0 +1,80 @@ +using namespace std; +// File : NOTIFICATION.cxx +// Created : 1 Avril 2002 +// Author : Laurent DADA / Francis KLOSS +// Project : SALOME +// Module : Notification General +// Copyright : CEA / Open CASCADE + +#include "NOTIFICATION.hxx" + +using namespace std; +#include "Utils_ORB_INIT.hxx" +#include "Utils_SINGLETON.hxx" + +CosNA_EventChannel_ptr NOTIFICATION_channel() { + ORB_INIT& init = *SINGLETON_::Instance(); ASSERT(SINGLETON_::IsAlreadyExisting()); + CORBA::ORB_ptr orb = init(0, 0); + + CosNA_EventChannel_ptr channel = CosNA_EventChannel::_nil(); + CosNaming::NamingContext_var name_context; + CosNaming::Name name; + CORBA::Object_var name_service; + + try { + name_service = orb->resolve_initial_references("NameService"); + name_context = CosNaming::NamingContext::_narrow(name_service); + if (CORBA::is_nil(name_context)) { + MESSAGE("NOTIFICATION Error : failed to obtain context for NameService"); + return(channel); + }; + } catch(CORBA::ORB::InvalidName& ex) { + MESSAGE("NOTIFICATION Error : service required is invalid [does not exist]"); + return(channel); + } catch (CORBA::COMM_FAILURE& ex) { + MESSAGE("NOTIFICATION Error : caught system exception COMM_FAILURE"); + return(channel); + } catch (...) { + MESSAGE("NOTIFICATION Error : caught exception while resolving the naming service"); + return(channel); + } + + name.length(1); + name[0].id = CORBA::string_dup((const char*)NOTIFICATION_ChannelName); + name[0].kind = CORBA::string_dup((const char*)NOTIFICATION_ChannelName); + + try { + CORBA::Object_var channel_ref = name_context->resolve(name); + channel = CosNA_EventChannel::_narrow(channel_ref); + if (CORBA::is_nil(channel)) { + MESSAGE("NOTIFICATION Error : failed to narrow object found in naming service"); + }; + } catch(CORBA::ORB::InvalidName& ex) { + MESSAGE("NOTIFICATION Error : invalid name"); + } catch (CORBA::COMM_FAILURE& ex) { + MESSAGE("NOTIFICATION Error : caught system exception COMM_FAILURE while resolving event channel name"); + } catch (...) { + MESSAGE("NOTIFICATION Error : caught exception while resolving event channel name"); + } + + return(channel); +} + +#include +#include + +static char JourSemaine[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu" , "Fri", "Sat"}; + +static char Mois[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + +static char NOTIFICATION_DATE[50]; + +char* NOTIFICATION_date() { + time_t aTime; + time(&aTime); + struct tm* temps = localtime(&aTime); + + sprintf(NOTIFICATION_DATE, "%4d %3d %3s %2d %3s %02d:%02d:%02d", 1900+temps->tm_year, temps->tm_mon+1, Mois[temps->tm_mon], temps->tm_mday, JourSemaine[temps->tm_wday], temps->tm_hour, temps->tm_min, temps->tm_sec); + + return(NOTIFICATION_DATE); +} diff --git a/src/Notification/NOTIFICATION.hxx b/src/Notification/NOTIFICATION.hxx new file mode 100644 index 000000000..964f76c05 --- /dev/null +++ b/src/Notification/NOTIFICATION.hxx @@ -0,0 +1,29 @@ +// File : NOTIFICATION.hxx +// Created : 1 Avril 2002 +// Author : Laurent DADA / Francis KLOSS +// Project : SALOME +// Module : Notification +// Copyright : CEA / Open CASCADE + +#ifndef NOTIFICATION_HXX +#define NOTIFICATION_HXX + +#define NOTIF_WARNING "Warning" +#define NOTIF_STEP "Step" +#define NOTIF_TRACE "Trace" +#define NOTIF_VERBOSE "Verbose" + +#define NOTIFICATION_ChannelName "EventChannel" + +#include "utilities.h" + +// kloss #include +#include "CosNotifyShorthands.h" + +#include "NOTIFICATION_Supplier.hxx" +#include "NOTIFICATION_Consumer.hxx" + +char* NOTIFICATION_date(); +CosNA_EventChannel_ptr NOTIFICATION_channel(); + +#endif diff --git a/src/Notification/NOTIFICATION_Consumer.cxx b/src/Notification/NOTIFICATION_Consumer.cxx new file mode 100644 index 000000000..17e379910 --- /dev/null +++ b/src/Notification/NOTIFICATION_Consumer.cxx @@ -0,0 +1,110 @@ +using namespace std; +// File : NOTIFICATION_Consumer.cxx +// Created : 1 Avril 2002 +// Author : Laurent DADA / Francis KLOSS +// Project : SALOME +// Module : Notification Consumer +// Copyright : CEA / Open CASCADE + +#include "NOTIFICATION.hxx" + +NOTIFICATION_Consumer::NOTIFICATION_Consumer(): + proxy_supplier(0), + _ok(false) +{ + CosNA_EventChannel_ptr channel = NOTIFICATION_channel(); + if (CORBA::is_nil(channel)) { + MESSAGE("NOTIFICATION Error : failed to get channel for consumer"); + } else { + CosNA_ConsumerAdmin_ptr consumerAdmin = channel->default_consumer_admin(); + + CosNA_ProxyID proxyId; + CosNotifyChannelAdmin::ProxySupplier_ptr supplier = consumerAdmin->obtain_notification_pull_supplier(CosNA_STRUCTURED_EVENT, proxyId); + if (CORBA::is_nil(supplier)) { + MESSAGE("NOTIFICATION Error : failed to get proxy pull supplier"); + } else { + proxy_supplier = CosNA_StructuredProxyPullSupplier::_narrow(supplier); + if (CORBA::is_nil(proxy_supplier)) { + MESSAGE("NOTIFICATION Error : failed to _narrow proxy pull supplier"); + } else { + try { + proxy_supplier->connect_structured_pull_consumer(_this()); + _ok = true; + MESSAGE("NOTIFICATION Info : successfully connection for pull consumer notification"); + } catch (CORBA::BAD_PARAM& ex) { + MESSAGE("NOTIFICATION Error : pull consumer BAD_PARAM exception while connecting"); + } catch (CosEventChannelAdmin::AlreadyConnected& ex) { + MESSAGE("NOTIFICATION Error : pull consumer already connected"); + } catch (...) { + MESSAGE("NOTIFICATION Error : pull consumer failed to connect"); + } + }; + }; + }; +} + +NOTIFICATION_Consumer::~NOTIFICATION_Consumer() { + if (_ok) { + _ok = false; + CosNA_StructuredProxyPullSupplier_var proxy = proxy_supplier; + proxy_supplier = CosNA_StructuredProxyPullSupplier::_nil(); + + try { + if (!CORBA::is_nil(proxy)) { + proxy->disconnect_structured_pull_supplier(); + }; + } catch(...) { + MESSAGE("NOTIFICATION Error : while disconnecting proxy pull supplier"); + } + }; +} + +bool NOTIFICATION_Consumer::Receive(char** graph, char** node, char** type, char** message, char** sender, long* counter, char** date, long* stamp) { + bool status = false; + CORBA::Boolean has_event; + CosN_StructuredEvent* event; + + if (_ok) { + try { + event = proxy_supplier->try_pull_structured_event(has_event); + status = has_event; + } catch (...) { + MESSAGE("NOTIFICATION Error : while calling try_pull_structured_event"); + }; + + if (status) { + char* Asender; + char* Agraph; + char* Atype; + CORBA::ULong Acounter; + CORBA::ULong Astamp; + char* Adate; + char* Anode; + char* Amessage; + event->filterable_data[0].value >>= Asender; + event->filterable_data[1].value >>= Agraph; + event->filterable_data[2].value >>= Atype; + event->filterable_data[3].value >>= Acounter; + event->filterable_data[4].value >>= Adate; + 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); + *counter = (long)Acounter; + *date = strdup(Adate); + *stamp = (long)Astamp; + }; + }; + + return(status); +} + +void NOTIFICATION_Consumer::disconnect_structured_pull_consumer() { +} + +void NOTIFICATION_Consumer::offer_change(const CosN_EventTypeSeq& added, const CosN_EventTypeSeq& deled) { +} diff --git a/src/Notification/NOTIFICATION_Consumer.hxx b/src/Notification/NOTIFICATION_Consumer.hxx new file mode 100644 index 000000000..3beec8add --- /dev/null +++ b/src/Notification/NOTIFICATION_Consumer.hxx @@ -0,0 +1,25 @@ +// File : NOTIFICATION_Consumer.hxx +// Created : 1 Avril 2002 +// Author : Laurent DADA / Francis KLOSS +// Project : SALOME +// Module : Notification Consumer +// Copyright : CEA / Open CASCADE + +#ifndef NOTIFICATION_Consumer_HXX +#define NOTIFICATION_Consumer_HXX + +class NOTIFICATION_Consumer: public POA_CosNotifyComm::StructuredPullConsumer { + public: + NOTIFICATION_Consumer(); + virtual ~NOTIFICATION_Consumer(); + bool Receive(char** graph, char** node, char** type, char** message, char** sender, long* counter, char** date, long* stamp); + + private: + void disconnect_structured_pull_consumer(); + void offer_change(const CosN_EventTypeSeq& added, const CosN_EventTypeSeq& deled); + + bool _ok; + CosNA_StructuredProxyPullSupplier_var proxy_supplier; +}; + +#endif diff --git a/src/Notification/NOTIFICATION_Supplier.cxx b/src/Notification/NOTIFICATION_Supplier.cxx new file mode 100644 index 000000000..0171b3e3a --- /dev/null +++ b/src/Notification/NOTIFICATION_Supplier.cxx @@ -0,0 +1,108 @@ +using namespace std; +// File : NOTIFICATION_Supplier.cxx +// Created : 1 Avril 2002 +// Author : Laurent DADA / Francis KLOSS +// Project : SALOME +// Module : Notification Supplier +// Copyright : CEA / Open CASCADE + +#include "NOTIFICATION.hxx" + +long NOTIFICATION_Supplier::_stamp = 0; + +NOTIFICATION_Supplier::NOTIFICATION_Supplier(const char* instanceName, bool notif): + _sender(instanceName), + _counter(0), + proxy_consumer(0), + _ok(false) +{ + if (notif) { + CosNA_EventChannel_ptr channel = NOTIFICATION_channel(); + if (CORBA::is_nil(channel)) { + MESSAGE("NOTIFICATION Error : failed to get channel for supplier"); + } else { + CosNA_SupplierAdmin_var supplierAdmin = channel->default_supplier_admin(); + + CosNA_ProxyID proxyId; + CosNotifyChannelAdmin::ProxyConsumer_ptr consumer = supplierAdmin->obtain_notification_push_consumer(CosNA_STRUCTURED_EVENT, proxyId); + if (CORBA::is_nil(consumer)) { + MESSAGE("NOTIFICATION Error : failed to get proxy push consumer"); + } else { + proxy_consumer = CosNA_StructuredProxyPushConsumer::_narrow(consumer); + if ( CORBA::is_nil(proxy_consumer)) { + MESSAGE("NOTIFICATION Error : failed to _narrow proxy push consumer"); + } else { + try { + proxy_consumer->connect_structured_push_supplier(_this()); + _ok = true; + MESSAGE("NOTIFICATION Info : successfully connection for push supplier notification"); + } catch (CORBA::BAD_PARAM& ex) { + MESSAGE("NOTIFICATION Error : push supplier BAD_PARAM Exception while connecting"); + } catch (CosEventChannelAdmin::AlreadyConnected& ex) { + MESSAGE("NOTIFICATION Error : push supplier already connected"); + } catch (...) { + MESSAGE("NOTIFICATION Error : push supplier failed to connect"); + } + }; + }; + }; + }; +} + +NOTIFICATION_Supplier::~NOTIFICATION_Supplier() { + if (_ok) { + _ok = false; + CosNA_StructuredProxyPushConsumer_var proxy = proxy_consumer; + proxy_consumer = CosNA_StructuredProxyPushConsumer::_nil(); + + try { + if (!CORBA::is_nil(proxy)) { + proxy->disconnect_structured_push_consumer(); + }; + } catch(...) { + MESSAGE("NOTIFICATION Error : while disconnecting proxy push consumer"); + } + }; +} + +void NOTIFICATION_Supplier::Send(const char* graph, const char* node, const char* type, const char* message) { + if (_ok) { + _stamp++; + _counter++; + CosN_StructuredEvent* event = new CosN_StructuredEvent; + + event->header.fixed_header.event_type.domain_name = CORBA::string_dup("SALOME"); + event->header.fixed_header.event_type.type_name = CORBA::string_dup("ComponentMessage"); + + event->header.variable_header.length(0); + + event->filterable_data.length(7); + event->filterable_data[0].name = CORBA::string_dup("SenderName"); + event->filterable_data[0].value <<= _sender; + event->filterable_data[1].name = CORBA::string_dup("DestinationGroup"); + event->filterable_data[1].value <<= graph; + event->filterable_data[2].name = CORBA::string_dup("EventType"); + event->filterable_data[2].value <<= type; + event->filterable_data[3].name = CORBA::string_dup("EventNumber"); + event->filterable_data[3].value <<= (CORBA::ULong)_counter; + event->filterable_data[4].name = CORBA::string_dup("SendingDate"); + event->filterable_data[4].value <<= (const char*)NOTIFICATION_date(); + event->filterable_data[5].name = CORBA::string_dup("DepartGroup"); + event->filterable_data[5].value <<= node; + event->filterable_data[6].name = CORBA::string_dup("Stamp"); + event->filterable_data[6].value <<= (CORBA::ULong)_stamp; + event->remainder_of_body <<= message; + + try { + proxy_consumer->push_structured_event(*event); + } catch (...) { + MESSAGE("NOTIFICATION Error : can't send a message with the component instance : " << _sender); + } + }; +} + +void NOTIFICATION_Supplier::disconnect_structured_push_supplier() { +} + +void NOTIFICATION_Supplier::subscription_change(const CosN_EventTypeSeq& added, const CosN_EventTypeSeq& deled) { +} diff --git a/src/Notification/NOTIFICATION_Supplier.hxx b/src/Notification/NOTIFICATION_Supplier.hxx new file mode 100644 index 000000000..a35b8179d --- /dev/null +++ b/src/Notification/NOTIFICATION_Supplier.hxx @@ -0,0 +1,28 @@ +// File : NOTIFICATION_Supplier.hxx +// Created : 1 Avril 2002 +// Author : Laurent DADA / Francis KLOSS +// Project : SALOME +// Module : Notification Supplier +// Copyright : CEA / Open CASCADE + +#ifndef NOTIFICATION_Supplier_HXX +#define NOTIFICATION_Supplier_HXX + +class NOTIFICATION_Supplier: public POA_CosNotifyComm::StructuredPushSupplier { + public: + NOTIFICATION_Supplier(const char* instanceName, bool notif); + virtual ~NOTIFICATION_Supplier(); + void Send(const char* graph, const char* node, const char* type, const char* message); + + private: + void disconnect_structured_push_supplier(); + void subscription_change(const CosN_EventTypeSeq& added, const CosN_EventTypeSeq& deled); + + bool _ok; + const char* _sender; + long _counter; + CosNA_StructuredProxyPushConsumer_var proxy_consumer; + static long _stamp; +}; + +#endif diff --git a/src/OBJECT/Handle_SALOME_AISObject.hxx b/src/OBJECT/Handle_SALOME_AISObject.hxx new file mode 100644 index 000000000..8e96f0032 --- /dev/null +++ b/src/OBJECT/Handle_SALOME_AISObject.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_SALOME_AISObject_HeaderFile +#define _Handle_SALOME_AISObject_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_AIS_InteractiveObject_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(AIS_InteractiveObject); +class SALOME_AISObject; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOME_AISObject); + +class Handle(SALOME_AISObject) : public Handle(AIS_InteractiveObject) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOME_AISObject)():Handle(AIS_InteractiveObject)() {} + Handle(SALOME_AISObject)(const Handle(SALOME_AISObject)& aHandle) : Handle(AIS_InteractiveObject)(aHandle) + { + } + + Handle(SALOME_AISObject)(const SALOME_AISObject* anItem) : Handle(AIS_InteractiveObject)((AIS_InteractiveObject *)anItem) + { + } + + Handle(SALOME_AISObject)& operator=(const Handle(SALOME_AISObject)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOME_AISObject)& operator=(const SALOME_AISObject* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOME_AISObject* operator->() + { + return (SALOME_AISObject *)ControlAccess(); + } + + SALOME_AISObject* operator->() const + { + return (SALOME_AISObject *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOME_AISObject)(); + + Standard_EXPORT static const Handle(SALOME_AISObject) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/OBJECT/Handle_SALOME_AISShape.hxx b/src/OBJECT/Handle_SALOME_AISShape.hxx new file mode 100644 index 000000000..9d6a94128 --- /dev/null +++ b/src/OBJECT/Handle_SALOME_AISShape.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_SALOME_AISShape_HeaderFile +#define _Handle_SALOME_AISShape_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_AIS_Shape_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(AIS_Shape); +class SALOME_AISShape; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOME_AISShape); + +class Handle(SALOME_AISShape) : public Handle(AIS_Shape) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOME_AISShape)():Handle(AIS_Shape)() {} + Handle(SALOME_AISShape)(const Handle(SALOME_AISShape)& aHandle) : Handle(AIS_Shape)(aHandle) + { + } + + Handle(SALOME_AISShape)(const SALOME_AISShape* anItem) : Handle(AIS_Shape)((AIS_Shape *)anItem) + { + } + + Handle(SALOME_AISShape)& operator=(const Handle(SALOME_AISShape)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOME_AISShape)& operator=(const SALOME_AISShape* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOME_AISShape* operator->() + { + return (SALOME_AISShape *)ControlAccess(); + } + + SALOME_AISShape* operator->() const + { + return (SALOME_AISShape *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOME_AISShape)(); + + Standard_EXPORT static const Handle(SALOME_AISShape) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/OBJECT/Handle_SALOME_InteractiveObject.hxx b/src/OBJECT/Handle_SALOME_InteractiveObject.hxx new file mode 100644 index 000000000..838d57417 --- /dev/null +++ b/src/OBJECT/Handle_SALOME_InteractiveObject.hxx @@ -0,0 +1,85 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#define _Handle_SALOME_InteractiveObject_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_MMgt_TShared_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(MMgt_TShared); +class SALOME_InteractiveObject; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOME_InteractiveObject); + +class Handle(SALOME_InteractiveObject) : public Handle(MMgt_TShared) { + public: + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + Handle(SALOME_InteractiveObject)():Handle(MMgt_TShared)() {} + Handle(SALOME_InteractiveObject)(const Handle(SALOME_InteractiveObject)& aHandle) : Handle(MMgt_TShared)(aHandle) + { + } + + Handle(SALOME_InteractiveObject)(const SALOME_InteractiveObject* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem) + { + } + + Handle(SALOME_InteractiveObject)& operator=(const Handle(SALOME_InteractiveObject)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOME_InteractiveObject)& operator=(const SALOME_InteractiveObject* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOME_InteractiveObject* operator->() + { + return (SALOME_InteractiveObject *)ControlAccess(); + } + + SALOME_InteractiveObject* operator->() const + { + return (SALOME_InteractiveObject *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOME_InteractiveObject)(); + + Standard_EXPORT static const Handle(SALOME_InteractiveObject) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in new file mode 100644 index 000000000..841fd6fb0 --- /dev/null +++ b/src/OBJECT/Makefile.in @@ -0,0 +1,36 @@ +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_HEADERS = SALOME_InteractiveObject.hxx \ + Handle_SALOME_InteractiveObject.hxx \ + SALOME_Actor.h \ + SALOME_AISShape.hxx \ + Handle_SALOME_AISShape.hxx \ + SALOME_AISObject.hxx \ + Handle_SALOME_AISObject.hxx + +# Libraries targets + +LIB = libSalomeObject.la +LIB_SRC = SALOME_InteractiveObject.cxx \ + SALOME_Actor.cxx \ + SALOME_AISShape.cxx\ + SALOME_AISObject.cxx + +LIB_CLIENT_IDL = + +# Executables targets +BIN = +BIN_SRC = + +CPPFLAGS+=$(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) +LDFLAGS+=$(OCC_LIBS) $(VTK_LIBS) $(OGL_LIBS) $(PYTHON_LIBS) + + +@CONCLUDE@ diff --git a/src/OBJECT/SALOME_AISObject.cxx b/src/OBJECT/SALOME_AISObject.cxx new file mode 100644 index 000000000..d1c9d799b --- /dev/null +++ b/src/OBJECT/SALOME_AISObject.cxx @@ -0,0 +1,10 @@ +using namespace std; +// File : SALOME_AISObject.hxx +// Created : Thu Feb 21 14:37:54 CET 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOME +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOME_AISObject.ixx" diff --git a/src/OBJECT/SALOME_AISObject.hxx b/src/OBJECT/SALOME_AISObject.hxx new file mode 100644 index 000000000..d19376bc8 --- /dev/null +++ b/src/OBJECT/SALOME_AISObject.hxx @@ -0,0 +1,108 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _SALOME_AISObject_HeaderFile +#define _SALOME_AISObject_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_AISObject_HeaderFile +#include +#endif + +#ifndef _AIS_InteractiveObject_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif +class SALOME_InteractiveObject; + + +class SALOME_AISObject : public AIS_InteractiveObject { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +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(const Standard_CString aName) = 0; +Standard_EXPORT ~SALOME_AISObject(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOME_AISObject_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/OBJECT/SALOME_AISObject.ixx b/src/OBJECT/SALOME_AISObject.ixx new file mode 100644 index 000000000..1dab9124a --- /dev/null +++ b/src/OBJECT/SALOME_AISObject.ixx @@ -0,0 +1,75 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_AISObject.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOME_AISObject::~SALOME_AISObject() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOME_AISObject_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(AIS_InteractiveObject); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(AIS_InteractiveObject); + static Handle_Standard_Type aType2 = STANDARD_TYPE(SelectMgr_SelectableObject); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(SelectMgr_SelectableObject); + static Handle_Standard_Type aType3 = STANDARD_TYPE(PrsMgr_PresentableObject); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(PrsMgr_PresentableObject); + static Handle_Standard_Type aType4 = STANDARD_TYPE(MMgt_TShared); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType5 = STANDARD_TYPE(Standard_Transient); + if ( aType5.IsNull()) aType5 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,aType5,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOME_AISObject", + sizeof(SALOME_AISObject), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOME_AISObject) Handle(SALOME_AISObject)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOME_AISObject) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOME_AISObject))) { + _anOtherObject = Handle(SALOME_AISObject)((Handle(SALOME_AISObject)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOME_AISObject::DynamicType() const +{ + return STANDARD_TYPE(SALOME_AISObject) ; +} +Standard_Boolean SALOME_AISObject::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOME_AISObject) == AType || AIS_InteractiveObject::IsKind(AType)); +} +Handle_SALOME_AISObject::~Handle_SALOME_AISObject() {} + diff --git a/src/OBJECT/SALOME_AISObject.jxx b/src/OBJECT/SALOME_AISObject.jxx new file mode 100644 index 000000000..568794822 --- /dev/null +++ b/src/OBJECT/SALOME_AISObject.jxx @@ -0,0 +1,6 @@ +#ifndef _SALOME_InteractiveObject_HeaderFile +#include "SALOME_InteractiveObject.hxx" +#endif +#ifndef _SALOME_AISObject_HeaderFile +#include "SALOME_AISObject.hxx" +#endif diff --git a/src/OBJECT/SALOME_AISShape.cxx b/src/OBJECT/SALOME_AISShape.cxx new file mode 100644 index 000000000..fe707e5dd --- /dev/null +++ b/src/OBJECT/SALOME_AISShape.cxx @@ -0,0 +1,14 @@ +using namespace std; +// File : SALOME_AISShape.hxx +// Created : Thu Feb 21 14:37:54 CET 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOME +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOME_AISShape.ixx" + +SALOME_AISShape::SALOME_AISShape(const TopoDS_Shape& shape): AIS_Shape(shape) { +} + diff --git a/src/OBJECT/SALOME_AISShape.hxx b/src/OBJECT/SALOME_AISShape.hxx new file mode 100644 index 000000000..bcaf96467 --- /dev/null +++ b/src/OBJECT/SALOME_AISShape.hxx @@ -0,0 +1,109 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _SALOME_AISShape_HeaderFile +#define _SALOME_AISShape_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_AISShape_HeaderFile +#include +#endif + +#ifndef _Standard_CString_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif +#ifndef _AIS_Shape_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class SALOME_InteractiveObject; +class TopoDS_Shape; + + +class SALOME_AISShape : public AIS_Shape { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT SALOME_AISShape(const TopoDS_Shape& shape); +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 ~SALOME_AISShape(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOME_AISShape_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/OBJECT/SALOME_AISShape.ixx b/src/OBJECT/SALOME_AISShape.ixx new file mode 100644 index 000000000..10bd7e052 --- /dev/null +++ b/src/OBJECT/SALOME_AISShape.ixx @@ -0,0 +1,77 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_AISShape.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOME_AISShape::~SALOME_AISShape() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOME_AISShape_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(AIS_Shape); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(AIS_Shape); + static Handle_Standard_Type aType2 = STANDARD_TYPE(AIS_InteractiveObject); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(AIS_InteractiveObject); + static Handle_Standard_Type aType3 = STANDARD_TYPE(SelectMgr_SelectableObject); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(SelectMgr_SelectableObject); + static Handle_Standard_Type aType4 = STANDARD_TYPE(PrsMgr_PresentableObject); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(PrsMgr_PresentableObject); + static Handle_Standard_Type aType5 = STANDARD_TYPE(MMgt_TShared); + if ( aType5.IsNull()) aType5 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType6 = STANDARD_TYPE(Standard_Transient); + if ( aType6.IsNull()) aType6 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,aType5,aType6,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOME_AISShape", + sizeof(SALOME_AISShape), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOME_AISShape) Handle(SALOME_AISShape)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOME_AISShape) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOME_AISShape))) { + _anOtherObject = Handle(SALOME_AISShape)((Handle(SALOME_AISShape)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOME_AISShape::DynamicType() const +{ + return STANDARD_TYPE(SALOME_AISShape) ; +} +Standard_Boolean SALOME_AISShape::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOME_AISShape) == AType || AIS_Shape::IsKind(AType)); +} +Handle_SALOME_AISShape::~Handle_SALOME_AISShape() {} + diff --git a/src/OBJECT/SALOME_AISShape.jxx b/src/OBJECT/SALOME_AISShape.jxx new file mode 100644 index 000000000..2b25db37a --- /dev/null +++ b/src/OBJECT/SALOME_AISShape.jxx @@ -0,0 +1,9 @@ +#ifndef _SALOME_InteractiveObject_HeaderFile +#include "SALOME_InteractiveObject.hxx" +#endif +#ifndef _TopoDS_Shape_HeaderFile +#include +#endif +#ifndef _SALOME_AISShape_HeaderFile +#include "SALOME_AISShape.hxx" +#endif diff --git a/src/OBJECT/SALOME_Actor.cxx b/src/OBJECT/SALOME_Actor.cxx new file mode 100644 index 000000000..2d84787bc --- /dev/null +++ b/src/OBJECT/SALOME_Actor.cxx @@ -0,0 +1,144 @@ +using namespace std; +// File : SALOME_Actor.cxx +// Created : Wed Feb 20 17:24:59 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OBJECT +// Copyright : Open CASCADE 2002 +// $Header$ + +/*! + \class SALOME_Actor SALOME_Actor.h + \brief Abstract class of SALOME Objects in VTK. +*/ + +#include "SALOME_Actor.h" + +// SALOME Includes +#include "utilities.h" + +// VTK Includes +#include +#include + + +void SALOME_Actor::ShallowCopy(vtkProp *prop) +{ + // Now do superclass + this->vtkActor::ShallowCopy(prop); +} + +void SALOME_Actor::Render(vtkRenderer *ren, vtkMapper *Mapper ) +{ + if (this->Mapper == NULL) { + MESSAGE ("No mapper for actor.") + return; + } + + vtkMapper *bestMapper; + bestMapper = this->Mapper; + + /* render the property */ + if (!this->Property) { + // force creation of a property + this->GetProperty(); + } + + this->Property->Render(this, ren); + if (this->BackfaceProperty) { + this->BackfaceProperty->BackfaceRender(this, ren); + this->Device->SetBackfaceProperty(this->BackfaceProperty); + } + this->Device->SetProperty(this->Property); + + + /* render the texture */ + if (this->Texture) { + this->Texture->Render(ren); + } + + + // Store information on time it takes to render. + // We might want to estimate time from the number of polygons in mapper. + this->Device->Render(ren,bestMapper); + this->EstimatedRenderTime = bestMapper->GetTimeToDraw(); +} + +int SALOME_Actor::RenderOpaqueGeometry(vtkViewport *vp) +{ + int renderedSomething = 0; + vtkRenderer *ren = (vtkRenderer *)vp; + + if ( ! this->Mapper ) { + return 0; + } + + // make sure we have a property + if (!this->Property) { + // force creation of a property + this->GetProperty(); + } + + // is this actor opaque ? + if (this->GetIsOpaque()) { + this->Property->Render(this, ren); + + // render the backface property + if (this->BackfaceProperty) { + this->BackfaceProperty->BackfaceRender(this, ren); + } + + // render the texture + if (this->Texture) { + this->Texture->Render(ren); + } + this->Render(ren,this->Mapper); + + renderedSomething = 1; + } + + return renderedSomething; +} + +void SALOME_Actor::ReleaseGraphicsResources(vtkWindow *renWin) +{ + vtkActor::ReleaseGraphicsResources(renWin); + this->Mapper->ReleaseGraphicsResources(renWin); +} + +// void SALOME_Actor::ApplyScaling ( vtkMapper* newMapper, bool recover = false ) +// { +// if ( recover && m_Isometric ) +// { +// SetMapper ( m_Isometric ); +// m_Isometric = NULL; +// } +// else +// if ( m_Isometric == NULL ) +// { +// m_Isometric = GetMapper(); +// SetMapper(newMapper); +// } +// } + +void SALOME_Actor::SetMapper ( vtkMapper* newMapper ) +{ + if ( m_Initial == NULL && Mapper != NULL ) + { + m_Initial = GetMapper(); + } + vtkLODActor::SetMapper(newMapper); +} + +SALOME_Actor::SALOME_Actor() +{ + m_Initial = NULL; + PreviewProperty = NULL; +} +SALOME_Actor::~SALOME_Actor() +{ + if ( m_Initial != NULL ) + m_Initial->Delete(); + if ( PreviewProperty != NULL ) + PreviewProperty->Delete(); +} diff --git a/src/OBJECT/SALOME_Actor.h b/src/OBJECT/SALOME_Actor.h new file mode 100644 index 000000000..47971b53d --- /dev/null +++ b/src/OBJECT/SALOME_Actor.h @@ -0,0 +1,99 @@ +// File : SALOME_Actor.h +// Created : Wed Feb 20 17:24:59 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOME +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef SALOME_ACTOR_H +#define SALOME_ACTOR_H + +// SALOME Includes +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif +#include "SALOME_InteractiveObject.hxx" + +//VTK Includes +#include + +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: + vtkTypeMacro(SALOME_Actor,vtkActor); + + // Description: + // This causes the actor to be rendered. It, in turn, will render the actor`s + // property and then mapper. + virtual void Render(vtkRenderer *, vtkMapper *); + + // Description: + // This method is used internally by the rendering process. + // We overide the superclass method to properly set the estimated render time. + virtual int RenderOpaqueGeometry(vtkViewport *viewport); + + // Description: + // Release any graphics resources that are being consumed by this actor. + // The parameter window could be used to determine which graphic + // resources to release. + virtual void ReleaseGraphicsResources(vtkWindow *); + + virtual void ShallowCopy(vtkProp *prop); + + virtual Standard_Boolean hasIO() { return !myIO.IsNull(); } + virtual Handle_SALOME_InteractiveObject getIO() { return myIO; } + 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 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; } + + virtual void SetOpacity(float opa) { m_opacity = opa; } + virtual float GetOpacity() { return m_opacity; } + + virtual void SetColor(float r,float g,float b) {}; + virtual void GetColor(float& r,float& g,float& b) {}; + + virtual void SetPreviewProperty(vtkProperty* Prop) { PreviewProperty = Prop; } + + virtual void SetPreSelected(Standard_Boolean presel = Standard_False) { ispreselected = presel; } + + // Used to obtain all dependent actors + virtual void GetChildActors(vtkActorCollection*) {}; + + //virtual void ApplyScaling ( vtkMapper* newMapper, bool recover = false ); + virtual void SetMapper ( vtkMapper* newMapper ); + virtual vtkMapper* GetInitialMapper() { return m_Initial; } + + protected: + vtkProperty *PreviewProperty; + Standard_Boolean ispreselected; + + Handle_SALOME_InteractiveObject myIO; + Standard_CString myName; + + float m_opacity; + Standard_Boolean ishighlighted; + int myDisplayMode; + + vtkMapper* m_Initial; +}; +#endif // SALOME_ACTOR_H diff --git a/src/OBJECT/SALOME_InteractiveObject.cxx b/src/OBJECT/SALOME_InteractiveObject.cxx new file mode 100644 index 000000000..252a21a1a --- /dev/null +++ b/src/OBJECT/SALOME_InteractiveObject.cxx @@ -0,0 +1,103 @@ +using namespace std; +// File : SALOME_InteractiveObject.cxx +// Created : Wed Feb 20 17:24:59 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOME +// Copyright : Open CASCADE 2002 +// $Header$ + +/*! + \class SALOME_InteractiveObject SALOME_InteractiveObject.hxx + \brief ... +*/ + +#include "SALOME_InteractiveObject.ixx" + +SALOME_InteractiveObject::SALOME_InteractiveObject() +{ + myEntry = ""; + myName = ""; + myComponentDataType = ""; + 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); +} + +Standard_CString SALOME_InteractiveObject::getEntry(){ + return myEntry; +} + +void SALOME_InteractiveObject::setComponentDataType(const Standard_CString aComponentDataType){ + myComponentDataType = new char [strlen(aComponentDataType)+1]; + strcpy( myComponentDataType, aComponentDataType); +} + +Standard_CString SALOME_InteractiveObject::getComponentDataType(){ + return myComponentDataType; +} + +void SALOME_InteractiveObject::setName(const Standard_CString aName){ + myName = new char [strlen(aName)+1]; + strcpy( myName, aName); +} + +Standard_CString SALOME_InteractiveObject::getName(){ + return myName; +} + +Standard_Boolean SALOME_InteractiveObject::hasEntry(){ + return !( strcmp(myEntry, "" ) == 0 ); +} + +Standard_Boolean SALOME_InteractiveObject::isSame(const Handle(SALOME_InteractiveObject)& anIO ){ + if ( anIO->hasEntry() && this->hasEntry() ) { + if ( strcmp(myEntry, anIO->getEntry() ) == 0 ) + return Standard_True; + } + + return Standard_False; +} + +Standard_Boolean SALOME_InteractiveObject::isComponentType(const Standard_CString ComponentDataType){ + if ( strcmp( myComponentDataType, ComponentDataType) == 0 ) + return Standard_True; + else + return Standard_False; +} + +Standard_Boolean SALOME_InteractiveObject::hasReference() +{ + return !( strcmp(myReference, "" ) == 0 ); +} + +Standard_CString SALOME_InteractiveObject::getReference() +{ + return myReference; +} + +void SALOME_InteractiveObject::setReference(const Standard_CString aReference) +{ + myReference = new char [strlen(aReference)+1]; + strcpy( myReference, aReference); +} diff --git a/src/OBJECT/SALOME_InteractiveObject.hxx b/src/OBJECT/SALOME_InteractiveObject.hxx new file mode 100644 index 000000000..e2c3544fc --- /dev/null +++ b/src/OBJECT/SALOME_InteractiveObject.hxx @@ -0,0 +1,118 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _SALOME_InteractiveObject_HeaderFile +#define _SALOME_InteractiveObject_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif + +#ifndef _Standard_CString_HeaderFile +#include +#endif +#ifndef _MMgt_TShared_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif + + +class SALOME_InteractiveObject : public MMgt_TShared { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // 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 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 void setComponentDataType(const Standard_CString ComponentDataType) ; +Standard_EXPORT Standard_CString getComponentDataType() ; +Standard_EXPORT Standard_Boolean isComponentType(const Standard_CString ComponentDataType) ; + +Standard_EXPORT ~SALOME_InteractiveObject(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOME_InteractiveObject_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // +Standard_CString myReference; +Standard_CString myEntry; +Standard_CString myName; +Standard_CString myComponentDataType; + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/OBJECT/SALOME_InteractiveObject.ixx b/src/OBJECT/SALOME_InteractiveObject.ixx new file mode 100644 index 000000000..db85d8332 --- /dev/null +++ b/src/OBJECT/SALOME_InteractiveObject.ixx @@ -0,0 +1,69 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_InteractiveObject.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOME_InteractiveObject::~SALOME_InteractiveObject() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOME_InteractiveObject_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(MMgt_TShared); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType2 = STANDARD_TYPE(Standard_Transient); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOME_InteractiveObject", + sizeof(SALOME_InteractiveObject), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOME_InteractiveObject) Handle(SALOME_InteractiveObject)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOME_InteractiveObject) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOME_InteractiveObject))) { + _anOtherObject = Handle(SALOME_InteractiveObject)((Handle(SALOME_InteractiveObject)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOME_InteractiveObject::DynamicType() const +{ + return STANDARD_TYPE(SALOME_InteractiveObject) ; +} +Standard_Boolean SALOME_InteractiveObject::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOME_InteractiveObject) == AType || MMgt_TShared::IsKind(AType)); +} +Handle_SALOME_InteractiveObject::~Handle_SALOME_InteractiveObject() {} + diff --git a/src/OBJECT/SALOME_InteractiveObject.jxx b/src/OBJECT/SALOME_InteractiveObject.jxx new file mode 100644 index 000000000..4d3dd36bb --- /dev/null +++ b/src/OBJECT/SALOME_InteractiveObject.jxx @@ -0,0 +1,3 @@ +#ifndef _SALOME_InteractiveObject_HeaderFile +#include "SALOME_InteractiveObject.hxx" +#endif diff --git a/src/OCCViewer/Makefile.in b/src/OCCViewer/Makefile.in new file mode 100644 index 000000000..f287b3f0e --- /dev/null +++ b/src/OCCViewer/Makefile.in @@ -0,0 +1,50 @@ +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_HEADERS = \ + OCCViewer_AISSelector.h \ + OCCViewer_Selector.h \ + OCCViewer_Viewer3d.h \ + OCCViewer_ViewFrame.h \ + OCCViewer_ViewPort.h \ + OCCViewer_ViewPort3d.h \ + OCCViewer_VService.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 + +LIB_MOC = \ + OCCViewer.h \ + OCCViewer_AISSelector.h \ + OCCViewer_Selector.h \ + OCCViewer_Viewer3d.h \ + OCCViewer_ViewFrame.h \ + OCCViewer_ViewPort.h \ + OCCViewer_ViewPort3d.h \ + +LIB_CLIENT_IDL = SALOMEDS.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + SALOME_Exception.idl + + +CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(OGL_INCLUDES) $(PYTHON_INCLUDES) +LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(OGL_LIBS) + + +@CONCLUDE@ diff --git a/src/OCCViewer/OCCViewer.cxx b/src/OCCViewer/OCCViewer.cxx new file mode 100644 index 000000000..bbce76c56 --- /dev/null +++ b/src/OCCViewer/OCCViewer.cxx @@ -0,0 +1,24 @@ +using namespace std; +// File : OCCViewer.cxx +// Created : Wed Mar 20 11:56:18 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "OCCViewer.h" +#include "OCCViewer_ViewFrame.h" + +QAD_ViewFrame* OCCViewer::createView(QAD_RightFrame* parent) +{ + return new OCCViewer_ViewFrame( parent, "occView" ); +} + +extern "C" +{ + QAD_ViewFrame* createView(QAD_RightFrame* parent) + { + return OCCViewer::createView(parent); + } +} diff --git a/src/OCCViewer/OCCViewer.h b/src/OCCViewer/OCCViewer.h new file mode 100644 index 000000000..a72d97a19 --- /dev/null +++ b/src/OCCViewer/OCCViewer.h @@ -0,0 +1,25 @@ +// File : OCCViewer.h +// Created : Wed Mar 20 11:56:18 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef OCCViewer_HeaderFile +#define OCCViewer_HeaderFile + +#include "QAD_RightFrame.h" +#include "QAD_ViewFrame.h" + +class OCCViewer : public QObject +{ + Q_OBJECT + +public : + + Standard_EXPORT static QAD_ViewFrame* createView ( QAD_RightFrame* parent); + +}; + +#endif diff --git a/src/OCCViewer/OCCViewer_AISSelector.cxx b/src/OCCViewer/OCCViewer_AISSelector.cxx new file mode 100644 index 000000000..a74e00636 --- /dev/null +++ b/src/OCCViewer/OCCViewer_AISSelector.cxx @@ -0,0 +1,201 @@ +using namespace std; +// File : OCCViewer_AISSelector.cxx +// Created : Wed Mar 20 10:58:50 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +/*! + \class OCCViewer_AISSelector OCCViewer_AISSelector.h + \brief Selector for AIS interactive context. + + Used only by Viewer Open CASCADE. +*/ + +#include "OCCViewer_AISSelector.h" + +/*! + Constructor +*/ +OCCViewer_AISSelector::OCCViewer_AISSelector( const Handle (AIS_InteractiveContext)& aisContext) : +myAISContext ( aisContext ) +{ + initialize(); +} + +/*! + Destructor +*/ +OCCViewer_AISSelector::~OCCViewer_AISSelector() +{ + cleanup(); +} + +/*! + Initialization ( internal ) +*/ +void OCCViewer_AISSelector::initialize() +{ + QAD_ASSERT_DEBUG_ONLY ( !myAISContext.IsNull() ); + + myHilightColor = Quantity_NOC_CYAN1; + mySelectColor = Quantity_NOC_GRAY80; + + myAISContext->SetHilightColor( myHilightColor ); + myAISContext->SelectionColor( mySelectColor ); + myAISContext->SetSubIntensityColor( Quantity_NOC_CYAN1 ); +} + +/*! + Cleanup ( internal ) +*/ +void OCCViewer_AISSelector::cleanup() +{ +} + +/*! + Sets the color to hilight the detected objects +*/ +void OCCViewer_AISSelector::setHilightColor ( Quantity_NameOfColor color ) +{ + myHilightColor = color; +} + +/*! + Sets the color to display the selected objects +*/ +void OCCViewer_AISSelector::setSelectColor ( Quantity_NameOfColor color ) +{ + mySelectColor = color; +} + +/*! + Sets the interactive context for this selector +*/ +void OCCViewer_AISSelector::setContext ( const Handle (AIS_InteractiveContext)& aisContext ) +{ + QAD_ASSERT_DEBUG_ONLY ( !aisContext.IsNull() ); + myAISContext = aisContext; +} + +/*! + Checks the status of pick and emits 'selSelectionDone' or + 'selSelectionCancel'. + Returns 'true' if no error, 'false' otherwise. +*/ +bool OCCViewer_AISSelector::checkSelection ( AIS_StatusOfPick status, bool hadSelection, bool addTo ) +{ + 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 ); +} + + +/*! + 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 ) +{ + if ( !myEnableSelection ) + return false; + + 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 ); +} + +/*! + Selects the detected interactive objects. + Calls checkSelection() for checking the status. +*/ +bool OCCViewer_AISSelector::select () +{ + if ( !myEnableSelection ) + return false; + + QAD_ASSERT_DEBUG_ONLY ( !myAISContext.IsNull() ); + bool hadSelection = ( myNumSelected > 0 ); + + /* select and send notifications */ + return checkSelection ( myAISContext->Select(), hadSelection, false ); +} + +/*! + Selects the objects covered by the rectangle. + 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, + const Handle (V3d_View)& view ) +{ + if ( !myEnableSelection || !myEnableMultipleSelection ) + return false; /* selection with rectangle is considered as multiple selection */ + + QAD_ASSERT_DEBUG_ONLY ( !myAISContext.IsNull() ); + bool hadSelection = ( myNumSelected > 0 ); + + /* select and send notifications */ + return checkSelection ( myAISContext->Select(left, top, right, bottom, view), + hadSelection, false ); +} + +/*! + Adds new selected objects to the objects previously selected. + Multiple selection must be enabled to get use of this function. + Calls checkSelection() for checking the status. +*/ +bool OCCViewer_AISSelector::shiftSelect () +{ + if ( !myEnableSelection ) + return false; + + QAD_ASSERT_DEBUG_ONLY ( !myAISContext.IsNull() ); + bool hadSelection = ( myNumSelected > 0 ); /* something was selected */ + if ( hadSelection && !myEnableMultipleSelection) + return false; + + /* select and send notifications */ + return checkSelection ( myAISContext->ShiftSelect(), hadSelection, true ); +} + +/*! + Adds new selected objects covered by the rectangle to the objects + previously selected. + 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, + const Handle (V3d_View)& view ) + +{ + if ( !myEnableSelection || !myEnableMultipleSelection ) + return false; /* 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; + + /* select and send notifications */ + return checkSelection ( myAISContext->ShiftSelect(left,top,right,bottom, view), + hadSelection, true ); +} diff --git a/src/OCCViewer/OCCViewer_AISSelector.h b/src/OCCViewer/OCCViewer_AISSelector.h new file mode 100644 index 000000000..d1b17c15b --- /dev/null +++ b/src/OCCViewer/OCCViewer_AISSelector.h @@ -0,0 +1,53 @@ +// File : OCCViewer_AISSelector.h +// Created : Wed Mar 20 10:58:22 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef OCCViewer_AISSELECTOR_H +#define OCCViewer_AISSELECTOR_H + +#include "QAD.h" +#include "OCCViewer_Selector.h" + +// Open CASCADE Includes +#include +#include + +class QAD_EXPORT OCCViewer_AISSelector : public OCCViewer_Selector +{ + Q_OBJECT + + void initialize(); + void cleanup(); + +public: + OCCViewer_AISSelector( const Handle (AIS_InteractiveContext)& ); + ~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 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 ); + +protected: + Handle (AIS_InteractiveContext) myAISContext; // graphic context + Quantity_NameOfColor myHilightColor; // color for hilight object + Quantity_NameOfColor mySelectColor; // color for selected object + +}; + +#endif + diff --git a/src/OCCViewer/OCCViewer_Selector.cxx b/src/OCCViewer/OCCViewer_Selector.cxx new file mode 100644 index 000000000..7b3d9480b --- /dev/null +++ b/src/OCCViewer/OCCViewer_Selector.cxx @@ -0,0 +1,52 @@ +using namespace std; +// File : OCCViewer_Selector.cxx +// Created : Wed Mar 20 10:57:47 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + + +/*! + \class OCCViewer_Selector OCCViewer_Selector.h + \brief Base class for object selection in Open CASCADE Viewer. +*/ + +#include "OCCViewer_Selector.h" + +/*! + Constructor +*/ +OCCViewer_Selector::OCCViewer_Selector() : + myNumSelected (0), + myEnableSelection( true ), + myEnableMultipleSelection( true ) +{ +} + +/*! + Destructor +*/ +OCCViewer_Selector::~OCCViewer_Selector() +{ +} + +/*! + Enables/disables selection +*/ +void OCCViewer_Selector::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_Selector::enableMultipleSelection( bool bEnable ) +{ + myEnableMultipleSelection = bEnable; + if ( bEnable ) myEnableSelection = bEnable; +} diff --git a/src/OCCViewer/OCCViewer_Selector.h b/src/OCCViewer/OCCViewer_Selector.h new file mode 100644 index 000000000..3322d75ac --- /dev/null +++ b/src/OCCViewer/OCCViewer_Selector.h @@ -0,0 +1,46 @@ +// File : OCCViewer_Selector.h +// Created : Wed Mar 20 10:56:53 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef OCCViewer_SELECTOR_H +#define OCCViewer_SELECTOR_H + +#include "QAD.h" + +// QT Include +#include + +// Open CASCADE Include +#include +#include + +class QAD_EXPORT OCCViewer_Selector : public QObject +{ + Q_OBJECT + + public: + OCCViewer_Selector(); + virtual ~OCCViewer_Selector(); + + public: + void enableSelection( bool ); + void enableMultipleSelection( bool ); + + signals: + + void selSelectionDone( bool bAdded ); + void selSelectionCancel( bool bAdded ); + + protected: + + int myNumSelected; + bool myEnableSelection; + bool myEnableMultipleSelection; +}; + +#endif + diff --git a/src/OCCViewer/OCCViewer_VService.cxx b/src/OCCViewer/OCCViewer_VService.cxx new file mode 100644 index 000000000..be23a846e --- /dev/null +++ b/src/OCCViewer/OCCViewer_VService.cxx @@ -0,0 +1,261 @@ +using namespace std; +// File : OCCViewer_VService.cxx +// Created : Wed Mar 20 10:36:38 2002 +// Author : GG, FMN, Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "OCCViewer_VService.h" + +// Open CASCADE Includes +#include +#include +#include + +#include +#include +#include + +#ifdef WNT +#include +#include +#include +#include +#include +#else +#include +#include +#include +#include +#include +#endif + +// For 2d +#define LOPTIM +#ifdef WNT +#ifndef LOPTIM +static Handle(WNT_GraphicDevice) XServiceDefault2dDevice; +static Handle(WNT_GraphicDevice) XServiceImageDevice; +#else +static Handle(WNT_GraphicDevice)& _XServiceDefault2dDevice() { +static Handle(WNT_GraphicDevice) XServiceDefault2dDevice; +return XServiceDefault2dDevice; +} +#define XServiceDefault2dDevice _XServiceDefault2dDevice() + +static Handle(WNT_GraphicDevice)& _XServiceImageDevice() { +static Handle(WNT_GraphicDevice) XServiceImageDevice; +return XServiceImageDevice; +} +#define XServiceImageDevice _XServiceImageDevice() +#endif // LOPTIM +#else +#ifndef LOPTIM +static Handle(Xw_GraphicDevice) XServiceDefault2dDevice; +static Handle(Xw_GraphicDevice) XServiceImageDevice; +#else +static Handle(Xw_GraphicDevice)& _XServiceDefault2dDevice() { +static Handle(Xw_GraphicDevice) XServiceDefault2dDevice; +return XServiceDefault2dDevice; +} +#define XServiceDefault2dDevice _XServiceImageDevice() + +static Handle(Xw_GraphicDevice)& _XServiceImageDevice() { +static Handle(Xw_GraphicDevice) XServiceImageDevice; +return XServiceImageDevice; +} +#define XServiceImageDevice _XServiceImageDevice() +#endif // LOPTIM +#endif // WNT + + +// ==================================== 3D ================================================================ +/*----------------------------------------------------------------------*/ + +void OCCViewer_VService::SetWindow (const Handle(V3d_View)& aView, + const Standard_Integer hiwin, + const Standard_Integer lowin, + const Xw_WindowQuality aQuality) +{ +#ifdef WNT + Handle(WNT_Window) w = new WNT_Window(Handle(Graphic3d_WNTGraphicDevice)::DownCast(aView->Viewer()->Device()),hiwin,lowin); +#else + Handle(Xw_Window) w = new Xw_Window(Handle(Graphic3d_GraphicDevice)::DownCast(aView->Viewer()->Device()),hiwin,lowin,aQuality); +#endif + aView->SetWindow(w); +// aView->SetShadingModel(V3d_GOURAUD); +} + +/*----------------------------------------------------------------------*/ + +void OCCViewer_VService::SetMagnify (const Handle(V3d_View)& aView, + const Standard_Integer hiwin, + const Standard_Integer lowin, + const Handle(V3d_View)& aPreviousView, + const Standard_Integer x1, + const Standard_Integer y1, + const Standard_Integer x2, + const Standard_Integer y2, + const Xw_WindowQuality aQuality) +{ +#ifdef WNT + Handle(WNT_Window) w = new WNT_Window(Handle(Graphic3d_WNTGraphicDevice)::DownCast(aView->Viewer()->Device()),hiwin,lowin); +#else + Handle(Xw_Window) w = new Xw_Window(Handle(Graphic3d_GraphicDevice)::DownCast(aView->Viewer()->Device()),hiwin,lowin,aQuality); +#endif // WNT + + aView->SetMagnify(w,aPreviousView,x1,y1,x2,y2); +// aView->SetShadingModel(V3d_GOURAUD); +// aView->SetSurfaceDetail(V3d_TEX_NONE); +// aView->SetVisualization(V3d_WIREFRAME); +// aView->SetVisualization(V3d_ZBUFFER); +} +/*----------------------------------------------------------------------*/ + +Handle(V3d_Viewer) OCCViewer_VService::Viewer( const Standard_CString aDisplay, + const Standard_ExtString aName, + const Standard_CString aDomain, + const Standard_Real ViewSize, + const V3d_TypeOfOrientation ViewProj, + const Standard_Boolean ComputedMode, + const Standard_Boolean aDefaultComputedMode ) +{ +#ifndef WNT +static Handle(Graphic3d_GraphicDevice) defaultdevice; + + if(defaultdevice.IsNull()) defaultdevice = new Graphic3d_GraphicDevice(aDisplay); + return new V3d_Viewer(defaultdevice,aName,aDomain,ViewSize,ViewProj, + Quantity_NOC_GRAY30,V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT, + ComputedMode,aDefaultComputedMode,V3d_TEX_NONE); +#else + static Handle(Graphic3d_WNTGraphicDevice) defaultdevice; + + if(defaultdevice.IsNull()) defaultdevice = new Graphic3d_WNTGraphicDevice(); + return new V3d_Viewer(defaultdevice,aName,aDomain,ViewSize,ViewProj, + Quantity_NOC_GRAY30,V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT, + ComputedMode,aDefaultComputedMode,V3d_TEX_NONE); +#endif // WNT +} + +/*----------------------------------------------------------------------*/ +// ==================================== 2D ================================================================ +Handle(V2d_View) OCCViewer_VService::XView( const Handle(V2d_Viewer)& aViewer, + const Standard_Integer hiwin, + const Standard_Integer lowin, + const Xw_WindowQuality aQuality, + const Standard_Boolean Update, + const Quantity_NameOfColor BackColor) +{ +#ifdef WNT + Handle(WNT_GraphicDevice) GD = Handle(WNT_GraphicDevice)::DownCast(aViewer->Device()); + Handle(WNT_Window) W = new WNT_Window(GD,hiwin,lowin,BackColor); + Handle(WNT_WDriver) D = new WNT_WDriver(W); +#else + Handle(Xw_GraphicDevice) GD = Handle(Xw_GraphicDevice)::DownCast(aViewer->Device()); + Handle(Xw_Window) W = new Xw_Window(GD,hiwin,lowin,aQuality,BackColor); + Handle(Xw_Driver) D = new Xw_Driver(W); +#endif + + Handle(V2d_View) V = new V2d_View(D,aViewer); + if(Update) V->Update(); + return V; +} + +Handle(V2d_View) OCCViewer_VService::XdpsView( const Handle(V2d_Viewer)& aViewer, + const Standard_Integer hiwin, + const Standard_Integer lowin, + const Xw_WindowQuality aQuality, + const Standard_Boolean Update, + const Quantity_NameOfColor BackColor) +{ +#ifdef WNT + Handle(WNT_GraphicDevice) GD = Handle(WNT_GraphicDevice)::DownCast(aViewer->Device()); + Handle(WNT_Window) W = new WNT_Window(GD,hiwin,lowin,BackColor); +//POP + W->SetBackground(BackColor); +//POP + Handle(WNT_WDriver) D = new WNT_WDriver(W); +#else + Handle(Xw_GraphicDevice) GD = Handle(Xw_GraphicDevice)::DownCast(aViewer->Device()); + Handle(Xw_Window) W = new Xw_Window(GD,hiwin,lowin,aQuality,BackColor); + Handle(Xdps_Driver) D = new Xdps_Driver(W); +#endif + Handle(V2d_View) V = new V2d_View(D,aViewer); + if(Update) V->Update(); + return V; +} + +Handle(V2d_Viewer) OCCViewer_VService::Viewer( const Standard_CString aDisplay, + const Standard_ExtString aName, + const Standard_CString aDomain) +{ +#ifdef WNT + if(XServiceDefault2dDevice.IsNull()) XServiceDefault2dDevice = new WNT_GraphicDevice(); +#else + if(XServiceDefault2dDevice.IsNull()) XServiceDefault2dDevice = new Xw_GraphicDevice(aDisplay,Xw_TOM_READONLY); +#endif + return new V2d_Viewer(XServiceDefault2dDevice,aName,aDomain); +} + +Handle(V2d_Viewer) OCCViewer_VService::Viewer( const Standard_CString aDisplay, + const Handle(Graphic2d_View)& aView, + const Standard_ExtString aName, + const Standard_CString aDomain) +{ +#ifdef WNT + if(XServiceDefault2dDevice.IsNull()) XServiceDefault2dDevice = new WNT_GraphicDevice(); +#else + if(XServiceDefault2dDevice.IsNull()) XServiceDefault2dDevice = new Xw_GraphicDevice(aDisplay,Xw_TOM_READONLY); +#endif + return new V2d_Viewer(XServiceDefault2dDevice,aView,aName,aDomain); +} + +Handle(Aspect_WindowDriver) OCCViewer_VService::WindowDriver( const Standard_CString aDisplay, + const Standard_Integer ahiwin, + const Standard_Integer alowin, + const Quantity_NameOfColor aColor) +{ +#ifdef WNT + if(XServiceDefault2dDevice.IsNull()) XServiceDefault2dDevice = new WNT_GraphicDevice(); + Handle(WNT_Window) W = new WNT_Window(XServiceDefault2dDevice,ahiwin,alowin,aColor); + return new WNT_WDriver(W); +#else + if(XServiceDefault2dDevice.IsNull()) XServiceDefault2dDevice = new Xw_GraphicDevice(aDisplay,Xw_TOM_READONLY); + Handle(Xw_Window) W = new Xw_Window(XServiceDefault2dDevice,ahiwin,alowin,Xw_WQ_DRAWINGQUALITY,aColor); + return new Xw_Driver(W); +#endif +} + +Handle(Aspect_WindowDriver) OCCViewer_VService::XdpsDriver( const Standard_CString aDisplay, + const Standard_Integer ahiwin, + const Standard_Integer alowin, + const Quantity_NameOfColor aColor) +{ +#ifdef WNT + if(XServiceDefault2dDevice.IsNull()) XServiceDefault2dDevice = new WNT_GraphicDevice(); + Handle(WNT_Window) W = new WNT_Window(XServiceDefault2dDevice,ahiwin,alowin,aColor); + return new WNT_WDriver(W); +#else + if(XServiceDefault2dDevice.IsNull()) XServiceDefault2dDevice = new Xw_GraphicDevice(aDisplay,Xw_TOM_READONLY); + Handle(Xw_Window) W = new Xw_Window(XServiceDefault2dDevice,ahiwin,alowin,Xw_WQ_DRAWINGQUALITY,aColor); + return new Xdps_Driver(W); +#endif +} + +Handle(Aspect_WindowDriver) OCCViewer_VService::ImageDriver( const Standard_CString aDisplay, + const Standard_Integer ahiwin, + const Standard_Integer alowin, + const Quantity_NameOfColor aColor) +{ +#ifdef WNT + if(XServiceImageDevice.IsNull()) XServiceImageDevice = new WNT_GraphicDevice(); + Handle(WNT_Window) W = new WNT_Window(XServiceImageDevice,ahiwin,alowin,aColor); + return new WNT_WDriver(W); +#else + if(XServiceImageDevice.IsNull()) XServiceImageDevice = new Xw_GraphicDevice(aDisplay,Xw_TOM_READONLY); + Handle(Xw_Window) W = new Xw_Window(XServiceImageDevice,ahiwin,alowin,Xw_WQ_PICTUREQUALITY,aColor); + return new Xw_Driver(W); +#endif +} diff --git a/src/OCCViewer/OCCViewer_VService.h b/src/OCCViewer/OCCViewer_VService.h new file mode 100644 index 000000000..5c133d8d1 --- /dev/null +++ b/src/OCCViewer/OCCViewer_VService.h @@ -0,0 +1,139 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _OCCViewer_VService_HeaderFile +#define _OCCViewer_VService_HeaderFile + +#ifndef _Handle_V3d_View_HeaderFile +#include +#endif +#ifndef _Handle_V2d_View_HeaderFile +#include +#endif +#ifndef _Handle_V2d_Viewer_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Xw_WindowQuality_HeaderFile +#include +#endif +#ifndef _Handle_V3d_Viewer_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif +#ifndef _Standard_ExtString_HeaderFile +#include +#endif +#ifndef _Quantity_Length_HeaderFile +#include +#endif +#ifndef _Quantity_NameOfColor_HeaderFile +#include +#endif +#ifndef _V3d_TypeOfOrientation_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_Graphic2d_View_HeaderFile +#include +#endif +#ifndef _Handle_Aspect_WindowDriver_HeaderFile +#include +#endif + +class V3d_View; +class V3d_Viewer; + +class V2d_View; +class V2d_Viewer; +class Graphic2d_View; +class Aspect_WindowDriver; + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class OCCViewer_VService { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + +// Methods PUBLIC +// +Standard_EXPORT static void SetWindow(const Handle(V3d_View)& aView,const Standard_Integer hiwin,const Standard_Integer lowin,const Xw_WindowQuality aQuality = Xw_WQ_3DQUALITY) ; +Standard_EXPORT static void SetMagnify(const Handle(V3d_View)& aView,const Standard_Integer hiwin,const Standard_Integer lowin,const Handle(V3d_View)& aPreviousView,const Standard_Integer x1,const Standard_Integer y1,const Standard_Integer x2,const Standard_Integer y2,const Xw_WindowQuality aQuality = Xw_WQ_3DQUALITY) ; +Standard_EXPORT static Handle_V3d_Viewer Viewer(const Standard_CString aDisplay,const Standard_ExtString aName,const Standard_CString aDomain = "",const Quantity_Length ViewSize = 1000.0,const V3d_TypeOfOrientation ViewProj = V3d_XposYnegZpos,const Standard_Boolean ComputedMode = Standard_True,const Standard_Boolean DefaultComputedMode = Standard_True) ; + +Standard_EXPORT static Handle_V2d_View XView(const Handle(V2d_Viewer)& aViewer,const Standard_Integer hiwin,const Standard_Integer lowin,const Xw_WindowQuality aQuality = Xw_WQ_DRAWINGQUALITY,const Standard_Boolean Update = Standard_True,const Quantity_NameOfColor BackColor = Quantity_NOC_MATRAGRAY) ; +Standard_EXPORT static Handle_V2d_View XdpsView(const Handle(V2d_Viewer)& aViewer,const Standard_Integer hiwin,const Standard_Integer lowin,const Xw_WindowQuality aQuality = Xw_WQ_DRAWINGQUALITY,const Standard_Boolean Update = Standard_True,const Quantity_NameOfColor BackColor = Quantity_NOC_MATRAGRAY) ; +Standard_EXPORT static Handle_V2d_Viewer Viewer(const Standard_CString aDisplay,const Standard_ExtString aName,const Standard_CString aDomain = "") ; +Standard_EXPORT static Handle_V2d_Viewer Viewer(const Standard_CString aDisplay,const Handle(Graphic2d_View)& aView,const Standard_ExtString aName,const Standard_CString aDomain = "") ; +Standard_EXPORT static Handle_Aspect_WindowDriver WindowDriver(const Standard_CString aDisplay,const Standard_Integer ahiwin,const Standard_Integer alowin,const Quantity_NameOfColor aColor = Quantity_NOC_GRAY69) ; +Standard_EXPORT static Handle_Aspect_WindowDriver XdpsDriver(const Standard_CString aDisplay,const Standard_Integer ahiwin,const Standard_Integer alowin,const Quantity_NameOfColor aColor = Quantity_NOC_GRAY69) ; +Standard_EXPORT static Handle_Aspect_WindowDriver ImageDriver(const Standard_CString aDisplay,const Standard_Integer ahiwin,const Standard_Integer alowin,const Quantity_NameOfColor aColor = Quantity_NOC_GRAY69) ; + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif + diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx new file mode 100644 index 000000000..ac6aca857 --- /dev/null +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -0,0 +1,644 @@ +using namespace std; +// File : OCCViewer_ViewFrame.cxx +// Created : Wed Mar 20 10:50:22 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "OCCViewer_ViewFrame.h" +#include "OCCViewer_Viewer3d.h" +#include "OCCViewer_ViewPort.h" +#include "OCCViewer_ViewPort3d.h" + +#include "QAD.h" +#include "QAD_Tools.h" +#include "QAD_Desktop.h" +#include "QAD_ViewFrame.h" +#include "QAD_MessageBox.h" +#include "QAD_Application.h" +#include "utilities.h" + +#include "SALOME_Selection.h" +#include "SALOME_AISShape.hxx" + +// QT Include +#include + +// Open CASCADE Include +#include +#include + + +/*! + Constructor +*/ +OCCViewer_ViewFrame::OCCViewer_ViewFrame(QWidget* parent, const QString& title) + : QAD_ViewFrame (parent, "") +{ + initialize(); +} + +/*! + Constructor +*/ +OCCViewer_ViewFrame::OCCViewer_ViewFrame( QWidget* parent ) + : QAD_ViewFrame (parent, "") +{ + initialize(); +} + +/*! + Destructor +*/ +OCCViewer_ViewFrame::~OCCViewer_ViewFrame() +{ + cleanup(); +} + +/*! + Init viewframe +*/ +void OCCViewer_ViewFrame::initialize() +{ + myViewPort = NULL; + myViewer = new OCCViewer_Viewer3d( this ); + + /* enable/disable selection */ + myViewer->enableSelection( true ); + myViewer->enableMultipleSelection( true ); +} + +/*! + Cleanup viewframe +*/ +void OCCViewer_ViewFrame::cleanup() +{ + +} + +/*! + Sets the viewport for this frame +*/ +void OCCViewer_ViewFrame::setViewPort( OCCViewer_ViewPort* view ) +{ + myViewPort = view; + initViewPort(); + setCentralWidget ( myViewPort ); +} + +/*! + Inits the viewport for this frame +*/ +void OCCViewer_ViewFrame::initViewPort() +{ + /* Active Key Event */ + setFocus(); + + /* Initial attributes */ + myViewPort->setCursor( cursor() ); + myViewPort->setBackgroundColor( backgroundColor() ); + + QAD_ASSERT ( QObject::connect(myViewPort, SIGNAL(vpKeyPress (QKeyEvent*)), + this, SIGNAL(vfKeyPress(QKeyEvent*))) ); + + /* Listen to my viewport */ + QAD_ASSERT ( QObject::connect(myViewPort, + SIGNAL(vpTransformationStarted (OCCViewer_ViewPort::OperationType)), + this, + SIGNAL(vfTransformationStarted(OCCViewer_ViewPort::OperationType))) ); + QAD_ASSERT ( QObject::connect( myViewPort, + SIGNAL(vpTransformationFinished (OCCViewer_ViewPort::OperationType)), + this, + SIGNAL(vfTransformationFinished(OCCViewer_ViewPort::OperationType))) ); + + QAD_ASSERT ( QObject::connect(myViewPort, SIGNAL(vpDrawExternal (QPainter*)), + this, SIGNAL(vfDrawExternal(QPainter*))) ); + QAD_ASSERT ( QObject::connect(myViewPort, SIGNAL(vpMousePress (QMouseEvent*)), + this, SIGNAL(vfMousePress(QMouseEvent*))) ); + QAD_ASSERT ( QObject::connect(myViewPort, SIGNAL(vpMouseRelease (QMouseEvent*)), + this, SIGNAL(vfMouseRelease(QMouseEvent*))) ); + QAD_ASSERT ( QObject::connect(myViewPort, SIGNAL(vpMouseMove (QMouseEvent*)), + this, SIGNAL(vfMouseMove(QMouseEvent*))) ); + QAD_ASSERT ( QObject::connect(myViewPort, SIGNAL(vpMouseDoubleClick (QMouseEvent*)), + this, SIGNAL(vfMouseDoubleClick(QMouseEvent*))) ); + + QAD_ASSERT ( QObject::connect(myViewPort, SIGNAL(vpKeyPress (QKeyEvent*)), + this, SIGNAL(vfKeyPress(QKeyEvent*))) ); + QAD_ASSERT ( QObject::connect(myViewPort, SIGNAL(vpKeyRelease (QKeyEvent*)), + this, SIGNAL(vfKeyRelease(QKeyEvent*))) ); +} + +/*! + Returns widget containing 3D-Viewer +*/ +QWidget* OCCViewer_ViewFrame::getViewWidget() +{ + return (QWidget*)getViewPort(); +} + +/*! + Returns the viewport of this frame +*/ +OCCViewer_ViewPort* OCCViewer_ViewFrame::getViewPort() const +{ + return myViewPort; +} + +/*! + Sets the cursor for the viewframe's viewport +*/ +void OCCViewer_ViewFrame::setCursor( const QCursor& cursor) +{ + if ( myViewPort ) + myViewPort->QWidget::setCursor(cursor); +} + +/*! + Returns the current cursor +*/ +QCursor OCCViewer_ViewFrame::cursor() const +{ + if ( myViewPort ) + return myViewPort->cursor(); + return QMainWindow::cursor(); +} + +/*! + Set background of the viewport +*/ +void OCCViewer_ViewFrame::setBackgroundColor( const QColor& color) +{ + if ( myViewPort ) + myViewPort->setBackgroundColor(color); +} + +/*! + Returns background of the viewport +*/ +QColor OCCViewer_ViewFrame::backgroundColor() const +{ + if ( myViewPort ) + return myViewPort->backgroundColor(); + return QMainWindow::backgroundColor(); +} + +/*! + Sets the parent viewer for the window +*/ +void OCCViewer_ViewFrame::setViewer(OCCViewer_Viewer3d* viewer) +{ + myViewer = viewer; +} + +/*! + Returns the parent viewer for the window +*/ +OCCViewer_Viewer3d* OCCViewer_ViewFrame::getViewer() const +{ + return myViewer; +} + +/*! + Returns 'true' if viewframe is visible +*/ +void OCCViewer_ViewFrame::setVisible( bool visible ) +{ + if ( visible == QWidget::isVisible() ) + return; + + if ( visible ) show(); + else hide(); +} + +/*! + Called when viewframe is about to close +*/ +void OCCViewer_ViewFrame::closeEvent(QCloseEvent* e) +{ + emit vfViewClosing(e); /* notify our viewer */ +} + +/*! + Called when viewframe is resized +*/ +void OCCViewer_ViewFrame::resizeEvent(QResizeEvent* e) +{ + emit vfResize(e); +} + +void OCCViewer_ViewFrame::keyPressEvent( QKeyEvent *k ) +{ + emit vfKeyPress(k); +} + +/*! + Fits all objects in the active view +*/ +void OCCViewer_ViewFrame::onViewFitAll() +{ + myViewPort->fitAll(); +} + +/*! + Fits all obejcts within a rectangular area of the active view +*/ +void OCCViewer_ViewFrame::onViewFitArea() +{ + myViewPort->activateWindowFit(); + QAD_Application::getDesktop()->putInfo( tr("PRP_VW3D_SKETCHAREA") ); +} + +/*! + Moves the active view +*/ +void OCCViewer_ViewFrame::onViewPan() +{ + myViewPort->activatePanning(); +} + +/*! + Zooms the active view +*/ +void OCCViewer_ViewFrame::onViewZoom() +{ + myViewPort->activateZoom(); +} + +/*! + Sets a new center of the active view +*/ +void OCCViewer_ViewFrame::onViewGlobalPan() +{ + myViewPort->activateGlobalPanning(); + QAD_Application::getDesktop()->putInfo( tr("PRP_VW3D_POINTCENTER") ); +} + +/*! + Rotates the active view +*/ +void OCCViewer_ViewFrame::onViewRotate() +{ + myViewPort->activateRotation(); +} + +/*! + Reset the active view +*/ +void OCCViewer_ViewFrame::onViewReset() +{ + myViewPort->reset(); +} + +/*! + Provides front projection of the active view +*/ +void OCCViewer_ViewFrame::onViewFront() +{ + Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)myViewPort)->getView(); + if ( !view3d.IsNull() ) view3d->SetProj (V3d_Xpos); + onViewFitAll(); +} + +/*! + Provides back projection of the active view +*/ +void OCCViewer_ViewFrame::onViewBack() +{ + Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)myViewPort)->getView(); + if ( !view3d.IsNull() ) view3d->SetProj (V3d_Xneg); + onViewFitAll(); +} + +/*! + Provides right projection of the active view +*/ +void OCCViewer_ViewFrame::onViewRight() +{ + Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)myViewPort)->getView(); + if ( !view3d.IsNull() ) view3d->SetProj (V3d_Yneg); + onViewFitAll(); +} + +/*! + Provides left projection of the active view +*/ +void OCCViewer_ViewFrame::onViewLeft() +{ + Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)myViewPort)->getView(); + if ( !view3d.IsNull() ) view3d->SetProj (V3d_Ypos); + onViewFitAll(); +} + +/*! + Provides bottom projection of the active view +*/ +void OCCViewer_ViewFrame::onViewBottom() +{ + Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)myViewPort)->getView(); + if ( !view3d.IsNull() ) view3d->SetProj(V3d_Zneg); + onViewFitAll(); +} + +/*! + Provides top projection of the active view +*/ +void OCCViewer_ViewFrame::onViewTop() +{ + Handle( V3d_View) view3d = ((OCCViewer_ViewPort3d*)myViewPort)->getView(); + if ( !view3d.IsNull() ) view3d->SetProj( V3d_Zpos ); + onViewFitAll(); +} + +/*! + Display/hide Trihedron +*/ +void OCCViewer_ViewFrame::onViewTrihedron() +{ + if (!myViewer->getAISContext()->IsDisplayed( myViewer->getTrihedron() )) + myViewer->getAISContext()->Display( myViewer->getTrihedron() ); + else + myViewer->getAISContext()->Erase( myViewer->getTrihedron() ); +} + +void OCCViewer_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject, QString newName ) +{ + myViewer->rename(IObject, newName); +} + +void OCCViewer_ViewFrame::unHighlightAll() +{ + myViewer->unHighlightAll(); +} + +void OCCViewer_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject, bool highlight, bool update ) +{ + myViewer->highlight(IObject, highlight, update); +} + +bool OCCViewer_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject ) +{ + return myViewer->isInViewer( IObject ); +} + +bool OCCViewer_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject ) +{ + return myViewer->isVisible( IObject ); +} + +void OCCViewer_ViewFrame::setPopupServer( QAD_Application* App ) +{ + myViewer->setPopupServer( App ); +} + +void OCCViewer_ViewFrame::undo(SALOMEDS::Study_var aStudy, + const char* StudyFrameEntry) +{ + 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); + } + } + } + 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); + } + } + } + ite.Next(); + } +} + +void OCCViewer_ViewFrame::redo(SALOMEDS::Study_var aStudy, + 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)) { + + 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(); + } + + } + } + + 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(); + } + Repaint(); +} + +void OCCViewer_ViewFrame::SetTrihedronSize( int dim ) +{ + myViewer->setTrihedronSize( dim ); +} + +/* selection */ +Handle(SALOME_InteractiveObject) OCCViewer_ViewFrame::FindIObject(const char* Entry) +{ + Handle(SALOME_InteractiveObject) IO; + Handle (AIS_InteractiveContext) ic = myViewer->getAISContext(); + + AIS_ListOfInteractive List; + ic->DisplayedObjects(List); + AIS_ListOfInteractive List1; + 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() ) { + IO = aSh->getIO(); + if ( IO->hasEntry() ) { + if ( strcmp( IO->getEntry(), Entry ) == 0 ) { + MESSAGE ( "IO found") + return IO; + } + } + } + } + ite.Next(); + } + MESSAGE ( "IO not found") + return IO; +} + +/* display */ +void OCCViewer_ViewFrame::Display(const Handle(SALOME_InteractiveObject)& IObject, bool update) +{ + QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel + = SALOME_Selection::Selection( myStudy->getSelection() ); + + Handle (AIS_InteractiveContext) ic = myViewer->getAISContext(); + + AIS_ListOfInteractive List; + ic->DisplayedObjects(List); + AIS_ListOfInteractive List1; + 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; + } + } + } + ite.Next(); + } + if (update) + Repaint(); +} + +void OCCViewer_ViewFrame::DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject) +{ + QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel + = SALOME_Selection::Selection( myStudy->getSelection() ); + + Handle (AIS_InteractiveContext) ic = myViewer->getAISContext(); + + AIS_ListOfInteractive List; + ic->DisplayedObjects(List); + AIS_ListOfInteractive List1; + 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); + } + } + } + ite.Next(); + } + Repaint(); +} +void OCCViewer_ViewFrame::Erase(const Handle(SALOME_InteractiveObject)& IObject, bool update) +{ + QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel + = SALOME_Selection::Selection( myStudy->getSelection() ); + + Handle (AIS_InteractiveContext) ic = myViewer->getAISContext(); + + AIS_ListOfInteractive List; + ic->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 ) ) + { + ic->Erase(aSh, false); + Sel->RemoveIObject(IO, false); + break; + } + } + } + ite.Next(); + } + if (update) + Repaint(); +} + +void OCCViewer_ViewFrame::DisplayAll() +{ + myViewer->getAISContext()->DisplayAll(Standard_False,Standard_True); +} +void OCCViewer_ViewFrame::EraseAll() +{ + Standard_Boolean isTrihedronDisplayed = + myViewer->getAISContext()->IsDisplayed( myViewer->getTrihedron() ); + myViewer->getAISContext()->EraseAll(); + if (isTrihedronDisplayed) + myViewer->getAISContext()->Display( myViewer->getTrihedron() ); + else + Repaint(); +} + + + +void OCCViewer_ViewFrame::Repaint(){ + myViewer->getViewer3d()->Update(); +} diff --git a/src/OCCViewer/OCCViewer_ViewFrame.h b/src/OCCViewer/OCCViewer_ViewFrame.h new file mode 100644 index 000000000..6c156bc6d --- /dev/null +++ b/src/OCCViewer/OCCViewer_ViewFrame.h @@ -0,0 +1,124 @@ +// File : OCCViewer_ViewFrame.h +// Created : Wed Mar 20 10:53:24 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef OCCViewer_ViewFrame_H +#define OCCViewer_ViewFrame_H + +#include "OCCViewer_ViewPort.h" +#include "QAD_ViewFrame.h" + +class OCCViewer_Viewer3d; +class QAD_EXPORT OCCViewer_ViewFrame : public QAD_ViewFrame +{ + Q_OBJECT + + public: + OCCViewer_ViewFrame(QWidget* parent, const QString& title); + OCCViewer_ViewFrame(QWidget* parent = 0); + virtual ~OCCViewer_ViewFrame(); + + protected: + virtual void initViewPort(); + void initialize(); + void cleanup(); + + public: + ViewType getTypeView() const{ return VIEW_OCC;}; + QWidget* getViewWidget(); + void setViewPort(OCCViewer_ViewPort* view); + OCCViewer_ViewPort* getViewPort() const; + + void setViewer(OCCViewer_Viewer3d* viewer); + OCCViewer_Viewer3d* getViewer() const; + + void setVisible( bool isVisible = true ); + + void setBackgroundColor( const QColor& ); + QColor backgroundColor() const; + + void setCursor( const QCursor& ); + QCursor cursor() const; + + void SetSelectionMode( int mode ) {}; + + void SetTrihedronSize( int dim ); + + /* popup management */ + void setPopupServer( QAD_Application* ); + + + /* interactive object management */ + void highlight( const Handle(SALOME_InteractiveObject)& IObject, + bool highlight, bool update = true ); + void unHighlightAll(); + void rename( const Handle(SALOME_InteractiveObject)& IObject, + QString newName ); + 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); + + /* display */ + void Display(const Handle(SALOME_InteractiveObject)& IObject, bool update = true); + void DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject); + void Erase(const Handle(SALOME_InteractiveObject)& IObject, bool update = true); + void DisplayAll(); + void EraseAll(); + void Repaint(); + + protected: + void closeEvent(QCloseEvent* e); + void resizeEvent(QResizeEvent* e); + void keyPressEvent( QKeyEvent *k ); + + signals: + void vfTransformationStarted ( OCCViewer_ViewPort::OperationType ); + void vfTransformationFinished( OCCViewer_ViewPort::OperationType ); + void vfDrawExternal(QPainter* painter); + void vfMousePress(QMouseEvent*); + void vfMouseRelease(QMouseEvent*); + void vfMouseMove(QMouseEvent*); + void vfMouseDoubleClick(QMouseEvent*); + void vfKeyPress(QKeyEvent*); + void vfKeyRelease(QKeyEvent*); + void vfResize(QResizeEvent*); + void vfPrint(QPaintEvent*); + void vfViewClosing(QCloseEvent*); + void vfMoved (QMoveEvent*); + + public slots: + + void onViewPan(); + void onViewZoom(); + void onViewFitAll(); + void onViewFitArea(); + void onViewGlobalPan(); + void onViewRotate(); + void onViewReset(); + void onViewFront(); + void onViewBack(); + void onViewRight(); + void onViewLeft(); + void onViewBottom(); + void onViewTop(); + void onViewTrihedron(); + + protected: + OCCViewer_Viewer3d* myViewer; // my owner + OCCViewer_ViewPort* myViewPort; // child viewport +}; + +#endif + diff --git a/src/OCCViewer/OCCViewer_ViewPort.cxx b/src/OCCViewer/OCCViewer_ViewPort.cxx new file mode 100644 index 000000000..b03f3c18b --- /dev/null +++ b/src/OCCViewer/OCCViewer_ViewPort.cxx @@ -0,0 +1,987 @@ +using namespace std; +// File : OCCViewer_ViewPort.cxx +// Created : Wed Mar 20 10:44:24 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include + +#if !defined WNT +#define QT_CLEAN_NAMESPACE /* avoid definition of INT32 and INT8 */ +#endif + +#include "OCCViewer_ViewPort.h" + +#include "QAD.h" +#include "QAD_Tools.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" + +#if !defined WNT +#include +#include +#include +#include +#include +#undef QT_CLEAN_NAMESPACE +#include +#include + +#include +#include + +/* XPM */ +const char* imageZoomCursor[] = { +"32 32 3 1", +". c None", +"a c #000000", +"# c #ffffff", +"................................", +"................................", +".#######........................", +"..aaaaaaa.......................", +"................................", +".............#####..............", +"...........##.aaaa##............", +"..........#.aa.....a#...........", +".........#.a.........#..........", +".........#a..........#a.........", +"........#.a...........#.........", +"........#a............#a........", +"........#a............#a........", +"........#a............#a........", +"........#a............#a........", +".........#...........#.a........", +".........#a..........#a.........", +".........##.........#.a.........", +"........#####.....##.a..........", +".......###aaa#####.aa...........", +"......###aa...aaaaa.......#.....", +".....###aa................#a....", +"....###aa.................#a....", +"...###aa...............#######..", +"....#aa.................aa#aaaa.", +".....a....................#a....", +"..........................#a....", +"...........................a....", +"................................", +"................................", +"................................", +"................................"}; + +const char* imageRotateCursor[] = { +"32 32 3 1", +". c None", +"a c #000000", +"# c #ffffff", +"................................", +"................................", +"................................", +"................................", +"........#.......................", +".......#.a......................", +"......#######...................", +".......#aaaaa#####..............", +"........#..##.a#aa##........##..", +".........a#.aa..#..a#.....##.aa.", +".........#.a.....#...#..##.aa...", +".........#a.......#..###.aa.....", +"........#.a.......#a..#aa.......", +"........#a.........#..#a........", +"........#a.........#a.#a........", +"........#a.........#a.#a........", +"........#a.........#a.#a........", +".........#.........#a#.a........", +"........##a........#a#a.........", +"......##.a#.......#.#.a.........", +"....##.aa..##.....##.a..........", +"..##.aa.....a#####.aa...........", +"...aa.........aaa#a.............", +"................#.a.............", +"...............#.a..............", +"..............#.a...............", +"...............a................", +"................................", +"................................", +"................................", +"................................", +"................................"}; + +struct CMapEntry { + CMapEntry(); + ~CMapEntry(); + Colormap cmap; + bool alloc; + XStandardColormap scmap; +}; + +CMapEntry::CMapEntry() +{ + cmap = 0; + alloc = false; + scmap.colormap = 0; +} + +CMapEntry::~CMapEntry() +{ + if ( alloc ) + XFreeColormap( QPaintDevice::x11AppDisplay(), cmap ); +} + +static QIntDict *cmap_dict = 0; +static bool mesa_gl = false; + +static void cleanup_cmaps() +{ + if ( !cmap_dict ) + return; + cmap_dict->setAutoDelete(true); + delete cmap_dict; + cmap_dict = 0; +} + +static Colormap choose_cmap(Display *dpy, XVisualInfo *vi) +{ + if ( !cmap_dict ) + { + cmap_dict = new QIntDict; + const char *v = glXQueryServerString( dpy, vi->screen, GLX_VERSION ); + mesa_gl = strstr(v,"Mesa") != 0; + qAddPostRoutine( cleanup_cmaps ); + } + + CMapEntry *x = cmap_dict->find( (long)vi->visualid ); + if ( x ) // found colormap for visual + return x->cmap; + + x = new CMapEntry(); + + XStandardColormap *c; + int n, i; + +#ifdef DEBUG + MESSAGE( "Choosing cmap for vID = " << vi->visualid ); +#endif + + if ( vi->visualid == XVisualIDFromVisual( (Visual*)QPaintDevice::x11AppVisual() ) ) + { +#ifdef DEBUG + MESSAGE( "Using x11AppColormap" ); +#endif + return QPaintDevice::x11AppColormap(); + } + + if ( mesa_gl ) + { + Atom hp_cmaps = XInternAtom( dpy, "_HP_RGB_SMOOTH_MAP_LIST", true ); + if ( hp_cmaps && vi->visual->c_class == TrueColor && vi->depth == 8 ) + { + if ( XGetRGBColormaps(dpy, RootWindow(dpy,vi->screen), &c, &n, hp_cmaps) ) + { + i = 0; + while ( i < n && x->cmap == 0 ) + { + if ( c[i].visualid == vi->visual->visualid ) + { + x->cmap = c[i].colormap; + x->scmap = c[i]; + // Using HP_RGB scmap + } + i++; + } + XFree( (char *)c ); + } + } + } + +#if !defined(_OS_SOLARIS_) + if ( !x->cmap ) + { + if ( XmuLookupStandardColormap(dpy,vi->screen,vi->visualid,vi->depth, + XA_RGB_DEFAULT_MAP,false,true) ) + { + if ( XGetRGBColormaps(dpy,RootWindow(dpy,vi->screen),&c,&n, + XA_RGB_DEFAULT_MAP) ) + { + i = 0; + while ( i < n && x->cmap == 0 ) + { + if ( c[i].visualid == vi->visualid ) + { + x->cmap = c[i].colormap; + x->scmap = c[i]; + // Using RGB_DEFAULT scmap + } + i++; + } + XFree( (char *)c ); + } + } + } +#endif + if ( !x->cmap ) + { + // no shared cmap found + x->cmap = XCreateColormap( dpy, RootWindow(dpy,vi->screen), vi->visual, + AllocNone ); + x->alloc = true; + // Allocating cmap + } + + cmap_dict->insert( (long)vi->visualid, x ); // associate cmap with visualid + return x->cmap; +} +#endif + +/* statics */ +int OCCViewer_ViewPort::nCounter = 0; +QCursor* OCCViewer_ViewPort::defCursor = NULL; +QCursor* OCCViewer_ViewPort::handCursor = NULL; +QCursor* OCCViewer_ViewPort::panCursor = NULL; +QCursor* OCCViewer_ViewPort::zoomCursor = NULL; +QCursor* OCCViewer_ViewPort::rotCursor = NULL; +QCursor* OCCViewer_ViewPort::glPanCursor = NULL; + +/*! + Creates the necessary viewport cursors [ static ] +*/ +void OCCViewer_ViewPort::createCursors () +{ + defCursor = new QCursor ( ArrowCursor ); + handCursor = new QCursor ( PointingHandCursor ); + panCursor = new QCursor ( SizeAllCursor ); + zoomCursor = new QCursor (QPixmap(imageZoomCursor)); + rotCursor = new QCursor (QPixmap(imageRotateCursor)); + glPanCursor = new QCursor (CrossCursor); +// QAD_ResourceMgr* rmgr = QAD_Desktop::getResourceManager(); +// zoomCursor = new QCursor ( rmgr->loadPixmap( "QAD", tr("ICON_CURSOR_ZOOM") )); +// rotCursor = new QCursor ( rmgr->loadPixmap( "QAD", tr("ICON_CURSOR_ROTATE") )); +} + +/*! + Destroys the viewport cursors [ static ] +*/ +void OCCViewer_ViewPort::destroyCursors () +{ + if ( defCursor ) delete defCursor; + defCursor = 0; + if ( handCursor ) delete handCursor; + handCursor = 0; + if ( panCursor ) delete panCursor; + panCursor = 0; + if ( zoomCursor ) delete zoomCursor; + zoomCursor = 0; + if ( rotCursor ) delete rotCursor; + rotCursor = 0; + if ( glPanCursor ) delete glPanCursor; + glPanCursor = 0; +} + +/*! + Sets new default cursor [ static ] +*/ +void OCCViewer_ViewPort::setDefaultCursor(const QCursor& newCursor) +{ + if ( !defCursor ) defCursor = new QCursor; + *defCursor = newCursor; +} + +/*! + Sets new cursor for drawing rectangle in the viewport [ static ] +*/ +void OCCViewer_ViewPort::setHandCursor(const QCursor& newCursor) +{ + if ( !handCursor ) handCursor = new QCursor; + *handCursor = newCursor; +} + +/*! + Sets new cursor for panning [ static ] +*/ +void OCCViewer_ViewPort::setPanCursor(const QCursor& newCursor) +{ + if ( !panCursor ) panCursor = new QCursor; + *panCursor = newCursor; +} + +/*! + Sets new cursor for zooming [ static ] +*/ +void OCCViewer_ViewPort::setZoomCursor(const QCursor& newCursor) +{ + if ( !zoomCursor ) zoomCursor = new QCursor; + *zoomCursor = newCursor; +} + +/*! + Sets new cursor for rotating [ static ] +*/ +void OCCViewer_ViewPort::setRotCursor(const QCursor& newCursor) +{ + if ( !rotCursor ) rotCursor = new QCursor; + *rotCursor = newCursor; +} + +/*! + Sets new cursor for global panning [ static ] +*/ +void OCCViewer_ViewPort::setGlPanCursor(const QCursor& newCursor) +{ + if ( !glPanCursor ) glPanCursor = new QCursor; + *glPanCursor = newCursor; +} + +/*! + Constructor +*/ +OCCViewer_ViewPort::OCCViewer_ViewPort(QWidget* parent) : + QWidget( parent, 0, WRepaintNoErase | WResizeNoErase) +{ + initialize(); +} + +/*! + Destructor +*/ +OCCViewer_ViewPort::~OCCViewer_ViewPort() +{ + cleanup(); +} + +/*! + Initializes viewport +*/ +void OCCViewer_ViewPort::initialize() +{ + /* initialize cursors */ + if ( nCounter++ == 0 ) createCursors(); + +#if !defined WNT + + XVisualInfo* pVisualInfo; + if ( x11Display() ) + { + /* Initialization with the default VisualID + */ + //NRI Visual *v = DefaultVisual(x11Display(), DefaultScreen(x11Display())); + //NRI int visualID = XVisualIDFromVisual(v); + + /* Here we use the settings from + Optimizer_ViewInfo::TxglCreateWindow() + */ + int visualAttr[] = { GLX_RGBA, GLX_DEPTH_SIZE, 1, + GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, + GLX_BLUE_SIZE, 1, GLX_DOUBLEBUFFER, + None }; + + pVisualInfo = ::glXChooseVisual (x11Display(), DefaultScreen(x11Display()), visualAttr); + + if ( isVisible() ) hide(); + + XSetWindowAttributes a; + + a.colormap = choose_cmap( x11Display(), pVisualInfo ); /* find best colormap */ + a.background_pixel = backgroundColor().pixel(); + a.border_pixel = black.pixel(); + Window p = RootWindow( x11Display(), DefaultScreen(x11Display()) ); + if ( parentWidget() ) p = parentWidget()->winId(); + + Window w = XCreateWindow( x11Display(), p, x(), y(), width(), height(), + 0, pVisualInfo->depth, InputOutput, pVisualInfo->visual, + CWBackPixel | CWBorderPixel | CWColormap, &a ); + Window *cmw; + Window *cmwret; + int count; + if ( XGetWMColormapWindows( x11Display(), topLevelWidget()->winId(), &cmwret, &count ) ) + { + cmw = new Window[count+1]; + memcpy( (char *)cmw, (char *)cmwret, sizeof(Window)*count ); + XFree( (char *)cmwret ); + int i; + + for (i = 0; i < count; i++) + { + if ( cmw[i] == winId() ) /* replace old window */ + { + cmw[i] = w; + break; + } + } + + if ( i >= count ) /* append new window */ + cmw[count++] = w; + } + else + { + count = 1; + cmw = new Window[count]; + cmw[0] = w; + } + + /* Creating new window (with good VisualID) for this widget + */ + create(w); + XSetWMColormapWindows( x11Display(), topLevelWidget()->winId(), cmw, count ); + delete [] cmw; + + if ( isVisible() ) show(); + + if ( pVisualInfo ) { + XFree( (char *)pVisualInfo ); + } + + XFlush(x11Display()); + // XSync(x11Display(), false); + // XSynchronize(x11Display(), true); + } +#endif // !defined WNT + + myOriginalViewport = NULL; + myCursorIsHand = false; + myCursor = *defCursor; + myHasWindow = false; + myDrawRect = false; + myStartX = myStartY = myCurrX = myCurrY =0; + myPaintersRedrawing = false; + myEnableDrawMode = true; + + setTransformRequested ( NOTHING ); + setTransformInProcess ( false ); + + setMouseTracking( true ); + setBackgroundMode(NoBackground); + + setFocus(); +} + +/*! + Cleans up the viewport +*/ +void OCCViewer_ViewPort::cleanup() +{ + if ( --nCounter == 0 ) + destroyCursors(); +} + +/*! + Sets the original view for the viewport +*/ +void OCCViewer_ViewPort::setOriginalView( OCCViewer_ViewPort* viewport, + const QRect& magnify ) +{ + myOriginalViewport = viewport; + myMagnifyRect = magnify; +} + +/*! + Returns the original view or null +*/ +OCCViewer_ViewPort* OCCViewer_ViewPort::getOriginalView() const +{ + return myOriginalViewport; +} + +/*! + Returns the 'magnify' rect ( used for 'magnify' operation ) +*/ +const QRect& OCCViewer_ViewPort::getMagnifyRect() const +{ + return myMagnifyRect; +} + +/*! + Returns the sketched rect ( used for multiple selection ) +*/ +const QRect& OCCViewer_ViewPort::getSelectionRect() const +{ + return myRect; +} + +/*! + Returns 'true' if the viewport has a native window +*/ +bool OCCViewer_ViewPort::hasWindow() const +{ + return myHasWindow; +} + +/*! + Must be called if native window was changed +*/ +void OCCViewer_ViewPort::windowChanged() +{ + myHasWindow = false; +} + +/*! + Sets the default cursor active +*/ +void OCCViewer_ViewPort::setDefaultCursorOn() +{ + setCursor ( *OCCViewer_ViewPort::defCursor ); +} + +/*! + Sets the 'hand' cursor active +*/ +void OCCViewer_ViewPort::setHandCursorOn() +{ + setCursor ( *OCCViewer_ViewPort::handCursor ); +} + +/*! + Sets the panning cursor active +*/ +void OCCViewer_ViewPort::setPanCursorOn() +{ + setCursor( *OCCViewer_ViewPort::panCursor ); +} + +/*! + Sets the zooming cursor active +*/ +void OCCViewer_ViewPort::setZoomCursorOn() +{ + setCursor( *OCCViewer_ViewPort::zoomCursor ); +} + +/*! + Sets the rotating cursor active +*/ +void OCCViewer_ViewPort::setRotCursorOn() +{ + setCursor( *OCCViewer_ViewPort::rotCursor ); +} + +/*! + Sets the global panning cursor active +*/ +void OCCViewer_ViewPort::setGlPanCursorOn() +{ + setCursor( *OCCViewer_ViewPort::glPanCursor ); +} + +/*! + Returns the default background color +*/ +QColor OCCViewer_ViewPort::backgroundColor() const +{ + return Qt::white; +} + +/*! + Activates 'zoom' transformation +*/ +void OCCViewer_ViewPort::activateZoom() +{ + if ( !transformRequested() && !myCursorIsHand ) + myCursor = cursor(); /* save old cursor */ + + if ( myOperation != ZOOMVIEW ) { + setTransformRequested ( ZOOMVIEW ); + setCursor( *zoomCursor ); + } +} + +/*! + Activates 'panning' transformation +*/ +void OCCViewer_ViewPort::activatePanning() +{ + if ( !transformRequested() && !myCursorIsHand ) + myCursor = cursor(); /* save old cursor */ + + if ( myOperation != PANVIEW ) { + setTransformRequested ( PANVIEW ); + setCursor( *panCursor ); + } +} + +/*! + Activates 'rotation' transformation +*/ +void OCCViewer_ViewPort::activateRotation() +{ + if ( !transformRequested() && !myCursorIsHand ) + myCursor = cursor(); /* save old cursor */ + + if ( myOperation != ROTATE ) { + setTransformRequested ( ROTATE ); + setCursor( *rotCursor ); + } +} + +/*! + Activates 'fit' transformation +*/ +void OCCViewer_ViewPort::activateWindowFit() +{ + if ( !transformRequested() && !myCursorIsHand ) + myCursor = cursor(); /* save old cursor */ + + if ( myOperation != WINDOWFIT ) { + setTransformRequested ( WINDOWFIT ); + setCursor ( *handCursor ); + myCursorIsHand = true; + } +// setTransformInProcess( true ); +// emit vpTransformationStarted ( WINDOWFIT ); +} + +/*! + Activates 'global panning' transformation +*/ +void OCCViewer_ViewPort::activateGlobalPanning() +{ + if ( !transformRequested() && !myCursorIsHand ) + myCursor = cursor(); /* save old cursor */ + + if ( myOperation != PANGLOBAL ) + { + fitAll(); /* fits view before selecting a new scene center */ + setTransformRequested ( PANGLOBAL ); + setCursor( *glPanCursor ); + } +// setTransformInProcess( true ); +// emit vpTransformationStarted ( PANGLOBAL ); +} + +/*! + Sets the viewport to its initial state + ( no transformations in process etc. ) +*/ +void OCCViewer_ViewPort::resetState() +{ + myDrawRect = false; + + /* make rectangle empty (left > right) */ + myRect.setLeft(2); + myRect.setRight(0); + + if ( transformRequested() || myCursorIsHand ) + setCursor( myCursor ); + myCursorIsHand = false; + + if ( transformRequested() ) + emit vpTransformationFinished (myOperation); + + setTransformInProcess( false ); + setTransformRequested ( NOTHING ); + QAD_Application::getDesktop()->putInfo( tr("INF_READY") ); +} + +/*! + Enable/disable user's ability to sketch a rect in the viewport +*/ +void OCCViewer_ViewPort::enableDrawMode(bool bEnable ) +{ + myEnableDrawMode = bEnable; +} + +/*! + Returns 'true' if user can sketch a rect in the viewport +*/ +bool OCCViewer_ViewPort::enableDrawMode() const +{ + return myEnableDrawMode; +} + +/*! + Sets the active operation 'op' +*/ +void OCCViewer_ViewPort::setTransformRequested ( OperationType op ) +{ + myOperation = op; + setMouseTracking ( myOperation == NOTHING ); +} + +/*! + Mouse event handler +*/ +void OCCViewer_ViewPort::mousePressEvent (QMouseEvent* event) +{ + myStartX = event->x(); + myStartY = event->y(); + switch ( myOperation ) + { + case WINDOWFIT: + if ( event->button() == Qt::LeftButton ) + emit vpTransformationStarted ( WINDOWFIT ); + break; +// return; + case PANGLOBAL: + if ( event->button() == Qt::LeftButton ) + emit vpTransformationStarted ( PANGLOBAL ); + break; +// return; + + case ZOOMVIEW: + if ( event->button() == Qt::LeftButton ) + emit vpTransformationStarted ( ZOOMVIEW ); + break; + + case PANVIEW: + if ( event->button() == Qt::LeftButton ) + emit vpTransformationStarted ( PANVIEW ); + break; + + case ROTATE: + if ( event->button() == Qt::LeftButton ) + { + startRotation(myStartX, myStartY); + emit vpTransformationStarted ( ROTATE ); + } + break; + + default: + + /* Try to activate a transformation + */ + if ( (event->state() == Qt::ControlButton) && + (event->button() == Qt::LeftButton) ) + { + /* MB1 + CTRL = Zooming */ + activateZoom(); + } + else if ( (event->state() == Qt::ControlButton) && + (event->button() == Qt::MidButton) ) + { + /* MB2 + CTRL = Panning */ + activatePanning(); + } + else if ( (event->state() == Qt::ControlButton) && + (event->button() == Qt::RightButton) ) + { + /* MB3 + CTRL = Rotation */ + activateRotation(); + startRotation(myStartX, myStartY); + } + + /* notify that we start a transformation */ + if ( transformRequested() ) + emit vpTransformationStarted ( myOperation ); + } + + if ( transformRequested() ) + setTransformInProcess( true ); + + /* NOTE: this signal must be emitted at the end + because we must to detect a transformation first + */ + emit vpMousePress (event); +} + +/*! + Mouse event handler +*/ +void OCCViewer_ViewPort::mouseMoveEvent (QMouseEvent* event) +{ + myCurrX = event->x(); + myCurrY = event->y(); + switch (myOperation) + { + case ROTATE: + rotate(myCurrX, myCurrY); + break; + + case ZOOMVIEW: + zoom(myStartX, myStartY, myCurrX, myCurrY); + myStartX = myCurrX; + myStartY = myCurrY; + break; + + case PANVIEW: + pan(myCurrX - myStartX, myStartY - myCurrY); + myStartX = myCurrX; + myStartY = myCurrY; + break; + +/* case WINDOWFIT: + myDrawRect = true; + repaint(); + break; +*/ + case PANGLOBAL: + break; + + default: + if ( event->state() == Qt::LeftButton || + event->state() == ( Qt::LeftButton | Qt::ShiftButton) ) + { + myDrawRect = myEnableDrawMode; + if ( myDrawRect ) + { + repaint( visibleRect(), false); + if ( !myCursorIsHand ) + { /* we are going to sketch a rectangle */ + myCursorIsHand = true; + myCursor = cursor(); + setCursor ( *handCursor ); + } + } + } + } + emit vpMouseMove( event ); +} + +/*! + Mouse event handler +*/ +void OCCViewer_ViewPort::mouseReleaseEvent (QMouseEvent* event) +{ + if ( !transformRequested() && (event->button() == Qt::RightButton) ) + { + QPopupMenu* popup = createPopup(); + if ( popup ) { + QAD_Tools::checkPopup( popup ); + if ( popup->count()>0 ) { + popup->exec( QCursor::pos() ); + } + destroyPopup(); + } + return; + } + + switch ( myOperation ) + { + case NOTHING: + break; + case ROTATE: + endRotation(); + resetState(); + break; + + case PANVIEW: + case ZOOMVIEW: + resetState(); + break; + + case PANGLOBAL: + if ( event->button() == Qt::LeftButton ) + { + setCenter( event->x(), event->y() ); + resetState(); + } + break; + + case WINDOWFIT: + if ( event->state() == Qt::LeftButton ) + { + myCurrX = event->x(); + myCurrY = event->y(); + QRect rect = QAD_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY); + if ( !rect.isEmpty() ) fitWindow(rect); + resetState(); + } + break; + } + + // NOTE: viewer 3D detects a rectangle of selection using this event + // so we must emit it BEFORE resetting the selection rectangle + emit vpMouseRelease (event); + + if ( event->button() == Qt::LeftButton && myDrawRect ) + { + myDrawRect = false; + repaint(visibleRect(), false); + resetState(); + } +} + +/*! + Mouse event handler +*/ +void OCCViewer_ViewPort::mouseDoubleClickEvent(QMouseEvent *event) +{ + emit vpMouseDoubleClick (event); +} + +/*! + Key event handler +*/ +void OCCViewer_ViewPort::keyPressEvent(QKeyEvent *event) +{ + emit vpKeyPress (event); +} + +/*! + Key event handler +*/ +void OCCViewer_ViewPort::keyReleaseEvent(QKeyEvent *event) +{ + emit vpKeyRelease (event); +} + +/*! + Called when the viewport gets the focus +*/ +void OCCViewer_ViewPort::focusInEvent(QFocusEvent *event) +{ + emit vpFocusIn (event); +} + +/*! + Called when the viewport loses the focus +*/ +void OCCViewer_ViewPort::focusOutEvent(QFocusEvent *event) +{ + emit vpFocusOut (event); +} + +/*! + Resizes the viewport +*/ +void OCCViewer_ViewPort::resizeEvent (QResizeEvent* event) +{ + windowResize(); +} + +/*! + Updates the viewport +*/ +void OCCViewer_ViewPort::update(int x, int y, int w, int h) +{ + if ( !myHasWindow ) + myHasWindow = setWindow(); + if ( myHasWindow) + repaint(x, y, w, h, true); +} + +/*! + Repaints the viewport +*/ +void OCCViewer_ViewPort::paintEvent (QPaintEvent *ev) +{ + emit vpPaint (ev); + if ( myDrawRect ) + { + QPainter thePainter(this); + thePainter.setRasterOp(Qt::XorROP); + thePainter.setPen(Qt::white); + QRect aRect = QAD_Tools::makeRect(myStartX, myStartY, myCurrX, myCurrY); + if ( !myRect.isEmpty() ) + thePainter.drawRect( myRect ); + thePainter.drawRect(aRect); + myRect = aRect; + } + + if ( myPaintersRedrawing ) + { + QPainter thePainter(this); + emit vpDrawExternal (&thePainter); + myPaintersRedrawing = false; + } +} + +/*! + Forces to redraw the viewport by an external painter +*/ +void OCCViewer_ViewPort::redrawPainters() +{ + myPaintersRedrawing = true; + repaint(); +} diff --git a/src/OCCViewer/OCCViewer_ViewPort.h b/src/OCCViewer/OCCViewer_ViewPort.h new file mode 100644 index 000000000..77f8bb136 --- /dev/null +++ b/src/OCCViewer/OCCViewer_ViewPort.h @@ -0,0 +1,187 @@ +// File : OCCViewer_ViewPort.h +// Created : Wed Mar 20 10:41:50 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef OCCViewer_ViewPort_H +#define OCCViewer_ViewPort_H + +#include "QAD.h" +#include "QAD_Popup.h" + +// QT Includes +#include +#include +#include +#include +#include + +class QAD_EXPORT OCCViewer_ViewPort: public QWidget, + public QAD_PopupClientServer +{ + Q_OBJECT + + /* Objects counter */ + static int nCounter; + + /* Cursors */ + static QCursor* defCursor; + static QCursor* handCursor; + static QCursor* panCursor; + static QCursor* zoomCursor; + static QCursor* rotCursor; + static QCursor* glPanCursor; + + void initialize(); + void cleanup(); + +public: + enum OperationType { + NOTHING, + PANVIEW, + ZOOMVIEW, + ROTATE, + PANGLOBAL, + WINDOWFIT + }; + +protected: + static void createCursors(); + static void destroyCursors(); + + static const QCursor* getDefaultCursor() { return defCursor; } + static void setDefaultCursor(const QCursor& newCursor); + static const QCursor* getHandCursor() { return handCursor; } + static void setHandCursor(const QCursor& newCursor); + static const QCursor* getPanCursor() { return panCursor; } + static void setPanCursor(const QCursor& newCursor); + static const QCursor* getZoomCursor() { return zoomCursor; } + static void setZoomCursor(const QCursor& newCursor); + static const QCursor* getRotCursor() { return rotCursor; } + static void setRotCursor(const QCursor& newCursor); + static const QCursor* getGlPanCursor() { return rotCursor; } + static void setGlPanCursor(const QCursor& newCursor); + + /* Transformation selected but not started yet */ + bool transformRequested() const { return ( myOperation != NOTHING ); } + void setTransformRequested ( OperationType op ); + + /* Transformation is selected and already started */ + bool transformInProcess() const { return myEventStarted; } + void setTransformInProcess( bool bOn ) { myEventStarted = bOn; } + +public: + OCCViewer_ViewPort( QWidget* parent ); + ~OCCViewer_ViewPort(); + + /* Draw mode management */ + void enableDrawMode( bool bEnable ); + bool enableDrawMode() const; + + /* Cursors management */ + void setDefaultCursorOn(); + void setHandCursorOn(); + void setPanCursorOn(); + void setZoomCursorOn(); + void setRotCursorOn(); + void setGlPanCursorOn(); + + void resetState(); + bool hasWindow() const; + void windowChanged(); + void redrawPainters(); + void update(int x, int y, int w, int h); + + void setOriginalView( OCCViewer_ViewPort* view, const QRect& magnify ); + OCCViewer_ViewPort* getOriginalView() const; + const QRect& getMagnifyRect() const; + const QRect& getSelectionRect() const; + + /* View transformations */ + virtual void activateZoom(); + virtual void activatePanning(); + virtual void activateRotation(); + virtual void activateWindowFit(); + virtual void activateGlobalPanning(); + + virtual void fitAll( bool withZ = true ) = 0; + virtual void reset() = 0; + + virtual QColor backgroundColor() const; + virtual void setBackgroundColor( const QColor& color) = 0; + +protected: + virtual void paintEvent(QPaintEvent *); + virtual void resizeEvent(QResizeEvent *); + + virtual void mouseMoveEvent(QMouseEvent *); + virtual void mouseReleaseEvent(QMouseEvent *); + virtual void mousePressEvent(QMouseEvent *); + virtual void mouseDoubleClickEvent(QMouseEvent *); + + virtual void keyPressEvent(QKeyEvent *); + virtual void keyReleaseEvent(QKeyEvent *); + + virtual void focusInEvent(QFocusEvent *event); + virtual void focusOutEvent(QFocusEvent *event); + +signals: + void vpTransformationStarted (OCCViewer_ViewPort::OperationType type); + void vpTransformationFinished (OCCViewer_ViewPort::OperationType type); + + void vpMousePress (QMouseEvent*); + void vpMouseRelease (QMouseEvent*); + void vpMouseMove (QMouseEvent*); + void vpMouseDoubleClick (QMouseEvent*); + + void vpKeyPress (QKeyEvent*); + void vpKeyRelease (QKeyEvent*); + + void vpFocusOut (QFocusEvent*); + void vpFocusIn (QFocusEvent*); + + void vpPaint (QPaintEvent*); + void vpDrawExternal (QPainter* painter); + +protected slots: + virtual void onChangeBackgroundColor() = 0; + +protected: + virtual bool setWindow() = 0; + virtual void windowResize() = 0; + virtual void pan(int dx, int dy) = 0; + virtual void setCenter(int x, int y) = 0; + virtual void fitWindow( const QRect& rect) = 0; + virtual void zoom(int x0, int y0, int x, int y) = 0; + virtual void startRotation(int x0, int y0) = 0; + virtual void rotate(int x, int y) = 0; + virtual void endRotation() = 0; + +protected: + OCCViewer_ViewPort* myOriginalViewport; + OperationType myOperation; + QCursor myCursor; + + QRect myMagnifyRect; + QRect myRect; + bool myDrawRect; /* set when a rect is used for selection or magnify */ + + /* Mouse coordinates */ + int myStartX; + int myStartY; + int myCurrX; + int myCurrY; + + bool myHasWindow; + bool myCursorIsHand; + bool myEnableDrawMode; + bool myEventStarted; /* set when transformation is in process */ + bool myPaintersRedrawing; /* set to draw with external painters */ +}; + +#endif + diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx new file mode 100644 index 000000000..c01680b6c --- /dev/null +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -0,0 +1,366 @@ +using namespace std; +// File : OCCViewer_ViewPort3d.cxx +// Created : Wed Mar 20 10:47:09 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "OCCViewer_ViewPort3d.h" + +#include "QAD.h" +#include "QAD_Settings.h" +#include "QAD_Config.h" +#include "QAD_Desktop.h" +#include "QAD_Study.h" +#include "SALOME_Selection.h" + +// QT Include +#include + +// Open CASCADE Includes +#include +#include + +#if !defined WNT +#include +#endif + +/*! + Constructor +*/ +OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_Viewer)& viewer, + V3d_TypeOfView viewType, OCCViewer_ViewPort* prevView , + const QRect* magnify ) : + OCCViewer_ViewPort( parent ) +{ + if ( viewType == V3d_ORTHOGRAPHIC ) + myActiveView = new V3d_OrthographicView( viewer ); + else + myActiveView = new V3d_PerspectiveView( viewer ); + + myCurScale = 1.0; + myDegenerated = true; + + myActiveView->SetDegenerateModeOn(); + + if ( prevView ) setOriginalView( prevView, *magnify ); +} + +/*! + Destructor +*/ +OCCViewer_ViewPort3d::~OCCViewer_ViewPort3d() +{ + myActiveView->Remove(); +} + +/*! + Creates the popup +*/ +void OCCViewer_ViewPort3d::onCreatePopup() +{ + if ( myPopup ) { + QAD_Desktop* Desktop = (QAD_Desktop*) QAD_Application::getDesktop(); + QAD_Study* myActiveStudy = Desktop->getActiveStudy(); + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + + QString theContext; + QString theParent("Viewer"); + QString theObject; + + Desktop->definePopup( theContext, theParent, theObject ); + Desktop->createPopup( myPopup, theContext, theParent, theObject); + Desktop->customPopup( myPopup, theContext, theParent, theObject ); + +// if (Sel->IObjectCount() == 0 && myPopup->count()<1) { + if ( myPopup->count() > 0 ) + myIDs.append ( myPopup->insertSeparator() ); + int id; + myIDs.append ( id = myPopup->insertItem (tr ("MEN_VP3D_CHANGEBGR")) ); + QAD_ASSERT ( myPopup->connectItem ( id, this, SLOT(onChangeBackgroundColor())) ); +// } + } +} + +/*! + Sets new CASCADE view on viewport. + Returns the previous view or null if the view hasn't been set. +*/ +Handle (V3d_View) OCCViewer_ViewPort3d::setView( const Handle (V3d_View)& view ) +{ + Handle (V3d_View) oldView = myActiveView; + myActiveView = view; + if ( hasWindow() ) setWindow(); + return oldView; +} + +/*! + Returns CasCade 3D view +*/ +Handle(V3d_View) OCCViewer_ViewPort3d::getView() const +{ + return myActiveView; +} + +/*! + Returns CasCade 3D viewer +*/ +Handle (V3d_Viewer) OCCViewer_ViewPort3d::getViewer() const +{ + Handle (V3d_Viewer) viewer; + if ( !myActiveView.IsNull() ) + viewer = myActiveView->Viewer(); + return viewer; +} + +/*! + Passed the handle of native window of the component to CASCADE view + (sets window handle for V3d_View class instance). +*/ +bool OCCViewer_ViewPort3d::setWindow() +{ + if ( !myActiveView.IsNull() ) + { + int windowHandle = (int) winId(); + if ( windowHandle == 0 ) + return false; + + short hi, lo; + lo = (short) windowHandle; + hi = (short) (windowHandle >> 16); + + OCCViewer_ViewPort* preView = getOriginalView(); + if ( preView ) + { + /* Create new window ( 'magnify' operation ) + */ + Handle (V3d_View) view; + QRect rect = getMagnifyRect(); + if ( preView->inherits("OCCViewer_ViewPort3d") ) + { + view = ((OCCViewer_ViewPort3d*)preView)->getView(); + } + if ( !view.IsNull() && !rect.isEmpty() ) + { + OCCViewer_VService::SetMagnify(myActiveView, (int)hi, (int) lo, view, + rect.x(), rect.y(), + rect.x() + rect.width(), rect.y() + rect.height(), + Xw_WQ_SAMEQUALITY); + return true; + } + } + + /* CasCade will use our widget as the drawing window */ + OCCViewer_VService::SetWindow( myActiveView, (int) hi, (int) lo, Xw_WQ_SAMEQUALITY); + return true; + } + return false; +} + +/*! + Forces the CASCADE view to resize window +*/ +void OCCViewer_ViewPort3d::windowResize() +{ + QApplication::syncX(); + if ( !myActiveView.IsNull() ) + myActiveView->MustBeResized(); +} + +/*! + Called at 'window fit' transformation +*/ +void OCCViewer_ViewPort3d::fitWindow(const QRect& rect) +{ + if ( !myActiveView.IsNull() ) + { + myActiveView->WindowFit( rect.x(), rect.y(), rect.x() + rect.width(), + rect.y() + rect.height()); + } +} + +/*! + Called at 'zoom' transformation +*/ +void OCCViewer_ViewPort3d::zoom(int x0, int y0, int x, int y) +{ + if ( !myActiveView.IsNull() ) + myActiveView->Zoom(x0, y0, x, y); +} + +/*! + Centers the viewport +*/ +void OCCViewer_ViewPort3d::setCenter(int x, int y) +{ + if ( !myActiveView.IsNull() ) + { + myActiveView->Place(x, y, myCurScale); + } +} + +/*! + Called at 'pan' transformation +*/ +void OCCViewer_ViewPort3d::pan(int dx, int dy) +{ + if ( !myActiveView.IsNull() ) + { + myActiveView->Pan(dx, dy, 1.0); + } +} + +/*! + Inits 'rotation' transformation +*/ +void OCCViewer_ViewPort3d::startRotation(int x0, int y0) +{ + if ( !myActiveView.IsNull() ) + { + myDegenerated = myActiveView->DegenerateModeIsOn(); + myActiveView->SetDegenerateModeOn(); + myActiveView->StartRotation(x0, y0); + } +} + +/*! + Rotates the viewport +*/ +void OCCViewer_ViewPort3d::rotate(int x, int y) +{ + if ( !myActiveView.IsNull() ) + { + myActiveView->Rotation(x, y); + } +} + +/*! + Resets the viewport after 'rotation' +*/ +void OCCViewer_ViewPort3d::endRotation() +{ + if ( !myActiveView.IsNull() ) + { + if ( !myDegenerated ) + myActiveView->SetDegenerateModeOff(); + } +} + +/*! + Called to update the background color +*/ +QColor OCCViewer_ViewPort3d::backgroundColor() const +{ + if ( !myActiveView.IsNull() ) + { + Standard_Real aRed, aGreen, aBlue; + myActiveView->BackgroundColor(Quantity_TOC_RGB, aRed, aGreen, aBlue); + int red = (int) (aRed * 255); + int green = (int) (aGreen * 255); + int blue = (int) (aBlue * 255); + return QColor(red, green, blue); + } + return OCCViewer_ViewPort::backgroundColor(); +} + +/*! + Sets the background color +*/ +void OCCViewer_ViewPort3d::setBackgroundColor( const QColor& color) +{ + if ( !myActiveView.IsNull() ) + { + myActiveView->SetBackgroundColor( Quantity_TOC_RGB, color.red()/255., + color.green()/255., color.blue()/255.); + + QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", color.red() ); + QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", color.green() ); + QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", color.blue() ); + + myActiveView->Update(); + } +} + +/*! + Sets the background color with color selection dialog +*/ +void OCCViewer_ViewPort3d::onChangeBackgroundColor() +{ + if ( !myActiveView.IsNull() ) + { + QColor selColor = QColorDialog::getColor ( backgroundColor(), this ); + if ( selColor.isValid() ) + { + setBackgroundColor( selColor ); + } + } +} + +/*! + Repaints the viewport +*/ +void OCCViewer_ViewPort3d::paintEvent (QPaintEvent* e ) +{ + if ( myActiveView.IsNull() ) + { + QPainter thePainter (this); + thePainter.drawText(50, 50, QObject::tr("ERR_VP_NOVIEW"), 7); + } + else + { + QApplication::syncX(); + if ( !myHasWindow ) + { + myHasWindow = setWindow(); + if ( myHasWindow ) fitAll(); + } + if ( myHasWindow ) + { + QRect visibleRect = e->rect(); + if ( (!myDrawRect) && (!myPaintersRedrawing) ) + { + myActiveView->Redraw ( visibleRect.x(), visibleRect.y(), visibleRect.width(), + visibleRect.height()); + } + } + } + OCCViewer_ViewPort::paintEvent( e ); +} + +/*! + Called at 'global panning' transformation +*/ +void OCCViewer_ViewPort3d::activateGlobalPanning() +{ + if ( !myActiveView.IsNull() ) + { + myCurScale = myActiveView->Scale(); + myActiveView->FitAll(0.01, false); + } + OCCViewer_ViewPort::activateGlobalPanning(); +} + +/*! + Fits all objects in view +*/ +void OCCViewer_ViewPort3d::fitAll( bool withZ ) +{ + if ( !myActiveView.IsNull() ) + { + myActiveView->FitAll(0.01, true); + if ( withZ ) myActiveView->ZFitAll(0.0); + } +} + +/*! + Resets the view +*/ +void OCCViewer_ViewPort3d::reset() +{ + if ( !myActiveView.IsNull() ) + { + myActiveView->Reset(); + } +} diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.h b/src/OCCViewer/OCCViewer_ViewPort3d.h new file mode 100644 index 000000000..93b0f0c5a --- /dev/null +++ b/src/OCCViewer/OCCViewer_ViewPort3d.h @@ -0,0 +1,82 @@ +// File : OCCViewer_ViewPort3d.h +// Created : Wed Mar 20 10:48:51 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef OCCViewer_ViewPort3d_H +#define OCCViewer_ViewPort3d_H + +#include "OCCViewer_ViewPort.h" +#include "OCCViewer_VService.h" + +#include "QAD.h" + +// Open CASCADE Includes +#include +#include +#include + +// QT Includes +#include +#include +#include +#include +#include + +class QAD_EXPORT OCCViewer_ViewPort3d: public OCCViewer_ViewPort +{ + Q_OBJECT + + public: + OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_Viewer)& viewer, + V3d_TypeOfView viewType = V3d_ORTHOGRAPHIC, + OCCViewer_ViewPort* prevView = 0, + const QRect* magnify = 0 ); + ~OCCViewer_ViewPort3d(); + + /* view 3D management */ + Handle (V3d_View) setView( const Handle( V3d_View )& ); + Handle (V3d_View) getView() const; + Handle (V3d_Viewer) getViewer() const; + V3d_TypeOfView setViewType( V3d_TypeOfView type ); + + /* popup management */ + void onCreatePopup(); + + /* view transformations */ + void activateGlobalPanning(); + void fitAll( bool withZ = true ); + void reset(); + + /* background */ + void setBackgroundColor( const QColor& color); + QColor backgroundColor() const; + + protected slots: + void onChangeBackgroundColor(); + + protected: + void paintEvent(QPaintEvent *ev); + + private: + bool setWindow(); + void windowResize(); + void pan(int dx, int dy); + void setCenter(int x, int y); + void fitWindow( const QRect& rect); + void zoom(int x0, int y0, int x, int y); + void startRotation(int x0, int y0); + void rotate(int x, int y); + void endRotation(); + + private: + Handle (V3d_View) myActiveView; + bool myDegenerated; + double myCurScale; +}; + +#endif + diff --git a/src/OCCViewer/OCCViewer_Viewer3d.cxx b/src/OCCViewer/OCCViewer_Viewer3d.cxx new file mode 100644 index 000000000..6bcf15e54 --- /dev/null +++ b/src/OCCViewer/OCCViewer_Viewer3d.cxx @@ -0,0 +1,851 @@ +using namespace std; +// File : OCCViewer_Viewer3d.cxx +// Created : Wed Mar 20 10:54:35 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + + +/*! + \class OCCViewer_Viewer3d OCCViewer_Viewer3d.h + \brief Open CASCADE Viewer 3D with viewport 3D and selection. +*/ + +#include "OCCViewer_Viewer3d.h" +#include "QAD.h" +#include "QAD_Config.h" +#include "QAD_Desktop.h" +#include "QAD_Settings.h" +#include "QAD_LeftFrame.h" +#include "OCCViewer_ViewPort3d.h" +#include "QAD_RightFrame.h" +#include "QAD_MessageBox.h" +#include "QAD_Application.h" + +#include "SALOME_Selection.h" +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "SALOME_AISShape.hxx" +#include "SALOME_AISObject.hxx" + +#include "utilities.h" + +// Open CASCADE Includes +#include +#include +#include + +/*! + Constructor +*/ +OCCViewer_Viewer3d::OCCViewer_Viewer3d(OCCViewer_ViewFrame* vf) : + myAISContext( NULL ), + myAISSelector( NULL ) +{ + if ( myV3dViewer.IsNull() ) + createViewer3d(); /* create viewer */ + + QString BackgroundColorRed = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorRed"); + QString BackgroundColorGreen = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorGreen"); + QString BackgroundColorBlue = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorBlue"); + + if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() ) + myBackColor = QColor(BackgroundColorRed.toInt(), + BackgroundColorGreen.toInt(), + BackgroundColorBlue.toInt()); + else + myBackColor = QColor(35, 136, 145); + + myViewFrame = vf; + myViewFrame->setViewPort ( new OCCViewer_ViewPort3d( myViewFrame, myV3dViewer ) ); + myViewFrame->setViewer(this); + + /* properties settings */ + // if ( !myIcon.isNull() ) + // myStudyFrame->setIcon( myIcon ); + + myViewFrame->setCursor( myCursor ); + myViewFrame->setBackgroundColor( myBackColor ); + + if ( myAISContext.IsNull() ) { + /* create interactive manager */ + myAISContext = new AIS_InteractiveContext ( myV3dViewer, myV3dCollector ); + + myAISContext->IsoOnPlane(true) ; + + /* create trihedron */ + Handle(Geom_Axis2Placement) anAxis=new Geom_Axis2Placement(gp::XOY()); + myTrihedron=new AIS_Trihedron(anAxis); + myTrihedron->SetInfiniteState( Standard_True ); + + Quantity_Color Col(193/255., 205/255., 193/255., Quantity_TOC_RGB); + myTrihedron->SetColor( Col ); + myTrihedron->SetArrowColor( Col.Name() ); + + float dim = 100; + QString Size = QAD_CONFIG->getSetting("Viewer:TrihedronSize"); + if (!Size. isEmpty() ) dim = Size.toFloat(); //get size from preferences + + myTrihedron->SetSize(dim); + + myAISContext->Display(myTrihedron); + myAISContext->Deactivate(myTrihedron); + + /* create selector */ + myAISSelector = new OCCViewer_AISSelector ( myAISContext ); + QAD_ASSERT ( connect (myAISSelector, SIGNAL(selSelectionDone(bool)), + this, SLOT(onSelectionDone(bool))) ); + QAD_ASSERT ( connect (myAISSelector, SIGNAL(selSelectionCancel(bool)), + this, SLOT(onSelectionCancel(bool))) ); + myEnableSelection = true; + } + + QAD_ASSERT ( connect(myViewFrame, + SIGNAL(vfKeyPress(QKeyEvent*)), + this, SLOT(onKeyPress(QKeyEvent*))) ); + + /* mouse events of the view */ + QAD_ASSERT ( QObject::connect(myViewFrame, + SIGNAL(vfMousePress(QMouseEvent*)), + this, SLOT(onMousePress(QMouseEvent*))) ); + QAD_ASSERT ( QObject::connect(myViewFrame, + SIGNAL(vfMouseRelease(QMouseEvent*)), + this, SLOT(onMouseRelease (QMouseEvent*))) ); + QAD_ASSERT ( QObject::connect(myViewFrame, + SIGNAL(vfMouseMove(QMouseEvent*)), + this, SLOT(onMouseMove (QMouseEvent*))) ); + QAD_ASSERT ( QObject::connect(myViewFrame, + SIGNAL(vfMouseDoubleClick(QMouseEvent*)), + this, SLOT(onMouseDoubleClick (QMouseEvent*))) ); + + /* transformation events */ + QAD_ASSERT ( QObject::connect(myViewFrame, + SIGNAL(vfTransformationStarted(OCCViewer_ViewPort::OperationType)), + this, SLOT(onTransformationStarted (OCCViewer_ViewPort::OperationType))) ); + QAD_ASSERT ( QObject::connect(myViewFrame, + SIGNAL(vfTransformationFinished(OCCViewer_ViewPort::OperationType)), + this, SLOT(onTransformationFinished (OCCViewer_ViewPort::OperationType))) ); + + /* set popup manager for the viewport */ + myViewFrame->getViewPort()->setPopupServer ( this ); + +} + + +/*! + Destructor +*/ +OCCViewer_Viewer3d::~OCCViewer_Viewer3d() +{ + delete myAISSelector; +} + + +/* trihedron */ +Handle(AIS_Trihedron) OCCViewer_Viewer3d::getTrihedron() const +{ + return myTrihedron; +} + +void OCCViewer_Viewer3d::setTrihedronSize(float size) +{ + myTrihedron->SetSize(size); + myAISContext->UpdateCurrentViewer(); +} + +bool OCCViewer_Viewer3d::isTrihedronDisplayed() + +{ + return myAISContext->IsDisplayed(myTrihedron); +} + +void OCCViewer_Viewer3d::rename( const Handle(SALOME_InteractiveObject)& IObject, QString newName ) +{ + 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 ) ) { + aSh->setName( strdup(newName.latin1()) ); + 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. + } + ite.Next(); + } +} + +void OCCViewer_Viewer3d::SetColor(const Handle(SALOME_InteractiveObject)& IObject, + QColor thecolor) +{ + 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 ) ) { + 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. + } + ite.Next(); + } + myV3dViewer->Update(); +} + +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(); + } + myV3dViewer->Update(); +} + +void OCCViewer_Viewer3d::SetTransparency(const Handle(SALOME_InteractiveObject)& IObject, + float transp) +{ + 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->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. + } + ite.Next(); + } + myV3dViewer->Update(); +} + +/*! + Highlights 'obj' in viewer, returns 'true' when selected successfully +*/ +bool OCCViewer_Viewer3d::highlight( const Handle(SALOME_InteractiveObject)& IObject, bool highlight, bool update ) +{ + 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; + } + } + } 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(); + } + if (update) + myV3dViewer->Update(); + return false; +} + +/*! + Unhighlight all selected objects +*/ +bool OCCViewer_Viewer3d::unHighlightAll() +{ + myAISContext->ClearCurrents(); + return false; +} + +/*! + Returns true if the IObject has a Graphical Object in this viewer. Returns FALSE otherwise. +*/ +bool OCCViewer_Viewer3d::isInViewer( const Handle(SALOME_InteractiveObject)& IObject, bool onlyInViewer) +{ + AIS_ListOfInteractive List; + myAISContext->DisplayedObjects(List); + + if ( onlyInViewer ) { + AIS_ListOfInteractive List1; + myAISContext->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 ( IObject->isSame( IO ) ) { + return 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(); + } + return false; +} + +bool OCCViewer_Viewer3d::isVisible( const Handle(SALOME_InteractiveObject)& IObject ) +{ + 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 ( 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()); + + // Add code here, if someone create a MODULE_AISObject. + } + ite.Next(); + } + return false; +} + +/*! + Returns the interactive context +*/ +Handle (AIS_InteractiveContext) OCCViewer_Viewer3d::getAISContext() const +{ + return myAISContext; +} + +OCCViewer_AISSelector* OCCViewer_Viewer3d::getAISSelector() const +{ + return myAISSelector; +} + +/*! + Returns 'true' if selection is enabled in this viewer, + 'false' otherwise. +*/ +bool OCCViewer_Viewer3d::enabledSelection() const +{ + return myEnableSelection; +} + +/*! + Enables/disables selection in the viewer +*/ +void OCCViewer_Viewer3d::enableSelection( bool enable ) +{ + myEnableSelection = enable; + myAISSelector->enableSelection( enable ); + + /* send notification */ + emit vw3dSelectionEnabled( enable ); +} + +/*! + Enables/disables ordinary and multiple selection + ( by 'Shift' key or with a rectangle ) in this viewer. +*/ +void OCCViewer_Viewer3d::enableMultipleSelection( bool enable ) +{ + /* Enable/disable rectangle skectching which + is used for multiple selection */ + myAISSelector->enableMultipleSelection( enable ); + + myViewFrame->getViewPort()->enableDrawMode( enable ); + + /* Enable non-multiple selection as well */ + if ( !myEnableSelection && enable ) + enableSelection( enable ); +} + +/*! + Key handler +*/ +void OCCViewer_Viewer3d::onKeyPress( QKeyEvent* pe ) +{ + if (!QAD_Application::getDesktop()->getActiveComponent().isEmpty()) { + QAD_Application::getDesktop()->onKeyPress( pe ); + } +} + +/*! + Mouse handler +*/ +void OCCViewer_Viewer3d::onMousePress( QMouseEvent* pe ) +{ + if ( pe->button() == Qt::LeftButton ) { + if ( !QAD_Application::getDesktop()->onMousePress( pe ) ) { + + QAD_ASSERT_DEBUG_ONLY ( myAISSelector ); + if ( pe->state() & Qt::ShiftButton ) + myAISSelector->shiftSelect(); /* append selection */ + else + myAISSelector->select(); /* new selection */ + } + } +} + +/*! + Mouse handler +*/ +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() ); + } +} + +/*! + Mouse handler +*/ +void OCCViewer_Viewer3d::onMouseRelease( QMouseEvent* pe ) +{ + /* Selection with a rectangle ( multiple ) */ + OCCViewer_ViewPort* vp = myViewFrame->getViewPort(); + QAD_ASSERT_DEBUG_ONLY ( vp ); + QRect selRect = vp->getSelectionRect (); + if ( selRect.isValid() ) { + QAD_ASSERT_DEBUG_ONLY ( myAISSelector ); + QAD_ASSERT_DEBUG_ONLY ( vp->inherits("OCCViewer_ViewPort3d") ); + if ( pe->state() & Qt::ShiftButton ) + myAISSelector->shiftSelect ( selRect.left(), selRect.top(), + selRect.right(), selRect.bottom(), + ((OCCViewer_ViewPort3d*)vp)->getView() ); + else + myAISSelector->select ( selRect.left(), selRect.top(), + selRect.right(), selRect.bottom(), + ((OCCViewer_ViewPort3d*)vp)->getView() ); + } +} + +/*! + Mouse handler +*/ +void OCCViewer_Viewer3d::onMouseDoubleClick( QMouseEvent* pe ) +{ +} + +/*! + Called when a transformation in viewport is started +*/ +void OCCViewer_Viewer3d::onTransformationStarted( OCCViewer_ViewPort::OperationType type ) +{ + QAD_ASSERT_DEBUG_ONLY ( myAISSelector ); + if ( myEnableSelection ) + myAISSelector->enableSelection ( false ); // lock until the end of transform + + if ( type == OCCViewer_ViewPort::PANGLOBAL || + type == OCCViewer_ViewPort::WINDOWFIT ) + { + /* Start watching 'global panning' and 'window fit'. + These operations require additional user's actions + in viewport and we have to reset the operations if + instead of these actions a user does something else. + */ + qApp->installEventFilter( this ); + } +} + +/*! + Called when a transformation in viewport is finished +*/ +void OCCViewer_Viewer3d::onTransformationFinished( OCCViewer_ViewPort::OperationType type ) +{ + QAD_ASSERT_DEBUG_ONLY ( myAISSelector ); + if ( myEnableSelection ) + myAISSelector->enableSelection ( true ); // unlock + + if ( type == OCCViewer_ViewPort::PANGLOBAL || + type == OCCViewer_ViewPort::WINDOWFIT ) + { + /* stop watching 'global panning' and 'window fit'*/ + qApp->removeEventFilter( this ); + } +} + +/*! + Called when an object is selected +*/ +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() ) + + QString ActiveComp = QAD_Application::getDesktop()->getActiveComponent(); + + if ( ActiveComp.isEmpty() ) { + unHighlightAll(); + return; + } + + 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 ); + } + } + } 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(); + } + + if ( DeltaPos.Extent() > 0 ) + Sel->ClearIObjects(); + + } else { /* shift select */ + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + 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(); + } + + 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. + } + myAISContext->NextCurrent(); + } + } + + // MESSAGE ( "VIEWER onSelectionDone DeltaNeg.count() == " << DeltaNeg.count() ) + SALOME_ListIteratorOfListIO ItNeg( DeltaNeg ); + 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()) { + Sel->AddIObject( ItPos.Value(), false ); + } + myV3dViewer->Update(); +} + +/*! + Called when an object is unselected +*/ +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() ) + + SALOME_ListIO DeltaPos; + DeltaPos.Clear(); + SALOME_ListIO DeltaNeg; + DeltaNeg.Clear(); + if (!bAdded) { /* select */ + Sel->ClearIObjects(); + } else { /* shiftselect */ + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + 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(); + } + + // only if isknown + if (!itemAllreadySelected) + DeltaNeg.Append( IO1 ); + } + } + + // MESSAGE ( "VIEWER onSelectionCancel DeltaNeg.count() == " << DeltaNeg.Extent() ) + SALOME_ListIteratorOfListIO ItNeg( DeltaNeg ); + for(;ItNeg.More();ItNeg.Next()) { + Sel->RemoveIObject( ItNeg.Value(), false); + } + myV3dViewer->Update(); +} + +/*! + Installed while 'fit area' and 'global panning' + operations are active +*/ +bool OCCViewer_Viewer3d::eventFilter( QObject * po, QEvent * pe) +{ + if ( ( pe->type() == QEvent::MouseButtonPress && + po != myViewFrame->getViewPort() ) || + pe->type() == QEvent::KeyPress ) { + /* user press any key or a MB outside the viewport */ + myViewFrame->getViewPort()->resetState(); + } + return QObject::eventFilter( po, pe ); +} + +/*! + Creates CasCade viewer 3D +*/ +void OCCViewer_Viewer3d::createViewer3d() +{ + myV3dViewer = OCCViewer_VService::Viewer ( "", (short*) "Viewer3d", "", 1000., + V3d_XposYnegZpos, true, true); + myV3dViewer->Init(); + + myV3dCollector = OCCViewer_VService::Viewer ( "", (short*) "Collector3d", "", 1000., + V3d_XposYnegZpos, true, true); + myV3dCollector->Init(); +} + +/*! + Returns CasCade viewer 3D +*/ +Handle(V3d_Viewer) OCCViewer_Viewer3d::getViewer3d() const +{ + return myV3dViewer; +} + +/*! + Sets a new cursor on all its studyframes +*/ +void OCCViewer_Viewer3d::setCursor( const QCursor& cursor) +{ + myCursor = cursor; +} + +/*! + Returns the current cursor +*/ +inline const QCursor& OCCViewer_Viewer3d::cursor() const +{ + return myCursor; +} + +/*! + Sets default background color on all its studyframes +*/ +void OCCViewer_Viewer3d::setBackgroundColor( const QColor& aColor ) +{ + myBackColor = aColor; +} + +/*! + Returns the current background +*/ +inline const QColor& OCCViewer_Viewer3d::backgroundColor() const +{ + return myBackColor; +} + +/*! + Sets a new icon to all its studyframes +*/ +void OCCViewer_Viewer3d::setIcon( const QPixmap& icon ) +{ + myIcon = icon; +} + +/*! + Returns current icon +*/ +inline const QPixmap& OCCViewer_Viewer3d::icon() const +{ + return myIcon; +} + +/*! + Builds popup menu +*/ +void OCCViewer_Viewer3d::onCreatePopup() +{ +} + diff --git a/src/OCCViewer/OCCViewer_Viewer3d.h b/src/OCCViewer/OCCViewer_Viewer3d.h new file mode 100644 index 000000000..ca33a84fb --- /dev/null +++ b/src/OCCViewer/OCCViewer_Viewer3d.h @@ -0,0 +1,123 @@ +// File : OCCViewer_Viewer3d.h +// Created : Wed Mar 20 11:00:02 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef OCCVIEWER_VIEWER3D_H +#define OCCVIEWER_VIEWER3D_H + +#include "OCCViewer_ViewFrame.h" +#include "OCCViewer_AISSelector.h" + +#include "QAD.h" +#include "QAD_Popup.h" +#include "QAD_ViewFrame.h" +#include "SALOME_InteractiveObject.hxx" + +// Open CASCADE Includes +#include +#include + +class QAD_EXPORT OCCViewer_Viewer3d : public QObject, public QAD_PopupClientServer +{ + Q_OBJECT + +public: + OCCViewer_Viewer3d(OCCViewer_ViewFrame* vf); + ~OCCViewer_Viewer3d(); + +signals: + void vwKeyPress( QKeyEvent* ); + void vwKeyRelease( QKeyEvent* ); + void vwDrawExternal( QPainter* ); + +public slots: + void onKeyPress(QKeyEvent*); + + void onMouseMove(QMouseEvent*); + void onMousePress(QMouseEvent*); + void onMouseRelease(QMouseEvent*); + void onMouseDoubleClick(QMouseEvent*); + + void onSelectionDone( bool bAdded ); + void onSelectionCancel( bool bAdded ); + + void onTransformationStarted( OCCViewer_ViewPort::OperationType ); + void onTransformationFinished( OCCViewer_ViewPort::OperationType ); + +signals: + void vw3dSelectionDone (bool added); + void vw3dSelectionCancel(); + void vw3dSelectionEnabled( bool ); + +public: + void createViewer3d(); + Handle(V3d_Viewer) getViewer3d() const; + + void setTrihedronSize(float size); + bool isTrihedronDisplayed(); + + /* popup management */ + void onCreatePopup(); + + void setCursor( const QCursor& cursor); + const QCursor& cursor() const; + void setIcon( const QPixmap& icon); + const QPixmap& icon() const; + void setBackgroundColor( const QColor& aColor); + const QColor& backgroundColor() const; + + /* Selection management */ + bool highlight( const Handle(SALOME_InteractiveObject)& IObject, + bool highlight, bool update=true); + bool unHighlightAll(); + bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject, + bool onlyInViewer = false ); + bool isVisible( const Handle(SALOME_InteractiveObject)& IObject ); + void rename( const Handle(SALOME_InteractiveObject)& IObject, + QString newName ); + + bool enabledSelection() const; + void enableSelection( bool ); + void enableMultipleSelection( bool ); + + void SetColor(const Handle(SALOME_InteractiveObject)& IObject, + QColor thecolor); + void SwitchRepresentation(const Handle(SALOME_InteractiveObject)& IObject, + int mode); + void SetTransparency(const Handle(SALOME_InteractiveObject)& IObject, + float transp); + + /* interactive context */ + Handle (AIS_InteractiveContext) getAISContext() const; + OCCViewer_AISSelector* getAISSelector() const; + + /* trihedron */ + Handle(AIS_Trihedron) getTrihedron() const; + +protected: + bool eventFilter( QObject *, QEvent * ); + +protected: + OCCViewer_ViewFrame* myViewFrame; + + Handle (AIS_InteractiveContext) myAISContext; + OCCViewer_AISSelector* myAISSelector; + bool myEnableSelection; + Handle(AIS_Trihedron) myTrihedron; + Handle(V3d_Viewer) myV3dViewer; + Handle(V3d_Viewer) myV3dCollector; + + /* attributes for all the views */ + QPixmap myIcon; /* icon */ + QCursor myCursor; /* current cursor */ + QColor myBackColor; /* background */ + +}; + +#endif + diff --git a/src/PatchQt/Makefile.in b/src/PatchQt/Makefile.in new file mode 100644 index 000000000..c57f9bac2 --- /dev/null +++ b/src/PatchQt/Makefile.in @@ -0,0 +1,28 @@ + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + +@COMMENCE@ + +EXPORT_HEADERS = \ + qsplitterP.h \ + qworkspaceP.h + +# Libraries targets + +LIB = libqsplitterP.la +LIB_SRC = qsplitterP.cxx qsplitterP_moc.cxx qworkspaceP.cxx qworkspaceP_moc.cxx +qsplitterP_moc.cxx: $(inc_builddir)/qsplitterP.h + $(MOC) $(inc_builddir)/qsplitterP.h -o qsplitterP_moc.cxx + +qworkspaceP_moc.cxx: $(inc_builddir)/qworkspaceP.h + $(MOC) $(inc_builddir)/qworkspaceP.h -o qworkspaceP_moc.cxx + +CPPFLAGS+=$(QT_INCLUDES) -I${QTDIR}/src/kernel -I$(QTDIR)/mkspecs/linux-g++ +CXXFLAGS+= +LDFLAGS+=$(QT_MT_LIBS) + +@CONCLUDE@ diff --git a/src/PatchQt/qsplitterP.cxx b/src/PatchQt/qsplitterP.cxx new file mode 100644 index 000000000..49decad82 --- /dev/null +++ b/src/PatchQt/qsplitterP.cxx @@ -0,0 +1,1400 @@ +using namespace std; +/**************************************************************************** +** $Id$ +** +** Splitter widget +** +** Created: 980105 +** +** Copyright (C) 1992-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 "qsplitterP.h" +#ifndef QT_NO_COMPLEXWIDGETS + +#include +#include +#include +#include +#include +#if QT_VERSION < 300 + #include + #include +#else + #include //qt3.x + #include //qt3.x + #include //qt3.x +#endif + +#include +#include //sendPostedEvents + +#define SPLITTER_ICON_WIDTH 10 +#define SPLITTER_ICON_HEIGHT 12 + +static int mouseOffset; +static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky + +static const char* splitter_left_xpm[] = { + "5 5 2 1 0 0", + " s none m none c none", + ". s iconColor1 m black c black", + " ..", + " ....", + ".....", + " ....", + " .." +}; + +static const char* splitter_right_xpm[] = { + "5 5 2 1 0 0", + " s iconColor1 m black c black", + ". s none m none c none", + " ...", + " .", + " ", + " .", + " ..." +}; + +static const char* splitter_up_xpm[] = { + "5 5 2 1 0 0", + " s none m none c none", + ". s iconColor1 m black c black", + " . ", + " ... ", + " ... ", + ".....", + "....." +}; + +static const char* splitter_down_xpm[] = { + "5 5 2 1 0 0", + " s iconColor1 m black c black", + ". s none m none c none", + " ", + " ", + ". .", + ". .", + ".. .." +}; + +QSplitterPHandle::QSplitterPHandle( Qt::Orientation o, + QSplitterP *parent, const char * name ) + : QWidget( parent, name ) +{ + s = parent; + + left = new QPushButton(this); + right = new QPushButton(this); + unleft = new QPushButton(this); + unright = new QPushButton(this); + + setOrientation(o); + + left->setAutoDefault(false); unleft->setAutoDefault(false); + right->setAutoDefault(false); unright->setAutoDefault(false); + left->setFlat(true); right->setFlat(true); unleft->setFlat(true); unright->setFlat(true); + left->setCursor( arrowCursor ); right->setCursor( arrowCursor ); + unleft->setCursor( arrowCursor ); unright->setCursor( arrowCursor ); + +// VSR 21/11/02 -> ================================ + setMinimumSize( 1, 1 ); +// VSR 21/11/02 <- ================================ + + connect(left, SIGNAL(clicked()), this, SLOT(onBeforeCompress())); + connect(right, SIGNAL(clicked()), this, SLOT(onAfterCompress())); + connect(unleft, SIGNAL(clicked()), this, SLOT(onBeforeUnCompress())); + connect(unright, SIGNAL(clicked()), this, SLOT(onAfterUnCompress())); +} + +void QSplitterPHandle::onBeforeCompress() { + oldpos = s->pick(pos()); + int pos = s->pick(s->widgetBefore(id())->pos()); + s->compress(s->widgetBefore(id())); + s->moveSplitter(pos, id()); + s->updateSplitterHandles(); +} + +void QSplitterPHandle::onBeforeUnCompress() { + s->unCompress(s->widgetBefore(id())); + s->moveSplitter(oldpos, id()); + s->updateSplitterHandles(); +} + +void QSplitterPHandle::onAfterCompress() { + oldpos = s->pick(pos()); + int pos = s->pick(s->widgetAfter(id())->pos()) + s->pick(s->widgetAfter(id())->size()) - s->pick(size()); + s->compress(s->widgetAfter(id())); + s->moveSplitter(pos, id()); + s->updateSplitterHandles(); +} + +void QSplitterPHandle::onAfterUnCompress() { + s->unCompress(s->widgetAfter(id())); + s->moveSplitter(oldpos, id()); + s->updateSplitterHandles(); +} + +// VSR 21/11/02 -> ================================ +void QSplitterPHandle::compressAfter() +{ + onAfterCompress(); +} + +void QSplitterPHandle::unCompressAfter() +{ + onAfterUnCompress(); +} + +void QSplitterPHandle::compressBefore() +{ + onBeforeCompress(); +} + +void QSplitterPHandle::unCompressBefore() +{ + onBeforeUnCompress(); +} +// VSR 21/11/02 <- ================================ + +QSizePolicy QSplitterPHandle::sizePolicy() const +{ + //### removeme 3.0 + return QWidget::sizePolicy(); +} + +QSize QSplitterPHandle::sizeHint() const +{ +#if QT_VERSION < 300 + int sw = style().splitterWidth(); + return QSize(sw,sw).expandedTo( QApplication::globalStrut() ); +#else + int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); + return (style().sizeFromContents(QStyle::CT_Splitter, s, QSize(sw, sw)). + expandedTo(QApplication::globalStrut())); +#endif +} + +void QSplitterPHandle::setOrientation( Qt::Orientation o ) +{ + orient = o; +#ifndef QT_NO_CURSOR + if ( o == QSplitterP::Horizontal ) + setCursor( splitHCursor ); + else + setCursor( splitVCursor ); +#endif + + QPixmap lp, rp; + if ( orient == QSplitterP::Horizontal ) + { + lp = QPixmap(splitter_left_xpm); + rp = QPixmap(splitter_right_xpm); + } + else + { + lp = QPixmap(splitter_up_xpm); + rp = QPixmap(splitter_down_xpm); + } + left->setPixmap(lp); + right->setPixmap(rp); + unleft->setPixmap(rp); + unright->setPixmap(lp); +} + +void QSplitterPHandle::mouseMoveEvent( QMouseEvent *e ) +{ + if ( !(e->state()&LeftButton) ) + return; + QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) + - mouseOffset; + if ( opaque() ) { + s->moveSplitter( pos, id() ); + } else { + int min = pos; int max = pos; + s->getRange( id(), &min, &max ); + s->setRubberband( QMAX( min, QMIN(max, pos ))); + } +} + +void QSplitterPHandle::mousePressEvent( QMouseEvent *e ) +{ + if ( e->button() == LeftButton ) + mouseOffset = s->pick(e->pos()); +} + +void QSplitterPHandle::mouseReleaseEvent( QMouseEvent *e ) +{ + if ( !opaque() && e->button() == LeftButton ) { + QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())); + s->setRubberband( -1 ); + s->moveSplitter( pos, id() ); + } +} + +void QSplitterPHandle::paintEvent( QPaintEvent * ) +{ + updateButtonState(); + QPainter p( this ); + s->drawSplitter( &p, 0, 0, width(), height() ); +} + +void QSplitterPHandle::updateButtonState() { + if (!s->isCompressEnabled()) { + left->hide(); + right->hide(); + unleft->hide(); + unright->hide(); + } + else { + if ( orient == QSplitterP::Horizontal ) + { + left->setGeometry( QRect( QPoint( (width() - SPLITTER_ICON_WIDTH)/2, 0 ), + QSize ( SPLITTER_ICON_WIDTH, SPLITTER_ICON_HEIGHT ) ) ); + right->setGeometry( QRect( QPoint( (width() - SPLITTER_ICON_WIDTH)/2, SPLITTER_ICON_HEIGHT ), + QSize ( SPLITTER_ICON_WIDTH, SPLITTER_ICON_HEIGHT ) ) ); + unleft->setGeometry( left->geometry() ); + unright->setGeometry( right->geometry() ); + } + else + { + left->setGeometry( QRect( QPoint( 0, (height() - SPLITTER_ICON_WIDTH)/2 ), + QSize ( SPLITTER_ICON_HEIGHT, SPLITTER_ICON_WIDTH ) ) ); + right->setGeometry( QRect( QPoint( SPLITTER_ICON_HEIGHT, (height() - SPLITTER_ICON_WIDTH)/2), + QSize ( SPLITTER_ICON_HEIGHT, SPLITTER_ICON_WIDTH ) ) ); + unleft->setGeometry( left->geometry() ); + unright->setGeometry( right->geometry() ); + } + if ( s->isCompressed( s->widgetBefore( id() ) ) ) { + left->hide(); + unleft->show(); + right->setEnabled(false); + } + else { + unleft->hide(); + left->show(); + right->setEnabled(true); + } + if ( s->isCompressed( s->widgetAfter( id() ) ) ) { + right->hide(); + unright->show(); + left->setEnabled(false); + } + else { + unright->hide(); + right->show(); + left->setEnabled(true); + } + } +} + +class QSplitterPLayoutStruct +{ +public: + QSplitterP::ResizeMode mode; + QCOORD sizer; + bool isSplitter; + QWidget *wid; +}; + +class QSplitterPData +{ +public: + QSplitterPData() : opaque( FALSE ), firstShow( TRUE ) {} + + QList list; + bool opaque; + bool firstShow; +}; + + +// NOT REVISED +/*! + \class QSplitter qsplitter.h + \brief The QSplitter class implements a splitter widget. + + \ingroup organizers + + A splitter lets the user control the size of child widgets by + dragging the boundary between the children. Any number of widgets + may be controlled. + + To show a QListBox, a QListView and a QMultiLineEdit side by side: + + \code + QSplitter *split = new QSplitter( parent ); + QListBox *lb = new QListBox( split ); + QListView *lv = new QListView( split ); + QMultiLineEdit *ed = new QMultiLineEdit( split ); + \endcode + + In QSplitter the boundary can be either horizontal or vertical. The + default is horizontal (the children are side by side) and you + can use setOrientation( QSplitter::Vertical ) to set it to vertical. + + By default, all widgets can be as large or as small as the user + wishes, down to \link QWidget::minimumSizeHint() minimumSizeHint()\endlink. + You can naturally use setMinimumSize() and/or + setMaximumSize() on the children. Use setResizeMode() to specify that + a widget should keep its size when the splitter is resized. + + QSplitter normally resizes the children only at the end of a + resize operation, but if you call setOpaqueResize( TRUE ), the + widgets are resized as often as possible. + + The initial distribution of size between the widgets is determined + by the initial size of each widget. You can also use setSizes() to + set the sizes of all the widgets. The function sizes() returns the + sizes set by the user. + + If you hide() a child, its space will be distributed among the other + children. When you show() it again, it will be reinstated. + + + + \sa QTabBar +*/ + + + +QSize QSplitterP::minSize( const QWidget *w ) const +{ + if ( isCompressed(w) && (data->list.count() > 1 ) ) return QSize(0,0); + QSize min = w->minimumSize(); + QSize s; + if ( min.height() <= 0 || min.width() <= 0 ) + s = w->minimumSizeHint(); + if ( min.height() > 0 ) + s.setHeight( min.height() ); + if ( min.width() > 0 ) + s.setWidth( min.width() ); + return s.expandedTo(QSize(0,0)); +} + +QSize QSplitterP::maxSize( const QWidget* w ) const +{ + if ( isCompressed(w) && (data->list.count() > 1 ) ) return QSize(0,0); + else return w->maximumSize(); +} + +/*! + Constructs a horizontal splitter. +*/ + +QSplitterP::QSplitterP( QWidget *parent, const char *name ) + :QFrame(parent,name,WPaintUnclipped) +{ + orient = Horizontal; + init(); +} + + +/*! + Constructs splitter with orientation \a o. +*/ + +QSplitterP::QSplitterP( Orientation o, QWidget *parent, const char *name ) + :QFrame(parent,name,WPaintUnclipped) +{ + orient = o; + init(); +} + + +/*! + Destructs the splitter. +*/ + +QSplitterP::~QSplitterP() +{ + data->list.setAutoDelete( TRUE ); + delete data; +} + + +void QSplitterP::init() +{ + data = new QSplitterPData; + if ( orient == Horizontal ) + setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum) ); + else + setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Fixed) ); + compressed_widgets.clear(); + compress_flag = false; +} + + +/*! + \fn void QSplitter::refresh() + + Updates the splitter state. You should not need to call this + function during normal use of the splitter. +*/ + + +/*! Sets the orientation to \a o. By default the orientation is + horizontal (the widgets are side by side). + + \sa orientation() +*/ + +void QSplitterP::setOrientation( Orientation o ) +{ + if ( orient == o ) + return; + orient = o; + + if ( orient == Horizontal ) + setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ) ); + else + setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) ); + + QSplitterPLayoutStruct *s = data->list.first(); + while ( s ) { + if ( s->isSplitter ) + ((QSplitterPHandle*)s->wid)->setOrientation( o ); + s = data->list.next(); // ### next at end of loop, no iterator + } + recalc( isVisible() ); +} + + +/*! + \fn Orientation QSplitter::orientation() const + + Returns the orientation (\c Horizontal or \c Vertical) of the splitter. + \sa setOrientation() +*/ + +/*! + \reimp +*/ +void QSplitterP::resizeEvent( QResizeEvent * ) +{ + doResize(); +} + + +/*! + Inserts the widget \a w at the end, or at the beginning if \a first is TRUE + + It is the responsibility of the caller of this function to make sure + that \a w is not already in the splitter, and to call recalcId if + needed. (If \a first is TRUE, then recalcId is very probably + needed.) +*/ + +QSplitterPLayoutStruct *QSplitterP::addWidget( QWidget *w, bool first ) +{ + QSplitterPLayoutStruct *s; + QSplitterPHandle *newHandle = 0; + if ( data->list.count() > 0 ) { + s = new QSplitterPLayoutStruct; + s->mode = KeepSize; + newHandle = new QSplitterPHandle( orientation(), this ); + s->wid = newHandle; + newHandle->setId(data->list.count()); + s->isSplitter = TRUE; + s->sizer = pick( newHandle->sizeHint() ); + if ( first ) + data->list.insert( 0, s ); + else + data->list.append( s ); + } + s = new QSplitterPLayoutStruct; + s->mode = Stretch; + s->wid = w; + if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) + s->sizer = pick( w->sizeHint() ); + else + s->sizer = pick( w->size() ); + s->isSplitter = FALSE; + if ( first ) + data->list.insert( 0, s ); + else + data->list.append( s ); + if ( newHandle && isVisible() ) + newHandle->show(); //will trigger sending of post events + return s; +} + + +/*! + Tells the splitter that a child widget has been inserted/removed. +*/ + +void QSplitterP::childEvent( QChildEvent *c ) +{ + if ( c->type() == QEvent::ChildInserted ) { + if ( !c->child()->isWidgetType() ) + return; + + if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) + return; + + QSplitterPLayoutStruct *s = data->list.first(); + while ( s ) { + if ( s->wid == c->child() ) + return; + s = data->list.next(); + } + addWidget( (QWidget*)c->child() ); + recalc( isVisible() ); + + } else if ( c->type() == QEvent::ChildRemoved ) { + QSplitterPLayoutStruct *p = 0; + if ( data->list.count() > 1 ) + p = data->list.at(1); //remove handle _after_ first widget. + QSplitterPLayoutStruct *s = data->list.first(); + while ( s ) { + if ( s->wid == c->child() ) { + data->list.removeRef( s ); + delete s; + if ( p && p->isSplitter ) { + data->list.removeRef( p ); + delete p->wid; //will call childEvent + delete p; + } + recalcId(); + doResize(); + return; + } + p = s; + s = data->list.next(); + } + } +} + + +/*! + Shows a rubber band at position \a p. If \a p is negative, the + rubber band is removed. +*/ + +void QSplitterP::setRubberband( int p ) +{ + QPainter paint( this ); + paint.setPen( gray ); + paint.setBrush( gray ); + paint.setRasterOp( XorROP ); + QRect r = contentsRect(); + const int rBord = 3; //Themable???? +#if QT_VERSION < 300 + const int sw = style().splitterWidth(); +#else + int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); //qt3.x +#endif + if ( orient == Horizontal ) { + if ( opaqueOldPos >= 0 ) + paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), + 2*rBord, r.height() ); + if ( p >= 0 ) + paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); + } else { + if ( opaqueOldPos >= 0 ) + paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, + r.width(), 2*rBord ); + if ( p >= 0 ) + paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); + } + opaqueOldPos = p; +} + + +/*! \reimp */ + +bool QSplitterP::event( QEvent *e ) +{ + if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { + recalc( isVisible() ); + if ( e->type() == QEvent::Show ) + data->firstShow = FALSE; + } + return QWidget::event( e ); +} + + +/*! + Draws the splitter handle in the rectangle described by \a x, \a y, + \a w, \a h using painter \a p. + \sa QStyle::drawSplitter +*/ + +void QSplitterP::drawSplitter( QPainter *p, + QCOORD x, QCOORD y, QCOORD w, QCOORD h ) +{ +#if QT_VERSION < 300 + style().drawSplitter( p, x, y, w, h, colorGroup(), orient ); +#else + style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), + (orientation() == Qt::Horizontal ? + QStyle::Style_Horizontal : 0)); +#endif +} + + +/*! + Returns the id of the splitter to the right of or below the widget \a w, + or 0 if there is no such splitter. + (ie. it is either not in this QSplitter, or it is at the end). +*/ + +int QSplitterP::idAfter( QWidget* w ) const +{ + QSplitterPLayoutStruct *s = data->list.first(); + bool seen_w = FALSE; + while ( s ) { + if ( s->isSplitter && seen_w ) + return data->list.at(); + if ( !s->isSplitter && s->wid == w ) + seen_w = TRUE; + s = data->list.next(); + } + return 0; +} + +// VSR 21/11/02 -> ================================ +QSplitterPHandle* QSplitterP::getHandleAfter(QWidget* w) +{ + QSplitterPLayoutStruct *s = data->list.first(); + bool seen_w = FALSE; + while ( s ) { + if ( s->isSplitter && seen_w ) + return (QSplitterPHandle*)s->wid; + if ( !s->isSplitter && s->wid == w ) + seen_w = TRUE; + s = data->list.next(); + } + return 0; +} + +QSplitterPHandle* QSplitterP::getHandleBefore(QWidget* w) +{ + QSplitterPLayoutStruct *s = data->list.first(); + QSplitterPHandle* h = 0; + while ( s ) { + if ( s->isSplitter ) + h = (QSplitterPHandle*)s; + if ( !s->isSplitter && s->wid == w ) + return h; + s = data->list.next(); + } + return 0; +} +// VSR 21/11/02 <- ================================ + +QWidget* QSplitterP::widgetBefore( int id ) const +{ + QSplitterPLayoutStruct *s = data->list.first(); + QWidget* w; + while ( s ) { + if ( !s->isSplitter ) { + w = s->wid; + if (idAfter(w) == id) return w; + } + s = data->list.next(); + } + return 0; +} + +QWidget* QSplitterP::widgetAfter( int id ) const +{ + QSplitterPLayoutStruct *s = data->list.first(); + bool seen_s = FALSE; + while ( s ) { + if ( !s->isSplitter && seen_s ) + return s->wid; + if ( s->isSplitter && data->list.at() == id ) + seen_s = TRUE; + s = data->list.next(); + } + return 0; +} + +void QSplitterP::unCompress(QWidget* w) { + compressed_widgets.remove(w); +} + +void QSplitterP::compress(QWidget* w) +{ + if (!isCompressed(w)) compressed_widgets.append(w); +} + +bool QSplitterP::isCompressed(const QWidget* w) const { + QWidget* t = (QWidget*)w; + if (compressed_widgets.containsRef(t)==0) return false; + else return true; +} + +/*! + Moves the left/top edge of the splitter handle with id \a id as + close as possible to \a p which is the distance from the left (or + top) edge of the widget. + + \sa idAfter() +*/ +void QSplitterP::moveSplitter( QCOORD p, int id ) +{ + p = adjustPos( p, id ); + + QSplitterPLayoutStruct *s = data->list.at(id); + int oldP = orient == Horizontal? s->wid->x() : s->wid->y(); + bool upLeft = p < oldP; + + moveAfter( p, id, upLeft ); + moveBefore( p-1, id-1, upLeft ); + + storeSizes(); +} + + +void QSplitterP::setG( QWidget *w, int p, int s ) +{ + if ( orient == Horizontal ) + w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); + else + w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); +} + + +/*! + Places the right/bottom edge of the widget at \a id at position \a pos. + + \sa idAfter() +*/ + +void QSplitterP::moveBefore( int pos, int id, bool upLeft ) +{ + QSplitterPLayoutStruct *s = data->list.at(id); + if ( !s ) + return; + QWidget *w = s->wid; + if ( w->isHidden() ) { + moveBefore( pos, id-1, upLeft ); + } else if ( s->isSplitter ) { + int dd = s->sizer; + if ( upLeft ) { + setG( w, pos-dd+1, dd ); + moveBefore( pos-dd, id-1, upLeft ); + } else { + moveBefore( pos-dd, id-1, upLeft ); + setG( w, pos-dd+1, dd ); + } + } else { + int left = pick( w->pos() ); + int dd = pos - left + 1; + dd = QMAX( pick(minSize(w)), QMIN(dd, pick(maxSize(w)))); + int newLeft = pos-dd+1; + setG( w, newLeft, dd ); + if ( left != newLeft ) + moveBefore( newLeft-1, id-1, upLeft ); + } +} + + +/*! + Places the left/top edge of the widget at \a id at position \a pos. + + \sa idAfter() +*/ + +void QSplitterP::moveAfter( int pos, int id, bool upLeft ) +{ + QSplitterPLayoutStruct *s = id < int(data->list.count()) ? + data->list.at(id) : 0; + if ( !s ) + return; + QWidget *w = s->wid; + if ( w->isHidden() ) { + moveAfter( pos, id+1, upLeft ); + } else if ( pick( w->pos() ) == pos ) { + //No need to do anything if it's already there. + return; + } else if ( s->isSplitter ) { + int dd = s->sizer; + if ( upLeft ) { + setG( w, pos, dd ); + moveAfter( pos+dd, id+1, upLeft ); + } else { + moveAfter( pos+dd, id+1, upLeft ); + setG( w, pos, dd ); + } + } else { + int right = pick( w->geometry().bottomRight() ); + + int dd = right - pos + 1; + dd = QMAX( pick(minSize(w)), QMIN(dd, pick(maxSize(w)))); + int newRight = pos+dd-1; + setG( w, pos, dd ); + moveAfter( newRight+1, id+1, upLeft ); + } +} + + +/*! + Returns the valid range of the splitter with id \a id in \a min and \a max. + + \sa idAfter() +*/ + +void QSplitterP::getRange( int id, int *min, int *max ) +{ + int minB = 0; //before + int maxB = 0; + int minA = 0; + int maxA = 0; //after + int n = data->list.count(); + if ( id < 0 || id >= n ) + return; + int i; + for ( i = 0; i < id; i++ ) { + QSplitterPLayoutStruct *s = data->list.at(i); + if ( s->isSplitter ) { + minB += s->sizer; + maxB += s->sizer; + } else { + minB += pick( minSize(s->wid) ); + maxB += pick( maxSize(s->wid) ); + } + } + for ( i = id; i < n; i++ ) { + QSplitterPLayoutStruct *s = data->list.at(i); + if ( s->isSplitter ) { + minA += s->sizer; + maxA += s->sizer; + } else { + minA += pick( minSize(s->wid) ); + maxA += pick( maxSize(s->wid) ); + } + } + QRect r = contentsRect(); + if ( min ) + *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); + if ( max ) + *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); + +} + + +/*! + Returns the legal position closest to \a p of the splitter with id \a id. + + \sa idAfter() +*/ + +int QSplitterP::adjustPos( int p, int id ) +{ + int min = 0; + int max = 0; + getRange( id, &min, &max ); + p = QMAX( min, QMIN( p, max ) ); + + return p; +} + + +void QSplitterP::doResize() +{ + QRect r = contentsRect(); + int i; + int n = data->list.count(); + QArray a( n ); + for ( i = 0; i< n; i++ ) { + a[i].init(); + QSplitterPLayoutStruct *s = data->list.at(i); + if ( s->wid->isHidden() ) { + a[i].stretch = 0; + a[i].sizeHint = a[i].minimumSize = 0; + a[i].maximumSize = 0; + } else if ( s->isSplitter ) { + a[i].stretch = 0; + a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; + a[i].empty = FALSE; + } else if ( s->mode == KeepSize ) { + a[i].stretch = 0; + a[i].minimumSize = pick( minSize(s->wid) ); + a[i].sizeHint = s->sizer; + a[i].maximumSize = pick( maxSize(s->wid) ); + a[i].empty = FALSE; + } else if ( s->mode == FollowSizeHint ) { + a[i].stretch = 0; + a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); + a[i].maximumSize = pick( maxSize(s->wid) ); + a[i].empty = FALSE; + } else { //proportional + a[i].stretch = s->sizer; + a[i].maximumSize = pick( maxSize(s->wid) ); + a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); + a[i].empty = FALSE; + } + } + + qGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); + for ( i = 0; i< n; i++ ) { + QSplitterPLayoutStruct *s = data->list.at(i); + if ( orient == Horizontal ) + s->wid->setGeometry( a[i].pos, r.top(), a[i].size, r.height() ); + else + s->wid->setGeometry( r.left(), a[i].pos, r.width(), a[i].size ); + } + +} + + +void QSplitterP::recalc( bool update ) +{ + int fi = 2*frameWidth(); + int maxl = fi; + int minl = fi; + int maxt = QWIDGETSIZE_MAX; + int mint = fi; + int n = data->list.count(); + bool first = TRUE; + /* + The splitter before a hidden widget is always hidden. + The splitter before the first visible widget is hidden. + The splitter before any other visible widget is visible. + */ + for ( int i = 0; i< n; i++ ) { + QSplitterPLayoutStruct *s = data->list.at(i); + if ( !s->isSplitter ) { + QSplitterPLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; + if ( p && p->isSplitter ) + if ( first || s->wid->isHidden() ) + p->wid->hide(); //may trigger new recalc + else + p->wid->show(); //may trigger new recalc + if ( !s->wid->isHidden() ) + first = FALSE; + } + } + + bool empty=TRUE; + for ( int j = 0; j< n; j++ ) { + QSplitterPLayoutStruct *s = data->list.at(j); + if ( !s->wid->isHidden() ) { + empty = FALSE; + if ( s->isSplitter ) { + minl += s->sizer; + maxl += s->sizer; + } else { + QSize minS = minSize(s->wid); + minl += pick( minS ); + maxl += pick( maxSize(s->wid) ); + mint = QMAX( mint, trans( minS )); + int tm = trans( maxSize(s->wid) ); + if ( tm > 0 ) + maxt = QMIN( maxt, tm ); + } + } + } + if ( empty ) + maxl = maxt = 0; + else + maxl = QMIN( maxl, QWIDGETSIZE_MAX ); + if ( maxt < mint ) + maxt = mint; + + if ( orient == Horizontal ) { + setMaximumSize( maxl, maxt ); + setMinimumSize( minl, mint ); + } else { + setMaximumSize( maxt, maxl ); + setMinimumSize( mint, minl ); + } + if ( update ) + doResize(); +} + +/*! \enum QSplitter::ResizeMode + + This enum type describes how QSplitter will resize each of its child widgets. The currently defined values are:
    + +
  • \c Stretch - the widget will be resized when the splitter + itself is resized. + +
  • \c KeepSize - QSplitter will try to keep this widget's size + unchanged. + +
  • \c FollowSizeHint - QSplitter will resize the widget when its + size hint changes. + +
+ +*/ + +/*! + Sets resize mode of \a w to \a mode. + + \sa ResizeMode +*/ + +void QSplitterP::setResizeMode( QWidget *w, ResizeMode mode ) +{ + processChildEvents(); + QSplitterPLayoutStruct *s = data->list.first(); + while ( s ) { + if ( s->wid == w ) { + s->mode = mode; + return; + } + s = data->list.next(); + } + s = addWidget( w, TRUE ); + s->mode = mode; +} + + +/*! + Returns TRUE if opaque resize is on, FALSE otherwise. + + \sa setOpaqueResize() +*/ + +bool QSplitterP::opaqueResize() const +{ + return data->opaque; +} + + +/*! + Sets opaque resize to \a on. Opaque resize is initially turned off. + + \sa opaqueResize() +*/ + +void QSplitterP::setOpaqueResize( bool on ) +{ + data->opaque = on; +} + + +/*! + Moves \a w to the leftmost/top position. +*/ + +void QSplitterP::moveToFirst( QWidget *w ) +{ + processChildEvents(); + bool found = FALSE; + QSplitterPLayoutStruct *s = data->list.first(); + while ( s ) { + if ( s->wid == w ) { + found = TRUE; + QSplitterPLayoutStruct *p = data->list.prev(); + if ( p ) { // not already at first place + data->list.take(); //take p + data->list.take(); // take s + data->list.insert( 0, p ); + data->list.insert( 0, s ); + } + break; + } + s = data->list.next(); + } + if ( !found ) + addWidget( w, TRUE ); + recalcId(); +} + + +/*! + Moves \a w to the rightmost/bottom position. +*/ + +void QSplitterP::moveToLast( QWidget *w ) +{ + processChildEvents(); + bool found = FALSE; + QSplitterPLayoutStruct *s = data->list.first(); + while ( s ) { + if ( s->wid == w ) { + found = TRUE; + data->list.take(); // take s + QSplitterPLayoutStruct *p = data->list.current(); + if ( p ) { // the splitter handle after s + data->list.take(); //take p + data->list.append( p ); + } + data->list.append( s ); + break; + } + s = data->list.next(); + } + if ( !found ) + addWidget( w); + recalcId(); +} + + +void QSplitterP::recalcId() +{ + int n = data->list.count(); + for ( int i = 0; i < n; i++ ) { + QSplitterPLayoutStruct *s = data->list.at(i); + if ( s->isSplitter ) + ((QSplitterPHandle*)s->wid)->setId(i); + } +} + + +/*!\reimp +*/ +QSize QSplitterP::sizeHint() const +{ + constPolish(); + int l = 0; + int t = 0; + if ( children() ) { + const QObjectList * c = children(); + QObjectListIt it( *c ); + QObject * o; + + while( (o=it.current()) != 0 ) { + ++it; + if ( o->isWidgetType() && + !((QWidget*)o)->isHidden() ) { + QSize s = ((QWidget*)o)->sizeHint(); + if ( s.isValid() ) { + l += pick( s ); + t = QMAX( t, trans( s ) ); + } + } + } + } + return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); +} + + +/*! +\reimp +*/ + +QSize QSplitterP::minimumSizeHint() const +{ + constPolish(); + int l = 0; + int t = 0; + if ( children() ) { + const QObjectList * c = children(); + QObjectListIt it( *c ); + QObject * o; + + while( (o=it.current()) != 0 ) { + ++it; + if ( o->isWidgetType() && + !((QWidget*)o)->isHidden() ) { + QSize s = minSize((QWidget*)o); + if ( s.isValid() ) { + l += pick( s ); + t = QMAX( t, trans( s ) ); + } + } + } + } + return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); +} + + + +/*!\reimp +*/ +QSizePolicy QSplitterP::sizePolicy() const +{ + return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); +} + + +/*! + Calculates stretch parameters from current sizes +*/ + +void QSplitterP::storeSizes() +{ + QSplitterPLayoutStruct *s = data->list.first(); + while ( s ) { + if ( !s->isSplitter ) + s->sizer = pick( s->wid->size() ); + s = data->list.next(); + } +} + + +#if 0 // ### remove this code ASAP + +/*! + Hides \a w if \a hide is TRUE, and updates the splitter. + + \warning Due to a limitation in the current implementation, + calling QWidget::hide() will not work. +*/ + +void QSplitterP::setHidden( QWidget *w, bool hide ) +{ + if ( w == w1 ) { + w1show = !hide; + } else if ( w == w2 ) { + w2show = !hide; + } else { +#ifdef CHECK_RANGE + qWarning( "QSplitterP::setHidden(), unknown widget" ); +#endif + return; + } + if ( hide ) + w->hide(); + else + w->show(); + recalc( TRUE ); +} + + +/*! + Returns the hidden status of \a w +*/ + +bool QSplitterP::isHidden( QWidget *w ) const +{ + if ( w == w1 ) + return !w1show; + else if ( w == w2 ) + return !w2show; +#ifdef CHECK_RANGE + else + qWarning( "QSplitterP::isHidden(), unknown widget" ); +#endif + return FALSE; +} +#endif + + +/*! + Returns a list of the size parameters of all the widgets in this + splitter. + + Giving the values to setSizes() will give a splitter with the same + layout as this one. +*/ + +QValueList QSplitterP::sizes() const +{ + if ( !testWState(WState_Polished) ) { + QWidget* that = (QWidget*) this; + that->polish(); + } + QValueList list; + QSplitterPLayoutStruct *s = data->list.first(); + while ( s ) { + if ( !s->isSplitter ) + list.append( s->sizer ); + s = data->list.next(); + } + return list; +} + + + +/*! + Sets the size parameters to the values given in \a list. + If the splitterP is horizontal, the values set the sizes from + left to right. If it is vertical, the sizes are applied from + top to bottom. + Extra values in \a list are ignored. + + If \a list contains too few values, the result is undefined + but the program will still be well-behaved. +*/ + +void QSplitterP::setSizes( QValueList list ) +{ + processChildEvents(); + QValueList::Iterator it = list.begin(); + QSplitterPLayoutStruct *s = data->list.first(); + while ( s && it != list.end() ) { + if ( !s->isSplitter ) { + s->sizer = *it; + ++it; + } + s = data->list.next(); + } + doResize(); +} + + +/*! + Gets all posted child events, ensuring that the internal state of + the splitter is consistent with the programmer's idea. +*/ + +void QSplitterP::processChildEvents() +{ + QApplication::sendPostedEvents( this, QEvent::ChildInserted ); +} + + +/*! + \reimp +*/ + +void QSplitterP::styleChange( QStyle& old ) +{ +#if QT_VERSION < 300 + int sw = style().splitterWidth(); +#else + int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); //qt3.x +#endif + QSplitterPLayoutStruct *s = data->list.first(); + while ( s ) { + if ( s->isSplitter ) + s->sizer = sw; + s = data->list.next(); + } + doResize(); + QFrame::styleChange( old ); +} +#endif + +bool QSplitterP::isCompressEnabled() const +{ + return compress_flag; +} + +void QSplitterP::setCompressEnabled(bool on) { + compress_flag = on; +} + +void QSplitterP::updateSplitterHandles() const { + QSplitterPLayoutStruct *s = data->list.first(); + while ( s ) { + if ( s->isSplitter ) + ((QSplitterPHandle*)s->wid)->updateButtonState(); + s = data->list.next(); + } +} diff --git a/src/PatchQt/qsplitterP.h b/src/PatchQt/qsplitterP.h new file mode 100644 index 000000000..56a277010 --- /dev/null +++ b/src/PatchQt/qsplitterP.h @@ -0,0 +1,205 @@ +/**************************************************************************** +** $Id$ +** +** Defintion of QSplitter class +** +** Created: 980105 +** +** Copyright (C) 1992-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 QSPLITTERP_H +#define QSPLITTERP_H + +#ifndef QT_H +#include +#include +#include // by STV +#endif // QT_H +#include + +#ifndef QT_NO_COMPLEXWIDGETS + +class QSplitterPHandle; +class QSplitterPData; +class QSplitterPLayoutStruct; + +class Q_EXPORT QSplitterP : public QFrame +{ + Q_OBJECT + Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) + +public: + enum ResizeMode { Stretch, KeepSize, FollowSizeHint }; + + QSplitterP( QWidget *parent=0, const char *name=0 ); + QSplitterP( Orientation, QWidget *parent=0, const char *name=0 ); + ~QSplitterP(); + + virtual void setOrientation( Orientation ); + Orientation orientation() const { return orient; } + + virtual void setResizeMode( QWidget *w, ResizeMode ); + virtual void setOpaqueResize( bool = TRUE ); + bool opaqueResize() const; + + void moveToFirst( QWidget * ); + void moveToLast( QWidget * ); + + void refresh() { recalc( TRUE ); } + QSize sizeHint() const; + QSize minimumSizeHint() const; + QSizePolicy sizePolicy() const; + + QValueList sizes() const; + void setSizes( QValueList ); + bool isCompressEnabled() const; + void setCompressEnabled(bool on); + + void compress(QWidget*); + void unCompress(QWidget*); + +// VSR 21/11/02 -> ================================ + QSplitterPHandle* getHandleAfter(QWidget* w); + QSplitterPHandle* getHandleBefore(QWidget* w); +// VSR 21/11/02 <- ================================ + +protected: + void childEvent( QChildEvent * ); + + bool event( QEvent * ); + void resizeEvent( QResizeEvent * ); + + 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; + + void moveSplitter( QCOORD pos, int id ); + virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y, + QCOORD w, QCOORD h ); + void styleChange( QStyle& ); + int adjustPos( int , int ); + virtual void setRubberband( int ); + void getRange( int id, int*, int* ); + +private: + void init(); + void recalc( bool update = FALSE ); + int hit( QPoint p ); + void doResize(); + void storeSizes(); + void processChildEvents(); + QSplitterPLayoutStruct *addWidget( QWidget*, bool first = FALSE ); + void recalcId(); + void moveBefore( int pos, int id, bool upLeft ); + void moveAfter( int pos, int id, bool upLeft ); + void setG( QWidget *w, int p, int s ); + void updateSplitterHandles() const; + + QCOORD pick( const QPoint &p ) const + { return orient == Horizontal ? p.x() : p.y(); } + QCOORD pick( const QSize &s ) const + { return orient == Horizontal ? s.width() : s.height(); } + + QCOORD trans( const QPoint &p ) const + { return orient == Vertical ? p.x() : p.y(); } + QCOORD trans( const QSize &s ) const + { return orient == Vertical ? s.width() : s.height(); } + + QSplitterPData *data; + QWidgetList compressed_widgets; + + Orientation orient; + bool compress_flag; + friend class QSplitterPHandle; +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + QSplitterP( const QSplitterP & ); + QSplitterP& operator=( const QSplitterP & ); +#endif +}; + +#endif // QT_NO_COMPLEXWIDGETS + + +class Q_EXPORT QSplitterPHandle : public QWidget +{ + Q_OBJECT +public: + QSplitterPHandle( Qt::Orientation o, + QSplitterP *parent, const char* name=0 ); + void setOrientation( Qt::Orientation o ); + Qt::Orientation orientation() const { return orient; } + + bool opaque() const { return s->opaqueResize(); } + + QSize sizeHint() const; + QSizePolicy sizePolicy() const; + + int id() const { return myId; } // data->list.at(id())->wid == this + void setId( int i ) { myId = i; } + void updateButtonState(); + +// VSR 21/11/02 -> ================================ + void compressAfter(); + void unCompressAfter(); + void compressBefore(); + void unCompressBefore(); +// VSR 21/11/02 <- ================================ + +protected: + void paintEvent( QPaintEvent * ); + void mouseMoveEvent( QMouseEvent * ); + void mousePressEvent( QMouseEvent * ); + void mouseReleaseEvent( QMouseEvent * ); + +protected slots: + void onBeforeCompress(); + void onAfterCompress(); + void onBeforeUnCompress(); + void onAfterUnCompress(); + +private: + Qt::Orientation orient; + bool opaq; + int myId; + + QSplitterP *s; + int oldpos; + QPushButton* left; + QPushButton* right; + QPushButton* unleft; + QPushButton* unright; +}; + + +#endif // QSPLITTERP_H diff --git a/src/PatchQt/qworkspaceP.cxx b/src/PatchQt/qworkspaceP.cxx new file mode 100644 index 000000000..993119b36 --- /dev/null +++ b/src/PatchQt/qworkspaceP.cxx @@ -0,0 +1,3371 @@ +using namespace std; +// File : qworkspaceP.cxx +// Created : UI team, 21.11.02 +// Descr : Patch for QWorkspace class (Qt 3.0.5) + +// Modified : Mon Nov 25 09:35:34 2002 +// Author : Vadim SANDLER +// Project : SALOME +// Module : PatchQt +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "qworkspaceP.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if defined(Q_WS_WIN) +#include +#endif +#include +#include +#include + +#include +#include + +#define BUTTON_WIDTH 16 +#define BUTTON_HEIGHT 14 + + +/*! + \class QWorkspaceP qworkspace.h + \brief The QWorkspaceP widget provides a workspace window that can + contain decorated windows, e.g. for MDI. + + \module workspace + + \ingroup application + \ingroup organizers + \mainclass + + An MDI (multiple document interface) application has one main + window with a menu bar. The central widget of this window is a + workspace. The workspace itself contains zero, one or more + document windows, each of which displays a document. + + The workspace itself is an ordinary Qt widget. It has a standard + constructor that takes a parent widget and an object name. The + parent window is usually a QMainWindow, but it need not be. + + Document windows (i.e. MDI windows) are also ordinary Qt widgets + which have the workspace as parent widget. When you call show(), + hide(), showMaximized(), setCaption(), etc. on a document window, + it is shown, hidden, etc. with a frame, caption, icon and icon + text, just as you'd expect. You can provide widget flags which + will be used for the layout of the decoration or the behaviour of + the widget itself. + + To change the geometry of the MDI windows it is necessary to make + the function calls to the parentWidget() of the widget, as this + will move or resize the decorated window. + + A document window becomes active when it gets the keyboard focus. + You can activate it using setFocus(), and the user can activate it + by moving focus in the normal ways. The workspace emits a signal + windowActivated() when it detects the activation change, and the + function activeWindow() always returns a pointer to the active + document window. + + The convenience function windowList() returns a list of all + document windows. This is useful to create a popup menu + "Windows" on the fly, for example. + + QWorkspaceP provides two built-in layout strategies for child + windows: cascade() and tile(). Both are slots so you can easily + connect menu entries to them. + + If you want your users to be able to work with document windows + larger than the actual workspace, set the scrollBarsEnabled + property to TRUE. + + If the top-level window contains a menu bar and a document window + is maximised, QWorkspaceP moves the document window's minimize, + restore and close buttons from the document window's frame to the + workspace window's menu bar. It then inserts a window operations + menu at the far left of the menu bar. +*/ + +static bool inCaptionChange = FALSE; + +class QWorkspacePPrivate { +public: + QWorkspacePChild* active; + QPtrList windows; + QPtrList focus; + QPtrList icons; + QWorkspacePChild* maxWindow; + QRect maxRestore; + QGuardedPtr maxcontrols; + QGuardedPtr maxmenubar; + + int px; + int py; + QWidget *becomeActive; + QGuardedPtr maxtools; + QPopupMenu* popup; + QPopupMenu* toolPopup; + int menuId; + int controlId; + QString topCaption; + bool autoFocusChange; + + QScrollBar *vbar, *hbar; + QWidget *corner; + int yoffset, xoffset; +}; + +/*! + Constructs a workspace with a \a parent and a \a name. + */ +QWorkspaceP::QWorkspaceP( QWidget *parent, const char *name ) + : QWidget( parent, name, WNoMousePropagation ) +{ + d = new QWorkspacePPrivate; + d->maxcontrols = 0; + d->active = 0; + d->maxWindow = 0; + d->maxtools = 0; + d->px = 0; + d->py = 0; + d->becomeActive = 0; + d->autoFocusChange = FALSE; +#if defined(Q_WS_WIN) + d->popup = new QPopupMenu( this, "qt_internal_mdi_popup" ); + d->toolPopup = new QPopupMenu( this, "qt_internal_mdi_popup" ); +#else + d->popup = new QPopupMenu( parentWidget(), "qt_internal_mdi_popup" ); + d->toolPopup = new QPopupMenu( parentWidget(), "qt_internal_mdi_popup" ); +#endif + + d->menuId = -1; + d->controlId = -1; + connect( d->popup, SIGNAL( aboutToShow() ), this, SLOT(operationMenuAboutToShow() )); + connect( d->popup, SIGNAL( activated(int) ), this, SLOT( operationMenuActivated(int) ) ); + d->popup->insertItem(QIconSet(style().stylePixmap(QStyle::SP_TitleBarNormalButton)), tr("&Restore"), 1); + d->popup->insertItem(tr("&Move"), 2); + d->popup->insertItem(tr("&Size"), 3); + d->popup->insertItem(QIconSet(style().stylePixmap(QStyle::SP_TitleBarMinButton)), tr("Mi&nimize"), 4); + d->popup->insertItem(QIconSet(style().stylePixmap(QStyle::SP_TitleBarMaxButton)), tr("Ma&ximize"), 5); + d->popup->insertSeparator(); + d->popup->insertItem(QIconSet(style().stylePixmap(QStyle::SP_TitleBarCloseButton)), + tr("&Close") +#ifndef QT_NO_ACCEL + +"\t"+QAccel::keyToString(CTRL+Key_F4) +#endif + , this, SLOT( closeActiveWindow() ) ); + + connect( d->toolPopup, SIGNAL( aboutToShow() ), this, SLOT(toolMenuAboutToShow() )); + connect( d->toolPopup, SIGNAL( activated(int) ), this, SLOT( operationMenuActivated(int) ) ); + d->toolPopup->insertItem(tr("&Move"), 2); + d->toolPopup->insertItem(tr("&Size"), 3); + d->toolPopup->insertItem(tr("Stay on &Top"), 7); + d->toolPopup->setItemChecked( 7, TRUE ); + d->toolPopup->setCheckable( TRUE ); + d->toolPopup->insertSeparator(); + d->toolPopup->insertItem(QIconSet(style().stylePixmap(QStyle::SP_TitleBarShadeButton)), tr("Sh&ade"), 6); + d->toolPopup->insertItem(QIconSet(style().stylePixmap(QStyle::SP_TitleBarCloseButton)), + tr("&Close") +#ifndef QT_NO_ACCEL + +"\t"+QAccel::keyToString( CTRL+Key_F4) +#endif + , this, SLOT( closeActiveWindow() ) ); + +#ifndef QT_NO_ACCEL + QAccel* a = new QAccel( this ); + a->connectItem( a->insertItem( ALT + Key_Minus), + this, SLOT( showOperationMenu() ) ); + + a->connectItem( a->insertItem( CTRL + Key_F6), + this, SLOT( activateNextWindow() ) ); + a->connectItem( a->insertItem( CTRL + Key_Tab), + this, SLOT( activateNextWindow() ) ); + + a->connectItem( a->insertItem( CTRL + SHIFT + Key_F6), + this, SLOT( activatePreviousWindow() ) ); + a->connectItem( a->insertItem( CTRL + SHIFT + Key_Tab), + this, SLOT( activatePreviousWindow() ) ); + + a->connectItem( a->insertItem( CTRL + Key_F4 ), + this, SLOT( closeActiveWindow() ) ); +#endif + + setBackgroundMode( PaletteDark ); + setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + +#ifndef QT_NO_WIDGET_TOPEXTRA + d->topCaption = topLevelWidget()->caption(); +#endif + + d->hbar = d->vbar = 0; + d->corner = 0; + d->xoffset = d->yoffset = 0; + + updateWorkspace(); + + topLevelWidget()->installEventFilter( this ); +} + +/*! Destroys the workspace and frees any allocated resources. */ + +QWorkspaceP::~QWorkspaceP() +{ + delete d; + d = 0; +} + +/*!\reimp */ +QSize QWorkspaceP::sizeHint() const +{ + QSize s( QApplication::desktop()->size() ); + return QSize( s.width()*2/3, s.height()*2/3); +} + +/*! \reimp */ +void QWorkspaceP::setPaletteBackgroundColor( const QColor & c ) +{ + setEraseColor( c ); +} + + +/*! \reimp */ +void QWorkspaceP::setPaletteBackgroundPixmap( const QPixmap & pm ) +{ + setErasePixmap( pm ); +} + +/*! \reimp */ +void QWorkspaceP::childEvent( QChildEvent * e) +{ + if (e->inserted() && e->child()->isWidgetType()) { + QWidget* w = (QWidget*) e->child(); + if ( !w || !w->testWFlags( WStyle_Title | WStyle_NormalBorder | WStyle_DialogBorder ) + || d->icons.contains( w ) || w == d->vbar || w == d->hbar || w == d->corner ) + return; // nothing to do + + bool hasBeenHidden = w->isHidden(); + bool hasSize = w->testWState( WState_Resized ); + int x = w->x(); + int y = w->y(); + bool hasPos = x != 0 || y != 0; + QSize s = w->size().expandedTo( w->minimumSizeHint() ); + if ( !hasSize && w->sizeHint().isValid() ) + w->adjustSize(); + + QWorkspacePChild* child = new QWorkspacePChild( w, this, "qt_workspacechild" ); + child->installEventFilter( this ); + + connect( child, SIGNAL( popupOperationMenu( const QPoint& ) ), + this, SLOT( popupOperationMenu( const QPoint& ) ) ); + connect( child, SIGNAL( showOperationMenu() ), + this, SLOT( showOperationMenu() ) ); + d->windows.append( child ); + if ( child->isVisibleTo( this ) ) + d->focus.append( child ); + child->internalRaise(); + + if ( hasBeenHidden ) + w->hide(); + else if ( !isVisible() ) // that's a case were we don't receive a showEvent in time. Tricky. + child->show(); + + if ( !hasPos ) + place( child ); + if ( hasSize ) + child->resize( s + child->baseSize() ); + else + child->adjustSize(); + if ( hasPos ) + child->move( x, y ); + + activateWindow( w ); + updateWorkspace(); + } else if (e->removed() ) { + if ( d->windows.contains( (QWorkspacePChild*)e->child() ) ) { + d->windows.removeRef( (QWorkspacePChild*)e->child() ); + d->focus.removeRef( (QWorkspacePChild*)e->child() ); + if (d->windows.count() <= 0) { // VSR+ 26/03/03 --> + activateWindow( 0 ); + d->maxWindow = 0; + hideMaximizeControls(); + } // <-- VSR+ 26/03/03 + updateWorkspace(); + } + } +} + +/*! \reimp +*/ +#ifndef QT_NO_WHEELEVENT +void QWorkspaceP::wheelEvent( QWheelEvent *e ) +{ + if ( !scrollBarsEnabled() ) + return; + if ( d->vbar && d->vbar->isVisible() && !( e->state() & AltButton ) ) + QApplication::sendEvent( d->vbar, e ); + else if ( d->hbar && d->hbar->isVisible() ) + QApplication::sendEvent( d->hbar, e ); +} +#endif + +void QWorkspaceP::activateWindow( QWidget* w, bool change_focus ) +{ + if ( !w ) { + d->active = 0; + emit windowActivated( 0 ); + return; + } + if ( !isVisibleTo( 0 ) ) { + d->becomeActive = w; + return; + } + if ( d->active && d->active->windowWidget() == w ) + return; + QPtrListIterator it( d->windows ); + while ( it.current () ) { + QWorkspacePChild* c = it.current(); + ++it; + c->setActive( c->windowWidget() == w ); + if (c->windowWidget() == w) + d->active = c; + } + + if (!d->active) + return; + + if ( d->maxWindow && d->maxWindow != d->active && d->active->windowWidget() && + d->active->windowWidget()->testWFlags( WStyle_MinMax ) && + !d->active->windowWidget()->testWFlags( WStyle_Tool ) ) { + maximizeWindow( d->active->windowWidget() ); + if ( d->maxtools ) { +#ifndef QT_NO_WIDGET_TOPEXTRA + if ( w->icon() ) { + QPixmap pm(*w->icon()); + if(pm.width() != 14 || pm.height() != 14) { + QImage im; + im = pm; + pm = im.smoothScale( 14, 14 ); + } + d->maxtools->setPixmap( pm ); + } else +#endif + { + QPixmap pm(14,14); + pm.fill( white ); + d->maxtools->setPixmap( pm ); + } + } + } + + d->active->internalRaise(); + + if ( change_focus ) { + if ( d->focus.find( d->active ) >=0 ) { + d->focus.removeRef( d->active ); +// d->focus.append( d->active ); //VSR- + } + d->focus.append( d->active ); //VSR+ + } + + updateWorkspace(); + emit windowActivated( w ); +} + + +/*! + Returns the active window, or 0 if no window is active. + */ +QWidget* QWorkspaceP::activeWindow() const +{ + return d->active?d->active->windowWidget():0; +} + + +void QWorkspaceP::place( QWidget* w) +{ + int overlap, minOverlap = 0; + int possible; + + QRect r1(0, 0, 0, 0); + QRect r2(0, 0, 0, 0); + QRect maxRect = rect(); + int x = maxRect.left(), y = maxRect.top(); + QPoint wpos(maxRect.left(), maxRect.top()); + + bool firstPass = TRUE; + + do { + if ( y + w->height() > maxRect.bottom() ) { + overlap = -1; + } else if( x + w->width() > maxRect.right() ) { + overlap = -2; + } else { + overlap = 0; + + r1.setRect(x, y, w->width(), w->height()); + + QWidget *l; + QPtrListIterator it( d->windows ); + while ( it.current () ) { + l = it.current(); + ++it; + if (! d->icons.contains(l) && ! l->isHidden() && l != w ) { + if ( d->maxWindow == l ) + r2 = d->maxRestore; + else + r2.setRect(l->x(), l->y(), l->width(), l->height()); + + if (r2.intersects(r1)) { + r2.setCoords(QMAX(r1.left(), r2.left()), + QMAX(r1.top(), r2.top()), + QMIN(r1.right(), r2.right()), + QMIN(r1.bottom(), r2.bottom()) + ); + + overlap += (r2.right() - r2.left()) * + (r2.bottom() - r2.top()); + } + } + } + } + + if (overlap == 0) { + wpos = QPoint(x, y); + break; + } + + if (firstPass) { + firstPass = FALSE; + minOverlap = overlap; + } else if ( overlap >= 0 && overlap < minOverlap) { + minOverlap = overlap; + wpos = QPoint(x, y); + } + + if ( overlap > 0 ) { + possible = maxRect.right(); + if ( possible - w->width() > x) possible -= w->width(); + + QWidget *l; + QPtrListIterator it( d->windows ); + while ( it.current () ) { + l = it.current(); + ++it; + if (! d->icons.contains(l) && ! l->isHidden() && l != w ) { + if ( d->maxWindow == l ) + r2 = d->maxRestore; + else + r2.setRect(l->x(), l->y(), l->width(), l->height()); + + if( ( y < r2.bottom() ) && ( r2.top() < w->height() + y ) ) { + if( r2.right() > x ) + possible = possible < r2.right() ? + possible : r2.right(); + + if( r2.left() - w->width() > x ) + possible = possible < r2.left() - w->width() ? + possible : r2.left() - w->width(); + } + } + } + + x = possible; + } else if ( overlap == -2 ) { + x = maxRect.left(); + possible = maxRect.bottom(); + + if ( possible - w->height() > y ) possible -= w->height(); + + QWidget *l; + QPtrListIterator it( d->windows ); + while ( it.current () ) { + l = it.current(); + ++it; + if (l != w && ! d->icons.contains(w)) { + if ( d->maxWindow == l ) + r2 = d->maxRestore; + else + r2.setRect(l->x(), l->y(), l->width(), l->height()); + + if( r2.bottom() > y) + possible = possible < r2.bottom() ? + possible : r2.bottom(); + + if( r2.top() - w->height() > y ) + possible = possible < r2.top() - w->height() ? + possible : r2.top() - w->height(); + } + } + + y = possible; + } + } + while( overlap != 0 && overlap != -1 ); + + w->move(wpos); + updateWorkspace(); +} + + +void QWorkspaceP::insertIcon( QWidget* w ) +{ + if ( !w || d->icons.contains( w ) ) + return; + d->icons.append( w ); + if (w->parentWidget() != this ) + w->reparent( this, 0, QPoint(0,0), FALSE); + + + QRect cr = updateWorkspace(); + int x = 0; + int y = cr.height() - w->height(); + + QPtrListIterator it( d->icons ); + while ( it.current () ) { + QWidget* i = it.current(); + ++it; + if ( x > 0 && x + i->width() > cr.width() ){ + x = 0; + y -= i->height(); + } + + if ( i != w && + i->geometry().intersects( QRect( x, y, w->width(), w->height() ) ) ) + x += i->width(); + } + w->move( x, y ); + + if ( isVisibleTo( parentWidget() ) ) { + w->show(); + w->lower(); + } + updateWorkspace(); +} + + +void QWorkspaceP::removeIcon( QWidget* w) +{ + if ( !d->icons.contains( w ) ) + return; + d->icons.remove( w ); + w->hide(); +} + + +/*! \reimp */ +void QWorkspaceP::resizeEvent( QResizeEvent * ) +{ + if ( d->maxWindow ) { + d->maxWindow->adjustToFullscreen(); + ((QWorkspaceP*)d->maxWindow->windowWidget())->setWState( WState_Maximized ); + } + + QRect cr = updateWorkspace(); + + QPtrListIterator it( d->windows ); + while ( it.current () ) { + QWorkspacePChild* c = it.current(); + ++it; + if ( c->windowWidget() && !c->windowWidget()->testWFlags( WStyle_Tool ) ) + continue; + + int x = c->x(); + int y = c->y(); + if ( c->snappedDown ) + y = cr.height() - c->height(); + if ( c->snappedRight ) + x = cr.width() - c->width(); + + if ( x != c->x() || y != c->y() ) + c->move( x, y ); + } + +} + +/*! \reimp */ +void QWorkspaceP::showEvent( QShowEvent *e ) +{ + if ( d->maxWindow && !style().styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, this)) + showMaximizeControls(); + QWidget::showEvent( e ); + if ( d->becomeActive ) { + activateWindow( d->becomeActive ); + d->becomeActive = 0; + } + else if ( d->windows.count() > 0 && !d->active ) + activateWindow( d->windows.first()->windowWidget() ); + + updateWorkspace(); +} + +/*! \reimp */ +void QWorkspaceP::hideEvent( QHideEvent * ) +{ + + if ( !isVisibleTo(0) && !style().styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, this)) + hideMaximizeControls(); +} + +void QWorkspaceP::minimizeWindow( QWidget* w) +{ + QWorkspacePChild* c = findChild( w ); + QWorkspacePChild* oldActive = d->active; //VSR+ + + if ( !w || w && (!w->testWFlags( WStyle_Minimize ) || w->testWFlags( WStyle_Tool) ) ) + return; + + if ( c ) { + QWorkspaceP *fake = (QWorkspaceP*)w; + + setUpdatesEnabled( FALSE ); + bool wasMax = FALSE; + if ( c == d->maxWindow ) { + wasMax = TRUE; + d->maxWindow = 0; + inCaptionChange = TRUE; +#ifndef QT_NO_WIDGET_TOPEXTRA + if ( !!d->topCaption ) + topLevelWidget()->setCaption( d->topCaption ); +#endif + inCaptionChange = FALSE; + if ( !style().styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, this) ) + hideMaximizeControls(); + for (QPtrListIterator it( d->windows ); it.current(); ++it ) { + QWorkspacePChild* c = it.current(); + if ( c->titlebar ) + c->titlebar->setMovable( TRUE ); + c->widgetResizeHandler->setActive( TRUE ); + } + } + insertIcon( c->iconWidget() ); + bool wasFocused = c->titlebar->isActive(); + blockSignals( TRUE );//VSR+ + c->hide(); + blockSignals( FALSE );//VSR+ + if ( wasFocused && ( !d->active || d->active && d->active->testWState( WState_Minimized ) ) ) { //VSR+ +// if ( wasFocused && d->active && d->active->testWState( WState_Minimized ) ) { //VSR- +//VSR- blockSignals( TRUE ); + activateWindow( w, FALSE ); +//VSR- blockSignals( FALSE ); + } + else if ( oldActive != d->active ) { //VSR+ + emit ( windowActivated( d->active ? d->active->windowWidget() : 0 ) ); //VSR+ + } //VSR+ + if ( wasMax ) + c->setGeometry( d->maxRestore ); + if ( d->focus.find( c ) < 0 ) // VSR+ + d->focus.append( c ); + + setUpdatesEnabled( TRUE ); + updateWorkspace(); + + fake->clearWState( WState_Maximized ); + fake->setWState( WState_Minimized ); + c->clearWState( WState_Maximized ); + c->setWState( WState_Minimized ); + } +} + +void QWorkspaceP::normalizeWindow( QWidget* w) +{ + QWorkspacePChild* c = findChild( w ); + if ( !w ) + return; + if ( c ) { + QWorkspaceP *fake = (QWorkspaceP*)w; + fake->clearWState( WState_Minimized | WState_Maximized ); + if ( !style().styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, this) && d->maxWindow ) { + hideMaximizeControls(); + } else { + c->widgetResizeHandler->setActive( TRUE ); + if ( c->titlebar ) + c->titlebar->setMovable(TRUE); + } + fake->clearWState( WState_Minimized | WState_Maximized ); + c->clearWState( WState_Minimized | WState_Maximized ); + + if ( c == d->maxWindow ) { + c->setGeometry( d->maxRestore ); + d->maxWindow = 0; +#ifndef QT_NO_WIDGET_TOPEXTRA + inCaptionChange = TRUE; + if ( !!d->topCaption ) + topLevelWidget()->setCaption( d->topCaption ); + inCaptionChange = FALSE; +#endif + } else { + if ( c->iconw ) + removeIcon( c->iconw->parentWidget() ); + c->show(); + } + + if ( !style().styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, this)) + hideMaximizeControls(); + for (QPtrListIterator it( d->windows ); it.current(); ++it ) { + QWorkspacePChild* c = it.current(); + if ( c->titlebar ) + c->titlebar->setMovable( TRUE ); + c->widgetResizeHandler->setActive( TRUE ); + } + activateWindow( w, TRUE ); + + updateWorkspace(); + } +} + +void QWorkspaceP::maximizeWindow( QWidget* w) +{ + QWorkspacePChild* c = findChild( w ); + + if ( !w || w && (!w->testWFlags( WStyle_Maximize ) || w->testWFlags( WStyle_Tool) ) ) + return; + if ( w->maximumSize().isValid() && ( w->maximumWidth() < width() || w->maximumHeight() < height() ) ) { + w->resize( w->maximumSize() ); + return; + } + + if ( c ) { + setUpdatesEnabled( FALSE ); + if (c->iconw && d->icons.contains( c->iconw->parentWidget() ) ) + normalizeWindow( w ); + QWorkspaceP *fake = (QWorkspaceP*)w; + + QRect r( c->geometry() ); + c->adjustToFullscreen(); + c->show(); + c->internalRaise(); + qApp->sendPostedEvents( c, QEvent::Resize ); + qApp->sendPostedEvents( c, QEvent::Move ); + qApp->sendPostedEvents( c, QEvent::ShowWindowRequest ); + if ( d->maxWindow != c ) { + if ( d->maxWindow ) + d->maxWindow->setGeometry( d->maxRestore ); + d->maxWindow = c; + d->maxRestore = r; + } + + activateWindow( w ); + if(!style().styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, this)) { + showMaximizeControls(); + } else { + c->widgetResizeHandler->setActive( FALSE ); + if ( c->titlebar ) + c->titlebar->setMovable( FALSE ); + } +#ifndef QT_NO_WIDGET_TOPEXTRA + inCaptionChange = TRUE; + if ( !!d->topCaption ) + topLevelWidget()->setCaption( tr("%1 - [%2]") + .arg(d->topCaption).arg(c->caption()) ); + inCaptionChange = FALSE; +#endif + setUpdatesEnabled( TRUE ); + + updateWorkspace(); + + fake->clearWState( WState_Minimized ); + fake->setWState( WState_Maximized ); + c->clearWState( WState_Minimized ); + c->setWState( WState_Maximized ); + } +} + +void QWorkspaceP::showWindow( QWidget* w) +{ + if ( d->maxWindow && w->testWFlags( WStyle_Maximize ) && !w->testWFlags( WStyle_Tool) ) + maximizeWindow( w ); + else if ( !w->testWFlags( WStyle_Tool ) ) + normalizeWindow( w ); + else + w->parentWidget()->show(); + if ( d->maxWindow ) + d->maxWindow->raise(); + updateWorkspace(); +} + + +QWorkspacePChild* QWorkspaceP::findChild( QWidget* w) +{ + QPtrListIterator it( d->windows ); + while ( it.current () ) { + QWorkspacePChild* c = it.current(); + ++it; + if (c->windowWidget() == w) + return c; + } + return 0; +} + +/*! + Returns a list of all windows. + */ +QWidgetList QWorkspaceP::windowList() const +{ + QWidgetList windows; + QPtrListIterator it( d->windows ); + while ( it.current () ) { + QWorkspacePChild* c = it.current(); + ++it; + if ( c->windowWidget() ) + windows.append( c->windowWidget() ); + } + return windows; +} + +/*!\reimp*/ +bool QWorkspaceP::eventFilter( QObject *o, QEvent * e) +{ + static QTime* t = 0; + static QWorkspaceP* tc = 0; +#ifndef QT_NO_MENUBAR + if ( o == d->maxtools && d->menuId != -1 ) { + switch ( e->type() ) { + case QEvent::MouseButtonPress: + { + QMenuBar* b = (QMenuBar*)o->parent(); + if ( !t ) + t = new QTime; + if ( tc != this || t->elapsed() > QApplication::doubleClickInterval() ) { + if ( QApplication::reverseLayout() ) { + QPoint p = b->mapToGlobal( QPoint( b->x() + b->width(), b->y() + b->height() ) ); + p.rx() -= d->popup->sizeHint().width(); + popupOperationMenu( p ); + } else { + popupOperationMenu( b->mapToGlobal( QPoint( b->x(), b->y() + b->height() ) ) ); + } + t->start(); + tc = this; + } else { + tc = 0; + closeActiveWindow(); + } + return TRUE; + } + default: + break; + } + return QWidget::eventFilter( o, e ); + } +#endif + switch ( e->type() ) { + case QEvent::Hide: + case QEvent::HideToParent: + if ( !o->isA( "QWorkspacePChild" ) || !isVisible() ) + break; + d->focus.removeRef( (QWorkspacePChild*)o ); + if ( d->active != o ) + break; + if ( d->focus.isEmpty() ) { + activateWindow( 0 ); + } else { + d->autoFocusChange = TRUE; + activatePreviousWindow(); + QWorkspacePChild* c = d->active; + while ( d->active && + d->active->windowWidget() && + d->active->windowWidget()->testWFlags( WStyle_Tool ) ) { + activatePreviousWindow(); + if ( d->active == c ) + break; + } + d->autoFocusChange = FALSE; + } + if ( d->maxWindow == o && d->maxWindow->isHidden() ) { + d->maxWindow->setGeometry( d->maxRestore ); + d->maxWindow = 0; + if ( d->active ) + maximizeWindow( d->active ); + + if ( !d->maxWindow ) { + + if ( style().styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, this)) { + QWorkspacePChild *wc = (QWorkspacePChild *)o; + wc->widgetResizeHandler->setActive( TRUE ); + if ( wc->titlebar ) + wc->titlebar->setMovable( TRUE ); + } else { + hideMaximizeControls(); + } +#ifndef QT_NO_WIDGET_TOPEXTRA + inCaptionChange = TRUE; + if ( !!d->topCaption ) + topLevelWidget()->setCaption( d->topCaption ); + inCaptionChange = FALSE; +#endif + } + } + break; + case QEvent::Show: + if ( o->isA("QWorkspacePChild") && !d->focus.containsRef( (QWorkspacePChild*)o ) ) + d->focus.append( (QWorkspacePChild*)o ); + updateWorkspace(); + break; + case QEvent::CaptionChange: + if ( inCaptionChange ) + break; + +#ifndef QT_NO_WIDGET_TOPEXTRA + inCaptionChange = TRUE; + if ( o == topLevelWidget() ) + d->topCaption = ((QWidget*)o)->caption(); + + if ( d->maxWindow && !!d->topCaption ) + topLevelWidget()->setCaption( tr("%1 - [%2]") + .arg(d->topCaption).arg(d->maxWindow->caption())); + inCaptionChange = FALSE; +#endif + + break; + case QEvent::Close: + if ( o == topLevelWidget() ) + { + QPtrListIterator it( d->windows ); + while ( it.current () ) { + QWorkspacePChild* c = it.current(); + ++it; + if ( c->shademode ) + c->showShaded(); + } + } else if ( o->inherits("QWorkspacePChild") ) { + d->popup->hide(); + } + if ( d->windows.count() > 1 || d->windows.first() && d->active != d->windows.first() ) + activatePreviousWindow(); + updateWorkspace(); + break; + default: + break; + } + return QWidget::eventFilter( o, e); +} + +void QWorkspaceP::showMaximizeControls() +{ +#ifndef QT_NO_MENUBAR + Q_ASSERT(d->maxWindow); + QMenuBar* b = 0; + + // Do a breadth-first search first on every parent, + QWidget* w = parentWidget(); + QObjectList * l = 0; + while ( !l && w ) { + l = w->queryList( "QMenuBar", 0, FALSE, FALSE ); + w = w->parentWidget(); + if ( l && !l->count() ) { + delete l; + l = 0; + } + } + + // and query recursively if nothing is found. + if ( !l || !l->count() ) { + if ( l ) + delete l; + l = topLevelWidget()->queryList( "QMenuBar", 0, 0, TRUE ); + } + if ( l && l->count() ) + b = (QMenuBar *)l->first(); + delete l; + + if ( !b ) + return; + + if ( !d->maxcontrols ) { + d->maxmenubar = b; + d->maxcontrols = new QFrame( topLevelWidget(), "qt_maxcontrols" ); + QHBoxLayout* l = new QHBoxLayout( d->maxcontrols, + d->maxcontrols->frameWidth(), 0 ); + if ( d->maxWindow->windowWidget()->testWFlags(WStyle_Minimize) ) { + QToolButton* iconB = new QToolButton( d->maxcontrols, "iconify" ); +#ifndef QT_NO_TOOLTIP + QToolTip::add( iconB, tr( "Minimize" ) ); +#endif + l->addWidget( iconB ); + iconB->setFocusPolicy( NoFocus ); + iconB->setIconSet(style().stylePixmap(QStyle::SP_TitleBarMinButton)); + iconB->setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT); + connect( iconB, SIGNAL( clicked() ), + this, SLOT( minimizeActiveWindow() ) ); + } + + QToolButton* restoreB = new QToolButton( d->maxcontrols, "restore" ); +#ifndef QT_NO_TOOLTIP + QToolTip::add( restoreB, tr( "Restore Down" ) ); +#endif + l->addWidget( restoreB ); + restoreB->setFocusPolicy( NoFocus ); + restoreB->setIconSet( style().stylePixmap(QStyle::SP_TitleBarNormalButton)); + restoreB->setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT); + connect( restoreB, SIGNAL( clicked() ), + this, SLOT( normalizeActiveWindow() ) ); + + l->addSpacing( 2 ); + QToolButton* closeB = new QToolButton( d->maxcontrols, "close" ); +#ifndef QT_NO_TOOLTIP + QToolTip::add( closeB, tr( "Close" ) ); +#endif + l->addWidget( closeB ); + closeB->setFocusPolicy( NoFocus ); + closeB->setIconSet( style().stylePixmap(QStyle::SP_TitleBarCloseButton) ); + closeB->setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT); + connect( closeB, SIGNAL( clicked() ), + this, SLOT( closeActiveWindow() ) ); + + d->maxcontrols->setFixedSize( d->maxcontrols->minimumSizeHint() ); + } + + if ( d->controlId == -1 || b->indexOf( d->controlId ) == -1 ) { + QFrame* dmaxcontrols = d->maxcontrols; + d->controlId = b->insertItem( dmaxcontrols, -1, b->count() ); + } + if ( d->active && ( d->menuId == -1 || b->indexOf( d->menuId ) == -1 ) ) { + if ( !d->maxtools ) { + d->maxtools = new QLabel( topLevelWidget(), "qt_maxtools" ); + d->maxtools->installEventFilter( this ); + } +#ifndef QT_NO_WIDGET_TOPEXTRA + if ( d->active->windowWidget() && d->active->windowWidget()->icon() ) { + QPixmap pm(*d->active->windowWidget()->icon()); + if(pm.width() != 14 || pm.height() != 14) { + QImage im; + im = pm; + pm = im.smoothScale( 14, 14 ); + } + d->maxtools->setPixmap( pm ); + } else +#endif + { + QPixmap pm(14,14); + pm.fill( white ); + d->maxtools->setPixmap( pm ); + } + d->menuId = b->insertItem( d->maxtools, -1, 0 ); + } +#endif +} + + +void QWorkspaceP::hideMaximizeControls() +{ +#ifndef QT_NO_MENUBAR + if ( d->maxmenubar ) { + int mi = d->menuId; + if ( mi != -1 ) { + if ( d->maxmenubar->indexOf( mi ) != -1 ) + d->maxmenubar->removeItem( mi ); + d->maxtools = 0; + } + int ci = d->controlId; + if ( ci != -1 && d->maxmenubar->indexOf( ci ) != -1 ) + d->maxmenubar->removeItem( ci ); + } + d->maxcontrols = 0; + d->menuId = -1; + d->controlId = -1; +#endif +} + +void QWorkspaceP::closeActiveWindow() +{ + setUpdatesEnabled( FALSE ); + if ( d->maxWindow && d->maxWindow->windowWidget() ) + d->maxWindow->windowWidget()->close(); + else if ( d->active && d->active->windowWidget() ) + d->active->windowWidget()->close(); + setUpdatesEnabled( TRUE ); + updateWorkspace(); +} + +void QWorkspaceP::closeAllWindows() +{ + QPtrListIterator it( d->windows ); + QWorkspacePChild *c = 0; + while ( ( c = it.current() ) != 0 ) { + ++it; + if ( c->windowWidget() ) + c->windowWidget()->close(); + } +} + +void QWorkspaceP::normalizeActiveWindow() +{ + if ( d->maxWindow ) + d->maxWindow->showNormal(); + else if ( d->active ) + d->active->showNormal(); +} + +void QWorkspaceP::minimizeActiveWindow() +{ + if ( d->maxWindow ) + d->maxWindow->showMinimized(); + else if ( d->active ) + d->active->showMinimized(); +} + +void QWorkspaceP::showOperationMenu() +{ + if ( !d->active || !d->active->windowWidget() ) + return; + Q_ASSERT( d->active->windowWidget()->testWFlags( WStyle_SysMenu ) ); + QPoint p; + QPopupMenu *popup = d->active->windowWidget()->testWFlags( WStyle_Tool ) ? d->toolPopup : d->popup; + if ( QApplication::reverseLayout() ) { + p = QPoint( d->active->windowWidget()->mapToGlobal( QPoint(d->active->windowWidget()->width(),0) ) ); + p.rx() -= popup->sizeHint().width(); + } else { + p = QPoint( d->active->windowWidget()->mapToGlobal( QPoint(0,0) ) ); + } + if ( !d->active->isVisible() ) { + p = d->active->iconWidget()->mapToGlobal( QPoint(0,0) ); + p.ry() -= popup->sizeHint().height(); + } + popupOperationMenu( p ); +} + +void QWorkspaceP::popupOperationMenu( const QPoint& p) +{ + if ( !d->active || !d->active->windowWidget() || !d->active->windowWidget()->testWFlags( WStyle_SysMenu ) ) + return; + if ( d->active->windowWidget()->testWFlags( WStyle_Tool )) + d->toolPopup->popup( p ); + else + d->popup->popup( p ); +} + +void QWorkspaceP::operationMenuAboutToShow() +{ + for ( int i = 1; i < 6; i++ ) { + bool enable = d->active != 0; + d->popup->setItemEnabled( i, enable ); + } + + if ( !d->active || !d->active->windowWidget() ) + return; + + d->popup->setItemEnabled( 4, d->active->windowWidget()->testWFlags( WStyle_Minimize ) ); + d->popup->setItemEnabled( 5, d->active->windowWidget()->testWFlags( WStyle_Maximize ) ); + + if ( d->active == d->maxWindow ) { + d->popup->setItemEnabled( 2, FALSE ); + d->popup->setItemEnabled( 3, FALSE ); + d->popup->setItemEnabled( 5, FALSE ); + } else if ( d->active->isVisible() ){ + d->popup->setItemEnabled( 1, FALSE ); + } else { + d->popup->setItemEnabled( 2, FALSE ); + d->popup->setItemEnabled( 3, FALSE ); + d->popup->setItemEnabled( 4, FALSE ); + } +} + +void QWorkspaceP::toolMenuAboutToShow() +{ + if ( !d->active || !d->active->windowWidget() ) + return; + + d->toolPopup->setItemEnabled( 3, !d->active->shademode ); + if ( d->active->shademode ) + d->toolPopup->changeItem( 6, + QIconSet(style().stylePixmap(QStyle::SP_TitleBarUnshadeButton)), tr("&Unshade") ); + else + d->toolPopup->changeItem( 6, QIconSet(style().stylePixmap(QStyle::SP_TitleBarShadeButton)), tr("Sh&ade") ); + d->toolPopup->setItemEnabled( 6, d->active->windowWidget()->testWFlags( WStyle_MinMax ) ); + d->toolPopup->setItemChecked( 7, d->active->windowWidget()->testWFlags( WStyle_StaysOnTop ) ); +} + +void QWorkspaceP::operationMenuActivated( int a ) +{ + if ( !d->active ) + return; + switch ( a ) { + case 1: + d->active->showNormal(); + break; + case 2: + d->active->doMove(); + break; + case 3: + if ( d->active->shademode ) + d->active->showShaded(); + d->active->doResize(); + break; + case 4: + d->active->showMinimized(); + break; + case 5: + d->active->showMaximized(); + break; + case 6: + d->active->showShaded(); + break; + case 7: + { + QWorkspaceP* w = (QWorkspaceP*)d->active->windowWidget(); + if ( !w ) + break; + if ( w->testWFlags( WStyle_StaysOnTop ) ) { + w->clearWFlags( WStyle_StaysOnTop ); + } else { + w->setWFlags( WStyle_StaysOnTop ); + w->parentWidget()->raise(); + } + } + break; + default: + break; + } +} + +void QWorkspaceP::activateNextWindow() +{ + if ( d->focus.isEmpty() ) + return; + if ( !d->active ) { + if ( d->focus.first() ) + activateWindow( d->focus.first()->windowWidget(), FALSE ); + return; + } + + int a = d->focus.find( d->active ) + 1; + + a = a % d->focus.count(); + + if ( d->focus.at( a ) ) + activateWindow( d->focus.at( a )->windowWidget(), FALSE ); + else + d->active = 0; +} + +void QWorkspaceP::activatePreviousWindow() +{ + if ( d->focus.isEmpty() ) { + if ( d->windows.count() > 0 ) { //VSR+ + activateWindow( d->windows.last()->windowWidget() ); //VSR+ + } //VSR+ + return; + } + if ( !d->active ) { + if ( d->focus.last() ) + activateWindow( d->focus.first()->windowWidget(), FALSE ); + else + activateWindow( 0 ); + + return; + } + + int a = d->focus.find( d->active ) - 1; + + if ( a < 0 ) + a = d->focus.count()-1; + + if ( d->autoFocusChange ) { + QWidget *widget = 0; + while ( a >= 0 && d->focus.at( a ) && ( widget = d->focus.at( a )->windowWidget() ) && !widget->isVisible() ) + a--; + if ( a < 0 ) + a = d->focus.count() - 1; + } + + if ( d->focus.at( a ) ) + activateWindow( d->focus.at( a )->windowWidget(), FALSE ); + else + activateWindow( 0 ); +} + + +/*! + \fn void QWorkspaceP::windowActivated( QWidget* w ) + + This signal is emitted when the window widget \a w becomes active. + Note that \a w can be null, and that more than one signal may be + fired for one activation event. + + \sa activeWindow(), windowList() +*/ + + + +/*! + Arranges all child windows in a cascade pattern. + + \sa tile() + */ +void QWorkspaceP::cascade() +{ + if ( d->maxWindow ) + d->maxWindow->showNormal(); + + if ( d->vbar ) { + d->vbar->blockSignals( TRUE ); + d->vbar->setValue( 0 ); + d->vbar->blockSignals( FALSE ); + d->hbar->blockSignals( TRUE ); + d->hbar->setValue( 0 ); + d->hbar->blockSignals( FALSE ); + scrollBarChanged(); + } + + const int xoffset = 13; + const int yoffset = 20; + + // make a list of all relevant mdi clients + QPtrList widgets; + QWorkspacePChild* wc = 0; + for ( wc = d->windows.first(); wc; wc = d->windows.next() ) + if ( wc->iconw ) + normalizeWindow( wc->windowWidget() ); + for ( wc = d->focus.first(); wc; wc = d->focus.next() ) + if ( wc->windowWidget()->isVisibleTo( this ) && !wc->windowWidget()->testWFlags( WStyle_Tool ) ) + widgets.append( wc ); + + int x = 0; + int y = 0; + + setUpdatesEnabled( FALSE ); + QPtrListIterator it( widgets ); + int children = d->windows.count() - 1; + while ( it.current () ) { + QWorkspacePChild *child = it.current(); + ++it; + child->setUpdatesEnabled( FALSE ); + bool hasSizeHint = FALSE; + QSize prefSize = child->windowWidget()->sizeHint().expandedTo( child->windowWidget()->minimumSizeHint() ); + + if ( !prefSize.isValid() ) + prefSize = QSize( width() - children * xoffset, height() - children * yoffset ); + else + hasSizeHint = TRUE; + prefSize = prefSize.expandedTo( child->windowWidget()->minimumSize() ).boundedTo( child->windowWidget()->maximumSize() ); + if ( hasSizeHint ) + prefSize += QSize( child->baseSize().width(), child->baseSize().height() ); + + int w = prefSize.width(); + int h = prefSize.height(); + + child->showNormal(); + qApp->sendPostedEvents( 0, QEvent::ShowNormal ); + if ( y + h > height() ) + y = 0; + if ( x + w > width() ) + x = 0; + child->setGeometry( x, y, w, h ); + x += xoffset; + y += yoffset; + child->internalRaise(); + child->setUpdatesEnabled( TRUE ); + } + setUpdatesEnabled( TRUE ); + updateWorkspace(); +} + +/*! + Arranges all child windows in a tile pattern. + + \sa cascade() + */ +void QWorkspaceP::tile() +{ + if ( d->maxWindow ) + d->maxWindow->showNormal(); + + if ( d->vbar ) { + d->vbar->blockSignals( TRUE ); + d->vbar->setValue( 0 ); + d->vbar->blockSignals( FALSE ); + d->hbar->blockSignals( TRUE ); + d->hbar->setValue( 0 ); + d->hbar->blockSignals( FALSE ); + scrollBarChanged(); + } + + int rows = 1; + int cols = 1; + int n = 0; + QWorkspacePChild* c; + + QPtrListIterator it( d->windows ); + while ( it.current () ) { + c = it.current(); + ++it; + if ( !c->windowWidget()->isHidden() && + !c->windowWidget()->testWFlags( WStyle_StaysOnTop ) && + !c->windowWidget()->testWFlags( WStyle_Tool ) ) + n++; + } + + while ( rows * cols < n ) { + if ( cols <= rows ) + cols++; + else + rows++; + } + int add = cols * rows - n; + bool* used = new bool[ cols*rows ]; + for ( int i = 0; i < rows*cols; i++ ) + used[i] = FALSE; + + int row = 0; + int col = 0; + int w = width() / cols; + int h = height() / rows; + + it.toFirst(); + while ( it.current () ) { + c = it.current(); + ++it; + if ( c->windowWidget()->isHidden() || c->windowWidget()->testWFlags( WStyle_Tool ) ) + continue; + if ( c->windowWidget()->testWFlags( WStyle_StaysOnTop ) ) { + QPoint p = c->pos(); + if ( p.x()+c->width() < 0 ) + p.setX( 0 ); + if ( p.x() > width() ) + p.setX( width() - c->width() ); + if ( p.y() + 10 < 0 ) + p.setY( 0 ); + if ( p.y() > height() ) + p.setY( height() - c->height() ); + + + if ( p != c->pos() ) + c->QFrame::move( p ); + } else { + c->showNormal(); + qApp->sendPostedEvents( 0, QEvent::ShowNormal ); + used[row*cols+col] = TRUE; + if ( add ) { + c->setGeometry( col*w, row*h, QMIN( w, c->windowWidget()->maximumWidth()+c->baseSize().width() ), + QMIN( 2*h, c->windowWidget()->maximumHeight()+c->baseSize().height() ) ); + used[(row+1)*cols+col] = TRUE; + add--; + } else { + c->setGeometry( col*w, row*h, QMIN( w, c->windowWidget()->maximumWidth()+c->baseSize().width() ), + QMIN( h, c->windowWidget()->maximumHeight()+c->baseSize().height() ) ); + } + while( row < rows && col < cols && used[row*cols+col] ) { + col++; + if ( col == cols ) { + col = 0; + row++; + } + } + } + } + delete [] used; + updateWorkspace(); +} + +QWorkspacePChild::QWorkspacePChild( QWidget* window, QWorkspaceP *parent, + const char *name ) + : QFrame( parent, name, + WStyle_Customize | WStyle_NoBorder | WDestructiveClose | WNoMousePropagation | WSubWindow ) +{ + setMouseTracking( TRUE ); + act = FALSE; + iconw = 0; + lastfocusw = 0; + shademode = FALSE; + titlebar = 0; + snappedRight = FALSE; + snappedDown = FALSE; + + if (window) { + switch (window->focusPolicy()) { + case QWidget::NoFocus: + window->setFocusPolicy(QWidget::ClickFocus); + break; + case QWidget::TabFocus: + window->setFocusPolicy(QWidget::StrongFocus); + break; + default: + break; + } + } + + if ( window && window->testWFlags( WStyle_Title ) ) { + titlebar = new QTitleBarP( window, this, "qt_ws_titlebar" ); + connect( titlebar, SIGNAL( doActivate() ), + this, SLOT( activate() ) ); + connect( titlebar, SIGNAL( doClose() ), + window, SLOT( close() ) ); + connect( titlebar, SIGNAL( doMinimize() ), + this, SLOT( showMinimized() ) ); + connect( titlebar, SIGNAL( doNormal() ), + this, SLOT( showNormal() ) ); + connect( titlebar, SIGNAL( doMaximize() ), + this, SLOT( showMaximized() ) ); + connect( titlebar, SIGNAL( popupOperationMenu( const QPoint& ) ), + this, SIGNAL( popupOperationMenu( const QPoint& ) ) ); + connect( titlebar, SIGNAL( showOperationMenu() ), + this, SIGNAL( showOperationMenu() ) ); + connect( titlebar, SIGNAL( doShade() ), + this, SLOT( showShaded() ) ); + connect( titlebar, SIGNAL( doubleClicked() ), + this, SLOT( titleBarDoubleClicked() ) ); + } + + if ( window && window->testWFlags( WStyle_Tool ) ) { + setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); + setLineWidth( 2 ); + setMinimumSize( 128, 0 ); + } else { + setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); + setLineWidth( 2 ); + setMinimumSize( 128, 0 ); + } + + childWidget = window; + if (!childWidget) + return; + +#ifndef QT_NO_WIDGET_TOPEXTRA + setCaption( childWidget->caption() ); +#endif + + QPoint p; + QSize s; + QSize cs; + + bool hasBeenResized = childWidget->testWState( WState_Resized ); + + if ( !hasBeenResized ) + cs = childWidget->sizeHint().expandedTo( childWidget->minimumSizeHint() ); + else + cs = childWidget->size(); + + int th = titlebar ? titlebar->sizeHint().height() : 0; + if ( titlebar ) { +#ifndef QT_NO_WIDGET_TOPEXTRA + if( childWidget->icon() ) { + QPixmap pm(*childWidget->icon()); + if(pm.width() != 14 || pm.height() != 14) { + QImage im; + im = pm; + pm = im.smoothScale( 14, 14 ); + } + titlebar->setIcon( pm ); + } +#endif + p = QPoint( contentsRect().x(), + th + contentsRect().y() ); + s = QSize( cs.width() + 2*frameWidth(), + cs.height() + 2*frameWidth() + th + 2 ); + } else { + p = QPoint( contentsRect().x(), contentsRect().y() ); + s = QSize( cs.width() + 2*frameWidth(), + cs.height() + 2*frameWidth() ); + } + + childWidget->reparent( this, p); + resize( s ); + + childWidget->installEventFilter( this ); + + widgetResizeHandler = new QWidgetResizeHandlerP( this, window ); + widgetResizeHandler->setMovingEnabled( FALSE ); + widgetResizeHandler->setSizeProtection( !parent->scrollBarsEnabled() ); + connect( widgetResizeHandler, SIGNAL( activate() ), + this, SLOT( activate() ) ); + widgetResizeHandler->setExtraHeight( th + 2 ); + + setBaseSize( baseSize() ); +} + +QWorkspacePChild::~QWorkspacePChild() +{ + if ( iconw ) + delete iconw->parentWidget(); +} + +void QWorkspacePChild::moveEvent( QMoveEvent * ) +{ + ((QWorkspaceP*) parentWidget() )->updateWorkspace(); +} + +void QWorkspacePChild::resizeEvent( QResizeEvent * ) +{ + QRect r = contentsRect(); + QRect cr; + + if ( titlebar ) { + int th = titlebar->sizeHint().height(); + QRect tbrect( 0, 0, width(), th ); + if ( !style().styleHint( QStyle::SH_TitleBar_NoBorder ) ) + tbrect = QRect( r.x(), r.y(), r.width(), th ); + titlebar->setGeometry( tbrect ); + cr = QRect( r.x(), r.y() + titlebar->height() + (shademode ? 5 : 1), + r.width(), r.height() - titlebar->height() - 2 ); + } else { + cr = r; + } + + if (!childWidget) + return; + + windowSize = cr.size(); + childWidget->setGeometry( cr ); + ((QWorkspaceP*) parentWidget() )->updateWorkspace(); +} + +QSize QWorkspacePChild::baseSize() const +{ + int th = titlebar ? titlebar->sizeHint().height() : 0; + return QSize( 2*frameWidth(), 2*frameWidth() + th + 2 ); +} + +QSize QWorkspacePChild::sizeHint() const +{ + if ( !childWidget ) + return QFrame::sizeHint() + baseSize(); + return childWidget->sizeHint().expandedTo( childWidget->minimumSizeHint() ) + baseSize(); +} + +QSize QWorkspacePChild::minimumSizeHint() const +{ + if ( !childWidget ) + return QFrame::minimumSizeHint() + baseSize(); + QSize s = childWidget->minimumSize(); + if ( s.isEmpty() ) + s = childWidget->minimumSizeHint(); + return s + baseSize(); +} + +void QWorkspacePChild::activate() +{ + ((QWorkspaceP*)parentWidget())->activateWindow( windowWidget() ); +} + +bool QWorkspacePChild::eventFilter( QObject * o, QEvent * e) +{ + if ( !isActive() && ( e->type() == QEvent::MouseButtonPress || + e->type() == QEvent::FocusIn ) ) { + if ( iconw ) { + ((QWorkspaceP*)parentWidget())->normalizeWindow( windowWidget() ); + if ( iconw ) { + ((QWorkspaceP*)parentWidget())->removeIcon( iconw->parentWidget() ); + delete iconw->parentWidget(); + iconw = 0; + } + } + activate(); + } + + // for all widgets except the window, we that's the only thing we + // process, and if we have no childWidget we skip totally + if ( o != childWidget || childWidget == 0 ) + return FALSE; + + switch ( e->type() ) { + case QEvent::Show: + if ( ((QWorkspaceP*)parentWidget())->d->focus.find( this ) < 0 ) + ((QWorkspaceP*)parentWidget())->d->focus.append( this ); + if ( isVisibleTo( parentWidget() ) ) + break; + if (( (QShowEvent*)e)->spontaneous() ) + break; + // fall through + case QEvent::ShowToParent: + if ( windowWidget() && windowWidget()->testWFlags( WStyle_StaysOnTop ) ) { + internalRaise(); + show(); + } + ((QWorkspaceP*)parentWidget())->showWindow( windowWidget() ); + break; + case QEvent::ShowMaximized: + if ( windowWidget()->maximumSize().isValid() && + ( windowWidget()->maximumWidth() < parentWidget()->width() || + windowWidget()->maximumHeight() < parentWidget()->height() ) ) { + windowWidget()->resize( windowWidget()->maximumSize() ); + break; + } + if ( windowWidget()->testWFlags( WStyle_Maximize ) && !windowWidget()->testWFlags( WStyle_Tool ) ) + ((QWorkspaceP*)parentWidget())->maximizeWindow( windowWidget() ); + else + ((QWorkspaceP*)parentWidget())->normalizeWindow( windowWidget() ); + break; + case QEvent::ShowMinimized: + ((QWorkspaceP*)parentWidget())->minimizeWindow( windowWidget() ); + break; + case QEvent::ShowNormal: + ((QWorkspaceP*)parentWidget())->normalizeWindow( windowWidget() ); + if (iconw) { + ((QWorkspaceP*)parentWidget())->removeIcon( iconw->parentWidget() ); + delete iconw->parentWidget(); + } + break; + case QEvent::Hide: + case QEvent::HideToParent: + if ( !childWidget->isVisibleTo( this ) ) { + QWidget * w = iconw; + if ( w && ( w = w->parentWidget() ) ) { + ((QWorkspaceP*)parentWidget())->removeIcon( w ); + delete w; + } + hide(); + } + break; + case QEvent::CaptionChange: +#ifndef QT_NO_WIDGET_TOPEXTRA + setCaption( childWidget->caption() ); + if ( iconw ) + iconw->setCaption( childWidget->caption() ); +#endif + break; + case QEvent::IconChange: + { + QWorkspaceP* ws = (QWorkspaceP*)parentWidget(); + if ( !titlebar ) + break; +#ifndef QT_NO_WIDGET_TOPEXTRA + if ( childWidget->icon() ) { + titlebar->setIcon( *childWidget->icon() ); + } else +#endif + { + QPixmap pm; + titlebar->setIcon( pm ); + } + + if ( ws->d->maxWindow != this ) + break; + + if ( ws->d->maxtools ) { +#ifndef QT_NO_WIDGET_TOPEXTRA + if ( childWidget->icon() ) { + QPixmap pm(*childWidget->icon()); + if(pm.width() != 14 || pm.height() != 14) { + QImage im; + im = pm; + pm = im.smoothScale( 14, 14 ); + } + ws->d->maxtools->setPixmap( pm ); + } else +#endif + { + QPixmap pm(14,14); + pm.fill( white ); + ws->d->maxtools->setPixmap( pm ); + } + } + } + break; + case QEvent::Resize: + { + QResizeEvent* re = (QResizeEvent*)e; + if ( re->size() != windowSize && !shademode ) + resize( re->size() + baseSize() ); + } + break; + + case QEvent::WindowDeactivate: + if ( titlebar ) + titlebar->setActive( FALSE ); + break; + + case QEvent::WindowActivate: + if ( titlebar ) + titlebar->setActive( act ); + break; + + default: + break; + } + + return QFrame::eventFilter(o, e); +} + +bool QWorkspacePChild::focusNextPrevChild( bool next ) +{ + QFocusData *f = focusData(); + + QWidget *startingPoint = f->home(); + QWidget *candidate = 0; + QWidget *w = next ? f->next() : f->prev(); + while( !candidate && w != startingPoint ) { + if ( w != startingPoint && + (w->focusPolicy() & TabFocus) == TabFocus + && w->isEnabled() &&!w->focusProxy() && w->isVisible() ) + candidate = w; + w = next ? f->next() : f->prev(); + } + + if ( candidate ) { + QObjectList *ol = queryList(); + bool ischild = ol->findRef( candidate ) != -1; + delete ol; + if ( !ischild ) { + startingPoint = f->home(); + QWidget *nw = next ? f->prev() : f->next(); + QObjectList *ol2 = queryList(); + QWidget *lastValid = 0; + candidate = startingPoint; + while ( nw != startingPoint ) { + if ( ( candidate->focusPolicy() & TabFocus ) == TabFocus + && candidate->isEnabled() &&!candidate->focusProxy() && candidate->isVisible() ) + lastValid = candidate; + if ( ol2->findRef( nw ) == -1 ) { + candidate = lastValid; + break; + } + candidate = nw; + nw = next ? f->prev() : f->next(); + } + delete ol2; + } + } + + if ( !candidate ) + return FALSE; + + candidate->setFocus(); + return TRUE; +} + +void QWorkspacePChild::childEvent( QChildEvent* e) +{ + if ( e->type() == QEvent::ChildRemoved && e->child() == childWidget ) { + childWidget = 0; + if ( iconw ) { + ((QWorkspaceP*)parentWidget())->removeIcon( iconw->parentWidget() ); + delete iconw->parentWidget(); + } + close(); + } +} + + +void QWorkspacePChild::doResize() +{ + widgetResizeHandler->doResize(); +} + +void QWorkspacePChild::doMove() +{ + widgetResizeHandler->doMove(); +} + +void QWorkspacePChild::enterEvent( QEvent * ) +{ +} + +void QWorkspacePChild::leaveEvent( QEvent * ) +{ +#ifndef QT_NO_CURSOR + if ( !widgetResizeHandler->isButtonDown() ) + setCursor( arrowCursor ); +#endif +} + +void QWorkspacePChild::drawFrame( QPainter *p ) +{ + QStyle::SFlags flags = QStyle::Style_Default; + QStyleOption opt(lineWidth(),midLineWidth()); + + if ( act ) + flags |= QStyle::Style_Active; + + style().drawPrimitive( QStyle::PE_WindowFrame, p, rect(), colorGroup(), flags, opt ); +} + +void QWorkspacePChild::styleChange( QStyle & ) +{ + resizeEvent( 0 ); + if ( iconw ) { + QVBox *vbox = (QVBox*)iconw->parentWidget()->qt_cast( "QVBox" ); + Q_ASSERT(vbox); + if ( !style().styleHint( QStyle::SH_TitleBar_NoBorder ) ) { + vbox->setFrameStyle( QFrame::WinPanel | QFrame::Raised ); + vbox->resize( 196+2*vbox->frameWidth(), 20 + 2*vbox->frameWidth() ); + } else { + vbox->resize( 196, 20 ); + } + } +} + +static bool isChildOf( QWidget * child, QWidget * parent ) +{ + if ( !parent || !child ) + return FALSE; + QWidget * w = child; + while( w && w != parent ) + w = w->parentWidget(); + return w != 0; +} + + +void QWorkspacePChild::setActive( bool b ) +{ + if ( !childWidget ) + return; + + if ( act == b ) + return; + + act = b; + repaint( FALSE ); + + if ( titlebar ) + titlebar->setActive( act ); + if ( iconw ) + iconw->setActive( act ); + + QObjectList* ol = childWidget->queryList( "QWidget" ); + if ( act ) { + QObject *o; + for ( o = ol->first(); o; o = ol->next() ) + o->removeEventFilter( this ); + bool hasFocus = isChildOf( focusWidget(), childWidget ); + if ( !hasFocus ) { + if ( lastfocusw && ol->contains( lastfocusw ) && + lastfocusw->focusPolicy() != NoFocus ) { + // this is a bug if lastfocusw has been deleted, a new + // widget has been created, and the new one is a child + // of the same window as the old one. but even though + // it's a bug the behaviour is reasonable + lastfocusw->setFocus(); + } else if ( childWidget->focusPolicy() != NoFocus ) { + childWidget->setFocus(); + } else { + // find something, anything, that accepts focus, and use that. + o = ol->first(); + while( o && ((QWidget*)o)->focusPolicy() == NoFocus ) + o = ol->next(); + if ( o ) + ((QWidget*)o)->setFocus(); + } + } + } else { + lastfocusw = 0; + if ( isChildOf( focusWidget(), childWidget ) ) + lastfocusw = focusWidget(); + QObject * o; + for ( o = ol->first(); o; o = ol->next() ) { + o->removeEventFilter( this ); + o->installEventFilter( this ); + } + } + delete ol; +} + +bool QWorkspacePChild::isActive() const +{ + return act; +} + +QWidget* QWorkspacePChild::windowWidget() const +{ + return childWidget; +} + + +QWidget* QWorkspacePChild::iconWidget() const +{ + if ( !iconw ) { + QWorkspacePChild* that = (QWorkspacePChild*) this; + QVBox* vbox = new QVBox(0, "qt_vbox" ); + if ( !style().styleHint( QStyle::SH_TitleBar_NoBorder ) ) { + vbox->setFrameStyle( QFrame::WinPanel | QFrame::Raised ); + vbox->resize( 196+2*vbox->frameWidth(), 20 + 2*vbox->frameWidth() ); + } else { + vbox->resize( 196, 20 ); + } + QTitleBarP *tb = new QTitleBarP( windowWidget(), vbox, "_workspacechild_icon_"); + ((QWorkspacePChild*)tb)->setWState( WState_Minimized ); + that->iconw = tb; + iconw->setActive( isActive() ); + connect( iconw, SIGNAL( doActivate() ), + this, SLOT( activate() ) ); + connect( iconw, SIGNAL( doClose() ), + windowWidget(), SLOT( close() ) ); + connect( iconw, SIGNAL( doNormal() ), + this, SLOT( showNormal() ) ); + connect( iconw, SIGNAL( doMaximize() ), + this, SLOT( showMaximized() ) ); + connect( iconw, SIGNAL( popupOperationMenu( const QPoint& ) ), + this, SIGNAL( popupOperationMenu( const QPoint& ) ) ); + connect( iconw, SIGNAL( showOperationMenu() ), + this, SIGNAL( showOperationMenu() ) ); + connect( iconw, SIGNAL( doubleClicked() ), + this, SLOT( titleBarDoubleClicked() ) ); + } +#ifndef QT_NO_WIDGET_TOPEXTRA + if ( windowWidget() ) { + iconw->setCaption( windowWidget()->caption() ); + if ( windowWidget()->icon() ) + iconw->setIcon( *windowWidget()->icon() ); + } +#endif + return iconw->parentWidget(); +} + +void QWorkspacePChild::showMinimized() +{ + QApplication::postEvent( windowWidget(), new QEvent( QEvent::ShowMinimized ) ); +} + +void QWorkspacePChild::showMaximized() +{ + QApplication::postEvent( windowWidget(), new QEvent( QEvent::ShowMaximized ) ); +} + +void QWorkspacePChild::showNormal() +{ + QApplication::postEvent( windowWidget(), new QEvent( QEvent::ShowNormal ) ); +} + +void QWorkspacePChild::showShaded() +{ + if ( !titlebar) + return; + Q_ASSERT( windowWidget()->testWFlags( WStyle_MinMax ) && windowWidget()->testWFlags( WStyle_Tool ) ); + ((QWorkspaceP*)parentWidget())->activateWindow( windowWidget() ); + if ( shademode ) { + QWorkspacePChild* fake = (QWorkspacePChild*)windowWidget(); + fake->clearWState( WState_Minimized ); + clearWState( WState_Minimized ); + + shademode = FALSE; + resize( shadeRestore ); + setMinimumSize( shadeRestoreMin ); + } else { + shadeRestore = size(); + shadeRestoreMin = minimumSize(); + setMinimumHeight(0); + shademode = TRUE; + QWorkspacePChild* fake = (QWorkspacePChild*)windowWidget(); + fake->setWState( WState_Minimized ); + setWState( WState_Minimized ); + + resize( width(), titlebar->height() + 2*lineWidth() + 1 ); + } + titlebar->update(); +} + +void QWorkspacePChild::titleBarDoubleClicked() +{ + if ( !windowWidget() ) + return; + if ( windowWidget()->testWFlags( WStyle_MinMax ) ) { + if ( windowWidget()->testWFlags( WStyle_Tool ) ) + showShaded(); + else if ( iconw ) + showNormal(); + else if ( windowWidget()->testWFlags( WStyle_Maximize ) ) + showMaximized(); + } +} + +void QWorkspacePChild::adjustToFullscreen() +{ + qApp->sendPostedEvents( this, QEvent::Resize ); + qApp->sendPostedEvents( childWidget, QEvent::Resize ); + qApp->sendPostedEvents( childWidget, QEvent::Move ); + if(style().styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, this)) { + setGeometry( 0, 0, parentWidget()->width(), parentWidget()->height()); + } else { + setGeometry( -childWidget->x(), -childWidget->y(), + parentWidget()->width() + width() - childWidget->width(), + parentWidget()->height() + height() - childWidget->height() ); + } + setWState( WState_Maximized ); + ((QWorkspacePChild*)childWidget)->setWState( WState_Maximized ); +} + +void QWorkspacePChild::adjustSize() +{ + if ( !testWState(WState_Polished) ) + polish(); + + QSize prefSize = windowWidget()->sizeHint().expandedTo( windowWidget()->minimumSizeHint() ); + prefSize = prefSize.expandedTo( windowWidget()->minimumSize() ).boundedTo( windowWidget()->maximumSize() ); + prefSize += baseSize(); + + resize( prefSize ); +} + +void QWorkspacePChild::setCaption( const QString& cap ) +{ + if ( titlebar ) + titlebar->setCaption( cap ); +#ifndef QT_NO_WIDGET_TOPEXTRA + QWidget::setCaption( cap ); +#endif +} + +void QWorkspacePChild::internalRaise() +{ + setUpdatesEnabled( FALSE ); + if ( iconw ) + iconw->parentWidget()->raise(); + raise(); + + if ( !windowWidget() || windowWidget()->testWFlags( WStyle_StaysOnTop ) ) { + setUpdatesEnabled( TRUE ); + return; + } + + QPtrListIterator it( ((QWorkspaceP*)parent())->d->windows ); + while ( it.current () ) { + QWorkspacePChild* c = it.current(); + ++it; + if ( c->windowWidget() && + !c->windowWidget()->isHidden() && + c->windowWidget()->testWFlags( WStyle_StaysOnTop ) ) + c->raise(); + } + + setUpdatesEnabled( TRUE ); +} + +void QWorkspacePChild::move( int x, int y ) +{ + int nx = x; + int ny = y; + + if ( windowWidget() && windowWidget()->testWFlags( WStyle_Tool ) ) { + int dx = 10; + int dy = 10; + + if ( QABS( x ) < dx ) + nx = 0; + if ( QABS( y ) < dy ) + ny = 0; + if ( QABS( x + width() - parentWidget()->width() ) < dx ) { + nx = parentWidget()->width() - width(); + snappedRight = TRUE; + } else + snappedRight = FALSE; + + if ( QABS( y + height() - parentWidget()->height() ) < dy ) { + ny = parentWidget()->height() - height(); + snappedDown = TRUE; + } else + snappedDown = FALSE; + } + QFrame::move( nx, ny ); +} + +bool QWorkspaceP::scrollBarsEnabled() const +{ + return d->vbar != 0; +} + +/*! \property QWorkspaceP::scrollBarsEnabled + \brief whether the workspace provides scrollbars + + If this property is set to TRUE, it is possible to resize child + windows over the right or the bottom edge out of the visible area + of the workspace. The workspace shows scrollbars to make it + possible for the user to access those windows. If this property is + set to FALSE (the default), resizing windows out of the visible + area of the workspace is not permitted. +*/ +void QWorkspaceP::setScrollBarsEnabled( bool enable ) +{ + if ( (d->vbar != 0) == enable ) + return; + + d->xoffset = d->yoffset = 0; + if ( enable ) { + d->vbar = new QScrollBar( Vertical, this, "vertical scrollbar" ); + connect( d->vbar, SIGNAL( valueChanged(int) ), this, SLOT( scrollBarChanged() ) ); + d->hbar = new QScrollBar( Horizontal, this, "horizontal scrollbar" ); + connect( d->hbar, SIGNAL( valueChanged(int) ), this, SLOT( scrollBarChanged() ) ); + d->corner = new QWidget( this, "qt_corner" ); + updateWorkspace(); + } else { + delete d->vbar; + delete d->hbar; + delete d->corner; + d->vbar = d->hbar = 0; + d->corner = 0; + } + + QPtrListIterator it( d->windows ); + while ( it.current () ) { + QWorkspacePChild *child = it.current(); + ++it; + child->widgetResizeHandler->setSizeProtection( !enable ); + } +} + +QRect QWorkspaceP::updateWorkspace() +{ + if ( !isUpdatesEnabled() ) + return rect(); + + QRect cr( rect() ); + + if ( scrollBarsEnabled() && !d->maxWindow ) { + d->corner->raise(); + d->vbar->raise(); + d->hbar->raise(); + if ( d->maxWindow ) + d->maxWindow->raise(); + + QRect r( 0, 0, 0, 0 ); + QPtrListIterator it( d->windows ); + while ( it.current () ) { + QWorkspacePChild *child = it.current(); + ++it; + if ( !child->isHidden() ) + r = r.unite( child->geometry() ); + } + d->vbar->blockSignals( TRUE ); + d->hbar->blockSignals( TRUE ); + + int hsbExt = d->hbar->sizeHint().height(); + int vsbExt = d->vbar->sizeHint().width(); + + + bool showv = d->yoffset || d->yoffset + r.bottom() - height() + 1 > 0 || d->yoffset + r.top() < 0; + bool showh = d->xoffset || d->xoffset + r.right() - width() + 1 > 0 || d->xoffset + r.left() < 0; + + if ( showh && !showv) + showv = d->yoffset + r.bottom() - height() + hsbExt + 1 > 0; + if ( showv && !showh ) + showh = d->xoffset + r.right() - width() + vsbExt + 1 > 0; + + if ( !showh ) + hsbExt = 0; + if ( !showv ) + vsbExt = 0; + + if ( showv ) { + d->vbar->setSteps( QMAX( height() / 12, 30 ), height() - hsbExt ); + d->vbar->setRange( QMIN( 0, d->yoffset + QMIN( 0, r.top() ) ), QMAX( 0, d->yoffset + QMAX( 0, r.bottom() - height() + hsbExt + 1) ) ); + d->vbar->setGeometry( width() - vsbExt, 0, vsbExt, height() - hsbExt ); + d->vbar->setValue( d->yoffset ); + d->vbar->show(); + } else { + d->vbar->hide(); + } + + if ( showh ) { + d->hbar->setSteps( QMAX( width() / 12, 30 ), width() - vsbExt ); + d->hbar->setRange( QMIN( 0, d->xoffset + QMIN( 0, r.left() ) ), QMAX( 0, d->xoffset + QMAX( 0, r.right() - width() + vsbExt + 1) ) ); + d->hbar->setGeometry( 0, height() - hsbExt, width() - vsbExt, hsbExt ); + d->hbar->setValue( d->xoffset ); + d->hbar->show(); + } else { + d->hbar->hide(); + } + + if ( showh && showv ) { + d->corner->setGeometry( width() - vsbExt, height() - hsbExt, vsbExt, hsbExt ); + d->corner->show(); + } else { + d->corner->hide(); + } + + d->vbar->blockSignals( FALSE ); + d->hbar->blockSignals( FALSE ); + + cr.setRect( 0, 0, width() - vsbExt, height() - hsbExt ); + } + + QPtrListIterator ii( d->icons ); + while ( ii.current() ) { + QWorkspacePChild* w = (QWorkspacePChild*)ii.current(); + ++ii; + int x = w->x(); + int y = w->y(); + bool m = FALSE; + if ( x+w->width() > cr.width() ) { + m = TRUE; + x = cr.width() - w->width(); + } + if ( y+w->height() > cr.height() ) { + y = cr.height() - w->height(); + m = TRUE; + } + if ( m ) + w->move( x, y ); + } + + return cr; + +} + +void QWorkspaceP::scrollBarChanged() +{ + int ver = d->yoffset - d->vbar->value(); + int hor = d->xoffset - d->hbar->value(); + d->yoffset = d->vbar->value(); + d->xoffset = d->hbar->value(); + + QPtrListIterator it( d->windows ); + while ( it.current () ) { + QWorkspacePChild *child = it.current(); + ++it; + // we do not use move() due to the reimplementation in QWorkspacePChild + child->setGeometry( child->x() + hor, child->y() + ver, child->width(), child->height() ); + } + updateWorkspace(); +} + +#ifndef QT_NO_STYLE +/*!\reimp */ +void QWorkspaceP::styleChange( QStyle &olds ) +{ + int fs = style().styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, this); + if ( isVisibleTo(0) && d->maxWindow && + fs != olds.styleHint(QStyle::SH_Workspace_FillSpaceOnMaximize, this)) { + if( fs ) + hideMaximizeControls(); + else + showMaximizeControls(); + } + QWidget::styleChange(olds); +} +#endif + +#define RANGE 4 + +static bool resizeHorizontalDirectionFixed = FALSE; +static bool resizeVerticalDirectionFixed = FALSE; + +QWidgetResizeHandlerP::QWidgetResizeHandlerP( QWidget *parent, QWidget *cw, const char *name ) + : QObject( parent, name ), widget( parent ), childWidget( cw ? cw : parent ), + extrahei( 0 ), buttonDown( FALSE ), moveResizeMode( FALSE ), sizeprotect( TRUE ), moving( TRUE ) +{ + mode = Nowhere; + widget->setMouseTracking( TRUE ); + range = widget->inherits( "QFrame" ) ? ((QFrame*)widget)->frameWidth() : RANGE; + range = QMAX( RANGE, range ); + active = TRUE; + qApp->installEventFilter( this ); +} + +static QWidget *childOf( QWidget *w, QWidget *child ) +{ + while ( child ) { + if ( child == w ) + return child; + child = child->parentWidget(); + } + return 0; +} + +bool QWidgetResizeHandlerP::eventFilter( QObject *o, QEvent *ee ) +{ + if ( !active || !o->isWidgetType() ) + return FALSE; + + QWidget *w = childOf( widget, (QWidget*)o ); + if ( !w || o->inherits( "QSizeGrip" ) ) + return FALSE; + + QMouseEvent *e = (QMouseEvent*)ee; + switch ( e->type() ) { + case QEvent::MouseButtonPress: { + if ( w->isMaximized() ) + break; + if ( !widget->rect().contains( widget->mapFromGlobal( e->globalPos() ) ) ) + return FALSE; + if ( e->button() == LeftButton ) { + emit activate(); + bool me = isMovingEnabled(); + setMovingEnabled( me && o == widget ); + mouseMoveEvent( e ); + setMovingEnabled( me ); + buttonDown = TRUE; + moveOffset = widget->mapFromGlobal( e->globalPos() ); + invertedMoveOffset = widget->rect().bottomRight() - moveOffset; + } + } break; + case QEvent::MouseButtonRelease: + if ( w->isMaximized() ) + break; + if ( e->button() == LeftButton ) { + moveResizeMode = FALSE; + buttonDown = FALSE; + widget->releaseMouse(); + widget->releaseKeyboard(); + } + break; + case QEvent::MouseMove: { + if ( w->isMaximized() ) + break; + bool me = isMovingEnabled(); + setMovingEnabled( me && o == widget ); + mouseMoveEvent( e ); + setMovingEnabled( me ); + if ( buttonDown && mode != Center ) + return TRUE; + } break; + case QEvent::KeyPress: + keyPressEvent( (QKeyEvent*)e ); + break; + case QEvent::AccelOverride: + if ( buttonDown ) { + ((QKeyEvent*)ee)->accept(); + return TRUE; + } + break; + default: + break; + } + return FALSE; +} + +void QWidgetResizeHandlerP::mouseMoveEvent( QMouseEvent *e ) +{ + QPoint pos = widget->mapFromGlobal( e->globalPos() ); + if ( !moveResizeMode && ( !buttonDown || ( e->state() & LeftButton ) == 0 ) ) { + if ( pos.y() <= range && pos.x() <= range) + mode = TopLeft; + else if ( pos.y() >= widget->height()-range && pos.x() >= widget->width()-range) + mode = BottomRight; + else if ( pos.y() >= widget->height()-range && pos.x() <= range) + mode = BottomLeft; + else if ( pos.y() <= range && pos.x() >= widget->width()-range) + mode = TopRight; + else if ( pos.y() <= range ) + mode = Top; + else if ( pos.y() >= widget->height()-range ) + mode = Bottom; + else if ( pos.x() <= range ) + mode = Left; + else if ( pos.x() >= widget->width()-range ) + mode = Right; + else + mode = Center; + + if ( widget->isMinimized() ) + mode = Center; +#ifndef QT_NO_CURSOR + setMouseCursor( mode ); +#endif + return; + } + + if ( buttonDown && !isMovingEnabled() && mode == Center && !moveResizeMode ) + return; + + if ( widget->testWState( WState_ConfigPending ) ) + return; + + QPoint globalPos = widget->parentWidget( TRUE ) ? + widget->parentWidget( TRUE )->mapFromGlobal( e->globalPos() ) : e->globalPos(); + if ( widget->parentWidget( TRUE ) && !widget->parentWidget( TRUE )->rect().contains( globalPos ) ) { + if ( globalPos.x() < 0 ) + globalPos.rx() = 0; + if ( globalPos.y() < 0 ) + globalPos.ry() = 0; + if ( sizeprotect && globalPos.x() > widget->parentWidget()->width() ) + globalPos.rx() = widget->parentWidget()->width(); + if ( sizeprotect && globalPos.y() > widget->parentWidget()->height() ) + globalPos.ry() = widget->parentWidget()->height(); + } + + QPoint p = globalPos + invertedMoveOffset; + QPoint pp = globalPos - moveOffset; + + int fw = 0; + int mw = QMAX( childWidget->minimumSizeHint().width(), + childWidget->minimumWidth() ); + int mh = QMAX( childWidget->minimumSizeHint().height(), + childWidget->minimumHeight() ); + if ( childWidget != widget ) { + if ( widget->inherits( "QFrame" ) ) + fw = ( (QFrame *) widget )->frameWidth(); + mw += 2 * fw; + mh += 2 * fw + extrahei; + } + + QSize mpsize( widget->geometry().right() - pp.x() + 1, + widget->geometry().bottom() - pp.y() + 1 ); + mpsize = mpsize.expandedTo( widget->minimumSize() ).expandedTo( QSize(mw, mh) ); + QPoint mp( widget->geometry().right() - mpsize.width() + 1, + widget->geometry().bottom() - mpsize.height() + 1 ); + + QRect geom = widget->geometry(); + + switch ( mode ) { + case TopLeft: + geom = QRect( mp, widget->geometry().bottomRight() ) ; + break; + case BottomRight: + geom = QRect( widget->geometry().topLeft(), p ) ; + break; + case BottomLeft: + geom = QRect( QPoint(mp.x(), widget->geometry().y() ), QPoint( widget->geometry().right(), p.y()) ) ; + break; + case TopRight: + geom = QRect( QPoint( widget->geometry().x(), mp.y() ), QPoint( p.x(), widget->geometry().bottom()) ) ; + break; + case Top: + geom = QRect( QPoint( widget->geometry().left(), mp.y() ), widget->geometry().bottomRight() ) ; + break; + case Bottom: + geom = QRect( widget->geometry().topLeft(), QPoint( widget->geometry().right(), p.y() ) ) ; + break; + case Left: + geom = QRect( QPoint( mp.x(), widget->geometry().top() ), widget->geometry().bottomRight() ) ; + break; + case Right: + geom = QRect( widget->geometry().topLeft(), QPoint( p.x(), widget->geometry().bottom() ) ) ; + break; + case Center: + if ( isMovingEnabled() || moveResizeMode ) + geom.moveTopLeft( pp ); + break; + default: + break; + } + + QSize maxsize( childWidget->maximumSize() ); + if ( childWidget != widget ) + maxsize += QSize( 2 * fw, 2 * fw + extrahei ); + + geom = QRect( geom.topLeft(), + geom.size().expandedTo( widget->minimumSize() ) + .expandedTo( QSize(mw, mh) ) + .boundedTo( maxsize ) ); + + if ( geom != widget->geometry() && + ( widget->isTopLevel() || widget->parentWidget()->rect().intersects( geom ) ) ) { + if ( widget->isMinimized() ) + widget->move( geom.topLeft() ); + else + widget->setGeometry( geom ); + } + +#if defined(Q_WS_WIN) + MSG msg; +#if defined(UNICODE) +# ifndef Q_OS_TEMP + if ( qWinVersion() & WV_NT_based ) { +# endif + while(PeekMessageW( &msg, widget->winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE )) + ; +# ifndef Q_OS_TEMP + } else +# endif +#endif +#ifndef Q_OS_TEMP + { + while(PeekMessageA( &msg, widget->winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE )) + ; + } +#endif +#endif + + QApplication::syncX(); +} + +void QWidgetResizeHandlerP::setMouseCursor( MousePosition m ) +{ +#ifndef QT_NO_CURSOR + switch ( m ) { + case TopLeft: + case BottomRight: + widget->setCursor( sizeFDiagCursor ); + break; + case BottomLeft: + case TopRight: + widget->setCursor( sizeBDiagCursor ); + break; + case Top: + case Bottom: + widget->setCursor( sizeVerCursor ); + break; + case Left: + case Right: + widget->setCursor( sizeHorCursor ); + break; + default: + widget->setCursor( arrowCursor ); + break; + } +#endif +} + +void QWidgetResizeHandlerP::keyPressEvent( QKeyEvent * e ) +{ + if ( !isMove() && !isResize() ) + return; + bool is_control = e->state() & ControlButton; + int delta = is_control?1:8; + QPoint pos = QCursor::pos(); + switch ( e->key() ) { + case Key_Left: + pos.rx() -= delta; + if ( pos.x() <= QApplication::desktop()->geometry().left() ) { + if ( mode == TopLeft || mode == BottomLeft ) { + moveOffset.rx() += delta; + invertedMoveOffset.rx() += delta; + } else { + moveOffset.rx() -= delta; + invertedMoveOffset.rx() -= delta; + } + } + if ( isResize() && !resizeHorizontalDirectionFixed ) { + resizeHorizontalDirectionFixed = TRUE; + if ( mode == BottomRight ) + mode = BottomLeft; + else if ( mode == TopRight ) + mode = TopLeft; +#ifndef QT_NO_CURSOR + setMouseCursor( mode ); + widget->grabMouse( widget->cursor() ); +#else + widget->grabMouse(); +#endif + } + break; + case Key_Right: + pos.rx() += delta; + if ( pos.x() >= QApplication::desktop()->geometry().right() ) { + if ( mode == TopRight || mode == BottomRight ) { + moveOffset.rx() += delta; + invertedMoveOffset.rx() += delta; + } else { + moveOffset.rx() -= delta; + invertedMoveOffset.rx() -= delta; + } + } + if ( isResize() && !resizeHorizontalDirectionFixed ) { + resizeHorizontalDirectionFixed = TRUE; + if ( mode == BottomLeft ) + mode = BottomRight; + else if ( mode == TopLeft ) + mode = TopRight; +#ifndef QT_NO_CURSOR + setMouseCursor( mode ); + widget->grabMouse( widget->cursor() ); +#else + widget->grabMouse(); +#endif + } + break; + case Key_Up: + pos.ry() -= delta; + if ( pos.y() <= QApplication::desktop()->geometry().top() ) { + if ( mode == TopLeft || mode == TopRight ) { + moveOffset.ry() += delta; + invertedMoveOffset.ry() += delta; + } else { + moveOffset.ry() -= delta; + invertedMoveOffset.ry() -= delta; + } + } + if ( isResize() && !resizeVerticalDirectionFixed ) { + resizeVerticalDirectionFixed = TRUE; + if ( mode == BottomLeft ) + mode = TopLeft; + else if ( mode == BottomRight ) + mode = TopRight; +#ifndef QT_NO_CURSOR + setMouseCursor( mode ); + widget->grabMouse( widget->cursor() ); +#else + widget->grabMouse(); +#endif + } + break; + case Key_Down: + pos.ry() += delta; + if ( pos.y() >= QApplication::desktop()->geometry().bottom() ) { + if ( mode == BottomLeft || mode == BottomRight ) { + moveOffset.ry() += delta; + invertedMoveOffset.ry() += delta; + } else { + moveOffset.ry() -= delta; + invertedMoveOffset.ry() -= delta; + } + } + if ( isResize() && !resizeVerticalDirectionFixed ) { + resizeVerticalDirectionFixed = TRUE; + if ( mode == TopLeft ) + mode = BottomLeft; + else if ( mode == TopRight ) + mode = BottomRight; +#ifndef QT_NO_CURSOR + setMouseCursor( mode ); + widget->grabMouse( widget->cursor() ); +#else + widget->grabMouse(); +#endif + } + break; + case Key_Space: + case Key_Return: + case Key_Enter: + case Key_Escape: + moveResizeMode = FALSE; + widget->releaseMouse(); + widget->releaseKeyboard(); + buttonDown = FALSE; + break; + default: + return; + } + QCursor::setPos( pos ); +} + + +void QWidgetResizeHandlerP::doResize() +{ + if ( !active ) + return; + + moveResizeMode = TRUE; + buttonDown = TRUE; + moveOffset = widget->mapFromGlobal( QCursor::pos() ); + if ( moveOffset.x() < widget->width()/2) { + if ( moveOffset.y() < widget->height()/2) + mode = TopLeft; + else + mode = BottomLeft; + } else { + if ( moveOffset.y() < widget->height()/2) + mode = TopRight; + else + mode = BottomRight; + } + invertedMoveOffset = widget->rect().bottomRight() - moveOffset; +#ifndef QT_NO_CURSOR + setMouseCursor( mode ); + widget->grabMouse( widget->cursor() ); +#else + widget->grabMouse(); +#endif + widget->grabKeyboard(); + resizeHorizontalDirectionFixed = FALSE; + resizeVerticalDirectionFixed = FALSE; +} + +void QWidgetResizeHandlerP::doMove() +{ + if ( !active ) + return; + + mode = Center; + moveResizeMode = TRUE; + buttonDown = TRUE; + moveOffset = widget->mapFromGlobal( QCursor::pos() ); + invertedMoveOffset = widget->rect().bottomRight() - moveOffset; +#ifndef QT_NO_CURSOR + widget->grabMouse( SizeAllCursor ); +#else + widget->grabMouse(); +#endif + widget->grabKeyboard(); +} + +#ifndef QT_NO_TOOLTIP +class QTitleBarPTip : public QToolTip +{ +public: + QTitleBarPTip( QWidget * parent ) : QToolTip( parent ) { } + + void maybeTip( const QPoint &pos ) + { + if ( !parentWidget()->inherits( "QTitleBarP" ) ) + return; + QTitleBarP *t = (QTitleBarP *)parentWidget(); + + QString tipstring; + QStyle::SubControl ctrl = t->style().querySubControl(QStyle::CC_TitleBar, t, pos); + QSize controlSize = t->style().querySubControlMetrics(QStyle::CC_TitleBar, t, ctrl).size(); + + QWidget *window = t->window(); + if ( window ) { + switch(ctrl) { + case QStyle::SC_TitleBarSysMenu: + if ( t->testWFlags( WStyle_SysMenu ) ) + tipstring = QTitleBarP::tr( "System Menu" ); + break; + + case QStyle::SC_TitleBarShadeButton: + if ( t->testWFlags( WStyle_Tool ) && t->testWFlags( WStyle_MinMax ) ) + tipstring = QTitleBarP::tr( "Shade" ); + break; + + case QStyle::SC_TitleBarUnshadeButton: + if ( t->testWFlags( WStyle_Tool ) && t->testWFlags( WStyle_MinMax ) ) + tipstring = QTitleBarP::tr( "Unshade" ); + break; + + case QStyle::SC_TitleBarNormalButton: + case QStyle::SC_TitleBarMinButton: + if ( !t->testWFlags( WStyle_Tool ) && t->testWFlags( WStyle_Minimize ) ) { + if( window->isMinimized() ) + tipstring = QTitleBarP::tr( "Normalize" ); + else + tipstring = QTitleBarP::tr( "Minimize" ); + } + break; + + case QStyle::SC_TitleBarMaxButton: + if ( !t->testWFlags( WStyle_Tool ) && t->testWFlags( WStyle_Maximize ) ) + tipstring = QTitleBarP::tr( "Maximize" ); + break; + + case QStyle::SC_TitleBarCloseButton: + if ( t->testWFlags( WStyle_SysMenu ) ) + tipstring = QTitleBarP::tr( "Close" ); + break; + + default: + break; + } + } +#ifndef QT_NO_WIDGET_TOPEXTRA + if ( tipstring.isEmpty() ) { + if ( t->visibleText() != t->caption() ) + tipstring = t->caption(); + } +#endif + if(!tipstring.isEmpty()) + tip( QRect(pos, controlSize), tipstring ); + } +}; +#endif + +class QTitleBarPPrivate +{ +public: + QTitleBarPPrivate() + : toolTip( 0 ), act( 0 ), window( 0 ), movable( 1 ), pressed( 0 ), autoraise(0) + { + } + + QStyle::SCFlags buttonDown; + QPoint moveOffset; + QToolTip *toolTip; + bool act :1; + QWidget* window; + bool movable :1; + bool pressed :1; + bool autoraise :1; + QString cuttext; +}; + +QTitleBarP::QTitleBarP(QWidget* w, QWidget* parent, const char* name) + : QWidget( parent, name, WStyle_Customize | WStyle_NoBorder | WResizeNoErase | WRepaintNoErase ) +{ + d = new QTitleBarPPrivate(); + +#ifndef QT_NO_TOOLTIP + d->toolTip = new QTitleBarPTip( this ); +#endif + d->window = w; + d->buttonDown = QStyle::SC_None; + d->act = 0; + if ( w ) { + setWFlags( ((QTitleBarP*)w)->getWFlags() | WResizeNoErase | WRepaintNoErase ); +#ifndef QT_NO_WIDGET_TOPEXTRA + setCaption( w->caption() ); +#endif + } else { + setWFlags( WStyle_Customize | WResizeNoErase | WRepaintNoErase ); + } + + readColors(); + setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + setMouseTracking(TRUE); +} + +QTitleBarP::~QTitleBarP() +{ +#ifndef QT_NO_TOOLTIP + delete d->toolTip; +#endif + + delete d; + d = 0; +} + +#ifdef Q_WS_WIN +extern QRgb qt_colorref2qrgb(COLORREF col); +#endif + +void QTitleBarP::readColors() +{ + QPalette pal = palette(); + +#ifdef Q_WS_WIN // ask system properties on windows +#ifndef SPI_GETGRADIENTCAPTIONS +#define SPI_GETGRADIENTCAPTIONS 0x1008 +#endif +#ifndef COLOR_GRADIENTACTIVECAPTION +#define COLOR_GRADIENTACTIVECAPTION 27 +#endif +#ifndef COLOR_GRADIENTINACTIVECAPTION +#define COLOR_GRADIENTINACTIVECAPTION 28 +#endif + if ( QApplication::desktopSettingsAware() ) { + pal.setColor( QPalette::Active, QColorGroup::Highlight, qt_colorref2qrgb(GetSysColor(COLOR_ACTIVECAPTION)) ); + pal.setColor( QPalette::Inactive, QColorGroup::Highlight, qt_colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTION)) ); + pal.setColor( QPalette::Active, QColorGroup::HighlightedText, qt_colorref2qrgb(GetSysColor(COLOR_CAPTIONTEXT)) ); + pal.setColor( QPalette::Inactive, QColorGroup::HighlightedText, qt_colorref2qrgb(GetSysColor(COLOR_INACTIVECAPTIONTEXT)) ); + if ( qt_winver != Qt::WV_95 && qt_winver != WV_NT ) { + BOOL gradient; +#ifdef Q_OS_TEMP + SystemParametersInfo( SPI_GETGRADIENTCAPTIONS, 0, &gradient, 0 ); +#else +#if defined(UNICODE) + if ( qt_winver & Qt::WV_NT_based ) + SystemParametersInfo( SPI_GETGRADIENTCAPTIONS, 0, &gradient, 0 ); + else +#endif + SystemParametersInfoA( SPI_GETGRADIENTCAPTIONS, 0, &gradient, 0 ); +#endif + if ( gradient ) { + pal.setColor( QPalette::Active, QColorGroup::Base, qt_colorref2qrgb(GetSysColor(COLOR_GRADIENTACTIVECAPTION)) ); + pal.setColor( QPalette::Inactive, QColorGroup::Base, qt_colorref2qrgb(GetSysColor(COLOR_GRADIENTINACTIVECAPTION)) ); + } else { + pal.setColor( QPalette::Active, QColorGroup::Base, palette().active().highlight() ); + pal.setColor( QPalette::Inactive, QColorGroup::Base, palette().inactive().highlight() ); + } + } + } else +#endif // Q_WS_WIN + { + pal.setColor( QPalette::Active, QColorGroup::Highlight, palette().active().highlight() ); + pal.setColor( QPalette::Active, QColorGroup::Base, palette().active().highlight() ); + pal.setColor( QPalette::Inactive, QColorGroup::Highlight, palette().inactive().dark() ); + pal.setColor( QPalette::Inactive, QColorGroup::Base, palette().inactive().dark() ); + pal.setColor( QPalette::Inactive, QColorGroup::HighlightedText, palette().inactive().background() ); + } + + setPalette( pal ); + setActive( d->act ); +} + +void QTitleBarP::mousePressEvent( QMouseEvent * e) +{ + emit doActivate(); + if ( e->button() == LeftButton ) { + d->pressed = TRUE; + QStyle::SCFlags ctrl = style().querySubControl(QStyle::CC_TitleBar, this, e->pos()); + switch (ctrl) { + case QStyle::SC_TitleBarSysMenu: + if ( testWFlags( WStyle_SysMenu ) && !testWFlags( WStyle_Tool ) ) { + d->buttonDown = QStyle::SC_None; + static QTime* t = 0; + static QTitleBarP* tc = 0; + if ( !t ) + t = new QTime; + if ( tc != this || t->elapsed() > QApplication::doubleClickInterval() ) { + emit showOperationMenu(); + t->start(); + tc = this; + } else { + tc = 0; + emit doClose(); + return; + } + } + break; + + case QStyle::SC_TitleBarShadeButton: + case QStyle::SC_TitleBarUnshadeButton: + if ( testWFlags( WStyle_MinMax ) && testWFlags( WStyle_Tool ) ) + d->buttonDown = ctrl; + break; + + case QStyle::SC_TitleBarNormalButton: + if( testWFlags( WStyle_Minimize ) && !testWFlags( WStyle_Tool ) ) + d->buttonDown = ctrl; + break; + + case QStyle::SC_TitleBarMinButton: + if( testWFlags( WStyle_Minimize ) && !testWFlags( WStyle_Tool ) ) + d->buttonDown = ctrl; + break; + + case QStyle::SC_TitleBarMaxButton: + if ( testWFlags( WStyle_Maximize ) && !testWFlags( WStyle_Tool ) ) + d->buttonDown = ctrl; + break; + + case QStyle::SC_TitleBarCloseButton: + if ( testWFlags( WStyle_SysMenu ) ) + d->buttonDown = ctrl; + break; + + case QStyle::SC_TitleBarLabel: + d->buttonDown = ctrl; + d->moveOffset = mapToParent( e->pos() ); + break; + + default: + break; + } + repaint( FALSE ); + } else { + d->pressed = FALSE; + } +} + +void QTitleBarP::contextMenuEvent( QContextMenuEvent *e ) +{ + QStyle::SCFlags ctrl = style().querySubControl(QStyle::CC_TitleBar, this, e->pos()); + if( ctrl == QStyle::SC_TitleBarLabel || ctrl == QStyle::SC_TitleBarSysMenu ) { + emit popupOperationMenu(e->globalPos()); + e->accept(); + } +} + +void QTitleBarP::mouseReleaseEvent( QMouseEvent * e) +{ + if ( e->button() == LeftButton && d->pressed) { + QStyle::SCFlags ctrl = style().querySubControl(QStyle::CC_TitleBar, this, e->pos()); + + if (ctrl == d->buttonDown) { + switch(ctrl) { + case QStyle::SC_TitleBarShadeButton: + case QStyle::SC_TitleBarUnshadeButton: + if( testWFlags( WStyle_MinMax ) && testWFlags( WStyle_Tool ) ) + emit doShade(); + break; + + case QStyle::SC_TitleBarNormalButton: + if( testWFlags( WStyle_MinMax ) && !testWFlags( WStyle_Tool ) ) + emit doNormal(); + break; + + case QStyle::SC_TitleBarMinButton: + if( testWFlags( WStyle_Minimize ) && !testWFlags( WStyle_Tool ) ) + emit doMinimize(); + break; + + case QStyle::SC_TitleBarMaxButton: + if( d->window && testWFlags( WStyle_Maximize ) && !testWFlags( WStyle_Tool ) ) { + if(d->window->isMaximized()) + emit doNormal(); + else + emit doMaximize(); + } + break; + + case QStyle::SC_TitleBarCloseButton: + if( testWFlags( WStyle_SysMenu ) ) { + d->buttonDown = QStyle::SC_None; + repaint(FALSE); + emit doClose(); + return; + } + break; + + default: + break; + } + } + d->buttonDown = QStyle::SC_None; + repaint(FALSE); + d->pressed = FALSE; + } +} + +void QTitleBarP::mouseMoveEvent( QMouseEvent * e) +{ + switch (d->buttonDown) { + case QStyle::SC_None: + if(autoRaise()) + repaint( FALSE ); + break; + case QStyle::SC_TitleBarSysMenu: + break; + case QStyle::SC_TitleBarShadeButton: + case QStyle::SC_TitleBarUnshadeButton: + case QStyle::SC_TitleBarNormalButton: + case QStyle::SC_TitleBarMinButton: + case QStyle::SC_TitleBarMaxButton: + case QStyle::SC_TitleBarCloseButton: + { + QStyle::SCFlags last_ctrl = d->buttonDown; + d->buttonDown = style().querySubControl(QStyle::CC_TitleBar, this, e->pos()); + if( d->buttonDown != last_ctrl) + d->buttonDown = QStyle::SC_None; + repaint(FALSE); + d->buttonDown = last_ctrl; + } + break; + + case QStyle::SC_TitleBarLabel: + if ( d->buttonDown == QStyle::SC_TitleBarLabel && d->movable && d->pressed ) { + if ( (d->moveOffset - mapToParent( e->pos() ) ).manhattanLength() >= 4 ) { + QPoint p = mapFromGlobal(e->globalPos()); +#ifndef QT_NO_WORKSPACE + if(d->window && d->window->parentWidget()->inherits("QWorkspacePChild")) { + QWidget *w = d->window->parentWidget()->parentWidget(); + if(w && w->inherits("QWorkspaceP")) { + QWorkspaceP *workspace = (QWorkspaceP*)w; + p = workspace->mapFromGlobal( e->globalPos() ); + if ( !workspace->rect().contains(p) ) { + if ( p.x() < 0 ) + p.rx() = 0; + if ( p.y() < 0 ) + p.ry() = 0; + if ( p.x() > workspace->width() ) + p.rx() = workspace->width(); + if ( p.y() > workspace->height() ) + p.ry() = workspace->height(); + } + } + } +#endif + QPoint pp = p - d->moveOffset; + parentWidget()->move( pp ); + } + } else { + QStyle::SCFlags last_ctrl = d->buttonDown; + d->buttonDown = QStyle::SC_None; + if( d->buttonDown != last_ctrl) + repaint(FALSE); + } + break; + } +} + +void QTitleBarP::resizeEvent( QResizeEvent *r) +{ + QWidget::resizeEvent(r); + cutText(); +} + +void QTitleBarP::paintEvent(QPaintEvent *) +{ + QStyle::SCFlags ctrls = QStyle::SC_TitleBarLabel; + if ( testWFlags( WStyle_SysMenu) ) { + if ( testWFlags( WStyle_Tool ) ) { + ctrls |= QStyle::SC_TitleBarCloseButton; + if ( d->window && testWFlags( WStyle_MinMax ) ) { + if ( d->window->isMinimized() ) + ctrls |= QStyle::SC_TitleBarUnshadeButton; + else + ctrls |= QStyle::SC_TitleBarShadeButton; + } + } else { + ctrls |= QStyle::SC_TitleBarSysMenu | QStyle::SC_TitleBarCloseButton; + if ( d->window && testWFlags( WStyle_Minimize ) ) { + if( d->window && d->window->isMinimized() ) + ctrls |= QStyle::SC_TitleBarNormalButton; + else + ctrls |= QStyle::SC_TitleBarMinButton; + } + if ( d->window && testWFlags( WStyle_Maximize ) && !d->window->isMaximized() ) + ctrls |= QStyle::SC_TitleBarMaxButton; + } + } + + QStyle::SCFlags under_mouse = QStyle::SC_None; + if( autoRaise() && hasMouse() ) { + QPoint p(mapFromGlobal(QCursor::pos())); + under_mouse = style().querySubControl(QStyle::CC_TitleBar, this, p); + ctrls ^= under_mouse; + } + + QSharedDoubleBuffer buffer( (bool)FALSE, (bool)FALSE ); + buffer.begin( this, rect() ); + style().drawComplexControl(QStyle::CC_TitleBar, buffer.painter(), this, rect(), + colorGroup(), + isEnabled() ? QStyle::Style_Enabled : + QStyle::Style_Default, ctrls, d->buttonDown); + if(under_mouse != QStyle::SC_None) + style().drawComplexControl(QStyle::CC_TitleBar, buffer.painter(), this, rect(), + colorGroup(), + QStyle::Style_MouseOver | + (isEnabled() ? QStyle::Style_Enabled : 0), + under_mouse, d->buttonDown); +} + +void QTitleBarP::mouseDoubleClickEvent( QMouseEvent *e ) +{ + if ( e->button() != LeftButton ) + return; + + switch(style().querySubControl(QStyle::CC_TitleBar, this, e->pos())) { + case QStyle::SC_TitleBarLabel: + emit doubleClicked(); + break; + + case QStyle::SC_TitleBarSysMenu: + if ( testWFlags( WStyle_SysMenu ) ) + emit doClose(); + break; + + default: + break; + } +} + +void QTitleBarP::cutText() +{ +#ifndef QT_NO_WIDGET_TOPEXTRA + QFontMetrics fm( font() ); + + int maxw = style().querySubControlMetrics(QStyle::CC_TitleBar, this, + QStyle::SC_TitleBarLabel).width(); + if ( !d->window ) + maxw = width() - 20; + const QString txt = caption(); + d->cuttext = txt; + if ( fm.width( txt + "m" ) > maxw ) { + int i = txt.length(); + int dotlength = fm.width( "..." ); + while ( i>0 && fm.width(txt.left( i )) + dotlength > maxw ) + i--; + if(i != (int)txt.length()) + d->cuttext = txt.left( i ) + "..."; + } +#endif +} + +void QTitleBarP::setCaption( const QString& title ) +{ +#ifndef QT_NO_WIDGET_TOPEXTRA + if( caption() == title) + return; + QWidget::setCaption( title ); + cutText(); + + update(); +#endif +} + + +void QTitleBarP::setIcon( const QPixmap& icon ) +{ +#ifndef QT_NO_WIDGET_TOPEXTRA +#ifndef QT_NO_IMAGE_SMOOTHSCALE + QRect menur = style().querySubControlMetrics(QStyle::CC_TitleBar, this, + QStyle::SC_TitleBarSysMenu); + + QPixmap theIcon; + if (icon.width() > menur.width()) { + // try to keep something close to the same aspect + int aspect = (icon.height() * 100) / icon.width(); + int newh = (aspect * menur.width()) / 100; + theIcon.convertFromImage( icon.convertToImage().smoothScale(menur.width(), + newh) ); + } else if (icon.height() > menur.height()) { + // try to keep something close to the same aspect + int aspect = (icon.width() * 100) / icon.height(); + int neww = (aspect * menur.height()) / 100; + theIcon.convertFromImage( icon.convertToImage().smoothScale(neww, + menur.height()) ); + } else + theIcon = icon; + + QWidget::setIcon( theIcon ); +#else + QWidget::setIcon( icon ); +#endif + + update(); +#endif +} + +void QTitleBarP::leaveEvent( QEvent * ) +{ + if(autoRaise() && !d->pressed) + repaint( FALSE ); +} + +void QTitleBarP::enterEvent( QEvent * ) +{ + if(autoRaise() && !d->pressed) + repaint( FALSE ); + QEvent e( QEvent::Leave ); + QApplication::sendEvent( parentWidget(), &e ); +} + +void QTitleBarP::setActive( bool active ) +{ + if ( d->act == active ) + return ; + + d->act = active; + update(); +} + +bool QTitleBarP::isActive() const +{ + return d->act; +} + +bool QTitleBarP::usesActiveColor() const +{ + return ( isActive() && isActiveWindow() ) || + ( !window() && topLevelWidget()->isActiveWindow() ); +} + +QString QTitleBarP::visibleText() const +{ + return d->cuttext; +} + +QWidget *QTitleBarP::window() const +{ + return d->window; +} + +bool QTitleBarP::event( QEvent* e ) +{ + if ( e->type() == QEvent::ApplicationPaletteChange ) { + readColors(); + return TRUE; + } else if ( e->type() == QEvent::WindowActivate ) { + setActive( d->act ); + } else if ( e->type() == QEvent::WindowDeactivate ) { + bool wasActive = d->act; + setActive( FALSE ); + d->act = wasActive; + } + + return QWidget::event( e ); +} + +void QTitleBarP::setMovable(bool b) +{ + d->movable = b; +} + +bool QTitleBarP::isMovable() const +{ + return d->movable; +} + +void QTitleBarP::setAutoRaise(bool b) +{ + d->autoraise = b; +} + +bool QTitleBarP::autoRaise() const +{ + return d->autoraise; +} + +QSize QTitleBarP::sizeHint() const +{ + constPolish(); + QRect menur = style().querySubControlMetrics(QStyle::CC_TitleBar, this, + QStyle::SC_TitleBarSysMenu); + return QSize( menur.width(), style().pixelMetric( QStyle::PM_TitleBarHeight, this ) ); +} + diff --git a/src/PatchQt/qworkspaceP.h b/src/PatchQt/qworkspaceP.h new file mode 100644 index 000000000..f037a3e50 --- /dev/null +++ b/src/PatchQt/qworkspaceP.h @@ -0,0 +1,322 @@ +// File : qworkspaceP.h +// Created : UI team, 21.11.02 +// Descr : Patch for QWorkspace class (Qt 3.0.5) + +// Modified : Mon Nov 25 09:30:11 2002 +// Author : Vadim SANDLER +// Project : SALOME +// Module : PatchQt +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef QWORKSPACEP_H +#define QWORKSPACEP_H + +#ifndef QT_H +#include +#include +#include +#include +#include +#include +#include +#endif // QT_H + +class QWorkspacePChild; +class QShowEvent; +class QWorkspacePPrivate; +class QPopupMenu; +class QWidgetResizeHandlerP; +class QTitleBarP; + +class Q_EXPORT QWorkspaceP : public QWidget +{ + Q_OBJECT + Q_PROPERTY( bool scrollBarsEnabled READ scrollBarsEnabled WRITE setScrollBarsEnabled ) +public: + QWorkspaceP( QWidget* parent=0, const char* name=0 ); + ~QWorkspaceP(); + + QWidget* activeWindow() const; + QWidgetList windowList() const; + + QSize sizeHint() const; + + bool scrollBarsEnabled() const; + void setScrollBarsEnabled( bool enable ); + + void setPaletteBackgroundColor( const QColor & ); + void setPaletteBackgroundPixmap( const QPixmap & ); + +signals: + void windowActivated( QWidget* w); + +public slots: + void cascade(); + void tile(); + +protected: +#ifndef QT_NO_STYLE + void styleChange( QStyle& ); +#endif + void childEvent( QChildEvent * ); + void resizeEvent( QResizeEvent * ); + bool eventFilter( QObject *, QEvent * ); + void showEvent( QShowEvent *e ); + void hideEvent( QHideEvent *e ); +#ifndef QT_NO_WHEELEVENT + void wheelEvent( QWheelEvent *e ); +#endif + +private slots: + void closeActiveWindow(); + void closeAllWindows(); + void normalizeActiveWindow(); + void minimizeActiveWindow(); + void showOperationMenu(); + void popupOperationMenu( const QPoint& ); + void operationMenuActivated( int ); + void operationMenuAboutToShow(); + void toolMenuAboutToShow(); + void scrollBarChanged(); +public slots: + void activateNextWindow(); + void activatePreviousWindow(); + +public: + void activateWindow( QWidget* w, bool change_focus = TRUE ); + +private: + void insertIcon( QWidget* w); + void removeIcon( QWidget* w); + void place( QWidget* ); + + QWorkspacePChild* findChild( QWidget* w); + void showMaximizeControls(); + void hideMaximizeControls(); + void showWindow( QWidget* w); + void maximizeWindow( QWidget* w); + void minimizeWindow( QWidget* w); + void normalizeWindow( QWidget* w); + + QRect updateWorkspace(); + + QPopupMenu* popup; + QWorkspacePPrivate* d; + + friend class QWorkspacePChild; + +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + QWorkspaceP( const QWorkspaceP & ); + QWorkspaceP& operator=( const QWorkspaceP & ); +#endif +}; + +class QWorkspacePChild : public QFrame +{ + Q_OBJECT + + friend class QWorkspaceP; + friend class QTitleBarP; + +public: + QWorkspacePChild( QWidget* window, + QWorkspaceP* parent=0, const char* name=0 ); + ~QWorkspacePChild(); + + void setActive( bool ); + bool isActive() const; + + void adjustToFullscreen(); + void adjustSize(); + + QWidget* windowWidget() const; + QWidget* iconWidget() const; + + void doResize(); + void doMove(); + + QSize sizeHint() const; + QSize minimumSizeHint() const; + + QSize baseSize() const; + +signals: + void showOperationMenu(); + void popupOperationMenu( const QPoint& ); + +public slots: + void activate(); + void showMinimized(); + void showMaximized(); + void showNormal(); + void showShaded(); + void setCaption( const QString& ); + void internalRaise(); + void titleBarDoubleClicked(); + + void move( int x, int y ); + +protected: + void enterEvent( QEvent * ); + void leaveEvent( QEvent * ); + void childEvent( QChildEvent* ); + void resizeEvent( QResizeEvent * ); + void moveEvent( QMoveEvent * ); + bool eventFilter( QObject *, QEvent * ); + + bool focusNextPrevChild( bool ); + + void drawFrame( QPainter * ); + void styleChange( QStyle & ); + +private: + QWidget* childWidget; + QWidget* lastfocusw; + QWidgetResizeHandlerP *widgetResizeHandler; + QTitleBarP* titlebar; + QGuardedPtr iconw; + QSize windowSize; + QSize shadeRestore; + QSize shadeRestoreMin; + bool act :1; + bool shademode :1; + bool snappedRight :1; + bool snappedDown :1; +}; + +#ifndef QT_H +#endif // QT_H +class QMouseEvent; +class QKeyEvent; + +class Q_EXPORT QWidgetResizeHandlerP : public QObject +{ + Q_OBJECT + +public: + QWidgetResizeHandlerP( QWidget *parent, QWidget *cw = 0, const char *name = 0 ); + void setActive( bool b ) { active = b; if ( !active ) setMouseCursor( Nowhere ); } + bool isActive() const { return active; } + void setMovingEnabled( bool b ) { moving = b; } + bool isMovingEnabled() const { return moving; } + + bool isButtonDown() const { return buttonDown; } + + void setExtraHeight( int h ) { extrahei = h; } + void setSizeProtection( bool b ) { sizeprotect = b; } + + void doResize(); + void doMove(); + +signals: + void activate(); + +protected: + bool eventFilter( QObject *o, QEvent *e ); + void mouseMoveEvent( QMouseEvent *e ); + void keyPressEvent( QKeyEvent *e ); + +private: + enum MousePosition { + Nowhere, + TopLeft, BottomRight, BottomLeft, TopRight, + Top, Bottom, Left, Right, + Center + }; + + QWidget *widget; + QWidget *childWidget; + QPoint moveOffset; + QPoint invertedMoveOffset; + MousePosition mode; + int extrahei; + int range; + uint buttonDown :1; + uint moveResizeMode :1; + uint active :1; + uint sizeprotect :1; + uint moving :1; + + void setMouseCursor( MousePosition m ); + bool isMove() const { + return moveResizeMode && mode == Center; + } + bool isResize() const { + return moveResizeMode && !isMove(); + } + +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + QWidgetResizeHandlerP( const QWidgetResizeHandlerP & ); + QWidgetResizeHandlerP& operator=( const QWidgetResizeHandlerP & ); +#endif + +}; + +class QToolTip; +class QTitleBarPPrivate; +class QPixmap; + +class Q_EXPORT QTitleBarP : public QWidget +{ + Q_OBJECT + Q_PROPERTY( bool autoRaise READ autoRaise WRITE setAutoRaise ) + Q_PROPERTY( bool movable READ isMovable WRITE setMovable ) + +public: + QTitleBarP (QWidget* w, QWidget* parent, const char* name=0); + ~QTitleBarP(); + + bool isActive() const; + bool usesActiveColor() const; + virtual QString visibleText() const; + + bool isMovable() const; + void setMovable(bool); + + bool autoRaise() const; + void setAutoRaise(bool); + + QWidget *window() const; + + QSize sizeHint() const; + +public slots: + void setActive( bool ); + void setCaption( const QString& title ); + void setIcon( const QPixmap& icon ); + +signals: + void doActivate(); + void doNormal(); + void doClose(); + void doMaximize(); + void doMinimize(); + void doShade(); + void showOperationMenu(); + void popupOperationMenu( const QPoint& ); + void doubleClicked(); + +protected: + bool event( QEvent *); + void resizeEvent( QResizeEvent *); + void contextMenuEvent( QContextMenuEvent * ); + void mousePressEvent( QMouseEvent * ); + void mouseDoubleClickEvent( QMouseEvent * ); + void mouseReleaseEvent( QMouseEvent * ); + void mouseMoveEvent( QMouseEvent * ); + void enterEvent( QEvent *e ); + void leaveEvent( QEvent *e ); + void paintEvent( QPaintEvent *p ); + + virtual void cutText(); + +private: + void readColors(); + + QTitleBarPPrivate *d; +}; + +#endif // QWORKSPACEP_H diff --git a/src/Plot2d/Makefile.in b/src/Plot2d/Makefile.in new file mode 100644 index 000000000..ca9ee3deb --- /dev/null +++ b/src/Plot2d/Makefile.in @@ -0,0 +1,58 @@ +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_HEADERS = \ + Plot2d.h \ + Plot2d_Curve.h \ + Plot2d_CurveContainer.h \ + Plot2d_ViewFrame.h \ + Plot2d_SetupViewDlg.h \ + Plot2d_SetupPlot2dDlg.h + +# .po files to transform in .qm +#PO_FILES = \ + +# Libraries targets + +LIB = libPlot2d.la +LIB_SRC = \ + Plot2d.cxx \ + Plot2d_Curve.cxx \ + Plot2d_CurveContainer.cxx \ + Plot2d_ViewFrame.cxx \ + Plot2d_SetupViewDlg.cxx \ + Plot2d_SetupPlot2dDlg.cxx + +LIB_MOC = \ + Plot2d.h \ + Plot2d_ViewFrame.h \ + Plot2d_SetupViewDlg.h \ + Plot2d_SetupPlot2dDlg.h + +LIB_CLIENT_IDL = SALOMEDS.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + SALOME_Exception.idl +#LIB_CLIENT_IDL = SALOMEDS.idl + +#CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) +#CPPFLAGS+=$(QT_INCLUDES) $(QWT_INCLUDES) $(PYTHON_INCLUDES) +#LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) -lSalomeNS -lqsplitterP -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject +#LDFLAGS+=$(QT_MT_LIBS) $(QWT_LIBS) + +CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(OGL_INCLUDES) $(PYTHON_INCLUDES) $(QWT_INCLUDES) +LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(OGL_LIBS) $(QWT_LIBS) + + +@CONCLUDE@ + + + + + diff --git a/src/Plot2d/Plot2d.cxx b/src/Plot2d/Plot2d.cxx new file mode 100644 index 000000000..07f33f4b3 --- /dev/null +++ b/src/Plot2d/Plot2d.cxx @@ -0,0 +1,23 @@ +// File : Plot2d.cxx +// Created : Wed Mar 20 11:56:18 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "Plot2d.h" +#include "Plot2d_ViewFrame.h" + +QAD_ViewFrame* Plot2d::createView(QAD_RightFrame* parent) +{ + return new Plot2d_ViewFrame( parent, "plotView" ); +} + +extern "C" +{ + QAD_ViewFrame* createView(QAD_RightFrame* parent) + { + return Plot2d::createView(parent); + } +} diff --git a/src/Plot2d/Plot2d.h b/src/Plot2d/Plot2d.h new file mode 100644 index 000000000..dc61b815e --- /dev/null +++ b/src/Plot2d/Plot2d.h @@ -0,0 +1,25 @@ +// File : Plot2d.h +// Created : Wed Mar 20 11:56:18 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : OCCViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef Plot2d_HeaderFile +#define Plot2d_HeaderFile + +#include "QAD_RightFrame.h" +#include "QAD_ViewFrame.h" + +class Plot2d : public QObject +{ + Q_OBJECT + +public : + + Standard_EXPORT static QAD_ViewFrame* createView ( QAD_RightFrame* parent); + +}; + +#endif // Plot2d_HeaderFile diff --git a/src/Plot2d/Plot2d_Curve.cxx b/src/Plot2d/Plot2d_Curve.cxx new file mode 100644 index 000000000..1db1bf345 --- /dev/null +++ b/src/Plot2d/Plot2d_Curve.cxx @@ -0,0 +1,229 @@ +using namespace std; +// File : Plot2d_Curve.cxx +// Created : UI team, 05.09.00 +// Descrip : Curve class + +// Modified : Mon Dec 03 15:37:21 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : Plot2d +// Copyright : Open CASCADE 2001 +// $Header$ + +#include "Plot2d_Curve.h" +#include "utilities.h" + +/*! + Constructor +*/ +Plot2d_Curve::Plot2d_Curve() + : myHorTitle( "" ), myVerTitle( "" ), + myHorUnits( "" ), myVerUnits( "" ), + myAutoAssign( true ), myColor( 0,0,0 ), myMarker( Circle ), myLine( Solid ), myLineWidth( 0 ) +{ +} +/*! + Destructor +*/ +Plot2d_Curve::~Plot2d_Curve() +{ +// MESSAGE("Plot2d_Curve::~Plot2d_Curve"); +} +/*! + Copy constructor. Makes deep copy of data. +*/ +Plot2d_Curve::Plot2d_Curve( const Plot2d_Curve& curve ) +{ + myAutoAssign = curve.isAutoAssign(); + myHorTitle = curve.getHorTitle(); + myVerTitle = curve.getVerTitle(); + myHorUnits = curve.getHorUnits(); + myVerUnits = curve.getVerUnits(); + myColor = curve.getColor(); + myMarker = curve.getMarker(); + myLine = curve.getLine(); + myLineWidth = curve.getLineWidth(); + myHorData.duplicate( curve.horData(), curve.nbPoints() ); + myVerData.duplicate( curve.verData(), curve.nbPoints() ); +} +/*! + operator=. Makes deep copy of data. +*/ +Plot2d_Curve& Plot2d_Curve::operator=( const Plot2d_Curve& curve ) +{ + myAutoAssign = curve.isAutoAssign(); + myHorTitle = curve.getHorTitle(); + myVerTitle = curve.getVerTitle(); + myHorUnits = curve.getHorUnits(); + myVerUnits = curve.getVerUnits(); + myColor = curve.getColor(); + myMarker = curve.getMarker(); + myLine = curve.getLine(); + myLineWidth = curve.getLineWidth(); + myHorData.duplicate( curve.horData(), curve.nbPoints() ); + myVerData.duplicate( curve.verData(), curve.nbPoints() ); + return *this; +} +/*! + Sets curve's horizontal title +*/ +void Plot2d_Curve::setHorTitle( const QString& title ) +{ + myHorTitle = title; +} +/*! + Gets curve's horizontal title +*/ +QString Plot2d_Curve::getHorTitle() const +{ + return myHorTitle; +} +/*! + Sets curve's vertical title +*/ +void Plot2d_Curve::setVerTitle( const QString& title ) +{ + myVerTitle = title; +} +/*! + Gets curve's vertical title +*/ +QString Plot2d_Curve::getVerTitle() const +{ + return myVerTitle; +} +/*! + Sets curve's horizontal units +*/ +void Plot2d_Curve::setHorUnits( const QString& units ) +{ + myHorUnits = units; +} +/*! + Gets curve's horizontal units +*/ +QString Plot2d_Curve::getHorUnits() const +{ + return myHorUnits; +} +/*! + Sets curve's vertical units +*/ +void Plot2d_Curve::setVerUnits( const QString& units ) +{ + myVerUnits = units; +} +/*! + Gets curve's vertical units +*/ +QString Plot2d_Curve::getVerUnits() const +{ + return myVerUnits; +} +/*! + Sets curve's data. Makes shallow copy of data. +*/ +void Plot2d_Curve::setData( const double* hData, const double* vData, long size ) +{ + myHorData.assign( hData, size ); + myVerData.assign( vData, size ); +} +/*! + Gets curve's data : abscissas of points +*/ +double* Plot2d_Curve::horData() const +{ + return myHorData.data(); +} +/*! + Gets curve's data : ordinates of points +*/ +double* Plot2d_Curve::verData() const +{ + return myVerData.data(); +} +/*! + Gets curve's data : number of points +*/ +long Plot2d_Curve::nbPoints() const +{ + return myHorData.size(); +} +/*! + Returns true if curve has no data +*/ +bool Plot2d_Curve::isEmpty() const +{ + return ( myHorData.isEmpty() || myVerData.isEmpty() ); +} +/*! + Sets curve's AutoAssign flag - in this case attributes will be set automatically +*/ +void Plot2d_Curve::setAutoAssign( bool on ) +{ + myAutoAssign = on; +} +/*! + Gets curve's AutoAssign flag state +*/ +bool Plot2d_Curve::isAutoAssign() const +{ + return myAutoAssign; +} +/*! + Sets curve's color ( and resets AutoAssign flag ) +*/ +void Plot2d_Curve::setColor( const QColor color ) +{ + myColor = color; + myAutoAssign = false; +} +/*! + Gets curve's color +*/ +QColor Plot2d_Curve::getColor() const +{ + return myColor; +} +/*! + Sets curve's marker ( and resets AutoAssign flag ) +*/ +void Plot2d_Curve::setMarker( MarkerType marker ) +{ + myMarker = marker; + myAutoAssign = false; +} +/*! + Gets curve's marker +*/ +Plot2d_Curve::MarkerType Plot2d_Curve::getMarker() const +{ + return myMarker; +} +/*! + Sets curve's line type and width ( and resets AutoAssign flag ) + NOTE : A line width of 0 will produce a 1 pixel wide line using a fast algorithm for diagonals. + A line width of 1 will also produce a 1 pixel wide line, but uses a slower more accurate algorithm for diagonals. + For horizontal and vertical lines a line width of 0 is the same as a line width of 1. +*/ +void Plot2d_Curve::setLine( LineType line, const int lineWidth ) +{ + myLine = line; + myLineWidth = lineWidth; + if ( myLineWidth < 0 ) myLineWidth = 0; + myAutoAssign = false; +} +/*! + Gets curve's line type +*/ +Plot2d_Curve::LineType Plot2d_Curve::getLine() const +{ + return myLine; +} +/*! + Gets curve's line width +*/ +int Plot2d_Curve::getLineWidth() const +{ + return myLineWidth; +} diff --git a/src/Plot2d/Plot2d_Curve.h b/src/Plot2d/Plot2d_Curve.h new file mode 100644 index 000000000..e000cf802 --- /dev/null +++ b/src/Plot2d/Plot2d_Curve.h @@ -0,0 +1,84 @@ +// File : Plot2d_Curve.h +// Created : UI team, 05.09.00 +// Descrip : Curve class + +// Modified : Mon Dec 03 15:37:21 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : Plot2d +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef Plot2d_Curve_h +#define Plot2d_Curve_h + +#include +#include +#include +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif +#include "SALOME_InteractiveObject.hxx" + +typedef QMemArray DoubleArray; + +class Plot2d_Curve +{ +public: + enum MarkerType { None, Circle, Rectangle, Diamond, + DTriangle, UTriangle, LTriangle, RTriangle, + Cross, XCross }; + enum LineType { NoPen, Solid, Dash, Dot, DashDot, DashDotDot }; + + Plot2d_Curve(); + ~Plot2d_Curve(); + Plot2d_Curve( const Plot2d_Curve& curve ); + Plot2d_Curve& operator= ( const Plot2d_Curve& curve ); + + void setHorTitle( const QString& title ); + QString getHorTitle() const; + void setVerTitle( const QString& title ); + QString getVerTitle() const; + void setHorUnits( const QString& units ); + QString getHorUnits() const; + void setVerUnits( const QString& units ); + QString getVerUnits() const; + void setData( const double* hData, const double* vData, long size ); + double* horData() const; + double* verData() const; + long nbPoints() const; + bool isEmpty() const; + + void setAutoAssign( bool on ); + bool isAutoAssign() const; + void setColor( const QColor color ); + QColor getColor() const; + void setMarker( MarkerType marker ); + MarkerType getMarker() const; + void setLine( LineType line, const int lineWidth = 0 ); + LineType getLine() const; + int getLineWidth() const; + + virtual bool hasIO() { return !myIO.IsNull(); } + virtual Handle(SALOME_InteractiveObject) getIO() { return myIO; } + virtual void setIO( const Handle(SALOME_InteractiveObject)& io ) { myIO = io; } + +private: + Handle(SALOME_InteractiveObject) myIO; + + bool myAutoAssign; + QString myHorTitle; + QString myVerTitle; + QString myHorUnits; + QString myVerUnits; + QColor myColor; + MarkerType myMarker; + LineType myLine; + int myLineWidth; + DoubleArray myHorData; + DoubleArray myVerData; +}; + +#endif // Plot2d_Curve_h + + diff --git a/src/Plot2d/Plot2d_CurveContainer.cxx b/src/Plot2d/Plot2d_CurveContainer.cxx new file mode 100644 index 000000000..12d4966aa --- /dev/null +++ b/src/Plot2d/Plot2d_CurveContainer.cxx @@ -0,0 +1,79 @@ +using namespace std; +// File : Plot2d_CurveContainer.cxx +// Created : UI team, 05.09.00 +// Descrip : Curve container class + +// Modified : Mon Dec 03 15:37:21 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : Plot2d +// Copyright : Open CASCADE 2001 +// $Header$ + +#include "Plot2d_CurveContainer.h" + +/*! + Constructor +*/ +Plot2d_CurveContainer::Plot2d_CurveContainer() +{ + myCurves.setAutoDelete( false ); +} +/*! + Destructor +*/ +Plot2d_CurveContainer::~Plot2d_CurveContainer() +{ + +} +/*! + Adds curve if not exist yet in the container +*/ +void Plot2d_CurveContainer::addCurve( Plot2d_Curve* curve ) +{ + if ( myCurves.find( curve ) < 0 ) + myCurves.append( curve ); +} +/*! + Removes curve form the container ( and deletes it if is true ) +*/ +void Plot2d_CurveContainer::removeCurve( const int index, bool alsoDelete ) +{ + Plot2d_Curve* curve = myCurves.take( index ); + if ( curve && alsoDelete ) + delete curve; +} +/*! + Clears container contents ( removes and deletes all curves ) +*/ +void Plot2d_CurveContainer::clear( bool alsoDelete ) +{ + while( myCurves.count() > 0 ) { + Plot2d_Curve* curve = myCurves.take( 0 ); + if ( curve && alsoDelete ) + delete curve; + } +} +/*! + Gets nb of curves in container +*/ +int Plot2d_CurveContainer::count() +{ + return myCurves.count(); +} +/*! + Returns true if contains no curves +*/ +bool Plot2d_CurveContainer::isEmpty() +{ + return myCurves.isEmpty(); +} +/*! + Gets curve by index +*/ +Plot2d_Curve* Plot2d_CurveContainer::curve( const int index ) +{ + return myCurves.at( index ); +} + + diff --git a/src/Plot2d/Plot2d_CurveContainer.h b/src/Plot2d/Plot2d_CurveContainer.h new file mode 100644 index 000000000..c018f430d --- /dev/null +++ b/src/Plot2d/Plot2d_CurveContainer.h @@ -0,0 +1,37 @@ +// File : Plot2d_CurveContainer.h +// Created : UI team, 05.09.00 +// Descrip : Curve container class + +// Modified : Mon Dec 03 15:37:21 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : Plot2d +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef Plot2d_CurveContainer_h +#define Plot2d_CurveContainer_h + +#include "Plot2d_Curve.h" +#include + +class Plot2d_CurveContainer +{ +public: + Plot2d_CurveContainer(); + ~Plot2d_CurveContainer(); + + void addCurve( Plot2d_Curve* curve ); + void removeCurve( const int index, bool alsoDelete = false ) ; + void clear( bool alsoDelete = false ); + int count(); + bool isEmpty(); + Plot2d_Curve* curve( const int index ); + +private: + QList myCurves; +}; + +#endif // Plot2d_CurveContainer_h + + diff --git a/src/Plot2d/Plot2d_SetupPlot2dDlg.cxx b/src/Plot2d/Plot2d_SetupPlot2dDlg.cxx new file mode 100644 index 000000000..e393db76c --- /dev/null +++ b/src/Plot2d/Plot2d_SetupPlot2dDlg.cxx @@ -0,0 +1,673 @@ +// File : Plot2d_SetupPlot2dDlg.cxx +// Created : Wed Jun 27 16:39:06 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "Plot2d_SetupPlot2dDlg.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_Tools.h" +#include "QAD_MessageBox.h" +#include "Plot2d_Curve.h" +#include "Plot2d_CurveContainer.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DLG_SIZE_WIDTH 500 +#define DLG_SIZE_HEIGHT 400 +#define MAX_LINE_WIDTH 100 +#define MARGIN_SIZE 11 +#define SPACING_SIZE 6 + +/*! + Constructor +*/ +Plot2d_SetupPlot2dDlg::Plot2d_SetupPlot2dDlg( SALOMEDS::SObject_var object, QWidget* parent ) + : QDialog( parent ? parent : QAD_Application::getDesktop(), + "Plot2d_SetupPlot2dDlg", + true, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr("TLT_SETUP_PLOT2D") ); + setSizeGripEnabled( TRUE ); + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setSpacing( SPACING_SIZE ); + topLayout->setMargin( MARGIN_SIZE ); + + myItems.setAutoDelete( false ); + + myObject = SALOMEDS::SObject::_duplicate( object ); + + /* Top scroll view */ + myView = new QScrollView( this ); + QFrame* frame = new QFrame( myView ); + frame->setFrameStyle( QFrame::Plain | QFrame::NoFrame ); + QGridLayout* frameLayout = new QGridLayout( frame, 1, 12 ); + frameLayout->setMargin( MARGIN_SIZE ); frameLayout->setSpacing( SPACING_SIZE ); + + QFrame* lin; + + QLabel* labAxis = new QLabel( tr( "AXIS_LBL" ), frame ); + QLabel* labData = new QLabel( tr( "DATA_LBL" ), frame ); + QLabel* labUnit = new QLabel( tr( "UNITS_LBL" ), frame ); + QLabel* labAttr = new QLabel( tr( "ATTRIBUTES_LBL" ), frame ); + labAxis->setAlignment( AlignCenter ); + labData->setAlignment( AlignCenter ); + labUnit->setAlignment( AlignCenter ); + labAttr->setAlignment( AlignCenter ); + QFont font = labAxis->font(); font.setBold( true ); + labAxis->setFont( font ); + labData->setFont( font ); + labUnit->setFont( font ); + labAttr->setFont( font ); + + frameLayout->addMultiCellWidget( labAxis, 0, 0, 0, 1 ); + lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); + frameLayout->addWidget( lin, 0, 2 ); + frameLayout->addWidget( labData, 0, 3 ); + lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); + frameLayout->addWidget( lin, 0, 4 ); + frameLayout->addWidget( labUnit, 0, 5 ); + lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); + frameLayout->addWidget( lin, 0, 6 ); + frameLayout->addMultiCellWidget( labAttr, 0, 0, 7, 11 ); + frameLayout->setColStretch( 12, 5 ); + lin = new QFrame( frame ); lin->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + frameLayout->addMultiCellWidget( lin, 1, 1, 0, 12 ); + + int row = 2; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeTableOfInteger_var tblIntAttr; + SALOMEDS::AttributeTableOfReal_var tblRealAttr; + + /* Try table of integer */ + if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) { + tblIntAttr = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr ); + if ( !tblIntAttr->_is_nil() ) { + try { + int nbRows = tblIntAttr->GetNbRows() ; + SALOMEDS::StringSeq_var rowTitles = tblIntAttr->GetRowTitles(); + SALOMEDS::StringSeq_var rowUnits = tblIntAttr->GetRowUnits(); + for ( int i = 0; i < nbRows; i++ ) { + Plot2d_ItemContainer* item = new Plot2d_ItemContainer( this ); + item->createWidgets( frame ); + frameLayout->addWidget( item->myHBtn, row, 0 ); + frameLayout->addWidget( item->myVBtn, row, 1 ); + frameLayout->addWidget( item->myTitleLab, row, 3 ); + if ( rowTitles->length() > 0 ) + item->myTitleLab->setText( QString( strdup( rowTitles[ i ] ) ) ); + frameLayout->addWidget( item->myUnitLab, row, 5 ); + if ( rowUnits->length() > 0 ) + item->myUnitLab->setText( QString( strdup( rowUnits[ i ] ) ) ); + frameLayout->addWidget( item->myAutoCheck, row, 7 ); + frameLayout->addWidget( item->myLineCombo, row, 8 ); + frameLayout->addWidget( item->myLineSpin, row, 9 ); + frameLayout->addWidget( item->myMarkerCombo, row, 10 ); + frameLayout->addWidget( item->myColorBtn, row, 11 ); + connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) ); + connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) ); + myItems.append( item ); + row++; + } + } + catch( ... ) { + MESSAGE("Plot2d_SetupPlot2dDlg::Plot2d_SetupPlot2dDlg : Exception has been caught (int)!!!"); + } + } + } + /* Try table of real */ + else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) { + tblRealAttr = SALOMEDS::AttributeTableOfReal::_narrow( anAttr ); + if ( !tblRealAttr->_is_nil() ) { + try { + int nbRows = tblRealAttr->GetNbRows() ; + SALOMEDS::StringSeq_var rowTitles = tblRealAttr->GetRowTitles(); + SALOMEDS::StringSeq_var rowUnits = tblRealAttr->GetRowUnits(); + for ( int i = 0; i < nbRows; i++ ) { + Plot2d_ItemContainer* item = new Plot2d_ItemContainer( this ); + item->createWidgets( frame ); + frameLayout->addWidget( item->myHBtn, row, 0 ); + frameLayout->addWidget( item->myVBtn, row, 1 ); + frameLayout->addWidget( item->myTitleLab, row, 3 ); + if ( rowTitles->length() > 0 ) + item->myTitleLab->setText( QString( strdup( rowTitles[ i ] ) ) ); + frameLayout->addWidget( item->myUnitLab, row, 5 ); + if ( rowUnits->length() > 0 ) + item->myUnitLab->setText( QString( strdup( rowUnits[ i ] ) ) ); + frameLayout->addWidget( item->myAutoCheck, row, 7 ); + frameLayout->addWidget( item->myLineCombo, row, 8 ); + frameLayout->addWidget( item->myLineSpin, row, 9 ); + frameLayout->addWidget( item->myMarkerCombo, row, 10 ); + frameLayout->addWidget( item->myColorBtn, row, 11 ); + connect( item, SIGNAL( horToggled( bool ) ), this, SLOT( onHBtnToggled( bool ) ) ); + connect( item, SIGNAL( verToggled( bool ) ), this, SLOT( onVBtnToggled( bool ) ) ); + myItems.append( item ); + row++; + } + } + catch( ... ) { + MESSAGE("Plot2d_SetupPlot2dDlg::Plot2d_SetupPlot2dDlg : Exception has been caught (real)!!!"); + } + } + } + lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); + frameLayout->addMultiCellWidget( lin, 2, row+1, 2, 2 ); + lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); + frameLayout->addMultiCellWidget( lin, 2, row+1, 4, 4 ); + lin = new QFrame( frame ); lin->setFrameStyle( QFrame::VLine | QFrame::Sunken ); + frameLayout->addMultiCellWidget( lin, 2, row+1, 6, 6 ); + frameLayout->setRowStretch( row+1, 5 ); + + myView->addChild( frame, 0, 0 ); + myView->setResizePolicy( QScrollView::AutoOneFit ); + + myView->setMinimumWidth( frame->sizeHint().width() + MARGIN_SIZE * 2 ); + + /* OK/Cancel buttons */ + myOkBtn = new QPushButton( tr( "BUT_OK" ), this, "buttonOk" ); + myOkBtn->setAutoDefault( TRUE ); + myOkBtn->setDefault( TRUE ); + myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this, "buttonCancel" ); + myCancelBtn->setAutoDefault( TRUE ); + + topLayout->addMultiCellWidget( myView, 0, 0, 0, 2 ); + topLayout->addWidget( myOkBtn, 1, 0 ); + topLayout->setColStretch( 1, 5 ); + topLayout->addWidget( myCancelBtn, 1, 2 ); + + connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + enableControls(); + + /* Center widget inside it's parent widget */ + resize( DLG_SIZE_WIDTH, DLG_SIZE_HEIGHT ); + QAD_Tools::centerWidget( this, parentWidget() ); +} +/*! + Destructor +*/ +Plot2d_SetupPlot2dDlg::~Plot2d_SetupPlot2dDlg() +{ +} +/*! + Gets curves info ( indexes of row data in the table for horizontal and verical axes ) +*/ +void Plot2d_SetupPlot2dDlg::getCurvesSource( int& horIndex, QValueList& verIndexes ) +{ + /* collecting horizontal and vertical axis items */ + horIndex = -1; + int i, j; + for ( i = 0; i < myItems.count(); i++ ) { + if ( myItems.at( i )->isHorizontalOn() ) { + horIndex = i; + } + else if ( myItems.at( i )->isVerticalOn() ) { + verIndexes.append( i ); + } + } +} +/*! + Gets curve attributes +*/ +bool Plot2d_SetupPlot2dDlg::getCurveAttributes( const int vIndex, + bool& isAuto, + int& marker, + int& line, + int& lineWidth, + QColor& color) +{ + if ( vIndex >= 0 && vIndex < myItems.count() ) { + isAuto = myItems.at( vIndex )->isAutoAssign(); + marker = myItems.at( vIndex )->getMarker(); + line = myItems.at( vIndex )->getLine(); + lineWidth = myItems.at( vIndex )->getLineWidth(); + color = myItems.at( vIndex )->getColor(); + return true; + } + return false; +} +/*! + Creates and returns curves presentations +*/ +void Plot2d_SetupPlot2dDlg::getCurves( Plot2d_CurveContainer& container ) +{ + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeTableOfInteger_var tblIntAttr; + SALOMEDS::AttributeTableOfReal_var tblRealAttr; + + /* clearing container contents */ + container.clear(); + + /* collecting horizontal and vertical axis items */ + int horIndex; + int i, j; + QValueList verIndex; + getCurvesSource( horIndex, verIndex ); + if ( horIndex < 0 || verIndex.isEmpty() ) /* no curves can be created */ + return; + + /* Try table of integer */ + if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) { + tblIntAttr = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr ); + if ( !tblIntAttr->_is_nil() ) { + try { + int nbCols = tblIntAttr->GetNbColumns() ; + SALOMEDS::StringSeq_var rowTitles = tblIntAttr->GetRowTitles(); + SALOMEDS::StringSeq_var rowUnits = tblIntAttr->GetRowUnits(); + + for ( i = 0; i < verIndex.count(); i++ ) { + Plot2d_Curve* curve = new Plot2d_Curve(); + // curve titles + if ( rowTitles->length() > 0 ) { + curve->setHorTitle( strdup( rowTitles[ horIndex ] ) ); + curve->setVerTitle( strdup( rowTitles[ verIndex[i] ] ) ); + } + // curve units + if ( rowUnits->length() > 0 ) { + curve->setHorUnits( strdup( rowUnits[ horIndex ] ) ); + curve->setVerUnits( strdup( rowUnits[ verIndex[i] ] ) ); + } + // curve data + int nbPoints = 0; + for ( j = 1; j <= nbCols; j++ ) { + if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) ) + nbPoints++; + } + if ( nbPoints > 0 ) { + double* xList = new double[ nbPoints ]; + double* yList = new double[ nbPoints ]; + for ( j = 1; j <= nbCols; j++ ) { + if ( tblIntAttr->HasValue( horIndex+1, j ) && tblIntAttr->HasValue( verIndex[i]+1, j ) ) { + xList[j-1] = tblIntAttr->GetValue( horIndex +1, j ); + yList[j-1] = tblIntAttr->GetValue( verIndex[i]+1, j ); + } + } + curve->setData( xList, yList, nbPoints ); + } + // curve attributes + curve->setLine( (Plot2d_Curve::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() ); + curve->setMarker( (Plot2d_Curve::MarkerType)myItems.at( verIndex[i] )->getMarker() ); + curve->setColor( myItems.at( verIndex[i] )->getColor() ); + curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() ); + // add curve into container + container.addCurve( curve ); + } + } + catch( ... ) { + MESSAGE("Plot2d_SetupPlot2dDlg::getCurves : Exception has been caught (int)!!!"); + } + } + } + /* Try table of real */ + else if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ) { + tblRealAttr = SALOMEDS::AttributeTableOfReal::_narrow( anAttr ); + if ( !tblRealAttr->_is_nil() ) { + try { + int nbCols = tblRealAttr->GetNbColumns() ; + SALOMEDS::StringSeq_var rowTitles = tblRealAttr->GetRowTitles(); + SALOMEDS::StringSeq_var rowUnits = tblRealAttr->GetRowUnits(); + + for ( i = 0; i < verIndex.count(); i++ ) { + Plot2d_Curve* curve = new Plot2d_Curve(); + // curve titles + if ( rowTitles->length() > 0 ) { + curve->setHorTitle( strdup( rowTitles[ horIndex ] ) ); + curve->setVerTitle( strdup( rowTitles[ verIndex[i] ] ) ); + } + // curve units + if ( rowUnits->length() > 0 ) { + curve->setHorUnits( strdup( rowUnits[ horIndex ] ) ); + curve->setVerUnits( strdup( rowUnits[ verIndex[i] ] ) ); + } + // curve data + int nbPoints = 0; + for ( j = 1; j <= nbCols; j++ ) { + if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) ) + nbPoints++; + } + if ( nbPoints > 0 ) { + double* xList = new double[ nbPoints ]; + double* yList = new double[ nbPoints ]; + for ( j = 1; j <= nbCols; j++ ) { + if ( tblRealAttr->HasValue( horIndex+1, j ) && tblRealAttr->HasValue( verIndex[i]+1, j ) ) { + xList[j-1] = tblRealAttr->GetValue( horIndex +1, j ); + yList[j-1] = tblRealAttr->GetValue( verIndex[i]+1, j ); + } + } + curve->setData( xList, yList, nbPoints ); + } + // curve attributes + curve->setLine( (Plot2d_Curve::LineType)myItems.at( verIndex[i] )->getLine(), myItems.at( verIndex[i] )->getLineWidth() ); + curve->setMarker( (Plot2d_Curve::MarkerType)myItems.at( verIndex[i] )->getMarker() ); + curve->setColor( myItems.at( verIndex[i] )->getColor() ); + curve->setAutoAssign( myItems.at( verIndex[i] )->isAutoAssign() ); + // add curve into container + container.addCurve( curve ); + } + } + catch( ... ) { + MESSAGE("Plot2d_SetupPlot2dDlg::getCurves : Exception has been caught (real)!!!"); + } + } + } +} +/*! + Slot, called when any button is clicked +*/ +void Plot2d_SetupPlot2dDlg::onHBtnToggled( bool on ) +{ + Plot2d_ItemContainer* item = ( Plot2d_ItemContainer* )sender(); + if ( on ) { + for ( int i = 0; i < myItems.count(); i++ ) { + if ( myItems.at( i ) != item ) + myItems.at( i )->setHorizontalOn( false ); + } + } + enableControls(); +} +/*! + Slot, called when any button is clicked +*/ +void Plot2d_SetupPlot2dDlg::onVBtnToggled( bool on ) +{ + Plot2d_ItemContainer* item = ( Plot2d_ItemContainer* )sender(); + QList itemList; + itemList.setAutoDelete( false ); + int i; + if ( on ) { + int totalOn = 0; + for ( i = 0; i < myItems.count(); i++ ) { + if ( myItems.at( i ) != item && !myItems.at( i )->isHorizontalOn() ) { + if ( myItems.at( i )->myUnitLab->text() == item->myUnitLab->text() ) { + if ( myItems.at( i )->isVerticalOn() ) + totalOn++; + else + itemList.append( myItems.at( i ) ); + } + else { + myItems.at( i )->setVerticalOn( false ); + } + } + } + if ( totalOn == 0 && !itemList.isEmpty() && + QAD_MessageBox::info2( this, + this->caption(), + tr( "QUE_WANT_SAME_UNITS" ), + tr( "BUT_YES" ), + tr( "BUT_NO" ), + 0, 1, 1 ) == 0 ) { + for ( i = 0; i < itemList.count(); i++ ) { + itemList.at( i )->blockSignals( true ); + itemList.at( i )->setVerticalOn( true ); + itemList.at( i )->blockSignals( false ); + } + } + } + enableControls(); +} +/*! + Enables/disables buttons +*/ +void Plot2d_SetupPlot2dDlg::enableControls() +{ + bool bHSet = false; + bool bVSet = false; + for ( int i = 0; i < myItems.count(); i++ ) { + if ( myItems.at( i )->isHorizontalOn() ) { + bHSet = true; + break; + } + } + for ( int i = 0; i < myItems.count(); i++ ) { + if ( myItems.at( i )->isVerticalOn() ) + bVSet = true; + myItems.at( i )->enableWidgets( bHSet && myItems.at( i )->isVerticalOn() ); + } + myOkBtn->setEnabled( bHSet && bVSet ); +} + +// ==================================================================================== +/*! + Constructor +*/ +Plot2d_ItemContainer::Plot2d_ItemContainer( QObject* parent, const char* name ) + : QObject( parent, name ), + myEnabled( true ) +{ +} +/*! + Creates widgets +*/ +void Plot2d_ItemContainer::createWidgets( QWidget* parentWidget ) +{ + myHBtn = new QToolButton( parentWidget ); + myHBtn->setText( tr( " H " ) ); + myHBtn->setToggleButton( true ); + myHBtn->setOn( false ); + + myVBtn = new QToolButton( parentWidget ); + myVBtn->setText( tr( " V " ) ); + myVBtn->setToggleButton( true ); + myVBtn->setOn( false ); + + myTitleLab = new QLabel( parentWidget ); + myUnitLab = new QLabel( parentWidget ); + myUnitLab->setAlignment( AlignCenter); + + myAutoCheck = new QCheckBox( tr( "AUTO_CHECK_LBL" ), parentWidget ); + myAutoCheck->setChecked( true ); + + myLineCombo = new QComboBox( false, parentWidget ); + myLineCombo->insertItem( tr( "NONE_LINE_LBL" ) ); + myLineCombo->insertItem( tr( "SOLID_LINE_LBL" ) ); + myLineCombo->insertItem( tr( "DASH_LINE_LBL" ) ); + myLineCombo->insertItem( tr( "DOT_LINE_LBL" ) ); + myLineCombo->insertItem( tr( "DASHDOT_LINE_LBL" ) ); + myLineCombo->insertItem( tr( "DAHSDOTDOT_LINE_LBL" ) ); + myLineCombo->setCurrentItem( 1 ); // SOLID by default + + myLineSpin = new QSpinBox( 0, MAX_LINE_WIDTH, 1, parentWidget ); + myLineSpin->setValue( 0 ); // width = 0 by default + + myMarkerCombo = new QComboBox( false, parentWidget ); + myMarkerCombo->insertItem( tr( "NONE_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "CIRCLE_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "RECTANGLE_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "DIAMOND_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "DTRIANGLE_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "UTRIANGLE_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "LTRIANGLE_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "RTRIANGLE_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "CROSS_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "XCROSS_MARKER_LBL" ) ); + myMarkerCombo->setCurrentItem( 1 ); // CIRCLE by default + + myColorBtn = new QToolButton( parentWidget ); + + connect( myAutoCheck, SIGNAL( clicked() ), this, SLOT( onAutoChanged() ) ); + connect( myColorBtn, SIGNAL( clicked() ), this, SLOT( onColorChanged() ) ); + connect( myHBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) ); + connect( myVBtn, SIGNAL( toggled( bool ) ), this, SLOT( onHVToggled( bool ) ) ); + setColor( QColor( 0, 0, 0 ) ); + updateState(); +} +/*! + Enables attributes widgets +*/ +void Plot2d_ItemContainer::enableWidgets( bool enable ) +{ + myEnabled = enable; + updateState(); +} +/*! + Sets horizontal button's state on +*/ +void Plot2d_ItemContainer::setHorizontalOn( bool on ) +{ + myHBtn->setOn( on ); +} +/*! + Gets horizontal button's state +*/ +bool Plot2d_ItemContainer::isHorizontalOn() const +{ + return myHBtn->isOn(); +} +/*! + Sets vertical button's state on +*/ +void Plot2d_ItemContainer::setVerticalOn( bool on ) +{ + myVBtn->setOn( on ); +} +/*! + Gets vertical button's state +*/ +bool Plot2d_ItemContainer::isVerticalOn() const +{ + return myVBtn->isOn(); +} +/*! + Sets item AutoAssign flag state +*/ +void Plot2d_ItemContainer::setAutoAssign( bool on ) +{ + myAutoCheck->setChecked( on ); + updateState(); +} +/*! + Gets item AutoAssign flag state +*/ +bool Plot2d_ItemContainer::isAutoAssign() const +{ + return myAutoCheck->isChecked(); +} +/*! + Sets item line type and width +*/ +void Plot2d_ItemContainer::setLine( const int line, const int width ) +{ + myLineCombo->setCurrentItem( line ); +} +/*! + Gets item line type +*/ +int Plot2d_ItemContainer::getLine() const +{ + return myLineCombo->currentItem(); +} +/*! + Gets item line width +*/ +int Plot2d_ItemContainer::getLineWidth() const +{ + return myLineSpin->value(); +} +/*! + Sets item marker type +*/ +void Plot2d_ItemContainer::setMarker( const int marker ) +{ + myMarkerCombo->setCurrentItem( marker ); +} +/*! + Gets item marker type +*/ +int Plot2d_ItemContainer::getMarker() const +{ + return myMarkerCombo->currentItem(); +} +/*! + Sets item color +*/ +void Plot2d_ItemContainer::setColor( const QColor& color ) +{ + QPalette pal = myColorBtn->palette(); + QColorGroup ca = pal.active(); + ca.setColor( QColorGroup::Button, color ); + QColorGroup ci = pal.inactive(); + ci.setColor( QColorGroup::Button, color ); + pal.setActive( ca ); + pal.setInactive( ci ); + myColorBtn->setPalette( pal ); +} +/*! + Gets item color +*/ +QColor Plot2d_ItemContainer::getColor() const +{ + return myColorBtn->palette().active().button(); +} +/*! + Enables/disables widgets +*/ +void Plot2d_ItemContainer::updateState() +{ + myAutoCheck->setEnabled( myEnabled ); + myLineCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() ); + myLineSpin->setEnabled( myEnabled && !myAutoCheck->isChecked() ); + myMarkerCombo->setEnabled( myEnabled && !myAutoCheck->isChecked() ); + myColorBtn->setEnabled( myEnabled && !myAutoCheck->isChecked() ); +} +/*! + Slot, called when user clickes check box +*/ +void Plot2d_ItemContainer::onAutoChanged() +{ + updateState(); + emit( autoClicked() ); +} +/*! + button slot, invokes color selection dialog box +*/ +void Plot2d_ItemContainer::onColorChanged() +{ + QColor color = QColorDialog::getColor( getColor() ); + if ( color.isValid() ) { + setColor( color ); + } +} +/*! + and buttons slot +*/ +void Plot2d_ItemContainer::onHVToggled( bool on ) +{ + const QObject* snd = sender(); + if ( snd == myHBtn ) { + if ( on ) { + if ( myVBtn->isOn() ) { +// blockSignals( true ); + myVBtn->setOn( false ); +// blockSignals( false ); + } + } + emit horToggled( on ); + } + else { + if ( on ) { + if ( myHBtn->isOn() ) { +// blockSignals( true ); + myHBtn->setOn( false ); +// blockSignals( false ); + } + } + emit verToggled( on ); + } +} + + + + + diff --git a/src/Plot2d/Plot2d_SetupPlot2dDlg.h b/src/Plot2d/Plot2d_SetupPlot2dDlg.h new file mode 100644 index 000000000..c135a6f96 --- /dev/null +++ b/src/Plot2d/Plot2d_SetupPlot2dDlg.h @@ -0,0 +1,111 @@ +// File : Plot2d_SetupPlot2dDlg.h +// Created : Wed Jun 27 16:38:42 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef Plot2d_SetupPlot2dDlg_H +#define Plot2d_SetupPlot2dDlg_H + +#include +#include + +#include +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +//================================================================================= +// class : Plot2d_SetupPlot2dDlg +// purpose : Dialog box for setup Plot2d view +//================================================================================= + +class QScrollView; +class QPushButton; +class QLabel; +class QCheckBox; +class QComboBox; +class QSpinBox; +class QToolButton; +class Plot2d_ItemContainer; +class Plot2d_CurveContainer; + +class Plot2d_SetupPlot2dDlg : public QDialog +{ + Q_OBJECT + +public: + Plot2d_SetupPlot2dDlg( SALOMEDS::SObject_var object, QWidget* parent = 0 ); + ~Plot2d_SetupPlot2dDlg(); + + void getCurves( Plot2d_CurveContainer& container ); + void getCurvesSource( int& horIndex, QValueList& verIndexes ); + bool getCurveAttributes( const int vIndex, bool& isAuto, int& marker, int& line, int& lineWidth, QColor& color); + +private slots: + void onHBtnToggled( bool ); + void onVBtnToggled( bool ); + void enableControls(); + +private: + QScrollView* myView; + QPushButton* myOkBtn; + QPushButton* myCancelBtn; + QList myItems; + + SALOMEDS::SObject_var myObject; +}; + +class Plot2d_ItemContainer : public QObject +{ + Q_OBJECT + +public: + Plot2d_ItemContainer( QObject* parent = 0, const char* name = 0 ); + + void createWidgets( QWidget* parentWidget ); + void enableWidgets( bool enable ); + + void setHorizontalOn( bool on ); + bool isHorizontalOn() const; + void setVerticalOn( bool on ); + bool isVerticalOn() const; + bool isAutoAssign() const; + void setAutoAssign( bool on ); + void setLine( const int line, const int width ); + int getLine() const; + int getLineWidth() const; + void setMarker( const int marker ); + int getMarker() const; + void setColor( const QColor& color ); + QColor getColor() const; + +protected: + void updateState(); + +signals: + void autoClicked(); + void horToggled( bool ); + void verToggled( bool ); + +public slots: + void onAutoChanged(); + void onColorChanged(); + void onHVToggled( bool ); + +public: + bool myEnabled; + QToolButton* myHBtn; + QToolButton* myVBtn; + QLabel* myTitleLab; + QLabel* myUnitLab; + QCheckBox* myAutoCheck; + QComboBox* myLineCombo; + QSpinBox* myLineSpin; + QComboBox* myMarkerCombo; + QToolButton* myColorBtn; +}; + +#endif // Plot2d_SetupPlot2dDlg_H + diff --git a/src/Plot2d/Plot2d_SetupViewDlg.cxx b/src/Plot2d/Plot2d_SetupViewDlg.cxx new file mode 100644 index 000000000..6cf1aaba6 --- /dev/null +++ b/src/Plot2d/Plot2d_SetupViewDlg.cxx @@ -0,0 +1,494 @@ +// File : Plot2d_SetupViewDlg.cxx +// Created : Wed Jun 27 16:38:42 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "Plot2d_SetupViewDlg.h" +#include "QAD_Tools.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MARGIN_SIZE 11 +#define SPACING_SIZE 6 +#define MIN_EDIT_WIDTH 200 +#define MIN_COMBO_WIDTH 100 +#define MIN_SPIN_WIDTH 70 + +/*! + Constructor +*/ +Plot2d_SetupViewDlg::Plot2d_SetupViewDlg( QWidget* parent, bool showDefCheck ) + : QDialog( parent, "Plot2d_SetupViewDlg", true, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr("TLT_SETUP_PLOT2D_VIEW") ); + setSizeGripEnabled( TRUE ); + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setSpacing( SPACING_SIZE ); + topLayout->setMargin( MARGIN_SIZE ); + + // main title + myTitleCheck = new QCheckBox( tr( "PLOT2D_ENABLE_MAIN_TITLE" ), this ); + myTitleEdit = new QLineEdit( this ); + myTitleEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myTitleEdit->setMinimumWidth( MIN_EDIT_WIDTH ); + // horizontal axis title + myTitleXCheck = new QCheckBox( tr( "PLOT2D_ENABLE_HOR_TITLE" ), this ); + myTitleXEdit = new QLineEdit( this ); + myTitleXEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myTitleXEdit->setMinimumWidth( MIN_EDIT_WIDTH ); + // vertical axis title + myTitleYCheck = new QCheckBox( tr( "PLOT2D_ENABLE_VER_TITLE" ), this ); + myTitleYEdit = new QLineEdit( this ); + myTitleYEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myTitleYEdit->setMinimumWidth( MIN_EDIT_WIDTH ); + // curve type : points, lines, spline + QLabel* aCurveLab = new QLabel( tr( "PLOT2D_CURVE_TYPE_LBL" ), this ); + myCurveCombo = new QComboBox( false, this ); + myCurveCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myCurveCombo->setMinimumWidth( MIN_COMBO_WIDTH ); + myCurveCombo->insertItem( tr( "PLOT2D_CURVE_TYPE_POINTS" ) ); + myCurveCombo->insertItem( tr( "PLOT2D_CURVE_TYPE_LINES" ) ); + myCurveCombo->insertItem( tr( "PLOT2D_CURVE_TYPE_SPLINE" ) ); + // legend + myLegendCheck = new QCheckBox( tr( "PLOT2D_ENABLE_LEGEND" ), this ); + myLegendCombo = new QComboBox( false, this ); + myLegendCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myLegendCombo->setMinimumWidth( MIN_COMBO_WIDTH ); + myLegendCombo->insertItem( tr( "PLOT2D_LEGEND_POSITION_LEFT" ) ); + myLegendCombo->insertItem( tr( "PLOT2D_LEGEND_POSITION_RIGHT" ) ); + myLegendCombo->insertItem( tr( "PLOT2D_LEGEND_POSITION_TOP" ) ); + myLegendCombo->insertItem( tr( "PLOT2D_LEGEND_POSITION_BOTTOM" ) ); + // marker size + QLabel* aMarkerLab = new QLabel( tr( "PLOT2D_MARKER_SIZE_LBL" ), this ); + myMarkerSpin = new QSpinBox( 0, 100, 1, this ); + myMarkerSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myMarkerSpin->setMinimumWidth( MIN_SPIN_WIDTH ); + // background color + QLabel* aBGLab = new QLabel( tr( "PLOT2D_BACKGROUND_COLOR_LBL" ), this ); + myBackgroundBtn = new QToolButton( this ); + // scale mode + QGroupBox* aScaleGrp = new QGroupBox( tr( "PLOT2D_SCALE_TLT" ), this ); + aScaleGrp->setColumnLayout(0, Qt::Vertical ); + aScaleGrp->layout()->setSpacing( 0 ); aScaleGrp->layout()->setMargin( 0 ); + QGridLayout* aScaleLayout = new QGridLayout( aScaleGrp->layout() ); + aScaleLayout->setMargin( MARGIN_SIZE ); aScaleLayout->setSpacing( SPACING_SIZE ); + + QLabel* xScaleLab = new QLabel( tr( "PLOT2D_SCALE_MODE_HOR" ), aScaleGrp ); + myXModeCombo = new QComboBox( false, aScaleGrp ); + myXModeCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myXModeCombo->setMinimumWidth( MIN_COMBO_WIDTH ); + myXModeCombo->insertItem( tr( "PLOT2D_SCALE_MODE_LINEAR" ) ); + myXModeCombo->insertItem( tr( "PLOT2D_SCALE_MODE_LOGARITHMIC" ) ); + QLabel* yScaleLab = new QLabel( tr( "PLOT2D_SCALE_MODE_VER" ), aScaleGrp ); + myYModeCombo = new QComboBox( false, aScaleGrp ); + myYModeCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myYModeCombo->setMinimumWidth( MIN_COMBO_WIDTH ); + myYModeCombo->insertItem( tr( "PLOT2D_SCALE_MODE_LINEAR" ) ); + myYModeCombo->insertItem( tr( "PLOT2D_SCALE_MODE_LOGARITHMIC" ) ); + + aScaleLayout->addWidget( xScaleLab, 0, 0 ); + aScaleLayout->addWidget( myXModeCombo, 0, 1 ); + aScaleLayout->addWidget( yScaleLab, 0, 2 ); + aScaleLayout->addWidget( myYModeCombo, 0, 3 ); + + // grid + QGroupBox* aGridGrp = new QGroupBox( tr( "PLOT2D_GRID_TLT" ), this ); + aGridGrp->setColumnLayout(0, Qt::Vertical ); + aGridGrp->layout()->setSpacing( 0 ); aGridGrp->layout()->setMargin( 0 ); + QGridLayout* aGridLayout = new QGridLayout( aGridGrp->layout() ); + aGridLayout->setMargin( MARGIN_SIZE ); aGridLayout->setSpacing( SPACING_SIZE ); + + myXGridCheck = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_HOR_MAJOR" ), aGridGrp ); + myXGridSpin = new QSpinBox( 1, 100, 1, aGridGrp ); + myXGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myXGridSpin->setMinimumWidth( MIN_SPIN_WIDTH ); + myYGridCheck = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_VER_MAJOR" ), aGridGrp ); + myYGridSpin = new QSpinBox( 1, 100, 1, aGridGrp ); + myYGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myYGridSpin->setMinimumWidth( MIN_SPIN_WIDTH ); + myXMinGridCheck = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_HOR_MINOR" ), aGridGrp ); + myXMinGridSpin = new QSpinBox( 1, 100, 1, aGridGrp ); + myXMinGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myXMinGridSpin->setMinimumWidth( MIN_SPIN_WIDTH ); + myYMinGridCheck = new QCheckBox( tr( "PLOT2D_GRID_ENABLE_VER_MINOR" ), aGridGrp ); + myYMinGridSpin = new QSpinBox( 1, 100, 1, aGridGrp ); + myYMinGridSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myYMinGridSpin->setMinimumWidth( MIN_SPIN_WIDTH ); + + aGridLayout->addWidget( myXGridCheck, 0, 0 ); + aGridLayout->addWidget( myXGridSpin, 0, 1 ); + aGridLayout->addWidget( myYGridCheck, 0, 2 ); + aGridLayout->addWidget( myYGridSpin, 0, 3 ); + aGridLayout->addWidget( myXMinGridCheck, 1, 0 ); + aGridLayout->addWidget( myXMinGridSpin, 1, 1 ); + aGridLayout->addWidget( myYMinGridCheck, 1, 2 ); + aGridLayout->addWidget( myYMinGridSpin, 1, 3 ); + + /* "Set as default" check box */ + myDefCheck = new QCheckBox( tr( "PLOT2D_SET_AS_DEFAULT_CHECK" ), this ); + + /* OK/Cancel buttons */ + myOkBtn = new QPushButton( tr( "BUT_OK" ), this ); + myOkBtn->setAutoDefault( TRUE ); + myOkBtn->setDefault( TRUE ); + myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this ); + myCancelBtn->setAutoDefault( TRUE ); + QHBoxLayout* btnLayout = new QHBoxLayout; + btnLayout->addWidget( myOkBtn ); + btnLayout->addStretch(); + btnLayout->addWidget( myCancelBtn ); + + // layout widgets + topLayout->addWidget( myTitleCheck, 0, 0 ); + topLayout->addMultiCellWidget( myTitleEdit, 0, 0, 1, 3 ); + topLayout->addWidget( myTitleXCheck, 1, 0 ); + topLayout->addMultiCellWidget( myTitleXEdit, 1, 1, 1, 3 ); + topLayout->addWidget( myTitleYCheck, 2, 0 ); + topLayout->addMultiCellWidget( myTitleYEdit, 2, 2, 1, 3 ); + topLayout->addWidget( aCurveLab, 3, 0 ); + topLayout->addWidget( myCurveCombo, 3, 1 ); + topLayout->addWidget( myLegendCheck, 3, 2 ); + topLayout->addWidget( myLegendCombo, 3, 3 ); + topLayout->addWidget( aMarkerLab, 4, 0 ); + topLayout->addWidget( myMarkerSpin, 4, 1 ); + QHBoxLayout* bgLayout = new QHBoxLayout; + bgLayout->addWidget( myBackgroundBtn ); bgLayout->addStretch(); + topLayout->addWidget( aBGLab, 4, 2 ); + topLayout->addLayout( bgLayout, 4, 3 ); + topLayout->addMultiCellWidget( aScaleGrp, 5, 5, 0, 3 ); + topLayout->addMultiCellWidget( aGridGrp, 6, 6, 0, 3 ); + topLayout->addMultiCellWidget( myDefCheck, 7, 7, 0, 3 ); + topLayout->setRowStretch( 8, 5 ); + topLayout->addMultiCellLayout( btnLayout, 9, 9, 0, 3 ); + + if ( !showDefCheck ) + myDefCheck->hide(); + + connect( myTitleCheck, SIGNAL( clicked() ), this, SLOT( onMainTitleChecked() ) ); + connect( myTitleXCheck, SIGNAL( clicked() ), this, SLOT( onXTitleChecked() ) ); + connect( myTitleYCheck, SIGNAL( clicked() ), this, SLOT( onYTitleChecked() ) ); + connect( myBackgroundBtn, SIGNAL( clicked() ), this, SLOT( onBackgroundClicked() ) ); + connect( myLegendCheck, SIGNAL( clicked() ), this, SLOT( onLegendChecked() ) ); + connect( myXGridCheck, SIGNAL( clicked() ), this, SLOT( onXGridMajorChecked() ) ); + connect( myYGridCheck, SIGNAL( clicked() ), this, SLOT( onYGridMajorChecked() ) ); + connect( myXMinGridCheck, SIGNAL( clicked() ), this, SLOT( onXGridMinorChecked() ) ); + connect( myYMinGridCheck, SIGNAL( clicked() ), this, SLOT( onYGridMinorChecked() ) ); + + connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + /* Center widget inside it's parent widget */ + QAD_Tools::centerWidget( this, parentWidget() ); + + // init fields + setBackgroundColor( Qt::gray ); + onMainTitleChecked(); + onXTitleChecked(); + onYTitleChecked(); + onLegendChecked(); + onXGridMajorChecked(); + onYGridMajorChecked(); + onXGridMinorChecked(); + onYGridMinorChecked(); +} + +/*! + Destructor +*/ +Plot2d_SetupViewDlg::~Plot2d_SetupViewDlg() +{ +} +/*! + Sets main title attributes +*/ +void Plot2d_SetupViewDlg::setMainTitle( bool enable, const QString& title ) +{ + myTitleCheck->setChecked( enable ); + if ( !title.isNull() ) + myTitleEdit->setText( title ); + onMainTitleChecked(); +} +/*! + Returns TRUE if main title is enabled +*/ +bool Plot2d_SetupViewDlg::isMainTitleEnabled() +{ + return myTitleCheck->isChecked(); +} +/*! + Gets main title +*/ +QString Plot2d_SetupViewDlg::getMainTitle() +{ + return myTitleEdit->text(); +} +/*! + Sets horizontal axis title attributes +*/ +void Plot2d_SetupViewDlg::setXTitle( bool enable, const QString& title ) +{ + myTitleXCheck->setChecked( enable ); + if ( !title.isNull() ) + myTitleXEdit->setText( title ); + onXTitleChecked(); +} +/*! + Returns TRUE if horizontal axis title is enabled +*/ +bool Plot2d_SetupViewDlg::isXTitleEnabled() +{ + return myTitleXCheck->isChecked(); +} +/*! + Gets horizontal axis title +*/ +QString Plot2d_SetupViewDlg::getXTitle() +{ + return myTitleXEdit->text(); +} +/*! + Sets horizontal axis title attributes +*/ +void Plot2d_SetupViewDlg::setYTitle( bool enable, const QString& title ) +{ + myTitleYCheck->setChecked( enable ); + if ( !title.isNull() ) + myTitleYEdit->setText( title ); + onYTitleChecked(); +} +/*! + Returns TRUE if vertical axis title is enabled +*/ +bool Plot2d_SetupViewDlg::isYTitleEnabled() +{ + return myTitleYCheck->isChecked(); +} +/*! + Gets vertical axis title +*/ +QString Plot2d_SetupViewDlg::getYTitle() +{ + return myTitleYEdit->text(); +} +/*! + Sets curve type : 0 - points, 1 - lines, 2 - splines +*/ +void Plot2d_SetupViewDlg::setCurveType( const int type ) +{ + myCurveCombo->setCurrentItem( type ); +} +/*! + Gets curve type : 0 - points, 1 - lines, 2 - splines +*/ +int Plot2d_SetupViewDlg::getCurveType() +{ + return myCurveCombo->currentItem(); +} +/*! + Sets legend attributes : pos = 0 - left, 1 - right, 2 - top, 3 - bottom +*/ +void Plot2d_SetupViewDlg::setLegend( bool enable, int pos ) +{ + myLegendCheck->setChecked( enable ); + myLegendCombo->setCurrentItem( pos ); + onLegendChecked(); +} +/*! + Returns TRUE if legend is enabled +*/ +bool Plot2d_SetupViewDlg::isLegendEnabled() +{ + return myLegendCheck->isChecked(); +} +/*! + Returns legend position +*/ +int Plot2d_SetupViewDlg::getLegendPos() +{ + return myLegendCombo->currentItem(); +} +/*! + Sets marker size +*/ +void Plot2d_SetupViewDlg::setMarkerSize( const int size ) +{ + myMarkerSpin->setValue( size ); +} +/*! + Gets marker size +*/ +int Plot2d_SetupViewDlg::getMarkerSize() +{ + return myMarkerSpin->value(); +} +/*! + Sets background color +*/ +void Plot2d_SetupViewDlg::setBackgroundColor( const QColor& color ) +{ + QPalette pal = myBackgroundBtn->palette(); + QColorGroup ca = pal.active(); + ca.setColor( QColorGroup::Button, color ); + QColorGroup ci = pal.inactive(); + ci.setColor( QColorGroup::Button, color ); + pal.setActive( ca ); + pal.setInactive( ci ); + myBackgroundBtn->setPalette( pal ); +} +/*! + Gets background color +*/ +QColor Plot2d_SetupViewDlg::getBackgroundColor() +{ + return myBackgroundBtn->palette().active().button(); +} +/*! + Sets major grid parameters +*/ +void Plot2d_SetupViewDlg::setMajorGrid( bool enableX, const int divX, bool enableY, const int divY ) +{ + myXGridCheck->setChecked( enableX ); + myXGridSpin->setValue( divX ); + myYGridCheck->setChecked( enableY ); + myYGridSpin->setValue( divY ); + onXGridMajorChecked(); + onYGridMajorChecked(); +} +/*! + Gets major grid parameters +*/ +void Plot2d_SetupViewDlg::getMajorGrid( bool& enableX, int& divX, bool& enableY, int& divY ) +{ + enableX = myXGridCheck->isChecked(); + divX = myXGridSpin->value(); + enableY = myYGridCheck->isChecked(); + divY = myYGridSpin->value(); +} +/*! + Sets minor grid parameters +*/ +void Plot2d_SetupViewDlg::setMinorGrid( bool enableX, const int divX, bool enableY, const int divY ) +{ + myXMinGridCheck->setChecked( enableX ); + myXMinGridSpin->setValue( divX ); + myYMinGridCheck->setChecked( enableY ); + myYMinGridSpin->setValue( divY ); + onXGridMinorChecked(); + onYGridMinorChecked(); +} +/*! + Gets minor grid parameters +*/ +void Plot2d_SetupViewDlg::getMinorGrid( bool& enableX, int& divX, bool& enableY, int& divY ) +{ + enableX = myXMinGridCheck->isChecked(); + divX = myXMinGridSpin->value(); + enableY = myYMinGridCheck->isChecked(); + divY = myYMinGridSpin->value(); +} +/*! + Sets scale mode for hor. and ver. axes : 0 - linear, 1 - logarithmic +*/ +void Plot2d_SetupViewDlg::setScaleMode( const int xMode, const int yMode ) +{ + myXModeCombo->setCurrentItem( xMode ); + myYModeCombo->setCurrentItem( yMode ); +} +/*! + Gets scale mode for hor. axis : 0 - linear, 1 - logarithmic +*/ +int Plot2d_SetupViewDlg::getXScaleMode() +{ + return myXModeCombo->currentItem(); +} +/*! + Gets scale mode for hor. axis : 0 - linear, 1 - logarithmic +*/ +int Plot2d_SetupViewDlg::getYScaleMode() +{ + return myYModeCombo->currentItem(); +} +/*! + Slot, called when user clicks "Show main title" check box +*/ +void Plot2d_SetupViewDlg::onMainTitleChecked() +{ + myTitleEdit->setEnabled( myTitleCheck->isChecked() ); +} +/*! + Slot, called when user clicks "Show horizontal axis title" check box +*/ +void Plot2d_SetupViewDlg::onXTitleChecked() +{ + myTitleXEdit->setEnabled( myTitleXCheck->isChecked() ); +} +/*! + Slot, called when user clicks "Show vertical axis title" check box +*/ +void Plot2d_SetupViewDlg::onYTitleChecked() +{ + myTitleYEdit->setEnabled( myTitleYCheck->isChecked() ); +} +/*! + Slot, called when user clicks "Change bacground color" button +*/ +void Plot2d_SetupViewDlg::onBackgroundClicked() +{ + QColor color = QColorDialog::getColor( getBackgroundColor() ); + if ( color.isValid() ) { + setBackgroundColor( color ); + } +} +/*! + Slot, called when user clicks "Show Legend" check box +*/ +void Plot2d_SetupViewDlg::onLegendChecked() +{ + myLegendCombo->setEnabled( myLegendCheck->isChecked() ); +} +/*! + Slot, called when user clicks "Enable hor. major grid" check box +*/ +void Plot2d_SetupViewDlg::onXGridMajorChecked() +{ + myXMinGridCheck->setEnabled( myXGridCheck->isChecked() ); +} +/*! + Slot, called when user clicks "Enable ver. major grid" check box +*/ +void Plot2d_SetupViewDlg::onYGridMajorChecked() +{ + myYMinGridCheck->setEnabled( myYGridCheck->isChecked() ); +} +/*! + Slot, called when user clicks "Enable hor. minor grid" check box +*/ +void Plot2d_SetupViewDlg::onXGridMinorChecked() +{ +} +/*! + Slot, called when user clicks "Enable ver. minor grid" check box +*/ +void Plot2d_SetupViewDlg::onYGridMinorChecked() +{ +} +/*! + Retursns true if "Set as default" check box is on +*/ +bool Plot2d_SetupViewDlg::isSetAsDefault() +{ + return myDefCheck->isChecked(); +} diff --git a/src/Plot2d/Plot2d_SetupViewDlg.h b/src/Plot2d/Plot2d_SetupViewDlg.h new file mode 100644 index 000000000..78c9ad482 --- /dev/null +++ b/src/Plot2d/Plot2d_SetupViewDlg.h @@ -0,0 +1,101 @@ +// File : Plot2d_SetupViewDlg.h +// Created : Wed Jun 27 16:38:42 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef Plot2d_SetupViewDlg_H +#define Plot2d_SetupViewDlg_H + +#include + +//================================================================================= +// class : Plot2d_SetupViewDlg +// purpose : Settings dialog for Plot2d view +//================================================================================= + +class QCheckBox; +class QLineEdit; +class QComboBox; +class QSpinBox; +class QToolButton; +class QPushButton; + +class Plot2d_SetupViewDlg : public QDialog +{ + Q_OBJECT + +public: + Plot2d_SetupViewDlg( QWidget* parent = 0, bool showDefCheck = false ); + ~Plot2d_SetupViewDlg(); + + void setMainTitle( bool enable, const QString& title = QString::null ); + bool isMainTitleEnabled(); + QString getMainTitle(); + void setXTitle( bool enable, const QString& title = QString::null ); + bool isXTitleEnabled(); + QString getXTitle(); + void setYTitle( bool enable, const QString& title = QString::null ); + bool isYTitleEnabled(); + QString getYTitle(); + void setCurveType( const int type ); + int getCurveType(); + void setLegend( bool enable, int pos ); + bool isLegendEnabled(); + int getLegendPos(); + void setMarkerSize( const int size ); + int getMarkerSize(); + void setBackgroundColor( const QColor& color ); + QColor getBackgroundColor(); + void setMajorGrid( bool enableX, const int xdiv, bool enableY, const int divY ); + void getMajorGrid( bool& enableX, int& xdiv, bool& enableY, int& divY ); + void setMinorGrid( bool enableX, const int xdiv, bool enableY, const int divY ); + void getMinorGrid( bool& enableX, int& xdiv, bool& enableY, int& divY ); + void setScaleMode( const int xMode, const int yMode ); + int getXScaleMode(); + int getYScaleMode(); + bool isSetAsDefault(); + +protected slots: + void onMainTitleChecked(); + void onXTitleChecked(); + void onYTitleChecked(); + void onBackgroundClicked(); + void onLegendChecked(); + void onXGridMajorChecked(); + void onYGridMajorChecked(); + void onXGridMinorChecked(); + void onYGridMinorChecked(); + +private: + QCheckBox* myTitleCheck; + QLineEdit* myTitleEdit; + QCheckBox* myTitleXCheck; + QLineEdit* myTitleXEdit; + QCheckBox* myTitleYCheck; + QLineEdit* myTitleYEdit; + QToolButton* myBackgroundBtn; + QCheckBox* myXGridCheck; + QSpinBox* myXGridSpin; + QCheckBox* myYGridCheck; + QSpinBox* myYGridSpin; + QCheckBox* myXMinGridCheck; + QSpinBox* myXMinGridSpin; + QCheckBox* myYMinGridCheck; + QSpinBox* myYMinGridSpin; + QComboBox* myCurveCombo; + QCheckBox* myLegendCheck; + QComboBox* myLegendCombo; + QSpinBox* myMarkerSpin; + QComboBox* myXModeCombo; + QComboBox* myYModeCombo; + QCheckBox* myDefCheck; + + QPushButton* myOkBtn; + QPushButton* myCancelBtn; +}; + +#endif // Plot2d_SetupViewDlg_H + diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx new file mode 100644 index 000000000..a5a5cb127 --- /dev/null +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -0,0 +1,1423 @@ +// File : Plot2d_ViewFrame.cxx +// Created : Wed Jun 27 16:38:42 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "Plot2d_ViewFrame.h" +#include "Plot2d_SetupViewDlg.h" +#include "QAD_Desktop.h" +#include "QAD_ResourceMgr.h" +#include "QAD_FileDlg.h" +#include "QAD_Tools.h" +#include "QAD_MessageBox.h" +#include "QAD_Config.h" +#include "SALOME_Selection.h" +#include "Plot2d_CurveContainer.h" +#include "Plot2d_Curve.h" +#include "utilities.h" +#include "qapplication.h" +#include +#include +#include +#include +#include + +#define DEFAULT_LINE_WIDTH 0 // (default) line width +#define DEFAULT_MARKER_SIZE 9 // default marker size +#define MIN_RECT_SIZE 11 // min sensibility area size + +/* XPM */ +const char* imageZoomCursor[] = { +"32 32 3 1", +". c None", +"a c #000000", +"# c #ffffff", +"................................", +"................................", +".#######........................", +"..aaaaaaa.......................", +"................................", +".............#####..............", +"...........##.aaaa##............", +"..........#.aa.....a#...........", +".........#.a.........#..........", +".........#a..........#a.........", +"........#.a...........#.........", +"........#a............#a........", +"........#a............#a........", +"........#a............#a........", +"........#a............#a........", +".........#...........#.a........", +".........#a..........#a.........", +".........##.........#.a.........", +"........#####.....##.a..........", +".......###aaa#####.aa...........", +"......###aa...aaaaa.......#.....", +".....###aa................#a....", +"....###aa.................#a....", +"...###aa...............#######..", +"....#aa.................aa#aaaa.", +".....a....................#a....", +"..........................#a....", +"...........................a....", +"................................", +"................................", +"................................", +"................................"}; + + +//================================================================================= +// Plot2d_ViewFrame implementation +//================================================================================= + +/*! + Constructor +*/ +Plot2d_ViewFrame::Plot2d_ViewFrame( QWidget* parent, const QString& title ) + : QAD_ViewFrame( parent, title ), + myOperation( NoOpId ), + myCurveType( 1 ), + myShowLegend( true ), myLegendPos( 1 ), + myMarkerSize( DEFAULT_MARKER_SIZE ), + myTitle( "" ), myXTitle( "" ), myYTitle( "" ), + myBackground( white ), + myTitleEnabled( true ), myXTitleEnabled( true ), myYTitleEnabled( true ), + myXGridMajorEnabled( true ), myYGridMajorEnabled( true ), + myXGridMinorEnabled( false ), myYGridMinorEnabled( false ), + myXGridMaxMajor( 8 ), myYGridMaxMajor( 8 ), myXGridMaxMinor( 5 ), myYGridMaxMinor( 5 ), + myXMode( 0 ), myYMode( 0 ) + +{ + setCaption( tr( "PLOT_2D_TLT" ) ); + setDockMenuEnabled( false ); + + myCurves.setAutoDelete( true ); + /* Plot 2d View */ + myPlot = new Plot2d_Plot2d( this ); + setCentralWidget( myPlot ); + + createActions(); + + connect( myPlot, SIGNAL( plotMouseMoved( const QMouseEvent& ) ), + this, SLOT( plotMouseMoved( const QMouseEvent& ) ) ); + connect( myPlot, SIGNAL( plotMousePressed( const QMouseEvent& ) ), + this, SLOT( plotMousePressed( const QMouseEvent& ) ) ); + connect( myPlot, SIGNAL( plotMouseReleased( const QMouseEvent& ) ), + this, SLOT( plotMouseReleased( const QMouseEvent& ) ) ); + connect( myPlot, SIGNAL( legendClicked( long ) ), + this, SLOT( onLegendClicked( long ) ) ); + + /* Initial Setup - get from the preferences */ + readPreferences(); + + myPlot->setMargin( 5 ); + setCurveType( myCurveType, false ); + setXGrid( myXGridMajorEnabled, myXGridMaxMajor, myXGridMinorEnabled, myXGridMaxMinor, false ); + setYGrid( myYGridMajorEnabled, myYGridMaxMajor, myYGridMinorEnabled, myYGridMaxMinor, false ); + setMainTitle( myTitleEnabled, myTitle, false ); + setXTitle( myXTitleEnabled, myXTitle, false ); + setYTitle( myYTitleEnabled, myYTitle, false ); + setHorScaleMode( myXMode, false ); + setVerScaleMode( myYMode, false ); + setBackgroundColor( myBackground ); + setLegendPos( myLegendPos ); + showLegend( myShowLegend, false ); + myPlot->replot(); + + if ( parent ) { + resize( 0.8 * parent->width(), 0.8 * parent->height() ); + } +} +/*! + Destructor +*/ +Plot2d_ViewFrame::~Plot2d_ViewFrame() +{ + qApp->removeEventFilter( this ); +} +/*! + Creates popup menu actions +*/ +void Plot2d_ViewFrame::createActions() +{ + QAD_ResourceMgr* rmgr = QAD_Desktop::getResourceManager(); + /* Linear/logarithmic mode */ + // Horizontal axis + QActionGroup* modeHorGrp = new QActionGroup( this ); + modeHorGrp->setExclusive( TRUE ); + QAction* linearXAction = new QAction ( tr( "TOT_PLOT2D_MODE_LINEAR_HOR"), + rmgr->loadPixmap( "SALOMEGUI", tr("ICON_PLOT2D_MODE_LINEAR_HOR") ) , + tr( "MEN_PLOT2D_MODE_LINEAR_HOR" ), 0, modeHorGrp ); + linearXAction->setStatusTip ( tr( "PRP_PLOT2D_MODE_LINEAR_HOR" ) ); + linearXAction->setToggleAction( true ); + myActions.insert( ModeXLinearId, linearXAction ); + QAction* logXAction = new QAction ( tr( "TOT_PLOT2D_MODE_LOGARITHMIC_HOR"), + rmgr->loadPixmap( "SALOMEGUI", tr("ICON_PLOT2D_MODE_LOGARITHMIC_HOR") ) , + tr( "MEN_PLOT2D_MODE_LOGARITHMIC_HOR" ), 0, modeHorGrp ); + logXAction->setStatusTip ( tr( "PRP_PLOT2D_MODE_LOGARITHMIC_HOR" ) ); + logXAction->setToggleAction( true ); + myActions.insert( ModeXLogarithmicId, logXAction ); + connect( modeHorGrp, SIGNAL( selected( QAction* ) ), this, SLOT( onHorMode() ) ); + + // Vertical axis + QActionGroup* modeVerGrp = new QActionGroup( this ); + modeVerGrp->setExclusive( TRUE ); + QAction* linearYAction = new QAction ( tr( "TOT_PLOT2D_MODE_LINEAR_VER"), + rmgr->loadPixmap( "SALOMEGUI", tr("ICON_PLOT2D_MODE_LINEAR_VER") ) , + tr( "MEN_PLOT2D_MODE_LINEAR_VER" ), 0, modeVerGrp ); + linearYAction->setStatusTip ( tr( "PRP_PLOT2D_MODE_LINEAR_VER" ) ); + linearYAction->setToggleAction( true ); + myActions.insert( ModeYLinearId, linearYAction ); + QAction* logYAction = new QAction ( tr( "TOT_PLOT2D_MODE_LOGARITHMIC_VER"), + rmgr->loadPixmap( "SALOMEGUI", tr("ICON_PLOT2D_MODE_LOGARITHMIC_VER") ) , + tr( "MEN_PLOT2D_MODE_LOGARITHMIC_VER" ), 0, modeVerGrp ); + logYAction->setStatusTip ( tr( "PRP_PLOT2D_MODE_LOGARITHMIC_VER" ) ); + logYAction->setToggleAction( true ); + myActions.insert( ModeYLogarithmicId, logYAction ); + connect( modeVerGrp, SIGNAL( selected( QAction* ) ), this, SLOT( onVerMode() ) ); + + /* Legend */ + QAction* legendAction = new QAction ( tr( "TOT_PLOT2D_SHOW_LEGEND"), + rmgr->loadPixmap( "SALOMEGUI", tr("ICON_PLOT2D_SHOW_LEGEND") ) , + tr( "MEN_PLOT2D_SHOW_LEGEND" ), 0, this ); + legendAction->setStatusTip ( tr( "PRP_PLOT2D_SHOW_LEGEND" ) ); + legendAction->setToggleAction( true ); + myActions.insert( LegendId, legendAction ); + connect( legendAction, SIGNAL( activated() ), this, SLOT( onLegend() ) ); + + /* Curve type */ + QActionGroup* curveGrp = new QActionGroup( this ); + curveGrp->setExclusive( TRUE ); + QAction* pointsAction = new QAction ( tr( "TOT_PLOT2D_CURVES_POINTS"), + rmgr->loadPixmap( "SALOMEGUI", tr("ICON_PLOT2D_CURVES_POINTS") ) , + tr( "MEN_PLOT2D_CURVES_POINTS" ), 0, curveGrp ); + pointsAction->setStatusTip ( tr( "PRP_PLOT2D_CURVES_POINTS" ) ); + pointsAction->setToggleAction( true ); + myActions.insert( CurvePointsId, pointsAction ); + QAction* linesAction = new QAction ( tr( "TOT_PLOT2D_CURVES_LINES"), + rmgr->loadPixmap( "SALOMEGUI", tr("ICON_PLOT2D_CURVES_LINES") ) , + tr( "MEN_PLOT2D_CURVES_LINES" ), 0, curveGrp ); + linesAction->setStatusTip ( tr( "PRP_PLOT2D_CURVES_LINES" ) ); + linesAction->setToggleAction( true ); + myActions.insert( CurveLinesId, linesAction ); + QAction* splinesAction = new QAction ( tr( "TOT_PLOT2D_CURVES_SPLINES"), + rmgr->loadPixmap( "SALOMEGUI", tr("ICON_PLOT2D_CURVES_SPLINES") ) , + tr( "MEN_PLOT2D_CURVES_SPLINES" ), 0, curveGrp ); + splinesAction->setStatusTip ( tr( "PRP_PLOT2D_CURVES_SPLINES" ) ); + splinesAction->setToggleAction( true ); + myActions.insert( CurveSplinesId, splinesAction ); + connect( curveGrp, SIGNAL( selected( QAction* ) ), this, SLOT( onCurves() ) ); + + // Settings + QAction* settingsAction = new QAction ( tr( "TOT_PLOT2D_SETTINGS"), + rmgr->loadPixmap( "SALOMEGUI", tr("ICON_PLOT2D_SETTINGS") ) , + tr( "MEN_PLOT2D_SETTINGS" ), 0, this ); + settingsAction->setStatusTip ( tr( "PRP_PLOT2D_SETTINGS" ) ); + myActions.insert( SettingsId, settingsAction ); + connect( settingsAction, SIGNAL( activated() ), this, SLOT( onSettings() ) ); +} +/*! + Gets window's central widget +*/ +QWidget* Plot2d_ViewFrame::getViewWidget() +{ + return (QWidget*)myPlot; +} +/* Popup management : sets Popup server */ +void Plot2d_ViewFrame::setPopupServer( QAD_Application* App ) +{ +// QAD_PopupClientServer::setPopupServer( (QAD_PopupServer*)App ); +} +/*! + Popup menu creation +*/ +void Plot2d_ViewFrame::onCreatePopup() +{ + if ( myPopup ) { + myPopup->clear(); + // scaling + QPopupMenu* scalingPopup = new QPopupMenu( myPopup ); + myActions[ ModeXLinearId ]->addTo( scalingPopup ); + myActions[ ModeXLogarithmicId ]->addTo( scalingPopup ); + scalingPopup->insertSeparator(); + myActions[ ModeYLinearId ]->addTo( scalingPopup ); + myActions[ ModeYLogarithmicId ]->addTo( scalingPopup ); + myPopup->insertItem( tr( "SCALING_POPUP" ), scalingPopup ); + // curve type + QPopupMenu* curTypePopup = new QPopupMenu( myPopup ); + myActions[ CurvePointsId ]->addTo( curTypePopup ); + myActions[ CurveLinesId ]->addTo( curTypePopup ); + myActions[ CurveSplinesId ]->addTo( curTypePopup ); + myPopup->insertItem( tr( "CURVE_TYPE_POPUP" ), curTypePopup ); + // legend + myPopup->insertSeparator(); + myActions[ LegendId ]->addTo( myPopup ); + // settings + myPopup->insertSeparator(); + myActions[ SettingsId ]->addTo( myPopup ); + } +} +/*! + Renames curve if it is found +*/ +void Plot2d_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject, QString newName ) +{ + Plot2d_Curve* curve = getCurveByIO( IObject ); + if ( curve ) { + curve->setVerTitle( newName ); + int key = hasCurve( curve ); + if ( key ) { + myPlot->setCurveTitle( key, newName ); +// int legendIndex = myPlot->getLegend()->findFirstKey( key ); +// if ( legendIndex != myPlot->getLegend()->itemCnt() ) +// myPlot->getLegend()->setText( legendIndex, aSymbol ); + } + } +} +/*! + Returns true if interactive object is presented in the viewer +*/ +bool Plot2d_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject ) +{ + return ( getCurveByIO( IObject ) != NULL ); +} +/*! + Returns true if interactive object is presented in the viewer and displayed +*/ +bool Plot2d_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject ) +{ + Plot2d_Curve* curve = getCurveByIO( IObject ); + if ( curve ) { + int key = hasCurve( curve ); + if ( key ) + return myPlot->curve( key )->enabled(); + } + return false; +} +/*! + Return interactive obeject if is presented in the viewer +*/ +Handle(SALOME_InteractiveObject) Plot2d_ViewFrame::FindIObject( const char* Entry ) +{ + Handle(SALOME_InteractiveObject) o; + QIntDictIterator it( myCurves ); + for ( ; it.current(); ++it ) { + if ( it.current()->hasIO() && !strcmp( it.current()->getIO()->getEntry(), Entry ) ) { + o = it.current()->getIO(); + break; + } + } + return o; +} +/*! + Actually this method just re-displays curves which refers to the +*/ +void Plot2d_ViewFrame::Display( const Handle(SALOME_InteractiveObject)& IObject, bool update ) +{ + Plot2d_Curve* curve = getCurveByIO( IObject ); + if ( curve ) + updateCurve( curve, update ); +} +/*! + Actually this method just erases all curves which don't refer to + and re-displays curve which is of +*/ +void Plot2d_ViewFrame::DisplayOnly( const Handle(SALOME_InteractiveObject)& IObject ) +{ + Plot2d_Curve* curve = getCurveByIO( IObject ); + QList clist; + getCurves( clist ); + for ( int i = 0; i < clist.count(); i++ ) { + if ( clist.at( i ) != curve ) + eraseCurve( curve ); + else + updateCurve( curve, false ); + } + myPlot->replot(); +} +/*! + Removes from the viewer the curves which refer to +*/ +void Plot2d_ViewFrame::Erase( const Handle(SALOME_InteractiveObject)& IObject, bool update ) +{ + Plot2d_Curve* curve = getCurveByIO( IObject ); + if ( curve ) + eraseCurve( curve, update ); +} +/*! + Actually this method just re-displays all curves which are presented in the viewer +*/ +void Plot2d_ViewFrame::DisplayAll() +{ + QList clist; + getCurves( clist ); + for ( int i = 0; i < clist.count(); i++ ) { + updateCurve( clist.at( i ), false ); + } + myPlot->replot(); +} +/*! + Removes all curves from the view +*/ +void Plot2d_ViewFrame::EraseAll() +{ + myPlot->clear(); + myCurves.clear(); + myPlot->replot(); +} +/*! + Redraws viewframe contents +*/ +void Plot2d_ViewFrame::Repaint() +{ + myPlot->replot(); +} +/*! + Event filter +*/ +bool Plot2d_ViewFrame::eventFilter( QObject* o, QEvent* e ) +{ + if ( ( e->type() == QEvent::MouseButtonPress || e->type() == QEvent::KeyPress ) && o != myPlot->canvas() ) { + myOperation = NoOpId; + qApp->removeEventFilter( this ); + } + return QMainWindow::eventFilter( o, e ); +} +/*! + Sets title +*/ +void Plot2d_ViewFrame::setTitle( const QString& title ) +{ + setMainTitle( myTitleEnabled, title, true ); +} +/*! + Reads Plot2d view settings from the preferences +*/ +void Plot2d_ViewFrame::readPreferences() +{ + if ( QAD_CONFIG->hasSetting( "Plot2d:CurveType" ) ) { // curve type + myCurveType = QAD_CONFIG->getSetting( "Plot2d:CurveType" ).toInt(); + if ( myCurveType < 0 || myCurveType > 2 ) myCurveType = 1; + } + if ( QAD_CONFIG->hasSetting( "Plot2d:ShowLegend" ) ) { + myShowLegend = QAD_CONFIG->getSetting( "Plot2d:ShowLegend" ) == QString( "true" ); // show legend + } + if ( QAD_CONFIG->hasSetting( "Plot2d:LegendPos" ) ) { // legend position + myLegendPos = QAD_CONFIG->getSetting( "Plot2d:LegendPos" ).toInt(); + if ( myLegendPos < 0 || myLegendPos > 3 ) myLegendPos = 1; + } + if ( QAD_CONFIG->hasSetting( "Plot2d:MarkerSize" ) ) { // marker size + myMarkerSize = QAD_CONFIG->getSetting( "Plot2d:MarkerSize" ).toInt(); + } + if ( QAD_CONFIG->hasSetting( "Plot2d:Background" ) ) { // background color + QString bgString = QAD_CONFIG->getSetting( "Plot2d:Background" ); + QStringList bgData = QStringList::split( ":", bgString, true ); + int bgRed = 0, bgGreen = 0, bgBlue = 0; + if ( bgData.count() > 0 ) bgRed = bgData[ 0 ].toInt(); + if ( bgData.count() > 1 ) bgGreen = bgData[ 1 ].toInt(); + if ( bgData.count() > 2 ) bgBlue = bgData[ 2 ].toInt(); + myBackground = QColor( bgRed, bgGreen, bgBlue ); + } + if ( QAD_CONFIG->hasSetting( "Plot2d:ShowTitle" ) ) { // main title + myTitleEnabled = QAD_CONFIG->getSetting( "Plot2d:ShowTitle" ) == QString( "true" ); + } + if ( QAD_CONFIG->hasSetting( "Plot2d:ShowHorTitle" ) ) { // hor.axis title + myXTitleEnabled = QAD_CONFIG->getSetting( "Plot2d:ShowHorTitle" ) == QString( "true" ); + } + if ( QAD_CONFIG->hasSetting( "Plot2d:ShowVerTitle" ) ) { // ver.axisn title + myYTitleEnabled = QAD_CONFIG->getSetting( "Plot2d:ShowVerTitle" ) == QString( "true" ); + } + if ( QAD_CONFIG->hasSetting( "Plot2d:EnableHorMajorGrid" ) ) { // grid + myXGridMajorEnabled = QAD_CONFIG->getSetting( "Plot2d:EnableHorMajorGrid" ) == QString( "true" ); + } + if ( QAD_CONFIG->hasSetting( "Plot2d:EnableVerMajorGrid" ) ) { + myYGridMajorEnabled = QAD_CONFIG->getSetting( "Plot2d:EnableVerMajorGrid" ) == QString( "true" ); + } + if ( QAD_CONFIG->hasSetting( "Plot2d:EnableHorMinorGrid" ) ) { + myXGridMinorEnabled = QAD_CONFIG->getSetting( "Plot2d:EnableHorMinorGrid" ) == QString( "true" ); + } + if ( QAD_CONFIG->hasSetting( "Plot2d:EnableVerMinorGrid" ) ) { + myYGridMinorEnabled = QAD_CONFIG->getSetting( "Plot2d:EnableVerMinorGrid" ) == QString( "true" ); + } + if ( QAD_CONFIG->hasSetting( "Plot2d:HorMajorGridMax" ) ) { + myXGridMaxMajor = QAD_CONFIG->getSetting( "Plot2d:HorMajorGridMax" ).toInt(); + } + if ( QAD_CONFIG->hasSetting( "Plot2d:VerMajorGridMax" ) ) { + myYGridMaxMajor = QAD_CONFIG->getSetting( "Plot2d:VerMajorGridMax" ).toInt(); + } + if ( QAD_CONFIG->hasSetting( "Plot2d:HorMinorGridMax" ) ) { + myXGridMaxMinor = QAD_CONFIG->getSetting( "Plot2d:HorMinorGridMax" ).toInt(); + } + if ( QAD_CONFIG->hasSetting( "Plot2d:VerMinorGridMax" ) ) { + myYGridMaxMinor = QAD_CONFIG->getSetting( "Plot2d:VerMinorGridMax" ).toInt(); + } + if ( QAD_CONFIG->hasSetting( "Plot2d:HorScaleMode" ) ) { // scale mode + myXMode = QAD_CONFIG->getSetting( "Plot2d:HorScaleMode" ).toInt(); + if ( myXMode < 0 || myXMode > 1 ) myXMode = 0; + } + if ( QAD_CONFIG->hasSetting( "Plot2d:VerScaleMode" ) ) { + myYMode = QAD_CONFIG->getSetting( "Plot2d:VerScaleMode" ).toInt(); + if ( myYMode < 0 || myYMode > 1 ) myYMode = 0; + } +} +/*! + Writes Plot2d view settings to the preferences +*/ +void Plot2d_ViewFrame::writePreferences() +{ + QAD_CONFIG->addSetting( "Plot2d:CurveType", myCurveType ); // curve type + QAD_CONFIG->addSetting( "Plot2d:ShowLegend", myShowLegend ? "true" : "false" ); // show legend + QAD_CONFIG->addSetting( "Plot2d:LegendPos", myLegendPos ); // legend position + QAD_CONFIG->addSetting( "Plot2d:MarkerSize", myMarkerSize ); // marker size + QStringList bgData; + bgData.append( QString::number( myBackground.red() ) ); + bgData.append( QString::number( myBackground.green() ) ); + bgData.append( QString::number( myBackground.blue() ) ); + QAD_CONFIG->addSetting( "Plot2d:Background", bgData.join( ":" ) ); // background color + QAD_CONFIG->addSetting( "Plot2d:ShowTitle", myTitleEnabled ? "true" : "false" ); // titles + QAD_CONFIG->addSetting( "Plot2d:ShowHorTitle", myXTitleEnabled ? "true" : "false" ); + QAD_CONFIG->addSetting( "Plot2d:ShowVerTitle", myYTitleEnabled ? "true" : "false" ); + QAD_CONFIG->addSetting( "Plot2d:EnableHorMajorGrid", myXGridMajorEnabled ? "true" : "false" ); // grid + QAD_CONFIG->addSetting( "Plot2d:EnableVerMajorGrid", myYGridMajorEnabled ? "true" : "false" ); + QAD_CONFIG->addSetting( "Plot2d:EnableHorMinorGrid", myXGridMinorEnabled ? "true" : "false" ); + QAD_CONFIG->addSetting( "Plot2d:EnableVerMinorGrid", myYGridMinorEnabled ? "true" : "false" ); + QAD_CONFIG->addSetting( "Plot2d:HorMajorGridMax", myXGridMaxMajor ); + QAD_CONFIG->addSetting( "Plot2d:VerMajorGridMax", myYGridMaxMajor ); + QAD_CONFIG->addSetting( "Plot2d:HorMinorGridMax", myXGridMaxMinor ); + QAD_CONFIG->addSetting( "Plot2d:VerMinorGridMax", myYGridMaxMinor ); + QAD_CONFIG->addSetting( "Plot2d:HorScaleMode", myXMode ); // scale mode + QAD_CONFIG->addSetting( "Plot2d:VerScaleMode", myYMode ); +} +/*! + Prints mouse cursor coordinates into string +*/ +QString Plot2d_ViewFrame::getInfo( const QPoint& pnt ) +{ + QString info; + info.sprintf( "%g - %g", + myPlot->invTransform( QwtPlot::xBottom, pnt.x() ), + myPlot->invTransform( QwtPlot::yLeft, pnt.y() ) ); + info = tr( "INF_COORDINATES" ) + " : " + info; + return info; +} +/*! + Adds curve into view +*/ +void Plot2d_ViewFrame::displayCurve( Plot2d_Curve* curve, bool update ) +{ + if ( !curve ) + return; + if ( hasCurve( curve ) ) { + updateCurve( curve, update ); + } + else { + long curveKey = myPlot->insertCurve( curve->getVerTitle() ); + myCurves.insert( curveKey, curve ); + if ( curve->isAutoAssign() ) { + QwtSymbol::Style typeMarker; + QColor color; + Qt::PenStyle typeLine; + myPlot->getNextMarker( typeMarker, color, typeLine ); + myPlot->setCurvePen( curveKey, QPen( color, DEFAULT_LINE_WIDTH, typeLine ) ); + myPlot->setCurveSymbol( curveKey, QwtSymbol( typeMarker, + QBrush( color ), + QPen( color ), + QSize( myMarkerSize, myMarkerSize ) ) ); + } + else { + Qt::PenStyle ps = Qt::NoPen; + QwtSymbol::Style ms = QwtSymbol::None; + switch ( curve->getLine() ) { + case Plot2d_Curve::Solid: + ps = Qt::SolidLine; break; + case Plot2d_Curve::Dash: + ps = Qt::DashLine; break; + case Plot2d_Curve::Dot: + ps = Qt::DotLine; break; + case Plot2d_Curve::DashDot: + ps = Qt::DashDotLine; break; + case Plot2d_Curve::DashDotDot: + ps = Qt::DashDotDotLine; break; + case Plot2d_Curve::NoPen: + default: + ps = Qt::NoPen; break; + } + switch ( curve->getMarker() ) { + case Plot2d_Curve::Circle: + ms = QwtSymbol::Ellipse; break; + case Plot2d_Curve::Rectangle: + ms = QwtSymbol::Rect; break; + case Plot2d_Curve::Diamond: + ms = QwtSymbol::Diamond; break; + case Plot2d_Curve::DTriangle: + ms = QwtSymbol::DTriangle; break; + case Plot2d_Curve::UTriangle: + ms = QwtSymbol::UTriangle; break; + case Plot2d_Curve::LTriangle: // Qwt confuses LTriangle and RTriangle :((( + ms = QwtSymbol::RTriangle; break; + case Plot2d_Curve::RTriangle: // Qwt confuses LTriangle and RTriangle :((( + ms = QwtSymbol::LTriangle; break; + case Plot2d_Curve::Cross: + ms = QwtSymbol::Cross; break; + case Plot2d_Curve::XCross: + ms = QwtSymbol::XCross; break; + case Plot2d_Curve::None: + default: + ms = QwtSymbol::None; break; + } + myPlot->setCurvePen( curveKey, QPen( curve->getColor(), curve->getLineWidth(), ps ) ); + myPlot->setCurveSymbol( curveKey, QwtSymbol( ms, + QBrush( curve->getColor() ), + QPen( curve->getColor() ), + QSize( myMarkerSize, myMarkerSize ) ) ); + } + if ( myCurveType == 0 ) + myPlot->setCurveStyle( curveKey, QwtCurve::NoCurve ); + else if ( myCurveType == 1 ) + myPlot->setCurveStyle( curveKey, QwtCurve::Lines ); + else if ( myCurveType == 2 ) + myPlot->setCurveStyle( curveKey, QwtCurve::Spline ); + myPlot->setCurveData( curveKey, curve->horData(), curve->verData(), curve->nbPoints() ); + } +// updateTitles(); + if ( update ) + myPlot->replot(); +} +/*! + Adds curves into view +*/ +void Plot2d_ViewFrame::displayCurves( Plot2d_CurveContainer& curves, bool update ) +{ + for ( int i = 0; i < curves.count(); i++ ) { + displayCurve( curves.curve( i ), false ); + } +// fitAll(); + if ( update ) + myPlot->replot(); +} +/*! + Erases curve +*/ +void Plot2d_ViewFrame::eraseCurve( Plot2d_Curve* curve, bool update ) +{ + if ( !curve ) + return; + int curveKey = hasCurve( curve ); + if ( curveKey ) { + myPlot->removeCurve( curveKey ); + myCurves.remove( curveKey ); + if ( update ) + myPlot->replot(); + } +} +/*! + Erases curves +*/ +void Plot2d_ViewFrame::eraseCurves( Plot2d_CurveContainer& curves, bool update ) +{ + for ( int i = 0; i < curves.count(); i++ ) { + eraseCurve( curves.curve( i ), false ); + } +// fitAll(); + if ( update ) + myPlot->replot(); +} +/*! + Udpates curves attributes +*/ +void Plot2d_ViewFrame::updateCurve( Plot2d_Curve* curve, bool update ) +{ + if ( !curve ) + return; + int curveKey = hasCurve( curve ); + if ( curveKey ) { + if ( !curve->isAutoAssign() ) { + Qt::PenStyle ps = Qt::NoPen; + QwtSymbol::Style ms = QwtSymbol::None; + switch ( curve->getLine() ) { + case Plot2d_Curve::Solid: + ps = Qt::SolidLine; break; + case Plot2d_Curve::Dash: + ps = Qt::DashLine; break; + case Plot2d_Curve::Dot: + ps = Qt::DotLine; break; + case Plot2d_Curve::DashDot: + ps = Qt::DashDotLine; break; + case Plot2d_Curve::DashDotDot: + ps = Qt::DashDotDotLine; break; + case Plot2d_Curve::NoPen: + default: + ps = Qt::NoPen; break; + } + switch ( curve->getMarker() ) { + case Plot2d_Curve::Circle: + ms = QwtSymbol::Ellipse; break; + case Plot2d_Curve::Rectangle: + ms = QwtSymbol::Rect; break; + case Plot2d_Curve::Diamond: + ms = QwtSymbol::Diamond; break; + case Plot2d_Curve::DTriangle: + ms = QwtSymbol::DTriangle; break; + case Plot2d_Curve::UTriangle: + ms = QwtSymbol::UTriangle; break; + case Plot2d_Curve::LTriangle: // Qwt confuses LTriangle and RTriangle :((( + ms = QwtSymbol::RTriangle; break; + case Plot2d_Curve::RTriangle: // Qwt confuses LTriangle and RTriangle :((( + ms = QwtSymbol::LTriangle; break; + case Plot2d_Curve::Cross: + ms = QwtSymbol::Cross; break; + case Plot2d_Curve::XCross: + ms = QwtSymbol::XCross; break; + case Plot2d_Curve::None: + default: + ms = QwtSymbol::None; break; + } + myPlot->setCurvePen( curveKey, QPen( curve->getColor(), curve->getLineWidth(), ps ) ); + myPlot->setCurveSymbol( curveKey, QwtSymbol( ms, + QBrush( curve->getColor() ), + QPen( curve->getColor() ), + QSize( myMarkerSize, myMarkerSize ) ) ); + } + myPlot->setCurveTitle( curveKey, curve->getVerTitle() ); + myPlot->curve( curveKey )->setEnabled( true ); + if ( update ) + myPlot->replot(); + } +} +/*! + Returns curve key if is is displayed in the viewer and 0 otherwise +*/ +int Plot2d_ViewFrame::hasCurve( Plot2d_Curve* curve ) +{ + QIntDictIterator it( myCurves ); + for ( ; it.current(); ++it ) { + if ( it.current() == curve ) + return it.currentKey(); + } + return 0; +} +Plot2d_Curve* Plot2d_ViewFrame::getCurveByIO( const Handle(SALOME_InteractiveObject)& theIObject ) +{ + if ( !theIObject.IsNull() ) { + QIntDictIterator it( myCurves ); + for ( ; it.current(); ++it ) { + if ( it.current()->hasIO() && it.current()->getIO()->isSame( theIObject ) ) + return it.current(); + } + } + return 0; +} +/*! + Gets lsit of displayed curves +*/ +int Plot2d_ViewFrame::getCurves( QList& clist ) +{ + clist.clear(); + clist.setAutoDelete( false ); + QIntDictIterator it( myCurves ); + for ( ; it.current(); ++it ) { + clist.append( it.current() ); + } + return clist.count(); +} +/*! + Updates titles according to curves +*/ +void Plot2d_ViewFrame::updateTitles() +{ + QIntDictIterator it( myCurves ); + if ( it.current() ) { + // update axes title + QString xTitle = it.current()->getHorTitle(); + QString yTitle = it.current()->getVerTitle(); + QString xUnits = it.current()->getHorUnits(); + QString yUnits = it.current()->getVerUnits(); + + xUnits = QString( "[ " ) + xUnits + QString( " ]" ); + xTitle = xTitle + ( xTitle.isEmpty() ? QString("") : QString(" ") ) + xUnits; + yUnits = QString( "[ " ) + yUnits + QString( " ]" ); + yTitle = yTitle + ( yTitle.isEmpty() ? QString("") : QString(" ") ) + yUnits; + setXTitle( myXTitleEnabled, xTitle ); + if ( myCurves.count() == 1 ) { + setYTitle( myYTitleEnabled, yTitle ); + } + else { + setYTitle( myYTitleEnabled, yUnits ); + } + setTitle( "" ); + } +} +/*! + Fits the view to see all data +*/ +void Plot2d_ViewFrame::fitAll() +{ + myPlot->setAxisAutoScale( QwtPlot::yLeft ); + myPlot->setAxisAutoScale( QwtPlot::xBottom ); + myPlot->replot(); +} +/*! + Fits the view to rectangle area (pixels) +*/ +void Plot2d_ViewFrame::fitArea( const QRect& area ) +{ + QRect rect = area.normalize(); + if ( rect.width() < MIN_RECT_SIZE ) { + rect.setWidth( MIN_RECT_SIZE ); + rect.setLeft( rect.left() - MIN_RECT_SIZE/2 ); + } + if ( rect.height() < MIN_RECT_SIZE ) { + rect.setHeight( MIN_RECT_SIZE ); + rect.setTop( rect.top() - MIN_RECT_SIZE/2 ); + } + myPlot->setAxisScale( QwtPlot::yLeft, + myPlot->invTransform( QwtPlot::yLeft, rect.top() ), + myPlot->invTransform( QwtPlot::yLeft, rect.bottom() ) ); + myPlot->setAxisScale( QwtPlot::xBottom, + myPlot->invTransform( QwtPlot::xBottom, rect.left() ), + myPlot->invTransform( QwtPlot::xBottom, rect.right() ) ); + myPlot->replot(); +} +/*! + Tests if it is necessary to start operation on mouse action +*/ +int Plot2d_ViewFrame::testOperation( const QMouseEvent& me ) +{ + int btn = me.button() | me.state(); + int zoomBtn = ControlButton | LeftButton; + int panBtn = ControlButton | MidButton; + int fitBtn = ControlButton | RightButton; + + if ( btn == zoomBtn ) + return ZoomId; + if ( btn == panBtn ) + return PanId; + if ( btn == fitBtn ) + return FitAreaId; + return NoOpId; +} +/*! + Mode toolbar buttons slot - horizontal axis (/) +*/ +void Plot2d_ViewFrame::onHorMode() +{ + if ( myActions[ ModeXLinearId ]->isOn() ) + setHorScaleMode( 0 ); + else if ( myActions[ ModeXLogarithmicId ]->isOn() ) + setHorScaleMode( 1 ); +} +/*! + Mode toolbar buttons slot - vertical axis (/) +*/ +void Plot2d_ViewFrame::onVerMode() +{ + if ( myActions[ ModeYLinearId ]->isOn() ) + setVerScaleMode( 0 ); + else if ( myActions[ ModeYLogarithmicId ]->isOn() ) + setVerScaleMode( 1 ); +} +/*! + "Show/hide legend" toolbar action slot +*/ +void Plot2d_ViewFrame::onLegend() +{ + showLegend( myActions[ LegendId ]->isOn() ); +} +/*! + "Curve type" toolbar action slot +*/ +void Plot2d_ViewFrame::onCurves() +{ + if ( myActions[ CurvePointsId ]->isOn() ) + setCurveType( 0 ); + else if ( myActions[ CurveLinesId ]->isOn() ) + setCurveType( 1 ); + else if ( myActions[ CurveSplinesId ]->isOn() ) + setCurveType( 2 ); +} +/*! + "Settings" toolbar action slot +*/ +void Plot2d_ViewFrame::onSettings() +{ + Plot2d_SetupViewDlg* dlg = new Plot2d_SetupViewDlg( this, true ); + dlg->setMainTitle( myTitleEnabled, myTitle ); + dlg->setXTitle( myXTitleEnabled, myXTitle ); + dlg->setYTitle( myYTitleEnabled, myYTitle ); + dlg->setCurveType( myCurveType ); + dlg->setLegend( myShowLegend, myLegendPos ); + dlg->setMarkerSize( myMarkerSize ); + dlg->setBackgroundColor( myBackground ); + dlg->setMajorGrid( myXGridMajorEnabled, myPlot->axisMaxMajor( QwtPlot::xBottom ), + myYGridMajorEnabled, myPlot->axisMaxMajor( QwtPlot::yLeft ) ); + dlg->setMinorGrid( myXGridMinorEnabled, myPlot->axisMaxMinor( QwtPlot::xBottom ), + myYGridMinorEnabled, myPlot->axisMaxMinor( QwtPlot::yLeft ) ); + dlg->setScaleMode( myXMode, myYMode ); + + if ( dlg->exec() == QDialog::Accepted ) { + // horizontal axis title + setXTitle( dlg->isXTitleEnabled(), dlg->getXTitle(), false ); + // vertical axis title + setYTitle( dlg->isYTitleEnabled(), dlg->getYTitle(), false ); + // main title + setMainTitle( dlg->isMainTitleEnabled(), dlg->getMainTitle(), true ); + // curve type + if ( myCurveType != dlg->getCurveType() ) { + setCurveType( dlg->getCurveType(), false ); + } + // legend + if ( myShowLegend != dlg->isLegendEnabled() ) { + showLegend( dlg->isLegendEnabled(), false ); + } + if ( myLegendPos != dlg->getLegendPos() ) { + setLegendPos( dlg->getLegendPos() ); + } + // marker size + if ( myMarkerSize != dlg->getMarkerSize() ) { + setMarkerSize( dlg->getMarkerSize(), false ); + } + // background color + if ( myBackground != dlg->getBackgroundColor() ) { + setBackgroundColor( dlg->getBackgroundColor() ); + } + // grid + bool aXGridMajorEnabled, aXGridMinorEnabled, aYGridMajorEnabled, aYGridMinorEnabled; + int aXGridMaxMajor, aXGridMaxMinor, aYGridMaxMajor, aYGridMaxMinor; + dlg->getMajorGrid( aXGridMajorEnabled, aXGridMaxMajor, aYGridMajorEnabled, aYGridMaxMajor ); + dlg->getMinorGrid( aXGridMinorEnabled, aXGridMaxMinor, aYGridMinorEnabled, aYGridMaxMinor ); + setXGrid( aXGridMajorEnabled, aXGridMaxMajor, aXGridMinorEnabled, aXGridMaxMinor, false ); + setYGrid( aYGridMajorEnabled, aYGridMaxMajor, aYGridMinorEnabled, aYGridMaxMinor, false ); + // scale mode + if ( myXMode != dlg->getXScaleMode() ) { + setHorScaleMode( dlg->getXScaleMode() ); + } + if ( myYMode != dlg->getYScaleMode() ) { + setVerScaleMode( dlg->getYScaleMode() ); + } + // update view + myPlot->replot(); + // update preferences + if ( dlg->isSetAsDefault() ) + writePreferences(); + } + delete dlg; +} +/*! + Sets curve type +*/ +void Plot2d_ViewFrame::setCurveType( int curveType, bool update ) +{ + myCurveType = curveType; + if ( curveType == 0 ) + myActions[ CurvePointsId ]->setOn( true ); + else if ( curveType == 1 ) + myActions[ CurveLinesId ]->setOn( true ); + else if ( curveType == 2 ) + myActions[ CurveSplinesId ]->setOn( true ); + + QArray keys = myPlot->curveKeys(); + for ( int i = 0; i < keys.count(); i++ ) { + if ( myCurveType == 0 ) + myPlot->setCurveStyle( keys[i], QwtCurve::NoCurve ); + else if ( myCurveType == 1 ) + myPlot->setCurveStyle( keys[i], QwtCurve::Lines ); + else if ( myCurveType == 2 ) + myPlot->setCurveStyle( keys[i], QwtCurve::Spline ); + } + if ( update ) + myPlot->replot(); +} +/*! + Shows/hides legend +*/ +void Plot2d_ViewFrame::showLegend( bool show, bool update ) +{ + myShowLegend = show; + myActions[ LegendId ]->setOn( myShowLegend ); + { + myPlot->setAutoLegend( myShowLegend ); + myPlot->enableLegend( myShowLegend ); + } + if ( update ) + myPlot->replot(); +} +/*! + Sets legend position : 0 - left, 1 - right, 2 - top, 3 - bottom +*/ +void Plot2d_ViewFrame::setLegendPos( int pos ) +{ + myLegendPos = pos; + switch( pos ) { + case 0: + myPlot->setLegendPos( Qwt::Left ); + break; + case 1: + myPlot->setLegendPos( Qwt::Right ); + break; + case 2: + myPlot->setLegendPos( Qwt::Top ); + break; + case 3: + myPlot->setLegendPos( Qwt::Bottom ); + break; + } +} +/*! + Sets new marker size +*/ +void Plot2d_ViewFrame::setMarkerSize( const int size, bool update ) +{ + if ( myMarkerSize != size ) { + myMarkerSize = size; + QArray keys = myPlot->curveKeys(); + for ( int i = 0; i < keys.count(); i++ ) { + QwtPlotCurve* crv = myPlot->curve( keys[i] ); + if ( crv ) { + QwtSymbol aSymbol = crv->symbol(); + aSymbol.setSize( myMarkerSize, myMarkerSize ); + crv->setSymbol( aSymbol ); + int legendIndex = myPlot->getLegend()->findFirstKey( keys[i] ); + if ( legendIndex != myPlot->getLegend()->itemCnt() ) + myPlot->getLegend()->setSymbol( legendIndex, aSymbol ); + } + } + if ( update ) + myPlot->replot(); + } +} +/*! + Sets background color +*/ +void Plot2d_ViewFrame::setBackgroundColor( const QColor& color ) +{ + myBackground = color; + myPlot->setCanvasBackground( myBackground ); +} +/*! + Gets background color +*/ +QColor Plot2d_ViewFrame::backgroundColor() const +{ + return myBackground; +} +/*! + Sets hor.axis grid parameters +*/ +void Plot2d_ViewFrame::setXGrid( bool xMajorEnabled, const int xMajorMax, + bool xMinorEnabled, const int xMinorMax, + bool update ) +{ + myXGridMajorEnabled = xMajorEnabled; + myXGridMinorEnabled = xMinorEnabled; + myXGridMaxMajor = xMajorMax; + myXGridMaxMinor = xMinorMax; + myPlot->setAxisMaxMajor( QwtPlot::xBottom, myXGridMaxMajor ); + myPlot->setAxisMaxMinor( QwtPlot::xBottom, myXGridMaxMinor ); + myPlot->enableGridX( myXGridMajorEnabled ); + myPlot->enableGridXMin( myXGridMinorEnabled ); + if ( update ) + myPlot->replot(); +} +/*! + Sets ver.axis grid parameters +*/ +void Plot2d_ViewFrame::setYGrid( bool yMajorEnabled, const int yMajorMax, + bool yMinorEnabled, const int yMinorMax, + bool update ) +{ + myYGridMajorEnabled = yMajorEnabled; + myYGridMinorEnabled = yMinorEnabled; + myYGridMaxMajor = yMajorMax; + myYGridMaxMinor = yMinorMax; + myPlot->setAxisMaxMajor( QwtPlot::yLeft, myYGridMaxMajor ); + myPlot->setAxisMaxMinor( QwtPlot::yLeft, myYGridMaxMinor ); + myPlot->enableGridY( myYGridMajorEnabled ); + myPlot->enableGridYMin( myYGridMinorEnabled ); + if ( update ) + myPlot->replot(); +} +/*! + Sets main title +*/ +void Plot2d_ViewFrame::setMainTitle( bool enabled, const QString& title, bool update ) +{ + myTitleEnabled = enabled; + myTitle = title; + myPlot->setTitle( myTitleEnabled ? myTitle : QString::null ); + if ( update ) + myPlot->replot(); +} +/*! + Sets hor.axis title +*/ +void Plot2d_ViewFrame::setXTitle( bool enabled, const QString& title, bool update ) +{ + myXTitleEnabled = enabled; + myXTitle = title; + myPlot->setAxisTitle( QwtPlot::xBottom, myXTitleEnabled ? myXTitle : QString::null ); + if ( update ) + myPlot->replot(); +} +/*! + Sets ver.axis title +*/ +void Plot2d_ViewFrame::setYTitle( bool enabled, const QString& title, bool update ) +{ + myYTitleEnabled = enabled; + myYTitle = title; + myPlot->setAxisTitle( QwtPlot::yLeft, myYTitleEnabled ? myYTitle : QString::null ); + if ( update ) + myPlot->replot(); +} +/*! + Sets scale mode for horizontal axis: 0 - linear, 1 - logarithmic +*/ +void Plot2d_ViewFrame::setHorScaleMode( const int mode, bool update ) +{ + myXMode = mode; + if ( myXMode == 0 ) { // linear + myActions[ ModeXLogarithmicId ]->setOn( false ); + myActions[ ModeXLinearId ]->setOn( true ); + myPlot->changeAxisOptions( QwtPlot::xBottom, QwtAutoScale::Logarithmic, false ); + } + else { // logarithmic + myActions[ ModeXLinearId ]->setOn( false ); + myActions[ ModeXLogarithmicId ]->setOn( true ); + myPlot->changeAxisOptions( QwtPlot::xBottom, QwtAutoScale::Logarithmic, true ); + } + if ( update ) +// myPlot->replot(); + fitAll(); +} +/*! + Sets scale mode for vertical axis: 0 - linear, 1 - logarithmic +*/ +void Plot2d_ViewFrame::setVerScaleMode( const int mode, bool update ) +{ + myYMode = mode; + if ( myYMode == 0 ) { // linear + myActions[ ModeYLogarithmicId ]->setOn( false ); + myActions[ ModeYLinearId ]->setOn( true ); + myPlot->changeAxisOptions( QwtPlot::yLeft, QwtAutoScale::Logarithmic, false ); + } + else { // logarithmic + myActions[ ModeYLinearId ]->setOn( false ); + myActions[ ModeYLogarithmicId ]->setOn( true ); + myPlot->changeAxisOptions( QwtPlot::yLeft, QwtAutoScale::Logarithmic, true ); + } + if ( update ) +// myPlot->replot(); + fitAll(); +} +/*! + Slot, called when Legend item is clicked +*/ +void Plot2d_ViewFrame::onLegendClicked( long key ) +{ + Plot2d_Curve* curve = myCurves[ key ]; + if ( curve && curve->hasIO() ) { + SALOME_Selection* Sel = SALOME_Selection::Selection( QAD_Application::getDesktop()->getActiveStudy()->getSelection() ); + Sel->ClearIObjects(); + Sel->AddIObject( curve->getIO(), true ); + } +} + +/*! + Slot, called when user presses mouse button +*/ +void Plot2d_ViewFrame::plotMousePressed( const QMouseEvent& me ) +{ + if ( myOperation == NoOpId ) + myOperation = testOperation( me ); + if ( myOperation != NoOpId ) { + myPnt = me.pos(); + if ( myOperation == ZoomId ) { + myPlot->canvas()->setCursor( QCursor( QPixmap( imageZoomCursor ) ) ); + } + else if ( myOperation == PanId ) { + myPlot->canvas()->setCursor( QCursor( Qt::SizeAllCursor ) ); + } + else if ( myOperation == FitAreaId ) { + myPlot->canvas()->setCursor( QCursor( Qt::PointingHandCursor ) ); + myPlot->setOutlineStyle( Qwt::Rect ); + } + } + else { + int btn = me.button() | me.state(); + if ( btn == RightButton ) { + createPopup(); + if ( myPopup ) { + QAD_Tools::checkPopup( myPopup ); + if ( myPopup->count()>0 ) { + myPopup->exec( QCursor::pos() ); + } + destroyPopup(); + } + } + else { + myPlot->setOutlineStyle( Qwt::Cross ); + QAD_Application::getDesktop()->putInfo( getInfo( me.pos() ) ); + } + } +} +/*! + Slot, called when user moves mouse +*/ +void Plot2d_ViewFrame::plotMouseMoved( const QMouseEvent& me ) +{ + int dx = me.pos().x() - myPnt.x(); + int dy = me.pos().y() - myPnt.y(); + + if ( myOperation != NoOpId) { + if ( myOperation == ZoomId ) { + QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); + QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); + + myPlot->setAxisScale( QwtPlot::yLeft, + myPlot->invTransform( QwtPlot::yLeft, yMap.i1() ), + myPlot->invTransform( QwtPlot::yLeft, yMap.i2() + dy ) ); + myPlot->setAxisScale( QwtPlot::xBottom, + myPlot->invTransform( QwtPlot::xBottom, xMap.i1() ), + myPlot->invTransform( QwtPlot::xBottom, xMap.i2() - dx ) ); + myPlot->replot(); + myPnt = me.pos(); + } + else if ( myOperation == PanId ) { + QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom ); + QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft ); + + myPlot->setAxisScale( QwtPlot::yLeft, + myPlot->invTransform( QwtPlot::yLeft, yMap.i1()-dy ), + myPlot->invTransform( QwtPlot::yLeft, yMap.i2()-dy ) ); + myPlot->setAxisScale( QwtPlot::xBottom, + myPlot->invTransform( QwtPlot::xBottom, xMap.i1()-dx ), + myPlot->invTransform( QwtPlot::xBottom, xMap.i2()-dx ) ); + myPlot->replot(); + myPnt = me.pos(); + } + } + else { + QAD_Application::getDesktop()->putInfo( getInfo( me.pos() ) ); + } +} +/*! + Slot, called when user releases mouse +*/ +void Plot2d_ViewFrame::plotMouseReleased( const QMouseEvent& me ) +{ + if ( myOperation == FitAreaId ) { + QRect rect( myPnt, me.pos() ); + fitArea( rect ); + } + myPlot->canvas()->setCursor( QCursor( Qt::CrossCursor ) ); + myPlot->setOutlineStyle( Qwt::Triangle ); + QAD_Application::getDesktop()->putInfo( tr( "INF_READY" ) ); + myOperation = NoOpId; +} +/*! + View operations : Pan view +*/ +void Plot2d_ViewFrame::onViewPan() +{ + myOperation = PanId; + qApp->installEventFilter( this ); +} +/*! + View operations : Zoom view +*/ +void Plot2d_ViewFrame::onViewZoom() +{ + myOperation = ZoomId; + qApp->installEventFilter( this ); +} +/*! + View operations : Fot All +*/ +void Plot2d_ViewFrame::onViewFitAll() +{ + fitAll(); +} +/*! + View operations : Fit Area +*/ +void Plot2d_ViewFrame::onViewFitArea() +{ + myOperation = FitAreaId; + qApp->installEventFilter( this ); +} +/*! + View operations : Global panning +*/ +void Plot2d_ViewFrame::onViewGlobalPan() +{ MESSAGE( "Plot2d_ViewFrame::onViewGlobalPan : NOT SUPPORTED" ); } +/*! + View operations : Rotate view +*/ +void Plot2d_ViewFrame::onViewRotate() +{ MESSAGE( "Plot2d_ViewFrame::onViewRotate : NOT SUPPORTED" ); } +/*! + View operations : Reset view +*/ +void Plot2d_ViewFrame::onViewReset() +{ MESSAGE( "Plot2d_ViewFrame::onViewReset : NOT SUPPORTED" ); } +/*! + View operations : View front +*/ +void Plot2d_ViewFrame::onViewFront() +{ MESSAGE( "Plot2d_ViewFrame::onViewFront : NOT SUPPORTED" ); } +/*! + View operations : View back +*/ +void Plot2d_ViewFrame::onViewBack() +{ MESSAGE( "Plot2d_ViewFrame::onViewBack : NOT SUPPORTED" ); } +/*! + View operations : View right +*/ +void Plot2d_ViewFrame::onViewRight() +{ MESSAGE( "Plot2d_ViewFrame::onViewRight : NOT SUPPORTED" ); } +/*! + View operations : View left +*/ +void Plot2d_ViewFrame::onViewLeft() +{ MESSAGE( "Plot2d_ViewFrame::onViewLeft : NOT SUPPORTED" ); } +/*! + View operations : View bottom +*/ +void Plot2d_ViewFrame::onViewBottom() +{ MESSAGE( "Plot2d_ViewFrame::onViewBottom : NOT SUPPORTED" ); } +/*! + View operations : View top +*/ +void Plot2d_ViewFrame::onViewTop() +{ MESSAGE( "Plot2d_ViewFrame::onViewTop : NOT SUPPORTED" ); } +/*! + View operations : Show/hide trihedron +*/ +void Plot2d_ViewFrame::onViewTrihedron() +{ MESSAGE( "Plot2d_ViewFrame::onViewTrihedron : NOT SUPPORTED" ); } + + +//================================================================================= +// Plot2d_Plot2d implementation +//================================================================================= + +/*! + Constructor +*/ +Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent ) + : QwtPlot( parent ) +{ + // outline + enableOutline( true ); + setOutlineStyle( Qwt::Triangle ); + setOutlinePen( green ); + // legend + setAutoLegend( false ); + setLegendFrameStyle( QFrame::Box | QFrame::Sunken ); + enableLegend( false ); + // grid + enableGridX( false ); + enableGridXMin( false ); + enableGridY( false ); + enableGridYMin( false ); + // auto scaling by default + setAxisAutoScale( QwtPlot::yLeft ); + setAxisAutoScale( QwtPlot::xBottom ); +} +/*! + Recalculates and redraws Plot 2d view +*/ +void Plot2d_Plot2d::replot() +{ + updateLayout(); // to fix bug(?) of Qwt - view is not updated when title is changed + QwtPlot::replot(); +} +/*! + Gets new unique marker for item if possible +*/ +void Plot2d_Plot2d::getNextMarker( QwtSymbol::Style& typeMarker, QColor& color, Qt::PenStyle& typeLine ) +{ + static int aMarker = -1; + static int aColor = -1; + static int aLine = -1; + + if ( myColors.isEmpty() ) { + // creating colors list + myColors.append( Qt::white ); + myColors.append( Qt::blue ); + myColors.append( Qt::gray ); + myColors.append( Qt::darkGreen ); + myColors.append( Qt::magenta ); + myColors.append( Qt::darkGray ); + myColors.append( Qt::red ); + myColors.append( Qt::darkBlue ); + myColors.append( Qt::darkYellow ); + myColors.append( Qt::cyan ); + myColors.append( Qt::darkRed ); + myColors.append( Qt::darkCyan ); + myColors.append( Qt::yellow ); + myColors.append( Qt::darkMagenta ); + myColors.append( Qt::green ); + myColors.append( Qt::black ); + } + + int nbMarkers = 11; // QwtSymbol supports 11 marker types + int nbLines = 6; // Qt supports 6 line types + int nbColors = myColors.count(); // number of default colors supported + + aMarker = ( aMarker + 1 ) % nbMarkers; + if ( aMarker == QwtSymbol::None || aMarker == QwtSymbol::Triangle ) aMarker++; + aColor = ( aColor + 1 ) % nbColors; + aLine = ( aLine + 1 ) % nbLines; + if ( aLine == Qt::NoPen ) aLine++; + + typeMarker = ( QwtSymbol::Style )aMarker; + color = myColors[ aColor ]; + typeLine = ( Qt::PenStyle )aLine; + if ( !existMarker( typeMarker, color, typeLine ) ) + return; + + int i, j, k; + for ( i = 0; i < nbMarkers; i++ ) { + aMarker = ( aMarker + 1 ) % nbMarkers; + if ( aMarker == QwtSymbol::None || aMarker == QwtSymbol::Triangle ) aMarker++; + for ( j = 0; j < nbColors; j++ ) { + aColor = ( aColor + 1 ) % nbColors; + for ( k = 0; k < nbLines; k++ ) { + aLine = ( aLine + 1 ) % nbLines; + if ( aLine == Qt::NoPen ) aLine++; + if ( !existMarker( ( QwtSymbol::Style )aMarker, aColor, ( Qt::PenStyle )aLine ) ) { + typeMarker = ( QwtSymbol::Style )aMarker; + color = myColors[ aColor ]; + typeLine = ( Qt::PenStyle )aLine; + return; + } + } + } + } +} +/*! + Checks if marker belongs to any enitity +*/ +bool Plot2d_Plot2d::existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine ) +{ + // getting all curves + QArray keys = curveKeys(); + QColor aRgbColor; + + for ( int i = 0; i < keys.count(); i++ ) { + QwtPlotCurve* crv = curve( keys[i] ); + if ( crv ) { + QwtSymbol::Style aStyle = crv->symbol().style(); + QColor aColor = crv->pen().color(); + Qt::PenStyle aLine = crv->pen().style(); + if ( aStyle == typeMarker && aColor == color && aLine == typeLine ) + return true; + } + } + return false; +} + diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h new file mode 100644 index 000000000..9b611874f --- /dev/null +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -0,0 +1,198 @@ +// File : Plot2d_ViewFrame.h +// Created : Wed Jun 27 16:38:42 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef Plot2d_ViewFrame_H +#define Plot2d_ViewFrame_H + +#include "QAD_ViewFrame.h" +#include "QAD_Popup.h" +#include "Plot2d_Curve.h" +#include "Plot2d_CurveContainer.h" +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : Plot2d_ViewFrame +// purpose : Plot2d view frame +//================================================================================= +class Plot2d_Plot2d; +typedef QIntDict CurveDict; + +class QAD_EXPORT Plot2d_ViewFrame : public QAD_ViewFrame, public QAD_PopupClientServer +{ + Q_OBJECT + + enum { NoOpId, FitAllId, FitAreaId, ZoomId, PanId, DumpId, + ModeXLinearId, ModeXLogarithmicId, ModeYLinearId, ModeYLogarithmicId, + LegendId, CurvePointsId, CurveLinesId, CurveSplinesId, SettingsId }; +public: + /* Construction/destruction */ + Plot2d_ViewFrame( QWidget* parent, const QString& title = "" ); + virtual ~Plot2d_ViewFrame(); + +public: + /* inherited */ + ViewType getTypeView() const { return VIEW_PLOT2D; } + QWidget* getViewWidget(); + void SetSelectionMode( int mode ) {} + void SetTrihedronSize( int dim ) {} + + /* popup management */ + void setPopupServer( QAD_Application* ); + void onCreatePopup(); + + /* interactive object management */ + void highlight( const Handle(SALOME_InteractiveObject)& IObject, + bool highlight, bool update = true ) {} + void unHighlightAll() {} + void rename( const Handle(SALOME_InteractiveObject)& IObject, + QString newName ); + 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 ) {} + + /* interactive objects handling */ + Handle(SALOME_InteractiveObject) FindIObject( const char* Entry ); + + /* display */ + void Display( const Handle(SALOME_InteractiveObject)& IObject, bool update = true ); + void DisplayOnly( const Handle(SALOME_InteractiveObject)& IObject ); + void Erase( const Handle(SALOME_InteractiveObject)& IObject, bool update = true ); + void DisplayAll(); + void EraseAll(); + void Repaint(); + + /* event filter */ + bool eventFilter( QObject* o, QEvent* e ); + + /* operations */ + void setTitle( const QString& title ); + QString getTitle() const { return myTitle; } + void displayCurve( Plot2d_Curve* curve, bool update = false ); + void displayCurves( Plot2d_CurveContainer& curves, bool update = false ); + void eraseCurve( Plot2d_Curve* curve, bool update = false ); + void eraseCurves( Plot2d_CurveContainer& curves, bool update = false ); + int getCurves( QList& clist ); + int hasCurve( Plot2d_Curve* curve ); + Plot2d_Curve* getCurveByIO( const Handle(SALOME_InteractiveObject)& theIObject ); + void updateCurve( Plot2d_Curve* curve, bool update = false ); + void fitAll(); + void fitArea( const QRect& area ); + + /* view parameters */ + void setCurveType( int curveType, bool update = true ); + int getCurveType() const { return myCurveType; } + void showLegend( bool show, bool update = true ); + void setLegendPos( int pos ); + int getLegendPos() const { return myLegendPos; } + void setMarkerSize( const int size, bool update = true ); + int getMarkerSize() const { return myMarkerSize; } + void setBackgroundColor( const QColor& color ); + QColor backgroundColor() const; + void setXGrid( bool xMajorEnabled, const int xMajorMax, bool xMinorEnabled, const int xMinorMax, bool update = true ); + void setYGrid( bool yMajorEnabled, const int yMajorMax, bool yMinorEnabled, const int yMinorMax, bool update = true ); + void setMainTitle( bool enabled, const QString& title, bool update = true); + void setXTitle( bool enabled, const QString& title, bool update = true ); + QString getXTitle() const { return myXTitle; } + void setYTitle( bool enabled, const QString& title, bool update = true ); + QString getYTitle() const { return myYTitle; } + void setHorScaleMode( const int mode, bool update = true ); + int getHorScaleMode() const { return myXMode; } + void setVerScaleMode( const int mode, bool update = true ); + int getVerScaleMode() const { return myYMode; } + +protected: + void createActions(); + int testOperation( const QMouseEvent& ); + void readPreferences(); + void writePreferences(); + QString getInfo( const QPoint& pnt ); + void updateTitles(); + +public slots: + void onViewPan(); + void onViewZoom(); + void onViewFitAll(); + void onViewFitArea(); + void onViewGlobalPan(); + void onViewRotate(); + void onViewReset(); + void onViewFront(); + void onViewBack(); + void onViewRight(); + void onViewLeft(); + void onViewBottom(); + void onViewTop(); + void onViewTrihedron(); + void onHorMode(); + void onVerMode(); + void onLegend(); + void onCurves(); + void onSettings(); + +protected slots: + void onLegendClicked( long key ); + void plotMousePressed( const QMouseEvent& ); + void plotMouseMoved( const QMouseEvent& ); + void plotMouseReleased( const QMouseEvent& ); + +private: + Plot2d_Plot2d* myPlot; + QMap myActions; + int myOperation; + QPoint myPnt; + CurveDict myCurves; + + int myCurveType; + bool myShowLegend; + int myLegendPos; + int myMarkerSize; + QColor myBackground; + QString myTitle, myXTitle, myYTitle; + bool myTitleEnabled, myXTitleEnabled, myYTitleEnabled; + bool myXGridMajorEnabled, myYGridMajorEnabled; + bool myXGridMinorEnabled, myYGridMinorEnabled; + int myXGridMaxMajor, myYGridMaxMajor; + int myXGridMaxMinor, myYGridMaxMinor; + int myXMode, myYMode; +}; + +//================================================================================= +// class : Plot2d_Plot2d +// purpose : Plot2d View +//================================================================================= +class Plot2d_Plot2d : public QwtPlot +{ +public: + Plot2d_Plot2d( QWidget* parent ); + + void replot(); + void getNextMarker( QwtSymbol::Style& typeMarker, QColor& color, Qt::PenStyle& typeLine ); + QwtLegend* getLegend() { return d_legend; } + +protected: + bool existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine ); + +protected: + QValueList myColors; +}; + +#endif // Plot2d_ViewFrame_H + + + + diff --git a/src/Registry/Makefile.in b/src/Registry/Makefile.in new file mode 100644 index 000000000..874140848 --- /dev/null +++ b/src/Registry/Makefile.in @@ -0,0 +1,38 @@ +#============================================================================== +# File : Makefile.in +# Created : mar jui 3 12:58:13 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl:../Logger + + +@COMMENCE@ + +EXPORT_PYSCRIPTS = + +EXPORT_HEADERS = \ + RegistryConnexion.hxx + +# Libraries targets + +LIB = libRegistry.la +LIB_SRC = RegistryConnexion.cxx +LIB_CLIENT_IDL = SALOME_Registry.idl + +# Executables targets +BIN = SALOME_Registry_Server +BIN_SRC = RegistryService.cxx +BIN_SERVER_IDL = SALOME_Registry.idl + +LDFLAGS+= -lSalomeNS -lOpUtil -lSalomeLoggerServer +CPPFLAGS+= -I../Logger + +@CONCLUDE@ diff --git a/src/Registry/RegistryConnexion.cxx b/src/Registry/RegistryConnexion.cxx new file mode 100644 index 000000000..59073d9cd --- /dev/null +++ b/src/Registry/RegistryConnexion.cxx @@ -0,0 +1,140 @@ +using namespace std; +//============================================================================= +// File : RegistryConnexion.cxx +// Created : Mon Nov 5 17:26:23 CET 2001 +// Author : Pascale NOYRET - Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +using namespace std; +# include "Utils_ORB_INIT.hxx" +# include "RegistryConnexion.hxx" +# include "SALOME_NamingService.hxx" +# include "Utils_Identity.hxx" +# include "Utils_SINGLETON.hxx" +# include "Utils_CommException.hxx" +# include "OpUtil.hxx" +# include "utilities.h" + +extern "C" +{ +# include +} + + +Registry::Components_var Connexion( int argc , char **argv , const char *ptrSessionName ) throw( CommException ) +{ + Registry::Components_var varComponents = 0 ; + ASSERT(ptrSessionName) ; + ASSERT(strlen(ptrSessionName)>0) ; + const char *registryName = "Registry" ; + + try + { + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + CORBA::ORB_var &orb = init( argc , argv ) ; + + SALOME_NamingService &naming = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + naming.init_orb( orb ) ; + + // Recuperation de la reference de l'objet + CORBA::Object_var object = naming.Resolve( registryName ) ; + if(CORBA::is_nil(object)) throw CommException( "unable to find the RegistryService" ) ; + + // Specialisation de l'objet generique + varComponents = Registry::Components::_narrow( object ) ; + ASSERT(! CORBA::is_nil(varComponents)) ; + } + catch( ... ) + { + throw CommException ( "NamingService Connexion Error" ) ; + } + return varComponents ; +} + + +RegistryConnexion::RegistryConnexion( int argc , char **argv , const char *ior , const char *ptrSessionName, const char *componentName ): \ + _Ior(duplicate(ior)), _VarComponents( Connexion(argc,argv,ptrSessionName) ), _SessionName(ptrSessionName),_Name(""), _Id(0) +{ + this->add( componentName ) ; +} + + +RegistryConnexion::RegistryConnexion( void ): _Ior(0), _VarComponents( 0 ), _Name(""), _Id(0) +{ + INTERRUPTION(EXIT_FAILURE) ; +} + + +RegistryConnexion::~RegistryConnexion() +{ + BEGIN_OF("RegistryConnexion::~RegistryConnexion()" ) ; + if( _Id != 0 ) + { + ASSERT(_SessionName!="" ) ; + ASSERT(_Name!="" ) ; + _VarComponents->remove( _Id ) ; + } + _Id = 0 ; + delete [] _Ior; + _Ior = 0; + _SessionName = ""; + _Name = "" ; + END_OF("RegistryConnexion::~RegistryConnexion()" ) ; +} + + +void RegistryConnexion::add( const char *aName ) +{ + ASSERT(_SessionName!="" ) ; + ASSERT(_Name=="" ) ; + ASSERT(_Id==0 ) ; + ASSERT(aName) ; + SCRUTE(aName) ; + ASSERT(strlen( aName )>0) ; + + const Identity lesInfos( aName ) ; + Registry::Infos infos ; + infos.name = CORBA::string_dup( lesInfos.name() ) ; + infos.pid = lesInfos.pid() ; + infos.machine = CORBA::string_dup( lesInfos.host_char() ) ; + infos.adip = CORBA::string_dup( lesInfos.adip() ) ; + infos.uid = lesInfos.uid() ; + infos.pwname = CORBA::string_dup( lesInfos.pwname() ) ; + infos.tc_start = lesInfos.start() ; + infos.tc_hello = 0 ; + infos.tc_end = 0 ; + infos.difftime = 0 ; + infos.cdir = CORBA::string_dup( lesInfos.rep() ) ; + infos.status = -1 ; + infos.ior = CORBA::string_dup(_Ior); + + ASSERT(!CORBA::is_nil(this->_VarComponents)) ; + + CORBA::ULong id = _VarComponents->add( infos ) ; + + SCRUTE(aName) ; SCRUTE(id) ; + ASSERT(id) ; + + _Id = id ; + _Name = aName ; + + return ; +} + + +void RegistryConnexion::remove( void ) +{ + ASSERT(_Id>0) ; + ASSERT(!CORBA::is_nil(this->_VarComponents)) ; + _VarComponents->remove( _Id ) ; + + _Name = "" ; + _Id = 0 ; + + return ; +} diff --git a/src/Registry/RegistryConnexion.hxx b/src/Registry/RegistryConnexion.hxx new file mode 100644 index 000000000..da87c4bae --- /dev/null +++ b/src/Registry/RegistryConnexion.hxx @@ -0,0 +1,38 @@ +//============================================================================= +// File : RegistryConnexion.hxx +// Created : Mon Nov 5 17:26:23 CET 2001 +// Author : Pascale NOYRET - Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +/* + RegistryConnexion should be used by an engine to add or to remove a component. + +*/ +# if !defined( __RegistryConnexion_HXX__ ) +# define __RegistryConnexion_HXX__ + +#include +#include CORBA_CLIENT_HEADER(SALOME_Registry) +#include + +class RegistryConnexion +{ +protected : + const char* _Ior ; // engine ior + Registry::Components_var _VarComponents ; // RegistryService reference + string _SessionName ; + string _Name ; // code name + int _Id ; // code identity returned by RegistryService + void add( const char *aName ); + void remove( void ); + RegistryConnexion( void ); + +public : + RegistryConnexion( int argc , char **argv , const char *ior , const char *ptrSessionName, const char *componentName ); + ~RegistryConnexion(); +} ; + +# endif /* # if !defined( __RegistryConnexion_H__ ) */ diff --git a/src/Registry/RegistryService.cxx b/src/Registry/RegistryService.cxx new file mode 100644 index 000000000..ff216e751 --- /dev/null +++ b/src/Registry/RegistryService.cxx @@ -0,0 +1,231 @@ +using namespace std; +//============================================================================= +// File : RegistryService.cxx +// Created : Mon Nov 5 17:26:23 CET 2001 +// Author : Pascale NOYRET - Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +using namespace std; +# include "RegistryService.hxx" +# include "OpUtil.hxx" +# include "utilities.h" + +extern "C" +{ +# include +} + +#include + +/* ------------------------------*/ +/* Constructeurs et Destructeurs */ +/* ------------------------------*/ + +RegistryService::RegistryService( void ) : _SessionName(0), _Compteur(0) +{ + MESSAGE("Passage dans RegistryService::RegistryService()") ; + +} + + +RegistryService::~RegistryService() +{ + BEGIN_OF("RegistryService::~RegistryService()") ; + map::iterator im; + for (im=_reg.begin();im!=_reg.end(); im++) + { + const client_infos &lesInfos = *(*im).second ; + MESSAGE("Deletion") ; SCRUTE( lesInfos._name ) ; + _reg.erase ( im ) ; + } + ASSERT(_reg.size()==0) ; + for (im=_fin.begin();im!=_fin.end(); im++) + { + const client_infos &lesInfos = *(*im).second ; + MESSAGE("Deletion") ; SCRUTE( lesInfos._name ) ; + _fin.erase ( im ) ; + } + ASSERT(_fin.size()==0) ; + _Compteur = -1 ; + if ( _SessionName ) + { + delete [] _SessionName ; + _SessionName = 0 ; + } + END_OF("RegistryService::~RegistryService()") ; +} + +/* ------------------------------*/ +/* Contrats IDL */ +/* ------------------------------*/ + +CORBA::ULong RegistryService::size ( void ) +{ + ASSERT(_SessionName) ; + ASSERT(strlen(_SessionName)>0) ; + return _reg.size() ; +} + + +CORBA::ULong RegistryService::add( const Registry::Infos & infos ) +{ + BEGIN_OF("RegistryService::add") ; + ASSERT(_SessionName) ; + ASSERT(strlen(_SessionName)>0) ; + client_infos *ptr_Component = new client_infos( infos ) ; + ASSERT(ptr_Component) ; + SCRUTE(ptr_Component->_name) ; + + _Compteur++; + _reg[_Compteur]=ptr_Component; + + END_OF("RegistryService::add") ; + return (CORBA::ULong)_Compteur ; +} + + +void RegistryService::remove( const CORBA::ULong id) +{ + BEGIN_OF("RegistryService::remove") ; + SCRUTE(id) ; + ASSERT(_SessionName) ; + ASSERT(strlen(_SessionName)>0) ; + + ASSERT(_reg.find(id)!=_reg.end()) + _reg[id]->_status=TERMINATED; + _reg[id]->_ts_end = time(NULL) ; + + _fin[id]=_reg[id]; + SCRUTE(_fin.size()) ; + + map::iterator pos = _reg.find ( id ) ; + _reg.erase ( pos ) ; + SCRUTE(_reg.size()) ; + SCRUTE(_fin.size()) ; + + END_OF("RegistryService::remove") ; + return ; +} + + + +void RegistryService::hello( const CORBA::ULong id ) +{ + BEGIN_OF("RegistryService::hello") ; + SCRUTE(id) ; + ASSERT(_SessionName) ; + ASSERT(strlen(_SessionName)>0) ; + + ASSERT(_reg.find(id)!=_reg.end()) + _reg[id]->_ts_hello = time(NULL) ; + + END_OF("RegistryService::hello") ; + return ; +} + + +void RegistryService::end( void ) +{ + ASSERT(_SessionName) ; + ASSERT(strlen(_SessionName)>0) ; + BEGIN_OF( "RegistryService::end( void )" ) ; + exit( EXIT_SUCCESS ) ; +} + + +Registry::AllInfos* RegistryService::getall( void ) +{ + ASSERT(_SessionName) ; + ASSERT(strlen(_SessionName)>0) ; + return RegistryService::makeseq(_reg) ; +} + +Registry::AllInfos* RegistryService::history( void ) +{ + ASSERT(_SessionName) ; + ASSERT(strlen(_SessionName)>0) ; + return RegistryService::makeseq(_fin) ; +} + +Registry::AllInfos* RegistryService::makeseq(map &mymap ) +{ + int i=0 ; + + Registry::AllInfos *all = new Registry::AllInfos ; + ASSERT(all) ; + const int RegLength = mymap.size(); + all->length(RegLength); + + map::iterator im; + for (im=mymap.begin();im!=mymap.end(); im++) + { + + Registry::Infos &infos = (*all)[i] ; + const client_infos &lesInfos = *(*im).second ; + infos.name = CORBA::string_dup( lesInfos._name ) ; + infos.pid = lesInfos._pid ; + infos.pwname = lesInfos._pwname ; + infos.machine = CORBA::string_dup( lesInfos._machine ) ; + infos.adip = CORBA::string_dup( lesInfos._adip ) ; + infos.uid = lesInfos._uid ; + infos.tc_start = lesInfos._ts_start + lesInfos._difftime ; + infos.tc_hello = lesInfos._ts_hello + lesInfos._difftime ; + infos.tc_end = lesInfos._ts_end + lesInfos._difftime ; + infos.difftime = lesInfos._difftime ; + infos.cdir = CORBA::string_dup( lesInfos._cdir ) ; + infos.status = lesInfos._status ; + + i++; + } + + return all ; +} + + +/* ------------------------------*/ +/* Autres */ +/* ------------------------------*/ + +RegistryService::client_infos::client_infos( const Registry::Infos &infos ):\ + _ior(duplicate(infos.ior)),\ + _name(duplicate(infos.name)),\ + _pid(infos.pid),\ + _machine(duplicate(infos.machine)),\ + _adip(duplicate(infos.adip)),\ + _uid(infos.uid),\ + _pwname(duplicate(infos.pwname)),\ + _ts_start(time(NULL)),\ + _difftime(infos.tc_start - _ts_start),\ + _cdir(duplicate(infos.cdir)),\ + _ts_hello(_ts_start),\ + _ts_end(0),\ + _status(RUNNING) +{ + // SCRUTE(_ior) ; + ; +} + +RegistryService::client_infos::~client_infos() +{ + delete [] (char*)_ior ; (char*&)_ior = NULL ; + delete [] (char*)_name ; (char*&)_name = NULL ; + delete [] (char*)_machine ; (char*&)_machine = NULL ; + delete [] (char*)_pwname ; (char*&)_pwname = NULL ; + delete [] (char*)_adip ; (char*&)_adip = NULL ; + delete [] (char*)_cdir ; (char*&)_cdir = NULL ; +} + +void RegistryService::SessionName( const char *sessionName ) +{ + ASSERT(sessionName) ; + ASSERT(strlen(sessionName)>0) ; + _SessionName = duplicate(sessionName) ; + return ; +} +void RegistryService::ping() +{ + MESSAGE(" RegistryService::ping() pid "<< getpid()); +} diff --git a/src/Registry/RegistryService.hxx b/src/Registry/RegistryService.hxx new file mode 100644 index 000000000..d90fa4652 --- /dev/null +++ b/src/Registry/RegistryService.hxx @@ -0,0 +1,78 @@ +//============================================================================= +// File : RegistryService.hxx +// Created : Mon Nov 5 17:26:23 CET 2001 +// Author : Pascale NOYRET - Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +# ifndef __RegistryService_h__ +# define __RegistryService_h__ + +#include +#include CORBA_SERVER_HEADER(SALOME_Registry) + +# include + + +class RegistryService : public POA_Registry::Components //, public PortableServer::RefCountServantBase +{ + +public : + enum Status { UNDEF=-1 , TERMINATED=0 , RUNNING=1 } ; + + class client_infos + { + protected : + const char* const _ior; + const char* const _name; + const long _pid ; + const char* const _machine; + const char* const _adip; + const long _uid; + const char* const _pwname; + const long _ts_start ; + const long _difftime; + const char* const _cdir ; + long _ts_hello ; + long _ts_end ; + Status _status; + public : + friend class RegistryService ; + + client_infos( const Registry::Infos &infos ); + ~client_infos(); + }; + + + +public : + RegistryService(void); + virtual ~RegistryService(void); + + void ping(); + virtual CORBA::ULong add (const Registry::Infos & infos); + virtual CORBA::ULong size ( void ); + virtual void remove( const CORBA::ULong id ); + virtual void hello( const CORBA::ULong id ); + virtual void end(void); + + virtual Registry::AllInfos *getall(void); + virtual Registry::AllInfos *history(void); + + void SessionName( const char *sessionName ) ; + + +protected : + + const char *_SessionName ; + int _Compteur ; + map _reg ; + map _fin ; + + Registry::AllInfos* makeseq(map &mymap ); + +} ; + +# endif diff --git a/src/Registry/SALOME_Registry_Server.cxx b/src/Registry/SALOME_Registry_Server.cxx new file mode 100644 index 000000000..b917ec29f --- /dev/null +++ b/src/Registry/SALOME_Registry_Server.cxx @@ -0,0 +1,118 @@ +using namespace std; +//============================================================================= +// File : SALOME_Registry_Server.cxx +// Created : Mon Nov 5 17:26:23 CET 2001 +// Author : Pascale NOYRET - Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +# include +# include +# include + +extern "C" +{ +# include +} + +# include "utilities.h" +# include "Utils_ORB_INIT.hxx" +# include "Utils_SINGLETON.hxx" +# include "Utils_SALOME_Exception.hxx" +# include "Utils_CommException.hxx" +# include "ServiceUnreachable.hxx" +# include "SALOME_NamingService.hxx" +# include "RegistryService.hxx" + +int main( int argc , char **argv ) +{ + BEGIN_OF( argv[0] ) + INFOS_COMPILATION + SCRUTE(argc) + if( argc<3 ) + { + MESSAGE("you must provide the Salome session name when you call SALOME_Registry_Server") ; + throw CommException("you must provide the Salome session name when you call SALOME_Registry_Server") ; + } + const char *ptrSessionName=0 ; + + int k=0 ; + for ( k=1 ; k0) ; + const char *registryName = "Registry" ; + + + try + { + ORB_INIT &init = *SINGLETON_::Instance() ; + CORBA::ORB_var &orb = init( argc , argv ) ; + + + SALOME_NamingService &naming = *SINGLETON_::Instance() ; + naming.init_orb( orb ) ; + + RegistryService *ptrRegistry = SINGLETON_::Instance() ; + ptrRegistry->SessionName( ptrSessionName ) ; + Registry::Components_var varComponents = ptrRegistry->_this() ; + + // The RegistryService must not already exist. + + try + { + CORBA::Object_var pipo = naming.Resolve( registryName ) ; + if (CORBA::is_nil(pipo) ) throw ServiceUnreachable() ; + MESSAGE("RegistryService servant already existing" ) ; + exit( EXIT_FAILURE ) ; + } + catch( const ServiceUnreachable &ex ) + { + } + catch( const CORBA::Exception &exx ) + { + } + string absoluteName = string("/") + registryName; + naming.Register( varComponents , absoluteName.c_str() ) ; + + + CORBA::Object_var poaObj = orb->resolve_initial_references( "RootPOA" ) ; + PortableServer::POA_var poa = PortableServer::POA::_narrow(poaObj) ; + PortableServer::POAManager_var manager = poa->the_POAManager() ; + + + MESSAGE("On attend les requetes des clients") ; + try + { + // Activation du POA + MESSAGE("Activation du POA") ; + manager->activate() ; + + // Lancement de l'ORB + MESSAGE("Lancement de l'ORB") ; + orb->run() ; + } + catch( const CORBA::Exception &ex ) + { + MESSAGE("Erreur systeme") ; + return EXIT_FAILURE ; + } + + } + catch( const SALOME_Exception &ex ) + { + MESSAGE( "Communication Error : " << ex.what() ) + return EXIT_FAILURE ; + } + + END_OF( argv[0] ) ; + return 0 ; +} diff --git a/src/RegistryDisplay/HelpWindow.cxx b/src/RegistryDisplay/HelpWindow.cxx new file mode 100644 index 000000000..200d62241 --- /dev/null +++ b/src/RegistryDisplay/HelpWindow.cxx @@ -0,0 +1,81 @@ +using namespace std; +//============================================================================= +// File : HelpWindow.cxx +// Created : Thu Dec 20 17:28:49 CET 2001 +// Author : Pascale NOYRET, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= +# include "HelpWindow.hxx" +# include "utilities.h" + +# include +# include +# include +# include + +HelpWindow::HelpWindow(QWidget* parent, const char* name ) + : QMainWindow( parent, name, WType_TopLevel | WDestructiveClose ) +{ + BEGIN_OF("Constructeur HelpWindow"); + + setCaption( tr( "Help" ) ); + + myTextView = new QTextView( this, "myTextView" ); + QPalette pal = myTextView->palette(); + QColorGroup cg = pal.active(); + cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); + cg.setColor( QColorGroup::HighlightedText, Qt::white ); + cg.setColor( QColorGroup::Base, QColor( 255,255,220 ) ); + cg.setColor( QColorGroup::Text, Qt::black ); + pal.setActive ( cg ); + cg = pal.inactive(); + cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); + cg.setColor( QColorGroup::HighlightedText, Qt::white ); + cg.setColor( QColorGroup::Base, QColor( 255,255,220 ) ); + cg.setColor( QColorGroup::Text, Qt::black ); + pal.setInactive( cg ); + cg = pal.disabled(); + cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); + cg.setColor( QColorGroup::HighlightedText, Qt::white ); + cg.setColor( QColorGroup::Base, QColor( 255,255,220 ) ); + cg.setColor( QColorGroup::Text, Qt::black ); + pal.setDisabled( cg ); + myTextView->setPalette( pal ); + + setCentralWidget( myTextView ); + setMinimumSize( 450, 250 ); + + QFile f ( "tmp.txt" ); + if ( f.open( IO_ReadOnly ) ) + { + QTextStream t( &f ); + while ( !t.eof() ) + { + myTextView->append(t.readLine()); + } + } + f.close(); + + END_OF("Constructeur HelpWindow"); +} + +/*! + Destructor +*/ +HelpWindow::~HelpWindow() +{ + BEGIN_OF("Destructeur HelpWindow"); + END_OF("Destructeur HelpWindow"); +}; + +/*! + Sets text +*/ +void HelpWindow::setText( const QString& text ) +{ + myTextView->setText( text ); +} + + diff --git a/src/RegistryDisplay/HelpWindow.hxx b/src/RegistryDisplay/HelpWindow.hxx new file mode 100644 index 000000000..3656385a2 --- /dev/null +++ b/src/RegistryDisplay/HelpWindow.hxx @@ -0,0 +1,31 @@ +//============================================================================= +// File : HelpWindow.hxx +// Created : Thu Dec 20 17:28:41 CET 2001 +// Author : Pascale NOYRET, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= +# ifndef __HELPWINDOW_H__ +# define __HELPWINDOW_H__ + +# include +# include + +class QTextView; + +class HelpWindow : public QMainWindow +{ +public: + HelpWindow( QWidget* parent = 0, const char* name = 0); + ~HelpWindow(); + + void setText( const QString& text ); + QTextView* textView() const { return myTextView; } + +private: + QTextView* myTextView; +}; +# endif /* __HELPWINDOW_H__ */ + + diff --git a/src/RegistryDisplay/IntervalWindow.cxx b/src/RegistryDisplay/IntervalWindow.cxx new file mode 100644 index 000000000..14a0255a6 --- /dev/null +++ b/src/RegistryDisplay/IntervalWindow.cxx @@ -0,0 +1,103 @@ +// File: IntervalWindow.cxx +// Created: Thu Apr 3 10:55:19 2003 +// Author: Oksana TCHEBANOVA +// + + +#include + +#include +#include +#include +#include +# include "utilities.h" + +#define MARGIN_SIZE 11 +#define SPACING_SIZE 6 +#define MIN_SPIN_WIDTH 100 + +IntervalWindow::IntervalWindow ( QWidget* parent ) + : QDialog( parent, "IntervalWindow" , true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + BEGIN_OF("IntervalWindow constructor") + setCaption( tr( "Refresh Interval" ) ); + setSizeGripEnabled( true ); + + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setSpacing( SPACING_SIZE ); + topLayout->setMargin( MARGIN_SIZE ); + + QGroupBox* intervalGrp = new QGroupBox( this, "intervalGrp" ); + intervalGrp->setColumnLayout( 0, Qt::Horizontal );//Vertical + intervalGrp->layout()->setSpacing( 0 ); + intervalGrp->layout()->setMargin( 0 ); + QGridLayout* intervalGrpLayout = new QGridLayout( intervalGrp->layout() ); + intervalGrpLayout->setAlignment( Qt::AlignTop ); + intervalGrpLayout->setSpacing( SPACING_SIZE ); + intervalGrpLayout->setMargin( MARGIN_SIZE ); + + QHBoxLayout* aBtnLayout = new QHBoxLayout; + aBtnLayout->setSpacing( SPACING_SIZE ); + aBtnLayout->setMargin( 0 ); + + myButtonOk = new QPushButton( this, "buttonOk" ); + myButtonOk->setText( tr( "BUT_OK" ) ); + myButtonOk->setAutoDefault( TRUE ); + myButtonOk->setDefault( TRUE ); + + myButtonCancel = new QPushButton( this, "buttonCancel" ); + myButtonCancel->setText( tr( "BUT_CANCEL" ) ); + myButtonCancel->setAutoDefault( TRUE ); + + QLabel* TextLabel = new QLabel( intervalGrp, "TextLabel" ); + TextLabel->setText( tr( "Please, enter a number of seconds:" ) ); + + mySpinBox = new QSpinBox( 1, 999999999, 1, intervalGrp, "SpinBox" ); + mySpinBox->setValue( 100 ); + mySpinBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + mySpinBox->setMinimumWidth(MIN_SPIN_WIDTH); + + intervalGrpLayout->addWidget(TextLabel, 0, 0); + intervalGrpLayout->addWidget(mySpinBox, 0, 1); + + aBtnLayout->addWidget( myButtonOk ); + aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + aBtnLayout->addWidget( myButtonCancel ); + + topLayout->addWidget( intervalGrp, 0, 0 ); + topLayout->addLayout( aBtnLayout, 1, 0 ); + + END_OF("IntervalWindow constructor") +} +IntervalWindow::~IntervalWindow() {} +/* + Sets start interval size +*/ +void IntervalWindow::setValue(const int size) +{ + mySpinBox->setValue(size); +} + +/* + Gets interval size +*/ +int IntervalWindow::getValue() +{ + return mySpinBox->value(); +} + +/* + gets a pointer to myButtonOk +*/ +QPushButton* IntervalWindow::Ok() +{ + return myButtonOk; +} + +/* + gets a pointer to myButtonCancel +*/ +QPushButton* IntervalWindow::Cancel() +{ + return myButtonCancel; +} diff --git a/src/RegistryDisplay/IntervalWindow.hxx b/src/RegistryDisplay/IntervalWindow.hxx new file mode 100644 index 000000000..63384403c --- /dev/null +++ b/src/RegistryDisplay/IntervalWindow.hxx @@ -0,0 +1,35 @@ +// File: IntervalWindow.hxx +// Created: Thu Apr 3 10:31:10 2003 +// Author: Oksana TCHEBANOVA +// + + +#ifndef IntervalWindow_HeaderFile +#define IntervalWindow_HeaderFile + +# include +# include +# include +# include + +using namespace std; + +class IntervalWindow : public QDialog +{ +public: + IntervalWindow( QWidget* parent = 0 ); + ~IntervalWindow(); + + QPushButton* Ok(); + QPushButton* Cancel(); + + int getValue(); + void setValue( int ); + +private: + QSpinBox* mySpinBox; + QPushButton* myButtonOk; + QPushButton* myButtonCancel; +}; + +#endif diff --git a/src/RegistryDisplay/Makefile.in b/src/RegistryDisplay/Makefile.in new file mode 100644 index 000000000..13d2baaf5 --- /dev/null +++ b/src/RegistryDisplay/Makefile.in @@ -0,0 +1,40 @@ +#============================================================================== +# File : Makefile.in +# Created : ven déc 7 15:16:49 CET 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + +@COMMENCE@ + +EXPORT_PYSCRIPTS = + +EXPORT_HEADERS = + +# Libraries targets + +LIB = libRegistryDisplay.la + +LIB_SRC = HelpWindow.cxx \ + RegWidget.cxx \ + RegWidgetFactory.cxx \ + RegWidget_moc.cxx \ + IntervalWindow.cxx + +LIB_CLIENT_IDL = SALOME_Registry.idl + +CPPFLAGS+=$(QT_INCLUDES) +LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lOpUtil + +%_moc.cxx: %.hxx + $(MOC) $< -o $@ + +@CONCLUDE@ diff --git a/src/RegistryDisplay/RegWidget.cxx b/src/RegistryDisplay/RegWidget.cxx new file mode 100644 index 000000000..fd1371b29 --- /dev/null +++ b/src/RegistryDisplay/RegWidget.cxx @@ -0,0 +1,558 @@ +using namespace std; +//============================================================================= +// File : RegWidget.cxx +// Created : Mon Nov 5 17:26:23 CET 2001 +// Author : Pascale NOYRET, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + + +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +# include "SALOME_NamingService.hxx" +# include "ServiceUnreachable.hxx" +# include "Utils_SINGLETON.hxx" +# include "Utils_CommException.hxx" + +# include "utilities.h" +# include "OpUtil.hxx" + +# include "RegWidget.hxx" +# include "HelpWindow.hxx" +# include "IntervalWindow.hxx" + +typedef int PIXELS; +RegWidget* RegWidget::myRegWidgetPtr = 0; + +#define BOLD( text ) ( QString( "" ) + QString( text ) + QString( "" ) ) +/*! + Creates components list +*/ +Registry::Components_var MakeRegistry( CORBA::ORB_var &orb ) +{ + + const char *registryName="Registry" ; + + SALOME_NamingService &naming = *SINGLETON_::Instance() ; + naming.init_orb( orb ) ; + + // Recuperation de la reference de l'objet + CORBA::Object_var object = 0 ; + try + { + SCRUTE(registryName) ; + object = naming.Resolve( registryName ) ; + if(CORBA::is_nil(object)) throw CommException( "unable to find the RegistryService" ) ; + } + catch( const ServiceUnreachable &ex ) + { + MESSAGE( ex.what() ) + exit( EXIT_FAILURE ) ; + } + catch( const CORBA::Exception &exx ) + { + exit( EXIT_FAILURE ) ; + } + + // Specialisation de l'objet generique + + return Registry::Components::_narrow( object ) ; +} + +/*! + Only one global registry window should exist at the moment + This method creates registry window if necessary and returns it + [ static ] +*/ +RegWidget* RegWidget::GetRegWidget( CORBA::ORB_var &orb , QWidget *parent, const char *name ) +{ + if ( !myRegWidgetPtr ) + myRegWidgetPtr = new RegWidget( orb, parent, name ); + return myRegWidgetPtr; +} + +/*! + Constructor +*/ +RegWidget::RegWidget(CORBA::ORB_var &orb, QWidget *parent, const char *name ) + : QMainWindow( parent, name, WType_TopLevel | WDestructiveClose ), + _VarComponents( MakeRegistry(orb) ), + _clients(0), _history(0), _parent( parent ), + _tabWidget(0), _refresh(0), _interval(0), + myInfoWindow(0), myHelpWindow(0), myIntervalWindow(0) +{ + char* dir = getenv( "CSF_ResourcesDefaults" ); + QString path( "" ); + if ( dir ) { + QDir qDir( dir ); + path = qDir.filePath( "default.png" ); + } + QPixmap pm ( path ); + if ( !pm.isNull() ) + setIcon( pm ); + + // Buttons definition + QToolBar* topbar = new QToolBar( tr("Toolbar"), this ); + setDockEnabled( topbar, DockTornOff, false ); + setDockMenuEnabled( false ); + + _refresh = new QPushButton( tr( "Refresh" ), topbar ); + connect( _refresh, SIGNAL( clicked() ), this, SLOT( slotListeSelect() ) ); + QToolTip::add( _refresh, "", toolTipGroup(), tr("Immediately updates list of components") ); + + 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() ) ); + QToolTip::add( _interval, "", toolTipGroup(), tr("Changes refresh interval") ); + + // Display area and associated slots definition + _tabWidget = new QTabWidget( this ); + _clients = new QListView( _tabWidget ); + SetListe(); + _history = new QListView( _tabWidget ); + SetListeHistory(); + + _tabWidget->addTab( _clients, tr( "Running" ) ); + _tabWidget->addTab( _history, tr( "History" ) ); + connect( _tabWidget, SIGNAL( currentChanged( QWidget* )), this, SLOT( slotListeSelect() ) ); + connect( _clients, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( slotClientChanged( QListViewItem* ) ) ); + connect( _history, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( slotHistoryChanged( QListViewItem* ) ) ); + setCentralWidget( _tabWidget ); + + // Timer definition (used to automaticaly refresh the display area) + _counter = new QTimer( this ); + connect( _counter, SIGNAL( timeout() ), this, SLOT( slotListeSelect() ) ); + myRefreshInterval = 10; + _counter->start( myRefreshInterval * 1000 ); + + PIXELS xpos = 160 ; + PIXELS ypos = 100 ; + PIXELS largeur = 800 ; + PIXELS hauteur = 350 ; + setGeometry( xpos, ypos, largeur, hauteur ) ; + setCaption( name ) ; + statusBar()->message(" "); +} + +/*! + Destructor +*/ +RegWidget::~RegWidget() +{ + MESSAGE("Debut du Destructeur"); + _counter->stop(); + myRegWidgetPtr = 0; +}; + +/*! + Event filter +*/ +bool RegWidget::eventFilter( QObject* object, QEvent* event ) +{ + if ( object ) { + if ( object == myHelpWindow && event->type() == QEvent::Close ) { + myHelpWindow = 0; + } + else if ( object == myInfoWindow && event->type() == QEvent::Close ) { + myInfoWindow = 0; + } + else if ( object == myIntervalWindow && event->type() == QEvent::Close ) { + myIntervalWindow = 0; + } + } + return QMainWindow::eventFilter( object, event ); +} + +/*! + Searches item in the list and returns it's index or -1 if not found +*/ +int RegWidget::numitem(const QString &name, const QString &pid, const QString &machine,const Registry::AllInfos *listclient) +{ + BEGIN_OF("numitem"); + for (CORBA::ULong i=0; ilength(); i++) + { + const Registry::Infos & c_info=(*listclient)[i]; + ASSERT( c_info.name!=NULL); + QString b; + b.setNum(int(c_info.pid)); + if ( (name.compare(QString(c_info.name)) == 0) && + (machine.compare(QString(c_info.machine)) == 0) && + (pid.compare(b) == 0) ) + { + END_OF("numitem"); + return i; + } + } + END_OF("numitem"); + return -1; +} + +/*! + Returns text, containing information about client [ static ] +*/ +QString RegWidget::setlongText( const Registry::Infos &c_info) +{ + BEGIN_OF("setlongText"); + ASSERT( c_info.name != NULL ); + QString a = QString( "

" ) + tr( "Code" ) + QString( " : " ); + a.append( QString( c_info.name ) ); + a.append( "



" ); + a.append( tr( "Process Id" ) + QString( " : " ) ); + a.append( BOLD( QString::number( int( c_info.pid ) ) ) ); + a.append( QString( " " ) + tr( "on machine" ) + QString( " " ) ); + a.append( BOLD( c_info.machine ) ); + a.append( QString( " " ) + tr( "ip address" ) + QString( " : " ) ); + a.append( BOLD( c_info.adip ) ); + a.append( "
" ); + + a.append( tr( "launched by user" ) + QString( " " ) ); + a.append( BOLD( c_info.pwname ) ); + a.append( QString( " ( " ) + tr( "pid" ) + QString( " : " ) ); + a.append( BOLD( QString::number( int( c_info.uid ) ) ) ); + a.append( QString( " )
" ) + tr( "in directory" ) + QString( " " )); + a.append( BOLD( c_info.cdir ) ); + + a.append( QString( "
" ) + tr( "begins" ) + QString( " " ) ); + char * t1 = (char * )duplicate(ctime(&c_info.tc_start)); + t1 [strlen(t1) -1 ] = ' '; + a.append( BOLD( t1 ) ); + delete [] t1; + a.append( "
" ); + + if (c_info.tc_hello != 0 ) + { + char * t2 = (char * )duplicate(ctime(&c_info.tc_hello)); + t2 [strlen(t2) -1 ] = ' '; + a.append( tr( "last signal" ) + QString(" : ") ); + a.append( BOLD( t2 ) ); + a.append( "
" ); + delete [] t2; + } + if ((c_info.tc_end - c_info.difftime) != 0) + { + char * t3 = (char * )duplicate(ctime(&c_info.tc_end)); + t3 [strlen(t3) -1 ] = ' '; + a.append( tr( "ends" ) + QString( " " ) ); + a.append( BOLD( t3 ) ); + a.append( "
" ); + delete [] t3; + } + else + { + a.append( tr( "still running" ) + QString( "
" ) ); + } + + SCRUTE(c_info.difftime); + if (c_info.difftime!= 0) + { + a.append( QString( "(" ) + tr( "Time on" ) + QString( " " ) ); + a.append( BOLD( c_info.machine ) ); + a.append( QString( " " ) + tr( "differs from server's time. The difference is" ) + QString( " " )); + a.append( BOLD( QString::number( int( c_info.difftime ) ) ) ); + a.append( QString( " " ) + tr( "seconds" ) + QString( ")
" ) ); + } + END_OF("setlongText"); + return a; + +} + +/*! + Close event +*/ +void RegWidget::closeEvent( QCloseEvent *e) +{ + BEGIN_OF("closeEvent"); + if ( myInfoWindow ) + myInfoWindow->close(); + if ( myHelpWindow ) + myHelpWindow->close(); + if (myIntervalWindow) + myIntervalWindow->close(); + e->accept(); + END_OF("closeEvent"); +}; + +/*! + Setups Clients list +*/ +void RegWidget::SetListe() +{ + BEGIN_OF("SetListe"); + _clients->addColumn( tr( "Component" ), -1); + _clients->addColumn( tr( "PID" ), -1 ); + _clients->addColumn( tr( "User Name" ), -1 ); + _clients->addColumn( tr( "Machine" ), -1 ); + _clients->addColumn( tr( "begins" ), -1 ); + _clients->addColumn( tr( "hello" ) , -1 ); + _clients->setColumnAlignment( 1, Qt::AlignRight ); + END_OF("SetListe"); +} + +/*! + Setups History list +*/ +void RegWidget::SetListeHistory() +{ + BEGIN_OF("SetListeHistory") + _history->addColumn( tr( "Component" ), -1); + _history->addColumn( tr( "PID" ), -1 ); + _history->addColumn( tr( "User Name" ), -1 ); + _history->addColumn( tr( "Machine" ), -1 ); + _history->addColumn( tr( "begins" ), -1 ); + _history->addColumn( tr( "ends" ), -1 ); + _history->setColumnAlignment( 1, Qt::AlignRight ); + END_OF("SetListeHistory") +} + +/*! + Updates History list +*/ +void RegWidget::InfoHistory() +{ + + BEGIN_OF("InfoHistory") + _history->clear(); + try + { + _serverhistory = _VarComponents->history(); + for (CORBA::ULong i=0; i<_serverhistory->length(); i++) + { + const Registry::Infos & c_info=(*_serverhistory)[i]; + ASSERT( c_info.name!=NULL); + QString a; + a.setNum(int(c_info.pid)); + char * t1 = (char * )duplicate(ctime(&c_info.tc_start)); + t1 [strlen(t1) -1 ] = ' '; + char * t2 = (char * )duplicate(ctime(&c_info.tc_end)); + t2 [strlen(t2) -1 ] = ' '; + QListViewItem * item = new QListViewItem(_history, QString(c_info.name),\ + a, QString(c_info.pwname), QString(c_info.machine), \ + QString(t1), QString(t2)); + item=0 ; + delete [] t1; + delete [] t2; + + } + } + catch( ... ) + { + _interval->setDisabled( TRUE ) ; + _refresh->setDisabled( TRUE ) ; + _counter->stop(); + MESSAGE("Sorry, No more Registry Server") ; + statusBar()->message( tr( "Sorry, No more Registry Server" ) ) ; + } + END_OF("InfoHistory") +} + +/*! + Updates clients list +*/ +void RegWidget::InfoReg() +{ + BEGIN_OF("InfoReg") + _clients->clear(); + try + { + _serverclients = _VarComponents->getall(); + for (CORBA::ULong i=0; i<_serverclients->length(); i++) + { + const Registry::Infos & c_info=(*_serverclients)[i]; + ASSERT( c_info.name!=NULL); + QString a; + a.setNum(int(c_info.pid)); + char * t1 = (char * )duplicate(ctime(&c_info.tc_start)); + t1 [strlen(t1) -1 ] = ' '; + char * t2 = (char * )duplicate(ctime(&c_info.tc_hello)); + t2 [strlen(t2) -1 ] = ' '; + QListViewItem * item = new QListViewItem(_clients, QString(c_info.name),\ + a, QString(c_info.pwname), QString(c_info.machine), \ + QString(t1), QString(t2)); + item=0 ; + delete [] t1; + delete [] t2; + + } + } + catch( ... ) + { + _interval->setDisabled( TRUE ) ; + _refresh->setDisabled( TRUE ) ; + _counter->stop(); + MESSAGE("Sorry, No more Registry Server") ; + statusBar()->message( tr( "Sorry, No more Registry Server" ) ) ; + } + END_OF("InfoReg") +} + +/*! + Called when button is clicked +*/ +void RegWidget::slotListeSelect() +{ + try + { + ASSERT(_tabWidget->currentPage() != NULL); + if (_tabWidget->currentPage () == _clients) InfoReg(); + else if (_tabWidget->currentPage () == _history) InfoHistory(); + } + catch( ... ) + { + MESSAGE("Sorry, No more Registry Server") ; + statusBar()->message( tr( "Sorry, No more Registry Server" ) ) ; + } +} + +/*! + Called when button is clicked (changing refresh interval) +*/ +void RegWidget::slotSelectRefresh() +{ + BEGIN_OF("slotSelectRefresh"); + myIntervalWindow = new IntervalWindow(this); + myIntervalWindow->installEventFilter( this ); + myIntervalWindow->setValue(myRefreshInterval); + myIntervalWindow->show(); + connect( myIntervalWindow->Cancel(), SIGNAL( clicked() ), myIntervalWindow, SLOT( reject() ) ); + connect( myIntervalWindow->Ok(), SIGNAL( clicked() ), this, SLOT( slotIntervalOk() ) ); + END_OF("slotSelectRefresh"); +} + +void RegWidget::slotIntervalOk() +{ + BEGIN_OF("slotIntervalOk"); + myRefreshInterval = myIntervalWindow->getValue(); + _counter->changeInterval( myRefreshInterval * 1000 ); + SCRUTE(myRefreshInterval); + myIntervalWindow->close(); + END_OF("slotIntervalOk"); +} +/*! + Called when button is clicked +*/ +void RegWidget::slotHelp() +{ + BEGIN_OF("slotHelp()"); + + if ( !myHelpWindow ) { + myHelpWindow = new HelpWindow( this ); + myHelpWindow->installEventFilter( this ); + } + myHelpWindow->show(); + myHelpWindow->raise(); + myHelpWindow->setActiveWindow(); + + END_OF("slotHelp()") ; +} + +/*! + Called when user clicks on item in list +*/ +void RegWidget::slotClientChanged( QListViewItem* item ) +{ + BEGIN_OF("slotClientChanged()") ; + + if ( item <= 0) + return; + + blockSignals( true ); // for sure that item will not be deleted when refreshing + + int numeroItem = numitem(item->text(0), item->text(1), item->text(3), _serverclients); + SCRUTE(numeroItem) ; + SCRUTE(item->text(1)) ; + + ASSERT(numeroItem>=0) ; + ASSERT((size_t)numeroItem<_serverclients->length()) ; + const Registry::Infos & c_info=(*_serverclients)[numeroItem]; + ASSERT( c_info.name!=NULL); + + if ( !myInfoWindow ) { + myInfoWindow = new InfoWindow( this ); + myInfoWindow->installEventFilter( this ); + } + QString a = tr( "More about" ) + QString( " " ) + QString( c_info.name ); + myInfoWindow->setCaption(a); + myInfoWindow->setText( RegWidget::setlongText( c_info) ); + myInfoWindow->show(); + myInfoWindow->raise(); + myInfoWindow->setActiveWindow(); + + blockSignals( false ); // enabling signals again + + END_OF("slotClientChanged()") ; + return ; +} + +/*! + Called when user clicks on item in list +*/ +void RegWidget::slotHistoryChanged( QListViewItem* item ) +{ + + BEGIN_OF("slotHistoryChanged()") ; + + if ( item <= 0) + return; + + blockSignals( true ); // for sure that item will not be deleted when refreshing + + int numeroItem = numitem(item->text(0), item->text(1), item->text(3), _serverhistory); + + SCRUTE(numeroItem) ; + SCRUTE(item->text(1)) ; + ASSERT(numeroItem>=0) ; + ASSERT((size_t)numeroItem<_serverhistory->length()) ; + const Registry::Infos & c_info=(*_serverhistory)[numeroItem]; + ASSERT( c_info.name!=NULL); + + if ( !myInfoWindow ) { + myInfoWindow = new InfoWindow( this ); + myInfoWindow->installEventFilter( this ); + } + QString a = tr( "More about" ) + QString( " " ) + QString( c_info.name ); + myInfoWindow->setCaption(a); + myInfoWindow->setText( RegWidget::setlongText( c_info ) ); + myInfoWindow->show(); + myInfoWindow->raise(); + myInfoWindow->setActiveWindow(); + + blockSignals( false ); // enabling signals again + + END_OF("slotHistoryChanged()") ; + return ; +} + +/*! + Constructor +*/ +InfoWindow::InfoWindow( QWidget* parent, const char* name ) + : QMainWindow( parent, name, WType_TopLevel | WDestructiveClose ) +{ + BEGIN_OF("InfoWindow"); + myTextView = new QTextView( this, "myTextView" ); + setCentralWidget( myTextView ); + setMinimumSize( 450, 250 ); + END_OF("InfoWindow"); +} + +/*! + Sets text +*/ +void InfoWindow::setText( const QString& text ) +{ + myTextView->setText( text ); +} diff --git a/src/RegistryDisplay/RegWidget.hxx b/src/RegistryDisplay/RegWidget.hxx new file mode 100644 index 000000000..a1149f8c4 --- /dev/null +++ b/src/RegistryDisplay/RegWidget.hxx @@ -0,0 +1,103 @@ +//============================================================================= +// File : RegWidget.hxx +// Created : Mon Nov 5 17:26:23 CET 2001 +// Author : Pascale NOYRET, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +# ifndef __REGWIDGET_H__ +# define __REGWIDGET_H__ +# include +# include + +#include +#include CORBA_CLIENT_HEADER(SALOME_Registry) + +#include + +class QTabWidget; +class QListView; +class QListViewItem; +class QWidget; +class QTimer; +class QCloseEvent; +class QTextView; +#if QT_VERSION > 300 +class QPushButton; +#endif +class HelpWindow; +class InfoWindow; + +class RegWidget : public QMainWindow +{ + + Q_OBJECT + +public: + RegWidget( CORBA::ORB_var &orb , QWidget *parent = 0, const char *name = 0 ); + ~RegWidget(); + void SetListe(); + void SetListeHistory(); + void InfoReg(); + void InfoHistory(); + + bool eventFilter( QObject* object, QEvent* event ); + + static RegWidget* GetRegWidget( CORBA::ORB_var &orb , QWidget *parent = 0, const char *name = 0 ); + +public slots: + void slotHelp(); + void slotListeSelect(); + void slotClientChanged( QListViewItem* ); + void slotHistoryChanged( QListViewItem* ); + void slotSelectRefresh(); + void slotIntervalOk(); +protected: + static QString setlongText( const Registry::Infos &c_info ); + int numitem( const QString& name, const QString& pid, const QString& machine, const Registry::AllInfos* c_info ); + void closeEvent( QCloseEvent *e); + +protected : + QListView* _clients; + QListView* _history; + QWidget* _parent; + QTabWidget* _tabWidget; + QPushButton* _refresh; + QPushButton* _interval; + QTimer* _counter; + Registry::AllInfos* _serverhistory; + Registry::AllInfos* _serverclients; + InfoWindow* myInfoWindow; + HelpWindow* myHelpWindow; + IntervalWindow* myIntervalWindow; + int myRefreshInterval; + +private: + const Registry::Components_var _VarComponents; + static RegWidget* myRegWidgetPtr; +}; + +class InfoWindow : public QMainWindow { +public: + InfoWindow( QWidget* parent = 0, const char* name = 0); + + void setText( const QString& text ); + QTextView* textView() const { return myTextView; } + +private: + QTextView* myTextView; + +}; + +# endif /* # ifndef __REGWIDGET_H__ */ + + + + + + + + + diff --git a/src/RegistryDisplay/RegWidgetFactory.cxx b/src/RegistryDisplay/RegWidgetFactory.cxx new file mode 100644 index 000000000..0c92d2dcb --- /dev/null +++ b/src/RegistryDisplay/RegWidgetFactory.cxx @@ -0,0 +1,28 @@ +using namespace std; +//============================================================================= +// File : RegWidgetFactory.cxx +// Created : Tue Nov 13 17:16:01 CET 2001 +// Author : Pascale NOYRET, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +# include "RegWidget.hxx" +# include "utilities.h" + +extern "C" +{ + +void OnGUIEvent( CORBA::ORB_var &orb, QWidget *parent, const char *name ) +{ + // N.B. parent can be 0 + RegWidget* ptrRegWidget = RegWidget::GetRegWidget( orb, parent, name ); + ASSERT ( !ptrRegWidget ); + ptrRegWidget->show(); + ptrRegWidget->raise(); + ptrRegWidget->setActiveWindow(); + return; +} + +} diff --git a/src/RessourcesCatalog/Makefile.in b/src/RessourcesCatalog/Makefile.in new file mode 100644 index 000000000..b6193a6f2 --- /dev/null +++ b/src/RessourcesCatalog/Makefile.in @@ -0,0 +1,43 @@ +#============================================================================== +# File : Makefile.in +# Created : mer jui 11 06:50:44 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_HEADERS = \ + SALOME_RessourcesCatalog_impl.hxx \ + SALOME_RessourcesCatalog_Parser.hxx \ + SALOME_RessourcesCatalog_Handler.hxx + +# Libraries targets +LIB = libSalomeRessourcesCatalog.la +LIB_SRC = \ + SALOME_RessourcesCatalog_Handler.cxx \ + SALOME_RessourcesCatalog_impl.cxx + +# Executables targets +# trouble we have client and serveur and build don't known about this with rule +# in fact client is a test ! So it may go away BIN ! +BIN = SALOME_RessourcesCatalog_Server SALOME_RessourcesCatalog_Client +BIN_SRC = +BIN_SERVER_IDL = SALOME_RessourcesCatalog.idl + +CPPFLAGS+= $(QT_MT_INCLUDES) +CXXFLAGS+= +LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSalomeLoggerServer + +@CONCLUDE@ + + diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Client.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Client.cxx new file mode 100644 index 000000000..1d3ce6129 --- /dev/null +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Client.cxx @@ -0,0 +1,86 @@ +using namespace std; +/* $Header$ */ + +#include +#include "SALOME_NamingService.hxx" +#include +#include CORBA_SERVER_HEADER(SALOME_RessourcesCatalog) +#include +#include "utilities.h" + +int main(int argc,char **argv) +{ + CORBA::ORB_var orb; + CosNaming::NamingContext_var _rootContext; + CORBA::Object_var objVar, objVarN; + try { + + // initialize the ORB + + orb = CORBA::ORB_init (argc, argv); + + + // Get CORBA reference of the catalog + SALOME_NamingService NS(orb); + CORBA::Object_var objVarN = NS.Resolve("/Kernel/RessourcesCatalog"); + + SALOME_RessourcesCatalog::RessourcesCatalog_var Catalogue = SALOME_RessourcesCatalog::RessourcesCatalog::_narrow(objVarN); + MESSAGE("Ressources distant catalog found"); + + //Get Computer list information + SALOME_RessourcesCatalog::ListOfComputer_var _list = Catalogue->GetComputerList(); + for (unsigned int ind = 0; ind < _list->length();ind++) + { + MESSAGE("Ressources list : " << _list[ind]); + } + + //Get container type list of computer eri + SALOME_RessourcesCatalog::ListOfContainerType_var list = Catalogue->GetContainerTypeList("eri"); + for (unsigned int ind = 0; ind < list->length();ind++) + { + MESSAGE("Container type list of eri : " << list[ind]); + } + + // Get processors information of eri + SALOME_RessourcesCatalog::computer_info_var computer = Catalogue->GetComputerInfo("eri"); + MESSAGE("Ressource name : " << computer->name); + MESSAGE("Ressource OS : " << computer->OS); + MESSAGE("Ressource OS version : " << computer->OS_version); + for (unsigned int ind = 0; ind < computer->procs.length();ind++) + { + MESSAGE("Processor number : " << computer->procs[ind].number); + MESSAGE("Processor model name : " << computer->procs[ind].model_name); + MESSAGE("Processor cpu : " << computer->procs[ind].cpu_mhz); + MESSAGE("Processor cache : " << computer->procs[ind].cache_size); + } + + } + catch(SALOME_RessourcesCatalog::NotFound &){ + INFOS("SALOME_RessourcesCatalog::NotFound"); + } + catch(CORBA::SystemException&) { + INFOS("Caught CORBA::SystemException.") + } + catch (CosNaming::NamingContext::CannotProceed &) { + INFOS("CosNaming::NamingContext::CannotProceed") + } + catch (CosNaming::NamingContext::NotFound &) { + INFOS("CosNaming::NamingContext::NotFound") + } + catch (CosNaming::NamingContext::InvalidName &) { + INFOS("CosNaming::NamingContext::InvalidName") + } + catch (CosNaming::NamingContext::AlreadyBound &) { + INFOS("CosNaming::NamingContext::AlreadyBound") + } + catch (CosNaming::NamingContext::NotEmpty &) { + INFOS("CosNaming::NamingContext::NotEmpty") + } + + catch(CORBA::Exception &sysEx) { + INFOS("Caught CORBA::Exception.") + } + + + return 0; +} diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.cxx new file mode 100755 index 000000000..0a0937af0 --- /dev/null +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.cxx @@ -0,0 +1,239 @@ +using namespace std; +//File SALOME_RessourcesCatalog_Handler.cxx +//Created: Fri Sept 07 2001 +//Author: Estelle Deville +//Project: SALOME +//Copyright: CEA/DEN/DM2S/LGLS +//$Header$ + +#define WRITE_RESSOURCES_TYPE +#include "SALOME_RessourcesCatalog_Handler.hxx" + +//---------------------------------------------------------------------- +//Function : SALOME_RessourcesCatalog_Handler +//Purpose: Constructor +//---------------------------------------------------------------------- +SALOME_RessourcesCatalog_Handler::SALOME_RessourcesCatalog_Handler() +{ + MESSAGE("SALOME_RessourcesCatalog_Handler creation"); + //XML tags initialisation + test_computer = "computer"; + test_computer_name="name"; + test_computer_OS="OS"; + test_computer_OS_version = "OS-version"; + test_proc = "proc"; + test_proc_number ="number" ; + test_proc_model= "model" ; + test_proc_cpu= "CPU-MHz" ; + test_proc_cache = "cache" ; + test_proc_list = "proc-list" ; + test_container_type = "containertype" ; + test_container_type_list = "containertype-list" ; +} + +//---------------------------------------------------------------------- +//Function : ~SALOME_RessourcesCatalog_Handler +//Purpose: Destructor +//---------------------------------------------------------------------- +SALOME_RessourcesCatalog_Handler::~SALOME_RessourcesCatalog_Handler() +{ + MESSAGE("SALOME_RessourcesCatalog_Handler destruction"); +} + +//---------------------------------------------------------------------- +//Function : startDocument +//Purpose: overload handler function +//---------------------------------------------------------------------- +bool +SALOME_RessourcesCatalog_Handler::startDocument() +{ + MESSAGE("Begin parse document"); + // Empty private elements + _procs_list.resize(0); + _ressources_list.resize(0); + _container_list.resize(0); + return true; +} + +//---------------------------------------------------------------------- +//Function : startElement +//Purpose: overload handler function +//---------------------------------------------------------------------- +bool +SALOME_RessourcesCatalog_Handler::startElement(const QString&, + const QString&, + const QString& qName, + const QXmlAttributes& atts) +{ + return true; +} + +//---------------------------------------------------------------------- +//Function : endElement +//Purpose: overload handler function +//---------------------------------------------------------------------- +bool +SALOME_RessourcesCatalog_Handler::endElement(const QString&, const QString&, + const QString& qName) +{ + // Ressources + + // tag test_computer_name + if((qName.compare(QString(test_computer_name))==0)) + _a_ressource.Parsername = content; + + // tag test_computer_OS + if((qName.compare(QString(test_computer_OS))==0)) + _a_ressource.ParserOS = content; + + // tag test_computer_OS_version + if((qName.compare(QString(test_computer_OS_version))==0)) + _a_ressource.ParserOS_version = content; + + //tag test_proc_number + if((qName.compare(QString(test_proc_number))==0)) + _a_proc.Parsernumber = atol(content.c_str()); + + //tag test_proc_model + if((qName.compare(QString(test_proc_model))==0)) + _a_proc.Parsermodel_name = content; + + //tag test_proc_cpu + if((qName.compare(QString(test_proc_cpu))==0)) + _a_proc.Parsercpu_mhz = atof(content.c_str()); + + //tag test_proc_cache + if((qName.compare(QString(test_proc_cache))==0)) + _a_proc.Parsercache_size = atof(content.c_str()); + + //tag test_proc + if((qName.compare(QString(test_proc))==0)) + { + _procs_list.push_back(_a_proc); + + // Empty temporary structures + _a_proc.Parsernumber = 0; + _a_proc.Parsermodel_name = ""; + _a_proc.Parsercpu_mhz = 0; + _a_proc.Parsercache_size = 0; + } + + //tag test_proc_list + if((qName.compare(QString(test_proc_list))==0)) + { + _a_ressource.Parserprocs = _procs_list; + + // Empty temporary structures + _procs_list.resize(0); + } + + //tag test_container_type + if((qName.compare(QString(test_container_type))==0)) + { + // We just have to compare the first character of content + // If C => Cpp + // If p => python + // If N => NP + switch(content[0]) { + case 'C': + _container_list.push_back(Cpp) ; + break; + case 'p': + _container_list.push_back(python) ; + break; + case 'N': + _container_list.push_back(NP) ; + break; + + default: + // If it'not in all theses cases, the type is affected to Cpp + _container_list.push_back(Cpp) ; + break; + } + } + + //tag test container_type_list + if((qName.compare(QString(test_container_type_list))==0)) + { + _a_ressource.Parsercontainertype = _container_list; + + // Empty temporary structures + _container_list.resize(0); + } + + // tag test_computer + if((qName.compare(QString(test_computer))==0)) + { + _ressources_list.push_back(_a_ressource); + + // Empty temporary structures + _a_ressource.Parsername = ""; + _a_ressource.ParserOS=""; + _a_ressource.ParserOS_version=""; + _a_ressource.Parserprocs.resize(0); + _a_ressource.Parsercontainertype.resize(0); + } + + return true; +} + +//---------------------------------------------------------------------- +//Function : characters +//Purpose: overload handler function +//---------------------------------------------------------------------- +bool SALOME_RessourcesCatalog_Handler::characters(const QString& chars) +{ + content = chars ; + return true; +} + +//---------------------------------------------------------------------- +//Function : endDocument +//Purpose: overload handler function +//---------------------------------------------------------------------- +bool SALOME_RessourcesCatalog_Handler::endDocument() +{ + //_ressources_list + for (unsigned int ind = 0; ind < _ressources_list.size(); ind++) + { + MESSAGE("Ressources name :"<<_ressources_list[ind].Parsername); + MESSAGE("OS :"<<_ressources_list[ind].ParserOS); + MESSAGE("OS version :"<<_ressources_list[ind].ParserOS_version); + for (unsigned int i = 0; i < _ressources_list[ind].Parserprocs.size(); i++) + { + MESSAGE("Proc number :" << _ressources_list[ind].Parserprocs[i].Parsernumber); + MESSAGE("Model name :" << _ressources_list[ind].Parserprocs[i].Parsermodel_name); + MESSAGE("CPU(MHz) :" << _ressources_list[ind].Parserprocs[i].Parsercpu_mhz); + MESSAGE("Cache :" << _ressources_list[ind].Parserprocs[i].Parsercache_size); + } + for (unsigned int j = 0; j < _ressources_list[ind].Parsercontainertype.size(); j++) + MESSAGE("Container Type :" << _ressources_list[ind].Parsercontainertype[j]); + } + + return true; +} + +//---------------------------------------------------------------------- +//Function : errorProtocol +//Purpose: overload handler function +//---------------------------------------------------------------------- +QString SALOME_RessourcesCatalog_Handler::errorProtocol() +{ + return errorProt; +} + +//---------------------------------------------------------------------- +//Function : fatalError +//Purpose: overload handler function +//---------------------------------------------------------------------- +bool +SALOME_RessourcesCatalog_Handler::fatalError(const QXmlParseException& exception) +{ + errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) + .arg( exception.message() ) + .arg( exception.lineNumber() ) + .arg( exception.columnNumber() ); + + return QXmlDefaultHandler::fatalError( exception ); +} + diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.hxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.hxx new file mode 100755 index 000000000..8a40f09f9 --- /dev/null +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Handler.hxx @@ -0,0 +1,106 @@ +//File SALOME_RessourcesCatalog_Handler.hxx +//Created: Fri Sept 07 2001 +//Author: Estelle Deville +//Project: SALOME +//Copyright: CEA/DEN/DM2S/LGLS +//$Header$ + +#ifndef SALOME_RESSOURCES_CATALOG_HANDLER +#define SALOME_RESSOURCES_CATALOG_HANDLER + +#include "utilities.h" +#include "SALOME_RessourcesCatalog_Parser.hxx" +#include +#include +#include + +class SALOME_RessourcesCatalog_Handler : public QXmlDefaultHandler +{ +public : + //! standard constructor + SALOME_RessourcesCatalog_Handler(); + + //! standard destructor + virtual ~SALOME_RessourcesCatalog_Handler(); + + //! method to overload handler function startDocument + /*! is called before a xml file is parsed + \return true if no error was detected + */ + virtual bool startDocument(); + + //! method to overload handler function startElement + /*! + \param QString argument by value + \param QString argument by value + \param QString qName argument by value + \param QXmlAttributes atts argument by value + \return true if no error was detected + */ + virtual bool startElement(const QString& , const QString& , + const QString& qName, const QXmlAttributes& atts); + + //! method to overload handler function endElement + /*! + \param QString argument by value + \param QString argument by value + \param QString qName argument by value + \return true if no error was detected + */ + virtual bool endElement(const QString&, const QString&, + const QString& qName); + + //! method to overload handler function characters + /*! + \param QString chars argument by value + \return true if no error was detected + */ + virtual bool characters(const QString& chars); + + //! method to overload handler function endDocument + /*! is called at the end of the parsing + \return true if no error was detected + */ + virtual bool endDocument(); + + //! method to overload handler function errorProtocol + /*! + \return the error message + */ + virtual QString errorProtocol(); + +//! method to overload handler function fatalError + /*! + \param QXmlParseException exception argument by value + \return true if no error was detected + */ + virtual bool fatalError(const QXmlParseException& exception); + + +private : + QString errorProt; + + string content; + + const char* test_computer; + const char* test_computer_name; + const char* test_computer_OS; + const char* test_computer_OS_version; + const char* test_proc; + const char* test_proc_number; + const char* test_proc_model; + const char* test_proc_cpu; + const char* test_proc_cache; + const char* test_proc_list; + const char* test_container_type; + const char* test_container_type_list; + + Parserressources _a_ressource; + + ListOfParserProc _procs_list; + ParserProc _a_proc; + ListOfParserContainerType _container_list; + +}; + +#endif // SALOME_RESSOURCES_CATALOG_HANDLER diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Parser.hxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Parser.hxx new file mode 100755 index 000000000..e0ab10156 --- /dev/null +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Parser.hxx @@ -0,0 +1,42 @@ +//File SALOME_RessourcesCatalog_Parser.hxx +//Created: Fri Sept 07 2001 +//Author: Estelle Deville +//Project: SALOME +//Copyright: CEA/DEN/DM2S/LGLS +//$Header$ + +#ifndef SALOME_RESSOURCES_CATALOG_PARSER +#define SALOME_RESSOURCES_CATALOG_PARSER + +#include +#include + +struct ParserProc{ + long Parsernumber; + string Parsermodel_name; + float Parsercpu_mhz; + float Parsercache_size; +}; + +typedef vector ListOfParserProc; + +enum Parsercontainertype {Cpp, python, NP}; +typedef vector ListOfParserContainerType; + +struct Parserressources{ + string Parsername; + string ParserOS; + string ParserOS_version; + ListOfParserProc Parserprocs; + ListOfParserContainerType Parsercontainertype; +}; + +typedef vector ListOfParserressources; + +#ifdef WRITE_RESSOURCES_TYPE +ListOfParserressources _ressources_list; +#else +extern ListOfParserressources _ressources_list; +#endif + +#endif //SALOME_RESSOURCES_CATALOG_PARSER diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx new file mode 100644 index 000000000..6208f0d62 --- /dev/null +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx @@ -0,0 +1,60 @@ +using namespace std; +// File: SALOME_RessourcesCatalog_Server.cxx +// Created: Mon Sep 10 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ +#include +#include "SALOME_NamingService.hxx" +#include "SALOME_RessourcesCatalog_impl.hxx" +#include "utilities.h" + +int main(int argc,char **argv) +{ + try { + CosNaming::NamingContext_var _rootContext, catalogContext; + + // initialize the ORB + + CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); + + // initialize POA + + CORBA::Object_var poaobj = orb->resolve_initial_references ("RootPOA"); + + PortableServer::POA_var poa = PortableServer::POA::_narrow (poaobj); + PortableServer::POAManager_var mgr = poa->the_POAManager(); + + // Active catalog + + SALOME_RessourcesCatalogImpl* Catalogue_i = new SALOME_RessourcesCatalogImpl(argc, argv); + poa->activate_object (Catalogue_i); + + mgr->activate(); + + + CORBA::Object_ptr myCata = Catalogue_i->_this(); + + // initialise Naming Service + SALOME_NamingService *_NS; + _NS = new SALOME_NamingService(orb); + // register Catalog in Naming Service + _NS->Register(myCata ,"/Kernel/RessourcesCatalog"); + + MESSAGE("Running Ressources Catalog Server.") + + orb->run(); + + poa->destroy(1,1); + + } + catch(CORBA::SystemException&) { + INFOS("Caught CORBA::SystemException.") + } + catch(CORBA::Exception&) { + INFOS("Caught CORBA::Exception.") + } + + return 0; +} diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx new file mode 100644 index 000000000..2d9806ba9 --- /dev/null +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.cxx @@ -0,0 +1,285 @@ +using namespace std; +// File: SALOME_RessourcesCatalog_impl.cxx +// Created: Mon Sep 10 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header $ + +#include "SALOME_RessourcesCatalog_impl.hxx" +#include + +//---------------------------------------------------------------------- +// Function : SALOME_RessourcesCatalogImpl +// Purpose : Constructor +//---------------------------------------------------------------------- +SALOME_RessourcesCatalogImpl::SALOME_RessourcesCatalogImpl(int argc, char** argv) +{ + MESSAGE("Ressources Catalog creation"); + + // Empty used variables + _ressourceslist.resize(0); + + // Parse the arguments given at server run + if (!_parseArguments(argc, argv,&_path_ressources)) + MESSAGE( "Error while argument parsing" ) + + // Test existency of files + if (_path_ressources == NULL) + MESSAGE( "Error the ressources catalog should be indicated" ) + else + { + MESSAGE("Parse ressources catalog"); + // Affect the variable _ressourceslist + _parse_xml_file(_path_ressources,_ressourceslist); + + // Verification of _datatype_list content + if(!_verify_ressources(_ressourceslist)) + MESSAGE( "Error while parsing the ressources catalog" ) + else MESSAGE("Ressources Catalog OK"); + } +} + +//---------------------------------------------------------------------- +// Function : ~SALOME_RessourcesCatalogImpl +// Purpose : Destructor +//---------------------------------------------------------------------- +SALOME_RessourcesCatalogImpl::~SALOME_RessourcesCatalogImpl() +{ + MESSAGE("Ressources Catalog Destruction"); +} + +//---------------------------------------------------------------------- +// Function : GetComputerList +// Purpose : get ressources list +//---------------------------------------------------------------------- +SALOME_RessourcesCatalog::ListOfComputer* +SALOME_RessourcesCatalogImpl::GetComputerList() +{ + MESSAGE("Begin of GetComputerList"); + SALOME_RessourcesCatalog::ListOfComputer_var _list = new SALOME_RessourcesCatalog::ListOfComputer; + _list->length(_ressourceslist.size()); + for (unsigned int ind=0; ind < _ressourceslist.size();ind++) + { + _list[ind]=CORBA::string_dup(_ressourceslist[ind].Parsername.c_str()); + } + return _list._retn(); +} + + +//---------------------------------------------------------------------- +// Function : GetRessourcesList +// Purpose : get a data type name list +//---------------------------------------------------------------------- +SALOME_RessourcesCatalog::ListOfContainerType* +SALOME_RessourcesCatalogImpl::GetContainerTypeList(const char* computer) + throw(SALOME_RessourcesCatalog::NotFound) +{ + MESSAGE("Begin of GetContainerTypeList"); + SALOME_RessourcesCatalog::ListOfContainerType_var _list = + new SALOME_RessourcesCatalog::ListOfContainerType; + + bool find = false ; + + // Looking for ressources named "computer" + // If found, get container type list + // If not found, exception is thrown + + for (unsigned int ind=0; ind < _ressourceslist.size();ind++) + { + if (strcmp((_ressourceslist[ind].Parsername).c_str(),computer) == 0) + { + MESSAGE("Ressources named " << computer << " found in the ressources catalog"); + find = true; + + _list->length(_ressourceslist[ind].Parsercontainertype.size()); + for (unsigned int ind1=0; ind1 < _ressourceslist[ind].Parsercontainertype.size();ind1++) + { + // get container type list + switch(_ressourceslist[ind].Parsercontainertype[ind1]){ + case Cpp: + _list[ind1] = SALOME_RessourcesCatalog::Cpp; + break; + case python: + _list[ind1] = SALOME_RessourcesCatalog::python; + break; + case NP: + _list[ind1] = SALOME_RessourcesCatalog::NP; + break; + } + } + } + } + + if (!find) + { + // The ressources was not found, the exception should be thrown + MESSAGE( "The ressource " << computer << " was not found in the ressources catalog" ) + throw SALOME_RessourcesCatalog::NotFound() ; + } + return _list._retn(); +} + +//---------------------------------------------------------------------- +// Function : GetComputerInfo +// Purpose : get ressources information +//---------------------------------------------------------------------- +SALOME_RessourcesCatalog::computer_info* +SALOME_RessourcesCatalogImpl::GetComputerInfo(const char* computer) + throw(SALOME_RessourcesCatalog::NotFound) +{ + MESSAGE("Begin of GetComputerInfo"); + SALOME_RessourcesCatalog::computer_info_var _computer_info = + new SALOME_RessourcesCatalog::computer_info; + + bool find = false ; + + // Looking for ressources named "computer" + // If found, get computer info + // If not found, exception is thrown + for (unsigned int ind=0; ind < _ressourceslist.size();ind++) + { + if (strcmp((_ressourceslist[ind].Parsername).c_str(),computer) == 0) + { + MESSAGE("Ressources named " << computer << " found in the ressources catalog"); + find = true; + + _computer_info->name = CORBA::string_dup(_ressourceslist[ind].Parsername.c_str()); + _computer_info->OS = CORBA::string_dup(_ressourceslist[ind].ParserOS.c_str()); + _computer_info->OS_version = CORBA::string_dup(_ressourceslist[ind].ParserOS_version.c_str()); + _computer_info->procs = _duplicate_procs(_ressourceslist[ind].Parserprocs); + } + } + + if (!find) + { + // The ressources was not found, the exception should be thrown + MESSAGE( "The ressource " << computer << " was not found in the ressources catalog" ) + throw SALOME_RessourcesCatalog::NotFound() ; + } + return _computer_info._retn(); +} + + + +//---------------------------------------------------------------------- +// Function : _parse_xml_file +// Purpose : parse one module catalog +//---------------------------------------------------------------------- +void +SALOME_RessourcesCatalogImpl::_parse_xml_file(const char* file, + ListOfParserressources& ressourceslist) +{ + SALOME_RessourcesCatalog_Handler* handler = new SALOME_RessourcesCatalog_Handler(); + QFile xmlFile(file); + + QXmlInputSource source(xmlFile); + + QXmlSimpleReader reader; + reader.setContentHandler( handler ); + reader.setErrorHandler( handler ); + reader.parse( source ); + xmlFile.close(); + ressourceslist = _ressources_list; +} + + +//---------------------------------------------------------------------- +// Function : _verify_ressources +// Purpose : verify ressources from the catalog parsing +// Verify that a computer is'nt defined twice in the catalog +//---------------------------------------------------------------------- +bool +SALOME_RessourcesCatalogImpl::_verify_ressources(ListOfParserressources ressourceslist) +{ + bool _return_value = true; + bool _bool = false ; + vector _machine_list; + _machine_list.resize(0); + + // Fill a list of all computers indicated in the ressources list + for (unsigned int ind = 0; ind < ressourceslist.size(); ind++) + _machine_list.push_back(ressourceslist[ind].Parsername); + + // Parse if a computer name is twice in the list of computers + for (unsigned int ind = 0; ind < _machine_list.size(); ind++) + { + for (unsigned int ind1 = ind+1 ; ind1 < _machine_list.size(); ind1++) + { + if(_machine_list[ind].compare(_machine_list[ind1]) == 0) + { + MESSAGE("The computer " << _machine_list[ind] << " is indicated more than once in the ressources list") + _return_value = false; + } + } + } + + return _return_value; +} + + +//---------------------------------------------------------------------- +// Function : _parseArguments +// Purpose : parse arguments to get general and personal catalog files +//---------------------------------------------------------------------- +bool +SALOME_RessourcesCatalogImpl::_parseArguments(int argc, char **argv, + char **_path) +{ + bool _return_value = true; + *_path = NULL; + for (int ind = 0; ind < argc ; ind++) + { + + if (strcmp(argv[ind],"-help") == 0) + { + INFOS( "Usage: " << argv[0] << " -common 'path to ressources catalog' -ORBInitRef NameService=corbaname::localhost"); + _return_value = false ; + } + if (strcmp(argv[ind],"-common") == 0) + { + if (ind + 1 <= argc) + { + // General catalog file + *_path= argv[ind + 1] ; + ifstream _path_file(*_path); + if (!_path_file) + { + MESSAGE( "Sorry the file " << *_path << " can't be open" ) + *_path = NULL; + _return_value = false; + } + } + } + + } + return _return_value; +} + +//---------------------------------------------------------------------- +// Function : _duplicate_procs +// Purpose : create a list of processors information from the catalog parsing +//---------------------------------------------------------------------- +SALOME_RessourcesCatalog::ListOfProc +SALOME_RessourcesCatalogImpl::_duplicate_procs(ListOfParserProc list_procs) +{ + SALOME_RessourcesCatalog::ListOfProc _list_procs; + unsigned int _length = list_procs.size(); + _list_procs.length(_length); + + for (unsigned int ind = 0; ind < _length; ind++) + { + //duplicate processor number + _list_procs[ind].number = list_procs[ind].Parsernumber; + + //duplicate model name + _list_procs[ind].model_name = CORBA::string_dup(list_procs[ind].Parsermodel_name.c_str()); + + //duplicate cpu + _list_procs[ind].cpu_mhz = list_procs[ind].Parsercpu_mhz; + + // duplicate cache size + _list_procs[ind].cache_size = list_procs[ind].Parsercache_size; + } + return _list_procs; +} diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.hxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.hxx new file mode 100644 index 000000000..8b6e8d090 --- /dev/null +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_impl.hxx @@ -0,0 +1,93 @@ +// File: SALOME_RessourcesCatalog_impl.hxx +// Created: Mon Sep 10 2001 +// Author: Estelle Deville +// Project: SALOME +// Copyright : CEA/DEN/DMSS/LGLS +// $Header$ + + +#ifndef RESSOURCESCATALOG_IMPL_H +#define RESSOURCESCATALOG_IMPL_H + +#include "utilities.h" +#include "SALOME_RessourcesCatalog_Handler.hxx" +#include +#include CORBA_SERVER_HEADER(SALOME_RessourcesCatalog) + +class SALOME_RessourcesCatalogImpl: public POA_SALOME_RessourcesCatalog::RessourcesCatalog, + public PortableServer::RefCountServantBase +{ +public: + //! standard constructor + SALOME_RessourcesCatalogImpl(int argc, char** argv); + + //! standard destructor + virtual ~SALOME_RessourcesCatalogImpl(); + + //! method to get the ressources list + /*! + \return a computer list + */ + virtual SALOME_RessourcesCatalog::ListOfComputer* GetComputerList(); + + //! method to get the container type list of a computer + /*! + \param computer const char* arguments + \return a container type list + */ + virtual SALOME_RessourcesCatalog::ListOfContainerType* GetContainerTypeList(const char* computer) throw(SALOME_RessourcesCatalog::NotFound); + + //! method to get informations on a computer + /*! + \param computer const char* arguments + \return informations of the computer + */ + virtual SALOME_RessourcesCatalog::computer_info* GetComputerInfo(const char* computer) throw(SALOME_RessourcesCatalog::NotFound); + + +private: + + //! method to parse the data type catalog + /*! + \param file const char* arguments + \param datatypelist ListOfParserDataType arguments + */ + virtual void _parse_xml_file(const char* file, + ListOfParserressources& ressourceslist); + + + //! method to verify ressources catalog content + /*! + \param ressourceslist ListOfParserRessources arguments + \return true if verfication is OK + */ + virtual bool _verify_ressources(ListOfParserressources ressourceslist); + + + //! method to parse arguments to get catalog file + /*! + \param argc int arguments + \param argv char** arguments + \param _path char** arguments + \return true if parsing is OK + */ + virtual bool _parseArguments(int argc, char **argv, char **_path); + + //! method to create a list of processors information from the catalog parsing + /*! + \param list_procs ListOfParserProc arguments + \return the processors information list + */ + virtual SALOME_RessourcesCatalog::ListOfProc + _duplicate_procs(ListOfParserProc list_procs); + + + // will contain the path to the ressources catalog + char* _path_ressources; + + + //will contain the informations on the data type catalog(after parsing) + ListOfParserressources _ressourceslist ; +}; + +#endif // RESSOURCESCATALOG_IMPL_H diff --git a/src/SALOMEDS/Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString.hxx b/src/SALOMEDS/Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString.hxx new file mode 100644 index 000000000..80b11fdbe --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString.hxx @@ -0,0 +1,78 @@ +// File : Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString.hxx +// Created : Mon Apr 7 10:13:30 2003 +// Author : Sergey Ruin +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + + +#ifndef _Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString_HeaderFile +#define _Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TCollection_MapNode_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TCollection_MapNode); +class SALOMEDS_DataMapNodeOfDataMapOfIntegerString; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_DataMapNodeOfDataMapOfIntegerString); + +class Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString) : public Handle(TCollection_MapNode) { + public: + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString)():Handle(TCollection_MapNode)() {} + Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString)(const Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString)(const SALOMEDS_DataMapNodeOfDataMapOfIntegerString* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString)& operator=(const Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString)& operator=(const SALOMEDS_DataMapNodeOfDataMapOfIntegerString* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_DataMapNodeOfDataMapOfIntegerString* operator->() + { + return (SALOMEDS_DataMapNodeOfDataMapOfIntegerString *)ControlAccess(); + } + + SALOMEDS_DataMapNodeOfDataMapOfIntegerString* operator->() const + { + return (SALOMEDS_DataMapNodeOfDataMapOfIntegerString *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString)(); + + Standard_EXPORT static const Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx b/src/SALOMEDS/Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx new file mode 100644 index 000000000..9ce140860 --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx @@ -0,0 +1,83 @@ +// File : Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx +// Created : Tue Aug 13 14:05:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#ifndef _Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile +#define _Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TCollection_MapNode_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TCollection_MapNode); +class SALOMEDS_DataMapNodeOfDataMapStringLabel; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_DataMapNodeOfDataMapStringLabel); + +class Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel) : public Handle(TCollection_MapNode) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel)():Handle(TCollection_MapNode)() {} + Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel)(const Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel)(const SALOMEDS_DataMapNodeOfDataMapStringLabel* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel)& operator=(const Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel)& operator=(const SALOMEDS_DataMapNodeOfDataMapStringLabel* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_DataMapNodeOfDataMapStringLabel* operator->() + { + return (SALOMEDS_DataMapNodeOfDataMapStringLabel *)ControlAccess(); + } + + SALOMEDS_DataMapNodeOfDataMapStringLabel* operator->() const + { + return (SALOMEDS_DataMapNodeOfDataMapStringLabel *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel)(); + + Standard_EXPORT static const Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_DrawableAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_DrawableAttribute.hxx new file mode 100644 index 000000000..bbc921bc1 --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_DrawableAttribute.hxx @@ -0,0 +1,83 @@ +// File : Handle_SALOMEDS_DrawableAttribute.hxx +// Created : Tue Jul 09 16:42:05 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Handle_SALOMEDS_DrawableAttribute_HeaderFile +#define _Handle_SALOMEDS_DrawableAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDataStd_Integer_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDataStd_Integer); +class SALOMEDS_DrawableAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_DrawableAttribute); + +class Handle(SALOMEDS_DrawableAttribute) : public Handle(TDataStd_Integer) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_DrawableAttribute)():Handle(TDataStd_Integer)() {} + Handle(SALOMEDS_DrawableAttribute)(const Handle(SALOMEDS_DrawableAttribute)& aHandle) : Handle(TDataStd_Integer)(aHandle) + { + } + + Handle(SALOMEDS_DrawableAttribute)(const SALOMEDS_DrawableAttribute* anItem) : Handle(TDataStd_Integer)((TDataStd_Integer *)anItem) + { + } + + Handle(SALOMEDS_DrawableAttribute)& operator=(const Handle(SALOMEDS_DrawableAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_DrawableAttribute)& operator=(const SALOMEDS_DrawableAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_DrawableAttribute* operator->() + { + return (SALOMEDS_DrawableAttribute *)ControlAccess(); + } + + SALOMEDS_DrawableAttribute* operator->() const + { + return (SALOMEDS_DrawableAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_DrawableAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_DrawableAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_ExpandableAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_ExpandableAttribute.hxx new file mode 100644 index 000000000..c4f0cdad1 --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_ExpandableAttribute.hxx @@ -0,0 +1,83 @@ +// File : Handle_SALOMEDS_ExpandableAttribute.hxx +// Created : Tue Jul 09 16:42:12 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Handle_SALOMEDS_ExpandableAttribute_HeaderFile +#define _Handle_SALOMEDS_ExpandableAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDataStd_Integer_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDataStd_Integer); +class SALOMEDS_ExpandableAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_ExpandableAttribute); + +class Handle(SALOMEDS_ExpandableAttribute) : public Handle(TDataStd_Integer) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_ExpandableAttribute)():Handle(TDataStd_Integer)() {} + Handle(SALOMEDS_ExpandableAttribute)(const Handle(SALOMEDS_ExpandableAttribute)& aHandle) : Handle(TDataStd_Integer)(aHandle) + { + } + + Handle(SALOMEDS_ExpandableAttribute)(const SALOMEDS_ExpandableAttribute* anItem) : Handle(TDataStd_Integer)((TDataStd_Integer *)anItem) + { + } + + Handle(SALOMEDS_ExpandableAttribute)& operator=(const Handle(SALOMEDS_ExpandableAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_ExpandableAttribute)& operator=(const SALOMEDS_ExpandableAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_ExpandableAttribute* operator->() + { + return (SALOMEDS_ExpandableAttribute *)ControlAccess(); + } + + SALOMEDS_ExpandableAttribute* operator->() const + { + return (SALOMEDS_ExpandableAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_ExpandableAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_ExpandableAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_IORAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_IORAttribute.hxx new file mode 100644 index 000000000..1a8f9876a --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_IORAttribute.hxx @@ -0,0 +1,83 @@ +// File : Handle_SALOMEDS_IORAttribute.hxx +// Created : Thu Nov 29 20:59:28 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef _Handle_SALOMEDS_IORAttribute_HeaderFile +#define _Handle_SALOMEDS_IORAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDataStd_Comment_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDataStd_Comment); +class SALOMEDS_IORAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_IORAttribute); + +class Handle(SALOMEDS_IORAttribute) : public Handle(TDataStd_Comment) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_IORAttribute)():Handle(TDataStd_Comment)() {} + Handle(SALOMEDS_IORAttribute)(const Handle(SALOMEDS_IORAttribute)& aHandle) : Handle(TDataStd_Comment)(aHandle) + { + } + + Handle(SALOMEDS_IORAttribute)(const SALOMEDS_IORAttribute* anItem) : Handle(TDataStd_Comment)((TDataStd_Comment *)anItem) + { + } + + Handle(SALOMEDS_IORAttribute)& operator=(const Handle(SALOMEDS_IORAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_IORAttribute)& operator=(const SALOMEDS_IORAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_IORAttribute* operator->() + { + return (SALOMEDS_IORAttribute *)ControlAccess(); + } + + SALOMEDS_IORAttribute* operator->() const + { + return (SALOMEDS_IORAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_IORAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_IORAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_LocalIDAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_LocalIDAttribute.hxx new file mode 100644 index 000000000..9afd1b12c --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_LocalIDAttribute.hxx @@ -0,0 +1,83 @@ +// File : Handle_SALOMEDS_LocalIDAttribute.hxx +// Created : Tue Aug 13 14:05:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#ifndef _Handle_SALOMEDS_LocalIDAttribute_HeaderFile +#define _Handle_SALOMEDS_LocalIDAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDataStd_Integer_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDataStd_Integer); +class SALOMEDS_LocalIDAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_LocalIDAttribute); + +class Handle(SALOMEDS_LocalIDAttribute) : public Handle(TDataStd_Integer) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_LocalIDAttribute)():Handle(TDataStd_Integer)() {} + Handle(SALOMEDS_LocalIDAttribute)(const Handle(SALOMEDS_LocalIDAttribute)& aHandle) : Handle(TDataStd_Integer)(aHandle) + { + } + + Handle(SALOMEDS_LocalIDAttribute)(const SALOMEDS_LocalIDAttribute* anItem) : Handle(TDataStd_Integer)((TDataStd_Integer *)anItem) + { + } + + Handle(SALOMEDS_LocalIDAttribute)& operator=(const Handle(SALOMEDS_LocalIDAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_LocalIDAttribute)& operator=(const SALOMEDS_LocalIDAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_LocalIDAttribute* operator->() + { + return (SALOMEDS_LocalIDAttribute *)ControlAccess(); + } + + SALOMEDS_LocalIDAttribute* operator->() const + { + return (SALOMEDS_LocalIDAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_LocalIDAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_LocalIDAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_OCAFApplication.hxx b/src/SALOMEDS/Handle_SALOMEDS_OCAFApplication.hxx new file mode 100644 index 000000000..49ff8f33f --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_OCAFApplication.hxx @@ -0,0 +1,83 @@ +// File : Handle_SALOMEDS_OCAFApplication.hxx +// Created : Thu Nov 29 20:59:51 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef _Handle_SALOMEDS_OCAFApplication_HeaderFile +#define _Handle_SALOMEDS_OCAFApplication_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDocStd_Application_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDocStd_Application); +class SALOMEDS_OCAFApplication; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_OCAFApplication); + +class Handle(SALOMEDS_OCAFApplication) : public Handle(TDocStd_Application) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_OCAFApplication)():Handle(TDocStd_Application)() {} + Handle(SALOMEDS_OCAFApplication)(const Handle(SALOMEDS_OCAFApplication)& aHandle) : Handle(TDocStd_Application)(aHandle) + { + } + + Handle(SALOMEDS_OCAFApplication)(const SALOMEDS_OCAFApplication* anItem) : Handle(TDocStd_Application)((TDocStd_Application *)anItem) + { + } + + Handle(SALOMEDS_OCAFApplication)& operator=(const Handle(SALOMEDS_OCAFApplication)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_OCAFApplication)& operator=(const SALOMEDS_OCAFApplication* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_OCAFApplication* operator->() + { + return (SALOMEDS_OCAFApplication *)ControlAccess(); + } + + SALOMEDS_OCAFApplication* operator->() const + { + return (SALOMEDS_OCAFApplication *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_OCAFApplication)(); + + Standard_EXPORT static const Handle(SALOMEDS_OCAFApplication) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_OpenedAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_OpenedAttribute.hxx new file mode 100644 index 000000000..4894b204f --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_OpenedAttribute.hxx @@ -0,0 +1,83 @@ +// File : Handle_SALOMEDS_OpenedAttribute.hxx +// Created : Tue Jul 09 16:42:38 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Handle_SALOMEDS_OpenedAttribute_HeaderFile +#define _Handle_SALOMEDS_OpenedAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDataStd_Integer_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDataStd_Integer); +class SALOMEDS_OpenedAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_OpenedAttribute); + +class Handle(SALOMEDS_OpenedAttribute) : public Handle(TDataStd_Integer) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_OpenedAttribute)():Handle(TDataStd_Integer)() {} + Handle(SALOMEDS_OpenedAttribute)(const Handle(SALOMEDS_OpenedAttribute)& aHandle) : Handle(TDataStd_Integer)(aHandle) + { + } + + Handle(SALOMEDS_OpenedAttribute)(const SALOMEDS_OpenedAttribute* anItem) : Handle(TDataStd_Integer)((TDataStd_Integer *)anItem) + { + } + + Handle(SALOMEDS_OpenedAttribute)& operator=(const Handle(SALOMEDS_OpenedAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_OpenedAttribute)& operator=(const SALOMEDS_OpenedAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_OpenedAttribute* operator->() + { + return (SALOMEDS_OpenedAttribute *)ControlAccess(); + } + + SALOMEDS_OpenedAttribute* operator->() const + { + return (SALOMEDS_OpenedAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_OpenedAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_OpenedAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_PersRefAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_PersRefAttribute.hxx new file mode 100644 index 000000000..a0bbeabe5 --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_PersRefAttribute.hxx @@ -0,0 +1,83 @@ +// File : Handle_SALOMEDS_PersRefAttribute.hxx +// Created : Thu Nov 29 21:00:10 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef _Handle_SALOMEDS_PersRefAttribute_HeaderFile +#define _Handle_SALOMEDS_PersRefAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDataStd_Comment_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDataStd_Comment); +class SALOMEDS_PersRefAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_PersRefAttribute); + +class Handle(SALOMEDS_PersRefAttribute) : public Handle(TDataStd_Comment) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_PersRefAttribute)():Handle(TDataStd_Comment)() {} + Handle(SALOMEDS_PersRefAttribute)(const Handle(SALOMEDS_PersRefAttribute)& aHandle) : Handle(TDataStd_Comment)(aHandle) + { + } + + Handle(SALOMEDS_PersRefAttribute)(const SALOMEDS_PersRefAttribute* anItem) : Handle(TDataStd_Comment)((TDataStd_Comment *)anItem) + { + } + + Handle(SALOMEDS_PersRefAttribute)& operator=(const Handle(SALOMEDS_PersRefAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_PersRefAttribute)& operator=(const SALOMEDS_PersRefAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_PersRefAttribute* operator->() + { + return (SALOMEDS_PersRefAttribute *)ControlAccess(); + } + + SALOMEDS_PersRefAttribute* operator->() const + { + return (SALOMEDS_PersRefAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_PersRefAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_PersRefAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_PixMapAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_PixMapAttribute.hxx new file mode 100644 index 000000000..27eba74a5 --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_PixMapAttribute.hxx @@ -0,0 +1,83 @@ +// File : Handle_SALOMEDS_PixMapAttribute.hxx +// Created : Tue Jul 09 16:42:46 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Handle_SALOMEDS_PixMapAttribute_HeaderFile +#define _Handle_SALOMEDS_PixMapAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDataStd_Comment_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDataStd_Comment); +class SALOMEDS_PixMapAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_PixMapAttribute); + +class Handle(SALOMEDS_PixMapAttribute) : public Handle(TDataStd_Comment) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_PixMapAttribute)():Handle(TDataStd_Comment)() {} + Handle(SALOMEDS_PixMapAttribute)(const Handle(SALOMEDS_PixMapAttribute)& aHandle) : Handle(TDataStd_Comment)(aHandle) + { + } + + Handle(SALOMEDS_PixMapAttribute)(const SALOMEDS_PixMapAttribute* anItem) : Handle(TDataStd_Comment)((TDataStd_Comment *)anItem) + { + } + + Handle(SALOMEDS_PixMapAttribute)& operator=(const Handle(SALOMEDS_PixMapAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_PixMapAttribute)& operator=(const SALOMEDS_PixMapAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_PixMapAttribute* operator->() + { + return (SALOMEDS_PixMapAttribute *)ControlAccess(); + } + + SALOMEDS_PixMapAttribute* operator->() const + { + return (SALOMEDS_PixMapAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_PixMapAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_PixMapAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_PythonObjectAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_PythonObjectAttribute.hxx new file mode 100644 index 000000000..9e724507b --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_PythonObjectAttribute.hxx @@ -0,0 +1,82 @@ +// File : Handle_SALOMEDS_PythonObjectAttribute.hxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#ifndef _Handle_SALOMEDS_PythonObjectAttribute_HeaderFile +#define _Handle_SALOMEDS_PythonObjectAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDF_Attribute); +class SALOMEDS_PythonObjectAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_PythonObjectAttribute); + +class Handle(SALOMEDS_PythonObjectAttribute) : public Handle(TDF_Attribute) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_PythonObjectAttribute)():Handle(TDF_Attribute)() {} + Handle(SALOMEDS_PythonObjectAttribute)(const Handle(SALOMEDS_PythonObjectAttribute)& aHandle) : Handle(TDF_Attribute)(aHandle) + { + } + + Handle(SALOMEDS_PythonObjectAttribute)(const SALOMEDS_PythonObjectAttribute* anItem) : Handle(TDF_Attribute)((TDF_Attribute *)anItem) + { + } + + Handle(SALOMEDS_PythonObjectAttribute)& operator=(const Handle(SALOMEDS_PythonObjectAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_PythonObjectAttribute)& operator=(const SALOMEDS_PythonObjectAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_PythonObjectAttribute* operator->() + { + return (SALOMEDS_PythonObjectAttribute *)ControlAccess(); + } + + SALOMEDS_PythonObjectAttribute* operator->() const + { + return (SALOMEDS_PythonObjectAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_PythonObjectAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_PythonObjectAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_SelectableAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_SelectableAttribute.hxx new file mode 100644 index 000000000..fa7df67ef --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_SelectableAttribute.hxx @@ -0,0 +1,83 @@ +// File : Handle_SALOMEDS_SelectableAttribute.hxx +// Created : Tue Jul 09 16:42:58 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Handle_SALOMEDS_SelectableAttribute_HeaderFile +#define _Handle_SALOMEDS_SelectableAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDataStd_Integer_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDataStd_Integer); +class SALOMEDS_SelectableAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_SelectableAttribute); + +class Handle(SALOMEDS_SelectableAttribute) : public Handle(TDataStd_Integer) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_SelectableAttribute)():Handle(TDataStd_Integer)() {} + Handle(SALOMEDS_SelectableAttribute)(const Handle(SALOMEDS_SelectableAttribute)& aHandle) : Handle(TDataStd_Integer)(aHandle) + { + } + + Handle(SALOMEDS_SelectableAttribute)(const SALOMEDS_SelectableAttribute* anItem) : Handle(TDataStd_Integer)((TDataStd_Integer *)anItem) + { + } + + Handle(SALOMEDS_SelectableAttribute)& operator=(const Handle(SALOMEDS_SelectableAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_SelectableAttribute)& operator=(const SALOMEDS_SelectableAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_SelectableAttribute* operator->() + { + return (SALOMEDS_SelectableAttribute *)ControlAccess(); + } + + SALOMEDS_SelectableAttribute* operator->() const + { + return (SALOMEDS_SelectableAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_SelectableAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_SelectableAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_SequenceOfIntegerAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_SequenceOfIntegerAttribute.hxx new file mode 100644 index 000000000..fa99d980a --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_SequenceOfIntegerAttribute.hxx @@ -0,0 +1,79 @@ +// File : Handle_SALOMEDS_SequenceOfIntegerAttribute.hxx +// Created : Fri Jul 05 10:55:49 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Handle_SALOMEDS_SequenceOfIntegerAttribute_HeaderFile +#define _Handle_SALOMEDS_SequenceOfIntegerAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDF_Attribute); +class SALOMEDS_SequenceOfIntegerAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_SequenceOfIntegerAttribute); + +class Handle(SALOMEDS_SequenceOfIntegerAttribute) : public Handle(TDF_Attribute) { + public: + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + Handle(SALOMEDS_SequenceOfIntegerAttribute)():Handle(TDF_Attribute)() {} + Handle(SALOMEDS_SequenceOfIntegerAttribute)(const Handle(SALOMEDS_SequenceOfIntegerAttribute)& aHandle) : Handle(TDF_Attribute)(aHandle) + { + } + + Handle(SALOMEDS_SequenceOfIntegerAttribute)(const SALOMEDS_SequenceOfIntegerAttribute* anItem) : Handle(TDF_Attribute)((TDF_Attribute *)anItem) + { + } + + Handle(SALOMEDS_SequenceOfIntegerAttribute)& operator=(const Handle(SALOMEDS_SequenceOfIntegerAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_SequenceOfIntegerAttribute)& operator=(const SALOMEDS_SequenceOfIntegerAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_SequenceOfIntegerAttribute* operator->() + { + return (SALOMEDS_SequenceOfIntegerAttribute *)ControlAccess(); + } + + SALOMEDS_SequenceOfIntegerAttribute* operator->() const + { + return (SALOMEDS_SequenceOfIntegerAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_SequenceOfIntegerAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_SequenceOfIntegerAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_SequenceOfRealAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_SequenceOfRealAttribute.hxx new file mode 100644 index 000000000..e7a9fb3a7 --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_SequenceOfRealAttribute.hxx @@ -0,0 +1,79 @@ +// File : Handle_SALOMEDS_SequenceOfRealAttribute.hxx +// Created : Fri Jul 05 10:55:39 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Handle_SALOMEDS_SequenceOfRealAttribute_HeaderFile +#define _Handle_SALOMEDS_SequenceOfRealAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDF_Attribute); +class SALOMEDS_SequenceOfRealAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_SequenceOfRealAttribute); + +class Handle(SALOMEDS_SequenceOfRealAttribute) : public Handle(TDF_Attribute) { + public: + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + Handle(SALOMEDS_SequenceOfRealAttribute)():Handle(TDF_Attribute)() {} + Handle(SALOMEDS_SequenceOfRealAttribute)(const Handle(SALOMEDS_SequenceOfRealAttribute)& aHandle) : Handle(TDF_Attribute)(aHandle) + { + } + + Handle(SALOMEDS_SequenceOfRealAttribute)(const SALOMEDS_SequenceOfRealAttribute* anItem) : Handle(TDF_Attribute)((TDF_Attribute *)anItem) + { + } + + Handle(SALOMEDS_SequenceOfRealAttribute)& operator=(const Handle(SALOMEDS_SequenceOfRealAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_SequenceOfRealAttribute)& operator=(const SALOMEDS_SequenceOfRealAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_SequenceOfRealAttribute* operator->() + { + return (SALOMEDS_SequenceOfRealAttribute *)ControlAccess(); + } + + SALOMEDS_SequenceOfRealAttribute* operator->() const + { + return (SALOMEDS_SequenceOfRealAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_SequenceOfRealAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_SequenceOfRealAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_StudyPropertiesAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_StudyPropertiesAttribute.hxx new file mode 100644 index 000000000..da160d92c --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_StudyPropertiesAttribute.hxx @@ -0,0 +1,82 @@ +// File : Handle_SALOMEDS_StudyPropertiesAttribute.hxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef _Handle_SALOMEDS_StudyPropertiesAttribute_HeaderFile +#define _Handle_SALOMEDS_StudyPropertiesAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDF_Attribute); +class SALOMEDS_StudyPropertiesAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_StudyPropertiesAttribute); + +class Handle(SALOMEDS_StudyPropertiesAttribute) : public Handle(TDF_Attribute) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_StudyPropertiesAttribute)():Handle(TDF_Attribute)() {} + Handle(SALOMEDS_StudyPropertiesAttribute)(const Handle(SALOMEDS_StudyPropertiesAttribute)& aHandle) : Handle(TDF_Attribute)(aHandle) + { + } + + Handle(SALOMEDS_StudyPropertiesAttribute)(const SALOMEDS_StudyPropertiesAttribute* anItem) : Handle(TDF_Attribute)((TDF_Attribute *)anItem) + { + } + + Handle(SALOMEDS_StudyPropertiesAttribute)& operator=(const Handle(SALOMEDS_StudyPropertiesAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_StudyPropertiesAttribute)& operator=(const SALOMEDS_StudyPropertiesAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_StudyPropertiesAttribute* operator->() + { + return (SALOMEDS_StudyPropertiesAttribute *)ControlAccess(); + } + + SALOMEDS_StudyPropertiesAttribute* operator->() const + { + return (SALOMEDS_StudyPropertiesAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_StudyPropertiesAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_StudyPropertiesAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_TableOfIntegerAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_TableOfIntegerAttribute.hxx new file mode 100644 index 000000000..49d2daa05 --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_TableOfIntegerAttribute.hxx @@ -0,0 +1,82 @@ +// File : Handle_SALOMEDS_TableOfIntegerAttribute.hxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#ifndef _Handle_SALOMEDS_TableOfIntegerAttribute_HeaderFile +#define _Handle_SALOMEDS_TableOfIntegerAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDF_Attribute); +class SALOMEDS_TableOfIntegerAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_TableOfIntegerAttribute); + +class Handle(SALOMEDS_TableOfIntegerAttribute) : public Handle(TDF_Attribute) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_TableOfIntegerAttribute)():Handle(TDF_Attribute)() {} + Handle(SALOMEDS_TableOfIntegerAttribute)(const Handle(SALOMEDS_TableOfIntegerAttribute)& aHandle) : Handle(TDF_Attribute)(aHandle) + { + } + + Handle(SALOMEDS_TableOfIntegerAttribute)(const SALOMEDS_TableOfIntegerAttribute* anItem) : Handle(TDF_Attribute)((TDF_Attribute *)anItem) + { + } + + Handle(SALOMEDS_TableOfIntegerAttribute)& operator=(const Handle(SALOMEDS_TableOfIntegerAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_TableOfIntegerAttribute)& operator=(const SALOMEDS_TableOfIntegerAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_TableOfIntegerAttribute* operator->() + { + return (SALOMEDS_TableOfIntegerAttribute *)ControlAccess(); + } + + SALOMEDS_TableOfIntegerAttribute* operator->() const + { + return (SALOMEDS_TableOfIntegerAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_TableOfIntegerAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_TableOfIntegerAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_TableOfRealAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_TableOfRealAttribute.hxx new file mode 100644 index 000000000..19d01c16b --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_TableOfRealAttribute.hxx @@ -0,0 +1,82 @@ +// File : Handle_SALOMEDS_TableOfRealAttribute.hxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#ifndef _Handle_SALOMEDS_TableOfRealAttribute_HeaderFile +#define _Handle_SALOMEDS_TableOfRealAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDF_Attribute); +class SALOMEDS_TableOfRealAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_TableOfRealAttribute); + +class Handle(SALOMEDS_TableOfRealAttribute) : public Handle(TDF_Attribute) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_TableOfRealAttribute)():Handle(TDF_Attribute)() {} + Handle(SALOMEDS_TableOfRealAttribute)(const Handle(SALOMEDS_TableOfRealAttribute)& aHandle) : Handle(TDF_Attribute)(aHandle) + { + } + + Handle(SALOMEDS_TableOfRealAttribute)(const SALOMEDS_TableOfRealAttribute* anItem) : Handle(TDF_Attribute)((TDF_Attribute *)anItem) + { + } + + Handle(SALOMEDS_TableOfRealAttribute)& operator=(const Handle(SALOMEDS_TableOfRealAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_TableOfRealAttribute)& operator=(const SALOMEDS_TableOfRealAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_TableOfRealAttribute* operator->() + { + return (SALOMEDS_TableOfRealAttribute *)ControlAccess(); + } + + SALOMEDS_TableOfRealAttribute* operator->() const + { + return (SALOMEDS_TableOfRealAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_TableOfRealAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_TableOfRealAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_TableOfStringAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_TableOfStringAttribute.hxx new file mode 100644 index 000000000..6c60e3c93 --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_TableOfStringAttribute.hxx @@ -0,0 +1,81 @@ +// File : Handle_SALOMEDS_TableOfStringAttribute.hxx +// Created : Mon Apr 7 10:13:30 2003 +// Author : Sergey Ruin +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + +#ifndef _Handle_SALOMEDS_TableOfStringAttribute_HeaderFile +#define _Handle_SALOMEDS_TableOfStringAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDF_Attribute); +class SALOMEDS_TableOfStringAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_TableOfStringAttribute); + +class Handle(SALOMEDS_TableOfStringAttribute) : public Handle(TDF_Attribute) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_TableOfStringAttribute)():Handle(TDF_Attribute)() {} + Handle(SALOMEDS_TableOfStringAttribute)(const Handle(SALOMEDS_TableOfStringAttribute)& aHandle) : Handle(TDF_Attribute)(aHandle) + { + } + + Handle(SALOMEDS_TableOfStringAttribute)(const SALOMEDS_TableOfStringAttribute* anItem) : Handle(TDF_Attribute)((TDF_Attribute *)anItem) + { + } + + Handle(SALOMEDS_TableOfStringAttribute)& operator=(const Handle(SALOMEDS_TableOfStringAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_TableOfStringAttribute)& operator=(const SALOMEDS_TableOfStringAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_TableOfStringAttribute* operator->() + { + return (SALOMEDS_TableOfStringAttribute *)ControlAccess(); + } + + SALOMEDS_TableOfStringAttribute* operator->() const + { + return (SALOMEDS_TableOfStringAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_TableOfStringAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_TableOfStringAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_TargetAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_TargetAttribute.hxx new file mode 100644 index 000000000..79ddb45d2 --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_TargetAttribute.hxx @@ -0,0 +1,83 @@ +// File : Handle_SALOMEDS_TargetAttribute.hxx +// Created : Fri Aug 16 10:20:05 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#ifndef _Handle_SALOMEDS_TargetAttribute_HeaderFile +#define _Handle_SALOMEDS_TargetAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDataStd_Integer_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDataStd_Integer); +class SALOMEDS_TargetAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_TargetAttribute); + +class Handle(SALOMEDS_TargetAttribute) : public Handle(TDataStd_Integer) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_TargetAttribute)():Handle(TDataStd_Integer)() {} + Handle(SALOMEDS_TargetAttribute)(const Handle(SALOMEDS_TargetAttribute)& aHandle) : Handle(TDataStd_Integer)(aHandle) + { + } + + Handle(SALOMEDS_TargetAttribute)(const SALOMEDS_TargetAttribute* anItem) : Handle(TDataStd_Integer)((TDataStd_Integer *)anItem) + { + } + + Handle(SALOMEDS_TargetAttribute)& operator=(const Handle(SALOMEDS_TargetAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_TargetAttribute)& operator=(const SALOMEDS_TargetAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_TargetAttribute* operator->() + { + return (SALOMEDS_TargetAttribute *)ControlAccess(); + } + + SALOMEDS_TargetAttribute* operator->() const + { + return (SALOMEDS_TargetAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_TargetAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_TargetAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_TextColorAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_TextColorAttribute.hxx new file mode 100644 index 000000000..9e879e4ed --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_TextColorAttribute.hxx @@ -0,0 +1,83 @@ +// File : Handle_SALOMEDS_TextColorAttribute.hxx +// Created : Wed Jul 10 12:52:50 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Handle_SALOMEDS_TextColorAttribute_HeaderFile +#define _Handle_SALOMEDS_TextColorAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDataStd_RealArray_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDataStd_RealArray); +class SALOMEDS_TextColorAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_TextColorAttribute); + +class Handle(SALOMEDS_TextColorAttribute) : public Handle(TDataStd_RealArray) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_TextColorAttribute)():Handle(TDataStd_RealArray)() {} + Handle(SALOMEDS_TextColorAttribute)(const Handle(SALOMEDS_TextColorAttribute)& aHandle) : Handle(TDataStd_RealArray)(aHandle) + { + } + + Handle(SALOMEDS_TextColorAttribute)(const SALOMEDS_TextColorAttribute* anItem) : Handle(TDataStd_RealArray)((TDataStd_RealArray *)anItem) + { + } + + Handle(SALOMEDS_TextColorAttribute)& operator=(const Handle(SALOMEDS_TextColorAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_TextColorAttribute)& operator=(const SALOMEDS_TextColorAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_TextColorAttribute* operator->() + { + return (SALOMEDS_TextColorAttribute *)ControlAccess(); + } + + SALOMEDS_TextColorAttribute* operator->() const + { + return (SALOMEDS_TextColorAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_TextColorAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_TextColorAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Handle_SALOMEDS_TextHighlightColorAttribute.hxx b/src/SALOMEDS/Handle_SALOMEDS_TextHighlightColorAttribute.hxx new file mode 100644 index 000000000..1ca7c5fe8 --- /dev/null +++ b/src/SALOMEDS/Handle_SALOMEDS_TextHighlightColorAttribute.hxx @@ -0,0 +1,83 @@ +// File : Handle_SALOMEDS_TextHighlightColorAttribute.hxx +// Created : Wed Jul 10 12:52:57 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Handle_SALOMEDS_TextHighlightColorAttribute_HeaderFile +#define _Handle_SALOMEDS_TextHighlightColorAttribute_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TDataStd_RealArray_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TDataStd_RealArray); +class SALOMEDS_TextHighlightColorAttribute; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOMEDS_TextHighlightColorAttribute); + +class Handle(SALOMEDS_TextHighlightColorAttribute) : public Handle(TDataStd_RealArray) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOMEDS_TextHighlightColorAttribute)():Handle(TDataStd_RealArray)() {} + Handle(SALOMEDS_TextHighlightColorAttribute)(const Handle(SALOMEDS_TextHighlightColorAttribute)& aHandle) : Handle(TDataStd_RealArray)(aHandle) + { + } + + Handle(SALOMEDS_TextHighlightColorAttribute)(const SALOMEDS_TextHighlightColorAttribute* anItem) : Handle(TDataStd_RealArray)((TDataStd_RealArray *)anItem) + { + } + + Handle(SALOMEDS_TextHighlightColorAttribute)& operator=(const Handle(SALOMEDS_TextHighlightColorAttribute)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOMEDS_TextHighlightColorAttribute)& operator=(const SALOMEDS_TextHighlightColorAttribute* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOMEDS_TextHighlightColorAttribute* operator->() + { + return (SALOMEDS_TextHighlightColorAttribute *)ControlAccess(); + } + + SALOMEDS_TextHighlightColorAttribute* operator->() const + { + return (SALOMEDS_TextHighlightColorAttribute *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOMEDS_TextHighlightColorAttribute)(); + + Standard_EXPORT static const Handle(SALOMEDS_TextHighlightColorAttribute) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEDS/Makefile.in b/src/SALOMEDS/Makefile.in new file mode 100644 index 000000000..523e9ed2c --- /dev/null +++ b/src/SALOMEDS/Makefile.in @@ -0,0 +1,97 @@ +#============================================================================== +# File : Makefile.in +# Author : Marc Tajchman +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_srcdir)/idl + + +@COMMENCE@ + +EXPORT_HEADERS = SALOMEDS_Tool.hxx + +# Libraries targets + +LIB = libSalomeDS.la +LIB_SRC = \ + SALOMEDS_StudyManager_i.cxx \ + SALOMEDS_UseCaseBuilder_i.cxx \ + SALOMEDS_UseCaseIterator_i.cxx \ + SALOMEDS_Tool.cxx \ + SALOMEDS_ChildIterator_i.cxx \ + SALOMEDS_SComponentIterator_i.cxx \ + SALOMEDS_Study_i.cxx \ + SALOMEDS_StudyBuilder_i.cxx \ + SALOMEDS_SObject_i.cxx \ + SALOMEDS_SComponent_i.cxx \ + SALOMEDS_OCAFApplication.cxx \ + SALOMEDS_GenericAttribute_i.cxx \ + SALOMEDS_IORAttribute.cxx \ + SALOMEDS_PersRefAttribute.cxx \ + SALOMEDS_AttributeComment_i.cxx \ + SALOMEDS_AttributeIOR_i.cxx \ + SALOMEDS_AttributeInteger_i.cxx \ + SALOMEDS_AttributeName_i.cxx \ + SALOMEDS_AttributePersistentRef_i.cxx \ + SALOMEDS_AttributeReal_i.cxx \ + SALOMEDS_AttributeSequenceOfReal_i.cxx \ + SALOMEDS_AttributeSequenceOfInteger_i.cxx \ + SALOMEDS_AttributeDrawable_i.cxx \ + SALOMEDS_AttributeSelectable_i.cxx \ + SALOMEDS_AttributeOpened_i.cxx \ + SALOMEDS_AttributeExpandable_i.cxx \ + SALOMEDS_AttributeTextColor_i.cxx \ + SALOMEDS_AttributeTextHighlightColor_i.cxx \ + SALOMEDS_AttributePixMap_i.cxx \ + SALOMEDS_AttributeTreeNode_i.cxx \ + SALOMEDS_AttributeLocalID_i.cxx \ + SALOMEDS_AttributeUserID_i.cxx \ + SALOMEDS_AttributeTarget_i.cxx \ + SALOMEDS_AttributeTableOfInteger_i.cxx \ + SALOMEDS_AttributeTableOfReal_i.cxx \ + SALOMEDS_AttributeTableOfString_i.cxx \ + SALOMEDS_AttributeStudyProperties_i.cxx \ + SALOMEDS_AttributePythonObject_i.cxx \ + SALOMEDS_SequenceOfRealAttribute.cxx \ + SALOMEDS_SequenceOfIntegerAttribute.cxx \ + SALOMEDS_DrawableAttribute.cxx \ + SALOMEDS_SelectableAttribute.cxx \ + SALOMEDS_ExpandableAttribute.cxx \ + SALOMEDS_OpenedAttribute.cxx \ + SALOMEDS_TextColorAttribute.cxx \ + SALOMEDS_TextHighlightColorAttribute.cxx \ + SALOMEDS_PixMapAttribute.cxx \ + SALOMEDS_LocalIDAttribute.cxx \ + SALOMEDS_TargetAttribute.cxx \ + SALOMEDS_TableOfIntegerAttribute.cxx \ + SALOMEDS_TableOfRealAttribute.cxx \ + SALOMEDS_TableOfStringAttribute.cxx \ + SALOMEDS_StudyPropertiesAttribute.cxx \ + SALOMEDS_PythonObjectAttribute.cxx \ + SALOMEDS_DataMapOfIntegerString_0.cxx \ + SALOMEDS_DataMapIteratorOfDataMapOfIntegerString_0.cxx \ + SALOMEDS_DataMapNodeOfDataMapOfIntegerString_0.cxx \ + SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx \ + SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx \ + SALOMEDS_DataMapStringLabel_0.cxx + +# Executables targets +BIN = SALOMEDS_Server SALOMEDS_Client +BIN_SRC = +LIB_SERVER_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl +BIN_SERVER_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl +BIN_CLIENT_IDL = + +CPPFLAGS+=$(OCC_INCLUDES) $(HDF5_INCLUDES) +CXXFLAGS+=$(OCC_CXXFLAGS) +LDFLAGS+=$(OCC_LIBS) $(OGL_LIBS) $(HDF5_LIBS) -lSalomeNS -lSalomeHDFPersist -lOpUtil -lSalomeLoggerServer +# -L/opt/ccmalloc/lib -lccmalloc -ldl +# -L/opt/efence/lib -lefence + +@CONCLUDE@ + + diff --git a/src/SALOMEDS/SALOMEDS.cdl b/src/SALOMEDS/SALOMEDS.cdl new file mode 100644 index 000000000..5da7d7a0b --- /dev/null +++ b/src/SALOMEDS/SALOMEDS.cdl @@ -0,0 +1,46 @@ +// File : SALOMEDS.cdl +// Created : Wed Nov 28 12:08:48 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + + + +package SALOMEDS + +uses TDocStd, + TDF, + TCollection, + TColStd, + TDataStd + + +is + + class OCAFApplication ; + class IORAttribute ; + class PersRefAttribute; + class SequenceOfRealAttribute; + class SequenceOfIntegerAttribute; + class DrawableAttribute; + class SelectableAttribute; + class ExpandableAttribute; + class OpenedAttribute; + class PixMapAttribute; + class TextColorAttribute; + class TextHighlightColorAttribute; + class LocalIDAttribute; + class UserIDAttribute; + class TableOfIntegerAttribute; + class TableOfRealAttribute; + class StudyPropertiesAttribute; + class PythonObjectAttribute; + + class DataMapStringLabel instantiates DataMap from TCollection + (ExtendedString from TColleciton, + Label from TDF, + ExtendedString from TCollection); + +end SALOMEDS; diff --git a/src/SALOMEDS/SALOMEDS_AttLong_i.cxx b/src/SALOMEDS/SALOMEDS_AttLong_i.cxx new file mode 100644 index 000000000..23d13f4b1 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttLong_i.cxx @@ -0,0 +1,86 @@ +using namespace std; +// File : SALOMEDS_AttLong_i.cxx +// Created : Mon Jun 10 10:54:58 CEST 2002 +// Author : Estelle Deville + +// Project : SALOME +// Module : SALOMEDS +// Copyright : CEA 2002 +// $Header$ + + + +#include "SALOMEDS_AttLong_i.hxx" +#include "utilities.h" +#include +#include + +//============================================================================ +/*! Function : Set + * Purpose : Affect a value to the basic attribute + */ +//============================================================================ +void SALOMEDS_AttLong_i::Set(CORBA::Long i) +{ + CheckLocked(); + TDataStd_Integer::Set (_Lab,i); +} + +//============================================================================ +/*! Function : Get + * Purpose : Get basic attribute's value + */ +//============================================================================ +CORBA::Long SALOMEDS_AttLong_i::Get() +{ + Handle(TDataStd_Integer) Att; + CORBA::Long x; + if (_Lab.FindAttribute(TDataStd_Integer::GetID(),Att)) + x = Att->Get (); + return x; +} + +//============================================================================ +/*! Function : Save + * Purpose : + */ +//============================================================================ +char* SALOMEDS_AttLong_i::Save() +{ + BEGIN_OF("SALOMEDS_AttLong_i::Save"); + CORBA::Long x = this->Get(); + char* out= new char[12]; + sprintf(out,"%ld",x); + return out; +} + +//============================================================================ +/*! Function : Load + * Purpose : + */ +//============================================================================ +void SALOMEDS_AttLong_i::Load() +{ + BEGIN_OF("SALOMEDS_AttLong_i::Load"); +} + +//============================================================================ +/*! Function : GetPtr + * Purpose : return sobject associated to the basic attribute (if exist) + */ +//============================================================================ +CORBA::Boolean SALOMEDS_AttLong_i::GetPtr(SALOMEDS::SObject_ptr anObject) +{ + Handle(TDataStd_Integer) Att; + return _Lab.FindAttribute(TDataStd_Integer::GetID(),Att); +} + +//============================================================================ +/*! Function : GetType + * Purpose : + */ +//============================================================================ +char* SALOMEDS_AttLong_i::GetType() +{ + return CORBA::string_dup(_type); +} diff --git a/src/SALOMEDS/SALOMEDS_AttLong_i.hxx b/src/SALOMEDS/SALOMEDS_AttLong_i.hxx new file mode 100644 index 000000000..fa46abd24 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttLong_i.hxx @@ -0,0 +1,35 @@ +// File : SALOMEDS_AttLong_i.hxx +// Created : Mon Jun 10 10:54:50 CEST 2002 +// Author : Estelle Deville + +// Project : SALOME +// Module : SALOMEDS +// Copyright : CEA 2002 +// $Header$ + +#ifndef __SALOMEDS_ATTLONG_I_H__ +#define __SALOMEDS_ATTLONG_I_H__ + +// IDL headers +#include +#include +#include CORBA_SERVER_HEADER(SALOMEDS_AttLong) +#include "SALOMEDS_BasicAttribute_i.hxx" + +class SALOMEDS_AttLong_i: public POA_SALOMEDS::AttLong, + public SALOMEDS_BasicAttribute_i { +protected: + char * _type; + +public: + + SALOMEDS_AttLong_i() { _type = "AttLong";}; + ~SALOMEDS_AttLong_i() {}; + void Set(CORBA::Long i); + CORBA::Long Get(); + virtual char* Save(); + virtual void Load(); + CORBA::Boolean GetPtr(SALOMEDS::SObject_ptr so); + virtual char* GetType(); +}; +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttReal_i.cxx new file mode 100644 index 000000000..2e2f920cf --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttReal_i.cxx @@ -0,0 +1,87 @@ +using namespace std; +// File : SALOMEDS_AttReal_i.cxx +// Created : Mon Jun 10 10:54:58 CEST 2002 +// Author : Estelle Deville + +// Project : SALOME +// Module : SALOMEDS +// Copyright : CEA 2002 +// $Header$ + + + +#include "SALOMEDS_AttReal_i.hxx" +#include "utilities.h" +#include +#include +#include + +//============================================================================ +/*! Function : Set + * Purpose : Affect a value to the basic attribute + */ +//============================================================================ +void SALOMEDS_AttReal_i::Set(CORBA::Double r) +{ + CheckLocked(); + TDataStd_Real::Set (_Lab,r); +} + +//============================================================================ +/*! Function : Get + * Purpose : Get basic attribute's value + */ +//============================================================================ +CORBA::Double SALOMEDS_AttReal_i::Get() +{ + Handle(TDataStd_Real) Att; + CORBA::Double x; + if (_Lab.FindAttribute(TDataStd_Real::GetID(),Att)) + x = Att->Get (); + return x; +} + +//============================================================================ +/*! Function : Save + * Purpose : + */ +//============================================================================ +char* SALOMEDS_AttReal_i::Save() +{ + BEGIN_OF("SALOMEDS_AttReal_i::Save"); + CORBA::Double x = this->Get(); + char* out= new char[12]; + sprintf(out,"%g",x); + return out; +} + +//============================================================================ +/*! Function : Load + * Purpose : + */ +//============================================================================ +void SALOMEDS_AttReal_i::Load() +{ + BEGIN_OF("SALOMEDS_AttReal_i::Load"); +} + +//============================================================================ +/*! Function : GetPtr + * Purpose : return sobject associated to the basic attribute (if exist) + */ +//============================================================================ +CORBA::Boolean SALOMEDS_AttReal_i::GetPtr(SALOMEDS::SObject_ptr anObject) +{ + Handle(TDataStd_Real) Att; + return _Lab.FindAttribute(TDataStd_Real::GetID(),Att); +} + +//============================================================================ +/*! Function : GetType + * Purpose : + */ +//============================================================================ +char* SALOMEDS_AttReal_i::GetType() +{ + return CORBA::string_dup(_type); +} diff --git a/src/SALOMEDS/SALOMEDS_AttReal_i.hxx b/src/SALOMEDS/SALOMEDS_AttReal_i.hxx new file mode 100644 index 000000000..35029f40a --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttReal_i.hxx @@ -0,0 +1,35 @@ +// File : SALOMEDS_AttReal_i.hxx +// Created : Mon Jun 10 10:54:50 CEST 2002 +// Author : Estelle Deville + +// Project : SALOME +// Module : SALOMEDS +// Copyright : CEA 2002 +// $Header$ + +#ifndef __SALOMEDS_ATTREAL_I_H__ +#define __SALOMEDS_ATTREAL_I_H__ + +// IDL headers +#include +#include +#include CORBA_SERVER_HEADER(SALOMEDS_AttReal) +#include "SALOMEDS_BasicAttribute_i.hxx" + +class SALOMEDS_AttReal_i: public POA_SALOMEDS::AttReal, + public SALOMEDS_BasicAttribute_i { +protected: + char * _type; + +public: + + SALOMEDS_AttReal_i() { _type = "AttReal";}; + ~SALOMEDS_AttReal_i() {}; + void Set(CORBA::Double r); + CORBA::Double Get(); + virtual char* Save(); + virtual void Load(); + CORBA::Boolean GetPtr(SALOMEDS::SObject_ptr so); + virtual char* GetType(); +}; +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx new file mode 100644 index 000000000..e9de8eb4c --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx @@ -0,0 +1,29 @@ +using namespace std; +// File : SALOMEDS_AttributeComment_i.cxx +// Created : Fri Jul 05 14:55:07 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributeComment_i.hxx" + +#include +#include "SALOMEDS_SObject_i.hxx" + +char* SALOMEDS_AttributeComment_i::Value() +{ + TCollection_ExtendedString S = Handle(TDataStd_Comment)::DownCast(_myAttr)->Get(); + CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString()); + return c_s._retn(); +} + +void SALOMEDS_AttributeComment_i::SetValue(const char* value) +{ + CheckLocked(); + CORBA::String_var Str = CORBA::string_dup(value); + Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeComment_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeComment_i.hxx new file mode 100644 index 000000000..f2f1933c7 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeComment_i.hxx @@ -0,0 +1,38 @@ +// File : SALOMEDS_AttributeComment_i.hxx +// Created : Fri Jul 05 10:57:20 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef SALOMEDS_AttributeComment_i_HeaderFile +#define SALOMEDS_AttributeComment_i_HeaderFile + +// IDL headers +#include +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeComment_i: public virtual POA_SALOMEDS::AttributeComment, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeComment_i(const Handle(TDataStd_Comment)& theCommentAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theCommentAttr; + } + ~SALOMEDS_AttributeComment_i() {}; + + char* Value(); + void SetValue(const char* value); + +}; + + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx new file mode 100644 index 000000000..e439db0c8 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx @@ -0,0 +1,24 @@ +using namespace std; +// File : SALOMEDS_AttributeDrawable_i.cxx +// Created : Fri Jul 05 14:25:13 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributeDrawable_i.hxx" +#include "SALOMEDS_SObject_i.hxx" + +CORBA::Boolean SALOMEDS_AttributeDrawable_i::IsDrawable() { + return (Handle(SALOMEDS_DrawableAttribute)::DownCast(_myAttr)->Get() == 1); +} + +void SALOMEDS_AttributeDrawable_i::SetDrawable(CORBA::Boolean value) { + CheckLocked(); + Standard_Integer val = 0; + if (value != 0) val = 1; + Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.hxx new file mode 100644 index 000000000..b91b8ac50 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeDrawable_i.hxx @@ -0,0 +1,37 @@ +// File: SALOMEDS_AttributeDrawable_i.hxx +// Created: Fri Jul 5 10:21:01 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#ifndef SALOMEDS_AttributeDrawable_i_HeaderFile +#define SALOMEDS_AttributeDrawable_i_HeaderFile + +// IDL headers + +#include "SALOMEDS_DrawableAttribute.hxx" +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeDrawable_i: public virtual POA_SALOMEDS::AttributeDrawable, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeDrawable_i(const Handle(SALOMEDS_DrawableAttribute)& theIntAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theIntAttr; + }; + ~SALOMEDS_AttributeDrawable_i() {}; + CORBA::Boolean IsDrawable(); + void SetDrawable(CORBA::Boolean value); +}; + + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx new file mode 100644 index 000000000..c468b0660 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx @@ -0,0 +1,23 @@ +using namespace std; +// File : SALOMEDS_AttributeExpandable_i.cxx +// Created : Fri Jul 05 14:25:13 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributeExpandable_i.hxx" +#include "SALOMEDS_SObject_i.hxx" + +CORBA::Boolean SALOMEDS_AttributeExpandable_i::IsExpandable() { + return (Handle(SALOMEDS_ExpandableAttribute)::DownCast(_myAttr)->Get() == 1); +} + +void SALOMEDS_AttributeExpandable_i::SetExpandable(CORBA::Boolean value) { + Standard_Integer val = 0; + if (value != 0) val = 1; + Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.hxx new file mode 100644 index 000000000..2fcc43064 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeExpandable_i.hxx @@ -0,0 +1,37 @@ +// File: SALOMEDS_AttributeExpandable_i.hxx +// Created: Fri Jul 5 10:21:01 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#ifndef SALOMEDS_AttributeExpandable_i_HeaderFile +#define SALOMEDS_AttributeExpandable_i_HeaderFile + +// IDL headers + +#include "SALOMEDS_ExpandableAttribute.hxx" +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeExpandable_i: public virtual POA_SALOMEDS::AttributeExpandable, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeExpandable_i(const Handle(SALOMEDS_ExpandableAttribute)& theIntAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theIntAttr; + }; + ~SALOMEDS_AttributeExpandable_i() {}; + CORBA::Boolean IsExpandable(); + void SetExpandable(CORBA::Boolean value); +}; + + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx new file mode 100644 index 000000000..60d55ad5b --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx @@ -0,0 +1,32 @@ +using namespace std; +// File : SALOMEDS_AttributeIOR_i.cxx +// Created : Fri Jul 05 15:17:19 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributeIOR_i.hxx" + + +#include +#include "SALOMEDS_SObject_i.hxx" +#include "SALOMEDS_Study_i.hxx" + +char* SALOMEDS_AttributeIOR_i::Value() +{ + TCollection_ExtendedString S = Handle(SALOMEDS_IORAttribute)::DownCast(_myAttr)->Get(); + CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString()); + return c_s._retn(); +} + +void SALOMEDS_AttributeIOR_i::SetValue(const char* value) +{ + CheckLocked(); + CORBA::String_var Str = CORBA::string_dup(value); + Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); + SALOMEDS_Study_i::IORUpdated(Handle(SALOMEDS_IORAttribute)::DownCast(_myAttr),_myOrb); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeIOR_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeIOR_i.hxx new file mode 100644 index 000000000..bc5744edc --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeIOR_i.hxx @@ -0,0 +1,36 @@ +// File : SALOMEDS_AttributeIOR_i.hxx +// Created : Fri Jul 05 10:57:09 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef SALOMEDS_AttributeIOR_i_HeaderFile +#define SALOMEDS_AttributeIOR_i_HeaderFile + +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" +#include "SALOMEDS_IORAttribute.hxx" + +class SALOMEDS_AttributeIOR_i: public virtual POA_SALOMEDS::AttributeIOR, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeIOR_i(const Handle(SALOMEDS_IORAttribute)& theIORAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theIORAttr; + } + ~SALOMEDS_AttributeIOR_i() {}; + + char* Value(); + void SetValue(const char* value); + +}; + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx new file mode 100644 index 000000000..3a6932cd9 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx @@ -0,0 +1,23 @@ +using namespace std; +// File : SALOMEDS_AttributeInteger_i.cxx +// Created : Fri Jul 05 14:25:13 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributeInteger_i.hxx" +#include "SALOMEDS_SObject_i.hxx" + + +CORBA::Long SALOMEDS_AttributeInteger_i::Value() { + return Handle(TDataStd_Integer)::DownCast(_myAttr)->Get(); +} + +void SALOMEDS_AttributeInteger_i::SetValue(CORBA::Long value) { + CheckLocked(); + Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(value); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeInteger_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeInteger_i.hxx new file mode 100644 index 000000000..2b24dcdc1 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeInteger_i.hxx @@ -0,0 +1,38 @@ +// File: SALOMEDS_AttributeInteger_i.hxx +// Created: Fri Jul 5 10:21:01 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#ifndef SALOMEDS_AttributeInteger_i_HeaderFile +#define SALOMEDS_AttributeInteger_i_HeaderFile + +// IDL headers + +#include +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeInteger_i: public virtual POA_SALOMEDS::AttributeInteger, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeInteger_i(const Handle(TDataStd_Integer)& theIntAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theIntAttr; + }; + ~SALOMEDS_AttributeInteger_i() {}; + + CORBA::Long Value(); + void SetValue(CORBA::Long value); +}; + + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx new file mode 100644 index 000000000..539f912fc --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx @@ -0,0 +1,22 @@ +using namespace std; +// File : SALOMEDS_AttributeLocalID_i.cxx +// Created : Tue Aug 13 14:05:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#include "SALOMEDS_AttributeLocalID_i.hxx" +#include "SALOMEDS_SObject_i.hxx" + +CORBA::Long SALOMEDS_AttributeLocalID_i::Value() { + return Handle(SALOMEDS_LocalIDAttribute)::DownCast(_myAttr)->Get(); +} + +void SALOMEDS_AttributeLocalID_i::SetValue(CORBA::Long value) { + CheckLocked(); + Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(value); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.hxx new file mode 100644 index 000000000..f5534d812 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeLocalID_i.hxx @@ -0,0 +1,37 @@ +// File: SALOMEDS_AttributeLocalID_i.hxx +// Created : Tue Aug 13 14:05:03 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#ifndef SALOMEDS_AttributeLocalID_i_HeaderFile +#define SALOMEDS_AttributeLocalID_i_HeaderFile + +// IDL headers + +#include "SALOMEDS_LocalIDAttribute.hxx" +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeLocalID_i: public virtual POA_SALOMEDS::AttributeLocalID, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeLocalID_i(const Handle(SALOMEDS_LocalIDAttribute)& theIntAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theIntAttr; + }; + ~SALOMEDS_AttributeLocalID_i() {}; + CORBA::Long Value(); + void SetValue(CORBA::Long value); +}; + + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx new file mode 100644 index 000000000..377559280 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeName_i.cxx @@ -0,0 +1,26 @@ +using namespace std; +// File : SALOMEDS_AttributeName_i.cxx +// Created : Fri Jul 05 14:40:12 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributeName_i.hxx" +#include +#include "SALOMEDS_SObject_i.hxx" + +char* SALOMEDS_AttributeName_i::Value() { + TCollection_ExtendedString S = Handle(TDataStd_Name)::DownCast(_myAttr)->Get(); + CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString()); + return c_s._retn(); +} + +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)); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeName_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeName_i.hxx new file mode 100644 index 000000000..8e9c580e5 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeName_i.hxx @@ -0,0 +1,38 @@ +// File: SALOMEDS_AttributeName_i.hxx +// Created: Fri Jul 5 10:21:51 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#ifndef SALOMEDS_AttributeName_i_HeaderFile +#define SALOMEDS_AttributeName_i_HeaderFile + +// IDL headers + +#include +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeName_i: public virtual POA_SALOMEDS::AttributeName, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeName_i(const Handle(TDataStd_Name)& theNameAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theNameAttr; + }; + ~SALOMEDS_AttributeName_i() {}; + + char* Value(); + void SetValue(const char* value); +}; + + + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx new file mode 100644 index 000000000..ac20e1b6e --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx @@ -0,0 +1,23 @@ +using namespace std; +// File : SALOMEDS_AttributeOpened_i.cxx +// Created : Fri Jul 05 14:25:13 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributeOpened_i.hxx" +#include "SALOMEDS_SObject_i.hxx" + +CORBA::Boolean SALOMEDS_AttributeOpened_i::IsOpened() { + return (Handle(SALOMEDS_OpenedAttribute)::DownCast(_myAttr)->Get() == 1); +} + +void SALOMEDS_AttributeOpened_i::SetOpened(CORBA::Boolean value) { + Standard_Integer val = 0; + if (value != 0) val = 1; + Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeOpened_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.hxx new file mode 100644 index 000000000..920282097 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeOpened_i.hxx @@ -0,0 +1,37 @@ +// File: SALOMEDS_AttributeOpened_i.hxx +// Created: Fri Jul 5 10:21:01 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#ifndef SALOMEDS_AttributeOpened_i_HeaderFile +#define SALOMEDS_AttributeOpened_i_HeaderFile + +// IDL headers + +#include "SALOMEDS_OpenedAttribute.hxx" +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeOpened_i: public virtual POA_SALOMEDS::AttributeOpened, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeOpened_i(const Handle(SALOMEDS_OpenedAttribute)& theIntAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theIntAttr; + }; + ~SALOMEDS_AttributeOpened_i() {}; + CORBA::Boolean IsOpened(); + void SetOpened(CORBA::Boolean value); +}; + + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx b/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx new file mode 100644 index 000000000..cc3b19ed3 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx @@ -0,0 +1,28 @@ +using namespace std; +// File : SALOMEDS_AttributePersistentRef_i.cxx +// Created : Fri Jul 05 15:12:57 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributePersistentRef_i.hxx" +#include +#include "SALOMEDS_SObject_i.hxx" + +char* SALOMEDS_AttributePersistentRef_i::Value() +{ + TCollection_ExtendedString S = Handle(SALOMEDS_PersRefAttribute)::DownCast(_myAttr)->Get(); + CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString()); + return c_s._retn(); +} + +void SALOMEDS_AttributePersistentRef_i::SetValue(const char* value) +{ + CheckLocked(); + CORBA::String_var Str = CORBA::string_dup(value); + Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.hxx b/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.hxx new file mode 100644 index 000000000..58131c54d --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.hxx @@ -0,0 +1,36 @@ +// File: SALOMEDS_AttributePersistentRef_i.hxx +// Created: Fri Jul 5 10:22:28 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#ifndef SALOMEDS_AttributePersistentRef_i_HeaderFile +#define SALOMEDS_AttributePersistentRef_i_HeaderFile + +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" +#include "SALOMEDS_PersRefAttribute.hxx" + +class SALOMEDS_AttributePersistentRef_i: public virtual POA_SALOMEDS::AttributePersistentRef, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributePersistentRef_i(const Handle(SALOMEDS_PersRefAttribute)& thePersRefAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = thePersRefAttr; + } + ~SALOMEDS_AttributePersistentRef_i() {}; + + char* Value(); + void SetValue(const char* value); + +}; + + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx new file mode 100644 index 000000000..b2dd7f6fe --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx @@ -0,0 +1,31 @@ +using namespace std; +// File : SALOMEDS_AttributePixMap_i.cxx +// Created : Fri Jul 05 14:38:10 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributePixMap_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include + +CORBA::Boolean SALOMEDS_AttributePixMap_i::HasPixMap() { + TCollection_ExtendedString S = Handle(SALOMEDS_PixMapAttribute)::DownCast(_myAttr)->Get(); + if (strcmp(TCollection_AsciiString(S).ToCString(), "None") == 0) return Standard_False; + return Standard_True; +} + +char* SALOMEDS_AttributePixMap_i::GetPixMap() { + CORBA::String_var S = CORBA::string_dup(TCollection_AsciiString(Handle(SALOMEDS_PixMapAttribute)::DownCast(_myAttr)->Get()).ToCString()); + return S._retn(); +} + +void SALOMEDS_AttributePixMap_i::SetPixMap(const char* value) { + CheckLocked(); + CORBA::String_var Str = CORBA::string_dup(value); + Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str)); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributePixMap_i.hxx b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.hxx new file mode 100644 index 000000000..5a4d9af6a --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributePixMap_i.hxx @@ -0,0 +1,36 @@ +// File: SALOMEDS_AttributePixMap_i.hxx +// Created: Fri Jul 5 10:21:15 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#ifndef SALOMEDS_AttributePixMap_i_HeaderFile +#define SALOMEDS_AttributePixMap_i_HeaderFile + +// IDL headers +#include "SALOMEDS_PixMapAttribute.hxx" +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributePixMap_i: public virtual POA_SALOMEDS::AttributePixMap, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributePixMap_i(const Handle(SALOMEDS_PixMapAttribute)& thePixMapAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = thePixMapAttr; + }; + ~SALOMEDS_AttributePixMap_i() {}; + CORBA::Boolean HasPixMap(); + char* GetPixMap(); + void SetPixMap(const char* value); +}; + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx new file mode 100644 index 000000000..83fec99bd --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx @@ -0,0 +1,29 @@ +using namespace std; +// File: SALOMEDS_AttributePythonObject_i.cxx +// Created: Tue Oct 8 10:13:30 2002 +// Author: Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#include "SALOMEDS_AttributePythonObject_i.hxx" +#include +#include +#include "SALOMEDS_SObject_i.hxx" + +void SALOMEDS_AttributePythonObject_i::SetObject(const char* theSequence, CORBA::Boolean IsScript) { + CheckLocked(); + char *aSeq = CORBA::string_dup(theSequence); + Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->SetObject(aSeq, IsScript); +} + +char* SALOMEDS_AttributePythonObject_i::GetObject() { + char* aSeq = Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->GetObject(); + CORBA::String_var aStr = CORBA::string_dup(aSeq); + return aStr._retn(); +} + +CORBA::Boolean SALOMEDS_AttributePythonObject_i::IsScript() { + return Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->IsScript(); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.hxx b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.hxx new file mode 100644 index 000000000..16031ba17 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributePythonObject_i.hxx @@ -0,0 +1,39 @@ +// File: SALOMEDS_AttributePythonObject_i.hxx +// Created: Tue Oct 8 10:13:30 2002 +// Author: Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#ifndef SALOMEDS_AttributePythonObject_i_HeaderFile +#define SALOMEDS_AttributePythonObject_i_HeaderFile + +// IDL headers + +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" +#include "SALOMEDS_PythonObjectAttribute.hxx" + +class SALOMEDS_AttributePythonObject_i: public virtual POA_SALOMEDS::AttributePythonObject, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributePythonObject_i(const Handle(SALOMEDS_PythonObjectAttribute)& theObjectAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theObjectAttr; + }; + ~SALOMEDS_AttributePythonObject_i() {}; + + virtual void SetObject(const char* theSequence, CORBA::Boolean IsScript); + virtual char* GetObject(); + virtual CORBA::Boolean IsScript(); + +}; + + + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx new file mode 100644 index 000000000..ce3a90bf2 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx @@ -0,0 +1,22 @@ +using namespace std; +// File : SALOMEDS_AttributeReal_i.cxx +// Created : Fri Jul 05 14:38:10 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributeReal_i.hxx" +#include "SALOMEDS_SObject_i.hxx" + +CORBA::Double SALOMEDS_AttributeReal_i::Value() { + return Handle(TDataStd_Real)::DownCast(_myAttr)->Get(); +} + +void SALOMEDS_AttributeReal_i::SetValue(CORBA::Double value) { + CheckLocked(); + Handle(TDataStd_Real)::DownCast(_myAttr)->Set(value); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeReal_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeReal_i.hxx new file mode 100644 index 000000000..a5c182674 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeReal_i.hxx @@ -0,0 +1,36 @@ +// File: SALOMEDS_AttributeReal_i.hxx +// Created: Fri Jul 5 10:21:15 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#ifndef SALOMEDS_AttributeReal_i_HeaderFile +#define SALOMEDS_AttributeReal_i_HeaderFile + +// IDL headers +#include +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeReal_i: public virtual POA_SALOMEDS::AttributeReal, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeReal_i(const Handle(TDataStd_Real)& theRealAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theRealAttr; + }; + ~SALOMEDS_AttributeReal_i() {}; + + CORBA::Double Value(); + void SetValue(CORBA::Double value); +}; + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx new file mode 100644 index 000000000..5630aaa1d --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx @@ -0,0 +1,23 @@ +using namespace std; +// File : SALOMEDS_AttributeSelectable_i.cxx +// Created : Fri Jul 05 14:25:13 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributeSelectable_i.hxx" +#include "SALOMEDS_SObject_i.hxx" + +CORBA::Boolean SALOMEDS_AttributeSelectable_i::IsSelectable() { + return (Handle(SALOMEDS_SelectableAttribute)::DownCast(_myAttr)->Get() == 1); +} + +void SALOMEDS_AttributeSelectable_i::SetSelectable(CORBA::Boolean value) { + Standard_Integer val = 0; + if (value != 0) val = 1; + Handle(TDataStd_Integer)::DownCast(_myAttr)->Set(val); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.hxx new file mode 100644 index 000000000..074c8ccf1 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeSelectable_i.hxx @@ -0,0 +1,37 @@ +// File: SALOMEDS_AttributeSelectable_i.hxx +// Created: Fri Jul 5 10:21:01 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#ifndef SALOMEDS_AttributeSelectable_i_HeaderFile +#define SALOMEDS_AttributeSelectable_i_HeaderFile + +// IDL headers + +#include "SALOMEDS_SelectableAttribute.hxx" +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeSelectable_i: public virtual POA_SALOMEDS::AttributeSelectable, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeSelectable_i(const Handle(SALOMEDS_SelectableAttribute)& theIntAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theIntAttr; + }; + ~SALOMEDS_AttributeSelectable_i() {}; + CORBA::Boolean IsSelectable(); + void SetSelectable(CORBA::Boolean value); +}; + + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx new file mode 100644 index 000000000..b0e6ce284 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx @@ -0,0 +1,64 @@ +using namespace std; +// File : SALOMEDS_AttributeSequenceOfInteger_i.cxx +// Created : Fri Jul 05 18:09:47 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include + + +void SALOMEDS_AttributeSequenceOfInteger_i::Assign(const SALOMEDS::LongSeq& other) +{ + CheckLocked(); + Handle(TColStd_HSequenceOfInteger) CasCadeSeq = new TColStd_HSequenceOfInteger; + for (int i = 0; i < other.length(); i++) { + CasCadeSeq->Append(other[i]); + } + Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq); +} + +SALOMEDS::LongSeq* SALOMEDS_AttributeSequenceOfInteger_i::CorbaSequence() +{ + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; + Handle(SALOMEDS_SequenceOfIntegerAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr); + CorbaSeq->length(CasCadeSeq->Length()); + for (int i = 0; i < CasCadeSeq->Length(); i++) { + CorbaSeq[i] = CasCadeSeq->Value(i+1);; + } + return CorbaSeq._retn(); +} + +void SALOMEDS_AttributeSequenceOfInteger_i::Add(CORBA::Long value) +{ + CheckLocked(); + Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Add(value); +} + +void SALOMEDS_AttributeSequenceOfInteger_i::Remove(CORBA::Long index) +{ + CheckLocked(); + Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Remove(index); +} + +void SALOMEDS_AttributeSequenceOfInteger_i::ChangeValue(CORBA::Long index, CORBA::Long value) +{ + CheckLocked(); + Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->ChangeValue(index, value); +} + +CORBA::Long SALOMEDS_AttributeSequenceOfInteger_i::Value(CORBA::Short index) +{ + return Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Value(index); +} + +CORBA::Long SALOMEDS_AttributeSequenceOfInteger_i::Length() +{ + return Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Length(); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.hxx new file mode 100644 index 000000000..256d89672 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.hxx @@ -0,0 +1,42 @@ +// File : SALOMEDS_AttributeSequenceOfInteger_i.hxx +// Created : Fri Jul 05 10:57:25 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef SALOMEDS_AttributeSequenceOfInteger_i_HeaderFile +#define SALOMEDS_AttributeSequenceOfInteger_i_HeaderFile + +// IDL headers +#include "SALOMEDS_SequenceOfIntegerAttribute.hxx" +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeSequenceOfInteger_i: public virtual POA_SALOMEDS::AttributeSequenceOfInteger, + public virtual SALOMEDS_GenericAttribute_i { + +public: + + SALOMEDS_AttributeSequenceOfInteger_i(const Handle(SALOMEDS_SequenceOfIntegerAttribute)& theSequenceOfIntegerAttr, + CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theSequenceOfIntegerAttr; + }; + ~SALOMEDS_AttributeSequenceOfInteger_i() {}; + + void Assign(const SALOMEDS::LongSeq& other); + SALOMEDS::LongSeq* CorbaSequence(); + void Add(CORBA::Long value); + void Remove(CORBA::Long index); + void ChangeValue(CORBA::Long index, CORBA::Long value); + CORBA::Long Value(CORBA::Short index); + CORBA::Long Length(); +}; + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx new file mode 100644 index 000000000..caf8cfa7c --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx @@ -0,0 +1,63 @@ +using namespace std; +// File : SALOMEDS_AttributeSequenceOfReal_i.cxx +// Created : Fri Jul 05 17:28:29 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributeSequenceOfReal_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include + +void SALOMEDS_AttributeSequenceOfReal_i::Assign(const SALOMEDS::DoubleSeq& other) +{ + CheckLocked(); + Handle(TColStd_HSequenceOfReal) CasCadeSeq = new TColStd_HSequenceOfReal; + for (int i = 0; i < other.length(); i++) { + CasCadeSeq->Append(other[i]); + } + Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq); +} + +SALOMEDS::DoubleSeq* SALOMEDS_AttributeSequenceOfReal_i::CorbaSequence() +{ + SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq; + Handle(SALOMEDS_SequenceOfRealAttribute) CasCadeSeq = Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr); + CorbaSeq->length(CasCadeSeq->Length()); + for (int i = 0; i < CasCadeSeq->Length(); i++) { + CorbaSeq[i] = CasCadeSeq->Value(i+1);; + } + return CorbaSeq._retn(); +} + +void SALOMEDS_AttributeSequenceOfReal_i::Add(CORBA::Double value) +{ + CheckLocked(); + Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Add(value); +} + +void SALOMEDS_AttributeSequenceOfReal_i::Remove(CORBA::Long index) +{ + CheckLocked(); + Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Remove(index); +} + +void SALOMEDS_AttributeSequenceOfReal_i::ChangeValue(CORBA::Long index, CORBA::Double value) +{ + CheckLocked(); + Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->ChangeValue(index, value); +} + +CORBA::Double SALOMEDS_AttributeSequenceOfReal_i::Value(CORBA::Short index) +{ + return Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Value(index); +} + +CORBA::Long SALOMEDS_AttributeSequenceOfReal_i::Length() +{ + return Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Length(); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.hxx new file mode 100644 index 000000000..a7143d8b3 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.hxx @@ -0,0 +1,43 @@ +// File : SALOMEDS_AttributeSequenceOfSequenceOfReal_i.hxx +// Created : Fri Jul 05 10:57:32 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef SALOMEDS_AttributeSequenceOfSequenceOfReal_i_HeaderFile +#define SALOMEDS_AttributeSequenceOfSequenceOfReal_i_HeaderFile + +// IDL headers +#include "SALOMEDS_SequenceOfRealAttribute.hxx" +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeSequenceOfReal_i: public virtual POA_SALOMEDS::AttributeSequenceOfReal, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeSequenceOfReal_i(const Handle(SALOMEDS_SequenceOfRealAttribute)& theSequenceOfRealAttr, + CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theSequenceOfRealAttr; + }; + ~SALOMEDS_AttributeSequenceOfReal_i() {}; + + void Assign(const SALOMEDS::DoubleSeq& other); + SALOMEDS::DoubleSeq* CorbaSequence(); + void Add(CORBA::Double value); + void Remove(CORBA::Long index); + void ChangeValue(CORBA::Long index, CORBA::Double value); + CORBA::Double Value(CORBA::Short index); + CORBA::Long Length(); +}; + + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx new file mode 100644 index 000000000..074bd3c7f --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx @@ -0,0 +1,154 @@ +using namespace std; +// File : SALOMEDS_AttributeStudyProperties_i.cxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributeStudyProperties_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include +#include + +#define CREATION_MODE_NOTDEFINED 0 +#define CREATION_MODE_SCRATCH 1 +#define CREATION_MODE_COPY 2 + +void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName) { + CheckLocked(); + Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); + CORBA::String_var Str = CORBA::string_dup(theName); + aProp->SetFirstName(TCollection_ExtendedString(Str)); +} + +char* SALOMEDS_AttributeStudyProperties_i::GetUserName() { + TCollection_ExtendedString S = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetCreatorName(); + CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(S).ToCString()); + return c_s._retn(); +} + +void SALOMEDS_AttributeStudyProperties_i::SetCreationDate(CORBA::Long theMinute, + CORBA::Long theHour, + CORBA::Long theDay, + CORBA::Long theMonth, + CORBA::Long theYear) { + CheckLocked(); + Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); + int aTmp; + if (aProp->GetCreationDate(aTmp, aTmp, aTmp, aTmp, aTmp)) return; + aProp->SetModificationDate(theMinute, theHour, theDay, theMonth, theYear); +} + +CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::GetCreationDate(CORBA::Long& theMinute, + CORBA::Long& theHour, + CORBA::Long& theDay, + CORBA::Long& theMonth, + CORBA::Long& theYear) { + Standard_Integer aMinute; + Standard_Integer aHour; + Standard_Integer aDay; + Standard_Integer aMonth; + Standard_Integer aYear; + if (Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetCreationDate(aMinute, aHour, aDay, + aMonth, aYear)) { + theMinute = aMinute; + theHour = aHour; + theDay = aDay; + theMonth = aMonth; + theYear = aYear; + return Standard_True; + } + return Standard_False; +} + +void SALOMEDS_AttributeStudyProperties_i::SetCreationMode(const char* theMode) { + CheckLocked(); + Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); + if (strcmp(theMode,"from scratch")==0) aProp->SetCreationMode(CREATION_MODE_SCRATCH); + else if (strcmp(theMode,"copy from")==0) aProp->SetCreationMode(CREATION_MODE_COPY); + else aProp->SetCreationMode(CREATION_MODE_NOTDEFINED); +} + +char* SALOMEDS_AttributeStudyProperties_i::GetCreationMode() { + CORBA::String_var c_s; + switch (Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetCreationMode()) { + case CREATION_MODE_SCRATCH: c_s = "from scratch"; break; + case CREATION_MODE_COPY: c_s = "copy from"; break; + default: c_s = ""; + } + return c_s._retn(); +} + +void SALOMEDS_AttributeStudyProperties_i::SetModified(CORBA::Long theModified) { + Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->SetModified(theModified); +} + +CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsModified() { + return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->IsModified(); +} + +CORBA::Long SALOMEDS_AttributeStudyProperties_i::GetModified() { + return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->GetModified(); +} + +void SALOMEDS_AttributeStudyProperties_i::SetLocked(CORBA::Boolean theLocked) { + Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->SetLocked(theLocked); +} + +CORBA::Boolean SALOMEDS_AttributeStudyProperties_i::IsLocked() { + return Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr)->IsLocked(); +} + +void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName, + CORBA::Long theMinute, + CORBA::Long theHour, + CORBA::Long theDay, + CORBA::Long theMonth, + CORBA::Long theYear) { + CheckLocked(); + Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); + aProp->SetUserName(CORBA::string_dup(theName)); + aProp->SetModificationDate((int)theMinute, (int)theHour, (int)theDay, (int)theMonth, (int)theYear); +} +void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames, + SALOMEDS::LongSeq_out theMinutes, + SALOMEDS::LongSeq_out theHours, + SALOMEDS::LongSeq_out theDays, + SALOMEDS::LongSeq_out theMonths, + SALOMEDS::LongSeq_out theYears, + CORBA::Boolean theWithCreator) { + Handle(TColStd_HSequenceOfExtendedString) aNames; + Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; + Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr); + aNames = aProp->GetUserNames(); + aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); + int aLength = aNames->Length()-((theWithCreator)?0:1); + theNames = new SALOMEDS::StringSeq; +// SALOMEDS::LongSeq *maminute = new SALOMEDS::LongSeq; +// maminute->length(5); + theMinutes = new SALOMEDS::LongSeq; + theHours = new SALOMEDS::LongSeq; + theDays = new SALOMEDS::LongSeq; + theMonths = new SALOMEDS::LongSeq; + theYears = new SALOMEDS::LongSeq; + theNames->length(aLength); + theMinutes->length(aLength); + theHours->length(aLength); + theDays->length(aLength); + theMonths->length(aLength); + theYears->length(aLength); + int a; + for(a = 0; a < aLength; a++) + { + (*theNames)[a] = CORBA::string_dup(TCollection_AsciiString(aNames->Value(a + 1 + ((theWithCreator)?0:1))).ToCString()); + (*theMinutes)[a] = aMinutes->Value(a + 1 + ((theWithCreator)?0:1)); + (*theHours)[a] = aHours->Value(a + 1 + ((theWithCreator)?0:1)); + (*theDays)[a] = aDays->Value(a + 1 + ((theWithCreator)?0:1)); + (*theMonths)[a] = aMonths->Value(a + 1 + ((theWithCreator)?0:1)); + (*theYears)[a] = aYears->Value(a + 1 + ((theWithCreator)?0:1)); + } +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx new file mode 100644 index 000000000..c67a278a4 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx @@ -0,0 +1,58 @@ +// File: SALOMEDS_AttributeStudyProperties_i.hxx +// Created: Tue Oct 8 10:13:30 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef SALOMEDS_AttributeStudyProperties_i_HeaderFile +#define SALOMEDS_AttributeStudyProperties_i_HeaderFile + +// IDL headers +#include +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeStudyProperties_i: public virtual POA_SALOMEDS::AttributeStudyProperties, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeStudyProperties_i(const Handle(SALOMEDS_StudyPropertiesAttribute)& theAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theAttr; + }; + ~SALOMEDS_AttributeStudyProperties_i() {}; + + virtual void SetUserName(const char* theName); + virtual char* GetUserName() ; + virtual void SetCreationDate(CORBA::Long theMinute, CORBA::Long theHour, CORBA::Long theDay, CORBA::Long theMonth, CORBA::Long theYear); + virtual CORBA::Boolean GetCreationDate(CORBA::Long& theMinute, CORBA::Long& theHour, CORBA::Long& theDay, CORBA::Long& theMonth, CORBA::Long& theYear); + virtual void SetCreationMode(const char* theMode); + virtual char* GetCreationMode(); + virtual void SetModified(CORBA::Long theModified); + virtual CORBA::Boolean IsModified(); + virtual CORBA::Long GetModified(); + virtual void SetLocked(CORBA::Boolean theLocked); + virtual CORBA::Boolean IsLocked(); + virtual void SetModification(const char* theName, + CORBA::Long theMinute, + CORBA::Long theHour, + CORBA::Long theDay, + CORBA::Long theMonth, + CORBA::Long theYear); + virtual void GetModificationsList(SALOMEDS::StringSeq_out theNames, + SALOMEDS::LongSeq_out theMinutes, + SALOMEDS::LongSeq_out theHours, + SALOMEDS::LongSeq_out theDays, + SALOMEDS::LongSeq_out theMonths, + SALOMEDS::LongSeq_out theYears, + CORBA::Boolean theWithCreator); +}; + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx new file mode 100644 index 000000000..ffa245052 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx @@ -0,0 +1,341 @@ +using namespace std; +// File : SALOMEDS_AttributeTableOfInteger_i.cxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + + +#include "SALOMEDS_AttributeTableOfInteger_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include +#include +#include + +#include +#include + +#define SEPARATOR '\1' + +static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString) +{ + TCollection_ExtendedString aString(theString); + int aPos = aString.Search(SEPARATOR); + if(aPos <= 0 || aPos == aString.Length() ) return TCollection_ExtendedString(); + return aString.Split(aPos); +} + +static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString) +{ + TCollection_ExtendedString aString(theString); + int aPos = aString.Search(SEPARATOR); + if(aPos < 1) return aString; + if(aPos == 1) return TCollection_ExtendedString(); + aString.Split(aPos-1); + return aString; +} + + + +void SALOMEDS_AttributeTableOfInteger_i::SetTitle(const char* theTitle) { + CheckLocked(); + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + CORBA::String_var aStr = CORBA::string_dup(theTitle); + aTable->SetTitle(TCollection_ExtendedString(aStr)); +} + +char* SALOMEDS_AttributeTableOfInteger_i::GetTitle() { + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(aTable->GetTitle()).ToCString()); + return c_s._retn(); +} + +void SALOMEDS_AttributeTableOfInteger_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); + CORBA::String_var aStr = CORBA::string_dup(theTitle); + TCollection_ExtendedString aTitle(aStr); + TCollection_ExtendedString aUnit = getUnit(aTable->GetRowTitle(theIndex)); + if(aUnit.Length() > 0) { + aTitle += SEPARATOR; + aTitle += aUnit; + } + + aTable->SetRowTitle(theIndex, aTitle); +} + +void SALOMEDS_AttributeTableOfInteger_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength(); + for (int i = 0; i < theTitles.length(); i++) { + SetRowTitle(i + 1, theTitles[i]); + } +} + +SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowTitles() { + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq; + aTitles->length(aTable->GetNbRows()); + for(int i = 0; i < aTitles->length(); i++) + aTitles[i] = CORBA::string_dup(TCollection_AsciiString(getTitle(aTable->GetRowTitle(i + 1))).ToCString()); + return aTitles._retn(); +} + +void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); + CORBA::String_var aStr = CORBA::string_dup(theTitle); + aTable->SetColumnTitle(theIndex, TCollection_ExtendedString(aStr)); +} + +void SALOMEDS_AttributeTableOfInteger_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength(); + for (int i = 0; i < theTitles.length(); i++) { + SetColumnTitle(i + 1, theTitles[i]); + } +} + +SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumnTitles() { + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq; + aTitles->length(aTable->GetNbColumns()); + for(int i = 0; i < aTitles->length(); i++) + aTitles[i] = CORBA::string_dup(TCollection_AsciiString(aTable->GetColumnTitle(i + 1)).ToCString()); + return aTitles._retn(); +} + +//Units support +void SALOMEDS_AttributeTableOfInteger_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); + CORBA::String_var aStr = CORBA::string_dup(theUnit); + TCollection_ExtendedString aTitle = getTitle(aTable->GetRowTitle(theIndex)); + TCollection_ExtendedString aUnit(aStr); + aTitle += SEPARATOR; + aTitle += aUnit; + aTable->SetRowTitle(theIndex, aTitle); +} + +void SALOMEDS_AttributeTableOfInteger_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength(); + for (int i = 0; i < theUnits.length(); i++) { + SetRowUnit(i + 1, theUnits[i]); + } +} + +SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowUnits() { + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + SALOMEDS::StringSeq_var aUnits = new SALOMEDS::StringSeq; + aUnits->length(aTable->GetNbRows()); + for(int i = 0; i < aUnits->length(); i++) + aUnits[i] = CORBA::string_dup(TCollection_AsciiString(getUnit(aTable->GetRowTitle(i + 1))).ToCString()); + return aUnits._retn(); +} + +CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetNbRows() { + return Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr)->GetNbRows(); +} +CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetNbColumns() { + return Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr)->GetNbColumns(); +} + +void SALOMEDS_AttributeTableOfInteger_i::AddRow(const SALOMEDS::LongSeq& theData) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + + Handle(TColStd_HSequenceOfInteger) aRow = new TColStd_HSequenceOfInteger; + for (int i = 0; i < theData.length(); i++) aRow->Append(theData[i]); + try { + aTable->SetRowData(aTable->GetNbRows() + 1, aRow); + } + catch(Standard_Failure) { + throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength(); + } +} + +void SALOMEDS_AttributeTableOfInteger_i::SetRow(CORBA::Long theRow, const SALOMEDS::LongSeq& theData) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + + Handle(TColStd_HSequenceOfInteger) aRow = new TColStd_HSequenceOfInteger; + for (int i = 0; i < theData.length(); i++) aRow->Append(theData[i]); + try { + aTable->SetRowData(theRow, aRow); + } + catch(Standard_Failure) { + throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength(); + } +} + +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRow(CORBA::Long theRow) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) +{ + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); + + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; + Handle(TColStd_HSequenceOfInteger) aRow = aTable->GetRowData(theRow); + CorbaSeq->length(aRow->Length()); + for (int i = 0; i < aRow->Length(); i++) { + CorbaSeq[i] = aRow->Value(i + 1); + } + return CorbaSeq._retn(); +} + +void SALOMEDS_AttributeTableOfInteger_i::AddColumn(const SALOMEDS::LongSeq& theData) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + + Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger; + for (int i = 0; i < theData.length(); i++) aColumn->Append(theData[i]); + try { + aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn); + } + catch(Standard_Failure) { + throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength(); + } +} + +void SALOMEDS_AttributeTableOfInteger_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::LongSeq& theData) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + + Handle(TColStd_HSequenceOfInteger) aColumn = new TColStd_HSequenceOfInteger; + for (int i = 0; i < theData.length(); i++) aColumn->Append(theData[i]); + try { + aTable->SetColumnData(theColumn, aColumn); + } + catch(Standard_Failure) { + throw SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength(); + } +} + +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetColumn(CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) +{ + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); + + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; + Handle(TColStd_HSequenceOfInteger) aColumn = aTable->GetColumnData(theColumn); + CorbaSeq->length(aColumn->Length()); + for (int i = 0; i < aColumn->Length(); i++) { + CorbaSeq[i] = aColumn->Value(i + 1); + } + return CorbaSeq._retn(); +} + +void SALOMEDS_AttributeTableOfInteger_i::PutValue(CORBA::Long theValue, CORBA::Long theRow, CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + + try { + aTable->PutValue(theValue, theRow, theColumn); + } + catch(Standard_Failure) { + throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); + } +} + +CORBA::Boolean SALOMEDS_AttributeTableOfInteger_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) { + return Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr)->HasValue(theRow, theColumn); +} + +CORBA::Long SALOMEDS_AttributeTableOfInteger_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex) +{ + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); + + CORBA::Long aValue; + try { + aValue = aTable->GetValue(theRow, theColumn); + } + catch(Standard_Failure) { + throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); + } + return aValue; +} + +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfInteger_i::GetRowSetIndices(CORBA::Long theRow) +{ + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + + if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfInteger::IncorrectIndex(); + + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; + Handle(TColStd_HSequenceOfInteger) aSeq = aTable->GetSetRowIndices(theRow); + CorbaSeq->length(aSeq->Length()); + for (int i = 0; i < aSeq->Length(); i++) { + CorbaSeq[i] = aSeq->Value(i + 1); + } + return CorbaSeq._retn(); +} + + +void SALOMEDS_AttributeTableOfInteger_i::SetNbColumns(CORBA::Long theNbColumns) +{ + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + aTable->SetNbColumns(theNbColumns); +} + +bool SALOMEDS_AttributeTableOfInteger_i::ReadFromFile(const SALOMEDS::TMPFile& theStream) +{ + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + + istrstream aStream((char*)&theStream[0], theStream.length()); + return aTable->RestoreFromString(aStream); +} + +SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfInteger_i::SaveToFile() +{ + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr); + + ostrstream ostr; + string aString; + aTable->ConvertToString(ostr); + + aString = ostr.rdbuf()->str(); + + char* aBuffer = (char*)CORBA::string_dup(aString.c_str()); + int aBufferSize = strlen((char*)aBuffer); + + CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer; + + SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1); + + return aStreamFile._retn(); +} + diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx new file mode 100644 index 000000000..ff4ceba2d --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx @@ -0,0 +1,78 @@ +// File : SALOMEDS_AttributeTableOfInteger_i.hxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + + +#ifndef SALOMEDS_AttributeTableOfInteger_i_HeaderFile +#define SALOMEDS_AttributeTableOfInteger_i_HeaderFile + +// IDL headers +#include "SALOMEDS_TableOfIntegerAttribute.hxx" +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeTableOfInteger_i: public virtual POA_SALOMEDS::AttributeTableOfInteger, + public virtual SALOMEDS_GenericAttribute_i { + +public: + + SALOMEDS_AttributeTableOfInteger_i(const Handle(SALOMEDS_TableOfIntegerAttribute)& theTableOfIntegerAttr, + CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theTableOfIntegerAttr; + }; + ~SALOMEDS_AttributeTableOfInteger_i() {}; + + virtual void SetTitle(const char* theTitle); + virtual char* GetTitle(); + virtual void SetRowTitle(CORBA::Long theIndex, const char* theTitle) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex); + virtual void SetRowTitles(const SALOMEDS::StringSeq& theTitles) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength); + virtual SALOMEDS::StringSeq* GetRowTitles(); + virtual void SetColumnTitle(CORBA::Long theIndex, const char* theTitle) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex); + virtual void SetColumnTitles(const SALOMEDS::StringSeq& theTitles) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength); + virtual SALOMEDS::StringSeq* GetColumnTitles(); + + virtual void SetRowUnit(CORBA::Long theIndex, const char* theUnit) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex); + virtual void SetRowUnits(const SALOMEDS::StringSeq& theUnits) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength); + virtual SALOMEDS::StringSeq* GetRowUnits(); + + virtual CORBA::Long GetNbRows(); + virtual CORBA::Long GetNbColumns(); + virtual void AddRow(const SALOMEDS::LongSeq& theData) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength); + virtual void SetRow(CORBA::Long theRow, const SALOMEDS::LongSeq& theData) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex); + virtual SALOMEDS::LongSeq* GetRow(CORBA::Long theRow) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex); + virtual void AddColumn(const SALOMEDS::LongSeq& theData) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength); + virtual void SetColumn(CORBA::Long theColumn, const SALOMEDS::LongSeq& theData) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectArgumentLength, SALOMEDS::AttributeTableOfInteger::IncorrectIndex); + virtual SALOMEDS::LongSeq* GetColumn(CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex); + virtual void PutValue(CORBA::Long theValue, CORBA::Long theRow, CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex); + virtual CORBA::Boolean HasValue(CORBA::Long theRow, CORBA::Long theColumn); + virtual CORBA::Long GetValue(CORBA::Long theRow, CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfInteger::IncorrectIndex); + + virtual SALOMEDS::LongSeq* GetRowSetIndices(CORBA::Long theRow); + virtual void SetNbColumns(CORBA::Long theNbColumns); + + virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream); + virtual SALOMEDS::TMPFile* SaveToFile(); +}; + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx new file mode 100644 index 000000000..b44309dde --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx @@ -0,0 +1,320 @@ +using namespace std; +// File : SALOMEDS_AttributeTableOfReal_i.cxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + + +#include "SALOMEDS_AttributeTableOfReal_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include +#include +#include + +#include +#include + +#define SEPARATOR '\1' + +static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString) +{ + TCollection_ExtendedString aString(theString); + int aPos = aString.Search(SEPARATOR); + if(aPos <= 0 || aPos == aString.Length() ) return TCollection_ExtendedString(); + return aString.Split(aPos); +} + +static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString) +{ + TCollection_ExtendedString aString(theString); + int aPos = aString.Search(SEPARATOR); + if(aPos < 1) return aString; + if(aPos == 1) return TCollection_ExtendedString(); + aString.Split(aPos-1); + return aString; +} + + + +void SALOMEDS_AttributeTableOfReal_i::SetTitle(const char* theTitle) { + CheckLocked(); + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + CORBA::String_var aStr = CORBA::string_dup(theTitle); + aTable->SetTitle(TCollection_ExtendedString(aStr)); +} + +char* SALOMEDS_AttributeTableOfReal_i::GetTitle() { + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(aTable->GetTitle()).ToCString()); + return c_s._retn(); +} + +void SALOMEDS_AttributeTableOfReal_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle) + throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); + CORBA::String_var aStr = CORBA::string_dup(theTitle); + TCollection_ExtendedString aTitle(aStr); + TCollection_ExtendedString aUnit = getUnit(aTable->GetRowTitle(theIndex)); + if(aUnit.Length() > 0) { + aTitle += SEPARATOR; + aTitle += aUnit; + } + + aTable->SetRowTitle(theIndex, aTitle); +} + +void SALOMEDS_AttributeTableOfReal_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles) + throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength(); + for (int i = 0; i < theTitles.length(); i++) { + SetRowTitle(i + 1, theTitles[i]); + } +} + +SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowTitles() { + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq; + aTitles->length(aTable->GetNbRows()); + for(int i = 0; i < aTitles->length(); i++) + aTitles[i] = CORBA::string_dup(TCollection_AsciiString(getTitle(aTable->GetRowTitle(i + 1))).ToCString()); + return aTitles._retn(); +} + +void SALOMEDS_AttributeTableOfReal_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle) + throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); + CORBA::String_var aStr = CORBA::string_dup(theTitle); + aTable->SetColumnTitle(theIndex, TCollection_ExtendedString(aStr)); +} + +void SALOMEDS_AttributeTableOfReal_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles) + throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength(); + for (int i = 0; i < theTitles.length(); i++) { + SetColumnTitle(i + 1, theTitles[i]); + } +} + +SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetColumnTitles() { + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq; + aTitles->length(aTable->GetNbColumns()); + for(int i = 0; i < aTitles->length(); i++) + aTitles[i] = CORBA::string_dup(TCollection_AsciiString(aTable->GetColumnTitle(i + 1)).ToCString()); + return aTitles._retn(); +} + +//Units support +void SALOMEDS_AttributeTableOfReal_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit) + throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); + CORBA::String_var aStr = CORBA::string_dup(theUnit); + TCollection_ExtendedString aTitle = getTitle(aTable->GetRowTitle(theIndex)); + TCollection_ExtendedString aUnit(aStr); + aTitle += SEPARATOR; + aTitle += aUnit; + aTable->SetRowTitle(theIndex, aTitle); +} + +void SALOMEDS_AttributeTableOfReal_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits) + throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength(); + for (int i = 0; i < theUnits.length(); i++) { + SetRowUnit(i + 1, theUnits[i]); + } +} + +SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfReal_i::GetRowUnits() { + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + SALOMEDS::StringSeq_var aUnits = new SALOMEDS::StringSeq; + aUnits->length(aTable->GetNbRows()); + for(int i = 0; i < aUnits->length(); i++) + aUnits[i] = CORBA::string_dup(TCollection_AsciiString(getUnit(aTable->GetRowTitle(i + 1))).ToCString()); + return aUnits._retn(); +} + + +CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbRows() { + return Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr)->GetNbRows(); +} +CORBA::Long SALOMEDS_AttributeTableOfReal_i::GetNbColumns() { + return Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr)->GetNbColumns(); +} + +void SALOMEDS_AttributeTableOfReal_i::AddRow(const SALOMEDS::DoubleSeq& theData) + throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + + Handle(TColStd_HSequenceOfReal) aRow = new TColStd_HSequenceOfReal; + for (int i = 0; i < theData.length(); i++) aRow->Append(theData[i]); + aTable->SetRowData(aTable->GetNbRows() + 1, aRow); +} + +void SALOMEDS_AttributeTableOfReal_i::SetRow(CORBA::Long theRow, const SALOMEDS::DoubleSeq& theData) + throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + + Handle(TColStd_HSequenceOfReal) aRow = new TColStd_HSequenceOfReal; + for (int i = 0; i < theData.length(); i++) aRow->Append(theData[i]); + aTable->SetRowData(theRow, aRow); +} + +SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetRow(CORBA::Long theRow) + throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) +{ + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); + + SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq; + Handle(TColStd_HSequenceOfReal) aRow = aTable->GetRowData(theRow); + CorbaSeq->length(aRow->Length()); + for (int i = 0; i < aRow->Length(); i++) { + CorbaSeq[i] = aRow->Value(i + 1); + } + return CorbaSeq._retn(); +} + +void SALOMEDS_AttributeTableOfReal_i::AddColumn(const SALOMEDS::DoubleSeq& theData) + throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + + Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal; + for (int i = 0; i < theData.length(); i++) aColumn->Append(theData[i]); + aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn); +} + +void SALOMEDS_AttributeTableOfReal_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::DoubleSeq& theData) + throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + + Handle(TColStd_HSequenceOfReal) aColumn = new TColStd_HSequenceOfReal; + for (int i = 0; i < theData.length(); i++) aColumn->Append(theData[i]); + aTable->SetColumnData(theColumn, aColumn); +} + +SALOMEDS::DoubleSeq* SALOMEDS_AttributeTableOfReal_i::GetColumn(CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) +{ + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); + + SALOMEDS::DoubleSeq_var CorbaSeq = new SALOMEDS::DoubleSeq; + Handle(TColStd_HSequenceOfReal) aColumn = aTable->GetColumnData(theColumn); + CorbaSeq->length(aColumn->Length()); + for (int i = 0; i < aColumn->Length(); i++) { + CorbaSeq[i] = aColumn->Value(i + 1); + } + return CorbaSeq._retn(); +} + +void SALOMEDS_AttributeTableOfReal_i::PutValue(CORBA::Double theValue, CORBA::Long theRow, CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + + aTable->PutValue(theValue, theRow, theColumn); +} + +CORBA::Boolean SALOMEDS_AttributeTableOfReal_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) { + return Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr)->HasValue(theRow, theColumn); +} + +CORBA::Double SALOMEDS_AttributeTableOfReal_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex) +{ + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); + + CORBA::Double aValue; + + try { + aValue = aTable->GetValue(theRow, theColumn); + } + catch(Standard_Failure) { + throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); + } + + return aValue; +} + + +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfReal_i::GetRowSetIndices(CORBA::Long theRow) +{ + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + + if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfReal::IncorrectIndex(); + + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; + Handle(TColStd_HSequenceOfInteger) aSeq = aTable->GetSetRowIndices(theRow); + CorbaSeq->length(aSeq->Length()); + for (int i = 0; i < aSeq->Length(); i++) { + CorbaSeq[i] = aSeq->Value(i + 1); + } + return CorbaSeq._retn(); +} + + +void SALOMEDS_AttributeTableOfReal_i::SetNbColumns(CORBA::Long theNbColumns) +{ + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + aTable->SetNbColumns(theNbColumns); +} + +bool SALOMEDS_AttributeTableOfReal_i::ReadFromFile(const SALOMEDS::TMPFile& theStream) +{ + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + + istrstream aStream((char*)&theStream[0], theStream.length()); + return aTable->RestoreFromString(aStream); +} + +SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfReal_i::SaveToFile() +{ + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr); + + ostrstream ostr; + string aString; + aTable->ConvertToString(ostr); + + aString = ostr.rdbuf()->str(); + + char* aBuffer = (char*)CORBA::string_dup(aString.c_str()); + int aBufferSize = strlen((char*)aBuffer); + + CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer; + + SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1); + + return aStreamFile._retn(); +} + diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx new file mode 100644 index 000000000..6f90f0552 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx @@ -0,0 +1,78 @@ +// File : SALOMEDS_AttributeTableOfReal_i.hxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + + +#ifndef SALOMEDS_AttributeTableOfReal_i_HeaderFile +#define SALOMEDS_AttributeTableOfReal_i_HeaderFile + +// IDL headers +#include "SALOMEDS_TableOfRealAttribute.hxx" +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeTableOfReal_i: public virtual POA_SALOMEDS::AttributeTableOfReal, + public virtual SALOMEDS_GenericAttribute_i { + +public: + + SALOMEDS_AttributeTableOfReal_i(const Handle(SALOMEDS_TableOfRealAttribute)& theTableOfRealAttr, + CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theTableOfRealAttr; + }; + ~SALOMEDS_AttributeTableOfReal_i() {}; + + virtual void SetTitle(const char* theTitle); + virtual char* GetTitle(); + virtual void SetRowTitle(CORBA::Long theIndex, const char* theTitle) + throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex); + virtual void SetRowTitles(const SALOMEDS::StringSeq& theTitles) + throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength); + virtual SALOMEDS::StringSeq* GetRowTitles(); + virtual void SetColumnTitle(CORBA::Long theIndex, const char* theTitle) + throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex); + virtual void SetColumnTitles(const SALOMEDS::StringSeq& theTitles) + throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength); + virtual SALOMEDS::StringSeq* GetColumnTitles(); + + virtual void SetRowUnit(CORBA::Long theIndex, const char* theUnit) + throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex); + virtual void SetRowUnits(const SALOMEDS::StringSeq& theUnits) + throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength); + virtual SALOMEDS::StringSeq* GetRowUnits(); + + virtual CORBA::Long GetNbRows(); + virtual CORBA::Long GetNbColumns(); + virtual void AddRow(const SALOMEDS::DoubleSeq& theData) + throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength); + virtual void SetRow(CORBA::Long theRow, const SALOMEDS::DoubleSeq& theData) + throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex); + virtual SALOMEDS::DoubleSeq* GetRow(CORBA::Long theRow) + throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex); + virtual void AddColumn(const SALOMEDS::DoubleSeq& theData) + throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength); + virtual void SetColumn(CORBA::Long theColumn, const SALOMEDS::DoubleSeq& theData) + throw (SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectIndex); + virtual SALOMEDS::DoubleSeq* GetColumn(CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex); + virtual void PutValue(CORBA::Double theValue, CORBA::Long theRow, CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex); + virtual CORBA::Boolean HasValue(CORBA::Long theRow, CORBA::Long theColumn); + virtual CORBA::Double GetValue(CORBA::Long theRow, CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex); + + virtual SALOMEDS::LongSeq* GetRowSetIndices(CORBA::Long theRow); + virtual void SetNbColumns(CORBA::Long theNbColumns); + + virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream); + virtual SALOMEDS::TMPFile* SaveToFile(); +}; + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx new file mode 100644 index 000000000..6b8a1f4f7 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx @@ -0,0 +1,328 @@ +using namespace std; +// File : SALOMEDS_AttributeTableOfString_i.cxx +// Created : Mon Apr 7 10:13:30 2003 +// Author : Sergey Ruin +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + + +#include +#include + +#include "SALOMEDS_AttributeTableOfString_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include + +#include +#include + +#include +#include + +#define SEPARATOR '\1' + +static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString) +{ + TCollection_ExtendedString aString(theString); + int aPos = aString.Search(SEPARATOR); + if(aPos <= 0 || aPos == aString.Length() ) return TCollection_ExtendedString(); + return aString.Split(aPos); +} + +static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString) +{ + TCollection_ExtendedString aString(theString); + int aPos = aString.Search(SEPARATOR); + if(aPos < 1) return aString; + if(aPos == 1) return TCollection_ExtendedString(); + aString.Split(aPos-1); + return aString; +} + + + +void SALOMEDS_AttributeTableOfString_i::SetTitle(const char* theTitle) { + CheckLocked(); + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + CORBA::String_var aStr = CORBA::string_dup(theTitle); + aTable->SetTitle(TCollection_ExtendedString(aStr)); +} + +char* SALOMEDS_AttributeTableOfString_i::GetTitle() { + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + CORBA::String_var c_s = CORBA::string_dup(TCollection_AsciiString(aTable->GetTitle()).ToCString()); + return c_s._retn(); +} + +void SALOMEDS_AttributeTableOfString_i::SetRowTitle(CORBA::Long theIndex, const char* theTitle) + throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); + CORBA::String_var aStr = CORBA::string_dup(theTitle); + TCollection_ExtendedString aTitle(aStr); + TCollection_ExtendedString aUnit = getUnit(aTable->GetRowTitle(theIndex)); + if(aUnit.Length() > 0) { + aTitle += SEPARATOR; + aTitle += aUnit; + } + + aTable->SetRowTitle(theIndex, aTitle); +} + +void SALOMEDS_AttributeTableOfString_i::SetRowTitles(const SALOMEDS::StringSeq& theTitles) + throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + if (theTitles.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength(); + for (int i = 0; i < theTitles.length(); i++) { + SetRowTitle(i + 1, CORBA::string_dup(theTitles[i])); + } +} + +SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRowTitles() { + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq; + aTitles->length(aTable->GetNbRows()); + for(int i = 0; i < aTitles->length(); i++) + aTitles[i] = CORBA::string_dup(TCollection_AsciiString(getTitle(aTable->GetRowTitle(i + 1))).ToCString()); + return aTitles._retn(); +} + +void SALOMEDS_AttributeTableOfString_i::SetColumnTitle(CORBA::Long theIndex, const char* theTitle) + throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + if (theIndex <= 0 || theIndex > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); + CORBA::String_var aStr = CORBA::string_dup(theTitle); + aTable->SetColumnTitle(theIndex, TCollection_ExtendedString(aStr)); +} + +void SALOMEDS_AttributeTableOfString_i::SetColumnTitles(const SALOMEDS::StringSeq& theTitles) + throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + if (theTitles.length() != aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength(); + for (int i = 0; i < theTitles.length(); i++) { + SetColumnTitle(i + 1, CORBA::string_dup(theTitles[i])); + } +} + +SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumnTitles() { + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + SALOMEDS::StringSeq_var aTitles = new SALOMEDS::StringSeq; + aTitles->length(aTable->GetNbColumns()); + for(int i = 0; i < aTitles->length(); i++) + aTitles[i] = CORBA::string_dup(TCollection_AsciiString(aTable->GetColumnTitle(i + 1)).ToCString()); + return aTitles._retn(); +} + +//Units support +void SALOMEDS_AttributeTableOfString_i::SetRowUnit(CORBA::Long theIndex, const char* theUnit) + throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + if (theIndex <= 0 || theIndex > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); + CORBA::String_var aStr = CORBA::string_dup(theUnit); + TCollection_ExtendedString aTitle = getTitle(aTable->GetRowTitle(theIndex)); + TCollection_ExtendedString aUnit(aStr); + aTitle += SEPARATOR; + aTitle += aUnit; + aTable->SetRowTitle(theIndex, aTitle); +} + +void SALOMEDS_AttributeTableOfString_i::SetRowUnits(const SALOMEDS::StringSeq& theUnits) + throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + if (theUnits.length() != aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectArgumentLength(); + for (int i = 0; i < theUnits.length(); i++) { + SetRowUnit(i + 1, CORBA::string_dup(theUnits[i])); + } +} + +SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRowUnits() { + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + SALOMEDS::StringSeq_var aUnits = new SALOMEDS::StringSeq; + aUnits->length(aTable->GetNbRows()); + for(int i = 0; i < aUnits->length(); i++) + aUnits[i] = CORBA::string_dup(TCollection_AsciiString(getUnit(aTable->GetRowTitle(i + 1))).ToCString()); + return aUnits._retn(); +} + + +CORBA::Long SALOMEDS_AttributeTableOfString_i::GetNbRows() { + return Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr)->GetNbRows(); +} +CORBA::Long SALOMEDS_AttributeTableOfString_i::GetNbColumns() { + return Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr)->GetNbColumns(); +} + +void SALOMEDS_AttributeTableOfString_i::AddRow(const SALOMEDS::StringSeq& theData) + throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + + Handle(TColStd_HSequenceOfExtendedString) aRow = new TColStd_HSequenceOfExtendedString; + for (int i = 0; i < theData.length(); i++) aRow->Append(TCollection_AsciiString(CORBA::string_dup(theData[i]))); + aTable->SetRowData(aTable->GetNbRows() + 1, aRow); +} + +void SALOMEDS_AttributeTableOfString_i::SetRow(CORBA::Long theRow, const SALOMEDS::StringSeq& theData) + throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + + Handle(TColStd_HSequenceOfExtendedString) aRow = new TColStd_HSequenceOfExtendedString; + for (int i = 0; i < theData.length(); i++) aRow->Append(TCollection_AsciiString(CORBA::string_dup(theData[i]))); + aTable->SetRowData(theRow, aRow); +} + +SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetRow(CORBA::Long theRow) + throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) +{ + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + if (theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); + + SALOMEDS::StringSeq_var CorbaSeq = new SALOMEDS::StringSeq; + Handle(TColStd_HSequenceOfExtendedString) aRow = aTable->GetRowData(theRow); + CorbaSeq->length(aRow->Length()); + for (int i = 0; i < aRow->Length(); i++) { + CorbaSeq[i] = CORBA::string_dup((TCollection_AsciiString(aRow->Value(i + 1))).ToCString()); + } + return CorbaSeq._retn(); +} + +void SALOMEDS_AttributeTableOfString_i::AddColumn(const SALOMEDS::StringSeq& theData) + throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + + Handle(TColStd_HSequenceOfExtendedString) aColumn = new TColStd_HSequenceOfExtendedString; + for (int i = 0; i < theData.length(); i++) aColumn->Append(TCollection_AsciiString(CORBA::string_dup(theData[i]))); + aTable->SetColumnData(aTable->GetNbColumns() + 1, aColumn); +} + +void SALOMEDS_AttributeTableOfString_i::SetColumn(CORBA::Long theColumn, const SALOMEDS::StringSeq& theData) + throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + + Handle(TColStd_HSequenceOfExtendedString) aColumn = new TColStd_HSequenceOfExtendedString; + for (int i = 0; i < theData.length(); i++) aColumn->Append(TCollection_AsciiString(CORBA::string_dup(theData[i]))); + aTable->SetColumnData(theColumn, aColumn); +} + +SALOMEDS::StringSeq* SALOMEDS_AttributeTableOfString_i::GetColumn(CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) +{ + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + if (theColumn <= 0 || theColumn > aTable->GetNbColumns()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); + + SALOMEDS::StringSeq_var CorbaSeq = new SALOMEDS::StringSeq; + Handle(TColStd_HSequenceOfExtendedString) aColumn = aTable->GetColumnData(theColumn); + CorbaSeq->length(aColumn->Length()); + for (int i = 0; i < aColumn->Length(); i++) { + CorbaSeq[i] = CORBA::string_dup((TCollection_AsciiString(aColumn->Value(i + 1))).ToCString()); + } + return CorbaSeq._retn(); +} + +void SALOMEDS_AttributeTableOfString_i::PutValue(const char* theValue, CORBA::Long theRow, CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) +{ + CheckLocked(); + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + char* aValue = CORBA::string_dup(theValue); + + aTable->PutValue(aValue, theRow, theColumn); +} + +CORBA::Boolean SALOMEDS_AttributeTableOfString_i::HasValue(CORBA::Long theRow, CORBA::Long theColumn) { + return Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr)->HasValue(theRow, theColumn); +} + +char* SALOMEDS_AttributeTableOfString_i::GetValue(CORBA::Long theRow, CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfString::IncorrectIndex) +{ + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + if (theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); + + TCollection_AsciiString aValue; + + try { + aValue = aTable->GetValue(theRow, theColumn); + } + catch(Standard_Failure) { + throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); + } + + return CORBA::string_dup(aValue.ToCString()); +} + + +SALOMEDS::LongSeq* SALOMEDS_AttributeTableOfString_i::GetRowSetIndices(CORBA::Long theRow) +{ + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + + if(theRow <= 0 || theRow > aTable->GetNbRows()) throw SALOMEDS::AttributeTableOfString::IncorrectIndex(); + + SALOMEDS::LongSeq_var CorbaSeq = new SALOMEDS::LongSeq; + Handle(TColStd_HSequenceOfInteger) aSeq = aTable->GetSetRowIndices(theRow); + CorbaSeq->length(aSeq->Length()); + for (int i = 0; i < aSeq->Length(); i++) { + CorbaSeq[i] = aSeq->Value(i + 1); + } + return CorbaSeq._retn(); +} + + +void SALOMEDS_AttributeTableOfString_i::SetNbColumns(CORBA::Long theNbColumns) +{ + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + aTable->SetNbColumns(theNbColumns); +} + +bool SALOMEDS_AttributeTableOfString_i::ReadFromFile(const SALOMEDS::TMPFile& theStream) +{ + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + + istrstream aStream((char*)&theStream[0], theStream.length()); + return aTable->RestoreFromString(aStream); +} + +SALOMEDS::TMPFile* SALOMEDS_AttributeTableOfString_i::SaveToFile() +{ + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr); + + ostrstream ostr; + string aString; + aTable->ConvertToString(ostr); + + aString = ostr.rdbuf()->str(); + + cout << " ######## STRLEN " << aString.size() << endl; + + char* aBuffer = (char*)CORBA::string_dup(aString.c_str()); + int aBufferSize = strlen((char*)aBuffer); + + cout << " ####### STRLEN " << aBufferSize << endl; + + CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer; + + SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1); + + return aStreamFile._retn(); +} + diff --git a/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx new file mode 100644 index 000000000..74f1713b3 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx @@ -0,0 +1,77 @@ +// File : SALOMEDS_AttributeTableOfString_i.hxx +// Created : Mon Apr 7 10:13:30 2003 +// Author : Sergey Ruin +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + + +#ifndef SALOMEDS_AttributeTableOfString_i_HeaderFile +#define SALOMEDS_AttributeTableOfString_i_HeaderFile + +// IDL headers +#include "SALOMEDS_TableOfStringAttribute.hxx" +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeTableOfString_i: public virtual POA_SALOMEDS::AttributeTableOfString, + public virtual SALOMEDS_GenericAttribute_i { + +public: + + SALOMEDS_AttributeTableOfString_i(const Handle(SALOMEDS_TableOfStringAttribute)& theTableOfStringAttr, + CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theTableOfStringAttr; + }; + ~SALOMEDS_AttributeTableOfString_i() {}; + + virtual void SetTitle(const char* theTitle); + virtual char* GetTitle(); + virtual void SetRowTitle(CORBA::Long theIndex, const char* theTitle) + throw (SALOMEDS::AttributeTableOfString::IncorrectIndex); + virtual void SetRowTitles(const SALOMEDS::StringSeq& theTitles) + throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength); + virtual SALOMEDS::StringSeq* GetRowTitles(); + virtual void SetColumnTitle(CORBA::Long theIndex, const char* theTitle) + throw (SALOMEDS::AttributeTableOfString::IncorrectIndex); + virtual void SetColumnTitles(const SALOMEDS::StringSeq& theTitles) + throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength); + virtual SALOMEDS::StringSeq* GetColumnTitles(); + + virtual void SetRowUnit(CORBA::Long theIndex, const char* theUnit) + throw (SALOMEDS::AttributeTableOfString::IncorrectIndex); + virtual void SetRowUnits(const SALOMEDS::StringSeq& theUnits) + throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength); + virtual SALOMEDS::StringSeq* GetRowUnits(); + + virtual CORBA::Long GetNbRows(); + virtual CORBA::Long GetNbColumns(); + virtual void AddRow(const SALOMEDS::StringSeq& theData) + throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength); + virtual void SetRow(CORBA::Long theRow, const SALOMEDS::StringSeq& theData) + throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex); + virtual SALOMEDS::StringSeq* GetRow(CORBA::Long theRow) + throw (SALOMEDS::AttributeTableOfString::IncorrectIndex); + virtual void AddColumn(const SALOMEDS::StringSeq& theData) + throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength); + virtual void SetColumn(CORBA::Long theColumn, const SALOMEDS::StringSeq& theData) + throw (SALOMEDS::AttributeTableOfString::IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectIndex); + virtual SALOMEDS::StringSeq* GetColumn(CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfString::IncorrectIndex); + virtual void PutValue(const char* theValue, CORBA::Long theRow, CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfString::IncorrectIndex); + virtual CORBA::Boolean HasValue(CORBA::Long theRow, CORBA::Long theColumn); + virtual char* GetValue(CORBA::Long theRow, CORBA::Long theColumn) + throw (SALOMEDS::AttributeTableOfString::IncorrectIndex); + + virtual SALOMEDS::LongSeq* GetRowSetIndices(CORBA::Long theRow); + virtual void SetNbColumns(CORBA::Long theNbColumns); + + virtual bool ReadFromFile(const SALOMEDS::TMPFile& theStream); + virtual SALOMEDS::TMPFile* SaveToFile(); +}; + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx new file mode 100644 index 000000000..f2a89990d --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx @@ -0,0 +1,41 @@ +using namespace std; +// File : SALOMEDS_AttributeTarget_i.cxx +// Created : Fri Aug 16 10:20:05 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#include "SALOMEDS_AttributeTarget_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include +#include + +void SALOMEDS_AttributeTarget_i::Add(SALOMEDS::SObject_ptr anObject) { + TDF_Label aLabel; + TDF_Tool::Label(_myAttr->Label().Data(),anObject->GetID(),aLabel,1); + (Handle(SALOMEDS_TargetAttribute)::DownCast(_myAttr))->Append(aLabel); +} + +SALOMEDS::Study::ListOfSObject* SALOMEDS_AttributeTarget_i::Get() { + TDF_LabelList aLList; + SALOMEDS::Study::ListOfSObject_var aSList = new SALOMEDS::Study::ListOfSObject; + (Handle(SALOMEDS_TargetAttribute)::DownCast(_myAttr))->Get(aLList); + aSList->length(aLList.Extent()); + TDF_ListIteratorOfLabelList anIter(aLList); + int index; + for(index=0;anIter.More();anIter.Next(),index++) { + SALOMEDS_SObject_i* anSO = new SALOMEDS_SObject_i(anIter.Value(),_myOrb); + aSList[index] = anSO->_this(); + } + return aSList._retn(); +} + +void SALOMEDS_AttributeTarget_i::Remove(SALOMEDS::SObject_ptr anObject) { + TDF_Label aLabel; + TDF_Tool::Label(_myAttr->Label().Data(),anObject->GetID(),aLabel,1); + (Handle(SALOMEDS_TargetAttribute)::DownCast(_myAttr))->Remove(aLabel); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTarget_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTarget_i.hxx new file mode 100644 index 000000000..9a9f0d476 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeTarget_i.hxx @@ -0,0 +1,39 @@ +// File: SALOMEDS_AttributeTarget_i.hxx +// Created : Fri Aug 16 10:20:05 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#ifndef SALOMEDS_AttributeTarget_i_HeaderFile +#define SALOMEDS_AttributeTarget_i_HeaderFile + +// IDL headers + +#include "SALOMEDS_TargetAttribute.hxx" +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeTarget_i: public virtual POA_SALOMEDS::AttributeTarget, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeTarget_i(const Handle(SALOMEDS_TargetAttribute)& theIntAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theIntAttr; + }; + ~SALOMEDS_AttributeTarget_i() {}; + + virtual void Add(SALOMEDS::SObject_ptr anObject) ; + virtual SALOMEDS::Study::ListOfSObject* Get(); + virtual void Remove(SALOMEDS::SObject_ptr anObject); +}; + + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx new file mode 100644 index 000000000..247669f6b --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx @@ -0,0 +1,39 @@ +using namespace std; +// File : SALOMEDS_AttributeTextColor_i.cxx +// Created : Fri Jul 05 14:38:10 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributeTextColor_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include + +SALOMEDS::Color SALOMEDS_AttributeTextColor_i::TextColor() { + SALOMEDS::Color TextColor; + Handle(TColStd_HArray1OfReal) anArray = Handle(SALOMEDS_TextColorAttribute)::DownCast(_myAttr)->Array(); + if (anArray.IsNull() || anArray->Length()!=3) { + TextColor.R = 0; + TextColor.G = 0; + TextColor.B = 0; + } + else { + TextColor.R = anArray->Value(1); + TextColor.G = anArray->Value(2); + TextColor.B = anArray->Value(3); + } + return TextColor; +} + +void SALOMEDS_AttributeTextColor_i::SetTextColor(const SALOMEDS::Color& value) { + CheckLocked(); + Handle(TColStd_HArray1OfReal) anArray = new TColStd_HArray1OfReal(1,3); + anArray->SetValue(1, value.R); + anArray->SetValue(2, value.G); + anArray->SetValue(3, value.B); + Handle(SALOMEDS_TextColorAttribute)::DownCast(_myAttr)->ChangeArray(anArray); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.hxx new file mode 100644 index 000000000..536058e45 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeTextColor_i.hxx @@ -0,0 +1,36 @@ +// File: SALOMEDS_AttributeTextColor_i.hxx +// Created: Fri Jul 5 10:21:15 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#ifndef SALOMEDS_AttributeTextColor_i_HeaderFile +#define SALOMEDS_AttributeTextColor_i_HeaderFile + +// IDL headers +#include "SALOMEDS_TextColorAttribute.hxx" +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeTextColor_i: public virtual POA_SALOMEDS::AttributeTextColor, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeTextColor_i(const Handle(SALOMEDS_TextColorAttribute)& theTextColorAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theTextColorAttr; + }; + ~SALOMEDS_AttributeTextColor_i() {}; + + SALOMEDS::Color TextColor(); + void SetTextColor(const SALOMEDS::Color& value); +}; + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx new file mode 100644 index 000000000..ea12dac63 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx @@ -0,0 +1,39 @@ +using namespace std; +// File : SALOMEDS_AttributeTextHighlightColor_i.cxx +// Created : Fri Jul 05 14:38:10 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_AttributeTextHighlightColor_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include + +SALOMEDS::Color SALOMEDS_AttributeTextHighlightColor_i::TextHighlightColor() { + SALOMEDS::Color TextHighlightColor; + Handle(TColStd_HArray1OfReal) anArray = Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(_myAttr)->Array(); + if (anArray.IsNull() || anArray->Length()!=3) { + TextHighlightColor.R = 0; + TextHighlightColor.G = 0; + TextHighlightColor.B = 0; + } + else { + TextHighlightColor.R = anArray->Value(1); + TextHighlightColor.G = anArray->Value(2); + TextHighlightColor.B = anArray->Value(3); + } + return TextHighlightColor; +} + +void SALOMEDS_AttributeTextHighlightColor_i::SetTextHighlightColor(const SALOMEDS::Color& value) { + CheckLocked(); + Handle(TColStd_HArray1OfReal) anArray = new TColStd_HArray1OfReal(1,3); + anArray->SetValue(1, value.R); + anArray->SetValue(2, value.G); + anArray->SetValue(3, value.B); + Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(_myAttr)->ChangeArray(anArray); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.hxx new file mode 100644 index 000000000..194fd0d98 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.hxx @@ -0,0 +1,36 @@ +// File: SALOMEDS_AttributeTextHighlightColor_i.hxx +// Created: Fri Jul 5 10:21:15 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#ifndef SALOMEDS_AttributeTextHighlightColor_i_HeaderFile +#define SALOMEDS_AttributeTextHighlightColor_i_HeaderFile + +// IDL headers +#include "SALOMEDS_TextHighlightColorAttribute.hxx" +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeTextHighlightColor_i: public virtual POA_SALOMEDS::AttributeTextHighlightColor, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeTextHighlightColor_i(const Handle(SALOMEDS_TextHighlightColorAttribute)& theTextHighlightColorAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theTextHighlightColorAttr; + }; + ~SALOMEDS_AttributeTextHighlightColor_i() {}; + + SALOMEDS::Color TextHighlightColor(); + void SetTextHighlightColor(const SALOMEDS::Color& value); +}; + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx new file mode 100644 index 000000000..cb589bb5d --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx @@ -0,0 +1,166 @@ +using namespace std; +// File : SALOMEDS_AttributeTreeNode_i.cxx +// Created : Fri Aug 02 14:25:13 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#include "SALOMEDS_AttributeTreeNode_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include "utilities.h" + +static Handle(TDataStd_TreeNode) GetNode(SALOMEDS::AttributeTreeNode_ptr value, + const Handle(TDataStd_TreeNode)& aNode) { + Handle(TDataStd_TreeNode) aResult = new TDataStd_TreeNode; + CORBA::String_var aString = CORBA::string_dup(value->Label()); + TDF_Label aLabel; + TDF_Tool::Label(aNode->Label().Data(), TCollection_AsciiString(aString), aLabel, 0); + if (aLabel.IsNull()) { + MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such label") + MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such label") + return aResult; + } + if (!aLabel.FindAttribute(aNode->ID(), aResult)) { + MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such attribute") + MESSAGE("SALOMEDS_AttributeTreeNode_i class: no such attribute") + } + return aResult; +} + +void SALOMEDS_AttributeTreeNode_i::SetFather(SALOMEDS::AttributeTreeNode_ptr value) { + CheckLocked(); + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + aNode->SetFather(GetNode(value, aNode)); +} + +CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFather() { + return Handle(TDataStd_TreeNode)::DownCast(_myAttr)->HasFather(); +} + +SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFather() { + SALOMEDS_AttributeTreeNode_i* aFather = new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(_myAttr)->Father(), _myOrb); + return aFather->POA_SALOMEDS::AttributeTreeNode::_this(); +} + +void SALOMEDS_AttributeTreeNode_i::SetPrevious(SALOMEDS::AttributeTreeNode_ptr value) { + CheckLocked(); + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + aNode->SetPrevious(GetNode(value, aNode)); +} + +CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasPrevious() { + return Handle(TDataStd_TreeNode)::DownCast(_myAttr)->HasPrevious(); +} + +SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetPrevious() { + SALOMEDS_AttributeTreeNode_i* aPrevious = new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(_myAttr)->Previous(), _myOrb); + return aPrevious->POA_SALOMEDS::AttributeTreeNode::_this(); +} + +void SALOMEDS_AttributeTreeNode_i::SetNext(SALOMEDS::AttributeTreeNode_ptr value) { + CheckLocked(); + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + aNode->SetNext(GetNode(value, aNode)); +} + +CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasNext() { + return Handle(TDataStd_TreeNode)::DownCast(_myAttr)->HasNext(); +} + +SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetNext() { + SALOMEDS_AttributeTreeNode_i* aNext = new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(_myAttr)->Next(), _myOrb); + return aNext->POA_SALOMEDS::AttributeTreeNode::_this(); +} + +void SALOMEDS_AttributeTreeNode_i::SetFirst(SALOMEDS::AttributeTreeNode_ptr value) { + CheckLocked(); + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + aNode->SetFirst(GetNode(value, aNode)); +} + +CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFirst() { + return Handle(TDataStd_TreeNode)::DownCast(_myAttr)->HasFirst(); +} + +SALOMEDS::AttributeTreeNode_ptr SALOMEDS_AttributeTreeNode_i::GetFirst() { + SALOMEDS_AttributeTreeNode_i* aFirst = new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(_myAttr)->First(), _myOrb); + return aFirst->POA_SALOMEDS::AttributeTreeNode::_this(); +} + +void SALOMEDS_AttributeTreeNode_i::SetTreeID(const char* value) { + CheckLocked(); + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + aNode->SetTreeID(Standard_GUID(aNode->ID())); +} + +char* SALOMEDS_AttributeTreeNode_i::GetTreeID() { + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + char aGUID[40]; + aNode->ID().ToCString(aGUID); + return CORBA::String_var(CORBA::string_dup(aGUID))._retn(); +} + +void SALOMEDS_AttributeTreeNode_i::Append(SALOMEDS::AttributeTreeNode_ptr value) { + CheckLocked(); + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + aNode->Append(GetNode(value, aNode)); +} + +void SALOMEDS_AttributeTreeNode_i::Prepend(SALOMEDS::AttributeTreeNode_ptr value) { + CheckLocked(); + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + aNode->Prepend(GetNode(value, aNode)); +} + +void SALOMEDS_AttributeTreeNode_i::InsertBefore(SALOMEDS::AttributeTreeNode_ptr value) { + CheckLocked(); + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + aNode->InsertBefore(GetNode(value, aNode)); +} + +void SALOMEDS_AttributeTreeNode_i::InsertAfter(SALOMEDS::AttributeTreeNode_ptr value) { + CheckLocked(); + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + aNode->InsertAfter(GetNode(value, aNode)); +} + +void SALOMEDS_AttributeTreeNode_i::Remove() { + CheckLocked(); + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + aNode->Remove(); +} + +CORBA::Long SALOMEDS_AttributeTreeNode_i::Depth() { + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + return aNode->Depth(); +} + +CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsRoot() { + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + return aNode->IsRoot(); +} + +CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsDescendant(SALOMEDS::AttributeTreeNode_ptr value) { + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + return aNode->IsDescendant(GetNode(value, aNode)); +} + +CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsFather(SALOMEDS::AttributeTreeNode_ptr value) { + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + return aNode->IsFather(GetNode(value, aNode)); +} + +CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsChild(SALOMEDS::AttributeTreeNode_ptr value) { + Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr); + return aNode->IsChild(GetNode(value, aNode)); +} + +char* SALOMEDS_AttributeTreeNode_i::Label() { + TCollection_AsciiString aLabelName; + TDF_Tool::Entry(_myAttr->Label(),aLabelName); + return CORBA::String_var(CORBA::string_dup(aLabelName.ToCString()))._retn(); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.hxx new file mode 100644 index 000000000..10b3ef378 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.hxx @@ -0,0 +1,58 @@ +// File: SALOMEDS_AttributeTreeNode_i.hxx +// Created: Fri Aug 2 10:21:01 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#ifndef SALOMEDS_AttributeTreeNode_i_HeaderFile +#define SALOMEDS_AttributeTreeNode_i_HeaderFile + +// IDL headers +#include +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeTreeNode_i: public virtual POA_SALOMEDS::AttributeTreeNode, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeTreeNode_i(const Handle(TDataStd_TreeNode)& theAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theAttr; + }; + ~SALOMEDS_AttributeTreeNode_i() {}; + + void SetFather(SALOMEDS::AttributeTreeNode_ptr value); + CORBA::Boolean HasFather(); + SALOMEDS::AttributeTreeNode_ptr GetFather(); + void SetPrevious(SALOMEDS::AttributeTreeNode_ptr value); + CORBA::Boolean HasPrevious(); + SALOMEDS::AttributeTreeNode_ptr GetPrevious(); + void SetNext(SALOMEDS::AttributeTreeNode_ptr value); + CORBA::Boolean HasNext(); + SALOMEDS::AttributeTreeNode_ptr GetNext(); + void SetFirst(SALOMEDS::AttributeTreeNode_ptr value); + CORBA::Boolean HasFirst(); + SALOMEDS::AttributeTreeNode_ptr GetFirst(); + void SetTreeID(const char* value); + char* GetTreeID(); + void Append(SALOMEDS::AttributeTreeNode_ptr value); + void Prepend(SALOMEDS::AttributeTreeNode_ptr value); + void InsertBefore(SALOMEDS::AttributeTreeNode_ptr value); + void InsertAfter(SALOMEDS::AttributeTreeNode_ptr value); + void Remove(); + CORBA::Long Depth(); + CORBA::Boolean IsRoot(); + CORBA::Boolean IsDescendant(SALOMEDS::AttributeTreeNode_ptr value); + CORBA::Boolean IsFather(SALOMEDS::AttributeTreeNode_ptr value); + CORBA::Boolean IsChild(SALOMEDS::AttributeTreeNode_ptr value); + char* Label(); +}; + +#endif diff --git a/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx b/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx new file mode 100644 index 000000000..8aa84f8ab --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx @@ -0,0 +1,27 @@ +using namespace std; +// File : SALOMEDS_AttributeName_i.cxx +// Created : Tue Aug 13 15:05:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + + +#include "SALOMEDS_AttributeUserID_i.hxx" +#include +#include "SALOMEDS_SObject_i.hxx" + +char* SALOMEDS_AttributeUserID_i::Value() { + char aGUID[40]; + Handle(TDataStd_UAttribute)::DownCast(_myAttr)->ID().ToCString(aGUID); + CORBA::String_var c_s = CORBA::string_dup(aGUID); + return c_s._retn(); +} + +void SALOMEDS_AttributeUserID_i::SetValue(const char* value) { + CheckLocked(); + CORBA::String_var Str = CORBA::string_dup(value); + Handle(TDataStd_UAttribute)::DownCast(_myAttr)->SetID(Standard_GUID(Standard_CString(Str))); +} diff --git a/src/SALOMEDS/SALOMEDS_AttributeUserID_i.hxx b/src/SALOMEDS/SALOMEDS_AttributeUserID_i.hxx new file mode 100644 index 000000000..853602953 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_AttributeUserID_i.hxx @@ -0,0 +1,43 @@ +// File: SALOMEDS_AttributeUserID_i.hxx +// Created : Tue Aug 13 15:05:03 2002 +// Author: Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#ifndef SALOMEDS_AttributeUserID_i_HeaderFile +#define SALOMEDS_AttributeUserID_i_HeaderFile + +// IDL headers + +#include +#include +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include "SALOMEDS_GenericAttribute_i.hxx" + +class SALOMEDS_AttributeUserID_i: public virtual POA_SALOMEDS::AttributeUserID, + public virtual SALOMEDS_GenericAttribute_i { +public: + + SALOMEDS_AttributeUserID_i(const Handle(TDataStd_UAttribute)& theUAttr, CORBA::ORB_ptr orb) + { + _myOrb = CORBA::ORB::_duplicate(orb); + _myAttr = theUAttr; + }; + ~SALOMEDS_AttributeUserID_i() {}; + + char* Value(); + void SetValue(const char* value); + + static const Standard_GUID& DefaultID() { + static Standard_GUID SALOMEDS_DefaultUserAttributeID ("FFFFFFFF-D9CD-11d6-945D-1050DA506788"); + return SALOMEDS_DefaultUserAttributeID; + } +}; + + + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_BasicAttributeFactory.cxx b/src/SALOMEDS/SALOMEDS_BasicAttributeFactory.cxx new file mode 100644 index 000000000..d110bfe4a --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_BasicAttributeFactory.cxx @@ -0,0 +1,34 @@ +using namespace std; +//============================================================================= +// File : SALOMEDS_BasicAttributeFactory.cxx +// Created : ven mai 31 13:45:47 CEST 2002 +// Author : Estelle Deville, CEA +// Project : SALOME +// Copyright : CEA 2002 +// $Header$ +//============================================================================= + +#include "SALOMEDS_BasicAttributeFactory.hxx" +#include "utilities.h" + +//============================================================================ +/*! Function : Create + * Purpose : create new basic attributes + */ +//============================================================================ +SALOMEDS_BasicAttribute_i* BasicAttributeFactory::Create(const char* type) + throw (SALOME_Exception) +{ + if (!strcmp(type,"AttReal")) + { + SALOMEDS_AttReal_i *A = new SALOMEDS_AttReal_i(); + return A; + } + else if(!strcmp(type,"AttLong")) + { + SALOMEDS_AttLong_i *A = new SALOMEDS_AttLong_i(); + return A; + } + else throw(SALOME_Exception(LOCALIZED("bad attribute type name"))); + +} diff --git a/src/SALOMEDS/SALOMEDS_BasicAttributeFactory.hxx b/src/SALOMEDS/SALOMEDS_BasicAttributeFactory.hxx new file mode 100644 index 000000000..1f78de676 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_BasicAttributeFactory.hxx @@ -0,0 +1,29 @@ +//============================================================================= +// File : SALOMEDS_BasicAttributeFactory.hxx +// Created : ven mai 31 13:45:47 CEST 2002 +// Author : Estelle Deville, CEA +// Project : SALOME +// Copyright : CEA 2002 +// $Header$ +//============================================================================= + +#ifndef _BASIC_ATTRIBUTEFACTORY_HXX_ +#define _BASIC_ATTRIBUTEFACTORY_HXX_ +#include "SALOMEDS_BasicAttribute_i.hxx" +// Add new Attribute type here +#include "SALOMEDS_AttReal_i.hxx" +#include "SALOMEDS_AttLong_i.hxx" + +#include "Utils_SALOME_Exception.hxx" + +class BasicAttributeFactory +{ +public: + BasicAttributeFactory() {}; + virtual ~BasicAttributeFactory() {}; + + SALOMEDS_BasicAttribute_i* Create(const char* type) + throw (SALOME_Exception); +}; + +#endif diff --git a/src/SALOMEDS/SALOMEDS_BasicAttribute_i.cxx b/src/SALOMEDS/SALOMEDS_BasicAttribute_i.cxx new file mode 100644 index 000000000..8f0e67fb3 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_BasicAttribute_i.cxx @@ -0,0 +1,23 @@ +using namespace std; +//============================================================================= +// File : SALOMEDS_BasicAttribute_i.cxx +// Created : ven mai 31 13:45:47 CEST 2002 +// Author : Estelle Deville, CEA +// Project : SALOME +// Copyright : CEA 2002 +// $Header$ +//============================================================================= + + +#include "SALOMEDS_BasicAttribute_i.hxx" + +//============================================================================ +/*! Function : SetLabel + * Purpose : + */ +//============================================================================ +void SALOMEDS_BasicAttribute_i::SetLabel(const TDF_Label Lab) +{ + _Lab = Lab; +} + diff --git a/src/SALOMEDS/SALOMEDS_BasicAttribute_i.hxx b/src/SALOMEDS/SALOMEDS_BasicAttribute_i.hxx new file mode 100644 index 000000000..dad4c6dd8 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_BasicAttribute_i.hxx @@ -0,0 +1,36 @@ +//============================================================================= +// File : SALOMEDS_BasicAttribute_i.hxx +// Created : ven mai 31 13:45:47 CEST 2002 +// Author : Estelle Deville, CEA +// Project : SALOME +// Copyright : CEA 2002 +// $Header$ +//============================================================================= + +#ifndef _BASIC_ATTRIBUTE_I_HXX_ +#define _BASIC_ATTRIBUTE_I_HXX_ + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) +#include + +class SALOMEDS_BasicAttribute_i: public POA_SALOMEDS::BasicAttribute, + public PortableServer::RefCountServantBase { +protected: + TDF_Label _Lab; + +public: + SALOMEDS_BasicAttribute_i() {}; + + ~SALOMEDS_BasicAttribute_i() {}; + + virtual char * Save() =0; + virtual void Load () =0; + CORBA::Boolean GetPtr(SALOMEDS::SObject so); + void SetLabel(const TDF_Label Lab); + virtual char* GetType() = 0; + +}; + +#endif diff --git a/src/SALOMEDS/SALOMEDS_Callback_i.hxx b/src/SALOMEDS/SALOMEDS_Callback_i.hxx new file mode 100644 index 000000000..29569168c --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_Callback_i.hxx @@ -0,0 +1,39 @@ +// File : SALOMEDS_Study_i.hxx +// Created : Wed Feb 26 11:27:37 2003 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2003 + +#ifndef __SALOMEDS_CALLBACK_I_H__ +#define __SALOMEDS_CALLBACK_I_H__ + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +class SALOMEDS_Callback_i: public POA_SALOMEDS::Callback, + public PortableServer::RefCountServantBase { + +private: + CORBA::ORB_var _orb; + SALOMEDS::UseCaseBuilder_var _builder; + +public: + + SALOMEDS_Callback_i(SALOMEDS::UseCaseBuilder_ptr builder, CORBA::ORB_ptr orb) { + _orb = CORBA::ORB::_duplicate(orb); + _builder = SALOMEDS::UseCaseBuilder::_duplicate(builder); + } + + virtual void OnAddSObject(SALOMEDS::SObject_ptr theObject) { + if(!_builder->_is_nil() && !theObject->_is_nil()) _builder->Append(theObject); + } + + virtual void OnRemoveSObject(SALOMEDS::SObject_ptr theObject) { + if(!_builder->_is_nil() && !theObject->_is_nil()) _builder->Remove(theObject); + } + +}; + +#endif diff --git a/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx b/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx new file mode 100644 index 000000000..7feabbddd --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx @@ -0,0 +1,93 @@ +using namespace std; +// File : SALOMEDS_ChildIterator_i.cxx +// Created : Wed Nov 28 16:15:25 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#include "SALOMEDS_ChildIterator_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include "utilities.h" + + + +//============================================================================ +/*! Function : constructor + * Purpose : + */ +//============================================================================ +SALOMEDS_ChildIterator_i::SALOMEDS_ChildIterator_i(TDF_Label lab, + CORBA::ORB_ptr orb) + : _lab(lab) +{ + _orb = CORBA::ORB::_duplicate(orb); + _it.Initialize (lab); +} + +//============================================================================ +/*! Function : destructor + * Purpose : + */ +//============================================================================ +SALOMEDS_ChildIterator_i::~SALOMEDS_ChildIterator_i() +{ +} + +//============================================================================ +/*! Function :Init + * + */ +//============================================================================ +void SALOMEDS_ChildIterator_i::Init() +{ + _it.Initialize (_lab); +} + +//============================================================================ +/*! Function :InitEx + * + */ +//============================================================================ +void SALOMEDS_ChildIterator_i::InitEx(CORBA::Boolean allLevels) +{ + _it.Initialize (_lab, allLevels); +} + +//============================================================================ +/*! Function : More + * + */ +//============================================================================ +CORBA::Boolean SALOMEDS_ChildIterator_i::More() +{ + return _it.More(); +} + + //============================================================================ +/*! Function : Next + * + */ +//============================================================================ +void SALOMEDS_ChildIterator_i::Next() +{ + _it.Next(); +} + + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ + +SALOMEDS::SObject_ptr SALOMEDS_ChildIterator_i::Value() +{ + TDF_Label L = _it.Value(); + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (L,_orb); + SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + return so; +} + diff --git a/src/SALOMEDS/SALOMEDS_ChildIterator_i.hxx b/src/SALOMEDS/SALOMEDS_ChildIterator_i.hxx new file mode 100644 index 000000000..af35c73b6 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_ChildIterator_i.hxx @@ -0,0 +1,47 @@ +// File : SALOMEDS_ChildIterator_i.hxx +// Created : Wed Nov 28 16:20:12 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef __SALOMEDS_CHILDITERATOR_I_H__ +#define __SALOMEDS_CHILDITERATOR_I_H__ + +// std C++ headers +#include + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + + + +// Cascade headers +#include +#include +#include + +class SALOMEDS_ChildIterator_i: public POA_SALOMEDS::ChildIterator, + public PortableServer::RefCountServantBase { +private: + CORBA::ORB_ptr _orb; + TDF_Label _lab; + TDF_ChildIterator _it; +public: + + //! standard constructor + SALOMEDS_ChildIterator_i(TDF_Label lab,CORBA::ORB_ptr); + + //! standard destructor + ~SALOMEDS_ChildIterator_i(); + + virtual void Init(); + virtual void InitEx(CORBA::Boolean); + virtual CORBA::Boolean More(); + virtual void Next(); + virtual SALOMEDS::SObject_ptr Value(); +}; +#endif diff --git a/src/SALOMEDS/SALOMEDS_Client.cxx b/src/SALOMEDS/SALOMEDS_Client.cxx new file mode 100644 index 000000000..94d5ad1b6 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_Client.cxx @@ -0,0 +1,305 @@ +using namespace std; +// File : SALOMEDS_Client.cxx +// Created : Wed Nov 28 16:20:25 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#include +#include CORBA_SERVER_HEADER(SALOMEDS) +#include "SALOMEDS_StudyManager_i.hxx" +#include "utilities.h" +#include "SALOMEDS_AttributeName_i.hxx" + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +static void DumpComponent(SALOMEDS::Study_ptr Study,SALOMEDS::SObject_ptr SO,Standard_Integer offset) { + SALOMEDS::SObject_var RefSO; + SALOMEDS::ChildIterator_var it = Study->NewChildIterator(SO); + for (; it->More();it->Next()){ + SALOMEDS::SObject_var CSO= it->Value(); + SALOMEDS::GenericAttribute_var anAttr; + if (CSO->FindAttribute(anAttr,"AttributeName")) + { + SALOMEDS::AttributeName_var Name = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var Val = Name->Value(); + for (Standard_Integer i = 1; i <= offset ; i++) + MESSAGE("--"); + MESSAGE(">"<GetID()<ReferencedObject(RefSO)) { + for (Standard_Integer i = 1; i <= offset ; i++) + MESSAGE(" "); + MESSAGE("*Reference"<GetID()); + } + DumpComponent(Study,CSO,offset+2); + } +} + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +static void DumpStudy (SALOMEDS::Study_ptr Study) { + MESSAGE("Explore Study and Write name of each object if it exists"); + + Standard_CString name; + SALOMEDS::SComponentIterator_var itcomp = Study->NewComponentIterator(); + Standard_Integer offset = 1; + for (; itcomp->More(); itcomp->Next()) { + SALOMEDS::SComponent_var SC = itcomp->Value(); + name = SC->ComponentDataType(); + MESSAGE("-> ComponentDataType is "<NewStudy("Study1"); + + MESSAGE("Create Builder "); + SALOMEDS::StudyBuilder_var StudyBuild = myStudy->NewBuilder(); + + + // Create new components + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var Name; + SALOMEDS::AttributeComment_var Comment; + SALOMEDS::AttributePersistentRef_var PRef; + + // GEOM + MESSAGE("Add Component GEOM"); + SALOMEDS::SComponent_var Geom = StudyBuild->NewComponent("GEOM"); + MESSAGE("Add attribute name GEOM to component Geom"); + anAttr = StudyBuild->FindOrCreateAttribute(Geom, "AttributeName"); + Name = SALOMEDS::AttributeName::_narrow(anAttr); + Name->SetValue("Geometry"); + + // MESH + MESSAGE("Add Component MESH"); + SALOMEDS::SComponent_var Mesh = StudyBuild->NewComponent("MESH"); + anAttr = StudyBuild->FindOrCreateAttribute(Mesh, "AttributeName"); + Name = SALOMEDS::AttributeName::_narrow(anAttr); + Name->SetValue("Mesh"); + + //Create objects + + //Value + //box + MESSAGE("Add Object box under GEOM"); + SALOMEDS::SObject_var box = StudyBuild->NewObject(Geom); + + MESSAGE("Add Attribute Name in object box"); + anAttr = StudyBuild->FindOrCreateAttribute(box, "AttributeName"); + Name = SALOMEDS::AttributeName::_narrow(anAttr); + Name->SetValue("box_0"); + + MESSAGE("Add Attribute Comment in object box"); + anAttr = StudyBuild->FindOrCreateAttribute(box, "AttributeComment"); + Comment = SALOMEDS::AttributeComment::_narrow(anAttr); + Comment->SetValue("this is a box"); + + //mesh_box + MESSAGE("Add Object mesh_box under MESH"); + SALOMEDS::SObject_var mesh_box = StudyBuild->NewObject(Mesh); + + MESSAGE("Add Attribute Name in object mesh_box"); + anAttr = StudyBuild->FindOrCreateAttribute(mesh_box, "AttributeName"); + Name = SALOMEDS::AttributeName::_narrow(anAttr); + Name->SetValue("mesh_box_0"); + + // Test attribute delete + //MESSAGE("Delete Attribute Name in object mesh_box"); + //StudyBuild->RemoveAttribute (mesh_box,SALOMEDS::Name); + + //mesh_box_face + MESSAGE("Add Object mesh_box_face under mesh_box"); + SALOMEDS::SObject_var mesh_box_face = StudyBuild->NewObject(mesh_box); + + MESSAGE("Add Attribute Name in object mesh_box_face"); + anAttr = StudyBuild->FindOrCreateAttribute(mesh_box_face, "AttributeName"); + Name = SALOMEDS::AttributeName::_narrow(anAttr); + Name->SetValue("mesh_box_face_0"); + + MESSAGE("Add Reference mesh_box_face to box"); + StudyBuild->Addreference (mesh_box_face,box); + + //cylinder + MESSAGE("Add Object cylinder under GEOM"); + SALOMEDS::SObject_var cylinder = StudyBuild->NewObject(Geom); + + MESSAGE("Add Attribute Name in object cylinder"); + anAttr = StudyBuild->FindOrCreateAttribute(cylinder, "AttributeName"); + Name = SALOMEDS::AttributeName::_narrow(anAttr); + Name->SetValue("cylinder_0"); + + MESSAGE("Add Attribute Persistent Reference in object cylinder"); + anAttr = StudyBuild->FindOrCreateAttribute(cylinder, "AttributePersistentRef"); + PRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr); + PRef->SetValue("/HDFROOT/GEOM/cylinder"); + + // Test Undo + MESSAGE("Test Undo"); + + StudyBuild->UndoLimit(3); + StudyBuild->NewCommand(); + MESSAGE("Add Object mesh_cylinder under MESH"); + SALOMEDS::SObject_var mesh_cylinder = StudyBuild->NewObject(Mesh); + MESSAGE("Add Attribute Name in object mesh_cylinder"); + anAttr = StudyBuild->FindOrCreateAttribute(mesh_cylinder, "AttributeName"); + Name = SALOMEDS::AttributeName::_narrow(anAttr); + Name->SetValue("mesh_cylinder_0"); + StudyBuild->CommitCommand(); + + MESSAGE("Test GetStudy"); + SALOMEDS::Study_var stu = mesh_cylinder->GetStudy(); + MESSAGE ("-> Study Name is "<Name()); + + DumpStudy(myStudy); + + StudyBuild->Undo(); + // Study should have no trace of object mesh_cylinder + DumpStudy(myStudy); + + + //myStudyMgr->Open ((char*)name); + //MESSAGE("Name " << name); + + // GetOpenStudies + MESSAGE("GetOpenStudies list"); + SALOMEDS::ListOfOpenStudies_var _list_open_studies = myStudyMgr->GetOpenStudies(); + + for (unsigned int ind = 0; ind < _list_open_studies->length();ind++) + { + MESSAGE("Open studies list : " << _list_open_studies[ind]); + } + + + // GetStudyByName + SALOMEDS::Study_var myStudy1 =myStudyMgr->GetStudyByName(_list_open_studies[0]); + MESSAGE("GetStudyByName done"); + + // Save as + myStudyMgr->SaveAs("/home/edeville/Study1.hdf",myStudy1, false); + + // Get Persistent Reference of the study test + name = myStudy1->GetPersistentReference(); + MESSAGE("Persitent Reference of the study " << name); + + // Get Transient Reference of the study test + name = myStudy1->GetTransientReference(); + MESSAGE("Transient Reference of the study " << name); + + // FindComponent Test + SALOMEDS::SComponent_var compo = myStudy1->FindComponent("GEOM"); + // Get ComponentDataType test + MESSAGE("Find ComponentDataType of compo"); + name = compo->ComponentDataType(); + MESSAGE("-> ComponentDataType is "<FindComponentID("0:1:2"); + // Get ComponentDataType test + MESSAGE("Find ComponentDataType of compo1"); + name = compo1->ComponentDataType(); + MESSAGE("-> ComponentDataType is "<FindObject("cylinder_0"); + // Test FindAttribute function : get AttributeName attribute + MESSAGE("Find Name in object objn"); + if (objn->FindAttribute(anAttr, "AttributeName")) { + Name = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var Val = Name->Value(); + MESSAGE("-> Name is "< Name is not found"); + } + + // FindObjectID Test + SALOMEDS::SObject_var obj = myStudy1->FindObjectID("0:1:2:1:1"); + // Test FindAttribute function : get AttributeName attribute + MESSAGE("Find Name in object obj"); + if (obj->FindAttribute(anAttr, "AttributeName")) { + Name = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var Val = Name->Value(); + MESSAGE("-> Name is "< Name is not found"); + } + //DumpStudy(myStudy1); + } + catch(HDFexception) + { + MESSAGE( "HDFexception ! " ) + } +} + +///////////////////////////// MAIN /////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +int main(int argc, char** argv) +{ + try { + // Initialise the ORB. + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3"); + + + + // Obtain a reference to the root POA. + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + PortableServer::POA_var poa = PortableServer::POA::_narrow(obj); + + SALOME_NamingService * salomens = new SALOME_NamingService(orb); + + MESSAGE("Find StudyManager "); + CORBA::Object_ptr obj2 = salomens->Resolve("myStudyManager"); + SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj2); + + // Obtain a POAManager, and tell the POA to start accepting + // requests on its objects. + PortableServer::POAManager_var pman = poa->the_POAManager(); + pman->activate(); + + // Test basic services + Test(myStudyMgr); + + orb->run(); + orb->destroy(); + } + catch(CORBA::SystemException&) { + MESSAGE("Caught CORBA::SystemException." ) + } + catch(CORBA::Exception&) { + MESSAGE( "Caught CORBA::Exception." ) + } + catch(omniORB::fatalException& fe) { + MESSAGE( "Caught omniORB::fatalException:" ) + MESSAGE( " file: " << fe.file() ) + MESSAGE( " line: " << fe.line() ) + MESSAGE( " mesg: " << fe.errmsg() ) + } + catch(...) { + MESSAGE( "Caught unknown exception." ) + } + return 0; +} + diff --git a/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapOfIntegerString.hxx b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapOfIntegerString.hxx new file mode 100644 index 000000000..51e787c38 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapOfIntegerString.hxx @@ -0,0 +1,92 @@ +// File : SALOMEDS_DataMapIteratorOfDataMapOfIntegerString.hxx +// Created : Mon Apr 7 10:13:30 2003 +// Author : Sergey Ruin +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + +#ifndef _SALOMEDS_DataMapIteratorOfDataMapOfIntegerString_HeaderFile +#define _SALOMEDS_DataMapIteratorOfDataMapOfIntegerString_HeaderFile + +#ifndef _TCollection_BasicMapIterator_HeaderFile +#include +#endif +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class TCollection_ExtendedString; +class TColStd_MapIntegerHasher; +class SALOMEDS_DataMapOfIntegerString; +class SALOMEDS_DataMapNodeOfDataMapOfIntegerString; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOMEDS_DataMapIteratorOfDataMapOfIntegerString : public TCollection_BasicMapIterator { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT SALOMEDS_DataMapIteratorOfDataMapOfIntegerString(); +Standard_EXPORT SALOMEDS_DataMapIteratorOfDataMapOfIntegerString(const SALOMEDS_DataMapOfIntegerString& aMap); +Standard_EXPORT void Initialize(const SALOMEDS_DataMapOfIntegerString& aMap) ; +Standard_EXPORT const Standard_Real& Key() const; +Standard_EXPORT const TCollection_ExtendedString& Value() const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapOfIntegerString_0.cxx b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapOfIntegerString_0.cxx new file mode 100644 index 000000000..43061996b --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapOfIntegerString_0.cxx @@ -0,0 +1,42 @@ +// File : SALOMEDS_DataMapIteratorOfDataMapOfIntegerString_0.cxx +// Created : Mon Apr 7 10:13:30 2003 +// Author : Sergey Ruin +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + +#include + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TColStd_MapIntegerHasher_HeaderFile +#include +#endif +#ifndef _SALOMEDS_DataMapOfIntegerString_HeaderFile +#include +#endif +#ifndef _SALOMEDS_DataMapNodeOfDataMapOfIntegerString_HeaderFile +#include +#endif + + +#define TheKey Standard_Real +#define TheKey_hxx +#define TheItem TCollection_ExtendedString +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDS_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator SALOMEDS_DataMapIteratorOfDataMapOfIntegerString +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_Type_() SALOMEDS_DataMapNodeOfDataMapOfIntegerString_Type_() +#define TCollection_DataMap SALOMEDS_DataMapOfIntegerString +#define TCollection_DataMap_hxx +#include + diff --git a/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx new file mode 100644 index 000000000..e4c551ae3 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx @@ -0,0 +1,95 @@ +// File : SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx +// Created : Tue Aug 13 14:05:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#ifndef _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile +#define _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile + +#ifndef _TCollection_BasicMapIterator_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class TCollection_ExtendedString; +class TDF_Label; +class SALOMEDS_DataMapStringLabel; +class SALOMEDS_DataMapNodeOfDataMapStringLabel; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOMEDS_DataMapIteratorOfDataMapStringLabel : public TCollection_BasicMapIterator { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT SALOMEDS_DataMapIteratorOfDataMapStringLabel(); +Standard_EXPORT SALOMEDS_DataMapIteratorOfDataMapStringLabel(const SALOMEDS_DataMapStringLabel& aMap); +Standard_EXPORT void Initialize(const SALOMEDS_DataMapStringLabel& aMap) ; +Standard_EXPORT const TCollection_ExtendedString& Key() const; +Standard_EXPORT const TDF_Label& Value() const; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx new file mode 100644 index 000000000..38e9a2964 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx @@ -0,0 +1,45 @@ +using namespace std; +// File : SALOMEDS_DataMapIteratorOfDataMapStringLabel_0.cxx +// Created : Tue Aug 13 14:05:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx" + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _SALOMEDS_DataMapStringLabel_HeaderFile +#include "SALOMEDS_DataMapStringLabel.hxx" +#endif +#ifndef _SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile +#include "SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx" +#endif + + +#define TheKey TCollection_ExtendedString +#define TheKey_hxx +#define TheItem TDF_Label +#define TheItem_hxx +#define Hasher TCollection_ExtendedString +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDS_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_hxx "SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx" +#define TCollection_DataMapIterator SALOMEDS_DataMapIteratorOfDataMapStringLabel +#define TCollection_DataMapIterator_hxx "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx" +#define Handle_TCollection_DataMapNode Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_Type_() SALOMEDS_DataMapNodeOfDataMapStringLabel_Type_() +#define TCollection_DataMap SALOMEDS_DataMapStringLabel +#define TCollection_DataMap_hxx "SALOMEDS_DataMapStringLabel.hxx" +#include + diff --git a/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapOfIntegerString.hxx b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapOfIntegerString.hxx new file mode 100644 index 000000000..f7a391f13 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapOfIntegerString.hxx @@ -0,0 +1,129 @@ +// File : SALOMEDS_DataMapNodeOfDataMapOfIntegerString.hxx +// Created : Mon Apr 7 10:13:30 2003 +// Author : Sergey Ruin +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + +#ifndef _SALOMEDS_DataMapNodeOfDataMapOfIntegerString_HeaderFile +#define _SALOMEDS_DataMapNodeOfDataMapOfIntegerString_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString_HeaderFile +#include +#endif + +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class TCollection_ExtendedString; +class TColStd_MapIntegerHasher; +class SALOMEDS_DataMapOfIntegerString; +class SALOMEDS_DataMapIteratorOfDataMapOfIntegerString; + + +class SALOMEDS_DataMapNodeOfDataMapOfIntegerString : public TCollection_MapNode { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +SALOMEDS_DataMapNodeOfDataMapOfIntegerString(const Standard_Real& K,const TCollection_ExtendedString& I,const TCollection_MapNodePtr& n); + Standard_Real& Key() const; + TCollection_ExtendedString& Value() const; +Standard_EXPORT ~SALOMEDS_DataMapNodeOfDataMapOfIntegerString(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_DataMapNodeOfDataMapOfIntegerString_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Real myKey; +TCollection_ExtendedString myValue; + + +}; + +#define TheKey Standard_Real +#define TheKey_hxx +#define TheItem TCollection_ExtendedString +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDS_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator SALOMEDS_DataMapIteratorOfDataMapOfIntegerString +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_Type_() SALOMEDS_DataMapNodeOfDataMapOfIntegerString_Type_() +#define TCollection_DataMap SALOMEDS_DataMapOfIntegerString +#define TCollection_DataMap_hxx + +#include + +#undef TheKey +#undef TheKey_hxx +#undef TheItem +#undef TheItem_hxx +#undef Hasher +#undef Hasher_hxx +#undef TCollection_DataMapNode +#undef TCollection_DataMapNode_hxx +#undef TCollection_DataMapIterator +#undef TCollection_DataMapIterator_hxx +#undef Handle_TCollection_DataMapNode +#undef TCollection_DataMapNode_Type_ +#undef TCollection_DataMap +#undef TCollection_DataMap_hxx + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapOfIntegerString_0.cxx b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapOfIntegerString_0.cxx new file mode 100644 index 000000000..baae0cd2c --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapOfIntegerString_0.cxx @@ -0,0 +1,91 @@ +// File : SALOMEDS_DataMapNodeOfDataMapOfIntegerString_0.cxx +// Created : Mon Apr 7 10:13:30 2003 +// Author : Sergey Ruin +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TColStd_MapIntegerHasher_HeaderFile +#include +#endif +#ifndef _SALOMEDS_DataMapOfIntegerString_HeaderFile +#include +#endif +#ifndef _SALOMEDS_DataMapIteratorOfDataMapOfIntegerString_HeaderFile +#include +#endif +SALOMEDS_DataMapNodeOfDataMapOfIntegerString::~SALOMEDS_DataMapNodeOfDataMapOfIntegerString() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_DataMapNodeOfDataMapOfIntegerString_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TCollection_MapNode); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TCollection_MapNode); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_DataMapNodeOfDataMapOfIntegerString", + sizeof(SALOMEDS_DataMapNodeOfDataMapOfIntegerString), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString) Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_DataMapNodeOfDataMapOfIntegerString))) { + _anOtherObject = Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString)((Handle(SALOMEDS_DataMapNodeOfDataMapOfIntegerString)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_DataMapNodeOfDataMapOfIntegerString::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_DataMapNodeOfDataMapOfIntegerString) ; +} +Standard_Boolean SALOMEDS_DataMapNodeOfDataMapOfIntegerString::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_DataMapNodeOfDataMapOfIntegerString) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString::~Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString() {} +#define TheKey Standard_Real +#define TheKey_hxx +#define TheItem TCollection_ExtendedString +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDS_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator SALOMEDS_DataMapIteratorOfDataMapOfIntegerString +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_Type_() SALOMEDS_DataMapNodeOfDataMapOfIntegerString_Type_() +#define TCollection_DataMap SALOMEDS_DataMapOfIntegerString +#define TCollection_DataMap_hxx +#include + diff --git a/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx new file mode 100644 index 000000000..54907ccaa --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx @@ -0,0 +1,135 @@ +// File : SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx +// Created : Tue Aug 13 14:05:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#ifndef _SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile +#define _SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile +#include +#endif + +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class TCollection_ExtendedString; +class TDF_Label; +class SALOMEDS_DataMapStringLabel; +class SALOMEDS_DataMapIteratorOfDataMapStringLabel; + + +class SALOMEDS_DataMapNodeOfDataMapStringLabel : public TCollection_MapNode { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT inline SALOMEDS_DataMapNodeOfDataMapStringLabel(const TCollection_ExtendedString& K,const TDF_Label& I,const TCollection_MapNodePtr& n); +Standard_EXPORT inline TCollection_ExtendedString& Key() const; +Standard_EXPORT inline TDF_Label& Value() const; +Standard_EXPORT ~SALOMEDS_DataMapNodeOfDataMapStringLabel(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_DataMapNodeOfDataMapStringLabel_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +TCollection_ExtendedString myKey; +TDF_Label myValue; + + +}; + +#define TheKey TCollection_ExtendedString +#define TheKey_hxx +#define TheItem TDF_Label +#define TheItem_hxx +#define Hasher TCollection_ExtendedString +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDS_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_hxx "SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx" +#define TCollection_DataMapIterator SALOMEDS_DataMapIteratorOfDataMapStringLabel +#define TCollection_DataMapIterator_hxx "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx" +#define Handle_TCollection_DataMapNode Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_Type_() SALOMEDS_DataMapNodeOfDataMapStringLabel_Type_() +#define TCollection_DataMap SALOMEDS_DataMapStringLabel +#define TCollection_DataMap_hxx "SALOMEDS_DataMapStringLabel.hxx" + +#include + +#undef TheKey +#undef TheKey_hxx +#undef TheItem +#undef TheItem_hxx +#undef Hasher +#undef Hasher_hxx +#undef TCollection_DataMapNode +#undef TCollection_DataMapNode_hxx +#undef TCollection_DataMapIterator +#undef TCollection_DataMapIterator_hxx +#undef Handle_TCollection_DataMapNode +#undef TCollection_DataMapNode_Type_ +#undef TCollection_DataMap +#undef TCollection_DataMap_hxx + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx new file mode 100644 index 000000000..00ab73f8a --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx @@ -0,0 +1,94 @@ +using namespace std; +// File : Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_0.cxx +// Created : Tue Aug 13 14:05:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#include "SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _SALOMEDS_DataMapStringLabel_HeaderFile +#include "SALOMEDS_DataMapStringLabel.hxx" +#endif +#ifndef _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile +#include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx" +#endif +SALOMEDS_DataMapNodeOfDataMapStringLabel::~SALOMEDS_DataMapNodeOfDataMapStringLabel() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_DataMapNodeOfDataMapStringLabel_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TCollection_MapNode); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TCollection_MapNode); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_DataMapNodeOfDataMapStringLabel", + sizeof(SALOMEDS_DataMapNodeOfDataMapStringLabel), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel) Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_DataMapNodeOfDataMapStringLabel))) { + _anOtherObject = Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel)((Handle(SALOMEDS_DataMapNodeOfDataMapStringLabel)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_DataMapNodeOfDataMapStringLabel::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_DataMapNodeOfDataMapStringLabel) ; +} +Standard_Boolean SALOMEDS_DataMapNodeOfDataMapStringLabel::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_DataMapNodeOfDataMapStringLabel) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel::~Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel() {} +#define TheKey TCollection_ExtendedString +#define TheKey_hxx +#define TheItem TDF_Label +#define TheItem_hxx +#define Hasher TCollection_ExtendedString +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDS_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_hxx "SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx" +#define TCollection_DataMapIterator SALOMEDS_DataMapIteratorOfDataMapStringLabel +#define TCollection_DataMapIterator_hxx "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx" +#define Handle_TCollection_DataMapNode Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_Type_() SALOMEDS_DataMapNodeOfDataMapStringLabel_Type_() +#define TCollection_DataMap SALOMEDS_DataMapStringLabel +#define TCollection_DataMap_hxx "SALOMEDS_DataMapStringLabel.hxx" +#include + diff --git a/src/SALOMEDS/SALOMEDS_DataMapOfIntegerString.hxx b/src/SALOMEDS/SALOMEDS_DataMapOfIntegerString.hxx new file mode 100644 index 000000000..ab1a4242f --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DataMapOfIntegerString.hxx @@ -0,0 +1,125 @@ +// File : SALOMEDS_DataMapOfIntegerString.hxx +// Created : Mon Apr 7 10:13:30 2003 +// Author : Sergey Ruin +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + + +#ifndef _SALOMEDS_DataMapOfIntegerString_HeaderFile +#define _SALOMEDS_DataMapOfIntegerString_HeaderFile + +#ifndef _TCollection_BasicMap_HeaderFile +#include +#endif +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_DomainError; +class Standard_NoSuchObject; +class TCollection_ExtendedString; +class TColStd_MapIntegerHasher; +class SALOMEDS_DataMapNodeOfDataMapOfIntegerString; +class SALOMEDS_DataMapIteratorOfDataMapOfIntegerString; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOMEDS_DataMapOfIntegerString : public TCollection_BasicMap { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT SALOMEDS_DataMapOfIntegerString(const Standard_Integer NbBuckets = 1); +Standard_EXPORT SALOMEDS_DataMapOfIntegerString& Assign(const SALOMEDS_DataMapOfIntegerString& Other) ; + SALOMEDS_DataMapOfIntegerString& operator =(const SALOMEDS_DataMapOfIntegerString& Other) +{ + return Assign(Other); +} + +Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; +Standard_EXPORT void Clear() ; +~SALOMEDS_DataMapOfIntegerString() +{ + Clear(); +} + +Standard_EXPORT Standard_Boolean Bind(const Standard_Real& K,const TCollection_ExtendedString& I) ; +Standard_EXPORT Standard_Boolean IsBound(const Standard_Real& K) const; +Standard_EXPORT Standard_Boolean UnBind(const Standard_Real& K) ; +Standard_EXPORT const TCollection_ExtendedString& Find(const Standard_Real& K) const; + const TCollection_ExtendedString& operator()(const Standard_Real& K) const +{ + return Find(K); +} + +Standard_EXPORT TCollection_ExtendedString& ChangeFind(const Standard_Real& K) ; + TCollection_ExtendedString& operator()(const Standard_Real& K) +{ + return ChangeFind(K); +} + + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT SALOMEDS_DataMapOfIntegerString(const SALOMEDS_DataMapOfIntegerString& Other); + + + // Fields PRIVATE + // + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_DataMapOfIntegerString_0.cxx b/src/SALOMEDS/SALOMEDS_DataMapOfIntegerString_0.cxx new file mode 100644 index 000000000..a228fb154 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DataMapOfIntegerString_0.cxx @@ -0,0 +1,45 @@ +// File : SALOMEDS_DataMapOfIntegerString_0.cxx +// Created : Mon Apr 7 10:13:30 2003 +// Author : Sergey Ruin +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + +#include + +#ifndef _Standard_DomainError_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TColStd_MapIntegerHasher_HeaderFile +#include +#endif +#ifndef _SALOMEDS_DataMapNodeOfDataMapOfIntegerString_HeaderFile +#include +#endif +#ifndef _SALOMEDS_DataMapIteratorOfDataMapOfIntegerString_HeaderFile +#include +#endif + + +#define TheKey Standard_Real +#define TheKey_hxx +#define TheItem TCollection_ExtendedString +#define TheItem_hxx +#define Hasher TColStd_MapIntegerHasher +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDS_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_hxx +#define TCollection_DataMapIterator SALOMEDS_DataMapIteratorOfDataMapOfIntegerString +#define TCollection_DataMapIterator_hxx +#define Handle_TCollection_DataMapNode Handle_SALOMEDS_DataMapNodeOfDataMapOfIntegerString +#define TCollection_DataMapNode_Type_() SALOMEDS_DataMapNodeOfDataMapOfIntegerString_Type_() +#define TCollection_DataMap SALOMEDS_DataMapOfIntegerString +#define TCollection_DataMap_hxx +#include + diff --git a/src/SALOMEDS/SALOMEDS_DataMapStringLabel.hxx b/src/SALOMEDS/SALOMEDS_DataMapStringLabel.hxx new file mode 100644 index 000000000..9f3f6bd22 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DataMapStringLabel.hxx @@ -0,0 +1,127 @@ +// File : SALOMEDS_DataMapStringLabel.hxx +// Created : Tue Aug 13 14:05:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#ifndef _SALOMEDS_DataMapStringLabel_HeaderFile +#define _SALOMEDS_DataMapStringLabel_HeaderFile + +#ifndef _TCollection_BasicMap_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_DomainError; +class Standard_NoSuchObject; +class TCollection_ExtendedString; +class TDF_Label; +class SALOMEDS_DataMapNodeOfDataMapStringLabel; +class SALOMEDS_DataMapIteratorOfDataMapStringLabel; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOMEDS_DataMapStringLabel : public TCollection_BasicMap { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT SALOMEDS_DataMapStringLabel(const Standard_Integer NbBuckets = 1); +Standard_EXPORT SALOMEDS_DataMapStringLabel& Assign(const SALOMEDS_DataMapStringLabel& Other) ; + SALOMEDS_DataMapStringLabel& operator =(const SALOMEDS_DataMapStringLabel& Other) +{ + return Assign(Other); +} + +Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; +Standard_EXPORT void Clear() ; +~SALOMEDS_DataMapStringLabel() +{ + Clear(); +} + +Standard_EXPORT Standard_Boolean Bind(const TCollection_ExtendedString& K,const TDF_Label& I) ; +Standard_EXPORT Standard_Boolean IsBound(const TCollection_ExtendedString& K) const; +Standard_EXPORT Standard_Boolean UnBind(const TCollection_ExtendedString& K) ; +Standard_EXPORT const TDF_Label& Find(const TCollection_ExtendedString& K) const; + const TDF_Label& operator()(const TCollection_ExtendedString& K) const +{ + return Find(K); +} + +Standard_EXPORT TDF_Label& ChangeFind(const TCollection_ExtendedString& K) ; + TDF_Label& operator()(const TCollection_ExtendedString& K) +{ + return ChangeFind(K); +} + + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT SALOMEDS_DataMapStringLabel(const SALOMEDS_DataMapStringLabel& Other); + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_DataMapStringLabel_0.cxx b/src/SALOMEDS/SALOMEDS_DataMapStringLabel_0.cxx new file mode 100644 index 000000000..ae180416d --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DataMapStringLabel_0.cxx @@ -0,0 +1,48 @@ +using namespace std; +// File : SALOMEDS_DataMapStringLabel_0.cxx +// Created : Tue Aug 13 14:05:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#include "SALOMEDS_DataMapStringLabel.hxx" + +#ifndef _Standard_DomainError_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _SALOMEDS_DataMapNodeOfDataMapStringLabel_HeaderFile +#include "SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx" +#endif +#ifndef _SALOMEDS_DataMapIteratorOfDataMapStringLabel_HeaderFile +#include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx" +#endif + + +#define TheKey TCollection_ExtendedString +#define TheKey_hxx +#define TheItem TDF_Label +#define TheItem_hxx +#define Hasher TCollection_ExtendedString +#define Hasher_hxx +#define TCollection_DataMapNode SALOMEDS_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_hxx "SALOMEDS_DataMapNodeOfDataMapStringLabel.hxx" +#define TCollection_DataMapIterator SALOMEDS_DataMapIteratorOfDataMapStringLabel +#define TCollection_DataMapIterator_hxx "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx" +#define Handle_TCollection_DataMapNode Handle_SALOMEDS_DataMapNodeOfDataMapStringLabel +#define TCollection_DataMapNode_Type_() SALOMEDS_DataMapNodeOfDataMapStringLabel_Type_() +#define TCollection_DataMap SALOMEDS_DataMapStringLabel +#define TCollection_DataMap_hxx "SALOMEDS_DataMapStringLabel.hxx" +#include + diff --git a/src/SALOMEDS/SALOMEDS_DrawableAttribute.cdl b/src/SALOMEDS/SALOMEDS_DrawableAttribute.cdl new file mode 100644 index 000000000..0f2d2de69 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DrawableAttribute.cdl @@ -0,0 +1,62 @@ +// File : SALOMEDS_DrawableAttribute.cdl +// Created : Tue Jul 09 16:20:05 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + + + + +class DrawableAttribute from SALOMEDS inherits Integer from TDataStd + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + ExtendedString from TCollection, + DataSet from TDF, + RelocationTable from TDF, + AttributeSequence from TDF, + Data from TDF, + Comment from TDataStd + + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + Set (myclass; label : Label from TDF; value : Integer from Standard) + ---Purpose: Find, or create a Comment attribute and set the string. + -- the Comment attribute is returned. + returns DrawableAttribute from SALOMEDS; + + ---Purpose: Comment methods + -- ============ + + Create + returns mutable DrawableAttribute from SALOMEDS; + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +end DrawableAttribute; diff --git a/src/SALOMEDS/SALOMEDS_DrawableAttribute.cxx b/src/SALOMEDS/SALOMEDS_DrawableAttribute.cxx new file mode 100644 index 000000000..17aa0b1e3 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DrawableAttribute.cxx @@ -0,0 +1,94 @@ +using namespace std; +// File : SALOMEDS_DrawableAttribute.cxx +// Created : Wed Nov 28 16:09:35 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + +#include "SALOMEDS_DrawableAttribute.ixx" +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_DrawableAttribute::GetID () +{ + static Standard_GUID SALOMEDS_DrawableAttributeID ("12837184-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_DrawableAttributeID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDS_DrawableAttribute) SALOMEDS_DrawableAttribute::Set (const TDF_Label& L, + const Standard_Integer value) +{ + Handle(SALOMEDS_DrawableAttribute) A; + if (!L.FindAttribute(SALOMEDS_DrawableAttribute::GetID(),A)) { + A = new SALOMEDS_DrawableAttribute(); + L.AddAttribute(A); + } + + (Handle(TDataStd_Integer)::DownCast(A))->Set (value); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDS_DrawableAttribute::SALOMEDS_DrawableAttribute() +{ + TDataStd_Integer::Set(0); +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_DrawableAttribute::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDS_DrawableAttribute::NewEmpty () const +{ + return new SALOMEDS_DrawableAttribute(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDS_DrawableAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer s = Handle(TDataStd_Integer)::DownCast (with)->Get (); + TDataStd_Integer::Set(s); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDS_DrawableAttribute::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(TDataStd_Integer)::DownCast (into)->Set (Get()); +} + diff --git a/src/SALOMEDS/SALOMEDS_DrawableAttribute.hxx b/src/SALOMEDS/SALOMEDS_DrawableAttribute.hxx new file mode 100644 index 000000000..cd1ebf22c --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DrawableAttribute.hxx @@ -0,0 +1,108 @@ +// File : SALOMEDS_DrawableAttribute.hxx +// Created : Tue Jul 09 16:44:15 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _SALOMEDS_DrawableAttribute_HeaderFile +#define _SALOMEDS_DrawableAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_DrawableAttribute_HeaderFile +#include +#endif + +#ifndef _TDataStd_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class Standard_GUID; +class TDF_Label; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_DrawableAttribute : public TDataStd_Integer { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_DrawableAttribute Set(const TDF_Label& label,const Standard_Integer value) ; +Standard_EXPORT SALOMEDS_DrawableAttribute(); +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT ~SALOMEDS_DrawableAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_DrawableAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_DrawableAttribute.ixx b/src/SALOMEDS/SALOMEDS_DrawableAttribute.ixx new file mode 100644 index 000000000..8ad12ab52 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DrawableAttribute.ixx @@ -0,0 +1,68 @@ +// File : SALOMEDS_DrawableAttribute.ixx +// Created : Tue Jul 09 16:44:26 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOMEDS_DrawableAttribute.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_DrawableAttribute::~SALOMEDS_DrawableAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_DrawableAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDataStd_Integer); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDataStd_Integer); + static Handle_Standard_Type aType2 = STANDARD_TYPE(TDF_Attribute); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType3 = STANDARD_TYPE(MMgt_TShared); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_DrawableAttribute", + sizeof(SALOMEDS_DrawableAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_DrawableAttribute) Handle(SALOMEDS_DrawableAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_DrawableAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_DrawableAttribute))) { + _anOtherObject = Handle(SALOMEDS_DrawableAttribute)((Handle(SALOMEDS_DrawableAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_DrawableAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_DrawableAttribute) ; +} +Standard_Boolean SALOMEDS_DrawableAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_DrawableAttribute) == AType || TDataStd_Integer::IsKind(AType)); +} +Handle_SALOMEDS_DrawableAttribute::~Handle_SALOMEDS_DrawableAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_DrawableAttribute.jxx b/src/SALOMEDS/SALOMEDS_DrawableAttribute.jxx new file mode 100644 index 000000000..d1e2ca053 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_DrawableAttribute.jxx @@ -0,0 +1,24 @@ +// File : SALOMEDS_DrawableAttribute.jxx +// Created : Tue Jul 09 16:44:32 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_DrawableAttribute_HeaderFile +#include "SALOMEDS_DrawableAttribute.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_ExpandableAttribute.cdl b/src/SALOMEDS/SALOMEDS_ExpandableAttribute.cdl new file mode 100644 index 000000000..fd9aa2c39 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_ExpandableAttribute.cdl @@ -0,0 +1,62 @@ +// File : SALOMEDS_ExpandableAttribute.cdl +// Created : Tue Jul 09 16:20:05 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + + + + +class ExpandableAttribute from SALOMEDS inherits Integer from TDataStd + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + ExtendedString from TCollection, + DataSet from TDF, + RelocationTable from TDF, + AttributeSequence from TDF, + Data from TDF, + Comment from TDataStd + + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + Set (myclass; label : Label from TDF; value : Integer from Standard) + ---Purpose: Find, or create a Comment attribute and set the string. + -- the Comment attribute is returned. + returns ExpandableAttribute from SALOMEDS; + + ---Purpose: Comment methods + -- ============ + + Create + returns mutable ExpandableAttribute from SALOMEDS; + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +end ExpandableAttribute; diff --git a/src/SALOMEDS/SALOMEDS_ExpandableAttribute.cxx b/src/SALOMEDS/SALOMEDS_ExpandableAttribute.cxx new file mode 100644 index 000000000..0431d819c --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_ExpandableAttribute.cxx @@ -0,0 +1,94 @@ +using namespace std; +// File : SALOMEDS_ExpandableAttribute.cxx +// Created : Wed Nov 28 16:09:35 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + +#include "SALOMEDS_ExpandableAttribute.ixx" +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_ExpandableAttribute::GetID () +{ + static Standard_GUID SALOMEDS_ExpandableAttributeID ("12837185-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_ExpandableAttributeID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDS_ExpandableAttribute) SALOMEDS_ExpandableAttribute::Set (const TDF_Label& L, + const Standard_Integer value) +{ + Handle(SALOMEDS_ExpandableAttribute) A; + if (!L.FindAttribute(SALOMEDS_ExpandableAttribute::GetID(),A)) { + A = new SALOMEDS_ExpandableAttribute(); + L.AddAttribute(A); + } + + (Handle(TDataStd_Integer)::DownCast(A))->Set (value); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDS_ExpandableAttribute::SALOMEDS_ExpandableAttribute() +{ + TDataStd_Integer::Set(0); +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_ExpandableAttribute::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDS_ExpandableAttribute::NewEmpty () const +{ + return new SALOMEDS_ExpandableAttribute(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDS_ExpandableAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer s = Handle(TDataStd_Integer)::DownCast (with)->Get (); + TDataStd_Integer::Set(s); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDS_ExpandableAttribute::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(TDataStd_Integer)::DownCast (into)->Set (Get()); +} + diff --git a/src/SALOMEDS/SALOMEDS_ExpandableAttribute.hxx b/src/SALOMEDS/SALOMEDS_ExpandableAttribute.hxx new file mode 100644 index 000000000..b9032d919 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_ExpandableAttribute.hxx @@ -0,0 +1,108 @@ +// File : SALOMEDS_ExpandableAttribute.hxx +// Created : Tue Jul 09 16:44:57 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _SALOMEDS_ExpandableAttribute_HeaderFile +#define _SALOMEDS_ExpandableAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_ExpandableAttribute_HeaderFile +#include +#endif + +#ifndef _TDataStd_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class Standard_GUID; +class TDF_Label; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_ExpandableAttribute : public TDataStd_Integer { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_ExpandableAttribute Set(const TDF_Label& label,const Standard_Integer value) ; +Standard_EXPORT SALOMEDS_ExpandableAttribute(); +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT ~SALOMEDS_ExpandableAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_ExpandableAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_ExpandableAttribute.ixx b/src/SALOMEDS/SALOMEDS_ExpandableAttribute.ixx new file mode 100644 index 000000000..6ac5b2abd --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_ExpandableAttribute.ixx @@ -0,0 +1,68 @@ +// File : SALOMEDS_ExpandableAttribute.ixx +// Created : Tue Jul 09 16:45:05 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOMEDS_ExpandableAttribute.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_ExpandableAttribute::~SALOMEDS_ExpandableAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_ExpandableAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDataStd_Integer); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDataStd_Integer); + static Handle_Standard_Type aType2 = STANDARD_TYPE(TDF_Attribute); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType3 = STANDARD_TYPE(MMgt_TShared); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_ExpandableAttribute", + sizeof(SALOMEDS_ExpandableAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_ExpandableAttribute) Handle(SALOMEDS_ExpandableAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_ExpandableAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_ExpandableAttribute))) { + _anOtherObject = Handle(SALOMEDS_ExpandableAttribute)((Handle(SALOMEDS_ExpandableAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_ExpandableAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_ExpandableAttribute) ; +} +Standard_Boolean SALOMEDS_ExpandableAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_ExpandableAttribute) == AType || TDataStd_Integer::IsKind(AType)); +} +Handle_SALOMEDS_ExpandableAttribute::~Handle_SALOMEDS_ExpandableAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_ExpandableAttribute.jxx b/src/SALOMEDS/SALOMEDS_ExpandableAttribute.jxx new file mode 100644 index 000000000..c14cf6c92 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_ExpandableAttribute.jxx @@ -0,0 +1,24 @@ +// File : SALOMEDS_ExpandableAttribute.jxx +// Created : Tue Jul 09 16:45:10 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_ExpandableAttribute_HeaderFile +#include "SALOMEDS_ExpandableAttribute.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx new file mode 100644 index 000000000..bbd790db6 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx @@ -0,0 +1,29 @@ +using namespace std; +// File : SALOMEDS_GenericAttribute_i.cxx +// Created : Fri Jul 05 15:49:37 2002 +// Author : Mikhail PONIKAROV + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOMEDS_StudyBuilder_i.hxx" + +void SALOMEDS_GenericAttribute_i::CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection) { + if (!_myAttr.IsNull() && _myAttr->IsValid() && !CORBA::is_nil(_myOrb)) { + Handle(SALOMEDS_IORAttribute) Att; + if (_myAttr->Label().Root().FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){ + TCollection_AsciiString ch(Att->Get()); + char* IOR = CORBA::string_dup(ch.ToCString()); + CORBA::Object_var obj = _myOrb->string_to_object(IOR); + SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj); + // ASSERT(!CORBA::is_nil(aStudy)); + if (aStudy->NewBuilder()->HasOpenCommand()) return; + if (aStudy->GetProperties()->IsLocked()) { + // INFOS("Locked document modification !!!"); + throw SALOMEDS::GenericAttribute::LockProtection(); + } + } + } +} diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx new file mode 100644 index 000000000..7fec24e58 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx @@ -0,0 +1,41 @@ +// File : SALOMEDS_GenericAttribute_i.hxx +// Created : Fri Jul 05 15:49:37 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _GENERIC_ATTRIBUTE_I_HXX_ +#define _GENERIC_ATTRIBUTE_I_HXX_ + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) +#include +#include "SALOMEDS_SObject_i.hxx" +#include "SALOMEDS_IORAttribute.hxx" + +class SALOMEDS_GenericAttribute_i: public POA_SALOMEDS::GenericAttribute, + public PortableServer::RefCountServantBase { +protected: + Handle(TDF_Attribute) _myAttr; + CORBA::ORB_ptr _myOrb; +public: + SALOMEDS_GenericAttribute_i() {}; + + void CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection); + + ~SALOMEDS_GenericAttribute_i() {}; + +// CORBA::Boolean GetPtr(SALOMEDS::SObject_out so) { +// SALOMEDS_SObject_i* sob_impl = new SALOMEDS_SObject_i(_myAttr->Label(), _myOrb); +// SALOMEDS::SObject_var sob = sob_impl->_this(); +// return sob._retn(); +// }; + + +}; + +#endif diff --git a/src/SALOMEDS/SALOMEDS_IORAttribute.cdl b/src/SALOMEDS/SALOMEDS_IORAttribute.cdl new file mode 100644 index 000000000..f3ac9146d --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_IORAttribute.cdl @@ -0,0 +1,60 @@ +// File : SALOMEDS_IORAttribute.cdl +// Created : Wed Nov 28 16:20:40 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + + +class IORAttribute from SALOMEDS inherits Comment from TDataStd + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + ExtendedString from TCollection, + DataSet from TDF, + RelocationTable from TDF, + AttributeSequence from TDF, + Data from TDF, + Comment from TDataStd + + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + Set (myclass; label : Label from TDF; string : ExtendedString from TCollection) + ---Purpose: Find, or create a Comment attribute and set the string. + -- the Comment attribute is returned. + returns IORAttribute from SALOMEDS; + + ---Purpose: Comment methods + -- ============ + + Create + returns mutable IORAttribute from SALOMEDS; + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +end IORAttribute; diff --git a/src/SALOMEDS/SALOMEDS_IORAttribute.cxx b/src/SALOMEDS/SALOMEDS_IORAttribute.cxx new file mode 100644 index 000000000..433da4a53 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_IORAttribute.cxx @@ -0,0 +1,95 @@ +using namespace std; +// File : SALOMEDS_IORAttribute.cxx +// Created : Wed Nov 28 16:09:35 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#include "SALOMEDS_IORAttribute.ixx" +#include +#include +#include "SALOMEDS_Study_i.hxx" + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_IORAttribute::GetID () +{ + static Standard_GUID SALOMEDS_IORAttributeID ("92888E01-7074-11d5-A690-0800369C8A03"); + return SALOMEDS_IORAttributeID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDS_IORAttribute) SALOMEDS_IORAttribute::Set (const TDF_Label& L, + const TCollection_ExtendedString& S, + CORBA::ORB_ptr orb) +{ + Handle(SALOMEDS_IORAttribute) A; + if (!L.FindAttribute(SALOMEDS_IORAttribute::GetID(),A)) { + A = new SALOMEDS_IORAttribute(); + L.AddAttribute(A); + } + + (Handle(TDataStd_Comment)::DownCast(A))->Set (S); + SALOMEDS_Study_i::IORUpdated(A,orb); + return A; +} + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDS_IORAttribute::SALOMEDS_IORAttribute() +{} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_IORAttribute::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDS_IORAttribute::NewEmpty () const +{ + return new SALOMEDS_IORAttribute(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDS_IORAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + TCollection_ExtendedString s = Handle(TDataStd_Comment)::DownCast (with)->Get (); + TDataStd_Comment::Set(s); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDS_IORAttribute::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(TDataStd_Comment)::DownCast (into)->Set (Get()); +} + diff --git a/src/SALOMEDS/SALOMEDS_IORAttribute.hxx b/src/SALOMEDS/SALOMEDS_IORAttribute.hxx new file mode 100644 index 000000000..fc5ae01e7 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_IORAttribute.hxx @@ -0,0 +1,110 @@ +// File : SALOMEDS_IORAttribute.hxx +// Created : Thu Nov 29 21:00:34 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef _SALOMEDS_IORAttribute_HeaderFile +#define _SALOMEDS_IORAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_IORAttribute_HeaderFile +#include "Handle_SALOMEDS_IORAttribute.hxx" +#endif + +#ifndef _TDataStd_Comment_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif + +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +class Standard_GUID; +class TDF_Label; +class TCollection_ExtendedString; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_IORAttribute : public TDataStd_Comment { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_IORAttribute Set(const TDF_Label& label,const TCollection_ExtendedString& string, CORBA::ORB_ptr orb) ; +Standard_EXPORT SALOMEDS_IORAttribute(); +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT ~SALOMEDS_IORAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_IORAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_IORAttribute.ixx b/src/SALOMEDS/SALOMEDS_IORAttribute.ixx new file mode 100644 index 000000000..2e7512e59 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_IORAttribute.ixx @@ -0,0 +1,68 @@ +// File : SALOMEDS_IORAttribute.ixx +// Created : Thu Nov 29 21:00:52 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#include "SALOMEDS_IORAttribute.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_IORAttribute::~SALOMEDS_IORAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_IORAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDataStd_Comment); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDataStd_Comment); + static Handle_Standard_Type aType2 = STANDARD_TYPE(TDF_Attribute); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType3 = STANDARD_TYPE(MMgt_TShared); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_IORAttribute", + sizeof(SALOMEDS_IORAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_IORAttribute) Handle(SALOMEDS_IORAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_IORAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_IORAttribute))) { + _anOtherObject = Handle(SALOMEDS_IORAttribute)((Handle(SALOMEDS_IORAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_IORAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_IORAttribute) ; +} +Standard_Boolean SALOMEDS_IORAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_IORAttribute) == AType || TDataStd_Comment::IsKind(AType)); +} +Handle_SALOMEDS_IORAttribute::~Handle_SALOMEDS_IORAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_IORAttribute.jxx b/src/SALOMEDS/SALOMEDS_IORAttribute.jxx new file mode 100644 index 000000000..b408ac969 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_IORAttribute.jxx @@ -0,0 +1,18 @@ +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_IORAttribute_HeaderFile +#include "SALOMEDS_IORAttribute.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.cdl b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.cdl new file mode 100644 index 000000000..f7dd9130c --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.cdl @@ -0,0 +1,56 @@ +// File : SALOMEDS_LocalIDAttribute.cdl +// Created : Tue Aug 13 14:05:03 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +class LocalIDAttribute from SALOMEDS inherits Integer from TDataStd + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + ExtendedString from TCollection, + DataSet from TDF, + RelocationTable from TDF, + AttributeSequence from TDF, + Data from TDF, + Comment from TDataStd + + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + Set (myclass; label : Label from TDF; value : Integer from Standard) + returns OpenedAttribute from SALOMEDS; + + ---Purpose: Comment methods + -- ============ + + Create + returns mutable OpenedAttribute from SALOMEDS; + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +end LocalIDAttribute; diff --git a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.cxx b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.cxx new file mode 100644 index 000000000..6721670b8 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.cxx @@ -0,0 +1,94 @@ +using namespace std; +// File : SALOMEDS_LocalIDAttribute.cxx +// Created : Tue Aug 13 14:05:03 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + +#include "SALOMEDS_LocalIDAttribute.ixx" +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_LocalIDAttribute::GetID () +{ + static Standard_GUID SALOMEDS_OpenedAttributeID ("12837196-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_OpenedAttributeID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDS_LocalIDAttribute) SALOMEDS_LocalIDAttribute::Set (const TDF_Label& L, + const Standard_Integer value) +{ + Handle(SALOMEDS_LocalIDAttribute) A; + if (!L.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(),A)) { + A = new SALOMEDS_LocalIDAttribute(); + L.AddAttribute(A); + } + + (Handle(TDataStd_Integer)::DownCast(A))->Set (value); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDS_LocalIDAttribute::SALOMEDS_LocalIDAttribute() +{ + TDataStd_Integer::Set(0); +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_LocalIDAttribute::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDS_LocalIDAttribute::NewEmpty () const +{ + return new SALOMEDS_LocalIDAttribute(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDS_LocalIDAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer s = Handle(TDataStd_Integer)::DownCast (with)->Get (); + TDataStd_Integer::Set(s); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDS_LocalIDAttribute::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(TDataStd_Integer)::DownCast (into)->Set (Get()); +} + diff --git a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.hxx b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.hxx new file mode 100644 index 000000000..345284300 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.hxx @@ -0,0 +1,108 @@ +// File : SALOMEDS_LocalIDAttribute.hxx +// Created : Tue Aug 13 14:05:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#ifndef _SALOMEDS_LocalIDAttribute_HeaderFile +#define _SALOMEDS_LocalIDAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_LocalIDAttribute_HeaderFile +#include +#endif + +#ifndef _TDataStd_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class Standard_GUID; +class TDF_Label; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_LocalIDAttribute : public TDataStd_Integer { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_LocalIDAttribute Set(const TDF_Label& label,const Standard_Integer value) ; +Standard_EXPORT SALOMEDS_LocalIDAttribute(); +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT ~SALOMEDS_LocalIDAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_LocalIDAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.ixx b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.ixx new file mode 100644 index 000000000..d754fe3f5 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.ixx @@ -0,0 +1,68 @@ +// File : SALOMEDS_LocalIDAttribute.ixx +// Created : Tue Aug 13 14:05:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#include "SALOMEDS_LocalIDAttribute.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_LocalIDAttribute::~SALOMEDS_LocalIDAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_LocalIDAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDataStd_Integer); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDataStd_Integer); + static Handle_Standard_Type aType2 = STANDARD_TYPE(TDF_Attribute); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType3 = STANDARD_TYPE(MMgt_TShared); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_LocalIDAttribute", + sizeof(SALOMEDS_LocalIDAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_LocalIDAttribute) Handle(SALOMEDS_LocalIDAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_LocalIDAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_LocalIDAttribute))) { + _anOtherObject = Handle(SALOMEDS_LocalIDAttribute)((Handle(SALOMEDS_LocalIDAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_LocalIDAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_LocalIDAttribute) ; +} +Standard_Boolean SALOMEDS_LocalIDAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_LocalIDAttribute) == AType || TDataStd_Integer::IsKind(AType)); +} +Handle_SALOMEDS_LocalIDAttribute::~Handle_SALOMEDS_LocalIDAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_LocalIDAttribute.jxx b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.jxx new file mode 100644 index 000000000..7f33b3b4a --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_LocalIDAttribute.jxx @@ -0,0 +1,24 @@ +// File : SALOMEDS_LocalIDAttribute.jxx +// Created : Tue Aug 13 14:05:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_LocalIDAttribute_HeaderFile +#include "SALOMEDS_LocalIDAttribute.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_OCAFApplication.cdl b/src/SALOMEDS/SALOMEDS_OCAFApplication.cdl new file mode 100644 index 000000000..f303fc6ac --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_OCAFApplication.cdl @@ -0,0 +1,29 @@ +-- File: SALOMEDS_OCAFApplication.cdl +-- Created: Fri Jun 29 12:19:49 2001 +-- Author: Yves FRICAUD +-- +---Copyright: OPEN CASCADE 2001 + + +class OCAFApplication from SALOMEDS inherits Application from TDocStd + + ---Purpose: + +uses + Label from TDF, + SequenceOfExtendedString from TColStd, + CString from Standard, + Document from TDocStd + + +is + + Create + returns mutable OCAFApplication from SALOMEDS; + + Formats(me: mutable; Formats: out SequenceOfExtendedString from TColStd) + is redefined; + + ResourcesName (me: mutable) returns CString from Standard; + +end OCAFApplication; diff --git a/src/SALOMEDS/SALOMEDS_OCAFApplication.cxx b/src/SALOMEDS/SALOMEDS_OCAFApplication.cxx new file mode 100644 index 000000000..29afbcdd0 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_OCAFApplication.cxx @@ -0,0 +1,48 @@ +using namespace std; +// File : SALOMEDS_OCAFApplication.cxx +// Created : Wed Nov 28 16:22:26 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + + +#include "SALOMEDS_OCAFApplication.ixx" + +//======================================================================= +//function : SALOMEDS_OCAFApplication +//purpose : +//======================================================================= + +SALOMEDS_OCAFApplication::SALOMEDS_OCAFApplication() +{ +} + + +//======================================================================= +//function : Formats +//purpose : +//======================================================================= + +void SALOMEDS_OCAFApplication::Formats(TColStd_SequenceOfExtendedString& Formats) +{ + Formats.Append(TCollection_ExtendedString ("SALOME_STUDY")); +} + + +//======================================================================= +//function : ResourcesName +//purpose : +//======================================================================= + +Standard_CString SALOMEDS_OCAFApplication::ResourcesName() +{ + return Standard_CString ("SALOMEDS_Resources"); +} + + + + + diff --git a/src/SALOMEDS/SALOMEDS_OCAFApplication.hxx b/src/SALOMEDS/SALOMEDS_OCAFApplication.hxx new file mode 100644 index 000000000..49201ec44 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_OCAFApplication.hxx @@ -0,0 +1,95 @@ +// File : SALOMEDS_OCAFApplication.hxx +// Created : Thu Nov 29 21:05:19 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef _SALOMEDS_OCAFApplication_HeaderFile +#define _SALOMEDS_OCAFApplication_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_OCAFApplication_HeaderFile +#include "Handle_SALOMEDS_OCAFApplication.hxx" +#endif + +#ifndef _TDocStd_Application_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif +class TColStd_SequenceOfExtendedString; + + +class SALOMEDS_OCAFApplication : public TDocStd_Application { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT SALOMEDS_OCAFApplication(); +Standard_EXPORT virtual void Formats(TColStd_SequenceOfExtendedString& Formats) ; +Standard_EXPORT Standard_CString ResourcesName() ; +Standard_EXPORT ~SALOMEDS_OCAFApplication(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_OCAFApplication_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_OCAFApplication.ixx b/src/SALOMEDS/SALOMEDS_OCAFApplication.ixx new file mode 100644 index 000000000..e07ae8ad2 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_OCAFApplication.ixx @@ -0,0 +1,67 @@ +// File : SALOMEDS_OCAFApplication.ixx +// Created : Thu Nov 29 21:01:58 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ +#include "SALOMEDS_OCAFApplication.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_OCAFApplication::~SALOMEDS_OCAFApplication() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_OCAFApplication_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDocStd_Application); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDocStd_Application); + static Handle_Standard_Type aType2 = STANDARD_TYPE(CDF_Application); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(CDF_Application); + static Handle_Standard_Type aType3 = STANDARD_TYPE(CDM_Application); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(CDM_Application); + static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_OCAFApplication", + sizeof(SALOMEDS_OCAFApplication), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_OCAFApplication) Handle(SALOMEDS_OCAFApplication)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_OCAFApplication) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_OCAFApplication))) { + _anOtherObject = Handle(SALOMEDS_OCAFApplication)((Handle(SALOMEDS_OCAFApplication)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_OCAFApplication::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_OCAFApplication) ; +} +Standard_Boolean SALOMEDS_OCAFApplication::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_OCAFApplication) == AType || TDocStd_Application::IsKind(AType)); +} +Handle_SALOMEDS_OCAFApplication::~Handle_SALOMEDS_OCAFApplication() {} + diff --git a/src/SALOMEDS/SALOMEDS_OCAFApplication.jxx b/src/SALOMEDS/SALOMEDS_OCAFApplication.jxx new file mode 100644 index 000000000..415a966ce --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_OCAFApplication.jxx @@ -0,0 +1,6 @@ +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _SALOMEDS_OCAFApplication_HeaderFile +#include "SALOMEDS_OCAFApplication.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_OpenedAttribute.cdl b/src/SALOMEDS/SALOMEDS_OpenedAttribute.cdl new file mode 100644 index 000000000..800556db8 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_OpenedAttribute.cdl @@ -0,0 +1,62 @@ +// File : SALOMEDS_OpenedAttribute.cdl +// Created : Tue Jul 09 16:20:05 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + + + + +class OpenedAttribute from SALOMEDS inherits Integer from TDataStd + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + ExtendedString from TCollection, + DataSet from TDF, + RelocationTable from TDF, + AttributeSequence from TDF, + Data from TDF, + Comment from TDataStd + + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + Set (myclass; label : Label from TDF; value : Integer from Standard) + ---Purpose: Find, or create a Comment attribute and set the string. + -- the Comment attribute is returned. + returns OpenedAttribute from SALOMEDS; + + ---Purpose: Comment methods + -- ============ + + Create + returns mutable OpenedAttribute from SALOMEDS; + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +end OpenedAttribute; diff --git a/src/SALOMEDS/SALOMEDS_OpenedAttribute.cxx b/src/SALOMEDS/SALOMEDS_OpenedAttribute.cxx new file mode 100644 index 000000000..e2648ce67 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_OpenedAttribute.cxx @@ -0,0 +1,94 @@ +using namespace std; +// File : SALOMEDS_OpenedAttribute.cxx +// Created : Wed Nov 28 16:09:35 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + +#include "SALOMEDS_OpenedAttribute.ixx" +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_OpenedAttribute::GetID () +{ + static Standard_GUID SALOMEDS_OpenedAttributeID ("12837186-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_OpenedAttributeID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDS_OpenedAttribute) SALOMEDS_OpenedAttribute::Set (const TDF_Label& L, + const Standard_Integer value) +{ + Handle(SALOMEDS_OpenedAttribute) A; + if (!L.FindAttribute(SALOMEDS_OpenedAttribute::GetID(),A)) { + A = new SALOMEDS_OpenedAttribute(); + L.AddAttribute(A); + } + + (Handle(TDataStd_Integer)::DownCast(A))->Set (value); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDS_OpenedAttribute::SALOMEDS_OpenedAttribute() +{ + TDataStd_Integer::Set(0); +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_OpenedAttribute::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDS_OpenedAttribute::NewEmpty () const +{ + return new SALOMEDS_OpenedAttribute(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDS_OpenedAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer s = Handle(TDataStd_Integer)::DownCast (with)->Get (); + TDataStd_Integer::Set(s); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDS_OpenedAttribute::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(TDataStd_Integer)::DownCast (into)->Set (Get()); +} + diff --git a/src/SALOMEDS/SALOMEDS_OpenedAttribute.hxx b/src/SALOMEDS/SALOMEDS_OpenedAttribute.hxx new file mode 100644 index 000000000..fc89f975d --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_OpenedAttribute.hxx @@ -0,0 +1,108 @@ +// File : SALOMEDS_OpenedAttribute.hxx +// Created : Tue Jul 09 16:45:33 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _SALOMEDS_OpenedAttribute_HeaderFile +#define _SALOMEDS_OpenedAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_OpenedAttribute_HeaderFile +#include +#endif + +#ifndef _TDataStd_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class Standard_GUID; +class TDF_Label; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_OpenedAttribute : public TDataStd_Integer { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_OpenedAttribute Set(const TDF_Label& label,const Standard_Integer value) ; +Standard_EXPORT SALOMEDS_OpenedAttribute(); +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT ~SALOMEDS_OpenedAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_OpenedAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_OpenedAttribute.ixx b/src/SALOMEDS/SALOMEDS_OpenedAttribute.ixx new file mode 100644 index 000000000..9cedd1605 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_OpenedAttribute.ixx @@ -0,0 +1,68 @@ +// File : SALOMEDS_OpenedAttribute.ixx +// Created : Tue Jul 09 16:45:40 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOMEDS_OpenedAttribute.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_OpenedAttribute::~SALOMEDS_OpenedAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_OpenedAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDataStd_Integer); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDataStd_Integer); + static Handle_Standard_Type aType2 = STANDARD_TYPE(TDF_Attribute); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType3 = STANDARD_TYPE(MMgt_TShared); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_OpenedAttribute", + sizeof(SALOMEDS_OpenedAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_OpenedAttribute) Handle(SALOMEDS_OpenedAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_OpenedAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_OpenedAttribute))) { + _anOtherObject = Handle(SALOMEDS_OpenedAttribute)((Handle(SALOMEDS_OpenedAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_OpenedAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_OpenedAttribute) ; +} +Standard_Boolean SALOMEDS_OpenedAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_OpenedAttribute) == AType || TDataStd_Integer::IsKind(AType)); +} +Handle_SALOMEDS_OpenedAttribute::~Handle_SALOMEDS_OpenedAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_OpenedAttribute.jxx b/src/SALOMEDS/SALOMEDS_OpenedAttribute.jxx new file mode 100644 index 000000000..21d551e6d --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_OpenedAttribute.jxx @@ -0,0 +1,24 @@ +// File : SALOMEDS_OpenedAttribute.jxx +// Created : Tue Jul 09 16:45:45 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_OpenedAttribute_HeaderFile +#include "SALOMEDS_OpenedAttribute.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_PersRefAttribute.cdl b/src/SALOMEDS/SALOMEDS_PersRefAttribute.cdl new file mode 100644 index 000000000..512b450b7 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PersRefAttribute.cdl @@ -0,0 +1,59 @@ +// File : SALOMEDS_PersRefAttribute.cdl +// Created : Wed Nov 28 16:23:00 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +class PersRefAttribute from SALOMEDS inherits Comment from TDataStd + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + ExtendedString from TCollection, + DataSet from TDF, + RelocationTable from TDF, + AttributeSequence from TDF, + Data from TDF, + Comment from TDataStd + + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + Set (myclass; label : Label from TDF; string : ExtendedString from TCollection) + ---Purpose: Find, or create a Comment attribute and set the string. + -- the Comment attribute is returned. + returns PersRefAttribute from SALOMEDS; + + ---Purpose: Comment methods + -- ============ + + Create + returns mutable PersRefAttribute from SALOMEDS; + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +end PersRefAttribute; diff --git a/src/SALOMEDS/SALOMEDS_PersRefAttribute.cxx b/src/SALOMEDS/SALOMEDS_PersRefAttribute.cxx new file mode 100644 index 000000000..c3025e6d7 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PersRefAttribute.cxx @@ -0,0 +1,94 @@ +using namespace std; +// File : SALOMEDS_PersRefAttribute.cxx +// Created : Wed Nov 28 16:23:19 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#include "SALOMEDS_PersRefAttribute.ixx" +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_PersRefAttribute::GetID () +{ + static Standard_GUID SALOMEDS_PersRefAttributeID ("92888E06-7074-11d5-A690-0800369C8A03"); + return SALOMEDS_PersRefAttributeID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDS_PersRefAttribute) SALOMEDS_PersRefAttribute::Set (const TDF_Label& L, + const TCollection_ExtendedString& S) +{ + Handle(SALOMEDS_PersRefAttribute) A; + if (!L.FindAttribute(SALOMEDS_PersRefAttribute::GetID(),A)) { + A = new SALOMEDS_PersRefAttribute(); + L.AddAttribute(A); + } + + (Handle(TDataStd_Comment)::DownCast(A))->Set (S); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDS_PersRefAttribute::SALOMEDS_PersRefAttribute() +{} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_PersRefAttribute::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDS_PersRefAttribute::NewEmpty () const +{ + return new SALOMEDS_PersRefAttribute(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDS_PersRefAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + TCollection_ExtendedString s = Handle(TDataStd_Comment)::DownCast (with)->Get (); + TDataStd_Comment::Set(s); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDS_PersRefAttribute::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(TDataStd_Comment)::DownCast (into)->Set (Get()); +} + diff --git a/src/SALOMEDS/SALOMEDS_PersRefAttribute.hxx b/src/SALOMEDS/SALOMEDS_PersRefAttribute.hxx new file mode 100644 index 000000000..9ed9968d1 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PersRefAttribute.hxx @@ -0,0 +1,106 @@ +// File : SALOMEDS_PersRefAttribute.hxx +// Created : Thu Nov 29 21:01:34 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef _SALOMEDS_PersRefAttribute_HeaderFile +#define _SALOMEDS_PersRefAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_PersRefAttribute_HeaderFile +#include +#endif + +#ifndef _TDataStd_Comment_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class Standard_GUID; +class TDF_Label; +class TCollection_ExtendedString; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_PersRefAttribute : public TDataStd_Comment { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_PersRefAttribute Set(const TDF_Label& label,const TCollection_ExtendedString& string) ; +Standard_EXPORT SALOMEDS_PersRefAttribute(); +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT ~SALOMEDS_PersRefAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_PersRefAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_PersRefAttribute.ixx b/src/SALOMEDS/SALOMEDS_PersRefAttribute.ixx new file mode 100644 index 000000000..35d1622cb --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PersRefAttribute.ixx @@ -0,0 +1,68 @@ +// File : SALOMEDS_PersRefAttribute.ixx +// Created : Thu Nov 29 21:02:22 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#include "SALOMEDS_PersRefAttribute.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_PersRefAttribute::~SALOMEDS_PersRefAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_PersRefAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDataStd_Comment); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDataStd_Comment); + static Handle_Standard_Type aType2 = STANDARD_TYPE(TDF_Attribute); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType3 = STANDARD_TYPE(MMgt_TShared); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_PersRefAttribute", + sizeof(SALOMEDS_PersRefAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_PersRefAttribute) Handle(SALOMEDS_PersRefAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_PersRefAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_PersRefAttribute))) { + _anOtherObject = Handle(SALOMEDS_PersRefAttribute)((Handle(SALOMEDS_PersRefAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_PersRefAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_PersRefAttribute) ; +} +Standard_Boolean SALOMEDS_PersRefAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_PersRefAttribute) == AType || TDataStd_Comment::IsKind(AType)); +} +Handle_SALOMEDS_PersRefAttribute::~Handle_SALOMEDS_PersRefAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_PersRefAttribute.jxx b/src/SALOMEDS/SALOMEDS_PersRefAttribute.jxx new file mode 100644 index 000000000..28557dc82 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PersRefAttribute.jxx @@ -0,0 +1,18 @@ +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_PersRefAttribute_HeaderFile +#include "SALOMEDS_PersRefAttribute.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_PixMapAttribute.cdl b/src/SALOMEDS/SALOMEDS_PixMapAttribute.cdl new file mode 100644 index 000000000..e38db2890 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PixMapAttribute.cdl @@ -0,0 +1,60 @@ +// File : SALOMEDS_PixMapAttribute.cdl +// Created : Wed Nov 28 16:20:40 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + + + +class PixMapAttribute from SALOMEDS inherits Comment from TDataStd + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + ExtendedString from TCollection, + DataSet from TDF, + RelocationTable from TDF, + AttributeSequence from TDF, + Data from TDF, + Comment from TDataStd + + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + Set (myclass; label : Label from TDF; string : ExtendedString from TCollection) + ---Purpose: Find, or create a Comment attribute and set the string. + -- the Comment attribute is returned. + returns PixMapAttribute from SALOMEDS; + + ---Purpose: Comment methods + -- ============ + + Create + returns mutable PixMapAttribute from SALOMEDS; + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +end PixMapAttribute; diff --git a/src/SALOMEDS/SALOMEDS_PixMapAttribute.cxx b/src/SALOMEDS/SALOMEDS_PixMapAttribute.cxx new file mode 100644 index 000000000..13cdfc997 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PixMapAttribute.cxx @@ -0,0 +1,94 @@ +using namespace std; +// File : SALOMEDS_PixMapAttribute.cxx +// Created : Wed Nov 28 16:23:19 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + +#include "SALOMEDS_PixMapAttribute.ixx" +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_PixMapAttribute::GetID () +{ + static Standard_GUID SALOMEDS_PixMapAttributeID ("12837187-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_PixMapAttributeID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDS_PixMapAttribute) SALOMEDS_PixMapAttribute::Set (const TDF_Label& L, + const TCollection_ExtendedString& S) +{ + Handle(SALOMEDS_PixMapAttribute) A; + if (!L.FindAttribute(SALOMEDS_PixMapAttribute::GetID(),A)) { + A = new SALOMEDS_PixMapAttribute(); + L.AddAttribute(A); + } + + (Handle(TDataStd_Comment)::DownCast(A))->Set (S); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDS_PixMapAttribute::SALOMEDS_PixMapAttribute() +{TDataStd_Comment::Set("None");} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_PixMapAttribute::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDS_PixMapAttribute::NewEmpty () const +{ + return new SALOMEDS_PixMapAttribute(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDS_PixMapAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + TCollection_ExtendedString s = Handle(TDataStd_Comment)::DownCast (with)->Get (); + TDataStd_Comment::Set(s); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDS_PixMapAttribute::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(TDataStd_Comment)::DownCast (into)->Set (Get()); +} + diff --git a/src/SALOMEDS/SALOMEDS_PixMapAttribute.hxx b/src/SALOMEDS/SALOMEDS_PixMapAttribute.hxx new file mode 100644 index 000000000..4186216be --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PixMapAttribute.hxx @@ -0,0 +1,106 @@ +// File : SALOMEDS_PixMapAttribute.hxx +// Created : Tue Jul 09 16:46:08 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _SALOMEDS_PixMapAttribute_HeaderFile +#define _SALOMEDS_PixMapAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_PixMapAttribute_HeaderFile +#include +#endif + +#ifndef _TDataStd_Comment_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class Standard_GUID; +class TDF_Label; +class TCollection_ExtendedString; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_PixMapAttribute : public TDataStd_Comment { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_PixMapAttribute Set(const TDF_Label& label,const TCollection_ExtendedString& string) ; +Standard_EXPORT SALOMEDS_PixMapAttribute(); +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT ~SALOMEDS_PixMapAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_PixMapAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_PixMapAttribute.ixx b/src/SALOMEDS/SALOMEDS_PixMapAttribute.ixx new file mode 100644 index 000000000..69098369a --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PixMapAttribute.ixx @@ -0,0 +1,68 @@ +// File : SALOMEDS_PixMapAttribute.ixx +// Created : Tue Jul 09 16:50:05 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOMEDS_PixMapAttribute.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_PixMapAttribute::~SALOMEDS_PixMapAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_PixMapAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDataStd_Comment); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDataStd_Comment); + static Handle_Standard_Type aType2 = STANDARD_TYPE(TDF_Attribute); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType3 = STANDARD_TYPE(MMgt_TShared); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_PixMapAttribute", + sizeof(SALOMEDS_PixMapAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_PixMapAttribute) Handle(SALOMEDS_PixMapAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_PixMapAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_PixMapAttribute))) { + _anOtherObject = Handle(SALOMEDS_PixMapAttribute)((Handle(SALOMEDS_PixMapAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_PixMapAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_PixMapAttribute) ; +} +Standard_Boolean SALOMEDS_PixMapAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_PixMapAttribute) == AType || TDataStd_Comment::IsKind(AType)); +} +Handle_SALOMEDS_PixMapAttribute::~Handle_SALOMEDS_PixMapAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_PixMapAttribute.jxx b/src/SALOMEDS/SALOMEDS_PixMapAttribute.jxx new file mode 100644 index 000000000..929fb0389 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PixMapAttribute.jxx @@ -0,0 +1,27 @@ +// File : SALOMEDS_PixMapAttribute.jxx +// Created : Tue Jul 09 16:50:10 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_PixMapAttribute_HeaderFile +#include "SALOMEDS_PixMapAttribute.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.cdl b/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.cdl new file mode 100644 index 000000000..08833e57d --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.cdl @@ -0,0 +1,66 @@ +-- File : SALOMEDS_PythonObjectAttribute.cdl +-- Created : Tue Oct 8 10:13:30 2002 +-- Author : Michael Ponikarov +-- Project : SALOME +-- Module : SALOMEDS +-- Copyright : Open CASCADE +-- $Header$ + +class PythonObjectAttribute from SALOMEDS inherits Attribute from TDF + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + DataSet from TDF, + RelocationTable from TDF, + Data from TDF, + HArray1OfCharacter from TColStd + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + Set (myclass; label : Label from TDF) + returns PythonObjectAttribute from SALOMEDS; + + ---Purpose: Common methods + -- ============ + + Create + returns mutable PythonObjectAttribute from SALOMEDS; + + SetObject(me: mutable; theSequence : CString from Standard; theScript : Boolean from Standard); + + GetObject(me) returns CString from Standard; + + IsScript(me) returns Boolean from Standard; + + GetLength(me) returns Integer from Standard; + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +fields + + mySequence : CString from Standard; + myIsScript : Boolean from Standard; + +end PythonObjectAttribute; diff --git a/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.cxx b/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.cxx new file mode 100644 index 000000000..c84b4ecf9 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.cxx @@ -0,0 +1,86 @@ +using namespace std; +// File : SALOMEDS_PythonObjectAttribute.cxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#include "SALOMEDS_PythonObjectAttribute.ixx" +#include + +const Standard_GUID& SALOMEDS_PythonObjectAttribute::GetID() +{ + static Standard_GUID SALOMEDS_PythonObjectAttributeID ("128371A3-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_PythonObjectAttributeID; +} + +Handle(SALOMEDS_PythonObjectAttribute) SALOMEDS_PythonObjectAttribute::Set(const TDF_Label& label) +{ + Handle(SALOMEDS_PythonObjectAttribute) anAttr; + if (!label.FindAttribute(SALOMEDS_PythonObjectAttribute::GetID(),anAttr)) { + anAttr = new SALOMEDS_PythonObjectAttribute(); + label.AddAttribute(anAttr); + } + return anAttr; +} + +SALOMEDS_PythonObjectAttribute::SALOMEDS_PythonObjectAttribute() +{ +} + +void SALOMEDS_PythonObjectAttribute::SetObject(const Standard_CString theSequence, + const Standard_Boolean theScript) +{ + Backup(); + if(mySequence != NULL) delete mySequence; + if (theSequence == NULL) { + mySequence = NULL; + } else { + mySequence = new char[strlen(theSequence)+1]; + strcpy(mySequence, theSequence); + } + + myIsScript = theScript; +} + +Standard_CString SALOMEDS_PythonObjectAttribute::GetObject() const +{ + return mySequence; +} + +Standard_Boolean SALOMEDS_PythonObjectAttribute::IsScript() const +{ + return myIsScript; +} + +Standard_Integer SALOMEDS_PythonObjectAttribute::GetLength() const +{ + if (mySequence == NULL) return 0; + return (strlen(mySequence)+1); +} + +const Standard_GUID& SALOMEDS_PythonObjectAttribute::ID() const +{ + return GetID(); +} + +void SALOMEDS_PythonObjectAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + Handle(SALOMEDS_PythonObjectAttribute) anObj = Handle(SALOMEDS_PythonObjectAttribute)::DownCast(with); + SetObject(anObj->GetObject(),anObj->IsScript()); +} + +Handle(TDF_Attribute) SALOMEDS_PythonObjectAttribute::NewEmpty() const +{ + return new SALOMEDS_PythonObjectAttribute(); +} + +void SALOMEDS_PythonObjectAttribute::Paste(const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)&) const +{ + Handle(SALOMEDS_PythonObjectAttribute) anObj = Handle(SALOMEDS_PythonObjectAttribute)::DownCast(into); + anObj->SetObject(GetObject(),IsScript()); +} + diff --git a/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.hxx b/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.hxx new file mode 100644 index 000000000..4ec505f9e --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.hxx @@ -0,0 +1,123 @@ +// File : SALOMEDS_PythonObjectAttribute.hxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#ifndef _SALOMEDS_PythonObjectAttribute_HeaderFile +#define _SALOMEDS_PythonObjectAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_PythonObjectAttribute_HeaderFile +#include +#endif + +#ifndef _Handle_TColStd_HArray1OfCharacter_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class TColStd_HArray1OfCharacter; +class Standard_GUID; +class TDF_Label; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_PythonObjectAttribute : public TDF_Attribute { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_PythonObjectAttribute Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDS_PythonObjectAttribute(); +Standard_EXPORT void SetObject(const Standard_CString theSequence,const Standard_Boolean theScript) ; +Standard_EXPORT Standard_CString GetObject() const; +Standard_EXPORT Standard_Boolean IsScript() const; +Standard_EXPORT Standard_Integer GetLength() const; +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT ~SALOMEDS_PythonObjectAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_PythonObjectAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_CString mySequence; +Standard_Boolean myIsScript; + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.ixx b/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.ixx new file mode 100644 index 000000000..ce6485efd --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.ixx @@ -0,0 +1,65 @@ +// File : SALOMEDS_PythonObjectAttribute.ixx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#include "SALOMEDS_PythonObjectAttribute.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_PythonObjectAttribute::~SALOMEDS_PythonObjectAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_PythonObjectAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDF_Attribute); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_PythonObjectAttribute", + sizeof(SALOMEDS_PythonObjectAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_PythonObjectAttribute) Handle(SALOMEDS_PythonObjectAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_PythonObjectAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_PythonObjectAttribute))) { + _anOtherObject = Handle(SALOMEDS_PythonObjectAttribute)((Handle(SALOMEDS_PythonObjectAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_PythonObjectAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_PythonObjectAttribute) ; +} +Standard_Boolean SALOMEDS_PythonObjectAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_PythonObjectAttribute) == AType || TDF_Attribute::IsKind(AType)); +} +Handle_SALOMEDS_PythonObjectAttribute::~Handle_SALOMEDS_PythonObjectAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.jxx b/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.jxx new file mode 100644 index 000000000..09c069968 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_PythonObjectAttribute.jxx @@ -0,0 +1,26 @@ +// File : SALOMEDS_PythonObjectAttribute.jxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#ifndef _TColStd_HArray1OfCharacter_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_PythonObjectAttribute_HeaderFile +#include "SALOMEDS_PythonObjectAttribute.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_SAttribute_i.hxx b/src/SALOMEDS/SALOMEDS_SAttribute_i.hxx new file mode 100644 index 000000000..848f7f34a --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SAttribute_i.hxx @@ -0,0 +1,44 @@ +// File : SALOMEDS_SAttribute_i.hxx +// Created : Thu Nov 29 21:02:46 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef __SALOMEDS_SATTRIBUTE_I_H__ +#define __SALOMEDS_SATTRIBUTE_I_H__ + +// std C++ headers +#include + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + + + +// Cascade headers +#include +#include + +class SALOMEDS_SAttribute_i: public POA_IStudy::SAttribute, + public PortableServer::RefCountServantBase { +private: + CORBA::ORB_ptr _orb; + char* _Type; + char +public: + + SALOMEDS_SAttribute_i(const Handle(TDocStd_Document), CORBA::ORB_ptr); + + ~SALOMEDS_SAttribute_i(); + + virtual char* GetID() ; + virtual SObject_ptr GetOwner(); + virtual char* GetType(); + virtual char* GetValue(); + +}; +#endif diff --git a/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx b/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx new file mode 100644 index 000000000..f757e2900 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx @@ -0,0 +1,84 @@ +using namespace std; +// File : SALOMEDS_SComponentIterator_i.cxx +// Created : Wed Nov 28 16:23:49 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#include "SALOMEDS_SComponentIterator_i.hxx" + + +//============================================================================ +/*! Function : constructor + * + */ +//============================================================================ + +SALOMEDS_SComponentIterator_i::SALOMEDS_SComponentIterator_i(const Handle(TDocStd_Document) aDoc, + CORBA::ORB_ptr orb) +{ + _orb = CORBA::ORB::_duplicate(orb); + _lab = aDoc->Main(); + _it.Initialize (_lab); +} + +//============================================================================ +/*! Function : destructor + * + */ +//============================================================================ +SALOMEDS_SComponentIterator_i::~SALOMEDS_SComponentIterator_i() +{ +} + +//============================================================================ +/*! Function : Init + * + */ +//============================================================================ +void SALOMEDS_SComponentIterator_i::Init() +{ + _it.Initialize (_lab); +} + +//============================================================================ +/*! Function : More + * + */ +//============================================================================ +CORBA::Boolean SALOMEDS_SComponentIterator_i::More() +{ + if (!_it.More()) + return false; + TDF_Label L = _it.Value(); + if (SALOMEDS_SComponent_i::IsA(L)) + return true; + + return _it.More(); +} + + //============================================================================ +/*! Function : Next + */ +//============================================================================ +void SALOMEDS_SComponentIterator_i::Next() +{ + _it.Next(); +} + + +//============================================================================ +/*! Function : Value + * + */ +//============================================================================ +SALOMEDS::SComponent_ptr SALOMEDS_SComponentIterator_i::Value() +{ + SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (_it.Value(),_orb); + SALOMEDS::SComponent_var so = SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); //pb d'heritage?? + return so; +} + diff --git a/src/SALOMEDS/SALOMEDS_SComponentIterator_i.hxx b/src/SALOMEDS/SALOMEDS_SComponentIterator_i.hxx new file mode 100644 index 000000000..35a821d93 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SComponentIterator_i.hxx @@ -0,0 +1,49 @@ +// File : SALOMEDS_SComponentIterator_i.hxx +// Created : Wed Nov 28 16:24:22 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef __SALOMEDS_SCOMPONENTITERATOR_I_H__ +#define __SALOMEDS_SCOMPONENTITERATOR_I_H__ + +// std C++ headers +#include + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +//SALOMEDS headers +#include "SALOMEDS_SComponent_i.hxx" + +// Cascade headers +#include +#include +#include +#include + +class SALOMEDS_SComponentIterator_i:public POA_SALOMEDS::SComponentIterator, + public PortableServer::RefCountServantBase { + +private: + + CORBA::ORB_ptr _orb; + TDF_ChildIterator _it; + TDF_Label _lab; + +public: + + SALOMEDS_SComponentIterator_i(const Handle(TDocStd_Document) adoc, CORBA::ORB_ptr); + + ~SALOMEDS_SComponentIterator_i(); + + virtual void Init(); + virtual CORBA::Boolean More(); + virtual void Next(); + virtual SALOMEDS::SComponent_ptr Value(); +}; +#endif diff --git a/src/SALOMEDS/SALOMEDS_SComponent_i.cxx b/src/SALOMEDS/SALOMEDS_SComponent_i.cxx new file mode 100644 index 000000000..de76b6155 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SComponent_i.cxx @@ -0,0 +1,91 @@ +using namespace std; +// File : SALOMEDS_SComponent_i.cxx +// Created : Wed Nov 28 16:24:34 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#include "SALOMEDS_SComponent_i.hxx" +#include "utilities.h" + + +//============================================================================ +/*! Function : constructor + * Purpose : + */ +//============================================================================ +SALOMEDS_SComponent_i::SALOMEDS_SComponent_i(const TDF_Label lab, CORBA::ORB_ptr orb) + :SALOMEDS_SObject_i(lab,orb) +{ +} + +//============================================================================ +/*! Function : destructor + * Purpose : + */ +//============================================================================ +SALOMEDS_SComponent_i::~SALOMEDS_SComponent_i() +{ +} + + +//============================================================================ +/*! Function : ComponentDataType + * Purpose : + */ +//============================================================================ +char* SALOMEDS_SComponent_i::ComponentDataType() +{ + //DEB + // MESSAGE("In SALOMEDS_SComponent_i::ComponentDataType"); + // TCollection_AsciiString anEntry; + // TDF_Tool::Entry (_lab,anEntry); + // MESSAGE("in SALOMEDS_SComponent_i, Entry :"<Get()); + res = ch.ToCString(); + } + + return CORBA::string_dup(res); +} + + +//============================================================================ +/*! Function : ComponentIOR + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_SComponent_i::ComponentIOR(CORBA::String_out IOR) +{ + Handle(SALOMEDS_IORAttribute) ior; + if (!_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),ior) ) + return false; + TCollection_AsciiString ch(ior->Get()); + IOR = strdup(ch.ToCString()); + return true; +} + + +//============================================================================ +/*! Function : IsA + * Purpose : + */ +//============================================================================ +Standard_Boolean SALOMEDS_SComponent_i::IsA(const TDF_Label Lab) +{ + Handle(TDF_Attribute) Att; + // scomponent must contain comment and belong to the 2th depth label + if ( Lab.FindAttribute(TDataStd_Comment::GetID(), Att) && Lab.Depth() == 2) { + return Standard_True; + } + return Standard_False; +} + + diff --git a/src/SALOMEDS/SALOMEDS_SComponent_i.hxx b/src/SALOMEDS/SALOMEDS_SComponent_i.hxx new file mode 100644 index 000000000..0d1f0a0d1 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SComponent_i.hxx @@ -0,0 +1,49 @@ +// File : SALOMEDS_SComponent_i.hxx +// Created : Wed Nov 28 16:24:50 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef __SALOMEDS_SCOMPONENT_I_H__ +#define __SALOMEDS_SCOMPONENT_I_H__ + +// std C++ headers +#include + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +//SALOMEDS headers +#include "SALOMEDS_SObject_i.hxx" +#include "SALOMEDS_IORAttribute.hxx" + +// Cascade headers +#include +#include +#include +#include +#include +#include + +class SALOMEDS_SComponent_i: public POA_SALOMEDS::SComponent, + public SALOMEDS_SObject_i +{ +public: + + SALOMEDS_SComponent_i(const TDF_Label lab, CORBA::ORB_ptr); + + ~SALOMEDS_SComponent_i(); + + + virtual char* ComponentDataType(); + virtual CORBA::Boolean ComponentIOR(CORBA::String_out theID); + + static Standard_Boolean IsA(const TDF_Label Lab); + + +}; +#endif diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.cxx b/src/SALOMEDS/SALOMEDS_SObject_i.cxx new file mode 100644 index 000000000..71b4c7bc0 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@ -0,0 +1,545 @@ +using namespace std; +// File : SALOMEDS_SObject_i.cxx +// Created : Thu Nov 29 21:03:39 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#include "utilities.h" +#include "SALOMEDS_SObject_i.hxx" +//SALOMEDS Headers +#include "SALOMEDS_SComponent_i.hxx" +#include "SALOMEDS_IORAttribute.hxx" +#include "SALOMEDS_PersRefAttribute.hxx" +#include "SALOMEDS_SequenceOfRealAttribute.hxx" +#include "SALOMEDS_SequenceOfIntegerAttribute.hxx" +#include "SALOMEDS_TableOfRealAttribute.hxx" +#include "SALOMEDS_TableOfIntegerAttribute.hxx" +#include "SALOMEDS_IORAttribute.hxx" +#include "SALOMEDS_PersRefAttribute.hxx" +#include "SALOMEDS_StudyPropertiesAttribute.hxx" +#include "SALOMEDS_PythonObjectAttribute.hxx" +#include "SALOMEDS_AttributePersistentRef_i.hxx" +#include "SALOMEDS_AttributeIOR_i.hxx" +#include "SALOMEDS_AttributeComment_i.hxx" +#include "SALOMEDS_AttributeName_i.hxx" +#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx" +#include "SALOMEDS_AttributeSequenceOfReal_i.hxx" +#include "SALOMEDS_AttributeInteger_i.hxx" +#include "SALOMEDS_AttributeReal_i.hxx" +#include "SALOMEDS_AttributeDrawable_i.hxx" +#include "SALOMEDS_AttributeSelectable_i.hxx" +#include "SALOMEDS_AttributeExpandable_i.hxx" +#include "SALOMEDS_AttributeOpened_i.hxx" +#include "SALOMEDS_AttributeTextColor_i.hxx" +#include "SALOMEDS_AttributeTextHighlightColor_i.hxx" +#include "SALOMEDS_AttributePixMap_i.hxx" +#include "SALOMEDS_AttributeTreeNode_i.hxx" +#include "SALOMEDS_AttributeLocalID_i.hxx" +#include "SALOMEDS_AttributeUserID_i.hxx" +#include "SALOMEDS_AttributeTarget_i.hxx" +#include "SALOMEDS_AttributeTableOfInteger_i.hxx" +#include "SALOMEDS_AttributeTableOfReal_i.hxx" +#include "SALOMEDS_AttributeTableOfString_i.hxx" +#include "SALOMEDS_AttributeStudyProperties_i.hxx" +#include "SALOMEDS_AttributePythonObject_i.hxx" +#include + +//============================================================================ +/*! Function : ReturnGUIDForAttribute + * Purpose : + */ +//============================================================================ + +Standard_GUID +SALOMEDS_SObject_i::ReturnGUIDForAttribute(const char* aTypeOfAttribute) +{ + Standard_GUID TypeID; + + if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) return TDataStd_Real::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) return TDataStd_Integer::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) return SALOMEDS_SequenceOfRealAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) return SALOMEDS_SequenceOfIntegerAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) return TDataStd_Name::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) return TDataStd_Comment::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) return SALOMEDS_IORAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) return SALOMEDS_PersRefAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) return SALOMEDS_DrawableAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) return SALOMEDS_SelectableAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) return SALOMEDS_ExpandableAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) return SALOMEDS_OpenedAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) return SALOMEDS_TextColorAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) return SALOMEDS_TextHighlightColorAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) return SALOMEDS_PixMapAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeTreeNode") == 0 ) return TDataStd_TreeNode::GetDefaultTreeID(); + else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) return SALOMEDS_LocalIDAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) return SALOMEDS_TargetAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) return SALOMEDS_TableOfIntegerAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) return SALOMEDS_TableOfRealAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) return SALOMEDS_TableOfStringAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) return SALOMEDS_StudyPropertiesAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) return SALOMEDS_PythonObjectAttribute::GetID(); + else if (strcmp(aTypeOfAttribute, "AttributeUserID") == 0 ) return SALOMEDS_AttributeUserID_i::DefaultID(); + else if (strncmp(aTypeOfAttribute,"AttributeTreeNodeGUID",21) == 0) { + char* aGUIDString = new char[40]; + sprintf(aGUIDString, &(aTypeOfAttribute[21])); + Standard_GUID aGUID = Standard_GUID(aGUIDString); // create tree node GUID by name + delete(aGUIDString); + return aGUID; + } + else Standard_NoSuchObject::Raise("SALOMEDS_SObject_i::ReturnGUIDForAttribute"); +} + +//============================================================================ +/*! Function : AttributeIDToType + * Purpose : + */ +//============================================================================ +char* SALOMEDS_SObject_i::AttributeIDToType(Standard_GUID ID) +{ + if (ID == TDataStd_Name::GetID()) return "AttributeName"; + else if (ID == TDataStd_Comment::GetID()) return "AttributeComment"; + else if (ID == SALOMEDS_IORAttribute::GetID()) return "AttributeIOR"; + else if (ID == SALOMEDS_PersRefAttribute::GetID()) return "AttributePersistentRef"; + else if (ID == TDataStd_Real::GetID()) return "AttributeReal"; + else if (ID == TDataStd_Integer::GetID()) return "AttributeInteger"; + else if (ID == SALOMEDS_SequenceOfRealAttribute::GetID()) return "AttributeSequenceOfReal"; + else if (ID == SALOMEDS_SequenceOfIntegerAttribute::GetID()) return "AttributeSequenceOfInteger"; + else if (ID == SALOMEDS_DrawableAttribute::GetID()) return "AttributeDrawable"; + else if (ID == SALOMEDS_SelectableAttribute::GetID()) return "AttributeSelectable"; + else if (ID == SALOMEDS_ExpandableAttribute::GetID()) return "AttributeExpandable"; + else if (ID == SALOMEDS_OpenedAttribute::GetID()) return "AttributeOpened"; + else if (ID == SALOMEDS_TextColorAttribute::GetID()) return "AttributeTextColor"; + else if (ID == SALOMEDS_TextHighlightColorAttribute::GetID()) return "AttributeTextHighlightColor"; + else if (ID == SALOMEDS_PixMapAttribute::GetID()) return "AttributePixMap"; + else if (ID == TDataStd_TreeNode::GetDefaultTreeID()) return "AttributeTreeNode"; + else if (ID == SALOMEDS_LocalIDAttribute::GetID()) return "AttributeLocalID"; + else if (ID == SALOMEDS_TargetAttribute::GetID()) return "AttributeTarget"; + else if (ID == SALOMEDS_TableOfIntegerAttribute::GetID()) return "AttributeTableOfInteger"; + else if (ID == SALOMEDS_TableOfRealAttribute::GetID()) return "AttributeTableOfReal"; + else if (ID == SALOMEDS_TableOfStringAttribute::GetID()) return "AttributeTableOfString"; + else if (ID == SALOMEDS_StudyPropertiesAttribute::GetID()) return "AttributeStudyProperties"; + else if (ID == SALOMEDS_PythonObjectAttribute::GetID()) return "AttributePythonObject"; + else if (ID == SALOMEDS_AttributeUserID_i::DefaultID()) return "AttributeUserID"; + // 08.01.2003 mpv: this method must be called only for attributes with constant GUID + else Standard_NoSuchObject::Raise("SALOMEDS_SObject_i::AttributeIDToType"); +} + + +//============================================================================ +/*! Function : constructor + * Purpose : + */ +//============================================================================ +SALOMEDS_SObject_i::SALOMEDS_SObject_i(const TDF_Label lab, CORBA::ORB_ptr orb) + :_lab(lab) +{ + _orb = CORBA::ORB::_duplicate(orb); + _value = NULL; + _type = NULL; + _name = NULL; + _liste_ba_type.resize(0); +} + + +//============================================================================ +/*! Function : destructor + * Purpose : + */ +//============================================================================ +SALOMEDS_SObject_i::~SALOMEDS_SObject_i() +{ + CORBA::string_free(_value); + CORBA::string_free(_type); + CORBA::string_free(_name); +} + + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +char* SALOMEDS_SObject_i::GetID() +{ + TCollection_AsciiString anEntry; + TDF_Tool::Entry (_lab,anEntry); + return CORBA::string_dup(anEntry.ToCString()); +} + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +SALOMEDS::SComponent_ptr SALOMEDS_SObject_i::GetFatherComponent() +{ + TDF_Label LF = _lab; + while (!SALOMEDS_SComponent_i::IsA(LF) && !LF.IsRoot()) { + LF = LF.Father(); + } + SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (LF,_orb); + SALOMEDS::SComponent_var so; + so= SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); + return so; +} + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +SALOMEDS::SObject_ptr SALOMEDS_SObject_i::GetFather() +{ + TDF_Label LF = _lab.Father(); + + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (LF,_orb); + SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + return so; +} + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +SALOMEDS::Study_ptr SALOMEDS_SObject_i::GetStudy() +{ + TDF_Label Root = _lab.Root(); + Handle(SALOMEDS_IORAttribute) Att; + char* IOR; + if (Root.FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){ + TCollection_AsciiString ch(Att->Get()); + IOR = CORBA::string_dup(ch.ToCString()); + CORBA::Object_var obj = _orb->string_to_object(IOR); + SALOMEDS::Study_var Study = SALOMEDS::Study::_narrow(obj) ; + ASSERT(!CORBA::is_nil(Study)); + return SALOMEDS::Study::_duplicate(Study); //return Study = abort... + } + INFOS("Problem GetStudy"); + return SALOMEDS::Study::_nil(); +} + +//============================================================================ +/*! Function : FindAttribute + * Purpose : Find attribute of given type on this SObject + */ +//============================================================================ +CORBA::Boolean SALOMEDS_SObject_i::FindAttribute (SALOMEDS::GenericAttribute_out anAttribute, + const char* aTypeOfAttribute) +{ + Handle(TDF_Attribute) anAttr; + Standard_Boolean found = _lab.FindAttribute(SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute), anAttr); + if (found) { + if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) { + SALOMEDS_AttributeReal_i* Attr = new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeReal::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) { + SALOMEDS_AttributeInteger_i* Attr = new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeInteger::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) { + SALOMEDS_AttributeSequenceOfReal_i* Attr = new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeSequenceOfReal::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) { + SALOMEDS_AttributeSequenceOfInteger_i* Attr = new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeSequenceOfInteger::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) { + SALOMEDS_AttributeName_i* Attr = new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeName::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) { + SALOMEDS_AttributeComment_i* Attr = new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeComment::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) { + SALOMEDS_AttributeIOR_i* Attr = new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeIOR::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) { + SALOMEDS_AttributePersistentRef_i* Attr = new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributePersistentRef::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) { + SALOMEDS_AttributeDrawable_i* Attr = new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeDrawable::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) { + SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeSelectable::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) { + SALOMEDS_AttributeExpandable_i* Attr = new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeExpandable::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) { + SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeOpened::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) { + SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTextColor::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) { + SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTextHighlightColor::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) { + SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributePixMap::_this(); + return Standard_True; + } + else if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) { + SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTreeNode::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) { + SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeLocalID::_this(); + return Standard_True; + } + else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) { + SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeUserID::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) { + SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTarget::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) { + SALOMEDS_AttributeTableOfInteger_i* Attr = new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTableOfInteger::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) { + SALOMEDS_AttributeTableOfReal_i* Attr = new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTableOfReal::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) { + SALOMEDS_AttributeTableOfString_i* Attr = new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTableOfString::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) { + SALOMEDS_AttributeStudyProperties_i* Attr = new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeStudyProperties::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) { + SALOMEDS_AttributePythonObject_i* Attr = new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributePythonObject::_this(); + return Standard_True; + } + } else return Standard_False; +} + +//============================================================================ +/*! Function : GetAllAttributes + * Purpose : Returns list of all attributes for this sobject + */ +//============================================================================ + +SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes() +{ + Standard_Integer NumAttr = _lab.NbAttributes(); + SALOMEDS::ListOfAttributes_var SeqOfAttr = new SALOMEDS::ListOfAttributes; + SeqOfAttr->length(NumAttr); + if (NumAttr != 0) { + Standard_Integer i = 0; + for(TDF_AttributeIterator iter(_lab);iter.More();iter.Next()) { + Handle(TDF_Attribute) anAttr = iter.Value(); + SALOMEDS::GenericAttribute_var anAttribute; + if (ReturnGUIDForAttribute("AttributeReal") == anAttr->ID()) { + SALOMEDS_AttributeReal_i* Attr= new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeReal::_this(); + } + else if (ReturnGUIDForAttribute("AttributeInteger") == anAttr->ID()) { + SALOMEDS_AttributeInteger_i* Attr= new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeInteger::_this(); + } + else if (ReturnGUIDForAttribute("AttributeSequenceOfReal") == anAttr->ID()) { + SALOMEDS_AttributeSequenceOfReal_i* Attr= new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeSequenceOfReal::_this(); + } + else if (ReturnGUIDForAttribute("AttributeSequenceOfInteger") == anAttr->ID()) { + SALOMEDS_AttributeSequenceOfInteger_i* Attr= new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeSequenceOfInteger::_this(); + } + else if (ReturnGUIDForAttribute("AttributeName") == anAttr->ID()) { + SALOMEDS_AttributeName_i* Attr= new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeName::_this(); + } + else if (ReturnGUIDForAttribute("AttributeComment") == anAttr->ID()) { + SALOMEDS_AttributeComment_i* Attr= new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeComment::_this(); + } + else if (ReturnGUIDForAttribute("AttributeIOR") == anAttr->ID()) { + SALOMEDS_AttributeIOR_i* Attr= new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeIOR::_this(); + } + else if (ReturnGUIDForAttribute("AttributePersistentRef") == anAttr->ID()) { + SALOMEDS_AttributePersistentRef_i* Attr= new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributePersistentRef::_this(); + } + else if (ReturnGUIDForAttribute("AttributeDrawable") == anAttr->ID()) { + SALOMEDS_AttributeDrawable_i* Attr= new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeDrawable::_this(); + } + else if (ReturnGUIDForAttribute("AttributeSelectable") == anAttr->ID()) { + SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeSelectable::_this(); + } + else if (ReturnGUIDForAttribute("AttributeExpandable") == anAttr->ID()) { + SALOMEDS_AttributeExpandable_i* Attr= new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeExpandable::_this(); + } + else if (ReturnGUIDForAttribute("AttributeOpened") == anAttr->ID()) { + SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeOpened::_this(); + } + else if (ReturnGUIDForAttribute("AttributeTextColor") == anAttr->ID()) { + SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTextColor::_this(); + } + else if (ReturnGUIDForAttribute("AttributeTextHighlightColor") == anAttr->ID()) { + SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTextHighlightColor::_this(); + } + else if (ReturnGUIDForAttribute("AttributePixMap") == anAttr->ID()) { + SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributePixMap::_this(); + } + else if (ReturnGUIDForAttribute("AttributeTreeNode") == anAttr->ID()) { + SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTreeNode::_this(); + } + else if (ReturnGUIDForAttribute("AttributeLocalID") == anAttr->ID()) { + SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeLocalID::_this(); + } + else if (ReturnGUIDForAttribute("AttributeTarget") == anAttr->ID()) { + SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTarget::_this(); + } + else if (ReturnGUIDForAttribute("AttributeTableOfInteger") == anAttr->ID()) { + SALOMEDS_AttributeTableOfInteger_i* Attr= new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTableOfInteger::_this(); + } + else if (ReturnGUIDForAttribute("AttributeTableOfReal") == anAttr->ID()) { + SALOMEDS_AttributeTableOfReal_i* Attr= new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTableOfReal::_this(); + } + else if (ReturnGUIDForAttribute("AttributeTableOfString") == anAttr->ID()) { + SALOMEDS_AttributeTableOfString_i* Attr= new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTableOfString::_this(); + } + else if (ReturnGUIDForAttribute("AttributeStudyProperties") == anAttr->ID()) { + SALOMEDS_AttributeStudyProperties_i* Attr= new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeStudyProperties::_this(); + } + else if (ReturnGUIDForAttribute("AttributePythonObject") == anAttr->ID()) { + SALOMEDS_AttributePythonObject_i* Attr= new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributePythonObject::_this(); + } + else if (!Handle(TDataStd_UAttribute)::DownCast(anAttr).IsNull()) { + SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeUserID::_this(); + } + else if (!Handle(TDataStd_TreeNode)::DownCast(anAttr).IsNull()) { + SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTreeNode::_this(); + } + + SeqOfAttr[i] = anAttribute; + i++; + } + } + return SeqOfAttr._retn(); +} + + +//============================================================================ +/*! Function : ReferencedObject + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_SObject_i::ReferencedObject(SALOMEDS::SObject_out obj) +{ + Handle(TDF_Reference) Ref; + if (!_lab.FindAttribute(TDF_Reference::GetID(),Ref)) + return false; + + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (Ref->Get(),_orb); + obj = SALOMEDS::SObject::_narrow(so_servant->_this()); + return true; +} + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_SObject_i::FindSubObject(long atag, SALOMEDS::SObject_out obj) +{ + TDF_Label L = _lab.FindChild(atag,false); + if (L.IsNull()) return false; + + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (L,_orb); + obj = SALOMEDS::SObject::_narrow(so_servant->_this()); + return true; + +} + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +char* SALOMEDS_SObject_i::Name() +{ + return CORBA::string_dup(_name); +} + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +void SALOMEDS_SObject_i::Name(const char* name) +{ + _name = CORBA::string_dup(name); +} + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ +CORBA::Short SALOMEDS_SObject_i::Tag() +{ + return _lab.Tag(); +} diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.hxx b/src/SALOMEDS/SALOMEDS_SObject_i.hxx new file mode 100644 index 000000000..e652be1f4 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SObject_i.hxx @@ -0,0 +1,72 @@ +// File : SALOMEDS_SObject_i.hxx +// Created : Wed Nov 28 16:25:50 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef __SALOMEDS_SOBJECT_I_H__ +#define __SALOMEDS_SOBJECT_I_H__ + +// std C++ headers +#include +#include +#include + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +// Cascade headers +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +class SALOMEDS_SObject_i: public POA_SALOMEDS::SObject, + public PortableServer::RefCountServantBase { +protected: + CORBA::ORB_ptr _orb; + TDF_Label _lab; + char* _name; + char* _value; + char* _type; + vector _liste_ba_type; + +public: + + SALOMEDS_SObject_i(const TDF_Label, CORBA::ORB_ptr); + + ~SALOMEDS_SObject_i(); + + virtual char* GetID(); + virtual SALOMEDS::SComponent_ptr GetFatherComponent(); + virtual SALOMEDS::SObject_ptr GetFather() ; + virtual CORBA::Boolean FindAttribute(SALOMEDS::GenericAttribute_out anAttribute, const char* aTypeOfAttribute); + virtual CORBA::Boolean ReferencedObject(SALOMEDS::SObject_out obj) ; + virtual CORBA::Boolean FindSubObject(long atag, SALOMEDS::SObject_out obj ); + + virtual SALOMEDS::Study_ptr GetStudy() ; + virtual char* Name(); + virtual void Name(const char*); + virtual SALOMEDS::ListOfAttributes* GetAllAttributes(); + + + virtual CORBA::Short Tag(); + + static char* AttributeIDToType(Standard_GUID); + + static Standard_GUID ReturnGUIDForAttribute(const char* aTypeOfAttribute); + +}; +#endif diff --git a/src/SALOMEDS/SALOMEDS_SelectableAttribute.cdl b/src/SALOMEDS/SALOMEDS_SelectableAttribute.cdl new file mode 100644 index 000000000..4f052be1b --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SelectableAttribute.cdl @@ -0,0 +1,62 @@ +// File : SALOMEDS_SelectableAttribute.cdl +// Created : Tue Jul 09 16:20:05 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + + + + +class SelectableAttribute from SALOMEDS inherits Integer from TDataStd + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + ExtendedString from TCollection, + DataSet from TDF, + RelocationTable from TDF, + AttributeSequence from TDF, + Data from TDF, + Comment from TDataStd + + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + Set (myclass; label : Label from TDF; value : Integer from Standard) + ---Purpose: Find, or create a Comment attribute and set the string. + -- the Comment attribute is returned. + returns SelectableAttribute from SALOMEDS; + + ---Purpose: Comment methods + -- ============ + + Create + returns mutable SelectableAttribute from SALOMEDS; + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +end SelectableAttribute; diff --git a/src/SALOMEDS/SALOMEDS_SelectableAttribute.cxx b/src/SALOMEDS/SALOMEDS_SelectableAttribute.cxx new file mode 100644 index 000000000..8f9d1992f --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SelectableAttribute.cxx @@ -0,0 +1,94 @@ +using namespace std; +// File : SALOMEDS_SelectableAttribute.cxx +// Created : Wed Nov 28 16:09:35 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + +#include "SALOMEDS_SelectableAttribute.ixx" +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_SelectableAttribute::GetID () +{ + static Standard_GUID SALOMEDS_SelectableAttributeID ("12837188-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_SelectableAttributeID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDS_SelectableAttribute) SALOMEDS_SelectableAttribute::Set (const TDF_Label& L, + const Standard_Integer value) +{ + Handle(SALOMEDS_SelectableAttribute) A; + if (!L.FindAttribute(SALOMEDS_SelectableAttribute::GetID(),A)) { + A = new SALOMEDS_SelectableAttribute(); + L.AddAttribute(A); + } + + (Handle(TDataStd_Integer)::DownCast(A))->Set (value); + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDS_SelectableAttribute::SALOMEDS_SelectableAttribute() +{ + TDataStd_Integer::Set(0); +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_SelectableAttribute::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDS_SelectableAttribute::NewEmpty () const +{ + return new SALOMEDS_SelectableAttribute(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDS_SelectableAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer s = Handle(TDataStd_Integer)::DownCast (with)->Get (); + TDataStd_Integer::Set(s); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDS_SelectableAttribute::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(TDataStd_Integer)::DownCast (into)->Set (Get()); +} + diff --git a/src/SALOMEDS/SALOMEDS_SelectableAttribute.hxx b/src/SALOMEDS/SALOMEDS_SelectableAttribute.hxx new file mode 100644 index 000000000..a31f6f659 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SelectableAttribute.hxx @@ -0,0 +1,108 @@ +// File : SALOMEDS_SelectableAttribute.hxx +// Created : Tue Jul 09 16:51:46 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _SALOMEDS_SelectableAttribute_HeaderFile +#define _SALOMEDS_SelectableAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_SelectableAttribute_HeaderFile +#include +#endif + +#ifndef _TDataStd_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class Standard_GUID; +class TDF_Label; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_SelectableAttribute : public TDataStd_Integer { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_SelectableAttribute Set(const TDF_Label& label,const Standard_Integer value) ; +Standard_EXPORT SALOMEDS_SelectableAttribute(); +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT ~SALOMEDS_SelectableAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_SelectableAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_SelectableAttribute.ixx b/src/SALOMEDS/SALOMEDS_SelectableAttribute.ixx new file mode 100644 index 000000000..b191249a2 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SelectableAttribute.ixx @@ -0,0 +1,68 @@ +// File : SALOMEDS_SelectableAttribute.ixx +// Created : Tue Jul 09 16:51:55 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOMEDS_SelectableAttribute.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_SelectableAttribute::~SALOMEDS_SelectableAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_SelectableAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDataStd_Integer); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDataStd_Integer); + static Handle_Standard_Type aType2 = STANDARD_TYPE(TDF_Attribute); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType3 = STANDARD_TYPE(MMgt_TShared); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_SelectableAttribute", + sizeof(SALOMEDS_SelectableAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_SelectableAttribute) Handle(SALOMEDS_SelectableAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_SelectableAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_SelectableAttribute))) { + _anOtherObject = Handle(SALOMEDS_SelectableAttribute)((Handle(SALOMEDS_SelectableAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_SelectableAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_SelectableAttribute) ; +} +Standard_Boolean SALOMEDS_SelectableAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_SelectableAttribute) == AType || TDataStd_Integer::IsKind(AType)); +} +Handle_SALOMEDS_SelectableAttribute::~Handle_SALOMEDS_SelectableAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_SelectableAttribute.jxx b/src/SALOMEDS/SALOMEDS_SelectableAttribute.jxx new file mode 100644 index 000000000..053dd0f44 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SelectableAttribute.jxx @@ -0,0 +1,24 @@ +// File : SALOMEDS_SelectableAttribute.jxx +// Created : Tue Jul 09 16:52:00 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_SelectableAttribute_HeaderFile +#include "SALOMEDS_SelectableAttribute.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.cdl b/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.cdl new file mode 100644 index 000000000..c252fe691 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.cdl @@ -0,0 +1,87 @@ +// File : SALOMEDS_SequenceOfIntegerAttribute.cdl +// Created : Wed Nov 28 16:20:40 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + + + +class SequenceOfIntegerAttribute from SALOMEDS inherits Attribute from TDF + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + HSequenceOfInteger from TColStd, + DataSet from TDF, + RelocationTable from TDF, + AttributeSequence from TDF, + Data from TDF, + Comment from TDataStd + + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + Set (myclass; label : Label from TDF) + ---Purpose: Find, or create a Comment attribute and set the string. + -- the Comment attribute is returned. + returns SequenceOfIntegerAttribute from SALOMEDS; + + ---Purpose: Comment methods + -- ============ + + Create + returns mutable SequenceOfIntegerAttribute from SALOMEDS; + + ---Category: IntegerArray methods + -- =============== + + Assign(me : mutable; other : HSequenceOfInteger from TColStd); + ---Purpose: Initialize the inner sequence by other one + + ChangeValue (me : mutable; Index, Value : Integer from Standard); + ---Purpose: Sets the th element of the sequence to + + Add (me : mutable; value : Integer from Standard); + ---Purpose: Add new value + + Value (me : mutable; Index : Integer from Standard) returns Integer; + ---Purpose: Value of index + + Remove (me : mutable; Index : Integer from Standard); + ---Purpose: Remove element on index + + Length (me : mutable) returns Integer; + ---Purpose: Returns length of sequence + + + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +fields + + myValue : HSequenceOfInteger from TColStd; + +end SequenceOfIntegerAttribute; diff --git a/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.cxx b/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.cxx new file mode 100644 index 000000000..01e19e184 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.cxx @@ -0,0 +1,131 @@ +using namespace std; +// File : SALOMEDS_SequenceOfIntegerAttribute.cxx +// Created : Wed Nov 28 16:09:35 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + +#include "SALOMEDS_SequenceOfIntegerAttribute.ixx" + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_SequenceOfIntegerAttribute::GetID () +{ + static Standard_GUID SALOMEDS_SequenceOfIntegerAttributeID ("12837182-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_SequenceOfIntegerAttributeID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDS_SequenceOfIntegerAttribute) SALOMEDS_SequenceOfIntegerAttribute::Set (const TDF_Label& L) +{ + Handle(SALOMEDS_SequenceOfIntegerAttribute) A; + if (!L.FindAttribute(SALOMEDS_SequenceOfIntegerAttribute::GetID(),A)) { + A = new SALOMEDS_SequenceOfIntegerAttribute(); + L.AddAttribute(A); + } + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDS_SequenceOfIntegerAttribute::SALOMEDS_SequenceOfIntegerAttribute() +{myValue = new TColStd_HSequenceOfInteger();} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_SequenceOfIntegerAttribute::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDS_SequenceOfIntegerAttribute::NewEmpty () const +{ + return new SALOMEDS_SequenceOfIntegerAttribute(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDS_SequenceOfIntegerAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer i; + Handle(SALOMEDS_SequenceOfIntegerAttribute) anSeq = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(with); + if(!anSeq->myValue.IsNull()) { + myValue = new TColStd_HSequenceOfInteger(); + Standard_Integer Len = anSeq->Length(); + for(i = 1; i<=Len; i++) Add(anSeq->Value(i)); + } + else + myValue.Nullify(); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDS_SequenceOfIntegerAttribute::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& ) const +{ + if(!myValue.IsNull()) { + Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast (into)->Assign(myValue); + } +} + +void SALOMEDS_SequenceOfIntegerAttribute::Assign(const Handle(TColStd_HSequenceOfInteger)& other) +{ + Backup(); + if (myValue.IsNull()) myValue = new TColStd_HSequenceOfInteger; + myValue->ChangeSequence() = other->Sequence(); +} + +void SALOMEDS_SequenceOfIntegerAttribute::ChangeValue(const Standard_Integer Index,const Standard_Integer Value) +{ + Backup(); + myValue->SetValue(Index, Value); +} + +void SALOMEDS_SequenceOfIntegerAttribute::Add(const Standard_Integer Value) +{ + Backup(); + myValue->Append(Value); +} + +void SALOMEDS_SequenceOfIntegerAttribute::Remove(const Standard_Integer Index) +{ + Backup(); + myValue->Remove(Index); +} + +Standard_Integer SALOMEDS_SequenceOfIntegerAttribute::Length() +{ + return myValue->Length(); +} +Standard_Integer SALOMEDS_SequenceOfIntegerAttribute::Value(const Standard_Integer Index) +{ + return myValue->Value(Index); +} + diff --git a/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.hxx b/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.hxx new file mode 100644 index 000000000..0326b9149 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.hxx @@ -0,0 +1,115 @@ +// File : SALOMEDS_SequenceOfIntegerAttribute.hxx +// Created : Fri Jul 05 12:59:44 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _SALOMEDS_SequenceOfIntegerAttribute_HeaderFile +#define _SALOMEDS_SequenceOfIntegerAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_SequenceOfIntegerAttribute_HeaderFile +#include +#endif + +#ifndef _Handle_TColStd_HSequenceOfInteger_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class TColStd_HSequenceOfInteger; +class Standard_GUID; +class TDF_Label; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_SequenceOfIntegerAttribute : public TDF_Attribute { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_SequenceOfIntegerAttribute Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDS_SequenceOfIntegerAttribute(); +Standard_EXPORT void Assign(const Handle(TColStd_HSequenceOfInteger)& other) ; +Standard_EXPORT void ChangeValue(const Standard_Integer Index,const Standard_Integer Value) ; +Standard_EXPORT void Add(const Standard_Integer value) ; +Standard_EXPORT Standard_Integer Value(const Standard_Integer Index) ; +Standard_EXPORT void Remove(const Standard_Integer Index) ; +Standard_EXPORT Standard_Integer Length() ; +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT ~SALOMEDS_SequenceOfIntegerAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_SequenceOfIntegerAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Handle_TColStd_HSequenceOfInteger myValue; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.ixx b/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.ixx new file mode 100644 index 000000000..c521234cf --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.ixx @@ -0,0 +1,66 @@ +// File : SALOMEDS_SequenceOfIntegerAttribute.ixx +// Created : Fri Jul 05 12:59:55 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOMEDS_SequenceOfIntegerAttribute.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_SequenceOfIntegerAttribute::~SALOMEDS_SequenceOfIntegerAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_SequenceOfIntegerAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDF_Attribute); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_SequenceOfIntegerAttribute", + sizeof(SALOMEDS_SequenceOfIntegerAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_SequenceOfIntegerAttribute) Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_SequenceOfIntegerAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_SequenceOfIntegerAttribute))) { + _anOtherObject = Handle(SALOMEDS_SequenceOfIntegerAttribute)((Handle(SALOMEDS_SequenceOfIntegerAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_SequenceOfIntegerAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_SequenceOfIntegerAttribute) ; +} +Standard_Boolean SALOMEDS_SequenceOfIntegerAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_SequenceOfIntegerAttribute) == AType || TDF_Attribute::IsKind(AType)); +} +Handle_SALOMEDS_SequenceOfIntegerAttribute::~Handle_SALOMEDS_SequenceOfIntegerAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.jxx b/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.jxx new file mode 100644 index 000000000..71f03df69 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SequenceOfIntegerAttribute.jxx @@ -0,0 +1,27 @@ +// File : SALOMEDS_SequenceOfIntegerAttribute.jxx +// Created : Fri Jul 05 13:00:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _TColStd_HSequenceOfInteger_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_SequenceOfIntegerAttribute_HeaderFile +#include "SALOMEDS_SequenceOfIntegerAttribute.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.cdl b/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.cdl new file mode 100644 index 000000000..3b0fd26ea --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.cdl @@ -0,0 +1,87 @@ +// File : SALOMEDS_SequenceOfRealAttribute.cdl +// Created : Wed Nov 28 16:20:40 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + + + +class SequenceOfRealAttribute from SALOMEDS inherits Attribute from TDF + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + HSequenceOfReal from TColStd, + DataSet from TDF, + RelocationTable from TDF, + AttributeSequence from TDF, + Data from TDF, + Comment from TDataStd + + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + Set (myclass; label : Label from TDF) + ---Purpose: Find, or create a Comment attribute and set the string. + -- the Comment attribute is returned. + returns SequenceOfRealAttribute from SALOMEDS; + + ---Purpose: Comment methods + -- ============ + + Create + returns mutable SequenceOfRealAttribute from SALOMEDS; + + ---Category: IntegerArray methods + -- =============== + + Assign(me : mutable; other : HSequenceOfReal from TColStd); + ---Purpose: Initialize the inner sequence by other one + + ChangeValue (me : mutable; Index : Integer from Standard; Value : Real); + ---Purpose: Sets the th element of the sequence to + + Add (me : mutable; Value : Real from Standard); + ---Purpose: Add new value + + Value (me : mutable; Index : Integer from Standard) returns Real; + ---Purpose: Value of index + + Remove (me : mutable; Index : Integer from Standard); + ---Purpose: Remove element on index + + Length (me : mutable) returns Integer; + ---Purpose: Returns length of sequence + + + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +fields + + myValue : HSequenceOfReal from TColStd; + +end SequenceOfRealAttribute; diff --git a/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.cxx b/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.cxx new file mode 100644 index 000000000..0aeff2e91 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.cxx @@ -0,0 +1,133 @@ +using namespace std; +// File : SALOMEDS_SequenceOfRealAttribute.cxx +// Created : Wed Nov 28 16:09:35 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + +#include "SALOMEDS_SequenceOfRealAttribute.ixx" +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_SequenceOfRealAttribute::GetID () +{ + static Standard_GUID SALOMEDS_SequenceOfRealAttributeID ("12837183-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_SequenceOfRealAttributeID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDS_SequenceOfRealAttribute) SALOMEDS_SequenceOfRealAttribute::Set (const TDF_Label& L) +{ + Handle(SALOMEDS_SequenceOfRealAttribute) A; + if (!L.FindAttribute(SALOMEDS_SequenceOfRealAttribute::GetID(),A)) { + A = new SALOMEDS_SequenceOfRealAttribute(); + L.AddAttribute(A); + } + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDS_SequenceOfRealAttribute::SALOMEDS_SequenceOfRealAttribute() +{myValue = new TColStd_HSequenceOfReal();} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_SequenceOfRealAttribute::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDS_SequenceOfRealAttribute::NewEmpty () const +{ + return new SALOMEDS_SequenceOfRealAttribute(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDS_SequenceOfRealAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer i; + Handle(SALOMEDS_SequenceOfRealAttribute) anSeq = Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(with); + if(!anSeq->myValue.IsNull()) { + myValue = new TColStd_HSequenceOfReal(); + Standard_Integer Len = anSeq->Length(); + for(i = 1; i<=Len; i++) Add(anSeq->Value(i)); + } + else + myValue.Nullify(); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDS_SequenceOfRealAttribute::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& ) const +{ + if(!myValue.IsNull()) { + Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast (into)->Assign(myValue); + } +} + +void SALOMEDS_SequenceOfRealAttribute::Assign(const Handle(TColStd_HSequenceOfReal)& other) +{ + Backup(); + if (myValue.IsNull()) myValue = new TColStd_HSequenceOfReal; + myValue->ChangeSequence() = other->Sequence(); +} + +void SALOMEDS_SequenceOfRealAttribute::ChangeValue(const Standard_Integer Index,const Standard_Real Value) +{ + Backup(); + myValue->SetValue(Index, Value); +} + +void SALOMEDS_SequenceOfRealAttribute::Add(const Standard_Real Value) +{ + Backup(); + myValue->Append(Value); +} + +void SALOMEDS_SequenceOfRealAttribute::Remove(const Standard_Integer Index) +{ + Backup(); + myValue->Remove(Index); +} + +Standard_Integer SALOMEDS_SequenceOfRealAttribute::Length() +{ + return myValue->Length(); +} + +Standard_Real SALOMEDS_SequenceOfRealAttribute::Value(const Standard_Integer Index) +{ + return myValue->Value(Index); +} + diff --git a/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.hxx b/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.hxx new file mode 100644 index 000000000..ca74e7451 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.hxx @@ -0,0 +1,118 @@ +// File : SALOMEDS_SequenceOfRealAttribute.hxx +// Created : Fri Jul 05 13:00:41 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _SALOMEDS_SequenceOfRealAttribute_HeaderFile +#define _SALOMEDS_SequenceOfRealAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_SequenceOfRealAttribute_HeaderFile +#include +#endif + +#ifndef _Handle_TColStd_HSequenceOfReal_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Real_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class TColStd_HSequenceOfReal; +class Standard_GUID; +class TDF_Label; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_SequenceOfRealAttribute : public TDF_Attribute { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_SequenceOfRealAttribute Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDS_SequenceOfRealAttribute(); +Standard_EXPORT void Assign(const Handle(TColStd_HSequenceOfReal)& other) ; +Standard_EXPORT void ChangeValue(const Standard_Integer Index,const Standard_Real Value) ; +Standard_EXPORT void Add(const Standard_Real Value) ; +Standard_EXPORT Standard_Real Value(const Standard_Integer Index) ; +Standard_EXPORT void Remove(const Standard_Integer Index) ; +Standard_EXPORT Standard_Integer Length() ; +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT ~SALOMEDS_SequenceOfRealAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_SequenceOfRealAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Handle_TColStd_HSequenceOfReal myValue; + + +}; + + + + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.ixx b/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.ixx new file mode 100644 index 000000000..64b5b68cd --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.ixx @@ -0,0 +1,67 @@ +// File : SALOMEDS_SequenceOfRealAttribute.ixx +// Created : Fri Jul 05 13:00:55 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SALOMEDS_SequenceOfRealAttribute.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_SequenceOfRealAttribute::~SALOMEDS_SequenceOfRealAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_SequenceOfRealAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDF_Attribute); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_SequenceOfRealAttribute", + sizeof(SALOMEDS_SequenceOfRealAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_SequenceOfRealAttribute) Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_SequenceOfRealAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_SequenceOfRealAttribute))) { + _anOtherObject = Handle(SALOMEDS_SequenceOfRealAttribute)((Handle(SALOMEDS_SequenceOfRealAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_SequenceOfRealAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_SequenceOfRealAttribute) ; +} +Standard_Boolean SALOMEDS_SequenceOfRealAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_SequenceOfRealAttribute) == AType || TDF_Attribute::IsKind(AType)); +} +Handle_SALOMEDS_SequenceOfRealAttribute::~Handle_SALOMEDS_SequenceOfRealAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.jxx b/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.jxx new file mode 100644 index 000000000..15caad6da --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_SequenceOfRealAttribute.jxx @@ -0,0 +1,27 @@ +// File : SALOMEDS_SequenceOfRealAttribute.jxx +// Created : Fri Jul 05 13:01:03 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _TColStd_HSequenceOfReal_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_SequenceOfRealAttribute_HeaderFile +#include "SALOMEDS_SequenceOfRealAttribute.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_Server.cxx b/src/SALOMEDS/SALOMEDS_Server.cxx new file mode 100644 index 000000000..2b41f0efe --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_Server.cxx @@ -0,0 +1,72 @@ +using namespace std; +// File : SALOMEDS_Server.cxx +// Created : Wed Nov 28 16:26:15 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#include +#include CORBA_SERVER_HEADER(SALOMEDS) +#include "SALOMEDS_StudyManager_i.hxx" +#include "utilities.h" + +// extern "C" +// { // for ccmalloc memory debug +// void ccmalloc_static_initialization(void); +// } + +///////////////////////////// MAIN /////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +int main(int argc, char** argv) +{ +// ccmalloc_static_initialization(); + + MESSAGE("SALOMEDS_Server - main"); + try { + // Initialise the ORB. + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB3"); + + // Obtain a reference to the root POA. + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); + PortableServer::POA_var poa = PortableServer::POA::_narrow(obj); + + + // We allocate the objects on the heap. Since these are reference + // counted objects, they will be deleted by the POA when they are no + // longer needed. + SALOMEDS_StudyManager_i * myStudyManager_i = new SALOMEDS_StudyManager_i(orb); + + // Activate the objects. This tells the POA that the objects are + // ready to accept requests. + PortableServer::ObjectId_var myStudyManager_iid = poa->activate_object(myStudyManager_i); + myStudyManager_i->register_name("/myStudyManager"); + + // Obtain a POAManager, and tell the POA to start accepting + // requests on its objects. + PortableServer::POAManager_var pman = poa->the_POAManager(); + pman->activate(); + + orb->run(); + orb->destroy(); + } + catch(CORBA::SystemException&) { + MESSAGE( "Caught CORBA::SystemException." ) + } + catch(CORBA::Exception&) { + MESSAGE( "Caught CORBA::Exception." ) + } + catch(omniORB::fatalException& fe) { + MESSAGE( "Caught omniORB::fatalException:" ) + MESSAGE( " file: " << fe.file() ) + MESSAGE( " line: " << fe.line() ) + MESSAGE( " mesg: " << fe.errmsg() ) + } + catch(...) { + MESSAGE( "Caught unknown exception." ) + } + return 0; +} + diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx new file mode 100644 index 000000000..3ffd884b9 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx @@ -0,0 +1,1139 @@ +using namespace std; +// File : SALOMEDS_StudyBuilder_i.cxx +// Created : Wed Nov 28 16:26:28 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#include "utilities.h" +#include "SALOMEDS_StudyBuilder_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include "SALOMEDS_SComponent_i.hxx" + +#include "SALOMEDS_IORAttribute.hxx" +#include "SALOMEDS_PersRefAttribute.hxx" +#include "SALOMEDS_TargetAttribute.hxx" +#include "SALOMEDS_StudyPropertiesAttribute.hxx" +#include "SALOMEDS_PythonObjectAttribute.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "SALOMEDS_AttributePersistentRef_i.hxx" +#include "SALOMEDS_AttributeIOR_i.hxx" +#include "SALOMEDS_AttributeComment_i.hxx" +#include "SALOMEDS_AttributeName_i.hxx" +#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx" +#include "SALOMEDS_AttributeSequenceOfReal_i.hxx" +#include "SALOMEDS_AttributeTableOfInteger_i.hxx" +#include "SALOMEDS_AttributeTableOfReal_i.hxx" +#include "SALOMEDS_AttributeTableOfString_i.hxx" +#include "SALOMEDS_AttributeInteger_i.hxx" +#include "SALOMEDS_AttributeReal_i.hxx" +#include "SALOMEDS_AttributeDrawable_i.hxx" +#include "SALOMEDS_AttributeSelectable_i.hxx" +#include "SALOMEDS_AttributeExpandable_i.hxx" +#include "SALOMEDS_AttributeOpened_i.hxx" +#include "SALOMEDS_AttributeTextColor_i.hxx" +#include "SALOMEDS_AttributeTextHighlightColor_i.hxx" +#include "SALOMEDS_AttributePixMap_i.hxx" +#include "SALOMEDS_AttributeTreeNode_i.hxx" +#include "SALOMEDS_AttributeTarget_i.hxx" +#include "SALOMEDS_AttributeLocalID_i.hxx" +#include "SALOMEDS_AttributeUserID_i.hxx" +#include "SALOMEDS_AttributeStudyProperties_i.hxx" +#include "SALOMEDS_AttributePythonObject_i.hxx" +#include "Utils_CorbaException.hxx" + +#include +#include + +#define USE_CASE_LABEL_TAG 2 +#define DIRECTORYID "DIRECTORY:" + +//============================================================================ +/*! Function : constructor + * Purpose : + */ +//============================================================================ +SALOMEDS_StudyBuilder_i::SALOMEDS_StudyBuilder_i(const Handle(TDocStd_Document) doc, + CORBA::ORB_ptr orb) : _doc(doc) +{ + _orb = CORBA::ORB::_duplicate(orb); +} + +//============================================================================ +/*! Function : destructor + * Purpose : + */ +//============================================================================ +SALOMEDS_StudyBuilder_i::~SALOMEDS_StudyBuilder_i() +{ +} + +//============================================================================ +/*! Function : NewComponent + * Purpose : Create a new component (Scomponent) + */ +//============================================================================ +SALOMEDS::SComponent_ptr +SALOMEDS_StudyBuilder_i::NewComponent(const char* DataType) +{ + //Always create component under main label. + TDF_Label L = _doc->Main(); + + // YFR DEBUG : 13/02/2002 TDF_Label NL = L.NewChild(); + + Standard_Integer imax = 0; + for (TDF_ChildIterator it(L); it.More(); it.Next()) { + if (it.Value().Tag() > imax) + imax = it.Value().Tag(); + } + imax++; + TDF_Label NL = L.FindChild(imax); + +// TDataStd_Comment::Set(NL,Standard_CString(DataType)); + TDataStd_Comment::Set(NL,Standard_CString(strdup(DataType))); + + SALOMEDS_SComponent_i * so_servant = new SALOMEDS_SComponent_i (NL,_orb); + SALOMEDS::SComponent_var so; + so= SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); + + if(!CORBA::is_nil(_callbackOnAdd)) _callbackOnAdd->OnAddSObject(so); + + return so; +} + +//============================================================================ +/*! Function : DefineComponentInstance + * Purpose : Add IOR attribute of a Scomponent + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::DefineComponentInstance(SALOMEDS::SComponent_ptr aComponent, + CORBA::Object_ptr IOR) +{ + //Find label + TDF_Label Lab; + ASSERT(!CORBA::is_nil(aComponent)); + CORBA::String_var compid = aComponent->GetID(); + TDF_Tool::Label(_doc->GetData(),strdup(compid),Lab); + + //add IOR definition + ASSERT(!CORBA::is_nil(IOR)); + CORBA::String_var iorstr = _orb->object_to_string(IOR); + SALOMEDS_IORAttribute::Set(Lab,strdup(iorstr),_orb); + +} + +//============================================================================ +/*! Function : RemoveComponent + * Purpose : Delete a Scomponent + */ +//============================================================================ +void +SALOMEDS_StudyBuilder_i::RemoveComponent(SALOMEDS::SComponent_ptr aComponent) +{ + ASSERT(!CORBA::is_nil(aComponent)); + RemoveObject(aComponent); +} + +//============================================================================ +/*! Function : NewObject + * Purpose : Create a new SObject + */ +//============================================================================ +SALOMEDS::SObject_ptr +SALOMEDS_StudyBuilder_i::NewObject(SALOMEDS::SObject_ptr theFatherObject) +{ + TCollection_AsciiString anEntry; + + //Find label of father + TDF_Label Lab; + + ASSERT(!CORBA::is_nil(theFatherObject)); + CORBA::String_var fatherid = theFatherObject->GetID(); + TDF_Tool::Label(_doc->GetData(),strdup(fatherid),Lab); + + //Create a new label + //YFR DEBUG : 13/02/2002 TDF_Label NewLab = Lab.NewChild(); + Standard_Integer imax = 0; + for (TDF_ChildIterator it(Lab); it.More(); it.Next()) { + if (it.Value().Tag() > imax) + imax = it.Value().Tag(); + } + imax++; + TDF_Label NewLab = Lab.FindChild(imax); + + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (NewLab,_orb); + SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + + if(!CORBA::is_nil(_callbackOnAdd)) _callbackOnAdd->OnAddSObject(so); + + return so; +} + +//============================================================================ +/*! Function : NewObjectToTag + * Purpose : + */ +//============================================================================ +SALOMEDS::SObject_ptr +SALOMEDS_StudyBuilder_i::NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject, + CORBA::Long atag) +{ + //Find label of father + TDF_Label Lab; + + ASSERT(!CORBA::is_nil(theFatherObject)); + CORBA::String_var fatherid = theFatherObject->GetID(); + TDF_Tool::Label(_doc->GetData(),strdup(fatherid),Lab); + //Create or find label + TDF_Label NewLab = Lab.FindChild(atag,1); + + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (NewLab,_orb); + SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + + if(!CORBA::is_nil(_callbackOnAdd)) _callbackOnAdd->OnAddSObject(so); + + return so; +} + +//============================================================================ +/*! Function : RemoveObject + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr anObject) +{ + if(!CORBA::is_nil(_callbackOnRemove)) _callbackOnRemove->OnRemoveSObject(anObject); + + TDF_Label Lab; + ASSERT(!CORBA::is_nil(anObject)); + TDF_Tool::Label(_doc->GetData(),anObject->GetID(),Lab); + Lab.ForgetAllAttributes(); +} + +//============================================================================ +/*! Function : RemoveObjectWithChildren + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr anObject) +{ + if(!CORBA::is_nil(_callbackOnRemove)) _callbackOnRemove->OnRemoveSObject(anObject); + + TDF_Label Lab; + ASSERT(!CORBA::is_nil(anObject)); + TDF_Tool::Label(_doc->GetData(),anObject->GetID(),Lab); + Lab.ForgetAllAttributes(Standard_True); +} + +//============================================================================ +/*! Function : Translate_persistentID_to_IOR + * Purpose : + */ +//============================================================================ +static void Translate_persistentID_to_IOR(TDF_Label Lab, + SALOMEDS::Driver_ptr driver, + CORBA::ORB_ptr orb, + CORBA::Boolean isMultiFile) +{ + TDF_ChildIterator itchild (Lab); + + for (; itchild.More(); itchild.Next()) { + TDF_Label current = itchild.Value(); + Handle(TDF_Attribute) Att; + if (current.FindAttribute(SALOMEDS_PersRefAttribute::GetID(),Att)) { + TCollection_ExtendedString res; + res = Handle(TDataStd_Comment)::DownCast(Att)->Get(); + TCollection_AsciiString ch(res); + + CORBA::String_var persistent_string = CORBA::string_dup(ch.ToCString()); + ASSERT(! CORBA::is_nil(driver)); + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (current,orb); + SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + + CORBA::String_var ior_string = driver->LocalPersistentIDToIOR(so, persistent_string, isMultiFile); + + TCollection_ExtendedString value(strdup(ior_string )); + SALOMEDS_IORAttribute::Set (current,value,orb); + + TCollection_AsciiString anEntry;TDF_Tool::Entry (current,anEntry); + + //delete persistent_string; + //delete ior_string; + } + Translate_persistentID_to_IOR (current,driver,orb,isMultiFile); + } +} + +//============================================================================ +/*! Function : LoadWith + * Purpose : + */ +//============================================================================ + +//============================================================================ +void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, + SALOMEDS::Driver_ptr aDriver) throw(SALOME::SALOME_Exception) +{ + TDF_Label Lab; + ASSERT(!CORBA::is_nil(anSCO)); + CORBA::String_var scoid = anSCO->GetID(); + TDF_Tool::Label(_doc->GetData(),strdup(scoid),Lab); + Handle(TDF_Attribute) Att; + + //Find the current Url of the study + if (_doc->Main().FindAttribute(SALOMEDS_PersRefAttribute::GetID(),Att)) { + int aLocked = anSCO->GetStudy()->GetProperties()->IsLocked(); + if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(false); + + TCollection_ExtendedString Res = Handle(TDataStd_Comment)::DownCast(Att)->Get(); + + Handle(TDataStd_Comment) type; + TCollection_ExtendedString DataType; + if (Lab.FindAttribute(TDataStd_Comment::GetID(),type)) + DataType = type->Get(); + else + MESSAGE("No Data Type"); + + // associate the driver to the SComponent + ASSERT(!CORBA::is_nil(aDriver)); + // mpv 06.03.2003: SAL1927 - if component data if already loaded, it is not necessary to do it again + if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), Att)) { + if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true); + return; + } + DefineComponentInstance (anSCO, aDriver); + + //Open the Study HDF file + TCollection_AsciiString aHDFPath(Res); + HDFfile *hdf_file = new HDFfile(aHDFPath.ToCString()); + + char aMultifileState[2]; + try { + CORBA::String_var scoid = anSCO->GetID(); + hdf_file->OpenOnDisk(HDF_RDONLY); + HDFgroup *hdf_group = new HDFgroup("DATACOMPONENT",hdf_file); + hdf_group->OpenOnDisk(); + HDFgroup *hdf_sco_group = new HDFgroup(scoid, hdf_group); + hdf_sco_group->OpenOnDisk(); + + SALOMEDS::TMPFile_var aStreamFile; + if (hdf_sco_group->ExistInternalObject("FILE_STREAM")) { + HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group); + hdf_dataset->OpenOnDisk(); + int aStreamSize = hdf_dataset->GetSize(); + unsigned char* aBuffer = new unsigned char[aStreamSize]; + if(aBuffer == NULL) throw HDFexception("Unable to open dataset FILE_STREAM"); + hdf_dataset->ReadFromDisk(aBuffer); + aStreamFile = new SALOMEDS::TMPFile(aStreamSize, aStreamSize, aBuffer, 1); + hdf_dataset->CloseOnDisk(); + hdf_dataset = 0; + } else aStreamFile = new SALOMEDS::TMPFile(0); + + HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group); + multifile_hdf_dataset->OpenOnDisk(); + multifile_hdf_dataset->ReadFromDisk(aMultifileState); + + + // set path without file name from URL + int aFileNameSize = Res.Length(); + char* aDir = new char[aFileNameSize]; + memcpy(aDir, TCollection_AsciiString(Res).ToCString(), aFileNameSize); + for(int aCounter = aFileNameSize-1; aCounter>=0; aCounter--) + if (aDir[aCounter] == '/') { + aDir[aCounter+1] = 0; + break; + } + + if(!aDriver->Load(anSCO, aStreamFile.in(), aDir, aMultifileState[0]=='M')) { + MESSAGE("Can't load component"); + THROW_SALOME_CORBA_EXCEPTION("Unable to load component data",SALOME::BAD_PARAM); +// throw HDFexception("Unable to load component"); + } + + delete(aDir); + + multifile_hdf_dataset->CloseOnDisk(); + multifile_hdf_dataset = 0; + hdf_sco_group->CloseOnDisk(); + hdf_sco_group = 0; + hdf_group->CloseOnDisk(); + hdf_group = 0; + hdf_file->CloseOnDisk(); + delete hdf_file; + } + catch (HDFexception) { + MESSAGE("No persistent file Name"); + delete hdf_file; + if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true); + return; + } + + try { + Translate_persistentID_to_IOR (Lab,aDriver,_orb, aMultifileState[0]=='M'); + } catch (SALOME::SALOME_Exception) { + MESSAGE("Can't translate PersRef to IOR"); + if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true); + THROW_SALOME_CORBA_EXCEPTION("Unable to convert component persistent data to the transient",SALOME::BAD_PARAM); +// throw HDFexception("Unable to load component data"); + } + if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true); + } else + MESSAGE("No persistent file Name"); +} + + +//============================================================================ +/*! Function : Load + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::Load(SALOMEDS::SObject_ptr sco) +{ + MESSAGE ( "This function is not yet implemented"); +} + +//============================================================================ +/*! Function : AddAttribute + * Purpose : + */ +//============================================================================ +/* +void SALOMEDS_StudyBuilder_i::AddAttribute(SALOMEDS::SObject_ptr anObject, + SALOMEDS::AttributeType aType, + const char * AttributeValue ) +{ + TDF_Label Lab; + ASSERT(!CORBA::is_nil(anObject)); + CORBA::String_var anobid = anObject->GetID(); + TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab); + + TCollection_ExtendedString Value(strdup(AttributeValue)); + + Standard_GUID ID = SALOMEDS_SObject_i::TypeToAttributeID(aType); + + if (ID == TDataStd_Name::GetID()) TDataStd_Name::Set (Lab,Value); + else if (ID == TDataStd_Comment::GetID()) TDataStd_Comment::Set (Lab,Value); + else if (ID == SALOMEDS_IORAttribute::GetID()) SALOMEDS_IORAttribute::Set (Lab,Value); + else if (ID == SALOMEDS_PersRefAttribute::GetID()) SALOMEDS_PersRefAttribute::Set(Lab,Value); +} +*/ +//============================================================================ +/*! Function : FindOrCreateAttribute + * Purpose : Add attribute of given type to SObject, if there is attribute of such type, returns + * existing one + */ +//============================================================================ + +SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SALOMEDS::SObject_ptr anObject, + const char* aTypeOfAttribute) +{ + TDF_Label Lab; + ASSERT(!CORBA::is_nil(anObject)); + CORBA::String_var anobid = anObject->GetID(); + TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab); + + if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) { + Handle(TDataStd_Real) anAttr; + if (!Lab.FindAttribute(TDataStd_Real::GetID(), anAttr)) { + anAttr = new TDataStd_Real; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeReal_i* aRealAttr = new SALOMEDS_AttributeReal_i(anAttr, _orb); + SALOMEDS::AttributeReal_var aRA = aRealAttr->AttributeReal::_this(); + return aRA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) { + Handle(TDataStd_Integer) anAttr; + if (!Lab.FindAttribute(TDataStd_Integer::GetID(), anAttr)) { + anAttr = new TDataStd_Integer; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeInteger_i* aIntAttr = new SALOMEDS_AttributeInteger_i(anAttr, _orb); + SALOMEDS::AttributeInteger_var aIA = aIntAttr->AttributeInteger::_this(); + return aIA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) { + Handle(SALOMEDS_SequenceOfRealAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_SequenceOfRealAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_SequenceOfRealAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeSequenceOfReal_i* aSeqRealAttr = new SALOMEDS_AttributeSequenceOfReal_i(anAttr, _orb); + SALOMEDS::AttributeSequenceOfReal_var aSRA = aSeqRealAttr->AttributeSequenceOfReal::_this(); + return aSRA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) { + Handle(SALOMEDS_SequenceOfIntegerAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_SequenceOfIntegerAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_SequenceOfIntegerAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeSequenceOfInteger_i* aSeqIntegerAttr = new SALOMEDS_AttributeSequenceOfInteger_i(anAttr, _orb); + SALOMEDS::AttributeSequenceOfInteger_var aSIA = aSeqIntegerAttr->AttributeSequenceOfInteger::_this(); + return aSIA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) { + Handle(TDataStd_Name) anAttr; + if (!Lab.FindAttribute(TDataStd_Name::GetID(), anAttr)) { + anAttr = new TDataStd_Name; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeName_i* aNameAttr = new SALOMEDS_AttributeName_i(anAttr, _orb); + SALOMEDS::AttributeName_var aSNA = aNameAttr->AttributeName::_this(); + return aSNA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) { + Handle(TDataStd_Comment) anAttr; + if (!Lab.FindAttribute(TDataStd_Comment::GetID(), anAttr)) { + anAttr = new TDataStd_Comment; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeComment_i* aCommentAttr = new SALOMEDS_AttributeComment_i(anAttr, _orb); + SALOMEDS::AttributeComment_var aCA = aCommentAttr->AttributeComment::_this(); + return aCA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) { + Handle(SALOMEDS_IORAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_IORAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeIOR_i* aIORAttr = new SALOMEDS_AttributeIOR_i(anAttr, _orb); + SALOMEDS::AttributeIOR_var aIA = aIORAttr->AttributeIOR::_this(); + return aIA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) { + Handle(SALOMEDS_PersRefAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_PersRefAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_PersRefAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributePersistentRef_i* aPerRefAttr = new SALOMEDS_AttributePersistentRef_i(anAttr, _orb); + SALOMEDS::AttributePersistentRef_var aPRA = aPerRefAttr->AttributePersistentRef::_this(); + return aPRA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) { + Handle(SALOMEDS_DrawableAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_DrawableAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_DrawableAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeDrawable_i* aDrawableAttr = new SALOMEDS_AttributeDrawable_i(anAttr, _orb); + SALOMEDS::AttributeDrawable_var aDrawA = aDrawableAttr->AttributeDrawable::_this(); + return aDrawA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) { + Handle(SALOMEDS_SelectableAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_SelectableAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_SelectableAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeSelectable_i* aSelectableAttr = new SALOMEDS_AttributeSelectable_i(anAttr, _orb); + SALOMEDS::AttributeSelectable_var aSelA = aSelectableAttr->AttributeSelectable::_this(); + return aSelA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) { + Handle(SALOMEDS_ExpandableAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_ExpandableAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_ExpandableAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeExpandable_i* aExpandableAttr = new SALOMEDS_AttributeExpandable_i(anAttr, _orb); + SALOMEDS::AttributeExpandable_var aExpA = aExpandableAttr->AttributeExpandable::_this(); + return aExpA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) { + Handle(SALOMEDS_OpenedAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_OpenedAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_OpenedAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeOpened_i* aOpenedAttr = new SALOMEDS_AttributeOpened_i(anAttr, _orb); + SALOMEDS::AttributeOpened_var aOpenA = aOpenedAttr->AttributeOpened::_this(); + return aOpenA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) { + Handle(SALOMEDS_TextColorAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_TextColorAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_TextColorAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeTextColor_i* aTextColorAttr = new SALOMEDS_AttributeTextColor_i(anAttr, _orb); + SALOMEDS::AttributeTextColor_var aTCA = aTextColorAttr->AttributeTextColor::_this(); + return aTCA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) { + Handle(SALOMEDS_TextHighlightColorAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_TextHighlightColorAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_TextHighlightColorAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeTextHighlightColor_i* aTextHighlightColorAttr = new SALOMEDS_AttributeTextHighlightColor_i(anAttr, _orb); + SALOMEDS::AttributeTextHighlightColor_var aTHCA = aTextHighlightColorAttr->AttributeTextHighlightColor::_this(); + return aTHCA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) { + Handle(SALOMEDS_PixMapAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_PixMapAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_PixMapAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributePixMap_i* aPixMapAttr = new SALOMEDS_AttributePixMap_i(anAttr, _orb); + SALOMEDS::AttributePixMap_var aPMA = aPixMapAttr->AttributePixMap::_this(); + return aPMA._retn(); + } + else if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) { + Standard_GUID aTreeNodeGUID; + if (strcmp(aTypeOfAttribute, "AttributeTreeNode") == 0) + aTreeNodeGUID = TDataStd_TreeNode::GetDefaultTreeID(); + else { + char* aGUIDString = new char[40]; + sprintf(aGUIDString, &(aTypeOfAttribute[21])); + Standard_GUID aGUID = Standard_GUID(aGUIDString); // create tree node GUID by name + delete(aGUIDString); + } + Handle(TDataStd_TreeNode) anAttr; + if (!Lab.FindAttribute(aTreeNodeGUID, anAttr)) + anAttr = TDataStd_TreeNode::Set(Lab, aTreeNodeGUID); + SALOMEDS_AttributeTreeNode_i* aTreeNodeAttr = new SALOMEDS_AttributeTreeNode_i(anAttr, _orb); + SALOMEDS::AttributeTreeNode_var aTNA = aTreeNodeAttr->AttributeTreeNode::_this(); + return aTNA._retn(); + } + else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) { + Handle(TDataStd_UAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_AttributeUserID_i::DefaultID(), anAttr)) + anAttr = TDataStd_UAttribute::Set(Lab, SALOMEDS_AttributeUserID_i::DefaultID()); + SALOMEDS_AttributeUserID_i* aUAttr = new SALOMEDS_AttributeUserID_i(anAttr, _orb); + SALOMEDS::AttributeUserID_var aUA = aUAttr->AttributeUserID::_this(); + return aUA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) { + Handle(SALOMEDS_LocalIDAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_LocalIDAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeLocalID_i* aLIDAttr = new SALOMEDS_AttributeLocalID_i(anAttr, _orb); + SALOMEDS::AttributeLocalID_var aLIDA = aLIDAttr->AttributeLocalID::_this(); + return aLIDA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) { + Handle(SALOMEDS_TargetAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_TargetAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_TargetAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeTarget_i* aLIDAttr = new SALOMEDS_AttributeTarget_i(anAttr, _orb); + SALOMEDS::AttributeTarget_var aLIDA = aLIDAttr->AttributeTarget::_this(); + return aLIDA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) { + Handle(SALOMEDS_TableOfIntegerAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_TableOfIntegerAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_TableOfIntegerAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeTableOfInteger_i* aTabIntegerAttr = new SALOMEDS_AttributeTableOfInteger_i(anAttr, _orb); + SALOMEDS::AttributeTableOfInteger_var aTIA = aTabIntegerAttr->AttributeTableOfInteger::_this(); + return aTIA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) { + Handle(SALOMEDS_TableOfRealAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_TableOfRealAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_TableOfRealAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeTableOfReal_i* aTabRealAttr = new SALOMEDS_AttributeTableOfReal_i(anAttr, _orb); + SALOMEDS::AttributeTableOfReal_var aTRA = aTabRealAttr->AttributeTableOfReal::_this(); + return aTRA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) { + Handle(SALOMEDS_TableOfStringAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_TableOfStringAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_TableOfStringAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributeTableOfString_i* aTabStringAttr = new SALOMEDS_AttributeTableOfString_i(anAttr, _orb); + SALOMEDS::AttributeTableOfString_var aTRA = aTabStringAttr->AttributeTableOfString::_this(); + return aTRA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) { + Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_StudyPropertiesAttribute; + Lab.AddAttribute(anAttr); + anAttr->SetModified(0); + } + SALOMEDS_AttributeStudyProperties_i* aStPropAttr = new SALOMEDS_AttributeStudyProperties_i(anAttr, _orb); + SALOMEDS::AttributeStudyProperties_var aSPA = aStPropAttr->AttributeStudyProperties::_this(); + return aSPA._retn(); + } + else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) { + Handle(SALOMEDS_PythonObjectAttribute) anAttr; + if (!Lab.FindAttribute(SALOMEDS_PythonObjectAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_PythonObjectAttribute; + Lab.AddAttribute(anAttr); + } + SALOMEDS_AttributePythonObject_i* aPObjAttr = new SALOMEDS_AttributePythonObject_i(anAttr, _orb); + SALOMEDS::AttributePythonObject_var aPOA = aPObjAttr->AttributePythonObject::_this(); + return aPOA._retn(); + } +} + +//============================================================================ +/*! Function : FindAttribute + * Purpose : Find attribute of given type assigned SObject, returns Standard_True if it is found + */ +//============================================================================ + +CORBA::Boolean SALOMEDS_StudyBuilder_i::FindAttribute(SALOMEDS::SObject_ptr anObject, + SALOMEDS::GenericAttribute_out anAttribute, + const char* aTypeOfAttribute) +{ + TDF_Label Lab; + ASSERT(!CORBA::is_nil(anObject)); + CORBA::String_var anobid = anObject->GetID(); + TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab); + Handle(TDF_Attribute) anAttr; + Standard_Boolean found = Lab.FindAttribute(SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute), anAttr); + if (found) { + if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 ) { + SALOMEDS_AttributeReal_i* Attr= new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeReal::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 ) { + SALOMEDS_AttributeInteger_i* Attr= new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeInteger::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 ) { + SALOMEDS_AttributeSequenceOfReal_i* Attr= new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeSequenceOfReal::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 ) { + SALOMEDS_AttributeSequenceOfInteger_i* Attr= new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeSequenceOfInteger::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) { + SALOMEDS_AttributeName_i* Attr= new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeName::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) { + SALOMEDS_AttributeComment_i* Attr= new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeComment::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) { + SALOMEDS_AttributeIOR_i* Attr= new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeIOR::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 ) { + SALOMEDS_AttributePersistentRef_i* Attr= new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributePersistentRef::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 ) { + SALOMEDS_AttributeDrawable_i* Attr= new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeDrawable::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 ) { + SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeSelectable::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 ) { + SALOMEDS_AttributeExpandable_i* Attr= new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeExpandable::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 ) { + SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeOpened::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 ) { + SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTextColor::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) { + SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTextHighlightColor::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 ) { + SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributePixMap::_this(); + return Standard_True; + } + else if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 ) { + SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTreeNode::_this(); + return Standard_True; + } + else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) { + SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeUserID::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 ) { + SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeLocalID::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 ) { + SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTarget::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 ) { + SALOMEDS_AttributeTableOfInteger_i* Attr= new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTableOfInteger::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 ) { + SALOMEDS_AttributeTableOfReal_i* Attr= new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTableOfReal::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 ) { + SALOMEDS_AttributeTableOfString_i* Attr= new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeTableOfString::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 ) { + SALOMEDS_AttributeStudyProperties_i* Attr= new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributeStudyProperties::_this(); + return Standard_True; + } + else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 ) { + SALOMEDS_AttributePythonObject_i* Attr= new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb); + anAttribute = Attr->AttributePythonObject::_this(); + return Standard_True; + } + } else return Standard_False; +} + +//============================================================================ +/*! Function : RemoveAttribute + * Purpose : Remove attribute of given type assigned SObject + */ +//============================================================================ + +void SALOMEDS_StudyBuilder_i::RemoveAttribute(SALOMEDS::SObject_ptr anObject, + const char* aTypeOfAttribute) +{ + TDF_Label Lab; + ASSERT(!CORBA::is_nil(anObject)); + CORBA::String_var anobid = anObject->GetID(); + TDF_Tool::Label(_doc->GetData(),strdup(anobid),Lab); + Lab.ForgetAttribute (SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute)); +} + +//============================================================================ +/*! Function : Addreference + * Purpose : + */ +//============================================================================ +void +SALOMEDS_StudyBuilder_i::Addreference(SALOMEDS::SObject_ptr me, + SALOMEDS::SObject_ptr theReferencedObject) +{ + TDF_Label Lab; + ASSERT(!CORBA::is_nil(me)); + CORBA::String_var meid = me->GetID(); + TDF_Tool::Label(_doc->GetData(),strdup(meid),Lab); + TDF_Label RefLab; + ASSERT(!CORBA::is_nil(theReferencedObject)); + CORBA::String_var roid = theReferencedObject->GetID(); + TDF_Tool::Label(_doc->GetData(),strdup(roid),RefLab); + TDF_Reference::Set(Lab,RefLab); + + SALOMEDS_TargetAttribute::Set(RefLab)->Append(Lab); + + if(!CORBA::is_nil(_callbackOnRemove)) _callbackOnRemove->OnRemoveSObject(me); +} + + +//============================================================================ +/*! Function : AddDirectory + * Purpose : adds a new directory with a path = thePath + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::AddDirectory(const char* thePath) +{ + if(thePath == NULL || strlen(thePath) == 0) throw SALOMEDS::Study::StudyInvalidDirectory(); + + TCollection_AsciiString aPath(CORBA::string_dup(thePath)), aContext(""), aFatherPath; + TDF_ChildIterator anIterator(_doc->Main()); + Handle(TDataStd_Name) aName; + TDF_Label aLabel; + SALOMEDS_SObject_i* so_servant = new SALOMEDS_SObject_i (_doc->Main(), _orb); + SALOMEDS::SObject_var anObject = SALOMEDS::SObject::_narrow(so_servant->_this()); + SALOMEDS::Study_var aStudy = anObject->GetStudy(); + + try { + anObject = aStudy->FindObjectByPath(thePath); //Check if the directory already exists + } + catch(...) { } + + if(!anObject->_is_nil()) throw SALOMEDS::Study::StudyNameAlreadyUsed(); + + if(aPath.Value(1) != '/') { //Relative path + aPath.Prepend('/'); + aPath = TCollection_AsciiString(aStudy->GetContext()) + aPath; + } + + TCollection_AsciiString aToken = aPath.Token("/", 1); + if(aToken.Length() == 0) aFatherPath = "/"; + + int i = 1; + while(aToken.Length() != 0) { + if(aPath.Token("/", i+1).Length() > 0) { + aFatherPath += "/"; + aFatherPath += aToken; + } + aToken = aPath.Token("/", ++i); + } + + anObject = SALOMEDS::SObject::_nil(); + try { + anObject = aStudy->FindObjectByPath(aFatherPath.ToCString()); //Check if the father directory exists + } + catch(...) { ; } + if(anObject->_is_nil()) throw SALOMEDS::Study::StudyInvalidDirectory(); + + SALOMEDS::SObject_var aNewObject = NewObject(anObject); + TDF_Tool::Label(_doc->GetData(), aNewObject->GetID(), aLabel); + if(aLabel.IsNull()) { + MESSAGE("### NULL label"); + throw SALOMEDS::Study::StudyInvalidComponent(); + } + + TDataStd_Name::Set(aLabel, aPath.Token("/", i-1)); + + //Set PersistentRef attribute to identify the directory object + SALOMEDS::GenericAttribute_var anAttr = FindOrCreateAttribute(aNewObject, "AttributePersistentRef"); + SALOMEDS::AttributePersistentRef_var aPersRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr); + if(aPersRef->_is_nil()) throw SALOMEDS::Study::StudyInvalidDirectory(); + + aPersRef->SetValue(DIRECTORYID); +} + + +//============================================================================ +/*! Function : SetGUID + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::SetGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID) +{ + TDF_Label aLabel; + ASSERT(!CORBA::is_nil(anObject)); + CORBA::String_var anEntry = anObject->GetID(); + TDF_Tool::Label(_doc->GetData(), strdup(anEntry), aLabel); + TDataStd_UAttribute::Set(aLabel, (char*)theGUID); +} + +//============================================================================ +/*! Function : IsGUID + * Purpose : + */ +//============================================================================ +bool SALOMEDS_StudyBuilder_i::IsGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID) +{ + TDF_Label aLabel; + ASSERT(!CORBA::is_nil(anObject)); + CORBA::String_var anEntry = anObject->GetID(); + TDF_Tool::Label(_doc->GetData(), strdup(anEntry), aLabel); + return aLabel.IsAttribute((char*)theGUID); +} + + +//============================================================================ +/*! Function : NewCommand + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::NewCommand() +{ + // mpv: for SAL2114 - unset "lock changed" flag at the operation start + Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; + if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_StudyPropertiesAttribute; + _doc->Main().AddAttribute(anAttr); + } + anAttr->IsLockChanged(true); + + _doc->NewCommand(); +} + +//============================================================================ +/*! Function : CommitCommand + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::CommitCommand() throw (SALOMEDS::StudyBuilder::LockProtection) +{ + Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; + if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_StudyPropertiesAttribute; + _doc->Main().AddAttribute(anAttr); + } + if (anAttr->IsLocked() && !anAttr->IsLockChanged(true)) { + INFOS("Locked document modification !!!"); + AbortCommand(); + throw SALOMEDS::StudyBuilder::LockProtection(); + } else { + int aModif = anAttr->GetModified(); + if (aModif < 0) aModif = 1000; // if user make undo and then - new transaction "modify" will never be zero + anAttr->SetModified(aModif+1); + _doc->CommitCommand(); + } +} + +//============================================================================ +/*! Function : HasOpenCommand + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_StudyBuilder_i::HasOpenCommand() +{ + _doc->HasOpenCommand(); +} + +//============================================================================ +/*! Function : AbortCommand + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::AbortCommand() +{ + _doc->AbortCommand(); +} + +//============================================================================ +/*! Function : Undo + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::Undo() throw (SALOMEDS::StudyBuilder::LockProtection) +{ + Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; + if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_StudyPropertiesAttribute; + _doc->Main().AddAttribute(anAttr); + } + if (anAttr->IsLocked()) { + INFOS("Locked document modification !!!"); + throw SALOMEDS::StudyBuilder::LockProtection(); + } else { + _doc->Undo(); + anAttr->SetModified(anAttr->GetModified()-1); + } +} + +//============================================================================ +/*! Function : Redo + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::Redo() throw (SALOMEDS::StudyBuilder::LockProtection) +{ + Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; + if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) { + anAttr = new SALOMEDS_StudyPropertiesAttribute; + _doc->Main().AddAttribute(anAttr); + } + + if (anAttr->IsLocked()) { + INFOS("Locked document modification !!!"); + throw SALOMEDS::StudyBuilder::LockProtection(); + } else { + _doc->Redo(); + anAttr->SetModified(anAttr->GetModified()+1); + } +} + +//============================================================================ +/*! Function : GetAvailableUndos + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_StudyBuilder_i::GetAvailableUndos() +{ + return _doc->GetAvailableUndos(); +} + +//============================================================================ +/*! Function : GetAvailableRedos + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_StudyBuilder_i::GetAvailableRedos() +{ + return _doc->GetAvailableRedos(); +} + + +//============================================================================ +/*! Function : UndoLimit + * Purpose : + */ +//============================================================================ +CORBA::Long SALOMEDS_StudyBuilder_i::UndoLimit() +{ + return _doc->GetUndoLimit(); +} + +//============================================================================ +/*! Function : UndoLimit + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyBuilder_i::UndoLimit(CORBA::Long n) +{ + _doc->SetUndoLimit (n); +} + +//============================================================================ +/*! Function : SetOnAddSObject + * Purpose : + */ +//============================================================================ +SALOMEDS::Callback_ptr SALOMEDS_StudyBuilder_i::SetOnAddSObject(SALOMEDS::Callback_ptr theCallback) +{ + SALOMEDS::Callback_ptr aRet = (CORBA::is_nil(_callbackOnAdd))?NULL:_callbackOnAdd._retn(); + _callbackOnAdd = SALOMEDS::Callback::_duplicate(theCallback); + return aRet; +} + +//============================================================================ +/*! Function : SetOnNewSObject + * Purpose : + */ +//============================================================================ +SALOMEDS::Callback_ptr SALOMEDS_StudyBuilder_i::SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback) +{ + SALOMEDS::Callback_ptr aRet = (CORBA::is_nil(_callbackOnRemove))?NULL:_callbackOnRemove._retn(); + _callbackOnRemove = SALOMEDS::Callback::_duplicate(theCallback); + return aRet; +} diff --git a/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx new file mode 100644 index 000000000..fcad36f06 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx @@ -0,0 +1,125 @@ +// File : SALOMEDS_StudyBuilder_i.hxx +// Created : Wed Nov 28 16:26:50 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef __SALOMEDS_STUDYBUIlDER_I_H__ +#define __SALOMEDS_STUDYBUILDER_I_H__ + + +// std C++ headers +#include + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +#include "SALOMEDS_AttributeComment_i.hxx" +#include "SALOMEDS_AttributePersistentRef_i.hxx" +#include "SALOMEDS_AttributeIOR_i.hxx" +#include "SALOMEDS_AttributeReal_i.hxx" +#include "SALOMEDS_AttributeInteger_i.hxx" +#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx" +#include "SALOMEDS_AttributeName_i.hxx" +#include "SALOMEDS_AttributeSequenceOfReal_i.hxx" +#include "SALOMEDS_Callback_i.hxx" + +// Cascade header +#include + +class SALOMEDS_StudyBuilder_i: public POA_SALOMEDS::StudyBuilder, + public PortableServer::RefCountServantBase { +private: + CORBA::ORB_ptr _orb; + Handle(TDocStd_Document) _doc; // OCAF Document + SALOMEDS::Callback_var _callbackOnAdd; + SALOMEDS::Callback_var _callbackOnRemove; +public: + + SALOMEDS_StudyBuilder_i(const Handle(TDocStd_Document), CORBA::ORB_ptr); + + ~SALOMEDS_StudyBuilder_i(); + + //! NewComponent + /*! + \param ComponentDataType + \return + */ + virtual SALOMEDS::SComponent_ptr NewComponent(const char* ComponentDataType); + + //! DefineComponentInstance + /*! + \param SComponent_ptr + \param ComponentIOR + */ + virtual void DefineComponentInstance (SALOMEDS::SComponent_ptr, CORBA::Object_ptr ComponentIOR); + + //! + /*! + + + \param aComponent + */ + virtual void RemoveComponent(SALOMEDS::SComponent_ptr aComponent); + + //! + /*! + + + \param theFatherObject + \return + */ + virtual SALOMEDS::SObject_ptr NewObject(SALOMEDS::SObject_ptr theFatherObject); + //! + /*! + + + \param theFatherObject + \param atag + \return + */ + virtual SALOMEDS::SObject_ptr NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject, CORBA::Long atag); + + /*! + The methods adds a new subdirectory, the path can be absolute or relative (then the current context is used) + */ + virtual void AddDirectory(const char* thePath); + + virtual void LoadWith(SALOMEDS::SComponent_ptr sco, SALOMEDS::Driver_ptr Engine) + throw(SALOME::SALOME_Exception); + virtual void Load(SALOMEDS::SObject_ptr sco); + + virtual void RemoveObject(SALOMEDS::SObject_ptr anObject); + virtual void RemoveObjectWithChildren(SALOMEDS::SObject_ptr anObject); + + virtual SALOMEDS::GenericAttribute_ptr FindOrCreateAttribute(SALOMEDS::SObject_ptr anObject, const char* aTypeOfAttribute); + virtual CORBA::Boolean FindAttribute(SALOMEDS::SObject_ptr anObject, SALOMEDS::GenericAttribute_out anAttribute, const char* aTypeOfAttribute); + virtual void RemoveAttribute(SALOMEDS::SObject_ptr anObject, const char* aTypeOfAttribute); + + virtual void Addreference(SALOMEDS::SObject_ptr me, SALOMEDS::SObject_ptr thereferencedObject); + + virtual void SetGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID); + virtual bool IsGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID); + + virtual void NewCommand(); + virtual void CommitCommand() throw(SALOMEDS::StudyBuilder::LockProtection); + virtual CORBA::Boolean HasOpenCommand(); + virtual void AbortCommand(); + virtual void Undo() throw(SALOMEDS::StudyBuilder::LockProtection); + virtual void Redo() throw(SALOMEDS::StudyBuilder::LockProtection); + CORBA::Boolean GetAvailableUndos(); + CORBA::Boolean GetAvailableRedos(); + CORBA::Boolean IsSaved(); + CORBA::Boolean IsModified(); + virtual CORBA::Long UndoLimit(); + virtual void UndoLimit(CORBA::Long); + + virtual SALOMEDS::Callback_ptr SetOnAddSObject(SALOMEDS::Callback_ptr theCallback); + virtual SALOMEDS::Callback_ptr SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback); +}; +#endif diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx new file mode 100644 index 000000000..2ed289228 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -0,0 +1,1803 @@ +using namespace std; +// File : SALOMEDS_StudyManager_i.cxx +// Created : Wed Nov 28 13:45:43 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ +// Modified by : Estelle DEVILLE : Implementation of Save methods + +#include "utilities.h" +#include "SALOMEDS_StudyManager_i.hxx" +#include "SALOMEDS_Study_i.hxx" +#include "SALOMEDS_SComponent_i.hxx" + +#include "SALOMEDS_IORAttribute.hxx" +#include "SALOMEDS_PersRefAttribute.hxx" +#include "SALOMEDS_Tool.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// #include +#include +#include +#include "HDFexplorer.hxx" +#include "SALOMEDS_SequenceOfRealAttribute.hxx" +#include "SALOMEDS_SequenceOfIntegerAttribute.hxx" +#include +#include +#include "SALOMEDS_PixMapAttribute.hxx" +#include "SALOMEDS_DrawableAttribute.hxx" +#include "SALOMEDS_SelectableAttribute.hxx" +#include "SALOMEDS_ExpandableAttribute.hxx" +#include "SALOMEDS_OpenedAttribute.hxx" +#include "SALOMEDS_TextColorAttribute.hxx" +#include "SALOMEDS_TextHighlightColorAttribute.hxx" +#include "SALOMEDS_LocalIDAttribute.hxx" +#include "SALOMEDS_TargetAttribute.hxx" +#include "SALOMEDS_TableOfIntegerAttribute.hxx" +#include "SALOMEDS_TableOfRealAttribute.hxx" +#include "SALOMEDS_TableOfStringAttribute.hxx" +#include "SALOMEDS_StudyPropertiesAttribute.hxx" +#include "SALOMEDS_PythonObjectAttribute.hxx" +#include +#include + +#include "Utils_CorbaException.hxx" + +#include + +#define USE_CASE_LABEL_ID "0:2" + +//=========================================================================== +//Function : LoadAttributes +//=========================================================================== +static void ReadAttributes(Handle(TDF_Data)& DF, + TDF_Label& Lab, + HDFdataset* hdf_dataset) +{ + hdf_dataset->OpenOnDisk(); + + if (hdf_dataset->GetType() == HDF_STRING) { + + if (!strncmp(hdf_dataset->GetName(),"AttributeTreeNode",17)) { + MESSAGE("Create a Attribute : AttributeTreeNode"); + char current_strings[5][hdf_dataset->GetSize()/5]; + hdf_dataset->ReadFromDisk(current_strings); + + MESSAGE("Create an Attribute : AttributeTreeNode"); + Standard_GUID aGUID(current_strings[4]); + Handle(TDataStd_TreeNode) aNewNode = TDataStd_TreeNode::Set(Lab,aGUID); + TDF_Label aLabel; + Handle(TDataStd_TreeNode) aNode; + if (current_strings[0][0]) { + TDF_Tool::Label(DF,current_strings[0],aLabel,1); + if (!aLabel.FindAttribute(aGUID,aNode)) aNode = TDataStd_TreeNode::Set(aLabel,aGUID); + aNewNode->SetFather(aNode); + } + if (current_strings[1][0]) { + TDF_Tool::Label(DF,current_strings[1],aLabel,1); + if (!aLabel.FindAttribute(aGUID,aNode)) aNode = TDataStd_TreeNode::Set(aLabel,aGUID); + aNewNode->SetPrevious(aNode); + } + if (current_strings[2][0]) { + TDF_Tool::Label(DF,current_strings[2],aLabel,1); + if (!aLabel.FindAttribute(aGUID,aNode)) aNode = TDataStd_TreeNode::Set(aLabel,aGUID); + aNewNode->SetNext(aNode); + } + if (current_strings[3][0]) { + TDF_Tool::Label(DF,current_strings[3],aLabel,1); + if (!aLabel.FindAttribute(aGUID,aNode)) aNode = TDataStd_TreeNode::Set(aLabel,aGUID); + aNewNode->SetFirst(aNode); + } + } else { + + int size = hdf_dataset->GetSize(); + char current_string[size]; + hdf_dataset->ReadFromDisk(current_string); + + if (!strcmp(hdf_dataset->GetName(),"COMPONENTDATATYPE")) { + MESSAGE("Create a OCAF Attribute : COMPONENTDATATYPE"); + TDataStd_Comment::Set (Lab,current_string); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributeComment")) { + MESSAGE("Create an Attribute : AttributeComment"); + TDataStd_Comment::Set (Lab,current_string); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributeName")) { + MESSAGE("Create an Attribute : AttributeName"); + TDataStd_Name::Set (Lab,current_string); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributePersistentRef")) { + MESSAGE("Create an Attribute : AttributePersistentRef"); + SALOMEDS_PersRefAttribute::Set(Lab,current_string); + } + else if (!strcmp(hdf_dataset->GetName(),"Reference")) { + MESSAGE("Create a OCAF Attribute : Reference"); + TDF_Label RefLab; + TDF_Tool::Label(DF,current_string,RefLab,1); + TDF_Reference::Set(Lab,RefLab); + SALOMEDS_TargetAttribute::Set(RefLab)->Append(Lab); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributeReal")) { + MESSAGE("Create a Attribute : AttributeReal"); + char * err = NULL; + CORBA::Double r = strtod(current_string, &err); + SCRUTE(r); + if (err == current_string) { + MESSAGE("AtttributeReal : conversion impossible"); + } + else TDataStd_Real::Set (Lab,r); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributeInteger")) { + MESSAGE("Create a Attribute : AttributeInteger"); + CORBA::Long r = atol(current_string); + SCRUTE(r); + TDataStd_Integer::Set (Lab,r); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributePixMap")) { + MESSAGE("Create an Attribute : AttributePixMap"); + SALOMEDS_PixMapAttribute::Set (Lab,current_string); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributeDrawable")) { + MESSAGE("Create a Attribute : DrawableAttribute"); + CORBA::Long r = atol(current_string); + SCRUTE(r); + SALOMEDS_DrawableAttribute::Set (Lab,r); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributeSelectable")) { + MESSAGE("Create a Attribute : AttributeSelectable"); + CORBA::Long r = atol(current_string); + SCRUTE(r); + SALOMEDS_SelectableAttribute::Set (Lab,r); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributeExpandable")) { + MESSAGE("Create a Attribute : AttributeExpandable"); + CORBA::Long r = atol(current_string); + SCRUTE(r); + SALOMEDS_ExpandableAttribute::Set (Lab,r); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributeOpened")) { + MESSAGE("Create a Attribute : AttributeOpened"); + CORBA::Long r = atol(current_string); + SCRUTE(r); + SALOMEDS_OpenedAttribute::Set (Lab,r); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributeLocalID")) { + MESSAGE("Create a Attribute : AttributeLocalID"); + CORBA::Long r = atol(current_string); + SCRUTE(r); + SALOMEDS_LocalIDAttribute::Set (Lab,r); + } + else if (!strncmp(hdf_dataset->GetName(),"AttributeUserID",15)) { + MESSAGE("Create an Attribute : AttributeUserID"); + TDataStd_UAttribute::Set (Lab,Standard_GUID(current_string)); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributeTableOfInteger")) { + MESSAGE("Create a Attribute : AttributeTableOfInteger"); + int size = hdf_dataset->GetSize(); + Handle(SALOMEDS_TableOfIntegerAttribute) Attr = SALOMEDS_TableOfIntegerAttribute::Set(Lab); + unsigned char* aBuffer = new unsigned char[size]; + if(aBuffer == NULL) throw HDFexception("Unable to open dataset AttributeTableOfInteger"); + hdf_dataset->ReadFromDisk(aBuffer); + SALOMEDS::TMPFile_var aTMPFile = new SALOMEDS::TMPFile(size, size, aBuffer, 1); + istrstream aStream((char*)&aTMPFile[0], aTMPFile->length()); + Attr->RestoreFromString(aStream); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributeTableOfReal")) { + MESSAGE("Create a Attribute : AttributeTableOfReal"); + int size = hdf_dataset->GetSize(); + Handle(SALOMEDS_TableOfRealAttribute) Attr = SALOMEDS_TableOfRealAttribute::Set(Lab); + unsigned char* aBuffer = new unsigned char[size]; + if(aBuffer == NULL) throw HDFexception("Unable to open dataset AttributeTableOfReal"); + hdf_dataset->ReadFromDisk(aBuffer); + SALOMEDS::TMPFile_var aTMPFile = new SALOMEDS::TMPFile(size, size, aBuffer, 1); + istrstream aStream((char*)&aTMPFile[0], aTMPFile->length()); + Attr->RestoreFromString(aStream); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributeTableOfString")) { + MESSAGE("Create a Attribute : AttributeTableOfString"); + int size = hdf_dataset->GetSize(); + Handle(SALOMEDS_TableOfStringAttribute) Attr = SALOMEDS_TableOfStringAttribute::Set(Lab); + unsigned char* aBuffer = new unsigned char[size]; + if(aBuffer == NULL) throw HDFexception("Unable to open dataset AttributeTableOfString"); + hdf_dataset->ReadFromDisk(aBuffer); + SALOMEDS::TMPFile_var aTMPFile = new SALOMEDS::TMPFile(size, size, aBuffer, 1); + istrstream aStream((char*)&aTMPFile[0], aTMPFile->length()); + Attr->RestoreFromString(aStream); + } + else if (!strcmp(hdf_dataset->GetName(),"AttributeStudyProperties")) { + MESSAGE("Create an Attribute : AttributeStudyProperties"); +// MESSAGE("current string :"<SetCreationMode(1);break; + case 'c': aProp->SetCreationMode(2);break; + } + + int anIndex; + for(anIndex = 2; anIndex + 2 < size ;) { + char str[10]; + Standard_Integer aMinute, aHour, aDay, aMonth, aYear; + str[0] = current_string[anIndex++]; + str[1] = current_string[anIndex++]; + str[2] = 0; + aMinute = atoi(str); + str[0] = current_string[anIndex++]; + str[1] = current_string[anIndex++]; + aHour = atoi(str); + str[0] = current_string[anIndex++]; + str[1] = current_string[anIndex++]; + aDay = atoi(str); + str[0] = current_string[anIndex++]; + str[1] = current_string[anIndex++]; + aMonth = atoi(str); + str[0] = current_string[anIndex++]; + str[1] = current_string[anIndex++]; + str[2] = current_string[anIndex++]; + str[3] = current_string[anIndex++]; + str[4] = 0; + aYear = atoi(str); + aProp->SetModificationDate(aMinute,aHour,aDay,aMonth,aYear); + + int aNameSize; + for(aNameSize = 0; current_string[anIndex+aNameSize]!=1; aNameSize++); + char *aName = new char[aNameSize+1]; + strncpy(aName, &(current_string[anIndex]), aNameSize); + aName[aNameSize] = 0; + aProp->SetUserName(TCollection_ExtendedString(aName)); + delete(aName); + anIndex += aNameSize + 1; + if (current_string[1] == 'l') { + aProp->SetLocked(Standard_True); + aProp->IsLockChanged(true); + } + aProp->SetModified(0); + } + } + else if (!strcmp(hdf_dataset->GetName(),"AttributePythonObject")) { + MESSAGE("Create an Attribute : AttributePythonObject"); + Handle(SALOMEDS_PythonObjectAttribute) anObj = SALOMEDS_PythonObjectAttribute::Set(Lab); + Standard_Boolean aScript = (current_string[0] == 's')?Standard_True:Standard_False; + anObj->SetObject((char *)(current_string+1), aScript); + } + else { + MESSAGE(hdf_dataset->GetName()); + MESSAGE("LoadAttributes: unknown types"); + } + } + } + if (hdf_dataset->GetType() == HDF_FLOAT64) { + if (!strcmp(hdf_dataset->GetName(),"AttributeSequenceOfReal")) { + MESSAGE("Create a Attribute : AttributeSequenceOfReal"); + int size = hdf_dataset->GetSize(); + hdf_float64* val = new hdf_float64[size]; + hdf_dataset->ReadFromDisk(val); + Handle(TColStd_HSequenceOfReal) SeqReal = new TColStd_HSequenceOfReal; + for (Standard_Integer i = 0; i < size; i++) { + SeqReal->Append(val[i]); +// MESSAGE( val[i] << " restored" ); + } + SALOMEDS_SequenceOfRealAttribute::Set (Lab); + Handle(SALOMEDS_SequenceOfRealAttribute) Attr; + Handle(TDF_Attribute) Att; + Lab.FindAttribute(SALOMEDS_SequenceOfRealAttribute::GetID(),Att); + Attr = Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(Att); + Attr->Assign(SeqReal); + } else + if (!strcmp(hdf_dataset->GetName(),"AttributeTextColor")) { + MESSAGE("Create a Attribute : AttributeTextColor"); + hdf_float64 val[3]; + hdf_dataset->ReadFromDisk(val); + Handle(SALOMEDS_TextColorAttribute) TC = new SALOMEDS_TextColorAttribute; + Lab.AddAttribute(TC); + TC->SetValue(1, val[0]); + TC->SetValue(2, val[1]); + TC->SetValue(3, val[2]); + } else + if (!strcmp(hdf_dataset->GetName(),"AttributeTextHighlightColor")) { + MESSAGE("Create a Attribute : AttributeTextHighlightColor"); + hdf_float64 val[3]; + hdf_dataset->ReadFromDisk(val); + Handle(SALOMEDS_TextHighlightColorAttribute) TC = new SALOMEDS_TextHighlightColorAttribute; + Lab.AddAttribute(TC); + TC->SetValue(1, val[0]); + TC->SetValue(2, val[1]); + TC->SetValue(3, val[2]); + }else { + MESSAGE(hdf_dataset->GetName()); + MESSAGE("LoadAttributes: unknown types"); + } + } + if (hdf_dataset->GetType() == HDF_INT32) { + if (!strcmp(hdf_dataset->GetName(),"AttributeSequenceOfInteger")) { + MESSAGE("Create a OCAF Attribute : AttributeSequenceOfInteger"); + int size = hdf_dataset->GetSize(); + hdf_int32* val = new hdf_int32[size]; + hdf_dataset->ReadFromDisk(val); + Handle(TColStd_HSequenceOfInteger) SeqInt = new TColStd_HSequenceOfInteger; + for (Standard_Integer i = 0; i < size; i++) { + SeqInt->Append(val[i]); +// MESSAGE( val[i] << " restored" ); + } + SALOMEDS_SequenceOfIntegerAttribute::Set (Lab); + Handle(SALOMEDS_SequenceOfIntegerAttribute) Attr; + Handle(TDF_Attribute) Att; + Lab.FindAttribute(SALOMEDS_SequenceOfIntegerAttribute::GetID(),Att); + Attr = Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(Att); + Attr->Assign(SeqInt); + } + else { + MESSAGE(hdf_dataset->GetName()); + MESSAGE("LoadAttributes: unknown types"); + } + } + hdf_dataset->CloseOnDisk(); +} + +//============================================================================ +//Function : Translate_IOR_to_persistentID +//============================================================================ +static void Translate_IOR_to_persistentID (SALOMEDS::Study_ptr study, + SALOMEDS::StudyBuilder_ptr SB, + SALOMEDS::SObject_ptr so, + SALOMEDS::Driver_ptr engine, + CORBA::Boolean isMultiFile) +{ + MESSAGE("In Translate_IOR_to_persistentID"); + SALOMEDS::ChildIterator_var itchild = study->NewChildIterator(so); + CORBA::String_var ior_string; + char* persistent_string = 0; + char *curid=0; + + for (; itchild->More(); itchild->Next()) { + SALOMEDS::SObject_var current = itchild->Value(); + SCRUTE(current->GetID()); + SCRUTE(ior_string); + SALOMEDS::GenericAttribute_var SObj; + if (current->FindAttribute(SObj, "AttributeIOR")) { + SALOMEDS::AttributeIOR_var IOR = SALOMEDS::AttributeIOR::_narrow(SObj); + ior_string = IOR->Value(); + SCRUTE(ior_string); + + persistent_string = engine->IORToLocalPersistentID (current,ior_string,isMultiFile); + +// SB->AddAttribute (current, SALOMEDS::PersistentRef,persistent_string); + SALOMEDS::AttributePersistentRef_var Pers = SALOMEDS::AttributePersistentRef::_narrow(SB->FindOrCreateAttribute (current, "AttributePersistentRef")); + Pers->SetValue(persistent_string); + SCRUTE(persistent_string); + curid = current->GetID(); + MESSAGE("Translate " << curid << + " to Persistent string "<OpenOnDisk(); + + TDF_Label Lab; + Standard_CString Entry = hdf_current_group->GetName(); + if (strcmp(Entry,"STUDY_STRUCTURE") == 0) { + MESSAGE("find the root of the document"); + Lab = DF->Root().FindChild(1,Standard_True); + } + else { + TDF_Tool::Label (DF,Entry,Lab,1); + MESSAGE("BuildTree : Create a new label"<nInternalObjects(); + + for (Standard_Integer i=0; iInternalObjectIndentify(i,name); + if (strncmp(name, "INTERNAL_COMPLEX",16) == 0) continue; + hdf_object_type type = hdf_current_group->InternalObjectType(name); + + if (type == HDF_DATASET) { + MESSAGE("--> Dataset: Internal Object Name : " << name); + HDFdataset* new_dataset = new HDFdataset(name,hdf_current_group); + ReadAttributes (DF,Lab,new_dataset); + new_dataset = 0; // will be deleted by father destructor + + } + else if (type == HDF_GROUP) { + MESSAGE( "--> Group: Internal Object Name : " << name); + HDFgroup* new_group = new HDFgroup(name,hdf_current_group); + BuildTree (DF,new_group); + new_group = 0; // will be deleted by father destructor + } + } + hdf_current_group->CloseOnDisk(); +} + + +//============================================================================ +/*! Function : SALOMEDS_StudyManager_i + * Purpose : SALOMEDS_StudyManager_i constructor + */ +//============================================================================ +SALOMEDS_StudyManager_i::SALOMEDS_StudyManager_i(CORBA::ORB_ptr orb) +{ + _orb = CORBA::ORB::_duplicate(orb); + _OCAFApp = new SALOMEDS_OCAFApplication(); + _name_service = new SALOME_NamingService(_orb); + // Study directory creation in the naming service : to register all + // open studies in the session + _name_service->Create_Directory("/Study"); + _IDcounter = 0; +} + +//============================================================================ +/*! Function : ~SALOMEDS_StudyManager_i + * Purpose : SALOMEDS_StudyManager_i destructor + */ +//============================================================================ +SALOMEDS_StudyManager_i::~SALOMEDS_StudyManager_i() +{ + // Destroy directory to register open studies + _name_service->Destroy_Directory("/Study"); + // Destroy OCAF document + delete &_OCAFApp; +} + +//============================================================================ +/*! Function : register_name + * Purpose : Register the study Manager in the naming service under the + * context name + */ +//============================================================================ +void SALOMEDS_StudyManager_i::register_name(char * name) { + SALOMEDS::StudyManager_ptr g = SALOMEDS::StudyManager::_narrow(_this()); + _name_service->Register(g, name); +} + + +//============================================================================ +/*! Function : NewStudy + * Purpose : Create a New Study of name study_name + */ +//============================================================================ +SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name) +{ + Handle(TDocStd_Document) Doc; + _OCAFApp->NewDocument("SALOME_STUDY",Doc); + + MESSAGE("NewStudy : Creating the CORBA servant holding it... "); + SALOMEDS_Study_i *Study_servant = new SALOMEDS_Study_i(Doc,_orb,study_name); + SALOMEDS::Study_var Study = SALOMEDS::Study::_narrow(Study_servant->_this()); + + //Study->StudyId( _OCAFApp->NbDocuments() ); + _IDcounter++; + Study->StudyId( _IDcounter ); + + // Register study in the naming service + // Path to acces the study + if(!_name_service->Change_Directory("/Study")) + MESSAGE( "Unable to access the study directory" ) + else + _name_service->Register(Study, 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); + + // set Study properties + SALOMEDS::AttributeStudyProperties_ptr aProp = Study->GetProperties(); + OSD_Process aProcess; + Quantity_Date aDate = aProcess.SystemDate(); + aProp->SetCreationDate(CORBA::Long(aDate.Minute()), CORBA::Long(aDate.Hour()), CORBA::Long(aDate.Day()), + CORBA::Long(aDate.Month()), CORBA::Long(aDate.Year())); + aProp->SetCreationMode("from scratch"); + aProp->SetUserName(aProcess.UserName().ToCString()); + + return Study; +} + +//============================================================================ +/*! Function : Open + * Purpose : Open a Study from it's persistent reference + */ +//============================================================================ +SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::Open(const char* aUrl) + throw(SALOME::SALOME_Exception) +{ + MESSAGE("Begin of SALOMEDS_StudyManager_i::Open"); + // open the HDFFile + HDFfile *hdf_file =0; + HDFgroup *hdf_group_study_structure =0; + + hdf_file = new HDFfile((char *)aUrl); + try { + hdf_file->OpenOnDisk(HDF_RDONLY);// mpv: was RDWR, but opened file can be write-protected too + } + catch (HDFexception) + { +// MESSAGE( "HDFexception ! " ); +// cerr << "HDFexception ! " << endl; + char eStr[strlen(aUrl)+17]; + sprintf(eStr,"Can't open file %s",aUrl); + THROW_SALOME_CORBA_EXCEPTION(CORBA::string_dup(eStr),SALOME::BAD_PARAM); + + } + MESSAGE("Open : Creating the CORBA servant holding it... "); + + // Temporary aStudyUrl in place of study name + Handle(TDocStd_Document) Doc; + _OCAFApp->NewDocument("SALOME_STUDY",Doc); + + SALOMEDS_Study_i * Study_servant = new SALOMEDS_Study_i(Doc, _orb, aUrl); + SALOMEDS::Study_var Study = SALOMEDS::Study::_narrow(Study_servant->_this()); + + // Study->StudyId( _OCAFApp->NbDocuments() ); + _IDcounter++; + Study->StudyId( _IDcounter ); + + // Register study in the naming service + // Path to acces the study + if(!_name_service->Change_Directory("/Study")) + MESSAGE( "Unable to access the study directory" ) + else + { + char* aPath = CORBA::string_dup(aUrl); + char *aName = NULL; + char *adr = strtok(aPath, "/"); + while (adr) + { + aName = adr; + adr = strtok(NULL, "/"); + } + adr = aName; + aName = strtok(adr, "."); + SCRUTE(aName); + _name_service->Register(Study, CORBA::string_dup(aName)); + CORBA::string_free(aPath); + } + + // Assign the value of the IOR in the study->root + CORBA::String_var IORStudy = _orb->object_to_string(Study); + SALOMEDS_IORAttribute::Set(Doc->Main().Root(), + TCollection_ExtendedString(CORBA::string_dup(IORStudy)),_orb); + + // Assign the value of the URL in the study object + Study->URL (aUrl); + SCRUTE(aUrl); + SALOMEDS_PersRefAttribute::Set(Doc->Main(),strdup(aUrl)); + + if (!hdf_file->ExistInternalObject("STUDY_STRUCTURE")) { + MESSAGE("SALOMEDS_StudyManager::Open : the study is empty"); + return Study; + } + + //Create the Structure of the OCAF Document + hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file); + + Handle(TDF_Data) DF = Doc->GetData(); + + try { + BuildTree (DF,hdf_group_study_structure); + } + catch (HDFexception) + { +// MESSAGE( "HDFexception ! " ); +// cerr << "HDFexception ! " << endl; + char eStr[strlen(aUrl)+17]; + sprintf(eStr,"Can't open file %s",aUrl); + THROW_SALOME_CORBA_EXCEPTION(CORBA::string_dup(eStr),SALOME::BAD_PARAM); + } + + hdf_file->CloseOnDisk(); + delete hdf_file; // all related hdf objects will be deleted + + return Study; +} + + + +//============================================================================ +/*! Function : Close + * Purpose : Close a study. + * If the study hasn't been saved, ask the user to confirm the + * close action without saving + */ +//============================================================================ +void SALOMEDS_StudyManager_i::Close(SALOMEDS::Study_ptr aStudy) +{ + if(aStudy->_is_nil()) return; + + // Destroy study name in the naming service + if(_name_service->Change_Directory("/Study")) + _name_service->Destroy_Name(aStudy->Name()); + + aStudy->Close(); +} + +//============================================================================ +/*! Function : Save + * Purpose : Save a Study to it's persistent reference + */ +//============================================================================ +void SALOMEDS_StudyManager_i::Save(SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) +{ + CORBA::String_var url = aStudy->URL(); + if (url==NULL) + MESSAGE( "No path specified to save the study. Nothing done") + else + { + _SaveAs(url,aStudy, theMultiFile); + } +} + + +//============================================================================= +/*! Function : SaveAs + * Purpose : Save a study to the persistent reference aUrl + */ +//============================================================================ +void SALOMEDS_StudyManager_i::SaveAs(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile) +{ + // Save the URL of the Study => to be used with the function "Save" + aStudy->URL(aUrl); + + _SaveAs(aUrl,aStudy,theMultiFile); +} + +//============================================================================ +/*! Function : GetOpenStudies + * Purpose : Get name list of open studies in the session + */ +//============================================================================ +SALOMEDS::ListOfOpenStudies* SALOMEDS_StudyManager_i::GetOpenStudies() +{ + // MESSAGE("Begin of GetOpenStudies"); + SALOMEDS::ListOfOpenStudies_var _list_open_studies = new SALOMEDS::ListOfOpenStudies; + _list_open_studies->length(0); + vector _list ; + + if(!_name_service->Change_Directory("/Study")) + { + MESSAGE("No active study in this session"); + } + else + { + _list = _name_service->list_directory(); + _list_open_studies->length(_list.size()); + for (unsigned int ind=0; ind < _list.size();ind++) + { + _list_open_studies[ind]=CORBA::string_dup(_list[ind].c_str()); + SCRUTE(_list_open_studies[ind]) ; + } + } + return _list_open_studies._retn(); +} + +//============================================================================ +/*! Function : GetStudyByName + * Purpose : Get a study from its name + */ +//============================================================================ +SALOMEDS::Study_ptr +SALOMEDS_StudyManager_i::GetStudyByName(const char* aStudyName) +{ + SALOMEDS::Study_var Study; + + // Go to study directory and look for aStudyName + if(!_name_service->Change_Directory("/Study")) + { + MESSAGE("No active study in this session"); + ASSERT(false); // Stop here... + } + +// const char *theStudyName = this->_SubstituteSlash(aStudyName); + const char* theStudyName = CORBA::string_dup(aStudyName); + + if(_name_service->Find(theStudyName)>0) + { + // Study found + CORBA::Object_ptr obj= _name_service->Resolve(theStudyName) ; + Study = SALOMEDS::Study::_narrow(obj); + MESSAGE("Study " << theStudyName << " found in the naming service"); + } + else + { + Study = SALOMEDS::Study::_narrow( CORBA::Object::_nil()); + MESSAGE("Study " << theStudyName << " not found in the naming service"); + } + return Study; +} + +//============================================================================ +/*! Function : GetStudyByID + * Purpose : Get a study from its ID + */ +//============================================================================ +SALOMEDS::Study_ptr +SALOMEDS_StudyManager_i::GetStudyByID(CORBA::Short aStudyID) +{ + SALOMEDS::Study_var Study; + vector _list ; + + if(!_name_service->Change_Directory("/Study")) + { + MESSAGE("No active study in this session"); + } + else + { + _list = _name_service->list_directory(); + for (unsigned int ind=0; ind < _list.size();ind++) + { + const char* theStudyName = CORBA::string_dup(_list[ind].c_str()); + MESSAGE ( "GetStudyByID = " << theStudyName ) + + if(_name_service->Find(theStudyName)>0) { + CORBA::Object_ptr obj= _name_service->Resolve(theStudyName) ; + Study = SALOMEDS::Study::_narrow(obj); + + MESSAGE ( " aStudyID : " << aStudyID << "-" << Study->StudyId() ) + + if ( aStudyID == Study->StudyId() ) { + MESSAGE("Study with studyID = " << aStudyID << " found in the naming service"); + return Study; + } + } else { + Study = SALOMEDS::Study::_narrow( CORBA::Object::_nil()); + MESSAGE("Study " << theStudyName << " not found in the naming service"); + } + } + Study = SALOMEDS::Study::_narrow( CORBA::Object::_nil()); + } + return Study; +} +//============================================================================ +/*! Function : SaveAttributes + * Purpose : Save attributes for object + */ +//============================================================================ +static void SaveAttributes(SALOMEDS::SObject_ptr SO, HDFgroup *hdf_group_sobject) { + HDFdataset *hdf_dataset = 0; + hdf_size size[1]; + hdf_int32 name_len = 0; + SALOMEDS::GenericAttribute_var SObj; + if(SO->FindAttribute(SObj, "AttributeComment")) + { + SALOMEDS::AttributeComment_var Comment = SALOMEDS::AttributeComment::_narrow(SObj); + CORBA::String_var Val = Comment->Value(); + name_len = (hdf_int32) strlen(Val); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("AttributeComment",hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(Val); + MESSAGE("attribute comment " << Val << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } + // Attribute SALOMEDS::PersistentRef + if(SO->FindAttribute(SObj, "AttributePersistentRef")) + { + SALOMEDS::AttributePersistentRef_var PersRef = SALOMEDS::AttributePersistentRef::_narrow(SObj); + CORBA::String_var Val = PersRef->Value(); + name_len = (hdf_int32) strlen(Val); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("AttributePersistentRef",hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(Val); + MESSAGE("attribute persistentref " << Val << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } + // Attribute SALOMEDS::Name + if(SO->FindAttribute(SObj, "AttributeName")) + { + SALOMEDS::AttributeName_var NameRef = SALOMEDS::AttributeName::_narrow(SObj); + CORBA::String_var Val = NameRef->Value(); + name_len = (hdf_int32) strlen(Val); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("AttributeName",hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(Val); + MESSAGE("attribute name " << Val << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } + if(SO->FindAttribute(SObj, "AttributeReal")) + { + char RealVal[25]; + SALOMEDS::AttributeReal_var RealRef = SALOMEDS::AttributeReal::_narrow(SObj); + sprintf(RealVal, "%f", RealRef->Value()); + name_len = (hdf_int32) strlen(RealVal); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("AttributeReal",hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(RealVal); + MESSAGE("attribute Real " << RealVal << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } + if(SO->FindAttribute(SObj, "AttributeInteger")) + { + char IntVal[25]; + SALOMEDS::AttributeInteger_var IntRef = SALOMEDS::AttributeInteger::_narrow(SObj); + sprintf(IntVal, "%d", IntRef->Value()); + name_len = (hdf_int32) strlen(IntVal); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("AttributeInteger",hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(IntVal); + MESSAGE("attribute Real " << IntVal << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } + + if(SO->FindAttribute(SObj, "AttributeSequenceOfReal")) + { + SALOMEDS::AttributeSequenceOfReal_var RealSeq = SALOMEDS::AttributeSequenceOfReal::_narrow(SObj); + size[0] = RealSeq->Length(); + SALOMEDS::DoubleSeq_var DS = RealSeq->CorbaSequence(); + hdf_dataset = new HDFdataset("AttributeSequenceOfReal",hdf_group_sobject,HDF_FLOAT64,size,1); + hdf_dataset->CreateOnDisk(); + hdf_float64 *data = new hdf_float64[RealSeq->Length()]; + for (Standard_Integer i = 0; i < RealSeq->Length(); i++) { + MESSAGE("Value = " << i << " = " << DS[i] << " wrote on file"); + data[i] = DS[i]; + } + hdf_dataset->WriteOnDisk(data); + // delete data; + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } + if(SO->FindAttribute(SObj, "AttributeSequenceOfInteger")) + { + SALOMEDS::AttributeSequenceOfInteger_var IntSeq = SALOMEDS::AttributeSequenceOfInteger::_narrow(SObj); + size[0] = IntSeq->Length(); + SALOMEDS::LongSeq_var LS = IntSeq->CorbaSequence(); + hdf_dataset = new HDFdataset("AttributeSequenceOfInteger",hdf_group_sobject,HDF_INT32,size,1); + hdf_dataset->CreateOnDisk(); + hdf_int32 *data = new hdf_int32[IntSeq->Length()]; + for (Standard_Integer i = 0; i < IntSeq->Length(); i++) { + MESSAGE("Value = " << i << " = " << LS[i] << " wrote on file"); + data[i] = LS[i]; + } + hdf_dataset->WriteOnDisk(data); + hdf_dataset->CloseOnDisk(); + // delete data; + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } + if(SO->FindAttribute(SObj, "AttributeDrawable")) + { + char IntVal[25]; + SALOMEDS::AttributeDrawable_var DrRef = SALOMEDS::AttributeDrawable::_narrow(SObj); + sprintf(IntVal, "%d", DrRef->IsDrawable()); + name_len = (hdf_int32) strlen(IntVal); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("AttributeDrawable",hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(IntVal); + MESSAGE("attribute Drawable " << IntVal << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } + if(SO->FindAttribute(SObj, "AttributeSelectable")) + { + char IntVal[25]; + SALOMEDS::AttributeSelectable_var SelRef = SALOMEDS::AttributeSelectable::_narrow(SObj); + sprintf(IntVal, "%d", SelRef->IsSelectable()); + name_len = (hdf_int32) strlen(IntVal); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("AttributeSelectable",hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(IntVal); + MESSAGE("attribute Selectable " << IntVal << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } + if(SO->FindAttribute(SObj, "AttributeExpandable")) + { + char IntVal[25]; + SALOMEDS::AttributeExpandable_var ExRef = SALOMEDS::AttributeExpandable::_narrow(SObj); + sprintf(IntVal, "%d", ExRef->IsExpandable()); + name_len = (hdf_int32) strlen(IntVal); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("AttributeExpandable",hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(IntVal); + MESSAGE("attribute Expandable " << IntVal << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } + if(SO->FindAttribute(SObj, "AttributeOpened")) + { + char IntVal[25]; + SALOMEDS::AttributeOpened_var OpRef = SALOMEDS::AttributeOpened::_narrow(SObj); + sprintf(IntVal, "%d", OpRef->IsOpened()); + name_len = (hdf_int32) strlen(IntVal); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("AttributeOpened",hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(IntVal); + MESSAGE("attribute Opened " << IntVal << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } + if(SO->FindAttribute(SObj, "AttributeTextColor")) + { + SALOMEDS::AttributeTextColor_var TextRef = SALOMEDS::AttributeTextColor::_narrow(SObj); + size[0] = 3; + hdf_float64 data[3]; + SALOMEDS::Color C = TextRef->TextColor(); + data[0] = C.R; + data[1] = C.G; + data[2] = C.B; + hdf_dataset = new HDFdataset("AttributeTextColor",hdf_group_sobject,HDF_FLOAT64,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(data); + MESSAGE("attribute AttributeTextColor wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } + if(SO->FindAttribute(SObj, "AttributeTextHighlightColor")) + { + SALOMEDS::AttributeTextHighlightColor_var TextRef = SALOMEDS::AttributeTextHighlightColor::_narrow(SObj); + size[0] = 3; + hdf_float64 data[3]; + SALOMEDS::Color C = TextRef->TextHighlightColor(); + data[0] = C.R; + data[1] = C.G; + data[2] = C.B; + hdf_dataset = new HDFdataset("AttributeTextHighlightColor",hdf_group_sobject,HDF_FLOAT64,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(data); + MESSAGE("attribute AttributeTextHighlightColor wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } + if(SO->FindAttribute(SObj, "AttributePixMap")) + { + SALOMEDS::AttributePixMap_var PMRef = SALOMEDS::AttributePixMap::_narrow(SObj); + if (PMRef->HasPixMap()) { + CORBA::String_var Val = PMRef->GetPixMap(); + name_len = (hdf_int32) strlen(Val); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("AttributePixMap",hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(Val); + MESSAGE("attribute PixMap " << Val << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + } + } + if(SO->FindAttribute(SObj, "AttributeLocalID")) + { + char IntVal[25]; + SALOMEDS::AttributeLocalID_var LIDRef = SALOMEDS::AttributeLocalID::_narrow(SObj); + sprintf(IntVal, "%d", LIDRef->Value()); + name_len = (hdf_int32) strlen(IntVal); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("AttributeLocalID",hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(IntVal); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + MESSAGE("attribute AttributeLocalID wrote on file"); + } + if(SO->FindAttribute(SObj, "AttributeTableOfInteger")) + { + SALOMEDS::AttributeTableOfInteger_var IntTab = SALOMEDS::AttributeTableOfInteger::_narrow(SObj); + SALOMEDS::TMPFile_var aStream = IntTab->SaveToFile(); + + hdf_size aHDFSize[1]; + aHDFSize[0] = aStream->length(); + + HDFdataset *hdf_dataset = new HDFdataset("AttributeTableOfInteger",hdf_group_sobject, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + + MESSAGE("attribute AttributeTableOfInteger wrote on file"); + } + if(SO->FindAttribute(SObj, "AttributeTableOfReal")) + { + SALOMEDS::AttributeTableOfReal_var RealTab = SALOMEDS::AttributeTableOfReal::_narrow(SObj); + SALOMEDS::TMPFile_var aStream = RealTab->SaveToFile(); + + hdf_size aHDFSize[1]; + aHDFSize[0] = aStream->length(); + + HDFdataset *hdf_dataset = new HDFdataset("AttributeTableOfReal",hdf_group_sobject, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + + MESSAGE("attribute AttributeTableOfReal wrote on file") + } + if(SO->FindAttribute(SObj, "AttributeTableOfString")) + { + SALOMEDS::AttributeTableOfString_var StrTab = SALOMEDS::AttributeTableOfString::_narrow(SObj); + SALOMEDS::TMPFile_var aStream = StrTab->SaveToFile(); + + hdf_size aHDFSize[1]; + aHDFSize[0] = aStream->length(); + + HDFdataset *hdf_dataset = new HDFdataset("AttributeTableOfString",hdf_group_sobject, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + + MESSAGE("attribute AttributeTableOfString wrote on file") + } + if(SO->FindAttribute(SObj, "AttributePythonObject")) + { + SALOMEDS::AttributePythonObject_var anObj = SALOMEDS::AttributePythonObject::_narrow(SObj); + char* aSeq = CORBA::string_dup(anObj->GetObject()); + int aLen = strlen(aSeq); + char* aString = new char[aLen+2]; + aString[0] = anObj->IsScript()?'s':'n'; + for(int i = 0; i < aLen; i++) aString[i+1] = aSeq[i]; + aString[aLen+1] = 0; + size[0] = aLen+2 ; + hdf_dataset = new HDFdataset("AttributePythonObject",hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(aString); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + MESSAGE("attribute AttributePythonObject wrote on file"); + } + +// Reference + SALOMEDS::SObject_var RefSO; + if(SO->ReferencedObject(RefSO)) + { + CORBA::String_var attribute_reference = strdup(RefSO->GetID()); + name_len = (hdf_int32) strlen(attribute_reference); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("Reference",hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(attribute_reference); + MESSAGE("attribute reference " << attribute_reference << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset =0; // will be deleted by father hdf object destructor + } + +// TreeNodeAttributes with not constant GUID + SALOMEDS::ListOfAttributes_var anAttrList = SO->GetAllAttributes(); + int anIndex, aLength = anAttrList->length(); + for(anIndex = 0; anIndex_is_nil()) { + char* Val = UAttr->Value(); + name_len = (hdf_int32) strlen(Val); + size[0] = name_len + 1; + char* aDataSetName = new char[60]; + sprintf(aDataSetName, "AttributeUserID_%s",Val); + hdf_dataset = new HDFdataset(aDataSetName,hdf_group_sobject,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(Val); + MESSAGE("attribute UesrID " << Val << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + delete(aDataSetName); + continue; + } + + SALOMEDS::AttributeTreeNode_var TNRef = SALOMEDS::AttributeTreeNode::_narrow(anAttrList[anIndex]); + if (!TNRef->_is_nil()) { + hdf_size TNsize[2]; + int maxSize,index; + CORBA::String_var Val[5]; + + if (TNRef->HasFather()) Val[0] = TNRef->GetFather()->Label(); else Val[0] = "\0"; + maxSize = strlen(Val[0]); + if (TNRef->HasPrevious()) Val[1] = TNRef->GetPrevious()->Label(); else Val[1] = "\0"; + maxSize = Max(maxSize,strlen(Val[1])); + if (TNRef->HasNext()) Val[2] = TNRef->GetNext()->Label(); else Val[2] = "\0"; + maxSize = Max(maxSize,strlen(Val[2])); + if (TNRef->HasFirst()) Val[3] = TNRef->GetFirst()->Label(); else Val[3] = "\0"; + maxSize = Max(maxSize,strlen(Val[3])); + Val[4] = TNRef->GetTreeID(); + maxSize = Max(maxSize,strlen(Val[4])); + + TNsize[0]=5; + TNsize[1]=maxSize+1; + char Data[5][maxSize+1]; + for(index=0;index<5;index++) strcpy(Data[index],Val[index]); + + char* aDataSetName = new char[60]; + sprintf(aDataSetName, "AttributeTreeNodeGUID%s",TNRef->GetTreeID()); + hdf_dataset = new HDFdataset(aDataSetName,hdf_group_sobject,HDF_STRING,TNsize,2); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(Data); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + MESSAGE("attribute AttributeTreeNode with various GUID wrote on file:"); + MESSAGE(aDataSetName); + delete(aDataSetName); + } + } +} + +//============================================================================= +/*! Function : _SaveProperties + * Purpose : save the study properties in HDF file + */ +//============================================================================ +void SALOMEDS_StudyManager_i::_SaveProperties(SALOMEDS::Study_ptr aStudy, HDFgroup *hdf_group) { + HDFdataset *hdf_dataset = 0; + hdf_size size[1]; + hdf_int32 name_len; + + // add modifications list (user and date of save) + SALOMEDS::AttributeStudyProperties_ptr aProp = aStudy->GetProperties(); + SALOMEDS::StudyBuilder_var SB= aStudy->NewBuilder(); +// SB->NewCommand(); + int aLocked = aProp->IsLocked(); + if (aLocked) aProp->SetLocked(Standard_False); + OSD_Process aProcess; + Quantity_Date aDate = aProcess.SystemDate(); + aProp->SetModification(aProcess.UserName().ToCString(), + CORBA::Long(aDate.Minute()), CORBA::Long(aDate.Hour()), CORBA::Long(aDate.Day()), + CORBA::Long(aDate.Month()), CORBA::Long(aDate.Year())); + if (aLocked) aProp->SetLocked(Standard_True); +// SB->CommitCommand(); + + + SALOMEDS::StringSeq_var aNames; + SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears; + aProp->GetModificationsList(aNames , aMinutes ,aHours, aDays, aMonths, aYears, true); + int aLength, anIndex; + for(aLength = 0, anIndex = aNames->length() - 1; anIndex >= 0; anIndex--) aLength += strlen(aNames[anIndex]) + 1; + + // string length: 1 byte = locked flag, 1 byte = modified flag, (12 + name length + 1) for each name and date, "zero" byte + char* aProperty = new char[3 + aLength + 12 * aNames->length()]; + + sprintf(aProperty,"%c%c", + (strlen(aProp->GetCreationMode()) != 0)?aProp->GetCreationMode()[0]:'0', + (aProp->IsLocked())?'l':'u'); + + aLength = aNames->length(); + int a = 2; + for(anIndex = 0; anIndex < aLength; anIndex++) { + sprintf(&(aProperty[a]),"%2d%2d%2d%2d%4d%s", + (int)(aMinutes[anIndex]), + (int)(aHours[anIndex]), + (int)(aDays[anIndex]), + (int)(aMonths[anIndex]), + (int)(aYears[anIndex]), + (char*)aNames[anIndex]); + a = strlen(aProperty); + aProperty[a++] = 1; + } + aProperty[a] = 0; + + name_len = (hdf_int32) a; +// MESSAGE("*** Property: "<CreateOnDisk(); + hdf_dataset->WriteOnDisk(aProperty); + MESSAGE("attribute StudyProperties " << aProperty << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + delete(aProperty); + aProp->SetModified(0); +} + +//============================================================================= +/*! Function : _SaveAs + * Purpose : save the study in HDF file + */ +//============================================================================ +void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl, + SALOMEDS::Study_ptr aStudy, + CORBA::Boolean theMultiFile) +{ + // HDF File will be composed of differents part : + // * For each ComponentDataType, all data created by the component + // Informations in data group hdf_group_datacomponent + // * Study Structure -> Exactly what is contained in OCAF document + // Informations in data group hdf_group_study_structure + + HDFfile *hdf_file=0; + HDFgroup *hdf_group_study_structure =0; + HDFgroup *hdf_sco_group =0; + HDFgroup *hdf_sco_group2 =0; + + HDFgroup *hdf_group_datacomponent =0; + HDFdataset *hdf_dataset =0; + HDFattribute *hdf_attribute=0; + hdf_size size[1]; + hdf_int32 name_len = 0; + char *component_name = 0; + char *attribute_name = 0; + char *attribute_comment = 0; + char *attribute_persistentref = 0; + + int aLocked = aStudy->GetProperties()->IsLocked(); + if (aLocked) aStudy->GetProperties()->SetLocked(false); + + SALOMEDS::StudyBuilder_var SB= aStudy->NewBuilder(); + + aStudy->URL(aUrl); + + ASSERT(!CORBA::is_nil(aStudy)); + try + { + // To change for Save + // Do not have to do a new file but just a Open??? Rewrite all informations after erasing evrything?? + hdf_file = new HDFfile((char *)aUrl); + hdf_file->CreateOnDisk(); + MESSAGE("File " << aUrl << " created"); + + //----------------------------------------------------------------------- + // 1 - Create a groupe for each SComponent and Update the PersistanceRef + //----------------------------------------------------------------------- + hdf_group_datacomponent = new HDFgroup("DATACOMPONENT",hdf_file); + hdf_group_datacomponent->CreateOnDisk(); + + SALOMEDS::SComponentIterator_var itcomponent = aStudy->NewComponentIterator(); + + for (; itcomponent->More(); itcomponent->Next()) + { + SALOMEDS::SComponent_var sco = itcomponent->Value(); + + CORBA::String_var scoid = sco->GetID(); + hdf_sco_group = new HDFgroup(scoid,hdf_group_datacomponent); + hdf_sco_group->CreateOnDisk(); + + CORBA::String_var componentDataType = sco->ComponentDataType(); + MESSAGE ( "Look for an engine for data type :"<< componentDataType); + // if there is an associated Engine call its method for saving + CORBA::String_var IOREngine; + if (sco->ComponentIOR(IOREngine)) + { + // we have found the associated engine to write the data + MESSAGE ( "We have found an engine for data type :"<< componentDataType); + CORBA::Object_var obj = _orb->string_to_object(IOREngine); + SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ; + + if (!CORBA::is_nil(Engine)) + { + MESSAGE ( "Save the data of type:"<< componentDataType); + MESSAGE("Engine :"<ComponentDataType()); + + SALOMEDS::TMPFile_var aStream = Engine->Save(sco, + SALOMEDS_Tool::GetDirFromPath(aUrl), + theMultiFile); + HDFdataset *hdf_dataset; + hdf_size aHDFSize[1]; + if(aStream->length() > 0) { //The component saved some auxiliary files, then put them into HDF file + + aHDFSize[0] = aStream->length(); + + HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file + hdf_dataset->CloseOnDisk(); + } + // store multifile state + aHDFSize[0] = 2; + hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk((void*)(theMultiFile?"M":"S")); // save: multi or single + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor + + Translate_IOR_to_persistentID (aStudy,SB,sco,Engine,theMultiFile); + MESSAGE("After Translate_IOR_to_persistentID"); + + // Creation of the persistance reference attribute + } + } + hdf_sco_group->CloseOnDisk(); + hdf_sco_group=0; // will be deleted by hdf_group_datacomponent destructor + } + hdf_group_datacomponent->CloseOnDisk(); + hdf_group_datacomponent =0; // will be deleted by hdf_file destructor + + + //----------------------------------------------------------------------- + //3 - Write the Study Structure + //----------------------------------------------------------------------- + hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file); + hdf_group_study_structure->CreateOnDisk(); + + // save component attributes + SALOMEDS::SComponentIterator_var itcomp = aStudy->NewComponentIterator(); + for (; itcomp->More(); itcomp->Next()) + { + SALOMEDS::SComponent_var SC = itcomp->Value(); + + CORBA::String_var scid = SC->GetID(); + hdf_sco_group2 = new HDFgroup(scid,hdf_group_study_structure); + hdf_sco_group2->CreateOnDisk(); + SaveAttributes(SC, hdf_sco_group2); + // ComponentDataType treatment + component_name = SC->ComponentDataType(); + MESSAGE("Component data type " << component_name << " treated"); + + name_len = (hdf_int32) strlen(component_name); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("COMPONENTDATATYPE",hdf_sco_group2,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + hdf_dataset->WriteOnDisk(component_name); + MESSAGE("component name " << component_name << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; //will be deleted by hdf_sco_group destructor + _SaveObject(aStudy, SC, hdf_sco_group2); + hdf_sco_group2->CloseOnDisk(); + hdf_sco_group2=0; // will be deleted by hdf_group_study_structure destructor + CORBA::string_free(component_name); + } + //----------------------------------------------------------------------- + //4 - Write the Study UseCases Structure + //----------------------------------------------------------------------- + SALOMEDS::SObject_var aSO = aStudy->FindObjectID(USE_CASE_LABEL_ID); + if (!aSO->_is_nil()) { + HDFgroup *hdf_soo_group = new HDFgroup(USE_CASE_LABEL_ID,hdf_group_study_structure); + hdf_soo_group->CreateOnDisk(); + SaveAttributes(aSO, hdf_soo_group); + _SaveObject(aStudy, aSO, hdf_soo_group); + MESSAGE("Use cases data structure writed"); + hdf_soo_group->CloseOnDisk(); + hdf_soo_group=0; // will be deleted by hdf_group_study_structure destructor + } + + if (aLocked) aStudy->GetProperties()->SetLocked(true); + //----------------------------------------------------------------------- + //5 - Write the Study Properties + //----------------------------------------------------------------------- + name_len = (hdf_int32) strlen(aStudy->Name()); + size[0] = name_len +1 ; + hdf_dataset = new HDFdataset("STUDY_NAME",hdf_group_study_structure,HDF_STRING,size,1); + hdf_dataset->CreateOnDisk(); + CORBA::String_var studid = aStudy->Name(); + hdf_dataset->WriteOnDisk(studid); + MESSAGE("study name " << studid << " wrote on file"); + hdf_dataset->CloseOnDisk(); + hdf_dataset=0; // will be deleted by hdf_group_study_structure destructor + + _SaveProperties(aStudy, hdf_group_study_structure); + + hdf_group_study_structure->CloseOnDisk(); + hdf_file->CloseOnDisk(); + aStudy->IsSaved(true); + hdf_group_study_structure =0; // will be deleted by hdf_file destructor + delete hdf_file; // recursively deletes all hdf objects... + } + catch (HDFexception) + { + MESSAGE( "HDFexception ! " ) + } +} + +//============================================================================ +/*! Function : _SaveObject + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS::Study_ptr aStudy, + SALOMEDS::SObject_ptr SC, + HDFgroup *hdf_group_datatype) +{ + // Write in group hdf_group_datatype all informations of SObject SC + // Iterative function to parse all SObjects under a SComponent + SALOMEDS::SObject_var RefSO; + HDFgroup *hdf_group_sobject = 0; + HDFdataset *hdf_dataset = 0; + hdf_size size[1]; + hdf_int32 name_len = 0; + + SALOMEDS::ChildIterator_var itchild = aStudy->NewChildIterator(SC); + for (; itchild->More(); itchild->Next()) + { + SALOMEDS::SObject_var SO = itchild->Value(); + + // mpv: don't save empty labels + if (SO->GetAllAttributes()->length() == 0) { + SALOMEDS::ChildIterator_var subchild = aStudy->NewChildIterator(SC); + if (!subchild->More()) { + continue; + } + subchild->InitEx(true); + bool anEmpty = true; + for (; subchild->More() && anEmpty; subchild->Next()) + if (subchild->Value()->GetAllAttributes()->length() != 0) anEmpty = false; + if (anEmpty) { + continue; + } + } + + CORBA::String_var scoid = strdup(SO->GetID()); + hdf_group_sobject = new HDFgroup(scoid,hdf_group_datatype); + hdf_group_sobject->CreateOnDisk(); + SaveAttributes(SO, hdf_group_sobject); + _SaveObject(aStudy,SO, hdf_group_sobject); + hdf_group_sobject->CloseOnDisk(); + hdf_group_sobject =0; // will be deleted by father hdf object destructor + + } +} + +//============================================================================ +/*! Function : _SubstituteSlash + * Purpose : + */ +//============================================================================ + +const char *SALOMEDS_StudyManager_i::_SubstituteSlash(const char *aUrl) +{ + ASSERT(1==0); + TCollection_ExtendedString theUrl(CORBA::string_dup(aUrl)); + Standard_ExtCharacter val1 = ToExtCharacter('/'); + Standard_ExtCharacter val2 = ToExtCharacter(':'); + theUrl.ChangeAll(val1,val2); + TCollection_AsciiString ch(theUrl); + return strdup(ch.ToCString()); +} + +//============================================================================ +/*! Function : CanCopy + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_StudyManager_i::CanCopy(SALOMEDS::SObject_ptr theObject) { + SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent(); + if (aComponent->_is_nil()) return false; + if (aComponent == theObject) return false; + + CORBA::String_var IOREngine; + if (!aComponent->ComponentIOR(IOREngine)) return false; + + 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->CanCopy(theObject); +} + +//============================================================================ +/*! Function : GetDocumentOfStudy + * Purpose : + */ +//============================================================================ +Handle(TDocStd_Document) SALOMEDS_StudyManager_i::GetDocumentOfStudy(SALOMEDS::Study_ptr theStudy) { + int a; + int aNbDocs = _OCAFApp->NbDocuments(); + Handle(TDocStd_Document) aDocument; + for(a = 1; a <= aNbDocs ; a++) { + _OCAFApp->GetDocument(a, aDocument); + if (!aDocument.IsNull()) { + SALOMEDS_SObject_i * aSOServant = new SALOMEDS_SObject_i (aDocument->Main(),_orb); + SALOMEDS::SObject_var aSO = SALOMEDS::SObject::_narrow(aSOServant->_this()); + if (aSO->GetStudy() == theStudy) break; + aDocument.Nullify(); + } + } + return aDocument; +} + +//============================================================================ +/*! Function : CopyLabel + * Purpose : + */ +//============================================================================ +void SALOMEDS_StudyManager_i::CopyLabel(const SALOMEDS::Study_ptr theSourceStudy, + const SALOMEDS::Driver_ptr theEngine, + const Standard_Integer theSourceStartDepth, + const TDF_Label& theSource, + const TDF_Label& theDestinationMain) { + int a; + TDF_Label aTargetLabel = theDestinationMain; + TDF_Label aAuxTargetLabel = theDestinationMain.Father().FindChild(2); + for(a = theSource.Depth() - theSourceStartDepth; a > 0 ; a--) { + TDF_Label aSourceLabel = theSource; + for(int aNbFather = 1; aNbFather < a; aNbFather++) aSourceLabel = aSourceLabel.Father(); + aTargetLabel = aTargetLabel.FindChild(aSourceLabel.Tag()); + aAuxTargetLabel = aAuxTargetLabel.FindChild(aSourceLabel.Tag()); + } + // iterate attributes + TDF_AttributeIterator anAttrIterator(theSource); + Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable(); + for(; anAttrIterator.More(); anAttrIterator.Next()) { + Handle(TDF_Attribute) anAttr = anAttrIterator.Value(); + if (!Handle(TDataStd_TreeNode)::DownCast(anAttr).IsNull()) continue; // never copy tree node attribute + if (!Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr).IsNull()) continue; // and target attribute + + if (!Handle(TDF_Reference)::DownCast(anAttr).IsNull()) { // reference copied as Comment in auxiliary tree + TDF_Label aReferenced = Handle(TDF_Reference)::DownCast(anAttr)->Get(); + TCollection_AsciiString anEntry; + TDF_Tool::Entry(aReferenced, anEntry); + // store the value of name attribute of referenced label + Handle(TDataStd_Name) aNameAttribute; + if (aReferenced.FindAttribute(TDataStd_Name::GetID(), aNameAttribute)) { + anEntry += " "; + anEntry += aNameAttribute->Get(); + } + TDataStd_Comment::Set(aAuxTargetLabel, TCollection_ExtendedString(anEntry)); + continue; + } + + 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())); +// if (theEngine->CanCopy(aSO)) { + CORBA::Long anObjID; +// TCollection_ExtendedString aResStr(strdup((char*)(theEngine->CopyFrom(aSO, anObjID)))); + SALOMEDS::TMPFile_var aStream = theEngine->CopyFrom(aSO, anObjID); + int aLen = aStream->length(); + TCollection_ExtendedString aResStr(""); + for(a = 0; a < aLen; a++) { + aResStr += TCollection_ExtendedString(ToExtCharacter((Standard_Character)aStream[a])); + } + TDataStd_Integer::Set(aAuxTargetLabel, anObjID); + TDataStd_Name::Set(aAuxTargetLabel, aResStr); +// } + continue; + } + Handle(TDF_Attribute) aNewAttribute = anAttr->NewEmpty(); + aTargetLabel.AddAttribute(aNewAttribute); + anAttr->Paste(aNewAttribute, aRT); +// aRT->SetRelocation(anAttr, aNewAttribute); + } +} + +//============================================================================ +/*! Function : Copy + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_StudyManager_i::Copy(SALOMEDS::SObject_ptr theObject) { + // adoptation for alliances datamodel copy: without IOR attributes !!! + bool aStructureOnly; // copy only SObjects and attributes without component help + SALOMEDS::GenericAttribute_var anAttribute; + aStructureOnly = !theObject->FindAttribute(anAttribute, "AttributeIOR"); + + // get component-engine + SALOMEDS::Study_var aStudy = theObject->GetStudy(); + + SALOMEDS::Driver_var Engine; + if (!aStructureOnly) { + SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent(); + CORBA::String_var IOREngine; + if (!aComponent->ComponentIOR(IOREngine)) return false; + + CORBA::Object_var obj = _orb->string_to_object(IOREngine); + Engine = SALOMEDS::Driver::_narrow(obj) ; + } + // CAF document of current study usage + Handle(TDocStd_Document) aDocument = GetDocumentOfStudy(aStudy); + if (aDocument.IsNull()) return false; + // create new document for clipboard + Handle(TDocStd_Document) aTargetDocument; + _OCAFApp->NewDocument("SALOME_STUDY", aTargetDocument); + // set component data type to the name attribute of root label + if (!aStructureOnly) { + TDataStd_Comment::Set(aTargetDocument->Main().Root(), + TCollection_ExtendedString(strdup(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()); + TDF_Tool::Label(aDocument->GetData(), aStartID, aStartLabel); + Standard_Integer aSourceStartDepth = aStartLabel.Depth(); + + // copy main source label + CopyLabel(aStudy, Engine, aSourceStartDepth, aStartLabel, aTargetDocument->Main()); + + // copy all subchildren of the main source label (all levels) + TDF_ChildIterator anIterator(aStartLabel, Standard_True); + for(; anIterator.More(); anIterator.Next()) { + CopyLabel(aStudy, Engine, aSourceStartDepth, anIterator.Value(), aTargetDocument->Main()); + } + // done: free old clipboard document and + if (!_clipboard.IsNull()) { +// Handle(TDocStd_Owner) anOwner; +// if (_clipboard->Main().Root().FindAttribute(TDocStd_Owner::GetID(), anOwner)) { +// Handle(TDocStd_Document) anEmptyDoc; +// anOwner->SetDocument(anEmptyDoc); +// } + _OCAFApp->Close(_clipboard); + } + _clipboard = aTargetDocument; + + return true; +} +//============================================================================ +/*! Function : CanPaste + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_StudyManager_i::CanPaste(SALOMEDS::SObject_ptr theObject) { + if (_clipboard.IsNull()) return false; + + Handle(TDataStd_Comment) aCompName; + if (!_clipboard->Main().Root().FindAttribute(TDataStd_Comment::GetID(), aCompName)) return false; + Handle(TDataStd_Integer) anObjID; + if (!_clipboard->Main().Father().FindChild(2).FindAttribute(TDataStd_Integer::GetID(), anObjID)) + return false; + + SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent(); + if (aComponent->_is_nil()) return false; + + CORBA::String_var IOREngine; + if (!aComponent->ComponentIOR(IOREngine)) return false; + + 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()); +} +//============================================================================ +/*! Function : PasteLabel + * Purpose : + */ +//============================================================================ +TDF_Label SALOMEDS_StudyManager_i::PasteLabel(const SALOMEDS::Study_ptr theDestinationStudy, + const SALOMEDS::Driver_ptr theEngine, + const TDF_Label& theSource, + const TDF_Label& theDestinationStart, + const int theCopiedStudyID, + const bool isFirstElement) { + // get corresponding source, target and auxiliary labels + TDF_Label aTargetLabel = theDestinationStart; + TDF_Label aAuxSourceLabel = theSource.Root().FindChild(2); + int a; + if (!isFirstElement) { + for(a = theSource.Depth() - 1; a > 0 ; a--) { + TDF_Label aSourceLabel = theSource; + for(int aNbFather = 1; aNbFather < a; aNbFather++) aSourceLabel = aSourceLabel.Father(); + aTargetLabel = aTargetLabel.FindChild(aSourceLabel.Tag()); + aAuxSourceLabel = aAuxSourceLabel.FindChild(aSourceLabel.Tag()); + } + } + + // check auxiliary label for TMPFile => IOR + Handle(TDataStd_Name) aNameAttribute; + if (aAuxSourceLabel.FindAttribute(TDataStd_Name::GetID(), aNameAttribute)) { + Handle(TDataStd_Integer) anObjID; + + 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()); + + if (theEngine->CanPaste(aCompName, anObjID->Get())) { + SALOMEDS::TMPFile_var aTMPFil = new SALOMEDS::TMPFile(); + TCollection_ExtendedString aTMPStr = aNameAttribute->Get(); + int aLen = aTMPStr.Length(); + aTMPFil->length(aLen); + for(a = 0; a < aLen; a++) { + aTMPFil[a] = ToCharacter(aTMPStr.Value(a+1)); + } +// char* aTMPStr = strdup(TCollection_AsciiString(aNameAttribute->Get()).ToCString()); +// int aLen = strlen(aTMPStr); +// SALOMEDS::TMPFile aTMPFil(aLen, aLen, (CORBA::Octet*)aTMPStr, 1); + + TCollection_AsciiString anEntry; + TDF_Tool::Entry(aTargetLabel, anEntry); + SALOMEDS::SObject_var aPastedSO = theDestinationStudy->FindObjectID(strdup(anEntry.ToCString())); + if (isFirstElement) { + SALOMEDS::SObject_var aDestSO = + theEngine->PasteInto(aTMPFil.in(), + anObjID->Get(), + aPastedSO->GetFatherComponent()); + TDF_Tool::Label(theDestinationStart.Data(), aDestSO->GetID(), aTargetLabel); + } else theEngine->PasteInto(aTMPFil.in(),anObjID->Get(),aPastedSO); + } + } + + // iterate attributes + TDF_AttributeIterator anAttrIterator(theSource); + Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable(); + for(; anAttrIterator.More(); anAttrIterator.Next()) { + Handle(TDF_Attribute) anAttr = anAttrIterator.Value(); + if (aTargetLabel.FindAttribute(anAttr->ID(), anAttr)) { + aTargetLabel.ForgetAttribute(anAttr->ID()); + anAttr = anAttrIterator.Value(); + } + Handle(TDF_Attribute) aNewAttribute = anAttr->NewEmpty(); + aTargetLabel.AddAttribute(aNewAttribute); + anAttr->Paste(aNewAttribute, aRT); +// aRT->SetRelocation(anAttr, aNewAttribute); + } + // check auxiliary label for Comment => reference or name attribute of the referenced object + Handle(TDataStd_Comment) aCommentAttribute; + if (aAuxSourceLabel.FindAttribute(TDataStd_Comment::GetID(), aCommentAttribute)) { + char * anEntry = new char[aCommentAttribute->Get().Length()]; + strcpy(anEntry, TCollection_AsciiString(aCommentAttribute->Get()).ToCString()); + char* aNameStart = strchr(anEntry, ' '); + if (aNameStart) { + *aNameStart = '\0'; + aNameStart++; + } + if (theCopiedStudyID == theDestinationStudy->StudyId()) { // if copy to the same study, reanimate reference + TDF_Label aRefLabel; + TDF_Tool::Label(aTargetLabel.Data(), anEntry, aRefLabel); + TDF_Reference::Set(aTargetLabel, aRefLabel); + SALOMEDS_TargetAttribute::Set(aRefLabel)->Append(aTargetLabel); // target attributes structure support + } else { + if (aNameStart) TDataStd_Name::Set(aTargetLabel, aNameStart); + else TDataStd_Name::Set(aTargetLabel, TCollection_ExtendedString("Reference to:")+anEntry); + } + delete(anEntry); + } + return aTargetLabel; +} +//============================================================================ +/*! Function : Paste + * Purpose : + */ +//============================================================================ +SALOMEDS::SObject_ptr SALOMEDS_StudyManager_i::Paste(SALOMEDS::SObject_ptr theObject) + throw(SALOMEDS::StudyBuilder::LockProtection) +{ + SALOMEDS::Study_var aStudy = theObject->GetStudy(); + // if study is locked, then paste can't be done + if (aStudy->GetProperties()->IsLocked()) + throw SALOMEDS::StudyBuilder::LockProtection(); + // if there is no component name, then paste only SObjects and attributes: without component help + Handle(TDataStd_Comment) aComponentName; + bool aStructureOnly = !_clipboard->Main().Root().FindAttribute(TDataStd_Comment::GetID(), aComponentName); + + // get copied study ID + Handle(TDataStd_Integer) aStudyIDAttribute; + if (!_clipboard->Main().Root().FindAttribute(TDataStd_Integer::GetID(), aStudyIDAttribute)) return NULL; + int aCStudyID = aStudyIDAttribute->Get(); + + // get component-engine + + SALOMEDS::Driver_var Engine; + SALOMEDS::SComponent_var aComponent; + if (!aStructureOnly) { + aComponent = theObject->GetFatherComponent(); + CORBA::String_var IOREngine; + if (!aComponent->ComponentIOR(IOREngine)) return NULL; + CORBA::Object_var obj = _orb->string_to_object(IOREngine); + Engine = SALOMEDS::Driver::_narrow(obj) ; + } + // CAF document of current study usage + Handle(TDocStd_Document) aDocument = GetDocumentOfStudy(aStudy); + if (aDocument.IsNull()) return NULL; + // fill root inserted SObject + TDF_Label aStartLabel; + if (aStructureOnly) { + TDF_Label anObjectLabel; + TDF_Tool::Label(aDocument->GetData(), theObject->GetID(), anObjectLabel); + aStartLabel = PasteLabel(aStudy, Engine, _clipboard->Main(), anObjectLabel, aCStudyID, false); + } else { + TDF_Label aComponentLabel; + TDF_Tool::Label(aDocument->GetData(), aComponent->GetID(), aComponentLabel); + aStartLabel = PasteLabel(aStudy, Engine, _clipboard->Main(), aComponentLabel, aCStudyID, true); + } + // paste all sublebels + TDF_ChildIterator anIterator(_clipboard->Main(), Standard_True); + for(; anIterator.More(); anIterator.Next()) { + PasteLabel(aStudy, Engine, anIterator.Value(), aStartLabel, aCStudyID, false); + } + + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aStartLabel, _orb); + SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + return so; +} diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx new file mode 100644 index 000000000..de061a44d --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx @@ -0,0 +1,153 @@ +// File : SALOMEDS_StudyManager_i.hxx +// Created : Wed Nov 28 16:27:08 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef __SALOMEDS_STUDYMANAGER_I_H__ +#define __SALOMEDS_STUDYMANAGER_I_H__ + +// std C++ headers +#include + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +// Cascade headers +#include "SALOMEDS_OCAFApplication.hxx" +#include +#include +#include +#include +#include + +// Naming Service header +#include "SALOME_NamingService.hxx" + +// HDF +#include +#include "HDFOI.hxx" +#include + +//Standard not implemented +#include + + +class SALOMEDS_StudyManager_i: public POA_SALOMEDS::StudyManager, + public PortableServer::RefCountServantBase { +private: + + CORBA::ORB_ptr _orb; + Handle (SALOMEDS_OCAFApplication) _OCAFApp; + SALOME_NamingService* _name_service; + int _IDcounter; + Handle(TDocStd_Document) _clipboard; + + // _SaveAs private function called by Save and SaveAs + virtual void _SaveAs(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); + // _SaveObject private function called by _SaveAs + virtual void _SaveObject(SALOMEDS::Study_ptr aStudy, + SALOMEDS::SObject_ptr SC, + HDFgroup *hdf_group_datatype); + // _SubstituteSlash function called by Open and GetStudyByName + virtual const char *_SubstituteSlash(const char *aUrl); + + virtual void _SaveProperties(SALOMEDS::Study_ptr aStudy, HDFgroup *hdf_group); + +public: + + //! standard constructor + SALOMEDS_StudyManager_i(CORBA::ORB_ptr orb); + + //! standard destructor + virtual ~SALOMEDS_StudyManager_i(); + + //! method to Register study Manager in the naming service + /*! + \param char* arguments, the context to register the study manager in the NS + */ + void register_name(char * name); + + //! method to Create a New Study of name study_name + /*! + \param char* arguments, the new study name + \return Study_ptr arguments + */ + virtual SALOMEDS::Study_ptr NewStudy(const char* study_name); + + //! method to Open a Study from it's persistent reference + /*! + \param char* arguments, the study URL + \return Study_ptr arguments + */ + virtual SALOMEDS::Study_ptr Open(const char* aStudyUrl) throw (SALOME::SALOME_Exception); + + + //! method to close a Study + /*! + \param Study_ptr arguments + */ + virtual void Close( SALOMEDS::Study_ptr aStudy); + + //! method to save a Study + /*! + \param Study_ptr arguments + */ + virtual void Save( SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); + + //! method to save a Study to the persistent reference aUrl + /*! + \param char* arguments, the new URL of the study + \param Study_ptr arguments + */ + virtual void SaveAs(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile); + + //! method to Get name list of open studies in the session + /*! + \return ListOfOpenStudies* arguments + */ + virtual SALOMEDS::ListOfOpenStudies* GetOpenStudies(); + + //! method to get a Study from it's name + /*! + \param char* arguments, the study name + \return Study_ptr arguments + */ + virtual SALOMEDS::Study_ptr GetStudyByName(const char* aStudyName) ; + + //! method to get a Study from it's ID + /*! + \param char* arguments, the study ID + \return Study_ptr arguments + */ + virtual SALOMEDS::Study_ptr GetStudyByID(CORBA::Short aStudyID) ; + + + Handle(TDocStd_Document) GetDocumentOfStudy(SALOMEDS::Study_ptr theStudy); + + void CopyLabel(const SALOMEDS::Study_ptr theSourceStudy, + const SALOMEDS::Driver_ptr theEngine, + const Standard_Integer theSourceStartDepth, + const TDF_Label& theSource, + const TDF_Label& theDestinationMain); + + TDF_Label PasteLabel(const SALOMEDS::Study_ptr theDestinationStudy, + const SALOMEDS::Driver_ptr theEngine, + const TDF_Label& theSource, + const TDF_Label& theDestinationStart, + const int theCopiedStudyID, + const bool isFirstElement); + + virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject); + virtual CORBA::Boolean Copy(SALOMEDS::SObject_ptr theObject); + virtual CORBA::Boolean CanPaste(SALOMEDS::SObject_ptr theObject); + virtual SALOMEDS::SObject_ptr Paste(SALOMEDS::SObject_ptr theObject) throw(SALOMEDS::StudyBuilder::LockProtection); + + void ping(){}; +}; + +#endif diff --git a/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.cdl b/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.cdl new file mode 100644 index 000000000..0eee05887 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.cdl @@ -0,0 +1,92 @@ +-- File : SALOMEDS_StudyPropertiesAttribute.cdl +-- Created : Tue Oct 8 10:13:30 2002 +-- Author : Yves FRICAUD + +-- Project : SALOME +-- Module : SALOMEDS +-- Copyright : Open CASCADE 2001 +-- $Header$ + +class StudyPropertiesAttribute from SALOMEDS inherits Attribute from TDF + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + DataSet from TDF, + RelocationTable from TDF, + Data from TDF, + ExtendedString from TCollection, + HSequenceOfExtendedString from TColStd, + HSequenceOfInteger from TColStd + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + Set (myclass; label : Label from TDF) + returns StudyPropertiesAttribute from SALOMEDS; + + ---Purpose: Common methods + -- ============ + + Create + returns mutable StudyPropertiesAttribute from SALOMEDS; + + Init(me: mutable); + + SetUserName(me: mutable; theName : ExtendedString from TCollection); + GetCreatorName(me) returns ExtendedString from TCollection; + GetUserNames(me) returns HSequenceOfExtendedString from TColStd; + SetFirstName(me: mutable; theName : ExtendedString from TCollection); + + SetModificationDate(me: mutable; theMinute, theHour, theDay, theMonth, theYear : Integer from Standard); + GetCreationDate(me; theMinute, theHour, theDay, theMonth, theYear : out Integer from Standard) + returns Boolean from Standard; + GetModificationDates(me; theMinutes, theHours, theDays, theMonths, theYears : out HSequenceOfInteger from TColStd); + + SetCreationMode(me: mutable; theMode : Integer from Standard); + GetCreationMode(me) returns Integer from Standard; + + SetModified(me: mutable; theModified : Integer from Standard); + IsModified(me) returns Boolean from Standard; + GetModified(me) returns Integer from Standard; + + SetLocked(me: mutable; theLocked : Boolean from Standard); + IsLocked(me) returns Boolean from Standard; + IsLockChanged(me: mutable; theErase : Boolean from Standard) returns Boolean from Standard; + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +fields + + myUserName : HSequenceOfExtendedString from TColStd; + myMinute : HSequenceOfInteger from TColStd; + myHour : HSequenceOfInteger from TColStd; + myDay : HSequenceOfInteger from TColStd; + myMonth : HSequenceOfInteger from TColStd; + myYear : HSequenceOfInteger from TColStd; + myMode : Integer from Standard; + myModified : Integer from Standard; + myLocked : Boolean from Standard; + myLockChanged : Boolean from Standard; + +end StudyPropertiesAttribute; diff --git a/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.cxx b/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.cxx new file mode 100644 index 000000000..9cebecc22 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.cxx @@ -0,0 +1,214 @@ +using namespace std; +// File : SALOMEDS_StudyPropertiesAttribute.cxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#include + +const Standard_GUID& SALOMEDS_StudyPropertiesAttribute::GetID() +{ + static Standard_GUID SALOMEDS_StudyPropertiesAttributeID ("128371A2-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_StudyPropertiesAttributeID; +} + +Handle(SALOMEDS_StudyPropertiesAttribute) SALOMEDS_StudyPropertiesAttribute::Set(const TDF_Label& label) +{ + Handle(SALOMEDS_StudyPropertiesAttribute) anAttr; + if (!label.FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(),anAttr)) { + anAttr = new SALOMEDS_StudyPropertiesAttribute(); + label.AddAttribute(anAttr); + } + return anAttr; +} + +SALOMEDS_StudyPropertiesAttribute::SALOMEDS_StudyPropertiesAttribute() +{ + myLocked = Standard_False; + myLockChanged = Standard_False; + Init(); +} + +void SALOMEDS_StudyPropertiesAttribute::Init() +{ + myUserName = new TColStd_HSequenceOfExtendedString(); + myMinute = new TColStd_HSequenceOfInteger(); + myHour = new TColStd_HSequenceOfInteger(); + myDay = new TColStd_HSequenceOfInteger(); + myMonth = new TColStd_HSequenceOfInteger(); + myYear = new TColStd_HSequenceOfInteger(); +// myModified = 0; + myMode = 0; // none +} + +void SALOMEDS_StudyPropertiesAttribute::SetUserName(const TCollection_ExtendedString& theName) +{ + Backup(); + myUserName->Append(theName); +} + +void SALOMEDS_StudyPropertiesAttribute::SetFirstName(const TCollection_ExtendedString& theName) +{ + Backup(); + if (myUserName->Length() == 0) myUserName->Append(theName); + else myUserName->SetValue(1, theName); +} + +TCollection_ExtendedString SALOMEDS_StudyPropertiesAttribute::GetCreatorName() const +{ + if (myUserName->Length() == 0) return TCollection_ExtendedString(""); + return myUserName->Value(1); +} + +Handle(TColStd_HSequenceOfExtendedString) SALOMEDS_StudyPropertiesAttribute::GetUserNames() const +{ + return myUserName; +} + +void SALOMEDS_StudyPropertiesAttribute::SetModificationDate(const Standard_Integer theMinute, + const Standard_Integer theHour, + const Standard_Integer theDay, + const Standard_Integer theMonth, + const Standard_Integer theYear) +{ + Backup(); + if (theMinute<0 || theMinute>60 || theHour<0 || theHour>24 || theDay<0 || theDay>31 || theMonth<0 || theMonth>12) + return; + myMinute->Append(theMinute); + myHour->Append(theHour); + myDay->Append(theDay); + myMonth->Append(theMonth); + myYear->Append(theYear); +} + +Standard_Boolean SALOMEDS_StudyPropertiesAttribute::GetCreationDate(Standard_Integer& theMinute, + Standard_Integer& theHour, + Standard_Integer& theDay, + Standard_Integer& theMonth, + Standard_Integer& theYear) const +{ + if (myMinute->Length() != 0) { + theMinute = myMinute->Value(1); + theHour = myHour->Value(1); + theDay = myDay->Value(1); + theMonth = myMonth->Value(1); + theYear = myYear->Value(1); + return Standard_True; + } + return Standard_False; +} + +void SALOMEDS_StudyPropertiesAttribute::GetModificationDates(Handle(TColStd_HSequenceOfInteger)& theMinutes, + Handle(TColStd_HSequenceOfInteger)& theHours, + Handle(TColStd_HSequenceOfInteger)& theDays, + Handle(TColStd_HSequenceOfInteger)& theMonths, + Handle(TColStd_HSequenceOfInteger)& theYears) const +{ + theMinutes = myMinute; + theHours = myHour; + theDays = myDay; + theMonths = myMonth; + theYears = myYear; +} + +void SALOMEDS_StudyPropertiesAttribute::SetCreationMode(const Standard_Integer theMode) +{ + Backup(); + myMode = theMode; +} + +Standard_Integer SALOMEDS_StudyPropertiesAttribute::GetCreationMode() const +{ + return myMode; +} + +void SALOMEDS_StudyPropertiesAttribute::SetModified(const Standard_Integer theModified) +{ + myModified = theModified; +} + +Standard_Boolean SALOMEDS_StudyPropertiesAttribute::IsModified() const +{ + return (myModified != 0); +} + +Standard_Integer SALOMEDS_StudyPropertiesAttribute::GetModified() const +{ + return myModified; +} + +void SALOMEDS_StudyPropertiesAttribute::SetLocked(const Standard_Boolean theLocked) +{ +// Backup(); + if (myLocked != theLocked) { + myLockChanged = Standard_True; + myLocked = theLocked; + } +} + +Standard_Boolean SALOMEDS_StudyPropertiesAttribute::IsLocked() const +{ + return myLocked; +} + +Standard_Boolean SALOMEDS_StudyPropertiesAttribute::IsLockChanged(const Standard_Boolean theErase) { + if (!myLockChanged) return Standard_False; + if (theErase) myLockChanged = Standard_False; + return Standard_True; +} + +const Standard_GUID& SALOMEDS_StudyPropertiesAttribute::ID() const +{ + return GetID(); +} + +void SALOMEDS_StudyPropertiesAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(with); + Init(); + Standard_Integer i; + Handle(TColStd_HSequenceOfExtendedString) aNames = aProp->GetUserNames(); + for(i = aNames->Length(); i > 0; i--) { + myUserName->Prepend(aNames->Value(i)); + } + Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears; + aProp->GetModificationDates(aMinutes, aHours, aDays, aMonths, aYears); + for(i = aMinutes->Length(); i > 0; i--) { + myMinute->Prepend(aMinutes->Value(i)); + myHour->Prepend(aHours->Value(i)); + myDay->Prepend(aDays->Value(i)); + myMonth->Prepend(aMonths->Value(i)); + myYear->Prepend(aYears->Value(i)); + } + myMode = aProp->GetCreationMode(); +// myModified = aProp->GetModified(); +// myLocked = aProp->IsLocked(); +} + +Handle(TDF_Attribute) SALOMEDS_StudyPropertiesAttribute::NewEmpty() const +{ + return new SALOMEDS_StudyPropertiesAttribute(); +} + +void SALOMEDS_StudyPropertiesAttribute::Paste(const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)&) const +{ + Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(into); + aProp->Init(); + + Standard_Integer i; + for(i = 1; i <= myUserName->Length(); i++) { + aProp->SetUserName(myUserName->Value(i)); + } + for(i = 1; i <= myMinute->Length(); i++) { + aProp->SetModificationDate(myMinute->Value(i), myHour->Value(i), myDay->Value(i), myMonth->Value(i), myYear->Value(i)); + } + + aProp->SetCreationMode(myMode); +// aProp->SetModified(myModified); +// aProp->SetLocked(myLocked); +} + diff --git a/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.hxx b/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.hxx new file mode 100644 index 000000000..0fbddb4be --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.hxx @@ -0,0 +1,145 @@ +// File : SALOMEDS_StudyPropertiesAttribute.hxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef _SALOMEDS_StudyPropertiesAttribute_HeaderFile +#define _SALOMEDS_StudyPropertiesAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_StudyPropertiesAttribute_HeaderFile +#include +#endif + +#ifndef _Handle_TColStd_HSequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Handle_TColStd_HSequenceOfInteger_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class TColStd_HSequenceOfExtendedString; +class TColStd_HSequenceOfInteger; +class Standard_GUID; +class TDF_Label; +class TCollection_ExtendedString; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_StudyPropertiesAttribute : public TDF_Attribute { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_StudyPropertiesAttribute Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDS_StudyPropertiesAttribute(); +Standard_EXPORT void Init() ; +Standard_EXPORT void SetUserName(const TCollection_ExtendedString& theName) ; +Standard_EXPORT void SetFirstName(const TCollection_ExtendedString& theName) ; +Standard_EXPORT TCollection_ExtendedString GetCreatorName() const; +Standard_EXPORT Handle_TColStd_HSequenceOfExtendedString GetUserNames() const; +Standard_EXPORT void SetModificationDate(const Standard_Integer theMinute,const Standard_Integer theHour,const Standard_Integer theDay,const Standard_Integer theMonth,const Standard_Integer theYear) ; +Standard_EXPORT Standard_Boolean GetCreationDate(Standard_Integer& theMinute,Standard_Integer& theHour,Standard_Integer& theDay,Standard_Integer& theMonth,Standard_Integer& theYear) const; +Standard_EXPORT void GetModificationDates(Handle(TColStd_HSequenceOfInteger)& theMinutes,Handle(TColStd_HSequenceOfInteger)& theHours,Handle(TColStd_HSequenceOfInteger)& theDays,Handle(TColStd_HSequenceOfInteger)& theMonths,Handle(TColStd_HSequenceOfInteger)& theYears) const; +Standard_EXPORT void SetCreationMode(const Standard_Integer theMode) ; +Standard_EXPORT Standard_Integer GetCreationMode() const; +Standard_EXPORT void SetModified(const Standard_Integer theModified) ; +Standard_EXPORT Standard_Boolean IsModified() const; +Standard_EXPORT Standard_Integer GetModified() const; +Standard_EXPORT void SetLocked(const Standard_Boolean theLocked) ; +Standard_EXPORT Standard_Boolean IsLocked() const; +Standard_EXPORT Standard_Boolean IsLockChanged(const Standard_Boolean theErase) ; +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT ~SALOMEDS_StudyPropertiesAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_StudyPropertiesAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Handle_TColStd_HSequenceOfExtendedString myUserName; +Handle_TColStd_HSequenceOfInteger myMinute; +Handle_TColStd_HSequenceOfInteger myHour; +Handle_TColStd_HSequenceOfInteger myDay; +Handle_TColStd_HSequenceOfInteger myMonth; +Handle_TColStd_HSequenceOfInteger myYear; +Standard_Integer myMode; +Standard_Integer myModified; +Standard_Boolean myLocked; +Standard_Boolean myLockChanged; + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.ixx b/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.ixx new file mode 100644 index 000000000..630d3f471 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.ixx @@ -0,0 +1,65 @@ +// File : SALOMEDS_StudyPropertiesAttribute.ixx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_StudyPropertiesAttribute::~SALOMEDS_StudyPropertiesAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_StudyPropertiesAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDF_Attribute); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_StudyPropertiesAttribute", + sizeof(SALOMEDS_StudyPropertiesAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_StudyPropertiesAttribute) Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_StudyPropertiesAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_StudyPropertiesAttribute))) { + _anOtherObject = Handle(SALOMEDS_StudyPropertiesAttribute)((Handle(SALOMEDS_StudyPropertiesAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_StudyPropertiesAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_StudyPropertiesAttribute) ; +} +Standard_Boolean SALOMEDS_StudyPropertiesAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_StudyPropertiesAttribute) == AType || TDF_Attribute::IsKind(AType)); +} +Handle_SALOMEDS_StudyPropertiesAttribute::~Handle_SALOMEDS_StudyPropertiesAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.jxx b/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.jxx new file mode 100644 index 000000000..2f174087a --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_StudyPropertiesAttribute.jxx @@ -0,0 +1,32 @@ +// File : SALOMEDS_StudyPropertiesAttribute.jxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef _TColStd_HSequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _TColStd_HSequenceOfInteger_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_StudyPropertiesAttribute_HeaderFile +#include +#endif diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx new file mode 100644 index 000000000..ae4a1f076 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -0,0 +1,959 @@ +using namespace std; +// File : SALOMEDS_Study_i.cxx +// Created : Wed Nov 28 16:27:23 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#include "utilities.h" +#include "SALOMEDS_Study_i.hxx" + +#include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx" +#include +#include +#include +#include +#include +#include +#include +#include +#include "SALOMEDS_LocalIDAttribute.hxx" +#include "SALOMEDS_UseCaseIterator_i.hxx" + + +#define DIRECTORYID "DIRECTORY:" +#define FILEID "FILE: " + +//============================================================================ +/*! Function : SALOMEDS_Study_i + * Purpose : SALOMEDS_Study_i constructor + */ +//============================================================================ +SALOMEDS_Study_i::SALOMEDS_Study_i(const Handle(TDocStd_Document) doc, + CORBA::ORB_ptr orb, + const char* study_name) +{ + _orb = CORBA::ORB::_duplicate(orb); + _doc = doc; + _name = new char[strlen(study_name) +1]; + strcpy(_name,study_name); + _isSaved = false ; + _URL = NULL; + _StudyId = -1; + _autoFill = true; +} + +//============================================================================ +/*! Function : ~SALOMEDS_Study_i + * Purpose : SALOMEDS_Study_i destructor + */ +//============================================================================ +SALOMEDS_Study_i::~SALOMEDS_Study_i() +{ + delete [] _name ; + delete [] _URL ; +} + +//============================================================================ +/*! Function : GetPersistentReference + * Purpose : Get persistent reference of study (idem URL()) + */ +//============================================================================ +char* SALOMEDS_Study_i::GetPersistentReference() +{ + return URL(); +} +//============================================================================ +/*! Function : GetTransientReference + * Purpose : Get IOR of the Study (registred in OCAF document in doc->Root) + */ +//============================================================================ +char* SALOMEDS_Study_i::GetTransientReference() +{ + CORBA::String_var IOR; + + Handle(SALOMEDS_IORAttribute) Att; + TDF_Label _lab = _doc->GetData()->Root(); + if (!_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){ + + TCollection_AsciiString ch(Att->Get()); + IOR = CORBA::string_dup(ch.ToCString()); + } + else IOR = CORBA::string_dup(""); // NULL ? + + return CORBA::string_dup(IOR); +} + +//============================================================================ +/*! Function : IsEmpty + * Purpose : Detect if study is empty + */ +//============================================================================ +CORBA::Boolean SALOMEDS_Study_i::IsEmpty() +{ + if (_doc.IsNull()) return true; + return _doc->IsEmpty(); +} + +//============================================================================ +/*! Function : FindComponent + * Purpose : Find a Component with ComponentDataType = aComponentName + */ +//============================================================================ +SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponentName) +{ + bool _find = false; + Standard_CString name; + SALOMEDS::SComponentIterator_var itcomp = NewComponentIterator(); + SALOMEDS::SComponent_var compo; + + for (; itcomp->More(); itcomp->Next()) { + SALOMEDS::SComponent_var SC = itcomp->Value(); + name = SC->ComponentDataType(); + //ED if ( TCollection_AsciiString(name).IsEqual(TCollection_AsciiString(strdup(aComponentName))) ) { + if(strcmp(aComponentName,name) == 0){ + _find = true; + return SALOMEDS::SComponent::_narrow(SC); + } + } + if(!_find) + { + return SALOMEDS::SComponent::_nil(); + } + return compo; +} + +//============================================================================ +/*! Function : FindComponentID + * Purpose : Find a Component from it's ID + */ +//============================================================================ +SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponentID(const char* aComponentID) +{ + // Iterate on each components defined in the study + // Get the component ID and compare with aComponentID + bool _find = false; + char *ID; + SALOMEDS::SComponent_ptr compo; + + SALOMEDS::SComponentIterator_var itcomp = NewComponentIterator(); + for (; itcomp->More(); itcomp->Next()) { + SALOMEDS::SComponent_var SC = itcomp->Value(); + ID = SC->GetID(); + if(strcmp(aComponentID,ID)==0) + { + // ComponentID found + _find = true; + compo = SALOMEDS::SComponent::_narrow(SC); + } + } + if(!_find) + { + compo = SALOMEDS::SComponent::_nil(); + } + return compo; +} + +//============================================================================ +/*! Function : FindObject + * Purpose : Find an Object with SALOMEDS::Name = anObjectName + */ +//============================================================================ +SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObject(const char* anObjectName) +{ + // Iterate to all components defined in the study + // After testing the component name, iterate in all objects defined under + // components (function _FindObject) + bool _find = false; + SALOMEDS::SObject_ptr RefSO = SALOMEDS::SObject::_nil(); + + SALOMEDS::SComponentIterator_var it = NewComponentIterator(); + for (; it->More();it->Next()){ + if(!_find) + { + SALOMEDS::SComponent_var SC = it->Value(); + SALOMEDS::GenericAttribute_var anAttr; + if (SC->FindAttribute(anAttr,"AttributeName")) + { + SALOMEDS::AttributeName_var Name = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var Val = Name->Value(); + if (strcmp(Val, anObjectName) == 0) + { + _find = true; + RefSO = SALOMEDS::SObject::_narrow(SC); + } + } + if (!_find) RefSO = _FindObject(SC,anObjectName, _find); + } + } + return RefSO; +} + +//============================================================================ +/*! Function : FindObjectID + * Purpose : Find an Object with ID = anObjectID + */ +//============================================================================ +SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID) +{ + // Convert aSO->GetID in TDF_Label. + TDF_Label Lab; + TDF_Tool::Label(_doc->GetData(), strdup(anObjectID), Lab); + + if (Lab.IsNull()) return SALOMEDS::SObject::_nil(); + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (Lab,_orb); + SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + return so; + +} + +//============================================================================ +/*! Function : FindObjectByName + * Purpose : Find Objects with SALOMEDS::Name = anObjectName in a Component + * : with ComponentDataType = aComponentName + */ +//============================================================================ +SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char* anObjectName, + const char* aComponentName ) +{ + SALOMEDS::Study::ListOfSObject_var listSO = new SALOMEDS::Study::ListOfSObject ; + listSO->length(0); + + SALOMEDS::SComponent_ptr compo = FindComponent(aComponentName) ; + if ( compo->_is_nil() ) { + MESSAGE ("In FindObjectByName() : Component named " << aComponentName << " not found "); + return listSO._retn(); + } + + // Iterate on each object and subobject of the component + // If objectName is found add it to the list of SObjects + char *name; + char *childName ; + SALOMEDS::SObject_ptr addSO = SALOMEDS::SObject::_nil(); + + CORBA::String_var compoId = compo->GetID(); + SALOMEDS::ChildIterator_var it = NewChildIterator(compo); + int length = 0 ; + for ( ; it->More();it->Next() ) { + + SALOMEDS::SObject_var CSO = it->Value(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if ( CSO->FindAttribute(anAttr, "AttributeName") ) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + name = aName->Value(); + if ( strcmp( name, anObjectName ) == 0) { + addSO = SALOMEDS::SObject::_narrow(CSO); + /* add to list */ + length++ ; + listSO->length(length); + listSO[length-1] = addSO ; + } + + /* looks also for eventual children */ + bool found = false ; + addSO = _FindObject( CSO, anObjectName, found ) ; + if( found) { + length++ ; + listSO->length(length); + listSO[length-1] = addSO ; + } + } + } + return listSO._retn() ; +} + + + +//============================================================================ +/*! Function : FindObjectIOR + * Purpose : Find an Object with IOR = anObjectIOR + */ +//============================================================================ +SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR) +{ + // firstly searching in the datamap for optimization + CORBA::String_var anIOR = CORBA::string_dup(anObjectIOR); + if (myIORLabels.IsBound(TCollection_ExtendedString(anIOR))) { + SALOMEDS_SObject_i* aResult = new SALOMEDS_SObject_i(myIORLabels.Find(TCollection_ExtendedString(anIOR)),_orb); + // 11 oct 2002: forbidden attributes must be checked here + SALOMEDS::GenericAttribute_var anAttr; + if (!aResult->FindAttribute(anAttr,"AttributeIOR")) { + myIORLabels.UnBind(TCollection_ExtendedString(anIOR)); + } else return aResult->_this(); + } + // Iterate to all components defined in the study + // After testing the component name, iterate in all objects defined under + // components (function _FindObject) + bool _find = false; + SALOMEDS::SObject_ptr RefSO = SALOMEDS::SObject::_nil(); + + SALOMEDS::SComponentIterator_var it = NewComponentIterator(); + for (; it->More();it->Next()){ + if(!_find) + { + SALOMEDS::SComponent_var SC = it->Value(); + SALOMEDS::GenericAttribute_var anAttr; + if (SC->FindAttribute(anAttr,"AttributeIOR")) + { + SALOMEDS::AttributeIOR_var IOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + CORBA::String_var Val = IOR->Value(); + if (strcmp(Val, anObjectIOR) == 0) + { + _find = true; + RefSO = SALOMEDS::SObject::_narrow(SC); + } + } + if (!_find) + RefSO = _FindObjectIOR(SC,anObjectIOR, _find); + } + } + if (!RefSO->_is_nil()) INFOS("SALOMEDS_Study_i::FindObjectIOR: found label with old methods"); + + return RefSO; +} + +//============================================================================ +/*! Function : FindObjectByPath + * Purpose : Find an Object by its path = thePath + */ +//============================================================================ +SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath) +{ + TCollection_AsciiString aPath(CORBA::string_dup(thePath)), aToken; + SALOMEDS::SObject_var aSO = SALOMEDS::SObject::_nil(); + int i = 1, aLength = aPath.Length(); + bool isRelative = false; + + if(aLength == 0) { //Empty path - return the current context + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (_current, _orb); + aSO = SALOMEDS::SObject::_narrow(so_servant->_this()); + return aSO._retn(); + } + + if(aPath.Value(1) != '/') //Relative path + isRelative = true; + + TDF_ChildIterator anIterator; + TDF_Label aLabel; + Handle(TDataStd_Name) anAttr; + + if(isRelative) { + if(_current.IsNull()) throw SALOMEDS::Study::StudyInvalidContext(); + anIterator.Initialize(_current, Standard_False); + } + else { + if(aPath.Length() == 1 && aPath.Value(1) == '/') { //Root + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (_doc->Main(), _orb); + aSO = SALOMEDS::SObject::_narrow(so_servant->_this()); + return aSO._retn(); + } + anIterator.Initialize(_doc->Main(), Standard_False); + } + + while(i <= aLength) { + + aToken = aPath.Token("/", i); + if(aToken.Length() == 0) break; + + for ( ; anIterator.More(); anIterator.Next() ) { + aLabel = anIterator.Value(); + if(aLabel.FindAttribute(TDataStd_Name::GetID(), anAttr)) { + if(anAttr->Get() == aToken) { + aToken = aPath.Token("/", i+1); //Check if it was the last part of the path + if(aToken.Length() == 0) { //The searched label is found (no part of the path is left) + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aLabel, _orb); + aSO = SALOMEDS::SObject::_narrow(so_servant->_this()); + return aSO._retn(); + } + + anIterator.Initialize(aLabel, Standard_False); + break; + } + } + } + + i++; + } + + return aSO._retn(); +} + +//============================================================================ +/*! Function : GetObjectPath + * Purpose : + */ +//============================================================================ +char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject) +{ + TCollection_AsciiString aPath(""); + if(CORBA::is_nil(theObject)) return CORBA::string_dup(aPath.ToCString()); + + SALOMEDS::SObject_var anObject = SALOMEDS::SObject::_narrow(theObject); + if(anObject->_is_nil()) { + anObject = FindObjectIOR(_orb->object_to_string(theObject)); + if(anObject->_is_nil()) return CORBA::string_dup(aPath.ToCString()); + } + + SALOMEDS::GenericAttribute_var anAttr; + if(anObject->FindAttribute(anAttr, "AttributeName")) { + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + if(anAttr->_is_nil()) return CORBA::string_dup(aPath.ToCString()); + TCollection_AsciiString aValue(aName->Value()); + aValue.Prepend("/"); + aValue += aPath; + aPath = aValue; + SALOMEDS::SObject_ptr aFather = anObject->GetFather(); + if(!aFather->_is_nil()) { + TDF_Label aLabel; + Handle(TDataStd_Name) aNameAttrib; + TDF_Tool::Label(_doc->GetData(), aFather->GetID(), aLabel); + if(aLabel.FindAttribute(TDataStd_Name::GetID(), aNameAttrib)) { + aValue = GetObjectPath(aFather); + aPath = aValue + aPath; + } + } + } + + return CORBA::string_dup(aPath.ToCString()); +} + + +//============================================================================ +/*! Function : SetContext + * Purpose : Sets the current context + */ +//============================================================================ +void SALOMEDS_Study_i::SetContext(const char* thePath) +{ + if(thePath == NULL || strlen(thePath) == 0) throw SALOMEDS::Study::StudyInvalidDirectory(); + TCollection_AsciiString aPath(CORBA::string_dup(thePath)), aContext(""); + bool isInvalid = false, isFound = false; + SALOMEDS::SObject_var aSO; + + if(aPath.Value(1) != '/') { //Relative path + aContext = TCollection_AsciiString(GetContext()); + aContext += '/'; + aContext += aPath; + } + else + aContext = aPath; + + try { + aSO = FindObjectByPath(aContext.ToCString()); + } + catch( ... ) { + isInvalid = true; + } + + if(isInvalid || aSO->_is_nil()) throw SALOMEDS::Study::StudyInvalidContext(); + + TDF_Label aLabel; + TDF_Tool::Label(_doc->GetData(), aSO->GetID(), aLabel); + if(aLabel.IsNull()) throw SALOMEDS::Study::StudyInvalidContext(); + else + _current = aLabel; //Set the current context + +} + +//============================================================================ +/*! Function : GetContext + * Purpose : Gets the current context + */ +//============================================================================ +char* SALOMEDS_Study_i::GetContext() +{ + if(_current.IsNull()) throw SALOMEDS::Study::StudyInvalidContext(); + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (_current, _orb); + SALOMEDS::SObject_var aSO = SALOMEDS::SObject::_narrow(so_servant->_this()); + return GetObjectPath(aSO._retn()); +} + +//============================================================================ +/*! Function : GetObjectNames + * Purpose : method to get all object names in the given context (or in the current context, if 'theContext' is empty) + */ +//============================================================================ +SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetObjectNames(const char* theContext) { + TColStd_SequenceOfExtendedString aResultSeq; + SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings; + TDF_Label aLabel; + if (strlen(theContext) == 0) { + if(_current.IsNull()) throw SALOMEDS::Study::StudyInvalidContext(); + aLabel = _current; + } else { + TDF_Label aTmp = _current; + SetContext(theContext); + aLabel = _current; + _current = aTmp; + } + TDF_ChildIterator anIter(aLabel, Standard_False); // iterate all subchildren at all sublevels + for(; anIter.More(); anIter.Next()) { + TDF_Label aLabel = anIter.Value(); +// Handle(TDF_Attribute) anAttribute; +// if (aLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttribute) || +// aLabel.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(), anAttribute)) { + Handle(TDataStd_Name) aName; + if (aLabel.FindAttribute(TDataStd_Name::GetID(), aName)) aResultSeq.Append(aName->Get()); +// } + } + // fill the result table + int anIndex, aLength = aResultSeq.Length(); + aResult->length(aLength); + for(anIndex = 0; anIndex < aLength; anIndex++) { + aResult[anIndex] = CORBA::string_dup(TCollection_AsciiString(aResultSeq.Value(anIndex + 1)).ToCString()); + } + return aResult._retn(); +} + +//============================================================================ +/*! Function : GetDirectoryNames + * Purpose : method to get all directory names in the given context (or in the current context, if 'theContext' is empty) + */ +//============================================================================ +SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetDirectoryNames(const char* theContext) { + TColStd_SequenceOfExtendedString aResultSeq; + SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings; + TDF_Label aLabel; + if (strlen(theContext) == 0) { + if(_current.IsNull()) throw SALOMEDS::Study::StudyInvalidContext(); + aLabel = _current; + } else { + TDF_Label aTmp = _current; + SetContext(theContext); + aLabel = _current; + _current = aTmp; + } + TDF_ChildIterator anIter(aLabel, Standard_False); // iterate first-level children at all sublevels + for(; anIter.More(); anIter.Next()) { + TDF_Label aLabel = anIter.Value(); +// Handle(TDF_Attribute) anAttribute; +// if (!aLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttribute) && +// !aLabel.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(), anAttribute)) { + Handle(SALOMEDS_PersRefAttribute) anID; + if (aLabel.FindAttribute(SALOMEDS_PersRefAttribute::GetID(), anID)) { + if (anID->Get().Search(TCollection_ExtendedString(DIRECTORYID)) == 1) { + Handle(TDataStd_Name) aName; + if (aLabel.FindAttribute(TDataStd_Name::GetID(), aName)) { + aResultSeq.Append(aName->Get()); + } + } + } +// } + } + // fill the result table + int anIndex, aLength = aResultSeq.Length(); + aResult->length(aLength); + for(anIndex = 0; anIndex < aLength; anIndex++) { + aResult[anIndex] = CORBA::string_dup(TCollection_AsciiString(aResultSeq.Value(anIndex + 1)).ToCString()); + } + return aResult._retn(); +} + +//============================================================================ +/*! Function : GetFileNames + * Purpose : method to get all file names in the given context (or in the current context, if 'theContext' is empty) + */ +//============================================================================ +SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetFileNames(const char* theContext) { + TColStd_SequenceOfExtendedString aResultSeq; + SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings; + TDF_Label aLabel; + if (strlen(theContext) == 0) { + if(_current.IsNull()) throw SALOMEDS::Study::StudyInvalidContext(); + aLabel = _current; + } else { + TDF_Label aTmp = _current; + SetContext(theContext); + aLabel = _current; + _current = aTmp; + } + TDF_ChildIterator anIter(aLabel, Standard_False); // iterate all subchildren at all sublevels + for(; anIter.More(); anIter.Next()) { + TDF_Label aLabel = anIter.Value(); +// Handle(TDF_Attribute) anAttribute; +// if (aLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttribute) || +// aLabel.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(), anAttribute)) { + Handle(SALOMEDS_PersRefAttribute) aName; + if (aLabel.FindAttribute(SALOMEDS_PersRefAttribute::GetID(), aName)) { + if (aName->Get().Search(TCollection_ExtendedString(FILEID)) == 1) { + aResultSeq.Append(aName->Get().Split(strlen(FILEID))); + } + } +// } + } + // fill the result table + int anIndex, aLength = aResultSeq.Length(); + aResult->length(aLength); + for(anIndex = 0; anIndex < aLength; anIndex++) { + aResult[anIndex] = CORBA::string_dup(TCollection_AsciiString(aResultSeq.Value(anIndex + 1)).ToCString()); + } + return aResult._retn(); +} + +//============================================================================ +/*! Function : GetComponentNames + * Purpose : method to get all components names + */ +//============================================================================ +SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetComponentNames(const char* theContext) { + TColStd_SequenceOfExtendedString aResultSeq; + SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings; + TDF_ChildIterator anIter(_doc->Main(), Standard_False); // iterate all subchildren at first level + for(; anIter.More(); anIter.Next()) { + TDF_Label aLabel = anIter.Value(); + Handle(TDataStd_Name) aName; + if (aLabel.FindAttribute(TDataStd_Name::GetID(), aName)) aResultSeq.Append(aName->Get()); + } + // fill the result table + int anIndex, aLength = aResultSeq.Length(); + aResult->length(aLength); + for(anIndex = 0; anIndex < aLength; anIndex++) { + aResult[anIndex] = CORBA::string_dup(TCollection_AsciiString(aResultSeq.Value(anIndex + 1)).ToCString()); + } + return aResult._retn(); +} + +//============================================================================ +/*! Function : NewChildIterator + * Purpose : Create a ChildIterator from an SObject + */ +//============================================================================ +SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr aSO) +{ + //Convert aSO->GetID in TDF_Label. + TDF_Label Lab; + TDF_Tool::Label(_doc->GetData(), strdup(aSO->GetID()), Lab); + + //Create iterator + SALOMEDS_ChildIterator_i* it_servant = new SALOMEDS_ChildIterator_i(Lab,_orb); + SALOMEDS::ChildIterator_var it = SALOMEDS::ChildIterator::_narrow(it_servant->_this()); + + return it; +} + + +//============================================================================ +/*! Function : NewComponentIterator + * Purpose : Create a SComponentIterator + */ +//============================================================================ +SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator() +{ + SALOMEDS_SComponentIterator_i* it_servant = new SALOMEDS_SComponentIterator_i(_doc,_orb); + SALOMEDS::SComponentIterator_var it = SALOMEDS::SComponentIterator::_narrow(it_servant->_this()); + return it; +} + + +//============================================================================ +/*! Function : NewBuilder + * Purpose : Create a StudyBuilder + */ +//============================================================================ +SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder() +{ + SALOMEDS_StudyBuilder_i* it_servant = new SALOMEDS_StudyBuilder_i(_doc,_orb); + SALOMEDS::StudyBuilder_var it = SALOMEDS::StudyBuilder::_narrow(it_servant->_this()); + + if(_autoFill) { + SALOMEDS_Callback_i* callback = new SALOMEDS_Callback_i(GetUseCaseBuilder(), _orb); + SALOMEDS::Callback_var cb = SALOMEDS::Callback::_narrow(callback->_this()); + + it->SetOnAddSObject(cb); + it->SetOnRemoveSObject(cb); + } + + return it; + +} + +//============================================================================ +/*! Function : Name + * Purpose : get study name + */ +//============================================================================ +char* SALOMEDS_Study_i::Name() +{ + return CORBA::string_dup(_name); +} + +//============================================================================ +/*! Function : Name + * Purpose : set study name + */ +//============================================================================ +void SALOMEDS_Study_i::Name(const char* name) +{ + _name = new char[strlen(name) +1]; + strcpy(_name,name); +} + +//============================================================================ +/*! Function : IsSaved + * Purpose : get if study has been saved + */ +//============================================================================ +CORBA::Boolean SALOMEDS_Study_i::IsSaved() +{ + return _isSaved; +} + +//============================================================================ +/*! Function : IsSaved + * Purpose : set if study has been saved + */ +//============================================================================ +void SALOMEDS_Study_i::IsSaved(CORBA::Boolean save) +{ + _isSaved = save; +} + +//============================================================================ +/*! Function : IsModified + * Purpose : Detect if a Study has been modified since it has been saved + */ +//============================================================================ +CORBA::Boolean SALOMEDS_Study_i::IsModified() +{ + // True if is modified and not saved + if (_doc->IsModified()) + if (!_isSaved) return true; + else return false; + else return false; +} + +//============================================================================ +/*! Function : URL + * Purpose : get URL of the study (persistent reference of the study) + */ +//============================================================================ +char* SALOMEDS_Study_i::URL() +{ + return CORBA::string_dup(_URL); +} + +//============================================================================ +/*! Function : URL + * Purpose : set URL of the study (persistent reference of the study) + */ +//============================================================================ +void SALOMEDS_Study_i::URL(const char* url) +{ + _URL = new char[strlen(url) +1]; + strcpy(_URL,url); + SCRUTE(_URL); +} + + +//============================================================================ +/*! Function : _FindObject + * Purpose : Find an Object with SALOMEDS::Name = anObjectName + */ +//============================================================================ +SALOMEDS::SObject_ptr SALOMEDS_Study_i::_FindObject(SALOMEDS::SObject_ptr SO, + const char* anObjectName, + bool& _find) +{ + // Iterate on each objects and subobjects of the component + // If objectName find, stop the loop and get the object reference + SALOMEDS::SObject_ptr RefSO = SALOMEDS::SObject::_nil(); + + CORBA::String_var soid = SO->GetID(); + SALOMEDS::ChildIterator_var it = NewChildIterator(SO); + for (; it->More();it->Next()){ + if(!_find) + { + SALOMEDS::SObject_var CSO = it->Value(); + SALOMEDS::GenericAttribute_var anAttr; + if (CSO->FindAttribute(anAttr,"AttributeName")) + { + SALOMEDS::AttributeName_var Name = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var Val = Name->Value(); + if (strcmp(Val, anObjectName) == 0) + { + RefSO = SALOMEDS::SObject::_narrow(CSO); + _find = true; + } + } + if (!_find) RefSO = _FindObject(CSO, anObjectName, _find); + } + } + return RefSO; +} + +//============================================================================ +/*! Function : _FindObject + * Purpose : Find an Object with SALOMEDS::IOR = anObjectIOR + */ +//============================================================================ +SALOMEDS::SObject_ptr +SALOMEDS_Study_i::_FindObjectIOR(SALOMEDS::SObject_ptr SO, + const char* anObjectIOR, + bool& _find) +{ + // Iterate on each objects and subobjects of the component + // If objectName find, stop the loop and get the object reference + SALOMEDS::SObject_ptr RefSO = SALOMEDS::SObject::_nil(); + + SALOMEDS::ChildIterator_var it = NewChildIterator(SO); + for (; it->More();it->Next()){ + if(!_find) + { + SALOMEDS::SObject_var CSO = it->Value(); + SALOMEDS::GenericAttribute_var anAttr; + if (CSO->FindAttribute(anAttr,"AttributeIOR")) + { + SALOMEDS::AttributeIOR_var IOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + CORBA::String_var Val = IOR->Value(); + if (strcmp(Val, anObjectIOR) == 0) + { + RefSO = SALOMEDS::SObject::_narrow(CSO); + _find = true; + } + } + if (!_find) RefSO = _FindObjectIOR(CSO, anObjectIOR, _find); + } + } + return RefSO; +} + +CORBA::Short SALOMEDS_Study_i::StudyId() +{ + return _StudyId; +} + +void SALOMEDS_Study_i::StudyId(CORBA::Short id) +{ + _StudyId = id; +} + +void SALOMEDS_Study_i::UpdateIORLabelMap(const char* anIOR,const char* anEntry) { + TDF_Label aLabel; + CORBA::String_var anEn = CORBA::string_dup(anEntry); + CORBA::String_var IOR = CORBA::string_dup(anIOR); + TDF_Tool::Label(_doc->GetData(),anEn,aLabel, Standard_True); + if (myIORLabels.IsBound(TCollection_ExtendedString(IOR))) myIORLabels.UnBind(TCollection_ExtendedString(IOR)); + myIORLabels.Bind(TCollection_ExtendedString(IOR), aLabel); +} + +void SALOMEDS_Study_i::IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute, CORBA::ORB_ptr orb) { + // get accorded study first + Handle(SALOMEDS_IORAttribute) Att; + if (theAttribute->Label().Root().FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){ + TCollection_AsciiString ch(Att->Get()); + char* IOR = CORBA::string_dup(ch.ToCString()); + CORBA::Object_var obj = orb->string_to_object(IOR); + SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ; + ASSERT(!CORBA::is_nil(aStudy)); + TCollection_AsciiString aString; + TDF_Tool::Entry(theAttribute->Label(),aString); + aStudy->UpdateIORLabelMap(TCollection_AsciiString(theAttribute->Get()).ToCString(), aString.ToCString()); + } else { + INFOS("IORUpdated: Problem to get study"); + return; + } +} + +SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject) { + SALOMEDS::GenericAttribute_ptr aTarget; + if (anObject->FindAttribute(aTarget,"AttributeTarget")) { + return SALOMEDS::AttributeTarget::_narrow(aTarget)->Get(); + } + SALOMEDS::Study::ListOfSObject* aList = new SALOMEDS::Study::ListOfSObject; + aList->length(0); + return aList; +} + + +SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties() { + SALOMEDS::GenericAttribute_ptr anAttr = NewBuilder()->FindOrCreateAttribute(FindObjectID("0:1"), + "AttributeStudyProperties"); + return SALOMEDS::AttributeStudyProperties::_narrow(anAttr); +} + +char* SALOMEDS_Study_i::GetLastModificationDate() { + SALOMEDS::AttributeStudyProperties_var aProp = GetProperties(); + SALOMEDS::StringSeq_var aNames; + SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears; + aProp->GetModificationsList(aNames , aMinutes ,aHours, aDays, aMonths, aYears, true); + int aLastIndex = aNames->length() - 1; + char aResult[20]; + sprintf(aResult, "%2.2d/%2.2d/%4.4d %2.2d:%2.2d", (int)(aDays[aLastIndex]),(int)(aMonths[aLastIndex]), + (int)(aYears[aLastIndex]), (int)(aHours[aLastIndex]), (int)(aMinutes[aLastIndex])); + CORBA::String_var aResStr = CORBA::string_dup(aResult); + return aResStr._retn(); +} + +SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate() { + SALOMEDS::AttributeStudyProperties_var aProp = GetProperties(); + SALOMEDS::StringSeq_var aNames; + SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears; + aProp->GetModificationsList(aNames , aMinutes ,aHours, aDays, aMonths, aYears, false); + + int anIndex, aLength = aNames->length(); + SALOMEDS::ListOfDates_var aDates = new SALOMEDS::ListOfDates; + aDates->length(aLength); + + for(anIndex = 0; anIndex < aLength; anIndex++) { + char aDate[20]; + sprintf(aDate, "%2.2d/%2.2d/%4.4d %2.2d:%2.2d", (int)(aDays[anIndex]), (int)(aMonths[anIndex]), + (int)(aYears[anIndex]), (int)(aHours[anIndex]), (int)(aMinutes[anIndex])); + aDates[anIndex] = CORBA::string_dup(aDate); + } + return aDates._retn(); +} + + + +//============================================================================ +/*! Function : GetUseCaseBuilder + * Purpose : Returns a UseCase builder + */ +//============================================================================ +SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder() +{ + SALOMEDS_UseCaseBuilder_i* _caseBuilder = new SALOMEDS_UseCaseBuilder_i(_doc, _orb); + SALOMEDS::UseCaseBuilder_var aBuilder = SALOMEDS::UseCaseBuilder::_narrow(_caseBuilder->_this()); + return aBuilder._retn(); +} + + +//============================================================================ +/*! Function : Close + * Purpose : + */ +//============================================================================ +void SALOMEDS_Study_i::Close() +{ + SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator(); + + for (; itcomponent->More(); itcomponent->Next()) { + SALOMEDS::SComponent_var sco = itcomponent->Value(); + + MESSAGE ( "Look for an engine for data type :"<< sco->ComponentDataType()); + // if there is an associated Engine call its method for closing + CORBA::String_var IOREngine; + if (sco->ComponentIOR(IOREngine)) { + // we have found the associated engine to write the data + MESSAGE ( "We have found an engine for data type :"<< sco->ComponentDataType()); + CORBA::Object_var obj = _orb->string_to_object(IOREngine); + SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ; + + if (!anEngine->_is_nil()) + anEngine->Close(sco); + } + } + + Handle(TDocStd_Application) anApp = Handle(TDocStd_Application)::DownCast(_doc->Application()); +// Handle(TDocStd_Owner) anOwner; +// if (_doc->Main().Root().FindAttribute(TDocStd_Owner::GetID(), anOwner)) { +// Handle(TDocStd_Document) anEmptyDoc; +// anOwner->SetDocument(anEmptyDoc); +// } + if(!anApp.IsNull()) anApp->Close(_doc); + _doc.Nullify(); +} diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx new file mode 100644 index 000000000..cbee5f615 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -0,0 +1,262 @@ +// File : SALOMEDS_Study_i.hxx +// Created : Wed Nov 28 16:27:37 2001 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef __SALOMEDS_STUDY_I_H__ +#define __SALOMEDS_STUDY_I_H__ + +// std C++ headers +#include + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +// Cascade headers +#include +#include +#include +#include +#include + +//SALOMEDS headers +#include "SALOMEDS_SComponentIterator_i.hxx" +#include "SALOMEDS_ChildIterator_i.hxx" +#include "SALOMEDS_StudyBuilder_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include "SALOMEDS_DataMapStringLabel.hxx" +#include "SALOMEDS_UseCaseBuilder_i.hxx" + +#include "SALOMEDS_Callback_i.hxx" + +class SALOMEDS_Study_i: public POA_SALOMEDS::Study, + public PortableServer::RefCountServantBase { +private: + CORBA::ORB_ptr _orb; + char* _name; + Handle(TDocStd_Document) _doc; // OCAF Document + CORBA::Boolean _isSaved; // True if the Study is saved + char* _URL; //URL of the persistent reference of the study + SALOMEDS::SObject_ptr _FindObject(SALOMEDS::SObject_ptr SO, + const char* anObjectName, + bool& _find); + SALOMEDS::SObject_ptr _FindObjectIOR(SALOMEDS::SObject_ptr SO, + const char* anObjectIOR, + bool& _find); + CORBA::Short _StudyId; + + SALOMEDS_DataMapStringLabel myIORLabels; + TDF_Label _current; + bool _autoFill; + +public: + + //! standard constructor + SALOMEDS_Study_i(const Handle(TDocStd_Document), + CORBA::ORB_ptr, + const char* study_name); + + //! standard destructor + virtual ~SALOMEDS_Study_i(); + + //! method to Get persistent reference of study (idem URL()) + /*! + \sa URL() + \return char* arguments, the persistent reference of the study + */ + virtual char* GetPersistentReference(); + + + //! method to Get transient reference of study + /*! + \return char* arguments, the transient reference of the study + */ + virtual char* GetTransientReference(); + + //! method to detect if a study is empty + /*! + \return bool arguments, true if study is empty + */ + virtual CORBA::Boolean IsEmpty(); + + //! method to Find a Component with ComponentDataType = aComponentName + /*! + \param aComponentName char* arguments + \return SComponent_ptr arguments, the component found + */ + virtual SALOMEDS::SComponent_ptr FindComponent (const char* aComponentName); + + //! method to Find a Component Find a Component from it's ID + /*! + \param aComponentID char* arguments + \return SComponent_ptr arguments, the component found + */ + virtual SALOMEDS::SComponent_ptr FindComponentID(const char* aComponentID); + + //! method to Find an Object with SALOMEDS::Name = anObjectName + /*! + \param anObjectName char* arguments + \return SObject_ptr arguments, the object found + */ + virtual SALOMEDS::SObject_ptr FindObject(const char* anObjectName); + + + //! method to Find Object(s) with SALOMEDS::Name = anObjectName in a component with ComponentDataType = aComponentName + /*! + \param anObjectName char* arguments + \param aComponentName char* arguments + \return ListOfSObject_ptr arguments, a list of objects found + */ + + virtual SALOMEDS::Study::ListOfSObject* FindObjectByName( const char* anObjectName, const char* aComponentName ) ; + + //! method to Find an Object with ID = anObjectID + /*! + \param anObjectID char* arguments + \return SObject_ptr arguments, the object found + */ + virtual SALOMEDS::SObject_ptr FindObjectID(const char* anObjectID); + + //! method to Find an Object with ID = anObjectIOR + /*! + \param anObjectIOR char* arguments + \return SObject_ptr arguments, the object found + */ + virtual SALOMEDS::SObject_ptr FindObjectIOR(const char* anObjectIOR); + + //! method to Find an Object by its path + /*! + \param thePath char* arguments + \return SObject_ptr arguments, the object found + */ + virtual SALOMEDS::SObject_ptr FindObjectByPath(const char* thePath); + + //! method to get a path of SObject + /*! + \param aSO SObject_ptr arguments + \return char* arguments, the path of the SObject + */ + virtual char* GetObjectPath(CORBA::Object_ptr theObject); + + //! method to set a context: root ('/') is UserData component + /*! + */ + virtual void SetContext(const char* thePath); + + //! method to get a context + /*! + */ + virtual char* GetContext(); + + //! method to get all object names in the given context (or in the current context, if 'theContext' is empty) + /*! + */ + virtual SALOMEDS::ListOfStrings* GetObjectNames(const char* theContext); + + //! method to get all directory names in the given context (or in the current context, if 'theContext' is empty) + /*! + */ + virtual SALOMEDS::ListOfStrings* GetDirectoryNames(const char* theContext); + + //! method to get all file names in the given context (or in the current context, if 'theContext' is empty) + /*! + */ + virtual SALOMEDS::ListOfStrings* GetFileNames(const char* theContext); + + //! method to get all components names + /*! + */ + virtual SALOMEDS::ListOfStrings* GetComponentNames(const char* theContext); + + //! method to Create a ChildIterator from an SObject + /*! + \param aSO SObject_ptr arguments + \return ChildIterator_ptr arguments, the created ChildIterator + */ + virtual SALOMEDS::ChildIterator_ptr NewChildIterator(SALOMEDS::SObject_ptr aSO); + + //! method to Create a SComponentIterator + /*! + \return SComponentIterator_ptr arguments, the created SComponentIterator + */ + virtual SALOMEDS::SComponentIterator_ptr NewComponentIterator(); + + //! method to Create a StudyBuilder + /*! + \return StudyBuilder_ptr arguments, the created StudyBuilder + */ + virtual SALOMEDS::StudyBuilder_ptr NewBuilder(); + + //! method to get study name + /*! + \return char* arguments, the study name + */ + virtual char* Name(); + + //! method to set study name + /*! + \param name char* arguments, the study name + */ + virtual void Name(const char* name); + + //! method to get if study has been saved + /*! + \return bool arguments + */ + virtual CORBA::Boolean IsSaved(); + + //! method to set if study has been saved + /*! + \param save bool arguments + */ + virtual void IsSaved(CORBA::Boolean save); + + //! method to Detect if a Study has been modified since it has been saved + /*! + \return bool arguments + */ + virtual CORBA::Boolean IsModified(); + + //! method to get URL of the study (idem GetPersistentReference) + /*! + \return char* arguments, the study URL + */ + virtual char* URL(); + + //! method to set URL of the study + /*! + \param url char* arguments, the study URL + */ + virtual void URL(const char* url); + + + virtual CORBA::Short StudyId(); + virtual void StudyId(CORBA::Short id); + + static void IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute, CORBA::ORB_ptr orb); + + virtual void UpdateIORLabelMap(const char* anIOR, const char* aLabel); + + virtual SALOMEDS::Study::ListOfSObject* FindDependances(SALOMEDS::SObject_ptr anObject); + + virtual SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties(); + + virtual char* GetLastModificationDate(); + + virtual SALOMEDS::ListOfDates* GetModificationsDate(); + + virtual char* ConvertObjectToIOR(CORBA::Object_ptr theObject) {return _orb->object_to_string(theObject); } + virtual CORBA::Object_ptr ConvertIORToObject(const char* theIOR) { return _orb->string_to_object(theIOR); }; + + virtual SALOMEDS::UseCaseBuilder_ptr GetUseCaseBuilder(); + + virtual void Close(); + + void EnableUseCaseAutoFilling(CORBA::Boolean isEnabled) { _autoFill = isEnabled; } +}; +#endif diff --git a/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.cxx b/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.cxx new file mode 100644 index 000000000..b5f3e43cf --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.cxx @@ -0,0 +1,398 @@ +using namespace std; +// File : SALOMEDS_TableOfIntegerAttribute.cxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// Modified by: Sergey Ruin +// $Header$ + +#include +#include +#include + +#include + +const Standard_GUID& SALOMEDS_TableOfIntegerAttribute::GetID() +{ + static Standard_GUID SALOMEDS_TableOfIntegerAttributeID ("128371A0-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_TableOfIntegerAttributeID; +} + +Handle(SALOMEDS_TableOfIntegerAttribute) SALOMEDS_TableOfIntegerAttribute::Set(const TDF_Label& label) +{ + Handle(SALOMEDS_TableOfIntegerAttribute) anAttr; + if (!label.FindAttribute(SALOMEDS_TableOfIntegerAttribute::GetID(),anAttr)) { + anAttr = new SALOMEDS_TableOfIntegerAttribute(); + label.AddAttribute(anAttr); + } + return anAttr; +} + +SALOMEDS_TableOfIntegerAttribute::SALOMEDS_TableOfIntegerAttribute() { + myRows = new TColStd_HSequenceOfExtendedString(); + myCols = new TColStd_HSequenceOfExtendedString(); + myNbRows = 0; + myNbColumns = 0; +} + +void SALOMEDS_TableOfIntegerAttribute::SetNbColumns(const Standard_Integer theNbColumns) +{ + Backup(); + + TColStd_DataMapOfIntegerInteger aMap; + aMap = myTable; + myTable.Clear(); + + TColStd_DataMapIteratorOfDataMapOfIntegerInteger anIterator(aMap); + for(; anIterator.More(); anIterator.Next()) { + int aRow = (int)(anIterator.Key()/myNbColumns) + 1; + int aCol = (int)(anIterator.Key() - myNbColumns*(aRow-1)); + if(aCol == 0) { aCol = myNbColumns; aRow--; } + if(aCol > theNbColumns) continue; + int aKey = (aRow-1)*theNbColumns+aCol; + myTable.Bind(aKey, anIterator.Value()); + } + + myNbColumns = theNbColumns; + + while (myCols->Length() < myNbColumns) { // append empty columns titles + myCols->Append(TCollection_ExtendedString("")); + } +} + +void SALOMEDS_TableOfIntegerAttribute::SetTitle(const TCollection_ExtendedString& theTitle) { + Backup(); + myTitle = theTitle; +} + +TCollection_ExtendedString SALOMEDS_TableOfIntegerAttribute::GetTitle() const { + return myTitle; +} + +void SALOMEDS_TableOfIntegerAttribute::SetRowData(const Standard_Integer theRow, + const Handle(TColStd_HSequenceOfInteger)& theData) +{ + if(theData->Length() > myNbColumns) SetNbColumns(theData->Length()); + + Backup(); + + while (myRows->Length() < theRow) { // append new row titles + myRows->Append(TCollection_ExtendedString("")); + } + + Standard_Integer i, aShift = (theRow-1)*myNbColumns, aLength = theData->Length(); + for(i = 1; i <= aLength; i++) { + myTable.Bind(aShift + i, theData->Value(i)); + } + + if(theRow > myNbRows) myNbRows = theRow; +} + +Handle(TColStd_HSequenceOfInteger) SALOMEDS_TableOfIntegerAttribute::GetRowData(const Standard_Integer theRow) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger(); + Standard_Integer i, aShift = (theRow-1)*myNbColumns; + for(i = 1; i <= myNbColumns; i++) { + if(myTable.IsBound(aShift+i)) + aSeq->Append(myTable.Find(aShift+i)); + else + aSeq->Append(0); + } + + return aSeq; +} + +void SALOMEDS_TableOfIntegerAttribute::SetRowTitle(const Standard_Integer theRow, + const TCollection_ExtendedString& theTitle) { + Backup(); + myRows->SetValue(theRow,theTitle); +} + +TCollection_ExtendedString SALOMEDS_TableOfIntegerAttribute::GetRowTitle(const Standard_Integer theRow) const { + return myRows->Value(theRow); +} + + +void SALOMEDS_TableOfIntegerAttribute::SetColumnData(const Standard_Integer theColumn, + const Handle(TColStd_HSequenceOfInteger)& theData) +{ + if(theColumn > myNbColumns) SetNbColumns(theColumn); + + Backup(); + + Standard_Integer i, aLength = theData->Length(); + for(i = 1; i <= aLength; i++) { + myTable.Bind(myNbColumns*(i-1)+theColumn, theData->Value(i)); + } + + if(aLength > myNbRows) { + myNbRows = aLength; + while (myRows->Length() < myNbRows) { // append empty row titles + myRows->Append(TCollection_ExtendedString("")); + } + } +} + + +Handle(TColStd_HSequenceOfInteger) SALOMEDS_TableOfIntegerAttribute::GetColumnData(const Standard_Integer theColumn) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + Standard_Integer i, anIndex; + for(i = 1; i <= myNbRows; i++) { + anIndex = myNbColumns*(i-1) + theColumn; + if(myTable.IsBound(anIndex)) + aSeq->Append(myTable.Find(anIndex)); + else + aSeq->Append(0); + } + + return aSeq; +} + +void SALOMEDS_TableOfIntegerAttribute::SetColumnTitle(const Standard_Integer theColumn, + const TCollection_ExtendedString& theTitle) { + Backup(); + while(myCols->Length() < theColumn) myCols->Append(TCollection_ExtendedString("")); + myCols->SetValue(theColumn,theTitle); +} + +TCollection_ExtendedString SALOMEDS_TableOfIntegerAttribute::GetColumnTitle(const Standard_Integer theColumn) const { + if(myCols.IsNull()) return ""; + if(myCols->Length() < theColumn) return ""; + return myCols->Value(theColumn); +} + + +Standard_Integer SALOMEDS_TableOfIntegerAttribute::GetNbRows() const +{ + return myNbRows; +} + +Standard_Integer SALOMEDS_TableOfIntegerAttribute::GetNbColumns() const +{ + return myNbColumns; +} + +void SALOMEDS_TableOfIntegerAttribute::PutValue(const Standard_Integer theValue, + const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + if(theColumn > myNbColumns) SetNbColumns(theColumn); + + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + myTable.Bind(anIndex, theValue); + + if(theRow > myNbRows) { + while (myRows->Length() < theRow) { // append empty row titles + myRows->Append(TCollection_ExtendedString("")); + } + myNbRows = theRow; + } +} + +Standard_Boolean SALOMEDS_TableOfIntegerAttribute::HasValue(const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + return myTable.IsBound(anIndex); +} + +Standard_Integer SALOMEDS_TableOfIntegerAttribute::GetValue(const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + if(myTable.IsBound(anIndex)) return myTable.Find(anIndex); + + Standard_Failure::Raise("Invalid cell index"); + return 0; +} + +const Standard_GUID& SALOMEDS_TableOfIntegerAttribute::ID() const +{ + return GetID(); +} + +void SALOMEDS_TableOfIntegerAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer anIndex; + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(with); + + myTable.Clear(); + myCols->Clear(); + myRows->Clear(); + + myTable = aTable->myTable; + myNbRows = aTable->myNbRows; + myNbColumns = aTable->myNbColumns; + myTitle = aTable->myTitle; + + for(anIndex = 1; anIndex <= aTable->GetNbRows();anIndex++) { + SetRowTitle(anIndex,aTable->GetRowTitle(anIndex)); + } + for(anIndex = 1; anIndex <= aTable->GetNbColumns(); anIndex++) + SetColumnTitle(anIndex, aTable->GetColumnTitle(anIndex)); +} + +Handle(TDF_Attribute) SALOMEDS_TableOfIntegerAttribute::NewEmpty() const +{ + return new SALOMEDS_TableOfIntegerAttribute(); +} + +void SALOMEDS_TableOfIntegerAttribute::Paste(const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)&) const +{ + Standard_Integer anIndex; + Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(into); + + aTable->myTable.Clear(); + aTable->myCols->Clear(); + aTable->myRows->Clear(); + + aTable->myTable = myTable; + aTable->myTitle = myTitle; + aTable->myNbRows = myNbRows; + aTable->myNbColumns = myNbColumns; + + for(anIndex = 1; anIndex <= GetNbRows();anIndex++) { + aTable->SetRowTitle(anIndex,GetRowTitle(anIndex)); + } + for(anIndex = 1; anIndex <= GetNbColumns(); anIndex++) + aTable->SetColumnTitle(anIndex, GetColumnTitle(anIndex)); +} + + +Handle_TColStd_HSequenceOfInteger SALOMEDS_TableOfIntegerAttribute::GetSetRowIndices(const Standard_Integer theRow) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + Standard_Integer i, aShift = myNbColumns*(theRow-1); + for(i = 1; i <= myNbColumns; i++) { + if(myTable.IsBound(aShift + i)) aSeq->Append(i); + } + + return aSeq; +} + +Handle_TColStd_HSequenceOfInteger SALOMEDS_TableOfIntegerAttribute::GetSetColumnIndices(const Standard_Integer theColumn) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + Standard_Integer i, anIndex; + for(i = 1; i <= myNbRows; i++) { + anIndex = myNbColumns*(i-1)+theColumn; + if(myTable.IsBound(anIndex)) aSeq->Append(i); + } + + return aSeq; +} + + +void SALOMEDS_TableOfIntegerAttribute::ConvertToString(ostrstream& theStream) +{ + int i, j, l; + + theStream.precision(64); + + //Title + l = myTitle.Length(); + theStream << l << "\n"; + for(i=1; i<=l; i++) + theStream << myTitle.Value(i) << "\n"; + + //Nb rows + theStream << myNbRows << "\n"; + + //Rows titles + for(i=1; i<=myNbRows; i++) { + l = myRows->Value(i).Length(); + theStream << l << "\n"; + for(j=1; j<=l; j++) + theStream << myRows->Value(i).Value(j) << "\n"; + } + + //Nb columns + theStream << myNbColumns << "\n"; + + //Columns titles + for(i=1; i<=myNbColumns; i++) { + l = myCols->Value(i).Length(); + theStream << l << "\n"; + for(j=1; j<=l; j++) + theStream << myCols->Value(i).Value(j) << "\n"; + } + + //Store the table values + l = myTable.Extent(); + theStream << l << "\n"; + TColStd_DataMapIteratorOfDataMapOfIntegerInteger anIterator(myTable); + for(; anIterator.More(); anIterator.Next()) { + theStream << anIterator.Key() << "\n"; + theStream << anIterator.Value() << "\n"; + } + + return; +} + +bool SALOMEDS_TableOfIntegerAttribute::RestoreFromString(istrstream& theStream) +{ + Backup(); + + int i, j, l; + + Standard_ExtCharacter anExtChar; + TCollection_ExtendedString aStr; + + //Title + theStream >> l; + + myTitle = TCollection_ExtendedString(l, 0); + for(i=1; i<=l; i++) { + theStream >> anExtChar; + myTitle.SetValue(i, anExtChar); + } + + //Nb rows + theStream >> myNbRows; + + //Rows titles + myRows->Clear(); + for(i=1; i<=myNbRows; i++) { + theStream >> l; + aStr = TCollection_ExtendedString(l,0); + for(j=1; j<=l; j++) { + theStream >> anExtChar; + aStr.SetValue(j, anExtChar); + } + myRows->Append(aStr); + } + + //Nb columns + theStream >> myNbColumns; + + //Columns titles + myCols->Clear(); + for(i=1; i<=myNbColumns; i++) { + theStream >> l; + aStr = TCollection_ExtendedString(l,0); + for(j=1; j<=l; j++) { + theStream >> anExtChar; + aStr.SetValue(j, anExtChar); + } + myCols->Append(aStr); + } + + //Restore the table values + theStream >> l; + myTable.Clear(); + for(i=1; i<=l; i++) { + int aKey, aValue; + theStream >> aKey; + theStream >> aValue; + myTable.Bind(aKey, aValue); + } + + return true; +} diff --git a/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.hxx b/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.hxx new file mode 100644 index 000000000..0b5fef30b --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.hxx @@ -0,0 +1,160 @@ +// File : SALOMEDS_TableOfIntegerAttribute.hxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#ifndef _SALOMEDS_TableOfIntegerAttribute_HeaderFile +#define _SALOMEDS_TableOfIntegerAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_TableOfIntegerAttribute_HeaderFile +#include +#endif + +#ifndef _TColStd_SequenceOfTransient_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _Handle_TColStd_HSequenceOfExtendedString_HeaderFile +#include +#endif + +#ifndef _TColStd_DataMapOfIntegerInteger_HeaderFile +#include +#endif + +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Handle_TColStd_HSequenceOfInteger_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class TColStd_HSequenceOfExtendedString; +class Standard_GUID; +class TDF_Label; +class TCollection_ExtendedString; +class TColStd_HSequenceOfInteger; +class TDF_Attribute; +class TDF_RelocationTable; + +#include + +class SALOMEDS_TableOfIntegerAttribute : public TDF_Attribute { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_TableOfIntegerAttribute Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDS_TableOfIntegerAttribute(); +Standard_EXPORT void SetNbColumns(const Standard_Integer theNbColumns); +Standard_EXPORT void SetTitle(const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetTitle() const; +Standard_EXPORT void SetRowData(const Standard_Integer theRow,const Handle(TColStd_HSequenceOfInteger)& theData) ; +Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetRowData(const Standard_Integer theRow) ; +Standard_EXPORT void SetRowTitle(const Standard_Integer theRow,const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetRowTitle(const Standard_Integer theRow) const; +Standard_EXPORT void SetColumnData(const Standard_Integer theColumn,const Handle(TColStd_HSequenceOfInteger)& theData) ; +Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetColumnData(const Standard_Integer theColumn) ; +Standard_EXPORT void SetColumnTitle(const Standard_Integer theColumn,const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetColumnTitle(const Standard_Integer theColumn) const; +Standard_EXPORT Standard_Integer GetNbRows() const; +Standard_EXPORT Standard_Integer GetNbColumns() const; + +Standard_EXPORT void PutValue(const Standard_Integer theValue,const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT Standard_Boolean HasValue(const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT Standard_Integer GetValue(const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; + +Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetSetRowIndices(const Standard_Integer theRow); +Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetSetColumnIndices(const Standard_Integer theColumn); + +Standard_EXPORT void ConvertToString(ostrstream& theStream); +Standard_EXPORT bool RestoreFromString(istrstream& theStream); + +Standard_EXPORT ~SALOMEDS_TableOfIntegerAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_TableOfIntegerAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +TColStd_DataMapOfIntegerInteger myTable; +TCollection_ExtendedString myTitle; +Handle_TColStd_HSequenceOfExtendedString myRows; +Handle_TColStd_HSequenceOfExtendedString myCols; +Standard_Integer myNbRows; +Standard_Integer myNbColumns; + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.ixx b/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.ixx new file mode 100644 index 000000000..c39ac5111 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.ixx @@ -0,0 +1,65 @@ +// File : SALOMEDS_TableOfIntegerAttribute.ixx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_TableOfIntegerAttribute::~SALOMEDS_TableOfIntegerAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_TableOfIntegerAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDF_Attribute); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_TableOfIntegerAttribute", + sizeof(SALOMEDS_TableOfIntegerAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_TableOfIntegerAttribute) Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_TableOfIntegerAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_TableOfIntegerAttribute))) { + _anOtherObject = Handle(SALOMEDS_TableOfIntegerAttribute)((Handle(SALOMEDS_TableOfIntegerAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_TableOfIntegerAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_TableOfIntegerAttribute) ; +} +Standard_Boolean SALOMEDS_TableOfIntegerAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_TableOfIntegerAttribute) == AType || TDF_Attribute::IsKind(AType)); +} +Handle_SALOMEDS_TableOfIntegerAttribute::~Handle_SALOMEDS_TableOfIntegerAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.jxx b/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.jxx new file mode 100644 index 000000000..c3618907f --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TableOfIntegerAttribute.jxx @@ -0,0 +1,32 @@ +// File : SALOMEDS_TableOfIntegerAttribute.jxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#ifndef _TColStd_HSequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TColStd_HSequenceOfInteger_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_TableOfIntegerAttribute_HeaderFile +#include +#endif diff --git a/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.cxx b/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.cxx new file mode 100644 index 000000000..13646bf2c --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.cxx @@ -0,0 +1,404 @@ +using namespace std; +// File : SALOMEDS_TableOfRealAttribute.cxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// Modified by: Sergey Ruin +// $Header$ + +#include +#include +#include + +#include +#include + +const Standard_GUID& SALOMEDS_TableOfRealAttribute::GetID() +{ + static Standard_GUID SALOMEDS_TableOfRealAttributeID ("128371A1-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_TableOfRealAttributeID; +} + +Handle(SALOMEDS_TableOfRealAttribute) SALOMEDS_TableOfRealAttribute::Set(const TDF_Label& label) +{ + Handle(SALOMEDS_TableOfRealAttribute) anAttr; + if (!label.FindAttribute(SALOMEDS_TableOfRealAttribute::GetID(),anAttr)) { + anAttr = new SALOMEDS_TableOfRealAttribute(); + label.AddAttribute(anAttr); + } + return anAttr; +} + +SALOMEDS_TableOfRealAttribute::SALOMEDS_TableOfRealAttribute() { + myRows = new TColStd_HSequenceOfExtendedString(); + myCols = new TColStd_HSequenceOfExtendedString(); + myNbRows = 0; + myNbColumns = 0; +} + +void SALOMEDS_TableOfRealAttribute::SetNbColumns(const Standard_Integer theNbColumns) +{ + Backup(); + + TColStd_DataMapOfIntegerReal aMap; + aMap = myTable; + myTable.Clear(); + + TColStd_DataMapIteratorOfDataMapOfIntegerReal anIterator(aMap); + for(; anIterator.More(); anIterator.Next()) { + int aRow = (int)(anIterator.Key()/myNbColumns) + 1; + int aCol = (int)(anIterator.Key() - myNbColumns*(aRow-1)); + if(aCol == 0) { aCol = myNbColumns; aRow--; } + if(aCol > theNbColumns) continue; + int aKey = (aRow-1)*theNbColumns+aCol; + myTable.Bind(aKey, anIterator.Value()); + } + + myNbColumns = theNbColumns; + + while (myCols->Length() < myNbColumns) { // append empty columns titles + myCols->Append(TCollection_ExtendedString("")); + } +} + +void SALOMEDS_TableOfRealAttribute::SetTitle(const TCollection_ExtendedString& theTitle) { + Backup(); + myTitle = theTitle; +} + +TCollection_ExtendedString SALOMEDS_TableOfRealAttribute::GetTitle() const { + return myTitle; +} + +void SALOMEDS_TableOfRealAttribute::SetRowData(const Standard_Integer theRow, + const Handle(TColStd_HSequenceOfReal)& theData) +{ + if(theData->Length() > myNbColumns) SetNbColumns(theData->Length()); + + Backup(); + + while (myRows->Length() < theRow) { // append new row titles + myRows->Append(TCollection_ExtendedString("")); + } + + Standard_Integer i, aShift = (theRow-1)*myNbColumns, aLength = theData->Length(); + for(i = 1; i <= aLength; i++) { + myTable.Bind(aShift + i, theData->Value(i)); + } + + if(theRow > myNbRows) myNbRows = theRow; +} + +Handle(TColStd_HSequenceOfReal) SALOMEDS_TableOfRealAttribute::GetRowData(const Standard_Integer theRow) +{ + Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal(); + Standard_Integer i, aShift = (theRow-1)*myNbColumns; + for(i = 1; i <= myNbColumns; i++) { + if(myTable.IsBound(aShift+i)) + aSeq->Append(myTable.Find(aShift+i)); + else + aSeq->Append(0.); + } + + return aSeq; +} + +void SALOMEDS_TableOfRealAttribute::SetRowTitle(const Standard_Integer theRow, + const TCollection_ExtendedString& theTitle) { + Backup(); + myRows->SetValue(theRow,theTitle); +} + +TCollection_ExtendedString SALOMEDS_TableOfRealAttribute::GetRowTitle(const Standard_Integer theRow) const { + return myRows->Value(theRow); +} + + +void SALOMEDS_TableOfRealAttribute::SetColumnData(const Standard_Integer theColumn, + const Handle(TColStd_HSequenceOfReal)& theData) +{ + if(theColumn > myNbColumns) SetNbColumns(theColumn); + + Backup(); + + Standard_Integer i, aLength = theData->Length(); + for(i = 1; i <= aLength; i++) { + myTable.Bind(myNbColumns*(i-1)+theColumn, theData->Value(i)); + } + + if(aLength > myNbRows) { + myNbRows = aLength; + while (myRows->Length() < myNbRows) { // append empty row titles + myRows->Append(TCollection_ExtendedString("")); + } + } +} + + +Handle(TColStd_HSequenceOfReal) SALOMEDS_TableOfRealAttribute::GetColumnData(const Standard_Integer theColumn) +{ + Handle(TColStd_HSequenceOfReal) aSeq = new TColStd_HSequenceOfReal; + + Standard_Integer i, anIndex; + for(i = 1; i <= myNbRows; i++) { + anIndex = myNbColumns*(i-1) + theColumn; + if(myTable.IsBound(anIndex)) + aSeq->Append(myTable.Find(anIndex)); + else + aSeq->Append(0.); + } + + return aSeq; +} + +void SALOMEDS_TableOfRealAttribute::SetColumnTitle(const Standard_Integer theColumn, + const TCollection_ExtendedString& theTitle) { + Backup(); + while(myCols->Length() < theColumn) myCols->Append(TCollection_ExtendedString("")); + myCols->SetValue(theColumn,theTitle); +} + +TCollection_ExtendedString SALOMEDS_TableOfRealAttribute::GetColumnTitle(const Standard_Integer theColumn) const { + if(myCols.IsNull()) return ""; + if(myCols->Length() < theColumn) return ""; + return myCols->Value(theColumn); +} + + +Standard_Integer SALOMEDS_TableOfRealAttribute::GetNbRows() const +{ + return myNbRows; +} + +Standard_Integer SALOMEDS_TableOfRealAttribute::GetNbColumns() const +{ + return myNbColumns; +} + +void SALOMEDS_TableOfRealAttribute::PutValue(const Standard_Real theValue, + const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + if(theColumn > myNbColumns) SetNbColumns(theColumn); + + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + myTable.Bind(anIndex, theValue); + + if(theRow > myNbRows) { + while (myRows->Length() < theRow) { // append empty row titles + myRows->Append(TCollection_ExtendedString("")); + } + myNbRows = theRow; + } +} + +Standard_Boolean SALOMEDS_TableOfRealAttribute::HasValue(const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + return myTable.IsBound(anIndex); +} + +Standard_Real SALOMEDS_TableOfRealAttribute::GetValue(const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + if(myTable.IsBound(anIndex)) return myTable.Find(anIndex); + + Standard_Failure::Raise("Invalid cell index"); + return 0.; +} + +const Standard_GUID& SALOMEDS_TableOfRealAttribute::ID() const +{ + return GetID(); +} + +void SALOMEDS_TableOfRealAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer anIndex; + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(with); + + myTable.Clear(); + myCols->Clear(); + myRows->Clear(); + + myTable = aTable->myTable; + myNbRows = aTable->myNbRows; + myNbColumns = aTable->myNbColumns; + myTitle = aTable->myTitle; + + for(anIndex = 1; anIndex <= aTable->GetNbRows();anIndex++) { + SetRowTitle(anIndex,aTable->GetRowTitle(anIndex)); + } + for(anIndex = 1; anIndex <= aTable->GetNbColumns(); anIndex++) + SetColumnTitle(anIndex, aTable->GetColumnTitle(anIndex)); +} + +Handle(TDF_Attribute) SALOMEDS_TableOfRealAttribute::NewEmpty() const +{ + return new SALOMEDS_TableOfRealAttribute(); +} + +void SALOMEDS_TableOfRealAttribute::Paste(const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)&) const +{ + Standard_Integer anIndex; + Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(into); + + aTable->myTable.Clear(); + aTable->myCols->Clear(); + aTable->myRows->Clear(); + + aTable->myTable = myTable; + aTable->myTitle = myTitle; + aTable->myNbRows = myNbRows; + aTable->myNbColumns = myNbColumns; + + for(anIndex = 1; anIndex <= GetNbRows();anIndex++) { + aTable->SetRowTitle(anIndex,GetRowTitle(anIndex)); + } + for(anIndex = 1; anIndex <= GetNbColumns(); anIndex++) + aTable->SetColumnTitle(anIndex, GetColumnTitle(anIndex)); +} + + +Handle_TColStd_HSequenceOfInteger SALOMEDS_TableOfRealAttribute::GetSetRowIndices(const Standard_Integer theRow) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + Standard_Integer i, aShift = myNbColumns*(theRow-1); + for(i = 1; i <= myNbColumns; i++) { + if(myTable.IsBound(aShift + i)) aSeq->Append(i); + } + + return aSeq; +} + +Handle_TColStd_HSequenceOfInteger SALOMEDS_TableOfRealAttribute::GetSetColumnIndices(const Standard_Integer theColumn) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + Standard_Integer i, anIndex; + for(i = 1; i <= myNbRows; i++) { + anIndex = myNbColumns*(i-1)+theColumn; + if(myTable.IsBound(anIndex)) aSeq->Append(i); + } + + return aSeq; +} + + + +void SALOMEDS_TableOfRealAttribute::ConvertToString(ostrstream& theStream) +{ + int i, j, l; + + + //Title + l = myTitle.Length(); + theStream << l << "\n"; + for(i=1; i<=l; i++) + theStream << myTitle.Value(i) << "\n"; + + //Nb rows + theStream << myNbRows << "\n"; + + //Rows titles + for(i=1; i<=myNbRows; i++) { + l = myRows->Value(i).Length(); + theStream << l << "\n"; + for(j=1; j<=l; j++) + theStream << myRows->Value(i).Value(j) << "\n"; + } + + //Nb columns + theStream << myNbColumns << "\n"; + + //Columns titles + for(i=1; i<=myNbColumns; i++) { + l = myCols->Value(i).Length(); + theStream << l << "\n"; + for(j=1; j<=l; j++) + theStream << myCols->Value(i).Value(j) << "\n"; + } + + //Store the table values + l = myTable.Extent(); + theStream << l << "\n"; + char *aBuffer = new char[128]; + TColStd_DataMapIteratorOfDataMapOfIntegerReal anIterator(myTable); + for(; anIterator.More(); anIterator.Next()) { + theStream << anIterator.Key() << "\n"; + sprintf(aBuffer, "%.64e", anIterator.Value()); + theStream << aBuffer << "\n"; + } + + delete []aBuffer; + + return; +} + +bool SALOMEDS_TableOfRealAttribute::RestoreFromString(istrstream& theStream) +{ + Backup(); + + int i, j, l; + + Standard_ExtCharacter anExtChar; + TCollection_ExtendedString aStr; + + //Title + theStream >> l; + + myTitle = TCollection_ExtendedString(l, 0); + for(i=1; i<=l; i++) { + theStream >> anExtChar; + myTitle.SetValue(i, anExtChar); + } + + //Nb rows + theStream >> myNbRows; + + //Rows titles + myRows->Clear(); + for(i=1; i<=myNbRows; i++) { + theStream >> l; + aStr = TCollection_ExtendedString(l,0); + for(j=1; j<=l; j++) { + theStream >> anExtChar; + aStr.SetValue(j, anExtChar); + } + myRows->Append(aStr); + } + + //Nb columns + theStream >> myNbColumns; + + //Columns titles + myCols->Clear(); + for(i=1; i<=myNbColumns; i++) { + theStream >> l; + aStr = TCollection_ExtendedString(l,0); + for(j=1; j<=l; j++) { + theStream >> anExtChar; + aStr.SetValue(j, anExtChar); + } + myCols->Append(aStr); + } + + //Restore the table values + theStream >> l; + myTable.Clear(); + for(i=1; i<=l; i++) { + Standard_Integer aKey; + Standard_Real aValue; + theStream >> aKey; + theStream >> aValue; + myTable.Bind(aKey, aValue); + } + + return true; +} diff --git a/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.hxx b/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.hxx new file mode 100644 index 000000000..19e3a6c46 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.hxx @@ -0,0 +1,168 @@ +// File : SALOMEDS_TableOfRealAttribute.hxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#ifndef _SALOMEDS_TableOfRealAttribute_HeaderFile +#define _SALOMEDS_TableOfRealAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_TableOfRealAttribute_HeaderFile +#include +#endif + +#ifndef _TColStd_SequenceOfTransient_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _Handle_TColStd_HSequenceOfExtendedString_HeaderFile +#include +#endif + +#ifndef _TColStd_DataMapOfIntegerReal_HeaderFile +#include +#endif + +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif + +#ifndef _Handle_TColStd_HSequenceOfInteger_HeaderFile +#include +#endif + +#ifndef TColStd_HSequenceOfInteger_HeaderFile +#include +#endif + +#ifndef _Handle_TColStd_HSequenceOfReal_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class TColStd_HSequenceOfExtendedString; +class Standard_GUID; +class TDF_Label; +class TCollection_ExtendedString; +class TColStd_HSequenceOfReal; +class TDF_Attribute; +class TDF_RelocationTable; + +#include + +class SALOMEDS_TableOfRealAttribute : public TDF_Attribute { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_TableOfRealAttribute Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDS_TableOfRealAttribute(); +Standard_EXPORT void SetNbColumns(const Standard_Integer theNbColumns); +Standard_EXPORT void SetTitle(const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetTitle() const; +Standard_EXPORT void SetRowData(const Standard_Integer theRow,const Handle(TColStd_HSequenceOfReal)& theData) ; +Standard_EXPORT Handle_TColStd_HSequenceOfReal GetRowData(const Standard_Integer theRow) ; +Standard_EXPORT void SetRowTitle(const Standard_Integer theRow,const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetRowTitle(const Standard_Integer theRow) const; +Standard_EXPORT void SetColumnData(const Standard_Integer theColumn,const Handle(TColStd_HSequenceOfReal)& theData) ; +Standard_EXPORT Handle_TColStd_HSequenceOfReal GetColumnData(const Standard_Integer theColumn) ; +Standard_EXPORT void SetColumnTitle(const Standard_Integer theColumn,const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetColumnTitle(const Standard_Integer theColumn) const; +Standard_EXPORT Standard_Integer GetNbRows() const; +Standard_EXPORT Standard_Integer GetNbColumns() const; + +Standard_EXPORT void PutValue(const Standard_Real theValue,const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT Standard_Boolean HasValue(const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT Standard_Real GetValue(const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; + +Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetSetRowIndices(const Standard_Integer theRow); +Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetSetColumnIndices(const Standard_Integer theColumn); + +Standard_EXPORT void ConvertToString(ostrstream& theStream); +Standard_EXPORT bool RestoreFromString(istrstream& theStream); + +Standard_EXPORT ~SALOMEDS_TableOfRealAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_TableOfRealAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +TColStd_DataMapOfIntegerReal myTable; +TCollection_ExtendedString myTitle; +Handle_TColStd_HSequenceOfExtendedString myRows; +Handle_TColStd_HSequenceOfExtendedString myCols; +Standard_Integer myNbRows; +Standard_Integer myNbColumns; + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.ixx b/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.ixx new file mode 100644 index 000000000..ab7e75f07 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.ixx @@ -0,0 +1,65 @@ +// File : SALOMEDS_TableOfRealAttribute.ixx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_TableOfRealAttribute::~SALOMEDS_TableOfRealAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_TableOfRealAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDF_Attribute); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_TableOfRealAttribute", + sizeof(SALOMEDS_TableOfRealAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_TableOfRealAttribute) Handle(SALOMEDS_TableOfRealAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_TableOfRealAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_TableOfRealAttribute))) { + _anOtherObject = Handle(SALOMEDS_TableOfRealAttribute)((Handle(SALOMEDS_TableOfRealAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_TableOfRealAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_TableOfRealAttribute) ; +} +Standard_Boolean SALOMEDS_TableOfRealAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_TableOfRealAttribute) == AType || TDF_Attribute::IsKind(AType)); +} +Handle_SALOMEDS_TableOfRealAttribute::~Handle_SALOMEDS_TableOfRealAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.jxx b/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.jxx new file mode 100644 index 000000000..447541e21 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TableOfRealAttribute.jxx @@ -0,0 +1,32 @@ +// File : SALOMEDS_TableOfRealAttribute.jxx +// Created : Tue Oct 8 10:13:30 2002 +// Author : Michael Ponikarov +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE +// $Header$ + +#ifndef _TColStd_HSequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TColStd_HSequenceOfReal_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_TableOfRealAttribute_HeaderFile +#include +#endif diff --git a/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx b/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx new file mode 100644 index 000000000..827dbef5a --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.cxx @@ -0,0 +1,409 @@ +using namespace std; +// File : SALOMEDS_TableOfStringAttribute.cxx +// Created : Mon Apr 7 10:13:30 2003 +// Author : Sergey Ruin +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + +#include +#include +#include + +#include +#include + +const Standard_GUID& SALOMEDS_TableOfStringAttribute::GetID() +{ + static Standard_GUID SALOMEDS_TableOfStringAttributeID ("128371A2-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_TableOfStringAttributeID; +} + +Handle(SALOMEDS_TableOfStringAttribute) SALOMEDS_TableOfStringAttribute::Set(const TDF_Label& label) +{ + Handle(SALOMEDS_TableOfStringAttribute) anAttr; + if (!label.FindAttribute(SALOMEDS_TableOfStringAttribute::GetID(),anAttr)) { + anAttr = new SALOMEDS_TableOfStringAttribute(); + label.AddAttribute(anAttr); + } + return anAttr; +} + +SALOMEDS_TableOfStringAttribute::SALOMEDS_TableOfStringAttribute() { + myRows = new TColStd_HSequenceOfExtendedString(); + myCols = new TColStd_HSequenceOfExtendedString(); + myNbRows = 0; + myNbColumns = 0; +} + +void SALOMEDS_TableOfStringAttribute::SetNbColumns(const Standard_Integer theNbColumns) +{ + Backup(); + + SALOMEDS_DataMapOfIntegerString aMap; + aMap = myTable; + myTable.Clear(); + + SALOMEDS_DataMapIteratorOfDataMapOfIntegerString anIterator(aMap); + for(; anIterator.More(); anIterator.Next()) { + int aRow = (int)(anIterator.Key()/myNbColumns) + 1; + int aCol = (int)(anIterator.Key() - myNbColumns*(aRow-1)); + if(aCol == 0) { aCol = myNbColumns; aRow--; } + if(aCol > theNbColumns) continue; + int aKey = (aRow-1)*theNbColumns+aCol; + myTable.Bind(aKey, anIterator.Value()); + } + + myNbColumns = theNbColumns; + + while (myCols->Length() < myNbColumns) { // append empty columns titles + myCols->Append(TCollection_ExtendedString("")); + } +} + +void SALOMEDS_TableOfStringAttribute::SetTitle(const TCollection_ExtendedString& theTitle) { + Backup(); + myTitle = theTitle; +} + +TCollection_ExtendedString SALOMEDS_TableOfStringAttribute::GetTitle() const { + return myTitle; +} + +void SALOMEDS_TableOfStringAttribute::SetRowData(const Standard_Integer theRow, + const Handle(TColStd_HSequenceOfExtendedString)& theData) +{ + if(theData->Length() > myNbColumns) SetNbColumns(theData->Length()); + + Backup(); + + while (myRows->Length() < theRow) { // append new row titles + myRows->Append(TCollection_ExtendedString("")); + } + + Standard_Integer i, aShift = (theRow-1)*myNbColumns, aLength = theData->Length(); + for(i = 1; i <= aLength; i++) { + myTable.Bind(aShift + i, theData->Value(i)); + } + + if(theRow > myNbRows) myNbRows = theRow; +} + +Handle(TColStd_HSequenceOfExtendedString) SALOMEDS_TableOfStringAttribute::GetRowData(const Standard_Integer theRow) +{ + Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString(); + Standard_Integer i, aShift = (theRow-1)*myNbColumns; + for(i = 1; i <= myNbColumns; i++) { + if(myTable.IsBound(aShift+i)) + aSeq->Append(myTable.Find(aShift+i)); + else + aSeq->Append(0.); + } + + return aSeq; +} + +void SALOMEDS_TableOfStringAttribute::SetRowTitle(const Standard_Integer theRow, + const TCollection_ExtendedString& theTitle) { + Backup(); + myRows->SetValue(theRow,theTitle); +} + +TCollection_ExtendedString SALOMEDS_TableOfStringAttribute::GetRowTitle(const Standard_Integer theRow) const { + return myRows->Value(theRow); +} + + +void SALOMEDS_TableOfStringAttribute::SetColumnData(const Standard_Integer theColumn, + const Handle(TColStd_HSequenceOfExtendedString)& theData) +{ + if(theColumn > myNbColumns) SetNbColumns(theColumn); + + Backup(); + + Standard_Integer i, aLength = theData->Length(); + for(i = 1; i <= aLength; i++) { + myTable.Bind(myNbColumns*(i-1)+theColumn, theData->Value(i)); + } + + if(aLength > myNbRows) { + myNbRows = aLength; + while (myRows->Length() < myNbRows) { // append empty row titles + myRows->Append(TCollection_ExtendedString("")); + } + } +} + + +Handle(TColStd_HSequenceOfExtendedString) SALOMEDS_TableOfStringAttribute::GetColumnData(const Standard_Integer theColumn) +{ + Handle(TColStd_HSequenceOfExtendedString) aSeq = new TColStd_HSequenceOfExtendedString; + + Standard_Integer i, anIndex; + for(i = 1; i <= myNbRows; i++) { + anIndex = myNbColumns*(i-1) + theColumn; + if(myTable.IsBound(anIndex)) + aSeq->Append(myTable.Find(anIndex)); + else + aSeq->Append(0.); + } + + return aSeq; +} + +void SALOMEDS_TableOfStringAttribute::SetColumnTitle(const Standard_Integer theColumn, + const TCollection_ExtendedString& theTitle) { + Backup(); + while(myCols->Length() < theColumn) myCols->Append(TCollection_ExtendedString("")); + myCols->SetValue(theColumn,theTitle); +} + +TCollection_ExtendedString SALOMEDS_TableOfStringAttribute::GetColumnTitle(const Standard_Integer theColumn) const { + if(myCols.IsNull()) return ""; + if(myCols->Length() < theColumn) return ""; + return myCols->Value(theColumn); +} + + +Standard_Integer SALOMEDS_TableOfStringAttribute::GetNbRows() const +{ + return myNbRows; +} + +Standard_Integer SALOMEDS_TableOfStringAttribute::GetNbColumns() const +{ + return myNbColumns; +} + +void SALOMEDS_TableOfStringAttribute::PutValue(const TCollection_ExtendedString& theValue, + const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + if(theColumn > myNbColumns) SetNbColumns(theColumn); + + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + myTable.Bind(anIndex, theValue); + + if(theRow > myNbRows) { + while (myRows->Length() < theRow) { // append empty row titles + myRows->Append(TCollection_ExtendedString("")); + } + myNbRows = theRow; + } +} + +Standard_Boolean SALOMEDS_TableOfStringAttribute::HasValue(const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + return myTable.IsBound(anIndex); +} + +TCollection_ExtendedString SALOMEDS_TableOfStringAttribute::GetValue(const Standard_Integer theRow, + const Standard_Integer theColumn) +{ + Standard_Integer anIndex = (theRow-1)*myNbColumns + theColumn; + if(myTable.IsBound(anIndex)) return myTable.Find(anIndex); + + Standard_Failure::Raise("Invalid cell index"); + return 0.; +} + +const Standard_GUID& SALOMEDS_TableOfStringAttribute::ID() const +{ + return GetID(); +} + +void SALOMEDS_TableOfStringAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + Standard_Integer anIndex; + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(with); + + myTable.Clear(); + myCols->Clear(); + myRows->Clear(); + + myTable = aTable->myTable; + myNbRows = aTable->myNbRows; + myNbColumns = aTable->myNbColumns; + myTitle = aTable->myTitle; + + for(anIndex = 1; anIndex <= aTable->GetNbRows();anIndex++) { + SetRowTitle(anIndex,aTable->GetRowTitle(anIndex)); + } + for(anIndex = 1; anIndex <= aTable->GetNbColumns(); anIndex++) + SetColumnTitle(anIndex, aTable->GetColumnTitle(anIndex)); +} + +Handle(TDF_Attribute) SALOMEDS_TableOfStringAttribute::NewEmpty() const +{ + return new SALOMEDS_TableOfStringAttribute(); +} + +void SALOMEDS_TableOfStringAttribute::Paste(const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)&) const +{ + Standard_Integer anIndex; + Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(into); + + aTable->myTable.Clear(); + aTable->myCols->Clear(); + aTable->myRows->Clear(); + + aTable->myTable = myTable; + aTable->myTitle = myTitle; + aTable->myNbRows = myNbRows; + aTable->myNbColumns = myNbColumns; + + for(anIndex = 1; anIndex <= GetNbRows();anIndex++) { + aTable->SetRowTitle(anIndex,GetRowTitle(anIndex)); + } + for(anIndex = 1; anIndex <= GetNbColumns(); anIndex++) + aTable->SetColumnTitle(anIndex, GetColumnTitle(anIndex)); +} + + +Handle_TColStd_HSequenceOfInteger SALOMEDS_TableOfStringAttribute::GetSetRowIndices(const Standard_Integer theRow) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + Standard_Integer i, aShift = myNbColumns*(theRow-1); + for(i = 1; i <= myNbColumns; i++) { + if(myTable.IsBound(aShift + i)) aSeq->Append(i); + } + + return aSeq; +} + +Handle_TColStd_HSequenceOfInteger SALOMEDS_TableOfStringAttribute::GetSetColumnIndices(const Standard_Integer theColumn) +{ + Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger; + + Standard_Integer i, anIndex; + for(i = 1; i <= myNbRows; i++) { + anIndex = myNbColumns*(i-1)+theColumn; + if(myTable.IsBound(anIndex)) aSeq->Append(i); + } + + return aSeq; +} + + + +void SALOMEDS_TableOfStringAttribute::ConvertToString(ostrstream& theStream) +{ + int i, j, l; +cout << "########## ConvertToString BEGIN " << endl; + + //Title + l = myTitle.Length(); + theStream << l << "\n"; + for(i=1; i<=l; i++) + theStream << myTitle.Value(i) << "\n"; + + //Nb rows + theStream << myNbRows << "\n"; + + //Rows titles + for(i=1; i<=myNbRows; i++) { + l = myRows->Value(i).Length(); + theStream << l << "\n"; + for(j=1; j<=l; j++) + theStream << myRows->Value(i).Value(j) << "\n"; + } + + //Nb columns + theStream << myNbColumns << "\n"; + + //Columns titles + for(i=1; i<=myNbColumns; i++) { + l = myCols->Value(i).Length(); + theStream << l << "\n"; + for(j=1; j<=l; j++) + theStream << myCols->Value(i).Value(j) << "\n"; + } + + //Store the table values + l = myTable.Extent(); + theStream << l << "\n"; + SALOMEDS_DataMapIteratorOfDataMapOfIntegerString anIterator(myTable); + for(; anIterator.More(); anIterator.Next()) { + theStream << anIterator.Key() << "\n"; + theStream << anIterator.Value() << "\n"; +// l = anIterator.Value().Length(); +// theStream << l << "\n"; +// for(j=1; j<=l; j++) +// theStream << anIterator.Value().Value(j) << "\n"; + } +cout << "########## ConvertToString END " << endl; + return; +} + +bool SALOMEDS_TableOfStringAttribute::RestoreFromString(istrstream& theStream) +{ + Backup(); + + int i, j, l; + + Standard_ExtCharacter anExtChar; + TCollection_ExtendedString aStr; + + //Title + theStream >> l; + + myTitle = TCollection_ExtendedString(l, 0); + for(i=1; i<=l; i++) { + theStream >> anExtChar; + myTitle.SetValue(i, anExtChar); + } + + //Nb rows + theStream >> myNbRows; + + //Rows titles + myRows->Clear(); + for(i=1; i<=myNbRows; i++) { + theStream >> l; + aStr = TCollection_ExtendedString(l,0); + for(j=1; j<=l; j++) { + theStream >> anExtChar; + aStr.SetValue(j, anExtChar); + } + myRows->Append(aStr); + } + + //Nb columns + theStream >> myNbColumns; + + //Columns titles + myCols->Clear(); + for(i=1; i<=myNbColumns; i++) { + theStream >> l; + aStr = TCollection_ExtendedString(l,0); + for(j=1; j<=l; j++) { + theStream >> anExtChar; + aStr.SetValue(j, anExtChar); + } + myCols->Append(aStr); + } + + //Restore the table values + TCollection_AsciiString aValue; + theStream >> l; + myTable.Clear(); + for(i=1; i<=l; i++) { + Standard_Integer aKey; + theStream >> aKey; + theStream >> aValue; + myTable.Bind(aKey, aValue); +// theStream >> l; +// aStr = TCollection_ExtendedString(l,0); +// for(j=1; j<=l; j++) { +// theStream >> anExtChar; +// aStr.SetValue(j, anExtChar); +// } +// myTable.Bind(aKey, aStr); + } + + return true; +} diff --git a/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.hxx b/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.hxx new file mode 100644 index 000000000..b63323d11 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.hxx @@ -0,0 +1,167 @@ +// File : SALOMEDS_TableOfStringAttribute.hxx +// Created : Mon Apr 7 10:13:30 2003 +// Author : Sergey Ruin +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + +#ifndef _SALOMEDS_TableOfStringAttribute_HeaderFile +#define _SALOMEDS_TableOfStringAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_TableOfStringAttribute_HeaderFile +#include +#endif + +#ifndef _TColStd_SequenceOfTransient_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _Handle_TColStd_HSequenceOfExtendedString_HeaderFile +#include +#endif + +#ifndef _SALOMEDS_DataMapOfIntegerString_HeaderFile +#include +#endif + +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif + +#ifndef _Handle_TColStd_HSequenceOfInteger_HeaderFile +#include +#endif + +#ifndef TColStd_HSequenceOfInteger_HeaderFile +#include +#endif + +#ifndef _Handle_TColStd_HSequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class TColStd_HSequenceOfExtendedString; +class Standard_GUID; +class TDF_Label; +class TCollection_ExtendedString; +class TColStd_HSequenceOfExtendedString; +class TDF_Attribute; +class TDF_RelocationTable; + +#include + +class SALOMEDS_TableOfStringAttribute : public TDF_Attribute { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_TableOfStringAttribute Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDS_TableOfStringAttribute(); +Standard_EXPORT void SetNbColumns(const Standard_Integer theNbColumns); +Standard_EXPORT void SetTitle(const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetTitle() const; +Standard_EXPORT void SetRowData(const Standard_Integer theRow,const Handle(TColStd_HSequenceOfExtendedString)& theData) ; +Standard_EXPORT Handle_TColStd_HSequenceOfExtendedString GetRowData(const Standard_Integer theRow) ; +Standard_EXPORT void SetRowTitle(const Standard_Integer theRow,const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetRowTitle(const Standard_Integer theRow) const; +Standard_EXPORT void SetColumnData(const Standard_Integer theColumn,const Handle(TColStd_HSequenceOfExtendedString)& theData) ; +Standard_EXPORT Handle_TColStd_HSequenceOfExtendedString GetColumnData(const Standard_Integer theColumn) ; +Standard_EXPORT void SetColumnTitle(const Standard_Integer theColumn,const TCollection_ExtendedString& theTitle) ; +Standard_EXPORT TCollection_ExtendedString GetColumnTitle(const Standard_Integer theColumn) const; +Standard_EXPORT Standard_Integer GetNbRows() const; +Standard_EXPORT Standard_Integer GetNbColumns() const; + +Standard_EXPORT void PutValue(const TCollection_ExtendedString& theValue,const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT Standard_Boolean HasValue(const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT TCollection_ExtendedString GetValue(const Standard_Integer theRow,const Standard_Integer theColumn) ; +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; + +Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetSetRowIndices(const Standard_Integer theRow); +Standard_EXPORT Handle_TColStd_HSequenceOfInteger GetSetColumnIndices(const Standard_Integer theColumn); + +Standard_EXPORT void ConvertToString(ostrstream& theStream); +Standard_EXPORT bool RestoreFromString(istrstream& theStream); + +Standard_EXPORT ~SALOMEDS_TableOfStringAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_TableOfStringAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +SALOMEDS_DataMapOfIntegerString myTable; +TCollection_ExtendedString myTitle; +Handle_TColStd_HSequenceOfExtendedString myRows; +Handle_TColStd_HSequenceOfExtendedString myCols; +Standard_Integer myNbRows; +Standard_Integer myNbColumns; + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.ixx b/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.ixx new file mode 100644 index 000000000..cc6da3752 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.ixx @@ -0,0 +1,64 @@ +// File : SALOMEDS_TableOfStringAttribute.ixx +// Created : Mon Apr 7 10:13:30 2003 +// Author : Sergey Ruin +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + +#include + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_TableOfStringAttribute::~SALOMEDS_TableOfStringAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_TableOfStringAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDF_Attribute); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_TableOfStringAttribute", + sizeof(SALOMEDS_TableOfStringAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_TableOfStringAttribute) Handle(SALOMEDS_TableOfStringAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_TableOfStringAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_TableOfStringAttribute))) { + _anOtherObject = Handle(SALOMEDS_TableOfStringAttribute)((Handle(SALOMEDS_TableOfStringAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_TableOfStringAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_TableOfStringAttribute) ; +} +Standard_Boolean SALOMEDS_TableOfStringAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_TableOfStringAttribute) == AType || TDF_Attribute::IsKind(AType)); +} +Handle_SALOMEDS_TableOfStringAttribute::~Handle_SALOMEDS_TableOfStringAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.jxx b/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.jxx new file mode 100644 index 000000000..9e241043c --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TableOfStringAttribute.jxx @@ -0,0 +1,31 @@ +// File : SALOMEDS_TableOfStringAttribute.jxx +// Created : Mon Apr 7 10:13:30 2003 +// Author : Sergey Ruin +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + +#ifndef _TColStd_HSequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TCollection_ExtendedString_HeaderFile +#include +#endif +#ifndef _TColStd_HSequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_TableOfStringAttribute_HeaderFile +#include +#endif diff --git a/src/SALOMEDS/SALOMEDS_TargetAttribute.cdl b/src/SALOMEDS/SALOMEDS_TargetAttribute.cdl new file mode 100644 index 000000000..933c61252 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TargetAttribute.cdl @@ -0,0 +1,55 @@ +// File : SALOMEDS_TargetAttribute.cdl +// Created : Fri Aug 16 10:20:05 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +class TargetAttribute from SALOMEDS inherits Relation from TDataStd + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + RelocationTable from TDF, + LabelList from TDF + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + Set (myclass; label : Label from TDF) + returns TargetAttribute from SALOMEDS; + + ---Purpose: Comment methods + -- ============ + + Create + returns mutable TargetAttribute from SALOMEDS; + + Append(me: mutable; theReferencedObject : mutable Label form TDF); + Get(me; theReferencedObjects : mutable : LabelList from TDF); + Remove(me: mutable; theReferencedObject : mutable Label form TDF); + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +end TargetAttribute; diff --git a/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx b/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx new file mode 100644 index 000000000..5116c5a3b --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TargetAttribute.cxx @@ -0,0 +1,100 @@ +using namespace std; +// File : SALOMEDS_TargetAttribute.cxx +// Created : Fri Aug 16 10:20:05 2002 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + +#include "SALOMEDS_TargetAttribute.ixx" +#include +#include +#include "utilities.h" + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_TargetAttribute::GetID () +{ + static Standard_GUID SALOMEDS_TargetAttributeID ("12837197-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_TargetAttributeID; +} + + + +//======================================================================= +//function : Set +//purpose : +//======================================================================= + +Handle(SALOMEDS_TargetAttribute) SALOMEDS_TargetAttribute::Set (const TDF_Label& L) +{ + Handle(SALOMEDS_TargetAttribute) A; + if (!L.FindAttribute(SALOMEDS_TargetAttribute::GetID(),A)) { + A = new SALOMEDS_TargetAttribute(); + L.AddAttribute(A); + } + return A; +} + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDS_TargetAttribute::SALOMEDS_TargetAttribute() +{} + +//======================================================================= +//function : Append +//purpose : +//======================================================================= + +void SALOMEDS_TargetAttribute::Append(TDF_Label& theReferencedObject) { + Backup(); + Handle(TDF_Reference) aReference; + if (theReferencedObject.FindAttribute(TDF_Reference::GetID(),aReference)) { + GetVariables().Append(aReference); + } else { + MESSAGE("SALOMEDS_TargetAttribute::Append: can't append referenced object"); + } +} + +//======================================================================= +//function : Get +//purpose : +//======================================================================= +void SALOMEDS_TargetAttribute::Get(TDF_LabelList& theReferencedObjects) { + theReferencedObjects.Clear(); + TDF_ListIteratorOfAttributeList anIter(GetVariables()); + for(;anIter.More();anIter.Next()) { + theReferencedObjects.Append(anIter.Value()->Label()); + } +} + +//======================================================================= +//function : Remove +//purpose : +//======================================================================= +void SALOMEDS_TargetAttribute::Remove(TDF_Label& theReferencedObject) { + Backup(); + TDF_ListIteratorOfAttributeList anIter(GetVariables()); + for(;anIter.More();anIter.Next()) { + if (anIter.Value()->Label() == theReferencedObject) { + GetVariables().Remove(anIter); + return; + } + } + MESSAGE("SALOMEDS_TargetAttribute::Remove: nothing to remove"); +} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_TargetAttribute::ID () const { return GetID(); } + diff --git a/src/SALOMEDS/SALOMEDS_TargetAttribute.hxx b/src/SALOMEDS/SALOMEDS_TargetAttribute.hxx new file mode 100644 index 000000000..867ccfa63 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TargetAttribute.hxx @@ -0,0 +1,114 @@ +// File : SALOMEDS_TargetAttribute.hxx +// Created : Fri Aug 16 10:20:05 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#ifndef _SALOMEDS_TargetAttribute_HeaderFile +#define _SALOMEDS_TargetAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_TargetAttribute_HeaderFile +#include +#endif + +#include +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _TDF_LabelList_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Reference_HeaderFile +#include +#endif +class Standard_GUID; +class TDF_Label; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_TargetAttribute : public TDataStd_Relation { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT static Handle_SALOMEDS_TargetAttribute Set(const TDF_Label& label) ; +Standard_EXPORT SALOMEDS_TargetAttribute(); +Standard_EXPORT void SALOMEDS_TargetAttribute::Append(TDF_Label& theReferencedObject); +Standard_EXPORT void SALOMEDS_TargetAttribute::Get(TDF_LabelList& theReferencedObjects); +Standard_EXPORT void SALOMEDS_TargetAttribute::Remove(TDF_Label& theReferencedObject); +Standard_EXPORT const Standard_GUID& ID() const; + +// Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +// Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +// Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; + +Standard_EXPORT ~SALOMEDS_TargetAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_TargetAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_TargetAttribute.ixx b/src/SALOMEDS/SALOMEDS_TargetAttribute.ixx new file mode 100644 index 000000000..4b01a5e14 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TargetAttribute.ixx @@ -0,0 +1,68 @@ +// File : SALOMEDS_TargetAttribute.ixx +// Created : Fri Aug 16 10:20:05 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#include "SALOMEDS_TargetAttribute.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_TargetAttribute::~SALOMEDS_TargetAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_TargetAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDataStd_Relation); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDataStd_Relation); + static Handle_Standard_Type aType2 = STANDARD_TYPE(TDF_Attribute); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType3 = STANDARD_TYPE(MMgt_TShared); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_TargetAttribute", + sizeof(SALOMEDS_TargetAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_TargetAttribute) Handle(SALOMEDS_TargetAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_TargetAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_TargetAttribute))) { + _anOtherObject = Handle(SALOMEDS_TargetAttribute)((Handle(SALOMEDS_TargetAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_TargetAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_TargetAttribute) ; +} +Standard_Boolean SALOMEDS_TargetAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_TargetAttribute) == AType || TDataStd_Relation::IsKind(AType)); +} +Handle_SALOMEDS_TargetAttribute::~Handle_SALOMEDS_TargetAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_TargetAttribute.jxx b/src/SALOMEDS/SALOMEDS_TargetAttribute.jxx new file mode 100644 index 000000000..b316dee1c --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TargetAttribute.jxx @@ -0,0 +1,24 @@ +// File : SALOMEDS_TargetAttribute.jxx +// Created : Fri Aug 16 10:20:05 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header: + +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Label_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_TargetAttribute_HeaderFile +#include "SALOMEDS_TargetAttribute.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_TextColorAttribute.cdl b/src/SALOMEDS/SALOMEDS_TextColorAttribute.cdl new file mode 100644 index 000000000..95ae157dc --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TextColorAttribute.cdl @@ -0,0 +1,56 @@ +// File : SALOMEDS_TextColorAttribute.cdl +// Created : Wed Nov 28 16:20:40 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + + + + +class TextColorAttribute from SALOMEDS inherits RealArray from TDataStd + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + ExtendedString from TCollection, + DataSet from TDF, + RelocationTable from TDF, + AttributeSequence from TDF, + Data from TDF, + Comment from TDataStd + + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + ---Purpose: Comment methods + -- ============ + + Create + returns mutable TextColorAttribute from SALOMEDS; + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +end TextColorAttribute; diff --git a/src/SALOMEDS/SALOMEDS_TextColorAttribute.cxx b/src/SALOMEDS/SALOMEDS_TextColorAttribute.cxx new file mode 100644 index 000000000..22b50d252 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TextColorAttribute.cxx @@ -0,0 +1,73 @@ +using namespace std; +// File : SALOMEDS_TextColorAttribute.cxx +// Created : Wed Nov 28 16:09:35 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + +#include "SALOMEDS_TextColorAttribute.ixx" + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_TextColorAttribute::GetID () +{ + static Standard_GUID SALOMEDS_TextColorAttributeID ("12837189-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_TextColorAttributeID; +} + + + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDS_TextColorAttribute::SALOMEDS_TextColorAttribute() +{Init(1,3);} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_TextColorAttribute::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDS_TextColorAttribute::NewEmpty () const +{ + return new SALOMEDS_TextColorAttribute(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDS_TextColorAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + Handle(TColStd_HArray1OfReal) s = Handle(TDataStd_RealArray)::DownCast (with)->Array (); + TDataStd_RealArray::ChangeArray(s); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDS_TextColorAttribute::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& RT) const +{ + Handle(TDataStd_RealArray)::DownCast (into)->ChangeArray (Array()); +} + diff --git a/src/SALOMEDS/SALOMEDS_TextColorAttribute.hxx b/src/SALOMEDS/SALOMEDS_TextColorAttribute.hxx new file mode 100644 index 000000000..f1a7c3de3 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TextColorAttribute.hxx @@ -0,0 +1,103 @@ +// File : SALOMEDS_TextColorAttribute.hxx +// Created : Wed Jul 10 16:42:01 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _SALOMEDS_TextColorAttribute_HeaderFile +#define _SALOMEDS_TextColorAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_TextColorAttribute_HeaderFile +#include +#endif + +#ifndef _TDataStd_RealArray_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class Standard_GUID; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_TextColorAttribute : public TDataStd_RealArray { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT SALOMEDS_TextColorAttribute(); +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT ~SALOMEDS_TextColorAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_TextColorAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_TextColorAttribute.ixx b/src/SALOMEDS/SALOMEDS_TextColorAttribute.ixx new file mode 100644 index 000000000..5db5e6802 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TextColorAttribute.ixx @@ -0,0 +1,68 @@ +// File : SALOMEDS_TextColorAttribute.ixx +// Created : Wed Jul 10 16:42:10 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOMEDS_TextColorAttribute.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_TextColorAttribute::~SALOMEDS_TextColorAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_TextColorAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDataStd_RealArray); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDataStd_RealArray); + static Handle_Standard_Type aType2 = STANDARD_TYPE(TDF_Attribute); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType3 = STANDARD_TYPE(MMgt_TShared); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_TextColorAttribute", + sizeof(SALOMEDS_TextColorAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_TextColorAttribute) Handle(SALOMEDS_TextColorAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_TextColorAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_TextColorAttribute))) { + _anOtherObject = Handle(SALOMEDS_TextColorAttribute)((Handle(SALOMEDS_TextColorAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_TextColorAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_TextColorAttribute) ; +} +Standard_Boolean SALOMEDS_TextColorAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_TextColorAttribute) == AType || TDataStd_RealArray::IsKind(AType)); +} +Handle_SALOMEDS_TextColorAttribute::~Handle_SALOMEDS_TextColorAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_TextColorAttribute.jxx b/src/SALOMEDS/SALOMEDS_TextColorAttribute.jxx new file mode 100644 index 000000000..7c08a81b1 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TextColorAttribute.jxx @@ -0,0 +1,21 @@ +// File : SALOMEDS_TextColorAttribute.jxx +// Created : Wed Jul 10 16:42:16 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_TextColorAttribute_HeaderFile +#include "SALOMEDS_TextColorAttribute.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.cdl b/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.cdl new file mode 100644 index 000000000..42f0fcb67 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.cdl @@ -0,0 +1,56 @@ +// File : SALOMEDS_TextHighlightColorAttribute.cdl +// Created : Wed Nov 28 16:20:40 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + + + + +class TextHighlightColorAttribute from SALOMEDS inherits RealArray from TDataStd + + ---Purpose: + + +uses Attribute from TDF, + Label from TDF, + GUID from Standard, + ExtendedString from TCollection, + DataSet from TDF, + RelocationTable from TDF, + AttributeSequence from TDF, + Data from TDF, + Comment from TDataStd + + +is + + + ---Purpose: class methods + -- ============= + + GetID (myclass) + ---C++: return const & + returns GUID from Standard; + + ---Purpose: Comment methods + -- ============ + + Create + returns mutable TextHighlightColorAttribute from SALOMEDS; + + ID (me) + ---C++: return const & + returns GUID from Standard; + + Restore (me: mutable; with : Attribute from TDF); + + NewEmpty (me) + returns mutable Attribute from TDF; + + Paste (me; into : mutable Attribute from TDF; + RT : mutable RelocationTable from TDF); + +end TextHighlightColorAttribute; diff --git a/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.cxx b/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.cxx new file mode 100644 index 000000000..2d670a4e3 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.cxx @@ -0,0 +1,72 @@ +using namespace std; +// File : SALOMEDS_TextHighlightColorAttribute.cxx +// Created : Wed Nov 28 16:09:35 2001 +// Author : Yves FRICAUD +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2001 +// $Header: + +#include "SALOMEDS_TextHighlightColorAttribute.ixx" + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_TextHighlightColorAttribute::GetID () +{ + static Standard_GUID SALOMEDS_TextHighlightColorAttributeID ("12837190-8F52-11d6-A8A3-0001021E8C7F"); + return SALOMEDS_TextHighlightColorAttributeID; +} + + + +//======================================================================= +//function : constructor +//purpose : +//======================================================================= +SALOMEDS_TextHighlightColorAttribute::SALOMEDS_TextHighlightColorAttribute() +{Init(1,3);} + +//======================================================================= +//function : ID +//purpose : +//======================================================================= + +const Standard_GUID& SALOMEDS_TextHighlightColorAttribute::ID () const { return GetID(); } + + +//======================================================================= +//function : NewEmpty +//purpose : +//======================================================================= + +Handle(TDF_Attribute) SALOMEDS_TextHighlightColorAttribute::NewEmpty () const +{ + return new SALOMEDS_TextHighlightColorAttribute(); +} + +//======================================================================= +//function : Restore +//purpose : +//======================================================================= + +void SALOMEDS_TextHighlightColorAttribute::Restore(const Handle(TDF_Attribute)& with) +{ + Handle(TColStd_HArray1OfReal) s = Handle(TDataStd_RealArray)::DownCast (with)->Array (); + TDataStd_RealArray::ChangeArray(s); + return; +} + +//======================================================================= +//function : Paste +//purpose : +//======================================================================= + +void SALOMEDS_TextHighlightColorAttribute::Paste (const Handle(TDF_Attribute)& into, + const Handle(TDF_RelocationTable)& ) const +{ + Handle(TDataStd_RealArray)::DownCast (into)->ChangeArray (Array()); +} + diff --git a/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.hxx b/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.hxx new file mode 100644 index 000000000..8416e3268 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.hxx @@ -0,0 +1,103 @@ +// File : SALOMEDS_TextHighlightColorAttribute.hxx +// Created : Wed Jul 10 16:42:47 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _SALOMEDS_TextHighlightColorAttribute_HeaderFile +#define _SALOMEDS_TextHighlightColorAttribute_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOMEDS_TextHighlightColorAttribute_HeaderFile +#include +#endif + +#ifndef _TDataStd_RealArray_HeaderFile +#include +#endif +#ifndef _Handle_TDF_Attribute_HeaderFile +#include +#endif +#ifndef _Handle_TDF_RelocationTable_HeaderFile +#include +#endif +class Standard_GUID; +class TDF_Attribute; +class TDF_RelocationTable; + + +class SALOMEDS_TextHighlightColorAttribute : public TDataStd_RealArray { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT static const Standard_GUID& GetID() ; +Standard_EXPORT SALOMEDS_TextHighlightColorAttribute(); +Standard_EXPORT const Standard_GUID& ID() const; +Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ; +Standard_EXPORT Handle_TDF_Attribute NewEmpty() const; +Standard_EXPORT void Paste(const Handle(TDF_Attribute)& into,const Handle(TDF_RelocationTable)& RT) const; +Standard_EXPORT ~SALOMEDS_TextHighlightColorAttribute(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOMEDS_TextHighlightColorAttribute_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.ixx b/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.ixx new file mode 100644 index 000000000..46666d6e0 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.ixx @@ -0,0 +1,68 @@ +// File : SALOMEDS_TextHighlightColorAttribute.ixx +// Created : Wed Jul 10 16:44:31 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOMEDS_TextHighlightColorAttribute.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOMEDS_TextHighlightColorAttribute::~SALOMEDS_TextHighlightColorAttribute() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOMEDS_TextHighlightColorAttribute_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TDataStd_RealArray); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TDataStd_RealArray); + static Handle_Standard_Type aType2 = STANDARD_TYPE(TDF_Attribute); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(TDF_Attribute); + static Handle_Standard_Type aType3 = STANDARD_TYPE(MMgt_TShared); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType4 = STANDARD_TYPE(Standard_Transient); + if ( aType4.IsNull()) aType4 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,aType4,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOMEDS_TextHighlightColorAttribute", + sizeof(SALOMEDS_TextHighlightColorAttribute), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOMEDS_TextHighlightColorAttribute) Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOMEDS_TextHighlightColorAttribute) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOMEDS_TextHighlightColorAttribute))) { + _anOtherObject = Handle(SALOMEDS_TextHighlightColorAttribute)((Handle(SALOMEDS_TextHighlightColorAttribute)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOMEDS_TextHighlightColorAttribute::DynamicType() const +{ + return STANDARD_TYPE(SALOMEDS_TextHighlightColorAttribute) ; +} +Standard_Boolean SALOMEDS_TextHighlightColorAttribute::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOMEDS_TextHighlightColorAttribute) == AType || TDataStd_RealArray::IsKind(AType)); +} +Handle_SALOMEDS_TextHighlightColorAttribute::~Handle_SALOMEDS_TextHighlightColorAttribute() {} + diff --git a/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.jxx b/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.jxx new file mode 100644 index 000000000..13a333508 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_TextHighlightColorAttribute.jxx @@ -0,0 +1,21 @@ +// File : SALOMEDS_TextHighlightColorAttribute.jxx +// Created : Wed Jul 10 16:44:36 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef _Standard_GUID_HeaderFile +#include +#endif +#ifndef _TDF_Attribute_HeaderFile +#include +#endif +#ifndef _TDF_RelocationTable_HeaderFile +#include +#endif +#ifndef _SALOMEDS_TextHighlightColorAttribute_HeaderFile +#include "SALOMEDS_TextHighlightColorAttribute.hxx" +#endif diff --git a/src/SALOMEDS/SALOMEDS_Tool.cxx b/src/SALOMEDS/SALOMEDS_Tool.cxx new file mode 100644 index 000000000..79c436f31 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_Tool.cxx @@ -0,0 +1,303 @@ +using namespace std; +// File : SALOMEDS_Tool.cxx +// Created : Mon Oct 21 16:24:34 2002 +// Author : Sergey RUIN + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + +#include "SALOMEDS_Tool.hxx" + +#include "utilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +//============================================================================ +// function : GetTempDir +// purpose : Return a temp directory to store created files like "/tmp/sub_dir/" +//============================================================================ +char* SALOMEDS_Tool::GetTmpDir() +{ + //Find a temporary directory to store a file + + TCollection_AsciiString aTmpDir; + + char *Tmp_dir = getenv("SALOME_TMP_DIR"); + if(Tmp_dir != NULL) { + aTmpDir = TCollection_AsciiString(Tmp_dir); +#ifdef WIN32 + if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\'; +#else + if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/'; +#endif + } + else { +#ifdef WIN32 + aTmpDir = TCollection_AsciiString("C:\\"); +#else + aTmpDir = TCollection_AsciiString("/tmp/"); +#endif + } + + srand((unsigned int)time(NULL)); + int aRND = 999 + (int)(100000.0*rand()/(RAND_MAX+1.0)); //Get a random number to present a name of a sub directory + TCollection_AsciiString aSubDir(aRND); + if(aSubDir.Length() <= 1) aSubDir = TCollection_AsciiString("123409876"); + + MESSAGE("#### RND " << aRND); + + aTmpDir += aSubDir; //Get RND sub directory + +#ifdef WIN32 + if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\'; +#else + if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/'; +#endif + + OSD_Path aPath(aTmpDir); + OSD_Directory aDir(aPath); + + for(aRND = 0; aDir.Exists(); aRND++) { + aTmpDir.Insert((aTmpDir.Length() - 1), TCollection_AsciiString(aRND)); //Build a unique directory name + aPath = OSD_Path(aTmpDir); + aDir = OSD_Directory(aPath); + } + + MESSAGE("#### TMP" << aTmpDir.ToCString()); + + OSD_Protection aProtection(OSD_RW, OSD_RWX, OSD_RX, OSD_RX); + aDir.Build(aProtection); + + return CORBA::string_dup(aTmpDir.ToCString()); +} + +//============================================================================ +// function : RemoveTemporaryFiles +// purpose : Removes files listed in theFileList +//============================================================================ +void SALOMEDS_Tool::RemoveTemporaryFiles(const char* theDirectory, + const SALOMEDS::ListOfFileNames& theFiles, + const bool IsDirDeleted) +{ + TCollection_AsciiString aDirName(const_cast(theDirectory)); + + int i, aLength = theFiles.length(); + for(i=0; i(theFromDirectory)); //Get a temporary directory for saved a file + + long aBufferSize = 0; + long aCurrentPos; + + int aNbFiles = 0; + int* aFileNameSize= new int[aLength]; + long* aFileSize= new long[aLength]; + + //Determine the required size of the buffer + + for(i=0; i 4) ? 4 : sizeof(int))); + + + aCurrentPos = 4; + + for(i=0; i 4) ? 4 : sizeof(int))); + aCurrentPos += 4; + + //Copy the file name to the buffer + memcpy((aBuffer + aCurrentPos), theFiles[i], aFileNameSize[i]); + aCurrentPos += aFileNameSize[i]; + + if (!theNamesOnly) { // mpv 15.01.2003: we don't copy file content to the buffer if !theNamesOnly + //Initialize 8 bytes of the buffer by 0 + memset((aBuffer + aCurrentPos), 0, 8); + //Copy the length of the file to the buffer + memcpy((aBuffer + aCurrentPos), (aFileSize + i), ((sizeof(long) > 8) ? 8 : sizeof(long))); + aCurrentPos += 8; + + aFile->seekg(0, ios::beg); + aFile->read((char *)(aBuffer + aCurrentPos), aFileSize[i]); + aFile->close(); + delete(aFile); + aCurrentPos += aFileSize[i]; + } + } + + delete[] aFileNameSize; + delete[] aFileSize; + + + CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer; + + return (new SALOMEDS::TMPFile(aBufferSize, aBufferSize, anOctetBuf, 1)); +} + +//============================================================================ +// function : PutStreamToFile +// purpose : converts the stream "theStream" to the files +//============================================================================ +SALOMEDS::ListOfFileNames* +SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream, + const char* theToDirectory, + const int theNamesOnly) +{ + if(theStream.length() == 0) return NULL; + TCollection_AsciiString aTmpDir(const_cast(theToDirectory)); //Get a temporary directory for saving a file + + unsigned char *aBuffer = (unsigned char*)theStream.NP_data(); + + + long aBufferSize = theStream.length(); + long aFileSize, aCurrentPos = 4; + int i, aFileNameSize, aNbFiles = 0; + + //Copy the number of files in the stream + memcpy(&aNbFiles, aBuffer, sizeof(int)); + + SALOMEDS::ListOfFileNames_var aFiles = new SALOMEDS::ListOfFileNames; + aFiles->length(aNbFiles); + + for(i=0; i 4) ? 4 : sizeof(int))); + aCurrentPos += 4; + + char *aFileName = new char[aFileNameSize]; + //Put a file name to aFileName + memcpy(aFileName, (aBuffer + aCurrentPos), aFileNameSize); + aCurrentPos += aFileNameSize; + + //Put a length of the file to aFileSize + if (!theNamesOnly) { + memcpy(&aFileSize, (aBuffer + aCurrentPos), ((sizeof(long) > 8) ? 8 : sizeof(long))); + aCurrentPos += 8; + + TCollection_AsciiString aFullPath = aTmpDir + aFileName; + ofstream aFile(aFullPath.ToCString()); + aFile.write((char *)(aBuffer+aCurrentPos), aFileSize); + aFile.close(); + aCurrentPos += aFileSize; + } + aFiles[i] = CORBA::string_dup(aFileName); + delete[] aFileName; + } + + return aFiles._retn(); +} + +//============================================================================ +// function : GetNameFromPath +// purpose : Returns the name by the path +//============================================================================ +char* SALOMEDS_Tool::GetNameFromPath(const char* thePath) { + if (thePath == NULL) return strdup(""); + OSD_Path aPath = OSD_Path(TCollection_AsciiString(strdup(thePath))); + TCollection_AsciiString aNameString(aPath.Name()); + return aNameString.ToCString(); +} + +//============================================================================ +// function : GetDirFromPath +// purpose : Returns the dir by the path +//============================================================================ +char* SALOMEDS_Tool::GetDirFromPath(const char* thePath) { + if (thePath == NULL) return strdup(""); + OSD_Path aPath = OSD_Path(TCollection_AsciiString(strdup(thePath))); + TCollection_AsciiString aDirString(aPath.Trek()); + aDirString.ChangeAll('|','/'); + return aDirString.ToCString(); +} diff --git a/src/SALOMEDS/SALOMEDS_Tool.hxx b/src/SALOMEDS/SALOMEDS_Tool.hxx new file mode 100644 index 000000000..c5f8e2260 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_Tool.hxx @@ -0,0 +1,52 @@ +// File : SALOMEDS_Tool.hxx +// Created : Mon Oct 21 16:24:50 2002 +// Author : Sergey RUIN + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE + + +#ifndef __SALOMEDS_Tool_H__ +#define __SALOMEDS_Tool_H__ + + + +// IDL headers +#include + +class SALOMEDS_Tool +{ +public: + + // Returns the unique temporary directory, that is defined in SALOME_TMP_DIR if this variable is set + // otherwise return /tmp/something/ for Unix or c:\something\ for WNT + static char* GetTmpDir(); + + + // Removes files which are in , the files for deletion are listed in + // if is true is also deleted if it is empty + static void RemoveTemporaryFiles(const char* theDirectory, + const SALOMEDS::ListOfFileNames& theFiles, + const bool IsDirDeleted); + + // Converts files listed in which are in into a byte sequence TMPFile + static SALOMEDS::TMPFile* PutFilesToStream(const char* theFromDirectory, + const SALOMEDS::ListOfFileNames& theFiles, + const int theNamesOnly = 0); + + // Converts a byte sequence to files and places them in + static SALOMEDS::ListOfFileNames* PutStreamToFiles(const SALOMEDS::TMPFile& theStream, + const char* theToDirectory, + const int theNamesOnly = 0); + + // Returns the name by the path + // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "doc1" + static char* GetNameFromPath(const char* thePath); + + // Returns the directory by the path + // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "/tmp/aaa" + static char* GetDirFromPath(const char* thePath); + +}; +#endif diff --git a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx new file mode 100644 index 000000000..f83e3e7e3 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx @@ -0,0 +1,397 @@ +using namespace std; +// File : SALOMEDS_UseCaseBuilder_i.cxx +// Created : Mon Oct 7 16:15:25 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 + +#include "SALOMEDS_UseCaseBuilder_i.hxx" +#include "SALOMEDS_AttributeComment_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include "SALOMEDS_SComponent_i.hxx" +#include "SALOMEDS_UseCaseIterator_i.hxx" +#include "utilities.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define USE_CASE_LABEL_TAG 2 +#define USE_CASE_GUID "AA43BB12-D9CD-11d6-945D-0050DA506788" + + +//============================================================================ +/*! Function : constructor + * Purpose : + */ +//============================================================================ +SALOMEDS_UseCaseBuilder_i::SALOMEDS_UseCaseBuilder_i(const Handle(TDocStd_Document)& theDocument, + CORBA::ORB_ptr orb) +:_doc(theDocument) +{ + _orb = CORBA::ORB::_duplicate(orb); + if(_doc.IsNull()) return; + + TDF_Label aLabel = _doc->Main().Root().FindChild(USE_CASE_LABEL_TAG); //Iterate all use cases + if(!aLabel.FindAttribute(Standard_GUID(USE_CASE_GUID), _root)) { + _root = TDataStd_TreeNode::Set(aLabel, Standard_GUID(USE_CASE_GUID)); + } + + Handle(TDF_Reference) aRef; + if(!_root->FindAttribute(TDF_Reference::GetID(), aRef)) { + aRef = TDF_Reference::Set(_root->Label(), _root->Label()); + } + + Handle(TDataStd_Name) aNameAttr; + if(!aLabel.FindAttribute(TDataStd_Name::GetID(), aNameAttr)) { + aNameAttr = TDataStd_Name::Set(aLabel, "Use cases"); + } + +} + +//============================================================================ +/*! Function : destructor + * Purpose : + */ +//============================================================================ +SALOMEDS_UseCaseBuilder_i::~SALOMEDS_UseCaseBuilder_i() +{ +} + + +//============================================================================ +/*! Function : Append + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_UseCaseBuilder_i::Append(SALOMEDS::SObject_ptr theObject) +{ + if(_root.IsNull() || theObject->_is_nil()) return 0; + + TDF_Label aLabel; + + TDF_Tool::Label(_root->Label().Data(), theObject->GetID(), aLabel); + if(aLabel.IsNull()) return 0; + + Handle(TDataStd_TreeNode) aNode, aCurrentNode; + aNode = TDataStd_TreeNode::Set(aLabel, _root->ID()); + aNode->Remove(); + + Handle(TDF_Reference) aRef; + if(!_root->FindAttribute(TDF_Reference::GetID(), aRef)) { + aRef = TDF_Reference::Set(_root->Label(), _root->Label()); + } + TDF_Label aCurrent = aRef->Get(); + + if(aCurrent.IsNull() || !aCurrent.FindAttribute(_root->ID(), aCurrentNode)) + aCurrentNode = _root; + + return aCurrentNode->Append(aNode); +} + + //============================================================================ +/*! Function : Remove + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_UseCaseBuilder_i::Remove(SALOMEDS::SObject_ptr theObject) +{ + if(_root.IsNull() || theObject->_is_nil()) return 0; + + TDF_Label aLabel; + TDF_Tool::Label(_root->Label().Data(), theObject->GetID(), aLabel); + if(aLabel.IsNull()) return 0; + + Handle(TDataStd_TreeNode) aNode; + if(!aLabel.FindAttribute(_root->ID(), aNode)) return 0; + + aNode->Remove(); + + TDF_AttributeList aList; + aList.Append(aNode); + + Handle(TDF_Reference) aRef; + if(!_root->FindAttribute(TDF_Reference::GetID(), aRef)) { + aRef = TDF_Reference::Set(_root->Label(), _root->Label()); + } + TDF_Label aCurrent = aRef->Get(); + + TDataStd_ChildNodeIterator aChildItr(aNode, Standard_True); + for(; aChildItr.More(); aChildItr.Next()) + aList.Append(aChildItr.Value()); + + TDF_ListIteratorOfAttributeList anIterator(aList); + for(; anIterator.More(); anIterator.Next()) { + if(anIterator.Value()->Label() == aCurrent) { //The current node is removed + aRef->Set(_root->Label()); //Reset the current node to the root + } + anIterator.Value()->Label().ForgetAttribute(_root->ID()); + } + + return 1; +} + + +//============================================================================ +/*! Function : AppendTo + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_UseCaseBuilder_i::AppendTo(SALOMEDS::SObject_ptr theFather, + SALOMEDS::SObject_ptr theObject) +{ + if(_root.IsNull() || theFather->_is_nil() || theObject->_is_nil()) return 0; + + TDF_Label aFatherLabel, aLabel; + Handle(TDataStd_TreeNode) aFather, aNode; + + TDF_Tool::Label(_root->Label().Data(), theFather->GetID(), aFatherLabel); + if(aFatherLabel.IsNull()) return 0; + if(!aFatherLabel.FindAttribute(_root->ID(), aFather)) return 0; + + TDF_Tool::Label(_root->Label().Data(), theObject->GetID(), aLabel); + if(aLabel.IsNull()) return 0; + if(!aLabel.FindAttribute(_root->ID(), aNode)) { + aNode = TDataStd_TreeNode::Set(aLabel, _root->ID()); + } + else + aNode->Remove(); + + return aFather->Append(aNode); +} + +//============================================================================ +/*! Function : InsertBefore + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_UseCaseBuilder_i::InsertBefore(SALOMEDS::SObject_ptr theFirst, + SALOMEDS::SObject_ptr theNext) +{ + if(_root.IsNull() || theFirst->_is_nil() || theNext->_is_nil()) return 0; + + TDF_Label aFirstLabel, aLabel; + Handle(TDataStd_TreeNode) aFirstNode, aNode; + + TDF_Tool::Label(_root->Label().Data(), theFirst->GetID(), aFirstLabel); + if(aFirstLabel.IsNull()) return 0; + if(aFirstLabel.FindAttribute(_root->ID(), aFirstNode)) { + aFirstNode->Remove(); + aFirstLabel.ForgetAttribute(aFirstNode->ID()); + } + + aFirstNode = TDataStd_TreeNode::Set(aFirstLabel, _root->ID()); + + + TDF_Tool::Label(_root->Label().Data(), theNext->GetID(), aLabel); + if(aLabel.IsNull()) return 0; + if(!aLabel.FindAttribute(_root->ID(), aNode)) return 0; + + return aNode->InsertBefore(aFirstNode); +} + + +//============================================================================ +/*! Function : SetCurrentObject + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_UseCaseBuilder_i::SetCurrentObject(SALOMEDS::SObject_ptr theObject) +{ + if(_root.IsNull() || theObject->_is_nil()) return 0; + + TDF_Label aLabel; + Handle(TDataStd_TreeNode) aNode; + TDF_Tool::Label(_root->Label().Data(), theObject->GetID(), aLabel); + if(aLabel.IsNull()) return 0; + if(!aLabel.FindAttribute(_root->ID(), aNode)) return 0; + + + Handle(TDF_Reference) aRef; + if(!_root->FindAttribute(TDF_Reference::GetID(), aRef)) { + aRef = TDF_Reference::Set(_root->Label(), aNode->Label()); + } + + aRef->Set(aNode->Label()); + + return 1; +} + +//============================================================================ +/*! Function : SetRootCurrent + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_UseCaseBuilder_i::SetRootCurrent() +{ + if(_root.IsNull()) return 0; + + Handle(TDF_Reference) aRef; + if(!_root->FindAttribute(TDF_Reference::GetID(), aRef)) + aRef = TDF_Reference::Set(_root->Label(), _root->Label()); + + aRef->Set(_root->Label()); + return 1; +} + +//============================================================================ +/*! Function : HasChildren + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_UseCaseBuilder_i::HasChildren(SALOMEDS::SObject_ptr theObject) +{ + if(_root.IsNull()) return 0; + + TDF_Label aLabel; + if (theObject->_is_nil()) aLabel = _root->Label(); + else TDF_Tool::Label(_root->Label().Data(), theObject->GetID(), aLabel); + if(aLabel.IsNull()) return 0; + + Handle(TDataStd_TreeNode) aNode; + if(!aLabel.FindAttribute(_root->ID(), aNode)) return 0; + + return !(aNode->First().IsNull()); +} + +//============================================================================ +/*! Function : SetName + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_UseCaseBuilder_i::SetName(const char* theName) { + if(_root.IsNull()) return 0; + + Handle(TDataStd_Name) aNameAttrib; + TCollection_ExtendedString aName(strdup(theName)); + + if (!_root->FindAttribute(TDataStd_Name::GetID(), aNameAttrib)) + aNameAttrib = TDataStd_Name::Set(_root->Label(), aName); + else + aNameAttrib->Set(aName); + + return 1; +} + + +//============================================================================ +/*! Function : GetCurrentObject + * Purpose : + */ +//============================================================================ +SALOMEDS::SObject_ptr SALOMEDS_UseCaseBuilder_i::GetCurrentObject() +{ + if(_root.IsNull()) return NULL; + + Handle(TDF_Reference) aRef; + if(!_root->FindAttribute(TDF_Reference::GetID(), aRef)) { + aRef = TDF_Reference::Set(_root->Label(), _root->Label()); + } + TDF_Label aCurrent = aRef->Get(); + if(aCurrent.IsNull()) return NULL; + + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aCurrent, _orb); + SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + return so._retn(); +} + +//============================================================================ +/*! Function : GetName + * Purpose : + */ +//============================================================================ +char* SALOMEDS_UseCaseBuilder_i::GetName() { + CORBA::String_var aString; + if(_root.IsNull()) return aString._retn(); + + Handle(TDataStd_Name) aName; + if (!_root->FindAttribute(TDataStd_Name::GetID(), aName)) return aString._retn(); + aString = strdup(TCollection_AsciiString(aName->Get()).ToCString()); + return aString._retn(); +} + +//============================================================================ +/*! Function : IsUseCase + * Purpose : + */ +//============================================================================ +CORBA::Boolean SALOMEDS_UseCaseBuilder_i::IsUseCase(SALOMEDS::SObject_ptr theObject) +{ + if(theObject->_is_nil()) return false; + TDF_Label aFather, aLabel; + TDF_Tool::Label(_doc->GetData(), theObject->GetID(), aLabel); + aFather = _doc->Main().Root().FindChild(USE_CASE_LABEL_TAG); + if(aLabel.Father() == aFather) return true; + return false; +} + +//============================================================================ +/*! Function : NewUseCase + * Purpose : + */ +//============================================================================ +SALOMEDS::SObject_ptr SALOMEDS_UseCaseBuilder_i::AddUseCase(const char* theName) +{ + Standard_GUID aBasicGUID(USE_CASE_GUID); + + //Create a use cases structure if it not exists + + Handle(TDataStd_TreeNode) aFatherNode, aNode; + Handle(TDataStd_Integer) anInteger; + Handle(TDF_Reference) aRef; + + TDF_Label aLabel = _doc->Main().Root().FindChild(USE_CASE_LABEL_TAG); + + if(!_root->FindAttribute(TDF_Reference::GetID(), aRef)) { + aRef = TDF_Reference::Set(aLabel, aLabel); + } + + if(!aRef->Get().FindAttribute(aBasicGUID, aFatherNode)) { + aFatherNode = TDataStd_TreeNode::Set(aRef->Get()); + } + + if(!_root->FindAttribute(TDataStd_Integer::GetID(), anInteger)) { + anInteger = TDataStd_Integer::Set(aLabel, 0); + } + + //Create a new use case + anInteger->Set(anInteger->Get()+1); + TDF_Label aChild = aLabel.FindChild(anInteger->Get()); + aNode = TDataStd_TreeNode::Set(aChild, aBasicGUID); + aFatherNode->Append(aNode); + TDataStd_Name::Set(aChild, TCollection_ExtendedString(strdup(theName))); + + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (aChild, _orb); + SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + + return so._retn(); +} + +//============================================================================ +/*! Function : GetUseCaseIterator + * Purpose : Creates a new UseCase iterator, if anObject is null all use cases are iterated + */ +//============================================================================ +SALOMEDS::UseCaseIterator_ptr SALOMEDS_UseCaseBuilder_i::GetUseCaseIterator(SALOMEDS::SObject_ptr anObject) +{ + TDF_Label aLabel; + + if(!anObject->_is_nil()) { + TDF_Tool::Label(_doc->GetData(), anObject->GetID(), aLabel); //Iterate only sub tree in the use case + } + else { + aLabel = _doc->Main().Root().FindChild(USE_CASE_LABEL_TAG); //Iterate all use cases + } + + SALOMEDS_UseCaseIterator_i* aServant = new SALOMEDS_UseCaseIterator_i(aLabel, USE_CASE_GUID, Standard_False, _orb); + SALOMEDS::UseCaseIterator_var anIterator = SALOMEDS::UseCaseIterator::_narrow(aServant->_this()); + + return anIterator._retn(); +} diff --git a/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.hxx b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.hxx new file mode 100644 index 000000000..8abda02b0 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.hxx @@ -0,0 +1,70 @@ +// File : SALOMEDS_UseCaseBuilder_i.hxx +// Created : Mon Oct 7 16:20:12 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 + +#ifndef __SALOMEDS_USECaseBuilder_I_H__ +#define __SALOMEDS_USECaseBuilder_I_H__ + +// std C++ headers +#include + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +// Cascade headers +#include +#include +#include +#include + +class SALOMEDS_UseCaseBuilder_i: public POA_SALOMEDS::UseCaseBuilder, + public PortableServer::RefCountServantBase { +private: + + CORBA::ORB_ptr _orb; + Handle(TDataStd_TreeNode) _root; + Handle(TDocStd_Document) _doc; + +public: + + //! standard constructor + SALOMEDS_UseCaseBuilder_i(const Handle(TDocStd_Document)& theDocument, + CORBA::ORB_ptr); + + //! standard destructor + ~SALOMEDS_UseCaseBuilder_i(); + + virtual CORBA::Boolean Append(SALOMEDS::SObject_ptr theObject); + + virtual CORBA::Boolean Remove(SALOMEDS::SObject_ptr theObject); + + virtual CORBA::Boolean AppendTo(SALOMEDS::SObject_ptr theFather, SALOMEDS::SObject_ptr theObject); + + virtual CORBA::Boolean InsertBefore(SALOMEDS::SObject_ptr theFirst, SALOMEDS::SObject_ptr theNext); + + virtual CORBA::Boolean SetCurrentObject(SALOMEDS::SObject_ptr theObject); + + virtual CORBA::Boolean SetRootCurrent(); + + virtual CORBA::Boolean HasChildren(SALOMEDS::SObject_ptr theObject); + + virtual CORBA::Boolean IsUseCase(SALOMEDS::SObject_ptr theObject); + + virtual CORBA::Boolean SetName(const char* theName); + + virtual SALOMEDS::SObject_ptr GetCurrentObject(); + + virtual char* GetName(); + + virtual SALOMEDS::SObject_ptr AddUseCase(const char* theName); + + virtual SALOMEDS::UseCaseIterator_ptr GetUseCaseIterator(SALOMEDS::SObject_ptr anObject); + +}; +#endif diff --git a/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx b/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx new file mode 100644 index 000000000..490a24acf --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx @@ -0,0 +1,87 @@ +using namespace std; +// File : SALOMEDS_UseCaseIterator_i.cxx +// Created : Mon Oct 7 16:15:25 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 + +#include "SALOMEDS_UseCaseIterator_i.hxx" +#include "SALOMEDS_SObject_i.hxx" +#include "utilities.h" + + + +//============================================================================ +/*! Function : constructor + * Purpose : + */ +//============================================================================ +SALOMEDS_UseCaseIterator_i::SALOMEDS_UseCaseIterator_i(const TDF_Label& theLabel, + const Standard_GUID& theGUID, + const Standard_Boolean allLevels, + CORBA::ORB_ptr orb) +:_guid(theGUID), _levels(allLevels) +{ + _orb = CORBA::ORB::_duplicate(orb); + + if(theLabel.FindAttribute(_guid, _node)) { + _it.Initialize (_node, _levels); + } +} + +//============================================================================ +/*! Function : destructor + * Purpose : + */ +//============================================================================ +SALOMEDS_UseCaseIterator_i::~SALOMEDS_UseCaseIterator_i() +{ +} + +//============================================================================ +/*! Function :Init + * + */ +//============================================================================ +void SALOMEDS_UseCaseIterator_i::Init(CORBA::Boolean allLevels) +{ + _it.Initialize (_node, allLevels); +} + +//============================================================================ +/*! Function : More + * + */ +//============================================================================ +CORBA::Boolean SALOMEDS_UseCaseIterator_i::More() +{ + return _it.More(); +} + + //============================================================================ +/*! Function : Next + * + */ +//============================================================================ +void SALOMEDS_UseCaseIterator_i::Next() +{ + _it.Next(); +} + + +//============================================================================ +/*! Function : + * Purpose : + */ +//============================================================================ + +SALOMEDS::SObject_ptr SALOMEDS_UseCaseIterator_i::Value() +{ + TDF_Label L = _it.Value()->Label(); + SALOMEDS_SObject_i * so_servant = new SALOMEDS_SObject_i (L,_orb); + SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); + return so._retn(); +} + diff --git a/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.hxx b/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.hxx new file mode 100644 index 000000000..8fe55d905 --- /dev/null +++ b/src/SALOMEDS/SALOMEDS_UseCaseIterator_i.hxx @@ -0,0 +1,53 @@ +// File : SALOMEDS_UseCaseIterator_i.hxx +// Created : Mon Oct 7 16:20:12 2002 +// Author : Yves FRICAUD + +// Project : SALOME +// Module : SALOMEDS +// Copyright : Open CASCADE 2002 + +#ifndef __SALOMEDS_USECASEITERATOR_I_H__ +#define __SALOMEDS_USECASEITERATOR_I_H__ + +// std C++ headers +#include + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + + + +// Cascade headers +#include +#include +#include +#include +#include + +class SALOMEDS_UseCaseIterator_i: public POA_SALOMEDS::UseCaseIterator, + public PortableServer::RefCountServantBase { +private: + Standard_GUID _guid; + Standard_Boolean _levels; + CORBA::ORB_ptr _orb; + Handle(TDataStd_TreeNode) _node; + TDataStd_ChildNodeIterator _it; + +public: + + //! standard constructor + SALOMEDS_UseCaseIterator_i(const TDF_Label& theLabel, + const Standard_GUID& theGUID, + const Standard_Boolean allLevels, + CORBA::ORB_ptr); + + //! standard destructor + ~SALOMEDS_UseCaseIterator_i(); + + virtual void Init(CORBA::Boolean); + virtual CORBA::Boolean More(); + virtual void Next(); + virtual SALOMEDS::SObject_ptr Value(); +}; +#endif diff --git a/src/SALOMEGUI/CLIENT_icons.po b/src/SALOMEGUI/CLIENT_icons.po new file mode 100644 index 000000000..333a02fa1 --- /dev/null +++ b/src/SALOMEGUI/CLIENT_icons.po @@ -0,0 +1,37 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: example-Qt-message-extraction\n" +"POT-Creation-Date: 1999-02-23 15:38+0200\n" +"PO-Revision-Date: 1999-02-23 15:38+0200\n" +"Last-Translator: \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +#-------------- +# DESKTOP +#-------------- + +msgid "ICON_DESK_DEFAULTICON" +msgstr "default.png" + +msgid "ICON_DESK_BACKGROUNDICON" +msgstr "Desktop.png" + +#-------------- +# APPLICATION +#-------------- + +msgid "ICON_APP_DEFAULTICON" +msgstr "default.png" + +#-------------- +# ABOUT +#-------------- + +msgid "ICON_ABOUT" +msgstr "Application-About.png" + +msgid "ICON_DESK_LOGO" +msgstr "Application-Logo.png" \ No newline at end of file diff --git a/src/SALOMEGUI/CLIENT_msg_en.po b/src/SALOMEGUI/CLIENT_msg_en.po new file mode 100644 index 000000000..0a1a5735b --- /dev/null +++ b/src/SALOMEGUI/CLIENT_msg_en.po @@ -0,0 +1,39 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: example-Qt-message-extraction\n" +"POT-Creation-Date: 1999-02-23 15:38+0200\n" +"PO-Revision-Date: 1999-02-23 15:38+0200\n" +"Last-Translator: \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +#--------------- +# INFORMATIONS +#--------------- + +msgid "INF_VERSION" +msgstr "Version 1.1a" + +msgid "INF_COPYRIGHT" +msgstr "Copyright (C) 2002, OPEN CASCADE" + +msgid "INF_LICENSE" +msgstr "All rights reserved" + +#: SALOMEGUI_AboutDlg.cxx:42 +msgid "ABOUT_TLT" +msgstr "About SALOME Professional" + +#: QAD_Config.cxx:84 +msgid "MEN_APPNAME" +msgstr "salome" + +#: QAD_Application.cxx:133 +msgid "QAD_Application::APP_DEFAULTTITLE" +msgstr "SALOME Professional 1.1a" + +#: QAD_Desktop.cxx:424 +msgid "QAD_Desktop::DESK_DEFAULTTITLE" +msgstr "SALOME Professional 1.1a" \ No newline at end of file diff --git a/src/SALOMEGUI/Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx b/src/SALOMEGUI/Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx new file mode 100644 index 000000000..de8d1438c --- /dev/null +++ b/src/SALOMEGUI/Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_HeaderFile +#define _Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TCollection_MapNode_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TCollection_MapNode); +class SALOME_DataMapNodeOfDataMapOfIOMapOfInteger; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger); + +class Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger) : public Handle(TCollection_MapNode) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger)():Handle(TCollection_MapNode)() {} + Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger)(const Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger)(const SALOME_DataMapNodeOfDataMapOfIOMapOfInteger* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger)& operator=(const Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger)& operator=(const SALOME_DataMapNodeOfDataMapOfIOMapOfInteger* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOME_DataMapNodeOfDataMapOfIOMapOfInteger* operator->() + { + return (SALOME_DataMapNodeOfDataMapOfIOMapOfInteger *)ControlAccess(); + } + + SALOME_DataMapNodeOfDataMapOfIOMapOfInteger* operator->() const + { + return (SALOME_DataMapNodeOfDataMapOfIOMapOfInteger *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger)(); + + Standard_EXPORT static const Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEGUI/Handle_SALOME_Filter.hxx b/src/SALOMEGUI/Handle_SALOME_Filter.hxx new file mode 100644 index 000000000..aba41d8aa --- /dev/null +++ b/src/SALOMEGUI/Handle_SALOME_Filter.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_SALOME_Filter_HeaderFile +#define _Handle_SALOME_Filter_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_MMgt_TShared_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(MMgt_TShared); +class SALOME_Filter; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOME_Filter); + +class Handle(SALOME_Filter) : public Handle(MMgt_TShared) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOME_Filter)():Handle(MMgt_TShared)() {} + Handle(SALOME_Filter)(const Handle(SALOME_Filter)& aHandle) : Handle(MMgt_TShared)(aHandle) + { + } + + Handle(SALOME_Filter)(const SALOME_Filter* anItem) : Handle(MMgt_TShared)((MMgt_TShared *)anItem) + { + } + + Handle(SALOME_Filter)& operator=(const Handle(SALOME_Filter)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOME_Filter)& operator=(const SALOME_Filter* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOME_Filter* operator->() + { + return (SALOME_Filter *)ControlAccess(); + } + + SALOME_Filter* operator->() const + { + return (SALOME_Filter *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOME_Filter)(); + + Standard_EXPORT static const Handle(SALOME_Filter) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEGUI/Handle_SALOME_ListNodeOfListIO.hxx b/src/SALOMEGUI/Handle_SALOME_ListNodeOfListIO.hxx new file mode 100644 index 000000000..e0aebcbcb --- /dev/null +++ b/src/SALOMEGUI/Handle_SALOME_ListNodeOfListIO.hxx @@ -0,0 +1,85 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_SALOME_ListNodeOfListIO_HeaderFile +#define _Handle_SALOME_ListNodeOfListIO_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TCollection_MapNode_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TCollection_MapNode); +class SALOME_ListNodeOfListIO; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOME_ListNodeOfListIO); + +class Handle(SALOME_ListNodeOfListIO) : public Handle(TCollection_MapNode) { + public: + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + Handle(SALOME_ListNodeOfListIO)():Handle(TCollection_MapNode)() {} + Handle(SALOME_ListNodeOfListIO)(const Handle(SALOME_ListNodeOfListIO)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(SALOME_ListNodeOfListIO)(const SALOME_ListNodeOfListIO* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(SALOME_ListNodeOfListIO)& operator=(const Handle(SALOME_ListNodeOfListIO)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOME_ListNodeOfListIO)& operator=(const SALOME_ListNodeOfListIO* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOME_ListNodeOfListIO* operator->() + { + return (SALOME_ListNodeOfListIO *)ControlAccess(); + } + + SALOME_ListNodeOfListIO* operator->() const + { + return (SALOME_ListNodeOfListIO *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOME_ListNodeOfListIO)(); + + Standard_EXPORT static const Handle(SALOME_ListNodeOfListIO) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEGUI/Handle_SALOME_ListNodeOfListOfFilter.hxx b/src/SALOMEGUI/Handle_SALOME_ListNodeOfListOfFilter.hxx new file mode 100644 index 000000000..b7358368a --- /dev/null +++ b/src/SALOMEGUI/Handle_SALOME_ListNodeOfListOfFilter.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_SALOME_ListNodeOfListOfFilter_HeaderFile +#define _Handle_SALOME_ListNodeOfListOfFilter_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_TCollection_MapNode_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TCollection_MapNode); +class SALOME_ListNodeOfListOfFilter; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOME_ListNodeOfListOfFilter); + +class Handle(SALOME_ListNodeOfListOfFilter) : public Handle(TCollection_MapNode) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOME_ListNodeOfListOfFilter)():Handle(TCollection_MapNode)() {} + Handle(SALOME_ListNodeOfListOfFilter)(const Handle(SALOME_ListNodeOfListOfFilter)& aHandle) : Handle(TCollection_MapNode)(aHandle) + { + } + + Handle(SALOME_ListNodeOfListOfFilter)(const SALOME_ListNodeOfListOfFilter* anItem) : Handle(TCollection_MapNode)((TCollection_MapNode *)anItem) + { + } + + Handle(SALOME_ListNodeOfListOfFilter)& operator=(const Handle(SALOME_ListNodeOfListOfFilter)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOME_ListNodeOfListOfFilter)& operator=(const SALOME_ListNodeOfListOfFilter* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOME_ListNodeOfListOfFilter* operator->() + { + return (SALOME_ListNodeOfListOfFilter *)ControlAccess(); + } + + SALOME_ListNodeOfListOfFilter* operator->() const + { + return (SALOME_ListNodeOfListOfFilter *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOME_ListNodeOfListOfFilter)(); + + Standard_EXPORT static const Handle(SALOME_ListNodeOfListOfFilter) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEGUI/Handle_SALOME_NumberFilter.hxx b/src/SALOMEGUI/Handle_SALOME_NumberFilter.hxx new file mode 100644 index 000000000..bd775fd59 --- /dev/null +++ b/src/SALOMEGUI/Handle_SALOME_NumberFilter.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_SALOME_NumberFilter_HeaderFile +#define _Handle_SALOME_NumberFilter_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_SALOME_Filter_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(SALOME_Filter); +class SALOME_NumberFilter; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOME_NumberFilter); + +class Handle(SALOME_NumberFilter) : public Handle(SALOME_Filter) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOME_NumberFilter)():Handle(SALOME_Filter)() {} + Handle(SALOME_NumberFilter)(const Handle(SALOME_NumberFilter)& aHandle) : Handle(SALOME_Filter)(aHandle) + { + } + + Handle(SALOME_NumberFilter)(const SALOME_NumberFilter* anItem) : Handle(SALOME_Filter)((SALOME_Filter *)anItem) + { + } + + Handle(SALOME_NumberFilter)& operator=(const Handle(SALOME_NumberFilter)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOME_NumberFilter)& operator=(const SALOME_NumberFilter* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOME_NumberFilter* operator->() + { + return (SALOME_NumberFilter *)ControlAccess(); + } + + SALOME_NumberFilter* operator->() const + { + return (SALOME_NumberFilter *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOME_NumberFilter)(); + + Standard_EXPORT static const Handle(SALOME_NumberFilter) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEGUI/Handle_SALOME_TypeFilter.hxx b/src/SALOMEGUI/Handle_SALOME_TypeFilter.hxx new file mode 100644 index 000000000..1bdcd31d7 --- /dev/null +++ b/src/SALOMEGUI/Handle_SALOME_TypeFilter.hxx @@ -0,0 +1,89 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _Handle_SALOME_TypeFilter_HeaderFile +#define _Handle_SALOME_TypeFilter_HeaderFile + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Handle_SALOME_Filter_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(SALOME_Filter); +class SALOME_TypeFilter; +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(SALOME_TypeFilter); + +class Handle(SALOME_TypeFilter) : public Handle(SALOME_Filter) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + Handle(SALOME_TypeFilter)():Handle(SALOME_Filter)() {} + Handle(SALOME_TypeFilter)(const Handle(SALOME_TypeFilter)& aHandle) : Handle(SALOME_Filter)(aHandle) + { + } + + Handle(SALOME_TypeFilter)(const SALOME_TypeFilter* anItem) : Handle(SALOME_Filter)((SALOME_Filter *)anItem) + { + } + + Handle(SALOME_TypeFilter)& operator=(const Handle(SALOME_TypeFilter)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(SALOME_TypeFilter)& operator=(const SALOME_TypeFilter* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + SALOME_TypeFilter* operator->() + { + return (SALOME_TypeFilter *)ControlAccess(); + } + + SALOME_TypeFilter* operator->() const + { + return (SALOME_TypeFilter *)ControlAccess(); + } + + Standard_EXPORT ~Handle(SALOME_TypeFilter)(); + + Standard_EXPORT static const Handle(SALOME_TypeFilter) DownCast(const Handle(Standard_Transient)& AnObject); +}; +#endif diff --git a/src/SALOMEGUI/Makefile.in b/src/SALOMEGUI/Makefile.in new file mode 100644 index 000000000..721761660 --- /dev/null +++ b/src/SALOMEGUI/Makefile.in @@ -0,0 +1,200 @@ +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_HEADERS = \ + QAD.h \ + QAD_Application.h \ + QAD_Config.h \ + QAD_Desktop.h \ + QAD_DirListDlg.h \ + QAD_XmlHandler.h \ + QAD_FileDlg.h \ + QAD_FileValidator.h \ + QAD_Help.h \ + QAD_HelpWindow.h \ + QAD_PyInterp.h \ + QAD_LeftFrame.h \ + QAD_ListMenuIdAction.h \ + QAD_ListPopupMenu.h \ + QAD_ListView.h \ + QAD_Menus.h \ + QAD_Message.h \ + QAD_MessageBox.h \ + QAD_Operation.h \ + QAD_OperatorMenus.h \ + QAD_ObjectBrowser.h \ + QAD_ObjectBrowserItem.h \ + QAD_Popup.h \ + QAD_PyEditor.h \ + PyInterp_base.h \ + PyInterp_PyQt.h \ + QAD_Resource.h \ + QAD_ResourceMgr.h \ + QAD_RightFrame.h \ + QAD_Settings.h \ + QAD_SpinBoxDbl.h \ + QAD_Splitter.h \ + QAD_Study.h \ + QAD_StudyFrame.h \ + QAD_Tools.h \ + QAD_ViewFrame.h \ + QAD_WaitCursor.h \ + SALOMEGUI_Application.h \ + SALOMEGUI_Desktop.h \ + SALOMEGUI_ImportOperation.h \ + SALOMEGUI_ViewChoiceDlg.h \ + SALOMEGUI_Swig.hxx \ + SALOMEGUI_Swig.i \ + SALOMEGUI_QtCatchCorbaException.hxx \ + SALOME_ListIO.hxx \ + SALOME_ListIteratorOfListIO.hxx \ + Handle_SALOME_ListNodeOfListIO.hxx \ + SALOME_Selection.h \ + Handle_SALOME_Filter.hxx \ + SALOME_Filter.hxx \ + SALOME_TypeFilter.hxx \ + Handle_SALOME_TypeFilter.hxx \ + SALOME_ListOfFilter.hxx \ + SALOME_ListIteratorOfListOfFilter.hxx \ + Handle_SALOME_ListNodeOfListOfFilter.hxx \ + SALOME_NumberFilter.hxx \ + Handle_SALOME_NumberFilter.hxx \ + SALOME_DataMapOfIOMapOfInteger.hxx \ + Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx \ + SALOMEGUI_LoadStudiesDlg.h \ + SALOMEGUI_TableDlg.h \ + SALOMEGUI_NameDlg.h \ + SALOMEGUI_SetValueDlg.h \ + SALOMEGUI_SetupCurveDlg.h \ + SALOMEGUI_CloseDlg.h + + +# .po files to transform in .qm +PO_FILES = \ + QAD_icons.po \ + QAD_msg_en.po \ + QAD_msg_fr.po \ + SALOMEGUI_icons.po \ + SALOMEGUI_msg_en.po \ + SALOMEGUI_msg_fr.po \ + CLIENT_icons.po \ + CLIENT_msg_en.po + +# Libraries targets + +LIB = libSalomeGUI.la +LIB_SRC = \ + QAD_Application.cxx \ + QAD_Config.cxx \ + QAD_Desktop.cxx \ + QAD_DirListDlg.cxx \ + QAD_XmlHandler.cxx \ + QAD_FileDlg.cxx \ + QAD_FileValidator.cxx \ + QAD_Help.cxx \ + QAD_HelpWindow.cxx \ + PyInterp_base.cxx \ + QAD_PyInterp.cxx \ + QAD_PyInterp_mono.cxx \ + PyInterp_PyQt.cxx \ + QAD_LeftFrame.cxx \ + QAD_ListMenuIdAction.cxx \ + QAD_ListPopupMenu.cxx \ + QAD_ListView.cxx \ + QAD_Menus.cxx \ + QAD_Message.cxx \ + QAD_MessageBox.cxx \ + QAD_Operation.cxx \ + QAD_OperatorMenus.cxx \ + QAD_ObjectBrowser.cxx \ + QAD_ObjectBrowserItem.cxx \ + QAD_ParserSettings.cxx \ + QAD_Popup.cxx \ + QAD_PyEditor.cxx \ + QAD_ResourceMgr.cxx \ + QAD_RightFrame.cxx \ + QAD_Settings.cxx \ + QAD_SpinBoxDbl.cxx \ + QAD_Splitter.cxx \ + QAD_Study.cxx \ + QAD_StudyFrame.cxx \ + QAD_Tools.cxx \ + QAD_ViewFrame.cxx \ + SALOMEGUI_Application.cxx \ + SALOMEGUI_Desktop.cxx \ + SALOMEGUI_ImportOperation.cxx \ + SALOMEGUI_ViewChoiceDlg.cxx \ + SALOMEGUI_AboutDlg.cxx \ + SALOMEGUI_Swig.cxx \ + SALOMEGUI_OpenWith.cxx \ + SALOMEGUI_StudyPropertiesDlg.cxx \ + SALOMEGUI_QtCatchCorbaException.cxx \ + SALOME_ListIO_0.cxx \ + SALOME_ListNodeOfListIO_0.cxx \ + SALOME_ListIteratorOfListIO_0.cxx \ + SALOME_Selection.cxx \ + SALOME_Filter.cxx \ + SALOME_ListOfFilter_0.cxx \ + SALOME_ListNodeOfListOfFilter_0.cxx \ + SALOME_ListIteratorOfListOfFilter_0.cxx \ + SALOME_TypeFilter.cxx \ + SALOME_NumberFilter.cxx \ + SALOME_DataMapOfIOMapOfInteger_0.cxx \ + SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_0.cxx \ + SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_0.cxx \ + SALOMEGUI_TrihedronSizeDlg.cxx \ + SALOMEGUI_LoadStudiesDlg.cxx \ + SALOMEGUI_TableDlg.cxx \ + SALOMEGUI_NameDlg.cxx \ + SALOMEGUI_SetValueDlg.cxx \ + SALOMEGUI_SetupCurveDlg.cxx \ + SALOMEGUI_CloseDlg.cxx + +LIB_MOC = \ + SALOMEGUI_Application.h \ + SALOMEGUI_Desktop.h \ + QAD_Application.h \ + QAD_Desktop.h \ + QAD_DirListDlg.h \ + QAD_FileDlg.h \ + QAD_HelpWindow.h \ + QAD_ListView.h \ + QAD_ObjectBrowser.h \ + QAD_Operation.h \ + QAD_PyEditor.h \ + QAD_ResourceMgr.h \ + QAD_Settings.h \ + QAD_SpinBoxDbl.h \ + QAD_Study.h \ + QAD_StudyFrame.h \ + QAD_ViewFrame.h \ + SALOMEGUI_OpenWith.h \ + SALOMEGUI_StudyPropertiesDlg.h \ + SALOMEGUI_TrihedronSizeDlg.h \ + SALOME_Selection.h \ + SALOMEGUI_LoadStudiesDlg.h \ + SALOMEGUI_ViewChoiceDlg.h \ + SALOMEGUI_TableDlg.h \ + SALOMEGUI_NameDlg.h \ + SALOMEGUI_SetupCurveDlg.h \ + SALOMEGUI_CloseDlg.h + +LIB_CLIENT_IDL = SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + SALOME_Exception.idl + +CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(QWT_INCLUDES) +LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeNS -lqsplitterP -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject + +LIBS+= $(PYTHON_LIBS) + + +@CONCLUDE@ diff --git a/src/SALOMEGUI/PyInterp_PyQt.cxx b/src/SALOMEGUI/PyInterp_PyQt.cxx new file mode 100644 index 000000000..05c0c4834 --- /dev/null +++ b/src/SALOMEGUI/PyInterp_PyQt.cxx @@ -0,0 +1,94 @@ +using namespace std; +using namespace std; +//============================================================================= +// File : PyInterp_PyQt.cxx +// Created : ven fév 7 10:01:36 CET 2003 +// Author : Christian CAREMOLI, Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2003 +// $Header$ +//============================================================================= + +#include "PyInterp_PyQt.h" + +#include "utilities.h" + +extern "C" PyObject * PyEval_EvalCode(PyObject *co, PyObject *g, PyObject *l); + +/*! + * constructor : the main SALOME Python interpreter is used for PyQt GUI. + * calls initialize method defined in base class, which calls virtual methods + * initstate & initcontext redefined here + */ +PyInterp_PyQt::PyInterp_PyQt() +{ + initialize(); +} + +PyInterp_PyQt::~PyInterp_PyQt() +{ +} + +void PyInterp_PyQt::initState() +{ + salomeAcquireLock(); //acquire python global lock (one for all interpreters) + SCRUTE(PyInterp_base::_gtstate); + _tstate=PyInterp_base::_gtstate; + PyThreadState_Swap(_tstate); + SCRUTE(_tstate); +} + +void PyInterp_PyQt::initContext() +{ + _g = PyDict_New(); // create interpreter dictionnary context + PyObject *bimod = PyImport_ImportModule("__builtin__"); + PyDict_SetItemString(_g, "__builtins__", bimod); + Py_DECREF(bimod); +} + +void PyInterp_PyQt::enter() +{ + PyThreadState *oldstate; + SCRUTE(_tstate); + salomeAcquireLock(); + oldstate=PyThreadState_Swap(_tstate); + SCRUTE(oldstate); +} + +void PyInterp_PyQt::quit() +{ + MESSAGE("quit"); + salomeReleaseLock(); + MESSAGE("fin quit"); +} + +void PyInterp_PyQt::run(const char *command) +{ + PyObject *code,*r; + enter(); + MESSAGE("compile"); + code=Py_CompileString((char *)command,"PyGUI",Py_file_input); + if (code == NULL) + { + /* + Une erreur s est produite en general SyntaxError + */ + PyErr_Print(); + quit(); + return; + } + r = PyEval_EvalCode(code,_g,_g); + Py_DECREF(code); + if (r==NULL) + { + /* + Une erreur s est produite a l execution + */ + PyErr_Print(); + quit(); + return; + } + Py_DECREF(r); + quit(); +} + diff --git a/src/SALOMEGUI/PyInterp_PyQt.h b/src/SALOMEGUI/PyInterp_PyQt.h new file mode 100644 index 000000000..3c8b18465 --- /dev/null +++ b/src/SALOMEGUI/PyInterp_PyQt.h @@ -0,0 +1,29 @@ +//============================================================================= +// File : PyInterp_PyQt.h +// Created : ven fév 7 10:01:36 CET 2003 +// Author : Christian CAREMOLI, Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2003 +// $Header$ +//============================================================================= + +#ifndef _PYINTERP_PYQT_H_ +#define _PYINTERP_PYQT_H_ + +#include "PyInterp_base.h" + +class PyInterp_PyQt : public PyInterp_base +{ + public: + PyInterp_PyQt(); + ~PyInterp_PyQt(); + void enter(); + void quit(); + void run(const char *command); + + protected: + void initState(); + void initContext(); +}; + +#endif diff --git a/src/SALOMEGUI/PyInterp_base.cxx b/src/SALOMEGUI/PyInterp_base.cxx new file mode 100644 index 000000000..52aa2c19f --- /dev/null +++ b/src/SALOMEGUI/PyInterp_base.cxx @@ -0,0 +1,427 @@ +using namespace std; +//============================================================================= +// File : PyInterp_base.cxx +// Created : ven fév 7 10:01:36 CET 2003 +// Author : Christian CAREMOLI, Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2003 +// $Header$ +//============================================================================= + +#include "PyInterp_base.h" +#include "utilities.h" +#include +#include +#include + +using namespace std; + +extern "C" PyObject * PyEval_EvalCode(PyObject *co, PyObject *g, PyObject *l); + +static PyThreadState *savedThreadState = NULL; + +/*! + * We have our own routines which are identical to the SIP routines + * to not depend from SIP software evolutions + */ + +extern "C" void salomeAcquireLock() +{ + MESSAGE("salomeAcquireLock"); + PyEval_RestoreThread(savedThreadState); + savedThreadState = NULL; +} + +extern "C" void salomeReleaseLock() +{ + MESSAGE("salomeReleaseLock"); + savedThreadState = PyEval_SaveThread(); +} + +extern "C" int salomeCondAcquireLock() +{ + MESSAGE("salomeCondAcquireLock"); + if(savedThreadState != NULL) + { + /* + * If savedThreadState is not NULL, Python global lock is not already acquired + * We acquire it + * and return 1 to the caller + */ + salomeAcquireLock(); + //MESSAGE("We got it (the lock)"); + return 1; + } + /* + * If savedThreadState is NULL, Python global lock is already acquired + * We don't acquire or release it + * We return 0 to the caller + * CAUTION : it's only true when there is no event programming running (Tkinter, PyQt) + */ + return 0; +} + +extern "C" void salomeCondReleaseLock(int rellock) +{ + MESSAGE("salomeCondReleaseLock"); + if(rellock ) + salomeReleaseLock(); +} + +// main python interpreter + +PyThreadState *PyInterp_base::_gtstate=0; // force 0 before execution +int PyInterp_base::_argc=1; +char* PyInterp_base::_argv[] = {""}; + +PyObject *PyInterp_base::builtinmodule=NULL; +PyObject *PyInterp_base::salome_shared_modules_module=NULL; + +void init_python() +{ + SCRUTE(PyInterp_base::_gtstate); + if (PyInterp_base::_gtstate) return; + Py_Initialize(); // Initialize the interpreter + PyEval_InitThreads(); // Create (and acquire) the interpreter lock + PySys_SetArgv(PyInterp_base::_argc,PyInterp_base::_argv); // initialize sys.argv + PyInterp_base::_gtstate = PyThreadState_Get(); + SCRUTE(PyInterp_base::_gtstate); + + // /* + // * Import __builtin__ module and store it to use it with all sub-interpreters + // * This hack could be used with event programming (PyQt) to avoid errors + // * encountered with incoherent builtins + // */ + + // PyInterp_base::builtinmodule =PyImport_ImportModule("__builtin__"); + // SCRUTE(PyInterp_base::builtinmodule->ob_refcnt); + + /* + * Import salome_shared_modules module and store it to use it with all sub-interpreters + */ + + PyInterp_base::salome_shared_modules_module =PyImport_ImportModule("salome_shared_modules"); + SCRUTE(PyInterp_base::salome_shared_modules_module->ob_refcnt); + + salomeReleaseLock(); +} + +/*! + * This function compiles a string (command) and then evaluates it in the dictionnary + * context if possible. + * Returns : + * -1 : fatal error + * 1 : incomplete text + * 0 : complete text executed with success + */ + +int compile_command(const char *command,PyObject *context) +{ + SCRUTE(command); + PyObject *m,*v,*r; + + m=PyImport_AddModule("codeop"); + if(m == NULL) + { + /* + * Fatal error. No way to go on. + */ + PyErr_Print(); + return -1; + } + v= PyObject_CallMethod(m,"compile_command","s",command); + if (v == NULL) + { + /* + * Error encountered. It could be SyntaxError + */ + PyErr_Print(); + return -1; + } + else if (v == Py_None) + { + /* + * Incomplete text we return 1 : we need a complete text to execute + */ + return 1; + } + else + { + /* + * Complete and correct text. We evaluate it. + */ + r = PyEval_EvalCode(v,context,context); + Py_DECREF(v); + if (r==NULL) + { + /* + * Execution error. We return -1 + */ + PyErr_Print(); + return -1; + } + Py_DECREF(r); + /* + * The command has been successfully executed. Return 0 + */ + return 0; + } +} + +/*! + * basic constructor here : herited classes constructors must call initalize() method + * defined here. + */ + +PyInterp_base::PyInterp_base():_tstate(0),_vout(0),_verr(0),_g(0),_atFirst(true) +{ + MESSAGE("PyInterp_base::PyInterp_base()"); +} + +PyInterp_base::~PyInterp_base() +{ + MESSAGE("PyInterp_base::~PyInterp_base()"); + salomeAcquireLock(); + PyThreadState_Swap(_tstate); + Py_EndInterpreter(_tstate); + salomeReleaseLock(); +} + +/*! + * Must be called by herited classes constructors. initialize() calls virtuals methods + * initstate & initcontext, not defined here in base class. initstate & initcontext methods + * must be implemented in herited classes, following the Python interpreter policy + * (mono or multi interpreter...). + */ +void PyInterp_base::initialize() +{ + MESSAGE("PyInterp_base::initialize()"); + PyObject *m,*v,*c; + + _history.clear(); // start a new list of user's commands + _ith = _history.begin(); + + init_python(); + + initState(); + + initContext(); + + m=PyImport_ImportModule("codeop"); // used to interpret & compile commands + if(m == NULL) + { + MESSAGE("Problem..."); + ASSERT(0); + PyErr_Print(); + salomeReleaseLock(); + return; + } + Py_DECREF(m); + + /* + * Create cStringIO to capture stdout and stderr + */ + //PycString_IMPORT; + PycStringIO=(PycStringIO_CAPI *)xxxPyCObject_Import("cStringIO", "cStringIO_CAPI"); + _vout=PycStringIO->NewOutput(128); + _verr=PycStringIO->NewOutput(128); + + // All the initRun outputs are redirected to the standard output (console) + this->initRun(); + + // We go out of Python world to enter the C++ world. Release the Python global lock + salomeReleaseLock(); + SCRUTE(_tstate); + SCRUTE(this); +} + +string PyInterp_base::getbanner() +{ + MESSAGE("PyInterp_base::getbanner()"); + string banner = "Python "; + banner = banner + Py_GetVersion() + " on " + Py_GetPlatform() ; + banner = banner + "\ntype help to get general information on environment\n"; + return banner.c_str(); +} + +int PyInterp_base::initRun() +{ + MESSAGE("PyInterp_base::initRun()"); + PySys_SetObject("stderr",_verr); + PySys_SetObject("stdout",_vout); + + PyObject *v = PyObject_CallMethod(_verr,"reset",""); + Py_XDECREF(v); + v = PyObject_CallMethod(_vout,"reset",""); + Py_XDECREF(v); + + + PyObject *m; + m = PyImport_GetModuleDict(); + + PySys_SetObject("stdout",PySys_GetObject("__stdout__")); + PySys_SetObject("stderr",PySys_GetObject("__stderr__")); + + MESSAGE(this->getvout()); + MESSAGE(this->getverr()); + + return 0; +} + +void PyInterp_base::enter() +{ + MESSAGE("PyInterp_base::enter()"); + salomeAcquireLock(); + PyThreadState_Swap(_tstate); +} + +void PyInterp_base::quit() +{ + MESSAGE("PyInterp_base::quit()"); + salomeReleaseLock(); +} + +void PyInterp_base::basicRun(const char *command) +{ + SCRUTE(command); + PyObject *code,*r; + enter(); + code=Py_CompileString((char *)command,"PyInterp_base",Py_file_input); + if (code == NULL) + { + /* + * Caught an error : SyntaxError + * Print it and quit + */ + PyErr_Print(); + quit(); + return; + } + r = PyEval_EvalCode(code,_g,_g); + Py_DECREF(code); + if (r==NULL) + { + /* + * Caught an error during execution + * Print it and quit + */ + PyErr_Print(); + quit(); + return; + } + Py_DECREF(r); + quit(); +} + +int PyInterp_base::run(const char *command) +{ + SCRUTE(command); + int ret = 0; + if (_atFirst) + { + _atFirst = false; + ret = this->simpleRun("from Help import *"); + MESSAGE(this->getvout()) + MESSAGE(this->getverr()) + if (ret != 0) return ret; + ret = this->simpleRun("import salome"); + MESSAGE(this->getvout()); + MESSAGE(this->getverr()) + if (ret != 0) return ret; + } + ret = this->simpleRun(command); + return ret; +} + +int PyInterp_base::simpleRun(const char *command) +{ + SCRUTE(command); + PyObject *v,*m,*r,*g; + char *output; + int ier=0; + string s_com = command; + + if (s_com.size() > 0) + { + _history.push_back(s_com); + _ith = _history.end(); + SCRUTE(_history.back()); + } + + // SCRUTE(this); + // SCRUTE(_tstate); + // We come from C++ to enter Python world + // We need to acquire the Python global lock + salomeAcquireLock(); + // Restore the sub interpreter thread state : this._tstate + PyThreadState_Swap(_tstate); + + /* + Reset redirected outputs before treatment + */ + PySys_SetObject("stderr",_verr); + PySys_SetObject("stdout",_vout); + + v = PyObject_CallMethod(_verr,"reset",""); + Py_XDECREF(v); + v = PyObject_CallMethod(_vout,"reset",""); + Py_XDECREF(v); + + ier=compile_command(command,_g); + + // Outputs are redirected on standards outputs (console) + PySys_SetObject("stdout",PySys_GetObject("__stdout__")); + PySys_SetObject("stderr",PySys_GetObject("__stderr__")); + + // We go back to the C++ world. Release the lock. + salomeReleaseLock(); + return ier; +} + +static string vout_buffer; +static string verr_buffer; + +char * PyInterp_base::getverr() +{ + MESSAGE("PyInterp_base::getverr"); + PyObject *v; + v=PycStringIO->cgetvalue(_verr); + verr_buffer=PyString_AsString(v); + Py_DECREF(v); + return (char *)verr_buffer.c_str(); +} + +char * PyInterp_base::getvout() +{ + MESSAGE("PyInterp_base::getvout"); + PyObject *v; + v=PycStringIO->cgetvalue(_vout); + vout_buffer=PyString_AsString(v); + Py_DECREF(v); + return (char *)vout_buffer.c_str(); +} + +const char * PyInterp_base::getPrevious() +{ + MESSAGE("PyInterp_base::getPrevious"); + if (_ith != _history.begin()) + { + _ith--; + return (*_ith).c_str(); + } + else + return BEGIN_HISTORY_PY; +} + +const char * PyInterp_base::getNext() +{ + MESSAGE("PyInterp_base::getNext"); + if (_ith != _history.end()) + { + _ith++; + } + if (_ith == _history.end()) + return TOP_HISTORY_PY; + else + return (*_ith).c_str(); +} diff --git a/src/SALOMEGUI/PyInterp_base.h b/src/SALOMEGUI/PyInterp_base.h new file mode 100644 index 000000000..81a76c5e6 --- /dev/null +++ b/src/SALOMEGUI/PyInterp_base.h @@ -0,0 +1,74 @@ +//============================================================================= +// File : PyInterp_base.h +// Created : ven fév 7 10:01:36 CET 2003 +// Author : Christian CAREMOLI, Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2003 +// $Header$ +//============================================================================= + +#ifndef _PYINTERP_BASE_H_ +#define _PYINTERP_BASE_H_ + +using namespace std; +#include +#include +#include +#include + +#define TOP_HISTORY_PY "--- top of history ---" +#define BEGIN_HISTORY_PY "--- begin of history ---" + +/*! + * We have our own routines which are identical to the SIP routines + * to not depend from SIP software evolutions + */ + +extern "C" void salomeAcquireLock(); +extern "C" void salomeReleaseLock(); +extern "C" int salomeCondAcquireLock(); +extern "C" void salomeCondReleaseLock(int rellock); + +/*! this class can only be used with derivation : + * 2 pure virtual methods, initstate() & initcontext() + */ + +class PyInterp_base +{ + public: + static PyThreadState *_gtstate; + static int _argc; + static char* _argv[]; + static PyObject *builtinmodule; + static PyObject *salome_shared_modules_module; + + PyInterp_base(); + ~PyInterp_base(); + void initialize(); + int run(const char *command); + char * getverr(); + char * getvout(); + string getbanner(); + const char * getPrevious(); + const char * getNext(); + void enter(); + void quit(); + void basicRun(const char *command); + + protected: + PyThreadState * _tstate; + PyObject * _vout; + PyObject * _verr; + PyObject * _g; + list _history; + list ::iterator _ith; + bool _atFirst; + + int simpleRun(const char* command); + int initRun(); + + virtual void initState() = 0; + virtual void initContext() =0; +}; + +#endif diff --git a/src/SALOMEGUI/QAD.h b/src/SALOMEGUI/QAD.h new file mode 100644 index 000000000..c0d237219 --- /dev/null +++ b/src/SALOMEGUI/QAD.h @@ -0,0 +1,51 @@ +/*********************************************************** +** File: QAD.h +** Descr: General definitions for QAD +** Created: UI team, 20.09.00 +************************************************************/ +#ifndef QAD_H +#define QAD_H + +#include + +#if defined QAD_DLL +#if defined WNT +#define QAD_EXPORT _declspec( dllexport ) +#else +#define QAD_EXPORT +#endif +#else +#if defined WNT +#define QAD_EXPORT _declspec( dllimport ) +#else +#define QAD_EXPORT +#endif +#endif + +#if defined SOLARIS +#define bool int +#define false 0 +#define true 1 +#endif + +#if defined WNT +#pragma warning ( disable: 4251 ) +#endif + +#if defined (_DEBUG) +#define QAD_ASSERT(x) assert(x) +#define QAD_ASSERT_DEBUG_ONLY(x) assert(x) + +#else /* _DEBUG */ +#define QAD_ASSERT(x) x +#define QAD_ASSERT_DEBUG_ONLY(x) +#endif + +/* Message box button's IDs */ +#define QAD_OK 1 +#define QAD_CANCEL 2 +#define QAD_YES 3 +#define QAD_NO 4 +#define QAD_HELP 5 + +#endif diff --git a/src/SALOMEGUI/QAD_Application.cxx b/src/SALOMEGUI/QAD_Application.cxx new file mode 100644 index 000000000..96b49170b --- /dev/null +++ b/src/SALOMEGUI/QAD_Application.cxx @@ -0,0 +1,1287 @@ +using namespace std; +// File : QAD_Application.cxx +// Created : UI team, 22.09.00 +// Descr : Study manager of QAD-based application + +// Modified : Mon Dec 03 13:21:50 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + +/*! + \class QAD_Application QAD_Application.h + \brief Study manager for QAD-based application. +*/ + +#include "QAD.h" +#include "QAD_Tools.h" +#include "QAD_Desktop.h" +#include "QAD_Application.h" +#include "QAD_MessageBox.h" +#include "QAD_Config.h" +#include "SALOMEGUI_AboutDlg.h" +#include "SALOME_Selection.h" + +#include +#include CORBA_CLIENT_HEADER(SALOME_Exception) + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Open CASCADE Includes +#include +#include +#include + +static bool checkPermission(QString fileName) { + if ( QFile::exists( fileName ) ) { + // if file exists - check it for writeability + if ( !QFileInfo( fileName ).isWritable() ) { + return false; + } + } + else { + // if file doesn't exist - try to create it + QFile qf( fileName ); + if ( !qf.open( IO_WriteOnly ) ) { + return false; + } + else { + qf.close(); + qf.remove(); + } + } + return true; +} + +QAD_Desktop* QAD_Application::desktop = 0; + +/*! + Registers a new application object and + adds it to the desktop [ static ] +*/ +bool QAD_Application::addToDesktop( QAD_Application* app, SALOME_NamingService* name_service ) +{ + /* create CAF application */ + if ( !app->initApp(name_service) ) + return false; + + /* create the only desktop */ + if ( !app->getDesktop() ) + { + app->createDesktop(name_service); + emit app->desktopCreated(); + } + + /* add application to the desktop */ + desktop->addApplication( app ); + return true; +} + +/*! + Runs the application [ static ] +*/ +void QAD_Application::run() +{ + /* at least one application must be on desktop */ + QAD_ASSERT_DEBUG_ONLY ( desktop ); + desktop->showDesktop(); +} + + +/*! + Returns reference to main desktop [ static ] +*/ +QAD_Desktop* QAD_Application::getDesktop() +{ + return desktop; +} + +/*! + Returns standard Palette [ static ] +*/ +QPalette QAD_Application::getPalette(bool alternative) +{ +/* $$$ ---> commented 20.09.2002 - application uses global palette but little changed if is true + QPalette pal; + QColorGroup cg; + cg.setColor( QColorGroup::Foreground, Qt::black ); + cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Light, Qt::white ); + cg.setColor( QColorGroup::Midlight, QColor( 223, 223, 223) ); + cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); + cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Text, Qt::black ); + cg.setColor( QColorGroup::BrightText, Qt::white ); + cg.setColor( QColorGroup::ButtonText, Qt::black ); + cg.setColor( QColorGroup::Base, QColor( 255,255,220 ) ); + cg.setColor( QColorGroup::Background, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Shadow, Qt::black ); + cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); + cg.setColor( QColorGroup::HighlightedText, Qt::white ); + pal.setActive( cg ); + cg.setColor( QColorGroup::Foreground, Qt::black ); + cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Light, Qt::white ); + cg.setColor( QColorGroup::Midlight, QColor( 220, 220, 220) ); + cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); + cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Text, Qt::black ); + cg.setColor( QColorGroup::BrightText, Qt::white ); + cg.setColor( QColorGroup::ButtonText, Qt::black ); + cg.setColor( QColorGroup::Base, QColor( 255,255,220 ) ); + cg.setColor( QColorGroup::Background, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Shadow, Qt::black ); + cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); + cg.setColor( QColorGroup::HighlightedText, Qt::white ); + pal.setInactive( cg ); + cg.setColor( QColorGroup::Foreground, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Light, Qt::white ); + cg.setColor( QColorGroup::Midlight, QColor( 220, 220, 220) ); + cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); + cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Text, Qt::black ); + cg.setColor( QColorGroup::BrightText, Qt::white ); + cg.setColor( QColorGroup::ButtonText, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Base, QColor( 255,255,220 ) ); + cg.setColor( QColorGroup::Background, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Shadow, Qt::black ); + cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); + cg.setColor( QColorGroup::HighlightedText, Qt::white ); + pal.setDisabled( cg ); + $$$ <--------------------------------------------------------------------- */ + QPalette pal = QApplication::palette(); + // $$$ --> this prevents qt bug - bag child window's icon drawing (not transparent) + // when it is maximized + pal.setColor(QPalette::Active, QColorGroup::Background, pal.active().button()); + pal.setColor(QPalette::Inactive, QColorGroup::Background, pal.inactive().button()); + pal.setColor(QPalette::Disabled, QColorGroup::Background, pal.disabled().button()); + // $$$ <--- + if (alternative) { + // alternative palette is used for Object Browser, PyEditor, Message and Help windows + QColorGroup cg = pal.active(); + cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); + cg.setColor( QColorGroup::HighlightedText, Qt::white ); + cg.setColor( QColorGroup::Base, QColor( 255,255,220 ) ); + cg.setColor( QColorGroup::Text, Qt::black ); + pal.setActive ( cg ); + cg = pal.inactive(); + cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); + cg.setColor( QColorGroup::HighlightedText, Qt::white ); + cg.setColor( QColorGroup::Base, QColor( 255,255,220 ) ); + cg.setColor( QColorGroup::Text, Qt::black ); + pal.setInactive( cg ); + cg = pal.disabled(); + cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); + cg.setColor( QColorGroup::HighlightedText, Qt::white ); + cg.setColor( QColorGroup::Base, QColor( 255,255,220 ) ); + cg.setColor( QColorGroup::Text, Qt::black ); + pal.setDisabled( cg ); + } + return pal; +} + +/*! + Constructor +*/ +QAD_Application::QAD_Application( const QString& format, const QString& description, + const QString& extension ) : +myActiveStudy( 0 ), +myStudyFormat( format ), +myStudyExtension( extension ), +myStudyDescription( description ) +{ + /* actions are stored in vectors only */ + myEditActions.setAutoDelete ( true ); + myViewActions.setAutoDelete ( true ); + myHelpActions.setAutoDelete ( true ); + + /* studies are managed by me */ + myStudies.setAutoDelete( true ); + + /* load resources for all QAD */ + QAD_ResourceMgr* resMgr = QAD_Desktop::getResourceManager(); + if ( !resMgr ) resMgr = QAD_Desktop::createResourceManager(); + QString message; + resMgr->loadResources( "QAD", message ); + resMgr->loadResources( "CLIENT", message ); + + /* set default icon */ + myIcon = resMgr->loadPixmap( "CLIENT", tr("ICON_APP_DEFAULTICON") ); + myName = tr("APP_DEFAULTTITLE"); + + /* We need to know that desktop is created in order + to have some additional internal initialization */ + QAD_ASSERT( connect( this, SIGNAL(desktopCreated()), this, + SLOT(onDesktopCreated()) )); +} + +/*! + Destructor +*/ +QAD_Application::~QAD_Application () +{ + myEditActions.clear(); + myViewActions.clear(); + myHelpActions.clear(); + QMap::Iterator it; + for ( it = myToolBars.begin(); it != myToolBars.end(); it++ ) { + delete it.data(); + } + myToolBars.clear(); +} + +/*! + Creates the main desktop( called once ) +*/ +bool QAD_Application::createDesktop( SALOME_NamingService* name_service ) +{ + QAD_ASSERT_DEBUG_ONLY( !desktop ); + desktop = new QAD_Desktop ( name_service ); + return ( desktop != NULL ); +} + +/*! + Creates the actions provided by this application + ( internal ) +*/ +void QAD_Application::createActions() +{ + /* Basic application provides only Undo/Redo + functionalities which is disabled by default. + All others must be added by subclasses. + */ + QAD_ResourceMgr* rmgr = QAD_Desktop::getResourceManager(); + // Undo + if ( !myEditActions.at( EditUndoId ) ) + { + QAction* editUndo = new QAction ( tr("TOT_APP_EDIT_UNDO"), + rmgr->loadPixmap( "QAD", + tr("ICON_APP_EDIT_UNDO") ), + tr("MEN_APP_EDIT_UNDO"), + CTRL+Key_Z, desktop ); + editUndo->setStatusTip ( tr("PRP_APP_EDIT_UNDO") ); + QAD_ASSERT ( connect( editUndo, SIGNAL( activated() ), this, SLOT( onUndo() ))); + myEditActions.insert( EditUndoId, editUndo ); + } + // Redo + if ( !myEditActions.at( EditRedoId ) ) + { + QAction* editRedo = new QAction ( tr("TOT_APP_EDIT_REDO"), + rmgr->loadPixmap( "QAD", tr("ICON_APP_EDIT_REDO") ), + tr("MEN_APP_EDIT_REDO"), CTRL+Key_Y, desktop ); + editRedo->setStatusTip ( tr("PRP_APP_EDIT_REDO") ); + QAD_ASSERT ( connect( editRedo, SIGNAL( activated() ), this, SLOT( onRedo() ))); + myEditActions.insert( EditRedoId, editRedo ); + } + // Copy + if ( !myEditActions.at( EditCopyId ) ) + { + QAction* editCopy = new QAction ( tr("TOT_APP_EDIT_COPY"), + rmgr->loadPixmap( "QAD", + tr("ICON_APP_EDIT_COPY") ), + tr("MEN_APP_EDIT_COPY"), + CTRL+Key_C, desktop ); + editCopy->setStatusTip ( tr("PRP_APP_EDIT_COPY") ); + QAD_ASSERT ( connect( editCopy, SIGNAL( activated() ), this, SLOT( onCopy() ))); + myEditActions.insert( EditCopyId, editCopy ); + } + // Paste + if ( !myEditActions.at( EditPasteId ) ) + { + QAction* editPaste = new QAction ( tr("TOT_APP_EDIT_PASTE"), + rmgr->loadPixmap( "QAD", + tr("ICON_APP_EDIT_PASTE") ), + tr("MEN_APP_EDIT_PASTE"), + CTRL+Key_V, desktop ); + editPaste->setStatusTip ( tr("PRP_APP_EDIT_PASTE") ); + QAD_ASSERT ( connect( editPaste, SIGNAL( activated() ), this, SLOT( onPaste() ))); + myEditActions.insert( EditPasteId, editPaste ); + } + // Update action state + updateActions(); +} + +/*! + Enables/disables the actions according to the + application state +*/ +void QAD_Application::updateActions() +{ + QAD_ASSERT_DEBUG_ONLY( !myEditActions.isEmpty() ); + if ( myActiveStudy ) { + myEditActions.at( EditUndoId )->setEnabled( myActiveStudy->canUndo() ); + myEditActions.at( EditRedoId )->setEnabled( myActiveStudy->canRedo() ); + myEditActions.at( EditCopyId )->setEnabled( canCopy() ); + myEditActions.at( EditPasteId )->setEnabled( canPaste() ); + } + else { + myEditActions.at( EditUndoId )->setEnabled( false ); + myEditActions.at( EditRedoId )->setEnabled( false ); + myEditActions.at( EditCopyId )->setEnabled( false ); + myEditActions.at( EditPasteId )->setEnabled( false ); + } +} + +/*! + Returns the aplication name +*/ +const QString& QAD_Application::getApplicationName() const +{ + return myName; +} + +/*! + Returns the application icon +*/ +const QPixmap& QAD_Application::getApplicationIcon() const +{ + return myIcon; +} + +/*! + Returns the study description +*/ +const QString& QAD_Application::getStudyDescription() const +{ + return myStudyDescription; +} + +/*! + Returns the CAF study format +*/ +const QString& QAD_Application::getStudyFormat() const +{ + return myStudyFormat; +} + +/*! + Returns the extension of supported type of files +*/ +const QString& QAD_Application::getStudyExtension() const +{ + return myStudyExtension; +} + +/*! + Returns 'true' if study is opened +*/ +bool QAD_Application::isStudyOpened( const QString& studyName ) +{ + QString Name = QAD_Tools::getFileNameFromPath( studyName, false ); + return (( getStudyByName( studyName ) != NULL ) || (getStudyByName( Name ) != NULL )); +} + +/*! + Returns the study object by its name +*/ +QAD_Study* QAD_Application::getStudyByName( const QString& studyname ) +{ + for ( QAD_Study* study = myStudies.first(); study; study = myStudies.next() ) + { + if ( (studyname.compare( study->getPath() ) == 0 ) || + (studyname.compare( study->getTitle() ) == 0 )) + return study; + } + return NULL; +} + +/*! + Returns vector of all opened studies +*/ +QList& QAD_Application::getStudies() +{ + return myStudies; +} + +/*! + Adds the study to the list of opened studies + and set listeners for the study signals. +*/ +void QAD_Application::addStudy( QAD_Study* study ) +{ + if ( !study ) return; + + QAD_ASSERT( connect(study,SIGNAL(docClosing(QAD_Study*)),desktop, + SLOT(onCloseStudy(QAD_Study*))) ); + myStudies.append( study ); +} + +/*! + Removes the study from the list of opened studies +*/ +void QAD_Application::removeStudy( QAD_Study* study ) +{ + if ( study ) + { + /* close and destroy */ + if ( study == myActiveStudy ) + myActiveStudy = 0; + myStudies.removeRef( study ); + } +} + +/*! + Activates 'About' dialog +*/ +void QAD_Application::helpAbout() +{ + /* just calls QAD_Desktop::helpAbout() but can have own implementation */ + getDesktop()->helpAbout(); +} + +/*! + Activates search in help +*/ +void QAD_Application::helpSearch() +{ + /* just calls QAD_Desktop::helpSearch() but can have own implementation */ + getDesktop()->helpSearch(); +} + +/*! + Activates help contents +*/ +void QAD_Application::helpContents() +{ + /* just calls QAD_Desktop::helpContents() but can have own implementation */ + getDesktop()->helpContents(); +} + +/*! + Customizes menu "File" for the active application +*/ +void QAD_Application::updateFilePopup( QPopupMenu* menu, bool add, int index ) +{ + if ( !menu ) return; + +#ifdef DEBUG + /* ensure that 'add' command is followed by 'remove' */ + static bool isAdded = false; + QAD_ASSERT_DEBUG_ONLY ( (add && !isAdded) || (!add && isAdded) ); + isAdded = add; +#endif + onUpdateFileActions( menu, add, index ); +} + +/*! + Customizes menu "Edit" for the active application +*/ +void QAD_Application::updateEditPopup( QPopupMenu* menu, bool add, int index ) +{ + if ( !menu ) return; + +#ifdef DEBUG + /* ensure that 'add' command is followed by 'remove' */ + static bool isAdded = false; + QAD_ASSERT_DEBUG_ONLY ( (add && !isAdded) || (!add && isAdded) ); + isAdded = add; +#endif + onUpdateEditActions( menu, add, index ); +} + +/*! + Customizes menu "View" for the active application +*/ +void QAD_Application::updateViewPopup( QPopupMenu* menu, bool add, int index ) +{ + if ( !menu ) return; + +#ifdef DEBUG + /* ensure that 'add' command is followed by 'remove' */ + static bool isAdded = false; + QAD_ASSERT_DEBUG_ONLY ( (add && !isAdded) || (!add && isAdded) ); + isAdded = add; +#endif + onUpdateViewActions( menu, add, index ); +} + +/*! + Customizes menu "Help" for the active application +*/ +void QAD_Application::updateHelpPopup( QPopupMenu* menu, bool add, int index ) +{ + if ( !menu ) return; +#ifdef DEBUG + /* ensure that 'add' command is followed by 'remove' */ + static bool isAdded = false; + QAD_ASSERT_DEBUG_ONLY ( (add && !isAdded) || (!add && isAdded) ); + isAdded = add; +#endif + onUpdateHelpActions ( menu, add, index ); +} + +/*! + Customizes the main menu bar to add some new popup, + 'Options' or 'Tools' for example. +*/ +void QAD_Application::updateMainMenu( QMenuBar* menubar, bool add, int index ) +{ + if ( !menubar ) return; +#ifdef DEBUG + /* ensure that 'add' command is followed by 'remove' */ + static bool isAdded = false; + QAD_ASSERT_DEBUG_ONLY ( (add && !isAdded) || (!add && isAdded) ); + isAdded = add; +#endif + onUpdateMainMenuItems ( menubar, add, index ); +} + +/*! + Adds specific application buttons for standard toolbar +*/ +void QAD_Application::updateToolBars( bool add ) +{ +#ifdef DEBUG + /* ensure that 'add' command is followed by 'remove' */ + static bool isAdded = false; + QAD_ASSERT_DEBUG_ONLY ( (add && !isAdded) || (!add && isAdded) ); + isAdded = add; +#endif + onUpdateToolBars ( add ); +} + +/*! + Customizes the status bar +*/ +void QAD_Application::updateStatusBar( QStatusBar* statusBar, bool add ) +{ +#ifdef DEBUG + /* ensure that 'add' command is followed by 'remove' */ + static bool isAdded = false; + QAD_ASSERT_DEBUG_ONLY ( (add && !isAdded) || (!add && isAdded) ); + isAdded = add; +#endif + onUpdateStatusBar( statusBar, add ); +} + +/*! + Creates toolbar to be managed by QAD_Application +*/ +QToolBar* QAD_Application::createToolBar( int id, + const QString& label, Dock dock, + bool dockTop, bool dockBottom, + bool dockLeft, bool dockRight, + bool dockMinimized, bool dockTornOff ) +{ + QToolBar* tb = 0; + if ( getDesktop() ) { + tb = new QToolBar( label, getDesktop(), 0 ); + tb->setCloseMode( QDockWindow::Undocked ); + getDesktop()->setDockEnabled( tb, DockTop, dockTop ); + getDesktop()->setDockEnabled( tb, DockBottom, dockBottom ); + getDesktop()->setDockEnabled( tb, DockLeft, dockLeft ); + getDesktop()->setDockEnabled( tb, DockRight, dockRight ); + getDesktop()->setDockEnabled( tb, DockMinimized, dockMinimized ); + getDesktop()->setDockEnabled( tb, DockTornOff, dockTornOff ); + getDesktop()->addDockWindow( tb, label, dock ); + getDesktop()->setAppropriate( tb, false ); + tb->hide(); + removeToolBar( id ); + myToolBars.insert( id, tb); + } + return tb; +} + +/*! + Removes toolbar +*/ +void QAD_Application::removeToolBar( int id ) +{ + QToolBar* tb = myToolBars[ id ]; + if ( tb ) { + myToolBars.remove( id ); + getDesktop()->removeDockWindow( tb ); + delete tb; + } +} + +/*! + Gets toolbar by id +*/ +QToolBar* QAD_Application::getToolBar( int id ) +{ + return myToolBars[ id ]; +} + +/*! + Gets all toolbars managed by QAD_Applica +*/ +QList QAD_Application::getToolBars() +{ + QList toolbars; + QMap::Iterator it; + for ( it = myToolBars.begin(); it != myToolBars.end(); it++ ) + toolbars.append( it.data() ); + return toolbars; +} + +/*! + Called by 'updateMainMenu' when application is activated/deactivated. + Redefine to insert/remove the actions provided by the application + to the main menu at 'index'. + Returns the number of added/removed items. +*/ +int QAD_Application::onUpdateMainMenuItems ( QMenuBar* mb, bool add, int index ) +{ + return 0; +} + +/*! + Called by 'updateFilePopup' when application is activated/deactivated. + Redefine to insert/remove the actions provided by the application to + 'File' menu of the desktop at 'index'. + Returns the number of added/removed items. +*/ +int QAD_Application::onUpdateFileActions ( QPopupMenu* popup, bool add, int index ) +{ + return 0; +} + +/*! + Called by 'updateEditPopup' when application is activated/deactivated. + Redefine to insert/remove the actions provided by the application to + 'Edit' menu of the desktop at 'index'. + Returns the number of added/removed items. +*/ +int QAD_Application::onUpdateEditActions ( QPopupMenu* popup, bool add, int index ) +{ + QAD_ASSERT_DEBUG_ONLY( !myEditActions.isEmpty() ); + QToolBar* tb = getDesktop()->getStdToolBar(); + QAction* undo = myEditActions.at( EditUndoId ); + QAction* redo = myEditActions.at( EditRedoId ); + QAction* copy = myEditActions.at( EditCopyId ); + QAction* paste = myEditActions.at( EditPasteId ); + if ( add ) + { + undo->addTo( popup ); + index++; + redo->addTo( popup ); + index++; + copy->addTo( popup ); + index++; + paste->addTo( popup ); + index++; + undo->addTo( tb ); + redo->addTo( tb ); + copy->addTo( tb ); + paste->addTo( tb ); + } + else + { + popup->removeItemAt(index); + popup->removeItemAt(index); + popup->removeItemAt(index); + popup->removeItemAt(index); + + undo->removeFrom( tb ); + redo->removeFrom( tb ); + copy->removeFrom( tb ); + paste->removeFrom( tb ); + } + return index; +} + +/*! + Called by 'updateViewPopup' when application is activated/deactivated. + Redefine to insert/remove the actions provided by the application to the + 'View' menu of the desktop at 'index'. + Returns the number of added/removed items. +*/ +int QAD_Application::onUpdateViewActions ( QPopupMenu* popup, bool add, int index ) +{ + return 0; +} + +/*! + Called by 'updateHelpPopup' when application is activated/deactivated. + Redefine to insert/remove the actions provided by the application + to 'Help' menu of the desktop at 'index'. + Returns the number of added/removed items. +*/ +int QAD_Application::onUpdateHelpActions ( QPopupMenu* popup, bool add, int index ) +{ + return 0; +} + +/*! + Called by 'updateStatusBar' when application is activated/deactivated. + Redefine to customize status bar. +*/ +void QAD_Application::onUpdateStatusBar( QStatusBar* sb, bool activate ) +{ +} + +/*! + Called by 'updateToolBars' when application is activated/deactivated. + Redefine to show your specific toolbars on the desktop. +*/ +void QAD_Application::onUpdateToolBars( bool activate ) +{ + QMap::Iterator it; + for ( it = myToolBars.begin(); it != myToolBars.end(); it++ ) { + activate ? it.data()->show() : it.data()->hide(); + getDesktop()->setAppropriate( it.data(), activate ); + } +} + +//=======================================================================// +// Study management // +//=======================================================================// +/*! + Returns the active study +*/ +QAD_Study* QAD_Application::getActiveStudy() const +{ + return myActiveStudy; +} + +//=======================================================================// +// Operation management // +//=======================================================================// +/*! + Runs a new operation of class appointed +*/ +void QAD_Application::startOperation( QAD_Operation* op ) +{ + if ( op ) op->start(); +} + + +//=======================================================================// +// Study management // +//=======================================================================// +/*! + Creates new study +*/ +QAD_Study* QAD_Application::newStudy() +{ + QAD_Study* newStudy = 0; + QAD_ASSERT_DEBUG_ONLY( !myStudyMgr->_is_nil() ); + QApplication::setOverrideCursor( Qt::waitCursor ); + try { + /* create QAD study*/ + QString StudyName = getDesktop()->getNewStudyName(); + + CORBA::Object_var obj = getDesktop()->getNameService()->Resolve("/myStudyManager"); + SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj); + ASSERT(! CORBA::is_nil(myStudyMgr)); + SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies(); + + bool exist = true; + + while ( exist ) { + exist = false; + for (unsigned int ind = 0; ind < List->length();ind++) { + QString NameS = QAD_Tools::getFileNameFromPath( QString( List[ind] ), false ); + if ( NameS.compare( StudyName ) == 0 ) { + StudyName = getDesktop()->getNewStudyName(); + exist = true; + break; + } + } + } + + if (getStudyByName ( StudyName ) != NULL ) + { + /* create StudyDS */ + SALOMEDS::Study_var aStudy = myStudyMgr->NewStudy(getDesktop()->getNewStudyName()); + newStudy = new QAD_Study( this, aStudy, getDesktop()->getNewStudyName()); + } + else + { + /* create StudyDS */ + SALOMEDS::Study_var aStudy = myStudyMgr->NewStudy(StudyName); + newStudy = new QAD_Study( this, aStudy, StudyName); + } + + if ( newStudy->getResult() ) { + addStudy( newStudy ); + + /* activate */ + onStudyActivated( newStudy ); + + /* customization on create ( called only once )*/ + onStudyCreated( newStudy ); + + /* show */ + newStudy->show(); + + /* customization on show ( called only once ) */ + onStudyShown( newStudy ); + } + } + catch( Standard_Failure ) { + } + qApp->processEvents(); /* update desktop*/ + QApplication::restoreOverrideCursor(); + return newStudy; +} + +/*! + Loads the existed study in StudyManager +*/ +QAD_Study* QAD_Application::loadStudy( const QString& fileName ) +{ + /* connect CAF document to CAF application */ + QAD_ASSERT_DEBUG_ONLY( !myStudyMgr->_is_nil() ); + + SALOMEDS::Study_var aStudy = myStudyMgr->GetStudyByName( fileName ); + + // SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies(); +// for (unsigned int ind = 0; ind < List->length();ind++) { +// MESSAGE ( " Study index : " << List[ind] ) +// aStudy = myStudyMgr->GetStudyByName(List[ind]); +// } + + QAD_Study* loadStudy = 0; + QApplication::setOverrideCursor( Qt::waitCursor ); + try { + /* create QAD study */ + loadStudy = new QAD_Study( this, aStudy, aStudy->Name() ); + + if ( loadStudy->getResult() ) { + addStudy( loadStudy ); + + /* activate */ + onStudyActivated( loadStudy ); + + /* customisation on load ( called only once ) */ + onStudyOpened( loadStudy ); + + /* show */ + loadStudy->show(); + + /* customization on show ( called only once ) */ + onStudyShown( loadStudy ); + } + + } + catch( Standard_Failure ) { + } + qApp->processEvents(); /* update desktop*/ + QApplication::restoreOverrideCursor(); + return loadStudy; +} + +/*! + Opens the existed study +*/ +QAD_Study* QAD_Application::openStudy( const QString& fileName ) +{ +#ifdef WNT + /* Qt uses UNIX-like slashes even on WIN platform */ + QString name = QAD_Tools::unix2win( fileName ); +#else + QString name = fileName; +#endif + SALOMEDS::Study_var aStudy; + + /* connect CAF document to CAF application */ + QAD_ASSERT_DEBUG_ONLY( !myStudyMgr->_is_nil() ); + + QAD_Study* openStudy = 0; + QApplication::setOverrideCursor( Qt::waitCursor ); + try { + /* open StudyDS */ + SALOMEDS::Study_var aStudy = myStudyMgr->Open((char*) name.latin1()); + + //NRI DEBUG : 11/02/2002 + aStudy->Name( QAD_Tools::getFileNameFromPath(name,false) ); + + /* create QAD study */ + openStudy = new QAD_Study( this, aStudy, fileName ); + + if ( openStudy->getResult() ) { + addStudy( openStudy ); + + /* activate */ + onStudyActivated( openStudy ); + + /* customisation on open ( called only once ) */ + onStudyOpened( openStudy ); + + /* show */ + openStudy->show(); + + /* customization on show ( called only once ) */ + onStudyShown( openStudy ); + } + + } + // Handle SALOME::SALOME_Exception raised by SALOMEDS::StudyMgr + // Ensure that null study is returned in case of errors + catch(SALOME::SALOME_Exception&) { + if (openStudy) { + delete openStudy; + openStudy = 0; + } + } + catch( Standard_Failure ) { + } + qApp->processEvents(); /* update desktop*/ + QApplication::restoreOverrideCursor(); + return openStudy; +} + +/*! + Saves the study +*/ +bool QAD_Application::saveStudy( QAD_Study* study ) +{ + bool MultiSave = QAD_CONFIG->getSetting("Desktop:MultiFileSave") == "true"; + bool success = true; + QApplication::setOverrideCursor( Qt::waitCursor ); + try { + /* save StudyDS */ + myStudyMgr->Save(study->getStudyDocument(), MultiSave); + study->updateCaptions(); + } + catch ( Standard_Failure ) { + success = false; + } + qApp->processEvents(); /* update desktop*/ + QApplication::restoreOverrideCursor(); + return success; +} + +/*! + Saves the study in a new file +*/ +bool QAD_Application::saveAsStudy( QAD_Study* study, const QString& fileName ) +{ + bool MultiSave = QAD_CONFIG->getSetting("Desktop:MultiFileSave") == "true"; + bool success = false; +#ifdef WNT + /* Qt uses UNIX-like slashes even on WIN platform */ + QString name = QAD_Tools::unix2win( fileName ); +#else + QString name = fileName; +#endif + if ( !name.isNull() ) + { + /* check permission */ + if (!checkPermission(name)) + return false; + QApplication::setOverrideCursor( Qt::waitCursor ); + TCollection_ExtendedString fileNameExt ( (char*) name.latin1() ); + try { + /* save as StudyDS */ + myStudyMgr->SaveAs(name.latin1(), study->getStudyDocument(), MultiSave); + + study->setTitle( fileName ); + study->updateCaptions(); + success = true; + } + catch (Standard_Failure) { + } + qApp->processEvents(); /* update desktop*/ + QApplication::restoreOverrideCursor(); + } + return success; +} + +/*! + Closes the study +*/ +bool QAD_Application::closeStudy( QAD_Study* study, bool permanently /*=false*/ ) +{ + bool success = true; + /* close CAF document */ + QApplication::setOverrideCursor( Qt::waitCursor ); + try + { + SALOMEDS::Study_var aStudyDocument = study->getStudyDocument(); + + /* customization */ + onStudyClosed( study ); + + /* remove */ + removeStudy( study ); + + /* activate */ + myActiveStudy = myStudies.last(); + + /* close application when the last study is closed */ + if ( myStudies.isEmpty() ) + emit appDeactivated ( this ); + + if ( permanently ) + { + /* close StudyDS */ + myStudyMgr->Close( aStudyDocument ); + } + } + catch ( Standard_Failure ) + { + success = false; + } + qApp->processEvents(); /* update desktop*/ + QApplication::restoreOverrideCursor(); + return success; +} + +/*! + Undo operation on the active study. + Calls undo( activeStudy ). +*/ +bool QAD_Application::onUndo() +{ + bool ok = undo( myActiveStudy ); + updateActions(); /* enable/disable undo/redo */ + return ok; +} + +/*! + Undo operation on the given study +*/ +bool QAD_Application::undo(QAD_Study* study) +{ + bool status = false; + if ( study ) + { + status = study->undo(); + } + return status; +} + +/*! + Redo operation on the active study. + Calls redo( myActiveStudy ). +*/ +bool QAD_Application::onRedo() +{ + bool ok = redo( myActiveStudy ); + updateActions(); /* enable/disable undo/redo */ + return ok; +} + +/*! + Redo operation on the given study. +*/ +bool QAD_Application::redo(QAD_Study* study) +{ + bool status = false; + if ( study ) + { + status = study->redo(); + } + return status; +} + +/*! + Copies object to the pseudo-clipboard +*/ +bool QAD_Application::onCopy() +{ + bool status = false; + if ( myActiveStudy) { + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + if ( Sel && Sel->IObjectCount() == 1 ) { + SALOMEDS::SObject_var SO = myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); + if ( !SO->_is_nil() ) { + SALOMEDS::SComponent_var SComp = SALOMEDS::SComponent::_narrow( SO ); + if ( SComp->_is_nil() ) { // disable 'copy' operations for components + status = myStudyMgr->Copy( SO ); + updateActions(); + } + } + } + } + return status; +} + +/*! + Pastes object from the pseudo-clipboard +*/ +bool QAD_Application::onPaste() +{ + SALOMEDS::SObject_var aResult; + if ( myActiveStudy) { + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + if ( Sel && Sel->IObjectCount() == 1 ) { + SALOMEDS::SObject_var SO = myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); + if ( !SO->_is_nil() ) { + try { + aResult = myStudyMgr->Paste( SO ); + } + catch ( SALOMEDS::StudyBuilder::LockProtection& ) { + myActiveStudy->updateObjBrowser( true ); + updateActions(); + QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK")); + return false; + } + myActiveStudy->updateObjBrowser( true ); + updateActions(); + } + } + } + return aResult->_is_nil(); +} + +/*! + Checks if it is possible to make 'copy' operation +*/ +bool QAD_Application::canCopy() +{ + bool status = false; + if ( myActiveStudy) { + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + if ( Sel && Sel->IObjectCount() == 1 ) { + SALOMEDS::SObject_var SO = myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); + if ( !SO->_is_nil() ) { + SALOMEDS::SComponent_var SComp = SALOMEDS::SComponent::_narrow( SO ); + if ( SComp->_is_nil() ) // disable copy for components + status = myStudyMgr->CanCopy( SO ); + } + } + } + return status; +} + +/*! + Checks if it is possible to make 'paste' operation +*/ +bool QAD_Application::canPaste() +{ + bool status = false; + if ( myActiveStudy) { + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + if ( Sel && Sel->IObjectCount() == 1 ) { + SALOMEDS::SObject_var SO = myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); + if ( !SO->_is_nil() ) { + status = myStudyMgr->CanPaste( SO ); + } + } + } + return status; +} + +/*! + Called when the main desktop is created ( internal ) +*/ +void QAD_Application::onDesktopCreated() +{ + createActions(); +} + +/*! + Called after creating the given study +*/ +void QAD_Application::onStudyCreated(QAD_Study* study) +{ +} + +/*! + Called after opening the given study +*/ +void QAD_Application::onStudyOpened(QAD_Study* study) +{ +} + +/*! + Called after the first showing of the given study +*/ +void QAD_Application::onStudyShown( QAD_Study* study ) +{ +} + +/*! + Called when the given study is activated +*/ +void QAD_Application::onStudyActivated(QAD_Study* study) +{ + // MESSAGE ("QAD_Application::onStudyActivated init. "); + + /* deactivate old study, activate new study*/ + + /* NRI : init DEBUG IAP_001 */ + QAD_Study* oldActiveStudy = 0; + if ( myActiveStudy != NULL ) + oldActiveStudy = myActiveStudy; + /* NRI : end DEBUG IAP_001 */ + + + if ( myActiveStudy ) + onStudyDeactivated( myActiveStudy ); + + myActiveStudy = study; + + /* notification */ + onActiveStudyChanged( oldActiveStudy, myActiveStudy ); + + /* application activated */ + emit appActivated( this ); +} + +/*! + Called when the given study is deactivated +*/ +void QAD_Application::onStudyDeactivated(QAD_Study* study) +{ + // MESSAGE ("QAD_Application::onStudyDeactivated init. "); + QAD_ASSERT_DEBUG_ONLY ( myActiveStudy == study ); + myActiveStudy->onStudyDeactivated(); + myActiveStudy = 0; + // MESSAGE ("QAD_Application::onStudyDeactivated done. "); +} + +/*! + Called before closing the given study +*/ +void QAD_Application::onStudyClosed(QAD_Study* study) +{ +} + +/*! + Called when the active study changed +*/ +void QAD_Application::onActiveStudyChanged( QAD_Study* oldActiveStudy, + QAD_Study* newActiveStudy ) +{ + getDesktop()->onActiveStudyChanged(); + + if ( oldActiveStudy ) + QAD_ASSERT( disconnect( oldActiveStudy, SIGNAL(docOperationTerminated( bool )), + this, SLOT( onOperationTerminated( bool ) ) )); + if ( newActiveStudy ) + QAD_ASSERT( connect( newActiveStudy, SIGNAL(docOperationTerminated( bool )), + this, SLOT( onOperationTerminated( bool ) ) )); + updateActions(); +} + +/*! + Called when the operation 'op' terminated [ protected slot ] +*/ +void QAD_Application::onOperationTerminated( bool successfully ) +{ + if ( successfully ) + updateActions(); /* enable/disable undo/redo */ +} + +/*! + Adds the specific items to context popup menu activated usually by MB3. + Redefine to fill with desired items. +*/ +void QAD_Application::onCreatePopup () +{ +} + diff --git a/src/SALOMEGUI/QAD_Application.h b/src/SALOMEGUI/QAD_Application.h new file mode 100644 index 000000000..aeee89532 --- /dev/null +++ b/src/SALOMEGUI/QAD_Application.h @@ -0,0 +1,184 @@ +// File : QAD_Application.h +// Created : UI team, 22.09.00 +// Descr : Study manager of QAD-based application + +// Modified : Mon Dec 03 13:21:50 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + + +#ifndef QAD_Application_H +#define QAD_Application_H + +#include "QAD.h" +#include "QAD_Popup.h" +#include "QAD_Study.h" + +#include "SALOME_NamingService.hxx" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include + +class QAD_Operation; +class QAD_Desktop; +class QAD_EXPORT QAD_Application : public QObject, public QAD_PopupServer +{ + Q_OBJECT + enum { EditUndoId, EditRedoId, EditCopyId, EditPasteId }; + +friend class QAD_Desktop; + +public: + QAD_Application ( const QString& format, const QString& description, + const QString& filter); + ~QAD_Application(); + +public: + static void run(); + static bool addToDesktop( QAD_Application* app, SALOME_NamingService* name_service ); + static QAD_Desktop* getDesktop(); + + static QPalette getPalette(bool alternative = false); + + const QString& getApplicationName() const; + const QPixmap& getApplicationIcon() const; + + /* studies management */ + const QString& getStudyFormat() const; + const QString& getStudyExtension() const; + const QString& getStudyDescription() const; + + /* studies */ + bool isStudyOpened( const QString& studyname ); + QAD_Study* getStudyByName( const QString& studyname ); + QAD_Study* getActiveStudy() const; + QList& getStudies(); + + QAD_Study* newStudy(); + QAD_Study* loadStudy( const QString& fileName); + QAD_Study* openStudy( const QString& fileName); + bool saveStudy( QAD_Study* study ); + bool saveAsStudy( QAD_Study* study, const QString& fileName ); + bool closeStudy( QAD_Study* study, bool permanently = false ); + + /* customization */ + void updateFilePopup( QPopupMenu* menu, bool add, int index = -1 ); + void updateEditPopup( QPopupMenu* menu, bool add, int index = -1 ); + void updateViewPopup( QPopupMenu* menu, bool add, int index = -1 ); + void updateHelpPopup( QPopupMenu* menu, bool add, int index = -1 ); + void updateMainMenu( QMenuBar* menu, bool add, int index = -1 ); + void updateStatusBar( QStatusBar*, bool add ); + void updateToolBars( bool add ); + + /* toolbars */ + QToolBar* createToolBar( int id, + const QString& label, Dock dock = DockTop, + bool dockTop = true, bool dockBottom = true, + bool dockLeft = true, bool dockRight = true, + bool dockMinimized = true, bool dockTornOff = true ); + void removeToolBar( int id ); + QToolBar* getToolBar( int id ); + QList getToolBars(); + + virtual void onStudyActivated( QAD_Study* ); + virtual void onStudyDeactivated( QAD_Study* ); + virtual void startOperation( QAD_Operation* op ); + + virtual void helpAbout(); + virtual void helpSearch(); + virtual void helpContents(); + +public slots: + void updateActions(); + +signals: + void appActivated ( QAD_Application* ); + void appDeactivated ( QAD_Application* ); + void desktopCreated(); + +protected slots: + virtual bool onUndo(); + virtual bool onRedo(); + virtual bool onCopy(); + virtual bool onPaste(); + virtual void onOperationTerminated( bool ); + +private slots: + void onDesktopCreated(); + +protected: + /* menu */ + virtual int onUpdateMainMenuItems ( QMenuBar*, bool add, int index ); + virtual int onUpdateFileActions ( QPopupMenu*, bool add, int index ); + virtual int onUpdateEditActions ( QPopupMenu*, bool add, int index ); + virtual int onUpdateViewActions ( QPopupMenu*, bool add, int index ); + virtual int onUpdateHelpActions ( QPopupMenu*, bool add, int index ); + virtual void onUpdateStatusBar( QStatusBar*, bool activate ); + virtual void onUpdateToolBars( bool activate ); + + /* study */ + virtual void onStudyCreated( QAD_Study* ); + virtual void onStudyOpened( QAD_Study* ); + virtual void onStudyClosed( QAD_Study* ); + virtual void onStudyShown( QAD_Study* ); + virtual void onActiveStudyChanged( QAD_Study* oldActiveStudy, + QAD_Study* newActiveStudy ); + /* specific initialization ( CAF etc. ) */ + virtual bool initApp(SALOME_NamingService* name_service) = 0; + virtual bool createDesktop(SALOME_NamingService* name_service); + + /* undo/redo */ + virtual bool undo( QAD_Study* study ); + virtual bool redo( QAD_Study* study ); + /* copy/paste */ + bool canCopy(); + bool canPaste(); + + /* popup */ + void onCreatePopup(); + +protected: + + SALOMEDS::StudyManager_var myStudyMgr; + + QAD_Study* myActiveStudy; + QList myStudies; + QPixmap myIcon; + QString myName; + + QString myStudyFormat; + QString myStudyExtension; + QString myStudyDescription; + +#if defined SOLARIS +/* SUN C++ v4.1 compiler BUG ? + Error when using protected 'desktop' in subclasses. + */ +public: +#endif + static QAD_Desktop* desktop; /* the only QAD desktop */ + +private: + void createActions(); + + void addStudy( QAD_Study* study ); + void removeStudy( QAD_Study* study ); + +private : + QList myEditActions; + QList myViewActions; + QList myHelpActions; + QMap myToolBars; +}; + +#endif + diff --git a/src/SALOMEGUI/QAD_Config.cxx b/src/SALOMEGUI/QAD_Config.cxx new file mode 100644 index 000000000..511c2ed3a --- /dev/null +++ b/src/SALOMEGUI/QAD_Config.cxx @@ -0,0 +1,202 @@ +using namespace std; +// File : QAD_Config.cxx +// Created : Tue Sep 04 09:58:34 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + + +/*! + \class QAD_Config QAD_Config.h + \brief Settings file management for QAD-based application. +*/ + +#include "QAD_Config.h" +#include "QAD_ParserSettings.h" + +// QT Includes +#include +#include +#include +#include + + +/*! + QAD_Config provides access to global settings. +*/ +QAD_Config* QAD_Config::theOneAndOnlyConfig=0; + + +/*! + Creates a new one on first call. +*/ +QAD_Config* QAD_Config::getConfig() +{ + if(theOneAndOnlyConfig==0) { + theOneAndOnlyConfig = new QAD_Config; + theOneAndOnlyConfig->ini(); + } + return theOneAndOnlyConfig; +} + + + +/*! + Constructor. +*/ +QAD_Config::QAD_Config() + : QAD_Settings('=', '"', '"') +{ +} + +/*! + Destructor. +*/ +QAD_Config::~QAD_Config() +{ +} + +/*! + Initializes the config object (only called once). +*/ +void QAD_Config::ini() +{ +} + + +/*! + Creates not existing config files. +*/ +bool QAD_Config::createConfigFile( bool overwrite ) +{ + bool ret=true; + +#ifdef DEF_WINDOWS + setConfigDir(QDir(prgDir.absPath())); +#else + setConfigDir(QDir(QDir::home().absPath() + "/." + tr("MEN_APPNAME") )); +#endif + + // Create config directory: + if(!configDir.exists()) { + if(!configDir.mkdir(configDir.absPath(), true)) { + // Can't create directory for config file! + return false; + } + } + + // Create "..conf": + QFile configFile(configDir.absPath() + "/" + tr("MEN_APPNAME") + ".conf"); + + if(!configFile.exists() || overwrite) { + if(configFile.open(IO_WriteOnly)) { // file opened successfully + QTextStream ts(&configFile); + QAD_Setting* setting; + + ts << + "# This file is automatically generated by " << tr("MEN_APPNAME") << ".\n" + "# Please edit only if " << tr("MEN_APPNAME") << " is not running.\n"; + + int sep; + QString section; + QString variable; + QStringList sectionList; // List of all sections + + // Collect section list: + for(setting=settingList.first(); setting!=0; setting=settingList.next()) { + sep = setting->getName().find( ':' ); + section = setting->getName().left( sep ); + + if( sectionList.find( section ) == sectionList.end() ) { + sectionList += section; + } + } + + sectionList.sort(); + + // Write the sections: + for( QStringList::Iterator it = sectionList.begin(); it!=sectionList.end(); ++it ) { + ts << "\n[" << (*it) << "]\n"; + for( setting=settingList.first(); setting!=0; setting=settingList.next() ) { + sep = setting->getName().find( ':' ); + section = setting->getName().left( sep ); + + if( section==(*it) ) { + variable = setting->getName().right( setting->getName().length()-sep-1 ); + ts << variable << "=\"" << setting->getValue() << "\"\n"; + } + } + } + + configFile.close(); + } + + else { + // Can't create file + ret=false; + } + } + + return ret; +} + +/*! + Reads the config file. +*/ +bool QAD_Config::readConfigFile() +{ +#ifdef DEF_WINDOWS + setConfigDir(QDir(prgDir.absPath())); +#else + setConfigDir(QDir(QDir::home().absPath() + "/." + tr("MEN_APPNAME") )); +#endif + + QString configPath; + configPath = configDir.absPath() + "/" + tr("MEN_APPNAME") + ".conf"; + + int i=0, j, l=0; // Index, length of matching string + QRegExp regSection("\\[[^]]*\\]"); // Reg exp for a section including brackets + QRegExp regName("[^=[]*"); // Reg exp for a setting name (lvalue) + QRegExp regValue("\"[^\"]*\""); // Reg exp for a setting value (rvalue) including quote marks + QString lSectionName; // Section name excluding brackets + QString setName; // Setting name + QString setValue; // Setting value + + // Get file contents without comments: + QString cont = QAD_ParserSettings::getContents(configPath, false); + + do { + // Read next section (name/contents): + i=regSection.match(cont, i, &l); + if(i==-1) break; + lSectionName = cont.mid(i+1, l-2); + i+=l; + + // Read next setting: + do { + j=regName.match(cont, i, &l); + if(j==-1) break; + setName = cont.mid(j, l); + if(setName.stripWhiteSpace().isEmpty()) break; + i=j+l; + + j=regValue.match(cont, i, &l); + if(j==-1) break; + setValue = cont.mid(j+1, l-2); + i=j+l; + + addSetting(lSectionName + ":" + setName.stripWhiteSpace(), setValue); + + } while(true); + + } while(true); + + // Add some values which were not saved in config file: + + return false; +} + + +// EOF diff --git a/src/SALOMEGUI/QAD_Config.h b/src/SALOMEGUI/QAD_Config.h new file mode 100644 index 000000000..8a7138f32 --- /dev/null +++ b/src/SALOMEGUI/QAD_Config.h @@ -0,0 +1,56 @@ +// File : QAD_Config.h +// Created : Tue Sep 04 09:54:37 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef QAD_CONFIG_H +#define QAD_CONFIG_H + +// Used for access to the configuration file e.g.: QAD_CONFIG->getSetting("Language:Language") +#define QAD_CONFIG QAD_Config::getConfig() + +#include +#include + +#include "QAD_Settings.h" + +class QAD_Config : public QAD_Settings +{ + +protected: + QAD_Config(); + + void ini(); + +public: + ~QAD_Config(); + + static QAD_Config* getConfig(); + + /** Sets directory of the local configuration file. */ + void setConfigDir(QDir _configDir) { configDir=_configDir; } + /** Gets directory of the local configuration file. */ + QDir getConfigDir() const { return configDir; } + + /** Sets directory of SALOME_ROOT. */ + void setPrgDir(QDir _prgDir) { prgDir=_prgDir; } + /** Gets directory of SALOME_ROOT. */ + QDir getPrgDir() const { return prgDir; } + + bool createConfigFile( bool overwrite=false ); + bool readConfigFile(); + +private: + static QAD_Config* theOneAndOnlyConfig; + + QDir prgDir; + QDir configDir; +}; + + +#endif + +// EOF diff --git a/src/SALOMEGUI/QAD_Desktop.cxx b/src/SALOMEGUI/QAD_Desktop.cxx new file mode 100644 index 000000000..fc6cd157c --- /dev/null +++ b/src/SALOMEGUI/QAD_Desktop.cxx @@ -0,0 +1,3279 @@ +using namespace std; +// File : QAD_Desktop.cxx +// Created : UI team, 02.10.00 +// Descr : Main desktop of QAD-based application + +// Modified : Mon Dec 03 13:40:28 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + +/*! + \class QAD_Desktop QAD_Desktop.h + \brief Main desktop of QAD-based application. +*/ +using namespace std; +# include "Utils_ORB_INIT.hxx" +# include "Utils_SINGLETON.hxx" + +#define INCLUDE_MENUITEM_DEF + +#include "QAD.h" +#include "QAD_Help.h" +#include "QAD_Tools.h" +#include "QAD_Desktop.h" +#include "QAD_LeftFrame.h" +#include "QAD_RightFrame.h" +#include "QAD_Operation.h" +#include "QAD_XmlHandler.h" +#include "QAD_MessageBox.h" +#include "QAD_Application.h" +#include "QAD_Settings.h" +#include "QAD_Config.h" +#include "QAD_ObjectBrowser.h" +#include "QAD_Resource.h" +#include "QAD_FileDlg.h" +#include "QAD_HelpWindow.h" +#include "QAD_DirListDlg.h" +#include "QAD_WaitCursor.h" +#include "SALOMEGUI_OpenWith.h" +#include "SALOMEGUI_StudyPropertiesDlg.h" +#include "SALOMEGUI_TrihedronSizeDlg.h" +#include "SALOMEGUI_LoadStudiesDlg.h" +#include "SALOME_Selection.h" +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOMEGUI_AboutDlg.h" +#include "SALOMEGUI_ViewChoiceDlg.h" +#include "utilities.h" + +#include "SALOMEGUI_CloseDlg.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if QT_VERSION > 300 + #include + #include +#endif + +// Open CASCADE Includes +#include +#include +#include + +extern "C" +{ +# include +} + +QAD_ResourceMgr* QAD_Desktop::resourceMgr = 0; +QPalette* QAD_Desktop::palette = 0; + + +/*! + Creates the resource manager [ static ] +*/ +QAD_ResourceMgr* QAD_Desktop::createResourceManager() +{ + if ( !resourceMgr ) + resourceMgr = new QAD_ResourceMgr; + return resourceMgr; +} + +/*! + Returns the resource manager [ static ] +*/ +QAD_ResourceMgr* QAD_Desktop::getResourceManager() +{ + return resourceMgr; +} + + +/*! + Loads the palette from settings [ static ] +*/ +QPalette* QAD_Desktop::createPalette() +{ + if ( !palette ) + palette = new QPalette(); + + return palette; +} + +/*! + Returns the palette [ static ] +*/ +QPalette* QAD_Desktop::getPalette() +{ + return palette; +} + +/*! + Gets window ratio width/heght [ static ] +*/ +static double myWindowRatio = 1; +static double getWindowRatio() +{ + return myWindowRatio; +} + +/*! + Sets window ratio width/heght [ static ] +*/ +static void setWindowRatio(double aRatio) +{ + myWindowRatio = aRatio; +} + +/*! + Constructor +*/ +QAD_Desktop::QAD_Desktop(SALOME_NamingService* name_service) : +QMainWindow(0, 0, WType_TopLevel | WDestructiveClose), +myStdToolBar(0), +myStatusBar(0), +myActiveApp(0), +myActiveStudy(0), +myCntUntitled(0), +myHelpWindow(0), +myDefaultTitle( tr("DESK_DEFAULTTITLE") ), +myQueryClose( true ) +{ + /* Force reading of user config file */ + QAD_CONFIG->readConfigFile(); + + /* menubar and status bar */ + myStatusBar = statusBar(); + myMainMenu = menuBar(); + myActiveComp = ""; + myNameService = name_service; + + /* default background icon */ + QPixmap backgroundicon ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT", + tr("ICON_DESK_BACKGROUNDICON") )); + myToolBarAction.setAutoDelete( true ); + + /* default icon and title */ + QPixmap icon ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT", + tr("ICON_DESK_DEFAULTICON") )); + if ( !icon.isNull() ) { + myDefaultIcon = icon; + setIcon( myDefaultIcon ); + } + setCaption( myDefaultTitle ); + + /* set size as 1/2 of the screen and center it */ + QWidget* d = QApplication::desktop(); + resize( 2*d->width()/3, 2*d->height()/3 ); + QAD_Tools::centerWidget( this, d ); + + /* workspace will manage child frames */ + QHBox* border = new QHBox ( this ); + border->setFrameStyle ( QFrame::Panel | QFrame::Sunken ); + setCentralWidget( border ); + myWorkspace = new QWorkspaceP( border ); + + QPalette pal = QAD_Application::getPalette(); + setPalette(pal); + QColorGroup cgA = pal.active(); + QColorGroup cgI = pal.inactive(); + QColorGroup cgD = pal.disabled(); + cgA.setColor( QColorGroup::Background, QColor(192, 192, 192)); + cgI.setColor( QColorGroup::Background, QColor(192, 192, 192)); + cgD.setColor( QColorGroup::Background, QColor(192, 192, 192)); + pal.setActive ( cgA ); + pal.setInactive( cgI ); + pal.setDisabled( cgD ); + myWorkspace->setPalette( pal ); + if ( !backgroundicon.isNull() ) { + MESSAGE("!!!DESKTOP background icon found!!!"); + myWorkspace->setPaletteBackgroundPixmap(backgroundicon); + } + + /* define standard file commands */ + createActions(); + + /* define operator menus for xml */ + myOperatorMenus = new QAD_OperatorMenus(this); + myXmlHandler = new QAD_XmlHandler(); + + /* New catalogue */ + CORBA::Object_var objVarN = myNameService->Resolve("/Kernel/ModulCatalog"); + myCatalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN); + + SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants = + myCatalogue->GetComponentIconeList(); + + + QToolBar* tbComponent = new QToolBar( tr("MEN_DESK_COMPONENTTOOLBAR"), this ); + tbComponent->setCloseMode( QDockWindow::Undocked ); + addToolBar(tbComponent, tr("MEN_DESK_COMPONENTTOOLBAR"), Bottom, TRUE ); + setDockEnabled( tbComponent, DockLeft, false ); + setDockEnabled( tbComponent, DockRight, false ); + + myCombo = new QComboBox( FALSE, tbComponent, "comboBox" ); + myCombo->setFocusPolicy( NoFocus ); + + tbComponent->addSeparator(); + + // PG : add ResourceManager to get function findFile !! + QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); + + for (unsigned int ind = 0; ind < list_composants->length();ind++) { + QString resDir; + + /* find component icon */ + QString iconfile = strdup(list_composants[ind].moduleicone) ; + QString modulename = strdup(list_composants[ind].modulename) ; + resDir = resMgr->findFile(iconfile,modulename) ; + if (resDir) + { + //resDir = QAD_Tools::addSlash(resDir) ; + //QPixmap Icone(resDir+iconfile) ; + QPixmap Icone( QAD_Tools::addSlash( resDir ) + iconfile ); + QToolButton * toolb = + new QToolButton( QIconSet( Icone ), modulename, QString::null, this, + SLOT( onButtonActiveComponent () ),tbComponent ); + toolb->setToggleButton( true ); + myComponentButton.append(toolb); + } + else + { + QString errMsg = tr("INF_ICON_RESOURCES").arg(iconfile).arg(modulename) + + tr("INF_RESOURCES"); + //QMessageBox::warning( this, tr("WRN_WARNING"), errMsg, tr ("BUT_OK") ); + } + + if ( !QString(list_composants[ind].modulename).isEmpty() ) + myCombo->insertItem( strdup(list_composants[ind].modulename) ); + + } + + myCombo->adjustSize(); + connect( myCombo, SIGNAL(activated(const QString&)), + this, SLOT( onComboActiveComponent(const QString&) ) ); + + /* new LifeCycleCORBA client, for Engines */ + myEnginesLifeCycle = new SALOME_LifeCycleCORBA(name_service); + + /* VSR 13/01/03 : installing global event filter for the application */ + qApp->installEventFilter( this ); +} + +/*! + Destructor +*/ +QAD_Desktop::~QAD_Desktop () +{ + qApp->removeEventFilter( this ); + myFilePopup.clear(); + myEditPopup.clear(); + myViewPopup.clear(); + myObjBrowserPopup.clear(); + //VRV: T2.5 - add default viewer + myDefaultViewer.clear(); + //VRV: T2.5 - add default viewer + myViewerPopup.clear(); + //NRI : SAL2214 + myNewViewPopup.clear(); + //NRI : SAL2214 + myToolsPopup.clear(); + myPrefPopup.clear(); + myStdActions.clear(); + myHelpPopup.clear(); + myToolBarsPopup.clear(); + myToolBarAction.clear(); + myApps.clear(); + delete resourceMgr; + if (myHelpWindow) + myHelpWindow->close(); + resourceMgr = 0; + QAD_Application::desktop = 0; +} + +const int IdCut = 1001; +const int IdCopy = 1002; +const int IdPaste = 1003; +const int IdSelectAll = 1004; +#ifndef QT_NO_ACCEL +#include +#define ACCEL_KEY(k) "\t" + QString(QKeySequence( Qt::CTRL | Qt::Key_ ## k )) +#else +#define ACCEL_KEY(k) "\t" + QString("Ctrl+" #k) +#endif +#include +/*! + Global event filter for qapplication (VSR 13/01/03) +*/ +bool QAD_Desktop::eventFilter( QObject* o, QEvent* e ) +{ + if ( e->type() == QEvent::ContextMenu ) { + QContextMenuEvent* ce = (QContextMenuEvent*)e; + if ( o->inherits("QRenameEdit") ) { + return TRUE; + } + else if ( o->inherits("QLineEdit") ) { + QLineEdit* le = (QLineEdit*)o; + if ( le->parentWidget() ) { + if ( ( le->parentWidget()->inherits("QSpinBox") || + le->parentWidget()->inherits("QSpinWidget") || + le->parentWidget()->inherits("QAD_SpinBoxDbl") ) && + le->isEnabled() ) { + QPopupMenu* popup = new QPopupMenu( 0, "qt_edit_menu" ); + popup->insertItem( tr( "EDIT_CUT_CMD" ) + ACCEL_KEY( X ), IdCut ); + popup->insertItem( tr( "EDIT_COPY_CMD" ) + ACCEL_KEY( C ), IdCopy ); + popup->insertItem( tr( "EDIT_PASTE_CMD" ) + ACCEL_KEY( V ), IdPaste ); + popup->insertSeparator(); +#if defined(Q_WS_X11) + popup->insertItem( tr( "EDIT_SELECTALL_CMD" ), IdSelectAll ); +#else + popup->insertItem( tr( "EDIT_SELECTALL_CMD" ) + ACCEL_KEY( A ), IdSelectAll ); +#endif + bool enableCut = !le->isReadOnly() && le->hasSelectedText(); + popup->setItemEnabled( IdCut, enableCut ); + popup->setItemEnabled( IdCopy, le->hasSelectedText() ); + bool enablePaste = !le->isReadOnly() && !QApplication::clipboard()->text().isEmpty(); + popup->setItemEnabled( IdPaste, enablePaste ); + bool allSelected = (le->selectedText() == le->text() ); + popup->setItemEnabled( IdSelectAll, (bool)(le->text().length()) && !allSelected ); + + QPoint pos = ce->reason() == QContextMenuEvent::Mouse ? ce->globalPos() : + le->mapToGlobal( QPoint(ce->pos().x(), 0) ) + QPoint( le->width() / 2, le->height() / 2 ); + if ( popup ) { + int r = popup->exec( pos ); + switch ( r ) { + case IdCut: + le->cut(); + break; + case IdCopy: + le->copy(); + break; + case IdPaste: + le->paste(); + break; + case IdSelectAll: + le->selectAll(); + break; + } + delete popup; + } + return TRUE; + } + } + } + } + return QMainWindow::eventFilter( o, e ); +} + +/*! + Creates and initializes the standard file operations + such as 'New/Open/Save/SaveAs/Close' and 'Help'. +*/ +void QAD_Desktop::createActions() +{ + + /* Used for string compare */ + const QString& aTrueQString = "true" ; + + /* create 'standard' toolbar */ + if ( !myStdToolBar ) { + myStdToolBar = new QToolBar ( tr("MEN_DESK_VIEW_STDTOOLBAR"), this ); + myStdToolBar->setCloseMode( QDockWindow::Undocked ); + } + + if ( !myMainMenu->count() ) { + /* Create main menu bar */ + myMainMenu->insertItem ( tr("MEN_DESK_FILE"), &myFilePopup, 1 ); /* add popup FILE */ + myMainMenu->insertItem ( tr("MEN_DESK_VIEW"), &myViewPopup, 2 ); /* add popup VIEW */ + myMainMenu->insertItem ( tr("MEN_DESK_TOOLS"), &myToolsPopup, 5 ); /* add popup TOOLS */ + myMainMenu->insertItem ( tr("MEN_DESK_PREF"), &myPrefPopup, 4 ); /* add popup PREF */ + myMainMenu->insertItem ( tr("MEN_DESK_WINDOW"), &myWindowPopup, 6 ); /* add popup WINDOW */ + myMainMenu->insertItem ( tr("MEN_DESK_HELP"), &myHelpPopup, 7 ); /* add popup HELP */ + + /* Applications will insert their items after 'File' 'Edit' and 'View' + ( 'Edit' will be inserted later ) + */ + myMainMenuPos = 3; + } + + /* insert logo picture to menu bar */ + QHBox* aLogoFrm = new QHBox(this); + aLogoFrm->setFrameStyle( QFrame::Plain | QFrame::NoFrame ); + QPixmap aLogoPixmap ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT", + tr("ICON_DESK_LOGO") )); + QLabel* aLogoLab = new QLabel(aLogoFrm); + aLogoLab->setPixmap(aLogoPixmap); + aLogoLab->setAlignment(AlignCenter); + aLogoLab->setScaledContents(false); + myMainMenu->insertItem(aLogoFrm); + + if ( myStdActions.isEmpty() ) { + /* Define standard actions. They should be inserted + into the list in order of their IDs. + */ + + /* 'File' actions */ + /* new */ + QAD_ResourceMgr* rmgr = QAD_Desktop::getResourceManager(); + QAction* fileNewAction = new QAction ( tr("TOT_DESK_FILE_NEW"), + rmgr->loadPixmap( "QAD", tr("ICON_FILE_NEW") ) , + tr("MEN_DESK_FILE_NEW"), CTRL+Key_N, this ); + fileNewAction->setStatusTip ( tr("PRP_DESK_FILE_NEW") ); + fileNewAction->setEnabled ( true ); + QAD_ASSERT ( connect( fileNewAction, SIGNAL( activated() ), this, SLOT( onNewStudy() ))); + fileNewAction->addTo( myStdToolBar ); + fileNewAction->addTo( &myFilePopup ); + myStdActions.insert ( FileNewId, fileNewAction ); + + /* open */ + QAction* fileOpenAction = new QAction( tr("TOT_DESK_FILE_OPEN"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_OPEN") ), + tr("MEN_DESK_FILE_OPEN"), CTRL+Key_O, this ); + fileOpenAction->setStatusTip ( tr("PRP_DESK_FILE_OPEN") ); + fileOpenAction->setEnabled ( true ); + QAD_ASSERT ( connect( fileOpenAction, SIGNAL( activated() ), this, SLOT( onOpenStudy() ))); + fileOpenAction->addTo( myStdToolBar ); + fileOpenAction->addTo( &myFilePopup ); + myStdActions.insert ( FileOpenId, fileOpenAction ); + + /* load */ + QAction* fileLoadAction = new QAction( tr("TOT_DESK_FILE_LOAD"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_LOAD") ), + tr("MEN_DESK_FILE_LOAD"), CTRL+Key_L, this ); + fileLoadAction->setStatusTip ( tr("PRP_DESK_FILE_LOAD") ); + fileLoadAction->setEnabled ( true ); + QAD_ASSERT ( connect( fileLoadAction, SIGNAL( activated() ), this, SLOT( onLoadStudy() ))); + fileLoadAction->addTo( &myFilePopup ); + myStdActions.insert ( FileLoadId, fileLoadAction ); + + /* close */ + QAction* fileCloseAction = new QAction( "", rmgr->loadPixmap( "QAD", tr("ICON_FILE_CLOSE") ), + tr("MEN_DESK_FILE_CLOSE"), CTRL+Key_W, this ); + fileCloseAction->setStatusTip ( tr("PRP_DESK_FILE_CLOSE") ); + QAD_ASSERT ( connect( fileCloseAction, SIGNAL( activated() ), this, SLOT( onCloseStudy() ))); + fileCloseAction->addTo( &myFilePopup ); + myStdActions.insert ( FileCloseId, fileCloseAction ); + + /* separator */ + myFilePopup.insertSeparator(); + + /* save */ + QAction* fileSaveAction = new QAction( tr("TOT_DESK_FILE_SAVE"), rmgr->loadPixmap( "QAD", tr("ICON_FILE_SAVE") ), + tr("MEN_DESK_FILE_SAVE"), CTRL+Key_S, this ); + fileSaveAction->setStatusTip ( tr("PRP_DESK_FILE_SAVE") ); + QAD_ASSERT ( connect( fileSaveAction, SIGNAL( activated() ), this, SLOT( onSaveStudy() ))); + fileSaveAction->addTo( myStdToolBar ); + fileSaveAction->addTo( &myFilePopup ); + myStdActions.insert ( FileSaveId, fileSaveAction ); + + /* save as */ + QAction* fileSaveAsAction = new QAction( "", tr("MEN_DESK_FILE_SAVEAS"), 0, this ); + fileSaveAsAction->setStatusTip ( tr("PRP_DESK_FILE_SAVEAS") ); + QAD_ASSERT ( connect( fileSaveAsAction, SIGNAL( activated() ), + this, SLOT( onSaveAsStudy() ))); + fileSaveAsAction->addTo( &myFilePopup ); + myStdActions.insert ( FileSaveAsId, fileSaveAsAction ); + + + /* separator */ + myFilePopup.insertSeparator(); + + // Study properties + QAction* filePropsAction = new QAction( "", QPixmap(), tr("MEN_DESK_FILE_PROPERTIES"), 0, this ); + filePropsAction->setStatusTip ( tr("PRP_DESK_FILE_PROPERTIES") ); + filePropsAction->setEnabled(false); + QAD_ASSERT ( connect( filePropsAction, SIGNAL( activated() ), this, SLOT( onStudyProperties() ))); + filePropsAction->addTo( &myFilePopup ); + myStdActions.insert ( FilePropsId, filePropsAction ); + + + int id = myFilePopup.insertSeparator(); + /* keep the position from which an application will insert its items + to menu 'File' at the time of customization of the desktop */ + + myFilePos = myFilePopup.indexOf( id ) + 1; + + /* exit application */ + QAction* exitAction = new QAction( "", tr("MEN_DESK_FILE_EXIT"), + CTRL+Key_X, this ); + exitAction->setStatusTip ( tr("PRP_DESK_FILE_EXIT") ); + QAD_ASSERT ( connect( exitAction, SIGNAL( activated() ), + this, SLOT( onExit() ))); + exitAction->addTo( &myFilePopup ); + myStdActions.insert ( FileExitId, exitAction ); + + /* 'Edit' actions : provided by application only */ + myEditPos = 0; + + /* 'View' actions */ + /* toolbars popup menu */ + myViewPopup.insertItem( tr("MEN_DESK_VIEW_TOOLBARS"), &myToolBarsPopup ); + QAD_ASSERT( connect ( &myViewPopup, SIGNAL(aboutToShow()), + this, SLOT(onToolBarPopupAboutToShow()) )); + + /* status bar */ + QAction* viewStatusBarAction = new QAction( "", + tr("MEN_DESK_VIEW_STATUSBAR"), + 0, this, 0, true ); + viewStatusBarAction->setStatusTip ( tr("PRP_DESK_VIEW_STATUSBAR") ); + viewStatusBarAction->setOn( true ); + QAD_ASSERT(connect( viewStatusBarAction, SIGNAL(activated()), this, SLOT(onViewStatusBar() ))); + viewStatusBarAction->addTo( &myViewPopup ); + myStdActions.insert( ViewStatusBarId, viewStatusBarAction ); + +// myViewPopup.insertItem( tr("MEN_DESK_SELECTION_MODE"), &mySelectionModePopup ); + + QAction* SelectionPointAction = new QAction( "", tr("MEN_DESK_SELECTION_POINT"), 0, this, 0, true ); + QAD_ASSERT(connect( SelectionPointAction, SIGNAL(activated()), this, SLOT(onSelectionMode() ))); + SelectionPointAction->addTo( &mySelectionModePopup ); + myStdActions.insert( SelectionPointId, SelectionPointAction ); + + QAction* SelectionEdgeAction = new QAction( "", tr("MEN_DESK_SELECTION_EDGE"), 0, this, 0, true ); + QAD_ASSERT(connect( SelectionEdgeAction, SIGNAL(activated()), this, SLOT(onSelectionMode() ))); + SelectionEdgeAction->addTo( &mySelectionModePopup ); + myStdActions.insert( SelectionEdgeId, SelectionEdgeAction ); + + QAction* SelectionCellAction = new QAction( "", tr("MEN_DESK_SELECTION_CELL"), 0, this, 0, true ); + QAD_ASSERT(connect( SelectionCellAction, SIGNAL(activated()), this, SLOT(onSelectionMode() ))); + SelectionCellAction->addTo( &mySelectionModePopup ); + myStdActions.insert( SelectionCellId, SelectionCellAction ); + + QAction* SelectionActorAction = new QAction( "", tr("MEN_DESK_SELECTION_ACTOR"), 0, this, 0, true ); + QAD_ASSERT(connect( SelectionActorAction, SIGNAL(activated()), this, SLOT(onSelectionMode() ))); + SelectionActorAction->addTo( &mySelectionModePopup ); + myStdActions.insert( SelectionActorId, SelectionActorAction ); + SelectionActorAction->setOn(true); + + myViewPos = myViewPopup.count(); + + /* Parse xml file */ + QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); + if ( resMgr ) { + QString msg; + if(!resMgr->loadResources( "ToolsGUI", msg )) + { + //NRI QCString errMsg; + // errMsg.sprintf( "Do not load all resources for module ToolsGUI.\n" ); + QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") ); + } + } + + myOperatorMenus = new QAD_OperatorMenus(this); + myXmlHandler = new QAD_XmlHandler(); + ASSERT(myXmlHandler) ; + myXmlHandler->setMainWindow(this); + if ( myXmlHandler->setComponent( resMgr->resources( "ToolsGUI" ) ) ) { + QString language = resMgr->language( "ToolsGUI" ); + QString ToolsXml = QString( "Tools_" ) + language + QString( ".xml" ); + + //ToolsXml = resMgr->resources("ToolsGUI") ; + //ToolsXml = QAD_Tools::addSlash(ToolsXml) ; + //ToolsXml = ToolsXml + "Tools_" + language + ".xml" ; + ToolsXml = QAD_Tools::addSlash( resMgr->findFile( ToolsXml, "ToolsGUI" ) ) + ToolsXml; + + QFile file( QAD_Tools::unix2win( ToolsXml ) ); + if ( file.exists() && file.open( IO_ReadOnly ) ) { + file.close(); + QXmlInputSource source( file ); + QXmlSimpleReader reader; + reader.setContentHandler( myXmlHandler ); + reader.setErrorHandler( myXmlHandler ); + bool ok = reader.parse( source ); + file.close(); + if ( !ok ) { + QMessageBox::critical( 0, + tr( "INF_PARSE_ERROR" ), + tr( myXmlHandler->errorProtocol() ) ); + } else { + myMenusList=myXmlHandler->myMenusList; + myActiveMenus=myMenusList.at(0); + myOperatorMenus->showMenuBar(0); + myActiveMenus->showAllToolBars(); + } + } + } + // } + + if ( myToolsPopup.count() == 0 ) { + myMainMenu->removeItem(5); + } + + /* 'Pref' actions */ + /* Viewer BackgroundColor */ + myPrefPopup.insertItem( tr("MEN_DESK_PREF_VIEWER"), &myViewerPopup ); + + QAction* viewerOCCAction = new QAction( "", tr("MEN_DESK_PREF_VIEWER_OCC"), 0, this ); + QAD_ASSERT(connect( viewerOCCAction, SIGNAL(activated()), this, SLOT(onViewerOCC() ))); + viewerOCCAction->addTo( &myViewerPopup ); + myStdActions.insert( PrefViewerOCCId, viewerOCCAction ); + + QAction* viewerVTKAction = new QAction( "", tr("MEN_DESK_PREF_VIEWER_VTK"), 0, this ); + QAD_ASSERT(connect( viewerVTKAction, SIGNAL(activated()), this, SLOT(onViewerVTK() ))); + viewerVTKAction->addTo( &myViewerPopup ); + myStdActions.insert( PrefViewerVTKId, viewerVTKAction ); + + QAction* graphSupervisorAction = new QAction( "", tr("MEN_DESK_PREF_GRAPH_SUPERVISOR"), 0, this ); + QAD_ASSERT(connect( graphSupervisorAction, SIGNAL(activated()), this, SLOT(onGraphSupervisor() ))); + graphSupervisorAction->addTo( &myViewerPopup ); + myStdActions.insert( PrefGraphSupervisorId, graphSupervisorAction ); + + QAction* viewerPlot2dAction = new QAction( "", tr("MEN_DESK_PREF_VIEWER_PLOT2D"), 0, this ); + QAD_ASSERT(connect( viewerPlot2dAction, SIGNAL(activated()), this, SLOT(onPlot2d() ))); + viewerPlot2dAction->addTo( &myViewerPopup ); + myStdActions.insert( PrefViewerPlot2dId, viewerPlot2dAction ); + + //VRV: T2.5 - add default viewer + QString viewerValue = QAD_CONFIG->getSetting( "Viewer:DefaultViewer" ); + bool ok; + int aViewerValue = viewerValue.toInt( &ok, 10 ); + if (!ok || aViewerValue < VIEW_OCC || aViewerValue >= VIEW_TYPE_MAX) + aViewerValue = VIEW_VTK; + + myPrefPopup.insertItem( tr("MEN_DESK_PREF_DEFAULT_VIEWER"), &myDefaultViewer ); + QActionGroup* myQAG = new QActionGroup ( this); + QAction* viewerOCCAction1 = new QAction( "", tr("MEN_DESK_PREF_VIEWER_OCC"), 0, this ); + viewerOCCAction1->setToggleAction ( true); + viewerOCCAction1->setOn ( aViewerValue == VIEW_OCC ); + myQAG->insert( viewerOCCAction1 ); + myStdActions.insert( DefaultViewerOCCId, viewerOCCAction1 ); + + QAction* viewerVTKAction1 = new QAction( "", tr("MEN_DESK_PREF_VIEWER_VTK"), 0, this ); + viewerVTKAction1->setToggleAction ( true); + viewerVTKAction1->setOn ( aViewerValue == VIEW_VTK ); + myQAG->insert( viewerVTKAction1 ); + myStdActions.insert( DefaultViewerVTKId, viewerVTKAction1 ); + +/* Remove Supervisor viewer from setting the background */ +// QAction* graphSupervisorAction1 = new QAction( "", tr("MEN_DESK_PREF_GRAPH_SUPERVISOR"), 0, this ); +// graphSupervisorAction1->setToggleAction ( true); +// graphSupervisorAction1->setOn ( aViewerValue == VIEW_GRAPHSUPERV ); +// myQAG->insert( graphSupervisorAction1 ); +// myStdActions.insert( DefaultGraphSupervisorId, graphSupervisorAction1 ); + + QAction* viewerPlot2dAction1 = new QAction( "", tr("MEN_DESK_PREF_VIEWER_PLOT2D"), 0, this ); + viewerPlot2dAction1->setToggleAction ( true); + viewerPlot2dAction1->setOn ( aViewerValue == VIEW_PLOT2D ); + myQAG->insert( viewerPlot2dAction1 ); + myStdActions.insert( DefaultPlot2dId, viewerPlot2dAction1 ); + + myQAG->addTo( &myDefaultViewer ); + QAD_ASSERT(connect( myQAG, SIGNAL(selected(QAction * )), this, SLOT(onDefaultViewer(QAction *) ))); + //VRV: T2.5 - add default viewer + + QAction* viewerTrihedronAction = new QAction( "", tr("MEN_DESK_PREF_VIEWER_TRIHEDRON"), 0, this ); + QAD_ASSERT(connect( viewerTrihedronAction, SIGNAL(activated()), this, SLOT(onViewerTrihedron() ))); + viewerTrihedronAction->addTo( &myPrefPopup ); + myStdActions.insert( PrefViewerTrihedronId, viewerTrihedronAction ); + + QAction* consoleFontAction = new QAction( "", tr("MEN_DESK_PREF_CONSOLE_FONT"), 0, this ); + QAD_ASSERT(connect( consoleFontAction, SIGNAL(activated()), this, SLOT(onConsoleFontAction() ))); + consoleFontAction->addTo( &myPrefPopup ); + myStdActions.insert( PrefConsoleFontId, consoleFontAction ); + + /* MultiFile save */ + QAction* multiFileSaveAction = new QAction( "", tr("MEN_DESK_PREF_MULTI_FILE_SAVE"), 0, this, 0, true ); + QAD_ASSERT(connect( multiFileSaveAction, SIGNAL(activated()), this, SLOT(onMultiFileSave() ))); + multiFileSaveAction->setToggleAction( true ); + QString MultiSave = QAD_CONFIG->getSetting("Desktop:MultiFileSave"); + multiFileSaveAction->setOn( MultiSave.compare( aTrueQString ) == 0 ); + multiFileSaveAction->addTo( &myPrefPopup ); + myStdActions.insert( PrefMultiFileSave, multiFileSaveAction ); + + myPrefPopup.insertSeparator(); + + /* BrowserPopup */ + myPrefPopup.insertItem( tr("MEN_DESK_PREF_OBJECTBROWSER"), &myObjBrowserPopup ); + + QAction* objectBrowserEntryAction = new QAction( "", tr("MEN_DESK_PREF_OBJECTBROWSER_ENTRY"), 0, this, 0, true ); + QAD_ASSERT(connect( objectBrowserEntryAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() ))); + objectBrowserEntryAction->setToggleAction(true); + QString AddColumn = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn"); + + if ( AddColumn.compare( aTrueQString ) == 0 ) + objectBrowserEntryAction->setOn(true); + else + objectBrowserEntryAction->setOn(false); + + objectBrowserEntryAction->addTo( &myObjBrowserPopup ); + myStdActions.insert( PrefObjectBrowserEntryId, objectBrowserEntryAction ); + + QAction* objectBrowserValueAction = new QAction( "", tr("MEN_DESK_PREF_OBJECTBROWSER_VALUE"), 0, this, 0, true ); + QAD_ASSERT(connect( objectBrowserValueAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() ))); + objectBrowserValueAction->setToggleAction(true); + QString ValueColumn = QAD_CONFIG->getSetting("ObjectBrowser:ValueColumn"); + + if ( ValueColumn.compare( aTrueQString ) == 0 ) + objectBrowserValueAction->setOn(true); + else + objectBrowserValueAction->setOn(false); + + objectBrowserValueAction->addTo( &myObjBrowserPopup ); + myStdActions.insert( PrefObjectBrowserValueId, objectBrowserValueAction ); + + QAction* objectBrowserIAPPAction = new QAction( "", tr("MEN_DESK_PREF_OBJECTBROWSER_IAPP"), 0, this, 0, true ); + QAD_ASSERT(connect( objectBrowserIAPPAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() ))); + objectBrowserIAPPAction->setToggleAction(true); + QString showIAPP = QAD_CONFIG->getSetting("ObjectBrowser:IAPP"); + + if ( showIAPP.compare( aTrueQString ) == 0 ) + objectBrowserIAPPAction->setOn(true); + else + objectBrowserIAPPAction->setOn(false); + + objectBrowserIAPPAction->addTo( &myObjBrowserPopup ); + myStdActions.insert( PrefObjectBrowserIAPPId, objectBrowserIAPPAction ); + + /* Chronological sorting of shapes on the entry creation */ + QAction* objectBrowserCHRONO_SORTAction = new QAction( "", tr("MEN_DESK_PREF_OBJECTBROWSER_CHRONO_SORT"), 0, this, 0, true ); + QAD_ASSERT(connect( objectBrowserCHRONO_SORTAction, SIGNAL(activated()), this, SLOT(onObjectBrowser() ))); + objectBrowserCHRONO_SORTAction->setToggleAction(true); + QString showSORT = QAD_CONFIG->getSetting("ObjectBrowser:CHRONO_SORT"); + + if ( showSORT.compare( aTrueQString ) == 0 ) + objectBrowserCHRONO_SORTAction->setOn(true) ; + else + objectBrowserCHRONO_SORTAction->setOn(false) ; + + objectBrowserCHRONO_SORTAction->addTo( &myObjBrowserPopup ); + myStdActions.insert( PrefObjectBrowserCHRONO_SORTId, objectBrowserCHRONO_SORTAction ) ; + + myPrefPopup.insertSeparator(); + + QAction* dirAction = new QAction( "", tr("MEN_DESK_PREF_DIRICTORIES"), 0, this ); + QAD_ASSERT(connect( dirAction, SIGNAL(activated()), this, SLOT(onDirList() ))); + dirAction->addTo( &myPrefPopup ); + myStdActions.insert( PrefDirsId, dirAction ); + + myPrefPopup.insertSeparator(); + + QAction* saveAction = new QAction( "", tr("MEN_DESK_PREF_SAVE"), 0, this ); + QAD_ASSERT(connect( saveAction, SIGNAL(activated()), this, SLOT(onSavePref() ))); + saveAction->addTo( &myPrefPopup ); + myStdActions.insert( PrefSaveId, saveAction ); + + /* 'Window' actions */ + /* new Window 3D */ + //NRI : SAL2214 + myWindowPopup.insertItem( tr("MEN_DESK_WINDOW_NEW3D"), &myNewViewPopup, WindowNew3dId ); + + QAction* viewOCCAction = new QAction( "", tr("MEN_DESK_VIEW_OCC"), 0, this ); + QAD_ASSERT(connect( viewOCCAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() ))); + viewOCCAction->addTo( &myNewViewPopup ); + myStdActions.insert( ViewOCCId, viewOCCAction ); + + QAction* viewVTKAction = new QAction( "", tr("MEN_DESK_VIEW_VTK"), 0, this ); + QAD_ASSERT(connect( viewVTKAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() ))); + viewVTKAction->addTo( &myNewViewPopup ); + myStdActions.insert( ViewVTKId, viewVTKAction ); + + QAction* viewPlot2dAction = new QAction( "", tr("MEN_DESK_VIEW_PLOT2D"), 0, this ); + QAD_ASSERT(connect( viewPlot2dAction, SIGNAL(activated()), this, SLOT(onNewWindow3d() ))); + viewPlot2dAction->addTo( &myNewViewPopup ); + myStdActions.insert( ViewPlot2dId, viewPlot2dAction ); + + // QAction* windowNew3dAction = new QAction( "",/* rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_NEW3D") ), */ + /*tr("MEN_DESK_WINDOW_NEW3D"), 0, this ); + windowNew3dAction->addTo( &myWindowPopup ); + QAD_ASSERT( connect( windowNew3dAction, SIGNAL(activated()), this , + SLOT( onNewWindow3d() ))); + myStdActions.insert( WindowNew3dId, windowNew3dAction ); + */ + + //NRI : SAL2214 + + /* cascaded */ + QAction* windowCascadeAction = new QAction( "", rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_CASCADE") ), + tr("MEN_DESK_WINDOW_CASCADE"), 0, this ); + windowCascadeAction->setStatusTip ( tr("PRP_DESK_WINDOW_CASCADE") ); + QAD_ASSERT( connect( windowCascadeAction, SIGNAL(activated()), this, + SLOT( onCascade() ))); + myStdActions.insert( WindowCascadeId, windowCascadeAction ); + + /* tiled */ + QAction* windowTileAction = new QAction( "", rmgr->loadPixmap( "QAD", tr("ICON_DESK_WINDOW_TILE") ), + tr("MEN_DESK_WINDOW_TILE"), 0, this ); + windowTileAction->setStatusTip ( tr("PRP_DESK_WINDOW_TILE") ); + QAD_ASSERT( connect( windowTileAction, SIGNAL(activated()), myWorkspace, SLOT( tile() ))); + myStdActions.insert( WindowTileId, windowTileAction ); + + QAD_ASSERT( connect ( &myWindowPopup, SIGNAL(aboutToShow()), + this, SLOT(onWindowPopupAboutToShow()) )); + /* 'Help' actions + */ + /* contents */ + QAction* helpContentsAction = new QAction( "", tr("MEN_DESK_HELP_CONTENTS"), 0, this ); + helpContentsAction->setStatusTip ( tr("PRP_DESK_HELP_CONTENTS") ); + QAD_ASSERT(connect( helpContentsAction, SIGNAL(activated()), + this, SLOT( onHelpContents() ))); + helpContentsAction->addTo( &myHelpPopup ); + myStdActions.insert( HelpContentsId , helpContentsAction ); + + /* search */ +// QAction* helpSearchAction = new QAction( "", tr("MEN_DESK_HELP_SEARCH"), 0, this ); +// helpSearchAction->setStatusTip ( tr("PRP_DESK_HELP_SEARCH") ); +// QAD_ASSERT( connect( helpSearchAction, SIGNAL(activated()), this, SLOT( onHelpSearch() ))); +// helpSearchAction->addTo( &myHelpPopup ); +// myStdActions.insert( HelpSearchId, helpSearchAction ); + + /* What's This */ +// QAction* helpWhatsThisAction = new QAction( "", tr("MEN_DESK_HELP_WHATSTHIS"), SHIFT+Key_F1, this ); +// helpWhatsThisAction->setStatusTip ( tr("PRP_DESK_HELP_WHATSTHIS" )); +// QAD_ASSERT( connect( helpWhatsThisAction, SIGNAL(activated()), this, SLOT( whatsThis() ))); +// helpWhatsThisAction->addTo( &myHelpPopup ); +// myStdActions.insert( HelpWhatsThisId, helpWhatsThisAction ); +// (void)QWhatsThis::whatsThisButton( myStdToolBar ); + + id = myHelpPopup.insertSeparator(); + myHelpPos = myHelpPopup.indexOf( id ); + + /* about */ + QAction* helpAboutAction = new QAction( "", tr("MEN_DESK_HELP_ABOUT"), 0, this ); + helpAboutAction->setStatusTip ( tr("PRP_DESK_HELP_ABOUT") ); + QAD_ASSERT( connect( helpAboutAction, SIGNAL(activated()), this, SLOT( onHelpAbout() ))); + helpAboutAction->addTo( &myHelpPopup ); + myStdActions.insert(HelpAboutId, helpAboutAction ); + } + updateActions(); +} + +/*! + Adds the given application into the list of supported applications +*/ +void QAD_Desktop::addApplication(QAD_Application* app) +{ + /* add only if is not already in the list */ + if ( myApps.findRef( app ) == -1 ) + { + myApps.append( app ); + + /* set activation/deactivation listener */ + QAD_ASSERT ( connect( app, SIGNAL(appActivated(QAD_Application*)), + this, SLOT(onActivateApp(QAD_Application*))) ); + + QAD_ASSERT ( connect( app, SIGNAL(appDeactivated(QAD_Application*)), + this, SLOT(onDeactivateApp(QAD_Application*))) ); + } +} + +/*! + Displays the control panel of the application. + This function is called when the desktop is shown first time. +*/ +void QAD_Desktop::showDesktop() +{ + show(); +} + +/*! + Closes Desktop. If is true query for exit will be skipped. +*/ +void QAD_Desktop::closeDesktop( bool forceClose ) +{ + if ( forceClose) + myQueryClose = false; + close(); +} + +/*! + Puts the message to the status bar +*/ +void QAD_Desktop::putInfo ( const QString& msg ) +{ + if ( myStatusBar ) + myStatusBar->message ( msg ); +} + +/*! + Puts the message to the status bar for ms milli-seconds +*/ +void QAD_Desktop::putInfo ( const QString& msg, int ms ) +{ + if ( myStatusBar ) + myStatusBar->message ( msg, ms ); +} + +/*! + Returns the standard toolbar +*/ +QMenuBar* QAD_Desktop::getMainMenuBar() const +{ + return myMainMenu; +} + +/*! + Returns the standard toolbar +*/ +QToolBar* QAD_Desktop::getStdToolBar() const +{ + return myStdToolBar; +} + +/*! + Updates desktop panel (menu, toolbar and status bar) according to current state of + the application. Calls update() for the active application. + The command { UD_ADD_APP or UD_REMOVE_APP ) specifies the desktop components + will be changed according to new active application. + This function is called after activating new study, closing current study etc. +*/ +void QAD_Desktop::updateDesktop( UpdateCommand cmd ) +{ + updateMenu( cmd ); + updateToolBars( cmd ); + updateStatusBar( cmd ); + updateActions(); +} + +/*! + Updates the desktop caption +*/ +void QAD_Desktop::updateCaption( UpdateCommand cmd ) +{ + if ( cmd == ActivateApp ) + { /* application's icon and title */ + setIcon( myActiveApp->getApplicationIcon() ); + setCaption( myActiveApp->getApplicationName() ); + } + else + { /* default icon and title */ + setIcon( myDefaultIcon ); + setCaption( myDefaultTitle ); + } +} + +/*! + Updates status bar when a new application becomes current +*/ +void QAD_Desktop::updateStatusBar( UpdateCommand cmd ) +{ + if ( myActiveApp ) + { + bool activate = ( cmd == ActivateApp ); + myActiveApp->updateStatusBar ( myStatusBar, activate ); + } +} + +/*! + Updates toolbars according to current active application. + This function is called from updateDesktop(). +*/ +void QAD_Desktop::updateToolBars( UpdateCommand cmd ) +{ + if ( myActiveApp ) + { + bool activate = ( cmd == ActivateApp ); + myActiveApp->updateToolBars ( activate ); + } +} + +/*! + Updates main menu bar of the application when application is activated + or deactivated. + This function is called by updateDesktop() +*/ +void QAD_Desktop::updateMenu( UpdateCommand cmd ) +{ + if ( myActiveApp ) + { + bool activate = ( cmd == ActivateApp ); + myActiveApp->updateFilePopup( &myFilePopup, activate, myFilePos ); + myActiveApp->updateEditPopup( &myEditPopup, activate, myEditPos ); + myActiveApp->updateViewPopup( &myViewPopup, activate, myViewPos ); + myActiveApp->updateHelpPopup( &myHelpPopup, activate, myHelpPos ); + myActiveApp->updateMainMenu( myMainMenu, activate, myMainMenuPos ); + + /* NOTE: + Since 'Edit' popup is completely customized by applications + desktop doesn't show it in main menubar without the active + application and we insert/remove this popup from the menubar + when activating/deactivating applications. + + We can't have 'Edit' popup be customized by an application + via UpdateMainMenu() method because applications may insert + its items to the menubar only AFTER 'View' item ( this fact + is respected by myMainMenuPos ) and the possibility of an + application to add its items into any arbitrary positions of + the main menubar requires a bit sophisticated implementation, + so we decided to avoid it, sorry :-(. + */ +#if defined( DEBUG ) + if ( !activate ) + /* applications MUST clear 'Edit' after themselves */ + QAD_ASSERT_DEBUG_ONLY( !myEditPopup.count() ); +#endif + + if ( activate ) /* insert after 'File' item */ + myMainMenu->insertItem( tr("MEN_DESK_EDIT"), &myEditPopup, 3, 1 ); + else + myMainMenu->removeItem( 3 ); + } +} + +/*! + Returns icon file name used by the application +*/ +const QPixmap& QAD_Desktop::getDefaultIcon() const +{ + static QPixmap defaultPixmap( QAD_Desktop::getResourceManager()->loadPixmap( "QAD", + tr("ICON_DESK_DEFAULTICON") )); + return defaultPixmap; +} + +/*! + Returns name of the application used as the title of desktop panel +*/ +const QString& QAD_Desktop::getDefaultTitle() const +{ + static QString defaultTitle ( tr("DESK_DEFAULTTITLE") ); + return defaultTitle; +} + +/*! + Returns default name of new studies +*/ +const QString& QAD_Desktop::getDefaultStudyName() const +{ + static QString defaultStudyName( tr("DESK_DEFAULTDOC") ); + return defaultStudyName; +} + +/*! + Returns next name for new study +*/ +QString QAD_Desktop::getNewStudyName() +{ + QString number; + number.sprintf( "%d", ++myCntUntitled ); + return ( getDefaultStudyName() + number ); +} + +/*! + Searches QAD_Study corresponding to , returns NULL if fails +*/ +QAD_Study* QAD_Desktop::findStudy( SALOMEDS::Study_ptr theStudy ) +{ + for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) { + QList studies; + studies.setAutoDelete( false ); + studies = app->getStudies(); + for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { + if ( study->getStudyDocument()->_is_equivalent( theStudy ) ) + return study; + } + } + return 0; +} + +/*! + Returns current active application +*/ +QAD_Application* QAD_Desktop::getActiveApp() const +{ + return myActiveApp; +} + +/*! + Returns current active study +*/ +QAD_Study* QAD_Desktop::getActiveStudy() const +{ + return myActiveStudy; +} + +/*! + Returns main frame +*/ +QWorkspaceP* QAD_Desktop::getMainFrame() const +{ + return myWorkspace; +} + +/*! + Find or load Engine, given a container name and an engine name +*/ +Engines::Component_var QAD_Desktop::getEngine(const char *containerName, + const char *componentName) +{ + Engines::Component_var eng = + myEnginesLifeCycle->FindOrLoad_Component(containerName, + componentName); + return eng._retn(); +} + +/*! + gets application Help Window (and creates if necessary) +*/ +QAD_HelpWindow* QAD_Desktop::getHelpWindow() +{ + if (!myHelpWindow) { + myHelpWindow = new QAD_HelpWindow(); + connect(myHelpWindow, SIGNAL(helpWindowClosed()), this, SLOT(onHelpWindowClosed())); + } + return myHelpWindow; +} + +/*! + Called when desktop is closing +*/ +void QAD_Desktop::closeEvent ( QCloseEvent* e ) +{ + bool doClose = true; + if ( myQueryClose ) { + doClose = QAD_MessageBox::info2 ( this, tr("INF_DESK_EXIT"), + tr("QUE_DESK_EXIT"), tr ("BUT_OK"), + tr ("BUT_CANCEL"), QAD_YES, + 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(); + putInfo( tr("INF_CANCELLED") ); + return; + } + } + study->close(); + } + } + } + myQueryClose = true; + doClose ? e->accept() : e->ignore(); +} + +/*! + Called when desktop is resized +*/ +void QAD_Desktop::resizeEvent( QResizeEvent* e ) +{ + QMainWindow::resizeEvent( e ); + myWorkspace->setGeometry( 1,1, centralWidget()->width()-2, + centralWidget()->height()-2 ); +} + + +/*! + Terminates the application. +*/ +void QAD_Desktop::onExit() +{ + close(); +} + +/************************************************************************ +** Study operations +*************************************************************************/ + +/*! + Creates new study. + If several application are supported it displays dialog window + to choose type of study. +*/ +void QAD_Desktop::createStudy(){ + onNewStudy(); +} +void QAD_Desktop::onNewStudy() +{ + unsigned numApps = myApps.count(); + if ( numApps ) { + if ( numApps == 1 ) + onNewStudy ( myApps.at(0) ); + else { /* select the type of application for new study */ + Desktop_AppSelectionDlg selDlg( this, myApps ); + if ( selDlg.exec() == QDialog::Accepted ) { + onNewStudy ( selDlg.selectedApp() ); + } + } + } else { /* no applications available in desktop */ + QAD_MessageBox::error1( this, + tr("ERR_ERROR"), + tr("ERR_APP_NOAPP"), + tr("BUT_OK") ); + } +} + +/*! + Creates new study for the given application. + Calls the respective function of the application class. +*/ +void QAD_Desktop::onNewStudy( QAD_Application* app ) +{ + if ( !app ) return; + + /* create new study of the specific app */ + putInfo ( tr ("INF_DOC_CREATING") ); + QAD_Study* newStudy = app->newStudy(); + + if ( !newStudy ) { + /* can't create new study */ + QAD_MessageBox::error1( this, tr("ERR_ERROR"), + tr("ERR_DOC_CANTCREATE"), + tr("BUT_OK") ); + } + putInfo ( tr("INF_READY") ); +} + +/*! + Loads the existing study. +*/ +void QAD_Desktop::onLoadStudy() +{ + QString name, studyname, ext; + + SALOMEGUI_LoadStudiesDlg* aDlg = new SALOMEGUI_LoadStudiesDlg( this, "Load Study", TRUE); + + CORBA::Object_var obj = myNameService->Resolve("/myStudyManager"); + SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj); + ASSERT(! CORBA::is_nil(myStudyMgr)); + SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies(); + for (unsigned int ind = 0; ind < List->length();ind++) { + studyname = List[ind]; + aDlg->ListComponent->insertItem( studyname ); + } + + int retVal = aDlg->exec(); + studyname = aDlg->ListComponent->currentText(); + delete aDlg; + if (retVal == QDialog::Rejected) + return; + + if ( studyname.isNull() || studyname.isEmpty() ) + return; + + name = studyname; + name.replace( QRegExp(":"), "/" ); + + /* + Try to associate an application to the opened study. + Assumed that the association study<->application is unique. + */ + bool appFound = false; + putInfo ( tr("INF_DOC_OPENING") + " " + name ); + for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) + { + /* application found */ + if ( app->isStudyOpened( name ) ) + { + /* already opened: prompt for reopen */ + if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"), + tr("QUE_DOC_ALREADYOPEN").arg( name ), + tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO, + QAD_NO ) == QAD_NO ) + { + putInfo ( tr("INF_READY") ); + return; + } + /* now the study is closed to be re-opened */ + //don't ask user to remove study permanently + if (app->getStudyByName ( name ) != NULL) + onCloseStudy ( app->getStudyByName ( name ), false ); + else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )) != NULL) + onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )), false ); + } + appFound = true; + + /* open the study */ + QAD_Study* openStudy = app->loadStudy( studyname ); + if ( !openStudy ) { + QAD_MessageBox::error1( this, + tr("ERR_ERROR"), + tr("ERR_DOC_CANTOPEN") + "\n" + name, + tr("BUT_OK") ); + } + break; + } + + if ( !appFound ) { + QAD_MessageBox::error1( this, + tr("ERR_ERROR"), + tr("ERR_DOC_UNKNOWNTYPE"), + tr("BUT_OK") ); + } + putInfo ( tr("INF_READY") ); +} + +/*! + Opens the existing study. + Displays select file dialog and calls corresponding function of + application class + (application is defined according to extension of selected file). +*/ +void QAD_Desktop::onOpenStudy() +{ + QString name, ext; + + /* Select a file to open */ + name = selectFileName ( true ); + if ( name.isNull() || name.isEmpty() ) + return; + + // Workaround for non-existent files + QFileInfo fi(name); + if (!fi.exists() || !fi.isFile()) { + QAD_MessageBox::error1 ( this, tr("ERR_ERROR"), + tr("ERR_DOC_CANTOPEN") +": " + name, + tr("BUT_OK") ); + return; + } + + CORBA::Object_var obj = myNameService->Resolve("/myStudyManager"); + SALOMEDS::StudyManager_var myStudyMgr = SALOMEDS::StudyManager::_narrow(obj); + ASSERT(! CORBA::is_nil(myStudyMgr)); + SALOMEDS::ListOfOpenStudies_var List = myStudyMgr->GetOpenStudies(); + for (unsigned int ind = 0; ind < List->length();ind++) { + QString NameExistingStudy(List[ind]); + QString NameOpeningStudy = QAD_Tools::getFileNameFromPath( name, false ); + + if ( NameExistingStudy.compare( NameOpeningStudy ) == 0 ) { + if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"), + tr("QUE_DOC_ALREADYEXIST").arg( name ), + tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO, + QAD_NO ) == QAD_NO ) + { + putInfo ( tr("INF_READY") ); + return; + } +// else +// { +// onLoadStudy(); +// return; +// } + } + } + + /* + Try to associate an application to the opened study. + Assumed that the association study<->application is unique. + */ + bool appFound = false; + putInfo ( tr("INF_DOC_OPENING") + " " + name ); + for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) + { + QString ext = QAD_Tools::getFileExtensionFromPath ( name ); + if ( app->getStudyExtension() == ext ) + { + /* application found */ + if ( app->isStudyOpened( name ) ) + { + /* already opened: prompt for reopen */ + if ( QAD_MessageBox::warn2 ( this, tr("WRN_WARNING"), + tr("QUE_DOC_ALREADYOPEN").arg( name ), + tr ("BUT_YES"), tr ("BUT_NO"), QAD_YES, QAD_NO, + QAD_NO ) == QAD_NO ) + { + putInfo ( tr("INF_READY") ); + return; + } + /* now the study is closed to be re-opened */ + //don't ask user to remove study permanently + if (app->getStudyByName ( name ) != NULL) + onCloseStudy ( app->getStudyByName ( name ), false ); + else if (app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )) != NULL) + onCloseStudy ( app->getStudyByName ( QAD_Tools::getFileNameFromPath( name, false )), false ); + } + appFound = true; + + /* open the study */ + QAD_Study* openStudy = app->openStudy( name ); + if ( !openStudy ) { + QAD_MessageBox::error1( this, + tr("ERR_ERROR"), + tr("ERR_DOC_CANTOPEN") + "\n" + name, + tr("BUT_OK") ); + } else if (myActiveComp != "") { + QApplication::setOverrideCursor( Qt::waitCursor ); + loadComponentData(myActiveComp); + openStudy->updateObjBrowser(true); + QApplication::restoreOverrideCursor(); + } + break; + } + } + + if ( !appFound ) + { + QAD_MessageBox::error1( this, + tr("ERR_ERROR"), + tr("ERR_DOC_UNKNOWNTYPE"), + tr("BUT_OK")); + } + putInfo ( tr("INF_READY") ); +} + +bool QAD_Desktop::loadComponentData( const QString& compName ) +{ + // Open component's data in active study if any + MESSAGE("loadComponentData(): Opening component data") + if (!myActiveStudy) { + MESSAGE("loadComponentData(): No active study exists") + return false; + } + + Engines::Component_var comp ; + if ( compName.compare("Supervision") == 0 ) { + comp = getEngine( "SuperVisionContainer", compName) ; + } + else { + /* comp = ( compName.compare("Data1") != 0 ) ? getEngine( "FactoryServer", compName) : + getEngine( "FactoryServerPy", compName); + */ + comp = getEngine( "FactoryServer", compName); + if ( comp->_is_nil() ) + comp = getEngine( "FactoryServerPy", compName); + } + + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + SALOMEDS::SComponent_var SCO = SALOMEDS::SComponent::_narrow(aStudy->FindObject(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(); + B->LoadWith(SCO,driver); + op->finish(); + } else { + return false; + } + } else { + MESSAGE("loadComponentData(): Driver is null"); + return false; + } + } else { + MESSAGE("loadComponentData(): Engine is null"); + return false; + } + } else { + MESSAGE("loadComponentData(): SComponent is null"); + return false; + } + + return true; +} + +/*! + Saves the active study +*/ +bool QAD_Desktop::onSaveStudy() +{ + return onSaveStudy ( myActiveStudy ); +} + +/*! + Saves the given study +*/ +bool QAD_Desktop::onSaveStudy( QAD_Study* study ) +{ + if ( !study ) return true; + + if ( !study->isSaved() ) + return onSaveAsStudy ( study ); + + /* saving study... */ + QAD_Application* app = study->getApp(); + QAD_ASSERT_DEBUG_ONLY ( app ); + putInfo ( tr("INF_DOC_SAVING") + study->getTitle() ); + if ( !app->saveStudy( study ) ) + { + putInfo( tr("INF_CANCELLED") ); + return false; + } + + /* saved ok */ + putInfo ( tr("INF_DOC_SAVED").arg( "" ) ); + return true; +} + +/*! + Saves the active study under a new name +*/ +bool QAD_Desktop::onSaveAsStudy() +{ + return onSaveAsStudy( myActiveStudy ); +} + +/*! + Saves the given study under a new name +*/ +bool QAD_Desktop::onSaveAsStudy( QAD_Study* study ) +{ + if ( !study ) return true; + + /* Save study in a format supported by its application + */ + QAD_Application* app = study->getApp(); + QAD_ASSERT_DEBUG_ONLY ( app ); + + /* Select a file where to save + */ + QString name = selectFileName ( false ); + if ( name.isNull() || name.isEmpty() ) + { + putInfo( tr("INF_CANCELLED") ); + return false; + } + + /* Saving study + */ + putInfo ( tr("INF_DOC_SAVING") + name ); + if ( !app->saveAsStudy( study, name ) ) { + /* can't save the file */ + QAD_MessageBox::error1( this, + tr("ERR_ERROR"), + tr("ERR_DOC_CANTWRITE") + "\n" + name, + tr("BUT_OK") ); + putInfo(""); + return false; /* cannot save */ + } + putInfo ( tr("INF_DOC_SAVED").arg( name ) ); + return true; /* saved ok */ +} + +/*! + Closes the active study +*/ +bool QAD_Desktop::onCloseStudy() +{ + bool close = this->onCloseStudy ( myActiveStudy, true ); + if ( close && !myXmlHandler->myIdList.IsEmpty() ) { + clearMenus(); + myActiveComp = ""; + myCombo->setCurrentItem (0); + for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) { + aButton->setOn(false); + } + } + return close; +} + +/*! + Closes the given study and ask user to remove study + from the study manager permanently +*/ +bool QAD_Desktop::onCloseStudy( QAD_Study* study ) +{ + return onCloseStudy( study, true ); +} + +/*! + Closes the given study and ask user to remove study + from the study manager permanently if ask is equal true +*/ +bool QAD_Desktop::onCloseStudy( QAD_Study* study, bool ask ) +{ + bool removePerm = false; + + if ( ask ) + { + SALOMEGUI_CloseDlg aDlg( this ); + int res = aDlg.exec(); + + switch ( res ) + { + case 1: + //if ( study->isModified() ) + if ( !onSaveStudy( study ) ) { + putInfo( tr("INF_CANCELLED") ); + return false; + } + removePerm = true; + break; + case 2: + removePerm = true; + break; + case 3: + removePerm = false; + break; + case 0: + default: + putInfo( tr("INF_CANCELLED") ); + return false; + } + } + /* close active component */ + if (!myXmlHandler->myIdList.IsEmpty()) + { + clearMenus(); + myActiveComp=""; + myCombo->setCurrentItem (0); + for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) + aButton->setOn(false); + qApp->processEvents(); + } + /* close the study */ + return study->getApp()->closeStudy( study, removePerm ); +} + +// Displays study properties dialog box +void QAD_Desktop::onStudyProperties() +{ + if (myActiveStudy) { + // open transaction + QAD_Operation* op = new QAD_Operation( myActiveStudy ); + op->start(); + + SALOMEGUI_StudyPropertiesDlg aDlg(this); + int res = aDlg.exec(); + + if ( res == QDialog::Accepted && aDlg.isChanged() ) + op->finish(); + else + op->abort(); + + // T2.12 - add the word "locked" to study frame captions if study is locked + myActiveStudy->updateCaptions(); + } +} + + +/*! + locate all windows in cascade mode + and resize them +*/ +void QAD_Desktop::onCascade() +{ + myWorkspace->cascade(); + int w = myWorkspace->width(); + int h = myWorkspace->height(); + QWidgetList wList = myWorkspace->windowList(); + QWidgetListIt it(wList); + + for(;it.current(); ++it) + it.current()->resize(0.8*w, 0.8*h); +} + +/*! + called when help window closed +*/ +void QAD_Desktop::onHelpWindowClosed() +{ + myHelpWindow = 0; +} + +/*! + Called when 'view status bar' option + is switched on/off. +*/ +void QAD_Desktop::onViewStatusBar() +{ + bool show = myStdActions.at( ViewStatusBarId )->isOn(); + if ( show == myStatusBar->isVisible() ) + return; + if ( show ) + myStatusBar->show(); + else + myStatusBar->hide(); +} + +/*! + Called when View/Toolbars popup menu is about to show +*/ +void QAD_Desktop::onToolBarPopupAboutToShow() +{ + myToolBarAction.clear(); + myToolBarsPopup.clear(); + QPtrList wlist = dockWindows(); + for ( QDockWindow* w = wlist.first(); w; w = wlist.next() ) { + if ( w->inherits( "QToolBar" ) ) { + QToolBar* tb = ( QToolBar* )w; + if ( appropriate( tb ) ) { + ToggleAction* a = new ToggleAction( tb->label(), tb->label(), 0, this, 0, true ); + a->setStatusTip ( tr("PRP_DESK_VIEW_TOOLBAR") ); + a->setOn( tb->isVisible() ); + QAD_ASSERT( connect( a, SIGNAL( toggledOn() ), tb, SLOT( show() ) ) ); + QAD_ASSERT( connect( a, SIGNAL( toggledOff() ), tb, SLOT( hide() ) ) ); + a->addTo( &myToolBarsPopup ); + myToolBarAction.append( a ); + } + } + } +} + +/*! + Called on 'View\Selection Mode' +*/ +void QAD_Desktop::onSelectionMode() +{ + const QAction* obj = (QAction*) sender(); + + int SelectionMode = 4; + + if ( obj == myStdActions.at(SelectionActorId) ) { + SelectionMode = 4; + if ( obj->isOn() ) { + myStdActions.at(SelectionCellId)->setOn(false); + myStdActions.at(SelectionEdgeId)->setOn(false); + myStdActions.at(SelectionPointId)->setOn(false); + } else + myStdActions.at(SelectionActorId)->setOn(true); + + } else if ( obj == myStdActions.at(SelectionCellId) ) { + SelectionMode = 3; + if ( obj->isOn() ) { + myStdActions.at(SelectionActorId)->setOn(false); + myStdActions.at(SelectionEdgeId)->setOn(false); + myStdActions.at(SelectionPointId)->setOn(false); + } else + myStdActions.at(SelectionActorId)->setOn(true); + + } else if ( obj == myStdActions.at(SelectionEdgeId) ) { + SelectionMode = 2; + if ( obj->isOn() ) { + myStdActions.at(SelectionActorId)->setOn(false); + myStdActions.at(SelectionCellId)->setOn(false); + myStdActions.at(SelectionPointId)->setOn(false); + } else + myStdActions.at(SelectionActorId)->setOn(true); + + } else if ( obj == myStdActions.at(SelectionPointId) ) { + SelectionMode = 1; + if ( obj->isOn() ) { + myStdActions.at(SelectionEdgeId)->setOn(false); + myStdActions.at(SelectionCellId)->setOn(false); + myStdActions.at(SelectionActorId)->setOn(false); + } else + myStdActions.at(SelectionActorId)->setOn(true); + } + + QAD_StudyFrame* sf = myActiveApp->getActiveStudy()->getActiveStudyFrame(); + sf->getRightFrame()->getViewFrame()->SetSelectionMode( SelectionMode ); + + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveApp->getActiveStudy()->getSelection() ); + Sel->SetSelectionMode( SelectionMode ); +} + +/*! + Called on 'View\Selection Mode' +*/ +void QAD_Desktop::SetSelectionMode(int mode, bool activeCompOnly) +{ + switch (mode) { + case 1: + { + myStdActions.at(SelectionEdgeId)->setOn(false); + myStdActions.at(SelectionCellId)->setOn(false); + myStdActions.at(SelectionActorId)->setOn(false); + myStdActions.at(SelectionPointId)->setOn(true); + break; + } + case 2: + { + myStdActions.at(SelectionActorId)->setOn(false); + myStdActions.at(SelectionCellId)->setOn(false); + myStdActions.at(SelectionPointId)->setOn(false); + myStdActions.at(SelectionEdgeId)->setOn(true); + break; + } + case 3: + { + myStdActions.at(SelectionActorId)->setOn(false); + myStdActions.at(SelectionEdgeId)->setOn(false); + myStdActions.at(SelectionPointId)->setOn(false); + myStdActions.at(SelectionCellId)->setOn(true); + break; + } + case 4: + { + myStdActions.at(SelectionCellId)->setOn(false); + myStdActions.at(SelectionEdgeId)->setOn(false); + myStdActions.at(SelectionPointId)->setOn(false); + myStdActions.at(SelectionActorId)->setOn(true); + break; + } + } + + QAD_StudyFrame* sf = myActiveApp->getActiveStudy()->getActiveStudyFrame(); + if ( sf->getTypeView() == VIEW_VTK ) { + sf->getRightFrame()->getViewFrame()->SetSelectionMode( mode ); + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveApp->getActiveStudy()->getSelection() ); + Sel->SetSelectionMode( mode, activeCompOnly ); + } else { + } +} + +/*! + Called on 'Window\NewWindow3d' +*/ +void QAD_Desktop::onNewWindow3d() +{ + //NRI : SAL2214 + /* + //VRV: T2.5 - add default viewer + QApplication::restoreOverrideCursor(); + SALOMEGUI_ViewChoiceDlg *choice = new SALOMEGUI_ViewChoiceDlg(this, "", TRUE); + int r = choice->exec(); + if (r) + { + myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(choice->getSelectedViewer())); + } + //VRV: T2.5 - add default viewer + */ + const QAction* obj = (QAction*) sender(); + if ( obj == myStdActions.at(ViewOCCId) ) { + myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(0)); + } else if ( obj == myStdActions.at(ViewVTKId) ) { + myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(1)); + } else if ( obj == myStdActions.at(ViewPlot2dId) ) { + myActiveApp->getActiveStudy()->newWindow3d(QString(""),(ViewType)(3)); + } + //NRI : SAL2214 +} + +/*! + Called on 'help\contents' +*/ +void QAD_Desktop::onHelpContents() +{ + if (myActiveApp) + myActiveApp->helpContents(); + else + helpContents(); +} + +/*! + Called on 'help\search' +*/ +void QAD_Desktop::onHelpSearch() +{ + if (myActiveApp) + myActiveApp->helpSearch(); + else + helpSearch(); +} + +/*! + Called on 'help\about' +*/ +void QAD_Desktop::onHelpAbout() +{ + if (myActiveApp) + myActiveApp->helpAbout(); + else + helpAbout(); +} + + +/*! + Activates the application and its active study +*/ +void QAD_Desktop::onActivateApp( QAD_Application* activeApp ) +{ + bool appChanged = ( activeApp != myActiveApp ); + if ( appChanged ) + { + updateDesktop( DeactivateApp ); + } + if ( activeApp ) + { + myActiveApp = activeApp; + myActiveStudy = myActiveApp->getActiveStudy(); + } + else + { + myActiveApp = 0; + myActiveStudy = 0; + } + + if ( appChanged ) + { + updateDesktop( ActivateApp ); + updateCaption( (activeApp != NULL) ? ActivateApp : DeactivateApp ); + } + updateActions(); +} + +/*! + Called when the last study is removed from + the application 'app'. +*/ +void QAD_Desktop::onDeactivateApp(QAD_Application* app) +{ + if ( app && app == myActiveApp ) + onActivateApp( 0 ); +} + +/*! + Enables/disables standard actions +*/ +void QAD_Desktop::updateActions() +{ + myStdActions.at( FileCloseId )->setEnabled ( myActiveStudy != NULL ); + myStdActions.at( FileSaveId )->setEnabled ( myActiveStudy != NULL ); + myStdActions.at( FileSaveAsId )->setEnabled ( myActiveStudy != NULL ); + myStdActions.at( FilePropsId )->setEnabled( myActiveStudy != NULL ); +// myStdActions.at( HelpContentsId )->setEnabled ( myActiveApp != NULL ); +// myStdActions.at( HelpSearchId )->setEnabled ( myActiveApp != NULL ); +// myStdActions.at( HelpWhatsThisId )->setEnabled ( myActiveApp != NULL ); +// myStdActions.at( HelpAboutId )->setEnabled ( myActiveApp != NULL ); + +// myToolsPopup.setEnabled ( myActiveStudy != NULL ); +// myPrefPopup.setEnabled ( myActiveStudy != NULL ); + + mySelectionModePopup.setEnabled ( myActiveStudy != NULL ); +} + +/*! + Called when 'Window' popup is about to show +*/ +void QAD_Desktop::onWindowPopupAboutToShow() +{ + /* add cascade/tile items */ + myWindowPopup.clear(); + + //NRI : SAL2214 + //myStdActions.at( WindowNew3dId )->addTo( &myWindowPopup ); + myWindowPopup.insertItem( tr("MEN_DESK_WINDOW_NEW3D"), &myNewViewPopup, WindowNew3dId ); + //myStdActions.at( WindowNew3dId )->setEnabled( true ); + myWindowPopup.setItemEnabled( WindowNew3dId, true ); + //NRI : SAL2214 + myStdActions.at( WindowCascadeId )->addTo( &myWindowPopup ); + myStdActions.at( WindowCascadeId )->setEnabled( true ); + myStdActions.at( WindowTileId )->addTo( &myWindowPopup ); + myStdActions.at( WindowTileId )->setEnabled( true ); + + /* add names of opened studies */ + QWidgetList windows = myWorkspace->windowList(); + if ( windows.isEmpty() ) + { + //NRI : SAL2214 myStdActions.at( WindowNew3dId )->setEnabled( false ); + myWindowPopup.setItemEnabled( WindowNew3dId, false ); + //NRI : SAL2214 + myStdActions.at( WindowCascadeId )->setEnabled( false ); + myStdActions.at( WindowTileId )->setEnabled( false ); + } + else + { + myWindowPopup.insertSeparator(); + for ( int i = 0; i < int(windows.count()); ++i ) + { + int id = myWindowPopup.insertItem( windows.at(i)->caption(), + this, SLOT( onWindowsPopupActivated( int ) ) ); + myWindowPopup.setItemParameter( id, i ); + myWindowPopup.setItemChecked( id, myWorkspace->activeWindow() == windows.at(i) ); + } + QAD_ASSERT( connect( &myWindowPopup, SIGNAL(highlighted( int )), this, + SLOT(onWindowsPopupStatusText( int )) )); + } +} + +/*! + Called when the item with 'id' of 'Windows' popup + is highlighted +*/ +void QAD_Desktop::onWindowsPopupStatusText( int id ) +{ + int cascadeId = myWindowPopup.idAt( 0 ); + int tileId = myWindowPopup.idAt( 1 ); + if ( id == cascadeId || id == tileId ) + return; + putInfo( tr("PRP_DESK_WINDOW_ACTIVATE") ); +} + +/*! + Called when user wants to activate a child window with 'wid' + in the main frame +*/ +void QAD_Desktop::onWindowsPopupActivated( int wid ) +{ + QWidget* w = myWorkspace->windowList().at( wid ); + if ( w ) w->setFocus(); +} + +/*! + Selects a file name when opening or saving files. + The basic implementation just uses the standard + Open/Save dialogs. + Please redefine if another behaviour is required. +*/ +QString QAD_Desktop::selectFileName ( bool open ) +{ + QAD_FileDlg* fd = new QAD_FileDlg( this, open, true, true ); + + QString name = ""; + QString dir = ""; + QStringList filters; + + if (open) { + // All the file types of the supported applications + // can be opened + for ( QAD_Application* app = myApps.first(); app; app = myApps.next() ) + { + filters += app->getStudyDescription() + " " + tr("DESK_FILES") + " " + + "(*." + app->getStudyExtension() + ")"; + } + } + else { + QAD_ASSERT_DEBUG_ONLY ( myActiveStudy ); + if (myActiveStudy) { + // get file name of active study + name = QAD_Tools::getFileNameFromPath ( myActiveStudy->getTitle() ); + // get path to the active study file + dir = QAD_Tools::getDirFromPath ( myActiveStudy->getPath(), false ); + } + QAD_ASSERT_DEBUG_ONLY ( !name.isNull() ); + // the file types supported by the active application + filters += myActiveApp->getStudyDescription() + " " + tr("DESK_FILES") + " " + + "(*." + myActiveApp->getStudyExtension() + ")" ; + } + if (!dir.isEmpty()) { + // when saving document ("Save As" command) - to get dir from active study filename + // for new documents - to use last opened directory + fd->setDir( dir ); + } + fd->setSelection( name ); + fd->setFilters( filters ); + + fd->exec(); + QString filename = fd->selectedFile(); + delete fd; + qApp->processEvents(); + return filename; +} + +/*! + Closes all the studies of 'app'. Returns + 'true' if thay are closed OK, 'false' at least + one can't be closed or user cancel the closure. +*/ +bool QAD_Desktop::closeAllStudies( QAD_Application* app ) +{ + QList& studies = app->getStudies(); + while ( !studies.isEmpty() ) + { + //don't ask user to remove study permanently + if ( !onCloseStudy( studies.at(0), false ) ) + return false; /* user cancelled closing */ + } + return true; +} + +/*! + Called on Popup item when SComponent representation in Object Browser is selected. +*/ +void QAD_Desktop::onOpenWith() +{ + Engines::Component_var comp; + QString ComponentSelected; + + SALOMEDS::SObject_var SO; + SALOMEDS::SComponent_var SCO; + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + if ( Sel->IObjectCount() == 1 ) { + Handle(SALOME_InteractiveObject) IO = Sel->firstIObject(); + SO = aStudy->FindObjectID( IO->getEntry() ); + SCO = SO->GetFatherComponent(); + char* name; + if (SCO->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + name = aName->Value(); + SALOME_ModuleCatalog::Acomponent_var Comp = myCatalogue->GetComponent( name ); + if ( !Comp->_is_nil() ) { + + SALOME_ModuleCatalog::ListOfComponents_var list_type_composants = + myCatalogue->GetTypedComponentList( Comp->component_type() ); + + if ( list_type_composants->length() == 1 ) { + ComponentSelected = name; + } else if ( list_type_composants->length() > 1 ) { + SALOMEGUI_OpenWith* aDlg = new SALOMEGUI_OpenWith( this ); + for (unsigned int ind = 0; ind < list_type_composants->length();ind++) { + aDlg->addComponent( strdup(list_type_composants[ind]) ); + } + + int retVal = aDlg->exec(); + ComponentSelected = aDlg->getComponent(); + delete aDlg; + if ( retVal == QDialog::Rejected || ComponentSelected.isEmpty()) { + return; + } + } else { + MESSAGE( "No component with type : " << Comp->component_type() << " exists" ); + return; + } + + } else { + MESSAGE( "This component not exists in the catalog" ); + return; + } + + QApplication::setOverrideCursor( Qt::waitCursor ); + Sel->ClearIObjects(); + +// if (loadComponentData(ComponentSelected)) { + onComboActiveComponent(ComponentSelected); +// int nbItem = myCombo->count(); +// int Index = 0; +// for (int i = 0; i < nbItem; i++) { +// if (myCombo->text(i).compare(ComponentSelected)==0) { +// Index = i; +// break; +// } +// } +// myCombo->setCurrentItem(Index); +// myActiveStudy->updateObjBrowser(true); +// } + } + } + QApplication::restoreOverrideCursor(); +} + +typedef bool OneDim1(QAD_Desktop*); + +/*! + Called to define settings of component. +*/ +void QAD_Desktop::setSettings() +{ + if (!myActiveComp.isEmpty()) { + OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings"); + if ( osdF != NULL ) { + OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF; + (*f1)(this); + } + } +} + +/*! + Called to load Component : xml resources and GUI librairy. +*/ +bool QAD_Desktop::loadComponent(QString Component) +{ + QAD_WaitCursor wc; + QString resDir("/"); //NRI : Pb under Windows + + QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); + if ( resMgr ) { + QString msg; + if (!resMgr->loadResources( Component + "GUI", msg )) + { + //NRI QCString errMsg; + // errMsg.sprintf( "Do not load all resources for module %sGUI.\n" , + // Component.latin1() ); + wc.stop(); + QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") ); + return false; + } + } + + /* Parse xml file */ + myXmlHandler = new QAD_XmlHandler(); + myXmlHandler->setMainWindow(this); + if (!myXmlHandler->setComponent(resMgr->resources(Component + "GUI"))) return false; + + QString language = resMgr->language( Component + "GUI" ); + + QString ComponentXml = Component + "_" + language + ".xml"; + //ComponentXml = resMgr->resources(Component + "GUI") ; + //ComponentXml = QAD_Tools::addSlash(ComponentXml) ; + ComponentXml = QAD_Tools::addSlash( resMgr->findFile( ComponentXml, Component + "GUI" ) ) + ComponentXml; + QFile file( ComponentXml ); + + if ( !file.exists() || !file.open( IO_ReadOnly ) ) { + QString errMsg; + errMsg.sprintf( "Cannot open xml file: %s\n.", + (file.name()).latin1() ); + wc.stop(); + QMessageBox::critical( this, tr("ERR_ERROR"), errMsg, tr ("BUT_OK") ); + return false; + } + file.close(); + + QXmlInputSource source( file ); + QXmlSimpleReader reader; + reader.setContentHandler( myXmlHandler ); + reader.setErrorHandler( myXmlHandler ); + bool ok = reader.parse( source ); + file.close(); + if ( !ok ) { + wc.stop(); + QMessageBox::critical( this, + tr( "INF_PARSE_ERROR" ), + tr( myXmlHandler->errorProtocol() ) ); + return false; + } + + myMenusList=myXmlHandler->myMenusList; + myActiveMenus=myMenusList.at(0); + myOperatorMenus->showMenuBar(0); + myActiveMenus->showAllToolBars(); + + /* Components toolbars */ + int nbToolbars = 0; + if (myActiveMenus) + nbToolbars = myActiveMenus->getToolBarList().count(); + /* Open Shared Library */ + mySharedLibrary = OSD_SharedLibrary(); + + QString ComponentLib; + QCString dir; + QFileInfo fileInfo ; + bool found = false; + if ( dir = getenv("SALOME_SITE_DIR")) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "lib" + Component.latin1() + "GUI.dll" ; +#else + dir = dir + "lib" + Component.latin1() + "GUI.so" ; +#endif + MESSAGE ( " GUI library = " << dir ) + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ComponentLib = fileInfo.fileName() ; + found = true; + } + } + + if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "lib" + Component.latin1() + "GUI.dll" ; +#else + dir = dir + "lib" + Component.latin1() + "GUI.so" ; +#endif + MESSAGE ( " GUI library = " << dir ) + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ComponentLib = fileInfo.fileName() ; + found = true; + } + } + + mySharedLibrary.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString()); + ok = mySharedLibrary.DlOpen(OSD_RTLD_LAZY); + if (!ok) { + wc.stop(); + QMessageBox::critical( this, + tr("ERR_ERROR"), + tr( mySharedLibrary.DlError() ) ); + return false; + } + + /* SETTINGS */ + OSD_Function osdF = mySharedLibrary.DlSymb("SetSettings"); + if ( osdF != NULL ) { + OneDim1 (*f1) = (bool (*) (QAD_Desktop*)) osdF; + (*f1)(this); + } + + /* COMPONENT INTERFACE */ + SALOME_ModuleCatalog::Acomponent_ptr aComponent = + myCatalogue->GetComponent(Component.latin1()); + + if (CORBA::is_nil (aComponent)) { + MESSAGE( "Catalog Error : Component not found in the catalog" ) + return false; + } + + myActiveStudy->setMessage(QString("Component : ") + + aComponent->componentname() + " created " ); + myActiveStudy->setMessage(QString("Type : ") + + QString::number(aComponent->component_type())); + myActiveStudy->setMessage(QString("Constraint : ") + + aComponent->constraint() ); + + /* obtain interfaces list of the component */ + SALOME_ModuleCatalog::ListOfInterfaces_var _list = + new SALOME_ModuleCatalog::ListOfInterfaces; + _list = aComponent->GetInterfaceList(); + + if (_list->length() != 0 ) { + + for (unsigned int ind = 0; ind < _list->length();ind++) + myActiveStudy->setMessage( QString("Interface name : ") + + _list[ind] ); + + + /* obtain services list of the component */ + SALOME_ModuleCatalog::ListOfServices_var list_services_component = + new SALOME_ModuleCatalog::ListOfServices; + list_services_component = aComponent->GetServiceList(_list[0]); + + if (list_services_component->length() != 0 ) { + + for (unsigned int ind = 0; ind < list_services_component->length();ind++) + myActiveStudy->setMessage( QString("Service name : ") + + list_services_component[ind] ); + + // Get a service of the component + SALOME_ModuleCatalog::Service_var service = new SALOME_ModuleCatalog::Service; + service = aComponent->GetService(_list[0],list_services_component[0]) ; + myActiveStudy->setMessage( QString("Service name: ") + service->ServiceName); + for (unsigned int ind1 = 0; ind1 ServiceinParameter.length();ind1++) { + myActiveStudy->setMessage( QString("Type of the in Parameter of this service : ") + + (const char *) service->ServiceinParameter[ind1].Parametertype); + myActiveStudy->setMessage( QString("Name of the in Parameter of this service : ") + + (const char *) service->ServiceinParameter[ind1].Parametername); + } + for (unsigned int ind1 = 0; ind1 ServiceoutParameter.length();ind1++) { + myActiveStudy->setMessage( QString("Type of the out Parameter of this service : ") + + (const char *) service->ServiceoutParameter[ind1].Parametertype); + myActiveStudy->setMessage( QString("Name of the out Parameter of this service : ") + + (const char *) service->ServiceoutParameter[ind1].Parametername); + } + } + } + return true; +} + +typedef bool OneDim(int, QAD_Desktop*); +typedef void (*PTR_FACTORY_FUNCTION)( CORBA::ORB_var &orb, QWidget *parent, const char *name ) ; + +/*! + */ +void QAD_Desktop::onDispatch() +{ + const QObject* obj = sender(); + + QList MenuList = myActiveMenus->getMenuList(); + QAD_ListMenuIdAction* aMenu; + int id = -1; + for(aMenu=MenuList.first();aMenu!=NULL;aMenu=MenuList.next()) { + if (aMenu->getAction()==obj) { + id = aMenu->getId(); + break; + } + } + onDispatch(id); +} + +/*! + */ +void QAD_Desktop::onDispatchTools(int id) +{ + /* Open Shared Library */ + OSD_SharedLibrary ToolsLibrary = OSD_SharedLibrary(); + + QString ToolsLib; + QCString dir; + QFileInfo fileInfo ; + bool found = false; + + char arg[256] ; + bool libToolsGUI = true; + if( QAD_XmlHandler::_bibmap[ id ].isEmpty() ) + { + + if ( dir = getenv("SALOME_SITE_DIR")) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "libToolsGUI.dll" ; +#else + dir = dir + "libToolsGUI.so" ; +#endif + MESSAGE ( " GUI library = " << dir ); + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ToolsLib = fileInfo.fileName() ; + found = true; + } + } + + if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "libToolsGUI.dll" ; +#else + dir = dir + "libToolsGUI.so" ; +#endif + MESSAGE ( " GUI library = " << dir ); + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ToolsLib = fileInfo.fileName() ; + found = true; + } + } + } + else { + libToolsGUI = false; + SCRUTE( QAD_XmlHandler::_bibmap[ id ] ) ; + if ( dir = getenv("SALOME_SITE_DIR")) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + QAD_XmlHandler::_bibmap[ id ].latin1() ; + MESSAGE ( " GUI library = " << dir ); + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ToolsLib = fileInfo.fileName() ; + found = true; + } + } + + if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + QAD_XmlHandler::_bibmap[ id ].latin1() ; + MESSAGE ( " GUI library = " << dir ); + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ToolsLib = fileInfo.fileName() ; + found = true; + } + } + } + + ToolsLibrary.SetName(TCollection_AsciiString((char*)ToolsLib.latin1()).ToCString()); + bool ok = ToolsLibrary.DlOpen(OSD_RTLD_LAZY); + if (ok) { + if ( libToolsGUI ) { + OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent"); + OneDim (*f1) = NULL; + f1 = (bool (*) (int, QAD_Desktop*)) osdF; + (*f1)(id,this); + } else { + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + CORBA::ORB_var &orb = init(0 , 0 ) ; + OSD_Function osdF = ToolsLibrary.DlSymb("OnGUIEvent"); + PTR_FACTORY_FUNCTION f1 = NULL; + f1 = (PTR_FACTORY_FUNCTION) osdF; + f1(orb,0,"Registry"); + } + } else { + QMessageBox::critical( this, + tr("ERR_ERROR"), + tr( ToolsLibrary.DlError() ) ); + } +} + +/*! + */ +void QAD_Desktop::onDispatch(int id) +{ + if (!myActiveComp.isEmpty()) { + OSD_Function osdF = mySharedLibrary.DlSymb("OnGUIEvent"); + OneDim (*f1) = NULL; + if ( osdF != NULL ) { + f1 = (bool (*) (int, QAD_Desktop*)) osdF; + (*f1)(id,this); + } + } +} + +/*! + Returns the component's catalogue +*/ +SALOME_ModuleCatalog::ModuleCatalog_var QAD_Desktop::getCatalogue() +{ + return myCatalogue; +} + +/*! + */ +void QAD_Desktop::onComboActiveComponent( const QString & component ){ + onComboActiveComponent(component,true); +} +void QAD_Desktop::onComboActiveComponent( const QString & component, bool isLoadData) +{ + if (myActiveStudy != 0) { + if (myActiveComp.compare(component)!=0) { + if (!myXmlHandler->myIdList.IsEmpty()) clearMenus(); + if ( myCombo->currentText() != component ) + myCombo->setCurrentText( component ); + if (component.compare(QString("Salome"))!= 0) { +// QApplication::setOverrideCursor( Qt::waitCursor ); + myActiveComp = component; + + SALOME_Selection* oldSel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + + for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) { + if ( aButton->textLabel().compare(component)==0) + aButton->setOn(true); + else + aButton->setOn(false); + } + + myActiveStudy->Selection( component ); + if ( !loadComponent(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() ); + for(;It.More();It.Next()) { + int res = Sel->AddIObject( It.Value() ); + + if ( res == -1 ) + myActiveStudy->highlight( It.Value(), false ); + if ( res == 0 ) + myActiveStudy->highlight( It.Value(), true ); + + } + + // Open new component's data in active study if any + if(isLoadData) loadComponentData(component); + + oldSel->Clear(); + myActiveStudy->updateObjBrowser(true); + +// QApplication::restoreOverrideCursor(); + + } else { // component == "Salome" + myActiveComp = ""; + myActiveStudy->Selection( "Salome" ); + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + Sel->ClearIObjects(); + for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) { + aButton->setOn(false); + } + } + } else { + for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) { + if ( aButton->textLabel().compare(component)==0) + aButton->setOn(true); + } + } + } else { + QMessageBox::critical( 0, + tr( "ERR_ERROR" ), + tr( "WRN_LOAD_COMPONENT" ) ); + myCombo->setCurrentItem (0); + for ( QToolButton* aButton=myComponentButton.first(); aButton; aButton=myComponentButton.next() ) { + aButton->setOn(false); + } + } +} + +/*! + */ +void QAD_Desktop::activateComponent(const QString& theName, bool isLoadData){ + int nbItem = myCombo->count(); + int Index = 0; + + for (int i = 0; i < nbItem; i++) { + if (myCombo->text(i).compare(theName)==0) { + Index = i; + break; + } + } + myCombo->setCurrentItem (Index); + onComboActiveComponent(theName,isLoadData); +}; + +void QAD_Desktop::onButtonActiveComponent( ) +{ + QToolButton* obj = (QToolButton*)sender(); + activateComponent(obj->textLabel()); +} + +/*! + Clears All Resources of current component + */ +void QAD_Desktop::clearMenus() +{ + onActiveStudyChanged(); + + /* menus */ + myMenusList.clear(); + if (myXmlHandler) { + int length = myXmlHandler->myIdList.Length(); + for (int k=length; k>0; k--) { + QMenuData* parent; + if ( menuBar()->findItem(myXmlHandler->myIdList.Value(k), &parent) ) + parent->removeItem( myXmlHandler->myIdList.Value(k) ); + } + } + + /* toolbars */ + if (myActiveMenus) { + int nbtoolbars = myActiveMenus->getToolBarList().count(); + for (int k=0; kgetToolBarList().at(k)->hide(); + myActiveMenus->getToolBarList().at(k)->clear(); + } + myActiveMenus->clearToolBar(); + + /* popups */ + QList PopupList = myActiveMenus->getPopupMenuList(); + QAD_ListPopupMenu* aPopup; + for(aPopup=PopupList.first();aPopup!=NULL;aPopup=PopupList.next()){ + aPopup->getPopup()->clear(); + + } + myActiveMenus->clearPopupMenu(); + + } + myActiveComp = ""; +} + +typedef bool TwoDim1(QKeyEvent* pe, QAD_Desktop*, QAD_StudyFrame*); +/*! + Exports Key Events in active component ( GUI Librairy ) + */ +void QAD_Desktop::onKeyPress( QKeyEvent* pe ) +{ + // MESSAGE ( "QAD_Desktop::onKeyPress" ) + if (!myActiveComp.isEmpty()) { + OSD_Function osdF = mySharedLibrary.DlSymb("OnKeyPress"); + if ( osdF != NULL ) { + TwoDim1 (*f1) = (bool (*) (QKeyEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF; + (*f1)(pe,this,myActiveStudy->getActiveStudyFrame()); + } + } +} + +typedef bool TwoDim(QMouseEvent* pe, QAD_Desktop*, QAD_StudyFrame*); +/*! + Exports Mouse Press Events in active component ( GUI Librairy ) + */ +bool QAD_Desktop::onMousePress( QMouseEvent* pe ) +{ + // MESSAGE ( "QAD_Desktop::onMousePress" ) + if (!myActiveComp.isEmpty()) { + OSD_Function osdF = mySharedLibrary.DlSymb("OnMousePress"); + if ( osdF != NULL ) { + TwoDim (*f1) = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF; + return (*f1)(pe,this,myActiveStudy->getActiveStudyFrame()); + } + } + return false; +} + +/*! + Exports Mouse Move Events in active component ( GUI Librairy ) + */ +void QAD_Desktop::onMouseMove( QMouseEvent* pe ) +{ + if (!myActiveComp.isEmpty()) { + OSD_Function osdF = mySharedLibrary.DlSymb("OnMouseMove"); + if ( osdF != NULL ) { + TwoDim (*f1) = (bool (*) (QMouseEvent*, QAD_Desktop*, QAD_StudyFrame*)) osdF; + (*f1)(pe,this,myActiveStudy->getActiveStudyFrame()); + } + } +} + +/*! + Returns name of active component +*/ +const QString& QAD_Desktop::getActiveComponent() const +{ + return myActiveComp; +} + + +typedef bool defineP( QString & theContext, QString & theParent, QString & theObject); + +void QAD_Desktop::definePopup(QString & theContext, + QString & theParent, + QString & theObject ) +{ + if (!myActiveComp.isEmpty()) { + OSD_Function osdF = mySharedLibrary.DlSymb("definePopup"); + if ( osdF != NULL ) { + defineP (*f1) = (bool (*) (QString &, QString &, QString &)) osdF; + (*f1)(theContext, theParent, theObject); + } + } +} + +/*! + Create popup +*/ +void QAD_Desktop::createPopup(QPopupMenu* popupFather, QPopupMenu* popup, + QString text, int popupID, bool separator) +{ + QMenuItem* item = popup->findItem(popupID); + if (item) { + QPopupMenu* popupChild = item->popup(); + if ( popupChild ) { + QPopupMenu* newPopup = new QPopupMenu; + int count = popupChild->count(); + // add items at the top of + for (int i = count - 1; i >= 0; i--) { + int j = popupChild->idAt(i); + QString text = popupChild->text(j); + createPopup( newPopup, popupChild, text, j); + } + popupFather->insertItem(popup->text(popupID), + newPopup, popupID, 0); + } else { + if ( !text.isNull() ) { + popupFather->insertItem(popup->text(popupID), + this, + SLOT( onDispatch(int) ), 0, popupID, 0);// try adding item at the top + } /*else if ( separator ) + popupFather->insertTearOffHandle(-1, 0);*/ + else + popupFather->insertSeparator(0); + } + } +} + +/*! + Create popup +*/ +void QAD_Desktop::createPopup(QPopupMenu* popup, const QString & theContext, + const QString & theParent, const QString & theObject ) +{ + if ( !myActiveComp.isEmpty() && + getOperatorMenus()->createPopupMenu(theContext,theParent,theObject) != NULL ) { + QPopupMenu* aPopup = getOperatorMenus()->createPopupMenu(theContext,theParent,theObject)->getPopup(); + int count = aPopup->count(); + + //for (int i = 0; i < count; i++) { + for (int i = count - 1; i >= 0; i--) { + int id = aPopup->idAt(i); + QString text = aPopup->text(id); + //QString mes("Inserting popup menu item loaded from XML: "); + //mes += text; + //MESSAGE ( mes.latin1() ) + if (i==0) + popup->insertItem(aPopup->text(id), + this, + SLOT( onDispatch(int) ), 0, id, 0);// try adding item at the top + else + createPopup( popup, aPopup, text, id); + } + } //else { + //QString mes("Popup does not exist for given (Context = "); + //mes += theContext; + //mes += ", Parent = "; + //mes += theParent; + //mes += ", Object = "; + //mes += theObject; + //MESSAGE (mes.latin1()) + //popup->clear(); + //} + + // IAPP Popup + // Should be moved to SALOMEGUI_Application::onCreatePopup()... + if ( myActiveComp.isEmpty() ) { + popup->removeItem(QAD_Display_Popup_ID); + popup->removeItem(QAD_DisplayOnly_Popup_ID); + popup->removeItem(QAD_Erase_Popup_ID); + int id = popup->idAt(popup->count()-1); // last item + if (id < 0 && id != -1) popup->removeItem(id); // separator + + if ( popup && theParent.compare("ObjectBrowser")==0 ) { + if ( popup->count()>0 ) { + popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()), 0, -1, 2); + popup->insertSeparator (3); + } + else { + popup->insertItem (tr ("MEN_OPENWITH"), this, SLOT(onOpenWith()) ); + } + } + } + +} + +typedef bool activeStudyChanged(QAD_Desktop*); + +void QAD_Desktop::onActiveStudyChanged() +{ + if (!myActiveComp.isEmpty()) { + OSD_Function osdF = mySharedLibrary.DlSymb("activeStudyChanged"); + if ( osdF != NULL ) { + activeStudyChanged (*f1) = (bool (*) (QAD_Desktop*)) osdF; + (*f1)(this); + } + } +} + +typedef bool customP(QAD_Desktop*, QPopupMenu*, const QString & theContext, + const QString & theParent, const QString & theObject); +/*! + Custom popup ( GUI Library ) +*/ +void QAD_Desktop::customPopup(QPopupMenu* popup, const QString & theContext, + const QString & theParent, const QString & theObject) +{ + if (!myActiveComp.isEmpty()) { + OSD_Function osdF = mySharedLibrary.DlSymb("customPopup"); + if ( osdF != NULL ) { + customP (*f1) = (bool (*) (QAD_Desktop*, QPopupMenu*, const QString &, + const QString &, const QString &)) osdF; + (*f1)(this, popup, theContext, theParent, theObject); + } + } +} + +void QAD_Desktop::onObjectBrowser() +{ + bool checkDiff = false; + + bool state = QAD_CONFIG->getSetting("ObjectBrowser:AddColumn").compare("true") == 0; + + if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() != state ) + checkDiff = true; + + bool showEntry; + if ( myStdActions.at( PrefObjectBrowserEntryId )->isOn() ) { + showEntry = true; + QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "true"); + } else { + showEntry = false; + QAD_CONFIG->addSetting( "ObjectBrowser:AddColumn", "false"); + } + + bool showValue; + if ( myStdActions.at( PrefObjectBrowserValueId )->isOn() ) { + showValue = true; + QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "true"); + } else { + showValue = false; + QAD_CONFIG->addSetting( "ObjectBrowser:ValueColumn", "false"); + } + + bool showIAPP; + if ( myStdActions.at( PrefObjectBrowserIAPPId )->isOn() ) { + showIAPP = true; + QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "true"); + } else { + showIAPP = false; + QAD_CONFIG->addSetting( "ObjectBrowser:IAPP", "false"); + } + + /* To sort created object in chrono order or reverse chrono order */ + bool showCHRONO_SORT ; + if ( myStdActions.at( PrefObjectBrowserCHRONO_SORTId )->isOn() ) { + showCHRONO_SORT = true; + QAD_CONFIG->addSetting( "ObjectBrowser:CHRONO_SORT", "true"); + } else { + showCHRONO_SORT = false; + QAD_CONFIG->addSetting( "ObjectBrowser:CHRONO_SORT", "false"); + } + + if ( myActiveApp ) { + QList& studies = myActiveApp->getStudies(); + for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { + int nbSf = study->getStudyFramesCount(); + for ( int i = 0; i < nbSf; i++ ) { + QAD_StudyFrame* sf = study->getStudyFrame(i); + sf->getLeftFrame()->getObjectBrowser()->setShowInfoColumns( showEntry ); + sf->getLeftFrame()->getObjectBrowser()->setShowValueColumn( showValue ); + sf->getLeftFrame()->getObjectBrowser()->setEnableChronoSort( showCHRONO_SORT ); +// sf->getLeftFrame()->getObjectBrowser()->setShowIAPP( showIAPP ); // this is done by below updateObjBrowser() call + } + study->updateObjBrowser(true); + } + } +} + +void QAD_Desktop::onViewerTrihedron() +{ + QString Size = QAD_CONFIG->getSetting("Viewer:TrihedronSize"); + float dim; + + SALOMEGUI_TrihedronSizeDlg *Dlg = new SALOMEGUI_TrihedronSizeDlg(this); + if (!Size.isEmpty()) + Dlg->setTrihedronSize(Size.toInt()); + int r = Dlg->exec(); + dim = Dlg->getTrihedronSize(); + delete Dlg; + + if (r == QDialog::Accepted) { + QAD_CONFIG->addSetting("Viewer:TrihedronSize", dim); + + if( myActiveApp ) { + QList& studies = myActiveApp->getStudies(); + for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { + int nbSf = study->getStudyFramesCount(); + for ( int i = 0; i < nbSf; i++ ) { + study->getStudyFrame(i)->getRightFrame()->getViewFrame()->SetTrihedronSize(dim); + } + } + } + } +} + +void QAD_Desktop::onDirList() +{ + // getting dir list from settings + QStringList dirList = QStringList::split(';', QAD_CONFIG->getSetting("FileDlg:QuickDirList"), false); + QAD_DirListDlg* dlg = new QAD_DirListDlg(this); + dlg->setPathList(dirList); + if ( dlg->exec() == QDialog::Accepted) { + dlg->getPathList(dirList); + QAD_CONFIG->addSetting("FileDlg:QuickDirList", dirList.join(";")); + } + delete dlg; +} + +void QAD_Desktop::onConsoleFontAction() +{ + // getting font from settings + QString fntSet = QAD_CONFIG->getSetting("Viewer:ConsoleFont"); + QFont font = QAD_Tools::stringToFont( fntSet ); + bool bOk; + font = QFontDialog::getFont( &bOk, font, this ); + if ( bOk ) { + fntSet = QAD_Tools::fontToString( font ); + QAD_CONFIG->addSetting("Viewer:ConsoleFont", fntSet ); + + if( myActiveApp ) { + QList& studies = myActiveApp->getStudies(); + for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { + int nbSf = study->getStudyFramesCount(); + for ( int i = 0; i < nbSf; i++ ) { + study->getStudyFrame(i)->getRightFrame()->getPyEditor()->setFont( font ); + study->getStudyFrame(i)->getRightFrame()->getMessage()->setFont( font ); + } + } + } + } +} + +void QAD_Desktop::onSavePref() +{ + QAD_CONFIG->createConfigFile(true); +} + +//VRV: T2.5 - add default viewer +void QAD_Desktop::onDefaultViewer(QAction * theAction) +{ + int type = VIEW_TYPE_MAX; + + QString myValue; + if (myStdActions.at(DefaultViewerOCCId) == theAction) + type = VIEW_OCC; + else if (myStdActions.at(DefaultViewerVTKId) == theAction) + type = VIEW_VTK; + else if (myStdActions.at(DefaultGraphSupervisorId) == theAction) + type = VIEW_GRAPHSUPERV; + else if (myStdActions.at(DefaultPlot2dId) == theAction) + type = VIEW_PLOT2D; + if ( type != VIEW_TYPE_MAX ) + QAD_CONFIG->addSetting( "Viewer:DefaultViewer", QString::number( type ) ); +} +//VRV: T2.5 - add default viewer + +void QAD_Desktop::onViewerOCC() +{ + QString BackgroundColorRed = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorRed"); + QString BackgroundColorGreen = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorGreen"); + QString BackgroundColorBlue = QAD_CONFIG->getSetting("OCCViewer:BackgroundColorBlue"); + QColor color; + + if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() ) + color = QColor(BackgroundColorRed.toInt(), + BackgroundColorGreen.toInt(), + BackgroundColorBlue.toInt()); + else + color = QColor(35, 136, 145); + + QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() ); + + if (c.isValid()) { + if ( myActiveApp ) { + QList& studies = myActiveApp->getStudies(); + for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { + int nbSf = study->getStudyFramesCount(); + for ( int i = 0; i < nbSf; i++ ) { + QAD_StudyFrame* sf = study->getStudyFrame(i); + if ( sf->getTypeView() == VIEW_OCC ) { + sf->getRightFrame()->getViewFrame()->setBackgroundColor( c ); + } + } + } + } + QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorRed", c.red() ); + QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorGreen", c.green() ); + QAD_CONFIG->addSetting( "OCCViewer:BackgroundColorBlue", c.blue() ); + } +} + +void QAD_Desktop::onGraphSupervisor() +{ + QString BackgroundColorRed = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed"); + QString BackgroundColorGreen = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen"); + QString BackgroundColorBlue = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue"); + QColor color; + + if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() ) + color = QColor(BackgroundColorRed.toInt(), + BackgroundColorGreen.toInt(), + BackgroundColorBlue.toInt()); + else + color = QColor(35, 136, 145); + + QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() ); + + if (c.isValid()) { + if ( myActiveApp ) { + QList& studies = myActiveApp->getStudies(); + for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { + int nbSf = study->getStudyFramesCount(); + for ( int i = 0; i < nbSf; i++ ) { + QAD_StudyFrame* sf = study->getStudyFrame(i); + if ( sf->getTypeView() == VIEW_GRAPHSUPERV ) { + sf->getRightFrame()->getViewFrame()->setBackgroundColor( c ); + } + } + } + } + + QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorRed", c.red() ); + QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorGreen", c.green() ); + QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorBlue", c.blue() ); + } +} + +void QAD_Desktop::onViewerVTK() +{ + QString BackgroundColorRed = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorRed"); + QString BackgroundColorGreen = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorGreen"); + QString BackgroundColorBlue = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorBlue"); + QColor color; + + if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() ) + color = QColor(BackgroundColorRed.toInt(), + BackgroundColorGreen.toInt(), + BackgroundColorBlue.toInt()); + else + color = QColor(0, 0, 0); + + QColor c = QColorDialog::getColor( color, QAD_Application::getDesktop() ); + + if (c.isValid()) { + if ( myActiveApp ) { + QList& studies = myActiveApp->getStudies(); + for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { + int nbSf = study->getStudyFramesCount(); + for ( int i = 0; i < nbSf; i++ ) { + QAD_StudyFrame* sf = study->getStudyFrame(i); + if ( sf->getTypeView() == VIEW_VTK ) { + sf->getRightFrame()->getViewFrame()->setBackgroundColor( c ); + } + } + } + } + + QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorRed", c.red() ); + QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorGreen", c.green() ); + QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorBlue", c.blue() ); + } +} + +void QAD_Desktop::onPlot2d() +{ + QColor color; + if ( QAD_CONFIG->hasSetting( "Plot2d:Background" ) ) { + QString bgString = QAD_CONFIG->getSetting( "Plot2d:Background" ); + QStringList bgData = QStringList::split( ":", bgString, true ); + int bgRed = 0, bgGreen = 0, bgBlue = 0; + if ( bgData.count() > 0 ) bgRed = bgData[ 0 ].toInt(); + if ( bgData.count() > 1 ) bgGreen = bgData[ 1 ].toInt(); + if ( bgData.count() > 2 ) bgBlue = bgData[ 2 ].toInt(); + color = QColor( bgRed, bgGreen, bgBlue ); + } + else { + color = QColor(0, 0, 0); + } + + color = QColorDialog::getColor( color, QAD_Application::getDesktop() ); + + if ( color.isValid() ) { + if ( myActiveApp ) { + QList& studies = myActiveApp->getStudies(); + for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { + int nbSf = study->getStudyFramesCount(); + for ( int i = 0; i < nbSf; i++ ) { + QAD_StudyFrame* sf = study->getStudyFrame(i); + if ( sf->getTypeView() == VIEW_PLOT2D ) { + sf->getRightFrame()->getViewFrame()->setBackgroundColor( color ); + } + } + } + } + QStringList bgData; + bgData.append( QString::number( color.red() ) ); + bgData.append( QString::number( color.green() ) ); + bgData.append( QString::number( color.blue() ) ); + QAD_CONFIG->addSetting( "Plot2d:Background", bgData.join( ":" ) ); + } +} + +/* Help About */ +void QAD_Desktop::helpAbout() +{ + SALOMEGUI_AboutDlg* About = new SALOMEGUI_AboutDlg( QAD_Application::getDesktop(), tr("MEN_ABOUT")); + About->exec(); + delete About; +} + +/* Help Search */ +void QAD_Desktop::helpSearch() +{ +} + +/* Help Contents */ +void QAD_Desktop::helpContents() +{ + getHelpWindow()->contents(); + getHelpWindow()->show(); + getHelpWindow()->raise(); + getHelpWindow()->setActiveWindow(); +} + +/* Help Context */ +void QAD_Desktop::helpContext(const QString& source, const QString& context) +{ + getHelpWindow()->context(source, context); + getHelpWindow()->show(); + getHelpWindow()->raise(); + getHelpWindow()->setActiveWindow(); +} + +/* Preferences/MultiFile Save */ +void QAD_Desktop::onMultiFileSave() +{ + if ( myStdActions.at( PrefMultiFileSave )->isOn() ) + QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "true"); + else + QAD_CONFIG->addSetting( "Desktop:MultiFileSave", "false"); +} + +/********************************************************************* +** Class: AppSelectionDlg +** Descr: Dialog for the selection of the application when several +** applications exist in the desktop and new study creation +** is activated by user. +** Level: Internal +**********************************************************************/ +/*! + \class Desktop_AppSelectionDlg QAD_Desktop.h + \brief Dialog for the selection of the application when several + applications exist in the desktop and new study creation + is activated by user. + + Level: Internal. +*/ + +Desktop_AppSelectionDlg::Desktop_AppSelectionDlg( QAD_Desktop* desktop, + QList& apps ) : +QDialog( desktop, 0, true ), +myAppId( 0 ), +myApps( apps ) +{ + QAD_ASSERT_DEBUG_ONLY ( desktop ); + setCaption( tr("INF_DESK_DOC_CREATE") ); + if ( desktop->icon() ) + setIcon( *desktop->icon() ); + + QBoxLayout* mainLayout = new QVBoxLayout( this, 5 ); + + /* Create selection buttons */ + QVButtonGroup* buttonGrp = new QVButtonGroup ( this ); + buttonGrp->setExclusive ( true ); + QBoxLayout* vLayout = new QVBoxLayout( mainLayout, 5 ); + vLayout->addWidget ( buttonGrp ); + + /* Create selection button for available app */ + unsigned id = 0; + for ( QAD_Application* app = myApps.first(); app; app = myApps.next(), id++ ) + { + /* add radio button for application */ + buttonGrp->insert( new QRadioButton( app->getStudyDescription() + + " (*." + app->getStudyExtension() + ")", buttonGrp ), id ); + } + + /* make the first application selected */ + buttonGrp->setButton( 0 ); + + /* listen to the selection */ + QAD_ASSERT ( connect ( buttonGrp, SIGNAL(clicked(int)), this, SLOT(onAppSelected(int)) )); + + /* Create OK/Cancel buttons + */ + QBoxLayout* hLayout = new QHBoxLayout( mainLayout, 5 ); + QPushButton* buttonOK = new QPushButton( tr("BUT_OK"), this ); + QPushButton* buttonCancel = new QPushButton( tr("BUT_CANCEL"), this ); + QPushButton* buttonHelp = new QPushButton( tr("BUT_HELP"), this ); + buttonOK->setDefault( true ); + + hLayout->addStretch(); + hLayout->addWidget( buttonOK ); + hLayout->addWidget( buttonCancel ); + hLayout->addWidget( buttonHelp ); + + /* connect buttons */ + QAD_ASSERT ( connect( buttonOK, SIGNAL(clicked()), this, SLOT(accept())) ); + QAD_ASSERT ( connect( buttonCancel, SIGNAL(clicked()), this, SLOT(reject())) ); + QAD_ASSERT ( connect( buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())) ); + + /* disable resizing */ + setFixedSize( 0, 0 ); + setSizePolicy( QSizePolicy ( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); +} + +Desktop_AppSelectionDlg::~Desktop_AppSelectionDlg() +{ +} + +QAD_Application* Desktop_AppSelectionDlg::selectedApp() const +{ + return myApps.at( myAppId ); +} + +void Desktop_AppSelectionDlg::resizeEvent( QResizeEvent* e ) +{ + QAD_Tools::centerWidget( this, parentWidget() ); +} + +/* + * Slots +*/ +void Desktop_AppSelectionDlg::onAppSelected( int id ) +{ + myAppId = id; +} + +void Desktop_AppSelectionDlg::onHelp() +{ +} + diff --git a/src/SALOMEGUI/QAD_Desktop.h b/src/SALOMEGUI/QAD_Desktop.h new file mode 100644 index 000000000..9b577de96 --- /dev/null +++ b/src/SALOMEGUI/QAD_Desktop.h @@ -0,0 +1,376 @@ +// File : QAD_Desktop.h +// Created : UI team, 02.10.00 +// Descr : Main desktop of QAD-based application + +// Modified : Mon Dec 03 13:40:28 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef QAD_DESKTOP_H +#define QAD_DESKTOP_H + +#include "QAD.h" +#include "QAD_ResourceMgr.h" +#include "QAD_Application.h" +#include "QAD_OperatorMenus.h" +#include "QAD_Menus.h" +#include "QAD_HelpWindow.h" + +#include "SALOME_NamingService.hxx" +#include "SALOME_LifeCycleCORBA.hxx" + +// IDL Headers +#include +#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) +#include CORBA_CLIENT_HEADER(SALOME_Component) +#include CORBA_SERVER_HEADER(SALOMEDS) + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include "qworkspaceP.h" +#include +#include +#include + +// Open CASCADE Includes +#include + +class ActionMap { + public: + ActionMap() {} + ~ActionMap() + { + QMapIterator it; + for ( it = myMap.begin(); it != myMap.end(); it++ ) delete (QAction*)it.data(); + myMap.clear(); + } + bool isEmpty() { return myMap.isEmpty(); } + void insert( const unsigned int id, QAction* action ) { myMap[id] = action; } + QAction* at( const unsigned int id ) { return myMap[id]; } + void clear() { myMap.clear(); } + QAction*& operator[] (const unsigned int id) { return myMap[id]; } + + private: + QMap myMap; + +}; + +class ToggleAction : public QAction { + Q_OBJECT + public: + ToggleAction( const QString& text, const QString& menuText, + QKeySequence accel, QObject* parent, + const char* name = 0, bool toggle = FALSE) + : QAction( text, menuText, accel, parent, name, toggle ) + { + connect( this, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool))); + } + private slots: + void onToggled( bool on) + { + on ? emit( toggledOn() ) : emit( toggledOff() ); + } + + signals: + void toggledOn(); + void toggledOff(); +}; + +class QAD_XmlHandler; + +class QAD_EXPORT QAD_Desktop : public QMainWindow +{ + Q_OBJECT + +protected: + enum ComponentType {GEOM, MESH, SOLVER, DATA, VISU, OTHER} ; + + enum { FileNewId = 0, FileOpenId, FileLoadId, FileCloseId, FileSaveId, FileSaveAsId, FilePropsId, FileExitId, + ViewStatusBarId, + SelectionPointId, SelectionEdgeId, SelectionCellId, SelectionActorId, + PrefViewerOCCId, PrefViewerVTKId, PrefGraphSupervisorId, PrefViewerPlot2dId, + //VRV: T2.5 - add default viewer + DefaultViewerOCCId, DefaultViewerVTKId, DefaultGraphSupervisorId, DefaultPlot2dId, + //VRV: T2.5 - add default viewer + PrefViewerTrihedronId, PrefConsoleFontId, PrefObjectBrowserEntryId, + PrefObjectBrowserIAPPId, PrefObjectBrowserValueId, PrefObjectBrowserCHRONO_SORTId, + PrefDirsId, PrefMultiFileSave, PrefSaveId, + //NRI : SAL2214 + WindowNew3dId, ViewOCCId, ViewVTKId, ViewPlot2dId, + //NRI : SAL2214 + WindowCascadeId, WindowTileId, + HelpContentsId, HelpSearchId, HelpWhatsThisId, HelpAboutId }; + enum UpdateCommand { ActivateApp, DeactivateApp }; + + /* Desktop can be created only by application */ + friend bool QAD_Application::createDesktop( SALOME_NamingService* name_service ); + QAD_Desktop( SALOME_NamingService* name_service ); + +public: + ~QAD_Desktop(); + + /* global event filter for qapplication */ + bool eventFilter( QObject* o, QEvent* e ); + + /* resources */ + static QAD_ResourceMgr* getResourceManager(); + static QAD_ResourceMgr* createResourceManager(); + + /* palette */ + static QPalette* getPalette(); + static QPalette* createPalette(); + + /* activeStudyChanged */ + void onActiveStudyChanged(); + + /* popup */ + void definePopup(QString & theContext, + QString & theParent, + QString & theObject ); + + void createPopup(QPopupMenu* popupFather, QPopupMenu* popup, + QString text, int popupID, bool separator = false); + void createPopup(QPopupMenu* popup, const QString & theContext, + const QString & theParent, const QString & theObject ); + void customPopup(QPopupMenu* popup, const QString & theContext, + const QString & theParent, const QString & theObject); + + /* selection mode */ + void SetSelectionMode(int mode, bool activeCompOnly = false); + + /* desktop */ + void showDesktop(); + void closeDesktop( bool forceClose = false ); + void putInfo ( const QString& ); + void putInfo ( const QString&, int ); + QToolBar* getStdToolBar() const; + QMenuBar* getMainMenuBar() const; + + /* application */ + void addApplication(QAD_Application* app); + + /* studies */ + const QString& getDefaultTitle() const; + const QPixmap& getDefaultIcon() const; + const QString& getDefaultStudyName() const; + QAD_Application* getActiveApp() const; + QAD_Study* getActiveStudy() const; + QWorkspaceP* getMainFrame() const; + QString getNewStudyName(); + QAD_Study* findStudy( SALOMEDS::Study_ptr theStudy ); + + /* help actions */ + virtual void helpAbout(); + virtual void helpSearch(); + virtual void helpContents(); + virtual void helpContext(const QString& path, const QString& dir = QString::null); + + bool loadComponent(QString); + void activateComponent(const QString& theName, bool isLoadData = true); + void createStudy(); + + void setSettings(); + + SALOME_ModuleCatalog::ModuleCatalog_var getCatalogue(); + + QAD_Menus* getActiveMenus() {return myActiveMenus;} + QAD_OperatorMenus* getOperatorMenus() {return myOperatorMenus;} + const OSD_SharedLibrary& getHandle() const {return mySharedLibrary;}// never return sych objects "by value" + const QString& getActiveComponent() const; + SALOME_NamingService* getNameService() {return myNameService;} + + Engines::Component_var getEngine(const char *containerName, + const char *componentName); + + QAD_HelpWindow* getHelpWindow(); + + void onMouseMove(QMouseEvent*); + bool onMousePress(QMouseEvent*); + void onKeyPress(QKeyEvent*); + +protected: + bool closeAllStudies( QAD_Application* ); + void closeEvent( QCloseEvent* ); + void resizeEvent( QResizeEvent* ); + + virtual QString selectFileName ( bool open ); + + virtual void updateDesktop( UpdateCommand ); + virtual void updateStatusBar( UpdateCommand ); + virtual void updateToolBars( UpdateCommand ); + virtual void updateCaption( UpdateCommand ); + virtual void updateMenu( UpdateCommand ); + + bool loadComponentData( const QString& ); + +protected slots: + virtual void onNewStudy(); + virtual void onNewStudy(QAD_Application* app); + virtual void onLoadStudy(); + virtual void onOpenStudy(); + virtual bool onSaveStudy(); + virtual bool onSaveStudy(QAD_Study* doc); + virtual bool onSaveAsStudy(); + virtual bool onSaveAsStudy(QAD_Study* doc); + virtual bool onCloseStudy(); + virtual bool onCloseStudy(QAD_Study* doc); + //ask user to remove study from study manager permanently + virtual bool onCloseStudy(QAD_Study* doc, bool ask); + + virtual void onStudyProperties(); + + virtual void onViewStatusBar(); + virtual void onToolBarPopupAboutToShow(); + + virtual void onExit(); + + virtual void onWindowPopupAboutToShow(); + void onWindowsPopupActivated( int id ); + void onWindowsPopupStatusText( int id ); + + void onSelectionMode(); + + void onDirList(); + void onSavePref(); + void onViewerOCC(); + void onViewerVTK(); + void onGraphSupervisor(); + void onPlot2d(); + void onConsoleFontAction(); + //VRV: T2.5 - add default viewer + void onDefaultViewer( QAction * theAction); + //VRV: T2.5 - add default viewer + + void onViewerTrihedron(); + void onObjectBrowser(); + void onMultiFileSave(); + + void onActivateApp(QAD_Application* app); + void onDeactivateApp(QAD_Application* app); + + void onHelpContents(); + void onHelpSearch(); + void onHelpAbout(); + + void onNewWindow3d(); + + void onOpenWith(); + + void onDispatchTools(int id); + void onDispatch(int id); + void onDispatch(); + void clearMenus(); + void onButtonActiveComponent(); + void onComboActiveComponent( const QString & ); + void onComboActiveComponent( const QString & , bool isLoadData); + void onCascade(); + + void onHelpWindowClosed(); + +protected: + QMenuBar* myMainMenu; /* the main menu bar */ + int myMainMenuPos; /* index after which application inserts its items */ + QPopupMenu myFilePopup; + int myFilePos; + QPopupMenu myEditPopup; + int myEditPos; + QPopupMenu myViewPopup; + int myViewPos; + QPopupMenu myHelpPopup; + int myHelpPos; + + //VRV: T2.5 - add default viewer + QPopupMenu myDefaultViewer; + //VRV: T2.5 - add default viewer + QPopupMenu myObjBrowserPopup; + QPopupMenu myViewerPopup; + //NRI : SAL2214 + QPopupMenu myNewViewPopup; + //NRI : SAL2214 + QPopupMenu myToolsPopup; + QPopupMenu myPrefPopup; + QPopupMenu mySelectionModePopup; + QPopupMenu myWindowPopup; /* not customized by an application */ + + ActionMap myStdActions; /* default actions */ + QToolBar* myStdToolBar; /* standard toolbar */ + QStatusBar* myStatusBar; /* the only status bar */ + + QList myToolBarAction; + QPopupMenu myToolBarsPopup; + + QList myApps; /* running applications */ + QAD_Application* myActiveApp; /* the active application */ + QAD_Study* myActiveStudy; /* the active document */ + + int myCntUntitled; /* number of untitled docs */ + QWorkspaceP* myWorkspace; /* workspace */ + + QPixmap myDefaultIcon; /* if no application is active */ + QString myDefaultTitle; /* desktop will use them */ + + QAD_OperatorMenus* myOperatorMenus; + QList myMenusList; + QAD_Menus* myActiveMenus; + + QAD_HelpWindow* myHelpWindow; + + QList myComponentButton; + +private: + static QAD_ResourceMgr* resourceMgr; + static QPalette* palette; + void createActions(); + void updateActions(); + OSD_SharedLibrary mySharedLibrary; + QAD_XmlHandler* myXmlHandler; + QString myActiveComp; + SALOME_NamingService* myNameService; + SALOME_ModuleCatalog::ModuleCatalog_var myCatalogue; + SALOME_LifeCycleCORBA * myEnginesLifeCycle; + QComboBox * myCombo; + bool myQueryClose; +}; + +/******************************************************************** +** Class: AppSelectionDlg +** Descr: Dialog for the selection of the application when several +** applications exist in the desktop and new document creation +** is activated by user. +** Level: Internal +*********************************************************************/ +class Desktop_AppSelectionDlg : public QDialog +{ + Q_OBJECT + +public: + Desktop_AppSelectionDlg( QAD_Desktop*, QList& ); + ~Desktop_AppSelectionDlg(); + +public: + QAD_Application* selectedApp() const; + +protected: + void resizeEvent( QResizeEvent* ); + +protected slots: + void onAppSelected(int); + void onHelp(); + +protected: + int myAppId; + QList& myApps; +}; + +#endif + diff --git a/src/SALOMEGUI/QAD_DirListDlg.cxx b/src/SALOMEGUI/QAD_DirListDlg.cxx new file mode 100644 index 000000000..5605f1b5f --- /dev/null +++ b/src/SALOMEGUI/QAD_DirListDlg.cxx @@ -0,0 +1,515 @@ +using namespace std; +// File : QAD_DirListDlg.cxx +// Created : 10/10/2002 +// Descr : Dialog box for editing of directory list + +// Author : Vadim SANDLER +// Project : SALOME Pro +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "QAD_DirListDlg.h" +#include "QAD_Desktop.h" +#include "QAD_FileDlg.h" +#include "QAD_MessageBox.h" +#include "QAD_Tools.h" +#include +#include +#include +#include + +#define MIN_WIDTH 400 +#define MIN_HEIGHT 200 +#define MARGIN_SIZE 11 +#define SPACING_SIZE 6 +#define SPACER_SIZE 5 + +/*! + Constructor +*/ +QAD_DirListDlg::QAD_DirListDlg(QWidget* parent, const char* name) + : QDialog (parent, name, true, WStyle_NormalBorder | WStyle_Customize | WStyle_Title | WStyle_SysMenu ) +{ + myEdited = false; + myLastSelected = 0; + myEdit = 0; + myBtn = 0; + + setCaption(tr("QUICK_DIR_LIST_TLT")); + setSizeGripEnabled( true ); + + QGridLayout* topLayout = new QGridLayout(this); + topLayout->setMargin(MARGIN_SIZE); + topLayout->setSpacing(SPACING_SIZE); + + myDirList = new QListBox(this); + myDirList->setMinimumSize(MIN_WIDTH, MIN_HEIGHT); +// myDirList->setMaximumSize(MIN_WIDTH, MIN_HEIGHT); + myDirList->setSelectionMode(QListBox::Single); + myDirList->setHScrollBarMode(QListBox::AlwaysOff); + myDirList->horizontalScrollBar()->installEventFilter(this); + myDirList->verticalScrollBar()->installEventFilter(this); + myDirList->insertItem(tr("EMPTY_DIR")); + myDirList->installEventFilter(this); + + QHBoxLayout* ctrlLayout = new QHBoxLayout; + ctrlLayout->setMargin(0); + ctrlLayout->setSpacing(0); + + QLabel* lab = new QLabel(myDirList, tr("DIRECTORIES_LBL"), this); + + QToolButton* insertBtn = new QToolButton(this); + insertBtn->setIconSet(QAD_Desktop::getResourceManager()->loadPixmap("QAD", tr("ICON_DIRLIST_INSERT"))); + insertBtn->setAutoRaise(true); + + QToolButton* deleteBtn = new QToolButton(this); + deleteBtn->setIconSet(QAD_Desktop::getResourceManager()->loadPixmap("QAD", tr("ICON_DIRLIST_DELETE"))); + deleteBtn->setAutoRaise(true); + + QToolButton* upBtn = new QToolButton(this); + upBtn->setIconSet(QAD_Desktop::getResourceManager()->loadPixmap("QAD", tr("ICON_DIRLIST_MOVEUP"))); + upBtn->setAutoRaise(true); + + QToolButton* downBtn = new QToolButton(this); + downBtn->setIconSet(QAD_Desktop::getResourceManager()->loadPixmap("QAD", tr("ICON_DIRLIST_MOVEDOWN"))); + downBtn->setAutoRaise(true); + + ctrlLayout->addWidget(lab); + ctrlLayout->addItem(new QSpacerItem(SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum)); + ctrlLayout->addWidget(insertBtn); + ctrlLayout->addWidget(deleteBtn); + ctrlLayout->addWidget(upBtn); + ctrlLayout->addWidget(downBtn); + + QHBoxLayout* btnLayout = new QHBoxLayout; + btnLayout->setMargin(0); + btnLayout->setSpacing(6); + + QPushButton * okBtn = new QPushButton(tr("BUT_OK"), this); + QPushButton * cancelBtn = new QPushButton(tr("BUT_CANCEL"), this); + okBtn->setDefault(true); + okBtn->setAutoDefault(true); + cancelBtn->setAutoDefault(true); + + btnLayout->addWidget(okBtn); + btnLayout->addItem(new QSpacerItem(SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum)); + btnLayout->addWidget(cancelBtn); + + topLayout->addLayout(ctrlLayout, 0, 0); + topLayout->addWidget(myDirList, 1, 0); + topLayout->addLayout(btnLayout, 2, 0); + + connect(myDirList, SIGNAL(mouseButtonClicked(int, QListBoxItem*, const QPoint&)), + this, SLOT(onMouseButtonClicked(int, QListBoxItem*, const QPoint&))); + connect(myDirList, SIGNAL(doubleClicked(QListBoxItem*)), + this, SLOT(onDblClicked(QListBoxItem*))); + + connect(insertBtn, SIGNAL(clicked()), this, SLOT(onInsert())); + connect(deleteBtn, SIGNAL(clicked()), this, SLOT(onDelete())); + connect(upBtn, SIGNAL(clicked()), this, SLOT(onUp())); + connect(downBtn, SIGNAL(clicked()), this, SLOT(onDown())); + connect(okBtn, SIGNAL(clicked()), this, SLOT(onOk())); + connect(cancelBtn, SIGNAL(clicked()), this, SLOT(reject())); + + QAD_Tools::centerWidget(this, parent); +} + +/*! + Destructor +*/ +QAD_DirListDlg::~QAD_DirListDlg() { +} + +/*! + Gets list of paths +*/ +void QAD_DirListDlg::getPathList(QStringList& list) { + list.clear(); + for (unsigned i = 0; i < myDirList->count()-1; i++) + list.append(myDirList->text(i)); +} + +/*! + Sets list of paths +*/ +void QAD_DirListDlg::setPathList(const QStringList& list) { + for (unsigned i = 0; i < list.count(); i++) + myDirList->insertItem(list[i], myDirList->count()-1); +} + +/*! + Validates entered path, returns true if OK +*/ +bool QAD_DirListDlg::validate() { + if (myEdited) { + QString dirPath = myEdit->text().stripWhiteSpace(); + QDir dir(dirPath); + QListBoxItem* found = 0; + for (unsigned i = 0; i < myDirList->count()-1; i++) { + QDir aDir(myDirList->text(i)); + if ( aDir.canonicalPath().isNull() && myDirList->text(i) == dir.absPath() || + !aDir.canonicalPath().isNull() && aDir.exists() && aDir.canonicalPath() == dir.canonicalPath()) { + found = myDirList->item(i); + break; + } + } + if (dirPath.isEmpty()) { + if (found) { + // it should be last (empty) item in the list - nothing to do + return true; + } + else { + // delete directory from the list + removeDir(myLastSelected); + return true; + } + } + else { + if (found) { + if (found != myLastSelected) { + // it is forbidden to add directory more then once + QAD_MessageBox::error1(this, + tr("ERR_ERROR"), + tr("ERR_DIRECTORY_SPECIFIED"), + tr("BUT_OK")); + myEdit->setFocus(); + return false; + } + } + else { + if (!dir.exists()) { + if ( QAD_MessageBox::info2(this, + tr("WRN_WARNING"), + tr("WRN_DIRECTORY_N0T_EXIST").arg(dir.absPath()), + tr ("BUT_YES"), tr ("BUT_NO"), + QAD_YES, QAD_NO, QAD_NO ) == QAD_NO ) { + myEdit->setFocus(); + return false; + } + } + // append + appendDir(myLastSelected, dir.absPath()); + } + } + } + return true; +} + +/*! + Appends/changes directory +*/ +void QAD_DirListDlg::appendDir(QListBoxItem* item, const QString& dir) { + int index = myDirList->index(item); + if (index >= 0 && index < (int)myDirList->count()) { + if (index == (int)myDirList->count()-1) { + // it is the last item (new), well, insert it before the last (empty) + myDirList->insertItem(dir, myDirList->count()-1); + } + else { + // change item + myDirList->changeItem(dir, index); + } + } +} + +/*! + Removes directory from list +*/ +void QAD_DirListDlg::removeDir(QListBoxItem* item) { + // do not remove last item (empty) + int index = myDirList->index(item); + if (index >= 0 && index < (int)myDirList->count()-1) { + delete item; + myLastSelected = myDirList->item(index); + myDirList->setSelected(myLastSelected, true); + } +} + +/*! + KeyPress event handler, processes and keys +*/ +void QAD_DirListDlg::keyPressEvent(QKeyEvent* event) { + if ( myEdited ) { + if ( event->key() == Key_Escape ) { + delete myEdit; + delete myBtn; + myEdit = 0; + myBtn = 0; + myEdited = false; + myDirList->setFocus(); + } + return; + } + if (event->key() == Key_Return || event->key() == Key_Enter) { + accept(); + } + QDialog::keyPressEvent(event); +} + +/*! + Resize event +*/ +void QAD_DirListDlg::resizeEvent(QResizeEvent* event) { + QDialog::resizeEvent(event); + if ( myEdited ) { + myEdit->resize(myDirList->viewport()->width()-myBtn->sizeHint().width(), myEdit->height()); + myBtn->move(myEdit->width(), myEdit->y()); + } +} + +/*! + Called when user clicks inside directories list box +*/ +void QAD_DirListDlg::onMouseButtonClicked(int button, + QListBoxItem* item, + const QPoint& point) { + if (myEdited) { + if (!validate()) { + myDirList->setCurrentItem(myLastSelected); + myDirList->setSelected(myLastSelected, true); + return; + } + delete myEdit; + delete myBtn; + myEdit = 0; + myBtn = 0; + myEdited = false; + myDirList->setFocus(); + } + if (item) { + myDirList->setCurrentItem(item); + myDirList->setSelected(item, true); + myDirList->ensureCurrentVisible(); + qApp->processEvents(); + if (button == LeftButton && myLastSelected == item) { + QRect ir = myDirList->itemRect(myLastSelected); + + myEdit = new QLineEdit(myDirList->viewport()); + myBtn = new QToolButton(myDirList->viewport()); + myBtn->setText(" ... "); + connect(myBtn, SIGNAL(clicked()), this, SLOT(onBtnClicked())); + myEdit->setGeometry(0, + ir.top()-(myEdit->sizeHint().height()-ir.height())/2, + myDirList->viewport()->width()-myBtn->sizeHint().width(), + myEdit->sizeHint().height()); + myBtn->setGeometry (myEdit->width(), + ir.top()-(myEdit->sizeHint().height()-ir.height())/2, + myBtn->sizeHint().width(), + myEdit->sizeHint().height()); + connect(myEdit, SIGNAL(returnPressed()), this, SLOT(onEditFinished())); + myEdited = true; + myEdit->show(); + myBtn->show(); + if (myDirList->index(myLastSelected) != (int)myDirList->count()-1) + myEdit->setText(myLastSelected->text()); + myEdit->selectAll(); + myEdit->setCursorPosition(myEdit->text().length()); + myEdit->installEventFilter(this); + myEdit->setFocus(); + } + } + else { + myDirList->clearSelection(); + } + myLastSelected = item; +} + +/*! + Called when user double-clicks on any item +*/ +void QAD_DirListDlg::onDblClicked(QListBoxItem* item) { + onMouseButtonClicked(LeftButton, item, QPoint(0,0)); +} + +/*! + <...> (Browse dir) button slot +*/ +void QAD_DirListDlg::onBtnClicked() { + QString dir = myEdit->text().stripWhiteSpace().isEmpty() ? + QString::null : + myEdit->text().stripWhiteSpace(); + dir = QAD_FileDlg::getExistingDirectory(this, dir, tr("SELECT_DIRECTORY"), true); + if (!dir.isEmpty()) { + myEdit->setText(dir); + myEdit->selectAll(); + myEdit->setCursorPosition(myEdit->text().length()); + } +} + +/*! + Called when user finises editing of path by pressing +*/ +void QAD_DirListDlg::onEditFinished() { + if (myEdit) { + if (!validate()) { + myDirList->setCurrentItem(myLastSelected); + myDirList->setSelected(myLastSelected, true); + return; + } + delete myEdit; + delete myBtn; + myEdit = 0; + myBtn = 0; + myEdited = false; + myDirList->setFocus(); + } +} + +/*! + Event filter +*/ +bool QAD_DirListDlg::eventFilter(QObject* object, QEvent* event) { + if ( myEdited ) { + if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick) { + if (object == myDirList->horizontalScrollBar() || object == myDirList->verticalScrollBar()) { + if (!validate()) { + myDirList->setCurrentItem(myLastSelected); + myDirList->setSelected(myLastSelected, true); + return true; + } + delete myEdit; + delete myBtn; + myEdit = 0; + myBtn = 0; + myEdited = false; + myDirList->setFocus(); + } + } + else if (event->type() == QEvent::KeyPress) { + QKeyEvent* ke = (QKeyEvent*)event; + if (ke->key() == Key_Tab) + return true; + if (object == myDirList) { + return true; + } + else if (object == myEdit) { + if ( ke->key() == Key_Up || ke->key() == Key_Down || ke->key() == Key_PageUp || ke->key() == Key_PageDown || + ( ke->key() == Key_Home || ke->key() == Key_End || ke->key() == Key_Prior || ke->key() == Key_Next ) && + (ke->state() & ControlButton) ) { + return true; + } + else if ( ke->key() == Key_Escape ) { + delete myEdit; + delete myBtn; + myEdit = 0; + myBtn = 0; + myEdited = false; + myDirList->setFocus(); + return true; + } + } + } + } + else { + if (event->type() == QEvent::KeyPress) { + if (object == myDirList) { + QKeyEvent* ke = (QKeyEvent*)event; + if (ke->key() == Key_Return || ke->key() == Key_Enter) { + accept(); + } + else { + QChar c(ke->ascii()); + if (c.isPrint()) { + QListBoxItem* item = myDirList->item(myDirList->currentItem()); + if (item) { + myDirList->setCurrentItem(item); + myDirList->setSelected(item, true); + myDirList->ensureCurrentVisible(); + myLastSelected = item; + qApp->processEvents(); + QRect ir = myDirList->itemRect(myLastSelected); + + myEdit = new QLineEdit(myDirList->viewport()); + myBtn = new QToolButton(myDirList->viewport()); + myBtn->setText(" ... "); + connect(myBtn, SIGNAL(clicked()), this, SLOT(onBtnClicked())); + myEdit->setGeometry(0, + ir.top()-(myEdit->sizeHint().height()-ir.height())/2, + myDirList->viewport()->width()-myBtn->sizeHint().width(), + myEdit->sizeHint().height()); + myBtn->setGeometry (myEdit->width(), + ir.top()-(myEdit->sizeHint().height()-ir.height())/2, + myBtn->sizeHint().width(), + myEdit->sizeHint().height()); + connect(myEdit, SIGNAL(returnPressed()), this, SLOT(onEditFinished())); + myEdited = true; + myEdit->show(); + myBtn->show(); + myEdit->setText(c); + myEdit->setCursorPosition(myEdit->text().length()); + myEdit->installEventFilter(this); + myEdit->setFocus(); + } + } + } + } + } + } + return QDialog::eventFilter(object, event); +} + +/*! + button slot +*/ +void QAD_DirListDlg::onInsert() { + if (!myEdited) { + myLastSelected = 0; + onMouseButtonClicked(LeftButton, myDirList->item(myDirList->count()-1), QPoint(0,0)); + onMouseButtonClicked(LeftButton, myDirList->item(myDirList->count()-1), QPoint(0,0)); + } +} + +/*! + button slot +*/ +void QAD_DirListDlg::onDelete() { + if (!myEdited && myDirList->currentItem() >=0) { + removeDir(myDirList->item(myDirList->currentItem())); + myDirList->setFocus(); + } +} + +/*! + button slot +*/ +void QAD_DirListDlg::onUp() { + if (!myEdited && myLastSelected) { + int index = myDirList->currentItem(); + if (index > 0 && index < (int)myDirList->count()-1 && myDirList->isSelected(index)) { + QString t = myDirList->text(index-1); + myDirList->changeItem(myDirList->text(index), index-1); + myDirList->changeItem(t, index); + myDirList->setCurrentItem(index-1); + myLastSelected = myDirList->item(index-1); + myDirList->setSelected(myLastSelected, true); + myDirList->setFocus(); + } + } +} + +/*! + button slot +*/ +void QAD_DirListDlg::onDown() { + if (!myEdited && myLastSelected) { + int index = myDirList->currentItem(); + if (index >= 0 && index < (int)myDirList->count()-2 && myDirList->isSelected(index)) { + QString t = myDirList->text(index+1); + myDirList->changeItem(myDirList->text(index), index+1); + myDirList->changeItem(t, index); + myDirList->setCurrentItem(index+1); + myLastSelected = myDirList->item(index+1); + myDirList->setSelected(myLastSelected, true); + myDirList->setFocus(); + } + } +} + +/*! + Purpose : button slot +*/ +void QAD_DirListDlg::onOk() { + if (validate()) + accept(); +} diff --git a/src/SALOMEGUI/QAD_DirListDlg.h b/src/SALOMEGUI/QAD_DirListDlg.h new file mode 100644 index 000000000..f6f462dc3 --- /dev/null +++ b/src/SALOMEGUI/QAD_DirListDlg.h @@ -0,0 +1,78 @@ +// File : QAD_DirListDlg.h +// Created : 10/10/2002 +// Descr : Dialog box for editing of directory list + +// Author : Vadim SANDLER +// Project : SALOME Pro +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#if !defined(QAD_DirListDlg_h) +#define QAD_DirListDlg_h + +#include +#include +#include +#include +#include + +class QAD_DirListDlg : public QDialog { + + Q_OBJECT + +public: +// constructor + QAD_DirListDlg(QWidget* parent, const char* name = 0); +// destructor + ~QAD_DirListDlg(); + +// gets list of paths + void getPathList(QStringList& list); +// sets list of paths + void setPathList(const QStringList& list); +// event filter + bool eventFilter(QObject* object, QEvent* event); + +protected: +// validates entered path, returns true if OK + bool validate(); +// appends/changes path + void appendDir(QListBoxItem* item, const QString& dir); +// removes directory from list + void removeDir(QListBoxItem* item); +// KeyPress event handler, processes and keys + void keyPressEvent(QKeyEvent* event); +// Resize event + void resizeEvent(QResizeEvent* event); + +protected slots: +// called when user clicks inside directories list box + void onMouseButtonClicked(int, QListBoxItem*, const QPoint&); +// called when user double-clicks on any item + void onDblClicked(QListBoxItem*); +// <...> (Browse dir) button slot + void onBtnClicked(); +// called when user finises editing of path by pressing + void onEditFinished(); +// button slot + void onInsert(); +// button slot + void onDelete(); +// button slot + void onUp(); +// button slot + void onDown(); +// button slot + void onOk(); + +private: + QListBox* myDirList; // directory list + QLineEdit* myEdit; // path edit box + QToolButton* myBtn; // browse pah button + bool myEdited; // edit mode flag + QListBoxItem* myLastSelected; // last selected row + +}; + +#endif // !defined(QAD_DirListDlg_h) diff --git a/src/SALOMEGUI/QAD_FileDlg.cxx b/src/SALOMEGUI/QAD_FileDlg.cxx new file mode 100644 index 000000000..94295f1e8 --- /dev/null +++ b/src/SALOMEGUI/QAD_FileDlg.cxx @@ -0,0 +1,346 @@ +using namespace std; +// File : QAD_FileDlg.cxx +// Created : UI team, 17.09.02 +// Descr : Open/Save File dialog + +// Modified : Tue Sep 17 11:15:23 2002 +// Author : +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + +#include +#include +#include +#include +#include +#include +#include +#include "QAD_Config.h" +#include "QAD_Desktop.h" +#include "QAD_FileDlg.h" +#include "QAD_MessageBox.h" +#include "QAD_Tools.h" + +#define MIN_COMBO_SIZE 100 + +QString QAD_FileDlg::myLastVisitedPath; + +/*! +Constructor +*/ +QAD_FileDlg::QAD_FileDlg( QWidget* parent, bool open, bool showQuickDir, bool modal ) : +QFileDialog( parent, 0, modal ), +myValidator( 0 ), +myQuickCombo( 0 ), +myOpen( open ) +{ + if ( parent->icon() ) + setIcon( *parent->icon() ); + setSizeGripEnabled( true ); + + if (showQuickDir) { + // inserting quick dir combo box + QLabel* lab = new QLabel(tr("Quick path:"), this); + myQuickCombo = new QComboBox(false, this); + myQuickCombo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + myQuickCombo->setMinimumSize(MIN_COMBO_SIZE, 0); + + // the following is a workaround for proper layouting of custom widgets =========== + QPushButton* btn = new QPushButton(this); + btn->setEnabled(false); + QPalette pal = btn->palette(); + QColorGroup ca = pal.active(); + ca.setColor(QColorGroup::Light, palette().active().background()); + ca.setColor(QColorGroup::Midlight, palette().active().background()); + ca.setColor(QColorGroup::Dark, palette().active().background()); + ca.setColor(QColorGroup::Mid, palette().active().background()); + ca.setColor(QColorGroup::Shadow, palette().active().background()); + QColorGroup ci = pal.inactive(); + ci.setColor(QColorGroup::Light, palette().inactive().background()); + ci.setColor(QColorGroup::Midlight, palette().inactive().background()); + ci.setColor(QColorGroup::Dark, palette().inactive().background()); + ci.setColor(QColorGroup::Mid, palette().inactive().background()); + ci.setColor(QColorGroup::Shadow, palette().inactive().background()); + QColorGroup cd = pal.disabled(); + cd.setColor(QColorGroup::Light, palette().disabled().background()); + cd.setColor(QColorGroup::Midlight, palette().disabled().background()); + cd.setColor(QColorGroup::Dark, palette().disabled().background()); + cd.setColor(QColorGroup::Mid, palette().disabled().background()); + cd.setColor(QColorGroup::Shadow, palette().disabled().background()); + pal.setActive(ca); pal.setInactive(ci); pal.setDisabled(cd); + btn->setPalette(pal); + // ================================================================================ + + connect(myQuickCombo, SIGNAL(activated(const QString&)), this, SLOT(quickDir(const QString&))); + addWidgets(lab, myQuickCombo, btn); + + // getting dir list from settings + QString dirs = QAD_CONFIG->getSetting("FileDlg:QuickDirList"); + QStringList dirList = QStringList::split(';', dirs, false); + if (dirList.count() > 0) { + for (unsigned i = 0; i < dirList.count(); i++) + myQuickCombo->insertItem(dirList[i]); + } + else { + myQuickCombo->insertItem(QDir::homeDirPath()); + } + + // the following is a workaround for proper layouting of custom widgets =========== + QValueList buttonList; + QValueList labelList; + const QObjectList *list = children(); + QObjectListIt it(*list); + int maxButWidth = lab->sizeHint().width(); + int maxLabWidth = btn->sizeHint().width(); + + for (; it.current() ; ++it) { + if ( it.current()->isA( "QLabel" ) ) { + int tempW = ((QLabel*)it.current())->minimumWidth(); + if ( maxLabWidth < tempW ) maxLabWidth = tempW; + labelList.append( (QLabel*)it.current() ); + } + else if( it.current()->isA("QPushButton") ) { + int tempW = ((QPushButton*)it.current())->minimumWidth(); + if ( maxButWidth < tempW ) maxButWidth = tempW; + buttonList.append( (QPushButton*)it.current() ); + } + } + if (maxButWidth > 0) { + QValueList::Iterator bListIt; + for ( bListIt = buttonList.begin(); bListIt != buttonList.end(); ++bListIt ) + (*bListIt)->setFixedWidth( maxButWidth ); + } + if (maxLabWidth > 0) { + QValueList::Iterator lListIt; + for ( lListIt = labelList.begin(); lListIt != labelList.end(); ++lListIt ) + (*lListIt)->setFixedWidth( maxLabWidth ); + } + // ================================================================================ + } + setMode( myOpen ? ExistingFile : AnyFile ); + setCaption( myOpen ? tr( "INF_DESK_DOC_OPEN" ) : tr( "INF_DESK_DOC_SAVE" ) ); + if (myLastVisitedPath.isNull() || myLastVisitedPath.isEmpty()) { + // If no last visited path exists -> switch to the first preferred path + processPath(myQuickCombo->text(0)); + } + else if ( !processPath(myLastVisitedPath) ) { + // If last visited path doesn't exist -> switch to the first preferred path + processPath(myQuickCombo->text(0)); + } + myValidator = new QAD_FileValidator(this); + +} + +/*! +Destructor +*/ +QAD_FileDlg::~QAD_FileDlg() +{ +} + +/*! +Sets validator for file names to open/save +Deletes previous validator +*/ +void QAD_FileDlg::setValidator( QAD_FileValidator* v ) +{ + if (myValidator) + delete myValidator; + myValidator = v; +} + +/*! +Returns the selected file +*/ +QString QAD_FileDlg::selectedFile() const +{ + return mySelectedFile; +} + +/*! +Returns 'true' if this is 'Open File' dialog +and 'false' if 'Save File' dialog +*/ +bool QAD_FileDlg::isOpenDlg() const +{ + return myOpen; +} + +/*! +Closes this dialog and sets the return code to 'Accepted' +if the selected name is valid ( see 'acceptData()' ) +*/ +void QAD_FileDlg::accept() +{ +// mySelectedFile = QFileDialog::selectedFile().simplifyWhiteSpace(); //VSR- 06/12/02 + mySelectedFile = QFileDialog::selectedFile(); //VSR+ 06/12/02 + addExtension(); +// mySelectedFile = mySelectedFile.simplifyWhiteSpace(); //VSR- 06/12/02 + + /* Qt 2.2.2 BUG: accept() is called twice if you validate + the selected file name by pressing 'Return' key in file + name editor but this name is not acceptable for acceptData() + */ + if ( acceptData() ) { + myLastVisitedPath = dirPath(); + QFileDialog::accept(); + } +} + +/*! +Closes this dialog and sets the return code to 'Rejected' +*/ +void QAD_FileDlg::reject() +{ + mySelectedFile = QString::null; + QFileDialog::reject(); +} + +/*! +Returns 'true' if selected file is valid. +The validity is checked by a file validator, +if there is no validator the file is always +considered as valid +*/ +bool QAD_FileDlg::acceptData() +{ + if ( myValidator ) + { + if ( isOpenDlg() ) + return myValidator->canOpen( selectedFile() ); + else + return myValidator->canSave( selectedFile() ); + } + return true; +} + +/*! +Adds an extension to the selected file name +if the file has not it. +The extension is extracted from the active filter. +*/ +void QAD_FileDlg::addExtension() +{ +// mySelectedFile.stripWhiteSpace();//VSR- 06/12/02 +// if ( mySelectedFile.isEmpty() )//VSR- 06/12/02 + if ( mySelectedFile.stripWhiteSpace().isEmpty() )//VSR+ 06/12/02 + return; + +// if ( QAD_Tools::getFileExtensionFromPath( mySelectedFile ).isEmpty() ) //VSR- 06/12/02 + if ( QAD_Tools::getFileExtensionFromPath( mySelectedFile ).isEmpty() && !mySelectedFile.contains(".") ) //VSR+ 06/12/02 + { +#if QT_VERSION < 0x030000 + QRegExp r( QString::fromLatin1("([a-zA-Z0-9.*? +;#]*)$") ); + int len, index = r.match( selectedFilter(), 0, &len ); +#else + QRegExp r( QString::fromLatin1("\\([a-zA-Z0-9.*? +;#]*\\)$") ); + int index = r.search(selectedFilter()); +#endif + if ( index >= 0 ) + { +#if QT_VERSION < 0x030000 +// QString wildcard = selectedFilter().mid( index + 1, len-2 ); //VSR- 06/12/02 + QString wildcard = selectedFilter().mid( index + 1, len-2 ).stripWhiteSpace(); //VSR+ 06/12/02 +#else +// QString wildcard = selectedFilter().mid( index + 1, r.matchedLength()-2 ); //VSR- 06/12/02 + QString wildcard = selectedFilter().mid( index + 1, r.matchedLength()-2 ).stripWhiteSpace(); //VSR+ 06/12/02 +#endif + index = wildcard.findRev( '.' ); + if ( index >= 0 ) + mySelectedFile += wildcard.mid( index ); + } + } +} + +/*! + Processes selection : tries to set given path or filename as selection +*/ +bool QAD_FileDlg::processPath( const QString& path ) +{ + if ( !path.isNull() ) { + QFileInfo fi( path ); + if ( fi.exists() ) { + if ( fi.isFile() ) + setSelection( path ); + else if ( fi.isDir() ) + setDir( path ); + return true; + } + else { + if ( QFileInfo( fi.dirPath() ).exists() ) { + setDir( fi.dirPath() ); + return true; + } + } + } + return false; +} +/*! + Called when user selects item from "Quick Dir" combo box +*/ +void QAD_FileDlg::quickDir(const QString& dirPath) +{ + if ( !QDir(dirPath).exists() ) { + QAD_MessageBox::error1(this, + tr("ERR_ERROR"), + tr("ERR_DIR_NOT_EXIST").arg(dirPath), + tr("BUT_OK")); + + } + else { + processPath(dirPath); + } +} + +/*! + Returns the file name for Open/Save [ static ] +*/ +QString QAD_FileDlg::getFileName( QWidget* parent, + const QString& initial, + const QStringList& filters, + const QString& caption, + bool open, + bool showQuickDir, + QAD_FileValidator* validator ) +{ + QAD_FileDlg* fd = new QAD_FileDlg( parent, open, showQuickDir, true ); + if ( !caption.isEmpty() ) + fd->setCaption( caption ); + 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 ); + if ( validator ) + fd->setValidator( validator ); + fd->exec(); + QString filename = fd->selectedFile(); + delete fd; + qApp->processEvents(); + return filename; +} + +/*! + Existing directory selection dialog [ static ] +*/ +QString QAD_FileDlg::getExistingDirectory ( QWidget* parent, + const QString& initial, + const QString& caption, + bool showQuickDir ) +{ + QAD_FileDlg* fd = new QAD_FileDlg( parent, true, showQuickDir, true); + if ( !caption.isEmpty() ) + fd->setCaption( caption ); + if ( !initial.isEmpty() ) { + fd->processPath( initial ); // VSR 24/03/03 check for existing of directory has been added to avoid QFileDialog's bug + } + 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 new file mode 100644 index 000000000..451c1a975 --- /dev/null +++ b/src/SALOMEGUI/QAD_FileDlg.h @@ -0,0 +1,64 @@ +// File : QAD_FileDlg.h +// Created : UI team, 17.09.02 +// Descr : Open/Save File dialog + +// Modified : Tue Sep 17 11:02:12 2002 +// Author : +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef QAD_FILEDIALOG_H +#define QAD_FILEDIALOG_H + +#include +#include +#include "QAD.h" +#include "QAD_FileValidator.h" + +class QAD_EXPORT QAD_FileDlg : public QFileDialog +{ + Q_OBJECT + +public: + QAD_FileDlg( QWidget* parent, bool open, bool showQuickDir = true, bool modal = true ); + ~QAD_FileDlg(); + +public: + bool isOpenDlg() const; + QString selectedFile() const; + + void setValidator( QAD_FileValidator* ); + + static QString getFileName( QWidget* parent, + const QString& initial, + const QStringList& filters, + const QString& caption, + bool open, + bool showQuickDir = true, + QAD_FileValidator* validator = 0); + static QString getExistingDirectory ( QWidget* parent, + const QString& initial, + const QString& caption, + bool showQuickDir = true); +private: + bool acceptData(); + void addExtension(); + bool processPath( const QString& path ); + +protected slots: + void accept(); + void reject(); + void quickDir(const QString&); + +protected: + bool myOpen; /* open/save selector */ + QString mySelectedFile; /* selected filename */ + 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 new file mode 100644 index 000000000..68215dee8 --- /dev/null +++ b/src/SALOMEGUI/QAD_FileValidator.cxx @@ -0,0 +1,94 @@ +using namespace std; +// File : QAD_FileValidator.cxx +// Created : UI team, 17.09.02 +// Descr : File validator for QFileDlg class + +// Modified : Tue Sep 17 10:47:01 2002 +// Author : +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + +#include "QAD_FileValidator.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" + +#include +#include + +/* constructor */ +QAD_FileValidator::QAD_FileValidator(QWidget* parent) : +myParent(parent) +{ + if (!myParent) { + myParent = QAD_Application::getDesktop(); + } +} + +/* returns false if can't open file */ +bool QAD_FileValidator::canOpen( const QString& file ) +{ +MESSAGE ( "QAD_FileValidator::canOpen" ) + if ( !QFile::exists( file ) ) { + QAD_MessageBox::error1( myParent, + QObject::tr( "ERR_ERROR" ), + QObject::tr( "ERR_DOC_FILENOTEXIST" ).arg( file ), + QObject::tr( "BUT_OK" ) ); + return false; + } + if ( !QFileInfo( file ).isReadable() ) { + QAD_MessageBox::error1( myParent, + QObject::tr( "ERR_ERROR" ), + QObject::tr( "ERR_PERMISSION_DENIED" ).arg( file ), + QObject::tr( "BUT_OK" ) ); + return false; + } + return true; +} + +/* returns false if can't save file */ +bool QAD_FileValidator::canSave( const QString& file ) +{ +MESSAGE ( "QAD_FileValidator::canSave" ) + if ( QFile::exists( file ) ) { + // if file exists - raise warning... + if ( QAD_MessageBox::warn2( myParent, + QObject::tr( "WRN_WARNING" ), + QObject::tr( "QUE_DOC_FILEEXISTS" ).arg( file ), + QObject::tr( "BUT_YES" ), + QObject::tr( "BUT_NO" ), + QAD_YES, + QAD_NO, + QAD_NO ) == QAD_NO ) { + return false; + } + // ... and if user wants to overwrite file, check it for writeability + if ( !QFileInfo( file ).isWritable() ) { + QAD_MessageBox::error1( myParent, + QObject::tr( "ERR_ERROR" ), + QObject::tr( "ERR_PERMISSION_DENIED" ).arg( file ), + QObject::tr( "BUT_OK" ) ); + return false; + } + } + else { + // if file doesn't exist - try to create it + QFile qf( file ); + if ( !qf.open( IO_WriteOnly ) ) { + QAD_MessageBox::error1( myParent, + QObject::tr( "ERR_ERROR" ), + QObject::tr( "ERR_PERMISSION_DENIED" ).arg( file ), + QObject::tr( "BUT_OK" ) ); + return false; + } + else { + // remove just created file + qf.close(); + qf.remove(); + } + } + return true; +} + diff --git a/src/SALOMEGUI/QAD_FileValidator.h b/src/SALOMEGUI/QAD_FileValidator.h new file mode 100644 index 000000000..a28c4caa2 --- /dev/null +++ b/src/SALOMEGUI/QAD_FileValidator.h @@ -0,0 +1,30 @@ +// File : QAD_FileValidator.h +// Created : UI team, 17.09.02 +// Descr : File validator for QFileDlg class + +// Modified : Tue Sep 17 10:40:50 2002 +// Author : +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef QAD_FILEVALIDATOR_H +#define QAD_FILEVALIDATOR_H + +#include +#include "QAD.h" + +class QAD_EXPORT QAD_FileValidator +{ +public: + QAD_FileValidator(QWidget* parent = 0); + + virtual bool canOpen( const QString& file ); + virtual bool canSave( const QString& file ); + + private: + QWidget* myParent; +}; + +#endif diff --git a/src/SALOMEGUI/QAD_Help.cxx b/src/SALOMEGUI/QAD_Help.cxx new file mode 100644 index 000000000..d6aca1a2e --- /dev/null +++ b/src/SALOMEGUI/QAD_Help.cxx @@ -0,0 +1,61 @@ +using namespace std; +// File : QAD_Help.cxx +// Created : UI team, 03.11.00 +// Descrip : Shows help in QAD-based applications + +// Modified : Mon Dec 03 13:40:28 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + + +#include "QAD_Help.h" + +/*! + \class QAD_Help QAD_HelpL.h + \brief Shows help in QAD-based applications. +*/ + +/*! + Constructor +*/ +QAD_Help::QAD_Help() +{ +} + +/*! + Destructor +*/ +QAD_Help::~QAD_Help() +{ +} + +/*! + Shows help index +*/ +void QAD_Help::index() +{ +} + +/*! + Help search +*/ +void QAD_Help::search() +{ +} + +/*! + Shows help contents +*/ +void QAD_Help::contents() +{ +} + +/*! + Shows context help for 'section' and 'topic' +*/ +void QAD_Help::context( const QCString& section, const QCString& topic ) +{ +} diff --git a/src/SALOMEGUI/QAD_Help.h b/src/SALOMEGUI/QAD_Help.h new file mode 100644 index 000000000..3b20b7f99 --- /dev/null +++ b/src/SALOMEGUI/QAD_Help.h @@ -0,0 +1,32 @@ +// File : QAD_Help.cxx +// Created : UI team, 03.11.00 +// Descrip : Shows help in QAD-based applications + +// Modified : Mon Dec 03 13:40:28 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + + +#ifndef QAD_HELP_H +#define QAD_HELP_H + +#include + +class QAD_Help +{ +public: + QAD_Help(); + ~QAD_Help(); + + static void index(); + static void search(); + static void contents (); + static void context( const QCString& context, const QCString& topic ); +}; + +#endif + + diff --git a/src/SALOMEGUI/QAD_HelpWindow.cxx b/src/SALOMEGUI/QAD_HelpWindow.cxx new file mode 100644 index 000000000..c1302c27f --- /dev/null +++ b/src/SALOMEGUI/QAD_HelpWindow.cxx @@ -0,0 +1,223 @@ +using namespace std; +// File : QAD_HelpWindow.cxx +// Created : Thu Jun 14 16:12:49 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +/*! + \class QAD_HelpWindow QAD_HelpWindow.h + \brief Html browser for help. +*/ + +#include "QAD_HelpWindow.h" +#include "QAD_ResourceMgr.h" +#include "QAD_Desktop.h" +#include "QAD_Application.h" +#include "QAD_Tools.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include + +/*! + Constructor +*/ +QAD_HelpWindow::QAD_HelpWindow() + : QMainWindow( 0, "SALOME Professional Help", WStyle_Customize | WType_TopLevel | WDestructiveClose ), + pathCombo( 0 ), selectedURL() +{ + QAD_ResourceMgr* rmgr = QAD_Desktop::getResourceManager(); + + // alternative palette + setPalette( QAD_Application::getPalette(true) ); + // caption + setCaption( tr("SALOMEGUI_HELP_TITLE") ); + // icon + QPixmap icon ( rmgr->loadPixmap( "CLIENT", tr("ICON_DESK_DEFAULTICON") ) ); + if ( !icon.isNull() ) setIcon( icon ); + + // create browser + browser = new QTextBrowser( this ); + browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); + connect( browser, SIGNAL( textChanged() ), this, SLOT( textChanged() ) ); + setCentralWidget( browser ); + + // menu/toolbar actions + menuBar()->setItemEnabled( forwardId, FALSE); + menuBar()->setItemEnabled( backwardId, FALSE); + connect( browser, SIGNAL( backwardAvailable( bool ) ), + this, SLOT( setBackwardAvailable( bool ) ) ); + connect( browser, SIGNAL( forwardAvailable( bool ) ), + this, SLOT( setForwardAvailable( bool ) ) ); + + QIconSet icon_back( QPixmap(rmgr->loadPixmap("QAD", tr("ICON_APP_HELP_BACK")) )); + QIconSet icon_forward( QPixmap(rmgr->loadPixmap("QAD", tr("ICON_APP_HELP_FORWARD")) )); + QIconSet icon_home( QPixmap(rmgr->loadPixmap("QAD", tr("ICON_APP_HELP_HOME")) )); + + QToolBar* toolbar = new QToolBar( this ); + addToolBar( toolbar, "Toolbar"); + QToolButton* button; + + button = new QToolButton( icon_back, tr("TOT_HELPWINDOW_BACKWARD"), "", browser, SLOT(backward()), toolbar ); + connect( browser, SIGNAL( backwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); + button->setEnabled( FALSE ); + button = new QToolButton( icon_forward, tr("TOT_HELPWINDOW_FORWARD"), "", browser, SLOT(forward()), toolbar ); + connect( browser, SIGNAL( forwardAvailable(bool) ), button, SLOT( setEnabled(bool) ) ); + button->setEnabled( FALSE ); + button = new QToolButton( icon_home, tr("TOT_HELPWINDOW_HOME"), "", browser, SLOT(home()), toolbar ); + + toolbar->addSeparator(); + + pathCombo = new QComboBox( TRUE, toolbar ); + pathCombo->setInsertionPolicy(QComboBox::NoInsertion); + pathCombo->setDuplicatesEnabled(false); + connect( pathCombo, SIGNAL( activated( const QString & ) ), + this, SLOT( pathSelected( const QString & ) ) ); + toolbar->setStretchableWidget( pathCombo ); + setRightJustification( TRUE ); + setDockEnabled( Left, FALSE ); + setDockEnabled( Right, FALSE ); + setDockEnabled( Bottom, FALSE ); + setDockEnabled( TornOff, FALSE ); + setDockMenuEnabled( false ); + + // look for index.html and set homeDir + // 1. $(SALOME_ROOT_DIR)/doc/index.html + // 2. $(SALOME_ROOT_DIR)/doc/html/index.html + // 3. $(SALOME_ROOT_DIR)/doc/html/html/index.html + // 4. /usr/local/doc/html/index.html + + QCString dir; + QString root; + if ( (dir = getenv("SALOME_ROOT_DIR")) ) { + root = QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + "doc" ); + if ( QFileInfo( root + "index.html" ).exists() ) { + homeDir = root; + } + else { + root = QAD_Tools::addSlash( root + "html" ); + if ( QFileInfo( root + "index.html" ).exists() ) { + homeDir = root; + } + else { + root = QAD_Tools::addSlash( root + "html" ); + if ( QFileInfo( root + "index.html" ).exists() ) { + homeDir = root; + } + } + } + } + if ( root.isEmpty() ) { + if ( QFileInfo( "/usr/local/doc/html/index.html" ).exists() ) { + homeDir = "/usr/local/doc/html/"; + } + } + if ( root.isEmpty() ) + root = "./doc/"; + + browser->setSource( QFileInfo( homeDir + "index.html" ).absFilePath() ); + browser->setFocus(); + + QSize dSize = QApplication::desktop()->size(); + int x = ( dSize.width() - 750 ) / 2; + int y = ( dSize.height() - 680 ) / 2; + setGeometry( x, y, 750, 680 ); +} + +/*! + Destructor +*/ +QAD_HelpWindow::~QAD_HelpWindow() +{ + emit(helpWindowClosed()); +} + +/*! + enables/disables button +*/ +void QAD_HelpWindow::setBackwardAvailable( bool b) +{ + menuBar()->setItemEnabled( backwardId, b); +} + +/*! + enables/disables button + */ +void QAD_HelpWindow::setForwardAvailable( bool b) +{ + menuBar()->setItemEnabled( forwardId, b); +} + +/*! + called when new document is loaded into browser +*/ +void QAD_HelpWindow::textChanged() +{ + if ( browser->documentTitle().isNull() && browser->context().isNull() && browser->source().isNull() ) + browser->clear(); + selectedURL = browser->source(); //caption(); + if ( !selectedURL.isEmpty() && pathCombo ) { + bool exists = FALSE; + int i; + for ( i = 0; i < pathCombo->count(); ++i ) { + if ( pathCombo->text( i ) == selectedURL ) { + exists = TRUE; + break; + } + } + if ( !exists ) { + pathCombo->insertItem( selectedURL, 0 ); + pathCombo->setCurrentItem( 0 ); + } else { + pathCombo->setCurrentItem( i ); + } + selectedURL = QString::null; + } +} + +/*! + called when users selectes dosument from the combo box +*/ +void QAD_HelpWindow::pathSelected( const QString& _path ) +{ + browser->setSource( _path ); +} + +/*! + goes back to the contents +*/ +void QAD_HelpWindow::contents() +{ + browser->home(); +} + +/*! + opens new document in browser window and makes context search + <_source> is a filename, can be relative, if empty, index.html name is used + <_context> is a context, e.g. link in the file +*/ +void QAD_HelpWindow::context( const QString& _source, const QString& _context) +{ + QString src; + if ( _source.isEmpty() ) { + src = homeDir + "index.html"; + } + else { + QFileInfo fi( _source ); + if ( fi.isRelative() ) + src = homeDir + _source; + else + src = _source; + } + if ( !_context.isEmpty() ) + src += "#" + _context; + browser->setSource( src ); +} diff --git a/src/SALOMEGUI/QAD_HelpWindow.h b/src/SALOMEGUI/QAD_HelpWindow.h new file mode 100644 index 000000000..f052d296d --- /dev/null +++ b/src/SALOMEGUI/QAD_HelpWindow.h @@ -0,0 +1,47 @@ +// File : QAD_HelpWindow.h +// Created : Thu Jun 14 16:11:33 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_HELPWINDOW_H +#define QAD_HELPWINDOW_H + +#include +#include + +class QComboBox; +class QPopupMenu; + +class QAD_HelpWindow : public QMainWindow +{ + Q_OBJECT +public: + QAD_HelpWindow(); + ~QAD_HelpWindow(); + + void contents(); + void context( const QString& _source, const QString& _context = QString::null ); + +private slots: + void setBackwardAvailable( bool ); + void setForwardAvailable( bool ); + void textChanged(); + void pathSelected( const QString & ); + +signals: + void helpWindowClosed(); + +private: + QTextBrowser* browser; + QComboBox* pathCombo; + int backwardId, forwardId; + QString selectedURL; + QString homeDir; + +}; + +#endif + diff --git a/src/SALOMEGUI/QAD_LeftFrame.cxx b/src/SALOMEGUI/QAD_LeftFrame.cxx new file mode 100644 index 000000000..2f8aff41c --- /dev/null +++ b/src/SALOMEGUI/QAD_LeftFrame.cxx @@ -0,0 +1,44 @@ +using namespace std; +// File : QAD_LeftFrame.cxx +// Created : Thu Jun 14 14:53:30 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + +#include "QAD_LeftFrame.h" +#include "QAD_ObjectBrowser.h" +#include + +/*! + \class QAD_LeftFrame QAD_LeftFrame.h + \brief Frame window which contains QAD_ObjectBrowser. +*/ + +/*! + Constructor +*/ +QAD_LeftFrame::QAD_LeftFrame( SALOMEDS::Study_var study, QWidget *parent, const char *name) + : QWidget( parent, name ) +{ + QVBoxLayout* layout = new QVBoxLayout( this ); + layout->setMargin( 0 ); layout->setSpacing( 6 ); + myObjectBrowser = new QAD_ObjectBrowser( study, this ); + layout->addWidget( myObjectBrowser ); +} + +/*! + Destructor +*/ +QAD_LeftFrame::~QAD_LeftFrame() +{ +} + +/*! + Returns reference to Object Browser [ static ] +*/ +QAD_ObjectBrowser* QAD_LeftFrame::getObjectBrowser() const +{ + return myObjectBrowser; +} diff --git a/src/SALOMEGUI/QAD_LeftFrame.h b/src/SALOMEGUI/QAD_LeftFrame.h new file mode 100644 index 000000000..b0a018740 --- /dev/null +++ b/src/SALOMEGUI/QAD_LeftFrame.h @@ -0,0 +1,32 @@ +// File : QAD_LeftFrame.h +// Created : Thu Jun 14 14:51:17 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_LeftFrame_H +#define QAD_LeftFrame_H + +#include "QAD.h" +#include +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +class QAD_ObjectBrowser; + +class QAD_EXPORT QAD_LeftFrame : public QWidget +{ +public: + QAD_LeftFrame( SALOMEDS::Study_var study, QWidget *parent, const char *name ); + ~QAD_LeftFrame(); + + QAD_ObjectBrowser* getObjectBrowser() const; + +protected: + QAD_ObjectBrowser* myObjectBrowser; +}; + +#endif diff --git a/src/SALOMEGUI/QAD_ListMenuIdAction.cxx b/src/SALOMEGUI/QAD_ListMenuIdAction.cxx new file mode 100644 index 000000000..445a8f371 --- /dev/null +++ b/src/SALOMEGUI/QAD_ListMenuIdAction.cxx @@ -0,0 +1,23 @@ +using namespace std; +// File : QAD_ListMenuIdAction.cxx +// Created : Thu Jun 14 13:54:44 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "QAD_ListMenuIdAction.h" + +QAD_ListMenuIdAction::QAD_ListMenuIdAction(QPopupMenu* theMenu, + int id, + QAction* theAction) +{ + myMenu = theMenu; + myId = id; + myAction = theAction; +} + +QAD_ListMenuIdAction::~QAD_ListMenuIdAction() +{ +} diff --git a/src/SALOMEGUI/QAD_ListMenuIdAction.h b/src/SALOMEGUI/QAD_ListMenuIdAction.h new file mode 100644 index 000000000..5fe1417e8 --- /dev/null +++ b/src/SALOMEGUI/QAD_ListMenuIdAction.h @@ -0,0 +1,32 @@ +// File : QAD_ListMenuIdAction.h +// Created : Thu Jun 14 13:55:29 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_LISTMENUIDACTION_H +#define QAD_LISTMENUIDACTION_H + +#include +#include + +class QAD_ListMenuIdAction +{ + +public: + QAD_ListMenuIdAction(QPopupMenu*,int,QAction*); + virtual ~QAD_ListMenuIdAction(); + + int getId() {return myId;} + QPopupMenu* getMenu() {return myMenu;} + QAction* getAction() {return myAction;} + +private: + QPopupMenu* myMenu; + int myId; + QAction* myAction; +}; + +#endif diff --git a/src/SALOMEGUI/QAD_ListPopupMenu.cxx b/src/SALOMEGUI/QAD_ListPopupMenu.cxx new file mode 100644 index 000000000..2ddc24522 --- /dev/null +++ b/src/SALOMEGUI/QAD_ListPopupMenu.cxx @@ -0,0 +1,32 @@ +using namespace std; +// File : QAD_ListPopupMenu.cxx +// Created : Thu Jun 14 13:53:41 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + + +#include "QAD_ListPopupMenu.h" + +/*! + Constructor. +*/ +QAD_ListPopupMenu::QAD_ListPopupMenu(QPopupMenu* thePopup, + const QString & theContext, + const QString & theParent, + const QString & theObject) +{ + myPopup = thePopup; + myContext = theContext; + myParent = theParent; + myObject = theObject; +} + +/*! + Destructor. +*/ +QAD_ListPopupMenu::~QAD_ListPopupMenu() +{ +} diff --git a/src/SALOMEGUI/QAD_ListPopupMenu.h b/src/SALOMEGUI/QAD_ListPopupMenu.h new file mode 100644 index 000000000..4d3f16fb9 --- /dev/null +++ b/src/SALOMEGUI/QAD_ListPopupMenu.h @@ -0,0 +1,36 @@ +// File : QAD_ListPopupMenu.h +// Created : Thu Jun 14 13:52:42 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_LISTPOPUPMENU_H +#define QAD_LISTPOPUPMENU_H + +#include + +class QAD_ListPopupMenu +{ + +public: + QAD_ListPopupMenu(QPopupMenu*, + const QString & theContext, + const QString & theParent, + const QString & theObject); + virtual ~QAD_ListPopupMenu(); + + QPopupMenu* getPopup() {return myPopup;} + QString & getContext() {return myContext;} + QString & getParent() {return myParent;} + QString & getObject() {return myObject;} + +private: + QPopupMenu* myPopup; + QString myContext; + QString myParent; + QString myObject; +}; + +#endif diff --git a/src/SALOMEGUI/QAD_ListView.cxx b/src/SALOMEGUI/QAD_ListView.cxx new file mode 100644 index 000000000..6b226f619 --- /dev/null +++ b/src/SALOMEGUI/QAD_ListView.cxx @@ -0,0 +1,1520 @@ +using namespace std; +// File : QAD_ListView.cxx +// Created : 24/10/2002 +// Descr : List view for editing of properties + +// Author : Vadim SANDLER +// Project : SALOME Pro +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "QAD_ListView.h" + +#include +#include +#include +#include + +#include "QAD_Desktop.h" + +//#include +//#include + + +#include +#include + +////////////////////////////////////////////////////////////////////// +// QAD_ListView class implementation +////////////////////////////////////////////////////////////////////// + +//================================================================ +// Function : computeEditGeometry +// Purpose : static function - used for resizing editing widget +//================================================================ +void computeEditGeometry(QAD_ListViewItem* theItem, + QAD_EntityEdit* theWidget) +{ + if (!theItem) + return; + QListView* aListView = theItem->listView(); + int anEditColumn = theItem->getEditedColumn(); + if (anEditColumn < 0) + return; + + int aX = 0, aY = 0, aW = 0, aH = 0; + + QRect aRect = aListView->itemRect(theItem); + aListView->contentsToViewport(aListView->header()->sectionPos(anEditColumn), 0, aX, aY); + if (aX < 0) + aX = 0; // THIS CAN BE REMOVED + QSize aSize = theWidget->getControl()->sizeHint(); + aH = QMAX(aSize.height() , aRect.height() ); + aY = aRect.y() - ((aH - aRect.height()) / 2); + //aW = aListView->columnWidth(anEditColumn); // CAN SUBSTITUTE NEXT 3 ROWS + aW = aListView->viewport()->width() - aX; + if (aW < 0) + aW = 0; + theWidget->setGeometry(aX, aY, aW, aH); +} + +//================================================================ +// Function : QAD_ListView::QAD_ListView +// Purpose : constructor +//================================================================ +QAD_ListView::QAD_ListView(QWidget *parent) : +QListView(parent) +{ + myPopup = 0; + myMouseEnabled = true; + myEditingEnabled = false; + enablePopup( true ); + setSelectionMode(Single); + setSorting(-1); + setRootIsDecorated(false); + setAllColumnsShowFocus(false); +// header()->setClickEnabled(false); + header()->setMovingEnabled(false); + + myEditedItem = 0; + myEdit = 0; + + viewport()->installEventFilter(this); + + connect(this, SIGNAL(selectionChanged()), + this, SLOT(onSelectionChanged())); + connect(header(), SIGNAL(sizeChange(int, int, int)), + this, SLOT(onHeaderSizeChange(int, int, int))); +} + +//================================================================ +// Function : QAD_ListView::~QAD_ListView +// Purpose : destructor +//================================================================ +QAD_ListView::~QAD_ListView() +{ +// destroy popup menu + deletePopupMenu(); + if (myEdit) { + delete myEdit; + } + myEdit = 0; + myEditedItem = 0; +} + +//================================================================ +// Function : QAD_ListView::updateViewer +// Purpose : updates all data viewer +//================================================================ +void QAD_ListView::updateViewer() +{ + // temporary disconnecting selection changed SIGNAL + blockSignals(true); + QAD_ListViewItem* aRoot = (QAD_ListViewItem*)firstChild(); + if (aRoot) + aRoot->updateAllLevels(); + updateContents(); + // connecting again selection changed SIGNAL + blockSignals(false); + emit selectionChanged(); +} + +//================================================================ +// Function : QAD_ListView::updateSelected +// Purpose : updates currently selected item(s) +//================================================================ +void QAD_ListView::updateSelected() +{ + // temporary disconnecting selection changed SIGNAL + blockSignals(true); + QAD_ListViewItem* aChild = (QAD_ListViewItem*)selectedItem(); + if (aChild) + aChild->updateAllLevels(); + updateContents(); + // connecting again selection changed SIGNAL + blockSignals(false); + emit selectionChanged(); +} + +//================================================================ +// Function : QAD_ListView::onCreatePopup +// Purpose : fills popup menu with items +//================================================================ +void QAD_ListView::onCreatePopup() +{ + if (myPopup) { + // add items here... + } +} + +//================================================================ +// Function : QAD_ListView::deletePopupMenu +// Purpose : delete popup menu +//================================================================ +void QAD_ListView::deletePopupMenu() +{ + if (myPopup) { + destroyPopup(); + delete myPopup; + myPopup = 0; + } +} + +//================================================================ +// Function : QAD_ListView::clear +// Purpose : clears view +//================================================================ +void QAD_ListView::clear() +{ + if (myEdit) { + delete myEdit; + myEdit = 0; + myEditedItem = 0; + } + QListView::clear(); +} + +//================================================================ +// Function : QAD_ListView::isMouseEnabled +// Purpose : returms true if mouse events are enabled +//================================================================ +bool QAD_ListView::isMouseEnabled() +{ + return myMouseEnabled; +} + +//================================================================ +// Function : QAD_ListView::enableMouse +// Purpose : enabled/disables mouse events (excluding MouseMove) +//================================================================ +void QAD_ListView::enableMouse(bool enable) +{ + myMouseEnabled = enable; +} + +//================================================================ +// Function : QAD_ListView::eventFilter +// Purpose : event filter +//================================================================ +bool QAD_ListView::eventFilter(QObject* object, QEvent* event) +{ + if (object == viewport() && + (event->type() == QEvent::MouseButtonPress || + event->type() == QEvent::MouseButtonRelease || + event->type() == QEvent::MouseButtonDblClick) && + !isMouseEnabled()) + return true; + else + return QListView::eventFilter(object, event); +} + +//================================================================ +// Function : QAD_ListView::enableEditing +// Purpose : setting editing of items availbale/not available +//================================================================ +void QAD_ListView::enableEditing(bool theFlag) +{ + myEditingEnabled = theFlag; + if (!myEditingEnabled) { + if (myEdit) { + delete myEdit; + myEdit = 0; + myEditedItem = 0; + } + } +} + +//================================================================ +// Function : QAD_ListView::isEnableEditing +// Purpose : says if editing is enabled +//================================================================ +bool QAD_ListView::isEnableEditing() +{ + return myEditingEnabled; +} + +//================================================================ +// Function : QAD_ListView::accept +// Purpose : calls finishEditing(true)... +//================================================================ +void QAD_ListView::accept() +{ + finishEditing(true); +} + +//================================================================ +// Function : QAD_ListView::contentsMouseReleaseEvent +// Purpose : mouse release button event +//================================================================ +void QAD_ListView::contentsMouseReleaseEvent(QMouseEvent* e) +{ + QListView::contentsMouseReleaseEvent(e); + // destroy popup menu if exist + qApp->processEvents(); + // create popup menu on right button click + if(e->button() == RightButton) { + + deletePopupMenu(); + QPopupMenu* aPopup = createPopup(); + if (aPopup) { + myPopup = aPopup; + if (myPopup->count() > 0) + //myPopup->exec(QCursor::pos()); + myPopup->popup(e->globalPos()); + } + } +} + +//================================================================ +// Function : QAD_ListView::onSelectionChanged +// Purpose : slot, called when selection changed in List Viewer +//================================================================ +void QAD_ListView::onSelectionChanged() +{ + if (myEdit) { + finishEditing(true); + delete myEdit; + myEdit = 0; + if (myEditedItem && !myEditedItem->isAccepted()) { + delete myEditedItem; + updateContents(); + } + myEditedItem = 0; + } + // editing is allowed in Single Selection Mode only + if (selectionMode() != Single || !isEnableEditing()) + return; + QAD_ListViewItem* anItem = (QAD_ListViewItem*)selectedItem(); + if (anItem) { + if (!anItem->isEditable()) + return; + myEdit = anItem->startEditing(); + if (myEdit) { + connect(myEdit, SIGNAL(returnPressed()), this, SLOT(onEditOk())); + connect(myEdit, SIGNAL(escapePressed()), this, SLOT(onEditCancel())); + myEditedItem = anItem; + myEdit->show(); + myEdit->setFocus(); + } + } +} + +//================================================================ +// Function : QAD_ListView::resizeEvent +// Purpose : called when Data Viewer is resized +//================================================================ +void QAD_ListView::resizeEvent( QResizeEvent * e) +{ + QListView::resizeEvent(e); + int aW = columnWidth(columns()-1); + int aX = header()->sectionPos(columns()-1); + if (aW < width() - frameWidth() * 2 - aX - 1) + setColumnWidth(columns()-1, width() - frameWidth() * 2 - aX - 1); + updateContents(); +} + +//================================================================ +// Function : QAD_ListView::onHeaderSizeChange +// Purpose : slot, called when columns sizes are changed +//================================================================ +void QAD_ListView::onHeaderSizeChange(int, int, int) +{ + int aW = columnWidth(columns()-1); + int aX = header()->sectionPos(columns()-1); + if (aW < width() - frameWidth() * 2 - aX - 1) + setColumnWidth(columns()-1, width() - frameWidth() * 2 - aX - 1); +} + +//================================================================ +// Function : QAD_ListView::viewportPaintEvent +// Purpose : handler for paint event +//================================================================ +void QAD_ListView::viewportPaintEvent(QPaintEvent* e) +{ + QListView::viewportPaintEvent(e); + if (myEditedItem && myEdit) { + computeEditGeometry(myEditedItem, myEdit); + } +} + +//================================================================ +// Function : QAD_ListView::onEditOk +// Purpose : called when user finishes in editing of item +//================================================================ +void QAD_ListView::onEditOk() +{ + finishEditing(true); +} + +//================================================================ +// Function : QAD_ListView::onEditCancel +// Purpose : called when user cancels item editing +//================================================================ +void QAD_ListView::onEditCancel() +{ + finishEditing(false); +} + +//================================================================ +// Function : QAD_ListView::finishEditing +// Purpose : finishes editing of entity +//================================================================ +UpdateType QAD_ListView::finishEditing(bool ok) +{ + UpdateType aNeedsUpdate = utCancel; + if (myEditedItem && myEdit) + { + disconnect(myEdit, SIGNAL(returnPressed()), this, SLOT(onEditOk())); + disconnect(myEdit, SIGNAL(escapePressed()), this, SLOT(onEditCancel())); + myEditedItem->setAccepted(true); + if (ok) { + aNeedsUpdate = myEditedItem->finishEditing(myEdit); + if (aNeedsUpdate == utCancel) { + // something to do here on Cancel... + } + else { + // something to do here on OK... + } + // updating contents + switch (aNeedsUpdate) { + case utUpdateItem: + { + if (myEditedItem) + myEditedItem->updateAllLevels(); + break; + } + case utUpdateParent: + { + if (myEditedItem) { + QAD_ListViewItem* aParent = (QAD_ListViewItem*)(myEditedItem->parent()); + if (aParent) + aParent->updateAllLevels(); + else + myEditedItem->updateAllLevels(); + } + break; + } + case utUpdateViewer: + { + updateViewer(); + break; + } + case utUpdateAll: + { + // doing the same as for utUpdateViewer here + // descendants can add extra processing + updateViewer(); + break; + } + default: + break; + } + } + } + + // hide widget + if (myEdit) { + myEdit->hide(); + } + + return aNeedsUpdate; +} + +//================================================================ +// Function : QAD_ListView::tip +// Purpose : gets current tooltip for list view +// returns valid rect in success +//================================================================ +QRect QAD_ListView::tip(QPoint aPos, + QString& aText, + QRect& dspRect, + QFont& dspFnt) const +{ + QRect result( -1, -1, -1, -1 ); + QAD_ListViewItem* aItem = (QAD_ListViewItem*)itemAt( aPos ); + if ( aItem ) { + for (int i = 0; i < columns(); i++) { + QRect aItemRect = aItem->itemRect(i); + QRect aTextRect = aItem->textRect(i); + if ( !aItem->text(i).isEmpty() && + ( aItemRect.width() > header()->sectionSize(i) || + aTextRect.left() < 0 || + aTextRect.top() < 0 || + aTextRect.right() > viewport()->width() || + aTextRect.bottom() > viewport()->height() ) ) { + // calculating tip data + aText = aItem->tipText(); + dspRect = aItem->tipRect(); + dspFnt = font(); + if (dspRect.isValid()) { + result = QRect(QPoint(0, aItemRect.top()), + QSize(viewport()->width(), aItemRect.height())); + } + } + } + } + return result; +} + +////////////////////////////////////////////////////////////////////// +// QAD_ListViewItem Class Implementation +////////////////////////////////////////////////////////////////////// + +//================================================================ +// Function : QAD_ListViewItem::QAD_ListViewItem +// Purpose : constructor +//================================================================ +QAD_ListViewItem::QAD_ListViewItem(QAD_ListView* parent) : +QListViewItem( parent ) +{ + init(); +} + +//================================================================ +// Function : QAD_ListViewItem::QAD_ListViewItem +// Purpose : constructor +//================================================================ +QAD_ListViewItem::QAD_ListViewItem(QAD_ListView* parent, + QAD_ListViewItem* after) : +QListViewItem( parent, after ) +{ + init(); +} + +//================================================================ +// Function : QAD_ListViewItem::QAD_ListViewItem +// Purpose : constructor +//================================================================ +QAD_ListViewItem::QAD_ListViewItem(QAD_ListView* parent, + const QString theName, + const bool theEditable) : +QListViewItem(parent, theName) +{ + init(); + setEditable(theEditable); +} + +//================================================================ +// Function : QAD_ListViewItem::QAD_ListViewItem +// Purpose : constructor +//================================================================ +QAD_ListViewItem::QAD_ListViewItem(QAD_ListView* parent, + const QString theName, + const QString theValue, + const bool theEditable) : +QListViewItem(parent, theName, theValue) +{ + init(); + setEditable(theEditable); +} + +//================================================================ +// Function : QAD_ListViewItem::QAD_ListViewItem +// Purpose : constructor +//================================================================ +QAD_ListViewItem::QAD_ListViewItem(QAD_ListViewItem* parent, + const QString theName, + const bool theEditable) : +QListViewItem(parent, theName) +{ + init(); + setEditable(theEditable); +} + +//================================================================ +// Function : QAD_ListViewItem::QAD_ListViewItem +// Purpose : constructor +//================================================================ +QAD_ListViewItem::QAD_ListViewItem(QAD_ListViewItem* parent, + QAD_ListViewItem* after, + const QString theName, + const bool theEditable) : +QListViewItem(parent, after, theName) +{ + init(); + setEditable(theEditable); +} + +//================================================================ +// Function : QAD_ListViewItem::QAD_ListViewItem +// Purpose : constructor +//================================================================ +QAD_ListViewItem::QAD_ListViewItem(QAD_ListView* parent, + QAD_ListViewItem* after, + const QString theName, + const bool theEditable) : +QListViewItem(parent, after, theName) +{ + init(); + setEditable(theEditable); +} + + +//================================================================ +// Function : QAD_ListViewItem::QAD_ListViewItem +// Purpose : constructor +//================================================================ +QAD_ListViewItem::QAD_ListViewItem(QAD_ListViewItem* parent, + const QString theName, + const QString theValue, + const bool theEditable) : +QListViewItem(parent, theName, theValue) +{ + init(); + setEditable(theEditable); +} + + +//================================================================ +// Function : QAD_ListViewItem::QAD_ListViewItem +// Purpose : constructor +//================================================================ +QAD_ListViewItem::QAD_ListViewItem(QAD_ListViewItem* parent, + QAD_ListViewItem* after, + const QString theName, + const QString theValue, + const bool theEditable) : +QListViewItem(parent, after, theName, theValue) +{ + init(); + setEditable(theEditable); +} + +//================================================================ +// Function : QAD_ListViewItem::QAD_ListViewItem +// Purpose : constructor +//================================================================ +QAD_ListViewItem::QAD_ListViewItem(QAD_ListView* parent, + QAD_ListViewItem* after, + const QString theName, + const QString theValue, + const bool theEditable) : +QListViewItem(parent, after, theName, theValue) +{ + init(); + setEditable(theEditable); +} + +//================================================================ +// Function : QAD_ListViewItem::~QAD_ListViewItem +// Purpose : destructor +//================================================================ +QAD_ListViewItem::~QAD_ListViewItem() +{ +} + +//================================================================ +// Function : QAD_ListViewItem::init +// Purpose : initialization +//================================================================ +void QAD_ListViewItem::init() +{ + myEditable = false; + myAccepted = true; + myEditingType = (int)QAD_EntityEdit::etLineEdit; + myValueType = (int)QAD_EntityEdit::vtString; + myButtons = 0; + myUserType = -1; +} + +//================================================================ +// Function : QAD_ListViewItem::getName +// Purpose : as default returns text in the first column +//================================================================ +QString QAD_ListViewItem::getName() const +{ + return ( listView()->columns() > 0 ) ? text(0) : QString(""); +} + +//================================================================ +// Function : QAD_ListViewItem::setName +// Purpose : as default sets text in the first column +//================================================================ +UpdateType QAD_ListViewItem::setName(const QString theName) +{ + UpdateType aNeedsUpdate = utCancel; + if (listView()->columns() > 0) { + setText(0, theName); + aNeedsUpdate = utNone; + } + return aNeedsUpdate; +} + +//================================================================ +// Function : QAD_ListViewItem::getValue +// Purpose : as default returns text in the second column +//================================================================ +QString QAD_ListViewItem::getValue() const +{ + return ( listView()->columns() > 1 ) ? text(1) : QString(""); +} + +//================================================================ +// Function : QAD_ListViewItem::setValue +// Purpose : as default sets text in the second column +//================================================================ +UpdateType QAD_ListViewItem::setValue(const QString theValue) +{ + UpdateType aNeedsUpdate = utCancel; + if (listView()->columns() > 1) { + setText(1, theValue); + aNeedsUpdate = utNone; + } + return aNeedsUpdate; +} + +//================================================================ +// Function : QAD_ListViewItem::fullName +// Purpose : returns full path to the entity from the root +//================================================================ +QString QAD_ListViewItem::fullName() +{ + QString aFullName = getName(); + QAD_ListViewItem* aParent = (QAD_ListViewItem*)parent(); + while(aParent != NULL) { + aFullName = aParent->getName() + QString(".") + aFullName; + aParent = (QAD_ListViewItem*)(aParent->parent()); + } + return aFullName; +} + +//================================================================ +// Function : QAD_ListViewItem::openAllLevels +// Purpose : expands all entities beginning from this level +//================================================================ +void QAD_ListViewItem::openAllLevels() +{ + setOpen(true); + QAD_ListViewItem* aChild = (QAD_ListViewItem*)firstChild(); + while( aChild ) { + aChild->openAllLevels(); + aChild = (QAD_ListViewItem*)(aChild->nextSibling()); + } +} + +//================================================================ +// Function : QAD_ListViewItem::updateAllLevels +// Purpose : update all entites beginning from this level +//================================================================ +void QAD_ListViewItem::updateAllLevels() +{ + QAD_ListViewItem* aChild = (QAD_ListViewItem*)firstChild(); + while( aChild ) { + aChild->updateAllLevels(); + aChild = (QAD_ListViewItem*)(aChild->nextSibling()); + } +} + +//================================================================ +// Function : QAD_EditBox::isEditable +// Purpose : return true if entity is editable +//================================================================ +bool QAD_ListViewItem::isEditable() const +{ + return myEditable; +} + +//================================================================ +// Function : QAD_ListViewItem::setEditable +// Purpose : sets editable flag fo the entity +//================================================================ +void QAD_ListViewItem::setEditable(bool theEditable) +{ + myEditable = theEditable; +} + +//================================================================ +// Function : QAD_ListViewItem::isAccepted +// Purpose : returns true if entitiy is accepted after editing +//================================================================ +bool QAD_ListViewItem::isAccepted() const +{ + return myAccepted; +} + +//================================================================ +// Function : QAD_ListViewItem::setAccepted +// Purpose : set entitiy accepted or not after editing +//================================================================ +void QAD_ListViewItem::setAccepted(bool theAccepted) +{ + myAccepted = theAccepted; +} + +//================================================================ +// Function : QAD_ListViewItem::getEditingType +// Purpose : returns type of edit control (0 - edit box, 1 - combo box, +// 2 - editable combo box), default is edit box +//================================================================ +int QAD_ListViewItem::getEditingType() +{ + return myEditingType; +} + +//================================================================ +// Function : QAD_ListViewItem::setEditingType +// Purpose : sets type of edit control (0 - edit box, 1 - combo box, +// 2 - editable combo box), negative value means none +//================================================================ +void QAD_ListViewItem::setEditingType(const int type) +{ + myEditingType = type; +} + +//================================================================ +// Function : QAD_ListViewItem::getEditedColumn +// Purpose : returns edited column, default is last column +// negative value means there are no editable columns +//================================================================ +int QAD_ListViewItem::getEditedColumn() +{ + return listView()->columns()-1; +} + +//================================================================ +// Function : QAD_ListViewItem::getValueType +// Purpose : returns type of edited value (string, int, double) +// default is string +//================================================================ +int QAD_ListViewItem::getValueType() +{ + return myValueType; +} + +//================================================================ +// Function : QAD_ListViewItem::setValueType +// Purpose : sets type of edited value +//================================================================ +void QAD_ListViewItem::setValueType(const int valueType) +{ + myValueType = valueType; +} + +//================================================================ +// Function : QAD_ListViewItem::getUserType +// Purpose : sets type of edited value +//================================================================ +int QAD_ListViewItem::getUserType() +{ + return myUserType; +} + +//================================================================ +// Function : QAD_ListViewItem::setUserType +// Purpose : sets type of edited value +//================================================================ +void QAD_ListViewItem::setUserType(const int userType) +{ + myUserType = userType; +} + +//================================================================ +// Function : QAD_ListViewItem::getButtons +// Purpose : returns buttons for editing widget (Apply (V), Cancel (X)) +// default is both buttons +//================================================================ +int QAD_ListViewItem::getButtons() +{ + return myButtons; +} + +//================================================================ +// Function : QAD_ListViewItem::getButtons +// Purpose : sets buttons for editing widget (Apply (V), Cancel (X)) +//================================================================ +void QAD_ListViewItem::setButtons(const int buttons) +{ + myButtons = buttons; +} + +//================================================================ +// Function : QAD_ListViewItem::startEditing +// Purpose : creates control for editing and fills it with values +//================================================================ +QAD_EntityEdit* QAD_ListViewItem::startEditing() +{ + QAD_EntityEdit* aWidget = 0; + QListView* aListView = listView(); + if (aListView) { + if (!isEditable()) + return 0; + int anEditType = getEditingType(); + int aValueType = getValueType(); + int aButtons = getButtons(); + int anEditColumn = getEditedColumn(); + if (anEditColumn < 0 || anEditType < 0) + return 0; + aWidget = new QAD_EntityEdit(aListView->viewport(), + anEditType, + aValueType, + aButtons & QAD_EntityEdit::btApply, + aButtons & QAD_EntityEdit::btCancel); + computeEditGeometry(this, aWidget); + + fillWidgetWithValues(aWidget); + } + return aWidget; +} + +//================================================================ +// Function : QAD_ListViewItem::fillWidgetWithValues +// Purpose : fills widget with initial values (list or single value) +//================================================================ +void QAD_ListViewItem::fillWidgetWithValues(QAD_EntityEdit* theWidget) +{ + int anEditColumn = getEditedColumn(); + if (theWidget && anEditColumn >= 0 && !text(anEditColumn).isEmpty()) + theWidget->insertItem(text(anEditColumn), true); +} + +//================================================================ +// Function : QAD_ListViewItem::finishEditing +// Purpose : finishes editing of entity +//================================================================ +UpdateType QAD_ListViewItem::finishEditing(QAD_EntityEdit* theWidget) +{ + UpdateType aNeedsUpdate = utCancel; + try { + if (theWidget) { + int anEditColumn = getEditedColumn(); + switch (anEditColumn) { + case 0: + aNeedsUpdate = setName(theWidget->getText()); + break; + case 1: + aNeedsUpdate = setValue(theWidget->getText()); + break; + default: + break; + } + } + } + catch (...) { + MESSAGE( "System error has been caught - QAD_ListViewItem::finishEditing" ) + } + return aNeedsUpdate; +} + +//================================================================ +// Function : QAD_ListViewItem::tipRect +// Purpose : calculates rectangle which should contain item's tip +//================================================================ +QRect QAD_ListViewItem::tipRect() +{ + QRect aRect = QRect(-1, -1, -1, -1); + QRect aItemRect = listView()->itemRect(this); + if ( !aItemRect.isValid() ) + return aItemRect; + + QString aTip = tipText(); + if (!aTip.isEmpty()) { + QRect aRect0 = textRect(0); + QFont aFont(listView()->font()); + QFontMetrics fm(aFont); + int iw = fm.width(aTip); + aRect = QRect(QPoint(aRect0.x() < 0 ? 0 : aRect0.x(), + aRect0.y()), + QSize (iw, + aRect0.height())); + } + return aRect; +} + +//================================================================ +// Function : QAD_ListViewItem::tipText +// Purpose : returns text for tooltip +//================================================================ +QString QAD_ListViewItem::tipText() +{ + QString aText = getName(); + if (!getValue().isEmpty()) + aText += QString(" : ") + getValue(); + return aText; +} + +//================================================================ +// Function : QAD_ListViewItem::textRect +// Purpose : calculates rect of item text in viewport coordinates +//================================================================ +QRect QAD_ListViewItem::textRect(const int column) const +{ + QRect aItemRect = listView()->itemRect( this ); + if ( !aItemRect.isValid() ) + return aItemRect; + + QFont aFont(listView()->font()); + QFontMetrics fm(aFont); + + int decorWidth = ( listView()->rootIsDecorated() ) ? + ( listView()->treeStepSize() * (depth() + 1) ) : + ( listView()->treeStepSize() * depth() ); + int pixmapWidth = ( pixmap(column) ) ? + pixmap(column)->width() + listView()->itemMargin() * 2 : + listView()->itemMargin(); + int prevWidth = 0; + for (int i = 0; i < column; i++) + prevWidth += listView()->header()->sectionSize(i); + int ix = prevWidth + + pixmapWidth + + ((column == 0) ? decorWidth : 0); + int iy = aItemRect.y(); + int iw = fm.width(text(column)); + int ih = aItemRect.height(); + if (pixmap(column)) { + iy += listView()->itemMargin(); + ih -= listView()->itemMargin() * 2; + } + ix -= listView()->contentsX(); + + QRect theResult(QPoint(ix, iy), QSize(iw, ih)); + return theResult; +} + +//================================================================ +// Function : QAD_ListViewItem::itemRect +// Purpose : calculates rect of item data in viewport coordinates +//================================================================ +QRect QAD_ListViewItem::itemRect(const int column) const +{ + QRect aItemRect = listView()->itemRect( this ); + if ( !aItemRect.isValid() ) + return aItemRect; + + QFont aFont(listView()->font()); + QFontMetrics fm(aFont); + + int decorWidth = ( listView()->rootIsDecorated() ) ? + ( listView()->treeStepSize() * (depth() + 1) ) : + ( listView()->treeStepSize() * depth() ); + int pixmapWidth = ( pixmap(column) ) ? + pixmap(column)->width() + listView()->itemMargin() * 2 : + 0; + int prevWidth = 0; + for (int i = 0; i < column; i++) + prevWidth += listView()->header()->sectionSize(i); + int ix = prevWidth; + int iy = aItemRect.y(); + int iw = pixmapWidth + + listView()->itemMargin() * 2 + + ((column == 0) ? decorWidth : 0) + + fm.width(text(column)); + int ih = aItemRect.height(); + ix -= listView()->contentsX(); + + QRect theResult(QPoint(ix, iy), QSize(iw, ih)); + return theResult; +} + +////////////////////////////////////////////////////////////////////// +// QAD_EditBox class implementation +////////////////////////////////////////////////////////////////////// + +//================================================================ +// Function : QAD_EditBox::QAD_EditBox +// Purpose : constructor +//================================================================ +QAD_EditBox::QAD_EditBox(QWidget* parent) : +QLineEdit(parent) +{ +} + +//================================================================ +// Function : QAD_EditBox::keyPressEvent +// Purpose : event filter for key pressing +//================================================================ +void QAD_EditBox::keyPressEvent( QKeyEvent *e ) +{ + if ( e->key() == Key_Escape ) + emit escapePressed(); + else + QLineEdit::keyPressEvent( e ); + e->accept(); +} + +////////////////////////////////////////////////////////////////////// +// QAD_ComboBox class implementation +////////////////////////////////////////////////////////////////////// + +//================================================================ +// Function : QAD_ComboBox::QAD_ComboBox +// Purpose : constructor +//================================================================ +QAD_ComboBox::QAD_ComboBox(bool rw, QWidget* parent, const char* name) : +QComboBox(rw, parent, name) +{ +} + +//================================================================ +// Function : QAD_ComboBox::findItem +// Purpose : searches item in list and returns its index +//================================================================ +int QAD_ComboBox::findItem(const QString theText) +{ + for (int i = 0; i < count(); i++) + if (text(i) == theText) + return i; + return -1; +} + +//================================================================ +// Function : QAD_ComboBox::insertItem +// Purpose : adds item in combo box +//================================================================ +void QAD_ComboBox::insertItem(const QString& theValue, + int theIndex) +{ + if (duplicatesEnabled() || findItem(theValue) < 0) + QComboBox::insertItem(theValue, theIndex); +} + +//================================================================ +// Function : QAD_ComboBox::insertList +// Purpose : adds list of items in combo box +//================================================================ +void QAD_ComboBox::insertList(const QStringList& theList) +{ + for (unsigned i = 0; i < theList.count(); i++) + insertItem(theList[i]); +} + +//================================================================ +// Function : QAD_ComboBox::insertItem +// Purpose : adds item in combo box +//================================================================ +void QAD_ComboBox::insertItem(const int theValue) +{ + int aNum; + bool bOk; + for (int i = 0; i < count(); i++) { + aNum = text(i).toInt(&bOk); + if (bOk) { + if (aNum > theValue || (aNum == theValue && duplicatesEnabled())) { + insertItem(QString::number(theValue), i); + return; + } + } + } + insertItem(QString::number(theValue)); +} + +//================================================================ +// Function : QAD_ComboBox::insertList +// Purpose : adds list of items in combo box +//================================================================ +void QAD_ComboBox::insertList(const TColStd_ListOfInteger& theList) +{ + for (TColStd_ListIteratorOfListOfInteger aIter(theList); aIter.More(); aIter.Next()) + insertItem(aIter.Value()); +} + +//================================================================ +// Function : QAD_ComboBox::insertItem +// Purpose : adds item in combo box +//================================================================ +void QAD_ComboBox::insertItem(const double theValue) +{ + double aNum; + bool bOk; + for (int i = 0; i < count(); i++) { + aNum = text(i).toDouble(&bOk); + if (bOk) { + if (aNum > theValue || (aNum == theValue && duplicatesEnabled())) { + insertItem(QString::number(theValue), i); + return; + } + } + } + insertItem(QString::number(theValue)); +} + +//================================================================ +// Function : QAD_ComboBox::insertList +// Purpose : adds list of items in combo box +//================================================================ +void QAD_ComboBox::insertList(const TColStd_ListOfReal& theList) +{ + for (TColStd_ListIteratorOfListOfReal aIter(theList); aIter.More(); aIter.Next()) + insertItem(aIter.Value()); +} + +////////////////////////////////////////////////////////////////////// +// QAD_EntityEdit class implementation +////////////////////////////////////////////////////////////////////// + +#include + +#define MIN_COMBO_WIDTH 1 +#define MIN_EDIT_WIDTH 1 + +//================================================================ +// Function : QAD_EntityEdit::QAD_EntityEdit +// Purpose : constructor +//================================================================ +QAD_EntityEdit::QAD_EntityEdit(QWidget* parent, + int controlType, + int valueType, + bool butApply, + bool butCancel) : +QWidget(parent), +myEdit(0), +myCombo(0), +myApplyBtn(0), +myCancelBtn(0) +{ + QHBoxLayout* aTopLayout = new QHBoxLayout(this); + aTopLayout->setAlignment( Qt::AlignTop ); + aTopLayout->setSpacing( 0 ); + aTopLayout->setMargin( 1 ); + if (controlType != etLineEdit && + controlType != etComboBox && + controlType != etComboEdit) + controlType = etLineEdit; + if (controlType == etComboBox || controlType == etComboEdit) { + // this is an editable combo box + myCombo = new QAD_ComboBox(controlType == etComboEdit, this); + myCombo->setMinimumSize(MIN_COMBO_WIDTH, 0); + myCombo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, + QSizePolicy::Fixed)); + // no insertions + myCombo->setInsertionPolicy(QComboBox::NoInsertion); + // no duplicates enabled by default + myCombo->setDuplicatesEnabled(false); + aTopLayout->addWidget(myCombo); + // connect signals + connect(myCombo, SIGNAL(activated(const QString&)), this, SLOT(onComboActivated(const QString&))); + connect(myCombo, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); + } + else { + // and this is an edit box + myEdit = new QAD_EditBox(this); + myEdit->setMinimumSize(MIN_EDIT_WIDTH, 0); + myEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, + QSizePolicy::Fixed)); + aTopLayout->addWidget(myEdit); + connect(myEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged(const QString&))); + connect(myEdit, SIGNAL(returnPressed()), this, SLOT(onApply())); + connect(myEdit, SIGNAL(escapePressed()), this, SLOT(onCancel())); + } + if (valueType != vtString && + valueType != vtInteger && + valueType != vtDouble) + valueType = vtString; + if (valueType == vtInteger) + setValidator(new QIntValidator(this)); + else if (valueType == vtDouble) + setValidator(new QDoubleValidator(this)); + if (butApply) { + // Apply button (V) + myApplyBtn = new QToolButton(this); + QPixmap anIcon = QAD_Desktop::getResourceManager()->loadPixmap( + "QAD",tr("ICON_APPLY_BTN")); + myApplyBtn->setPixmap(anIcon); + myApplyBtn->setEnabled(false); + myApplyBtn->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + myApplyBtn->setMinimumSize(16, 16); + myApplyBtn->setMaximumSize(16, 20); + aTopLayout->addWidget(myApplyBtn); + connect(myApplyBtn, SIGNAL(clicked()), this, SLOT(onApply())); + } + if (butCancel) { + // Cancel button (X) + myCancelBtn = new QToolButton(this); + QPixmap anIcon = QAD_Desktop::getResourceManager()->loadPixmap( + "QAD",tr("ICON_CANCEL_BTN")); + myCancelBtn->setPixmap(anIcon); + myCancelBtn->setEnabled(false); + myCancelBtn->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + myCancelBtn->setMinimumSize(16, 16); + myCancelBtn->setMaximumSize(16, 20); + aTopLayout->addWidget(myCancelBtn); + connect(myCancelBtn, SIGNAL(clicked()), this, SLOT(onCancel())); + } +} + +//================================================================ +// Function : QAD_EntityEdit::~QAD_EntityEdit +// Purpose : destructor +//================================================================ +QAD_EntityEdit::~QAD_EntityEdit() +{ +} + +//================================================================ +// Function : QAD_EntityEdit::clear +// Purpose : clears edit/combo box +//================================================================ +void QAD_EntityEdit::clear() +{ + if (myEdit) + myEdit->clear(); + if (myCombo) + myCombo->clear(); +} + +//================================================================ +// Function : QAD_EntityEdit::getText +// Purpose : returns current text in edit box or combo box +//================================================================ +QString QAD_EntityEdit::getText() +{ + if (myEdit) + return myEdit->text(); + else if (myCombo) + return myCombo->currentText(); + else + return ""; +} + +//================================================================ +// Function : QAD_EntityEdit::setText +// Purpose : sets text +//================================================================ +void QAD_EntityEdit::setText(const QString& theText) +{ + myString = theText; + if (myEdit) + myEdit->setText(theText); + if (myCombo) { + int aFound = myCombo->findItem(theText); + if (aFound >= 0) { + myCombo->setCurrentItem(aFound); + onTextChanged(theText); + } + } +} + +//================================================================ +// Function : QAD_EntityEdit::insertItem +// Purpose : adds item in combo box, +// sets it current if theSetCurrent is true +//================================================================ +void QAD_EntityEdit::insertItem(const QString& theValue, + bool theSetCurrent, + int theOrder) +{ + if (myCombo) { + int aIndexAt = -1; + if (theOrder == atTop) + aIndexAt = 0; + else if (theOrder == atBeforeCurrent && myCombo->count() > 0) + aIndexAt = myCombo->currentItem(); + else if (theOrder == atAfterCurrent && + myCombo->count() > 0 && + myCombo->currentItem() < myCombo->count()-1) + aIndexAt = myCombo->currentItem() + 1; + myCombo->insertItem(theValue, aIndexAt); + } + if (theSetCurrent) + setText(theValue); +} + +//================================================================ +// Function : QAD_EntityEdit::insertList +// Purpose : adds items in combo box, +// sets item theCurrent as current +//================================================================ +void QAD_EntityEdit::insertList(const QStringList& theList, + const int theCurrent) +{ + if (myCombo) + myCombo->insertList(theList); + if (theCurrent >= 0 && theCurrent < (int)theList.count()) + setText(theList[theCurrent]); +} + +//================================================================ +// Function : QAD_EntityEdit::insertItem +// Purpose : adds item in combo box, +// sets it current if theSetCurrent is true +//================================================================ +void QAD_EntityEdit::insertItem(const int theValue, + bool theSetCurrent) +{ + if (myCombo) { + myCombo->insertItem(theValue); + } + if (theSetCurrent) + setText(QString::number(theValue)); +} + +//================================================================ +// Function : QAD_EntityEdit::insertList +// Purpose : adds items in combo box, +// sets item theCurrent as current +//================================================================ +void QAD_EntityEdit::insertList(const TColStd_ListOfInteger& theList, + const int theCurrent) +{ + if (myCombo) + myCombo->insertList(theList); + + TColStd_ListIteratorOfListOfInteger aIter(theList); + for (unsigned i = 0; aIter.More(); aIter.Next(), i++) { + if (theCurrent == i) { + setText(QString::number(aIter.Value())); + break; + } + } +} + +//================================================================ +// Function : QAD_EntityEdit::insertItem +// Purpose : adds item in combo box, +// sets it current if theSetCurrent is true +//================================================================ +void QAD_EntityEdit::insertItem(const double theValue, + bool theSetCurrent) +{ + if (myCombo) { + myCombo->insertItem(theValue); + } + if (theSetCurrent) + setText(QString::number(theValue)); +} + +//================================================================ +// Function : QAD_EntityEdit::insertList +// Purpose : adds items in combo box, +// sets item theCurrent as current +//================================================================ +void QAD_EntityEdit::insertList(const TColStd_ListOfReal& theList, + const int theCurrent) +{ + if (myCombo) + myCombo->insertList(theList); + + TColStd_ListIteratorOfListOfReal aIter(theList); + for (unsigned i = 0; aIter.More(); aIter.Next(), i++) { + if (theCurrent == i) { + setText(QString::number(aIter.Value())); + break; + } + } +} + +//================================================================ +// Function : QAD_EntityEdit::getControl +// Purpose : gets actual widget +//================================================================ +QWidget* QAD_EntityEdit::getControl() +{ + if (myEdit) + return myEdit; + else if (myCombo) + return myCombo; + else + return 0; +} + +//================================================================ +// Function : QAD_EntityEdit::setFocus +// Purpose : redirect focus to corresponding widget +//================================================================ +void QAD_EntityEdit::setFocus() +{ + if (myEdit) { + myEdit->setFocus(); + //myEdit->selectAll(); + } + else if (myCombo && myCombo->editable()) { + myCombo->setFocus(); + //myCombo->lineEdit()->selectAll(); + } +} + +//================================================================ +// Function : QAD_EntityEdit::setValidator +// Purpose : sets validator for the control +//================================================================ +void QAD_EntityEdit::setValidator(const QValidator* theValidator) +{ + if (myEdit) + myEdit->setValidator(theValidator); + if (myCombo) + myCombo->setValidator(theValidator); +} + +//================================================================ +// Function : QAD_EntityEdit::keyPressEvent +// Purpose : event filter for KeyPress event +//================================================================ +void QAD_EntityEdit::keyPressEvent( QKeyEvent * e) +{ + if ( (e->key() == Key_Enter || + e->key() == Key_Return ) ) + onApply(); + else if (e->key() == Key_Escape) + onCancel(); +} + +//================================================================ +// Function : QAD_EntityEdit::onComboActivated +// Purpose : called when item activated in combo box +//================================================================ +void QAD_EntityEdit::onComboActivated(const QString& theText) +{ + onTextChanged(theText); +} + +//================================================================ +// Function : QAD_EntityEdit::onTextChanged +// Purpose : slot, called when text changed in line edit +//================================================================ +void QAD_EntityEdit::onTextChanged(const QString& theText) +{ + if (myApplyBtn) + myApplyBtn->setEnabled(!(theText == myString)); + if (myCancelBtn) + myCancelBtn->setEnabled(!(theText == myString)); +} + +//================================================================ +// Function : QAD_EntityEdit::onCancel +// Purpose : slot, called when user presses Cancel button +//================================================================ +void QAD_EntityEdit::onCancel() +{ + setText(myString); + if (myApplyBtn) + myApplyBtn->setEnabled(false); + if (myCancelBtn) + myCancelBtn->setEnabled(false); + emit escapePressed(); +} + +//================================================================ +// Function : QAD_EntityEdit::onApply +// Purpose : slot, called when user presses Apply button +//================================================================ +void QAD_EntityEdit::onApply() +{ + myString = getText(); + if (myApplyBtn) + myApplyBtn->setEnabled(false); + if (myCancelBtn) + myCancelBtn->setEnabled(false); + emit returnPressed(); +} + +//================================================================ +// Function : QAD_EntityEdit::showButtons +// Purpose : shows/hides buttons +//================================================================ +void QAD_EntityEdit::showButtons(bool show) +{ + if (myApplyBtn) + show ? myApplyBtn->show() : myApplyBtn->hide(); + if (myCancelBtn) + show ? myCancelBtn->show() : myCancelBtn->hide(); +} + +//================================================================ +// Function : QAD_EntityEdit::setDuplicatesEnabled +// Purpose : enables/disables data duplication (for combo box) +//================================================================ +void QAD_EntityEdit::setDuplicatesEnabled(bool enabled) +{ + if (myCombo) + myCombo->setDuplicatesEnabled(enabled); +} diff --git a/src/SALOMEGUI/QAD_ListView.h b/src/SALOMEGUI/QAD_ListView.h new file mode 100644 index 000000000..95b9c1b63 --- /dev/null +++ b/src/SALOMEGUI/QAD_ListView.h @@ -0,0 +1,415 @@ +// File : QAD_ListView.h +// Created : 24/10/2002 +// Descr : List view for editing of properties + +// Author : Vadim SANDLER +// Project : SALOME Pro +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#if !defined(_QAD_ListView_HeaderFile) +#define _QAD_ListView_HeaderFile + +#include +#include +#include +#include +#include +#include + +//VRV: porting on Qt 3.0.5 +#if QT_VERSION >= 0x030005 +#include +#endif +//VRV: porting on Qt 3.0.5 + +#include "QAD_Popup.h" + +#include +#include + +// enumeration for ListView updating mode +enum UpdateType { + utCancel = -1, // cancel updating + utNone = 0, // needs no any update + utUpdateItem, // update one item + utUpdateParent, // update parent item too + utUpdateViewer, // update all viewer + utUpdateAll // strong update +}; + +class QAD_ListViewItem; +class QAD_EntityEdit; + +//================================================================ +// Class : QAD_ListView +// Description : parent class for Data Viewer and Properties Viewer +//================================================================ +class QAD_ListView : public QListView , public QAD_PopupServer { + + Q_OBJECT + +public: +// constructor + QAD_ListView(QWidget *parent); +// destructor + virtual ~QAD_ListView(); + +// updates list viewer + virtual void updateViewer(); +// updtes currently selected item(s) + virtual void updateSelected(); + +// fills popup with items + void onCreatePopup(); +// delete popup + void deletePopupMenu(); + +// setting editing of items availbale/not available + void enableEditing(bool theFlag); +// says if editing is enabled + bool isEnableEditing(); +// accepts user input by calling finishEditing(true) + void accept(); + +// clears view + void clear(); + +// event filter + bool eventFilter(QObject* object, QEvent* event) ; + +// gets current tooltip for list view +// returns valid rect in success + QRect tip(QPoint aPos, QString& aText, QRect& dspRect, QFont& dspFnt) const; + +protected: +// handler for mouse button release event (execute popup menu) + void contentsMouseReleaseEvent(QMouseEvent* e); +// handler for resize event + void resizeEvent(QResizeEvent* e); +// handler for paint event + void viewportPaintEvent(QPaintEvent* e); +// finishes editing of entity + virtual UpdateType finishEditing(bool ok); + +// returns true if mouse events are enabled + bool isMouseEnabled(); +// enables/disables mouse events (excluding MouseMove) + void enableMouse(bool enable); + +protected slots: +// called when selection changed in list + virtual void onSelectionChanged(); +// called when user finishes in editing of item + void onEditOk(); +// called when user cancels item editing + void onEditCancel(); +// called when columns sizes are changed + void onHeaderSizeChange(int, int, int); + +protected: + QAD_EntityEdit* myEdit; + QAD_ListViewItem* myEditedItem; + bool myEditingEnabled; + bool myMouseEnabled; +}; + + +//================================================================ +// Class : QAD_ListViewItem +// Purpose : List Viewer entity +//================================================================ +class QAD_ListViewItem : public QListViewItem { + +public: +// constructor + QAD_ListViewItem(QAD_ListView* parent); +// constructor + QAD_ListViewItem(QAD_ListView* parent, + QAD_ListViewItem* after); +// constructor + QAD_ListViewItem(QAD_ListView* parent, + const QString theName, + const bool theEditable = false); +// constructor + QAD_ListViewItem(QAD_ListView* parent, + const QString theName, + const QString theValue, + const bool theEditable = false); +// constructor + QAD_ListViewItem(QAD_ListViewItem* parent, + const QString theName, + const bool theEditable = false); +// constructor + QAD_ListViewItem(QAD_ListView* parent, + QAD_ListViewItem* after, + const QString theName, + const bool theEditable = false); +// constructor + QAD_ListViewItem(QAD_ListViewItem* parent, + QAD_ListViewItem* after, + const QString theName, + const bool theEditable = false); +// constructor + QAD_ListViewItem(QAD_ListViewItem* parent, + const QString theName, + const QString theValue, + const bool theEditable = false); +// constructor + QAD_ListViewItem(QAD_ListView* parent, + QAD_ListViewItem* after, + const QString theName, + const QString theValue, + const bool theEditable = false); +// constructor + QAD_ListViewItem(QAD_ListViewItem* parent, + QAD_ListViewItem* after, + const QString theName, + const QString theValue, + const bool theEditable = false); +// destructor + ~QAD_ListViewItem(); + +// returns full path to the entity (full name) + QString fullName(); + +// expands all entities beginning from this level + void openAllLevels(); +// updates all entites beginning from this level + virtual void updateAllLevels(); + +// returns true if entity can be edited + bool isEditable() const; +// set entity as editable/uneditable + void setEditable(bool theEditable); + +// returns true if entitiy is accepted after editing + bool isAccepted() const; +// set entity accepted or not after editing + void setAccepted(bool theAccepted); + +// returns name of entity (as default it is text in first column) + virtual QString getName() const; +// sets name of entity (as default it is text in first column) + virtual UpdateType setName(const QString theName); + +// returns value of entity (as default it is text in second column) + virtual QString getValue() const; +// sets value of entity (as default it is text in second column) + virtual UpdateType setValue(const QString theValue); + +// creates control for editing and fills it with values + QAD_EntityEdit* startEditing(); +// fills widget with initial values (list or single value) + virtual void fillWidgetWithValues(QAD_EntityEdit* theWidget); +// finishes editing of entity + virtual UpdateType finishEditing(QAD_EntityEdit* theWidget); + +// returns type of edit control (0 - edit box, 1 - combo box, 2 - editable combo box) + virtual int getEditingType(); +// sets type of edit control (0 - edit box, 1 - combo box, 2 - editable combo box) + virtual void setEditingType(const int); +// returns edited column + virtual int getEditedColumn(); +// returns type of edited value (string, int, double) + virtual int getValueType(); +// sets type of edited value (string, int, double) + virtual void setValueType(const int); + +// gets user type + virtual int getUserType(); +// sets user type + virtual void setUserType(const int); + +// returns buttons for editing widget + virtual int getButtons(); +// sets buttons for editing widget + virtual void setButtons(const int); +// returns text for tooltip + QString tipText(); +// calculates rectangle which should contain items tip + QRect tipRect(); +// calculates rect of item text in viewport coordinates + QRect textRect(const int column) const; +// calculates full rect of item data in viewport coordinates + QRect itemRect(const int column) const; + +protected: +// initialization + void init(); + +private: + bool myEditable; + bool myAccepted; + int myEditingType; + int myValueType; + int myButtons; + int myUserType; // user are welcome to put additional data here and use it in fillWidgetWithValues() +}; + + +//================================================================ +// Class : QAD_EditBox +// Description : edit box for list entity editing +//================================================================ +class QAD_EditBox: public QLineEdit { + + Q_OBJECT + +public: +// constructor + QAD_EditBox(QWidget* parent); + +protected: +// event filter (for KeyPress event) + void keyPressEvent(QKeyEvent* e); + +signals: + void escapePressed(); + +}; + + +//================================================================ +// Class : QAD_ComboBox +// Description : combo box for list entity editing +//================================================================ +class QAD_ComboBox: public QComboBox { + + Q_OBJECT + +public: +// constructor + QAD_ComboBox(bool rw, QWidget* parent = 0, const char* name = 0); + +// searches item in list and returns its index + int findItem(const QString theText); +// adds item in combo box + void insertItem(const QString& theValue, int theIndex = -1); +// adds list of items in combo box + void insertList(const QStringList& theList); +// adds item in combo box + void insertItem(const int theValue); +// adds list of items in combo box + void insertList(const TColStd_ListOfInteger& theList); +// adds item in combo box + void insertItem(const double theValue); +// adds list of items in combo box + void insertList(const TColStd_ListOfReal& theList); + +}; + + +//================================================================ +// Class : QAD_EntityEdit +// Description : edit control for QAD List View +//================================================================ +class QAD_EntityEdit : public QWidget { + + Q_OBJECT + +public: +// enum for edit control type + enum { + etLineEdit, // simple edit box + etComboBox, // non-editable combo box + etComboEdit // editable combo box + }; +// enum for value type + enum { + vtString, // string + vtInteger, // integer value + vtDouble // double value + }; +// enum for insertion order + enum { + atBottom, + atTop, + atBeforeCurrent, + atAfterCurrent + }; +// enum for edit box buttons (Apply = Cancel) + enum { + btApply = 0x0001, + btCancel = 0x0002 + }; + +// constructor + QAD_EntityEdit(QWidget* parent, + int controlType = etLineEdit, + int valueType = vtString, + bool butApply = false, + bool butCancel = false); +// destructor + ~QAD_EntityEdit(); + +// finishes editing + void finishEditing(); +// clears edit/combo box + void clear(); +// returns current text in edit box or combo box + QString getText(); +// sets text + void setText(const QString& theText); +// adds item in combo box + void insertItem(const QString& theValue, + bool theSetCurrent = false, + int theOrder = atBottom); +// adds list of items in combo box + void insertList(const QStringList& theList, + const int theCurrent = -1); +// adds item in combo box + void insertItem(const int theValue, + bool theSetCurrent = false); +// adds list of items in combo box + void insertList(const TColStd_ListOfInteger& theList, + const int theCurrent = -1); +// adds item in combo box + void insertItem(const double theValue, + bool theSetCurrent = false); +// adds list of items in combo box + void insertList(const TColStd_ListOfReal& theList, + const int theCurrent = -1); +// gets actual widget + QWidget* getControl(); +// redirect focus to corresponding widget + void setFocus(); +// sets validator for the control + void setValidator(const QValidator*); +// shows/hides buttons + void showButtons(bool show); +// enables/disables data duplication (for combo box) + void setDuplicatesEnabled(bool enabled); + +protected: +// event filter for KeyPress event + void keyPressEvent ( QKeyEvent * e); + +private slots: +// called when item activated in combo box + void onComboActivated(const QString&); +// called when text changed in control + void onTextChanged(const QString&); +// called when user presses Apply button + void onApply(); +// called when user presses Cancel button + void onCancel(); + +signals: + void returnPressed(); + void escapePressed(); + +private: +// Widgets + QAD_EditBox* myEdit; + QAD_ComboBox* myCombo; + QToolButton* myApplyBtn; + QToolButton* myCancelBtn; + + QString myString; + +}; + + +#endif diff --git a/src/SALOMEGUI/QAD_Menus.cxx b/src/SALOMEGUI/QAD_Menus.cxx new file mode 100644 index 000000000..ad7dacb30 --- /dev/null +++ b/src/SALOMEGUI/QAD_Menus.cxx @@ -0,0 +1,151 @@ +using namespace std; +// File : QAD_Menus.cxx +// Created : Thu Jun 14 13:56:16 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + + +#include "QAD_Menus.h" + +/*! + Constructor. +*/ +QAD_Menus::QAD_Menus(QMainWindow* theParent) +{ + myMainWindow=theParent; + myToolBarList.setAutoDelete(TRUE); +} + +/*! + Desctructor. +*/ +QAD_Menus::~QAD_Menus() +{ + myToolBarList.clear(); + myPopupMenuList.clear(); + myMenuBarList.clear(); + myMenuList.clear(); +} + +/*! + Appends a MenuBar +*/ +void QAD_Menus::append(QMenuBar* theMenuBar) +{ + myMenuBarList.append(theMenuBar); +} + +/*! + Appends a ToolBar +*/ +void QAD_Menus::append(QToolBar* theToolBar) +{ + myToolBarList.append(theToolBar); +} + +/*! + Appends a PopupMenu +*/ +void QAD_Menus::append(QAD_ListPopupMenu* thePopupMenu) +{ + myPopupMenuList.append(thePopupMenu); +} + +/*! + Appends a MenuId +*/ +void QAD_Menus::append(QAD_ListMenuIdAction* theMenu) +{ + myMenuList.append(theMenu); +} + +/*! + Shows a ToolBar +*/ +void QAD_Menus::showToolBar(QToolBar* theToolBar) +{ + if(theToolBar!=NULL && theToolBar->isHidden()) { + theToolBar->show(); + } +} + +/*! + Shows all ToolBars +*/ +void QAD_Menus::showAllToolBars() +{ + QToolBar* aToolBar; + + for(aToolBar=myToolBarList.first();aToolBar!=NULL;aToolBar=myToolBarList.next()) { + if(aToolBar->isHidden()) { + aToolBar->show(); + } + } +} + +/*! + Hides a ToolBar +*/ +void QAD_Menus::hideToolBar(QToolBar* theToolBar) +{ + if(theToolBar!=NULL && theToolBar->isVisible()) { + theToolBar->hide(); + } +} + +/*! + Hides all ToolBars +*/ +void QAD_Menus::hideAllToolBars() +{ + QToolBar* aToolBar; + + for(aToolBar=myToolBarList.first();aToolBar!=NULL;aToolBar=myToolBarList.next()) { + if(aToolBar->isVisible()) { + aToolBar->hide(); + } + } +} + +/*! + Sets current MenuBar +*/ +void QAD_Menus::setActiveMenuBar(QMenuBar* theMenuBar) +{ + myActiveMenuBar=theMenuBar; +} + +/*! + Sets current setActivePopupMenu with index \a thePopupMenuIndex +*/ +void QAD_Menus::setActivePopupMenu(int thePopupMenuIndex) +{ + myActivePopupMenu=myPopupMenuList.at(thePopupMenuIndex)->getPopup(); +} + +/*! + Sets current PopupMenu +*/ +void QAD_Menus::setActivePopupMenu(QPopupMenu* thePopupMenu) +{ + myActivePopupMenu=thePopupMenu; +} + +/*! + Sets current ToolBar with index \a theToolBarIndex +*/ +void QAD_Menus::setActiveToolBar(int theToolBarIndex) +{ + myActiveToolBar=myToolBarList.at(theToolBarIndex); +} + +/*! + Sets current ToolBar +*/ +void QAD_Menus::setActiveToolBar(QToolBar* theToolBar) +{ + myActiveToolBar=theToolBar; +} diff --git a/src/SALOMEGUI/QAD_Menus.h b/src/SALOMEGUI/QAD_Menus.h new file mode 100644 index 000000000..5d73d720f --- /dev/null +++ b/src/SALOMEGUI/QAD_Menus.h @@ -0,0 +1,67 @@ +// File : QAD_Menus.h +// Created : Thu Jun 14 13:57:00 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_MENUS_H +#define QAD_MENUS_H + +#include "QAD_ListMenuIdAction.h" +#include "QAD_ListPopupMenu.h" + +#include +#include +#include +#include + +class QAD_MainWindow; + +class QAD_Menus +{ + +public: + QAD_Menus(QMainWindow*); + virtual ~QAD_Menus(); + + QMenuBar* myActiveMenuBar; + QToolBar* myActiveToolBar; + QStatusBar* myActiveStatusBar; + QPopupMenu* myActivePopupMenu; + + QMainWindow* getMainWindow() {return myMainWindow;} + QList getMenuBarList() {return myMenuBarList;} + QList getToolBarList() {return myToolBarList;} + QPopupMenu* getActivePopupMenu() {return myActivePopupMenu;} + QList getMenuList() {return myMenuList;} + QList getPopupMenuList() {return myPopupMenuList;} + + void setActiveMenuBar(QMenuBar*); + void setActivePopupMenu(int); + void setActivePopupMenu(QPopupMenu*); + void setActiveToolBar(int); + void setActiveToolBar(QToolBar*); + + void append(QMenuBar*); + void append(QToolBar*); + void append(QAD_ListPopupMenu*); + void append(QAD_ListMenuIdAction*); + void clearToolBar() {myToolBarList.clear();} + void clearPopupMenu() {myPopupMenuList.clear();} + void showToolBar(QToolBar*); + void showAllToolBars(); + void hideToolBar(QToolBar*); + void hideAllToolBars(); + +protected: + QMainWindow* myMainWindow; + QList myMenuBarList; + QList myToolBarList; + QList myMenuList; + QList myPopupMenuList; + +}; + +#endif diff --git a/src/SALOMEGUI/QAD_Message.cxx b/src/SALOMEGUI/QAD_Message.cxx new file mode 100644 index 000000000..b642fff14 --- /dev/null +++ b/src/SALOMEGUI/QAD_Message.cxx @@ -0,0 +1,125 @@ +using namespace std; +// File : QAD_Message.cxx +// Created : Thu Jun 14 15:55:14 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "QAD_Message.h" +#include "QAD_Application.h" +#include "QAD_Config.h" +#include "QAD_Tools.h" +#include +#include +#include +#include + +enum { IdCopy, IdClear, IdSelectAll }; + +/*! + \class QAD_Message QAD_Message.h + \brief Messages window for Study. +*/ + +/*! + Constructor - creates Message Log window +*/ +QAD_Message::QAD_Message(QWidget *parent, const char* name) + : QMultiLineEdit(parent, name) +{ + // setting default title + myTitle = tr("MESSAGE_LOG_NAME"); + // setting default prompt + myPrompt = ">>> "; + // setting font ( from preferences ) + QString fntSet = QAD_CONFIG->getSetting("Viewer:ConsoleFont"); + QFont myFont = QAD_Tools::stringToFont( fntSet ); +// QFont myFont("Courier", 11); + setFont(myFont); + setReadOnly(TRUE); + // appending title + setMessage(myTitle); + // setting palette (special) + setPalette( QAD_Application::getPalette(true) ); + setFocusPolicy( NoFocus ); + // currently no text wrap + setWordWrap(NoWrap); +} + +/*! + Destructor +*/ +QAD_Message::~QAD_Message() +{ +} + +/*! + Adds message +*/ +void QAD_Message::setMessage(const QString& s) +{ + int line = numLines() > 0 ? numLines()-1 : 0; + int col = lineLength(line); + if (!s.isNull() && s.length() > 0) { + QString ss = s; + insertAt(ss, line, col, false); + } + append(myPrompt); +} + +/* + Processes own popup manu +*/ +void QAD_Message::mousePressEvent(QMouseEvent* event) +{ + if ( event->button() == RightButton ) { + QPopupMenu *popup = new QPopupMenu( this ); + QMap idMap; + + int line1, col1, line2, col2; + getMarkedRegion(&line1, &col1, &line2, &col2); + bool allSelected = getMarkedRegion(&line1, &col1, &line2, &col2) && + line1 == 0 && line2 == numLines()-1 && col1 == 0 && col2 == lineLength(line2); + int id; + id = popup->insertItem( tr( "EDIT_COPY_CMD" ) ); + idMap.insert(IdCopy, id); + id = popup->insertItem( tr( "EDIT_CLEAR_CMD" ) ); + idMap.insert(IdClear, id); + popup->insertSeparator(); + id = popup->insertItem( tr( "EDIT_SELECTALL_CMD" ) ); + idMap.insert(IdSelectAll, id); + popup->setItemEnabled( idMap[ IdCopy ], hasMarkedText() ); + popup->setItemEnabled( idMap[ IdSelectAll ], + (bool)text().length() && !allSelected ); + + int r = popup->exec( event->globalPos() ); + delete popup; + + if ( r == idMap[ IdCopy ] ) { + copy(); + } + else if ( r == idMap [ IdClear ] ) { + clear(); + setMessage(myTitle); + } + else if ( r == idMap[ IdSelectAll ] ) { + selectAll(); + } + return; + } + else { + QMultiLineEdit::mousePressEvent(event); + } +} + +/* + Sets prompt ( default is '>>> ' ) +*/ +void QAD_Message::setPrompt(const QString& prompt) +{ + myPrompt = prompt; + clear(); + setMessage(myTitle); +} diff --git a/src/SALOMEGUI/QAD_Message.h b/src/SALOMEGUI/QAD_Message.h new file mode 100644 index 000000000..f7180190a --- /dev/null +++ b/src/SALOMEGUI/QAD_Message.h @@ -0,0 +1,39 @@ +// File : QAD_Message.h +// Created : Thu Jun 14 15:54:52 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_Message_H +#define QAD_Message_H + +#include "QAD.h" +#include + +class QAD_EXPORT QAD_Message : public QMultiLineEdit +{ +public: +// constructor + QAD_Message(QWidget *parent = 0, const char* name = 0 ); +// destructor + ~QAD_Message(); + +// adds message + void setMessage(const QString& s); +// sets prompt + void setPrompt(const QString& prompt); + +protected: +// MousePress event handler + void mousePressEvent(QMouseEvent* event); + +private: +// Title + QString myTitle; +// Prompt + QString myPrompt; +}; + +#endif diff --git a/src/SALOMEGUI/QAD_MessageBox.cxx b/src/SALOMEGUI/QAD_MessageBox.cxx new file mode 100644 index 000000000..dcf9445a4 --- /dev/null +++ b/src/SALOMEGUI/QAD_MessageBox.cxx @@ -0,0 +1,188 @@ +using namespace std; +// File : QAD_MessageBox.cxx +// Created : 02.10.00 +// Author : UI team +// Descr : Message dialog box for QAD-based application +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +/*! + \class QAD_MessageBox QAD_MessageBox.h + \brief Message dialog box for QAD-based application. +*/ + +#include "QAD_MessageBox.h" + +// QT Includes +#include +#include + +/*! + Shows info message box with one button [ static ] +*/ +int QAD_MessageBox::info1 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0 ) +{ + int ret = QMessageBox::information ( parent, caption, text, textButton0, + QString::null, QString::null, 0, 0); + qApp->processEvents(); /* update desktop */ + return ret; +} + +/*! + Shows warning message box with one button [ static ] +*/ +int QAD_MessageBox::warn1 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0 ) +{ + int ret = QMessageBox::warning ( parent, caption, text, textButton0, + QString::null, QString::null, 0, 0); + qApp->processEvents(); /* update desktop */ + return ret; +} + +/*! + Shows error message box with one button [ static ] +*/ +int QAD_MessageBox::error1 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0 ) +{ + int ret = QMessageBox::critical ( parent, caption, text, textButton0, + QString::null, QString::null, 0, 0); + qApp->processEvents(); /* update desktop */ + return ret; +} + +/*! + Shows info message box with two buttons. + Returns id of the pressed button or -1 if escaped [ static ] +*/ +int QAD_MessageBox::info2 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + int idButton0, int idButton1, int idDefault ) +{ + if ( idDefault == idButton0 ) idDefault = 0; + else if ( idDefault == idButton1 ) idDefault = 1; + else idDefault = 0; + + int ret = QMessageBox::information ( parent, caption, text, textButton0, + textButton1, QString::null, idDefault ); + qApp->processEvents(); /* update desktop */ + return ( ret == 0 ? idButton0 : idButton1 ); +} + +/*! + Shows warning message box with two buttons. + Returns id of the pressed button or -1 if escaped [ static ] +*/ +int QAD_MessageBox::warn2 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + int idButton0, int idButton1, int idDefault ) +{ + if ( idDefault == idButton0 ) idDefault = 0; + else if ( idDefault == idButton1 ) idDefault = 1; + else idDefault = 0; + + int ret = QMessageBox::warning ( parent, caption, text, textButton0, + textButton1, QString::null, idDefault ); + qApp->processEvents(); /* update desktop */ + return ( ret == 0 ? idButton0 : idButton1 ); +} + +/*! + Shows error message box with two buttons + Returns id of the pressed button or -1 if escaped [ static ] +*/ +int QAD_MessageBox::error2 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + int idButton0, int idButton1, int idDefault ) +{ + if ( idDefault == idButton0 ) idDefault = 0; + else if ( idDefault == idButton1 ) idDefault = 1; + else idDefault = 0; + + int ret = QMessageBox::critical ( parent, caption, text, textButton0, + textButton1, QString::null, idDefault ); + qApp->processEvents(); /* update desktop */ + return ( ret == 0 ? idButton0 : idButton1 ); +} + +/*! + Shows info message box with three buttons. + Returns id of the pressed button or -1 if escaped [ static ] +*/ +int QAD_MessageBox::info3 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + const QString& textButton2, int idButton0, int idButton1, + int idButton2, int idDefault ) +{ + if ( idDefault == idButton0 ) idDefault = 0; + else if ( idDefault == idButton1 ) idDefault = 1; + else if ( idDefault == idButton2 ) idDefault = 2; + else idDefault = 0; + + int ret = QMessageBox::information ( parent, caption, text, textButton0, + textButton1, textButton2, idDefault ); + qApp->processEvents(); /* update desktop */ + switch ( ret ) + { + case 0: return idButton0; + case 1: return idButton1; + case 2: return idButton2; + } + return -1; +} + +/*! + Shows warning message box with three buttons. + Returns id of the pressed button or -1 if escaped [ static ] +*/ +int QAD_MessageBox::warn3 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + const QString& textButton2, int idButton0, int idButton1, + int idButton2, int idDefault ) +{ + if ( idDefault == idButton0 ) idDefault = 0; + else if ( idDefault == idButton1 ) idDefault = 1; + else if ( idDefault == idButton2 ) idDefault = 2; + else idDefault = 0; + + int ret = QMessageBox::warning ( parent, caption, text, textButton0, + textButton1, textButton2, idDefault ); + qApp->processEvents(); /* update desktop */ + switch ( ret ) + { + case 0: return idButton0; + case 1: return idButton1; + case 2: return idButton2; + } + return -1; +} + +/*! + Shows error message box with three buttons. + Returns id of the pressed button or -1 if escaped [ static ] +*/ +int QAD_MessageBox::error3 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + const QString& textButton2, int idButton0, int idButton1, + int idButton2, int idDefault ) +{ + if ( idDefault == idButton0 ) idDefault = 0; + else if ( idDefault == idButton1 ) idDefault = 1; + else if ( idDefault == idButton2 ) idDefault = 2; + else idDefault = 0; + + int ret = QMessageBox::critical ( parent, caption, text, textButton0, + textButton1, textButton2, idDefault ); + qApp->processEvents(); /* update desktop */ + switch ( ret ) + { + case 0: return idButton0; + case 1: return idButton1; + case 2: return idButton2; + } + return -1; +} diff --git a/src/SALOMEGUI/QAD_MessageBox.h b/src/SALOMEGUI/QAD_MessageBox.h new file mode 100644 index 000000000..68148d07b --- /dev/null +++ b/src/SALOMEGUI/QAD_MessageBox.h @@ -0,0 +1,53 @@ +/******************************************************************** +** Class: QAD_MessageBox +** Descr: Message dialog box for QAD-based application +** Module: QAD +** Created: UI team, 02.10.00 +*********************************************************************/ +#ifndef QAD_MESSAGEBOX_H +#define QAD_MESSAGEBOX_H + +#include +#include + +#include "QAD.h" + +class QAD_EXPORT QAD_MessageBox +{ +public: + /* show a box with one button */ + static int info1 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0 ); + static int warn1 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0 ); + static int error1 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0 ); + + /* show a box with two buttons */ + static int info2 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + int idButton0, int idButton1, int idDefault ); + static int warn2 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + int idButton0, int idButton1, int idDefault ); + static int error2 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + int idButton0, int idButton1, int idDefault ); + + /* show a box with three buttons */ + static int info3 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + const QString& textButton2, int idButton0, int idButton1, + int idButton2, int idDefault ); + static int warn3 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + const QString& textButton2, int idButton0, int idButton1, + int idButton2, int idDefault ); + static int error3 ( QWidget* parent, const QString& caption, const QString& text, + const QString& textButton0, const QString& textButton1, + const QString& textButton2, int idButton0, int idButton1, + int idButton2, int idDefault ); +}; + +#endif + diff --git a/src/SALOMEGUI/QAD_NameBrowser.cxx b/src/SALOMEGUI/QAD_NameBrowser.cxx new file mode 100644 index 000000000..688a45078 --- /dev/null +++ b/src/SALOMEGUI/QAD_NameBrowser.cxx @@ -0,0 +1,426 @@ +using namespace std; +// File : QAD_NameBrowser.cxx +// Created : Mon Nov 26 10:15:24 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "QAD_NameBrowser.h" + +#include "QAD_Study.h" +#include "QAD_Desktop.h" +#include "QAD_Application.h" +#include "QAD_Selection.h" +#include "QAD_InteractiveObject.h" + +#include "utilities.h" + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*! + Constructs a QAD_NameBrowser which is a child of 'parent', with the + name 'name' +*/ +QAD_NameBrowser::QAD_NameBrowser( QWidget* parent, const char* name) + : QMainWindow( parent, name, WStyle_NormalBorder | + WStyle_MinMax | WStyle_SysMenu | WDestructiveClose ) +{ + if ( !name ) + setName( "QAD_NameBrowser" ); + + resize( 321, 280 ); + setCaption( name ); + + GroupBox1 = new QGroupBox( this, "GroupBox1" ); + GroupBox1->setGeometry( QRect( 10, 10, 300, 50 ) ); + GroupBox1->setTitle( tr( "Filters" ) ); + + ComboBox1 = new QComboBox( TRUE, GroupBox1 ); + ComboBox1->setGeometry( QRect( 10, 20, 120, 21 ) ); + ComboBox1->insertItem( tr( "Type" ) ); + + connect( ComboBox1, SIGNAL( textChanged(const QString &) ), this, SLOT( updateFilters() ) ); + + + PushButton5 = new QPushButton( tr( " = " ), GroupBox1); + PushButton5->setGeometry( QRect( 140, 20, 30, 21 ) ); + + ComboBox2 = new QComboBox( TRUE, GroupBox1); + ComboBox2->setGeometry( QRect( 180, 20, 111, 21 ) ); + ComboBox2->insertItem( tr( "All" ) ); + connect( ComboBox2, SIGNAL( textChanged(const QString &) ), this, SLOT( updateFilters() ) ); + + GroupBox2 = new QGroupBox( this, "GroupBox2" ); + GroupBox2->setGeometry( QRect( 10, 60, 300, 200 ) ); + GroupBox2->setTitle( tr( "Objects" ) ); + + PushButton1 = new QPushButton( tr( "All" ), GroupBox2 ); + PushButton1->setGeometry( QRect( 10, 170, 71, 21 ) ); + connect( PushButton1, SIGNAL( clicked() ), this, SLOT( selectAllFilteredObjects() ) ); + + ListView1 = new QListView( GroupBox2 ); + ListView1->setGeometry( QRect( 10, 20, 280, 140 ) ); + ListView1->addColumn(""); + ListView1->addColumn(""); + ListView1->addColumn(""); + ListView1->setColumnText( 0, tr( "Filtered" ) ); + ListView1->setColumnWidth(0, 130); + ListView1->setRootIsDecorated(TRUE); + ListView1->setMultiSelection (TRUE); + ListView1->setSelectionMode ( QListView::Extended ); + + connect (ListView1, + SIGNAL( selectionChanged() ), + this, SLOT(onFilteredObjects()) ); + + initFilters(); +} + +/*! + Returns reference to QListView +*/ +QListView* QAD_NameBrowser::getListView() const +{ + return ListView1; +} + +/*! + Destroys the object and frees any allocated resources +*/ +QAD_NameBrowser::~QAD_NameBrowser() +{ + // no need to delete child widgets, Qt does it all for us +} + +void QAD_NameBrowser::selectAllFilteredObjects() +{ + ListView1->selectAll( true ); +} + +void QAD_NameBrowser::updateFilters() +{ + initFilters(); +} + +void QAD_NameBrowser::initFilters() +{ + QAD_Desktop* myDesktop = QAD_Application::getDesktop(); + QAD_Study* myActiveStudy = myDesktop->getActiveStudy(); + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + + Update( aStudy ); + + +// QAD_Selection* Sel = QAD_Selection::Selection( myActiveStudy->getSelection() ); +// const QList& ListIO = Sel->getInteractiveObjects(); +// int NbSelected = ListIO.count(); +// if ( NbSelected == 0 ) { +// // setFilter "All" +// Update( aStudy ); + +// } else if ( NbSelected == 1 ) { +// // setFilter "type of selected object" +// QAD_InteractiveObject* IObject = Sel->getFisrtInteractiveObject(); +// SALOMEDS::SComponent_var SC = SALOMEDS::SComponent::_narrow ( myActiveStudy->FindObjectIOR( IObject->getFatherIOR() )); +// if ( !SC->_is_nil() ) { +// char* ObjectComp = ""; +// if ( SC->GetAttribute(SALOMEDS::Name, ObjectComp)) { +// Update( aStudy, SC ); +// } +// } + +// } else { +// // const QList& ListIO = Sel->getInteractiveObjects(); +// // QListIterator it( Sel->getInteractiveObjects() ); +// // for ( ; it.current(); ++it ) { +// // QAD_InteractiveObject* IObject = it.current(); +// // QString IOR = IObject->getFatherIOR() )); + +// // } + +// // heterogeneous selection -> setFilter "All" +// Update( aStudy ); + +// // homogeneous selection -> setFilter "type of selected objects" +// } +} + +void QAD_NameBrowser::onFilteredObjects() +{ + QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + QAD_Selection* Sel = QAD_Selection::Selection( myActiveStudy->getSelection() ); + QAD_StudyFrame* myActiveSFrame = myActiveStudy->getActiveStudyFrame(); + + QString ActiveComp = QAD_Application::getDesktop()->getActiveComponent(); + + MESSAGE ( "QAD_NAMEBROWSER - NB SELECTED INTERACTIVE OBJECT : " << Sel->getInteractiveObjectCount() ) + + QList DeltaPos; + DeltaPos.clear(); + QList DeltaNeg; + DeltaNeg.clear(); + + QListViewItemIterator it( ListView1 ); + for ( ; it.current(); ++it ) { + QListViewItem* item = it.current(); + QString theIOR = item->text(2); + QString theEntry = item->text(1); + + if ( ActiveComp.isEmpty() ) {/* Neutral point = no component loaded */ + if ( !theEntry.isEmpty() && theIOR.isEmpty() ) { /* A component may be selected */ + if ( item->isSelected() ) { + bool itemAlreadySelected = false; + + int nbSel = Sel->getInteractiveObjectCount(); + for ( int i = 0; i < nbSel; i++ ) { + QAD_InteractiveObject* SO = Sel->getInteractiveObject(i); + if ( SO->getIOR().compare(item->text(1)) == 0 ) { + itemAlreadySelected = true; + break; + } + } + if (!itemAlreadySelected) { + QAD_InteractiveObject* SO = new QAD_InteractiveObject( item->text(1), "" ); + DeltaPos.append( SO ); + } + } else { + int nbSel = Sel->getInteractiveObjectCount(); + for ( int i = 0; i < nbSel; i++ ) { + QAD_InteractiveObject* SO = Sel->getInteractiveObject(i); + if ( SO->getIOR().compare(item->text(1)) == 0 ) { + DeltaNeg.append( SO ); + break; + } + } + } + + } else { /* An object is selected */ + if ( item->isSelected() ) { + item->setSelected( false ); + item->repaint(); + } + } + + } else { + if ( !theIOR.isEmpty() ) { + if ( item->isSelected() ) { + bool itemAllreadySelected = false; + + int nbSel = Sel->getInteractiveObjectCount(); + for ( int i = 0; i < nbSel; i++ ) { + QAD_InteractiveObject* SO = Sel->getInteractiveObject(i); + if ( SO->getIOR().compare(theIOR) == 0 ) { + itemAllreadySelected = true; + break; + } + } + + if (!itemAllreadySelected) { + SALOMEDS::SObject_var obj = aStudy->FindObjectID(theEntry.latin1()); + SALOMEDS::SComponent_var theComponent = obj->GetFatherComponent(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + Standard_CString ior =" "; + Standard_CString iorFather =" "; + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + ior = anIOR->Value(); + } + theComponent->ComponentIOR(iorFather); + QAD_InteractiveObject* SO = new QAD_InteractiveObject( QString(ior), + QString(iorFather), + QString(theEntry) ); + DeltaPos.append( SO ); + } + } else { + int nbSel = Sel->getInteractiveObjectCount(); + for ( int i = 0; i < nbSel; i++ ) { + QAD_InteractiveObject* SO = Sel->getInteractiveObject(i); + if ( SO->getIOR().compare(theIOR) == 0 ) { + DeltaNeg.append( SO ); + break; + } + } + + } + } else if ( !theEntry.isEmpty() && theIOR.isEmpty() ) { + if ( item->isSelected() ) { + bool itemAllreadySelected = false; + + int nbSel = Sel->getInteractiveObjectCount(); + for ( int i = 0; i < nbSel; i++ ) { + QAD_InteractiveObject* SO = Sel->getInteractiveObject(i); + if ( SO->getEntry().compare(theEntry) == 0 ) { + itemAllreadySelected = true; + break; + } + } + if (!itemAllreadySelected) { + SALOMEDS::SObject_var obj = aStudy->FindObjectID(theEntry.latin1()); + SALOMEDS::SComponent_var theComponent = obj->GetFatherComponent(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + Standard_CString ior =" "; + Standard_CString iorFather =" "; + if (obj->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + ior = anIOR->Value(); + } + theComponent->ComponentIOR(iorFather); + QAD_InteractiveObject* SO = new QAD_InteractiveObject( QString(ior), + QString(iorFather), + QString(theEntry) ); + DeltaPos.append( SO ); + } + } else { + int nbSel = Sel->getInteractiveObjectCount(); + for ( int i = 0; i < nbSel; i++ ) { + QAD_InteractiveObject* SO = Sel->getInteractiveObject(i); + if ( SO->getEntry().compare(theEntry) == 0 ) { + DeltaNeg.append( SO ); + break; + } + } + + } + } else { + item->setSelected( false ); + item->repaint(); + } + } + } + + MESSAGE ( "NAMEBROWSER DeltaNeg.count() == " << DeltaNeg.count() ) + for ( QAD_InteractiveObject* SO = DeltaNeg.first(); SO; SO = DeltaNeg.next() ) { + MESSAGE ( "------" << SO->getIOR() ) + Sel->RemoveInteractiveObject(SO); + } + MESSAGE ( "NAMEBROWSER DeltaPos.count() == " << DeltaPos.count() ) + for ( QAD_InteractiveObject* SO = DeltaPos.first(); SO; SO = DeltaPos.next() ) { + MESSAGE ( "++++++" << SO->getIOR() ) + Sel->AddInteractiveObject(SO); + } +} + +/*! + Update +*/ +void QAD_NameBrowser::Update(SALOMEDS::Study_ptr Study, + SALOMEDS::SObject_ptr SO) +{ + SALOMEDS::SObject_var RefSO; + SALOMEDS::ChildIterator_var it = Study->NewChildIterator(SO); + + for (; it->More();it->Next()) { + SALOMEDS::SObject_var CSO= it->Value(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + QListViewItem* Item; + + if (CSO->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + if (CSO->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + Item = AddItem ( aName->Value(), CSO->GetID(), anIOR->Value()); + } + } + + Update(Study,CSO); + } +} + +/*! + Update +*/ +void QAD_NameBrowser::Update(SALOMEDS::Study_ptr Study, + SALOMEDS::SComponent_ptr SC) +{ + ListView1->clear(); + + if (Study->_is_nil()) { + return; + } + +// Standard_CString name; + Standard_CString dataType; + Standard_CString ior=""; + + QListViewItem* Item; + + SALOMEDS::SComponentIterator_var itcomp; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + + if ( !SC->_is_nil() ) { + if (SC->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + Item = AddItem (aName->Value(),SC->GetID(),ior); + } else { + Item = AddItem (dataType,SC->GetID(),ior); + } + Update ( Study, SALOMEDS::SObject::_narrow(SC) ); + + } else { + itcomp = Study->NewComponentIterator(); + for (; itcomp->More(); itcomp->Next()) { + SALOMEDS::SComponent_var SC1 = itcomp->Value(); + dataType = SC1->ComponentDataType(); + + if (SC1->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + ior = anIOR->Value(); + } + + if ( QString(dataType).compare("Interface Applicative") != 0 ) { + if (SC1->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + Item = AddItem (aName->Value(), SC1->GetID(), ior); + } else { + Item = AddItem (dataType, SC1->GetID(), ior); + } + + Update ( Study, SALOMEDS::SObject::_narrow(SC1) ); + } + } + } +} + +QListViewItem* QAD_NameBrowser::AddItem(const QString& theText, + const QString& theEntry, + const QString& theIOR) + +{ + QListViewItem* anItem = new QListViewItem( ListView1 ); + anItem->setText(0, theText); + anItem->setText(1, theEntry); + anItem->setText(2, theIOR); + + return anItem; +} + +/*! + Called when NameBrowser is about to close +*/ +void QAD_NameBrowser::closeEvent(QCloseEvent* e) +{ + QAD_Application::getDesktop()->closeNameBrowser(); + e->accept(); +} diff --git a/src/SALOMEGUI/QAD_NameBrowser.h b/src/SALOMEGUI/QAD_NameBrowser.h new file mode 100644 index 000000000..276432b74 --- /dev/null +++ b/src/SALOMEGUI/QAD_NameBrowser.h @@ -0,0 +1,70 @@ +// File : QAD_NameBrowser.h +// Created : Mon Nov 26 10:15:34 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_NAMEBROWSER_H +#define QAD_NAMEBROWSER_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QComboBox; +class QGroupBox; +class QLabel; +class QListView; +class QListViewItem; +class QPushButton; +class QToolButton; + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +class QAD_NameBrowser : public QMainWindow +{ + Q_OBJECT + +public: + QAD_NameBrowser( QWidget* parent = 0, const char* name = 0); + ~QAD_NameBrowser(); + + QListView* getListView() const; + + void initFilters(); + + QListViewItem* AddItem(const QString&, + const QString&, + const QString&); + void Update(SALOMEDS::Study_ptr Study, + SALOMEDS::SObject_ptr SO); + void Update(SALOMEDS::Study_ptr Study, + SALOMEDS::SComponent_ptr SC = SALOMEDS::SComponent::_narrow( CORBA::Object::_nil() )); + + + void closeEvent(QCloseEvent* e); + +protected slots: + void selectAllFilteredObjects(); + void updateFilters(); + + void onFilteredObjects(); + +private: + QGroupBox* GroupBox1; + QComboBox* ComboBox1; + QPushButton* PushButton5; + QComboBox* ComboBox2; + QGroupBox* GroupBox2; + QPushButton* PushButton1; + QListView* ListView1; + +}; + +#endif // QAD_NAMEBROWSER_H diff --git a/src/SALOMEGUI/QAD_ObjectBrowser.cxx b/src/SALOMEGUI/QAD_ObjectBrowser.cxx new file mode 100644 index 000000000..9ed2eb23b --- /dev/null +++ b/src/SALOMEGUI/QAD_ObjectBrowser.cxx @@ -0,0 +1,1787 @@ +using namespace std; +// File : QAD_ObjectBrowser.cxx +// Created : Thu Jun 14 15:42:10 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + + +#include "QAD_ObjectBrowserItem.h" +#include "QAD_ObjectBrowser.h" +#include "QAD_Application.h" +#include "QAD_MessageBox.h" +#include "QAD_Desktop.h" +#include "QAD_Config.h" +#include "QAD_Settings.h" +#include "QAD_Tools.h" +#include "QAD_RightFrame.h" +#include "SALOME_Selection.h" +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOMEGUI_SetValueDlg.h" +#include "SALOMEGUI_TableDlg.h" +#include "SALOMEGUI_NameDlg.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//VRV: porting on Qt 3.0.5 +#if QT_VERSION >= 0x030005 +#include +#endif +//VRV: porting on Qt 3.0.5 + +#define UC_NEW_EMPTY_ID 1000000 +#define UC_NEW_COMP_ID 1000002 +#define UC_NEW_FULL_ID 1000004 +#define UC_NEW_COPY_ID 1000006 +#define UC_APPEND_ID 1000008 +#define UC_REMOVE_ID 1000010 +#define UC_RENAME_ID 1000012 +#define UC_CLEAR_ID 1000014 +#define UC_SET_CURRENT_ID 1000016 + +/*! + Gets selected top-level items (i.e. not including sub-items) [ static ] +*/ +static void getSelectedParents( QListViewItem* listViewItem, QList& itemList ) +{ + QListViewItem* item = listViewItem->firstChild(); + while ( item ) { + if ( item->isSelected() ) { + itemList.append( item ); + } + else { + getSelectedParents( item, itemList ); + } + item = item->nextSibling(); + } +} +/*! + Gets selected top-level items (i.e. not including sub-items) [ static ] +*/ +static void getSelectedParents( QListView* listView, QList& itemList, bool ignoreRoot = false ) +{ + itemList.clear(); + QListViewItem* item = listView->firstChild(); + while ( item ) { + if ( item->isSelected() && !ignoreRoot ) { + itemList.append( item ); + } + else { + getSelectedParents( item, itemList ); + } + item = item->nextSibling(); + } +} +/*! + Gets top-most parent item [ static ] +*/ +static QListViewItem* getTopParent( QListViewItem* item ) +{ + if ( !item ) + return 0; + QListViewItem* p = item->parent(); + if ( !p ) + return item; + while ( p->parent() ) { + p = p->parent(); + } + return p; +} +/*! + Returns true if the item is top-level (root) +*/ +static bool isRootItem( QListViewItem* item ) +{ + return ( item->listView() && !item->parent() ); +} +/*! + Constructor +*/ +QAD_ObjectBrowser::QAD_ObjectBrowser( SALOMEDS::Study_var study, QWidget* parent, const char* name, WFlags fl ) + : QTabWidget( parent, name, fl ) +{ + myStudy = SALOMEDS::Study::_duplicate( study ); + myListViewMap.clear(); + myUseCaseMap.clear(); + setupListView(); +} + +/*! + Destructor +*/ +QAD_ObjectBrowser::~QAD_ObjectBrowser() +{ + if (!myStudy->_is_nil()) + CORBA::release(myStudy); +} + +/*! + Configures Object Browser and UseCase Browser. + Columns, Selection Mode and Palette. +*/ +void QAD_ObjectBrowser::setupListView() +{ + QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); + + this->setTabPosition( QTabWidget::Bottom ); + + /* Reading setting : Columns for Value, OCAF Doc entry, object IOR, OCAF Doc ref entry and Chrono sorting */ + QString AddColumn = QAD_CONFIG->getSetting( "ObjectBrowser:AddColumn" ); + QString ValueColumn = QAD_CONFIG->getSetting( "ObjectBrowser:ValueColumn" ); + QString ShowCHRONO_SORT = QAD_CONFIG->getSetting( "ObjectBrowser:CHRONO_SORT" ); + + /* create and setup Object Browser ================================= */ + myListView = new QListView( this, "Object Browser"); + myListView->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + myListView->setMinimumSize( 1, 1 ); + myListView->setPalette( QAD_Application::getPalette( true ) ); + + /* First two columns = object name and value - always visible */ + myListView->addColumn( tr( "OBJECT_BROWSER_OBJECT" ) ); /* Adding Object column */ + myListView->addColumn( tr( "OBJECT_BROWSER_VALUE" ) ); /* Adding Value column */ + myListView->addColumn( tr( "OBJECT_BROWSER_ENTRY" ) ); /* Adding Doc entry column */ + myListView->addColumn( tr( "OBJECT_BROWSER_IOR" ) ); /* Adding Object IOR column */ + myListView->addColumn( tr( "OBJECT_BROWSER_REFENTRY" ) ); /* Adding OCAF Doc ref entry column */ + myListView->header()->setMovingEnabled( false ); + + /* Properties */ + myListView->header()->setClickEnabled( TRUE ); /* Enable clicking on the header */ + myListView->setShowSortIndicator( TRUE ) ; /* Add user arrows to indicate the sort order : LPN */ + myListView->setRootIsDecorated( TRUE ); /* Enable expand/collapse control for the root item */ + myListView->setSelectionMode ( QListView::Extended ); /* Enable multiple selection */ + myListView->setVScrollBarMode( QScrollView::AlwaysOn ); /* Set scrollbars always visible */ + myListView->setHScrollBarMode( QScrollView::AlwaysOn ); /* ... */ + + /* Connect section */ + //VRV: porting on Qt 3.0.5 +#if QT_VERSION < 0x030005 + connect( myListView, SIGNAL( rightButtonClicked( QListViewItem*, const QPoint&, int ) ), + this, SLOT( showPopupMenu( QListViewItem* ) ) ); +#else + connect( myListView, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ), + this, SLOT( showPopupMenu( QListViewItem* ) ) ); +#endif + //VRV: porting on Qt 3.0.5 + + connect( myListView, SIGNAL( selectionChanged() ), + this, SLOT( onSelectedItem() ) ); + connect( myListView, SIGNAL( expanded( QListViewItem* ) ), + this, SLOT( onExpanded( QListViewItem* ) ) ); + connect( myListView, SIGNAL( collapsed( QListViewItem* ) ), + this, SLOT( onCollapsed( QListViewItem* ) ) ); + + /* create and setup UseCase Browser ================================ */ + QWidget* vBox = new QWidget( this ); + QVBoxLayout* vBoxLayout = new QVBoxLayout( vBox ); + + myUseCaseView = new QListView( vBox, "UseCase Browser"); + myUseCaseView->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + myUseCaseView->setMinimumSize( 1, 1 ); + myUseCaseView->setPalette( QAD_Application::getPalette( true ) ); + + /* First column = object name */ + myUseCaseView->addColumn( tr( "OBJECT_BROWSER_OBJECT" ) ); + /* Properties */ + myUseCaseView->header()->setClickEnabled( TRUE ); /* Enable clicking on the header */ + myUseCaseView->setShowSortIndicator( TRUE ) ; /* Add user arrows to indicate the sort order : LPN */ + myUseCaseView->setRootIsDecorated( TRUE ); /* Enable expand/collapse control for the root item */ + myUseCaseView->setSelectionMode ( QListView::Extended ); /* Enable multiple selection */ + myUseCaseView->setVScrollBarMode( QScrollView::AlwaysOn ); /* Set scrollbars always visible */ + myUseCaseView->setHScrollBarMode( QScrollView::AlwaysOn ); /* ... */ + myUseCaseView->header()->setMovingEnabled( false ); + myUseCaseView->viewport()->setAcceptDrops( true ); + myUseCaseView->installEventFilter( this ); + myUseCaseView->viewport()->installEventFilter( this ); + myUseCaseView->setSorting( -1 ) ; + vBoxLayout->addWidget( myUseCaseView ); + + myNewBtn = new QToolButton( vBox ); + myNewBtn->setIconSet( resMgr->loadPixmap( "QAD", tr("ICON_UC_NEW") ) ); + myNewBtn->setAutoRaise( true ); + QToolTip::add( myNewBtn, tr( "UC_NEW_ID" ), QAD_Application::getDesktop()->toolTipGroup(), tr( "UC_NEW_TIP" ) ); + myAddBtn = new QToolButton( vBox ); + myAddBtn->setIconSet( resMgr->loadPixmap( "QAD", tr("ICON_UC_ADD") ) ); + myAddBtn->setAutoRaise( true ); + QToolTip::add( myAddBtn, tr( "UC_APPEND_ID" ), QAD_Application::getDesktop()->toolTipGroup(), tr( "UC_APPEND_TIP" ) ); + myDelBtn = new QToolButton( vBox ); + myDelBtn->setIconSet( resMgr->loadPixmap( "QAD", tr("ICON_UC_REMOVE") ) ); + myDelBtn->setAutoRaise( true ); + QToolTip::add( myDelBtn, tr( "UC_REMOVE_ID" ), QAD_Application::getDesktop()->toolTipGroup(), tr( "UC_REMOVE_TIP" ) ); + myClearBtn = new QToolButton( vBox ); + myClearBtn->setIconSet( resMgr->loadPixmap( "QAD", tr("ICON_UC_CLEAR") ) ); + myClearBtn->setAutoRaise( true ); + QToolTip::add( myClearBtn, tr( "UC_CLEAR_ID" ), QAD_Application::getDesktop()->toolTipGroup(), tr( "UC_CLEAR_TIP" ) ); + myCurrentBtn = new QToolButton( vBox ); + myCurrentBtn->setIconSet( resMgr->loadPixmap( "QAD", tr("ICON_UC_SET_CURRENT") ) ); + myCurrentBtn->setAutoRaise( true ); + QToolTip::add( myCurrentBtn, tr( "UC_SET_CURRENT_ID" ), QAD_Application::getDesktop()->toolTipGroup(), tr( "UC_SET_CURRENT_TIP" ) ); + + QHBoxLayout* btnLayout = new QHBoxLayout; + btnLayout->setMargin( 3 ); btnLayout->setSpacing( 3 ); + btnLayout->addWidget( myNewBtn ); + btnLayout->addStretch(); + btnLayout->addSpacing( 5 ); + btnLayout->addStretch(); + btnLayout->addWidget( myAddBtn ); + btnLayout->addWidget( myDelBtn ); + btnLayout->addStretch(); + btnLayout->addSpacing( 5 ); + btnLayout->addStretch(); + btnLayout->addWidget( myClearBtn ); + btnLayout->addStretch(); + btnLayout->addSpacing( 5 ); + btnLayout->addStretch(); + btnLayout->addWidget( myCurrentBtn ); + btnLayout->addStretch(); + + vBoxLayout->addLayout( btnLayout ); + + connect( myNewBtn, SIGNAL( clicked() ), this, SLOT( onUseCaseBtn() ) ); + connect( myAddBtn, SIGNAL( clicked() ), this, SLOT( onUseCaseBtn() ) ); + connect( myDelBtn, SIGNAL( clicked() ), this, SLOT( onUseCaseBtn() ) ); + connect( myClearBtn, SIGNAL( clicked() ), this, SLOT( onUseCaseBtn() ) ); + connect( myCurrentBtn, SIGNAL( clicked() ), this, SLOT( onUseCaseBtn() ) ); + + /* Connect section */ +#if QT_VERSION < 0x030005 + connect( myUseCaseView, SIGNAL( rightButtonClicked( QListViewItem*, const QPoint&, int ) ), + this, SLOT( showPopupMenu( QListViewItem* ) ) ); +#else + connect( myUseCaseView, SIGNAL( contextMenuRequested( QListViewItem*, const QPoint&, int ) ), + this, SLOT( showPopupMenu( QListViewItem* ) ) ); +#endif + + connect( myUseCaseView, SIGNAL( selectionChanged() ), + this, SLOT( onSelectedItem() ) ); + + /* add Object Browser and UseCase Browser as pages ================= */ + this->addTab( myListView, tr( "TLT_OBJECT_BROWSER" ) ); + this->addTab( vBox, tr( "TLT_USECASE_BROWSER" ) ); + + setShowInfoColumns( AddColumn == "true" ); + setShowValueColumn( ValueColumn == "true" ); + setEnableChronoSort( ShowCHRONO_SORT == "true" ); + + resize( QSize( 100, 400 ) ); +} + +/*! + Event filter +*/ + +bool QAD_ObjectBrowser::eventFilter( QObject* o, QEvent* e ) +{ + QAD_Desktop* Desktop = (QAD_Desktop*) QAD_Application::getDesktop(); + QAD_Study* myActiveStudy = Desktop->getActiveStudy(); + if ( myStudy->_is_nil() ) + return QTabWidget::eventFilter( o, e ); + + SALOMEDS::UseCaseBuilder_var UCBuilder = myStudy->GetUseCaseBuilder(); + if ( o == myUseCaseView->viewport() ) { + if ( e->type() == QEvent::MouseButtonPress ) { + // Test if clicked on selection and start drag if necessary + QMouseEvent* me = ( QMouseEvent* )e; + QAD_ObjectBrowserItem* item = ( QAD_ObjectBrowserItem* )( myUseCaseView->itemAt( me->pos() ) ); + if ( item && item->isSelected() && me->button() == LeftButton) { + if ( me->pos().x() > myUseCaseView->header()->sectionPos( myUseCaseView->header()->mapToIndex( 0 ) ) + + myUseCaseView->treeStepSize() * ( item->depth() + ( myUseCaseView->rootIsDecorated() ? 1 : 0 ) ) + + myUseCaseView->itemMargin() || + me->pos().x() < myUseCaseView->header()->sectionPos( myUseCaseView->header()->mapToIndex( 0 ) ) ) { + QStringList entryList; + QListViewItemIterator it( myUseCaseView ); + bool done = true; + for ( ; it.current(); ++it ) { + QAD_ObjectBrowserItem* selItem = ( QAD_ObjectBrowserItem* )( it.current() ); + if ( selItem->isSelected() ) { + if ( isRootItem( selItem ) ) { + done = false; + break; + } + else { + entryList.append( selItem->getEntry() ); + } + } + } + if ( done && !entryList.isEmpty() ) { + QTextDrag *d = new QTextDrag( entryList.join("*"), myUseCaseView->viewport() ); + d->dragMove(); + return true; + } + } + } + } + else if ( e->type() == QEvent::DragMove ) { + QDragMoveEvent* dme = ( QDragMoveEvent* )e; + if ( dme->source() == myUseCaseView->viewport() ) { + dme->accept(); + } + else { + dme->ignore(); + } + return true; + } + else if ( e->type() == QEvent::Drop ) { + QDropEvent* de = ( QDropEvent* )e; + QString text; + QAD_ObjectBrowserItem* dropItem = ( QAD_ObjectBrowserItem* )( myUseCaseView->itemAt( de->pos() ) ); + if ( de->source() == myUseCaseView->viewport() ) { + if ( QTextDrag::decode( de, text ) && dropItem && !dropItem->isSelected() ) { + QAD_ObjectBrowserItem* useCaseItem = ( QAD_ObjectBrowserItem* )getTopParent( dropItem ); + if ( useCaseItem ) { + if ( !UCBuilder->_is_nil() ) { + UCBuilder->SetRootCurrent(); + if ( useCaseItem != dropItem ) { + SALOMEDS::SObject_var dropObject = myStudy->FindObjectID( dropItem->getEntry() ); + if ( !dropObject->_is_nil() ) + UCBuilder->SetCurrentObject( dropObject ); + } + QStringList entryList = QStringList::split( "*", text, false ); + // if Move action then first remove all selected items + if ( de->action() == QDropEvent::Move ) { + QList ucSelected; + ucSelected.setAutoDelete( false ); + getSelectedParents( myUseCaseView, ucSelected ); + for ( int j = 0; j < entryList.count(); j++ ) { + QAD_ObjectBrowserItem* delItem = ( QAD_ObjectBrowserItem* )( ucSelected.at( j ) ); + QAD_ObjectBrowserItem* ucDelItem = ( QAD_ObjectBrowserItem* )getTopParent( delItem ); + SALOMEDS::SObject_var delSO = myStudy->FindObjectID( delItem->getEntry() ); + if ( !delSO->_is_nil() && ucDelItem ) { + UCBuilder->Remove( delSO ); + } + } + } + // then try to append items to destination + for ( int i = 0; i < entryList.count(); i++ ) { + SALOMEDS::SObject_var SO = myStudy->FindObjectID( entryList[i] ); + if ( !SO->_is_nil() ) { + UCBuilder->Remove( SO ); + UCBuilder->Append( SO ); + } + } + myActiveStudy->updateUseCaseBrowser(); + } + } + } + de->acceptAction(); + } + else { + de->ignore(); + } + return true; + } + } + else if ( o == myUseCaseView ) { + if ( e->type() == QEvent::KeyPress ) { + QKeyEvent* ke = ( QKeyEvent* )e; + if ( ke->key() == Key_Delete ) { + onUseCasePopupMenu( UC_REMOVE_ID ); + return true; + } + } + } + return QTabWidget::eventFilter( o, e ); +} + + +/*! + Builds popup menu +*/ +void QAD_ObjectBrowser::onCreatePopup() +{ + QAD_Desktop* Desktop = (QAD_Desktop*) QAD_Application::getDesktop(); + QAD_Study* myActiveStudy = Desktop->getActiveStudy(); + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + + /* VSR : Creation of common POPUP menu for Object Browser/Use Case Browser */ + if ( Sel->IObjectCount() > 0 ) { + QString theContext; + QString theParent; + QString theObject; + + Desktop->definePopup( theContext, theParent, theObject ); + if ( myPopup ) { + Desktop->createPopup( myPopup, theContext, "ObjectBrowser", theObject); + if ( !Desktop->getActiveComponent().isEmpty() ) { + Desktop->customPopup( myPopup, theContext, "ObjectBrowser", theObject ); + } + // VSR:22/01/03 - Command for edit attributes value + bool EditValues = QAD_CONFIG->getSetting( "ObjectBrowser:EditValues" ) == "true"; + if ( EditValues && Sel->IObjectCount() == 1 && hasEditableAttribute(Sel->firstIObject()) ) { + if ( myPopup->count() > 0 ) + myPopup->insertSeparator(); + myPopup->insertItem( tr( "EDIT_VALUE_CMD" ), + this, + SLOT( onEditAttribute() ) ); + } + } + } else { + // NRI 02/12/2002 + // No selected item => it's not necessary to create popup + //NRI- : Desktop->createPopup( myPopup, "", "ObjectBrowser", ""); + } + if ( currentPage() != myListView ) { + /* VSR : Creation of POPUP menu for UseCase Browser */ + QList ucSelected; + ucSelected.setAutoDelete( false ); + getSelectedParents( myUseCaseView, ucSelected ); + + if ( myPopup && !myStudy->_is_nil() ) { + SALOMEDS::UseCaseBuilder_var UCBuilder = myStudy->GetUseCaseBuilder(); +// myPopup->clear(); + bool isOne = ucSelected.count() == 1; + bool isMany = ucSelected.count() > 1; + bool isEmpty = ucSelected.count() == 1; + bool obSelected = Sel->IObjectCount() > 0; + bool isRoot = isOne && isRootItem( ucSelected.at( 0 ) ); + bool manyChildren = myUseCaseView->childCount() > 0 && myUseCaseView->firstChild()->childCount() > 0; + bool isUseCase = isOne && + ( isRoot || UCBuilder->IsUseCase( myStudy->FindObjectID( (( QAD_ObjectBrowserItem* )( ucSelected.at(0) ))->getEntry() ) ) ); + + if ( isRoot ) + myPopup->clear(); + QPopupMenu *UseCasePopup = new QPopupMenu( myPopup ); + if ( isOne ) + UseCasePopup->insertItem( tr( "UC_NEW_ID" ), this, SLOT( onUseCasePopupMenu( int ) ), 0, UC_NEW_EMPTY_ID ); + if ( isOne ) + UseCasePopup->insertItem( tr( "UC_SET_CURRENT_ID" ), this, SLOT( onUseCasePopupMenu( int ) ), 0, UC_SET_CURRENT_ID ); + if ( isUseCase ) + UseCasePopup->insertItem( tr( "UC_RENAME_ID" ), this, SLOT( onUseCasePopupMenu( int ) ), 0, UC_RENAME_ID ); + if ( isRoot && manyChildren ) + UseCasePopup->insertItem( tr( "UC_CLEAR_ID" ), this, SLOT( onUseCasePopupMenu( int ) ), 0, UC_CLEAR_ID ); + + if ( UseCasePopup->count() > 0 ) { + if ( myPopup->count() > 0 ) + myPopup->insertSeparator(); + myPopup->insertItem( tr( "UC_POPUP" ), UseCasePopup ); + } + else { + delete UseCasePopup; + } + } + } +} + +/*! + Returns Object Browser list view +*/ +QListView* QAD_ObjectBrowser::getListView() const +{ + return myListView; +} + +/*! + Returns UseCase Browser list view +*/ +QListView* QAD_ObjectBrowser::getUseCaseView() const +{ + return myUseCaseView; +} + +/*! + Adds anItem ( probably a SComponent ) +*/ +QAD_ObjectBrowserItem* QAD_ObjectBrowser::AddItem(QListView* theView, + const QString& theName, + const QString& theEntry, + const QString& theIOR, + int theType, + const QString& theValue, + QAD_ObjectBrowserItem* theAfter) + +{ + QAD_ObjectBrowserItem* last = (QAD_ObjectBrowserItem*)(theView->firstChild()); + if ( theAfter ) + last = theAfter; + else if ( last ) { + for ( ; last->nextSibling(); last = (QAD_ObjectBrowserItem*)(last->nextSibling()) ); + } + QAD_ObjectBrowserItem* anItem = new QAD_ObjectBrowserItem( theView, last ); + + anItem->setType( theType ); + anItem->setOpen( FALSE ); + anItem->setName( theName ); + anItem->setValue( theValue ); + anItem->setEntry( theEntry ); + anItem->setIOR( theIOR ); + anItem->setReference( "" ); + + return anItem; +} + +/*! + Adds anItem ( probably a StudyObject ) +*/ +QAD_ObjectBrowserItem* QAD_ObjectBrowser::AddItem(QAD_ObjectBrowserItem* theParentItem, + const QString& theName, + const QString& theEntry, + const QString& theIOR, + int theType, + const QString& theRef, + const QString& theValue, + QAD_ObjectBrowserItem* theAfter) + +{ + QAD_ObjectBrowserItem* last = (QAD_ObjectBrowserItem*)(theParentItem->firstChild()); + if ( theAfter ) + last = theAfter; + else if ( last ) { + for ( ; last->nextSibling(); last = (QAD_ObjectBrowserItem*)(last->nextSibling()) ); + } + QAD_ObjectBrowserItem* anItem = new QAD_ObjectBrowserItem(theParentItem, last); + anItem->setType( theType ); + anItem->setOpen( FALSE ); + anItem->setName( theName ); + anItem->setValue( theValue ); + anItem->setEntry( theEntry ); + anItem->setIOR( theIOR ); + anItem->setReference( theRef ); + + return anItem; +} + +/*! + Updates Object Browsers' item [ protected ] +*/ +void QAD_ObjectBrowser::Update( SALOMEDS::SObject_ptr SO, + QAD_ObjectBrowserItem* theParentItem ) +{ + if ( myStudy->_is_nil() || SO->_is_nil() || !theParentItem ) { + return; + } + SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(SO); + + for (; it->More();it->Next()) { + SALOMEDS::SObject_var CSO = it->Value(); + SALOMEDS::SObject_var RefSO; + QString ior = ""; + QString CSOEntry = strdup( CSO->GetID() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeComment_var aCmnt; + SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributeReal_var aReal; + SALOMEDS::AttributeInteger_var anInt; + SALOMEDS::AttributeSelectable_var aSelectable; + SALOMEDS::AttributeExpandable_var anExpandable; + SALOMEDS::AttributeOpened_var anOpened; + SALOMEDS::AttributePixMap_var aPixmap; + SALOMEDS::AttributeTextColor_var aTextColor; + SALOMEDS::AttributeTextHighlightColor_var aTextHighlightColor; + + QAD_ObjectBrowserItem* Item = 0; + QAD_ObjectBrowserItem* subItem; + QString valueString; + + if ( CSO->ReferencedObject(RefSO) && !RefSO->_is_nil() ) { + + QString RefSOEntry = strdup( 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() ); + } + valueString = getValueFromObject( RefSO ); +// AddItem (Item, QString(" * ") + strdup( aName->Value() ), RefSOEntry, ior, 2, CSOEntry); + Item = AddItem(theParentItem, + QString(" * ") + strdup( aName->Value() ), + RefSOEntry, + ior, + 2, + CSOEntry, + valueString); + myListViewMap[ RefSOEntry ].append( Item ); + } + else { + MESSAGE("QAD_ObjectBrowser::Update : noname item: "<GetID()); + } + } else { + // getting Value + valueString = getValueFromObject( CSO ); + // getting IOR + if (CSO->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + ior = strdup( 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); + myListViewMap[ CSOEntry ].append( Item ); + } + else { + MESSAGE("QAD_ObjectBrowser::Update : noname item: "<GetID()); + } + // adding other attributes + if (Item) { + // Selectable + if ( CSO->FindAttribute(anAttr, "AttributeSelectable") ) { + aSelectable = SALOMEDS::AttributeSelectable::_narrow(anAttr); + Item->setSelectable(aSelectable->IsSelectable()); + } + // Expandable + if ( CSO->FindAttribute(anAttr, "AttributeExpandable") ) { + anExpandable = SALOMEDS::AttributeExpandable::_narrow(anAttr); + Item->setExpandable(anExpandable->IsExpandable()); + } + // Opened + if ( CSO->FindAttribute(anAttr, "AttributeOpened") ) { + anOpened = SALOMEDS::AttributeOpened::_narrow(anAttr); + Item->setOpen(anOpened->IsOpened()); + } + // TextColor + if ( CSO->FindAttribute(anAttr, "AttributeTextColor") ) { + aTextColor = SALOMEDS::AttributeTextColor::_narrow(anAttr); + QColor aColor(aTextColor->TextColor().R, aTextColor->TextColor().G, aTextColor->TextColor().B) ; + Item->setTextColor(aColor); + } + // TextHighlightColor + if ( CSO->FindAttribute(anAttr, "AttributeTextHighlightColor") ) { + aTextHighlightColor = SALOMEDS::AttributeTextHighlightColor::_narrow(anAttr); + QColor aColor(aTextHighlightColor->TextHighlightColor().R, + aTextHighlightColor->TextHighlightColor().G, + aTextHighlightColor->TextHighlightColor().B) ; + Item->setTextHighlightColor(aColor); + } + // Pixmap + if ( CSO->FindAttribute(anAttr, "AttributePixMap") ) { + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + if ( aPixmap->HasPixMap() ) { + SALOMEDS::SComponent_var father = CSO->GetFatherComponent(); + if (father->FindAttribute(anAttr, "AttributeName") ) { + SALOMEDS::AttributeName_var aFatherName; + aFatherName = SALOMEDS::AttributeName::_narrow(anAttr); + + QString msg; + QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); + if ( resMgr ) { + if(resMgr->loadResources( QString(aFatherName->Value()) + "GUI", msg )) { + QPixmap icon ( resMgr->loadPixmap( QString(aFatherName->Value()) + "GUI", + tr(aPixmap->GetPixMap()) /*tr( "ICON_OBJBROWSER_" + theComponent )*/ )); + Item->setPixmap( 0, icon ); + } + } + } + } + } + } + } +// if ( theParentItem->isOpen() ) +// Item->setOpen(TRUE); + + if ( Item ) + Update(CSO, Item); + } +} + +/*! + Updates Object Browser tree and UseCase Browser tree +*/ +void QAD_ObjectBrowser::Update() +{ + myListView->clear(); + myListViewMap.clear(); + + if ( myStudy->_is_nil() ) { + return; + } + + QString ShowIAPP = QAD_CONFIG->getSetting("ObjectBrowser:IAPP"); + + /* Updating Object Browser ============================================== */ + SALOMEDS::SComponentIterator_var itcomp = myStudy->NewComponentIterator(); + for (; itcomp->More(); itcomp->Next()) { + QAD_ObjectBrowserItem* Item = 0; + SALOMEDS::SComponent_var SC = itcomp->Value(); + QString dataType = strdup( SC->ComponentDataType() ); + QString ior = ""; + QString SCEntry = strdup( SC->GetID() ); + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeComment_var aCmnt; + SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributeReal_var aReal; + SALOMEDS::AttributeInteger_var anInt; + SALOMEDS::AttributeSelectable_var aSelectable; + SALOMEDS::AttributeExpandable_var anExpandable; + SALOMEDS::AttributeOpened_var anOpened; + SALOMEDS::AttributePixMap_var aPixmap; + SALOMEDS::AttributeTextColor_var aTextColor; + SALOMEDS::AttributeTextHighlightColor_var aTextHighlightColor; + + if (SC->FindAttribute(anAttr, "AttributeIOR")) { + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + ior = strdup( anIOR->Value() ); + } + + bool caseIAPP = false; + + // create data-tree item, corresponding to component (and set name if component has it) + if ( dataType.compare("Interface Applicative") == 0 ) { + caseIAPP = true; + 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, ""); + myListViewMap[ SCEntry ].append( Item ); + } + else { + Item = AddItem (myListView, dataType, SCEntry, ior, 1, ""); + myListViewMap[ SCEntry ].append( Item ); + } + + } + } + else { + caseIAPP = false; + if (SC->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + Item = AddItem (myListView, strdup( aName->Value() ), SCEntry, ior, 1, ""); + myListViewMap[ SCEntry ].append( Item ); + } + else { + /*In according to CAF - any label (even if it is empty) exist during to whole session. + So, if label haven't an "AttributeName" it is means that the label is empty. + Therefore follow action couses bug - + Item = AddItem (myListView, dataType, SC->GetID(), ior, 1, ""); + */ + } + } + // add other attributes + if (Item) { + QAD_ObjectBrowserItem* subItem; + // Selectable + if ( SC->FindAttribute(anAttr, "AttributeSelectable") ) { + aSelectable = SALOMEDS::AttributeSelectable::_narrow(anAttr); + Item->setSelectable(aSelectable->IsSelectable()); + } + // Expandable + if ( SC->FindAttribute(anAttr, "AttributeExpandable") ) { + anExpandable = SALOMEDS::AttributeExpandable::_narrow(anAttr); + Item->setExpandable(anExpandable->IsExpandable()); + } + // Opened + if ( SC->FindAttribute(anAttr, "AttributeOpened") ) { + anOpened = SALOMEDS::AttributeOpened::_narrow(anAttr); + Item->setOpen(anOpened->IsOpened()); + } + // TextColor + if ( SC->FindAttribute(anAttr, "AttributeTextColor") ) { + aTextColor = SALOMEDS::AttributeTextColor::_narrow(anAttr); + QColor aColor(aTextColor->TextColor().R, aTextColor->TextColor().G, aTextColor->TextColor().B) ; + Item->setTextColor(aColor); + } + // TextHighlightColor + if ( SC->FindAttribute(anAttr, "AttributeTextHighlightColor") ) { + aTextHighlightColor = SALOMEDS::AttributeTextHighlightColor::_narrow(anAttr); + QColor aColor(aTextHighlightColor->TextHighlightColor().R, + aTextHighlightColor->TextHighlightColor().G, + aTextHighlightColor->TextHighlightColor().B) ; + Item->setTextHighlightColor(aColor); + } + + // Pixmap + if ( SC->FindAttribute(anAttr, "AttributePixMap") ) { + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + if ( aPixmap->HasPixMap() ) { + QString msg; + QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); + if ( resMgr ) { + MESSAGE ( " Component " << aName->Value() ) + MESSAGE ( " Icon " << aPixmap->GetPixMap() ) + if(resMgr->loadResources( QString(aName->Value()) + "GUI", msg )) { + QPixmap icon ( resMgr->loadPixmap( QString(aName->Value()) + "GUI", + tr(aPixmap->GetPixMap()) /*tr( "ICON_OBJBROWSER_" + theComponent )*/ )); + Item->setPixmap( 0, icon ); + } + } + } + } + /* + if ( strcmp(dataType, TypeComponent) == 0 ) + Item->setOpen(TRUE); + */ + if ( caseIAPP && ShowIAPP.compare("true") == 0 ) + Update (SC, Item); + + if ( !caseIAPP ) + Update (SC, Item); + } + } + /* Updating UseCase Browser ============================================= */ + UpdateUseCaseBrowser(); +} + +/*! + Removes item with all childs from the map - used to optimize UseCase browser update +*/ +void removeFromMap( ItemMap& theMap, QAD_ObjectBrowserItem* item ) +{ + if ( item ) { + QAD_ObjectBrowserItem* subItem = ( QAD_ObjectBrowserItem* )( item->firstChild() ); + while ( subItem ) { + removeFromMap( theMap, subItem ); + subItem = ( QAD_ObjectBrowserItem* )( subItem->nextSibling() ); + } + if ( theMap.contains( item->getEntry() ) ) { + theMap[ item->getEntry() ].removeRef( item ); + if ( theMap[ item->getEntry() ].isEmpty() ) { + theMap.remove( item->getEntry() ); + } + } + } +} + +/*! + Updates only UseCase Browser +*/ +void QAD_ObjectBrowser::UpdateUseCaseBrowser() { +// myUseCaseView->clear(); myUseCaseMap.clear(); + if ( myStudy->_is_nil() ) { + return; + } + myUseCaseView->blockSignals( true ); +// myUseCaseView->setUpdatesEnabled( false ); + + 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() ) ); + if ( UCName.isEmpty() ) + UCName = QString( tr( "Root" ) ); + // creating root item if is not yet created + if ( !root ) { + root = AddItem( myUseCaseView, UCName, "0:2", "", 1, "" ); + myUseCaseMap[ "0:2" ].append( root ); + } + else + root->setName( UCName ); + // setting it current if necessary + root->setCurrent( SOCurrent->_is_nil() || !strcmp( SOCurrent->GetID(), "0:2" ) ); + // updating list view... + QMap ucList; + SALOMEDS::UseCaseIterator_var UCIter = UCBuilder->GetUseCaseIterator( SALOMEDS::SObject::_nil() ); + if ( !UCIter->_is_nil() ) { + for ( ; UCIter->More(); UCIter->Next() ) { + SALOMEDS::SObject_var UCObject = UCIter->Value(); + QString UCEntry = strdup( UCObject->GetID() ); + ucList[ UCEntry ] = UCObject; + } + } + // ... 1) delete removed items + QAD_ObjectBrowserItem* childItem = ( QAD_ObjectBrowserItem* )root->firstChild(); + while ( childItem ) { + QAD_ObjectBrowserItem* prevItem = childItem; + childItem = ( QAD_ObjectBrowserItem* )childItem->nextSibling(); + if ( !ucList.contains( prevItem->getEntry() ) ) { +// myUseCaseMap[ prevItem->getEntry() ].removeRef( prevItem ); +// if ( myUseCaseMap[ prevItem->getEntry() ].isEmpty() ) +// myUseCaseMap.remove( prevItem->getEntry() ); + removeFromMap( myUseCaseMap, prevItem ); + delete prevItem; + } + } + // ... 2) create/update existing + QMap::Iterator it; + for ( it = ucList.begin(); it != ucList.end(); ++it ) { + UpdateUCItem( it.data(), root ); + } + myUseCaseView->blockSignals( false ); +// myUseCaseView->setUpdatesEnabled( true ); +// myUseCaseView->update(); +// UCItem->setOpen( true ); +} + +/*! + Updates UseCase Browser's item +*/ +void QAD_ObjectBrowser::UpdateUCItem( SALOMEDS::SObject_var UCObject, QAD_ObjectBrowserItem* UCItem ) +{ + if ( myStudy->_is_nil() || !UCItem ) + return; + + /* Creating SObjects item */ + SALOMEDS::SObject_var RefSO; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + SALOMEDS::AttributeSelectable_var aSelectable; + SALOMEDS::AttributeExpandable_var anExpandable; + SALOMEDS::AttributePixMap_var aPixmap; + SALOMEDS::AttributeTextColor_var aTextColor; + SALOMEDS::AttributeTextHighlightColor_var aTextHighlightColor; + QString valueString; + QString ior = ""; + QString UCEntry = strdup( UCObject->GetID() ); + + SALOMEDS::UseCaseBuilder_var UCBuilder = myStudy->GetUseCaseBuilder(); + SALOMEDS::SObject_var SOCurrent = UCBuilder->GetCurrentObject(); + + bool bFound = false; + QAD_ObjectBrowserItem* UCSubItem = 0; + if ( myUseCaseMap.contains( UCEntry ) && myUseCaseMap[ UCEntry ].count() > 0 ) + UCSubItem = myUseCaseMap[ UCEntry ].first(); + +// if ( !bFound ) { + if ( UCObject->ReferencedObject( RefSO ) && !RefSO->_is_nil() ) { + QString RefSOEntry = strdup( 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() ); + } + valueString = getValueFromObject( RefSO ); + if ( !UCSubItem ) { + UCSubItem = AddItem( UCItem, + QString( " * " ) + strdup( aName->Value() ), + RefSOEntry, + ior, + 2, + UCEntry, + valueString ); + myUseCaseMap[ RefSOEntry ].append( UCSubItem ); + } + else { + UCSubItem->setName( QString( " * " ) + strdup( aName->Value() ) ); + UCSubItem->setEntry( RefSOEntry ); + UCSubItem->setIOR( ior ); + UCSubItem->setReference( UCEntry ); + UCSubItem->setValue( valueString ); + } + UCSubItem->setCurrent( !SOCurrent->_is_nil() && QString( SOCurrent->GetID() ) == QString( UCEntry ) ); + } + } + else { + // getting Value + valueString = getValueFromObject( UCObject ); + // getting IOR + if ( UCObject->FindAttribute( anAttr, "AttributeIOR" ) ) { + anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr ); + ior = strdup( 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 ); + myUseCaseMap[ UCEntry ].append( UCSubItem ); + } + else { + UCSubItem->setName( strdup( aName->Value() ) ); + UCSubItem->setEntry( UCEntry ); + UCSubItem->setIOR( ior ); + UCSubItem->setReference( "" ); + UCSubItem->setValue( valueString ); + } + } + // adding other attributes + if ( UCSubItem ) { + UCSubItem->setCurrent( !SOCurrent->_is_nil() && QString( SOCurrent->GetID() ) == QString( UCEntry ) ); +// Selectable +// if ( UCObject->FindAttribute( anAttr, "AttributeSelectable" ) ) { +// aSelectable = SALOMEDS::AttributeSelectable::_narrow( anAttr ); +// UCSubItem->setSelectable( aSelectable->IsSelectable() ); +// } +// Expandable +// if ( UCObject->FindAttribute( anAttr, "AttributeExpandable" ) ) { +// anExpandable = SALOMEDS::AttributeExpandable::_narrow( anAttr ); +// UCSubItem->setExpandable( anExpandable->IsExpandable() ); +// } +// TextColor + if ( UCObject->FindAttribute(anAttr, "AttributeTextColor" ) ) { + aTextColor = SALOMEDS::AttributeTextColor::_narrow( anAttr ); + QColor aColor( aTextColor->TextColor().R, + aTextColor->TextColor().G, + aTextColor->TextColor().B ); + UCSubItem->setTextColor( aColor ); + } + // TextHighlightColor + if ( UCObject->FindAttribute( anAttr, "AttributeTextHighlightColor" ) ) { + aTextHighlightColor = SALOMEDS::AttributeTextHighlightColor::_narrow( anAttr ); + QColor aColor( aTextHighlightColor->TextHighlightColor().R, + aTextHighlightColor->TextHighlightColor().G, + aTextHighlightColor->TextHighlightColor().B ); + UCSubItem->setTextHighlightColor( aColor ); + } + // Pixmap + if ( UCObject->FindAttribute( anAttr, "AttributePixMap" ) ) { + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + if ( aPixmap->HasPixMap() ) { + SALOMEDS::SComponent_var father = UCObject->GetFatherComponent(); + if ( father->FindAttribute( anAttr, "AttributeName" ) ) { + SALOMEDS::AttributeName_var aFatherName; + aFatherName = SALOMEDS::AttributeName::_narrow( anAttr ); + QAD_ResourceMgr* resMgr = QAD_Desktop::getResourceManager(); + if ( resMgr ) { + QString msg; + if( resMgr->loadResources( QString( aFatherName->Value() ) + "GUI", msg ) ) { + QPixmap icon ( resMgr->loadPixmap( QString( aFatherName->Value() ) + "GUI", + tr( aPixmap->GetPixMap() ) /*tr( "ICON_OBJBROWSER_" + theComponent )*/ ) ); + UCSubItem->setPixmap( 0, icon ); + } + } + } + } + } + } + } + if ( UCSubItem ) { + // updating children ... + QMap ucList; + SALOMEDS::UseCaseIterator_var UCIter = UCBuilder->GetUseCaseIterator( UCObject ); + if ( !UCIter->_is_nil() ) { + for ( ; UCIter->More(); UCIter->Next() ) { + SALOMEDS::SObject_var UCSubObject = UCIter->Value(); + QString UCSubEntry = strdup( UCSubObject->GetID() ); + ucList[ UCSubEntry ] = UCSubObject; + } + } + // ... 1) delete removed items + QAD_ObjectBrowserItem* childItem = ( QAD_ObjectBrowserItem* )UCSubItem->firstChild(); + while ( childItem ) { + QAD_ObjectBrowserItem* prevItem = childItem; + childItem = ( QAD_ObjectBrowserItem* )childItem->nextSibling(); + if ( !ucList.contains( prevItem->getEntry() ) ) { + // myUseCaseMap[ prevItem->getEntry() ].removeRef( prevItem ); + // if ( myUseCaseMap[ prevItem->getEntry() ].isEmpty() ) + // myUseCaseMap.remove( prevItem->getEntry() ); + removeFromMap( myUseCaseMap, prevItem ); + delete prevItem; + } + } + // ... 2) create/update existing + QMap::Iterator it; + for ( it = ucList.begin(); it != ucList.end(); ++it ) { + UpdateUCItem( it.data(), UCSubItem ); + } + } +} + +/*! + Unhighlights all items +*/ +void QAD_ObjectBrowser::unHighlightAll() +{ + myListView->clearSelection(); + myUseCaseView->clearSelection(); +} + +/*! + Highlights items which refer to object +*/ +void QAD_ObjectBrowser::highlight( const Handle(SALOME_InteractiveObject)& IObject, bool highlight ) +{ + QList List; + if (getItems(IObject, List)) { + for (int i = 0; i < List.count(); i++) { + List.at(i)->setSelected( highlight ); + List.at(i)->repaint(); + } + } +} + +/*! + Gets items from Object Browser which refer to object +*/ +bool QAD_ObjectBrowser::getItems( const Handle(SALOME_InteractiveObject)& IObject, + QList& List) +{ + List.clear(); + if ( myListViewMap.contains( IObject->getEntry() ) ) { + ItemList ilist = myListViewMap[ IObject->getEntry() ]; + for ( int i = 0; i < ilist.count(); i++ ) + List.append( ilist.at(i) ); + } + if ( myUseCaseMap.contains( IObject->getEntry() ) ) { + ItemList ilist = myUseCaseMap[ IObject->getEntry() ]; + for ( int i = 0; i < ilist.count(); i++ ) + List.append( ilist.at(i) ); + } + return (List.count() > 0); +} + +/*! + Gets items from Object Browser which refer to object +*/ +bool QAD_ObjectBrowser::getItems( SALOMEDS::SObject_ptr SO, + QList& List) +{ + List.clear(); + if ( myListViewMap.contains( SO->GetID() ) ) { + ItemList ilist = myListViewMap[ SO->GetID() ]; + for ( int i = 0; i < ilist.count(); i++ ) + List.append( ilist.at(i) ); + } + if ( myUseCaseMap.contains( SO->GetID() ) ) { + ItemList ilist = myUseCaseMap[ SO->GetID() ]; + for ( int i = 0; i < ilist.count(); i++ ) + List.append( ilist.at(i) ); + } + return (List.count() > 0); +} + +/*! + Gets first item from Object Browser which refers to object (not reference) +*/ +QAD_ObjectBrowserItem* QAD_ObjectBrowser::getItem( const Handle(SALOME_InteractiveObject)& IObject ) +{ + if ( myListViewMap.contains( IObject->getEntry() ) ) { + ItemList ilist = myListViewMap[ IObject->getEntry() ]; + for ( int i = 0; i < ilist.count(); i++ ) { + QString aRef = ilist.at(i)->getReference(); + if ( ilist.at(i)->getReference().isEmpty() ) + return ilist.at(i); + } + } + return 0; +} + +/*! + Finds item from Object Browser corresponding to Object, returns 0 if fails +*/ +QAD_ObjectBrowserItem* QAD_ObjectBrowser::getItem( SALOMEDS::SObject_ptr SO ) +{ + if ( myListViewMap.contains( SO->GetID() ) ) { + ItemList ilist = myListViewMap[ SO->GetID() ]; + for ( int i = 0; i < ilist.count(); i++ ) { + QString aRef = ilist.at(i)->getReference(); + if ( ilist.at(i)->getReference().isEmpty() ) + return ilist.at(i); + } + } + return 0; +} + + +/*! + Gets first item from UseCase Browser which refers to object (not reference) +*/ +QAD_ObjectBrowserItem* QAD_ObjectBrowser::getUCItem( const Handle(SALOME_InteractiveObject)& IObject ) +{ + if ( myUseCaseMap.contains( IObject->getEntry() ) ) { + ItemList ilist = myUseCaseMap[ IObject->getEntry() ]; + for ( int i = 0; i < ilist.count(); i++ ) { + QString aRef = ilist.at(i)->getReference(); + if ( ilist.at(i)->getReference().isEmpty() ) + return ilist.at(i); + } + } + return 0; +} + +/*! + Finds item from UseCase Browser corresponding to Object, returns 0 if fails +*/ +QAD_ObjectBrowserItem* QAD_ObjectBrowser::getUCItem( SALOMEDS::SObject_ptr SO ) +{ + if ( myUseCaseMap.contains( SO->GetID() ) ) { + ItemList ilist = myUseCaseMap[ SO->GetID() ]; + for ( int i = 0; i < ilist.count(); i++ ) { + QString aRef = ilist.at(i)->getReference(); + if ( ilist.at(i)->getReference().isEmpty() ) + return ilist.at(i); + } + } + return 0; +} +/*! + Finds item corresponding to interactive object, returns 0 if fails +*/ +void QAD_ObjectBrowser::rename( const Handle(SALOME_InteractiveObject)& IObject, QString newName ) +{ + QAD_ObjectBrowserItem* item = getItem( IObject ); + if ( item ) { + item->setName( newName ); + item->repaint(); + } + item = getUCItem( IObject ); + if ( item ) { + item->setName( newName ); + item->repaint(); + } +} + +/*! + Creates and show specific Popup to this according to current selection (Object Browser) +*/ +void QAD_ObjectBrowser::showPopupMenu(QListViewItem* theItem) +{ + QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + QString ActiveComp = QAD_Application::getDesktop()->getActiveComponent(); + + if (theItem != NULL && ( Sel->IObjectCount()>0 || ActiveComp.isEmpty() ) ) { + createPopup(); + + if ( myPopup ) { + QAD_Tools::checkPopup( myPopup ); + if ( myPopup->count()>0 ) { + myPopup->exec( QCursor::pos() ); + } + destroyPopup(); + } + } +} + +/*! + Creates and show specific Popup to this according to current selection (UseCase Browser) +*/ +void QAD_ObjectBrowser::showUseCasePopupMenu(QListViewItem* theItem) +{ + createPopup(); + if ( myPopup ) { + QAD_Tools::checkPopup( myPopup ); + if ( myPopup->count() > 0 ) { + myPopup->exec( QCursor::pos() ); + } + destroyPopup(); + } +} + +/*! + Called when current selection was changed (Object Browser) +*/ +void QAD_ObjectBrowser::onSelectedItem() +{ + QListView* whoIs; + if ( sender()->inherits("QListView") ) + whoIs = (QListView*)sender(); + else + whoIs = myListView; + QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + QAD_Application* myApp = QAD_Application::getDesktop()->getActiveApp(); + + SALOME_ListIO DeltaPos; + DeltaPos.Clear(); + SALOME_ListIO DeltaNeg; + DeltaNeg.Clear(); + + QListViewItemIterator it( whoIs ); + for ( ; it.current(); ++it ) { + QAD_ObjectBrowserItem* item = (QAD_ObjectBrowserItem*)it.current(); + QString theEntry = item->getEntry(); + QString theName = item->getName(); + QString theRef = item->getReference(); + + 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) { + 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) ); + } + } else { + newIO = new SALOME_InteractiveObject( strdup(theEntry), + "", + strdup(theName) ); + newIO->setReference( strdup(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; + } + } + } + } + } + + SALOME_ListIteratorOfListIO ItNeg( DeltaNeg ); + for(;ItNeg.More();ItNeg.Next()) { + Sel->RemoveIObject( ItNeg.Value() ); + } + + SALOME_ListIteratorOfListIO ItPos( DeltaPos ); + for(;ItPos.More();ItPos.Next()) { + Sel->AddIObject( ItPos.Value() ); + } + if ( myApp ) + myApp->updateActions(); +} + +/*! + Called when selection is changed (UseCase Browser) +*/ +void QAD_ObjectBrowser::onUseCaseSelectedItem() +{ +} + +/*! + Called when item is expanded +*/ +void QAD_ObjectBrowser::onExpanded (QListViewItem* item) +{ + QAD_ObjectBrowserItem* aItem = (QAD_ObjectBrowserItem*)item; + if (!myStudy->_is_nil() && aItem) + { + SALOMEDS::SObject_var Object = myStudy->FindObjectID(aItem->getEntry()); + if (!Object->_is_nil()) + { + SALOMEDS::StudyBuilder_var StudyBuilder = myStudy->NewBuilder(); + SALOMEDS::AttributeOpened_var anAttr = SALOMEDS::AttributeOpened::_narrow( + StudyBuilder->FindOrCreateAttribute(Object, "AttributeOpened") ); + anAttr->SetOpened(true); + } + } +} + +/*! + Called when item is collapsed +*/ +void QAD_ObjectBrowser::onCollapsed(QListViewItem* item) +{ + QAD_ObjectBrowserItem* aItem = (QAD_ObjectBrowserItem*)item; + if (!myStudy->_is_nil() && aItem) + { + SALOMEDS::SObject_var Object = myStudy->FindObjectID(aItem->getEntry()); + if (!Object->_is_nil()) + { + SALOMEDS::StudyBuilder_var StudyBuilder = myStudy->NewBuilder(); + SALOMEDS::AttributeOpened_var anAttr = SALOMEDS::AttributeOpened::_narrow( + StudyBuilder->FindOrCreateAttribute(Object, "AttributeOpened") ); + anAttr->SetOpened(false); + } + } +} + +/*! + Find and returns value for the object + Warning: object can have several values attributes, search is done in the following order: + [integer], [real], [table of integer], [table of real], [comment] +*/ +QString QAD_ObjectBrowser::getValueFromObject( SALOMEDS::SObject_ptr SO ) +{ + if ( SO->_is_nil() ) + return QString::null; + SALOMEDS::SComponent_var isComponent = SALOMEDS::SComponent::_narrow( SO ); + if ( !isComponent->_is_nil() ) + return QString::null; // no values to show for components + + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeInteger_var anInt; + SALOMEDS::AttributeReal_var aReal; + SALOMEDS::AttributeTableOfInteger_var aTableInt; + SALOMEDS::AttributeTableOfReal_var aTableReal; + SALOMEDS::AttributeComment_var aComment; + + // Integer + if ( SO->FindAttribute( anAttr, "AttributeInteger" ) ) { + anInt = SALOMEDS::AttributeInteger::_narrow( anAttr ); + QString val = QString::number( anInt->Value() ); + return val; + } + // Real + if ( SO->FindAttribute( anAttr, "AttributeReal" ) ) { + aReal = SALOMEDS::AttributeReal::_narrow( anAttr ); + QString val = QString::number( aReal->Value() ); + return val; + } + // Table of integer + if ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) { + aTableInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr ); + QString tlt = QString( strdup( aTableInt->GetTitle() ) ); + if ( !tlt.isEmpty() ) + tlt += " "; + int nbRows = aTableInt->GetNbRows() ; + int nbCols = aTableInt->GetNbColumns(); + QString val = tlt + QString( "[" ) + QString::number( nbRows ) + QString( "," ) + QString::number( nbCols ) + QString( "]" ); + return val; + } + // Table of real + if ( SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) { + aTableReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr ); + QString tlt = QString( strdup( aTableReal->GetTitle() ) ); + if ( !tlt.isEmpty() ) + tlt += " "; + int nbRows = aTableReal->GetNbRows() ; + int nbCols = aTableReal->GetNbColumns(); + QString val = tlt + QString( "[" ) + QString::number( nbRows ) + QString( "," ) + QString::number( nbCols ) + QString( "]" ); + return val; + } + // Comment + if ( SO->FindAttribute(anAttr, "AttributeComment") ) { + aComment = SALOMEDS::AttributeComment::_narrow( anAttr ); + QString val = QString( strdup( aComment->Value() ) ); + return val; + } + return QString::null; +} + +/*! + Shows/hides IAPP sub-tree in ObjectBrowser + Current implementation just udpates browser +*/ +void QAD_ObjectBrowser::setShowIAPP( bool show ) +{ + Update(); +} + +/*! + Shows/hides info columns: Entry, IOR, Reference +*/ +void QAD_ObjectBrowser::setShowInfoColumns( bool show ) +{ + bool shown = myListView->header()->isResizeEnabled( 2 ); + if ( show != shown ) { + if ( show ) { + myListView->header()->setResizeEnabled( true, 2 ); + myListView->header()->setResizeEnabled( true, 3 ); + myListView->header()->setResizeEnabled( true, 4 ); + myListView->setColumnWidthMode( 2, QListView::Maximum ); + myListView->setColumnWidthMode( 3, QListView::Maximum ); + myListView->setColumnWidthMode( 4, QListView::Maximum ); + if ( myListView->columnWidth( 2 ) <= 0 ) + myListView->header()->resizeSection( 2, 50 ); + if ( myListView->columnWidth( 3 ) <= 0 ) + myListView->header()->resizeSection( 3, 50 ); + if ( myListView->columnWidth( 4 ) <= 0 ) + myListView->header()->resizeSection( 4, 50 ); + } + else { + myListView->setColumnWidthMode( 2, QListView::Manual ); + myListView->setColumnWidthMode( 3, QListView::Manual ); + myListView->setColumnWidthMode( 4, QListView::Manual ); + myListView->header()->resizeSection( 2, 0 ); + myListView->header()->resizeSection( 3, 0 ); + myListView->header()->resizeSection( 4, 0 ); + myListView->header()->setResizeEnabled( false, 2 ); + myListView->header()->setResizeEnabled( false, 3 ); + myListView->header()->setResizeEnabled( false, 4 ); + } + } +} + +/*! + Shows/hides Value column +*/ +void QAD_ObjectBrowser::setShowValueColumn( bool show ) +{ + bool shown = myListView->header()->isResizeEnabled( 1 ); + if ( show != shown ) { + if ( show ) { + myListView->header()->setResizeEnabled( true, 1 ); + myListView->setColumnWidthMode( 1, QListView::Maximum ); + if ( myListView->columnWidth( 1 ) <= 0 ) + myListView->header()->resizeSection( 1, 50 ); + } + else { + myListView->setColumnWidthMode( 1, QListView::Manual ); + myListView->header()->resizeSection( 1, 0 ); + myListView->header()->setResizeEnabled( false, 1 ); + } + } +} + +/*! + Sets CHRONO sorting enabled/disabled + Note: when CHRONO sorting is enabled items are sorted by Entry value and column headers + become unclickable to prohibit another sort type; + when CHRONO sorting is disabled column headers become clickable - this allows + to sort data by any column +*/ +void QAD_ObjectBrowser::setEnableChronoSort( bool enable ) +{ + if ( enable ) { + // if CHRONO sorting is enabled set clickable header disabled ... + myListView->header()->setClickEnabled( false ); + // ... and then sort by column 2 - OCAF doc entry + myListView->setSorting( 2, TRUE ) ; + } + else { + // if CHRONO sorting is enabled set clickable header enabled ... + myListView->header()->setClickEnabled( true ); + // and clear sorting by column 2 + myListView->setSorting( 10, TRUE ); + } +// myListView->sort( ) ; +} + +/*! + Slot, called to edit value +*/ +void QAD_ObjectBrowser::onEditAttribute() +{ + QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + QString ActiveComp = QAD_Application::getDesktop()->getActiveComponent(); + if ( myStudy->_is_nil() ) + return; + + if ( Sel->IObjectCount() == 1 ) { + SALOMEDS::SObject_var SO = myStudy->FindObjectID( Sel->firstIObject()->getEntry() ); + SALOMEDS::SComponent_var isComponent = SALOMEDS::SComponent::_narrow( SO ); + if ( !SO->_is_nil() && isComponent->_is_nil() ) { // no values to show for components + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeInteger_var anInt; + SALOMEDS::AttributeReal_var aReal; + SALOMEDS::AttributeTableOfInteger_var aTableInt; + SALOMEDS::AttributeTableOfReal_var aTableReal; + SALOMEDS::AttributeComment_var aComment; + bool bOk = false; + + // if Integer + if ( SO->FindAttribute( anAttr, "AttributeInteger" ) ) { + anInt = SALOMEDS::AttributeInteger::_narrow( anAttr ); + int val = SALOMEGUI_SetValueDlg::getInteger( tr( "SET_VALUE_INT_TLT" ), + tr( "SET_VALUE_INT_LBL" ), + anInt->Value(), + &bOk, + QAD_Application::getDesktop() ); + if ( bOk ) { + anInt->SetValue( val ); + } + } + // if Real + else + if ( SO->FindAttribute( anAttr, "AttributeReal" ) ) { + aReal = SALOMEDS::AttributeReal::_narrow( anAttr ); + double val = SALOMEGUI_SetValueDlg::getDouble( tr( "SET_VALUE_REAL_TLT" ), + tr( "SET_VALUE_REAL_LBL" ), + aReal->Value(), + &bOk, + QAD_Application::getDesktop() ); + if ( bOk ) { + aReal->SetValue( val ); + } + } + // if Table of integer + else + if ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) { + SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(), + SO, + true, + SALOMEGUI_TableDlg::ttInt ); + bOk = ( dlg->exec() == QDialog::Accepted ); + } + // if Table of real + else + if ( SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) { + SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(), + SO, + true, + SALOMEGUI_TableDlg::ttReal ); + bOk = ( dlg->exec() == QDialog::Accepted ); + } + // if Comment + else + if ( SO->FindAttribute(anAttr, "AttributeComment") ) { + aComment = SALOMEDS::AttributeComment::_narrow( anAttr ); + QString val = SALOMEGUI_SetValueDlg::getString( tr( "SET_VALUE_COMMENT_TLT" ), + tr( "SET_VALUE_COMMENT_LBL" ), + aComment->Value(), + &bOk, + QAD_Application::getDesktop() ); + if ( bOk ) { + aComment->SetValue( val ); + } + } + if ( bOk ) { + Update(); + } + } + } +} + +/*! + Returns true if object has editable attrubute : + integer, real, table or comment +*/ +bool QAD_ObjectBrowser::hasEditableAttribute( const Handle(SALOME_InteractiveObject)& object ) +{ + if ( !myStudy->_is_nil() ) { + SALOMEDS::SObject_var obj = myStudy->FindObjectID( object->getEntry() ); + SALOMEDS::SComponent_var comp = myStudy->FindComponentID( object->getEntry() ); + if ( !comp->_is_nil() || obj->_is_nil() ) + return false; + QString val = getValueFromObject( obj ); + return ( !val.isNull() ); + } + return false; +} + +/*! + Returns true if object has table attrubute ( integer and/or real ) +*/ +bool QAD_ObjectBrowser::hasTable( const Handle(SALOME_InteractiveObject)& object ) +{ + SALOMEDS::GenericAttribute_var anAttr; + if ( !myStudy->_is_nil() ) { + SALOMEDS::SObject_var obj = myStudy->FindObjectID( object->getEntry() ); + SALOMEDS::SComponent_var comp = myStudy->FindComponentID( object->getEntry() ); + if ( !comp->_is_nil() || obj->_is_nil() ) + return false; + if ( obj->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) + return true; + if ( obj->FindAttribute( anAttr, "AttributeTableOfReal" ) ) + return true; + } + return false; +} + +/*! + Slot, called when one of the UseCase Browser menu command is called +*/ +void QAD_ObjectBrowser::onUseCasePopupMenu( int action ) +{ + if ( myStudy->_is_nil() ) + return; + QAD_Desktop* Desktop = (QAD_Desktop*) QAD_Application::getDesktop(); + QAD_Study* myActiveStudy = Desktop->getActiveStudy(); + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SALOMEDS::UseCaseBuilder_var UCBuilder = myStudy->GetUseCaseBuilder(); + SALOMEDS::SObject_var Current = UCBuilder->GetCurrentObject(); + + QList ucSelected; + ucSelected.setAutoDelete( false ); + getSelectedParents( myUseCaseView, ucSelected ); + + if ( action == UC_NEW_EMPTY_ID ) { + if ( ucSelected.count() == 1 ) { + if ( isRootItem( ucSelected.at(0) ) ) + UCBuilder->SetRootCurrent(); + else + UCBuilder->SetCurrentObject( myStudy->FindObjectID( (( QAD_ObjectBrowserItem* )( ucSelected.at(0) ))->getEntry() ) ); + UCBuilder->AddUseCase( tr( "NEW_OBJECT" ) ); + myActiveStudy->updateUseCaseBrowser(); + } + } + else + if ( action == UC_SET_CURRENT_ID ) { + if ( ucSelected.count() > 0 ) { + if ( isRootItem( ucSelected.at(0) ) ) + UCBuilder->SetRootCurrent(); + else + UCBuilder->SetCurrentObject( myStudy->FindObjectID( (( QAD_ObjectBrowserItem* )( ucSelected.at(0) ))->getEntry() ) ); + } + myActiveStudy->updateUseCaseBrowser( ); + } + else + if ( action == UC_RENAME_ID ) { + 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() ) ); + if ( !name.isEmpty() ) { + bool ok = UCBuilder->SetName( strdup( 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() ) ); + if ( !name.isEmpty() ) { + myActiveStudy->renameIObject( Sel->firstIObject(), name ); + } + } + } + } + else + if ( action == UC_APPEND_ID ) { + if ( Sel->IObjectCount() > 0 ) { + SALOME_ListIO SelIO; SelIO = Sel->StoredIObjects(); + SALOME_ListIteratorOfListIO SelIt( SelIO ); + for( ; SelIt.More(); SelIt.Next() ) { + SALOMEDS::SObject_var selSO = myStudy->FindObjectID( SelIt.Value()->getEntry() ); + if ( !selSO->_is_nil() && strcmp( SelIt.Value()->getEntry(), ( "0:2" ) ) != 0 ) { + UCBuilder->Remove( selSO ); // first remove object for sure ... + UCBuilder->Append( selSO ); // ... and now re-append it + } + } + myActiveStudy->updateUseCaseBrowser( true ); + } + } + else + if ( action == UC_REMOVE_ID ) { + ucSelected.clear(); + getSelectedParents( myUseCaseView, ucSelected, true ); + for ( int i = 0; i < ucSelected.count(); i++ ) { + QAD_ObjectBrowserItem* item = ( QAD_ObjectBrowserItem* )ucSelected.at( i ); + if ( !isRootItem( item ) ) { + // SObject selected + SALOMEDS::SObject_var SO = myStudy->FindObjectID( item->getEntry() ); + if ( !SO->_is_nil() ) { + UCBuilder->Remove( SO ); + } + } + else { + } + } + Sel->ClearIObjects(); + myActiveStudy->updateUseCaseBrowser( true ); + } + else + if ( action == UC_CLEAR_ID ) { + if ( myUseCaseView->childCount() > 0 && myUseCaseView->firstChild()->childCount() > 0) { + QAD_ObjectBrowserItem* child = ( QAD_ObjectBrowserItem* )myUseCaseView->firstChild()->firstChild(); + while ( child ) { + UCBuilder->Remove( myStudy->FindObjectID( child->getEntry().latin1() ) ); + child = ( QAD_ObjectBrowserItem* )( child->nextSibling() ); + } + Sel->ClearIObjects(); + myActiveStudy->updateUseCaseBrowser(); + } + } +} +/*! + Use Case browser buttons slot +*/ +void QAD_ObjectBrowser::onUseCaseBtn() +{ + 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(); + } + if ( sender() == myAddBtn ) + onUseCasePopupMenu( UC_APPEND_ID ); + if ( sender() == myDelBtn ) + onUseCasePopupMenu( UC_REMOVE_ID ); + if ( sender() == myClearBtn ) + onUseCasePopupMenu( UC_CLEAR_ID ); + if ( sender() == myCurrentBtn ) + onUseCasePopupMenu( UC_SET_CURRENT_ID ); +} diff --git a/src/SALOMEGUI/QAD_ObjectBrowser.h b/src/SALOMEGUI/QAD_ObjectBrowser.h new file mode 100644 index 000000000..bfa849bed --- /dev/null +++ b/src/SALOMEGUI/QAD_ObjectBrowser.h @@ -0,0 +1,126 @@ +// File : QAD_ObjectBrowser.h +// Created : Thu Jun 14 15:40:24 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_OBJECTBROWSER_H +#define QAD_OBJECTBROWSER_H + +#include "QAD.h" +#include "QAD_Popup.h" + +#include "SALOME_InteractiveObject.hxx" + +// QT Includes +#include +#include +#include +#include +#include +#include + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +class QListViewItem; +class QListView; +class QAD_ObjectBrowserItem; +typedef QList ItemList; +typedef QMap ItemMap; + +class QAD_EXPORT QAD_ObjectBrowser : public QTabWidget, public QAD_PopupClientServer +{ + Q_OBJECT + +public: + QAD_ObjectBrowser( SALOMEDS::Study_var study, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + virtual ~QAD_ObjectBrowser(); + + bool eventFilter( QObject* o, QEvent* e ); + + void setupListView(); + /* popup management */ + void onCreatePopup(); + + QListView* getListView() const; + QListView* getUseCaseView() const; + + void Update(); + void UpdateUseCaseBrowser(); + + void unHighlightAll(); + void highlight( const Handle(SALOME_InteractiveObject)& IObject, bool highlight ); + bool getItems( const Handle(SALOME_InteractiveObject)& IObject, + QList& List); + bool getItems( SALOMEDS::SObject_ptr SO, + QList& List); + QAD_ObjectBrowserItem* getItem( const Handle(SALOME_InteractiveObject)& IObject ); + QAD_ObjectBrowserItem* getItem( SALOMEDS::SObject_ptr SO ); + QAD_ObjectBrowserItem* getUCItem( const Handle(SALOME_InteractiveObject)& IObject ); + QAD_ObjectBrowserItem* getUCItem( SALOMEDS::SObject_ptr SO ); + void rename( const Handle(SALOME_InteractiveObject)& IObject, QString newName ); + + void setShowIAPP( bool show ); + void setShowInfoColumns( bool show ); + void setShowValueColumn( bool show ); + void setEnableChronoSort( bool enable ); + +protected: + void Update( SALOMEDS::SObject_ptr SO, + QAD_ObjectBrowserItem* theParentItem ); + void UpdateUCItem( SALOMEDS::SObject_var UCObject, + QAD_ObjectBrowserItem* UCItem ); + QAD_ObjectBrowserItem* AddItem( QListView* theView, + const QString& theName, + const QString& theEntry, + const QString& theIOR, + int theType, + const QString& theValue, + QAD_ObjectBrowserItem* theAfter = 0 ); + QAD_ObjectBrowserItem* AddItem( QAD_ObjectBrowserItem* theParentItem, + const QString& theName, + const QString& theEntry, + const QString& theIOR, + int theType, + const QString& theRef, + const QString& theValue, + QAD_ObjectBrowserItem* theAfter = 0 ); + QString getValueFromObject( SALOMEDS::SObject_ptr SO ); + bool hasEditableAttribute( const Handle(SALOME_InteractiveObject)& object ); + bool hasTable( const Handle(SALOME_InteractiveObject)& object ); + +protected slots: + void onSelectedItem(); + void onUseCaseSelectedItem(); + void onEditAttribute(); + + void showPopupMenu(QListViewItem*); + void showUseCasePopupMenu(QListViewItem*); + + void onExpanded (QListViewItem*); + void onCollapsed(QListViewItem*); + void onUseCasePopupMenu( int ); + + void onUseCaseBtn(); + +private: + ItemMap myListViewMap; + ItemMap myUseCaseMap; + QListView* myListView; + QListView* myUseCaseView; + QPopupMenu* myPopupMenu; + SALOMEDS::Study_ptr myStudy; + QToolButton* myNewBtn; + QToolButton* myAddBtn; + QToolButton* myDelBtn; + QToolButton* myCurrentBtn; + QToolButton* myRenameBtn; + QToolButton* myClearBtn; +}; + +#endif diff --git a/src/SALOMEGUI/QAD_ObjectBrowserItem.cxx b/src/SALOMEGUI/QAD_ObjectBrowserItem.cxx new file mode 100644 index 000000000..ff9b506bb --- /dev/null +++ b/src/SALOMEGUI/QAD_ObjectBrowserItem.cxx @@ -0,0 +1,257 @@ +using namespace std; +// File : QAD_ObjectBrowserItem.cxx +// Created : Thu Jun 14 17:07:42 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "QAD_ObjectBrowserItem.h" + +#include +#include +#include +#include +#include + +/*! + Constructors +*/ +QAD_ObjectBrowserItem::QAD_ObjectBrowserItem( QListView *theParent ) + : QListViewItem(theParent) +{ + myType = BlackItem; + myCurrent = false; +} +QAD_ObjectBrowserItem::QAD_ObjectBrowserItem( QListView* theParent, QAD_ObjectBrowserItem* after ) + : QListViewItem(theParent, after) +{ + myType = BlackItem; + myCurrent = false; +} +QAD_ObjectBrowserItem::QAD_ObjectBrowserItem( QAD_ObjectBrowserItem *theParent ) + : QListViewItem(theParent) +{ + myType = BlackItem; + myCurrent = false; +} +QAD_ObjectBrowserItem::QAD_ObjectBrowserItem( QAD_ObjectBrowserItem *theParent, QAD_ObjectBrowserItem* after ) + : QListViewItem(theParent, after) +{ + myType = BlackItem; + myCurrent = false; +} + +/*! + Destructor +*/ +QAD_ObjectBrowserItem::~QAD_ObjectBrowserItem() +{ +} + +/*! + Sets type +*/ +void QAD_ObjectBrowserItem::setType( int type ) +{ + myType = type; + repaint(); +} + +/*! + Sets text color +*/ +void QAD_ObjectBrowserItem::setTextColor( const QColor& color ) +{ + myTextColor = color; + repaint(); +} + +/*! + Sets text highlight color +*/ +void QAD_ObjectBrowserItem::setTextHighlightColor(const QColor& color) +{ + myTextHighlightColor = color; +} + +/*! + Gets item name +*/ +QString QAD_ObjectBrowserItem::getName() const +{ + return QListViewItem::text( 0 ); +} + +/*! + Sets name +*/ +void QAD_ObjectBrowserItem::setName( const QString& name ) +{ + setText( 0, name ); +} + +/*! + Gets value +*/ +QString QAD_ObjectBrowserItem::getValue() const +{ + return QListViewItem::text( 1 ); +} + +/*! + Sets value +*/ +void QAD_ObjectBrowserItem::setValue( const QString& value ) +{ + setText( 1, value ); +} + +/*! + Gets entry +*/ +QString QAD_ObjectBrowserItem::getEntry() const +{ + return QListViewItem::text( 2 ); +} + +/*! + Sets entry +*/ +void QAD_ObjectBrowserItem::setEntry( const QString& entry ) +{ + setText( 2, entry ); +} + +/*! + Gets IOR +*/ +QString QAD_ObjectBrowserItem::getIOR() const +{ + return QListViewItem::text( 3 ); +} + +/*! + Sets IOR +*/ + void QAD_ObjectBrowserItem::setIOR( const QString& IOR ) +{ + setText( 3, IOR ); +} + +/*! + Gets reference +*/ +QString QAD_ObjectBrowserItem::getReference() const +{ + return QListViewItem::text( 4 ); +} + +/*! + Sets reference +*/ +void QAD_ObjectBrowserItem::setReference( const QString& ref ) +{ + setText( 4, ref ); +} +/*! + Returns true if this item is current (for UseCase browser - it is bold) +*/ +bool QAD_ObjectBrowserItem::isCurrent() const +{ + return myCurrent; +} +/*! + Sets this item to be current (for UseCase browser - it is bold) +*/ +void QAD_ObjectBrowserItem::setCurrent( bool on ) +{ + myCurrent = on; + repaint(); +} + +/*! + Paints cell [ redefined ] +*/ +void QAD_ObjectBrowserItem::paintCell( QPainter* thePainter, + const QColorGroup& theColorGroup, + int theColumn, + int theWidth, + int theAlignment ) +{ + QColorGroup aColorGroup(theColorGroup); + QColor aColor = aColorGroup.text(); + QColor aColorHighlight = aColorGroup.highlight(); + + switch (myType) + { + case 1 : + { + aColorGroup.setColor(QColorGroup::Text, Qt::blue); + aColorGroup.setColor(QColorGroup::Highlight, Qt::blue); + break; + } + case 2 : + { + aColorGroup.setColor(QColorGroup::Text, Qt::red); + aColorGroup.setColor(QColorGroup::Highlight, Qt::red); + break; + } + default : + { + aColorGroup.setColor(QColorGroup::Text, Qt::black); + aColorGroup.setColor(QColorGroup::Highlight, Qt::black); + break; + } + } + + if (myTextColor.isValid()) + aColorGroup.setColor(QColorGroup::Text, myTextColor); + if (myTextHighlightColor.isValid()) + aColorGroup.setColor(QColorGroup::Highlight, myTextHighlightColor); + if (myCurrent) { // UseCase's current entry + QFont font = thePainter->font(); + font.setBold(true); + thePainter->setFont(font); + } + + QListViewItem::paintCell(thePainter, + aColorGroup, + theColumn, + theWidth, + theAlignment); + aColorGroup.setColor(QColorGroup::Text, aColor); + aColorGroup.setColor(QColorGroup::Highlight, aColorHighlight); +} + +/*! + Returns item's column text + Overrided to protect access outside +*/ +QString QAD_ObjectBrowserItem::text( int column ) const +{ + return QListViewItem::text( column ); +} + +/*! + Compares two item to sort list view data by column +*/ +int QAD_ObjectBrowserItem::compare( QListViewItem* i, int col, bool ascending ) const +{ + // Additional check is necessary for Entry or Reference entry (2 and 4) columns + if ( ( col == 2 || col == 4 ) && !key( col, ascending ).isEmpty() && !i->key( col, ascending ).isEmpty() ) { + QStringList mylist = QStringList::split( ":", key( col, ascending ), false ); + QStringList ilist = QStringList::split( ":", i->key( col, ascending ), false ); + if ( mylist.count() != ilist.count() || mylist.count() == 0 ) + return ( mylist.count() < ilist.count() ) ? -1 : 1; + for ( int i = 0; i < mylist.count(); i++ ) { + if ( mylist[i].toInt() < ilist[i].toInt() ) + return -1; + else if ( mylist[i].toInt() > ilist[i].toInt() ) + return 1; + } + return 0; + } + return QListViewItem::compare( i, col, ascending ); +} diff --git a/src/SALOMEGUI/QAD_ObjectBrowserItem.h b/src/SALOMEGUI/QAD_ObjectBrowserItem.h new file mode 100644 index 000000000..057e9735d --- /dev/null +++ b/src/SALOMEGUI/QAD_ObjectBrowserItem.h @@ -0,0 +1,66 @@ +// File : QAD_ObjectBrowserItem.h +// Created : Thu Jun 14 17:06:54 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_OBJECTBROWSERITEM_H +#define QAD_OBJECTBROWSERITEM_H + +#include +#include + +class QPainter; +class QColorGroup; + +class QAD_ObjectBrowserItem : public QListViewItem +{ + friend class QListView; + +public: + QAD_ObjectBrowserItem( QListView* theParent ); + QAD_ObjectBrowserItem( QListView* theParent, QAD_ObjectBrowserItem* after ); + QAD_ObjectBrowserItem( QAD_ObjectBrowserItem* theParent ); + QAD_ObjectBrowserItem( QAD_ObjectBrowserItem* theParent, QAD_ObjectBrowserItem* after ); + virtual ~QAD_ObjectBrowserItem(); + + void setType( int type ); + void setTextColor( const QColor& color ); + void setTextHighlightColor( const QColor& color ); + + QString getName() const; + void setName( const QString& name ); + QString getValue() const; + void setValue( const QString& value ); + QString getEntry() const; + void setEntry( const QString& entry ); + QString getIOR() const; + void setIOR( const QString& IOR ); + QString getReference() const; + void setReference( const QString& ref ); + + bool isCurrent() const; + void setCurrent( bool on ); + + int compare( QListViewItem* i, int col, bool ascending ) const; + +protected: + enum { BlackItem = 0, BlueItem, RedItem }; + int myType; + QColor myTextColor; + QColor myTextHighlightColor; + bool myCurrent; + + void paintCell( QPainter*, const QColorGroup &, int, int, int ); + QString text( int column ) const; +}; + +#endif + + + + + + diff --git a/src/SALOMEGUI/QAD_Operation.cxx b/src/SALOMEGUI/QAD_Operation.cxx new file mode 100644 index 000000000..66bc0ce5e --- /dev/null +++ b/src/SALOMEGUI/QAD_Operation.cxx @@ -0,0 +1,182 @@ +using namespace std; +// File : QAD_Operation.cxx +// Created : UI team, 22.09.00 +// Descrip : Base class for operations in QAD-based application +// Author : UI team +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + +/*! + \class QAD_Operation QAD_Operation.h + \brief Base class for OCAF operations in QAD-based application. +*/ + +#include "QAD.h" +#include "QAD_Operation.h" +#include "QAD_Study.h" +#include "QAD_Application.h" + +// QT Include +#include + +/*! + Constructor +*/ +QAD_Operation::QAD_Operation (QAD_Study* doc) : +myDoc ( doc ) +{ + /* this class is useless without valid doc */ + QAD_ASSERT_DEBUG_ONLY( myDoc ); +} + +/*! + Destructor +*/ +QAD_Operation::~QAD_Operation () +{ +} + +/*! + Returns reference to the document +*/ +QAD_Study* QAD_Operation::getDoc() const +{ + return myDoc; +} + +/*! + Returns reference to the application +*/ +QAD_Application* QAD_Operation::getApp() const +{ + return myDoc->getApp(); +} + +/*! + Checks compatibility with the other launched operations. + Returns \true if appointed operation can be performed. + By default returns \false for all operations. +*/ +bool QAD_Operation::compatibleWith( QAD_Operation* op ) const +{ + return false; +} + +/*! + Returns true if operation can be aborted by pressing "Escape" key + (default behaviour). +*/ +bool QAD_Operation::supportCancelByEscape() const +{ + return true; +} + +/*! + Returns true if operation changes document data. In this case it won't be + launched if document is opened as "read only". Value by default is true. +*/ +bool QAD_Operation::changesData() const +{ + return true; +} + +/*! + Starts this operation. +*/ +bool QAD_Operation::start() +{ + /* open transaction */ + if ( !myDoc->onOperationStarted( this ) ) + return false; + + /* started OK */ + onStartOperation(); + return true; +} + +/*! + Called after operation started. Does nothing by default. + Override to set a desired behaviour. +*/ +void QAD_Operation::onStartOperation() +{ +} + +/*! + Ends the operation. +*/ +void QAD_Operation::finish() +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + + onFinishOperation(); /* customization */ + myDoc->onOperationFinished( this ); /* close transaction */ + + QApplication::restoreOverrideCursor(); +} + +/*! + Called after operation finished. Does nothing by default. + Override to set a desired behaviour. +*/ +void QAD_Operation::onFinishOperation() +{ +} + +/*! + Suspends operation process when the document is deactivated. +*/ +void QAD_Operation::suspend() +{ + onSuspendOperation(); /* customization */ + myDoc->onOperationSuspended( this ); /* notification */ +} + +/*! + Called after operation suspended. Does nothing by default. + Override to set a desired behaviour. +*/ +void QAD_Operation::onSuspendOperation() +{ +} + +/*! + Resumes operation performing process when the document became active + (if the operation wasn't aborted earlier). +*/ +void QAD_Operation::resume() +{ + onResumeOperation(); /* customization */ + myDoc->onOperationResumed( this ); /* notification */ +} + +/*! + Called after operation resumed. Does nothing by default. + Override to set a desired behaviour. +*/ +void QAD_Operation::onResumeOperation() +{ +} + +/*! + Cancels operation performing process without ending. +*/ +void QAD_Operation::abort() +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + + onAbortOperation(); /* customization */ + myDoc->onOperationAborted( this ); /* abort transaction */ + + QApplication::restoreOverrideCursor(); +} + +/*! + Called after operation aborted. Does nothing by default. + Override to set a desired behaviour. +*/ +void QAD_Operation::onAbortOperation() +{ +} diff --git a/src/SALOMEGUI/QAD_Operation.h b/src/SALOMEGUI/QAD_Operation.h new file mode 100644 index 000000000..9a9e3dd39 --- /dev/null +++ b/src/SALOMEGUI/QAD_Operation.h @@ -0,0 +1,59 @@ +// File : QAD_Operation.h +// Created : UI team, 22.09.00 +// Author : UI team +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + + +#ifndef QAD_Operation_H +#define QAD_Operation_H + +#include "QAD.h" +#include + +class QAD_Study; +class QAD_Application; + +enum OperationState { + Undef, Started, Finished, Suspended, Resumed, + Aborted +}; + +class QAD_EXPORT QAD_Operation : public QObject +{ + Q_OBJECT + +public: + QAD_Operation( QAD_Study* aDoc ); + ~QAD_Operation(); + +public: + QAD_Study* getDoc() const; + QAD_Application* getApp() const; + + bool start(); + void finish(); + void suspend(); + void resume(); + void abort(); + + virtual bool changesData() const; + virtual bool supportCancelByEscape() const; + virtual bool compatibleWith( QAD_Operation* ) const; + +protected: + /* customization */ + virtual void onStartOperation(); + virtual void onFinishOperation(); + virtual void onSuspendOperation(); + virtual void onResumeOperation(); + virtual void onAbortOperation(); + +protected: + QAD_Study* myDoc; +}; + +#endif + diff --git a/src/SALOMEGUI/QAD_OperatorMenus.cxx b/src/SALOMEGUI/QAD_OperatorMenus.cxx new file mode 100644 index 000000000..ab7da0db3 --- /dev/null +++ b/src/SALOMEGUI/QAD_OperatorMenus.cxx @@ -0,0 +1,111 @@ +using namespace std; +// File : QAD_OperatorMenus.cxx +// Created : Thu Jun 14 14:37:17 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "QAD_OperatorMenus.h" +#include "QAD_Desktop.h" + +/*! + Constructor. +*/ +QAD_OperatorMenus::QAD_OperatorMenus(QAD_Desktop* theDesktop) +{ + myDesktop=theDesktop; +} + +/*! + Destructor. +*/ +QAD_OperatorMenus::~QAD_OperatorMenus() +{ +} + +/*! + Builds popup menu with a 'Context', a 'Parent' and an 'Object'. + Parent is equal to 'Objectbrowser' or 'Viewer'. +*/ +QAD_ListPopupMenu* QAD_OperatorMenus::createPopupMenu(const QString & theContext, + const QString & theParent, + const QString & theObject) +{ + QAD_Menus* aMenus = myDesktop->getActiveMenus(); + QAD_ListPopupMenu* aPopup; + + QList PopupList = aMenus->getPopupMenuList(); + + for(aPopup=PopupList.first();aPopup!=NULL;aPopup=PopupList.next()){ + if ((aPopup->getContext().compare(theContext)==0) && + (aPopup->getParent().compare(theParent)==0) && + (aPopup->getObject().compare(theObject)==0)) { + return aPopup; + } + } + return NULL; +} + +QAD_ListPopupMenu* QAD_OperatorMenus::createPopupMenu(int thePopupMenuId) +{ + QAD_Menus* aMenus = myDesktop->getActiveMenus(); + + if(!aMenus->getPopupMenuList().isEmpty() && + aMenus->getPopupMenuList().at(thePopupMenuId)!=NULL) { + return aMenus->getPopupMenuList().at(thePopupMenuId); + } else + return NULL; +} + +void QAD_OperatorMenus::showMenuBar(int theMenuBarId) + +{ + QAD_Menus* aMenus = myDesktop->getActiveMenus(); + if(!aMenus->getMenuBarList().isEmpty() && + aMenus->getMenuBarList().at(theMenuBarId)!=NULL) { + aMenus->getMenuBarList().at(theMenuBarId)->show(); + } +} + +void QAD_OperatorMenus::hideMenuBar(int theMenuBarId) + +{ + QAD_Menus* aMenus; + aMenus=myDesktop->getActiveMenus(); + if(!aMenus->getMenuBarList().isEmpty() && + aMenus->getMenuBarList().at(theMenuBarId)!=NULL) { + aMenus->getMenuBarList().at(theMenuBarId)->hide(); + } +} + +void QAD_OperatorMenus::showToolBar(int theToolBarId) + +{ + QAD_Menus* aMenus; + + aMenus=myDesktop->getActiveMenus(); + if(!aMenus->getToolBarList().isEmpty() && + aMenus->getToolBarList().at(theToolBarId)!=NULL) { + aMenus->getToolBarList().at(theToolBarId)->show(); + } +} + +void QAD_OperatorMenus::hideToolBar(int theToolBarId) + +{ + QAD_Menus* aMenus; + + aMenus=myDesktop->getActiveMenus(); + if(!aMenus->getToolBarList().isEmpty() && + aMenus->getToolBarList().at(theToolBarId)!=NULL) { + aMenus->getToolBarList().at(theToolBarId)->hide(); + } +} + + + + + + diff --git a/src/SALOMEGUI/QAD_OperatorMenus.h b/src/SALOMEGUI/QAD_OperatorMenus.h new file mode 100644 index 000000000..35197a8f6 --- /dev/null +++ b/src/SALOMEGUI/QAD_OperatorMenus.h @@ -0,0 +1,35 @@ +// File : QAD_OperatorMenus.h +// Created : Thu Jun 14 14:38:48 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_OPERATOR_MENUS_H +#define QAD_OPERATOR_MENUS_H + +#include "QAD_ListPopupMenu.h" + +class QAD_Desktop; + +class QAD_OperatorMenus +{ +public: + QAD_OperatorMenus(QAD_Desktop *); + virtual ~QAD_OperatorMenus(); + + QAD_Desktop* myDesktop; + QAD_ListPopupMenu* createPopupMenu(int); + QAD_ListPopupMenu* createPopupMenu(const QString & theContext, + const QString & theParent, + const QString & theObject); + + void showMenuBar(int); + void hideMenuBar(int); + void showToolBar(int); + void hideToolBar(int); +}; + +#endif + diff --git a/src/SALOMEGUI/QAD_ParserSettings.cxx b/src/SALOMEGUI/QAD_ParserSettings.cxx new file mode 100644 index 000000000..4735c68e2 --- /dev/null +++ b/src/SALOMEGUI/QAD_ParserSettings.cxx @@ -0,0 +1,325 @@ +using namespace std; +// File : QAD_ParserSettings.cxx +// Created : Sat Sep 08 22:00:08 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + + +#include "QAD_ParserSettings.h" + +#include + +// QT Includes +#include +#include +#include + + +/*! + Constructor. +*/ +QAD_ParserSettings::QAD_ParserSettings() +{ +} + + +/*! + Destructor. +*/ +QAD_ParserSettings::~QAD_ParserSettings() +{ +} + + +/*! + Gets the contents of a file. +*/ +QString QAD_ParserSettings::getContents(QString fileName, bool comments, + bool sections, bool whiteSpace, + bool htmlComments) +{ + QFileInfo fi(fileName); + QFile f(fi.absFilePath()); + QString s=""; // Buffer for the whole file + + if(f.open(IO_ReadOnly)) { // file opened successfully + QTextStream t(&f); // use a text stream + + s = t.read(); // The whole file in a string + f.close(); + + if(!comments) s = QAD_ParserSettings::removeComments(s); + if(!sections) s = QAD_ParserSettings::removeSections(s); + if(!whiteSpace) s = s.simplifyWhiteSpace(); + if(!htmlComments) s = QAD_ParserSettings::removeHtmlComments(s); + } + else { + // Can't open file + } + + return s; +} + + +/*! + Gets the body of a section from a string. +*/ +QString QAD_ParserSettings::getSection(QString s, QString sectionName) +{ + QString result=""; + + QChar ch; // A single byte of the file + int bracketCounter=1; // Bracket counter (increase on '{' and decrese on '}'. + int i; // Current index + int l=0; // Length of current part we must have + + if((i=s.find(sectionName, 0, false)) >= 0 && // Jump to section [styles] + (i=s.find('{', i)) >= 0 ) { + + ++i; + + while(i+l<(int)s.length()) { + ch = s.at(i+l); // Single byte + + ++l; + + if(ch=='{') ++bracketCounter; + if(ch=='}') --bracketCounter; + + if(bracketCounter==0) break; + } + + result = s.mid(i, l-1); + } + + return result; +} + + + +/*! + Gets the HTML comments out of a file. +*/ +QString QAD_ParserSettings::getHtmlComment(QString s) +{ + QString result=""; + int length; // length of the sub string + int ind=0; + + if((ind =s.find("", ind)-ind)!=0) { + + result=s.mid(ind, length-3); + } + + return result; +} + + + +/*! + Gets the next String between two given characters. The index-parameter gets moved to the character after + the stopper or to -1 if the starter / stopper were not found. +*/ +QString QAD_ParserSettings::getNextStringBetween(QString s, int& startIndex, + QChar starter, QChar stopper) +{ + QString result=""; + int length=0; // length of the sub string + + if((startIndex =s.find(starter, startIndex))>=0 && + (length=s.find(stopper, startIndex+1)-startIndex)!=0) { + + result=s.mid(startIndex+1, length-1); + startIndex+=2; + } + + return result; +} + + +/*! + Gets the next String between the given index and a given stopper character. The index-parameter gets moved to + the character after the stopper or to -1 if the stopper was not found. +*/ +QString QAD_ParserSettings::getNextStringUntil(QString s, int& startIndex, QChar stopper) +{ + QString result=""; + int length; // length of the sub string + + if((length=s.find(stopper, startIndex)-startIndex)!=0) { + result=s.mid(startIndex, length); + startIndex++; + } + + return result; +} + + +/*! + Removes all comments (between '/ *' and '* /'). +*/ +QString QAD_ParserSettings::removeComments(QString s) +{ + QString result=""; + int i1=0, i2; + + while((i2=s.find("/*", i1))>=0) { + result += s.mid(i1, i2-i1); + + i1+=2; + i1=s.find("*/", i1); + i1+=2; + } + + result += s.mid(i1, s.length()-i1); + + return result; +} + + + +/*! + Removes all HTML comments (between ''). +*/ +QString QAD_ParserSettings::removeHtmlComments(QString s) +{ + QString result=""; + int i1=0, i2; + + while((i2=s.find("", i1); + i1+=3; + } + + result += s.mid(i1, s.length()-i1); + + return result; +} + + + +/*! + Removes all sections ('[section] { }'). +*/ +QString QAD_ParserSettings::removeSections(QString s) +{ + QString result=""; + + QChar ch; // A single byte of the file + int bracketCounter; // Bracket counter (increase on '{' and decrese on '}'. + int i=0; // Current index + + while(i<(int)s.length()) { + ch = s.at(i); // Single byte + + if(ch=='[') { + bracketCounter=1; + while(i<(int)s.length() && ch!=']') { ch = s.at(i); ++i; } + ++i; + while(i<(int)s.length() && ch!='{') { ch = s.at(i); ++i; } + ++i; + + while(i<(int)s.length() && bracketCounter!=0) { + ch = s.at(i); + if(ch=='{') ++bracketCounter; + if(ch=='}') --bracketCounter; + ++i; + } + ++i; + } + else { + result+=ch; + } + + ++i; + } + + return result; +} + + +/*! + Format plain text into HTML-code with a given maximal width. + Spaces get replaced with non breaking spaces. Tabulators get filled up + with non breaking spaces. +*/ +QString QAD_ParserSettings::plainTextToHtml(QString s, int autoBreak) +{ + QString result="\n"; + + if(!s.isEmpty()) { + int col=1, i; + + for(i=0; i<(int)s.length(); ++i) { + // Line feed: + // + if(s[i]=='\n') { + result+="
\n"; + col=1; + } + + // Auto break: + // + else if(col==autoBreak && autoBreak!=0) { + result+="
\n"; + result+=s[i]; + col=1; + } + + // Tab: + // + else if(s[i]=='\t') { + while(col%8!=0) { result+=" "; ++col; } + result+=" "; + ++col; + } + + // Space: + // + else if(s[i]==' ') { + result+=" "; + ++col; + } + + // Normal char / special code: + // + else { + if(s[i].isLetter() || s[i].isNumber()) { + result+=s[i]; + } + else { + result+=charToHtml(s[i]); + } + ++col; + } + } + + result+="\n"; + } + + return result; +} + + +/*! + Converts a special character to html code (e.g.: '»' to "»") +*/ +QString QAD_ParserSettings::charToHtml(QChar c) +{ + QString s; + QString uc; + uc.setNum(c.unicode()); + s = "&#" + uc + ";"; + return s; +} + + +// EOF diff --git a/src/SALOMEGUI/QAD_ParserSettings.h b/src/SALOMEGUI/QAD_ParserSettings.h new file mode 100644 index 000000000..e495b33e7 --- /dev/null +++ b/src/SALOMEGUI/QAD_ParserSettings.h @@ -0,0 +1,35 @@ +// File : QAD_ParserSettings.h +// Created : Sat Sep 08 21:58:39 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_PARSERSETTINGS_H +#define QAD_PARSERSETTINGS_H + +#include + +class QAD_ParserSettings +{ +public: + QAD_ParserSettings(); + ~QAD_ParserSettings(); + + static QString getContents(QString fileName, bool comments=true, + bool sections=true, bool whitespace=true, + bool htmlComments=true); + static QString getSection(QString s, QString sectionName); + static QString getHtmlComment(QString s); + static QString getNextStringBetween(QString s, int& startIndex, QChar starter, QChar stopper); + static QString getNextStringUntil(QString s, int& startIndex, QChar stopper); + static QString removeComments(QString s); + static QString removeHtmlComments(QString s); + static QString removeSections(QString s); + static QString plainTextToHtml(QString s, int autoBreak); + static QString charToHtml(QChar c); + +}; + +#endif diff --git a/src/SALOMEGUI/QAD_Popup.cxx b/src/SALOMEGUI/QAD_Popup.cxx new file mode 100644 index 000000000..92771b403 --- /dev/null +++ b/src/SALOMEGUI/QAD_Popup.cxx @@ -0,0 +1,213 @@ +using namespace std; +// File : QAD_Popup.cxx +// Created : 22.09.00 +// Descr : Popup menu management + +// Author : UI team +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "QAD.h" +#include "QAD_Popup.h" +#include "utilities.h" + +/***************************************************************************** +** Class QAD_PopupClientServer +*****************************************************************************/ + +/*! + Constructor +*/ +QAD_PopupServer::QAD_PopupServer() : +myPopup( NULL ), +myEnablePopup( true ) +{ +} + +/*! + Enables/disables creation of popup. + Useful when user doesn't want to create popup + provided by server by default and does not + want to inherit from the server +*/ +void QAD_PopupServer::enablePopup( bool enable ) +{ + myEnablePopup = enable; +} + +/*! + Called by popup client when it wants + to activate popup +*/ +QPopupMenu* QAD_PopupServer::createPopup() +{ + if ( !myEnablePopup ) + return 0; + + if ( !myPopup ) + myPopup = new QPopupMenu; + onCreatePopup(); /* add specific menu items */ + return myPopup; +} + +/*! + Called by popup client when popup + is deactivated. +*/ +void QAD_PopupServer::destroyPopup() +{ + if ( myPopup ) myPopup->clear(); +} + +/*! + Destructor +*/ +QAD_PopupServer::~QAD_PopupServer() +{ + delete (QPopupMenu*) myPopup; +} + +/***************************************************************************** +** Class QAD_PopupClient +*****************************************************************************/ + +/*! + Constructor +*/ +QAD_PopupClient::QAD_PopupClient() : +myPopupServer( 0 ) +{ +} + +/*! + Destructor +*/ +QAD_PopupClient::~QAD_PopupClient() +{ +} + +/*! + Sets a popup server for this client +*/ +void QAD_PopupClient::setPopupServer ( QAD_PopupServer* server) +{ + myPopupServer = server; +} + +/*! + Returns the popup server for this client +*/ +QAD_PopupServer* QAD_PopupClient::getPopupServer () const +{ + return myPopupServer; +} + +/***************************************************************************** +** Class QAD_PopupClientServer +*****************************************************************************/ + +/*! + Constructor +*/ +QAD_PopupClientServer::QAD_PopupClientServer( bool separateItems, bool smartSeparator ) : + myOnlyServer( false ), + mySeparateItems( separateItems ), + mySmartSeparator( smartSeparator ) +{ +} + +/*! + Destructor +*/ +QAD_PopupClientServer::~QAD_PopupClientServer() +{ +} + +/*! + Called by popup client when it wants + to activate popup. The result is the + popup returned by this object's server + ( client role ) + the appended popup + provided by itself ( server role ). +*/ +QPopupMenu* QAD_PopupClientServer::createPopup() +{ + if ( !myEnablePopup ) + return 0; + + QPopupMenu* popupMenu = 0; + if ( myPopupServer ) + { /* get the popup provided by my server */ + popupMenu = myPopupServer->createPopup(); + } + + if ( !popupMenu ) + { /* there is no popup from my server */ + if ( !myPopup ) myPopup = new QPopupMenu; + popupMenu = myPopup; + myOnlyServer = true; + } + else + { + if ( myPopup ) myPopup->clear(); + myPopup = popupMenu; + myOnlyServer = false; + } + + /* Attach my popup to the popup of my server */ + if ( popupMenu->count() && mySeparateItems ) + { + /* Separate my items only if I will really + add some items + */ + int sepId, numBefore, numAfter; + sepId = mySmartSeparator ? popupMenu->insertSeparator(0) : popupMenu->insertSeparator(); + numBefore = popupMenu->count(); + int sepPosBefore = mySmartSeparator ? 0 : numBefore - 1; + + /* add items */ + onCreatePopup(); + + numAfter = popupMenu->count(); + int sepPosAfter = popupMenu->indexOf(sepId); + if ( numAfter > numBefore || ( sepPosAfter != -1 && sepPosAfter && sepPosAfter != numAfter - 1 ) ) { + myIDs.append( sepId ); + } + else if ( sepPosAfter != -1 ) + popupMenu->removeItem( sepId ); + } + else + onCreatePopup(); /* add items */ + + return popupMenu; +} + +/*! + Deactivates the popup +*/ +void QAD_PopupClientServer::destroyPopup() +{ + if ( myPopup ) + { + /* remove all my items */ + QValueList::ConstIterator it; + for( it = myIDs.begin(); it != myIDs.end(); ++it ) + myPopup->removeItem ( *it ); + + /* clear list of IDs */ + myIDs.clear(); + + if ( myOnlyServer ) + { /* popup must be empty now */ + QAD_ASSERT_DEBUG_ONLY ( !myPopup->count() ); + return; + } + myPopup = 0; + } + + /* dispatch to my server */ + if ( myPopupServer ) + myPopupServer->destroyPopup(); +} diff --git a/src/SALOMEGUI/QAD_Popup.h b/src/SALOMEGUI/QAD_Popup.h new file mode 100644 index 000000000..cf310c7d0 --- /dev/null +++ b/src/SALOMEGUI/QAD_Popup.h @@ -0,0 +1,88 @@ +// File : QAD_Popup.h +// Created : 22.09.00 +// Descr : Popup menu management + +// Author : UI team +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_POPUP_H +#define QAD_POPUP_H + +#include "QAD.h" +#include +#include + +/**************************************************************************** +** +** Interface QAD_PopupServer: must be implemented by a class which is going +** to be a popup server for clients i.e. be able to create a popup menu +** +*****************************************************************************/ +class QAD_EXPORT QAD_PopupServer +{ +public: + QAD_PopupServer(); + virtual ~QAD_PopupServer(); + +public: + virtual QPopupMenu* createPopup(); + virtual void destroyPopup(); + void enablePopup( bool ); + +protected: + virtual void onCreatePopup () = 0; /* addition of menu items goes here */ + +protected: + QPopupMenu* myPopup; /* resulting popup menu */ + bool myEnablePopup; /* enable/disable popup creation */ +}; + +/**************************************************************************** +** +** Class QAD_PopupClient: must be inherited by a class which is going +** to be a popup client i.e. be able to show its server's popup menu +** +*****************************************************************************/ +class QAD_EXPORT QAD_PopupClient +{ +public: + QAD_PopupClient(); + virtual ~QAD_PopupClient(); + +public: + void setPopupServer ( QAD_PopupServer* ); + QAD_PopupServer* getPopupServer () const; + +protected: + QAD_PopupServer* myPopupServer; +}; + +/**************************************************************************** +** +** Class QAD_PopupClientServer: both client and server. Can be used as +** a server only or as a client only ( if server is not set ). +** +*****************************************************************************/ +class QAD_EXPORT QAD_PopupClientServer : public QAD_PopupClient, + public QAD_PopupServer +{ +public: + QAD_PopupClientServer( bool separateItems = true, bool smartSeparator = true ); + ~QAD_PopupClientServer(); + +public: + QPopupMenu* createPopup(); + void destroyPopup(); + +protected: + QValueList myIDs; // ids of the items added by myself as a server + bool myOnlyServer; // true if I`m fully responsible for the menu + bool mySeparateItems; // to insert separator before my items + bool mySmartSeparator; // if true then separator is inserted after own items, + // not at the end of menu +}; + +#endif diff --git a/src/SALOMEGUI/QAD_PyEditor.cxx b/src/SALOMEGUI/QAD_PyEditor.cxx new file mode 100644 index 000000000..c91e96971 --- /dev/null +++ b/src/SALOMEGUI/QAD_PyEditor.cxx @@ -0,0 +1,377 @@ +using namespace std; +// File : QAD_PyEditor.cxx +// Created : Thu Jun 14 16:04:59 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "QAD_PyEditor.h" +#include "QAD_PyInterp.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_Config.h" +#include "QAD_Tools.h" +#include "QAD_MessageBox.h" +//#include "QAD_RightFrame.h" + +#include +#include +#include + +// NRI : Temporary added +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +//NRI + +#define SIZEPR 4 +enum { IdCopy, IdPaste, IdClear, IdSelectAll }; + +/*! + Constructor +*/ +QAD_PyEditor::QAD_PyEditor(QAD_PyInterp* interp, + QWidget *parent, const char *name) + : QMultiLineEdit(parent,name) +{ + QString fntSet = QAD_CONFIG->getSetting("Viewer:ConsoleFont"); + QFont myFont = QAD_Tools::stringToFont( fntSet ); +// QFont myFont("Courier",11); + setFont(myFont); + _interp = interp; + string banner = _interp->getbanner(); + setText(banner.c_str()); + _isInHistory = false; + _currentPrompt = ">>> "; + // put error messages of interpreter if they exist. + _buf.truncate(0); + setText(_interp->getverr()); + setText(_currentPrompt); + setPalette( QAD_Application::getPalette(true) ); + setWordWrap(NoWrap); + connect(this,SIGNAL(returnPressed()),this,SLOT(handleReturn()) ); +} + +/*! + Destructor +*/ +QAD_PyEditor::~QAD_PyEditor() +{ +} + +/*! + Called to insert a string s +*/ +void QAD_PyEditor::setText(QString s) +{ +// MESSAGE("setText"); + int line=numLines()-1; + int col=lineLength(line); + insertAt(s,line,col); + int n = numLines()-1; + setCursorPosition( n, textLine(n).length()); +} + +/*! + Called when an handleReturn +*/ +void QAD_PyEditor::handleReturn() +{ + QApplication::setOverrideCursor( Qt::waitCursor ); + int ret; + int line=numLines()-2; + + // NRI : Temporary added + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + + if ( aStudy->GetProperties()->IsLocked() ) { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), + QObject::tr("WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + + _currentPrompt = ">>> "; + setText(_currentPrompt); + + return; + } + // NRI + + _buf.append(textLine(line).remove(0,SIZEPR)); + ret = _interp->run(_buf); + if(ret <= 0) + { + _buf.truncate(0); + setText(_interp->getvout()); + setText(_interp->getverr()); + _currentPrompt = ">>> "; + setText(_currentPrompt); + } + if(ret == 1) + { + _buf.append("\n"); + _currentPrompt = "... "; + setText(_currentPrompt); + } + _isInHistory = false; + QApplication::restoreOverrideCursor(); +} + +/* + Processes own popup menu +*/ +void QAD_PyEditor::mousePressEvent (QMouseEvent * event) +{ + if ( event->button() == RightButton ) { + QPopupMenu *popup = new QPopupMenu( this ); + QMap idMap; + + int line1, col1, line2, col2; + getMarkedRegion(&line1, &col1, &line2, &col2); + bool allSelected = getMarkedRegion(&line1, &col1, &line2, &col2) && + line1 == 0 && line2 == numLines()-1 && col1 == 0 && col2 == lineLength(line2); + int id; + id = popup->insertItem( tr( "EDIT_COPY_CMD" ) ); + idMap.insert(IdCopy, id); + id = popup->insertItem( tr( "EDIT_PASTE_CMD" ) ); + idMap.insert(IdPaste, id); + id = popup->insertItem( tr( "EDIT_CLEAR_CMD" ) ); + idMap.insert(IdClear, id); + popup->insertSeparator(); + id = popup->insertItem( tr( "EDIT_SELECTALL_CMD" ) ); + idMap.insert(IdSelectAll, id); + popup->setItemEnabled( idMap[ IdCopy ], hasMarkedText() ); + popup->setItemEnabled( idMap[ IdPaste ], + !isReadOnly() && (bool)QApplication::clipboard()->text().length() ); + popup->setItemEnabled( idMap[ IdSelectAll ], + (bool)text().length() && !allSelected ); + + int r = popup->exec( event->globalPos() ); + delete popup; + + if ( r == idMap[ IdCopy ] ) { + copy(); + } + else if ( r == idMap[ IdPaste ] ) { + paste(); + } + else if ( r == idMap[ IdClear ] ) { + clear(); + string banner = _interp->getbanner(); + setText(banner.c_str()); + setText(_currentPrompt); + } + else if ( r == idMap[ IdSelectAll ] ) { + selectAll(); + } + return; + } + else { + QMultiLineEdit::mousePressEvent(event); + } +} + +/*! + Called when a Mouse release event +*/ +void QAD_PyEditor::mouseReleaseEvent ( QMouseEvent * e ) +{ + // MESSAGE("mouseReleaseEvent"); + int curLine, curCol; // for cursor position + int endLine, endCol; // for last edited line + getCursorPosition(&curLine, &curCol); + endLine = numLines() -1; + if (e->button() != MidButton) + QMultiLineEdit::mouseReleaseEvent(e); + else if ((curLine == endLine) && (curCol >= SIZEPR)) + QMultiLineEdit::mouseReleaseEvent(e); +} + +/*! + Called when a drop event (Drag & Drop) +*/ + void QAD_PyEditor::dropEvent (QDropEvent *e) +{ + INFOS("dropEvent : not handled"); +} + +/*! + Checks, is the string a command line or not. +*/ + +bool QAD_PyEditor::isCommand( const QString& str) const +{ + if (str.find(_currentPrompt)==0) + return true; + return false; +} + + +/*! + Called when a keyPress event +*/ +void QAD_PyEditor::keyPressEvent( QKeyEvent *e ) +{ + int curLine, curCol; // for cursor position + int endLine, endCol; // for last edited line + getCursorPosition(&curLine, &curCol); + endLine = numLines() -1; + //MESSAGE("current position " << curLine << ", " << curCol); + //MESSAGE("last line " << endLine); + //MESSAGE(e->key()); + int aKey=e->key(); + int keyRange=0; + if ((aKey >= Key_Space) && (aKey <= Key_ydiaeresis)) + keyRange = 0; + else + keyRange = aKey; + + bool ctrlPressed = ( (e->state() & ControlButton) == ControlButton ); + bool shftPressed = ( (e->state() & ShiftButton) == ShiftButton ); + + switch (keyRange) + { + case 0 : + { + if (curLine getPrevious(); + if (previousCommand.compare(BEGIN_HISTORY_PY) != 0) + { + removeLine(endLine); + histLine.append(previousCommand); + insertLine(histLine); + } + endLine = numLines() -1; + setCursorPosition(endLine, lineLength(endLine)); + } + // if Shift+Key_Up event then move cursor up and select the text + else if ( shftPressed && curLine > 0 ){ + setCursorPosition(curLine-1, curCol, true); + } + // move cursor up + else { QMultiLineEdit::keyPressEvent( e ); } + break; + } + case Key_Down: + { + // if Cntr+Key_Down event then scroll the commands stack down + if (ctrlPressed) { + QString histLine = _currentPrompt; + QString nextCommand = _interp->getNext(); + if (nextCommand.compare(TOP_HISTORY_PY) != 0) + { + removeLine(endLine); + histLine.append(nextCommand); + insertLine(histLine); + } + else + if (_isInHistory) + { + _isInHistory = false; + removeLine(endLine); + histLine.append(_currentCommand); + insertLine(histLine); + } + endLine = numLines() -1; + setCursorPosition(endLine, lineLength(endLine)); + } + // if Shift+Key_Down event then move cursor down and select the text + else if ( shftPressed && curLine < endLine ) { + setCursorPosition(curLine+1, curCol, true); + } + //move cursor down + else { QMultiLineEdit::keyPressEvent( e ); } + + break; + } + case Key_Left: + { + if (!shftPressed && isCommand(textLine(curLine)) && curCol <= SIZEPR ) + { + setCursorPosition((curLine -1), SIZEPR); + end(); + } + else QMultiLineEdit::keyPressEvent( e ); + break; + } + case Key_Right: + { + if (!shftPressed && isCommand(textLine(curLine)) + && curCol < SIZEPR) setCursorPosition(curLine, SIZEPR-1); + QMultiLineEdit::keyPressEvent( e ); + break; + } + case Key_Home: + { + if (isCommand(textLine(curLine)) && curCol <= SIZEPR) + setCursorPosition(curLine, SIZEPR, shftPressed); + else setCursorPosition(curLine, 0, shftPressed); + break; + } + case Key_End: + { + setCursorPosition(curLine, textLine(curLine).length(), shftPressed); + break; + } + case Key_Backspace : + { + if ((curLine == endLine) && (curCol > SIZEPR)) + QMultiLineEdit::keyPressEvent( e ); + break; + } + case Key_Delete : + { + if ((curLine == endLine) && (curCol > SIZEPR-1)) + QMultiLineEdit::keyPressEvent( e ); + break; + } + } + if ( e->key() == Key_C && ( e->state() & ControlButton ) ) + { + _buf.truncate(0); + setText("\n"); + _currentPrompt = ">>> "; + setText(_currentPrompt); + } + + // NRI : DEBUG PAS TERRIBLE // + if (( e->key() == Key_F3) || + ( e->key() == Key_F4) || + ( e->key() == Key_Return) || + ( e->key() == Key_Escape)) + QAD_Application::getDesktop()->onKeyPress( e ); + // NRI // +} diff --git a/src/SALOMEGUI/QAD_PyEditor.h b/src/SALOMEGUI/QAD_PyEditor.h new file mode 100644 index 000000000..eb4629ab9 --- /dev/null +++ b/src/SALOMEGUI/QAD_PyEditor.h @@ -0,0 +1,45 @@ +// File : QAD_PyEditor.h +// Created : Thu Jun 14 16:05:46 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_PyEditor_H +#define QAD_PyEditor_H + +#include + +class QAD_PyInterp; + +class QAD_PyEditor : public QMultiLineEdit +{ + Q_OBJECT + +public: + QAD_PyEditor(QAD_PyInterp* interp, QWidget *parent=0, const char *name=0); + ~QAD_PyEditor(); + + void setText(QString s); + bool isCommand(const QString& str) const; + +protected: + void keyPressEvent (QKeyEvent * e); + void mousePressEvent (QMouseEvent * e); + void mouseReleaseEvent (QMouseEvent * e); + void dropEvent (QDropEvent *e); + +public slots: + void handleReturn(); + +private: + QAD_PyInterp * _interp; + QString _buf; + QString _currentCommand; + QString _currentPrompt; + bool _isInHistory; +}; + +#endif + diff --git a/src/SALOMEGUI/QAD_PyInterp.cxx b/src/SALOMEGUI/QAD_PyInterp.cxx new file mode 100644 index 000000000..f4c0da963 --- /dev/null +++ b/src/SALOMEGUI/QAD_PyInterp.cxx @@ -0,0 +1,110 @@ +using namespace std; +using namespace std; +//============================================================================= +// File : QAD_PyInterp.cxx +// Created : Thu Jun 14 14:03:58 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ +//============================================================================= + +// TODO: +// control & limit history length + +#include "QAD_PyInterp.h" +#include "utilities.h" + +/*! + * constructor : multi Python interpreter, one per SALOME study. + * calls initialize method defined in base class, which calls virtual methods + * initstate & initcontext redefined here. + */ +QAD_PyInterp::QAD_PyInterp(): PyInterp_base() +{ + initialize(); +} + +QAD_PyInterp::~QAD_PyInterp() +{ +} + +/*! + * EDF-CCAR + * When SALOME uses multi Python interpreter feature, + * Every study has its own interpreter and thread state (_tstate = Py_NewInterpreter()) + * This is fine because every study has its own modules (sys.modules) stdout and stderr + * BUT some Python modules must be imported only once. In multi interpreter context Python + * modules (*.py) are imported several times. + * The pyqt module must be imported only once because it registers classes in a C module. + * It's quite the same with omniorb modules (internals and generated with omniidl) + * This problem is handled with "shared modules" defined in salome_shared_modules.py + * These "shared modules" are imported only once and only copied in all the other interpreters + * BUT it's not the only problem. Every interpreter has its own __builtin__ module. That's fine + * but if we have copied some modules and imported others problems may arise with operations that + * are not allowed in restricted execution environment. So we must impose that all interpreters + * have identical __builtin__ module. + * That's all, for the moment ... + */ + +void QAD_PyInterp::initState() +{ + MESSAGE("QAD_PyInterp::initState"); + salomeAcquireLock(); //acquire python global lock (one for all interpreters) + _tstate = Py_NewInterpreter(); //create an interpreter and save current state + SCRUTE(_tstate); + SCRUTE(PyInterp_base::_argc); + SCRUTE(PyInterp_base::_argv[0]); + PySys_SetArgv(PyInterp_base::_argc,PyInterp_base::_argv); // initialize sys.argv + + if(builtinmodule == NULL)return; + /* + * If builtinmodule has been initialized all the sub interpreters + * will have the same __builtin__ module + */ + PyObject *m=PyImport_GetModuleDict(); + PyDict_SetItemString(m, "__builtin__", builtinmodule); + SCRUTE(builtinmodule->ob_refcnt); // builtinmodule reference counter + _tstate->interp->builtins = PyModule_GetDict(builtinmodule); + Py_INCREF(_tstate->interp->builtins); +} + +void QAD_PyInterp::initContext() +{ + MESSAGE("QAD_PyInterp::initContext"); + PyObject *m; + m=PyImport_AddModule("__main__"); // interpreter main module (module context) + if(m == NULL) + { + MESSAGE("problem..."); + ASSERT(0); + PyErr_Print(); + salomeReleaseLock(); + return; + } + _g = PyModule_GetDict(m); // get interpreter dictionnary context + SCRUTE(_g); + + if(builtinmodule) + { + PyDict_SetItemString(_g, "__builtins__", builtinmodule); // assign singleton __builtin__ module + } + /* + * Call salome_shared_modules to import salome shared modules that must not be initialized twice + * so import_shared_modules makes only a copy of the modules in _tstate->interp->modules + * (sys.modules) + */ + m= PyObject_CallMethod(salome_shared_modules_module, + "import_shared_modules","O", + _tstate->interp->modules); + if (m == NULL) + { + /* + * Problem , print it + */ + MESSAGE("problem..."); + ASSERT(0); + PyErr_Print(); + } +} diff --git a/src/SALOMEGUI/QAD_PyInterp.h b/src/SALOMEGUI/QAD_PyInterp.h new file mode 100644 index 000000000..47d0fc86d --- /dev/null +++ b/src/SALOMEGUI/QAD_PyInterp.h @@ -0,0 +1,27 @@ +//============================================================================= +// File : QAD_PyInterp.h +// Created : Thu Jun 14 14:04:27 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ +//============================================================================= + +#ifndef _QAD_PYINTERP_H_ +#define _QAD_PYINTERP_H_ + +#include "PyInterp_base.h" + +class QAD_PyInterp : public PyInterp_base +{ + public: + QAD_PyInterp(); + ~QAD_PyInterp(); + + protected: + void initState(); + void initContext(); +}; + +#endif diff --git a/src/SALOMEGUI/QAD_PyInterp_mono.cxx b/src/SALOMEGUI/QAD_PyInterp_mono.cxx new file mode 100644 index 000000000..867f663e0 --- /dev/null +++ b/src/SALOMEGUI/QAD_PyInterp_mono.cxx @@ -0,0 +1,51 @@ +using namespace std; +using namespace std; +//============================================================================= +// File : QAD_PyInterp_mono.cxx +// Created : ven fév 7 10:01:36 CET 2003 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2003 +// $Header$ +//============================================================================= + +#include "QAD_PyInterp_mono.h" +#include "utilities.h" + +/*! + * constructor : only one Python interpreter, shared within SALOME studies. + * calls initialize method defined in base class, which calls virtual methods + * initstate & initcontext redefined here. + */ +QAD_PyInterp_mono::QAD_PyInterp_mono(): PyInterp_base() +{ + initialize(); +} + +QAD_PyInterp_mono::~QAD_PyInterp_mono() +{ +} + +/*! + * EDF-CCAR + * When SALOME uses mono Python interpreter feature, + * every study has its own context (dictionnary) but shares builtins + * and all the modules (sys, ...) with other studies. + * A module imported in a study is seen in another study (pros ans cons !). + */ + +void QAD_PyInterp_mono::initState() +{ + salomeAcquireLock(); //acquire python global lock (one for all interpreters) + _tstate = PyThreadState_Get(); + PySys_SetArgv(PyInterp_base::_argc,PyInterp_base::_argv); // initialize sys.argv +} + +void QAD_PyInterp_mono::initContext() +{ + _g = PyDict_New(); // create interpreter dictionnary context + PyObject *bimod = PyImport_ImportModule("__builtin__"); + PyDict_SetItemString(_g, "__builtins__", bimod); + Py_DECREF(bimod); +} + diff --git a/src/SALOMEGUI/QAD_PyInterp_mono.h b/src/SALOMEGUI/QAD_PyInterp_mono.h new file mode 100644 index 000000000..73af63303 --- /dev/null +++ b/src/SALOMEGUI/QAD_PyInterp_mono.h @@ -0,0 +1,26 @@ +//============================================================================= +// File : QAD_PyInterp_mono.h +// Created : ven fév 7 10:01:36 CET 2003 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2003 +// $Header$ +//============================================================================= + +#ifndef _QAD_PYINTERP_MONO_H_ +#define _QAD_PYINTERP_MONO_H_ + +#include "PyInterp_base.h" + +class QAD_PyInterp_mono: public PyInterp_base +{ + public: + QAD_PyInterp_mono(); + ~QAD_PyInterp_mono(); + + protected: + void initState(); + void initContext(); +}; + +#endif diff --git a/src/SALOMEGUI/QAD_Resource.h b/src/SALOMEGUI/QAD_Resource.h new file mode 100644 index 000000000..ff1fffd03 --- /dev/null +++ b/src/SALOMEGUI/QAD_Resource.h @@ -0,0 +1,26 @@ +// File : QAD_Resource.h +// Created : Fri Aug 23 12:01:23 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_RESOURCE_H +#define QAD_RESOURCE_H + +// Here go definition of common popup menu item IDs. +// These values should be used by all component GUI modules when customizing popup menus + +// Special popup item used to display a name of the selected object +#define QAD_TopLabel_Popup_ID 99000 + +#define QAD_Display_Popup_ID 99001 + +#define QAD_DisplayOnly_Popup_ID 99002 + +#define QAD_Erase_Popup_ID 99003 + + + +#endif diff --git a/src/SALOMEGUI/QAD_ResourceMgr.cxx b/src/SALOMEGUI/QAD_ResourceMgr.cxx new file mode 100644 index 000000000..19ce185d3 --- /dev/null +++ b/src/SALOMEGUI/QAD_ResourceMgr.cxx @@ -0,0 +1,442 @@ +using namespace std; +// File : QAD_ResourceMgr.cxx +// Created : UI team, 22.10.00 +// Descr : ResourceMgr QAD-based application +// Author : UI team +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +/*! + \class QAD_ResourceMgr QAD_ResourceMgr.h + \brief ResourceMgr QAD-based application. +*/ + +#include "QAD.h" +#include "QAD_Tools.h" +#include "QAD_MessageBox.h" +#include "QAD_ResourceMgr.h" + +#include "utilities.h" + +#include +#include +#include +#include +#include + +#include + +/* configuration file */ +static const char* CONFIG_FILE = "config"; + +/* config keys */ +static const char* RES_DIR = "res"; +static const char* RES_DOCS = "docs"; +static const char* RES_PIXMAPS = "icons"; +static const char* RES_STRINGS = "strings"; +static const char* RES_LANGUAGE = "language"; + +static const char* SEPARATOR = ":"; + +/*! + Constructor +*/ +QAD_ResourceMgr::QAD_ResourceMgr() : +myRes( 5, false ) +{ + myRes.setAutoDelete( true ); +} + +/*! + Destructor +*/ +QAD_ResourceMgr::~QAD_ResourceMgr() +{ + myRes.clear(); +} + +/*! + Removes icons and messages from 'prefix'_msg_'lang' + and 'prefix'_icons' files. Returns 'true' if OK. + Each application which has its own resources must + have a unique 'prefix' ( prefix "QAD" is reserved ) +*/ +bool QAD_ResourceMgr::removeResources( const char* prefix ) +{ + return myRes.remove(prefix); +} + +/*! + Loads icons and messages from 'prefix'_msg_'lang' + and 'prefix'_icons' files. Returns 'true' if OK. + Each application which has its own resources must + have a unique 'prefix' ( prefix "QAD" is reserved ) +*/ +bool QAD_ResourceMgr::loadResources( const char* prefix, QString &msg ) +{ + bool allLoaded = true; + if ( !myRes[ prefix ] ) { + QCString dir ; + + /* We read the settings once and keep them. + The resources are loaded consequently from the end of directory list + which ( see collectDirs() method description ). This allows to override + resources when it is necessary. + */ + + ResourceSettings* settings = new ResourceSettings(); + StringDict& conf = settings->config(); + myRes.insert( prefix, settings ); + + // settings->config().insert( RES_DIR, new QString( resDir ) ); + + /* we search language definition : we read it in config file + If not found, we use default : English + */ + conf.insert( RES_LANGUAGE, new QString( "en" ) ); + + /* Read configuration file */ + + /* WE MUST HAVE ONE CONFIGURATION FILE FOR ALL SALOME !!! + I DON'T KNOW WHERE READ IT AND SAVE ITS CONTENTS FOR ALL GUI + ALL GUI HAS SAME LANGUAGE AND HAVE DEFAULT (en) IF SPECIFIED + IS NOT FOUND !! + */ + QString resDirs = collectDirs( prefix ); + conf.insert( RES_DIR, new QString( resDirs ) ); + QString fileConfig = path( CONFIG_FILE, prefix, 0 ) ; + //MESSAGE("QAD_ResourceMgr::loadresources : config : "< 0 ) { + int index; + if ( ( index = line.find( "=" ) ) > 0 ) { + QString key = line.left(index).stripWhiteSpace(); + QString value = line.mid( index+1 ).stripWhiteSpace(); + conf.replace( key, new QString( value ) ); + } + } + } + configFile.close(); + } + } + + /* Load the resources */ + QString stFile( prefix ); + stFile = stFile + "_msg_" + *( conf[ RES_LANGUAGE ] ) + ".qm" ; + QString imagesFile( prefix ); + imagesFile = imagesFile + "_" + RES_PIXMAPS + ".qm"; + if ( conf[ RES_STRINGS ] && !conf[ RES_STRINGS ]->isEmpty() ) + stFile = QAD_Tools::addSlash( *conf[ RES_STRINGS ] ) + stFile; + if ( conf[ RES_PIXMAPS ] && !conf[ RES_PIXMAPS ]->isEmpty() ) + imagesFile = QAD_Tools::addSlash( *conf[ RES_PIXMAPS ] ) + imagesFile; + + bool bLoadString = false; + bool bLoadImages = false; + + QStringList dirList = QStringList::split( SEPARATOR, resDirs, false ); // skip empty entries + for ( int i = dirList.count()-1; i >= 0; i-- ) { + QString dir = dirList[ i ]; + QString fileString = QAD_Tools::addSlash( dir ) + stFile; + QString fileImage = QAD_Tools::addSlash( dir ) + imagesFile; + + if ( settings->load( fileString ) ) { + bLoadString = true; + } + if ( settings->load( fileImage ) ) { + bLoadImages = true; + } + } + + if ( !bLoadString ) { + QString warnMsg; + warnMsg.sprintf( "String resources for module %s not found.\n" + "Please, check your settings.", + prefix ); + msg = warnMsg; +// removeResources( prefix ); + return false; + } + if ( !bLoadImages ) { + QString warnMsg; + warnMsg.sprintf( "Icons resources for module %s not found.\n" + "Please, check your settings.", + prefix ); + msg = warnMsg; +// removeResources( prefix ); + return false; + } + allLoaded = bLoadString && bLoadImages; + } + return allLoaded; +} + +/*! + Returns language setting for the module 'prefix' ( e.g. "en" ) +*/ +QString QAD_ResourceMgr::language( const char* prefix ) const +{ + QString ret; + ResourceSettings* rs = myRes[ prefix ]; + if ( rs ) + { + StringDict& conf = rs->config(); + ret = *(conf[RES_LANGUAGE]); + } + return ret; +} + +/*! + Returns list of directories where resources can be located + See collectDirs() method description for more detail +*/ +QString QAD_ResourceMgr::resources( const char* prefix ) const +{ + QString ret; + ResourceSettings* rs = myRes[ prefix ]; + if ( rs ) + { + StringDict& conf = rs->config(); + ret = *(conf[RES_DIR]); + } + return ret; +} + +/*! + Collects list of directories, separated by ';' where resources for module 'prefix' + can be situated + The order is following : + - CSF_Resources env.var directory ( or directory list ) + - CSF_ResourcesDefaults env.var directory ( or directory list ) + - ${HOME}/.salome/resources directory + - ${SALOME_SITE_DIR}/share/salome/resources directory + - ${SALOME_ROOT_DIR}/share/salome/resources directory +*/ +QString QAD_ResourceMgr::collectDirs( const QString& prefix ) const +{ + QString dirList; + QCString envVar( "CSF_" ); + QString dir; + char* cenv; + + // Try CSF_Resources env.var directory ( or directory list ) + if ( !prefix.isEmpty() ) { + envVar = QCString( "CSF_" ) + prefix.latin1() + QCString( "Resources" ); + cenv = getenv( ( const char* ) envVar ); + if ( cenv ) { + dir.sprintf( "%s", cenv ); + if ( !dir.isEmpty() ) + dirList.append( dirList.isEmpty() ? dir : ( QString( SEPARATOR ) + dir ) ); + } + } + // Try CSF_ResourcesDefaults env.var directory ( or directory list ) + cenv = getenv( "CSF_ResourcesDefaults" ); + if ( cenv ) { + dir.sprintf( "%s", cenv ); + if ( !dir.isEmpty() ) + dirList.append( dirList.isEmpty() ? dir : ( QString( SEPARATOR ) + dir ) ); + } + // Try ${HOME}/.salome/resources directory + cenv = getenv( "HOME" ); + if ( cenv ) { + dir.sprintf( "%s", cenv ); + if ( !dir.isEmpty() ) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + ".salome" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "resources" ; + dir = QAD_Tools::addSlash(dir) ; + dirList.append( dirList.isEmpty() ? dir : ( QString( SEPARATOR ) + dir ) ); + } + } + // Try ${SALOME_SITE_DIR}/share/salome/resources directory + cenv = getenv( "SALOME_SITE_DIR" ); + if ( cenv ) { + dir.sprintf( "%s", cenv ); + if ( !dir.isEmpty() ) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "share" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "salome" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "resources" ; + dir = QAD_Tools::addSlash(dir) ; + dirList.append( dirList.isEmpty() ? dir : ( QString( SEPARATOR ) + dir ) ); + } + } + // Try ${SALOME_ROOT_DIR}/share/salome/resources directory + cenv = getenv( "SALOME_ROOT_DIR" ); + if ( cenv ) { + dir.sprintf( "%s", cenv ); + if ( !dir.isEmpty() ) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "share" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "salome" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "resources" ; + dir = QAD_Tools::addSlash(dir) ; + dirList.append( dirList.isEmpty() ? dir : ( QString( SEPARATOR ) + dir ) ); + } + } + //MESSAGE("QAD_ResourceMgr::collectDirs : "<config(); + QString resDirs = QString( *( conf[ RES_DIR ] ) ); + if ( !resDirs.isEmpty() ) { + //MESSAGE("QAD_ResourceMgr::resDirs : <"<") ; + QStringList dirList = QStringList::split( SEPARATOR, resDirs, false ); // skip empty entries + for ( int i = 0; i < dirList.count(); i++ ) { + QString dir = dirList[ i ]; + dir = QAD_Tools::addSlash( dir ); + if ( key ) { + QString* where = conf[ key ]; + if ( where ) + dir = dir + QAD_Tools::addSlash( *where ); + } + dir = dir + filename; + QFileInfo fileInfo( dir ); + if ( fileInfo.isFile() && fileInfo.exists() ) { + filePath = fileInfo.filePath(); + break; + } + } + } + } + //MESSAGE("QAD_ResourceMgr::path : <"< : "<= 0x030000 // VSR: workaround - crash on qt3.0.5 ========== + static const int magic_length = 16; // length of *.qm file header (qtranslator.cpp) + static const uchar magic[magic_length] = { // magic number for the file + 0x3c, 0xb8, 0x64, 0x18, 0xca, 0xef, 0x9c, 0x95, + 0xcd, 0x21, 0x1c, 0xbf, 0x60, 0xa1, 0xbd, 0xdd }; + QFile f(file); + if ( !f.exists() || f.size() < magic_length) + return false; + char buf[magic_length]; + if ( !f.open(IO_ReadOnly) ) + return false; + bool bOk = ( f.readBlock(buf, magic_length) == magic_length ); + f.close(); + if (!bOk) + return false; + if ( memcmp( (const void *)buf, magic, magic_length ) ) + return false; + if ( f.size() == magic_length) + return true; +#endif // VSR ============================================================= + QTranslator* strTbl = new QTranslator( 0 ); + try { + if ( !strTbl->load( file, "" ) ) { + delete strTbl; + return false; + } + } + catch (...) { + return false; + } + QAD_ASSERT_DEBUG_ONLY( qApp ); + qApp->installTranslator( strTbl ); + return true; +} diff --git a/src/SALOMEGUI/QAD_ResourceMgr.h b/src/SALOMEGUI/QAD_ResourceMgr.h new file mode 100644 index 000000000..83ccdfe26 --- /dev/null +++ b/src/SALOMEGUI/QAD_ResourceMgr.h @@ -0,0 +1,68 @@ +// File : QAD_ResourceMgr.cxx +// Created : UI team, 22.10.00 +// Descr : ResourceMgr QAD-based application +// Author : UI team +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + + +#ifndef QAD_RESOURCEMGR_H +#define QAD_RESOURCEMGR_H + +#include +#include +#include +#include +#include + +#include "QAD.h" +class QAD_EXPORT QAD_ResourceMgr : public QObject +{ + Q_OBJECT + + typedef QDict StringDict; + class ResourceSettings + { + StringDict myConfig; + public: + ResourceSettings() : myConfig( 10, false ) + { myConfig.setAutoDelete( true ); } + ~ResourceSettings() + { myConfig.clear(); } + + StringDict& config() { return myConfig; } + bool load( const QString& filename ); + }; + +public: + QAD_ResourceMgr(); + ~QAD_ResourceMgr(); + +public: + bool loadResources( const char* resname, QString& msg ); + QPixmap loadPixmap( const char* resname, + const QString& id ) const; + bool loadDoc( const char* resname, + const QString& id ) const; + QString language( const char* prefix ) const; + QString resources( const char* prefix ) const; + + QString findFile(const QString& filename, const char* prefix ) const; + QString getFile( const QString& filename, const char* prefix ) const; + + bool removeResources( const char* resname ); + +private: + QString path( const QString& filename, + const char* resname, + const char* key ) const; + QString collectDirs( const QString& prefix ) const; + +private: + QAsciiDict myRes; /* prefix <-> resources */ +}; + +#endif + diff --git a/src/SALOMEGUI/QAD_RightFrame.cxx b/src/SALOMEGUI/QAD_RightFrame.cxx new file mode 100644 index 000000000..feb272649 --- /dev/null +++ b/src/SALOMEGUI/QAD_RightFrame.cxx @@ -0,0 +1,344 @@ +using namespace std; +// File : QAD_RightFrame.cxx +// Created : Thu Jun 14 14:51:52 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "QAD_RightFrame.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_StudyFrame.h" +#include "QAD_Tools.h" +#include + +// QT Include +#include + +// Open CASCADE Include +#include + +/*! + \class QAD_RightFrame QAD_RightFrame.h + \brief Frame window which contains QAD_ViewFrame, QAD_PyInterp and QAD_Message. +*/ + +typedef QAD_ViewFrame* View(QAD_RightFrame*); + + +/*! + Constructor +*/ +QAD_RightFrame::QAD_RightFrame(QWidget *parent, const char *name, + QAD_PyInterp* interp, ViewType vt) + : QAD_Splitter( Qt::Vertical, parent, name ) +{ + this->setCompressEnabled( true ); + myViewType = vt; + + QAD_Desktop* Desktop = QAD_Application::getDesktop(); + int DesktopHeight = Desktop->getMainFrame()->width(); + int DesktopWidth = Desktop->getMainFrame()->height(); + + _interp = interp; + + OSD_SharedLibrary SharedLib = OSD_SharedLibrary(); + QString ComponentLib; + QCString dir; + QFileInfo fileInfo ; + bool found = false; + if (myViewType == VIEW_OCC) { + if ( dir = getenv("SALOME_SITE_DIR")) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "salome" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "libOCCViewer.dll" ; +#else + dir = dir + "libOCCViewer.so" ; +#endif + MESSAGE ( " GUI library = " << dir ) + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ComponentLib = fileInfo.fileName(); + found = true; + MESSAGE (" Found ") + } else + MESSAGE (" Not found ") + } + + if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "salome" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "libOCCViewer.dll" ; +#else + dir = dir + "libOCCViewer.so" ; +#endif + MESSAGE ( " GUI library = " << dir ) + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ComponentLib = fileInfo.fileName(); + found = true; + MESSAGE (" Found ") + } else + MESSAGE (" Not found ") + } + } else if (myViewType == VIEW_VTK) { + + if ( dir = getenv("SALOME_SITE_DIR")) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "salome" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "libVTKViewer.dll" ; +#else + dir = dir + "libVTKViewer.so" ; +#endif + MESSAGE ( " GUI library = " << dir ); + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ComponentLib = fileInfo.fileName(); + found = true; + MESSAGE (" Found "); + } else + MESSAGE (" Not found "); + } + + if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "salome" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "libVTKViewer.dll" ; +#else + dir = dir + "libVTKViewer.so" ; +#endif + MESSAGE ( " GUI library = " << dir ); + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ComponentLib = fileInfo.fileName(); + found = true; + MESSAGE (" Found "); + } else + MESSAGE (" Not found "); + } + } else if (myViewType == VIEW_GRAPHSUPERV) { + if ( dir = getenv("SALOME_SITE_DIR")){ + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "salome" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "libSUPERVGraph.dll" ; +#else + dir = dir + "libSUPERVGraph.so" ; +#endif + MESSAGE ( " GUI library = " << dir ) + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ComponentLib = fileInfo.fileName() ; + found = true; + MESSAGE (" Found ") + } else + MESSAGE (" Not found ") + } + + if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "salome" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "libSUPERVGraph.dll" ; +#else + dir = dir + "libSUPERVGraph.so" ; +#endif + MESSAGE ( " GUI library = " << dir ) + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ComponentLib = fileInfo.fileName() ; + found = true; + MESSAGE (" Found ") + } else + MESSAGE (" Not found ") + } + } else if (myViewType == VIEW_PLOT2D) { + if ( dir = getenv("SALOME_SITE_DIR")){ + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "salome" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "libPlot2d.dll" ; +#else + dir = dir + "libPlot2d.so" ; +#endif + MESSAGE ( " GUI library = " << dir ) + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ComponentLib = fileInfo.fileName() ; + found = true; + MESSAGE (" Found ") + } else + MESSAGE (" Not found ") + } + + if ( (dir = getenv("SALOME_ROOT_DIR")) && !found ) { + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "salome" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "libPlot2d.dll" ; +#else + dir = dir + "libPlot2d.so" ; +#endif + MESSAGE ( " GUI library = " << dir ) + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ComponentLib = fileInfo.fileName() ; + found = true; + MESSAGE (" Found ") + } else + MESSAGE (" Not found ") + } + } else { + QMessageBox::critical( this, + tr("ERR_ERROR"), + tr("undefined view type") ); + return; + } + + SharedLib.SetName( strdup(ComponentLib) ); + + bool ok = SharedLib.DlOpen(OSD_RTLD_LAZY); + if (!ok) { + QMessageBox::critical( this, + tr("ERR_ERROR"), + tr( SharedLib.DlError() ) ); + return; + } else { + OSD_Function osdF = SharedLib.DlSymb("createView"); + if ( osdF != NULL ) { + View (*f1) = (QAD_ViewFrame* (*) (QAD_RightFrame*)) osdF; + myViewFrame = (*f1)(this); + } else { + QMessageBox::critical( this, + tr("ERR_ERROR"), + tr("createView undefined") ); + return; + } + } + + QValueList sizes; + + myViewFrame->setMinimumSize( 1, 1 ); + vsplitter = new QAD_Splitter( Qt::Horizontal, this ); + vsplitter->setMinimumSize( 1, 1 ); + vsplitter->setCompressEnabled( true ); + myPyEditor = new QAD_PyEditor(_interp, vsplitter ,"Python Interpreter"); + myPyEditor->setMinimumSize( 1, 1 ); + myMessage = new QAD_Message( vsplitter ,"Message"); + myMessage->setMinimumSize( 1, 1 ); + + sizes.append( 0.48 * DesktopHeight ); + sizes.append( 0.16 * DesktopHeight ); + setSizes( sizes ); + sizes.clear(); + sizes.append( 0.25 * DesktopWidth ); + sizes.append( 0.25 * DesktopWidth ); + vsplitter->setSizes( sizes ); +} + +/*! + Destructor +*/ +QAD_RightFrame::~QAD_RightFrame() +{ +} + +QAD_ViewFrame* QAD_RightFrame::getViewFrame() const +{ + return myViewFrame; +} + +/*! + Returns reference to the message window [ static ] +*/ +QAD_Message* QAD_RightFrame::getMessage() const +{ + return myMessage; +} + +/*! + Returns the Python interpreter that belongs to this study +*/ +QAD_PyInterp* QAD_RightFrame::get_PyInterp(void) +{ + return _interp; +} + +/*! + Returns reference to the Python window [ static ] +*/ +QAD_PyEditor* QAD_RightFrame::getPyEditor() const +{ + return myPyEditor; +} + +/*! + Compress views +*/ +void QAD_RightFrame::compressUp() +{ + QSplitterPHandle* h = getHandleAfter(myViewFrame); + if (h) + h->compressBefore(); +} + +/*! + Uncompress views +*/ +void QAD_RightFrame::unCompressUp() +{ + QSplitterPHandle* h = getHandleAfter(myViewFrame); + if (h) + h->unCompressBefore(); +} + +/*! + Compress Python Interpreter and Messages windows +*/ +void QAD_RightFrame::compressBottom() +{ + QSplitterPHandle* h = getHandleAfter(myViewFrame); + if (h) + h->compressAfter(); +} + +/*! + Uncompress Python Interpreter and Messages windows +*/ +void QAD_RightFrame::unCompressBottom() +{ + QSplitterPHandle* h = getHandleAfter(myViewFrame); + if (h) + h->unCompressAfter(); +} + diff --git a/src/SALOMEGUI/QAD_RightFrame.h b/src/SALOMEGUI/QAD_RightFrame.h new file mode 100644 index 000000000..7896dee7d --- /dev/null +++ b/src/SALOMEGUI/QAD_RightFrame.h @@ -0,0 +1,46 @@ +// File : QAD_RightFrame.h +// Created : Thu Jun 14 14:52:28 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_RightFrame_H +#define QAD_RightFrame_H + +#include "QAD_ViewFrame.h" +#include "QAD_Message.h" +#include "QAD_PyEditor.h" +#include "QAD_Splitter.h" +#include "QAD_PyInterp.h" + +class QAD_EXPORT QAD_RightFrame : public QAD_Splitter +{ + public: + QAD_RightFrame(QWidget *parent, const char *name, + QAD_PyInterp* interp, ViewType vt); + ~QAD_RightFrame(); + + QAD_ViewFrame* getViewFrame() const; + QAD_PyInterp* get_PyInterp(void); + QAD_Message* getMessage() const; + QAD_PyEditor* getPyEditor() const; + + void compressBottom(); + void compressUp(); + void unCompressBottom(); + void unCompressUp(); + +protected: + ViewType myViewType; + + QAD_ViewFrame* myViewFrame; + QAD_PyEditor* myPyEditor; + QAD_Message* myMessage; + QAD_Splitter* vsplitter; + QAD_PyInterp* _interp; +}; + +#endif + diff --git a/src/SALOMEGUI/QAD_Settings.cxx b/src/SALOMEGUI/QAD_Settings.cxx new file mode 100644 index 000000000..346955796 --- /dev/null +++ b/src/SALOMEGUI/QAD_Settings.cxx @@ -0,0 +1,231 @@ +using namespace std; +// File : QAD_Settings.cxx +// Created : Tue Sep 04 09:28:02 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + + +#include "QAD_Settings.h" + +#include + +// QT Includes +#include +#include +#include +#include + +/*! + Class QAD_Settings is a base class for different kind of settings + (identifying strings and values). +*/ +QAD_Settings::QAD_Settings(QString _sectionName, + QChar _nameStarter, QChar _nameStopper, + QChar _valueStarter, QChar _valueStopper) +{ + sectionName = _sectionName; + nameStarter = _nameStarter; + nameStopper = _nameStopper; + valueStarter = _valueStarter; + valueStopper = _valueStopper; + settingList.setAutoDelete(true); +} + +/*! + Constructor. +*/ +QAD_Settings::QAD_Settings(QString _sectionName, + QChar _nameStarter, + QChar _separator, + QChar _valueStopper) +{ + sectionName = _sectionName; + nameStarter = _nameStarter; + nameStopper = _separator; + valueStopper = _valueStopper; + valueStarter=0; + settingList.setAutoDelete(true); +} +/*! + Constructor. +*/ +QAD_Settings::QAD_Settings(QChar _nameStopper, QChar _valueStarter, + QChar _valueStopper) +{ + sectionName = ""; + nameStarter = 0; + nameStopper = _nameStopper; + valueStarter = _valueStarter; + valueStopper = _valueStopper; + settingList.setAutoDelete(true); +} + + +/*! + Destructor. +*/ +QAD_Settings::~QAD_Settings() +{ +} + + +/*! + Clears all settings. +*/ +void QAD_Settings::clear() +{ + settingList.clear(); +} + + +/*! + Adds a setting. If a setting with the given name is already defined it + gets overwritten. +*/ +void QAD_Settings::addSetting(QString _name, QString _value, bool _autoValue) +{ + // Remove all settings with the same name: + removeSettings(_name.simplifyWhiteSpace()); + + // Add new setting: + QAD_Setting* newSetting = new QAD_Setting(_name.simplifyWhiteSpace(), + _value.simplifyWhiteSpace(), + _autoValue); + settingList.append(newSetting); +} + + +/*! + Adds an int setting. If a setting with the given name is already defined it + gets overwritten. +*/ +void QAD_Settings::addSetting(QString _name, int _value, bool _autoValue) +{ + QString strVal; + strVal.setNum(_value); + + addSetting(_name, strVal, _autoValue); +} + +/*! + Adds a double setting. If a setting with the given name is already defined it + gets overwritten. +*/ +void QAD_Settings::addSetting(QString _name, double _value, bool _autoValue) +{ + QString strVal; + strVal.setNum(_value); + + addSetting(_name, strVal, _autoValue); +} + + +/*! + Removes all setting with the given name (should be unique anyway). +*/ +bool QAD_Settings::removeSettings(QString name) +{ + QAD_Setting* s; + bool ret=false; + + for(s=settingList.first(); s!=0;) { + if(s->getName()==name) { + settingList.remove(s); + s=settingList.current(); + ret=true; + } + else { + s=settingList.next(); + } + } + + return ret; +} + + +/*! + Removes all setting which are not automatically generated. +*/ +void QAD_Settings::removeNonAutoSettings() +{ + QAD_Setting* s; + + for(s=settingList.first(); s!=0;) { + if(!s->isAutoValue()) { + settingList.remove(s); + s=settingList.current(); + } + else { + s=settingList.next(); + } + } +} + + +/*! + Gets the setting value of the given setting. +*/ +QString QAD_Settings::getSetting(QString name) +{ + QAD_Setting* s; + + for(s=settingList.first(); s!=0; s=settingList.next()) { + if(s->getName()==name) return s->getValue(); + } + + return ""; +} + +/*! + Replaces variables in the given string by their values. +*/ +QString QAD_Settings::replace(QString str) +{ + if(!str.contains('$')) return str; + + QAD_Setting* t; + QString result=str.copy(); + int i; + bool found; + + // Replace until we have no occurences of variables or recursive counter>16: + do { + found=false; + for(t=settingList.first(); t!=0; t=settingList.next()) { + if(result.contains('$')) { + i=0; + do { + i = result.find(QRegExp("\\$" + t->getName() + "[^a-zA-z0-9_]"), i); + if(i!=-1) { + result.replace(i, (int)t->getName().length()+1, t->getValue()); + found=true; + } + }while(i!=-1); + } + else goto end; + } + } while(found); + + end: + + return result; +} + +/*! + Returns true if list contains given setting +*/ +bool QAD_Settings::hasSetting(QString name) +{ + QAD_Setting* s; + + for(s=settingList.first(); s!=0; s=settingList.next()) { + if(s->getName()==name) return true; + } + return false; +} + +// EOF + diff --git a/src/SALOMEGUI/QAD_Settings.h b/src/SALOMEGUI/QAD_Settings.h new file mode 100644 index 000000000..ee0555a44 --- /dev/null +++ b/src/SALOMEGUI/QAD_Settings.h @@ -0,0 +1,113 @@ +// File : QAD_Settings.h +// Created : Tue Sep 04 09:30:33 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_SETTINGS_H +#define QAD_SETTINGS_H + +#include +#include +#include + +/*! + Class Setting wraps a single setting with a name and a value. +*/ +class QAD_Setting +{ + +public: + /** Constructor. */ + QAD_Setting() { autoValue=true; } + QAD_Setting( QString _name, QString _value, bool _autoValue=true ) + { name=_name; value=_value; autoValue=_autoValue; } + + ~QAD_Setting() {} + + /** Sets the name of this setting. */ + void setName(QString _name) + { name=_name; } + + /** Gets the name of this setting. */ + QString getName() + { return name; } + + /** Sets the value of this setting. */ + void setValue(QString _value) + { value=_value; } + + /** Gets the value of the setting. */ + QString getValue() + { return value; } + + /** Sets the auto value flag. */ + void setAutoValue(bool _av) + { autoValue=_av; } + + /** Gets the auto value flag. */ + bool isAutoValue() + { return autoValue; } + +private: + QString name; + QString value; + bool autoValue; +}; + + + +class QAD_Settings : public QObject +{ + Q_OBJECT + +public: + /** Constructor. */ + QAD_Settings() { settingList.setAutoDelete(true); } + QAD_Settings(QString _sectionName, + QChar _nameStarter, QChar _nameStopper, + QChar _valueStarter, QChar _valueStopper); + QAD_Settings(QString _sectionName, + QChar _nameStarter, QChar _separator, + QChar _valueStopper); + QAD_Settings(QChar _nameStopper, QChar _valueStarter, + QChar _valueStopper); + virtual ~QAD_Settings(); + + /** Returns the list of settings as a QList. */ + QList* getSettingList() { return &settingList; } + + /** Sets the name of the section where this settings are saved. */ + virtual void setSectionName(QString name) { sectionName=name; } + + virtual void clear(); + virtual void addSetting(QString _name, QString _value, bool _autoValue=true); + virtual void addSetting(QString _name, int _value, bool _autoValue=true); + virtual void addSetting(QString _name, double _value, bool _autoValue=true); + virtual bool removeSettings(QString name); + virtual void removeNonAutoSettings(); + virtual QString getSetting(QString name); + virtual QString replace(QString str); + virtual bool hasSetting(QString name); + +protected: + /** The list which contains all stored settings. */ + QList settingList; + +private: + QString sectionName; + QChar nameStarter; + QChar nameStopper; + QChar valueStarter; + QChar valueStopper; + +}; + +#endif + + + + + diff --git a/src/SALOMEGUI/QAD_SpinBoxDbl.cxx b/src/SALOMEGUI/QAD_SpinBoxDbl.cxx new file mode 100644 index 000000000..ddcde43d2 --- /dev/null +++ b/src/SALOMEGUI/QAD_SpinBoxDbl.cxx @@ -0,0 +1,1227 @@ +using namespace std; +// File : QAD_SpinBoxDbl.cxx +// Created : UI team, 21.11.02 +// Descr : Spin box for double values + +// Modified : Fri Nov 22 09:30:11 2002 +// Author : Vadim SANDLER +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "QAD_SpinBoxDbl.h" +#include +#include +#include +#include +#include +#include +#include +#include + +//****************************************************************************** +// QDblRangeControl class +//****************************************************************************** + +/*! + Constructs a range control with min value 0.00, max value 99.99, + line step 0.1, page step 1.00, precision 6, double precision 10e-6, + convertion flag 'g' and initial value 0.00. +*/ +QDblRangeControl::QDblRangeControl() +{ + prec = 6; + dblPrec = 10e-6; + convFlag = 'g'; + minVal = roundPrecision( 0.00 ); + maxVal = roundPrecision( 99.99 ); + line = roundPrecision( 0.10 ); + page = roundPrecision( 1.00 ); + prevVal = roundPrecision( -0.10 ); + val = bound( 0.00 ); +} + +/*! + Constructs a range control whose value can never be smaller than + or greater than , whose line step size is + and page step size is and whose value is + initially (which is guaranteed to be in range using bound()), + precision is , double precision is and + convertion flag is +*/ +QDblRangeControl::QDblRangeControl( double minValue, double maxValue, + double lineStep, double pageStep, + double value, + int precision, + double dblPrecision, + char cFlag ) +{ + prec = precision; + dblPrec = dblPrecision; + convFlag = cFlag; + minVal = roundPrecision( minValue ); + maxVal = roundPrecision( maxValue ); + line = roundPrecision( QABS( lineStep ) ); + page = roundPrecision( QABS( pageStep ) ); + prevVal = roundPrecision( minVal - 0.1 ); + val = bound( value ); +} + +/*! + Destroys the range control +*/ +QDblRangeControl::~QDblRangeControl() +{ +} + +/*! + Returns the current range control value. This is guaranteed to be + within the range [minValue(), maxValue()]. +*/ +inline double QDblRangeControl::value() const +{ return val; } + +/*! + Sets the range control's value to and forces it to be within + the legal range. + Calls the virtual valueChange() function if the new value is + different from the previous value. The old value can still be + retrieved using prevValue(). +*/ +void QDblRangeControl::setValue( double value ) +{ + directSetValue( value ); + if ( !equal(prevVal, val ) ) + valueChange(); +} + +/*! + Equivalent to {setValue( value() + pageStep() )}. + If the value is changed, then valueChange() is called. +*/ +void QDblRangeControl::addPage() +{ + setValue( value() + pageStep() ); +} + +/*! + Equivalent to {setValue( value() - pageStep() )}. + If the value is changed, then valueChange() is called. +*/ +void QDblRangeControl::subtractPage() +{ + setValue( value() - pageStep() ); +} + +/*! + Equivalent to {setValue( value() + lineStep() )}. + If the value is changed, then valueChange() is called. +*/ +void QDblRangeControl::addLine() +{ + setValue( value() + lineStep() ); +} + +/*! + Equivalent to {setValue( value() - lineStep() )}. + If the value is changed, then valueChange() is called. +*/ +void QDblRangeControl::subtractLine() +{ + setValue( value() - lineStep() ); +} + +/*! + Returns the current minimum value of the range. +*/ +inline double QDblRangeControl::minValue() const +{ return minVal; } + +/*! + Returns the current maximum value of the range. +*/ +inline double QDblRangeControl::maxValue() const +{ return maxVal; } + +/*! + Sets the range control's min value to and its max value + to . + + Calls the virtual rangeChange() function if one or both of the new + min and max values are different from the previous setting. Calls + the virtual valueChange() function if the current value is adjusted + because it was outside the new range. + + If is smaller than , becomes the + only legal value. +*/ +void QDblRangeControl::setRange( double minValue, double maxValue ) +{ + minValue = roundPrecision( minValue ); + maxValue = roundPrecision( maxValue ); + if ( minValue > maxValue ) { + maxValue = minValue; + } + if ( equal( minValue, minVal ) && equal( maxValue, maxVal ) ) + return; + minVal = minValue; + maxVal = maxValue; + double tmp = bound( val ); + rangeChange(); + if ( !equal( tmp, val ) ) { + prevVal = val; + val = tmp; + valueChange(); + } +} + +/*! + Sets the current minimum value of the range to . + If necessary, the maxValue() is adjusted so that the range remains + valid. +*/ +void QDblRangeControl::setMinValue( double minVal ) +{ + double maxVal = maxValue(); + if ( maxVal < minVal ) + maxVal = minVal; + setRange( minVal, maxVal ); +} + +/*! + Sets the current maximum value of the range to . + If necessary, the minValue() is adjusted so that the range remains + valid. +*/ +void QDblRangeControl::setMaxValue( double maxVal ) +{ + double minVal = minValue(); + if ( minVal > maxVal ) + minVal = maxVal; + setRange( minVal, maxVal ); +} + +/*! + Returns the current line step. +*/ +inline double QDblRangeControl::lineStep() const +{ return line; } + +/*! + Returns the current page step. +*/ +inline double QDblRangeControl::pageStep() const +{ return page; } + +/*! + Sets the range line step to and page step to . + Calls the virtual stepChange() function if the new line step and/or + page step are different from the previous settings. +*/ +void QDblRangeControl::setSteps( double lineStep, double pageStep ) +{ + lineStep = roundPrecision( QABS( lineStep ) ); + pageStep = roundPrecision( QABS( pageStep ) ); + if ( !equal( lineStep, line ) || !equal( pageStep, page ) ) { + line = lineStep; + page = pageStep; + stepChange(); + } +} + +/*! + Returs precision ( see QString::setNum() for details ) +*/ +int QDblRangeControl::precision() const +{ return prec; } + +/*! + Sets precision ( see QString::setNum() for details ) +*/ +void QDblRangeControl::setPrecision( int precision ) +{ + if ( precision > 0 && prec != precision ) { + prec = precision; + setRange( minValue(), maxValue() ); + setSteps( lineStep(), pageStep() ); + } +} + +/*! + Returns double precision which is used for rounding amd comparing + of double numbers +*/ +double QDblRangeControl::dblPrecision() const +{ return dblPrec; } + +/*! + Sets double precision which is used for rounding amd comparing + of double numbers +*/ +void QDblRangeControl::setDblPrecision( double dblPrecision ) +{ + dblPrecision = QABS( dblPrecision ); + if ( dblPrecision > 0 && dblPrecision != dblPrec ) { + dblPrec = dblPrecision; + setRange( minValue(), maxValue() ); + setSteps( lineStep(), pageStep() ); + } +} + +/*! + Returns convertion flag ( see QString::setNum() for details ) +*/ +char QDblRangeControl::convertFlag() const +{ return convFlag; } + +/*! + Sets convertion flag ( see QString::setNum() for details ) +*/ +void QDblRangeControl::setConvertFlag( char cFlag ) +{ + if ( ( cFlag == 'f' || cFlag == 'F' || cFlag == 'e' || + cFlag == 'E' || cFlag == 'g' || cFlag == 'G' ) && + ( cFlag != convFlag ) ) { + convFlag = cFlag; + setRange( minValue(), maxValue() ); + setSteps( lineStep(), pageStep() ); + } +} + +/*! + Forces the value to be within the range from minValue() to + maxValue() inclusive, and returns the result. + + This function is provided so that you can easily force other numbers + than value() into the allowed range. You do not need to call it in + order to use QDblRangeControl itself. +*/ +double QDblRangeControl::bound( double v ) const +{ + if ( v < minVal ) + return minVal; + if ( v > maxVal ) + return maxVal; + return roundPrecision( v ); +} + +/*! + Sets the range control value directly without calling valueChange(). + Forces the new value to be within the legal range. + + You will rarely have to call this function. However, if you want to + change the range control's value inside the overloaded method + valueChange(), setValue() would call the function valueChange() + again. To avoid this recursion you must use directSetValue() + instead. +*/ +void QDblRangeControl::directSetValue( double value ) +{ + prevVal = val; + val = bound( value ); +} + +/*! + Returns the previous value of the range control. "Previous value" + means the value before the last change occurred. Setting a new range + may affect the value, too, because the value is forced to be inside + the specified range. When the range control is initially created, + this is the same as value(). + + prevValue() can be outside the current legal range if a call to + setRange() causes the current value to change. For example, if the + range was [0, 1000] and the current value is 500, setRange(0, 400) + makes value() return 400 and prevValue() return 500. +*/ +inline double QDblRangeControl::prevValue() const +{ return prevVal; } + +/*! + This virtual function is called whenever the range control value + changes. You can reimplement it if you want to be notified when the + value changes. The default implementation does nothing. + + Note that this method is called after the value changed. The previous + value can be retrieved using prevValue(). +*/ +void QDblRangeControl::valueChange() +{ +} + +/*! + This virtual function is called whenever the range control's range + changes. You can reimplement it if you want to be notified when the range + changes. The default implementation does nothing. + + Note that this method is called after the range changed. +*/ +void QDblRangeControl::rangeChange() +{ +} + +/*! + This virtual function is called whenever the range control's + line/page step settings change. You can reimplement it if you want + to be notified when the step changes. The default implementation + does nothing. + + Note that this method is called after the step settings change. +*/ +void QDblRangeControl::stepChange() +{ +} + +/*! + returns true if values qre equal ( with tolerance = dblPrecision() ) +*/ +bool QDblRangeControl::equal( double first, double second ) const +{ + return QABS( first - second ) < dblPrecision(); +} + +/*! + Retuns rounded value +*/ +double QDblRangeControl::roundPrecision( double value) const +{ + bool bOk; + QString convertor; + convertor.setNum( value, convertFlag(), precision() ); + double newValue = convertor.toDouble(&bOk); + if ( bOk ) { + if ( QABS( newValue ) < dblPrecision() ) + newValue = 0.0; + } + else { + newValue = value; + } + return newValue; +} + +//****************************************************************************** +// QAD_SpinBox class +//****************************************************************************** + +/*! + Returns true if ends by [ static ] +*/ +static bool endsWith(const QString& str, const QString& substr) +{ +#if QT_VERSION < 0x030000 + if ( str.length() < substr.length() ) + return false; + return ( str.right( substr.length() ) == substr ); +#else + return str.endsWith(substr); +#endif +} + +/*! + Validator class for double value spin box +*/ +class QAD_SpinBoxDblValidator: public QDoubleValidator +{ +public: + QAD_SpinBoxDblValidator( QAD_SpinBoxDbl* sb, const char* name ) + : QDoubleValidator( sb, name ), + spinBox( sb ) {} + + State validate( QString& str, int& pos ) const; + +private: + QAD_SpinBoxDbl* spinBox; +}; + +/*! + Validates data entered +*/ +QValidator::State QAD_SpinBoxDblValidator::validate( QString& str, int& pos ) const +{ + QString pref = spinBox->prefix(); + QString suff = spinBox->suffix(); + uint overhead = pref.length() + suff.length(); + State state = Invalid; + + ((QDoubleValidator *) this)->setRange( spinBox->minValue(), + spinBox->maxValue() ); + if ( overhead == 0 ) { + state = QDoubleValidator::validate( str, pos ); + } else { + if ( str.length() >= overhead && + str.startsWith(pref) && + endsWith(str, suff) ) { + QString core = str.mid( pref.length(), str.length() - overhead ); + int corePos = pos - pref.length(); + state = QDoubleValidator::validate( core, corePos ); + pos = corePos + pref.length(); + str.replace( pref.length(), str.length() - overhead, core ); + } else { + state = QDoubleValidator::validate( str, pos ); + if ( state == Invalid ) { + // stripWhiteSpace(), cf. QAD_SpinBoxDbl::interpretText() + QString special = spinBox->specialValueText().stripWhiteSpace(); + QString candidate = str.stripWhiteSpace(); + + if ( special.startsWith(candidate) ) { + if ( candidate.length() == special.length() ) { + state = Acceptable; + } else { + state = Intermediate; + } + } + } + } + } + return state; +} + +/*! + Creates a spin box with min value 0.00, max value 99.99, + line step 0.1, precision 6, double precision 10e-6, + convertion flag 'g' and initial value 0.00. +*/ +QAD_SpinBoxDbl::QAD_SpinBoxDbl( QWidget* parent, const char* name ) +: QFrame(parent, name), + QDblRangeControl() +{ + initSpinBox(); +} + +/*! + Constructor + Creates a spin box with min value , max value , + line step , precision , double precision , + convertion flag and initial value +*/ +QAD_SpinBoxDbl::QAD_SpinBoxDbl( QWidget* parent, + double minValue, + double maxValue, + double step, + int precision, + double dblPrecision, + char cFlag, + const char* name ) +: QFrame( parent, name ), + QDblRangeControl( minValue, maxValue, step, step, minValue, precision, dblPrecision, cFlag ) +{ + initSpinBox(); +} + +/*! + Destructor +*/ +QAD_SpinBoxDbl::~QAD_SpinBoxDbl() +{} + +/*! + Internal initialization. +*/ +void QAD_SpinBoxDbl::initSpinBox() +{ + wrap = FALSE; + edited = FALSE; + butSymbols = UpDownArrows; + selreq = FALSE; + + up = new QPushButton( this, "up" ); + up->setFocusPolicy( QWidget::NoFocus ); + up->setAutoDefault( FALSE ); + up->setAutoRepeat( TRUE ); + + down = new QPushButton( this, "down" ); + down->setFocusPolicy( QWidget::NoFocus ); + down->setAutoDefault( FALSE ); + down->setAutoRepeat( TRUE ); + + validate = new QAD_SpinBoxDblValidator( this, "validator" ); + vi = new QLineEdit( this, "line editor" ); + vi->setFrame( FALSE ); + setFocusProxy( vi ); + setFocusPolicy( StrongFocus ); + vi->setValidator( validate ); + vi->installEventFilter( this ); + + setFrameStyle( Panel | Sunken ); + setLineWidth( 2 ); + +// setPalettePropagation( AllChildren ); +// setFontPropagation( AllChildren ); + + setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed ) ); + updateDisplay(); + + connect( up, SIGNAL(pressed()), SLOT(stepUp()) ); + connect( down, SIGNAL(pressed()), SLOT(stepDown()) ); + connect( vi, SIGNAL(textChanged(const QString&)), SLOT(textChanged()) ); +} + +/*! + Returns the current text of the spin box, including any prefix() and suffix(). +*/ +QString QAD_SpinBoxDbl::text() const +{ + return vi->text(); +} + +/*! + Returns a copy of the current text of the spin box with any prefix + and/or suffix and white space at the start and end removed. +*/ +QString QAD_SpinBoxDbl::cleanText() const +{ + QString s = QString(text()).stripWhiteSpace(); + if ( !prefix().isEmpty() ) { + QString px = QString(prefix()).stripWhiteSpace(); + int len = px.length(); + if ( len && s.left(len) == px ) // Remove _only_ if it is the prefix + s.remove( 0, len ); + } + if ( !suffix().isEmpty() ) { + QString sx = QString(suffix()).stripWhiteSpace(); + int len = sx.length(); + if ( len && s.right(len) == sx ) // Remove _only_ if it is the suffix + s.truncate( s.length() - len ); + } + return s.stripWhiteSpace(); +} + +/*! + Sets the special-value text to text. If set, the spin box will + display this text instead of a numeric value whenever the current + value is equal to minVal(). Typically used for indicating that this + choice has a special (default) meaning. +*/ +void QAD_SpinBoxDbl::setSpecialValueText( const QString &text ) +{ + specText = text; + updateDisplay(); +} + +/*! + Returns the currently special-value text, or a null string if no + special-value text is currently set. +*/ +QString QAD_SpinBoxDbl::specialValueText() const +{ + if ( specText.isEmpty() ) + return QString::null; + else + return specText; +} + +/*! + Sets the prefix to . The prefix is prepended to the start of + the displayed value. Typical use is to indicate the unit of + measurement to the user. +*/ +void QAD_SpinBoxDbl::setPrefix( const QString &text ) +{ + pfix = text; + updateDisplay(); +} + +/*! + Sets the suffix to . The suffix is appended to the end of the + displayed value. Typical use is to indicate the unit of measurement + to the user. +*/ +void QAD_SpinBoxDbl::setSuffix( const QString &text ) +{ + sfix = text; + updateDisplay(); +} + +/*! + Returns the currently set prefix, or a null string if no prefix is set. +*/ +QString QAD_SpinBoxDbl::prefix() const +{ + if ( pfix.isEmpty() ) + return QString::null; + else + return pfix; +} + +/*! + Returns the currently set suffix, or a null string if no suffix is set. +*/ +QString QAD_SpinBoxDbl::suffix() const +{ + if ( sfix.isEmpty() ) + return QString::null; + else + return sfix; +} + +/*! + Setting wrapping to TRUE will allow the value to be stepped from the + highest value to the lowest, and vice versa. By default, wrapping is + turned off. +*/ +void QAD_SpinBoxDbl::setWrapping( bool on ) +{ + wrap = on; + updateDisplay(); +} + +/*! + Returns the current setWrapping() value. +*/ +bool QAD_SpinBoxDbl::wrapping() const +{ + return wrap; +} + +/*! + Reimplementation +*/ +QSize QAD_SpinBoxDbl::sizeHint() const +{ + constPolish(); + QFontMetrics fm = fontMetrics(); + int h = vi->sizeHint().height(); + if ( h < 12 ) // ensure enough space for the button pixmaps + h = 12; + int w = 35; // minimum width for the value + int wx = fm.width( ' ' )*2; + QString s; + + QAD_SpinBoxDbl* that = (QAD_SpinBoxDbl*)this; + s = prefix() + that->mapValueToText( that->minValue() ) + suffix(); + w = QMAX( w, fm.width( s ) + wx); + s = prefix() + that->mapValueToText( that->maxValue() ) + suffix(); + w = QMAX(w, fm.width( s ) + wx ); + if ( !specialValueText().isEmpty() ) { + s = specialValueText(); + w = QMAX( w, fm.width( s ) + wx ); + } + QSize r( h * 8/5 // ~ buttons width + + w // widest value + + frameWidth() * 2, // left/right frame + frameWidth() * 2 // top/bottom frame + + h // font height + ); + return r.expandedTo( QApplication::globalStrut() ); +} + +/*! + Does the layout of the lineedit and the buttons +*/ +void QAD_SpinBoxDbl::arrangeWidgets() +{ + if ( !up || !down ) // may happen if the application has a pointer error + return; + + QSize bs; // no, it's short for 'button size' + bs.setHeight( height()/2 - frameWidth() ); + if ( bs.height() < 8 ) + bs.setHeight( 8 ); + bs.setWidth( bs.height() * 8 / 5 ); // 1.6 - approximate golden mean + setFrameRect( QRect( 0, 0, 0, 0 ) ); + + if ( up->size() != bs || down->size() != bs ) { + up->resize( bs ); + down->resize( bs ); + updateButtonSymbols(); + } + + int y = frameWidth(); + int x = width() - y - bs.width(); + up->move( x, y ); + down->move( x, height() - y - up->height() ); + vi->setGeometry( frameWidth(), frameWidth(), + x - frameWidth(), height() - 2*frameWidth() ); +} + +/*! + Sets the current value of the spin box to . This is + QRangeControl::setValue() made available as a slot. +*/ +void QAD_SpinBoxDbl::setValue( double value ) +{ + QDblRangeControl::setValue( value ); +} + +/*! + Increases the current value one step, wrapping as necessary. This is + the same as clicking on the pointing-up button, and can be used for + e.g. keyboard accelerators. +*/ +void QAD_SpinBoxDbl::stepUp() +{ + if ( edited ) + interpretText(); + if ( wrapping() && ( value()+lineStep() > maxValue() ) ) + setValue( minValue() ); + else + addLine(); +} + +/*! + Decreases the current value one step, wrapping as necessary. This is + the same as clicking on the pointing-down button, and can be used + for e.g. keyboard accelerators. +*/ +void QAD_SpinBoxDbl::stepDown() +{ + if ( edited ) + interpretText(); + if ( wrapping() && ( value()-lineStep() < minValue() ) ) + setValue( maxValue() ); + else + subtractLine(); +} + +/*! + Intercepts and handles those events coming to the embedded QLineEdit + which have special meaning for the QAD_SpinBoxDbl. +*/ +bool QAD_SpinBoxDbl::eventFilter( QObject* obj, QEvent* ev ) +{ + if ( obj != vi ) + return FALSE; + + if ( ev->type() == QEvent::KeyPress ) { + QKeyEvent* k = (QKeyEvent*)ev; + + bool retval = FALSE; // workaround for MSVC++ optimization bug + if( (k->key() == Key_Tab) || (k->key() == Key_BackTab) ){ + if ( edited ) + interpretText(); + qApp->sendEvent( this, ev ); + retval = TRUE; + } if ( k->key() == Key_Up ) { + stepUp(); + retval = TRUE; + } else if ( k->key() == Key_Down ) { + stepDown(); + retval = TRUE; + } else if ( k->key() == Key_Return ) { + interpretText(); + return FALSE; + } + if ( retval ) + return retval; + } else if ( ev->type() == QEvent::FocusOut || ev->type() == QEvent::Leave || ev->type() == QEvent::Hide ) { + if ( edited ) { + interpretText(); + } + return FALSE; + } + return FALSE; +} + +/*! + Reimplementation +*/ +void QAD_SpinBoxDbl::leaveEvent( QEvent* ) +{ + if ( edited ) + interpretText(); +} + +/*! + Reimplementation +*/ +void QAD_SpinBoxDbl::resizeEvent( QResizeEvent* ) +{ + arrangeWidgets(); +} + +/*! + Reimplementation +*/ +void QAD_SpinBoxDbl::wheelEvent( QWheelEvent * e ) +{ + e->accept(); + static float offset = 0; + static QAD_SpinBoxDbl* offset_owner = 0; + if (offset_owner != this) { + offset_owner = this; + offset = 0; + } + offset += -e->delta()/120; + if (QABS(offset) < 1) + return; + int ioff = int(offset); + int i; + for (i=0; i 0 ? stepDown() : stepUp(); + offset -= ioff; +} + +/*! + This method gets called by QRangeControl whenever the value has changed. + Updates the display and emits the valueChanged() signals. +*/ +void QAD_SpinBoxDbl::valueChange() +{ + selreq = hasFocus(); + updateDisplay(); + selreq = FALSE; + emit valueChanged( value() ); + emit valueChanged( currentValueText() ); +} + +/*! + This method gets called by QRangeControl whenever the range has + changed. It adjusts the default validator and updates the display. +*/ +void QAD_SpinBoxDbl::rangeChange() +{ + updateDisplay(); +} + +/*! + Sets the validator to . The validator controls what keyboard + input is accepted when the user is editing in the value field. The + default is to use a suitable QIntValidator. +*/ +void QAD_SpinBoxDbl::setValidator( const QValidator* v ) +{ + if ( vi ) + vi->setValidator( v ); +} +/*! + Returns the validator which constrains editing for this spin box if + there is any, or else 0. +*/ +const QValidator* QAD_SpinBoxDbl::validator() const +{ + return vi ? vi->validator() : 0; +} + +/*! + Updates the contents of the embedded QLineEdit to reflect current + value, using mapValueToText(). Also enables/disables the push + buttons accordingly. +*/ +void QAD_SpinBoxDbl::updateDisplay() +{ + vi->setUpdatesEnabled( FALSE ); + vi->setText( currentValueText() ); + if ( selreq && isVisible() && ( hasFocus() || vi->hasFocus() ) ) { + selectAll(); + } else { + if ( !suffix().isEmpty() && + endsWith(vi->text(), suffix()) ) + vi->setCursorPosition( vi->text().length() - suffix().length() ); + } + vi->setUpdatesEnabled( TRUE ); + vi->repaint( FALSE ); // immediate repaint needed for some reason + edited = FALSE; + + up->setEnabled( isEnabled() && (wrapping() || value() < maxValue()) ); + down->setEnabled( isEnabled() && (wrapping() || value() > minValue()) ); + vi->setEnabled( isEnabled() ); +} + +/*! + QAD_SpinBoxDbl calls this after the user has manually edited the contents + of the spin box (not using the up/down buttons/keys). + The default implementation of this function interprets the new text + using mapTextToValue(). If mapTextToValue() is successful, it + changes the spin box' value. If not the value if left unchanged. +*/ +void QAD_SpinBoxDbl::interpretText() +{ + bool ok = TRUE; + bool done = FALSE; + double newVal = 0; + if ( !specialValueText().isEmpty() ) { + QString s = QString(text()).stripWhiteSpace(); + QString t = QString(specialValueText()).stripWhiteSpace(); + if ( s == t ) { + newVal = minValue(); + done = TRUE; + } + } + if ( !done ) + newVal = mapTextToValue( &ok ); + if ( ok ) + setValue( newVal ); + updateDisplay(); // Sometimes redundant +} + +/*! + Returns a pointer to the embedded 'up' button. +*/ + +QPushButton* QAD_SpinBoxDbl::upButton() const +{ + return up; +} + +/*! + Returns a pointer to the embedded 'down' button. +*/ +QPushButton* QAD_SpinBoxDbl::downButton() const +{ + return down; +} + +/*! + Returns a pointer to the embedded QLineEdit. +*/ +QLineEdit* QAD_SpinBoxDbl::editor() const +{ + return vi; +} + +/*! + This slot gets called whenever the user edits the text of the spin box. +*/ +void QAD_SpinBoxDbl::textChanged() +{ + edited = TRUE; // This flag is cleared in updateDisplay() +}; + +/*! + This virtual function is used by the spin box whenever it needs to + display value . The default implementation returns a string + containing printed in the standard way. +*/ + +QString QAD_SpinBoxDbl::mapValueToText( double v ) +{ + QString s; + s.setNum( v, convertFlag(), precision() ); + return s; +} + +/*! + This virtual function is used by the spin box whenever it needs to + interpret the text entered by the user as a value. The default + implementation tries to interpret it as an integer in the standard + way, and returns the double value. +*/ +double QAD_SpinBoxDbl::mapTextToValue( bool* ok ) +{ + QString s = text(); + double newVal = s.toDouble( ok ); + if ( !(*ok) && !( !prefix() && !suffix() ) ) {// Try removing any pre/suffix + s = cleanText(); + newVal = s.toDouble( ok ); + } + return newVal; +} + +/*! + Returns the full text calculated from the current value, including any + prefix, suffix or special-value text. +*/ +QString QAD_SpinBoxDbl::currentValueText() +{ + QString s; + if ( (value() <= minValue()) && !specialValueText().isEmpty() ) { + s = specialValueText(); + } else { + s = prefix(); + s.append( mapValueToText( value() ) ); + s.append( suffix() ); + } + return s; +} + +/*! + Reimplementation +*/ +void QAD_SpinBoxDbl::setEnabled( bool on ) +{ + bool b = isEnabled(); + QFrame::setEnabled( on ); + if ( isEnabled() != b ) { + // ## enabledChange() might have been a better choice + updateDisplay(); + } +} + +/*! + Reimplementation +*/ +void QAD_SpinBoxDbl::styleChange( QStyle& old ) +{ + setFrameStyle( Panel | Sunken ); + arrangeWidgets(); + QWidget::styleChange( old ); +} + +/*! + Sets the spin box to display on its buttons. + can be either (the default) or . +*/ +void QAD_SpinBoxDbl::setButtonSymbols( ButtonSymbols newSymbols ) +{ + if ( buttonSymbols() == newSymbols ) + return; + butSymbols = newSymbols; + updateButtonSymbols(); +} + +/*! + Returns the current button symbol mode. The default is +*/ +QAD_SpinBoxDbl::ButtonSymbols QAD_SpinBoxDbl::buttonSymbols() const +{ + return butSymbols; +} + +/*! + This function uses the pixmap cache for a Different Reason: the + pixmap cache also preserves QPixmap::serialNumber(). by doing + this, QButton::setPixmap() is able to avoid flicker e.g. when the + spin box is resized in such a way that the height of the buttons + does not change (common the default size policy). +*/ +void QAD_SpinBoxDbl::updateButtonSymbols() +{ + QString key( QString::fromLatin1( "$qt$QAD_SpinBoxDbl$" ) ); + bool pmSym = buttonSymbols() == PlusMinus; + key += QString::fromLatin1( pmSym ? "+-" : "^v" ); + key += QString::number( down->height() ); + QString upKey = key + QString::fromLatin1( "$up" ); + QString dnKey = key + QString::fromLatin1( "$down" ); + QBitmap upBm; + QBitmap dnBm; + + bool found = QPixmapCache::find( dnKey, dnBm ) + && QPixmapCache::find( upKey, upBm ); + + if ( !found ) { + QPainter p; + if ( pmSym ) { + int h = down->height()-4; + if ( h < 3 ) + return; + else if ( h == 4 ) + h = 3; + else if ( (h > 6) && (h & 1) ) + h--; + h -= ( h / 8 ) * 2; // Empty border + dnBm.resize( h, h ); + p.begin( &dnBm ); + p.eraseRect( 0, 0, h, h ); + p.setBrush( color1 ); + int c = h/2; + p.drawLine( 0, c, h, c ); + if ( !(h & 1) ) + p.drawLine( 0, c-1, h, c-1 ); + p.end(); + upBm = dnBm; + p.begin( &upBm ); + p.drawLine( c, 0, c, h ); + if ( !(h & 1) ) + p.drawLine( c-1, 0, c-1, h ); + p.end(); + } + else { + int w = down->width()-4; + if ( w < 3 ) + return; + else if ( !(w & 1) ) + w--; + w -= ( w / 7 ) * 2; // Empty border + int h = w/2 + 2; // Must have empty row at foot of arrow + dnBm.resize( w, h ); + p.begin( &dnBm ); + p.eraseRect( 0, 0, w, h ); + QPointArray a; + a.setPoints( 3, 0, 1, w-1, 1, h-2, h-1 ); + p.setBrush( color1 ); + p.drawPolygon( a ); + p.end(); +#ifndef QT_NO_TRANSFORMATIONS + QWMatrix wm; + wm.scale( 1, -1 ); + upBm = dnBm.xForm( wm ); +#else + upBm.resize( w, h ); + p.begin( &upBm ); + p.eraseRect( 0, 0, w, h ); + a.setPoints( 3, 0, h-2, w-1, h-2, h-2, 0 ); + p.setBrush( color1 ); + p.drawPolygon( a ); + p.end(); +#endif + } + QPixmapCache::insert( dnKey, dnBm ); + QPixmapCache::insert( upKey, upBm ); + } + down->setPixmap( dnBm ); + up->setPixmap( upBm ); +} + +/*! + Returns minimum value, reimplementaion +*/ +double QAD_SpinBoxDbl::minValue() +{ + return QDblRangeControl::minValue(); +} + +/*! + Returns maximum value, reimplementaion +*/ +double QAD_SpinBoxDbl::maxValue() +{ + return QDblRangeControl::maxValue(); +} + +/*! + Sets minimum value, reimplementaion +*/ +void QAD_SpinBoxDbl::setMinValue( double minValue ) +{ + QDblRangeControl::setMinValue( minValue ); +} + +/*! + Sets maximum value, reimplementaion +*/ +void QAD_SpinBoxDbl::setMaxValue( double maxValue ) +{ + QDblRangeControl::setMaxValue( maxValue ); +} + +/*! + Returns step size, reimplementaion +*/ +double QAD_SpinBoxDbl::lineStep() +{ + return QDblRangeControl::lineStep(); +} + +/*! + Sets step size +*/ +void QAD_SpinBoxDbl::setLineStep( double step ) +{ + setSteps( step, pageStep() ); +} + +/*! + Returns value of the spin box, reimplementaion +*/ +double QAD_SpinBoxDbl::value() +{ + QAD_SpinBoxDbl* that = ( QAD_SpinBoxDbl* ) this; + if ( edited ) { + that->edited = FALSE; // avoid recursion + that->interpretText(); + } + return QDblRangeControl::value(); +} + +/*! + Selects all the text in the editor of the spinbox. +*/ +void QAD_SpinBoxDbl::selectAll() +{ + int overhead = prefix().length() + suffix().length(); + if ( !overhead || currentValueText() == specialValueText() ) { + vi->selectAll(); + } else { + vi->setSelection( prefix().length(), vi->text().length() - overhead ); + } +} diff --git a/src/SALOMEGUI/QAD_SpinBoxDbl.h b/src/SALOMEGUI/QAD_SpinBoxDbl.h new file mode 100644 index 000000000..c592ada7b --- /dev/null +++ b/src/SALOMEGUI/QAD_SpinBoxDbl.h @@ -0,0 +1,193 @@ +// File : QAD_SpinBoxDbl.h +// Created : UI team, 21.11.02 +// Descr : Spin box for double values + +// Modified : Fri Nov 22 09:30:11 2002 +// Author : Vadim SANDLER +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef QAD_SPINBOXDBL_H +#define QAD_SPINBOXDBL_H + +#include "QAD.h" +#include + +class QAD_EXPORT QDblRangeControl +{ +public: + QDblRangeControl(); + QDblRangeControl( double minValue, double maxValue, + double lineStep, double pageStep, + double value, + int precision = 6, + double dblPrecision = 10e-6, + char cFlag = 'g'); + virtual ~QDblRangeControl(); + double value() const; + void setValue( double ); + void addPage(); + void subtractPage(); + void addLine(); + void subtractLine(); + + double minValue() const; + double maxValue() const; + void setRange( double minValue, double maxValue ); + void setMinValue( double minVal ); + void setMaxValue( double minVal ); + + double lineStep() const; + double pageStep() const; + void setSteps( double line, double page ); + + int precision() const; + void setPrecision( int precision ); + double dblPrecision() const; + void setDblPrecision( double dblPrecision ); + char convertFlag() const; + void setConvertFlag( char cFlag ); + + double bound( double ) const; + +protected: + void directSetValue( double val ); + double prevValue() const; + + virtual void valueChange(); + virtual void rangeChange(); + virtual void stepChange(); + bool equal( double first, double second ) const; + double roundPrecision( double value) const; + +private: + double minVal, maxVal; + double line, page; + double val, prevVal; + int prec; + double dblPrec; + char convFlag; + +private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + QDblRangeControl( const QDblRangeControl & ); + QDblRangeControl &operator=( const QDblRangeControl & ); +#endif +}; + +class QPushButton; +class QLineEdit; +class QValidator; + +class QAD_EXPORT QAD_SpinBoxDbl: public QFrame, public QDblRangeControl +{ + Q_OBJECT + +public: + QAD_SpinBoxDbl( QWidget* parent, const char* name = 0 ); + QAD_SpinBoxDbl( QWidget* parent, + double minValue, + double maxValue, + double step, + int precision = 6, + double dblPrecision = 10e-6, + char cFlag = 'g', + const char* name = 0 ); + ~QAD_SpinBoxDbl(); + + QString text() const; + + virtual QString prefix() const; + virtual QString suffix() const; + virtual QString cleanText() const; + + virtual void setSpecialValueText( const QString &text ); + QString specialValueText() const; + + virtual void setWrapping( bool on ); + bool wrapping() const; + + enum ButtonSymbols { UpDownArrows, PlusMinus }; + void setButtonSymbols( ButtonSymbols ); + ButtonSymbols buttonSymbols() const; + + virtual void setValidator( const QValidator* v ); + const QValidator* validator() const; + + QSize sizeHint() const; + + double minValue(); + double maxValue(); + void setMinValue( double ); + void setMaxValue( double ); + double lineStep(); + void setLineStep( double ); + double value(); + +public slots: + virtual void setValue( double ); + virtual void setPrefix( const QString &text ); + virtual void setSuffix( const QString &text ); + virtual void stepUp(); + virtual void stepDown(); + virtual void setEnabled( bool ); + virtual void selectAll(); + +signals: + void valueChanged( double value ); + void valueChanged( const QString &valueText ); + +protected: + virtual QString mapValueToText( double value ); + virtual double mapTextToValue( bool* ok ); + QString currentValueText(); + + virtual void updateDisplay(); + virtual void interpretText(); + + QPushButton* upButton() const; + QPushButton* downButton() const; + QLineEdit* editor() const; + + virtual void valueChange(); + virtual void rangeChange(); + + bool eventFilter( QObject* obj, QEvent* ev ); + void resizeEvent( QResizeEvent* ev ); + void wheelEvent( QWheelEvent * ); + void leaveEvent( QEvent* ); + + void styleChange( QStyle& ); + +protected slots: + void textChanged(); + +private: + void initSpinBox(); + + ButtonSymbols butSymbols; + QPushButton* up; + QPushButton* down; + QLineEdit* vi; + QValidator* validate; + QString pfix; + QString sfix; + QString specText; + bool wrap; + bool edited; + bool selreq; + + void arrangeWidgets(); + void updateButtonSymbols(); + + private: // Disabled copy constructor and operator= +#if defined(Q_DISABLE_COPY) + QAD_SpinBoxDbl( const QAD_SpinBoxDbl& ); + QAD_SpinBoxDbl& operator=( const QAD_SpinBoxDbl& ); +#endif + +}; + +#endif diff --git a/src/SALOMEGUI/QAD_Splitter.cxx b/src/SALOMEGUI/QAD_Splitter.cxx new file mode 100644 index 000000000..dd2ac2678 --- /dev/null +++ b/src/SALOMEGUI/QAD_Splitter.cxx @@ -0,0 +1,34 @@ +using namespace std; +// File : QAD_Splitter.cxx +// Created : Thu Jun 14 16:36:01 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "QAD_Splitter.h" + +/*! + Constructs an horizontal splitter. +*/ + +QAD_Splitter::QAD_Splitter( QWidget *parent, const char *name ) + :QSplitterP(parent,name) +{ +} + +/*! + Constructs splitter with orientation \a o. +*/ +QAD_Splitter::QAD_Splitter( Orientation o, QWidget *parent, const char *name ) + :QSplitterP(o, parent, name) +{ +} + +/*! + Destructs the splitter. +*/ +QAD_Splitter::~QAD_Splitter() +{ +} diff --git a/src/SALOMEGUI/QAD_Splitter.h b/src/SALOMEGUI/QAD_Splitter.h new file mode 100644 index 000000000..5c5825a2e --- /dev/null +++ b/src/SALOMEGUI/QAD_Splitter.h @@ -0,0 +1,23 @@ +// File : QAD_Splitter.h +// Created : Thu Jun 14 16:35:23 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_SPLITTER_H +#define QAD_SPLITTER_H + +#include + +class QSplitterP; +class QAD_Splitter : public QSplitterP +{ +public: + QAD_Splitter( QWidget *parent=0, const char *name=0 ); + QAD_Splitter( Orientation, QWidget *parent=0, const char *name=0 ); + ~QAD_Splitter(); +}; + +#endif diff --git a/src/SALOMEGUI/QAD_Study.cxx b/src/SALOMEGUI/QAD_Study.cxx new file mode 100644 index 000000000..113237997 --- /dev/null +++ b/src/SALOMEGUI/QAD_Study.cxx @@ -0,0 +1,1287 @@ +using namespace std; +// File : QAD_Study.cxx +// Created : UI team, 05.09.00 +// Descr : Study for QAD-based application + +// Modified : Mon Dec 03 14:20:05 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + +/*! + \class QAD_Study QAD_Study.h + \brief Study for QAD-based application. +*/ + +#include "QAD.h" +#include "QAD_Tools.h" +#include "QAD_Desktop.h" +#include "QAD_Study.h" +#include "QAD_RightFrame.h" +#include "QAD_LeftFrame.h" +#include "QAD_MessageBox.h" +#include "QAD_Application.h" +#include "QAD_ObjectBrowser.h" +#include "QAD_PyInterp.h" +#include "QAD_Config.h" + +#include "utilities.h" + +#include "SALOME_Selection.h" +#include "SALOME_TypeFilter.hxx" +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +// OPEN CASCADE Include +#include + +// QT Include +#include + +#define MAX_UNDO 10 +/*! + Constructor +*/ +QAD_Study::QAD_Study(QAD_Application* app, + SALOMEDS::Study_var aStudy, + const QString& path ) : +myOperationState( Undef ), +myApp( app ), +myActiveStudyFrame( 0 ), +myStudyFrameCount( 0 ), +myPath( path ) +{ + myStudy = aStudy; + + myTitle = QAD_Tools::getFileNameFromPath( path, false ); + + myIsActive = false; + myIsSaved = false; + myIsModified = false; + myIsReadOnly = false; + + myStudyFrames.clear(); + myOperations.clear(); + + myStudyFrames.setAutoDelete( true ); + myOperations.setAutoDelete( true ); + myChildWidgets.setAutoDelete( true ); + + /* create python interpreter */ + _interp = new QAD_PyInterp(); + SCRUTE(_interp); + + /* create default selection */ + Selection( "Salome" ); + + /* create study frame */ + myResult = true; + createStudyFrame( getNextStudyFrameName() ); + + /* set default Undo/Redo limit */ + QAD_ASSERT_DEBUG_ONLY( !myStudy->_is_nil() ); + SALOMEDS::StudyBuilder_var SB = myStudy->NewBuilder(); + SB->UndoLimit( MAX_UNDO ); +} + +/*! + Destructor +*/ +QAD_Study::~QAD_Study () +{ + close(); +} + +/*! + Returns TRUE if Study is created correctly. Returns FALSE otherwise. +*/ +bool QAD_Study::getResult() +{ + return myResult; +} + + +//=======================================================================// +// StudyFrames management // +//=======================================================================// +/*! + Adds study frame +*/ +void QAD_Study::addStudyFrame(QAD_StudyFrame* sf ) +{ + myStudyFrames.append( sf ); + + sf->getRightFrame()->getViewFrame()->setPopupServer( myApp ); + // Provide the same common popup menu commands for both the Object Browser and 3D viewer + sf->getLeftFrame()->getObjectBrowser()->setPopupServer( myApp ); + + /* icon of Study Frame */ + const QPixmap& icon = myApp->getApplicationIcon(); + if ( !icon.isNull() ) + sf->setIcon ( icon ); + + /* activation */ + QAD_ASSERT ( connect( sf, SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*) ), + SLOT(onStudyFrameActivated(QAD_StudyFrame*))) ); + + /* closing */ + QAD_ASSERT ( connect( sf, + SIGNAL(sfStudyFrameClosing(QAD_StudyFrame*) ), + this, + SLOT(onLastStudyFrameClosing(QAD_StudyFrame*))) ); + + /* set active sf */ + myActiveStudyFrame = sf; +} + +/*! + Removes studyframe from the list +*/ +void QAD_Study::removeStudyFrame( QAD_StudyFrame* sf ) +{ + if (sf) { + if (!myStudy->IsEmpty()) { + SALOMEDS::SObject_var fatherSF = myStudy->FindObjectID(sf->entry()); + if (!fatherSF->_is_nil()) { + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + aStudyBuilder->RemoveObject(fatherSF); + } + + updateObjBrowser( true ); + } + myStudyFrames.removeRef( sf ); + } +} + +/*! + Returns number of study frames +*/ +int QAD_Study::getStudyFramesCount() const +{ + return myStudyFrames.count(); +} + +/*! + Returns study frame by its index in list +*/ +QAD_StudyFrame* QAD_Study::getStudyFrame( unsigned i ) +{ + return myStudyFrames.at(i); +} + +/*! + Returns study frame by its name or null if not found +*/ +QAD_StudyFrame* QAD_Study::getStudyFrameByName ( const QString& name ) +{ + for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf; sf = myStudyFrames.next() ) + { + if ( sf->title().compare(name) == 0 ) { + return sf; + } + } + return NULL; +} + +/*! + Returns first study frame in the list +*/ +QAD_StudyFrame* QAD_Study::getFirstStudyFrame() +{ + return myStudyFrames.first(); +} + +/*! + Returns last study frame in the list +*/ +QAD_StudyFrame* QAD_Study::getLastStudyFrame() +{ + return myStudyFrames.last(); +} + +/*! + Returns the vector of studyframes +*/ +const QList& QAD_Study::getStudyFrames() const +{ + return myStudyFrames; +} + +/*! + Returns the active study frame +*/ +QAD_StudyFrame* QAD_Study::getActiveStudyFrame() const +{ + return myActiveStudyFrame; +} + +//=======================================================================// +// Study properties // +//=======================================================================// +/*! + Returns reference to supporting application +*/ +QAD_Application* QAD_Study::getApp() const +{ + return myApp; +} + +/*! + Returns the name of document ( filename without path and extension ) +*/ +const QString& QAD_Study::getTitle() const +{ + return myTitle; +} + +/*! + Returns the absolute file path of this document +*/ +const QString& QAD_Study::getPath() const +{ + return myPath; +} + +/*! + Changes the name of document +*/ +void QAD_Study::setTitle( const QString& path ) +{ + myPath = path; + + QString title = QAD_Tools::getFileNameFromPath( path, false ); + QAD_ASSERT_DEBUG_ONLY ( !title.isNull() ); + + for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf ; sf = myStudyFrames.next() ) + { + QString oldName = sf->title(); + int k = oldName.find( myTitle, 0, false ); + QString restName = ( oldName.length() > myTitle.length() + k) ? + oldName.right(oldName.length() - (myTitle.length() + k) + 1) : + QString( "" ); + + if ( k != -1 ) + { + QString newName; + if ( k == 0 ) { + int l = restName.find( "#", 0, false ); + int ll = restName.length(); + newName = title + restName.mid( l, ll-l ); + } else { + newName = oldName.mid(0, k); + newName = newName + title + restName; + } + sf->setTitle( newName ); + } + } + myTitle = title; + + Selection( QAD_Application::getDesktop()->getActiveComponent() ); +} + +/*! + Returns whether the document is active +*/ +bool QAD_Study::isActive() const +{ + return myIsActive; +} + +/*! + Returns whether the document is read only +*/ +bool QAD_Study::isReadOnly() const +{ + return myIsReadOnly; +} + +/*! + Sets read-only property +*/ +void QAD_Study::setReadOnly(bool state) +{ + myIsReadOnly = state; +} + +//=======================================================================// +// Study operations // +//=======================================================================// +/*! + Performs specific study frame related actions when it is activated. + By default resumes all suspended operations. +*/ +void QAD_Study::onStudyFrameActivated( QAD_StudyFrame* activeStudyFrame ) +{ + static int IS_FIRST_STUDY = 1; + if(IS_FIRST_STUDY){ //for normally initialize "salome.py and ..." + _interp->run(""); IS_FIRST_STUDY = 0; + } +// bool found = false; + for ( QAD_StudyFrame* studyframe = myStudyFrames.first(); studyframe; studyframe = myStudyFrames.next() ) { + if ( studyframe == activeStudyFrame) { /* one of my study frames */ +// found = true; +// if ( !myActiveStudyFrame || myActiveStudyFrame != activeStudyFrame ) { + myActiveStudyFrame = activeStudyFrame; + //NRI if ( !myIsActive ) { + myIsActive = true; + resumeAllOperations(); + /* activate application */ + myApp->onStudyActivated( this ); + //NRI } +// } +// return; + } + } +// if (!found) +// myActiveStudyFrame = 0; +} + + +/*! + Performs specific study related actions when it is deactivated. + By default suspends all performing operations. +*/ +void QAD_Study::onStudyDeactivated() +{ + // MESSAGE ("QAD_Study::onStudyDeactivated init. "); + myIsActive = false; + suspendAllOperations(); + // MESSAGE ("QAD_Study::onStudyDeactivated done. "); +} + +/*! + Closes all study frames of the study and performs other specific study + related actions needed for proper closing of the study +*/ +void QAD_Study::close() +{ + if ( !myStudy->_is_nil() ) + abortAllOperations(); + /* clear each study frame */ + for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf; sf = myStudyFrames.first() ) { + sf->disconnect(); + sf->close(); + qApp->processEvents(); + qApp->processEvents(); + removeStudyFrame(sf); + } + + /* delete all studyframes */ + myStudyFrames.clear(); + myOperations.clear(); + myChildWidgets.clear(); + +// QWorkspace* ws = QAD_Application::getDesktop()->getMainFrame(); +// if (/* !ws->activeWindow() && */ws->windowList().count() > 0 ) +// ws->activateWindow(ws->windowList().last()); +} + +//=======================================================================// +// Operations management // +//=======================================================================// +/*! + Returns number of completed operations +*/ +int QAD_Study::getOperationsCount() const +{ + return myOperations.count(); +} + +/*! + Returns the state of the last operation +*/ +OperationState QAD_Study::getOperationState() const +{ + return myOperationState; +} + +/*! + Returns operation by its index in list +*/ +QAD_Operation* QAD_Study::getOperation( unsigned i) +{ + return ( myOperations.isEmpty() ? 0 : myOperations.at(i) ); +} + +/*! + Returns performing operation launched first +*/ +QAD_Operation* QAD_Study::getFirstOperation() +{ + return ( myOperations.isEmpty() ? 0 : myOperations.first() ); +} + +/*! + Returns performing operation launched last +*/ +QAD_Operation* QAD_Study::getLastOperation() +{ + return ( myOperations.isEmpty() ? 0 : myOperations.last() ); +} + +/*! + Aborts all performing operations +*/ +void QAD_Study::abortAllOperations() +{ + for ( QAD_Operation* op = myOperations.last(); op; + op = myOperations.prev() ) + op->abort(); +} + +/*! + Resumes all performing operations +*/ +void QAD_Study::resumeAllOperations() +{ + for ( QAD_Operation* op = myOperations.first(); op; + op = myOperations.next() ) + op->resume(); +} + +/*! + Suspendes all performing operations +*/ +void QAD_Study::suspendAllOperations() +{ + // MESSAGE ( " QAD_Study::suspendAllOperations init. " ) + for ( QAD_Operation* op = myOperations.last(); op; + op = myOperations.prev() ) + op->suspend(); +} + +/*! + Initializes the operation and checks its compatibility + with another operation in process if any. + Returns 'true' if init'ed OK, 'false' otherwise. +*/ +bool QAD_Study::initOperation( QAD_Operation* op ) +{ + if ( myIsReadOnly ) + { /* can't start a non-const operation */ + if ( op->changesData() ) + { + QAD_MessageBox::error1( QAD_Application::getDesktop(), tr("ERR_ERROR"), + tr("ERR_DOC_READONLY"), tr("BUT_OK") ); + return false; + } + } + + /* Add the new operation + */ + if ( myOperations.isEmpty() ) + myOperations.append( op ); + else + { + /* Check compatibility of new operation with the existing operations. + Since each operations is checked in that way, it's enough to check + the last operation only */ + if ( !getLastOperation()->compatibleWith( op ) ) + { + if ( QAD_MessageBox::warn2( QAD_Application::getDesktop(), tr("WRN_WARNING"), + tr("QUE_ABORTCURRENTOPERATION"), tr("BUT_YES"), + tr("BUT_NO"), QAD_YES, QAD_NO, QAD_NO ) + == QAD_NO ) + return false; + getLastOperation()->abort(); + } + myOperations.append( op ); + } + return true; +} + +/*! + Called when operation was finished. + Removes appointed operation from the list and aborted all operations + launched after it. +*/ +void QAD_Study::clearOperation( QAD_Operation* op) +{ + if ( myOperations.contains( op ) ) + { + /* abort all the operations launched after 'op' */ + for ( QAD_Operation* cur = myOperations.last(); cur; + cur = myOperations.prev() ) + { + if ( cur == op ) break; + cur->abort(); + } + myOperations.remove( op ); + } +} + +/*! + Creates study frame +*/ +QAD_StudyFrame* QAD_Study::createStudyFrame( const QString& title, ViewType theViewType) +{ + QAD_Desktop* parent = QAD_Application::getDesktop(); +//srn: Forbid appending Interface Applicative and its children to UseCase + myStudy->EnableUseCaseAutoFilling(false); + + SALOMEDS::SComponent_var father = myStudy->FindComponent("Interface Applicative"); + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeComment_var aComment; + SALOMEDS::AttributeSelectable_var aSelAttr; + +// mpv : where is "NewCommand" call? +// aStudyBuilder->CommitCommand(); + +// mpv : is study is locked, then next code will raise exception. So, temporary unlock study + int aLocked = myStudy->GetProperties()->IsLocked(); + if (aLocked) myStudy->GetProperties()->SetLocked(false); + + if ( father->_is_nil() ) { + father = aStudyBuilder->NewComponent("Interface Applicative"); + anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue("Interface Applicative"); + + anAttr = aStudyBuilder->FindOrCreateAttribute(father, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + } + + //VRV: T2.5 - add default viewer + if(theViewType == VIEW_TYPE_MAX) { + QString viewerValue = QAD_CONFIG->getSetting( "Viewer:DefaultViewer" ); + bool ok; + theViewType = (ViewType)viewerValue.toInt( &ok, 10 ); + if (!ok || theViewType < VIEW_OCC || theViewType >= VIEW_TYPE_MAX) + theViewType = VIEW_VTK; + } + //QApplication::restoreOverrideCursor(); + QAD_StudyFrame* sf = NULL; + SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(father); + if ( theViewType == VIEW_OCC) { + // MESSAGE ("Create Study Frame for OCC viewer"); + sf = new QAD_StudyFrame ( this, parent->getMainFrame(), + title, _interp, VIEW_OCC ); + + Standard_CString name = strdup(sf->title().latin1()); + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(name); + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeComment"); + aComment = SALOMEDS::AttributeComment::_narrow(anAttr); + aComment->SetValue("OCC"); + + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + } + else if ( theViewType == VIEW_VTK) { + // MESSAGE ("Create Study Frame for VTK viewer"); + sf = new QAD_StudyFrame ( this, parent->getMainFrame(), + title, _interp, VIEW_VTK ); + Standard_CString name = strdup(sf->title().latin1()); + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(name); + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeComment"); + aComment = SALOMEDS::AttributeComment::_narrow(anAttr); + aComment->SetValue("VTK"); + + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + } + else if ( theViewType == VIEW_GRAPHSUPERV) { + //MESSAGE ("Create Study Frame for SUPER`VISOR Graph"); + sf = new QAD_StudyFrame ( this, parent->getMainFrame(), + title, _interp, VIEW_GRAPHSUPERV ); + Standard_CString name = strdup(sf->title().latin1()); + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(name); + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeComment"); + aComment = SALOMEDS::AttributeComment::_narrow(anAttr); + aComment->SetValue("GRAPH"); + + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + } + else if ( theViewType == VIEW_PLOT2D ) { + sf = new QAD_StudyFrame ( this, parent->getMainFrame(), + title, _interp, VIEW_PLOT2D ); + Standard_CString name = strdup(sf->title().latin1()); + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(name); + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeComment"); + aComment = SALOMEDS::AttributeComment::_narrow(anAttr); + aComment->SetValue("PLOT2D"); + + anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + } + //VRV: T2.5 - add default viewer + + sf->resize( int (0.8*parent->getMainFrame()->width()), + int (0.8*parent->getMainFrame()->height() )); + + sf->setEntry(newObj->GetID()); + + addStudyFrame( sf ); + + updateObjBrowser( true ); + + parent->setSettings(); + + myResult = true; + + if (aLocked) myStudy->GetProperties()->SetLocked(true); + + // T2.12 - add the word "locked" to study frame captions if this study is locked + updateCaptions(); + + myStudy->EnableUseCaseAutoFilling(true); + + return sf; +} + +/*! + Updates study frame captions according to IsLocked study flag +*/ +void QAD_Study::updateCaptions() +{ + QString appendix(""); + + if (!myStudy->_is_nil()) { + SALOMEDS::AttributeStudyProperties_var propAttr = myStudy->GetProperties(); +/* + if (!propAttr->_is_nil() ) { + if ( propAttr->IsModified() ) + appendix += " (" + tr("PRP_STUDY_MODIFIED") + ")"; + else + appendix += " (" + tr("PRP_STUDY_SAVED") + ")"; + } + +*/ + if (!propAttr->_is_nil() && propAttr->IsLocked()) { + appendix += " (" + tr("PRP_STUDY_LOCKED") + ")"; + } + } + + for (myStudyFrames.first(); myStudyFrames.current(); myStudyFrames.next()) { + myStudyFrames.current()->setCaption(myStudyFrames.current()->title() + appendix); + } + +} + +/*! + Shows the active study frame. + Called by Desktop after 'new' and 'open' commands. +*/ +void QAD_Study::show() +{ + for (myStudyFrames.first(); myStudyFrames.current(); myStudyFrames.next()) { + myStudyFrames.current()->show(); + } +} + +//=======================================================================// +// Study properties (CAF related) // +//=======================================================================// + +/*! + Returns connected SALOMEDS_Study object +*/ +SALOMEDS::Study_var QAD_Study::getStudyDocument() +{ + return myStudy; +} + +/*! + Returns whether the document was saved in file +*/ +bool QAD_Study::isSaved() const +{ + return myStudy->IsSaved(); +} + +/*! + Returns whether the document is modified +*/ +bool QAD_Study::isModified() const +{ +// return myStudy->IsModified(); // VSR:05/12/02 - USE PROPERTY : MODIFIED FLAG + if ( !myStudy->_is_nil() ) { + SALOMEDS::AttributeStudyProperties_var propAttr = myStudy->GetProperties(); + if ( !propAttr->_is_nil() ) + return propAttr->IsModified(); + } + return false; +} + +bool QAD_Study::undo() +{ + try { + SALOMEDS::StudyBuilder_var SB = myStudy->NewBuilder(); + SB->Undo(); + + /* Update Object Browser */ + updateObjBrowser( true ); + + for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf; sf = myStudyFrames.next() ) { + /* Update Viewer */ + sf->getRightFrame()->getViewFrame()->undo( myStudy, sf->entry() ); + } + updateCaptions(); + + // mpv 07.03.2003 SAL1805: clear selection must be called after study structure changed + SALOME_Selection* Sel = SALOME_Selection::Selection( getSelection() ); + Sel->ClearIObjects(); + } + // mpv : undo command can raise exception, if study is locked + catch ( SALOMEDS::StudyBuilder::LockProtection& ) { + QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK")); + return false; + } + catch ( Standard_Failure ) { + return false; } + return true; +} + +/*! + Redo last undo +*/ +bool QAD_Study::redo() +{ + try { + SALOMEDS::StudyBuilder_var SB = myStudy->NewBuilder(); + SB->Redo(); + + /* Update Object Browser */ + updateObjBrowser( true ); + + /* Update Viewer */ + for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf; sf = myStudyFrames.next() ) { + sf->getRightFrame()->getViewFrame()->redo( myStudy, sf->entry() ); + } + updateCaptions(); + + // mpv 07.03.2003 SAL1805: clear selection must be called after study structure changed + SALOME_Selection* Sel = SALOME_Selection::Selection( getSelection() ); + Sel->ClearIObjects(); + } + // mpv : redo command can raise exception, if study is locked + catch ( SALOMEDS::StudyBuilder::LockProtection& ) { + QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK")); + return false; + } + catch ( Standard_Failure ) { + return false; } + return true; +} + +/*! + Check if possible to perform 'undo' command +*/ +bool QAD_Study::canUndo() const +{ + if ( myStudy->_is_nil() ) + return false; + + SALOMEDS::StudyBuilder_var SB = myStudy->NewBuilder(); + return (SB->GetAvailableUndos() > 0 ); +} + +/*! + Check if possible to perform 'redo' command +*/ +bool QAD_Study::canRedo() const +{ + if ( myStudy->_is_nil() ) + return false; + + SALOMEDS::StudyBuilder_var SB = myStudy->NewBuilder(); + return (SB->GetAvailableRedos() > 0 ); +} + +/*! + Called when operation is started + Returns 'true' if started OK, 'false' otherwise. +*/ +bool QAD_Study::onOperationStarted( QAD_Operation* op ) +{ + if ( !initOperation( op ) ) + return false; + + try + { /* start a new transaction */ + SALOMEDS::StudyBuilder_var SB = myStudy->NewBuilder(); + SB->NewCommand(); + } + catch ( Standard_Failure ) + { + /* May be, a transaction is already open, + it's not a problem */ + } + myOperationState = Started; + return true; +} + +/*! + Called when operation is finished +*/ +void QAD_Study::onOperationFinished( QAD_Operation* op ) +{ + try { + /* transaction is completed OK */ + SALOMEDS::StudyBuilder_var SB = myStudy->NewBuilder(); + SB->CommitCommand(); + } + catch ( SALOMEDS::StudyBuilder::LockProtection& ) { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK")); + onOperationAborted(op); + updateObjBrowser( true ); + return; + } + catch ( Standard_Failure ) { + } + myOperationState = Finished; + emit docOperationTerminated( true ); /* terminated successfully */ + + updateCaptions(); + // mpv: any operation must call this method, otherwise study may not be saved + updateObjBrowser( true ); + + clearOperation( op ); /* we don't need the operation anymore */ + QAD_Application::getDesktop()->putInfo ( tr("INF_DOC_OPERATIONFINISHED") ); +} + +/*! + Called when operation is suspended +*/ +void QAD_Study::onOperationSuspended( QAD_Operation* op ) +{ + myOperationState = Suspended; +} + +/*! + Called when operation is resumed +*/ +void QAD_Study::onOperationResumed( QAD_Operation* op ) +{ + myOperationState = Resumed; +} + +/*! + Called when operation is aborted +*/ +void QAD_Study::onOperationAborted(QAD_Operation* op) +{ + try { + /* abort transaction */ + SALOMEDS::StudyBuilder_var SB = myStudy->NewBuilder(); + SB->AbortCommand(); + } + catch ( Standard_Failure ) + { + } + myOperationState = Aborted; + emit docOperationTerminated( false ); /* aborted */ + + updateCaptions(); + + clearOperation(op); + QAD_Application::getDesktop()->putInfo ( tr("INF_DOC_OPERATIONABORTED") ); +} + +/*! + Call when the last study frame is closing +*/ +void QAD_Study::onLastStudyFrameClosing( QAD_StudyFrame* sf ) +{ + if ( myStudyFrames.count() == 1 ) { + emit docClosing( this ); + } else + removeStudyFrame( sf ); + +// QWorkspace* ws = QAD_Application::getDesktop()->getMainFrame(); +// if ( !ws->activeWindow() && ws->windowList().count() > 0 ) +// ws->activatePreviousWindow(); +} + +/*! + Call when created a new window3d +*/ +QAD_StudyFrame* QAD_Study::newWindow3d(QString name, ViewType theViewType, bool toShow) +{ + if(name == "") name = getNextStudyFrameName(); + QAD_StudyFrame* sf = createStudyFrame( name, theViewType ); + if ( myResult ) { + if (toShow) showFrame(sf); + // sf->compressLeft(); /* compress LeftFrame */ + sf->getRightFrame()->compressBottom(); /* compress BottomFrame */ + return sf; + } + return 0; +} + +void QAD_Study::showFrame(QAD_StudyFrame* theFrame){ + theFrame->resize(0.64*QAD_Application::getDesktop()->getMainFrame()->width(), + 0.64*QAD_Application::getDesktop()->getMainFrame()->height()); + theFrame->show(); + +} + + + +/*! + Call when setted a message +*/ +void QAD_Study::setMessage(const char* message) +{ + for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf; sf = myStudyFrames.next() ) { + sf->getRightFrame()->getMessage()->setMessage(message); + } +} + +/*! + Call when updated object browser +*/ +void QAD_Study::updateObjBrowser( bool updateSelection ) +{ + QAD_Desktop* parent = QAD_Application::getDesktop(); + SALOME_ModuleCatalog::ModuleCatalog_var Catalog = parent->getCatalogue(); + + QString ActiveComp = parent->getActiveComponent(); + + for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf; sf = myStudyFrames.next() ) { + sf->getLeftFrame()->getObjectBrowser()->Update(); + } + + /* update selection */ + if ( updateSelection && (myStudyFrames.count() > 0) ) { + SALOME_Selection* Sel = SALOME_Selection::Selection( getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for(;It.More();It.Next()) { + if ( Sel->AddIObject( It.Value() ) == 0 ) { + highlight( It.Value(), true, false ); + } + } + } + /* update viewers */ + update3dViewers(); +} + +/*! + Updates only Use Case Browser +*/ +void QAD_Study::updateUseCaseBrowser( bool updateSelection ) +{ + for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf; sf = myStudyFrames.next() ) { + sf->getLeftFrame()->getObjectBrowser()->UpdateUseCaseBrowser(); + } + /* update selection */ + if ( updateSelection && (myStudyFrames.count() > 0) ) { + SALOME_Selection* Sel = SALOME_Selection::Selection( getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for(;It.More();It.Next()) { + if ( Sel->AddIObject( It.Value() ) == 0 ) { + highlight( It.Value(), true, false ); + } + } + /* update viewers */ + update3dViewers(); + } +} + +/*! + unHighlight All Interactive Objects in All Devices +*/ +void QAD_Study::unHighlightAll() +{ + for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf; sf = myStudyFrames.next() ) { + /* Device = Viewers */ + sf->getRightFrame()->getViewFrame()->unHighlightAll(); + + /* Device = ObjectBrowser */ + sf->getLeftFrame()->getObjectBrowser()->unHighlightAll(); + } +} + +/*! + Returns type of Interactive Object +*/ +int QAD_Study::typeIObject( const Handle(SALOME_InteractiveObject)& IObject ) +{ + bool IsStudyObject = isInStudy( IObject ); + bool IsGraphicalObject = isInViewer( IObject ); + + // MESSAGE ( "IsStudyObject : " << IsStudyObject ) + // MESSAGE ( "IsGraphicalObject : " << IsGraphicalObject ) + + if ( IsStudyObject ) { + if ( IsGraphicalObject ) + return 1; /* StudyObject and GraphicalObject */ + else + return 2; /* only StudyObject */ + } else { + if ( IsGraphicalObject ) + return 3; /* only GraphicalObject */ + else + return 4; /* may be a component */ + } + return 0; +} + + +/*! + Renames the Interactive Object in All Devices +*/ +void QAD_Study::renameIObject( const Handle(SALOME_InteractiveObject)& IObject, QString newName ) +{ + if (myStudy->GetProperties()->IsLocked()) { + QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK")); + return; + } + + highlight( IObject, false ); + + int nbFrames = myStudyFrames.count(); + for ( int i = 0; i < nbFrames; i++ ) { + QAD_StudyFrame* sf = myStudyFrames.at( i ); + switch ( typeIObject(IObject) ) { + case 1: + { + /* Device = Viewers */ + sf->getRightFrame()->getViewFrame()->rename(IObject, newName); + /* Device = ObjectBrowser */ + sf->getLeftFrame()->getObjectBrowser()->rename(IObject, newName); + break; + } + case 2: + { + /* Device = ObjectBrowser */ + sf->getLeftFrame()->getObjectBrowser()->rename(IObject, newName); + break; + } + case 3: + { + /* Device = Viewers */ + sf->getRightFrame()->getViewFrame()->rename(IObject, newName); + break; + } + case 4: + { + QString ActiveComp = QAD_Application::getDesktop()->getActiveComponent(); + if ( !ActiveComp.isEmpty() ) { + sf->getLeftFrame()->getObjectBrowser()->rename(IObject,newName); + } + break; + } + } + } + + /* SALOMEDS */ + SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); + SALOMEDS::SObject_var obj = myStudy->FindObjectID( IObject->getEntry() ); + if ( !obj->_is_nil() ) { + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + anAttr = aStudyBuilder->FindOrCreateAttribute(obj, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(strdup(newName.latin1())); + } + + // VSR 13/03/03 - rename Interactive object + IObject->setName( ( char* )newName.latin1() ); + + updateObjBrowser( true ); +} + +/*! + Selects the Interactive Object in All Devices +*/ +void QAD_Study::highlight( const Handle(SALOME_InteractiveObject)& IObject, bool highlight,bool immediatly ) +{ + // MESSAGE ( " QAD_Study::highlight : " << highlight ) + int typeIO = typeIObject( IObject ); + + for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf; sf = myStudyFrames.next() ) { + switch ( typeIO ) { + case 1: + { + /* Device = Viewer */ + if (sf->getTypeView() >= 0 ) { /* Device = Viewers */ + sf->getRightFrame()->getViewFrame()->highlight(IObject, highlight, immediatly); + } + /* Device = ObjectBrowser */ + sf->getLeftFrame()->getObjectBrowser()->highlight(IObject, highlight); + break; + } + case 2: + { + /* Device = ObjectBrowser */ + sf->getLeftFrame()->getObjectBrowser()->highlight(IObject, highlight); + break; + } + case 3: + { + /* Device = Viewer */ + if (sf->getTypeView() >= 0) { /* Device = Viewers */ + sf->getRightFrame()->getViewFrame()->highlight(IObject, highlight, immediatly); + } + break; + } + case 4: + { + QString ActiveComp = QAD_Application::getDesktop()->getActiveComponent(); + if ( !ActiveComp.isEmpty() ) { + sf->getLeftFrame()->getObjectBrowser()->highlight(IObject,highlight); + } + break; + } + } + } +} + +/*! + Returns TRUE if the IObject is a Study Object. Returns FALSE otherwise. +*/ +bool QAD_Study::isInStudy( const Handle(SALOME_InteractiveObject)& IObject ) +{ + return IObject->hasEntry(); +} + +/*! + Returns true if the IObject has a Graphical Object. Returns FALSE otherwise. +*/ +bool QAD_Study::isInViewer( const Handle(SALOME_InteractiveObject)& IObject ) +{ + bool found = false; + for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf; sf = myStudyFrames.next() ) { + found = sf->getRightFrame()->getViewFrame()->isInViewer(IObject); + if ( found ) + return true; + } + return found; +} + +/*! + Returns true if the IObject has a Graphical Object into studyframe. Returns FALSE otherwise. +*/ +bool QAD_Study::isInViewer(const char* anEntry, const char* StudyFrameEntry) +{ + SALOMEDS::SObject_var RefSO; + SALOMEDS::SObject_var SO = myStudy->FindObjectID(StudyFrameEntry); + SALOMEDS::ChildIterator_var it = myStudy->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; +} + + +/*! + Returns title for the new studyframe window +*/ +QString QAD_Study::getNextStudyFrameName() +{ + QString numStudyFrame; + numStudyFrame.sprintf("%s%d", "#", ++myStudyFrameCount ); + return myTitle + numStudyFrame; /* return unique name ( title + unique number) */ +} + + +/*! + Returns the Python interpreter that belongs to this study +*/ +QAD_PyInterp* QAD_Study::get_PyInterp(void) +{ + return _interp; +} + +/*! + Sets current selection. +*/ +void QAD_Study::Selection( QString aSelection ) +{ + if ( !SALOME_Selection::FindSelection( QString(myTitle + "_" + aSelection) ) ) + SALOME_Selection::CreateSelection( QString(myTitle + "_" + aSelection) ); + + SALOME_Selection* Sel = SALOME_Selection::Selection( QString(myTitle + "_" + aSelection) ); + + mySelection = aSelection; +} + +/*! + Returns the name of current selection +*/ +QString QAD_Study::getSelection() +{ + return QString (myTitle + "_" + mySelection); +} + +/*! + Returns the study Id. +*/ +int QAD_Study::getStudyId() +{ + return myStudy->StudyId(); +} + +void QAD_Study::update3dViewers() +{ + for ( QAD_StudyFrame* sf = myStudyFrames.first(); sf; sf = myStudyFrames.next() ) { + sf->getRightFrame()->getViewFrame()->Repaint(); + } +} + +/* Adds new child window */ +void QAD_Study::addChildWidget( QWidget* child ) +{ + if ( myChildWidgets.findRef( child ) < 0 ) { + myChildWidgets.append( child ); + child->installEventFilter( this ); + } +} + +/*! + Removes child window from the list ( and deletes it ) +*/ +void QAD_Study::removeChildWidget( QWidget* child ) +{ + myChildWidgets.removeRef( child ); +} + +/* Event filter */ +bool QAD_Study::eventFilter( QObject* o, QEvent* e) +{ + int index = myChildWidgets.findRef( ( QWidget* )o ); + if ( index >= 0 && e->type() == QEvent::Close ) { + myChildWidgets.at( index )->removeEventFilter( this ); + myChildWidgets.remove( ( QWidget* )o ); + return TRUE; + } + return QObject::eventFilter( o, e ); +} + diff --git a/src/SALOMEGUI/QAD_Study.h b/src/SALOMEGUI/QAD_Study.h new file mode 100644 index 000000000..136e0702c --- /dev/null +++ b/src/SALOMEGUI/QAD_Study.h @@ -0,0 +1,178 @@ +// File : QAD_Study.cxx +// Created : UI team, 05.09.00 +// Descrip : Study for QAD-based application + +// Modified : Mon Dec 03 15:37:21 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2001 +// $Header$ + +#ifndef QAD_STUDY_H +#define QAD_STUDY_H + +#include "QAD_Operation.h" +#include "QAD_StudyFrame.h" + +#include "SALOME_InteractiveObject.hxx" + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +// QT Includes +#include +#include +#include + +class QAD_Application; +class QAD_PyInterp; + +class QAD_EXPORT QAD_Study : public QObject +{ + Q_OBJECT + +public: + QAD_Study(QAD_Application* app, + SALOMEDS::Study_var aStudy, + const QString& title); + ~QAD_Study(); + + /* Event filter */ + bool eventFilter( QObject* o, QEvent* e); + +public: + /* studyframes management */ + QAD_StudyFrame* createStudyFrame(const QString& name, ViewType theViewType = VIEW_TYPE_MAX); + void removeStudyFrame( QAD_StudyFrame* ); + int getStudyFramesCount() const; + const QList& getStudyFrames() const; + QAD_StudyFrame* getStudyFrameByName( const QString& name ); + QAD_StudyFrame* getFirstStudyFrame(); + QAD_StudyFrame* getLastStudyFrame(); + QAD_StudyFrame* getStudyFrame( unsigned i ); + QAD_StudyFrame* getActiveStudyFrame() const; + + bool getResult(); + + /* document state management */ + bool isActive() const; + bool isSaved() const; + bool isModified() const; + bool isReadOnly() const; + void setReadOnly(bool state); + const QString& getTitle() const; + int getStudyId(); + const QString& getPath() const; + void setTitle( const QString& title); + void updateCaptions(); + void close(); + QAD_Application* getApp() const; + + /* visualization */ + void show(); + + /* operation management */ + OperationState getOperationState() const; + int getOperationsCount() const; + QAD_Operation* getOperation( unsigned i ); + QAD_Operation* getFirstOperation(); + QAD_Operation* getLastOperation(); + + void abortAllOperations(); + void resumeAllOperations(); + void suspendAllOperations(); + + bool onOperationStarted( QAD_Operation* ); + void onOperationFinished( QAD_Operation* ); + void onOperationSuspended( QAD_Operation* ); + void onOperationResumed( QAD_Operation* ); + void onOperationAborted( QAD_Operation* ); + + /* standard CAF document */ + SALOMEDS::Study_var getStudyDocument(); + + bool undo(); + bool redo(); + bool canUndo() const; + bool canRedo() const; + + QAD_StudyFrame* newWindow3d(QString name = "", ViewType theViewType = VIEW_TYPE_MAX, bool toShow = true); + void showFrame(QAD_StudyFrame* theFrame); + + void setMessage(const char* message); + + void updateObjBrowser( bool updateSelection = true ); + void updateUseCaseBrowser( bool updateSelection = true ); + void update3dViewers(); + + /* interactive object management */ + void highlight( const Handle(SALOME_InteractiveObject)& IObject, + bool highlight, bool immediatly=true ); + void unHighlightAll(); + + void renameIObject( const Handle(SALOME_InteractiveObject)& IObject, + QString newName ); + int typeIObject( const Handle(SALOME_InteractiveObject)& IObject ); + + bool isInStudy( const Handle(SALOME_InteractiveObject)& IObject ); + bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject ); + bool isInViewer(const char* anEntry, + const char* StudyFrameEntry); + + /* selection */ + void Selection( QString aSelection ); + QString getSelection(); + + /* python interpreter */ + QAD_PyInterp* get_PyInterp(void); + + QString getNextStudyFrameName(); + + /* Child widgets handling (not QAD_StudyFrame) */ + void addChildWidget( QWidget* child ); + void removeChildWidget( QWidget* child ); + +signals: + void docClosing( QAD_Study* ); + void docOperationTerminated( bool ); + +public slots: + void onStudyFrameActivated( QAD_StudyFrame* ); + void onStudyDeactivated(); + void onLastStudyFrameClosing( QAD_StudyFrame* ); + +private: + void addStudyFrame( QAD_StudyFrame* ); + bool initOperation( QAD_Operation* ); + void clearOperation( QAD_Operation* ); + +private: + SALOMEDS::Study_var myStudy; + + QList myOperations; + OperationState myOperationState; + + QAD_Application* myApp; + QList myStudyFrames; + QAD_StudyFrame* myActiveStudyFrame; + int myStudyFrameCount; + + QList myChildWidgets; + + QString myPath; + QString myTitle; + + QString mySelection; + + bool myIsActive; + bool myIsSaved; + bool myIsModified; + bool myIsReadOnly; + bool myResult; + QAD_PyInterp* _interp; +}; + +#endif + diff --git a/src/SALOMEGUI/QAD_StudyFrame.cxx b/src/SALOMEGUI/QAD_StudyFrame.cxx new file mode 100644 index 000000000..2148c9b71 --- /dev/null +++ b/src/SALOMEGUI/QAD_StudyFrame.cxx @@ -0,0 +1,186 @@ +using namespace std; +// File : QAD_StudyFrame.cxx +// Created : Sun Jul 22 15:31:59 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +/*! + \class QAD_StudyFrame QAD_StudyFrame.h + \brief Frame window which contains QAD_LeftFrame and QAD_RightFrame. +*/ + +#include "QAD_StudyFrame.h" +#include "QAD_RightFrame.h" +#include "QAD_LeftFrame.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_Study.h" +#include "QAD_ObjectBrowser.h" +#include + +/*! + Constructor +*/ +QAD_StudyFrame::QAD_StudyFrame(QAD_Study* study, QWidget* parent, const QString& title, + QAD_PyInterp* interp, ViewType typeView) : + QMainWindow( parent , title, WStyle_NormalBorder | + WStyle_MinMax | WStyle_SysMenu | WDestructiveClose), + myStudy(study) +{ + myTypeView = typeView; + myTitle = title; + setCaption( myTitle ); + setPalette(QAD_Application::getPalette()); + + myEntry = ""; + _interp = interp; + + s1 = new QAD_Splitter( Qt::Horizontal, this); + s1->setCompressEnabled( true ); + + setCentralWidget( s1 ); + myLeftFrm = new QAD_LeftFrame(study->getStudyDocument(), s1 , title ); + myRightFrm = new QAD_RightFrame( s1, title, _interp, myTypeView); + + QValueList sizes; + sizes.append( 0.30*QAD_Application::getDesktop()->getMainFrame()->width() ); + sizes.append( 0.50*QAD_Application::getDesktop()->getMainFrame()->width() ); + s1->setSizes( sizes ); + + QAD_ASSERT_DEBUG_ONLY ( parent->inherits("QWorkspaceP") ); + QAD_ASSERT ( QObject::connect( (QWorkspaceP*)parent, SIGNAL(windowActivated(QWidget*)), + this, SLOT(onStudyFrameActivated(QWidget*))) ); +} + +/*! + Constructor +*/ +QAD_StudyFrame::QAD_StudyFrame(QAD_Study* study, QWidget* parent ) : + QMainWindow ( parent ), + myStudy(study) +{ +} + +/*! + Destructor +*/ +QAD_StudyFrame::~QAD_StudyFrame() +{ +} + +/*! + Returns the rightframe of this frame +*/ +QAD_RightFrame* QAD_StudyFrame::getRightFrame() const +{ + return myRightFrm; +} + +/*! + Returns the leftframe of this frame +*/ +QAD_LeftFrame* QAD_StudyFrame::getLeftFrame() const +{ + return myLeftFrm; +} + +/*! + Returns 'true' if studyframe is visible +*/ +void QAD_StudyFrame::setVisible( bool visible ) +{ + if ( visible == isVisible() ) + return; + + if ( visible ) show(); + else hide(); +} + +/*! + Called when StudyFrame is about to close +*/ +void QAD_StudyFrame::closeEvent(QCloseEvent* e) +{ + emit sfBeforeStudyFrameClosing(this); + emit sfStudyFrameClosing(this); +} + +/*! + Call when + */ +void QAD_StudyFrame::compressLeft() +{ + s1->compress(myLeftFrm); +} + +void QAD_StudyFrame::compressRight() +{ + s1->compress(myRightFrm); +} + +void QAD_StudyFrame::unCompressLeft() +{ + s1->unCompress(myLeftFrm); +} + +void QAD_StudyFrame::unCompressRight() +{ + s1->unCompress(myRightFrm); +} + +/*! + Returns the title of studyframe +*/ +const QString& QAD_StudyFrame::title() const +{ + return myTitle; +} + +/*! + Sets the new title of studyframe +*/ +void QAD_StudyFrame::setTitle( const QString& title ) +{ + myTitle = title; + setCaption( myTitle ); +} + +/*! + Returns the entry of studyframe +*/ +const QString& QAD_StudyFrame::entry() const +{ + return myEntry; +} + +/*! + Sets the new entru of studyframe +*/ +void QAD_StudyFrame::setEntry( const QString& entry ) +{ + myEntry = entry; +} + +ViewType QAD_StudyFrame::getTypeView() const +{ + return myTypeView; +} + +/*! + The slot is called when a studyframe is activated +*/ +void QAD_StudyFrame::onStudyFrameActivated ( QWidget* activeWindow ) +{ + emit sfStudyFrameActivated( (QAD_StudyFrame*) activeWindow ); +} + +/*! + Returns the Python interpreter that belongs to this study +*/ +QAD_PyInterp* QAD_StudyFrame::get_PyInterp(void) +{ + return _interp; +} diff --git a/src/SALOMEGUI/QAD_StudyFrame.h b/src/SALOMEGUI/QAD_StudyFrame.h new file mode 100644 index 000000000..7f48b7b38 --- /dev/null +++ b/src/SALOMEGUI/QAD_StudyFrame.h @@ -0,0 +1,88 @@ +// File : QAD_StudyFrame.h +// Created : Wed Mar 20 11:10:03 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef QAD_StudyFrame_H +#define QAD_StudyFrame_H + +#include "QAD.h" +#include "QAD_Splitter.h" +#include "QAD_PyInterp.h" + +// QT Includes +#include +#include + +class QAD_RightFrame; +class QAD_LeftFrame; +class QAD_Splitter; +class QAD_Study; + +enum ViewType { + VIEW_OCC, + VIEW_VTK, + VIEW_GRAPHSUPERV, + VIEW_PLOT2D, + VIEW_TYPE_MAX // must always be the last one; insert new values before it +}; + +class QAD_EXPORT QAD_StudyFrame: public QMainWindow +{ + Q_OBJECT + + public: + QAD_StudyFrame(QAD_Study* study, + QWidget* parent, const QString& title, + QAD_PyInterp* interp, ViewType typeView); + QAD_StudyFrame(QAD_Study*, + QWidget* parent = 0); + virtual ~QAD_StudyFrame(); + + QAD_Study* getStudy() { return myStudy; } + QAD_RightFrame* getRightFrame() const; + QAD_LeftFrame* getLeftFrame() const; + + ViewType getTypeView() const; + + QAD_PyInterp* get_PyInterp(void); + + void setTitle( const QString& aTitle); + const QString& title() const; + + void setEntry( const QString& aTitle); + const QString& entry() const; + + void setVisible( bool isVisible = true ); + void closeEvent(QCloseEvent* e); + + void compressLeft(); + void compressRight(); + void unCompressLeft(); + void unCompressRight(); + + signals: + void sfStudyFrameActivated( QAD_StudyFrame* ); + void sfStudyFrameClosing( QAD_StudyFrame*); + void sfBeforeStudyFrameClosing( QAD_StudyFrame*); + + public slots: + void onStudyFrameActivated ( QWidget* ); + + + private: + QString myTitle; /* title */ + QString myEntry; /* entry */ + + ViewType myTypeView; + QAD_LeftFrame* myLeftFrm; + QAD_RightFrame* myRightFrm; + QAD_Splitter* s1; + QAD_PyInterp* _interp; + QAD_Study* myStudy; +}; + +#endif diff --git a/src/SALOMEGUI/QAD_Tools.cxx b/src/SALOMEGUI/QAD_Tools.cxx new file mode 100644 index 000000000..dac82d7f7 --- /dev/null +++ b/src/SALOMEGUI/QAD_Tools.cxx @@ -0,0 +1,300 @@ +using namespace std; +// File : QAD_Tools.cxx +// Created : UI team, 22.09.00 +// Descr : Helpful functions for QAD +// Author : UI team +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + + +/*! + \class QAD_Tools QAD_Tools.h + \brief Helpful functions for QAD. +*/ + +#include "QAD_Tools.h" +#include "utilities.h" + +// QT Inlcude +#include +#include +#include +#include +#include +#include +#include +#include + +static char* tempName() +{ + static char tempDir[512]; + strcpy ( tempDir, getenv ("tmp") ); + +#if defined WNT + if ( tempDir[ strlen(tempDir)-1 ] != '\\' ) + strcat ( tempDir,"\\"); +#else + if ( tempDir[ strlen(tempDir)-1 ] != '/' ) + strcat ( tempDir,"/"); +#endif + strcat ( tempDir,"Salome_trace"); + return tempDir; +} + +/*! + Returns max 'int' value [ static ] +*/ +inline int QAD_Tools::getMax(int v1, int v2) +{ + return v1 >= v2 ? v1 : v2; +} + +/*! + Returns min 'int' value [ static ] +*/ +inline int QAD_Tools::getMin(int v1, int v2) +{ + return v1 <= v2 ? v1 : v2; +} + +/*! + [ static ] + Creates a rect with TopLeft = ( min(x1,x2), min(y1,y2) ) + and BottomRight = ( TopLeft + (x2-x1)(y2-y1) ) +*/ +QRect QAD_Tools::makeRect(int x1, int y1, int x2, int y2) +{ + QRect aRect; + aRect.setRect( getMin(x1, x2), getMin(y1, y2), abs(x2-x1), abs(y2-y1)); + return aRect; +} + +/*! + Traces output to log-file. [ static ] + If log is NULL, 'Salome_trace' file is created in temp directory. + Log file is written in 'append' mode. +*/ +void QAD_Tools::trace (const char* lpszLog, const char* lpszFormat, ... ) +{ + static char* lpszTmp = tempName(); + + FILE* pStream; + pStream = fopen ( lpszLog ? lpszLog : lpszTmp, "a" ); + if ( pStream ) + { + va_list argptr; + va_start(argptr, lpszFormat); + //NRI vfprintf ( pStream, lpszFormat, argptr); + fprintf ( pStream, "- Trace %s [%d] : %s", __FILE__, __LINE__, lpszFormat); + va_end(argptr); + fclose ( pStream ); + } +} + +/*! + Parses the path to select the dir name only [ static ]. + Returns NULL if the path is empty (null). + NB: Unix-style slashes are assumed in 'path' +*/ +QString QAD_Tools::getDirFromPath ( const QString& path, bool absPath ) +{ + return QFileInfo( path ).dirPath( absPath ); +} + + +/*! + Parses the path to select the file name with or without extension [ static ]. +*/ +QString QAD_Tools::getFileNameFromPath( const QString& path, + bool withExtension ) +{ + if ( withExtension ) + return QFileInfo( path ).fileName(); + else + return QFileInfo( path ).baseName(); +} + +/*! + Parses the path to select the file extension [ static ]. +*/ +QString QAD_Tools::getFileExtensionFromPath( const QString& path ) +{ + return QFileInfo( path ).extension(false); +} + +/*! + Adds a slash to the end of 'path' if it is not already there [ static ] +*/ +QString QAD_Tools::addSlash( const QString& path ) +{ + if (!path.isNull()) { +#ifdef WNT + QChar slash ('\\'); +#else + QChar slash ('/'); +#endif + if ( path.at(path.length()-1) != slash ) + return path + slash; + } + return path; +} + +/*! + Converts slashes from unix-like to win-like [ static ] + Returns null string if 'path' is empty or null. +*/ +QString QAD_Tools::unix2win( const QString& path ) +{ + QString ret = path; +#ifdef WNT + int pos; + QChar winSlash ('\\'), unixSlash('/'); + for ( int start = 0; + (pos = path.find( unixSlash, start, false )) >= 0; + start = pos + 1 ) + { + ret.replace( pos, 1, &winSlash, 1 ); + } +#endif + return ret; +} +/*! + Centers widget 'w' as refered to widget 'ref' [ static ] +*/ +void QAD_Tools::centerWidget( QWidget* src, const QWidget* ref ) +{ + QAD_Tools::alignWidget(src, ref, Qt::AlignCenter); +} + +/*! + Aligns widget 'w' as refered to widget 'ref' [ static ] +*/ +void QAD_Tools::alignWidget ( QWidget* src, const QWidget* ref, int alignFlags ) +{ + if ( !src || !ref || !alignFlags ) return; + + QPoint srcOri = src->mapToGlobal( QPoint( 1, 1 ) ); + QPoint refOri = ref->mapToGlobal( QPoint( 1, 1 ) ); + + int x = srcOri.x(), y = srcOri.y(); + int refWidth = ref->width(), refHei = ref->height(); + int srcWidth = src->width(), srcHei = src->height(); + if ( srcWidth <= 1 ) + srcWidth = src->sizeHint().width(); + if ( srcHei <= 1 ) + srcHei = src->sizeHint().height(); + + if ( alignFlags & AlignLeft ) + x = refOri.x(); + if ( alignFlags & AlignRight ) + x = refOri.x() + refWidth - srcWidth; + if ( alignFlags & AlignTop ) + y = refOri.y(); + if ( alignFlags & AlignBottom ) + y = refOri.y() + refHei - srcHei; + if ( alignFlags & AlignHCenter ) + x = refOri.x() + ( refWidth - srcWidth ) / 2; + if ( alignFlags & AlignVCenter ) + y = refOri.y() + ( refHei - srcHei ) / 2; + + if ( src->parentWidget() && /* we move a widget inside its parent */ + !src->inherits( "QDialog" )) /* dialogs use global coordinates */ + { + QPoint pos = src->parentWidget()->mapFromGlobal( QPoint(x,y) ); + x = pos.x(); y = pos.y(); + } +#ifdef WNT + x -= 4; /* - frame border width ( approx. ) */ + y -= 30; /* - caption height ( approx. ) */ +#endif + + src->move( x, y ); +} + +/*! + Converts TCollection_ExtendedString to QString +*/ +QString QAD_Tools::toQString( const TCollection_ExtendedString& extString) +{ + QString result = QString ( (const QChar*) extString.ToExtString(), + extString.Length() ); + return result; +} + +/*! + Converts QString to TCollection_ExtendedString +*/ +TCollection_ExtendedString QAD_Tools::toExtString( const QString& qString) +{ + TCollection_ExtendedString result; + for ( int i = 0; i < (int)qString.length(); i++ ) + result.Insert( i + 1, qString[ i ].unicode() ); + return result; +} + +/*! + Converts TCollection_AsciiString to QString +*/ +QString QAD_Tools::toQString( const TCollection_AsciiString& asciiString) +{ + QString result = QString ( asciiString.ToCString() ); + return result; +} + +/*! + Converts QString to TCollection_AsciiString +*/ +TCollection_AsciiString QAD_Tools::toAsciiString( const QString& qString) +{ + TCollection_AsciiString result = TCollection_AsciiString((char*)(qString.latin1())); + return result; +} + +/*! + Creates font from string description +*/ +QFont QAD_Tools::stringToFont( const QString& fontDescription ) +{ + QFont font; + if ( !font.fromString( fontDescription ) ) + font = QFont( "Courier", 11 ); + return font; +} + +/*! + Creates font's string description +*/ +QString QAD_Tools::fontToString( const QFont& font ) +{ + return font.toString(); +} + +/*! + Checks popup menu recursively for unnecessary separators and removes them +*/ +void QAD_Tools::checkPopup( QPopupMenu* popup ) +{ + if ( popup->count() > 0 ) { + QValueList idRemove; + for ( int i = 1; i < popup->count(); i++ ) { + if ( popup->findItem( popup->idAt( i ) )->isSeparator() ) { + if ( popup->findItem( popup->idAt( i-1 ) )->isSeparator() ) + idRemove.append( popup->idAt( i ) ); + } + else { + QPopupMenu* child = popup->findItem( popup->idAt( i ) )->popup(); + if ( child ) { + checkPopup( child ); + } + } + } + for ( int i = 0; i < idRemove.count(); i++ ) + popup->removeItem( idRemove[i] ); + if ( popup->count() > 0 && popup->findItem( popup->idAt( 0 ) )->isSeparator() ) + popup->removeItem( popup->idAt( 0 ) ); + if ( popup->count() > 0 && popup->findItem( popup->idAt( popup->count()-1 ) )->isSeparator() ) + popup->removeItem( popup->idAt( popup->count()-1 ) ); + } +} diff --git a/src/SALOMEGUI/QAD_Tools.h b/src/SALOMEGUI/QAD_Tools.h new file mode 100644 index 000000000..389ed9459 --- /dev/null +++ b/src/SALOMEGUI/QAD_Tools.h @@ -0,0 +1,62 @@ +// File : QAD_Tools.h +// Created : 22.09.00 +// Descr : Helpful functions for QAD + +// Author : UI team +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_TOOLS_H +#define QAD_TOOLS_H + +#include "QAD.h" +#include +#include +#include +#include +#include +#include + +class QAD_EXPORT QAD_Tools : public Qt +{ +public: + /* min/max functions */ + static int getMax(int v1, int v2); + static int getMin(int v1, int v2); + + /* makes rectangle */ + static QRect makeRect(int x1, int y1, int x2, int y2); + + /* trace function */ + static void trace (const char* pLog, const char* szFormat, ... ); + + /* path functions */ + static QString getDirFromPath( const QString& path, bool absPath = true ); + static QString getFileNameFromPath( const QString& path, bool withExtension = true ); + static QString getFileExtensionFromPath( const QString& path ); + static QString addSlash( const QString& path ); + static QString unix2win( const QString& path ); + + /* aligning widget in 'ref' widget */ + static void centerWidget( QWidget* src, const QWidget* ref ); + static void alignWidget ( QWidget* src, const QWidget* ref, int alignFlags = AlignCenter ); + + /* converting strings */ + static QString toQString ( const TCollection_ExtendedString& extString); + static TCollection_ExtendedString toExtString ( const QString& qString); + static QString toQString ( const TCollection_AsciiString& asciiString); + static TCollection_AsciiString toAsciiString( const QString& qString); + + static QFont stringToFont( const QString& fontDescription ); + static QString fontToString( const QFont& font ); + + /* popup menu optimization */ + static void checkPopup( QPopupMenu* popup ); +}; + +#endif + + + diff --git a/src/SALOMEGUI/QAD_ViewFrame.cxx b/src/SALOMEGUI/QAD_ViewFrame.cxx new file mode 100644 index 000000000..334fa751a --- /dev/null +++ b/src/SALOMEGUI/QAD_ViewFrame.cxx @@ -0,0 +1,111 @@ +using namespace std; +// File : QAD_ViewFrame.cxx +// Created : UI team, 05.09.00 +// Descrip : Frame window for viewport in QAD-based application + +// Modified : Mon Dec 03 15:41:43 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + + +#include "QAD.h" +#include "QAD_ViewFrame.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_FileDlg.h" +#include "QAD_MessageBox.h" +#include "QAD_Tools.h" +#include +#include +#include "utilities.h" + +/*! + Constructor +*/ +QAD_ViewFrame::QAD_ViewFrame(QWidget* parent, const QString& title) + : QMainWindow (parent, title, 0) +{ +} + +/*! + Constructor +*/ +QAD_ViewFrame::QAD_ViewFrame( QWidget* parent ) + : QMainWindow (parent, "",0) +{ +} + +/*! + Destructor +*/ +QAD_ViewFrame::~QAD_ViewFrame() +{ + cleanup(); +} + +/*! + Cleanup viewframe +*/ +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; +} + +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 +*/ +void QAD_ViewFrame::onViewDump() +{ + if (!getViewWidget()) + return; + + QApplication::setOverrideCursor( Qt::waitCursor ); + QPixmap px = QPixmap::grabWindow(getViewWidget()->winId()); + QApplication::restoreOverrideCursor(); + + QString fileName = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + QString::null, + tr("OCC_IMAGE_FILES"), + tr("INF_APP_DUMP_VIEW"), + false); + if (!fileName.isNull()) { + QApplication::setOverrideCursor( Qt::waitCursor ); + QString fmt = QAD_Tools::getFileExtensionFromPath(fileName).upper(); + if (fmt.isEmpty()) + fmt = QString("BMP"); // default format + if (fmt == "JPG") + fmt = "JPEG"; + bool bOk = px.save(fileName, fmt.latin1()); + QApplication::restoreOverrideCursor(); + if (!bOk) { + QAD_MessageBox::error1(QAD_Application::getDesktop(), + tr("ERR_ERROR"), + tr("ERR_DOC_CANT_SAVE_FILE"), + tr("BUT_OK")); + } + } +} diff --git a/src/SALOMEGUI/QAD_ViewFrame.h b/src/SALOMEGUI/QAD_ViewFrame.h new file mode 100644 index 000000000..2f190d492 --- /dev/null +++ b/src/SALOMEGUI/QAD_ViewFrame.h @@ -0,0 +1,101 @@ +// File : QAD_ViewFrame.cxx +// Created : UI team, 05.09.00 +// Descrip : Frame window for viewport in QAD-based application + +// Modified : Mon Dec 03 15:41:43 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + + +#ifndef QAD_ViewFrame_H +#define QAD_ViewFrame_H + +#include "QAD.h" +#include "QAD_Application.h" +#include "QAD_StudyFrame.h" +#include "SALOME_InteractiveObject.hxx" + +// QT Include +#include + +class vtkRenderer; + +class QAD_EXPORT QAD_ViewFrame : public QMainWindow +{ + Q_OBJECT + +public: + QAD_ViewFrame(QWidget* parent, const QString& title); + QAD_ViewFrame(QWidget* parent = 0); + virtual ~QAD_ViewFrame(); + + void cleanup(); + + virtual ViewType getTypeView() const = 0; + virtual QWidget* getViewWidget() = 0; + virtual vtkRenderer* getRenderer(); + + virtual void setBackgroundColor( const QColor& ) = 0; + virtual QColor backgroundColor() const = 0; + + virtual void SetSelectionMode( int mode ) = 0; + + virtual void SetTrihedronSize( int dim ) = 0; + + /* popup management */ + virtual void setPopupServer( QAD_Application* ) = 0; + + /* interactive object management */ + virtual void highlight( const Handle(SALOME_InteractiveObject)& IObject, + bool highlight, bool immediatly = true ) = 0; + virtual void unHighlightAll() = 0; + virtual void rename( const Handle(SALOME_InteractiveObject)& IObject, + QString newName ) = 0; + virtual bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject ) = 0; + virtual bool isVisible( const Handle(SALOME_InteractiveObject)& IObject ) = 0; + + /* undo/redo management */ + virtual void undo(SALOMEDS::Study_var aStudy, + const char* StudyFrameEntry) = 0; + virtual void redo(SALOMEDS::Study_var aStudy, + const char* StudyFrameEntry) = 0; + + static bool isInViewer(SALOMEDS::Study_var aStudy, + const char* anEntry, + const char* StudyFrameEntry); + + /* selection */ + virtual Handle(SALOME_InteractiveObject) FindIObject(const char* Entry) = 0; + + /* display */ + virtual void Display(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly = true) = 0; + virtual void DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject) = 0; + virtual void Erase(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly = true) = 0; + virtual void DisplayAll() = 0; + virtual void EraseAll() = 0; + virtual void Repaint() = 0; + +protected slots: + virtual void onViewPan() = 0; + virtual void onViewZoom() = 0; + virtual void onViewFitAll() = 0; + virtual void onViewFitArea() = 0; + virtual void onViewGlobalPan() = 0; + virtual void onViewRotate() = 0; + virtual void onViewReset() = 0; + virtual void onViewFront() = 0; + virtual void onViewBack() = 0; + virtual void onViewRight() = 0; + virtual void onViewLeft() = 0; + virtual void onViewBottom() = 0; + virtual void onViewTop() = 0; + virtual void onViewTrihedron() = 0; + virtual void onViewDump(); + +}; + +#endif + diff --git a/src/SALOMEGUI/QAD_WaitCursor.h b/src/SALOMEGUI/QAD_WaitCursor.h new file mode 100644 index 000000000..f3acd9a66 --- /dev/null +++ b/src/SALOMEGUI/QAD_WaitCursor.h @@ -0,0 +1,35 @@ +// File : QAD_WaitCursor.h +// Created : 02/10/2002 +// Descr : Use this class to set wait cursor on long operatins + +// Author : Vadim SANDLER +// Project : SALOME Pro +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef QAD_WAITCURSOR_H +#define QAD_WAITCURSOR_H + +#include +#include "QAD.h" + +class QAD_EXPORT QAD_WaitCursor { + public: +// constructor + QAD_WaitCursor() : myStarted(false) { start(); } +// destructor + ~QAD_WaitCursor() { stop(); } + +// sets WAIT cursor if not set yet + void start() { if (!myStarted) { QApplication::setOverrideCursor(Qt::waitCursor); myStarted = true; } } +// clears WAIT cursor if set + void stop() { if (myStarted) { QApplication::restoreOverrideCursor(); myStarted = false; } } +// returns true if WAIT cursor is active + bool isStarted() { return myStarted; } + + private: + bool myStarted; +}; + +#endif diff --git a/src/SALOMEGUI/QAD_XmlHandler.cxx b/src/SALOMEGUI/QAD_XmlHandler.cxx new file mode 100644 index 000000000..53d569777 --- /dev/null +++ b/src/SALOMEGUI/QAD_XmlHandler.cxx @@ -0,0 +1,342 @@ +using namespace std; +// File : QAD_XmlHandler.cxx +// Created : Thu Jun 14 13:59:36 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#define INCLUDE_MENUITEM_DEF + +#include "QAD_Desktop.h" +#include "QAD_XmlHandler.h" +#include "QAD_ListMenuIdAction.h" +#include "QAD_Menus.h" +#include "QAD_MessageBox.h" +#include "QAD_Tools.h" +#include "QAD_Resource.h" + +// QT Include +#include +#include +#include + +map QAD_XmlHandler::_bibmap; + +static const char* SEPARATOR = ":"; + +static QString findFile( QString resDirs, QString fileName ) +{ + QStringList dirList = QStringList::split( SEPARATOR, resDirs, false ); // skip empty entries + for ( int i = 0; i < dirList.count(); i++ ) { + QString dir = dirList[ i ]; + QFileInfo fi( QAD_Tools::addSlash( dir ) + fileName ); + if ( fi.isFile() && fi.exists() ) + return fi.filePath(); + } + return QString(); +} + +/*! + Constructor +*/ +QAD_XmlHandler::QAD_XmlHandler() +{ +} + +/*! + Destructor +*/ +QAD_XmlHandler::~QAD_XmlHandler() +{ +} + +/*! + Sets \a desktop widget which contains menubar. +*/ +void QAD_XmlHandler::setMainWindow(QAD_Desktop* desktop) +{ + myDesktop = desktop; + myIdList = TColStd_SequenceOfInteger(); + myBackMenu = true; + myBackPopupMenus.setAutoDelete(false); +} + +/*! + Returns TRUE if environment variable CSF_"Component"Resources is undefined. + Returns FALSE otherwise. +*/ +bool QAD_XmlHandler::setComponent (const QString& dirs ) +{ + myPathResources = dirs; + + return true ; +} + +/*! + Starts parsing of document. Does some initialization + + Reimplemented from QXmlDefaultHandler. +*/ +bool QAD_XmlHandler::startDocument() +{ + myErrorProt = ""; + return TRUE; +} + +/*! + Does different actions depending on the name of the tag and the + state you are in document. + + Reimplemented from QXmlDefaultHandler. +*/ +bool QAD_XmlHandler::startElement( const QString&, const QString&, + const QString& qName, + const QXmlAttributes& atts ) +{ + char Slot_Name[200]; + + if ( qName == "application") { + myMenus=new QAD_Menus(myDesktop); + myMenusList.append(myMenus); + } else if ( qName == "desktop" ) { //DESKTOP + } else if ( qName == "menubar" ) { //MENUBAR + QMenuBar* aMenuBar = myDesktop->menuBar(); /*new QMenuBar(myMainWindow);*/ + myMenus->myActiveMenuBar=aMenuBar; + myMenus->append(aMenuBar); + myMenus->myActiveMenuBar->hide(); + + } else if ( qName == "menu-item" ) { //MENU-ITEM + myBackMenu = true; + QMenuItem* item = myMenus->myActiveMenuBar->findItem(atts.value( "item-id" ).toInt()); + if ( item ) { + QPopupMenu* aMenuItem = item->popup(); + myMenus->myActivePopupMenu=aMenuItem; + } else { + QPopupMenu* aMenuItem=new QPopupMenu(myMenus->myActiveMenuBar); + myMenus->myActivePopupMenu=aMenuItem; + int id; + int pos; + if (atts.value( "pos-id" ).compare(QString(""))==0) { + pos = -1; + } + else { + pos = atts.value( "pos-id" ).toInt(); + if ( pos < 0 ) + pos = myMenus->myActiveMenuBar->count() + pos; + } + id = myMenus->myActiveMenuBar->insertItem( atts.value( "label-id" ), + aMenuItem, + atts.value( "item-id" ).toInt(), + pos ); + myIdList.Append( id ); + } + } else if ( qName == "popup-item" ) { //POPUP-ITEM + QString aCommandID(atts.value( "item-id" )); + int id; + int pos; + if (atts.value( "pos-id" ).compare(QString(""))==0) { + pos = -1; + } + else { + pos = atts.value( "pos-id" ).toInt(); + if ( pos < 0 ) + pos = myMenus->myActivePopupMenu->count() + pos; + } + if (atts.value( "icon-id").compare(QString(""))==0) + if (atts.value( "execute-action" ).compare(QString(""))==0) + id = myMenus->myActivePopupMenu->insertItem( atts.value( "label-id" ), + myDesktop, SLOT (onDispatch( int )), + QAccel::stringToKey(atts.value( "accel-id" )), + aCommandID.toInt(), + pos); + else + id = myMenus->myActivePopupMenu->insertItem( atts.value( "label-id" ), + myDesktop, SLOT (onDispatchTools( int )), + QAccel::stringToKey(atts.value( "accel-id" )), + aCommandID.toInt(), + pos); + + else + if (atts.value( "execute-action" ).compare(QString(""))==0) + id = myMenus->myActivePopupMenu->insertItem( QPixmap( findFile( myPathResources, atts.value( "icon-id" ) ) ), + atts.value( "label-id" ), + myDesktop, SLOT (onDispatch( int )), + QAccel::stringToKey(atts.value( "accel-id" )), + aCommandID.toInt(), + pos ); + else + id = myMenus->myActivePopupMenu->insertItem( QPixmap( findFile( myPathResources, atts.value( "icon-id") ) ), + atts.value( "label-id" ), + myDesktop, SLOT (onDispatchTools( int )), + QAccel::stringToKey(atts.value( "accel-id" )), + aCommandID.toInt(), + pos); + if (atts.value( "chaine")!=NULL) { + QAD_XmlHandler::_bibmap[atts.value( "item-id").toInt()]=QString(atts.value( "chaine")); +// SCRUTE(atts.value( "item-id").toInt() ) ; +// SCRUTE(QAD_XmlHandler::_bibmap[atts.value( "item-id").toInt()] ) ; + } + if (atts.value( "toggle-id" ).compare(QString(""))!=0) { + if (atts.value( "toggle-id" ).compare(QString("false"))==0) { + myMenus->myActivePopupMenu->setItemChecked(id,false); + } + if (atts.value( "toggle-id" ).compare(QString("true"))==0) { + myMenus->myActivePopupMenu->setItemChecked(id,true); + } + } + myIdList.Append( id ); + myMenus->myActivePopupMenu->setItemParameter( id, aCommandID.toInt()); + } else if ( qName == "submenu" ) { //SUBMENU + myBackPopupMenus.push(myMenus->myActivePopupMenu); + QMenuItem* item = 0; + if ( myBackMenu ) + item = myMenus->myActivePopupMenu->findItem(atts.value( "item-id" ).toInt()); + + QPopupMenu* aSubmenu = new QPopupMenu(); + if ( item ) { + if (item->popup()) { + aSubmenu=item->popup(); + //Enable submenu only if disable + if (!myMenus->myActivePopupMenu->isItemEnabled( atts.value( "item-id" ).toInt())) + myMenus->myActivePopupMenu->setItemEnabled( atts.value( "item-id" ).toInt(), true); + } + } else { + aSubmenu=new QPopupMenu(myMenus->myActivePopupMenu); + int id; + int pos; + if (atts.value( "pos-id" ).compare(QString(""))==0) { + pos = -1; + } + else { + pos = atts.value( "pos-id" ).toInt(); + if ( pos < 0 ) + pos = myMenus->myActivePopupMenu->count() + pos; + } + id = myMenus->myActivePopupMenu->insertItem(atts.value( "label-id" ), + aSubmenu,atts.value( "item-id" ).toInt(), + pos); + myIdList.Append(id); + } + myMenus->myActivePopupMenu=aSubmenu; + } else if ( qName == "endsubmenu" ) { //SUBMENU + myMenus->myActivePopupMenu = myBackPopupMenus.pop(); + } else if ( qName == "popupmenu" ) { //POPUP MENU + myBackMenu = false; + QPopupMenu* aPopupMenu=new QPopupMenu; + myMenus->myActivePopupMenu=aPopupMenu; + aPopupMenu->insertItem( atts.value( "label-id" ), aPopupMenu, QAD_TopLabel_Popup_ID); + QAD_ListPopupMenu* pmenu = new QAD_ListPopupMenu(myMenus->myActivePopupMenu, + atts.value( "context-id" ), + atts.value( "parent-id" ), + atts.value( "object-id" )); + myMenus->append(pmenu); + } else if ( qName == "toolbar" ) { //TOOLBAR + QToolBar* aToolBar=new QToolBar(atts.value( "label-id" ),myDesktop); + aToolBar->setCloseMode( QDockWindow::Undocked ); + myMenus->append(aToolBar); + myMenus->myActiveToolBar=aToolBar; + myMenus->myActiveToolBar->hide(); + } else if ( qName == "toolbutton-item" ) { //TOOL BUTTON + QString aQStringToolButtonItemId(atts.value( "item-id" )); + QAction* anAction= + new QAction + (QObject::tr(atts.value( "label-id" )), + QPixmap( findFile( myPathResources, atts.value( "icon-id") ) ), + QObject::tr(atts.value( "label-id" )), + QAccel::stringToKey(QObject::tr(atts.value( "accel-id" ))), + myDesktop); + + anAction->setStatusTip(QObject::tr(atts.value( "tooltip-id" ))); + anAction->setToolTip(QObject::tr(atts.value( "tooltip-id" ))); + anAction->addTo(myMenus->myActiveToolBar); + QAD_ListMenuIdAction* menu = new QAD_ListMenuIdAction(myMenus->myActivePopupMenu, + aQStringToolButtonItemId.toInt(), + anAction); + myMenus->append(menu); + QObject::connect(anAction,SIGNAL(activated()), myDesktop,SLOT(onDispatch( ))); + } else if (qName == "separatorTB") { + myMenus->myActiveToolBar->addSeparator(); + } else if (qName == "separator") { + int id; + int pos; + if (atts.value( "pos-id" ).compare(QString(""))==0) { + pos = -1; + } + else { + pos = atts.value( "pos-id" ).toInt(); + if ( pos < 0 ) + pos = myMenus->myActivePopupMenu->count() + pos; + } + id = myMenus->myActivePopupMenu->insertSeparator( pos ); + myIdList.Append(id); + }else { + // error + return FALSE; + } + return TRUE; +} + + +/*! + Reimplemented from QXmlDefaultHandler. +*/ +bool QAD_XmlHandler::endElement( const QString&, const QString&, const QString& ) +{ + return TRUE; +} + + +/*! + Reimplemented from QXmlDefaultHandler. +*/ +bool QAD_XmlHandler::characters( const QString& ch ) +{ + // we are not interested in whitespaces + QString ch_simplified = ch.simplifyWhiteSpace(); + if ( ch_simplified.isEmpty() ) + return TRUE; + return TRUE; +} + + +/*! + Returns the default error string. + + Reimplemented from QXmlDefaultHandler. +*/ +QString QAD_XmlHandler::errorString() +{ + return "the document is not in the quote file format"; +} + +/*! + Returns exception + + Reimplemented from QXmlDefaultHandler. +*/ +bool QAD_XmlHandler::fatalError( const QXmlParseException& exception ) +{ + myErrorProt += QString( "fatal parsing error: %1 in line %2, column %3\n" ) + .arg( exception.message() ) + .arg( exception.lineNumber() ) + .arg( exception.columnNumber() ); + + return QXmlDefaultHandler::fatalError( exception ); +} + +/*! + Returns the error protocol if parsing failed + + Reimplemented from QXmlDefaultHandler. +*/ +QString QAD_XmlHandler::errorProtocol() +{ + return myErrorProt; +} + +QString QAD_XmlHandler::givebib(const int mykey) +{ + return QAD_XmlHandler::_bibmap[mykey]; +} diff --git a/src/SALOMEGUI/QAD_XmlHandler.h b/src/SALOMEGUI/QAD_XmlHandler.h new file mode 100644 index 000000000..91c18f203 --- /dev/null +++ b/src/SALOMEGUI/QAD_XmlHandler.h @@ -0,0 +1,55 @@ +// File : QAD_XmlHandler.h +// Created : Thu Jun 14 14:02:23 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include +#include +#include +#include +#include +#include + +#include + +class QAD_Desktop; +class QAD_Menus; + +class QAD_XmlHandler : public QXmlDefaultHandler +{ +public: + QAD_XmlHandler(); + virtual ~QAD_XmlHandler(); + + bool startDocument(); + bool startElement( const QString& namespaceURI, const QString& localName, + const QString& qName, const QXmlAttributes& atts ); + bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); + bool characters( const QString& ch ); + + QString errorString(); + QString errorProtocol(); + bool fatalError (const QXmlParseException& exception); + QString givebib (const int mykey); + + void setMainWindow(QAD_Desktop*); + bool setComponent (const QString& aComponent); + + QList myMenusList; + TColStd_SequenceOfInteger myIdList; + QAD_Menus* myMenus; + + static map _bibmap; + +private: + QString myErrorProt; + QString myPathResources; + + bool myBackMenu; + QStack myBackPopupMenus; + + QAD_Desktop* myDesktop; +}; diff --git a/src/SALOMEGUI/QAD_icons.po b/src/SALOMEGUI/QAD_icons.po new file mode 100644 index 000000000..089044e1a --- /dev/null +++ b/src/SALOMEGUI/QAD_icons.po @@ -0,0 +1,116 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: example-Qt-message-extraction\n" +"POT-Creation-Date: 1999-02-23 15:38+0200\n" +"PO-Revision-Date: 1999-02-23 15:38+0200\n" +"Last-Translator: \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +#-------------- +# DESKTOP +#-------------- + +msgid "ICON_DESK_WINDOW_CASCADE" +msgstr "cascade.png" + +msgid "ICON_DESK_WINDOW_TILE" +msgstr "tile.png" + +#-------------- +# FILE +#-------------- + +msgid "ICON_FILE_NEW" +msgstr "new.png" + +msgid "ICON_FILE_OPEN" +msgstr "open.png" + +msgid "ICON_FILE_LOAD" +msgstr "open.png" + +msgid "ICON_FILE_SAVE" +msgstr "save.png" + +msgid "ICON_FILE_CLOSE" +msgstr "close.png" + +#-------------- +# HELP +#-------------- + +msgid "ICON_HELP" +msgstr "help.png" + +msgid "QAD_HelpWindow::ICON_APP_HELP_BACK" +msgstr "back.xpm" + +msgid "QAD_HelpWindow::ICON_APP_HELP_FORWARD" +msgstr "forward.xpm" + +msgid "QAD_HelpWindow::ICON_APP_HELP_HOME" +msgstr "home.xpm" + +#-------------- +# VIEW +#-------------- + +msgid "ICON_PRINT" +msgstr "print.png" + +msgid "ICON_RESET" +msgstr "reset.png" + +#-------------- +# APPLICATION +#-------------- + +msgid "ICON_APP_EDIT_UNDO" +msgstr "undo.png" + +msgid "ICON_APP_EDIT_REDO" +msgstr "redo.png" + +msgid "ICON_APP_EDIT_COPY" +msgstr "copy.png" + +msgid "ICON_APP_EDIT_PASTE" +msgstr "paste.png" + +#-------------- +# DIALOGS +#-------------- + +msgid "ICON_DIRLIST_INSERT" +msgstr "dl_insert.png" + +msgid "ICON_DIRLIST_DELETE" +msgstr "dl_delete.png" + +msgid "ICON_DIRLIST_MOVEUP" +msgstr "dl_moveup.png" + +msgid "ICON_DIRLIST_MOVEDOWN" +msgstr "dl_movedown.png" + +#----------------- +# USE CASE BROWSER +#----------------- + +msgid "ICON_UC_ADD" +msgstr "uc_add.png" + +msgid "ICON_UC_REMOVE" +msgstr "uc_del.png" + +msgid "ICON_UC_SET_CURRENT" +msgstr "uc_current.png" + +msgid "ICON_UC_NEW" +msgstr "uc_new.png" + +msgid "ICON_UC_CLEAR" +msgstr "uc_clear.png" diff --git a/src/SALOMEGUI/QAD_msg_en.po b/src/SALOMEGUI/QAD_msg_en.po new file mode 100644 index 000000000..55fab2465 --- /dev/null +++ b/src/SALOMEGUI/QAD_msg_en.po @@ -0,0 +1,747 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: example-Qt-message-extraction\n" +"POT-Creation-Date: 1999-02-23 15:38+0200\n" +"PO-Revision-Date: 1999-02-23 15:38+0200\n" +"Last-Translator: \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +#--------------- +# BUTTONS +#--------------- + +msgid "BUT_CANCEL" +msgstr "Cancel" + +msgid "BUT_HELP" +msgstr "Help" + +msgid "BUT_OK" +msgstr "Ok" + +msgid "BUT_NO" +msgstr "No" + +msgid "BUT_YES" +msgstr "Yes" + +#--------------- +# INFORMATIONS +#--------------- + +#: QAD_Desktop.cxx:1152 +msgid "Desktop_AppSelectionDlg::INF_DESK_DOC_CREATE" +msgstr "Create a new study" + +#: QAD_Desktop.cxx:722 +msgid "INF_CANCELLED" +msgstr "Cancelled" + +#: QAD_Desktop.cxx:605 +msgid "INF_READY" +msgstr "Ready" + +#: QAD_Desktop.cxx:605 +msgid "INF_RESOURCES" +msgstr "Check your resources installation." + +#: QAD_Desktop.cxx:605 +msgid "INF_ICON_RESOURCES" +msgstr "Could not find icon file %1 for module %2.\n" + +#: QAD_Desktop.cxx:551 +msgid "INF_DESK_DOC_OPEN" +msgstr "Open study" + +#: QAD_Desktop.cxx:654 +msgid "INF_DESK_DOC_SAVE" +msgstr "Save study" + +#: QAD_Desktop.cxx:465 +msgid "QAD_Desktop::INF_DESK_EXIT" +msgstr "Exit" + +#: QAD_Desktop.cxx:530 +msgid "QAD_Desktop::INF_DOC_CREATING" +msgstr "Creating study " + +#: QAD_Desktop.cxx:558 +msgid "QAD_Desktop::INF_DOC_OPENING" +msgstr "Opening study " + +#: QAD_Desktop.cxx:691 +msgid "QAD_Desktop::INF_DOC_SAVED" +msgstr "Study %1 saved" + +#: QAD_Desktop.cxx:679 +msgid "QAD_Desktop::INF_DOC_SAVING" +msgstr "Saving study " + +#: QAD_Desktop.cxx:993 +msgid "QAD_Desktop::INF_PARSE_ERROR" +msgstr "Parse error" + +#: QAD_Study.cxx:570 +msgid "QAD_Study::INF_DOC_OPERATIONABORTED" +msgstr "Operation aborted" + +#: QAD_Study.cxx:539 +msgid "QAD_Study::INF_DOC_OPERATIONFINISHED" +msgstr "Operation finished" + +#: *.cxx:855 +msgid "INF_APP_EXPORT" +msgstr "Image Files" + +#--------------- +# MENUS +#--------------- + +#: QAD_Desktop.cxx:19 +msgid "QAD_Desktop::MEN_OPENWITH" +msgstr "Open With..." + +#: QAD_Desktop.cxx:407 +msgid "QAD_Desktop::MEN_DESK_EDIT" +msgstr "&Edit" + +#: QAD_Desktop.cxx:138 +msgid "QAD_Desktop::MEN_DESK_FILE" +msgstr "&File" + +#: QAD_Desktop.cxx:176 +msgid "QAD_Desktop::MEN_DESK_FILE_CLOSE" +msgstr "&Close" + +#: QAD_Desktop.cxx:206 +msgid "QAD_Desktop::MEN_DESK_FILE_EXIT" +msgstr "E&xit" + +#: QAD_Desktop.cxx:155 +msgid "QAD_Desktop::MEN_DESK_FILE_NEW" +msgstr "&New" + +#: QAD_Desktop.cxx:166 +msgid "QAD_Desktop::MEN_DESK_FILE_OPEN" +msgstr "&Open ..." + +#: QAD_Desktop.cxx:166 +msgid "QAD_Desktop::MEN_DESK_FILE_LOAD" +msgstr "&Load ..." + +#: QAD_Desktop.cxx:187 +msgid "QAD_Desktop::MEN_DESK_FILE_SAVE" +msgstr "&Save" + +#: QAD_Desktop.cxx:195 +msgid "QAD_Desktop::MEN_DESK_FILE_SAVEAS" +msgstr "Save As ..." + +#: QAD_Desktop.cxx:141 +msgid "QAD_Desktop::MEN_DESK_HELP" +msgstr "&Help" + +#: QAD_Desktop.cxx:291 +msgid "QAD_Desktop::MEN_DESK_HELP_ABOUT" +msgstr "&About ..." + +#: QAD_Desktop.cxx:265 +msgid "QAD_Desktop::MEN_DESK_HELP_CONTENTS" +msgstr "&Contents" + +#: QAD_Desktop.cxx:273 +msgid "QAD_Desktop::MEN_DESK_HELP_SEARCH" +msgstr "&Search ..." + +#: QAD_Desktop.cxx:280 +msgid "QAD_Desktop::MEN_DESK_HELP_WHATSTHIS" +msgstr "What's this?" + +#: QAD_Desktop.cxx:139 +msgid "QAD_Desktop::MEN_DESK_VIEW" +msgstr "&View" + +#: QAD_Config.cxx:265 +msgid "MEN_DESK_PREF" +msgstr "Preferences" + +#: QAD_Config.cxx:376 +msgid "MEN_DESK_PREF_SAVE" +msgstr "Save" + +#: QAD_Config.cxx:376 +msgid "MEN_DESK_PREF_VIEWER" +msgstr "3D View background" + +#: QAD_Config.cxx:376 +msgid "MEN_DESK_PREF_VIEWER_TRIHEDRON" +msgstr "Trihedron size" + +msgid "MEN_DESK_PREF_DEFAULT_VIEWER" +msgstr "Default viewer" + +#: QAD_Config.cxx:378 +msgid "MEN_DESK_PREF_VIEWER_OCC" +msgstr "OCC Viewer" + +#: QAD_Config.cxx:383 +msgid "MEN_DESK_PREF_VIEWER_VTK" +msgstr "VTK Viewer" + +#: QAD_Config.cxx:383 +msgid "MEN_DESK_PREF_GRAPH_SUPERVISOR" +msgstr "Graph Supervisor" + +msgid "MEN_DESK_PREF_VIEWER_PLOT2D" +msgstr "Plot2d Viewer" + +#: QAD_Config.cxx:378 +msgid "MEN_DESK_VIEW_OCC" +msgstr "OCC View" + +#: QAD_Config.cxx:383 +msgid "MEN_DESK_VIEW_VTK" +msgstr "VTK View" + +msgid "MEN_DESK_VIEW_PLOT2D" +msgstr "Plot2d View" + +#: QAD_Desktop.cxx:473 +msgid "MEN_DESK_PREF_OBJECTBROWSER" +msgstr "ObjectBrowser" + +#: QAD_Desktop.cxx:473 +msgid "MEN_DESK_PREF_OBJECTBROWSER_ENTRY" +msgstr "Entry, IOR columns" + +#: QAD_Desktop.cxx:473 +msgid "MEN_DESK_PREF_OBJECTBROWSER_IAPP" +msgstr "Interface Applicative" + +msgid "MEN_DESK_PREF_OBJECTBROWSER_CHRONO_SORT" +msgstr "Chronological sort of objects" + + +msgid "QAD_Desktop::MEN_DESK_SELECTION_MODE" +msgstr "Selection Mode" + +msgid "QAD_Desktop::MEN_DESK_SELECTION_POINT" +msgstr "Point" + +msgid "QAD_Desktop::MEN_DESK_SELECTION_EDGE" +msgstr "Link" + +msgid "QAD_Desktop::MEN_DESK_SELECTION_CELL" +msgstr "Cell" + +msgid "QAD_Desktop::MEN_DESK_SELECTION_ACTOR" +msgstr "Actor" + +#: QAD_Config.cxx:265 +msgid "MEN_DESK_TOOLS" +msgstr "Tools" + +#: QAD_Desktop.cxx:228 +msgid "QAD_Desktop::MEN_DESK_VIEW_STATUSBAR" +msgstr "&Status Bar" + +#: QAD_Desktop.cxx:217 +msgid "QAD_Desktop::MEN_DESK_VIEW_STDTOOLBAR" +msgstr "Standard" + +#: SALOMEGUI_Application.cxx:82 +msgid "SALOMEGUI_Application::MEN_DESK_VIEWERTOOLBAR" +msgstr "Viewer" + +#: QAD_Desktop.cxx:226 +msgid "QAD_Desktop::MEN_DESK_COMPONENTTOOLBAR" +msgstr "Components" + +#: QAD_Desktop.cxx:140 +msgid "QAD_Desktop::MEN_DESK_WINDOW" +msgstr "&Window" + +#: QAD_Desktop.cxx:248 +msgid "QAD_Desktop::MEN_DESK_WINDOW_CASCADE" +msgstr "&Cascade" + +#: QAD_Desktop.cxx:240 +msgid "QAD_Desktop::MEN_DESK_WINDOW_NEW3D" +msgstr "&New Window" + +#: QAD_Desktop.cxx:256 +msgid "QAD_Desktop::MEN_DESK_WINDOW_TILE" +msgstr "&Tile" + +#: QAD_Application.cxx:175 +msgid "QAD_Application::MEN_APP_EDIT_REDO" +msgstr "&Redo" + +#: QAD_Application.cxx:165 +msgid "QAD_Application::MEN_APP_EDIT_UNDO" +msgstr "&Undo" + +#: QAD_Study.cxx:482 +msgid "QAD_Study::MEN_VIEWER" +msgstr "Viewer" + +#: *.cxx:45 +msgid "MEN_VP3D_CHANGEBGR" +msgstr "Change background..." + +msgid "MEN_APP_DISPLAY" +msgstr "Display" + +msgid "MEN_APP_DISPLAY_ONLY" +msgstr "Display only" + +msgid "MEN_APP_ERASE" +msgstr "Erase" + +#--------------- +# PRP +#--------------- + +#: QAD_Desktop.cxx:177 +msgid "QAD_Desktop::PRP_DESK_FILE_CLOSE" +msgstr "Closes the active study" + +#: QAD_Desktop.cxx:207 +msgid "QAD_Desktop::PRP_DESK_FILE_EXIT" +msgstr "Exits the application" + +#: QAD_Desktop.cxx:156 +msgid "QAD_Desktop::PRP_DESK_FILE_NEW" +msgstr "Creates a new study" + +#: QAD_Desktop.cxx:167 +msgid "QAD_Desktop::PRP_DESK_FILE_OPEN" +msgstr "Opens an existing study" + +#: QAD_Desktop.cxx:167 +msgid "QAD_Desktop::PRP_DESK_FILE_LOAD" +msgstr "Loads an existing study" + +#: QAD_Desktop.cxx:188 +msgid "QAD_Desktop::PRP_DESK_FILE_SAVE" +msgstr "Saves the active study" + +#: QAD_Desktop.cxx:196 +msgid "QAD_Desktop::PRP_DESK_FILE_SAVEAS" +msgstr "Saves the active study with a new name" + +#: QAD_Desktop.cxx:292 +msgid "QAD_Desktop::PRP_DESK_HELP_ABOUT" +msgstr "Shows \'About\' dialog" + +#: QAD_Desktop.cxx:266 +msgid "QAD_Desktop::PRP_DESK_HELP_CONTENTS" +msgstr "Shows the whole help contents" + +#: QAD_Desktop.cxx:274 +msgid "QAD_Desktop::PRP_DESK_HELP_SEARCH" +msgstr "Searches help for a topic" + +#: QAD_Desktop.cxx:281 +msgid "QAD_Desktop::PRP_DESK_HELP_WHATSTHIS" +msgstr "What's this?" + +msgid "QAD_Desktop::MEN_DESK_VIEW_TOOLBARS" +msgstr "Toolbars" + +#: QAD_Desktop.cxx:230 +msgid "QAD_Desktop::PRP_DESK_VIEW_STATUSBAR" +msgstr "Toggles status bar view on/off" + +#: QAD_Desktop.cxx:220 +msgid "QAD_Desktop::PRP_DESK_VIEW_TOOLBAR" +msgstr "Toggles toolbar on/off" + +#: QAD_Desktop.cxx:871 +msgid "QAD_Desktop::PRP_DESK_WINDOW_ACTIVATE" +msgstr "Activates this window" + +#: QAD_Desktop.cxx:249 +msgid "QAD_Desktop::PRP_DESK_WINDOW_CASCADE" +msgstr "Arranges the windows as overlapping tiles" + +#: QAD_Desktop.cxx:257 +msgid "QAD_Desktop::PRP_DESK_WINDOW_TILE" +msgstr "Arranges the windows as nonoverlapping tiles" + +#: QAD_Application.cxx:176 +msgid "QAD_Application::PRP_APP_EDIT_REDO" +msgstr "Redoes the last operation" + +#: QAD_Application.cxx:166 +msgid "QAD_Application::PRP_APP_EDIT_UNDO" +msgstr "Undoes the last operation" + +#: *.cxx:405 +msgid "PRP_VW3D_POINTCENTER" +msgstr "Set a new center of the view with MB1" + +#: *.cxx:374 +msgid "PRP_VW3D_SKETCHAREA" +msgstr "Sketch a rectangular area to fit the view" + +#--------------- +# TOOL TIP +#--------------- + +#: QAD_HelpWindow.cxx:57 +msgid "QAD_HelpWindow::TOT_HELPWINDOW_BACKWARD" +msgstr "Backward" + +#: QAD_HelpWindow.cxx:60 +msgid "QAD_HelpWindow::TOT_HELPWINDOW_FORWARD" +msgstr "Forward" + +#: QAD_HelpWindow.cxx:63 +msgid "QAD_HelpWindow::TOT_HELPWINDOW_HOME" +msgstr "Home" + +msgid "QAD_HelpWindow::QAD_HELP_CONTENTS" +msgstr "Contents" + +#: QAD_Application.cxx:173 +msgid "QAD_Application::TOT_APP_EDIT_REDO" +msgstr "Redo last operation" + +#: QAD_Application.cxx:163 +msgid "QAD_Application::TOT_APP_EDIT_UNDO" +msgstr "Undo last operation" + +#: QAD_Desktop.cxx:153 +msgid "QAD_Desktop::TOT_DESK_FILE_NEW" +msgstr "New study" + +#: QAD_Desktop.cxx:165 +msgid "QAD_Desktop::TOT_DESK_FILE_OPEN" +msgstr "Open study" + +#: QAD_Desktop.cxx:165 +msgid "QAD_Desktop::TOT_DESK_FILE_LOAD" +msgstr "Load study" + +#: QAD_Desktop.cxx:186 +msgid "QAD_Desktop::TOT_DESK_FILE_SAVE" +msgstr "Save study" + +#--------------- +# ERROR +#--------------- + +#: *.cxx:233 +msgid "QObject::ERR_VP_NOVIEW" +msgstr "No View" + +#: QAD_Desktop.cxx:516 +msgid "QAD_Desktop::ERR_APP_NOAPP" +msgstr "No application" + +#: QAD_Desktop.cxx:535 +msgid "QAD_Desktop::ERR_DOC_CANTCREATE" +msgstr "Cannot create study" + +#: QAD_Desktop.cxx:586 +msgid "QAD_Desktop::ERR_DOC_CANTOPEN" +msgstr "Cannot open study" + +#: QAD_Desktop.cxx:683 +msgid "QAD_Desktop::ERR_DOC_CANTWRITE" +msgstr "Cannot save study" + +#: QAD_Desktop.cxx:599 +msgid "QAD_Desktop::ERR_DOC_UNKNOWNTYPE" +msgstr "Unknown study type" + +#: QAD_Study.cxx:321 +msgid "QAD_Study::ERR_DOC_READONLY" +msgstr "The study is read-only" + +#: QAD_Desktop.cxx:683 +msgid "ERR_ERROR" +msgstr "Error" + +msgid "ERR_APP_EXCEPTION" +msgstr "An exception has been caught. Click to continue." + +msgid "ERR_ONLY_PLOT2D_VIEWER" +msgstr "This function is available only in Plot2d viewer" + +#--------------- +# QUESTION +#--------------- + +#: QAD_Study.cxx:335 +msgid "QAD_Study::QUE_ABORTCURRENTOPERATION" +msgstr "The current operation is not terminated yet.\nDo you want to abort it ?" + +#: QAD_Desktop.cxx:465 +msgid "QAD_Desktop::QUE_DESK_EXIT" +msgstr "Do you really want to quit ?" + +#: QAD_Desktop.cxx:569 +msgid "QAD_Desktop::QUE_DOC_ALREADYOPEN" +msgstr "The study %1 is already open.\nDo you want to reload it ?" + +#: QAD_Desktop.cxx:569 +msgid "QAD_Desktop::QUE_DOC_ALREADYEXIST" +msgstr "The study %1 already exists in study manager.\nDo you want to reload it ?" + +#: QAD_Desktop.cxx:668 +msgid "QUE_DOC_FILEEXISTS" +msgstr "The file %1 already exists.\nDo you want to overwrite it ?" + +#: *.cxx:502 +#msgid "INF_READY" +#msgstr "Ready" + +#: QAD_Desktop.cxx:710 +msgid "QAD_Desktop::QUE_DOC_NOTSAVED" +msgstr "The study %1 is not saved.\nDo you want to save it ?" + +#--------------- +# WARNING +#--------------- + +#: *.cxx:374 +#msgid "PRP_VW3D_SKETCHAREA" +#msgstr "Sketch a rectangular area to fit the view" + +#: *.cxx:709 +msgid "WRN_WARNING" +msgstr "Warning" + +#: QAD_Desktop.cxx:1072 +msgid "QAD_Desktop::WRN_LOAD_COMPONENT" +msgstr "Creates or opens before a study" + +msgid "WRN_STUDY_LOCKED" +msgstr "This study is locked and therefore cannot be modified" + +------ + +#: QAD_Desktop.cxx:431 +msgid "QAD_Desktop::DESK_DEFAULTDOC" +msgstr "Study" + + +#: QAD_Desktop.cxx:920 +msgid "QAD_Desktop::DESK_FILES" +msgstr "Files" + +msgid "OCC_IMAGE_FILES" +msgstr "Images Files (*.bmp *.png *.jpg *.jpeg)" + +msgid "VTK_IMAGE_FILES" +msgstr "Images Files (*.tif)" + +msgid "INF_APP_DUMP_VIEW" +msgstr "Dump view" + +msgid "ERR_DOC_CANT_SAVE_FILE" +msgstr "Cannot save file" + +msgid "EDIT_CUT_CMD" +msgstr "Cu&t" + +msgid "EDIT_COPY_CMD" +msgstr "&Copy" + +msgid "EDIT_PASTE_CMD" +msgstr "&Paste" + +msgid "EDIT_CLEAR_CMD" +msgstr "Clear" + +msgid "EDIT_SELECTALL_CMD" +msgstr "Select All" + +msgid "MESSAGE_LOG_NAME" +msgstr "Message Log" + +msgid "QAD_DirListDlg::QUICK_DIR_LIST_TLT" +msgstr "Quick directory list" + +msgid "QAD_DirListDlg::EMPTY_DIR" +msgstr "" + +msgid "QAD_DirListDlg::DIRECTORIES_LBL" +msgstr "&Directories:" + +msgid "QAD_DirListDlg::ERR_DIRECTORY_SPECIFIED" +msgstr "Directory already specified." + +msgid "QAD_DirListDlg::WRN_DIRECTORY_N0T_EXIST" +msgstr "%1\n\nThe directory doesn't exist.\nAdd directory anyway?" + +msgid "QAD_DirListDlg::SELECT_DIRECTORY" +msgstr "Select directory" + +msgid "ERR_DOC_FILENOTEXIST" +msgstr "The file %1 doesn't exist" + +msgid "ERR_PERMISSION_DENIED" +msgstr "Can't save file %1.\nPermission denied." + +msgid "ERR_DIR_NOT_EXIST" +msgstr "%1\n\nThe directory doesn't exist." + +msgid "MEN_DESK_PREF_DIRICTORIES" +msgstr "&Directories..." + +msgid "QAD_FileDlg::DIRECTORIES_FILTER" +msgstr "Directories" + +msgid "MEN_DESK_FILE_PROPERTIES" +msgstr "&Properties..." + +msgid "PRP_DESK_FILE_PROPERTIES" +msgstr "View/modify study properties" + +msgid "PRP_YES" +msgstr "Yes" + +msgid "PRP_NO" +msgstr "No" + +msgid "PRP_STUDY_LOCKED" +msgstr "LOCKED" + +msgid "PRP_STUDY_MODIFIED" +msgstr "MODIFIED" + +msgid "PRP_STUDY_SAVED" +msgstr "SAVED" + +msgid "PRP_MODIFICATIONS" +msgstr "Modifications" + +msgid "PRP_MODE_FROM_SCRATCH" +msgstr "from scratch" + +msgid "PRP_MODE_FROM_COPYFROM" +msgstr "copy from" + +msgid "SALOMEGUI_StudyPropertiesDlg::TLT_STUDY_PROPERTIES" +msgstr "Study Properties" + +msgid "MEN_DESK_PREF_CONSOLE_FONT" +msgstr "Console Font" + +msgid "TLT_OBJECT_BROWSER" +msgstr "Object Browser" + +msgid "TLT_USECASE_BROWSER" +msgstr "UseCase Browser" + +msgid "OBJECT_BROWSER_VALUE" +msgstr "Value" + +msgid "OBJECT_BROWSER_ENTRY" +msgstr "Entry" + +msgid "OBJECT_BROWSER_IOR" +msgstr "IOR" + +msgid "OBJECT_BROWSER_REFENTRY" +msgstr "Reference entry" + +msgid "OBJECT_BROWSER_OBJECT" +msgstr "Object" + +msgid "MEN_DESK_PREF_OBJECTBROWSER_VALUE" +msgstr "Value column" + +msgid "SET_VALUE_INT_TLT" +msgstr "Set Integer" + +msgid "SET_VALUE_INT_LBL" +msgstr "Value:" + +msgid "SET_VALUE_REAL_TLT" +msgstr "Set Real" + +msgid "SET_VALUE_REAL_LBL" +msgstr "Value:" + +msgid "SET_VALUE_COMMENT_TLT" +msgstr "Set Comment" + +msgid "SET_VALUE_COMMENT_LBL" +msgstr "Comment:" + +msgid "QAD_Desktop::TLT_CLOSESTUDY" +msgstr "Close Study" + +msgid "QAD_Desktop::QUESTION_CLOSESTUDY" +msgstr "Do you want to delete study permanently?" + +msgid "UC_POPUP" +msgstr "Use case" + +msgid "UC_NEW_ID" +msgstr "New object" +msgid "UC_NEW_TIP" +msgstr "Creates new object under current context" + +msgid "UC_SET_CURRENT_ID" +msgstr "Set current" +msgid "UC_SET_CURRENT_TIP" +msgstr "Sets current context" + +msgid "UC_APPEND_ID" +msgstr "Add objects" +msgid "UC_APPEND_TIP" +msgstr "Add selected object(s) under current context" + +msgid "UC_REMOVE_ID" +msgstr "Remove objects" +msgid "UC_REMOVE_TIP" +msgstr "Remove selected object(s) from use case" + +msgid "UC_RENAME_ID" +msgstr "Rename" +msgid "UC_RENAME_TIP" +msgstr "Renames object" + +msgid "UC_CLEAR_ID" +msgstr "Clear" +msgid "UC_CLEAR_TIP" +msgstr "Clears use case" + +msgid "MEN_DESK_PREF_MULTI_FILE_SAVE" +msgstr "MultiFile Save" + +msgid "TOT_APP_EDIT_COPY" +msgstr "Copy" + +msgid "MEN_APP_EDIT_COPY" +msgstr "&Copy" + +msgid "PRP_APP_EDIT_COPY" +msgstr "Copies selected object into the clipboard" + +msgid "TOT_APP_EDIT_PASTE" +msgstr "Paste" + +msgid "MEN_APP_EDIT_PASTE" +msgstr "&Paste" + +msgid "PRP_APP_EDIT_PASTE" +msgstr "Pastes object from the clipboard" + +msgid "EDIT_VALUE_CMD" +msgstr "Edit value" + +msgid "PLOT_TABLE_CMD" +msgstr "Plot table" + +msgid "NEW_OBJECT" +msgstr "New object" + diff --git a/src/SALOMEGUI/QAD_msg_fr.po b/src/SALOMEGUI/QAD_msg_fr.po new file mode 100644 index 000000000..83dad7cdc --- /dev/null +++ b/src/SALOMEGUI/QAD_msg_fr.po @@ -0,0 +1,599 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: example-Qt-message-extraction\n" +"POT-Creation-Date: 1999-02-23 15:38+0200\n" +"PO-Revision-Date: 1999-02-23 15:38+0200\n" +"Last-Translator: \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +#--------------- +# BUTTONS +#--------------- + +msgid "BUT_CANCEL" +msgstr "Annule" + +msgid "BUT_HELP" +msgstr "Aide" + +msgid "BUT_OK" +msgstr "Ok" + +msgid "BUT_NO" +msgstr "Non" + +msgid "BUT_YES" +msgstr "Oui" + +#--------------- +# INFORMATIONS +#--------------- + +#: QAD_Desktop.cxx:1152 +msgid "Desktop_AppSelectionDlg::INF_DESK_DOC_CREATE" +msgstr "Créer une nouvelle étude" + +#: QAD_Desktop.cxx:722 +msgid "INF_CANCELLED" +msgstr "Annulé" + +#: QAD_Desktop.cxx:605 +msgid "INF_READY" +msgstr "Ready" + +#: QAD_Desktop.cxx:605 +msgid "INF_RESOURCES" +msgstr "Check your resources installation." + +#: QAD_Desktop.cxx:605 +msgid "INF_ICON_RESOURCES" +msgstr "Could not find icon file %1 for module %2.\n" + +#: QAD_Desktop.cxx:551 +msgid "INF_DESK_DOC_OPEN" +msgstr "Ouvrir l'étude" + +#: QAD_Desktop.cxx:654 +msgid "INF_DESK_DOC_SAVE" +msgstr "Enregistrer l'étude" + +#: QAD_Desktop.cxx:465 +msgid "QAD_Desktop::INF_DESK_EXIT" +msgstr "Quitter" + +#: QAD_Desktop.cxx:530 +msgid "QAD_Desktop::INF_DOC_CREATING" +msgstr "Création de l'étude" + +#: QAD_Desktop.cxx:558 +msgid "QAD_Desktop::INF_DOC_OPENING" +msgstr "Ouverture de l'étude" + +#: QAD_Desktop.cxx:691 +msgid "QAD_Desktop::INF_DOC_SAVED" +msgstr "Étude %1 sauvée" + +#: QAD_Desktop.cxx:679 +msgid "QAD_Desktop::INF_DOC_SAVING" +msgstr "Enregistrement de l'étude" + +#: QAD_Desktop.cxx:993 +msgid "QAD_Desktop::INF_PARSE_ERROR" +msgstr "Parse error" + +#: QAD_Study.cxx:570 +msgid "QAD_Study::INF_DOC_OPERATIONABORTED" +msgstr "Opération interrompue" + +#: QAD_Study.cxx:539 +msgid "QAD_Study::INF_DOC_OPERATIONFINISHED" +msgstr "Opération terminée" + +#: *.cxx:855 +msgid "INF_APP_EXPORT" +msgstr "Fichiers Images" + +#--------------- +# MENUS +#--------------- + +#: QAD_Desktop.cxx:19 +msgid "QAD_Desktop::MEN_OPENWITH" +msgstr "Open With..." + +#: QAD_Application.cxx:331 +msgid "QAD_Application::MEN_ABOUT" +msgstr "A propos de SALOME Professional" + +#: QAD_Desktop.cxx:407 +msgid "QAD_Desktop::MEN_DESK_EDIT" +msgstr "&Édition" + +#: QAD_Desktop.cxx:138 +msgid "QAD_Desktop::MEN_DESK_FILE" +msgstr "&Fichier" + +#: QAD_Desktop.cxx:176 +msgid "QAD_Desktop::MEN_DESK_FILE_CLOSE" +msgstr "&Fermer" + +#: QAD_Desktop.cxx:206 +msgid "QAD_Desktop::MEN_DESK_FILE_EXIT" +msgstr "&Quitter" + +#: QAD_Desktop.cxx:155 +msgid "QAD_Desktop::MEN_DESK_FILE_NEW" +msgstr "&Nouveau" + +#: QAD_Desktop.cxx:166 +msgid "QAD_Desktop::MEN_DESK_FILE_OPEN" +msgstr "&Ouvrir ..." + +#: QAD_Desktop.cxx:166 +msgid "QAD_Desktop::MEN_DESK_FILE_LOAD" +msgstr "&Charger ..." + +#: QAD_Desktop.cxx:187 +msgid "QAD_Desktop::MEN_DESK_FILE_SAVE" +msgstr "&Enregistrer" + +#: QAD_Desktop.cxx:195 +msgid "QAD_Desktop::MEN_DESK_FILE_SAVEAS" +msgstr "Enregistrer sous ..." + +#: QAD_Desktop.cxx:141 +msgid "QAD_Desktop::MEN_DESK_HELP" +msgstr "&Aide" + +#: QAD_Desktop.cxx:291 +msgid "QAD_Desktop::MEN_DESK_HELP_ABOUT" +msgstr "&A propos de ..." + +#: QAD_Desktop.cxx:265 +msgid "QAD_Desktop::MEN_DESK_HELP_CONTENTS" +msgstr "&Sommaire" + +#: QAD_Desktop.cxx:273 +msgid "QAD_Desktop::MEN_DESK_HELP_SEARCH" +msgstr "&Recherche ..." + +#: QAD_Desktop.cxx:280 +msgid "QAD_Desktop::MEN_DESK_HELP_WHATSTHIS" +msgstr "Qu'est-ce-que c'est?" + +#: QAD_Desktop.cxx:139 +msgid "QAD_Desktop::MEN_DESK_VIEW" +msgstr "&Affichage" + +#: QAD_Config.cxx:265 +msgid "MEN_DESK_PREF" +msgstr "Préférences" + +#: QAD_Config.cxx:376 +msgid "MEN_DESK_PREF_SAVE" +msgstr "Enregistrer" + +#: QAD_Config.cxx:376 +msgid "MEN_DESK_PREF_VIEWER" +msgstr "Fond vues 3D" + +#: QAD_Config.cxx:376 +msgid "MEN_DESK_PREF_VIEWER_TRIHEDRON" +msgstr "Dimension du repère" + +msgid "MEN_DESK_PREF_DEFAULT_VIEWER" +msgstr "Default viewer" + +#: QAD_Config.cxx:378 +msgid "MEN_DESK_PREF_VIEWER_OCC" +msgstr "Viewer OCC" + +#: QAD_Config.cxx:383 +msgid "MEN_DESK_PREF_VIEWER_VTK" +msgstr "Viewer VTK" + +#: QAD_Config.cxx:383 +msgid "MEN_DESK_PREF_GRAPH_SUPERVISOR" +msgstr "Graphe Supervision" + +#: QAD_Desktop.cxx:473 +msgid "MEN_DESK_PREF_OBJECTBROWSER" +msgstr "ObjectBrowser" + +#: QAD_Desktop.cxx:473 +msgid "MEN_DESK_PREF_OBJECTBROWSER_ENTRY" +msgstr "Entry, IOR colonnes" + +#: QAD_Desktop.cxx:473 +msgid "MEN_DESK_PREF_OBJECTBROWSER_IAPP" +msgstr "Interface Applicative" + +msgid "MEN_DESK_PREF_OBJECTBROWSER_CHRONO_SORT" +msgstr "Objets par ordre chrono" + + +msgid "QAD_Desktop::MEN_DESK_SELECTION_MODE" +msgstr "Mode de Selection" + +msgid "QAD_Desktop::MEN_DESK_SELECTION_POINT" +msgstr "Point" + +msgid "QAD_Desktop::MEN_DESK_SELECTION_EDGE" +msgstr "Arête" + +msgid "QAD_Desktop::MEN_DESK_SELECTION_CELL" +msgstr "Cellule" + +msgid "QAD_Desktop::MEN_DESK_SELECTION_ACTOR" +msgstr "Acteur" + +#: QAD_Config.cxx:265 +msgid "MEN_DESK_TOOLS" +msgstr "Outils" + +#: QAD_Desktop.cxx:228 +msgid "QAD_Desktop::MEN_DESK_VIEW_STATUSBAR" +msgstr "&Barre d'état" + +#: QAD_Desktop.cxx:217 +msgid "QAD_Desktop::MEN_DESK_VIEW_STDTOOLBAR" +msgstr "Barre d'outils standard" + +#: QAD_Desktop.cxx:140 +msgid "QAD_Desktop::MEN_DESK_WINDOW" +msgstr "&Fenêtre" + +#: QAD_Desktop.cxx:248 +msgid "QAD_Desktop::MEN_DESK_WINDOW_CASCADE" +msgstr "&Cascade" + +#: QAD_Desktop.cxx:240 +msgid "QAD_Desktop::MEN_DESK_WINDOW_NEW3D" +msgstr "&Nouvelle fenêtre 3D" + +#: QAD_Desktop.cxx:256 +msgid "QAD_Desktop::MEN_DESK_WINDOW_TILE" +msgstr "&Mozaïque" + +#: QAD_Application.cxx:175 +msgid "QAD_Application::MEN_APP_EDIT_REDO" +msgstr "Répeter" + +#: QAD_Application.cxx:165 +msgid "QAD_Application::MEN_APP_EDIT_UNDO" +msgstr "Annuler" + +#: QAD_Config.cxx:84 +msgid "MEN_APPNAME" +msgstr "salome" + +#: QAD_Study.cxx:482 +msgid "QAD_Study::MEN_VIEWER" +msgstr "Viewer" + +#: *.cxx:45 +msgid "MEN_VP3D_CHANGEBGR" +msgstr "Changer l'arrière-plan..." + +msgid "MEN_APP_DISPLAY" +msgstr "Afficher" + +msgid "MEN_APP_DISPLAY_ONLY" +msgstr "Afficher seulement" + +msgid "MEN_APP_ERASE" +msgstr "Effacer" + +#--------------- +# PRP +#--------------- + +#: QAD_Desktop.cxx:177 +msgid "QAD_Desktop::PRP_DESK_FILE_CLOSE" +msgstr "Fermer l'étude" + +#: QAD_Desktop.cxx:207 +msgid "QAD_Desktop::PRP_DESK_FILE_EXIT" +msgstr "Quitter l'application" + +#: QAD_Desktop.cxx:156 +msgid "QAD_Desktop::PRP_DESK_FILE_NEW" +msgstr "Créer une nouvelle étude" + +#: QAD_Desktop.cxx:167 +msgid "QAD_Desktop::PRP_DESK_FILE_OPEN" +msgstr "Ouvrir une étude existante" + +#: QAD_Desktop.cxx:167 +msgid "QAD_Desktop::PRP_DESK_FILE_LOAD" +msgstr "Charger une étude existante" + +#: QAD_Desktop.cxx:188 +msgid "QAD_Desktop::PRP_DESK_FILE_SAVE" +msgstr "Enregistrer l'étude" + +#: QAD_Desktop.cxx:196 +msgid "QAD_Desktop::PRP_DESK_FILE_SAVEAS" +msgstr "Enregistrer l'étude sous ..." + +#: QAD_Desktop.cxx:292 +msgid "QAD_Desktop::PRP_DESK_HELP_ABOUT" +msgstr "Shows \'About\' dialog" + +#: QAD_Desktop.cxx:266 +msgid "QAD_Desktop::PRP_DESK_HELP_CONTENTS" +msgstr "Sommaire" + +#: QAD_Desktop.cxx:274 +msgid "QAD_Desktop::PRP_DESK_HELP_SEARCH" +msgstr "Recherche" + +#: QAD_Desktop.cxx:281 +msgid "QAD_Desktop::PRP_DESK_HELP_WHATSTHIS" +msgstr "Qu'est-ce-que c'est?" + +#: QAD_Desktop.cxx:230 +msgid "QAD_Desktop::PRP_DESK_VIEW_STATUSBAR" +msgstr "Toggles status bar view on/off" + +#: QAD_Desktop.cxx:220 +msgid "QAD_Desktop::PRP_DESK_VIEW_STDTOOLBAR" +msgstr "Toggles standard toolbar on/off" + +#: QAD_Desktop.cxx:871 +msgid "QAD_Desktop::PRP_DESK_WINDOW_ACTIVATE" +msgstr "Activer cette fenêtre" + +#: QAD_Desktop.cxx:249 +msgid "QAD_Desktop::PRP_DESK_WINDOW_CASCADE" +msgstr "Fenêtres en cascade" + +#: QAD_Desktop.cxx:257 +msgid "QAD_Desktop::PRP_DESK_WINDOW_TILE" +msgstr "Fenêtres en mozaïque" + +#: QAD_Application.cxx:176 +msgid "QAD_Application::PRP_APP_EDIT_REDO" +msgstr "Répéter la dernière opération" + +#: QAD_Application.cxx:166 +msgid "QAD_Application::PRP_APP_EDIT_UNDO" +msgstr "Annuler la dernière opération" + +#: *.cxx:405 +msgid "PRP_VW3D_POINTCENTER" +msgstr "Choisir un centre pour la vue avec MB1" + +#: *.cxx:374 +msgid "PRP_VW3D_SKETCHAREA" +msgstr "Sélectionner une zone d'affichage" + +#--------------- +# TOOL TIP +#--------------- + +#: QAD_HelpWindow.cxx:57 +msgid "QAD_HelpWindow::TOT_HELPWINDOW_BACKWARD" +msgstr "Avant" + +#: QAD_HelpWindow.cxx:60 +msgid "QAD_HelpWindow::TOT_HELPWINDOW_FORWARD" +msgstr "Apres" + +#: QAD_HelpWindow.cxx:63 +msgid "QAD_HelpWindow::TOT_HELPWINDOW_HOME" +msgstr "Home" + +#: QAD_Application.cxx:173 +msgid "QAD_Application::TOT_APP_EDIT_REDO" +msgstr "Répéter l'opération" + +#: QAD_Application.cxx:163 +msgid "QAD_Application::TOT_APP_EDIT_UNDO" +msgstr "Annuler l'opération" + +#: QAD_Desktop.cxx:153 +msgid "QAD_Desktop::TOT_DESK_FILE_NEW" +msgstr "Nouvelle étude" + +#: QAD_Desktop.cxx:165 +msgid "QAD_Desktop::TOT_DESK_FILE_OPEN" +msgstr "Ouvrir étude" + +#: QAD_Desktop.cxx:165 +msgid "QAD_Desktop::TOT_DESK_FILE_LOAD" +msgstr "Charger étude" + +#: QAD_Desktop.cxx:186 +msgid "QAD_Desktop::TOT_DESK_FILE_SAVE" +msgstr "Enregistrer étude" + +#--------------- +# ERROR +#--------------- + +#: *.cxx:233 +msgid "QObject::ERR_VP_NOVIEW" +msgstr "Pas de Vue" + +#: QAD_Desktop.cxx:516 +msgid "QAD_Desktop::ERR_APP_NOAPP" +msgstr "Pas d'application" + +#: QAD_Desktop.cxx:535 +msgid "QAD_Desktop::ERR_DOC_CANTCREATE" +msgstr "Impossible de créer l'étude" + +#: QAD_Desktop.cxx:586 +msgid "QAD_Desktop::ERR_DOC_CANTOPEN" +msgstr "Impossible d'ouvrir l'étude" + +#: QAD_Desktop.cxx:683 +msgid "QAD_Desktop::ERR_DOC_CANTWRITE" +msgstr "Impossible d'enregistrer l'étude" + +#: QAD_Desktop.cxx:599 +msgid "QAD_Desktop::ERR_DOC_UNKNOWNTYPE" +msgstr "Type d'étude inconnu" + +#: QAD_Study.cxx:321 +msgid "QAD_Study::ERR_DOC_READONLY" +msgstr "L'étude est en lecture seule" + +#: QAD_Desktop.cxx:683 +msgid "ERR_ERROR" +msgstr "Erreur" + +#--------------- +# QUESTION +#--------------- + +#: QAD_Study.cxx:335 +msgid "QAD_Study::QUE_ABORTCURRENTOPERATION" +msgstr "L'opération n'est pas encore terminée.\nVoulez-vous l'interrompre ?" + +#: QAD_Desktop.cxx:465 +msgid "QAD_Desktop::QUE_DESK_EXIT" +msgstr "Voulez-vous vraiment quitter ? " + +#: QAD_Desktop.cxx:569 +msgid "QAD_Desktop::QUE_DOC_ALREADYOPEN" +msgstr "L'étude %1 est déja ouverte.\nVoulez-vous la recharger ?" + +#: QAD_Desktop.cxx:569 +msgid "QAD_Desktop::QUE_DOC_ALREADYEXIST" +msgstr "L'étude %1 est déja présente dans le gestionnaire d'études.\nVoulez-vous la recharger ?" + +#: *.cxx:502 +#msgid "INF_READY" +#msgstr "Ready" + +#: QAD_Desktop.cxx:668 +msgid "QAD_Desktop::QUE_DOC_FILEEXISTS" +msgstr "Le fichier %1 existe déja.\nVoulez-vous l'écraser ?" + +#: *.cxx:405 +#msgid "PRP_VW3D_POINTCENTER" +#msgstr "Choisir un centre pour la vue avec MB1" + +#: QAD_Desktop.cxx:710 +msgid "QAD_Desktop::QUE_DOC_NOTSAVED" +msgstr "L'étude %1 n'est pas enregistrée.\nVoulez-vous l'enregistrer ?" + +#--------------- +# WARNING +#--------------- + +#: QAD_Desktop.cxx:709 +msgid "WRN_WARNING" +msgstr "Attention" + +#: QAD_Desktop.cxx:1072 +msgid "QAD_Desktop::WRN_LOAD_COMPONENT" +msgstr "Créer ou ouvrir une étude" + +------ + +#: QAD_Application.cxx:133 +msgid "QAD_Application::APP_DEFAULTTITLE" +msgstr "SALOME Professional" + + +#: QAD_Desktop.cxx:431 +msgid "QAD_Desktop::DESK_DEFAULTDOC" +msgstr "Étude" + +#: QAD_Desktop.cxx:424 +msgid "QAD_Desktop::DESK_DEFAULTTITLE" +msgstr "SALOME Professional" + +#: QAD_Desktop.cxx:920 +msgid "QAD_Desktop::DESK_FILES" +msgstr "Fichiers" + +msgid "OCC_IMAGE_FILES" +msgstr "Fichiers Images (*.bmp *.png *.jpg *.jpeg)" + +msgid "VTK_IMAGE_FILES" +msgstr "Fichiers Images (*.tif)" + +msgid "INF_APP_DUMP_VIEW" +msgstr "Dump vue" + +msgid "ERR_DOC_CANT_SAVE_FILE" +msgstr "Impossible d'enregistrer le fichier" + +msgid "EDIT_COPY_CMD" +msgstr "Copier" + +msgid "EDIT_PASTE_CMD" +msgstr "Coller" + +msgid "EDIT_CLEAR_CMD" +msgstr "Vider" + +msgid "EDIT_SELECTALL_CMD" +msgstr "Sélectionner Tout" + +msgid "MESSAGE_LOG_NAME" +msgstr "Message Log" + +msgid "QAD_DirListDlg::QUICK_DIR_LIST_TLT" +msgstr "Quick directory list" + +msgid "QAD_DirListDlg::EMPTY_DIR" +msgstr "" + +msgid "QAD_DirListDlg::DIRECTORIES_LBL" +msgstr "&Directories:" + +msgid "QAD_DirListDlg::ERR_DIRECTORY_SPECIFIED" +msgstr "Directory already specified." + +msgid "QAD_DirListDlg::WRN_DIRECTORY_N0T_EXIST" +msgstr "%1\n\nThe directory doesn't exist.\nAdd directory anyway?" + +msgid "QAD_DirListDlg::SELECT_DIRECTORY" +msgstr "Select directory" + +msgid "ERR_DOC_FILENOTEXIST" +msgstr "The file %1 doesn't exist" + +msgid "ERR_PERMISSION_DENIED" +msgstr "Can't save file %1.\nPermission denied." + +msgid "ERR_DIR_NOT_EXIST" +msgstr "%1\n\nThe directory doesn't exist." + +msgid "MEN_DESK_PREF_DIRICTORIES" +msgstr "&Directories..." + +msgid "QAD_FileDlg::DIRECTORIES_FILTER" +msgstr "Directories" + +msgid "MEN_DESK_FILE_PROPERTIES" +msgstr "&Properties..." + +msgid "PRP_DESK_FILE_PROPERTIES" +msgstr "View/modify study properties" + +msgid "PRP_YES" +msgstr "Yes" + +msgid "PRP_NO" +msgstr "No" + +msgid "PRP_STUDY_LOCKED" +msgstr "LOCKED" + +msgid "PRP_STUDY_MODIFIED" +msgstr "MODIFIED" + +msgid "PRP_STUDY_SAVED" +msgstr "SAVED" + +msgid "PRP_MODIFICATIONS" +msgstr "Modifications" diff --git a/src/SALOMEGUI/SALOMEGUI.cxx b/src/SALOMEGUI/SALOMEGUI.cxx new file mode 100644 index 000000000..50e3b389f --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI.cxx @@ -0,0 +1,109 @@ +using namespace std; +// File : SALOMEGUI.cxx +// Created : Thu Jun 14 12:00:40 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +#include "QAD.h" +#include "QAD_MessageBox.h" +#include "QAD_Application.h" +#include "SALOMEGUI_Application.h" + +#include +#include + +#include "SALOME_NamingService.hxx" + +int main(int argc, char* argv[]) +{ + QApplication a( argc, argv ); + + // Setting up the CORBA environment + // Initializing omniORB + SALOME_NamingService * name_service; + CORBA::ORB_var orb; + + orb = CORBA::ORB_init(argc, argv, "omniORB3"); + + // Get the reference the server. + name_service = new SALOME_NamingService(orb); + + QAD_ASSERT ( QObject::connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) ) ); + + /* Initialize the desktop and 'SALOMEGUI' application */ + SALOMEGUI_Application* app = + new SALOMEGUI_Application ( "MDTV-Standard", "HDF","hdf" ); + + if ( !SALOMEGUI_Application::addToDesktop ( app, name_service ) ) + { + QAD_MessageBox::error1 ( 0, + QObject::tr("ERR_ERROR"), + QObject::tr("ERR_APP_INITFAILED"), + QObject::tr("BUT_OK") ); + return -1; + } + + QPalette pal; + QColorGroup cg; + cg.setColor( QColorGroup::Foreground, Qt::black ); + cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Light, Qt::white ); + cg.setColor( QColorGroup::Midlight, QColor( 223, 223, 223) ); + cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); + cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Text, Qt::black ); + cg.setColor( QColorGroup::BrightText, Qt::white ); + cg.setColor( QColorGroup::ButtonText, Qt::black ); + cg.setColor( QColorGroup::Base, Qt::white ); + cg.setColor( QColorGroup::Background, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Shadow, Qt::black ); + cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); + cg.setColor( QColorGroup::HighlightedText, Qt::white ); + pal.setActive( cg ); + cg.setColor( QColorGroup::Foreground, Qt::black ); + cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Light, Qt::white ); + cg.setColor( QColorGroup::Midlight, QColor( 220, 220, 220) ); + cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); + cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Text, Qt::black ); + cg.setColor( QColorGroup::BrightText, Qt::white ); + cg.setColor( QColorGroup::ButtonText, Qt::black ); + cg.setColor( QColorGroup::Base, Qt::white ); + cg.setColor( QColorGroup::Background, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Shadow, Qt::black ); + cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); + cg.setColor( QColorGroup::HighlightedText, Qt::white ); + pal.setInactive( cg ); + cg.setColor( QColorGroup::Foreground, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Light, Qt::white ); + cg.setColor( QColorGroup::Midlight, QColor( 220, 220, 220) ); + cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); + cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Text, Qt::black ); + cg.setColor( QColorGroup::BrightText, Qt::white ); + cg.setColor( QColorGroup::ButtonText, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Base, Qt::white ); + cg.setColor( QColorGroup::Background, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Shadow, Qt::black ); + cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); + cg.setColor( QColorGroup::HighlightedText, Qt::white ); + pal.setDisabled( cg ); + qApp->setPalette( pal ); + + /* Run 'SALOMEGUI' application */ + QAD_Application::run(); + a.exec(); + + delete name_service; + orb->destroy(); + + return 0; +} diff --git a/src/SALOMEGUI/SALOMEGUI_AboutDlg.cxx b/src/SALOMEGUI/SALOMEGUI_AboutDlg.cxx new file mode 100644 index 000000000..3370f5d05 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_AboutDlg.cxx @@ -0,0 +1,127 @@ +using namespace std; +// File : SALOMEGUI_AboutDlg.cxx +// Created : Fri Sep 14 09:56:23 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "SALOMEGUI_AboutDlg.h" +#include "QAD_Desktop.h" +#include "QAD_Tools.h" +#include +#include +#include + +/* + * Constructor + */ +SALOMEGUI_AboutDlg::SALOMEGUI_AboutDlg(QWidget* parent, const char* name ) + : QDialog( parent, name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QPalette pal = palette(); + QColorGroup cg; + cg.setColor( QColorGroup::Foreground, Qt::black ); + cg.setColor( QColorGroup::Button, QColor( 192, 192, 192) ); + cg.setColor( QColorGroup::Light, Qt::white ); + cg.setColor( QColorGroup::Midlight, QColor( 223, 223, 223) ); + cg.setColor( QColorGroup::Dark, QColor( 96, 96, 96) ); + cg.setColor( QColorGroup::Mid, QColor( 128, 128, 128) ); + cg.setColor( QColorGroup::Text, Qt::black ); + cg.setColor( QColorGroup::BrightText, Qt::white ); + cg.setColor( QColorGroup::ButtonText, Qt::black ); + cg.setColor( QColorGroup::Base, Qt::white ); + cg.setColor( QColorGroup::Background, Qt::white ); + cg.setColor( QColorGroup::Shadow, Qt::black ); + cg.setColor( QColorGroup::Highlight, QColor( 0, 0, 128) ); + cg.setColor( QColorGroup::HighlightedText, Qt::white ); + pal.setActive( cg ); + pal.setInactive( cg ); + pal.setDisabled( cg ); + setPalette(pal); + + setCaption( tr("ABOUT_TLT") ); + setSizeGripEnabled( false ); + QVBoxLayout* SALOMEGUI_AboutDlgLayout = new QVBoxLayout( this ); + SALOMEGUI_AboutDlgLayout->setSpacing( 6 ); + SALOMEGUI_AboutDlgLayout->setMargin( 11 ); + + AboutPicLab = new QLabel( this, "AboutPicLab" ); + AboutPicLab->setFrameStyle( QLabel::Plain | QLabel::Box ); + QPixmap icon1 ( QAD_Desktop::getResourceManager()->loadPixmap( "CLIENT", + tr("ICON_ABOUT") )); + + QString msg; + if(!QAD_Desktop::getResourceManager()->loadResources( "CLIENT", msg )) + { + QMessageBox::warning( this, tr("WRN_WARNING"), msg, tr ("BUT_OK") ); + } + + AboutPicLab->setPixmap( icon1 ); + AboutPicLab->setScaledContents( false ); + AboutPicLab->setAlignment( AlignCenter ); + AboutPicLab->installEventFilter(this); + SALOMEGUI_AboutDlgLayout->addWidget( AboutPicLab ); + + VersionLab = new QLabel( this, "VersionLab" ); + VersionLab->setText( tr( "INF_VERSION" ) ); + VersionLab->setAlignment( AlignCenter ); + VersionLab->installEventFilter(this); + SALOMEGUI_AboutDlgLayout->addWidget( VersionLab ); + + CopyrightLab = new QLabel( this, "CopyrightLab" ); + CopyrightLab->setText( tr( "INF_COPYRIGHT" ) ); + CopyrightLab->setAlignment( AlignCenter ); + CopyrightLab->installEventFilter(this); + SALOMEGUI_AboutDlgLayout->addWidget( CopyrightLab ); + + LicenseLab = new QLabel( this, "LicenseLab" ); + LicenseLab->setText( tr( "INF_LICENSE" ) ); + LicenseLab->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) ); + QFont LicenseLabFont( LicenseLab->font() ); + LicenseLabFont.setPointSize( 10 ); + LicenseLab->setFont( LicenseLabFont ); + LicenseLab->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); + LicenseLab->installEventFilter(this); + SALOMEGUI_AboutDlgLayout->addWidget( LicenseLab ); + LicenseLab->polish(); + + setMaximumSize(minimumSize()); + + QAD_Tools::alignWidget(this, parent, AlignCenter); +} + +/* + * Destroys the object and frees any allocated resources + */ +SALOMEGUI_AboutDlg::~SALOMEGUI_AboutDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +/* + * Main event handler. Reimplemented to handle application + * font changes + */ +bool SALOMEGUI_AboutDlg::event( QEvent* ev ) +{ + bool ret = QDialog::event( ev ); + if ( ev->type() == QEvent::ApplicationFontChange ) { + QFont LicenseLabFont( LicenseLab->font() ); + LicenseLabFont.setPointSize( 10 ); + LicenseLab->setFont( LicenseLabFont ); + } + else if ( ev->type() == QEvent::MouseButtonRelease ) { + accept(); + } + return ret; +} + +bool SALOMEGUI_AboutDlg::eventFilter( QObject* o, QEvent* e) +{ + if (e->type() == QEvent::MouseButtonRelease) { + accept(); + } + return QDialog::eventFilter(o, e); +} diff --git a/src/SALOMEGUI/SALOMEGUI_AboutDlg.h b/src/SALOMEGUI/SALOMEGUI_AboutDlg.h new file mode 100644 index 000000000..cb772cc49 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_AboutDlg.h @@ -0,0 +1,34 @@ +// File : SALOMEGUI_AboutDlg.h +// Created : Fri Sep 14 09:56:08 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef SALOMEGUI_ABOUTDLG_H +#define SALOMEGUI_ABOUTDLG_H + +#include +#include +#include + +class SALOMEGUI_AboutDlg : public QDialog +{ +public: + SALOMEGUI_AboutDlg( QWidget* parent = 0, const char* name = 0 ); + ~SALOMEGUI_AboutDlg(); + +protected: + bool event( QEvent* ); + bool eventFilter( QObject*, QEvent* ); + +protected: + QLabel* AboutPicLab; + QLabel* VersionLab; + QLabel* CopyrightLab; + QLabel* PartnerPicLab; + QLabel* LicenseLab; +}; + +#endif // SALOMEGUI_ABOUTDIALOG_H diff --git a/src/SALOMEGUI/SALOMEGUI_Application.cxx b/src/SALOMEGUI/SALOMEGUI_Application.cxx new file mode 100644 index 000000000..437d6f054 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_Application.cxx @@ -0,0 +1,674 @@ +using namespace std; +// File : SALOMEGUI_Application.cxx +// Created : Thu Jun 14 12:01:00 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "SALOMEGUI_Application.h" +#include "SALOMEGUI_Desktop.h" +#include "SALOMEGUI_ImportOperation.h" +#include "SALOME_Selection.h" +#include "SALOME_ListIO.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOME_InteractiveObject.hxx" +#include "QAD.h" +#include "QAD_Desktop.h" +#include "QAD_RightFrame.h" +#include "QAD_LeftFrame.h" +#include "QAD_ObjectBrowser.h" +#include "QAD_Resource.h" +#include "QAD_Tools.h" +#include "QAD_WaitCursor.h" + +// QT Includes +#include +#include +#include + +// Open CASCADE Include +#include +#include + +/*! + Constructor +*/ +SALOMEGUI_Application::SALOMEGUI_Application( const QString& format, + const QString& description, + const QString& filters) : +QAD_Application( format, description, filters ) +{ + /* load resources */ + QString message; + QAD_ResourceMgr* resMgr = QAD_Desktop::getResourceManager(); + if ( !resMgr ) resMgr = QAD_Desktop::createResourceManager(); + if ( resMgr ) resMgr->loadResources( "SALOMEGUI", message ); + + QPalette* palette = QAD_Desktop::getPalette(); + if ( !palette) palette = QAD_Desktop::createPalette(); + // if ( !palette) palette->loadPalette(); + + myViewActions.setAutoDelete( true ); + + /* We need to know that the desktop is created to have + some additional internal initialization */ + QAD_ASSERT( connect( this, SIGNAL(desktopCreated()), SLOT(onDesktopCreated()) )); +} + +/*! + Destructor +*/ +SALOMEGUI_Application::~SALOMEGUI_Application() +{ +} + +/*! + Creates the actions provided by this application( internal ) +*/ +void SALOMEGUI_Application::createActions() +{ +#ifdef DEBUG + /* this function must be called only once */ + static bool created = false; + QAD_ASSERT_DEBUG_ONLY( !created ); + created = true; +#endif + + /* Create 'View' actions + */ + QToolBar* tbView = createToolBar( ViewToolBarId, tr("MEN_DESK_VIEWERTOOLBAR") ); + + QAD_ResourceMgr* rmgr = QAD_Desktop::getResourceManager(); +#define CREATE_ACTION(ID,NAME) \ + if(!myViewActions.at(ID)){ \ + QAction* action = new QAction(tr("TOT_APP_VIEW_" #NAME), \ + rmgr->loadPixmap("SALOMEGUI", tr("ICON_APP_VIEW_" #NAME)), \ + tr("MEN_APP_VIEW_" #NAME), 0, QAD_Application::getDesktop()); \ + action->setStatusTip(tr("PRP_APP_VIEW_" #NAME)); \ + myViewActions.insert(ID,action); \ + } + + CREATE_ACTION(ViewDumpId,DUMP); + CREATE_ACTION(ViewTrihedronId,TRIHEDRON); + CREATE_ACTION(ViewFitAllId,FITALL); + CREATE_ACTION(ViewFitAreaId,FITAREA); + CREATE_ACTION(ViewZoomId,ZOOM); + CREATE_ACTION(ViewPanId,PAN); + CREATE_ACTION(ViewRotateId,ROTATE); + CREATE_ACTION(ViewGlobalPanId,GLOBALPAN); + CREATE_ACTION(ViewFrontId,FRONT); + CREATE_ACTION(ViewBackId,BACK); + CREATE_ACTION(ViewTopId,TOP); + CREATE_ACTION(ViewBottomId,BOTTOM); + CREATE_ACTION(ViewLeftId,LEFT); + CREATE_ACTION(ViewRightId,RIGHT); + CREATE_ACTION(ViewResetId,RESET); + +#undef CREATE_ACTION +} + +/*! + Enables/disables the actions provided by this + application( internal ) +*/ +void SALOMEGUI_Application::updateActions() +{ +} + +/*! + Creates CAF application +*/ +bool SALOMEGUI_Application::initApp(SALOME_NamingService* name_service) +{ + if ( myStudyMgr->_is_nil() ) { + try { + CORBA::Object_ptr obj = name_service->Resolve("/myStudyManager"); + myStudyMgr = SALOMEDS::StudyManager::_narrow(obj); + } + catch ( Standard_Failure ) { + return false; + } + } + + return true; +} + +/*! + Creates the main desktop +*/ +bool SALOMEGUI_Application::createDesktop( SALOME_NamingService* name_service ) +{ + QAD_ASSERT_DEBUG_ONLY( !desktop ); + desktop = new SALOMEGUI_Desktop(name_service); + return ( desktop != NULL ); +} + +/*! + Called when the main desktop is created ( internal ) +*/ +void SALOMEGUI_Application::onDesktopCreated() +{ + createActions(); +} + +/*! + Called for customization when study is created +*/ +void SALOMEGUI_Application::onStudyCreated( QAD_Study* study ) +{ +} + +/*! + Called for customization when study is opened +*/ +void SALOMEGUI_Application::onStudyOpened( QAD_Study* study ) +{ +} + +/*! + Called for customization when study is activated (shown) +*/ +void SALOMEGUI_Application::onStudyShown( QAD_Study* study ) +{ + SALOMEDS::Study_var aStudy = study->getStudyDocument(); + +//srn: Forbid appending Interface Applicative and its children to UseCase + aStudy->EnableUseCaseAutoFilling(false); + + /* mpv: study may be locked */ + int aLocked = aStudy->GetProperties()->IsLocked(); + if (aLocked) aStudy->GetProperties()->SetLocked(false); + + /* update Object Browser */ + SALOMEDS::StudyBuilder_var B = aStudy->NewBuilder(); + SALOMEDS::SComponentIterator_var itcomp = aStudy->NewComponentIterator(); + for (; itcomp->More(); itcomp->Next()) { + SALOMEDS::SComponent_var SC = itcomp->Value(); + Standard_CString dataType = SC->ComponentDataType(); + if ( QString(dataType).compare("Interface Applicative") == 0 ) { + SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SC); + for (; it->More();it->Next()) { + SALOMEDS::SObject_var CSO = it->Value(); + B->RemoveObject(CSO); + } + } + } + + QAD_StudyFrame* sf = myActiveStudy->getActiveStudyFrame(); + Standard_CString name = strdup(sf->title().latin1()); + + SALOMEDS::SComponent_var father = aStudy->FindComponent("Interface Applicative"); + SALOMEDS::SObject_var newObj = B->NewObject(father); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeComment_var aComment; + SALOMEDS::AttributeSelectable_var aSelAttr; + + anAttr = B->FindOrCreateAttribute(newObj, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(name); + + anAttr = B->FindOrCreateAttribute(newObj, "AttributeSelectable"); + aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); + aSelAttr->SetSelectable(false); + + if (sf->getTypeView() == VIEW_OCC) { + anAttr = B->FindOrCreateAttribute(newObj, "AttributeComment"); + aComment = SALOMEDS::AttributeComment::_narrow(anAttr); + aComment->SetValue("OCC"); + } + else if (sf->getTypeView() == VIEW_VTK) { + anAttr = B->FindOrCreateAttribute(newObj, "AttributeComment"); + aComment = SALOMEDS::AttributeComment::_narrow(anAttr); + aComment->SetValue("VTK"); + } else { + anAttr = B->FindOrCreateAttribute(newObj, "AttributeComment"); + aComment = SALOMEDS::AttributeComment::_narrow(anAttr); + aComment->SetValue("GRAPH"); + } + sf->setEntry(newObj->GetID()); + + if (aLocked) aStudy->GetProperties()->SetLocked(true); + + study->updateObjBrowser( false ); + + aStudy->EnableUseCaseAutoFilling(true); +} + +/*! + Called for customization when the active study is changed +*/ +void SALOMEGUI_Application::onActiveStudyChanged( QAD_Study* oldActiveStudy, + QAD_Study* newActiveStudy ) +{ + // MESSAGE ("SALOMEGUI_Application::onActiveStudyChanged init."); + /* superclass MUST be called */ + QAD_Application::onActiveStudyChanged( oldActiveStudy, newActiveStudy ); + + if ( oldActiveStudy ) { + int count = oldActiveStudy->getStudyFramesCount(); + for ( int i = 0; i < count; i++ ) { + disconnectFromViewer( oldActiveStudy->getStudyFrame(i)->getRightFrame()->getViewFrame() ); + } + } + + if ( newActiveStudy && newActiveStudy->getActiveStudyFrame() ) { + connectToViewer( newActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame() ); + } +} + +void SALOMEGUI_Application::connectToViewer( QAD_ViewFrame* vf ) +{ +#define CONNECT_ACTION(NAME) \ + QAD_ASSERT(connect(myViewActions.at(View ##NAME ##Id), SIGNAL(activated()), vf, SLOT(onView ##NAME()))) + + if ( vf ) { + QToolBar* tbView = getToolBar( ViewToolBarId ); + QListIterator it( myViewActions ); + for( ; it.current(); ++it ) + it.current()->removeFrom( tbView ); + if( vf->getTypeView() == VIEW_GRAPHSUPERV ) { + //myViewActions.at(ViewDumpId)->addTo(tbView); + //myViewActions.at(ViewFitAllId)->addTo(tbView); + //myViewActions.at(ViewFitAreaId)->addTo(tbView); + //myViewActions.at(ViewZoomId)->addTo(tbView); + myViewActions.at(ViewPanId)->addTo(tbView); + //myViewActions.at(ViewGlobalPanId)->addTo(tbView); + myViewActions.at(ViewResetId)->addTo(tbView); + } + else if( vf->getTypeView() == VIEW_PLOT2D ) { + myViewActions.at(ViewDumpId)->addTo(tbView); + myViewActions.at(ViewFitAllId)->addTo(tbView); + myViewActions.at(ViewFitAreaId)->addTo(tbView); + myViewActions.at(ViewZoomId)->addTo(tbView); + myViewActions.at(ViewPanId)->addTo(tbView); + //myViewActions.at(ViewGlobalPanId)->addTo(tbView); + //myViewActions.at(ViewResetId)->addTo(tbView); + } + else { + it.toFirst(); + for( ; it.current(); ++it ) + it.current()->addTo(tbView); + } + //CONNECT_ACTION(Mu4Id) + CONNECT_ACTION(Dump); + CONNECT_ACTION(Trihedron); + CONNECT_ACTION(FitAll); + CONNECT_ACTION(FitArea); + CONNECT_ACTION(Zoom); + CONNECT_ACTION(Pan); + CONNECT_ACTION(Rotate); + CONNECT_ACTION(GlobalPan); + CONNECT_ACTION(Front); + CONNECT_ACTION(Back); + CONNECT_ACTION(Top); + CONNECT_ACTION(Bottom); + CONNECT_ACTION(Left); + CONNECT_ACTION(Right); + CONNECT_ACTION(Reset); + } + +#undef CONNECT_ACTION +} + +void SALOMEGUI_Application::disconnectFromViewer( QAD_ViewFrame* vf ) +{ +#define DISCONNECT_ACTION(NAME) \ + QAD_ASSERT(disconnect(myViewActions.at(View ##NAME ##Id), SIGNAL(activated()), vf, SLOT(onView ##NAME()))); + + if ( !vf || myViewActions.isEmpty() ) + return; + //DISCONNECT_ACTION(Mu4Id) + DISCONNECT_ACTION(Dump); + DISCONNECT_ACTION(Trihedron); + DISCONNECT_ACTION(FitAll); + DISCONNECT_ACTION(FitArea); + DISCONNECT_ACTION(Zoom); + DISCONNECT_ACTION(Pan); + DISCONNECT_ACTION(Rotate); + DISCONNECT_ACTION(GlobalPan); + DISCONNECT_ACTION(Front); + DISCONNECT_ACTION(Back); + DISCONNECT_ACTION(Top); + DISCONNECT_ACTION(Bottom); + DISCONNECT_ACTION(Left); + DISCONNECT_ACTION(Right); + DISCONNECT_ACTION(Reset); + +#undef DISCONNECT_ACTION +} + +/*! + Customizes 'View' menu of the desktop +*/ +int SALOMEGUI_Application::onUpdateViewActions ( QPopupMenu* popup, bool add, int index ) +{ + int nItemsAdded = QAD_Application::onUpdateViewActions( popup, add, index ); + // NRI + // if ( add ) { + // index += nItemsAdded; + // QAD_ASSERT_DEBUG_ONLY( !myViewActions.isEmpty() ); + // popup->insertSeparator( index++ ); + // myViewActions.at( ViewTrihedronId )->addTo( popup ); + // index++; + // popup->insertSeparator( index++ ); + // for ( int i = (int)ViewMu4Id; i <= (int)ViewRightId; i++ ) { + // myViewActions.at( i )->addTo( popup ); + // index++; + // } + // popup->insertSeparator( index++ ); + // myViewActions.at( ViewResetId )->addTo( popup ); + // index++; + // } else { + // for ( int i = (int)ViewTrihedronId; i <= (int)ViewResetId; i++ ) { + // popup->removeItemAt(index); + // } + + // /* remove separators */ + // popup->removeItemAt( index ); + // popup->removeItemAt( index ); + // popup->removeItemAt( index ); + // } + + return index; +} + +/*! + Adds the context popup items +*/ +void SALOMEGUI_Application::onCreatePopup() +{ + // Here common menu items should be added (Display, Erase, etc.). + // They should be obtained through the standard XML-based mechanism, + // i.e. corresponding XML file should be loaded somewhere in advance + // and desktop->getOperatorsMenu() should return the default popup menu. + // These items are always added; if necessary any of them can be hidden + // during popup customization by means of the corresponding unique ID defined in QAD_Resource.h. + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + + if ( Sel->IObjectCount() > 0 ) { + myPopup->insertItem (tr ("MEN_APP_DISPLAY"), this, SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID); + myPopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), this, SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID); + myPopup->insertItem (tr ("MEN_APP_ERASE"), this, SLOT(onErase()), 0, QAD_Erase_Popup_ID); + } + +} + + +void SALOMEGUI_Application::onDisplay(int id) +{ + QAD_WaitCursor waitCursor; + + // Obtain the component to deal with (according to selected object's parent component) + SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection() ); + + QString parentComp = ((SALOMEGUI_Desktop*)desktop)->getComponentFromSelection(); + if (parentComp.isNull()) { // objects from several components are selected -> do nothing + return; + } + + // Obtain the component's GUI library + // Library cashing will be implemented soon in QAD_Desktop to increase performance + OSD_Function osdF, osdViewTypeFunc; + OSD_SharedLibrary foreignGUI; + void (*builder)(const Handle(SALOME_InteractiveObject)&); + bool isForeignGUIUsed = false; + bool isViewTypeOK = true; + int viewTypes[VIEW_TYPE_MAX]; + + for (int i = 0; i < VIEW_TYPE_MAX; i++) + viewTypes[i] = -1; + + if (parentComp.compare(desktop->getActiveComponent()) == 0) { // use active GUI library + const OSD_SharedLibrary& compGUI = desktop->getHandle(); + osdF = compGUI.DlSymb("buildPresentation"); + if ( osdF == NULL ) { + MESSAGE("BuildPresentation method not found in component's GUI") + return; + } + osdViewTypeFunc = compGUI.DlSymb("supportedViewType"); + if ( osdViewTypeFunc == NULL ) { + MESSAGE("supportedViewType method not found in component's GUI") + } + MESSAGE("onDisplay(): using active GUI to build presentations") + } else { // use native GUI library + QString ComponentLib; + QCString dir; + QFileInfo fileInfo ; + bool found = false; + if ( getenv("SALOME_SITE_DIR") ) { + dir.fill('\0'); + dir.sprintf("%s",getenv("SALOME_SITE_DIR")); + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "lib" + parentComp.latin1() + "GUI.dll" ; +#else + dir = dir + "lib" + parentComp.latin1() + "GUI.so" ; +#endif + MESSAGE ( " GUI library = " << dir ) + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ComponentLib = fileInfo.fileName(); + found = true; + MESSAGE ( " found " ) + } else { + MESSAGE ( " Not found " ) + } + } + if ( !found && getenv("SALOME_ROOT_DIR") ) { + dir.fill('\0'); + dir.sprintf("%s", getenv("SALOME_ROOT_DIR")); + dir = QAD_Tools::addSlash(dir) ; + dir = dir + "lib" ; + dir = QAD_Tools::addSlash(dir) ; +#ifdef WNT + dir = dir + "lib" + parentComp.latin1() + "GUI.dll" ; +#else + dir = dir + "lib" + parentComp.latin1() + "GUI.so" ; +#endif + MESSAGE ( " GUI library = " << dir ) + fileInfo.setFile(dir) ; + if (fileInfo.exists()) { + ComponentLib = fileInfo.fileName() ; + found = true; + MESSAGE ( " found " ) + } else { + MESSAGE ( " Not found " ) + } + } + + if (ComponentLib.isEmpty()) { + waitCursor.stop(); + QMessageBox::critical( desktop, + tr("ERR_ERROR"), + "Empty name of component "+ parentComp + " library"); + return; + } + + foreignGUI.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString()); + + bool ok = foreignGUI.DlOpen(OSD_RTLD_LAZY); + if (!ok) { + waitCursor.stop(); + QMessageBox::critical( desktop, + tr("ERR_ERROR"), + tr( foreignGUI.DlError() ) ); + return; + } + + osdF = foreignGUI.DlSymb("buildPresentation"); + if ( osdF == NULL ) { + MESSAGE("BuildPresentation method not found in component's GUI") + foreignGUI.DlClose(); + return; + } + osdViewTypeFunc = foreignGUI.DlSymb("supportedViewType"); + if ( osdViewTypeFunc == NULL ) { + MESSAGE("supportedViewType method not found in component's GUI") + } + isForeignGUIUsed = true; + MESSAGE("onDisplay(): using parent component's GUI to build presentations") + } + + // Check if another view type is required (if viewToActivate < 0 then any type of view is acceptable) + if (osdViewTypeFunc) { + void (*viewTypeChecker)(int*, int) = (void (*)(int*, int)) osdViewTypeFunc; + (*viewTypeChecker)(viewTypes, VIEW_TYPE_MAX); + if (viewTypes[0] >= 0) { // not all the view types are supported + for (int i = 0; i < VIEW_TYPE_MAX; i++) { + if (viewTypes[i] < 0) // no more types supported + break; + isViewTypeOK = ((int)myActiveStudy->getActiveStudyFrame()->getTypeView() == viewTypes[i]); + if (isViewTypeOK) // one of supported views is already active + break; + } + } + } + + // Try to activate a view of one of supported types + if (!isViewTypeOK) { + MESSAGE("onDisplay(): view type is not acceptable") + unsigned frameCount = myActiveStudy->getStudyFramesCount(); + for (unsigned i = 0; i < frameCount; i++) { + QAD_StudyFrame* frame = myActiveStudy->getStudyFrame(i); + for (int j = 0; j < VIEW_TYPE_MAX; j++) { + if (frame->getTypeView() == viewTypes[j]) { + MESSAGE("onDisplay(): activating other frame") + isViewTypeOK = true; + frame->setFocus(); + break; + } + } + } + if (!isViewTypeOK) { + waitCursor.stop(); + QMessageBox::warning( desktop, + tr("ERR_ERROR"), + tr("ERR_APP_WRONG_VIEW_TYPE")); + return; + } + } + + QAD_ViewFrame* viewFrame = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + + // Build the graphic presentation (it is stored in the corresponding viewer) + builder = (void (*) (const Handle(SALOME_InteractiveObject)&)) osdF; + + // Copy the selection + SALOME_ListIteratorOfListIO itInit( Sel->StoredIObjects() ); + SALOME_ListIO selList; + for (; itInit.More(); itInit.Next()) { + selList.Append(itInit.Value()); + } + + 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(); + Handle(SALOME_InteractiveObject) childIObject = new SALOME_InteractiveObject(); + childIObject->setEntry(child->GetID()); + + // Ensure that proper 3D presentation exists for IObject + (*builder)(childIObject); + viewFrame->Display(childIObject, false); + needRepaint = true; + } + } else { // for child object -> simply display it (no children are displayed) + // Ensure that proper 3D presentation exists for IObject + (*builder)(IObject); + viewFrame->Display(IObject, false); + needRepaint = true; + } + + } + + if (needRepaint) + viewFrame->Repaint(); + + if (isForeignGUIUsed) + foreignGUI.DlClose(); + myActiveStudy->updateObjBrowser(true); +} + + + +void SALOMEGUI_Application::onErase() +{ + QAD_WaitCursor waitCursor; + + SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection() ); + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + QAD_ViewFrame* viewFrame = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + bool needRepaint = false; + + // Copy the selection + SALOME_ListIteratorOfListIO itInit( Sel->StoredIObjects() ); + SALOME_ListIO selList; + for (; itInit.More(); itInit.Next()) { + selList.Append(itInit.Value()); + } + + 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; + SALOMEDS::SObject_var obj; + + if (IObject->hasEntry()) { + obj = aStudy->FindObjectID(IObject->getEntry()); + if (!obj->_is_nil()) { + SALOMEDS::SComponent_var comp = obj->GetFatherComponent(); + isComponent = (strcmp(comp->GetID(), obj->GetID()) == 0); + } + } + + // For component -> erase 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(); + Handle(SALOME_InteractiveObject) childIObject = new SALOME_InteractiveObject(); + childIObject->setEntry(child->GetID()); + viewFrame->Erase(childIObject, false); + } + } else { // for child object -> simply erase it (no children are erased) + viewFrame->Erase(IObject, false); + } + needRepaint = true; + } + + if (needRepaint) + viewFrame->Repaint(); + +} diff --git a/src/SALOMEGUI/SALOMEGUI_Application.h b/src/SALOMEGUI/SALOMEGUI_Application.h new file mode 100644 index 000000000..ced55c5b1 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_Application.h @@ -0,0 +1,79 @@ +// File : SALOMEGUI_Application.h +// Created : Thu Jun 14 12:01:23 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef SALOMEGUI_APPLICATION_H +#define SALOMEGUI_APPLICATION_H + +#include "QAD_Application.h" +#include "QAD_ViewFrame.h" + +// IDL headers +#include +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +// QT Includes +#include +#include +#include +#include +#include + +class SALOMEGUI_Application : public QAD_Application +{ + Q_OBJECT + enum { ViewToolBarId = 100 }; + + enum { ViewDumpId, ViewTrihedronId, ViewFitAllId, ViewFitAreaId, + ViewZoomId, ViewPanId, ViewRotateId, ViewGlobalPanId, + ViewFrontId, ViewBackId, ViewTopId, ViewBottomId, ViewLeftId, + ViewRightId, ViewResetId }; +public: + SALOMEGUI_Application ( const QString& format, + const QString& description, + const QString& filters); + ~SALOMEGUI_Application(); +public slots: + // Common display services + void onDisplay(int); + void onErase(); + +protected: + /* application management */ + bool initApp( SALOME_NamingService* name_service ); + bool createDesktop( SALOME_NamingService* name_service ); + + /* popup */ + void onCreatePopup(); + + /* document management */ + void onStudyCreated( QAD_Study* ); + void onStudyOpened( QAD_Study* ); + void onActiveStudyChanged( QAD_Study* oldActiveStudy, + QAD_Study* newActiveStudy ); + void onStudyShown( QAD_Study* ); + + /* menu management */ + int onUpdateViewActions ( QPopupMenu*, bool add, int index ); + +private slots: + void onDesktopCreated(); + +private: + void connectToViewer( QAD_ViewFrame* ); + void disconnectFromViewer( QAD_ViewFrame* ); + void createActions(); + void updateActions(); + +private: + QList myViewActions; + QAD_Operation* myCurOperation; +}; + +#endif + diff --git a/src/SALOMEGUI/SALOMEGUI_CloseDlg.cxx b/src/SALOMEGUI/SALOMEGUI_CloseDlg.cxx new file mode 100644 index 000000000..b2e04c1e4 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_CloseDlg.cxx @@ -0,0 +1,74 @@ +using namespace std; +// File : SALOMEGUI_CloseDlg.cxx +// Created : Wed Feb 26 11:40:52 2003 +// Author : Vasily RUSYAEV (vrv) +// Copyright : Open CASCADE + +#include "SALOMEGUI_CloseDlg.h" + +#include +#include +#include +#include +#include + + +SALOMEGUI_CloseDlg::SALOMEGUI_CloseDlg ( QWidget * parent, const char * name, bool modal, WFlags f ) + : QDialog ( parent, "", TRUE, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setSizeGripEnabled ( TRUE ) ; + setCaption( tr( "CAPTION" ) ); + + QVBoxLayout* m_vbL = new QVBoxLayout( this ); + m_vbL->setMargin( 11 ); m_vbL->setSpacing( 6 ); + + QLabel* m_lIcon = new QLabel (this, "m_lDescr"); + QPixmap pm = QMessageBox::standardIcon( QMessageBox::Warning ); + m_lIcon->setPixmap( pm ); + m_lIcon->setScaledContents( false ); + m_lIcon->setAlignment( Qt::AlignCenter ); + + QLabel* m_lDescr = new QLabel (this, "m_lDescr"); + m_lDescr->setText ( tr ("CLOSE_DESCRIPTION") ); + m_lDescr->setAlignment( Qt::AlignCenter ); + m_lDescr->setMinimumHeight( m_lDescr->sizeHint().height()*5 ); + m_lDescr->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + + QHBoxLayout* m_hl1 = new QHBoxLayout(); + m_hl1->setMargin( 0 ); m_hl1->setSpacing( 6 ); + m_hl1->addWidget( m_lIcon ); + m_hl1->addWidget( m_lDescr ); + + m_pb1 = new QPushButton( tr ("SAVE_CLOSE"), this ); + m_pb2 = new QPushButton( tr ("CLOSE"), this ); + m_pb3 = new QPushButton( tr ("UNLOAD"), this ); + m_pb4 = new QPushButton( tr ("CANCEL"), this ); + + QGridLayout* m_hl2 = new QGridLayout(); + m_hl2->setMargin( 0 ); m_hl2->setSpacing( 6 ); + m_hl2->addWidget( m_pb1, 0, 0 ); + m_hl2->addWidget( m_pb2, 0, 1 ); + m_hl2->addWidget( m_pb3, 0, 2 ); + m_hl2->addColSpacing( 3, 10 ); + m_hl2->setColStretch( 3, 5 ); + m_hl2->addWidget( m_pb4, 0, 4 ); + + m_vbL->addLayout( m_hl1 ); + m_vbL->addLayout( m_hl2 ); + + connect( m_pb1, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); + connect( m_pb2, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); + connect( m_pb3, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) ); + connect( m_pb4, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +void SALOMEGUI_CloseDlg::onButtonClicked() +{ + QPushButton* btn = ( QPushButton* )sender(); + if ( btn == m_pb1 ) + done( 1 ); + if ( btn == m_pb2 ) + done( 2 ); + if ( btn == m_pb3 ) + done( 3 ); +} diff --git a/src/SALOMEGUI/SALOMEGUI_CloseDlg.h b/src/SALOMEGUI/SALOMEGUI_CloseDlg.h new file mode 100644 index 000000000..f593860c8 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_CloseDlg.h @@ -0,0 +1,30 @@ +// File : SALOMEGUI_CloseDlg.h +// Created : Wed Feb 26 11:40:52 2003 +// Author : Vasily RUSYAEV (vrv) +// Copyright : Open CASCADE + +#ifndef SALOMEGUI_CloseDlg_H +#define SALOMEGUI_CloseDlg_H + +#include + +class SALOMEGUI_CloseDlg: public QDialog +{ + Q_OBJECT + +public: + SALOMEGUI_CloseDlg ( QWidget * parent = 0, const char * name = 0, bool modal = FALSE, WFlags f = 0 ) ; + ~SALOMEGUI_CloseDlg ( ) { }; + +private slots: + void onButtonClicked(); + +private: + QPushButton* m_pb1; + QPushButton *m_pb2; + QPushButton *m_pb3; + QPushButton *m_pb4; +}; + +#endif + diff --git a/src/SALOMEGUI/SALOMEGUI_Desktop.cxx b/src/SALOMEGUI/SALOMEGUI_Desktop.cxx new file mode 100644 index 000000000..a78a4d926 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_Desktop.cxx @@ -0,0 +1,83 @@ +using namespace std; +// File : SALOMEGUI_Desktop.cxx +// Created : Thu Jun 14 12:02:58 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "SALOMEGUI_Desktop.h" +#include "SALOME_Selection.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +/*! + Constructor +*/ +SALOMEGUI_Desktop::SALOMEGUI_Desktop(SALOME_NamingService* name_service) : + QAD_Desktop( name_service ) +{ + QAD_ASSERT_DEBUG_ONLY( !myStdActions.isEmpty() ); + //myStdActions.at( FileOpenId )->setEnabled( true ); + //myStdActions.at( FileSaveId )->setEnabled( true ); + //myStdActions.at( FileSaveAsId )->setEnabled( true ); +} + +/*! + Disable file actions for DEMO +*/ +void SALOMEGUI_Desktop::updateDesktop( UpdateCommand cmd ) +{ + QAD_Desktop::updateDesktop( cmd ); + + QAD_ASSERT_DEBUG_ONLY( !myStdActions.isEmpty() ); + //myStdActions.at( FileOpenId )->setEnabled( true ); + //myStdActions.at( FileSaveId )->setEnabled( true ); + //myStdActions.at( FileSaveAsId )->setEnabled( true ); +} + +QString SALOMEGUI_Desktop::getComponentFromSelection() +{ + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + /* copy the list */ + SALOME_ListIO List; + SALOME_ListIteratorOfListIO Itinit( Sel->StoredIObjects() ); + for (; Itinit.More(); Itinit.Next()) { + List.Append(Itinit.Value()); + } + + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + + SALOME_ListIteratorOfListIO It( List ); + QString parentComp; + + for (; It.More(); It.Next()) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + + if (!IObject->hasEntry()) continue; + + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); + + if ( !obj->_is_nil() ) { + SALOMEDS::SComponent_var comp = obj->GetFatherComponent(); + if ( !comp->_is_nil() ) { + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if (comp->FindAttribute(anAttr, "AttributeName")) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + QString compName(aName->Value()); + if (parentComp.isNull()) + parentComp = compName; + else if (parentComp.compare(compName) != 0) { // objects belonging to different components are selected + parentComp = QString::null; + break; + } + } + } + } + } + + return parentComp; +} diff --git a/src/SALOMEGUI/SALOMEGUI_Desktop.h b/src/SALOMEGUI/SALOMEGUI_Desktop.h new file mode 100644 index 000000000..a6419765a --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_Desktop.h @@ -0,0 +1,30 @@ +// File : SALOMEGUI_Desktop.h +// Created : Thu Jun 14 12:02:21 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef SALOMEGUI_DESKTOP_H +#define SALOMEGUI_DESKTOP_H + +#include "QAD_Desktop.h" +#include "QAD_Study.h" +class SALOMEGUI_Desktop : public QAD_Desktop +{ + Q_OBJECT + +public: + SALOMEGUI_Desktop( SALOME_NamingService* name_service ); + + // returns the name of the component selected objects belong to (null if two or more components) + QString getComponentFromSelection(); + +protected: + void updateDesktop( UpdateCommand ); + +}; + +#endif + diff --git a/src/SALOMEGUI/SALOMEGUI_ImportOperation.cxx b/src/SALOMEGUI/SALOMEGUI_ImportOperation.cxx new file mode 100644 index 000000000..dc0f67004 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_ImportOperation.cxx @@ -0,0 +1,15 @@ +using namespace std; +// File : SALOMEGUI_ImportOperation.cxx +// Created : Thu Jun 14 12:07:10 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "SALOMEGUI_ImportOperation.h" + +SALOMEGUI_ImportOperation::SALOMEGUI_ImportOperation( QAD_Study* study ) : +QAD_Operation( study ) +{ +} diff --git a/src/SALOMEGUI/SALOMEGUI_ImportOperation.h b/src/SALOMEGUI/SALOMEGUI_ImportOperation.h new file mode 100644 index 000000000..2164ce17d --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_ImportOperation.h @@ -0,0 +1,23 @@ +// File : SALOMEGUI_ImportOperation.h +// Created : Thu Jun 14 12:07:26 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#if !defined SALOMEGUI_IMPORTOPERATION +#define SALOMEGUI_IMPORTOPERATION + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "QAD_Operation.h" +class SALOMEGUI_ImportOperation : public QAD_Operation +{ +public: + SALOMEGUI_ImportOperation( QAD_Study* ); +}; + +#endif diff --git a/src/SALOMEGUI/SALOMEGUI_LoadStudiesDlg.cxx b/src/SALOMEGUI/SALOMEGUI_LoadStudiesDlg.cxx new file mode 100644 index 000000000..bdd5a6fcc --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_LoadStudiesDlg.cxx @@ -0,0 +1,77 @@ +using namespace std; +// File : SALOMEGUI_LoadStudiesDlg.cxx +// Created : Wed Apr 03 13:37:13 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOMEGUI_LoadStudiesDlg.h" + +#include +#include +#include +#include + +#define SPACING_SIZE 6 +#define MARGIN_SIZE 11 +#define MIN_LISTBOX_WIDTH 150 +#define MIN_LISTBOX_HEIGHT 100 + +SALOMEGUI_LoadStudiesDlg::SALOMEGUI_LoadStudiesDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "SALOMEGUI_LoadStudiesDlg" ); + resize( 321, 181 ); + setCaption( name ); + setSizeGripEnabled( TRUE ); + + QGridLayout* aTopLayout = new QGridLayout(this); + aTopLayout->setMargin(MARGIN_SIZE); + aTopLayout->setSpacing(SPACING_SIZE); + + TextLabel1 = new QLabel( this, "TextLabel1" ); + TextLabel1->setGeometry( QRect( 11, 12, 297, 16 ) ); + TextLabel1->setText( tr( "MEN_STUDIES_CHOICE" ) ); + + QHBoxLayout* aBtnLayout = new QHBoxLayout; + aBtnLayout->setSpacing( SPACING_SIZE ); + aBtnLayout->setMargin( 0 ); + + buttonOk = new QPushButton( this, "buttonOk" ); + buttonOk->setText( tr( "BUT_OK" ) ); + buttonOk->setAutoDefault( true ); + buttonOk->setDefault( true ); + + buttonCancel = new QPushButton( this, "buttonCancel" ); + buttonCancel->setText( tr( "BUT_CANCEL" ) ); + buttonCancel->setAutoDefault( true ); + + aBtnLayout->addWidget( buttonOk ); + aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + aBtnLayout->addWidget( buttonCancel ); + + ListComponent = new QListBox( this, "ListComponent" ); + ListComponent->setVScrollBarMode(QListBox::AlwaysOn); + ListComponent->setMinimumSize(MIN_LISTBOX_WIDTH, MIN_LISTBOX_HEIGHT); + ListComponent->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + ListComponent->setSelectionMode(QListBox::Single); + + aTopLayout->addWidget(TextLabel1, 0, 0); + aTopLayout->addWidget(ListComponent, 1, 0); + aTopLayout->addLayout(aBtnLayout, 2, 0); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +/* + * Destroys the object and frees any allocated resources + */ +SALOMEGUI_LoadStudiesDlg::~SALOMEGUI_LoadStudiesDlg() +{ + // no need to delete child widgets, Qt does it all for us +} diff --git a/src/SALOMEGUI/SALOMEGUI_LoadStudiesDlg.h b/src/SALOMEGUI/SALOMEGUI_LoadStudiesDlg.h new file mode 100644 index 000000000..279f3d84d --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_LoadStudiesDlg.h @@ -0,0 +1,37 @@ +// File : SALOMEGUI_LoadStudiesDlg.h +// Created : Wed Apr 03 13:36:09 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef SALOMEGUI_LOADSTUDIESDLG_H +#define SALOMEGUI_LOADSTUDIESDLG_H + +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QLabel; +class QListBox; +class QListBoxItem; +class QPushButton; + +class SALOMEGUI_LoadStudiesDlg : public QDialog +{ + Q_OBJECT + +public: + SALOMEGUI_LoadStudiesDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SALOMEGUI_LoadStudiesDlg(); + + QLabel* TextLabel1; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QListBox* ListComponent; + +}; + +#endif // SALOMEGUI_LOADSTUDIESDLG_H diff --git a/src/SALOMEGUI/SALOMEGUI_NameDlg.cxx b/src/SALOMEGUI/SALOMEGUI_NameDlg.cxx new file mode 100644 index 000000000..63ab69eb2 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_NameDlg.cxx @@ -0,0 +1,121 @@ +using namespace std; +// File : SALOMEGUI_NameDlg.cxx +// Created : Wed Jun 27 16:39:06 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "SALOMEGUI_NameDlg.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_Tools.h" + +#include +#include +#include +#include +#include + +/*! + Constructor +*/ +SALOMEGUI_NameDlg::SALOMEGUI_NameDlg( QWidget* parent ) + : QDialog( parent ? parent : QAD_Application::getDesktop(), + "SALOMEGUI_NameDlg", + true, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr("TLT_RENAME") ); + setSizeGripEnabled( TRUE ); + + QVBoxLayout* topLayout = new QVBoxLayout( this ); + topLayout->setMargin( 11 ); topLayout->setSpacing( 6 ); + + /***************************************************************/ + QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setMargin( 0 ); GroupC1->layout()->setSpacing( 0 ); + QHBoxLayout* GroupC1Layout = new QHBoxLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setMargin( 11 ); GroupC1Layout->setSpacing( 6 ); + + QLabel* TextLabel = new QLabel( GroupC1, "TextLabel1" ); + TextLabel->setText( tr( "NAME_LBL" ) ); + GroupC1Layout->addWidget( TextLabel ); + + myLineEdit = new QLineEdit( GroupC1, "LineEdit1" ); + myLineEdit->setMinimumSize( 250, 0 ); + GroupC1Layout->addWidget( myLineEdit ); + + /***************************************************************/ + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setMargin( 0 ); GroupButtons->layout()->setSpacing( 0 ); + QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setMargin( 11 ); GroupButtonsLayout->setSpacing( 6 ); + + myButtonOk = new QPushButton( GroupButtons, "buttonOk" ); + myButtonOk->setText( tr( "BUT_OK" ) ); + myButtonOk->setAutoDefault( TRUE ); myButtonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( myButtonOk ); + + GroupButtonsLayout->addStretch(); + + myButtonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + myButtonCancel->setText( tr( "BUT_CANCEL" ) ); + myButtonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( myButtonCancel ); + /***************************************************************/ + + topLayout->addWidget( GroupC1 ); + topLayout->addWidget( GroupButtons ); + + // signals and slots connections + connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + /* Move widget on the botton right corner of main widget */ + QAD_Tools::centerWidget( this, parent ); +} + +/*! + Destructor +*/ +SALOMEGUI_NameDlg::~SALOMEGUI_NameDlg() +{ +} + +/*! + Sets name +*/ +void SALOMEGUI_NameDlg::setName( const QString& name ) +{ + myLineEdit->setText( name ); + myLineEdit->selectAll(); +} + +/*! + Returns name entered by user +*/ +QString SALOMEGUI_NameDlg::name() +{ + return myLineEdit->text(); +} + +/*! + Creates modal dialog and returns name entered [ static ] +*/ +QString SALOMEGUI_NameDlg::getName( QWidget* parent, const QString& oldName ) +{ + QString n; + SALOMEGUI_NameDlg* dlg = new SALOMEGUI_NameDlg( parent ); + if ( !oldName.isNull() ) + dlg->setName( oldName ); + if ( dlg->exec() == QDialog::Accepted ) + n = dlg->name(); + delete dlg; + return n; +} diff --git a/src/SALOMEGUI/SALOMEGUI_NameDlg.h b/src/SALOMEGUI/SALOMEGUI_NameDlg.h new file mode 100644 index 000000000..9556adde7 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_NameDlg.h @@ -0,0 +1,40 @@ +// File : SALOMEGUI_NameDlg.h +// Created : Wed Jun 27 16:38:42 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef SALOMEGUI_NAMEDLG_H +#define SALOMEGUI_NAMEDLG_H + +#include + +class QLineEdit; +class QPushButton; + +//================================================================================= +// class : SALOMEGUI_NameDlg +// purpose : Common dialog box class +//================================================================================= +class SALOMEGUI_NameDlg : public QDialog +{ + Q_OBJECT + +public: + SALOMEGUI_NameDlg( QWidget* parent = 0 ); + ~SALOMEGUI_NameDlg(); + + void setName( const QString& name ); + QString name(); + + static QString getName( QWidget* parent = 0, const QString& oldName = QString::null ); + +private: + QPushButton* myButtonOk; + QPushButton* myButtonCancel; + QLineEdit* myLineEdit; +}; + +#endif // SALOMEGUI_NAMEDLG_H diff --git a/src/SALOMEGUI/SALOMEGUI_OpenWith.cxx b/src/SALOMEGUI/SALOMEGUI_OpenWith.cxx new file mode 100644 index 000000000..5359d9341 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_OpenWith.cxx @@ -0,0 +1,118 @@ +using namespace std; +// File : SALOMEGUI_OpenWith.cxx +// Created : Wed Oct 24 12:19:34 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + + +#include "SALOMEGUI_OpenWith.h" + +#include +#include +#include +#include +#include + +#define SPACING_SIZE 6 +#define MARGIN_SIZE 11 +#define MIN_LISTBOX_WIDTH 150 +#define MIN_LISTBOX_HEIGHT 100 + +/* + * Constructs modal SALOMEGUI_OpenWith which is a child of 'parent', with the + * name 'name' + */ +SALOMEGUI_OpenWith::SALOMEGUI_OpenWith(QWidget* parent, const char* name) + : QDialog( parent, name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "SALOMEGUI_OpenWith" ); + setCaption( tr("OPEN_WITH_TLT") ); + setSizeGripEnabled( TRUE ); + + QGridLayout* aTopLayout = new QGridLayout(this); + aTopLayout->setMargin(MARGIN_SIZE); + aTopLayout->setSpacing(SPACING_SIZE); + + AllwaysCheckBox = 0; +/* + AllwaysCheckBox = new QCheckBox( this, "AllwaysCheckBox" ); + AllwaysCheckBox->setText( tr( "MEN_COMPONENT_CHOICE1" ) ); +*/ + QHBoxLayout* aBtnLayout = new QHBoxLayout; + aBtnLayout->setSpacing( SPACING_SIZE ); + aBtnLayout->setMargin( 0 ); + + buttonOk = new QPushButton( this, "buttonOk" ); + buttonOk->setText( tr( "BUT_OK" ) ); + buttonOk->setAutoDefault( true ); + buttonOk->setDefault( true ); + + buttonCancel = new QPushButton( this, "buttonCancel" ); + buttonCancel->setText( tr( "BUT_CANCEL" ) ); + buttonCancel->setAutoDefault( true ); + + aBtnLayout->addWidget( buttonOk ); + aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + aBtnLayout->addWidget( buttonCancel ); + + ListComponent = new QListBox( this, "ListComponent" ); + ListComponent->setVScrollBarMode(QListBox::AlwaysOn); + ListComponent->setMinimumSize(MIN_LISTBOX_WIDTH, MIN_LISTBOX_HEIGHT); + ListComponent->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + ListComponent->setSelectionMode(QListBox::Single); + + aTopLayout->addWidget(ListComponent, 0, 0); +// aTopLayout->addWidget(AllwaysCheckBox, 1, 0); + aTopLayout->addLayout(aBtnLayout, 1, 0); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( ListComponent, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() )); + + updateButtonState(); +} + +/* + * Destroys the object and frees any allocated resources + */ +SALOMEGUI_OpenWith::~SALOMEGUI_OpenWith() +{ +} + +/* + Inserts new component into component list +*/ +void SALOMEGUI_OpenWith::addComponent(const QString& aComp) +{ + ListComponent->insertItem(aComp); +} + +/* + Returns choosen component +*/ +QString SALOMEGUI_OpenWith::getComponent() +{ + return ListComponent->currentText(); +} + +bool SALOMEGUI_OpenWith::getAlwaysFlag() +{ + if ( AllwaysCheckBox ) + return AllwaysCheckBox->isChecked(); + return false; +} +void SALOMEGUI_OpenWith::onSelectionChanged() +{ + updateButtonState(); +} + +void SALOMEGUI_OpenWith:: updateButtonState() +{ + buttonOk->setEnabled( ListComponent->currentItem() >=0 && + ListComponent->currentItem() < ListComponent->count() ) ; +} diff --git a/src/SALOMEGUI/SALOMEGUI_OpenWith.h b/src/SALOMEGUI/SALOMEGUI_OpenWith.h new file mode 100644 index 000000000..3d10ac03e --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_OpenWith.h @@ -0,0 +1,45 @@ +// File : SALOMEGUI_OpenWith.cxx +// Created : Wed Oct 24 12:19:34 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + + +#ifndef SALOMEGUI_OPENWITH_H +#define SALOMEGUI_OPENWITH_H + +#include + +class QListBox; +class QCheckBox; +class QPushButton; + +class SALOMEGUI_OpenWith : public QDialog +{ + Q_OBJECT + +public: + SALOMEGUI_OpenWith(QWidget* parent = 0, const char* name = 0); + ~SALOMEGUI_OpenWith(); + + void addComponent(const QString& aComp); + QString getComponent(); + bool getAlwaysFlag(); + +protected slots: + void onSelectionChanged(); + +protected: + void updateButtonState(); + +protected: + QListBox* ListComponent; + QCheckBox* AllwaysCheckBox; + QPushButton* buttonHelp; + QPushButton* buttonCancel; + QPushButton* buttonOk; +}; + +#endif // SALOMEGUI_OPENWITH_H diff --git a/src/SALOMEGUI/SALOMEGUI_QtCatchCorbaException.cxx b/src/SALOMEGUI/SALOMEGUI_QtCatchCorbaException.cxx new file mode 100644 index 000000000..676822a2a --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_QtCatchCorbaException.cxx @@ -0,0 +1,68 @@ +using namespace std; +//============================================================================= +// File : SALOMEGUI_QtCatchCorbaException.cxx +// Created : mer déc 19 14:52:07 CET 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "utilities.h" + +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" + +void QtCatchCorbaException(const SALOME::SALOME_Exception & S_ex) +{ + switch (S_ex.details.type) + { + case SALOME::COMM: + case SALOME::INTERNAL_ERROR: + { + QString str(S_ex.details.text); + QString source(S_ex.details.sourceFile); + QString line; + line.setNum(S_ex.details.lineNumber); + QString message = str + " \n" + source + " : " + line; + QAD_MessageBox::error1 + ( QAD_Application::getDesktop(), + QObject::tr ("Engine Error"), + message, + QObject::tr ("OK") ); + break; + } + + case SALOME::BAD_PARAM: + { + QString message(S_ex.details.text); +#ifdef _DEBUG_ + QString source(S_ex.details.sourceFile); + QString line; + line.setNum(S_ex.details.lineNumber); + message = message + " \n" + source + " : " + line; +#endif + QAD_MessageBox::warn1 + ( QAD_Application::getDesktop(), + QObject::tr ("Engine Warning"), + message, + QObject::tr ("OK") ); + break; + } + default: + { + QString str("SALOME CORBA Exception Type invalid"); + QString source(S_ex.details.sourceFile); + QString line; + line.setNum(S_ex.details.lineNumber); + QString message = str + " \n" + source + " : " + line; + QAD_MessageBox::error1 + ( QAD_Application::getDesktop(), + QObject::tr ("Internal SALOME Error"), + message, + QObject::tr ("OK") ); + break; + } + } +} diff --git a/src/SALOMEGUI/SALOMEGUI_QtCatchCorbaException.hxx b/src/SALOMEGUI/SALOMEGUI_QtCatchCorbaException.hxx new file mode 100644 index 000000000..3ab567351 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_QtCatchCorbaException.hxx @@ -0,0 +1,18 @@ +//============================================================================= +// File : SALOMEGUI_QtCatchCorbaException.hxx +// Created : mer déc 19 14:31:42 CET 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#ifndef _SALOMEGUI__QTCATCHCORBAEXCEPTION_HXX_ +#define _SALOMEGUI__QTCATCHCORBAEXCEPTION_HXX_ + +#include +#include CORBA_CLIENT_HEADER(SALOME_Exception) + +void QtCatchCorbaException(const SALOME::SALOME_Exception & S_ex); + +#endif diff --git a/src/SALOMEGUI/SALOMEGUI_SetValueDlg.cxx b/src/SALOMEGUI/SALOMEGUI_SetValueDlg.cxx new file mode 100644 index 000000000..71be7de20 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_SetValueDlg.cxx @@ -0,0 +1,189 @@ +using namespace std; +// File : SALOMEGUI_SetValueDlg.cxx +// Created : Wed Jun 27 16:39:06 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "SALOMEGUI_SetValueDlg.h" +#include "QAD_Tools.h" + +#include +#include +#include +#include +#include +#include + +#define MARGIN_SIZE 11 +#define SPACING_SIZE 6 +/*! + Constructor +*/ +SALOMEGUI_SetValueDlg::SALOMEGUI_SetValueDlg( QWidget* parent ) + : QDialog( parent, "SALOMEGUI_SetValueDlg", true, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr("TLT_SETVALUE") ); + setSizeGripEnabled( TRUE ); + + QVBoxLayout* topLayout = new QVBoxLayout( this ); + topLayout->setMargin( MARGIN_SIZE ); topLayout->setSpacing( SPACING_SIZE ); + + /***************************************************************/ + QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" ); + TopGroup->setColumnLayout(0, Qt::Vertical ); + TopGroup->layout()->setMargin( 0 ); TopGroup->layout()->setSpacing( 0 ); + QHBoxLayout* TopGroupLayout = new QHBoxLayout( TopGroup->layout() ); + TopGroupLayout->setAlignment( Qt::AlignTop ); + TopGroupLayout->setMargin( MARGIN_SIZE ); TopGroupLayout->setSpacing( SPACING_SIZE ); + + myLabel = new QLabel( tr( "VALUE_LBL" ), TopGroup, "myLabel" ); + myLineEdit = new QLineEdit( TopGroup, "myLineEdit" ); + myLineEdit->setMinimumSize( 250, 0 ); + + TopGroupLayout->addWidget( myLabel ); + TopGroupLayout->addWidget( myLineEdit ); + + /***************************************************************/ + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setMargin( 0 ); GroupButtons->layout()->setSpacing( 0 ); + QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setMargin( MARGIN_SIZE ); GroupButtonsLayout->setSpacing( SPACING_SIZE ); + + myButtonOk = new QPushButton( tr( "BUT_OK" ), GroupButtons, "myButtonOk" ); + myButtonOk->setAutoDefault( TRUE ); myButtonOk->setDefault( TRUE ); + myButtonCancel = new QPushButton( tr( "BUT_CANCEL" ), GroupButtons, "myButtonCancel" ); + myButtonCancel->setAutoDefault( TRUE ); + + GroupButtonsLayout->addWidget( myButtonOk ); + GroupButtonsLayout->addStretch(); + GroupButtonsLayout->addWidget( myButtonCancel ); + /***************************************************************/ + + topLayout->addWidget( TopGroup ); + topLayout->addWidget( GroupButtons ); + + // signals and slots connections + connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + /* Move widget on the botton right corner of main widget */ + QAD_Tools::centerWidget( this, parent ); +} + +/*! + Destructor +*/ +SALOMEGUI_SetValueDlg::~SALOMEGUI_SetValueDlg() +{ +} + +/*! + Sets value +*/ +void SALOMEGUI_SetValueDlg::setValue( const QString& value ) +{ + myLineEdit->setText( value ); + myLineEdit->selectAll(); +} + +/*! + Returns value entered by user +*/ +QString SALOMEGUI_SetValueDlg::value() +{ + return myLineEdit->text(); +} + +/*! + Sets validator +*/ +void SALOMEGUI_SetValueDlg::setValidator( QValidator* v ) +{ + myLineEdit->setValidator( v ); +} + +/*! + Sets label text +*/ +void SALOMEGUI_SetValueDlg::setLabel( const QString& label ) +{ + myLabel->setText( label ); +} + +/*! + Gets string value +*/ +QString SALOMEGUI_SetValueDlg::getString ( const QString& caption, + const QString& label, + const QString& oldValue, + bool* ok, + QWidget* parent ) +{ + QString v = QString::null; + SALOMEGUI_SetValueDlg* dlg = new SALOMEGUI_SetValueDlg( parent ); + dlg->setCaption( caption ); + dlg->setLabel( label ); + if ( !oldValue.isNull() ) + dlg->setValue( oldValue ); + int result = dlg->exec(); + if ( result == QDialog::Accepted ) + v = dlg->value(); + if ( ok ) + *ok = result == QDialog::Accepted; + delete dlg; + return v; +} + +/*! + Gets integer value +*/ +int SALOMEGUI_SetValueDlg::getInteger( const QString& caption, + const QString& label, + const int oldValue, + bool* ok, + QWidget* parent ) +{ + int v = 0; + SALOMEGUI_SetValueDlg* dlg = new SALOMEGUI_SetValueDlg( parent ); + dlg->setCaption( caption ); + dlg->setLabel( label ); + dlg->setValidator( new QIntValidator( dlg ) ); + dlg->setValue( QString::number( oldValue ) ); + int result = dlg->exec(); + if ( result == QDialog::Accepted ) + v = dlg->value().toInt(); + if ( ok ) + *ok = result == QDialog::Accepted; + delete dlg; + return v; +} + +/*! + Gets double value +*/ +double SALOMEGUI_SetValueDlg::getDouble ( const QString& caption, + const QString& label, + const double oldValue, + bool* ok, + QWidget* parent ) +{ + double v = 0; + SALOMEGUI_SetValueDlg* dlg = new SALOMEGUI_SetValueDlg( parent ); + dlg->setCaption( caption ); + dlg->setLabel( label ); + dlg->setValidator( new QDoubleValidator( dlg ) ); + dlg->setValue( QString::number( oldValue ) ); + int result = dlg->exec(); + if ( result == QDialog::Accepted ) + v = dlg->value().toDouble(); + if ( ok ) + *ok = result == QDialog::Accepted; + delete dlg; + return v; +} diff --git a/src/SALOMEGUI/SALOMEGUI_SetValueDlg.h b/src/SALOMEGUI/SALOMEGUI_SetValueDlg.h new file mode 100644 index 000000000..428b19008 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_SetValueDlg.h @@ -0,0 +1,58 @@ +// File : SALOMEGUI_SetValueDlg.h +// Created : Wed Jan 21 16:38:42 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef SALOMEGUI_SETVALUEDLG_H +#define SALOMEGUI_SETVALUEDLG_H + +#include + +class QLineEdit; +class QPushButton; +class QValidator; +class QLabel; + +//================================================================================= +// class : SALOMEGUI_SetValueDlg +// purpose : Common dialog box for setting integer, double and string values +//================================================================================= +class SALOMEGUI_SetValueDlg : public QDialog +{ +public: + static QString getString ( const QString& caption, + const QString& label, + const QString& oldValue = QString::null, + bool* ok = 0, + QWidget* parent = 0 ); + static int getInteger( const QString& caption, + const QString& label, + const int oldValue = 0, + bool* ok = 0, + QWidget* parent = 0 ); + static double getDouble ( const QString& caption, + const QString& label, + const double oldValue = 0.0, + bool* ok = 0, + QWidget* parent = 0 ); + +private: + SALOMEGUI_SetValueDlg( QWidget* parent = 0 ); + ~SALOMEGUI_SetValueDlg(); + + void setValue( const QString& value ); + QString value(); + void setValidator( QValidator* v ); + void setLabel( const QString& label ); + +private: + QLabel* myLabel; + QLineEdit* myLineEdit; + QPushButton* myButtonOk; + QPushButton* myButtonCancel; +}; + +#endif // SALOMEGUI_SETVALUEDLG_H diff --git a/src/SALOMEGUI/SALOMEGUI_SetupCurveDlg.cxx b/src/SALOMEGUI/SALOMEGUI_SetupCurveDlg.cxx new file mode 100644 index 000000000..cf6d5e3a4 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_SetupCurveDlg.cxx @@ -0,0 +1,196 @@ +using namespace std; +// File : SALOMEGUI_SetupCurveDlg.cxx +// Created : Wed Jun 27 16:38:42 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "SALOMEGUI_SetupCurveDlg.h" +#include "QAD_Tools.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#define MARGIN_SIZE 11 +#define SPACING_SIZE 6 +#define MIN_COMBO_WIDTH 100 +#define MIN_SPIN_WIDTH 50 +#define MAX_LINE_WIDTH 100 + +/*! + Constructor +*/ +SALOMEGUI_SetupCurveDlg::SALOMEGUI_SetupCurveDlg( QWidget* parent ) + : QDialog( parent, "SALOMEGUI_SetupCurveDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr("TLT_SETUP_CURVE") ); + setSizeGripEnabled( TRUE ); + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setSpacing( SPACING_SIZE ); + topLayout->setMargin( MARGIN_SIZE ); + + QGroupBox* TopGroup = new QGroupBox( this ); + TopGroup->setColumnLayout( 0, Qt::Vertical ); + TopGroup->layout()->setSpacing( 0 ); TopGroup->layout()->setMargin( 0 ); + QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() ); + TopGroupLayout->setAlignment( Qt::AlignTop ); + TopGroupLayout->setSpacing( SPACING_SIZE ); TopGroupLayout->setMargin( MARGIN_SIZE ); + + QLabel* aLineTypeLab = new QLabel( tr( "CURVE_LINE_TYPE_LAB" ), TopGroup ); + myLineCombo = new QComboBox( false, TopGroup ); + myLineCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myLineCombo->setMinimumWidth( MIN_COMBO_WIDTH ); + myLineCombo->insertItem( tr( "NONE_LINE_LBL" ) ); + myLineCombo->insertItem( tr( "SOLID_LINE_LBL" ) ); + myLineCombo->insertItem( tr( "DASH_LINE_LBL" ) ); + myLineCombo->insertItem( tr( "DOT_LINE_LBL" ) ); + myLineCombo->insertItem( tr( "DASHDOT_LINE_LBL" ) ); + myLineCombo->insertItem( tr( "DAHSDOTDOT_LINE_LBL" ) ); + myLineCombo->setCurrentItem( 1 ); // SOLID by default + + QLabel* aLineWidthLab = new QLabel( tr( "CURVE_LINE_WIDTH_LAB" ), TopGroup ); + myLineSpin = new QSpinBox( 0, MAX_LINE_WIDTH, 1, TopGroup ); + myLineSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myLineSpin->setMinimumWidth( MIN_SPIN_WIDTH ); + myLineSpin->setValue( 0 ); // default width is 0 + + QLabel* aMarkerLab = new QLabel( tr( "CURVE_MARKER_TYPE_LAB" ), TopGroup ); + myMarkerCombo = new QComboBox( false, TopGroup ); + myMarkerCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myMarkerCombo->setMinimumWidth( MIN_COMBO_WIDTH ); + myMarkerCombo->insertItem( tr( "NONE_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "CIRCLE_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "RECTANGLE_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "DIAMOND_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "DTRIANGLE_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "UTRIANGLE_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "LTRIANGLE_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "RTRIANGLE_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "CROSS_MARKER_LBL" ) ); + myMarkerCombo->insertItem( tr( "XCROSS_MARKER_LBL" ) ); + myMarkerCombo->setCurrentItem( 1 ); // CIRCLE by default + + QLabel* aColorLab = new QLabel( tr( "CURVE_COLOR_LAB" ), TopGroup ); + myColorBtn = new QToolButton( TopGroup ); + + TopGroupLayout->addWidget( aLineTypeLab, 0, 0 ); + TopGroupLayout->addMultiCellWidget( myLineCombo, 0, 0, 1, 2 ); + TopGroupLayout->addWidget( aLineWidthLab, 1, 0 ); + TopGroupLayout->addMultiCellWidget( myLineSpin, 1, 1, 1, 2 ); + TopGroupLayout->addWidget( aMarkerLab, 2, 0 ); + TopGroupLayout->addMultiCellWidget( myMarkerCombo, 2, 2, 1, 2 ); + TopGroupLayout->addWidget( aColorLab, 3, 0 ); + TopGroupLayout->addWidget( myColorBtn, 3, 1 ); + TopGroupLayout->setColStretch( 2, 5 ); + + QGroupBox* GroupButtons = new QGroupBox( this ); + GroupButtons->setColumnLayout( 0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); GroupButtons->layout()->setMargin( 0 ); + QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( SPACING_SIZE ); GroupButtonsLayout->setMargin( MARGIN_SIZE ); + + myOkBtn = new QPushButton( tr( "BUT_OK" ), GroupButtons ); + myOkBtn->setAutoDefault( true ); myOkBtn->setDefault( true ); + myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ) , GroupButtons ); + myCancelBtn->setAutoDefault( true ); + + GroupButtonsLayout->addWidget( myOkBtn ); + GroupButtonsLayout->addStretch(); + GroupButtonsLayout->addWidget( myCancelBtn ); + + connect( myColorBtn, SIGNAL( clicked() ), this, SLOT( onColorChanged() ) ); + connect( myOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + setColor( QColor( 0, 0, 0 ) ); + + topLayout->addWidget( TopGroup, 0, 0 ); + topLayout->addWidget( GroupButtons, 1, 0 ); + + QAD_Tools::centerWidget( this, parent ); +} +/*! + Destructor +*/ +SALOMEGUI_SetupCurveDlg::~SALOMEGUI_SetupCurveDlg() +{ +} +/*! + Sets line style and width +*/ +void SALOMEGUI_SetupCurveDlg::setLine( const int line, const int width ) +{ + myLineCombo->setCurrentItem( line ); + myLineSpin->setValue( width ); +} +/*! + Gets line style +*/ +int SALOMEGUI_SetupCurveDlg::getLine() const +{ + return myLineCombo->currentItem(); +} +/*! + Gets line width +*/ +int SALOMEGUI_SetupCurveDlg::getLineWidth() const +{ + return myLineSpin->value(); +} +/*! + Sets marker style +*/ +void SALOMEGUI_SetupCurveDlg::setMarker( const int marker ) +{ + myMarkerCombo->setCurrentItem( marker ); +} +/*! + Gets marker style +*/ +int SALOMEGUI_SetupCurveDlg::getMarker() const +{ + return myMarkerCombo->currentItem(); +} +/*! + Sets color +*/ +void SALOMEGUI_SetupCurveDlg::setColor( const QColor& color ) +{ + QPalette pal = myColorBtn->palette(); + QColorGroup ca = pal.active(); + ca.setColor( QColorGroup::Button, color ); + QColorGroup ci = pal.inactive(); + ci.setColor( QColorGroup::Button, color ); + pal.setActive( ca ); + pal.setInactive( ci ); + myColorBtn->setPalette( pal ); +} +/*! + Gets color +*/ +QColor SALOMEGUI_SetupCurveDlg::getColor() const +{ + return myColorBtn->palette().active().button(); +} +/*! + button slot, invokes color selection dialog box +*/ +void SALOMEGUI_SetupCurveDlg::onColorChanged() +{ + QColor color = QColorDialog::getColor( getColor() ); + if ( color.isValid() ) { + setColor( color ); + } +} + + + + + diff --git a/src/SALOMEGUI/SALOMEGUI_SetupCurveDlg.h b/src/SALOMEGUI/SALOMEGUI_SetupCurveDlg.h new file mode 100644 index 000000000..7f526f5ae --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_SetupCurveDlg.h @@ -0,0 +1,54 @@ +// File : SALOMEGUI_SetupCurveDlg.h +// Created : Wed Jun 27 16:38:42 2001 +// Author : Vadim SANDLER +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef SALOMEGUI_SetupCurveDlg_H +#define SALOMEGUI_SetupCurveDlg_H + +#include + +//================================================================================= +// class : SALOMEGUI_SetupCurveDlg +// purpose : Dialog box for setup Plot2d curve +//================================================================================= + +class QPushButton; +class QComboBox; +class QSpinBox; +class QToolButton; + +class SALOMEGUI_SetupCurveDlg : public QDialog +{ + Q_OBJECT + +public: + SALOMEGUI_SetupCurveDlg( QWidget* parent = 0 ); + ~SALOMEGUI_SetupCurveDlg(); + +public: + void setLine( const int line, const int width ); + int getLine() const; + int getLineWidth() const; + void setMarker( const int marker ); + int getMarker() const ; + void setColor( const QColor& color ); + QColor getColor() const; + +protected slots: + void onColorChanged(); + +private: + QPushButton* myOkBtn; + QPushButton* myCancelBtn; + QComboBox* myLineCombo; + QSpinBox* myLineSpin; + QComboBox* myMarkerCombo; + QToolButton* myColorBtn; +}; + +#endif // SALOMEGUI_SetupCurveDlg_H + diff --git a/src/SALOMEGUI/SALOMEGUI_StudyPropertiesDlg.cxx b/src/SALOMEGUI/SALOMEGUI_StudyPropertiesDlg.cxx new file mode 100644 index 000000000..d2c662efe --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_StudyPropertiesDlg.cxx @@ -0,0 +1,290 @@ +using namespace std; +// File : SALOMEGUI_StudyPropertiesDlg.cxx +// Created : Tue Oct 22 12:28:23 2002 +// Descr : Dialog box for editing of study properties + +// Author : Sergey ANIKIN +// Project : SALOME Pro +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "SALOMEGUI_StudyPropertiesDlg.h" + +#include "QAD_Desktop.h" +#include "QAD_ListView.h" + +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +#include +#include + +#define DEFAULT_MARGIN 11 +#define DEFAULT_SPACING 6 +#define SPACER_SIZE 5 +#define MIN_LIST_WIDTH 300 +#define MIN_LIST_HEIGHT 150 + +class SALOMEGUI_PropItem : public QAD_ListViewItem +{ +public: +// constructor + SALOMEGUI_PropItem(QAD_ListView* parent, + const QString theName, + const bool theEditable, + const int theUserType) : + QAD_ListViewItem(parent, theName, theEditable) + { + setUserType(theUserType); + } +// constructor + SALOMEGUI_PropItem(QAD_ListView* parent, + QAD_ListViewItem* after, + const QString theName, + const bool theEditable, + const int theUserType) : + QAD_ListViewItem(parent, after, theName, theEditable) + { + setUserType(theUserType); + } +// fills widget with initial values (list or single value) + void fillWidgetWithValues(QAD_EntityEdit* theWidget) + { + QStringList list; + switch(getUserType()) { + case SALOMEGUI_StudyPropertiesDlg::prpModeId: + { + list << QObject::tr("PRP_MODE_FROM_SCRATCH")<< QObject::tr("PRP_MODE_FROM_COPYFROM"); + theWidget->insertList(list); + break; + } + case SALOMEGUI_StudyPropertiesDlg::prpLockedId: + { + list << QObject::tr("PRP_NO") << QObject::tr("PRP_YES"); + theWidget->insertList(list, getValue() == QObject::tr("PRP_NO") ? 0 : 1); + break; + } + case SALOMEGUI_StudyPropertiesDlg::prpModificationsId: + { + QAD_Study* study = QAD_Application::getDesktop()->getActiveStudy(); + if (study) { + SALOMEDS::Study_var studyDoc = study->getStudyDocument(); + SALOMEDS::AttributeStudyProperties_var propAttr; + if (!studyDoc->_is_nil()) { + propAttr = studyDoc->GetProperties(); + if (!propAttr->_is_nil()) { + SALOMEDS::StringSeq_var aUsers; + SALOMEDS::LongSeq_var aMins, aHours, aDays, aMonths, aYears; + propAttr->GetModificationsList(aUsers, aMins, aHours, aDays, aMonths, aYears, false); + int aCnt = aUsers->length(); + for ( int i = 0; i < aCnt; i++ ) { + QString val; + val.sprintf("%2.2d/%2.2d/%2d %2.2d:%2.2d", + aDays [i], + aMonths[i], + aYears [i], + aHours [i], + aMins [i]); + val = val + " : " + QString(aUsers[i]); + list.prepend(val); + } + theWidget->setDuplicatesEnabled(true); + theWidget->insertList(list); + } + } + } + break; + } + default: + { + QAD_ListViewItem::fillWidgetWithValues(theWidget); + break; + } + } + } +// finishes editing of entity + virtual UpdateType finishEditing(QAD_EntityEdit* theWidget) { + if ( getUserType() == SALOMEGUI_StudyPropertiesDlg::prpModificationsId ) + return utCancel; + else + return QAD_ListViewItem::finishEditing(theWidget); + } +}; + +SALOMEGUI_StudyPropertiesDlg::SALOMEGUI_StudyPropertiesDlg(QWidget* parent) + : QDialog(parent, "", TRUE, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + myChanged( false ) +{ + setCaption(tr("TLT_STUDY_PROPERTIES")); + setSizeGripEnabled( true ); + + clearWFlags(Qt::WStyle_ContextHelp); + + QGridLayout* mainLayout = new QGridLayout(this); + mainLayout->setMargin(DEFAULT_MARGIN); + mainLayout->setSpacing(DEFAULT_SPACING); + + myPropList = new QAD_ListView(this); + myPropList->addColumn(""); + myPropList->addColumn(""); + myPropList->enableEditing(TRUE); + myPropList->setMinimumSize(MIN_LIST_WIDTH, MIN_LIST_HEIGHT); + mainLayout->addMultiCellWidget(myPropList, 0, 0, 0, 2); + + myOKBtn = new QPushButton(tr("BUT_OK"), this); + mainLayout->addWidget(myOKBtn, 1, 0); + + myCancelBtn = new QPushButton(tr("BUT_CANCEL"), this); + mainLayout->addWidget(myCancelBtn, 1, 2); + + QSpacerItem* spacer1 = new QSpacerItem(SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum); + mainLayout->addItem(spacer1, 1, 1); + + // Display study properties + QAD_Study* study = ((QAD_Desktop*)parent)->getActiveStudy(); + if (study) myStudyDoc = study->getStudyDocument(); + + initData(); + + connect(myOKBtn, SIGNAL(clicked()), this, SLOT(onOK())); + connect(myCancelBtn, SIGNAL(clicked()), this, SLOT(reject())); +} + +SALOMEGUI_StudyPropertiesDlg::~SALOMEGUI_StudyPropertiesDlg() +{ +} + +void SALOMEGUI_StudyPropertiesDlg::initData() +{ + bool hasData = !myStudyDoc->_is_nil(); + SALOMEDS::AttributeStudyProperties_var propAttr; + if (hasData) propAttr = myStudyDoc->GetProperties(); + hasData = hasData && !propAttr->_is_nil(); + + // Study author's name + SALOMEGUI_PropItem* item = new SALOMEGUI_PropItem(myPropList, tr("PRP_AUTHOR")+":", true, prpAuthorId); + if (hasData) item->setValue(propAttr->GetUserName()); + + // Date of creation + item = new SALOMEGUI_PropItem(myPropList, item, tr("PRP_DATE")+":", false, prpDateId); + if (hasData) { + CORBA::Long minutes, hours, day, month, year; + if (propAttr->GetCreationDate(minutes, hours, day, month, year)) { + QString strDate; + strDate.sprintf("%2.2d/%2.2d/%2d %2.2d:%2.2d", day, month, year, hours, minutes); + item->setValue(strDate); + } + } + + // Creation mode +// item = new SALOMEGUI_PropItem(myPropList, item, tr("PRP_MODE")+":", true, prpModeId); +// item->setEditingType(QAD_EntityEdit::etComboBox); +// if (hasData) item->setValue(propAttr->GetCreationMode()); + + // Locked or not + item = new SALOMEGUI_PropItem(myPropList, item, tr("PRP_LOCKED")+":", true, prpLockedId); + item->setEditingType(QAD_EntityEdit::etComboBox); + if (hasData) (propAttr->IsLocked()) ? item->setValue(tr("PRP_YES")) : item->setValue(tr("PRP_NO")); + + // Saved or not + item = new SALOMEGUI_PropItem(myPropList, item, tr("PRP_MODIFIED")+":", false, prpSavedId); + if (hasData) { + if (propAttr->IsModified()) + item->setValue(tr("PRP_YES")); + else + item->setValue(tr("PRP_NO")); + } + + // Modifications list + item = new SALOMEGUI_PropItem(myPropList, item, tr("PRP_MODIFICATIONS")+":", true, prpModificationsId); + item->setEditingType(QAD_EntityEdit::etComboBox); + if (hasData) { + SALOMEDS::StringSeq_var aUsers; + SALOMEDS::LongSeq_var aMins, aHours, aDays, aMonths, aYears; + propAttr->GetModificationsList(aUsers, aMins, aHours, aDays, aMonths, aYears, false); + int aLast = aUsers->length()-1; + if (aLast >= 0) { + QString val; + val.sprintf("%2.2d/%2.2d/%2d %2.2d:%2.2d", + aDays [aLast], + aMonths[aLast], + aYears [aLast], + aHours [aLast], + aMins [aLast]); + val = val + " : " + QString(aUsers[aUsers->length()-1]); + item->setValue(val); + } + } + + myOKBtn->setEnabled(hasData); +} + +bool SALOMEGUI_StudyPropertiesDlg::acceptData() +{ + return TRUE; +} + +void SALOMEGUI_StudyPropertiesDlg::onOK() +{ + myPropList->accept(); + + if (acceptData()) { + SALOMEDS::AttributeStudyProperties_var propAttr = myStudyDoc->GetProperties(); + myChanged = propChanged(); + if ( !propAttr->_is_nil() && myChanged ) { + QListViewItemIterator it( myPropList ); + // iterate through all items of the listview + for ( ; it.current(); ++it ) { + SALOMEGUI_PropItem* item = (SALOMEGUI_PropItem*)(it.current()); + switch (item->getUserType()) { + case prpAuthorId: + propAttr->SetUserName(item->getValue().stripWhiteSpace().latin1()); + break; + case prpModeId: + propAttr->SetCreationMode(item->getValue().stripWhiteSpace().latin1()); + break; + case prpLockedId: + propAttr->SetLocked(item->getValue().compare(tr("PRP_YES")) == 0); + break; + default: + break; + } + } + } + accept(); + } +} + +bool SALOMEGUI_StudyPropertiesDlg::propChanged() { + SALOMEDS::AttributeStudyProperties_var propAttr = myStudyDoc->GetProperties(); + if ( !propAttr->_is_nil() ) { + QListViewItemIterator it( myPropList ); + // iterate through all items of the listview + for ( ; it.current(); ++it ) { + SALOMEGUI_PropItem* item = (SALOMEGUI_PropItem*)(it.current()); + switch (item->getUserType()) { + case prpAuthorId: + if ( QString( propAttr->GetUserName() ) != item->getValue().stripWhiteSpace() ) { + return true; + } + break; + case prpModeId: + if ( QString( propAttr->GetCreationMode() ) != item->getValue().stripWhiteSpace() ) { + return true; + } + break; + case prpLockedId: + { + bool bLocked = item->getValue().compare( tr( "PRP_YES" ) ) == 0; + if ( propAttr->IsLocked() != bLocked ) { + return true; + } + break; + } + default: + break; + } + } + } + return false; +} diff --git a/src/SALOMEGUI/SALOMEGUI_StudyPropertiesDlg.h b/src/SALOMEGUI/SALOMEGUI_StudyPropertiesDlg.h new file mode 100644 index 000000000..de67fdce6 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_StudyPropertiesDlg.h @@ -0,0 +1,61 @@ +// File : SALOMEGUI_StudyPropertiesDlg.h +// Created : Tue Oct 22 12:28:23 2002 +// Descr : Dialog box for editing of study properties + +// Author : Sergey ANIKIN +// Project : SALOME Pro +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef SALOMEGUI_STUDY_PROPERTIES_DLG_H +#define SALOMEGUI_STUDY_PROPERTIES_DLG_H + +#include + +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +class QAD_ListView; +class QAD_ListViewItem; +class QPushButton; + +class SALOMEGUI_StudyPropertiesDlg : public QDialog +{ + Q_OBJECT + +public: + + enum { + prpAuthorId, + prpModeId, + prpDateId, + prpSavedId, + prpLockedId, + prpModificationsId, + prpLastId + }; + + SALOMEGUI_StudyPropertiesDlg( QWidget* parent = 0 ); + ~SALOMEGUI_StudyPropertiesDlg(); + + bool isChanged() { return myChanged; } + +public slots: + void onOK(); + +private: + void initData(); + bool acceptData(); + bool propChanged(); + +private: + QAD_ListView* myPropList; + QPushButton* myOKBtn; + QPushButton* myCancelBtn; + bool myChanged; + + SALOMEDS::Study_var myStudyDoc; +}; + +#endif // SALOMEGUI_STUDY_PROPERTIES_DLG_H diff --git a/src/SALOMEGUI/SALOMEGUI_Swig.cxx b/src/SALOMEGUI/SALOMEGUI_Swig.cxx new file mode 100644 index 000000000..c97025c01 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_Swig.cxx @@ -0,0 +1,269 @@ +using namespace std; +//============================================================================= +// File : SALOMEGUI_Swig.cxx +// Created : ven oct 12 15:44:16 CEST 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 + +// Modified : Mon Jul 29 21:38:07 2002 +// Author : Nicolas REJNERI +// Copyright : OPEN CASCADE 2002 +// $Header$ +//============================================================================= + +#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_Selection.h" +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" + + +/*! + Constructor +*/ +SALOMEGUI_Swig::SALOMEGUI_Swig(): _studyId(0) +{ + // MESSAGE("Constructeur"); +} + +/*! + Destructor +*/ +SALOMEGUI_Swig::~SALOMEGUI_Swig() +{ + // MESSAGE("Destructeur"); +} + +/*! + Call when updated object browser. +*/ +void SALOMEGUI_Swig::updateObjBrowser( bool updateSelection ) +{ + QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + myActiveStudy->updateObjBrowser( updateSelection ); +} + +/*! + Returns active Study Id. +*/ +int SALOMEGUI_Swig::getActiveStudyId() +{ + // NRI 24-02-03 : + // if (_studyId ==0) + // { + // QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + // _name = myStudy->getTitle(); + _studyId = QAD_Application::getDesktop()->getActiveStudy()->getStudyId(); + SCRUTE(_studyId); + // } + return _studyId; +} + +/*! + Returns active Study Name. +*/ +const char *SALOMEGUI_Swig::getActiveStudyName() +{ + QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + _name = myStudy->getTitle(); + // NRI 24-02-03 : + //if (_studyId ==0) + // getActiveStudyId(); + return _name.latin1(); +} + +/*! + Returns the number of selected objects. +*/ +int SALOMEGUI_Swig::SelectedCount() +{ + QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel + = SALOME_Selection::Selection( myStudy->getSelection() ); + return Sel->IObjectCount(); +} + +/*! + Returns the selected object at index i. +*/ +const char* SALOMEGUI_Swig::getSelected(int i) +{ + QAD_Study* myStudy = QAD_Application::getDesktop()->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) +{ + QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel + = SALOME_Selection::Selection( myStudy->getSelection() ); + + if ( !SALOMEGUI_Swig::IsInCurrentView( Entry ) ) + return; + + Handle(SALOME_InteractiveObject) IO = + myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry ); + Sel->AddIObject( IO ); +} + + +/*! + Removes object with Entry into selection. +*/ +void SALOMEGUI_Swig::RemoveIObject(const char *Entry) +{ + QAD_Study* myStudy + = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel + = SALOME_Selection::Selection( myStudy->getSelection() ); + + if ( !SALOMEGUI_Swig::IsInCurrentView( Entry ) ) + return; + + Handle(SALOME_InteractiveObject) IO = + myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry ); + Sel->RemoveIObject( IO ); +} + + +/*! + Removes all objects into selection. +*/ +void SALOMEGUI_Swig::ClearIObjects() +{ + QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel + = SALOME_Selection::Selection( myStudy->getSelection() ); + Sel->ClearIObjects(); +} + +/*! + Display +*/ +void SALOMEGUI_Swig::Display(const char *Entry) +{ + QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + + if ( !SALOMEGUI_Swig::IsInCurrentView( Entry ) ) + return; + + Handle(SALOME_InteractiveObject) IO = + myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry ); + + myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Display(IO); +} + +/*! + Display only +*/ +void SALOMEGUI_Swig::DisplayOnly(const char *Entry) +{ + if ( !SALOMEGUI_Swig::IsInCurrentView( Entry ) ) + return; + + QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + + Handle(SALOME_InteractiveObject) IO = + myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry ); + + if ( !IO.IsNull() ) { + myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->DisplayOnly(IO); + } +} + +/*! + Erase +*/ +void SALOMEGUI_Swig::Erase(const char *Entry) +{ + if ( !SALOMEGUI_Swig::IsInCurrentView( Entry ) ) + return; + + QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + + Handle(SALOME_InteractiveObject) IO = + myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry ); + + myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Erase(IO); +} + +/*! + Display all +*/ +void SALOMEGUI_Swig::DisplayAll() +{ + QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->DisplayAll(); +} + +/*! + Erse only +*/ +void SALOMEGUI_Swig::EraseAll() +{ + QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel + = SALOME_Selection::Selection( myStudy->getSelection() ); + + Sel->ClearIObjects(); + myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->EraseAll(); +} + +/*! + Check +*/ +bool SALOMEGUI_Swig::IsInCurrentView(const char *Entry) +{ + QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + return myStudy->isInViewer( Entry, myStudy->getActiveStudyFrame()->entry() ); +} + +vtkRenderer *SALOMEGUI_Swig::getRenderer(int viewId) +{ + QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); + 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) INFOS("No VTK Renderer available !"); + return myRenderer; +} diff --git a/src/SALOMEGUI/SALOMEGUI_Swig.hxx b/src/SALOMEGUI/SALOMEGUI_Swig.hxx new file mode 100644 index 000000000..a3e6fd951 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_Swig.hxx @@ -0,0 +1,60 @@ +//============================================================================= +// File : SALOMEGUI_Swig.hxx +// Created : ven oct 12 15:44:16 CEST 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 + +// Modified : Mon Jul 29 21:38:07 2002 +// Author : Nicolas REJNERI +// Copyright : OPEN CASCADE 2002 +// $Header$ +//============================================================================= + +#ifndef _SALOMEGUI_SWIG_HXX_ +#define _SALOMEGUI_SWIG_HXX_ + +//QT Include +#include + +#include + +class vtkRenderer; + +class SALOMEGUI_Swig +{ +public: + SALOMEGUI_Swig(); + ~SALOMEGUI_Swig(); + + static vtkRenderer* getRenderer(int viewId = -1); + + void updateObjBrowser( bool updateSelection ); + int getActiveStudyId(); + const char* getActiveStudyName(); + +/* selection */ + int SelectedCount(); + const char* getSelected(int i); + + void AddIObject(const char *Entry); + void RemoveIObject(const char *Entry); + void ClearIObjects(); + +/* display */ + void Display(const char *Entry); + void DisplayOnly(const char *Entry); + void Erase(const char *Entry); + void DisplayAll(); + void EraseAll(); + +/* check */ + bool IsInCurrentView(const char *Entry); + +protected: + int _studyId; + QString _name; +}; + + +#endif diff --git a/src/SALOMEGUI/SALOMEGUI_Swig.i b/src/SALOMEGUI/SALOMEGUI_Swig.i new file mode 100644 index 000000000..65db31489 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_Swig.i @@ -0,0 +1,63 @@ +//============================================================================= +// File : SALOMEGUI_Swig.i +// Created : ven oct 12 15:44:16 CEST 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +%{ +#include "SALOMEGUI_Swig.hxx" +%} + +%include "pointer.i" + +/* %typemap(python,out) const char** */ +/* { */ +/* int len,i; */ +/* if ($source) */ +/* { */ +/* len=atoi($source[0]); */ +/* $target = PyList_New(len); */ +/* for (i=0; i +#include +#include +#include +#include +#include +#include +#include +#include "utilities.h" + +#define MARGIN_SIZE 11 +#define SPACING_SIZE 6 +#define SPACER_SIZE 5 +#define MIN_TABLE_WIDTH 200 +#define MIN_TABLE_HEIGHT 200 + + +class SALOMEGUI_Table : public QTable { +public: + SALOMEGUI_Table( Orientation orient, QWidget* parent = 0, const char* name = 0 ) + : QTable( parent, name ), myValidator( 0 ), myOrientation( orient ) {} + SALOMEGUI_Table( Orientation orient, int numRows, int numCols, QWidget* parent = 0, const char* name = 0 ) + : QTable( numRows, numCols, parent, name ), myValidator( 0 ), myOrientation( orient ) {} + + void setValidator( QValidator* v = 0 ) { myValidator = v; } + bool isEditing() const { return QTable::isEditing(); } + +protected: + QWidget* createEditor ( int row, int col, bool initFromCell ) const + { + bool testUnits = ( myOrientation == Horizontal && col == 0 ) || ( myOrientation == Vertical && row == 0 ); + QWidget* wg = QTable::createEditor( row, col, initFromCell ); + if ( wg && wg->inherits("QLineEdit") && myValidator && !testUnits ) + (( QLineEdit*)wg)->setValidator( myValidator ); + return wg; + } + +protected: + QValidator* myValidator; + Orientation myOrientation; +}; + +/*! + Constructor +*/ +SALOMEGUI_TableDlg::SALOMEGUI_TableDlg( QWidget* parent, + SALOMEDS::SObject_var obj, + bool edit, + int which, + Orientation orient, + bool showColumnTitles ) + : QDialog( parent, "", false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), + myIntTable( 0 ), myRealTable( 0 ) +{ + setCaption( edit ? tr( "EDIT_TABLE_TLT" ) : tr( "VIEW_TABLE_TLT" ) ); + setSizeGripEnabled( true ); + + myObject = SALOMEDS::SObject::_duplicate( obj ); + bool bHasIntTable = false; + bool bHasRealTable = false; + if ( !myObject->_is_nil() ) { + SALOMEDS::GenericAttribute_var anAttr; + bHasIntTable = myObject->FindAttribute( anAttr, "AttributeTableOfInteger"); + bHasRealTable = myObject->FindAttribute( anAttr, "AttributeTableOfReal"); + } + + QVBoxLayout* mainLayout = new QVBoxLayout( this ); + mainLayout->setMargin( MARGIN_SIZE ); + mainLayout->setSpacing( SPACING_SIZE ); + + bool bDoInt = which == ttInt || which == ttBoth || which == ttAuto && bHasIntTable; + bool bDoReal = which == ttReal || which == ttBoth || which == ttAuto && bHasRealTable; + + QWidget* top; + QVBoxLayout* tl; + if ( bDoInt && bDoReal ) { + top = new QTabWidget( this, "TabWidget" ); + ( ( QTabWidget* ) top) ->setMargin( MARGIN_SIZE ); + } + else { + top = new QWidget( this, "DumbWidget" ); + tl = new QVBoxLayout( top ); tl->setMargin( 0 ); tl->setSpacing( SPACING_SIZE ); + } + + if ( bDoInt ) { + myIntTable = new SALOMEGUI_TableWidget( top, "myIntTable", edit, orient, showColumnTitles ); + myIntTable->getTable()->setValidator( new QIntValidator( this ) ); + if ( bDoInt && bDoReal ) + ( ( QTabWidget* )top )->addTab( myIntTable, tr( "TABLE_OF_INTEGER_TLT" ) ); + else + tl->addWidget( myIntTable ); + } + if ( bDoReal ) { + myRealTable = new SALOMEGUI_TableWidget( top, "myRealTable", edit, orient, showColumnTitles ); + myRealTable->getTable()->setValidator( new QDoubleValidator( this ) ); + if ( bDoInt && bDoReal ) + ( ( QTabWidget* )top )->addTab( myRealTable, tr( "TABLE_OF_REAL_TLT" ) ); + else + tl->addWidget( myRealTable ); + } + if ( !bDoInt && !bDoReal ) { + QLabel *dumbLabel = new QLabel( tr( "ERR_TABLE_NOT_AVAILABLE" ), top, "DumbLabel" ); + dumbLabel->setAlignment( AlignCenter ); + tl->addWidget( dumbLabel ); + } + + QHBoxLayout* btnLayout = new QHBoxLayout; + btnLayout->setMargin( 0 ); btnLayout->setSpacing( SPACING_SIZE ); + + myOKBtn = new QPushButton( tr( "BUT_OK" ), this ); + if ( edit ) { + myCancelBtn = new QPushButton( tr( "BUT_CANCEL" ), this ); + btnLayout->addWidget( myOKBtn ); + btnLayout->addItem( new QSpacerItem( SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + btnLayout->addWidget( myCancelBtn ); + connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( onOK() ) ); + connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + } + else { + btnLayout->addItem( new QSpacerItem( SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + btnLayout->addWidget( myOKBtn ); + btnLayout->addItem( new QSpacerItem( SPACER_SIZE, SPACER_SIZE, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + } + + mainLayout->addWidget( top ); + mainLayout->addLayout( btnLayout ); + + initDlg(); + resize( 500, 400 ); + QAD_Tools::centerWidget( this, parent ); +} + +/*! + Destructor +*/ +SALOMEGUI_TableDlg::~SALOMEGUI_TableDlg() +{ +} + +/*! + button slot, saves table(s) + Called only in create/edit mode ( parameter for constructor is true ) +*/ +void SALOMEGUI_TableDlg::onOK() +{ + myOKBtn->setFocus(); // accept possible changes + bool done = true; + + if ( !myObject->_is_nil() ) { + SALOMEDS::Study_var study = myObject->GetStudy(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeTableOfInteger_var tblIntAttr; + SALOMEDS::AttributeTableOfReal_var tblRealAttr; + + if ( !study->_is_nil() ) { + SALOMEDS::StudyBuilder_var builder = study->NewBuilder(); + builder->NewCommand(); // start transaction !!!!!!!!!!!!!!!!!!!!!!!!!!!!! + try { + if ( myIntTable ) { + builder->RemoveAttribute( myObject, "AttributeTableOfInteger" ); + tblIntAttr = SALOMEDS::AttributeTableOfInteger::_narrow( + builder->FindOrCreateAttribute( myObject, "AttributeTableOfInteger" ) ); + + int i; + int nbRows = myIntTable->getNumRows(); + int nbCols = myIntTable->getNumCols(); + QString tlt = myIntTable->getTableTitle(); + QStringList rowTitles, colTitles, units; + myIntTable->getRowTitles( rowTitles ); + myIntTable->getColTitles( colTitles ); + myIntTable->getUnits( units ); + + if ( nbRows > 0) { + // data + int nRow = 0; + tblIntAttr->SetNbColumns( nbCols ); + for ( i = 0; i < nbRows; i++ ) { + QStringList data; + myIntTable->getRowData( i, data ); + bool bEmptyRow = true; + for ( int j = 0; j < data.count(); j++ ) { + if ( !data[ j ].isNull() ) { + tblIntAttr->PutValue( data[ j ].toInt(), nRow+1, j+1 ); + bEmptyRow = false; + } + } + if ( !bEmptyRow ) { // Skip rows with no data !!! + // set row title + tblIntAttr->SetRowTitle( nRow+1, rowTitles[ i ].isNull() ? strdup( "" ) : strdup( rowTitles[ i ] ) ); + // set row unit + tblIntAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? strdup( "" ) : strdup( 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 ] ) ); + } + } + // title + tblIntAttr->SetTitle( myIntTable->getTableTitle().latin1() ); + } + if ( myRealTable ) { + builder->RemoveAttribute( myObject, "AttributeTableOfReal" ); + tblRealAttr = SALOMEDS::AttributeTableOfReal::_narrow( + builder->FindOrCreateAttribute( myObject, "AttributeTableOfReal" ) ); + + int i; + int nbRows = myRealTable->getNumRows(); + int nbCols = myRealTable->getNumCols(); + QString tlt = myRealTable->getTableTitle(); + QStringList rowTitles, colTitles, units; + myRealTable->getRowTitles( rowTitles ); + myRealTable->getColTitles( colTitles ); + myRealTable->getUnits( units ); + + if ( nbRows > 0) { + // data + int nRow = 0; + tblRealAttr->SetNbColumns( nbCols ); + for ( i = 0; i < nbRows; i++ ) { + QStringList data; + myRealTable->getRowData( i, data ); + bool bEmptyRow = true; + for ( int j = 0; j < data.count(); j++ ) { + if ( !data[ j ].isNull() ) { + tblRealAttr->PutValue( data[ j ].toDouble(), nRow+1, j+1 ); + bEmptyRow = false; + } + } + if ( !bEmptyRow ) { // Skip rows with no data !!! + // set row title + tblRealAttr->SetRowTitle( nRow+1, rowTitles[ i ].isNull() ? strdup( "" ) : strdup( rowTitles[ i ] ) ); + // set row unit + tblRealAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? strdup( "" ) : strdup( 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 ] ) ); + } + } + // title + tblRealAttr->SetTitle( myRealTable->getTableTitle().latin1() ); + } + if ( myIntTable || myRealTable) + builder->CommitCommand(); // commit transaction !!!!!!!!!!!!!!!!!!!!!!!!!!! + else + builder->AbortCommand(); // abort transaction !!!!!!!!!!!!!!!!!!!!!!!!!!! + } + catch( ... ) { + MESSAGE("SALOMEGUI_TableDlg::onOK : Exception has been caught !!!"); + builder->AbortCommand(); // abort transaction !!!!!!!!!!!!!!!!!!!!!!!!!!! + done = false; + QAD_MessageBox::error1 ( this, tr("ERR_ERROR"), tr("ERR_APP_EXCEPTION"), tr ("BUT_OK") ); + } + } + } + if ( done ) + accept(); +} + +/*! + Populates table with data +*/ +void SALOMEGUI_TableDlg::initDlg() +{ + int i, j; + if ( !myObject->_is_nil() ) { + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeTableOfInteger_var tblIntAttr; + SALOMEDS::AttributeTableOfReal_var tblRealAttr; + if ( myObject->FindAttribute( anAttr, "AttributeTableOfInteger") ) { + tblIntAttr = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr ); + } + if ( myObject->FindAttribute( anAttr, "AttributeTableOfReal") ) { + tblRealAttr = SALOMEDS::AttributeTableOfReal::_narrow( anAttr ); + } + // Table of integer + if ( !tblIntAttr->_is_nil() && myIntTable ) { + try { + SALOMEGUI_Table* tbl = myIntTable->getTable(); + // title + myIntTable->setTableTitle( strdup( tblIntAttr->GetTitle() ) ); + // nb of rows & cols + int nbRows = tblIntAttr->GetNbRows() ; + int nbCols = tblIntAttr->GetNbColumns(); + myIntTable->setNumRows( nbRows ); + myIntTable->setNumCols( nbCols ); + // rows titles + QStringList strlist; + SALOMEDS::StringSeq_var rowTitles = tblIntAttr->GetRowTitles(); + for ( i = 0; i < nbRows; i++ ) { + if ( rowTitles->length() > 0 ) + strlist.append( strdup( rowTitles[i] ) ); + else + strlist.append( "" ); + } + myIntTable->setRowTitles( strlist ); + // columns titles + strlist.clear(); + SALOMEDS::StringSeq_var colTitles = tblIntAttr->GetColumnTitles(); + for ( i = 0; i < nbCols; i++ ) { + if ( colTitles->length() > 0 ) + strlist.append( strdup( colTitles[i] ) ); + else + strlist.append( "" ); + } + myIntTable->setColTitles( strlist ); + // units + strlist.clear(); + SALOMEDS::StringSeq_var rowUnits = tblIntAttr->GetRowUnits(); + if ( rowUnits->length() > 0 ) { + for ( i = 0; i < nbRows; i++ ) + strlist.append( strdup( rowUnits[i] ) ); + myIntTable->setUnits( strlist ); + } + // data + for ( i = 1; i <= nbRows; i++ ) { + strlist.clear(); + for ( j = 1; j <= nbCols; j++ ) { + if ( tblIntAttr->HasValue( i, j ) ) + strlist.append( QString::number( tblIntAttr->GetValue( i, j ) ) ); + else + strlist.append( QString::null ); + } + myIntTable->setRowData( i-1, strlist ); + } + myIntTable->adjustTable(); + } + catch( ... ) { + MESSAGE("SALOMEGUI_TableDlg::initDlg : Exception has been caught !!!"); + } + } + // Table of real + if ( !tblRealAttr->_is_nil() && myRealTable ) { + try { + SALOMEGUI_Table* tbl = myRealTable->getTable(); + // title + myRealTable->setTableTitle( strdup( tblRealAttr->GetTitle() ) ); + // nb of rows & cols + int nbRows = tblRealAttr->GetNbRows() ; + int nbCols = tblRealAttr->GetNbColumns(); + myRealTable->setNumRows( nbRows ); + myRealTable->setNumCols( nbCols ); + // rows titles + QStringList strlist; + SALOMEDS::StringSeq_var rowTitles = tblRealAttr->GetRowTitles(); + for ( i = 0; i < nbRows; i++ ) { + if ( rowTitles->length() > 0 ) + strlist.append( strdup( rowTitles[i] ) ); + else + strlist.append( "" ); + } + myRealTable->setRowTitles( strlist ); + // columns titles + strlist.clear(); + SALOMEDS::StringSeq_var colTitles = tblRealAttr->GetColumnTitles(); + for ( i = 0; i < nbCols; i++ ) { + if ( colTitles->length() > 0 ) + strlist.append( strdup( colTitles[i] ) ); + else + strlist.append( "" ); + } + myRealTable->setColTitles( strlist ); + // units + strlist.clear(); + SALOMEDS::StringSeq_var rowUnits = tblRealAttr->GetRowUnits(); + if ( rowUnits->length() > 0 ) { + for ( i = 0; i < nbRows; i++ ) + strlist.append( strdup( rowUnits[i] ) ); + myRealTable->setUnits( strlist ); + } + // data + for ( i = 1; i <= nbRows; i++ ) { + strlist.clear(); + for ( j = 1; j <= nbCols; j++ ) { + if ( tblRealAttr->HasValue( i, j ) ) + strlist.append( QString::number( tblRealAttr->GetValue( i, j ) ) ); + else + strlist.append( QString::null ); + } + myRealTable->setRowData( i-1, strlist ); + } + myRealTable->adjustTable(); + } + catch( ... ) { + MESSAGE("SALOMEGUI_TableDlg::initDlg : Exception has been caught !!!"); + } + } + } +} + +/*! + Constructor +*/ +SALOMEGUI_TableWidget::SALOMEGUI_TableWidget( QWidget* parent, + const char* name, + bool edit, + Orientation orient, + bool showColumnTitles ) + : QWidget( parent, name ), myOrientation( orient ) +{ + QGridLayout* mainLayout = new QGridLayout( this ); + mainLayout->setMargin( 0 ); + mainLayout->setSpacing( SPACING_SIZE ); + + myTitleEdit = new QLineEdit( this, "TitleEdit" ); + myTitleEdit->setAlignment( AlignCenter ); + myTitleEdit->setReadOnly( !edit ); + QFont fnt = myTitleEdit->font(); + fnt.setBold( true ); + myTitleEdit->setFont( fnt ); + + myTable = new SALOMEGUI_Table( orient, this, "Table" ); + myTable->setNumRows( 5 ); + myTable->setNumCols( 5 ); + myTable->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + myTable->setMinimumSize( MIN_TABLE_WIDTH, MIN_TABLE_HEIGHT ); + myTable->setSelectionMode( QTable::Single ); + myTable->setShowGrid( true ); + myTable->setColumnMovingEnabled( false ); + myTable->setRowMovingEnabled( false ); + myTable->setReadOnly( !edit ); + myTable->setDragEnabled( false ); + setUnitsTitle( tr( "UNITS_TLT" ) ); + + if ( !showColumnTitles ) { + if ( myOrientation == Horizontal ) { + myTable->horizontalHeader()->hide(); + myTable->setTopMargin( 0 ); + } + else { + myTable->verticalHeader()->hide(); + myTable->setLeftMargin( 0 ); + } + } + + mainLayout->addWidget( myTitleEdit, 0, 0 ); + mainLayout->addWidget( myTable, 1, 0 ); + + if ( edit ) { + myAddRowBtn = new QPushButton( tr( "ADD_ROW_BTN" ), this, "AddRowBtn" ); + myDelRowBtn = new QPushButton( tr( "REMOVE_ROW_BTN" ), this, "DelRowBtn" ); + myAddColBtn = new QPushButton( tr( "ADD_COLUMN_BTN" ), this, "AddColBtn" ); + myDelColBtn = new QPushButton( tr( "REMOVE_COLUMN_BTN" ), this, "DelColBtn" ); + myAdjustBtn = new QPushButton( tr( "ADJUST_CELLS_BTN" ), this, "AdjustBtn" ); + mySelectAllBtn = new QPushButton( tr( "SELECT_ALL_BTN" ), this, "SelectAllBtn" ); + myClearBtn = new QPushButton( tr( "CLEAR_BTN"), this, "ClearBtn" ); + QVBoxLayout* btnLayout = new QVBoxLayout; btnLayout->setMargin( 0 ); btnLayout->setSpacing( SPACING_SIZE ); + btnLayout->addWidget( myAddRowBtn ); + btnLayout->addWidget( myDelRowBtn ); + btnLayout->addWidget( myAddColBtn ); + btnLayout->addWidget( myDelColBtn ); + btnLayout->addStretch(); + btnLayout->addWidget( myAdjustBtn ); + btnLayout->addStretch(); + btnLayout->addWidget( mySelectAllBtn ); + btnLayout->addWidget( myClearBtn ); + mainLayout->addLayout( btnLayout, 1, 1 ); + connect( myTable, SIGNAL( selectionChanged() ), this, SLOT( updateButtonsState() ) ); + connect( myTable, SIGNAL( currentChanged( int, int) ), this, SLOT( updateButtonsState() ) ); + connect( myAddRowBtn, SIGNAL( clicked() ), this, SLOT( addRow() ) ); + connect( myAddColBtn, SIGNAL( clicked() ), this, SLOT( addCol() ) ); + connect( myDelRowBtn, SIGNAL( clicked() ), this, SLOT( delRow() ) ); + connect( myDelColBtn, SIGNAL( clicked() ), this, SLOT( delCol() ) ); + connect( myAdjustBtn, SIGNAL( clicked() ), this, SLOT( adjustTable() ) ); + connect( mySelectAllBtn, SIGNAL( clicked() ), this, SLOT( selectAll() ) ); + connect( myClearBtn, SIGNAL( clicked() ), this, SLOT( clearTable() ) ); + myTable->horizontalHeader()->installEventFilter( this ); + myTable->verticalHeader()->installEventFilter( this ); + myTable->installEventFilter( this ); + } + updateButtonsState(); +} +/*! + Destructor +*/ +SALOMEGUI_TableWidget::~SALOMEGUI_TableWidget() +{ +} +/*! + Sets table title +*/ +void SALOMEGUI_TableWidget::setTableTitle( const QString& title ) +{ + myTitleEdit->setText( title ); +} +/*! + Gets table title +*/ +QString SALOMEGUI_TableWidget::getTableTitle() +{ + return myTitleEdit->text(); +} +/*! + Sets total number of rows +*/ +void SALOMEGUI_TableWidget::setNumRows( const int num ) +{ + myOrientation == Horizontal ? myTable->setNumRows( num ) : myTable->setNumCols( num ); +} +/*! + Gets total number of rows +*/ +int SALOMEGUI_TableWidget::getNumRows() +{ + return myOrientation == Horizontal ? myTable->numRows() : myTable->numCols(); +} +/*! + Sets total number of columns +*/ +void SALOMEGUI_TableWidget::setNumCols( const int num ) +{ + // !!! first column contains units !!! + myOrientation == Horizontal ? myTable->setNumCols( num+1 ) : myTable->setNumRows( num+1 ); +// myOrientation == Horizontal ? myTable->setColumnReadOnly( 0, true ) : myTable->setRowReadOnly( 0, true ); +} +/*! + Gets total number of columns +*/ +int SALOMEGUI_TableWidget::getNumCols() +{ + // !!! first column contains units !!! + return myOrientation == Horizontal ? myTable->numCols()-1 : myTable->numRows()-1; +} +/*! + Sets rows titles +*/ +void SALOMEGUI_TableWidget::setRowTitles( QStringList& tlts ) +{ + for ( int i = 0; i < tlts.count(); i++ ) { + myOrientation == Horizontal ? + myTable->verticalHeader()->setLabel( i, tlts[i] ) : + myTable->horizontalHeader()->setLabel( i, tlts[i] ); + } +} +/*! + Gets rows titles +*/ +void SALOMEGUI_TableWidget::getRowTitles( QStringList& tlts ) +{ + tlts.clear(); + if ( myOrientation == Horizontal ) { + for ( int i = 0; i < myTable->numRows(); i++ ) { + tlts.append( myTable->verticalHeader()->label( i ) ); + } + } + else { + for ( int i = 0; i < myTable->numCols(); i++ ) { + tlts.append( myTable->horizontalHeader()->label( i ) ); + } + } +} +/*! + Sets columns titles +*/ +void SALOMEGUI_TableWidget::setColTitles( QStringList& tlts ) +{ + // !!! first column contains units !!! + for ( int i = 0; i < tlts.count(); i++ ) { + myOrientation == Horizontal ? + myTable->horizontalHeader()->setLabel( i+1, tlts[i] ) : + myTable->verticalHeader()->setLabel( i+1, tlts[i] ); + } +} +/*! + Sets columns titles +*/ +void SALOMEGUI_TableWidget::getColTitles( QStringList& tlts ) +{ + // !!! first column contains units !!! + tlts.clear(); + if ( myOrientation == Horizontal ) { + for ( int i = 1; i < myTable->numCols(); i++ ) { + tlts.append( myTable->horizontalHeader()->label( i ) ); + } + } + else { + for ( int i = 1; i < myTable->numRows(); i++ ) { + tlts.append( myTable->verticalHeader()->label( i ) ); + } + } +} +/*! + Sets units title +*/ +void SALOMEGUI_TableWidget::setUnitsTitle( const QString& tlt ) { + // !!! first column contains units !!! + myOrientation == Horizontal ? myTable->horizontalHeader()->setLabel( 0, tlt ) : myTable->verticalHeader()->setLabel( 0, tlt ); +} +/*! + Sets units +*/ +void SALOMEGUI_TableWidget::setUnits( QStringList& units ) +{ + for ( int i = 0; i < units.count(); i++ ) { + myOrientation == Horizontal ? myTable->setText( i, 0, units[i] ) : myTable->setText( 0, i, units[i] ); + } +} +/*! + Gets units +*/ +void SALOMEGUI_TableWidget::getUnits( QStringList& units ) +{ + units.clear(); + if ( myOrientation == Horizontal ) { + for ( int i = 0; i < myTable->numRows(); i++ ) + units.append( myTable->text( i, 0 ).isNull() ? QString("") : myTable->text( i, 0 ) ); + } + else { + for ( int i = 0; i < myTable->numCols(); i++ ) + units.append( myTable->text( 0, i ).isNull() ? QString("") : myTable->text( 0, i ) ); + } +} +/*! + Sets row data +*/ +void SALOMEGUI_TableWidget::setRowData( int row, QStringList& data ) +{ + if ( row >= 0 && row < getNumRows() ) { + for ( int i = 0; i < data.count(); i++ ) { + if ( data[i].isNull() ) { + myOrientation == Horizontal ? myTable->clearCell( row, i+1 ) : + myTable->clearCell( i+1, row ); + } + else { + myOrientation == Horizontal ? myTable->setText( row, i+1, data[i] ) : + myTable->setText( i+1, row, data[i] ); + } + } + } +} +/*! + Gets row data +*/ +void SALOMEGUI_TableWidget::getRowData( int row, QStringList& data ) +{ + data.clear(); + if ( row >= 0 && row < getNumRows() ) { + if ( myOrientation == Horizontal ) { + for ( int i = 1; i < myTable->numCols(); i++ ) + data.append( myTable->text( row, i ) ); + } + else { + for ( int i = 1; i < myTable->numRows(); i++ ) + data.append( myTable->text( i, row ) ); + } + } +} +/*! + Adjusts table cell to see contents, button slot +*/ +void SALOMEGUI_TableWidget::adjustTable() +{ + int i; + for ( i = 0; i < myTable->numRows(); i++ ) + myTable->adjustRow( i ); + for ( i = 0; i < myTable->numCols(); i++ ) + myTable->adjustColumn( i ); +} +/*! + Called when selection changed in table +*/ +void SALOMEGUI_TableWidget::updateButtonsState() +{ + if ( myTable->isReadOnly() ) + return; + bool bDR = false; // + bool bDC = false; // + bool bSA = false; // button slot +*/ +void SALOMEGUI_TableWidget::selectAll() +{ + myTable->clearSelection(); + QTableSelection ts; + ts.init( 0, 0 ); ts.expandTo( myTable->numRows()-1, myTable->numCols()-1 ); + myTable->addSelection( ts ); + updateButtonsState(); +} +/*! + button slot +*/ +void SALOMEGUI_TableWidget::clearTable() +{ + int nbSel = myTable->numSelections(); + for ( int i = 0; i < nbSel; i++ ) { + QTableSelection ts = myTable->selection( i ); + for ( int j = ts.topRow(); j < ts.bottomRow()+1; j++) { + if ( myOrientation == Vertical && j == 0 ) { +// continue; // UNITS + } + for ( int k = ts.leftCol(); k < ts.rightCol()+1; k++) { + if ( myOrientation == Horizontal && k == 0 ) { +// continue; // UNITS + } + myTable->clearCell( j, k ); + } + } + } + if ( nbSel == 0 ) + myTable->clearCell( myTable->currentRow(), myTable->currentColumn() ); + myTable->clearSelection(); + updateButtonsState(); +} +/*! + Event filter - handles titles editing +*/ +bool SALOMEGUI_TableWidget::eventFilter( QObject* o, QEvent* e ) +{ + if ( e->type() == QEvent::MouseButtonDblClick) { + QMouseEvent* me = ( QMouseEvent* )e; + if ( me->button() == LeftButton && !myTable->isReadOnly() ) { + if ( o == myTable->horizontalHeader() ) { + for ( int i = 0; i < myTable->horizontalHeader()->count(); i++ ) { + QRect rect = myTable->horizontalHeader()->sectionRect( i ); + rect.addCoords( 1, 1, -1, -1 ); + if ( rect.contains( myTable->horizontalHeader()->mapFromGlobal( me->globalPos() ) ) ) { + if ( myOrientation == Vertical || i != 0 ) { + bool bOk; + QString tlt = QInputDialog::getText( tr( "SET_TITLE_TLT" ), + tr( "TITLE_LBL" ), + QLineEdit::Normal, + myTable->horizontalHeader()->label( i ), + &bOk, + this ); + if ( bOk && !tlt.isNull() ) + myTable->horizontalHeader()->setLabel( i, tlt ); + break; + } + } + } + } + if ( o == myTable->verticalHeader() ) { + for ( int i = 0; i < myTable->verticalHeader()->count(); i++ ) { + QRect rect = myTable->verticalHeader()->sectionRect( i ); + rect.addCoords( 1, 1, -1, -1 ); + if ( rect.contains( myTable->verticalHeader()->mapFromGlobal( me->globalPos() ) ) ) { + if ( myOrientation == Horizontal || i != 0 ) { + bool bOk; + QString tlt = QInputDialog::getText( tr( "SET_TITLE_TLT" ), + tr( "TITLE_LBL" ), + QLineEdit::Normal, + myTable->verticalHeader()->label( i ), + &bOk, + this ); + if ( bOk && !tlt.isNull() ) + myTable->verticalHeader()->setLabel( i, tlt ); + break; + } + } + } + } + } + } + else if ( e->type() == QEvent::KeyRelease && o == myTable ) { + QKeyEvent* ke = (QKeyEvent*)e; + if ( ke->key() == Key_Delete && !myTable->isEditing() ) { + clearTable(); + } + else if ( ke->key() == Key_Backspace && !myTable->isEditing() ) { + clearTable(); + int i = myTable->currentRow(); + int j = myTable->currentColumn() - 1; + if ( j < 0 ) { j = myTable->numCols()-1; i--; } + if ( i >= 0 && j >= 0 ) + myTable->setCurrentCell( i, j ); + } + } + return QWidget::eventFilter( o, e ); +} + + + diff --git a/src/SALOMEGUI/SALOMEGUI_TableDlg.h b/src/SALOMEGUI/SALOMEGUI_TableDlg.h new file mode 100644 index 000000000..e66462c72 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_TableDlg.h @@ -0,0 +1,112 @@ +// File : SALOMEGUI_TableDlg.h +// Created : Wed Dec 25 12:00:00 2002 +// Descr : Dialog box for displaying/editing of table + +// Author : Vadim SANDLER +// Project : SALOME for ALLIANCES +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef SALOMEGUI_TABLE_DLG_H +#define SALOMEGUI_TABLE_DLG_H + +#include +#include +#include + +class SALOMEGUI_Table; +class SALOMEGUI_TableWidget; + +#include +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +class SALOMEGUI_TableDlg : public QDialog +{ + Q_OBJECT + +public: + + enum { ttNone, ttInt, ttReal, ttBoth, ttAuto }; + + SALOMEGUI_TableDlg( QWidget* parent, + SALOMEDS::SObject_var obj, + bool edit = false, + int which = ttAuto, + Orientation orient = Horizontal, + bool showColumnTitles = true ); + ~SALOMEGUI_TableDlg(); + +public slots: + void onOK(); + +private: + void initDlg(); + +private: + SALOMEGUI_TableWidget* myIntTable; + SALOMEGUI_TableWidget* myRealTable; + QPushButton* myOKBtn; + QPushButton* myCancelBtn; + + SALOMEDS::SObject_var myObject; +}; + +class SALOMEGUI_TableWidget : public QWidget +{ + Q_OBJECT +public: + SALOMEGUI_TableWidget( QWidget* parent = 0, + const char* name = 0, + bool edit = false, + Orientation orient = Horizontal, + bool showColumnTitles = true ); + ~SALOMEGUI_TableWidget(); + + void setTableTitle( const QString& title ); + QString getTableTitle(); + void setNumRows( const int num ); + int getNumRows(); + void setNumCols( const int num ); + int getNumCols(); + void setRowTitles( QStringList& tlts ); + void getRowTitles( QStringList& tlts ); + void setColTitles( QStringList& tlts ); + void getColTitles( QStringList& tlts ); + void setUnitsTitle( const QString& tlt ); + void setUnits( QStringList& units ); + void getUnits( QStringList& units ); + void setRowData( int row, QStringList& data ); + void getRowData( int row, QStringList& data ); + + SALOMEGUI_Table* getTable() { return myTable; } + QLineEdit* getTitleEdit() { return myTitleEdit; } + + bool eventFilter( QObject* o, QEvent* e); + +public slots: + void updateButtonsState(); + void addRow(); + void addCol(); + void delRow(); + void delCol(); + void adjustTable(); + void selectAll(); + void clearTable(); + +private: + QLineEdit* myTitleEdit; + SALOMEGUI_Table* myTable; + QPushButton* myAddRowBtn; + QPushButton* myAddColBtn; + QPushButton* myDelRowBtn; + QPushButton* myDelColBtn; + QPushButton* myAdjustBtn; + QPushButton* mySelectAllBtn; + QPushButton* myClearBtn; + Orientation myOrientation; +}; + +#endif // SALOMEGUI_TABLE_DLG_H + diff --git a/src/SALOMEGUI/SALOMEGUI_TrihedronSizeDlg.cxx b/src/SALOMEGUI/SALOMEGUI_TrihedronSizeDlg.cxx new file mode 100644 index 000000000..4f77e1b21 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_TrihedronSizeDlg.cxx @@ -0,0 +1,103 @@ +using namespace std; +// File : SALOMEGUI_TrihedronSizeDlg.cxx +// Created : Fri Mar 22 16:34:27 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOMEGUI_TrihedronSizeDlg.h" + +#include +#include +#include +#include +#include + +#define MARGIN_SIZE 11 +#define SPACING_SIZE 6 +#define MIN_SPIN_WIDTH 100 + +/* + * Constructs a modal SALOMEGUI_TrihedronSizeDlg which is a child of 'parent' + * + */ +SALOMEGUI_TrihedronSizeDlg::SALOMEGUI_TrihedronSizeDlg( QWidget* parent ) + : QDialog( parent, "SALOMEGUI_TrihedronSizeDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr( "MEN_TRIHEDRON" ) ); + setSizeGripEnabled( true ); + + QGridLayout* topLayout = new QGridLayout( this ); + topLayout->setSpacing( SPACING_SIZE ); + topLayout->setMargin( MARGIN_SIZE ); + + QGroupBox* trihedronGrp = new QGroupBox( this, "trihedronGrp" ); + trihedronGrp->setColumnLayout( 0, Qt::Vertical ); + trihedronGrp->layout()->setSpacing( 0 ); + trihedronGrp->layout()->setMargin( 0 ); + QGridLayout* trihedronGrpLayout = new QGridLayout( trihedronGrp->layout() ); + trihedronGrpLayout->setAlignment( Qt::AlignTop ); + trihedronGrpLayout->setSpacing( SPACING_SIZE ); + trihedronGrpLayout->setMargin( MARGIN_SIZE ); + + QHBoxLayout* aBtnLayout = new QHBoxLayout; + aBtnLayout->setSpacing( SPACING_SIZE ); + aBtnLayout->setMargin( 0 ); + + QPushButton* buttonOk = new QPushButton( this, "buttonOk" ); + buttonOk->setText( tr( "BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + + QPushButton* buttonCancel = new QPushButton( this, "buttonCancel" ); + buttonCancel->setText( tr( "BUT_CANCEL" ) ); + buttonCancel->setAutoDefault( TRUE ); + + QLabel* TextLabel = new QLabel( trihedronGrp, "TextLabel" ); + TextLabel->setText( tr( "MEN_TRIHEDRON_SIZE" ) ); + + SpinBox = new QSpinBox( 1, 999999999, 1, trihedronGrp, "SpinBox" ); + SpinBox->setValue( 100 ); + SpinBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + SpinBox->setMinimumWidth(MIN_SPIN_WIDTH); + + trihedronGrpLayout->addWidget(TextLabel, 0, 0); + trihedronGrpLayout->addWidget(SpinBox, 0, 1); + + aBtnLayout->addWidget( buttonOk ); + aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + aBtnLayout->addWidget( buttonCancel ); + + topLayout->addWidget( trihedronGrp, 0, 0 ); + topLayout->addLayout( aBtnLayout, 1, 0 ); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +/* + * Destroys the object and frees any allocated resources + */ +SALOMEGUI_TrihedronSizeDlg::~SALOMEGUI_TrihedronSizeDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +/* + Sets start trihedron size +*/ +void SALOMEGUI_TrihedronSizeDlg::setTrihedronSize(const int size) +{ + SpinBox->setValue(size); +} + +/* + Gets trihedron size +*/ +int SALOMEGUI_TrihedronSizeDlg::getTrihedronSize() +{ + return SpinBox->value(); +} diff --git a/src/SALOMEGUI/SALOMEGUI_TrihedronSizeDlg.h b/src/SALOMEGUI/SALOMEGUI_TrihedronSizeDlg.h new file mode 100644 index 000000000..3e06dc4d3 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_TrihedronSizeDlg.h @@ -0,0 +1,31 @@ +// File : SALOMEGUI_TrihedronSizeDlg.h +// Created : Fri Mar 22 16:33:18 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef SALOMEGUI_TRIHEDRON_SIZE_DLG_H +#define SALOMEGUI_TRIHEDRON_SIZE_DLG_H + +#include + +class QSpinBox; + +class SALOMEGUI_TrihedronSizeDlg : public QDialog +{ + Q_OBJECT + +public: + SALOMEGUI_TrihedronSizeDlg( QWidget* parent = 0 ); + ~SALOMEGUI_TrihedronSizeDlg(); + + void setTrihedronSize(const int size); + int getTrihedronSize(); + +protected: + QSpinBox* SpinBox; +}; + +#endif // SALOMEGUI_TRIHEDRON_SIZE_DLG_H diff --git a/src/SALOMEGUI/SALOMEGUI_ViewChoiceDlg.cxx b/src/SALOMEGUI/SALOMEGUI_ViewChoiceDlg.cxx new file mode 100644 index 000000000..b3d6c6b29 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_ViewChoiceDlg.cxx @@ -0,0 +1,114 @@ +using namespace std; +// File : SALOMEGUI_ViewChoiceDlg.cxx +// Created : Mon Jul 29 22:16:49 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOMEGUI_ViewChoiceDlg.h" +#include "QAD_Config.h" +#include "QAD_StudyFrame.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constructs a SALOMEGUI_ViewChoiceDlg which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +SALOMEGUI_ViewChoiceDlg::SALOMEGUI_ViewChoiceDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "SALOMEGUI_ViewChoiceDlg" ); + setCaption( tr( "MEN_CHOICE" ) ); + setSizeGripEnabled( true ); + + QGridLayout* theBaseLayout = new QGridLayout( this, 2, 1, 11, 6); + + GroupBox1 = new QGroupBox(0, Qt::Vertical, tr("MEN_VIEW"), this); + theBaseLayout->addWidget(GroupBox1, 0, 0); + + QHBoxLayout* aBoxLayout = new QHBoxLayout(GroupBox1->layout()); + + QHBoxLayout* aInternalLayout = new QHBoxLayout(6); + + TextLabel1 = new QLabel(tr("MEN_VIEWER_TYPE"), GroupBox1); + aInternalLayout->addWidget(TextLabel1); + + ComboBox1 = new QComboBox( false, GroupBox1); + ComboBox1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + ComboBox1->setMinimumWidth( 200 ); + // OCC Viewer + ComboBox1->insertItem(tr("MEN_VIEWER_OCC")); + myViewers.append(VIEW_OCC); + if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_OCC ) + ComboBox1->setCurrentItem( ComboBox1->count()-1 ); + // VTK Viewer + ComboBox1->insertItem(tr("MEN_VIEWER_VTK")); + myViewers.append(VIEW_VTK); + if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_VTK ) + ComboBox1->setCurrentItem( ComboBox1->count()-1 ); + // SUPERVISOR Viewer +// ComboBox1->insertItem(tr("MEN_VIEWER_GRAPH")); +// myViewers.append(VIEW_GRAPHSUPERV); +// if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_GRAPHSUPERV ) +// ComboBox1->setCurrentItem( ComboBox1->count()-1 ); + // Plot2d Viewer + ComboBox1->insertItem(tr("MEN_VIEWER_PLOT2D")); + myViewers.append(VIEW_PLOT2D); + if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_PLOT2D ) + ComboBox1->setCurrentItem( ComboBox1->count()-1 ); + TextLabel1->setBuddy(ComboBox1); + aInternalLayout->addWidget(ComboBox1); + + aBoxLayout->addLayout(aInternalLayout); + + QFrame* aButtonFrame = new QFrame( this ); + theBaseLayout->addWidget(aButtonFrame, 1, 0); + + QHBoxLayout* aButtLayout = new QHBoxLayout(aButtonFrame); + + buttonOk = new QPushButton(tr("BUT_OK"), aButtonFrame); + buttonOk->setAutoDefault(true); + buttonOk->setDefault(true); + aButtLayout->addWidget(buttonOk); + + QSpacerItem* aSpacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding); + aButtLayout->addItem(aSpacer); + + buttonCancel = new QPushButton(tr( "BUT_CANCEL" ), aButtonFrame); + buttonCancel->setAutoDefault(true); + aButtLayout->addWidget(buttonCancel); + + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +/* + * Destroys the object and frees any allocated resources + */ +SALOMEGUI_ViewChoiceDlg::~SALOMEGUI_ViewChoiceDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +/*! + Gets user's choice +*/ +int SALOMEGUI_ViewChoiceDlg::getSelectedViewer() +{ + return myViewers[ ComboBox1->currentItem() ]; +} diff --git a/src/SALOMEGUI/SALOMEGUI_ViewChoiceDlg.h b/src/SALOMEGUI/SALOMEGUI_ViewChoiceDlg.h new file mode 100644 index 000000000..29b228f6d --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_ViewChoiceDlg.h @@ -0,0 +1,42 @@ +// File : SALOMEGUI_ViewChoiceDlg.h +// Created : Mon Jul 29 22:17:24 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef SALOMEGUI_VIEWCHOICEDLG_H +#define SALOMEGUI_VIEWCHOICEDLG_H + +#include +#include +#include +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QComboBox; +class QGroupBox; +class QLabel; +class QPushButton; + +class SALOMEGUI_ViewChoiceDlg : public QDialog +{ + Q_OBJECT + +public: + SALOMEGUI_ViewChoiceDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SALOMEGUI_ViewChoiceDlg(); + + int getSelectedViewer(); + + QGroupBox* GroupBox1; + QLabel* TextLabel1; + QComboBox* ComboBox1; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QValueList myViewers; +}; + +#endif // SALOMEGUI_VIEWCHOICEDLG_H diff --git a/src/SALOMEGUI/SALOMEGUI_icons.po b/src/SALOMEGUI/SALOMEGUI_icons.po new file mode 100644 index 000000000..9020b0525 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_icons.po @@ -0,0 +1,98 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: example-Qt-message-extraction\n" +"POT-Creation-Date: 1999-02-23 15:38+0200\n" +"PO-Revision-Date: 1999-02-23 15:38+0200\n" +"Last-Translator: \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_BACK" +msgstr "view_back.png" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_BOTTOM" +msgstr "view_bottom.png" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_FITALL" +msgstr "view_fitall.png" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_FITAREA" +msgstr "view_fitarea.png" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_FRONT" +msgstr "view_front.png" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_GLOBALPAN" +msgstr "view_glpan.png" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_LEFT" +msgstr "view_left.png" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_PAN" +msgstr "view_pan.png" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_RESET" +msgstr "view_reset.png" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_RIGHT" +msgstr "view_right.png" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_ROTATE" +msgstr "view_rotate.png" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_TOP" +msgstr "view_top.png" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_ZOOM" +msgstr "view_zoom.png" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_TRIHEDRON" +msgstr "view_triedre.png" + +msgid "SALOMEGUI_Application::ICON_APP_VIEW_DUMP" +msgstr "view_camera_dump.png" + +msgid "ICON_PLOT2D_FIT_ALL" +msgstr "plot2d_fitall.png" + +msgid "ICON_PLOT2D_FIT_AREA" +msgstr "plot2d_fitarea.png" + +msgid "ICON_PLOT2D_ZOOM" +msgstr "plot2d_zoom.png" + +msgid "ICON_PLOT2D_PAN" +msgstr "plot2d_pan.png" + +msgid "ICON_PLOT2D_DUMP" +msgstr "plot2d_dump.png" + +msgid "ICON_PLOT2D_MODE_LINEAR_HOR" +msgstr "plot2d_linear.png" + +msgid "ICON_PLOT2D_MODE_LOGARITHMIC_HOR" +msgstr "plot2d_log.png" + +msgid "ICON_PLOT2D_MODE_LINEAR_VER" +msgstr "plot2d_linear_y.png" + +msgid "ICON_PLOT2D_MODE_LOGARITHMIC_VER" +msgstr "plot2d_log_y.png" + +msgid "ICON_PLOT2D_SHOW_LEGEND" +msgstr "plot2d_legend.png" + +msgid "ICON_PLOT2D_CURVES_POINTS" +msgstr "plot2d_points.png" + +msgid "ICON_PLOT2D_CURVES_LINES" +msgstr "plot2d_lines.png" + +msgid "ICON_PLOT2D_CURVES_SPLINES" +msgstr "plot2d_splines.png" + +msgid "ICON_PLOT2D_SETTINGS" +msgstr "plot2d_settings.png" + diff --git a/src/SALOMEGUI/SALOMEGUI_msg_en.po b/src/SALOMEGUI/SALOMEGUI_msg_en.po new file mode 100644 index 000000000..11fef0798 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_msg_en.po @@ -0,0 +1,633 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: example-Qt-message-extraction\n" +"POT-Creation-Date: 1999-02-23 15:38+0200\n" +"PO-Revision-Date: 1999-02-23 15:38+0200\n" +"Last-Translator: \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +#--------------- +# BUTTONS +#--------------- + +msgid "BUT_OK" +msgstr "Ok" + +msgid "BUT_HELP" +msgstr "Help" + +msgid "BUT_CANCEL" +msgstr "Cancel" + +#--------------- +# ERROR +#--------------- + +#: SALOMEGUI.cxx:45 +msgid "QObject::ERR_APP_INITFAILED" +msgstr "Initialization failed" + +#: SALOMEGUI.cxx:44 +msgid "ERR_ERROR" +msgstr "Error" + +#: SALOMEGUI_Application.cxx:672 +msgid "ERR_APP_WRONG_VIEW_TYPE" +msgstr "Appropriate view must be created to display selected object(s)" + +#--------------- +# MENUS +#--------------- + +#: SALOMEGUI_TrihedronSizeDlg.cxx:77 +msgid "SALOMEGUI_TrihedronSizeDlg::MEN_TRIHEDRON_SIZE" +msgstr "Size :" + +#: SALOMEGUI_TrihedronSizeDlg.cxx:36 +msgid "SALOMEGUI_TrihedronSizeDlg::MEN_TRIHEDRON" +msgstr "Trihedron" + +#: SALOMEGUI_OpenWith.cxx:37 +msgid "SALOMEGUI_OpenWith::MEN_COMPONENT_CHOICE1" +msgstr "Always use this component to open this type of object" + +#: SALOMEGUI_OpenWith.cxx:65 +msgid "SALOMEGUI_OpenWith::MEN_COMPONENT_CHOICE2" +msgstr "Choose the component you want to use :" + +#: SALOMEGUI_OpenWith.cxx:33 +msgid "SALOMEGUI_OpenWith::MEN_COMPONENT_CHOICE3" +msgstr "Choose the component you want to use to open objects :" + +#: SALOMEGUI_LoadStudiesDlg.cxx:27 +msgid "SALOMEGUI_LoadStudiesDlg::MEN_STUDIES_CHOICE" +msgstr "Choose existing study." + +#: SALOMEGUI_Application.cxx:87 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_MU4" +msgstr "Split View" + +#: SALOMEGUI_Application.cxx:135 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_PAN" +msgstr "&Pan View\tCtrl+MB2" + +#: SALOMEGUI_Application.cxx:243 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_RESET" +msgstr "R&eset View" + +#: SALOMEGUI_Application.cxx:231 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_RIGHT" +msgstr "&Right View" + +#: SALOMEGUI_Application.cxx:147 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_ROTATE" +msgstr "R&otate View\tCtrl+MB3" + +#: SALOMEGUI_Application.cxx:195 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_TOP" +msgstr "&Top View" + +#: SALOMEGUI_Application.cxx:75 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_TRIHEDRON" +msgstr "Shows - Hides Trihedron" + +#: SALOMEGUI_Application.cxx:123 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_ZOOM" +msgstr "&Zoom View\tCtrl+MB1" + +msgid "SALOMEGUI_Application::MEN_APP_VIEW_FITALL" +msgstr "&Fit All" + +msgid "SALOMEGUI_Application::MEN_APP_VIEW_FITAREA" +msgstr "Fit &Area" + +msgid "SALOMEGUI_Application::MEN_APP_VIEW_FRONT" +msgstr "&Front View" + +msgid "SALOMEGUI_Application::MEN_APP_VIEW_GLOBALPAN" +msgstr "&Global Pan View" + +msgid "SALOMEGUI_Application::MEN_APP_VIEW_BACK" +msgstr "Bac&k View" + +msgid "SALOMEGUI_Application::MEN_APP_VIEW_BOTTOM" +msgstr "&Bottom View" + +msgid "SALOMEGUI_Application::MEN_APP_VIEW_LEFT" +msgstr "&Left View" + +#--------------- +# PRP +#--------------- + +#: SALOMEGUI_Application.cxx:185 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_TRIHEDRON" +msgstr "Shows \ hides trihedron" + +#: SALOMEGUI_Application.cxx:185 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_BACK" +msgstr "Shows back view of objects" + +#: SALOMEGUI_Application.cxx:209 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_BOTTOM" +msgstr "Shows bottom view of objects" + +#: SALOMEGUI_Application.cxx:101 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_FITALL" +msgstr "Fits all the objects in the view" + +#: SALOMEGUI_Application.cxx:113 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_FITAREA" +msgstr "Fits the view within an area" + +#: SALOMEGUI_Application.cxx:173 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_FRONT" +msgstr "Shows front view of objects" + +#: SALOMEGUI_Application.cxx:161 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_GLOBALPAN" +msgstr "Defines a new center of the view" + +#: SALOMEGUI_Application.cxx:221 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_LEFT" +msgstr "Shows left view of objects" + +#: SALOMEGUI_Application.cxx:89 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_MU4" +msgstr "Splits View" + +#: SALOMEGUI_Application.cxx:137 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_PAN" +msgstr "Moves objects in the view" + +#: SALOMEGUI_Application.cxx:245 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_RESET" +msgstr "Resets the view" + +#: SALOMEGUI_Application.cxx:233 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_RIGHT" +msgstr "Shows right view of objects" + +#: SALOMEGUI_Application.cxx:149 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_ROTATE" +msgstr "Rotates objects in the view" + +#: SALOMEGUI_Application.cxx:197 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_TOP" +msgstr "Shows top view of objects" + +#: SALOMEGUI_Application.cxx:125 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_ZOOM" +msgstr "Zooms the active view" + +#: SALOMEGUI_Application.cxx:125 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_DUMP" +msgstr "Saves the active view in the image file" + +#--------------- +# TOOL TIP +#--------------- + +#: SALOMEGUI_Application.cxx:181 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_BACK" +msgstr "Back view" + +#: SALOMEGUI_Application.cxx:205 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_BOTTOM" +msgstr "Bottom view" + +#: SALOMEGUI_Application.cxx:97 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_FITALL" +msgstr "Fit all" + +#: SALOMEGUI_Application.cxx:109 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_FITAREA" +msgstr "Fit within rectangle" + +#: SALOMEGUI_Application.cxx:169 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_FRONT" +msgstr "Front view" + +#: SALOMEGUI_Application.cxx:157 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_GLOBALPAN" +msgstr "Global panning" + +#: SALOMEGUI_Application.cxx:217 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_LEFT" +msgstr "Left view" + +#: SALOMEGUI_Application.cxx:85 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_MU4" +msgstr "Splits View" + +#: SALOMEGUI_Application.cxx:85 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_TRIHEDRON" +msgstr "Shows \ hides trihedron" + +#: SALOMEGUI_Application.cxx:133 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_PAN" +msgstr "Panning" + +#: SALOMEGUI_Application.cxx:241 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_RESET" +msgstr "Reset" + +#: SALOMEGUI_Application.cxx:229 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_RIGHT" +msgstr "Right view" + +#: SALOMEGUI_Application.cxx:145 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_ROTATE" +msgstr "Rotate view" + +#: SALOMEGUI_Application.cxx:193 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_TOP" +msgstr "Top view" + +#: SALOMEGUI_Application.cxx:121 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_ZOOM" +msgstr "Zoom" + +#: SALOMEGUI_Application.cxx:121 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_DUMP" +msgstr "Camera Dump" + +--------------- + +#: SALOMEGUI_ViewChoiceDlg.cxx:28 +msgid "SALOMEGUI_ViewChoiceDlg::MEN_CHOICE" +msgstr "Choice" + +#: SALOMEGUI_ViewChoiceDlg.cxx:38 +msgid "SALOMEGUI_ViewChoiceDlg::MEN_VIEW" +msgstr "View" + +#: SALOMEGUI_ViewChoiceDlg.cxx:59 +msgid "SALOMEGUI_ViewChoiceDlg::MEN_VIEWER_GRAPH" +msgstr "Graph Supervisor" + +#: SALOMEGUI_ViewChoiceDlg.cxx:57 +msgid "SALOMEGUI_ViewChoiceDlg::MEN_VIEWER_OCC" +msgstr "Open CASCADE Viewer" + +#: SALOMEGUI_ViewChoiceDlg.cxx:53 +msgid "SALOMEGUI_ViewChoiceDlg::MEN_VIEWER_TYPE" +msgstr "Type :" + +#: SALOMEGUI_ViewChoiceDlg.cxx:58 +msgid "SALOMEGUI_ViewChoiceDlg::MEN_VIEWER_VTK" +msgstr "VTK Viewer" + +msgid "SALOMEGUI_ViewChoiceDlg::MEN_VIEWER_PLOT2D" +msgstr "Plot2d Viewer" + +msgid "SALOMEGUI_OpenWith::OPEN_WITH_TLT" +msgstr "Open With" + +msgid "SALOMEGUI_StudyPropertiesDlg::PRP_AUTHOR" +msgstr "Author" + +msgid "SALOMEGUI_StudyPropertiesDlg::PRP_DATE" +msgstr "Created" + +msgid "SALOMEGUI_StudyPropertiesDlg::PRP_MODE" +msgstr "Creation mode" + +msgid "SALOMEGUI_StudyPropertiesDlg::PRP_MODIFIED" +msgstr "Modified" + +msgid "SALOMEGUI_StudyPropertiesDlg::PRP_LOCKED" +msgstr "Locked" + +msgid "SALOMEGUI_TableDlg::VIEW_TABLE_TLT" +msgstr "View Table" + +msgid "SALOMEGUI_TableDlg::EDIT_TABLE_TLT" +msgstr "Edit Table" + +msgid "SALOMEGUI_TableDlg::TABLE_OF_INTEGER_TLT" +msgstr "Table of integer" + +msgid "SALOMEGUI_TableDlg::TABLE_OF_REAL_TLT" +msgstr "Table of real" + +msgid "SALOMEGUI_TableDlg::ERR_TABLE_NOT_AVAILABLE" +msgstr "Table is not available" + +msgid "SALOMEGUI_TableWidget::UNITS_TLT" +msgstr "Units" + +msgid "SALOMEGUI_TableWidget::ADD_ROW_BTN" +msgstr "Add Row" + +msgid "SALOMEGUI_TableWidget::REMOVE_ROW_BTN" +msgstr "Remove Row(s)" + +msgid "SALOMEGUI_TableWidget::ADD_COLUMN_BTN" +msgstr "Add Column" + +msgid "SALOMEGUI_TableWidget::REMOVE_COLUMN_BTN" +msgstr "Remove Column(s)" + +msgid "SALOMEGUI_TableWidget::ADJUST_CELLS_BTN" +msgstr "Adjust Cells" + +msgid "SALOMEGUI_TableWidget::SELECT_ALL_BTN" +msgstr "Select All" + +msgid "SALOMEGUI_TableWidget::CLEAR_BTN" +msgstr "Clear" + +msgid "SALOMEGUI_TableWidget::SET_TITLE_TLT" +msgstr "Set title" + +msgid "SALOMEGUI_TableWidget::TITLE_LBL" +msgstr "Title:" + +msgid "SALOMEGUI_NameDlg::TLT_RENAME" +msgstr "Rename" + +msgid "SALOMEGUI_NameDlg::NAME_LBL" +msgstr "Name:" + +msgid "TLT_SETVALUE" +msgstr "Set Value" + +msgid "VALUE_LBL" +msgstr "Value:" + +msgid "TLT_SETUP_PLOT2D" +msgstr "Setup Plot 2d" + +msgid "AUTO_CHECK_LBL" +msgstr "Auto assign" + +msgid "NONE_LINE_LBL" +msgstr "None" + +msgid "SOLID_LINE_LBL" +msgstr "Solid" + +msgid "DASH_LINE_LBL" +msgstr "Dash" + +msgid "DOT_LINE_LBL" +msgstr "Dot" + +msgid "DASHDOT_LINE_LBL" +msgstr "DashDot" + +msgid "DAHSDOTDOT_LINE_LBL" +msgstr "DashDotDot" + +msgid "NONE_MARKER_LBL" +msgstr "None" + +msgid "CIRCLE_MARKER_LBL" +msgstr "Circle" + +msgid "RECTANGLE_MARKER_LBL" +msgstr "Rectangle" + +msgid "DIAMOND_MARKER_LBL" +msgstr "Diamond" + +msgid "DTRIANGLE_MARKER_LBL" +msgstr "Downward triangle" + +msgid "UTRIANGLE_MARKER_LBL" +msgstr "Upward triangle" + +msgid "LTRIANGLE_MARKER_LBL" +msgstr "Leftward triangle" + +msgid "RTRIANGLE_MARKER_LBL" +msgstr "Rightward triangle" + +msgid "CROSS_MARKER_LBL" +msgstr "Cross" + +msgid "XCROSS_MARKER_LBL" +msgstr "Diagonal cross" + +msgid "AXIS_LBL" +msgstr "Axis" + +msgid "DATA_LBL" +msgstr "Data" + +msgid "UNITS_LBL" +msgstr "Units" + +msgid "ATTRIBUTES_LBL" +msgstr "Attributes" + +msgid "QUE_WANT_SAME_UNITS" +msgstr "Do you want to choose all items with the same units for vertical axis?" + +msgid "PLOT_2D_TLT" +msgstr "Plot 2D" + +msgid "TLT_SETUP_PLOT2D_VIEW" +msgstr "Plot 2d View Settings" + +msgid "PLOT2D_ENABLE_MAIN_TITLE" +msgstr "Main title" + +msgid "PLOT2D_ENABLE_HOR_TITLE" +msgstr "Horizontal axis title" + +msgid "PLOT2D_ENABLE_VER_TITLE" +msgstr "Vertical axis title" + +msgid "PLOT2D_CURVE_TYPE_LBL" +msgstr "Curve type:" + +msgid "PLOT2D_CURVE_TYPE_POINTS" +msgstr "Points" + +msgid "PLOT2D_CURVE_TYPE_LINES" +msgstr "Lines" + +msgid "PLOT2D_CURVE_TYPE_SPLINE" +msgstr "Spline" + +msgid "PLOT2D_ENABLE_LEGEND" +msgstr "Show legend" + +msgid "PLOT2D_LEGEND_POSITION_LEFT" +msgstr "Left" + +msgid "PLOT2D_LEGEND_POSITION_RIGHT" +msgstr "Right" + +msgid "PLOT2D_LEGEND_POSITION_TOP" +msgstr "Top" + +msgid "PLOT2D_LEGEND_POSITION_BOTTOM" +msgstr "Bottom" + +msgid "PLOT2D_MARKER_SIZE_LBL" +msgstr "Marker size:" + +msgid "PLOT2D_BACKGROUND_COLOR_LBL" +msgstr "Background color:" + +msgid "PLOT2D_SCALE_TLT" +msgstr "Scale mode" + +msgid "PLOT2D_SCALE_MODE_HOR" +msgstr "Horizontal axis:" + +msgid "PLOT2D_SCALE_MODE_VER" +msgstr "Vertical axis:" + +msgid "PLOT2D_SCALE_MODE_LINEAR" +msgstr "Linear" + +msgid "PLOT2D_SCALE_MODE_LOGARITHMIC" +msgstr "Logarithmic" + +msgid "PLOT2D_GRID_TLT" +msgstr "Grid / Axes marks" + +msgid "PLOT2D_GRID_ENABLE_HOR_MAJOR" +msgstr "Horizontal major" + +msgid "PLOT2D_GRID_ENABLE_VER_MAJOR" +msgstr "Vertical major" + +msgid "PLOT2D_GRID_ENABLE_HOR_MINOR" +msgstr "Horizontal minor" + +msgid "PLOT2D_GRID_ENABLE_VER_MINOR" +msgstr "Vertical minor" + +msgid "PLOT2D_SET_AS_DEFAULT_CHECK" +msgstr "Save settings as default" + +msgid "TOT_PLOT2D_FIT_ALL" +msgstr "Fit All" +msgid "MEN_PLOT2D_FIT_ALL" +msgstr "&Fit All" +msgid "PRP_PLOT2D_FIT_ALL" +msgstr "Fits view to show all curves" +msgid "TOT_PLOT2D_FIT_AREA" +msgstr "Fit Area" +msgid "MEN_PLOT2D_FIT_AREA" +msgstr "Fit &Area" +msgid "PRP_PLOT2D_FIT_AREA" +msgstr "Fits the view within an area" +msgid "TOT_PLOT2D_ZOOM" +msgstr "Zoom" +msgid "MEN_PLOT2D_ZOOM" +msgstr "&Zoom view" +msgid "PRP_PLOT2D_ZOOM" +msgstr "Zooms the view" +msgid "TOT_PLOT2D_PAN" +msgstr "Panning" +msgid "MEN_PLOT2D_PAN" +msgstr "&Pan view" +msgid "PRP_PLOT2D_PAN" +msgstr "Moves curves in the view" +msgid "TOT_PLOT2D_DUMP" +msgstr "Camera Dump" +msgid "MEN_PLOT2D_DUMP" +msgstr "Camera &Dump" +msgid "PRP_PLOT2D_DUMP" +msgstr "Saves view contents in the image file" +msgid "SCALING_POPUP" +msgstr "Scaling" +msgid "TOT_PLOT2D_MODE_LINEAR_HOR" +msgstr "Horizontal axis: linear" +msgid "MEN_PLOT2D_MODE_LINEAR_HOR" +msgstr "Horizontal axis: linear" +msgid "PRP_PLOT2D_MODE_LINEAR_HOR" +msgstr "Switches view to linear scaling mode along horizontal axis" +msgid "TOT_PLOT2D_MODE_LOGARITHMIC_HOR" +msgstr "Horizontal axis: logarithmic" +msgid "MEN_PLOT2D_MODE_LOGARITHMIC_HOR" +msgstr "Horizontal axis: logarithmic" +msgid "PRP_PLOT2D_MODE_LOGARITHMIC_HOR" +msgstr "Switches view to logarithmic scaling mode along horizontal axis" +msgid "TOT_PLOT2D_MODE_LINEAR_VER" +msgstr "Vertical axis: linear" +msgid "MEN_PLOT2D_MODE_LINEAR_VER" +msgstr "Vertical axis: linear" +msgid "PRP_PLOT2D_MODE_LINEAR_VER" +msgstr "Switches view to linear scaling mode along vertical axis" +msgid "TOT_PLOT2D_MODE_LOGARITHMIC_VER" +msgstr "Vertical axis: logarithmic" +msgid "MEN_PLOT2D_MODE_LOGARITHMIC_VER" +msgstr "Vertical axis: logarithmic" +msgid "PRP_PLOT2D_MODE_LOGARITHMIC_VER" +msgstr "Switches view to logarithmic scaling mode along vertical axis" +msgid "TOT_PLOT2D_SHOW_LEGEND" +msgstr "Show Legend" +msgid "MEN_PLOT2D_SHOW_LEGEND" +msgstr "Show &Legend" +msgid "PRP_PLOT2D_SHOW_LEGEND" +msgstr "Enables/disables legend" +msgid "CURVE_TYPE_POPUP" +msgstr "Curve type" +msgid "TOT_PLOT2D_CURVES_POINTS" +msgstr "Draw points" +msgid "MEN_PLOT2D_CURVES_POINTS" +msgstr "Draw points" +msgid "PRP_PLOT2D_CURVES_POINTS" +msgstr "Switches view to points mode" +msgid "TOT_PLOT2D_CURVES_LINES" +msgstr "Draw lines" +msgid "MEN_PLOT2D_CURVES_LINES" +msgstr "Draw lines" +msgid "PRP_PLOT2D_CURVES_LINES" +msgstr "Switches view to lines mode" +msgid "TOT_PLOT2D_CURVES_SPLINES" +msgstr "Draw splines" +msgid "MEN_PLOT2D_CURVES_SPLINES" +msgstr "Draw splines" +msgid "PRP_PLOT2D_CURVES_SPLINES" +msgstr "Switches view to splines mode" +msgid "TOT_PLOT2D_SETTINGS" +msgstr "Settings" +msgid "MEN_PLOT2D_SETTINGS" +msgstr "&Settings" +msgid "PRP_PLOT2D_SETTINGS" +msgstr "Setups view properties" + +msgid "INF_COORDINATES" +msgstr "Coordinates" + +msgid "SALOMEGUI_SetupCurveDlg::TLT_SETUP_CURVE" +msgstr "Setup Curve" +msgid "SALOMEGUI_SetupCurveDlg::CURVE_LINE_TYPE_LAB" +msgstr "Line type:" +msgid "SALOMEGUI_SetupCurveDlg::CURVE_LINE_WIDTH_LAB" +msgstr "Line width:" +msgid "SALOMEGUI_SetupCurveDlg::CURVE_MARKER_TYPE_LAB" +msgstr "Marker type:" +msgid "SALOMEGUI_SetupCurveDlg::CURVE_COLOR_LAB" +msgstr "Color:" +msgid "SALOMEGUI_CloseDlg::CAPTION" +msgstr "Close active study" + +msgid "SALOMEGUI_CloseDlg::SAVE_CLOSE" +msgstr "&Save&&Close" + +msgid "SALOMEGUI_CloseDlg::CLOSE" +msgstr "C&lose w/o saving" + +msgid "SALOMEGUI_CloseDlg::UNLOAD" +msgstr "&Unload" + +msgid "SALOMEGUI_CloseDlg::CANCEL" +msgstr "&Cancel" + +msgid "SALOMEGUI_CloseDlg::CLOSE_DESCRIPTION" +msgstr "Do you want to close or only unload the study ?" + +msgid "SALOMEGUI_HELP_TITLE" +msgstr "SALOME Professional Help" diff --git a/src/SALOMEGUI/SALOMEGUI_msg_fr.po b/src/SALOMEGUI/SALOMEGUI_msg_fr.po new file mode 100644 index 000000000..f2c33bb51 --- /dev/null +++ b/src/SALOMEGUI/SALOMEGUI_msg_fr.po @@ -0,0 +1,299 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: example-Qt-message-extraction\n" +"POT-Creation-Date: 1999-02-23 15:38+0200\n" +"PO-Revision-Date: 1999-02-23 15:38+0200\n" +"Last-Translator: \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +#--------------- +# BUTTONS +#--------------- + +msgid "BUT_OK" +msgstr "Ok" + +msgid "BUT_HELP" +msgstr "Aide" + +msgid "BUT_CANCEL" +msgstr "Annule" + +#--------------- +# ERROR +#--------------- + +#: SALOMEGUI.cxx:45 +msgid "QObject::ERR_APP_INITFAILED" +msgstr "Echec d'Initialisation" + +#: SALOMEGUI.cxx:44 +msgid "ERR_ERROR" +msgstr "Erreur" + +#: SALOMEGUI_Application.cxx:672 +msgid "ERR_APP_WRONG_VIEW_TYPE" +msgstr "La vue appropriée doit étre créée pour afficher l'objet choisi" + +#--------------- +# INFORMATIONS +#--------------- + +msgid "INF_VERSION" +msgstr "Version 1.0" + +msgid "INF_COPYRIGHT" +msgstr "Copyright (C) 2002" + +msgid "INF_LICENSE" +msgstr "All rights reserved" + + +#--------------- +# MENUS +#--------------- + +#: SALOMEGUI_TrihedronSizeDlg.cxx:77 +msgid "SALOMEGUI_TrihedronSizeDlg::MEN_TRIHEDRON_SIZE" +msgstr "Size :" + +#: SALOMEGUI_TrihedronSizeDlg.cxx:36 +msgid "SALOMEGUI_TrihedronSizeDlg::MEN_TRIHEDRON" +msgstr "Trihedron" + +#: SALOMEGUI_OpenWith.cxx:37 +msgid "SALOMEGUI_OpenWith::MEN_COMPONENT_CHOICE1" +msgstr "Always use this component to open this type of object" + +#: SALOMEGUI_OpenWith.cxx:65 +msgid "SALOMEGUI_OpenWith::MEN_COMPONENT_CHOICE2" +msgstr "Choose the component you want to use :" + +#: SALOMEGUI_OpenWith.cxx:33 +msgid "SALOMEGUI_OpenWith::MEN_COMPONENT_CHOICE3" +msgstr "Choose the component you want to use to open objects :" + +#: SALOMEGUI_LoadStudiesDlg.cxx:27 +msgid "SALOMEGUI_LoadStudiesDlg::MEN_STUDIES_CHOICE" +msgstr "Choose existing study." + +#: SALOMEGUI_Application.cxx:87 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_MU4" +msgstr "Multiple Vue" + +#: SALOMEGUI_Application.cxx:135 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_PAN" +msgstr "&Pan Vue\tCtrl+MB2" + +#: SALOMEGUI_Application.cxx:243 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_RESET" +msgstr "R&estaure la Vue" + +#: SALOMEGUI_Application.cxx:231 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_RIGHT" +msgstr "Vue D&roite" + +#: SALOMEGUI_Application.cxx:147 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_ROTATE" +msgstr "R&otation Vue\tCtrl+MB3" + +#: SALOMEGUI_Application.cxx:195 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_TOP" +msgstr "&Top Vue" + +#: SALOMEGUI_Application.cxx:75 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_TRIHEDRON" +msgstr "Afficher - Masquer OXYZ" + +#: SALOMEGUI_Application.cxx:123 +msgid "SALOMEGUI_Application::MEN_APP_VIEW_ZOOM" +msgstr "&Zoom \tCtrl+MB1" + +msgid "SALOMEGUI_Application::MEN_APP_VIEW_FITALL" +msgstr "&Fit All" + +msgid "SALOMEGUI_Application::MEN_APP_VIEW_FITAREA" +msgstr "Fit &Area" + +msgid "SALOMEGUI_Application::MEN_APP_VIEW_FRONT" +msgstr "&Premier Plan" + +msgid "SALOMEGUI_Application::MEN_APP_VIEW_GLOBALPAN" +msgstr "&Global Pan Vue" + +msgid "SALOMEGUI_Application::MEN_APP_VIEW_BACK" +msgstr "Arrière plan" + +msgid "SALOMEGUI_Application::MEN_APP_VIEW_BOTTOM" +msgstr "&Vue du dessous" + +msgid "SALOMEGUI_Application::MEN_APP_VIEW_LEFT" +msgstr "&Vue gauche" + +#--------------- +# PRP +#--------------- + +#: SALOMEGUI_Application.cxx:185 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_TRIHEDRON" +msgstr "Afficher \ masquer OXYZ" + +#: SALOMEGUI_Application.cxx:185 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_BACK" +msgstr "Affiche la vue arrière des objets" + +#: SALOMEGUI_Application.cxx:209 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_BOTTOM" +msgstr "Affiche la vue du dessous des objets" + +#: SALOMEGUI_Application.cxx:101 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_FITALL" +msgstr "Fits all the objects in the view" + +#: SALOMEGUI_Application.cxx:113 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_FITAREA" +msgstr "Fits the view within an area" + +#: SALOMEGUI_Application.cxx:173 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_FRONT" +msgstr "Affiche la vue de face des objets" + +#: SALOMEGUI_Application.cxx:161 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_GLOBALPAN" +msgstr "Définir le centre de la vue" + +#: SALOMEGUI_Application.cxx:221 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_LEFT" +msgstr "Affiche la vue gauche des objets" + +#: SALOMEGUI_Application.cxx:89 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_MU4" +msgstr "Fractionner la vue" + +#: SALOMEGUI_Application.cxx:137 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_PAN" +msgstr "Déplacer les objets" + +#: SALOMEGUI_Application.cxx:245 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_RESET" +msgstr "Restaure la vue" + +#: SALOMEGUI_Application.cxx:233 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_RIGHT" +msgstr "Affiche la vue droite des objets" + +#: SALOMEGUI_Application.cxx:149 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_ROTATE" +msgstr "Rotation des objets" + +#: SALOMEGUI_Application.cxx:197 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_TOP" +msgstr "Affiche la vue supérieure des objets" + +#: SALOMEGUI_Application.cxx:125 +msgid "SALOMEGUI_Application::PRP_APP_VIEW_ZOOM" +msgstr "Zoom la vue active" + +#--------------- +# TOOL TIP +#--------------- + +#: SALOMEGUI_Application.cxx:181 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_BACK" +msgstr "Arrière plan" + +#: SALOMEGUI_Application.cxx:205 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_BOTTOM" +msgstr "Vue du dessous" + +#: SALOMEGUI_Application.cxx:97 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_FITALL" +msgstr "Fit all" + +#: SALOMEGUI_Application.cxx:109 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_FITAREA" +msgstr "Fit within rectangle" + +#: SALOMEGUI_Application.cxx:169 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_FRONT" +msgstr "Premier plan" + +#: SALOMEGUI_Application.cxx:157 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_GLOBALPAN" +msgstr "Global panning" + +#: SALOMEGUI_Application.cxx:217 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_LEFT" +msgstr "Vue gauche" + +#: SALOMEGUI_Application.cxx:85 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_MU4" +msgstr "Fractionner la vue" + +#: SALOMEGUI_Application.cxx:85 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_TRIHEDRON" +msgstr "Afficher \ masquer trihedron" + +#: SALOMEGUI_Application.cxx:133 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_PAN" +msgstr "Panning" + +#: SALOMEGUI_Application.cxx:241 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_RESET" +msgstr "Restaure" + +#: SALOMEGUI_Application.cxx:229 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_RIGHT" +msgstr "Vue droite" + +#: SALOMEGUI_Application.cxx:145 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_ROTATE" +msgstr "Vue de la rotation" + +#: SALOMEGUI_Application.cxx:193 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_TOP" +msgstr "Top view" + +#: SALOMEGUI_Application.cxx:121 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_ZOOM" +msgstr "Zoom" + +#: SALOMEGUI_Application.cxx:121 +msgid "SALOMEGUI_Application::TOT_APP_VIEW_DUMP" +msgstr "Capture du Viewer" + +--------------- + +#: SALOMEGUI_ViewChoiceDlg.cxx:28 +msgid "SALOMEGUI_ViewChoiceDlg::MEN_CHOICE" +msgstr "Choix" + +#: SALOMEGUI_ViewChoiceDlg.cxx:38 +msgid "SALOMEGUI_ViewChoiceDlg::MEN_VIEW" +msgstr "Vue" + +#: SALOMEGUI_ViewChoiceDlg.cxx:59 +msgid "SALOMEGUI_ViewChoiceDlg::MEN_VIEWER_GRAPH" +msgstr "Graphe Supervision" + +#: SALOMEGUI_ViewChoiceDlg.cxx:57 +msgid "SALOMEGUI_ViewChoiceDlg::MEN_VIEWER_OCC" +msgstr "Open CASCADE Viewer" + +#: SALOMEGUI_ViewChoiceDlg.cxx:53 +msgid "SALOMEGUI_ViewChoiceDlg::MEN_VIEWER_TYPE" +msgstr "Type :" + +#: SALOMEGUI_ViewChoiceDlg.cxx:58 +msgid "SALOMEGUI_ViewChoiceDlg::MEN_VIEWER_VTK" +msgstr "VTK Viewer" + +#: SALOMEGUI_AboutDlg.cxx:42 +msgid "ABOUT_SALOME_TLT" +msgstr "About SALOME Professional" + +msgid "SALOMEGUI_OpenWith::OPEN_WITH_TLT" +msgstr "Open With" diff --git a/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx b/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx new file mode 100644 index 000000000..604840740 --- /dev/null +++ b/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx @@ -0,0 +1,104 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_HeaderFile +#define _SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_HeaderFile + +#ifndef _TCollection_BasicMapIterator_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class SALOME_InteractiveObject; +class TColStd_MapOfInteger; +class TColStd_MapTransientHasher; +class SALOME_DataMapOfIOMapOfInteger; +class SALOME_DataMapNodeOfDataMapOfIOMapOfInteger; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger : public TCollection_BasicMapIterator { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +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; + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_0.cxx b/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_0.cxx new file mode 100644 index 000000000..06564d69b --- /dev/null +++ b/src/SALOMEGUI/SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_0.cxx @@ -0,0 +1,53 @@ +using namespace std; +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx" + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _SALOME_InteractiveObject_HeaderFile +#include "SALOME_InteractiveObject.hxx" +#endif +#ifndef _TColStd_MapOfInteger_HeaderFile +#include +#endif +#ifndef _TColStd_MapTransientHasher_HeaderFile +#include +#endif +#ifndef _SALOME_DataMapOfIOMapOfInteger_HeaderFile +#include "SALOME_DataMapOfIOMapOfInteger.hxx" +#endif +#ifndef _SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_HeaderFile +#include "SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx" +#endif + + +#define TheKey Handle_SALOME_InteractiveObject +#define TheKey_hxx "SALOME_InteractiveObject.hxx" +#define TheItem TColStd_MapOfInteger +#define TheItem_hxx +#define Hasher TColStd_MapTransientHasher +#define Hasher_hxx +#define TCollection_DataMapNode SALOME_DataMapNodeOfDataMapOfIOMapOfInteger +#define TCollection_DataMapNode_hxx "SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx" +#define TCollection_DataMapIterator SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger +#define TCollection_DataMapIterator_hxx "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx" +#define Handle_TCollection_DataMapNode Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger +#define TCollection_DataMapNode_Type_() SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_Type_() +#define TCollection_DataMap SALOME_DataMapOfIOMapOfInteger +#define TCollection_DataMap_hxx "SALOME_DataMapOfIOMapOfInteger.hxx" +#include + diff --git a/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx b/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx new file mode 100644 index 000000000..209c96872 --- /dev/null +++ b/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx @@ -0,0 +1,142 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_HeaderFile +#define _SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_HeaderFile +#include +#endif + +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif +#ifndef _TColStd_MapOfInteger_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class SALOME_InteractiveObject; +class TColStd_MapOfInteger; +class TColStd_MapTransientHasher; +class SALOME_DataMapOfIOMapOfInteger; +class SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger; + + +class SALOME_DataMapNodeOfDataMapOfIOMapOfInteger : public TCollection_MapNode { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT inline SALOME_DataMapNodeOfDataMapOfIOMapOfInteger(const Handle(SALOME_InteractiveObject)& K,const TColStd_MapOfInteger& I,const TCollection_MapNodePtr& n); +Standard_EXPORT inline Handle_SALOME_InteractiveObject& Key() const; +Standard_EXPORT inline TColStd_MapOfInteger& Value() const; +Standard_EXPORT ~SALOME_DataMapNodeOfDataMapOfIOMapOfInteger(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Handle_SALOME_InteractiveObject myKey; +TColStd_MapOfInteger myValue; + + +}; + +#define TheKey Handle_SALOME_InteractiveObject +#define TheKey_hxx "SALOME_InteractiveObject.hxx" +#define TheItem TColStd_MapOfInteger +#define TheItem_hxx +#define Hasher TColStd_MapTransientHasher +#define Hasher_hxx +#define TCollection_DataMapNode SALOME_DataMapNodeOfDataMapOfIOMapOfInteger +#define TCollection_DataMapNode_hxx "SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx" +#define TCollection_DataMapIterator SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger +#define TCollection_DataMapIterator_hxx "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx" +#define Handle_TCollection_DataMapNode Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger +#define TCollection_DataMapNode_Type_() SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_Type_() +#define TCollection_DataMap SALOME_DataMapOfIOMapOfInteger +#define TCollection_DataMap_hxx "SALOME_DataMapOfIOMapOfInteger.hxx" + +#include + +#undef TheKey +#undef TheKey_hxx +#undef TheItem +#undef TheItem_hxx +#undef Hasher +#undef Hasher_hxx +#undef TCollection_DataMapNode +#undef TCollection_DataMapNode_hxx +#undef TCollection_DataMapIterator +#undef TCollection_DataMapIterator_hxx +#undef Handle_TCollection_DataMapNode +#undef TCollection_DataMapNode_Type_ +#undef TCollection_DataMap +#undef TCollection_DataMap_hxx + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_0.cxx b/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_0.cxx new file mode 100644 index 000000000..4d7b1fdda --- /dev/null +++ b/src/SALOMEGUI/SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_0.cxx @@ -0,0 +1,102 @@ +using namespace std; +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _SALOME_InteractiveObject_HeaderFile +#include "SALOME_InteractiveObject.hxx" +#endif +#ifndef _TColStd_MapOfInteger_HeaderFile +#include +#endif +#ifndef _TColStd_MapTransientHasher_HeaderFile +#include +#endif +#ifndef _SALOME_DataMapOfIOMapOfInteger_HeaderFile +#include "SALOME_DataMapOfIOMapOfInteger.hxx" +#endif +#ifndef _SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_HeaderFile +#include "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx" +#endif +SALOME_DataMapNodeOfDataMapOfIOMapOfInteger::~SALOME_DataMapNodeOfDataMapOfIOMapOfInteger() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TCollection_MapNode); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TCollection_MapNode); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOME_DataMapNodeOfDataMapOfIOMapOfInteger", + sizeof(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger) Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger))) { + _anOtherObject = Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger)((Handle(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOME_DataMapNodeOfDataMapOfIOMapOfInteger::DynamicType() const +{ + return STANDARD_TYPE(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger) ; +} +Standard_Boolean SALOME_DataMapNodeOfDataMapOfIOMapOfInteger::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOME_DataMapNodeOfDataMapOfIOMapOfInteger) == AType || TCollection_MapNode::IsKind(AType)); +} +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 Hasher TColStd_MapTransientHasher +#define Hasher_hxx +#define TCollection_DataMapNode SALOME_DataMapNodeOfDataMapOfIOMapOfInteger +#define TCollection_DataMapNode_hxx "SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx" +#define TCollection_DataMapIterator SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger +#define TCollection_DataMapIterator_hxx "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx" +#define Handle_TCollection_DataMapNode Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger +#define TCollection_DataMapNode_Type_() SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_Type_() +#define TCollection_DataMap SALOME_DataMapOfIOMapOfInteger +#define TCollection_DataMap_hxx "SALOME_DataMapOfIOMapOfInteger.hxx" +#include + diff --git a/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger.hxx b/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger.hxx new file mode 100644 index 000000000..dc17b84e5 --- /dev/null +++ b/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger.hxx @@ -0,0 +1,136 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _SALOME_DataMapOfIOMapOfInteger_HeaderFile +#define _SALOME_DataMapOfIOMapOfInteger_HeaderFile + +#ifndef _TCollection_BasicMap_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_DomainError; +class Standard_NoSuchObject; +class SALOME_InteractiveObject; +class TColStd_MapOfInteger; +class TColStd_MapTransientHasher; +class SALOME_DataMapNodeOfDataMapOfIOMapOfInteger; +class SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOME_DataMapOfIOMapOfInteger : public TCollection_BasicMap { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT SALOME_DataMapOfIOMapOfInteger(const Standard_Integer NbBuckets = 1); +Standard_EXPORT SALOME_DataMapOfIOMapOfInteger& Assign(const SALOME_DataMapOfIOMapOfInteger& Other) ; + SALOME_DataMapOfIOMapOfInteger& operator =(const SALOME_DataMapOfIOMapOfInteger& Other) +{ + return Assign(Other); +} + +Standard_EXPORT void ReSize(const Standard_Integer NbBuckets) ; +Standard_EXPORT void Clear() ; +~SALOME_DataMapOfIOMapOfInteger() +{ + Clear(); +} + +Standard_EXPORT Standard_Boolean Bind(const Handle(SALOME_InteractiveObject)& K,const TColStd_MapOfInteger& 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 +{ + return Find(K); +} + +Standard_EXPORT TColStd_MapOfInteger& ChangeFind(const Handle(SALOME_InteractiveObject)& K) ; + TColStd_MapOfInteger& operator()(const Handle(SALOME_InteractiveObject)& K) +{ + return ChangeFind(K); +} + + + + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT SALOME_DataMapOfIOMapOfInteger(const SALOME_DataMapOfIOMapOfInteger& Other); + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger_0.cxx b/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger_0.cxx new file mode 100644 index 000000000..915af9c34 --- /dev/null +++ b/src/SALOMEGUI/SALOME_DataMapOfIOMapOfInteger_0.cxx @@ -0,0 +1,56 @@ +using namespace std; +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_DataMapOfIOMapOfInteger.hxx" + +#ifndef _Standard_DomainError_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _SALOME_InteractiveObject_HeaderFile +#include "SALOME_InteractiveObject.hxx" +#endif +#ifndef _TColStd_MapOfInteger_HeaderFile +#include +#endif +#ifndef _TColStd_MapTransientHasher_HeaderFile +#include +#endif +#ifndef _SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_HeaderFile +#include "SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx" +#endif +#ifndef _SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger_HeaderFile +#include "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx" +#endif + + +#define TheKey Handle_SALOME_InteractiveObject +#define TheKey_hxx "SALOME_InteractiveObject.hxx" +#define TheItem TColStd_MapOfInteger +#define TheItem_hxx +#define Hasher TColStd_MapTransientHasher +#define Hasher_hxx +#define TCollection_DataMapNode SALOME_DataMapNodeOfDataMapOfIOMapOfInteger +#define TCollection_DataMapNode_hxx "SALOME_DataMapNodeOfDataMapOfIOMapOfInteger.hxx" +#define TCollection_DataMapIterator SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger +#define TCollection_DataMapIterator_hxx "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx" +#define Handle_TCollection_DataMapNode Handle_SALOME_DataMapNodeOfDataMapOfIOMapOfInteger +#define TCollection_DataMapNode_Type_() SALOME_DataMapNodeOfDataMapOfIOMapOfInteger_Type_() +#define TCollection_DataMap SALOME_DataMapOfIOMapOfInteger +#define TCollection_DataMap_hxx "SALOME_DataMapOfIOMapOfInteger.hxx" +#include + diff --git a/src/SALOMEGUI/SALOME_Filter.cxx b/src/SALOMEGUI/SALOME_Filter.cxx new file mode 100644 index 000000000..17b9c5992 --- /dev/null +++ b/src/SALOMEGUI/SALOME_Filter.cxx @@ -0,0 +1,11 @@ +using namespace std; +// File : SALOME_Filter.cxx +// Created : Wed Feb 20 17:24:59 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOME_Filter.ixx" + diff --git a/src/SALOMEGUI/SALOME_Filter.hxx b/src/SALOMEGUI/SALOME_Filter.hxx new file mode 100644 index 000000000..ec8f831e8 --- /dev/null +++ b/src/SALOMEGUI/SALOME_Filter.hxx @@ -0,0 +1,100 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _SALOME_Filter_HeaderFile +#define _SALOME_Filter_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_Filter_HeaderFile +#include +#endif + +#ifndef _MMgt_TShared_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif + +class SALOME_Filter : public MMgt_TShared { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anObj) const = 0; +Standard_EXPORT ~SALOME_Filter(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOME_Filter_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEGUI/SALOME_Filter.ixx b/src/SALOMEGUI/SALOME_Filter.ixx new file mode 100644 index 000000000..71639eeb9 --- /dev/null +++ b/src/SALOMEGUI/SALOME_Filter.ixx @@ -0,0 +1,69 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_Filter.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOME_Filter::~SALOME_Filter() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOME_Filter_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(MMgt_TShared); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType2 = STANDARD_TYPE(Standard_Transient); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOME_Filter", + sizeof(SALOME_Filter), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOME_Filter) Handle(SALOME_Filter)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOME_Filter) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOME_Filter))) { + _anOtherObject = Handle(SALOME_Filter)((Handle(SALOME_Filter)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOME_Filter::DynamicType() const +{ + return STANDARD_TYPE(SALOME_Filter) ; +} +Standard_Boolean SALOME_Filter::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOME_Filter) == AType || MMgt_TShared::IsKind(AType)); +} +Handle_SALOME_Filter::~Handle_SALOME_Filter() {} + diff --git a/src/SALOMEGUI/SALOME_Filter.jxx b/src/SALOMEGUI/SALOME_Filter.jxx new file mode 100644 index 000000000..61a179f47 --- /dev/null +++ b/src/SALOMEGUI/SALOME_Filter.jxx @@ -0,0 +1,3 @@ +#ifndef _SALOME_Filter_HeaderFile +#include "SALOME_Filter.hxx" +#endif diff --git a/src/SALOMEGUI/SALOME_ListIO.hxx b/src/SALOMEGUI/SALOME_ListIO.hxx new file mode 100644 index 000000000..498241daf --- /dev/null +++ b/src/SALOMEGUI/SALOME_ListIO.hxx @@ -0,0 +1,151 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _SALOME_ListIO_HeaderFile +#define _SALOME_ListIO_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_ListNodeOfListIO_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class SALOME_ListIteratorOfListIO; +class SALOME_InteractiveObject; +class SALOME_ListNodeOfListIO; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOME_ListIO { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT SALOME_ListIO(); +Standard_EXPORT void Assign(const SALOME_ListIO& Other) ; + void operator=(const SALOME_ListIO& Other) +{ + Assign(Other); +} + +Standard_EXPORT Standard_Integer Extent() const; +Standard_EXPORT void Clear() ; +~SALOME_ListIO() +{ + Clear(); +} + +Standard_EXPORT Standard_Boolean IsEmpty() const; +Standard_EXPORT void Prepend(const Handle(SALOME_InteractiveObject)& I) ; +Standard_EXPORT void Prepend(SALOME_ListIO& Other) ; +Standard_EXPORT void Append(const Handle(SALOME_InteractiveObject)& I) ; +Standard_EXPORT void Append(SALOME_ListIO& Other) ; +Standard_EXPORT Handle_SALOME_InteractiveObject& First() const; +Standard_EXPORT Handle_SALOME_InteractiveObject& Last() const; +Standard_EXPORT void RemoveFirst() ; +Standard_EXPORT void Remove(SALOME_ListIteratorOfListIO& It) ; +Standard_EXPORT void InsertBefore(const Handle(SALOME_InteractiveObject)& I,SALOME_ListIteratorOfListIO& It) ; +Standard_EXPORT void InsertBefore(SALOME_ListIO& Other,SALOME_ListIteratorOfListIO& It) ; +Standard_EXPORT void InsertAfter(const Handle(SALOME_InteractiveObject)& I,SALOME_ListIteratorOfListIO& It) ; +Standard_EXPORT void InsertAfter(SALOME_ListIO& Other,SALOME_ListIteratorOfListIO& It) ; + + +friend class SALOME_ListIteratorOfListIO; + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT SALOME_ListIO(const SALOME_ListIO& Other); + + + // Fields PRIVATE + // +Standard_Address myFirst; +Standard_Address myLast; + + +}; + +#define Item Handle_SALOME_InteractiveObject +#define Item_hxx "SALOME_InteractiveObject.hxx" +#define TCollection_ListNode SALOME_ListNodeOfListIO +#define TCollection_ListNode_hxx "SALOME_ListNodeOfListIO.hxx" +#define TCollection_ListIterator SALOME_ListIteratorOfListIO +#define TCollection_ListIterator_hxx "SALOME_ListIteratorOfListIO.hxx" +#define Handle_TCollection_ListNode Handle_SALOME_ListNodeOfListIO +#define TCollection_ListNode_Type_() SALOME_ListNodeOfListIO_Type_() +#define TCollection_List SALOME_ListIO +#define TCollection_List_hxx "SALOME_ListIO.hxx" + +#include + +#undef Item +#undef Item_hxx +#undef TCollection_ListNode +#undef TCollection_ListNode_hxx +#undef TCollection_ListIterator +#undef TCollection_ListIterator_hxx +#undef Handle_TCollection_ListNode +#undef TCollection_ListNode_Type_ +#undef TCollection_List +#undef TCollection_List_hxx + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEGUI/SALOME_ListIO_0.cxx b/src/SALOMEGUI/SALOME_ListIO_0.cxx new file mode 100644 index 000000000..e93ad65fe --- /dev/null +++ b/src/SALOMEGUI/SALOME_ListIO_0.cxx @@ -0,0 +1,43 @@ +using namespace std; +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_ListIO.hxx" + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _SALOME_ListIteratorOfListIO_HeaderFile +#include "SALOME_ListIteratorOfListIO.hxx" +#endif +#ifndef _SALOME_InteractiveObject_HeaderFile +#include "SALOME_InteractiveObject.hxx" +#endif +#ifndef _SALOME_ListNodeOfListIO_HeaderFile +#include "SALOME_ListNodeOfListIO.hxx" +#endif + + +#define Item Handle_SALOME_InteractiveObject +#define Item_hxx "SALOME_InteractiveObject.hxx" +#define TCollection_ListNode SALOME_ListNodeOfListIO +#define TCollection_ListNode_hxx "SALOME_ListNodeOfListIO.hxx" +#define TCollection_ListIterator SALOME_ListIteratorOfListIO +#define TCollection_ListIterator_hxx "SALOME_ListIteratorOfListIO.hxx" +#define Handle_TCollection_ListNode Handle_SALOME_ListNodeOfListIO +#define TCollection_ListNode_Type_() SALOME_ListNodeOfListIO_Type_() +#define TCollection_List SALOME_ListIO +#define TCollection_List_hxx "SALOME_ListIO.hxx" +#include + diff --git a/src/SALOMEGUI/SALOME_ListIteratorOfListIO.hxx b/src/SALOMEGUI/SALOME_ListIteratorOfListIO.hxx new file mode 100644 index 000000000..2d7c88b3f --- /dev/null +++ b/src/SALOMEGUI/SALOME_ListIteratorOfListIO.hxx @@ -0,0 +1,127 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _SALOME_ListIteratorOfListIO_HeaderFile +#define _SALOME_ListIteratorOfListIO_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_ListNodeOfListIO_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_NoMoreObject; +class Standard_NoSuchObject; +class SALOME_ListIO; +class SALOME_InteractiveObject; +class SALOME_ListNodeOfListIO; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOME_ListIteratorOfListIO { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +Standard_EXPORT SALOME_ListIteratorOfListIO(); +Standard_EXPORT SALOME_ListIteratorOfListIO(const SALOME_ListIO& L); +Standard_EXPORT void Initialize(const SALOME_ListIO& L) ; +Standard_EXPORT Standard_Boolean More() const; +Standard_EXPORT void Next() ; +Standard_EXPORT Handle_SALOME_InteractiveObject& Value() const; + + +friend class SALOME_ListIO; + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Address current; +Standard_Address previous; + + +}; + +#define Item Handle_SALOME_InteractiveObject +#define Item_hxx "SALOME_InteractiveObject.hxx" +#define TCollection_ListNode SALOME_ListNodeOfListIO +#define TCollection_ListNode_hxx "SALOME_ListNodeOfListIO.hxx" +#define TCollection_ListIterator SALOME_ListIteratorOfListIO +#define TCollection_ListIterator_hxx "SALOME_ListIteratorOfListIO.hxx" +#define Handle_TCollection_ListNode Handle_SALOME_ListNodeOfListIO +#define TCollection_ListNode_Type_() SALOME_ListNodeOfListIO_Type_() +#define TCollection_List SALOME_ListIO +#define TCollection_List_hxx "SALOME_ListIO.hxx" + +#include + +#undef Item +#undef Item_hxx +#undef TCollection_ListNode +#undef TCollection_ListNode_hxx +#undef TCollection_ListIterator +#undef TCollection_ListIterator_hxx +#undef Handle_TCollection_ListNode +#undef TCollection_ListNode_Type_ +#undef TCollection_List +#undef TCollection_List_hxx + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEGUI/SALOME_ListIteratorOfListIO_0.cxx b/src/SALOMEGUI/SALOME_ListIteratorOfListIO_0.cxx new file mode 100644 index 000000000..cc981e80b --- /dev/null +++ b/src/SALOMEGUI/SALOME_ListIteratorOfListIO_0.cxx @@ -0,0 +1,46 @@ +using namespace std; +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_ListIteratorOfListIO.hxx" + +#ifndef _Standard_NoMoreObject_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _SALOME_ListIO_HeaderFile +#include "SALOME_ListIO.hxx" +#endif +#ifndef _SALOME_InteractiveObject_HeaderFile +#include "SALOME_InteractiveObject.hxx" +#endif +#ifndef _SALOME_ListNodeOfListIO_HeaderFile +#include "SALOME_ListNodeOfListIO.hxx" +#endif + + +#define Item Handle_SALOME_InteractiveObject +#define Item_hxx "SALOME_InteractiveObject.hxx" +#define TCollection_ListNode SALOME_ListNodeOfListIO +#define TCollection_ListNode_hxx "SALOME_ListNodeOfListIO.hxx" +#define TCollection_ListIterator SALOME_ListIteratorOfListIO +#define TCollection_ListIterator_hxx "SALOME_ListIteratorOfListIO.hxx" +#define Handle_TCollection_ListNode Handle_SALOME_ListNodeOfListIO +#define TCollection_ListNode_Type_() SALOME_ListNodeOfListIO_Type_() +#define TCollection_List SALOME_ListIO +#define TCollection_List_hxx "SALOME_ListIO.hxx" +#include + diff --git a/src/SALOMEGUI/SALOME_ListIteratorOfListOfFilter.hxx b/src/SALOMEGUI/SALOME_ListIteratorOfListOfFilter.hxx new file mode 100644 index 000000000..42a2389f3 --- /dev/null +++ b/src/SALOMEGUI/SALOME_ListIteratorOfListOfFilter.hxx @@ -0,0 +1,131 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _SALOME_ListIteratorOfListOfFilter_HeaderFile +#define _SALOME_ListIteratorOfListOfFilter_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_Filter_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_ListNodeOfListOfFilter_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_NoMoreObject; +class Standard_NoSuchObject; +class SALOME_ListOfFilter; +class SALOME_Filter; +class SALOME_ListNodeOfListOfFilter; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOME_ListIteratorOfListOfFilter { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT SALOME_ListIteratorOfListOfFilter(); +Standard_EXPORT SALOME_ListIteratorOfListOfFilter(const SALOME_ListOfFilter& L); +Standard_EXPORT void Initialize(const SALOME_ListOfFilter& L) ; +Standard_EXPORT inline Standard_Boolean More() const; +Standard_EXPORT void Next() ; +Standard_EXPORT Handle_SALOME_Filter& Value() const; + + +friend class SALOME_ListOfFilter; + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Standard_Address current; +Standard_Address previous; + + +}; + +#define Item Handle_SALOME_Filter +#define Item_hxx "SALOME_Filter.hxx" +#define TCollection_ListNode SALOME_ListNodeOfListOfFilter +#define TCollection_ListNode_hxx "SALOME_ListNodeOfListOfFilter.hxx" +#define TCollection_ListIterator SALOME_ListIteratorOfListOfFilter +#define TCollection_ListIterator_hxx "SALOME_ListIteratorOfListOfFilter.hxx" +#define Handle_TCollection_ListNode Handle_SALOME_ListNodeOfListOfFilter +#define TCollection_ListNode_Type_() SALOME_ListNodeOfListOfFilter_Type_() +#define TCollection_List SALOME_ListOfFilter +#define TCollection_List_hxx "SALOME_ListOfFilter.hxx" + +#include + +#undef Item +#undef Item_hxx +#undef TCollection_ListNode +#undef TCollection_ListNode_hxx +#undef TCollection_ListIterator +#undef TCollection_ListIterator_hxx +#undef Handle_TCollection_ListNode +#undef TCollection_ListNode_Type_ +#undef TCollection_List +#undef TCollection_List_hxx + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEGUI/SALOME_ListIteratorOfListOfFilter_0.cxx b/src/SALOMEGUI/SALOME_ListIteratorOfListOfFilter_0.cxx new file mode 100644 index 000000000..cf39dcb06 --- /dev/null +++ b/src/SALOMEGUI/SALOME_ListIteratorOfListOfFilter_0.cxx @@ -0,0 +1,46 @@ +using namespace std; +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_ListIteratorOfListOfFilter.hxx" + +#ifndef _Standard_NoMoreObject_HeaderFile +#include +#endif +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _SALOME_ListOfFilter_HeaderFile +#include "SALOME_ListOfFilter.hxx" +#endif +#ifndef _SALOME_Filter_HeaderFile +#include "SALOME_Filter.hxx" +#endif +#ifndef _SALOME_ListNodeOfListOfFilter_HeaderFile +#include "SALOME_ListNodeOfListOfFilter.hxx" +#endif + + +#define Item Handle_SALOME_Filter +#define Item_hxx "SALOME_Filter.hxx" +#define TCollection_ListNode SALOME_ListNodeOfListOfFilter +#define TCollection_ListNode_hxx "SALOME_ListNodeOfListOfFilter.hxx" +#define TCollection_ListIterator SALOME_ListIteratorOfListOfFilter +#define TCollection_ListIterator_hxx "SALOME_ListIteratorOfListOfFilter.hxx" +#define Handle_TCollection_ListNode Handle_SALOME_ListNodeOfListOfFilter +#define TCollection_ListNode_Type_() SALOME_ListNodeOfListOfFilter_Type_() +#define TCollection_List SALOME_ListOfFilter +#define TCollection_List_hxx "SALOME_ListOfFilter.hxx" +#include + diff --git a/src/SALOMEGUI/SALOME_ListNodeOfListIO.hxx b/src/SALOMEGUI/SALOME_ListNodeOfListIO.hxx new file mode 100644 index 000000000..50e127a4c --- /dev/null +++ b/src/SALOMEGUI/SALOME_ListNodeOfListIO.hxx @@ -0,0 +1,123 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _SALOME_ListNodeOfListIO_HeaderFile +#define _SALOME_ListNodeOfListIO_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_ListNodeOfListIO_HeaderFile +#include +#endif + +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class SALOME_InteractiveObject; +class SALOME_ListIO; +class SALOME_ListIteratorOfListIO; + + +class SALOME_ListNodeOfListIO : public TCollection_MapNode { + +public: + + void* operator new(size_t,void* anAddress) + { + return anAddress; + } + void* operator new(size_t size) + { + return Standard::Allocate(size); + } + void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + // Methods PUBLIC + // +SALOME_ListNodeOfListIO(const Handle(SALOME_InteractiveObject)& I,const TCollection_MapNodePtr& n); + Handle_SALOME_InteractiveObject& Value() const; +Standard_EXPORT ~SALOME_ListNodeOfListIO(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOME_ListNodeOfListIO_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Handle_SALOME_InteractiveObject myValue; + + +}; + +#define Item Handle_SALOME_InteractiveObject +#define Item_hxx "SALOME_InteractiveObject.hxx" +#define TCollection_ListNode SALOME_ListNodeOfListIO +#define TCollection_ListNode_hxx "SALOME_ListNodeOfListIO.hxx" +#define TCollection_ListIterator SALOME_ListIteratorOfListIO +#define TCollection_ListIterator_hxx "SALOME_ListIteratorOfListIO.hxx" +#define Handle_TCollection_ListNode Handle_SALOME_ListNodeOfListIO +#define TCollection_ListNode_Type_() SALOME_ListNodeOfListIO_Type_() +#define TCollection_List SALOME_ListIO +#define TCollection_List_hxx "SALOME_ListIO.hxx" + +#include + +#undef Item +#undef Item_hxx +#undef TCollection_ListNode +#undef TCollection_ListNode_hxx +#undef TCollection_ListIterator +#undef TCollection_ListIterator_hxx +#undef Handle_TCollection_ListNode +#undef TCollection_ListNode_Type_ +#undef TCollection_List +#undef TCollection_List_hxx + + +// other Inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEGUI/SALOME_ListNodeOfListIO_0.cxx b/src/SALOMEGUI/SALOME_ListNodeOfListIO_0.cxx new file mode 100644 index 000000000..8d3654595 --- /dev/null +++ b/src/SALOMEGUI/SALOME_ListNodeOfListIO_0.cxx @@ -0,0 +1,92 @@ +using namespace std; +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_ListNodeOfListIO.hxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _SALOME_InteractiveObject_HeaderFile +#include "SALOME_InteractiveObject.hxx" +#endif +#ifndef _SALOME_ListIO_HeaderFile +#include "SALOME_ListIO.hxx" +#endif +#ifndef _SALOME_ListIteratorOfListIO_HeaderFile +#include "SALOME_ListIteratorOfListIO.hxx" +#endif +SALOME_ListNodeOfListIO::~SALOME_ListNodeOfListIO() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOME_ListNodeOfListIO_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TCollection_MapNode); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TCollection_MapNode); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOME_ListNodeOfListIO", + sizeof(SALOME_ListNodeOfListIO), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOME_ListNodeOfListIO) Handle(SALOME_ListNodeOfListIO)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOME_ListNodeOfListIO) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOME_ListNodeOfListIO))) { + _anOtherObject = Handle(SALOME_ListNodeOfListIO)((Handle(SALOME_ListNodeOfListIO)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOME_ListNodeOfListIO::DynamicType() const +{ + return STANDARD_TYPE(SALOME_ListNodeOfListIO) ; +} +Standard_Boolean SALOME_ListNodeOfListIO::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOME_ListNodeOfListIO) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_SALOME_ListNodeOfListIO::~Handle_SALOME_ListNodeOfListIO() {} +#define Item Handle_SALOME_InteractiveObject +#define Item_hxx "SALOME_InteractiveObject.hxx" +#define TCollection_ListNode SALOME_ListNodeOfListIO +#define TCollection_ListNode_hxx "SALOME_ListNodeOfListIO.hxx" +#define TCollection_ListIterator SALOME_ListIteratorOfListIO +#define TCollection_ListIterator_hxx "SALOME_ListIteratorOfListIO.hxx" +#define Handle_TCollection_ListNode Handle_SALOME_ListNodeOfListIO +#define TCollection_ListNode_Type_() SALOME_ListNodeOfListIO_Type_() +#define TCollection_List SALOME_ListIO +#define TCollection_List_hxx "SALOME_ListIO.hxx" +#include + diff --git a/src/SALOMEGUI/SALOME_ListNodeOfListOfFilter.hxx b/src/SALOMEGUI/SALOME_ListNodeOfListOfFilter.hxx new file mode 100644 index 000000000..cb3fcafb0 --- /dev/null +++ b/src/SALOMEGUI/SALOME_ListNodeOfListOfFilter.hxx @@ -0,0 +1,127 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _SALOME_ListNodeOfListOfFilter_HeaderFile +#define _SALOME_ListNodeOfListOfFilter_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_ListNodeOfListOfFilter_HeaderFile +#include +#endif + +#ifndef _Handle_SALOME_Filter_HeaderFile +#include +#endif +#ifndef _TCollection_MapNode_HeaderFile +#include +#endif +#ifndef _TCollection_MapNodePtr_HeaderFile +#include +#endif +class SALOME_Filter; +class SALOME_ListOfFilter; +class SALOME_ListIteratorOfListOfFilter; + + +class SALOME_ListNodeOfListOfFilter : public TCollection_MapNode { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT inline SALOME_ListNodeOfListOfFilter(const Handle(SALOME_Filter)& I,const TCollection_MapNodePtr& n); +Standard_EXPORT inline Handle_SALOME_Filter& Value() const; +Standard_EXPORT ~SALOME_ListNodeOfListOfFilter(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOME_ListNodeOfListOfFilter_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // +Handle_SALOME_Filter myValue; + + +}; + +#define Item Handle_SALOME_Filter +#define Item_hxx "SALOME_Filter.hxx" +#define TCollection_ListNode SALOME_ListNodeOfListOfFilter +#define TCollection_ListNode_hxx "SALOME_ListNodeOfListOfFilter.hxx" +#define TCollection_ListIterator SALOME_ListIteratorOfListOfFilter +#define TCollection_ListIterator_hxx "SALOME_ListIteratorOfListOfFilter.hxx" +#define Handle_TCollection_ListNode Handle_SALOME_ListNodeOfListOfFilter +#define TCollection_ListNode_Type_() SALOME_ListNodeOfListOfFilter_Type_() +#define TCollection_List SALOME_ListOfFilter +#define TCollection_List_hxx "SALOME_ListOfFilter.hxx" + +#include + +#undef Item +#undef Item_hxx +#undef TCollection_ListNode +#undef TCollection_ListNode_hxx +#undef TCollection_ListIterator +#undef TCollection_ListIterator_hxx +#undef Handle_TCollection_ListNode +#undef TCollection_ListNode_Type_ +#undef TCollection_List +#undef TCollection_List_hxx + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEGUI/SALOME_ListNodeOfListOfFilter_0.cxx b/src/SALOMEGUI/SALOME_ListNodeOfListOfFilter_0.cxx new file mode 100644 index 000000000..4b729c28a --- /dev/null +++ b/src/SALOMEGUI/SALOME_ListNodeOfListOfFilter_0.cxx @@ -0,0 +1,92 @@ +using namespace std; +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_ListNodeOfListOfFilter.hxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _SALOME_Filter_HeaderFile +#include "SALOME_Filter.hxx" +#endif +#ifndef _SALOME_ListOfFilter_HeaderFile +#include "SALOME_ListOfFilter.hxx" +#endif +#ifndef _SALOME_ListIteratorOfListOfFilter_HeaderFile +#include "SALOME_ListIteratorOfListOfFilter.hxx" +#endif +SALOME_ListNodeOfListOfFilter::~SALOME_ListNodeOfListOfFilter() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOME_ListNodeOfListOfFilter_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TCollection_MapNode); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TCollection_MapNode); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOME_ListNodeOfListOfFilter", + sizeof(SALOME_ListNodeOfListOfFilter), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOME_ListNodeOfListOfFilter) Handle(SALOME_ListNodeOfListOfFilter)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOME_ListNodeOfListOfFilter) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOME_ListNodeOfListOfFilter))) { + _anOtherObject = Handle(SALOME_ListNodeOfListOfFilter)((Handle(SALOME_ListNodeOfListOfFilter)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOME_ListNodeOfListOfFilter::DynamicType() const +{ + return STANDARD_TYPE(SALOME_ListNodeOfListOfFilter) ; +} +Standard_Boolean SALOME_ListNodeOfListOfFilter::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOME_ListNodeOfListOfFilter) == AType || TCollection_MapNode::IsKind(AType)); +} +Handle_SALOME_ListNodeOfListOfFilter::~Handle_SALOME_ListNodeOfListOfFilter() {} +#define Item Handle_SALOME_Filter +#define Item_hxx "SALOME_Filter.hxx" +#define TCollection_ListNode SALOME_ListNodeOfListOfFilter +#define TCollection_ListNode_hxx "SALOME_ListNodeOfListOfFilter.hxx" +#define TCollection_ListIterator SALOME_ListIteratorOfListOfFilter +#define TCollection_ListIterator_hxx "SALOME_ListIteratorOfListOfFilter.hxx" +#define Handle_TCollection_ListNode Handle_SALOME_ListNodeOfListOfFilter +#define TCollection_ListNode_Type_() SALOME_ListNodeOfListOfFilter_Type_() +#define TCollection_List SALOME_ListOfFilter +#define TCollection_List_hxx "SALOME_ListOfFilter.hxx" +#include + diff --git a/src/SALOMEGUI/SALOME_ListOfFilter.hxx b/src/SALOMEGUI/SALOME_ListOfFilter.hxx new file mode 100644 index 000000000..1f2296b6b --- /dev/null +++ b/src/SALOMEGUI/SALOME_ListOfFilter.hxx @@ -0,0 +1,155 @@ +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. + +#ifndef _SALOME_ListOfFilter_HeaderFile +#define _SALOME_ListOfFilter_HeaderFile + +#ifndef _Standard_Address_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_Filter_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_ListNodeOfListOfFilter_HeaderFile +#include +#endif +#ifndef _Standard_Integer_HeaderFile +#include +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +class Standard_NoSuchObject; +class SALOME_ListIteratorOfListOfFilter; +class SALOME_Filter; +class SALOME_ListNodeOfListOfFilter; + + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_Macro_HeaderFile +#include +#endif + +class SALOME_ListOfFilter { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT SALOME_ListOfFilter(); +Standard_EXPORT void Assign(const SALOME_ListOfFilter& Other) ; + void operator=(const SALOME_ListOfFilter& Other) +{ + Assign(Other); +} + +Standard_EXPORT Standard_Integer Extent() const; +Standard_EXPORT void Clear() ; +~SALOME_ListOfFilter() +{ + Clear(); +} + +Standard_EXPORT inline Standard_Boolean IsEmpty() const; +Standard_EXPORT void Prepend(const Handle(SALOME_Filter)& I) ; +Standard_EXPORT void Prepend(SALOME_ListOfFilter& Other) ; +Standard_EXPORT void Append(const Handle(SALOME_Filter)& I) ; +Standard_EXPORT void Append(SALOME_ListOfFilter& Other) ; +Standard_EXPORT Handle_SALOME_Filter& First() const; +Standard_EXPORT Handle_SALOME_Filter& Last() const; +Standard_EXPORT void RemoveFirst() ; +Standard_EXPORT void Remove(SALOME_ListIteratorOfListOfFilter& It) ; +Standard_EXPORT void InsertBefore(const Handle(SALOME_Filter)& I,SALOME_ListIteratorOfListOfFilter& It) ; +Standard_EXPORT void InsertBefore(SALOME_ListOfFilter& Other,SALOME_ListIteratorOfListOfFilter& It) ; +Standard_EXPORT void InsertAfter(const Handle(SALOME_Filter)& I,SALOME_ListIteratorOfListOfFilter& It) ; +Standard_EXPORT void InsertAfter(SALOME_ListOfFilter& Other,SALOME_ListIteratorOfListOfFilter& It) ; + + +friend class SALOME_ListIteratorOfListOfFilter; + + + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // +Standard_EXPORT SALOME_ListOfFilter(const SALOME_ListOfFilter& Other); + + + // Fields PRIVATE + // +Standard_Address myFirst; +Standard_Address myLast; + + +}; + +#define Item Handle_SALOME_Filter +#define Item_hxx "SALOME_Filter.hxx" +#define TCollection_ListNode SALOME_ListNodeOfListOfFilter +#define TCollection_ListNode_hxx "SALOME_ListNodeOfListOfFilter.hxx" +#define TCollection_ListIterator SALOME_ListIteratorOfListOfFilter +#define TCollection_ListIterator_hxx "SALOME_ListIteratorOfListOfFilter.hxx" +#define Handle_TCollection_ListNode Handle_SALOME_ListNodeOfListOfFilter +#define TCollection_ListNode_Type_() SALOME_ListNodeOfListOfFilter_Type_() +#define TCollection_List SALOME_ListOfFilter +#define TCollection_List_hxx "SALOME_ListOfFilter.hxx" + +#include + +#undef Item +#undef Item_hxx +#undef TCollection_ListNode +#undef TCollection_ListNode_hxx +#undef TCollection_ListIterator +#undef TCollection_ListIterator_hxx +#undef Handle_TCollection_ListNode +#undef TCollection_ListNode_Type_ +#undef TCollection_List +#undef TCollection_List_hxx + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEGUI/SALOME_ListOfFilter_0.cxx b/src/SALOMEGUI/SALOME_ListOfFilter_0.cxx new file mode 100644 index 000000000..6f95521fd --- /dev/null +++ b/src/SALOMEGUI/SALOME_ListOfFilter_0.cxx @@ -0,0 +1,43 @@ +using namespace std; +// File generated by CPPExt (Value) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_ListOfFilter.hxx" + +#ifndef _Standard_NoSuchObject_HeaderFile +#include +#endif +#ifndef _SALOME_ListIteratorOfListOfFilter_HeaderFile +#include "SALOME_ListIteratorOfListOfFilter.hxx" +#endif +#ifndef _SALOME_Filter_HeaderFile +#include "SALOME_Filter.hxx" +#endif +#ifndef _SALOME_ListNodeOfListOfFilter_HeaderFile +#include "SALOME_ListNodeOfListOfFilter.hxx" +#endif + + +#define Item Handle_SALOME_Filter +#define Item_hxx "SALOME_Filter.hxx" +#define TCollection_ListNode SALOME_ListNodeOfListOfFilter +#define TCollection_ListNode_hxx "SALOME_ListNodeOfListOfFilter.hxx" +#define TCollection_ListIterator SALOME_ListIteratorOfListOfFilter +#define TCollection_ListIterator_hxx "SALOME_ListIteratorOfListOfFilter.hxx" +#define Handle_TCollection_ListNode Handle_SALOME_ListNodeOfListOfFilter +#define TCollection_ListNode_Type_() SALOME_ListNodeOfListOfFilter_Type_() +#define TCollection_List SALOME_ListOfFilter +#define TCollection_List_hxx "SALOME_ListOfFilter.hxx" +#include + diff --git a/src/SALOMEGUI/SALOME_NumberFilter.cxx b/src/SALOMEGUI/SALOME_NumberFilter.cxx new file mode 100644 index 000000000..dd32400d1 --- /dev/null +++ b/src/SALOMEGUI/SALOME_NumberFilter.cxx @@ -0,0 +1,68 @@ +using namespace std; +// File : SALOME_NumberFilter.cxx +// Created : Wed Feb 20 17:24:59 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOME_NumberFilter.ixx" +#include "SALOME_Selection.h" +#include "SALOME_InteractiveObject.hxx" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_Study.h" + +SALOME_NumberFilter::SALOME_NumberFilter(NumberFilter TheKind, Standard_Integer aValue): +myKind(TheKind), +myValue(aValue){} + +Standard_Boolean SALOME_NumberFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const +{ + bool result = false; + QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + int nbSel = Sel->IObjectCount(); + + switch ( myKind ) + { + case 0 : // INFERIOR + { + if ( (nbSel + 1 ) < myValue ) + result = true; + else + result = false; + break; + } + case 1 : // INFERIOR_OR_EQUAL + { + if ( (nbSel + 1 ) <= myValue ) + result = true; + else + result = false; + break; + } + case 2 : // SUPERIOR + { + result = true; + break; + } + case 3 : // SUPERIOR_OR_EQUAL + { + result = true; + break; + } + case 4 : // EQUAL + { + if ( (nbSel + 1 ) == myValue ) + result = true; + else + result = false; + break; + } + } + + return result; +} diff --git a/src/SALOMEGUI/SALOME_NumberFilter.hxx b/src/SALOMEGUI/SALOME_NumberFilter.hxx new file mode 100644 index 000000000..ed722d165 --- /dev/null +++ b/src/SALOMEGUI/SALOME_NumberFilter.hxx @@ -0,0 +1,107 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _SALOME_NumberFilter_HeaderFile +#define _SALOME_NumberFilter_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_NumberFilter_HeaderFile +#include +#endif + +#ifndef _Standard_CString_HeaderFile +#include +#endif +#ifndef _SALOME_Filter_HeaderFile +#include "SALOME_Filter.hxx" +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif + +class SALOME_NumberFilter : public SALOME_Filter { + +public: + + enum NumberFilter { INFERIOR, INFERIOR_OR_EQUAL, SUPERIOR, SUPERIOR_OR_EQUAL, EQUAL }; + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT SALOME_NumberFilter(NumberFilter aGivenKind, Standard_Integer aValue); +Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const; +Standard_EXPORT ~SALOME_NumberFilter(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOME_NumberFilter_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // +NumberFilter myKind; +Standard_Integer myValue; + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEGUI/SALOME_NumberFilter.ixx b/src/SALOMEGUI/SALOME_NumberFilter.ixx new file mode 100644 index 000000000..327ff5295 --- /dev/null +++ b/src/SALOMEGUI/SALOME_NumberFilter.ixx @@ -0,0 +1,71 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_NumberFilter.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOME_NumberFilter::~SALOME_NumberFilter() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOME_NumberFilter_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_Filter); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_Filter); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOME_NumberFilter", + sizeof(SALOME_NumberFilter), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOME_NumberFilter) Handle(SALOME_NumberFilter)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOME_NumberFilter) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOME_NumberFilter))) { + _anOtherObject = Handle(SALOME_NumberFilter)((Handle(SALOME_NumberFilter)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOME_NumberFilter::DynamicType() const +{ + return STANDARD_TYPE(SALOME_NumberFilter) ; +} +Standard_Boolean SALOME_NumberFilter::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOME_NumberFilter) == AType || SALOME_Filter::IsKind(AType)); +} +Handle_SALOME_NumberFilter::~Handle_SALOME_NumberFilter() {} + diff --git a/src/SALOMEGUI/SALOME_NumberFilter.jxx b/src/SALOMEGUI/SALOME_NumberFilter.jxx new file mode 100644 index 000000000..071a0e3a3 --- /dev/null +++ b/src/SALOMEGUI/SALOME_NumberFilter.jxx @@ -0,0 +1,3 @@ +#ifndef _SALOME_NumberFilter_HeaderFile +#include "SALOME_NumberFilter.hxx" +#endif diff --git a/src/SALOMEGUI/SALOME_Selection.cxx b/src/SALOMEGUI/SALOME_Selection.cxx new file mode 100644 index 000000000..0634aa4de --- /dev/null +++ b/src/SALOMEGUI/SALOME_Selection.cxx @@ -0,0 +1,403 @@ +using namespace std; +// File : SALOME_Selection.cxx +// Created : Wed Feb 20 17:24:59 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +/*! + \class SALOME_Selection SALOME_Selection.h + \brief Selection Mechanism of Interactive Object. +*/ + +#include "SALOME_Selection.h" +#include "SALOME_Filter.hxx" +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOME_ListIteratorOfListOfFilter.hxx" + +#include "QAD_Desktop.h" +#include "utilities.h" + +static QList& SALOME_Sel_GetSelections() +{ + static QList Selections; + return Selections; +} + +//======================================================================= +// SELECTIONS MANAGEMENT +//======================================================================= + +/*! + Constructor +*/ +SALOME_Selection::SALOME_Selection(const QString& aName) : + myName(aName) +{ + myFilters.Clear(); + myIObjects.Clear(); + mySelectionMode = 4; /*Actor*/ + mySelActiveCompOnly = false; + + QAD_Desktop* aDesktop = QAD_Application::getDesktop(); + if (aDesktop) { + QAD_Application *anActiveApplication = aDesktop->getActiveApp(); + if (anActiveApplication) QAD_ASSERT(connect(this, SIGNAL(currentSelectionChanged()),anActiveApplication, SLOT(updateActions()))); + } +} + +/*! + Destructor +*/ +SALOME_Selection::~SALOME_Selection() +{ +} + +/*! + Create a Selection with name \a aName + \return TRUE if the Selection is created. Returns FALSE otherwise. +*/ +bool SALOME_Selection::CreateSelection(const QString& aName) +{ + SALOME_Selection* S = NULL; + if ( SALOME_Selection::FindSelection( aName ) ) + S = SALOME_Selection::Selection( aName ); + else { + S = new SALOME_Selection(aName); + SALOME_Sel_GetSelections().prepend(S); + } + return true; +} + + +/*! + Sets the current Selection with \a aName +*/ +SALOME_Selection* SALOME_Selection::Selection(const QString& aName) +{ + SALOME_Selection* Sel = NULL; + if(SALOME_Sel_GetSelections().isEmpty()) return Sel; + + for( Sel=SALOME_Sel_GetSelections().first(); Sel!=0; Sel=SALOME_Sel_GetSelections().next() ){ + if( Sel->myName.compare(aName) == 0 ) + return Sel; + } + + return Sel; +} + +/*! + Finds Selection with \a aName + \return TRUE if the Selection is found. Returns FALSE otherwise. +*/ +bool SALOME_Selection::FindSelection(const QString& aName) +{ + SALOME_Selection* Sel; + for( Sel=SALOME_Sel_GetSelections().first(); Sel!=0; Sel=SALOME_Sel_GetSelections().next() ){ + if( Sel->myName.compare(aName) == 0 ) + return true; + } + + return false; +} + +/*! + Removes Selection with \a aName + \return TRUE if the Selection is removed. Returns FALSE otherwise. +*/ +bool SALOME_Selection::RemoveSelection(const QString& aName) +{ + SALOME_Selection* Sel; + for( Sel=SALOME_Sel_GetSelections().first(); Sel!=0; Sel=SALOME_Sel_GetSelections().next() ){ + if( Sel->myName.compare(aName) == 0 ) + return SALOME_Sel_GetSelections().remove(Sel); + } + return false; +} + + + +//======================================================================= +// FILTERS MANAGEMENT +//======================================================================= + +/*! + Adds Filter +*/ +void SALOME_Selection::AddFilter(const Handle(SALOME_Filter)& aFilter, + bool updateSelection) +{ + if ( !FindFilter(aFilter) ) { + myFilters.Append( aFilter ); + + SALOME_ListIO removedIObjects; + + if ( updateSelection ) { + SALOME_ListIteratorOfListIO It(myIObjects); + for(;It.More();It.Next()){ + Handle(SALOME_InteractiveObject) Object = It.Value(); + if( !IsOk(Object) ) { + removedIObjects.Append( Object ); + // RemoveIObject( Object ); + } + } + + SALOME_ListIteratorOfListIO It1(removedIObjects); + for(;It1.More();It1.Next()){ + Handle(SALOME_InteractiveObject) Object = It1.Value(); + RemoveIObject( Object ); + } + } + } +} + +/*! + Removes Filter +*/ +bool SALOME_Selection::RemoveFilter(const Handle(SALOME_Filter)& aFilter) +{ + SALOME_ListIteratorOfListOfFilter It(myFilters); + for(;It.More();It.Next()){ + if (aFilter==It.Value()){ + myFilters.Remove(It); + return true; + } + } + return false; +} + +//! Clears All Filters +void SALOME_Selection::ClearFilters() +{ + myFilters.Clear(); +} + +//! Finds aFilter +bool SALOME_Selection::FindFilter(const Handle(SALOME_Filter)& aFilter) +{ + SALOME_ListIteratorOfListOfFilter It(myFilters); + for(;It.More();It.Next()) + if (aFilter==It.Value()) + return true; + return false; +} + +//! Returns the list of stored Filters +const SALOME_ListOfFilter& SALOME_Selection::StoredFilters() +{ + return myFilters; +} + + + +//======================================================================= +// INTERACTIVE OBJECTS MANAGEMENT +//======================================================================= + +void SALOME_Selection::Clear() +{ + myIObjects.Clear(); +} + +//! Clears all Interactive Objects +void SALOME_Selection::ClearIObjects() +{ + myIObjects.Clear(); + + QAD_Desktop* myDesktop = (QAD_Desktop*) QAD_Application::getDesktop(); + QAD_Study* myActiveStudy = myDesktop->getActiveStudy(); + myActiveStudy->unHighlightAll(); + + myMapIOSubIndex.Clear(); + + emit currentSelectionChanged(); +} + +//! Add an InteractiveObject +int SALOME_Selection::AddIObject(const Handle(SALOME_InteractiveObject)& anObject, bool update) +{ + QAD_Desktop* myDesktop = (QAD_Desktop*) QAD_Application::getDesktop(); + QAD_Study* myActiveStudy = myDesktop->getActiveStudy(); + + if ( !IsOk(anObject) ) { + MESSAGE ( "The Object not authorized by Filters" ) + myActiveStudy->highlight(anObject,false, update); + return -1; + } + + bool Found = false; + SALOME_ListIteratorOfListIO It(myIObjects); + for(;It.More();It.Next()) { + if (anObject->isSame(It.Value())) { + Found = true; + break; + } + } + + // Il n'est pas dedans, on le rajoute.... + if(Found==false) { + myIObjects.Append( anObject ); + myActiveStudy->highlight(anObject, true, update); + emit currentSelectionChanged(); + return 1; + } + return 0; +} + +//! Removes an InteractiveObject +int SALOME_Selection::RemoveIObject(const Handle(SALOME_InteractiveObject)& anObject, bool update) +{ + SALOME_ListIteratorOfListIO It(myIObjects); + for(;It.More();It.Next()) { + if (anObject->isSame(It.Value())) { + QAD_Desktop* myDesktop = (QAD_Desktop*) QAD_Application::getDesktop(); + QAD_Study* myActiveStudy = myDesktop->getActiveStudy(); + myActiveStudy->highlight(anObject, false, update); + + if ( myMapIOSubIndex.IsBound( anObject ) ) { + myMapIOSubIndex.UnBind( anObject ); + } + + myIObjects.Remove(It); + + emit currentSelectionChanged(); + return 1; + } + } + return 0; +} + +//! Returns the list of InteractiveObjects +const SALOME_ListIO& SALOME_Selection::StoredIObjects() +{ + return myIObjects; +} + +//! Returns the number of InteractiveObjects in the selection. +int SALOME_Selection::IObjectCount() +{ + return myIObjects.Extent(); +} + +//! Returns the first InteractiveObject in the selection. +Handle(SALOME_InteractiveObject) SALOME_Selection::firstIObject() +{ + return myIObjects.First(); +} + +//! Returns the last InteractiveObject in the selection. +Handle(SALOME_InteractiveObject) SALOME_Selection::lastIObject() +{ + return myIObjects.Last(); +} + +/*! + Returns TRUE if the InteractiveObject is authorized by Filters. Returns FALSE otherwise. +*/ +bool SALOME_Selection::IsOk(const Handle(SALOME_InteractiveObject)& anObj) +{ + SALOME_ListIteratorOfListOfFilter It(myFilters); + for(;It.More();It.Next()){ + Handle(SALOME_Filter) theFilter = It.Value(); + if ( !theFilter->IsOk(anObj) ) + return false; + } + return true; +} + +void SALOME_Selection::SetSelectionMode(int mode, bool activeCompOnly) +{ + mySelectionMode = mode; + mySelActiveCompOnly = activeCompOnly; +} + +int SALOME_Selection::SelectionMode() +{ + return mySelectionMode; +} + +bool SALOME_Selection::IsSelectActiveCompOnly() const +{ + return mySelActiveCompOnly; +} + +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 ) +{ + if ( myMapIOSubIndex.IsBound(IObject) ) { + theIndex = myMapIOSubIndex.Find(IObject); + } + else { + theIndex.Clear(); + } +} + + + +bool SALOME_Selection::IsIndexSelected(const Handle(SALOME_InteractiveObject)& IObject, int index) +{ + if ( !myMapIOSubIndex.IsBound( IObject ) ) { + return false; + } + TColStd_MapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject ); + return MapIndex.Contains( index ); +} + + + + +bool SALOME_Selection::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, + int index, + bool modeShift, + bool update) +{ + MESSAGE ( " 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; + myMapIOSubIndex.Bind( IObject, Empty ); + } + TColStd_MapOfInteger& MapIndex = myMapIOSubIndex.ChangeFind( IObject ); + + if ( MapIndex.Contains( index )) { + if ( modeShift ) { + MapIndex.Remove( index ); + myActiveStudy->highlight( IObject, true, update ); + } + } else { + if ( !modeShift ) + MapIndex.Clear(); + + MapIndex.Add( index ); + myActiveStudy->highlight( IObject, true, update ); + emit currentSelectionChanged(); + return true; + } + + if ( MapIndex.IsEmpty() ) { + myMapIOSubIndex.UnBind( IObject ); + RemoveIObject( IObject, update ); + } + + emit currentSelectionChanged(); + return false; +} + +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 ); + } +} + diff --git a/src/SALOMEGUI/SALOME_Selection.h b/src/SALOMEGUI/SALOME_Selection.h new file mode 100644 index 000000000..95d1fd4b3 --- /dev/null +++ b/src/SALOMEGUI/SALOME_Selection.h @@ -0,0 +1,88 @@ +// File : SALOME_Selection.h +// Created : Wed Feb 20 17:24:59 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef SALOME_SELECTION_H +#define SALOME_SELECTION_H + +#include "SALOME_Filter.hxx" +#include "SALOME_ListIO.hxx" +#include "SALOME_ListOfFilter.hxx" +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_DataMapOfIOMapOfInteger.hxx" + +// Qt Includes +#include +#include +#include + +// Open CASCADE Include +#include + +class SALOME_Selection : public QObject +{ + Q_OBJECT + +public: + SALOME_Selection(const QString& aName); + ~SALOME_Selection(); + + static bool CreateSelection(const QString& aName) ; + static SALOME_Selection* Selection (const QString& aName) ; + static bool RemoveSelection(const QString& aName) ; + static bool FindSelection (const QString& aName) ; + + void Clear () ; + + void ClearIObjects () ; + int AddIObject ( const Handle(SALOME_InteractiveObject)& anObject, bool update = true) ; + int RemoveIObject ( const Handle(SALOME_InteractiveObject)& anObject, bool update = true) ; + + const SALOME_ListIO& StoredIObjects() ; + int IObjectCount() ; + + Handle(SALOME_InteractiveObject) firstIObject() ; + Handle(SALOME_InteractiveObject) lastIObject() ; + + void AddFilter(const Handle(SALOME_Filter)& aFilter, + bool updateSelection = true ) ; + bool RemoveFilter(const Handle(SALOME_Filter)& aFilter) ; + void ClearFilters(); + const SALOME_ListOfFilter& StoredFilters(); + bool FindFilter(const Handle(SALOME_Filter)& aFilter); + + bool IsOk( const Handle(SALOME_InteractiveObject)& IObject ) ; + + + void SetSelectionMode(int mode, bool activeCompOnly = false); + int SelectionMode(); + bool IsSelectActiveCompOnly() const; + + bool HasIndex( const Handle(SALOME_InteractiveObject)& IObject ); + void GetIndex( const Handle(SALOME_InteractiveObject)& IObject, + TColStd_MapOfInteger& theIndex ); + + bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index, bool modeShift, bool update=true ); + void RemoveIndex( const Handle(SALOME_InteractiveObject)& IObject, int index ); + bool IsIndexSelected(const Handle(SALOME_InteractiveObject)& IObject, int index); + +signals: + void currentSelectionChanged(); + +private: + QString myName; + SALOME_ListOfFilter myFilters; + SALOME_ListIO myIObjects; + + SALOME_DataMapOfIOMapOfInteger myMapIOSubIndex; + + int mySelectionMode; + bool mySelActiveCompOnly; +}; + +#endif + diff --git a/src/SALOMEGUI/SALOME_TypeFilter.cxx b/src/SALOMEGUI/SALOME_TypeFilter.cxx new file mode 100644 index 000000000..246906ba2 --- /dev/null +++ b/src/SALOMEGUI/SALOME_TypeFilter.cxx @@ -0,0 +1,19 @@ +using namespace std; +// File : SALOME_TypeFilter.cxx +// Created : Wed Feb 20 17:24:59 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SALOMEGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SALOME_TypeFilter.ixx" +#include "SALOME_InteractiveObject.hxx" + +SALOME_TypeFilter::SALOME_TypeFilter(const Standard_CString TheKind): +myKind(TheKind){} + +Standard_Boolean SALOME_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const +{ + return anObj->isComponentType( myKind ); +} diff --git a/src/SALOMEGUI/SALOME_TypeFilter.hxx b/src/SALOMEGUI/SALOME_TypeFilter.hxx new file mode 100644 index 000000000..b5346a837 --- /dev/null +++ b/src/SALOMEGUI/SALOME_TypeFilter.hxx @@ -0,0 +1,105 @@ +// File generated by CPPExt (Transient) +// +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#ifndef _SALOME_TypeFilter_HeaderFile +#define _SALOME_TypeFilter_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_TypeFilter_HeaderFile +#include +#endif + +#ifndef _Standard_CString_HeaderFile +#include +#endif +#ifndef _SALOME_Filter_HeaderFile +#include "SALOME_Filter.hxx" +#endif +#ifndef _Standard_Boolean_HeaderFile +#include +#endif +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif + +class SALOME_TypeFilter : public SALOME_Filter { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } +// inline void operator delete(void *anAddress, size_t size) +// { +// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); +// } + // Methods PUBLIC + // +Standard_EXPORT SALOME_TypeFilter(const Standard_CString aGivenKind); +Standard_EXPORT virtual Standard_Boolean IsOk(const Handle(SALOME_InteractiveObject)& anobj) const; +Standard_EXPORT ~SALOME_TypeFilter(); + + + + + // Type management + // + Standard_EXPORT friend Handle_Standard_Type& SALOME_TypeFilter_Type_(); + Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; + Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // +Standard_CString myKind; + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + + +}; + + + + + +// other inline functions and methods (like "C++: function call" methods) +// + + +#endif diff --git a/src/SALOMEGUI/SALOME_TypeFilter.ixx b/src/SALOMEGUI/SALOME_TypeFilter.ixx new file mode 100644 index 000000000..f806b74b7 --- /dev/null +++ b/src/SALOMEGUI/SALOME_TypeFilter.ixx @@ -0,0 +1,71 @@ +// File generated by CPPExt (Transient) +// Copyright (C) 1991,1995 by +// +// MATRA DATAVISION, FRANCE +// +// This software is furnished in accordance with the terms and conditions +// of the contract and with the inclusion of the above copyright notice. +// This software or any other copy thereof may not be provided or otherwise +// be made available to any other person. No title to an ownership of the +// software is hereby transferred. +// +// At the termination of the contract, the software and all copies of this +// software must be deleted. +// +#include "SALOME_TypeFilter.jxx" + +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +SALOME_TypeFilter::~SALOME_TypeFilter() {} + + + +Standard_EXPORT Handle_Standard_Type& SALOME_TypeFilter_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(SALOME_Filter); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(SALOME_Filter); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("SALOME_TypeFilter", + sizeof(SALOME_TypeFilter), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + + +// DownCast method +// allow safe downcasting +// +const Handle(SALOME_TypeFilter) Handle(SALOME_TypeFilter)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(SALOME_TypeFilter) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(SALOME_TypeFilter))) { + _anOtherObject = Handle(SALOME_TypeFilter)((Handle(SALOME_TypeFilter)&)AnObject); + } + } + + return _anOtherObject ; +} +const Handle(Standard_Type)& SALOME_TypeFilter::DynamicType() const +{ + return STANDARD_TYPE(SALOME_TypeFilter) ; +} +Standard_Boolean SALOME_TypeFilter::IsKind(const Handle(Standard_Type)& AType) const +{ + return (STANDARD_TYPE(SALOME_TypeFilter) == AType || SALOME_Filter::IsKind(AType)); +} +Handle_SALOME_TypeFilter::~Handle_SALOME_TypeFilter() {} + diff --git a/src/SALOMEGUI/SALOME_TypeFilter.jxx b/src/SALOMEGUI/SALOME_TypeFilter.jxx new file mode 100644 index 000000000..420415f6a --- /dev/null +++ b/src/SALOMEGUI/SALOME_TypeFilter.jxx @@ -0,0 +1,3 @@ +#ifndef _SALOME_TypeFilter_HeaderFile +#include "SALOME_TypeFilter.hxx" +#endif diff --git a/src/SALOME_PY/Makefile.in b/src/SALOME_PY/Makefile.in new file mode 100644 index 000000000..3a558d579 --- /dev/null +++ b/src/SALOME_PY/Makefile.in @@ -0,0 +1,33 @@ +#============================================================================== +# File : Makefile.in +# Created : ven nov 16 18:12:41 CET 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# Libraries targets + +LIB = libSalomePy.la +LIB_SRC = SalomePy.cxx + +LIB_CLIENT_IDL = SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_Exception.idl + +CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) -DHAVE_CONFIG_H +LDFLAGS+= $(PYTHON_LIBS) $(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) $(OGL_LIBS) -lSALOME_Swigcmodule -lSalomeGUI -lVTKCommonPython -lVTKGraphicsPython -lVTKContribPython -lVTKImagingPython +#LDFLAGS+= $(PYTHON_LIBS) $(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) $(OGL_LIBS) -lSalomeGUI -lVTKCommonPython -lVTKGraphicsPython -lVTKContribPython -lVTKImagingPython + + +@CONCLUDE@ diff --git a/src/SALOME_PY/SalomePy.cxx b/src/SALOME_PY/SalomePy.cxx new file mode 100644 index 000000000..05a889cd8 --- /dev/null +++ b/src/SALOME_PY/SalomePy.cxx @@ -0,0 +1,100 @@ +using namespace std; +//============================================================================= +// File : SalomePy.cxx +// Created : ven nov 16 17:29:20 CET 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#include "SALOMEGUI_Swig.hxx" +#include +#include +#include +#include +#include "utilities.h" + +extern "C" +{ + static PyObject * libSalomePy_getRenderer(PyObject *self, PyObject *args); +} + +static PyObject *libSalomePy_getRenderer(PyObject *self, PyObject *args) +{ + if (!PyArg_ParseTuple(args, ":getRenderer")) + return NULL; + // exemple retournant systematiquement Py_None + Py_INCREF(Py_None); + return Py_None; +} + +static PyMethodDef Module_Methods[] = + { + {"getRenderer", libSalomePy_getRenderer, METH_VARARGS}, + {NULL, NULL} + }; + +extern "C" { void initlibSalomePy();} + +void initlibSalomePy() +{ + PyObject *m, *d, *c, *md, *obj, *vtkclass; + + static char modulename[] = "libSalomePy"; + MESSAGE("---"); + m = Py_InitModule(modulename, Module_Methods); + MESSAGE("---"); + d = PyModule_GetDict(m); + MESSAGE("---"); + // DANGEROUS : if (!d) Py_FatalError("can't get dictionary for module SalomePy!"); + if (PyErr_Occurred()) + { + MESSAGE("---"); + return; + } + + m=PyImport_ImportModule("libVTKGraphicsPython"); // import module if not already imported (new ref) + MESSAGE("---"); + + if (PyErr_Occurred()) + { + PyErr_Print(); + MESSAGE("---"); + return; + } + + if ( m ) { + md = PyModule_GetDict(m); // dict of libVTKGraphicsPython (borrowed ref ; not decref) + MESSAGE("---"); + + vtkclass=PyDict_GetItemString(md,"vtkRenderer"); // (borrowed ref ; not decref) + Py_DECREF(m); // no more need of m + MESSAGE("---"); + } +//NRI + vtkRenderer *renderer = SALOMEGUI_Swig::getRenderer(); + + MESSAGE("---"); + obj = PyVTKObject_New(vtkclass,renderer); // (new ref) + MESSAGE( "Nombre de references sur obj : " << obj->ob_refcnt ); // sys.getrefcount(o) gives ref count + 1 in Python interp + PyDict_SetItemString(d,"renderer",obj); // (add a ref to obj ; has to be decref) + MESSAGE( "Nombre de references sur obj : " << obj->ob_refcnt ); // sys.getrefcount(o) gives ref count + 1 in Python interp + Py_DECREF(obj); // only one ref is sufficient + MESSAGE( "Nombre de references sur obj : " << obj->ob_refcnt ); // sys.getrefcount(o) gives ref count + 1 in Python interp +//NRI + +// vtkclass=PyDict_GetItemString(md,"vtkRenderWindowInteractor"); // (borrowed ref ; not decref) +// Py_DECREF(m); // no more need of m +// MESSAGE("---"); +// vtkRenderWindowInteractor *RWInteractor = SALOMEGUI_Swig::getRWInteractor(); +// MESSAGE("---"); +// obj = PyVTKObject_New(vtkclass,RWInteractor); // (new ref) +// MESSAGE( "Nombre de references sur obj : " << obj->ob_refcnt ); // sys.getrefcount(o) gives ref count + 1 in Python interp +// PyDict_SetItemString(d,"interactor",obj); // (add a ref to obj ; has to be decref) +// MESSAGE( "Nombre de references sur obj : " << obj->ob_refcnt ); // sys.getrefcount(o) gives ref count + 1 in Python interp +// Py_DECREF(obj); // only one ref is sufficient +// MESSAGE( "Nombre de references sur obj : " << obj->ob_refcnt ); // sys.getrefcount(o) gives ref count + 1 in Python interp +} + + diff --git a/src/SALOME_PYQT/Makefile.in b/src/SALOME_PYQT/Makefile.in new file mode 100644 index 000000000..3f343b587 --- /dev/null +++ b/src/SALOME_PYQT/Makefile.in @@ -0,0 +1,65 @@ +#============================================================================== +# File : Makefile.in +# Created : ven sep 28 17:32:46 CEST 2001 +# Author : Nicolas REJNERI +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# PyQt +# PYQT_SIPS defined in make_commence.in + +# SIP C++ Python +# SIP defined in make_commence.in +SIP_FLAGS = -t WS_X11 -t Qt_3_0_5 -s ".cc" -c $(CURDIR) -I $(PYQT_SIPS) + + +# SIP input file(s) + +SIP_FILES = SalomePyQt.sip + +# SIP-generated C++ source files (corresponding line should be added for each wrapped class +# contained by SalomePyQt module) + +SIP_SRC=$(CURDIR)/SalomePyQtcmodule.cc \ + $(CURDIR)/sipSalomePyQtSalomePyQt.cc \ + $(CURDIR)/sipSalomePyQtSALOME_Selection.cc + +# Libraries targets + +LIB = libSalomePyQtcmodule.la + +MOC_SRC = sipSalomePyQtProxySalomePyQt_moc.cxx + +LIB_SRC += SalomePyQt.cxx $(SIP_SRC) $(MOC_SRC) + +#LIB_MOC += sipSalomePyQtProxySalomePyQt.h + +EXPORT_SHAREDPYSCRIPTS = SalomePyQt.py + +LIB_CLIENT_IDL = SALOME_Exception.idl + +CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(SIP_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) +LIBS+= $(PYTHON_LIBS) $(SIP_LIBS) $(PYQT_LIBS) $(OCC_LIBS) $(VTK_LIBS) $(OGL_LIBS) +LDFLAGS+= -lSalomeGUI + + +# Custom build step: generate C++ wrapping according to $(SIP_FILES) + +$(SIP_SRC): $(SIP_FILES) + $(SIP) $(SIP_FLAGS) $< + +$(MOC_SRC): sipSalomePyQtProxySalomePyQt.h + $(MOC) $< -o $@ + +@CONCLUDE@ diff --git a/src/SALOME_PYQT/SalomePyQt.cxx b/src/SALOME_PYQT/SalomePyQt.cxx new file mode 100644 index 000000000..8ea6026e2 --- /dev/null +++ b/src/SALOME_PYQT/SalomePyQt.cxx @@ -0,0 +1,85 @@ +using namespace std; +#include "SalomePyQt.hxx" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_Study.h" + +#include "QAD_Config.h" +#include "QAD_Settings.h" + +QWidget* SalomePyQt::getDesktop() +{ + return (QWidget*)(QAD_Application::getDesktop()); +} + +QWorkspace* SalomePyQt::getMainFrame() +{ + return (QWorkspace*)(QAD_Application::getDesktop()->getMainFrame()); +} + +QMenuBar* SalomePyQt::getMainMenuBar() +{ + return (QMenuBar*)(QAD_Application::getDesktop()->getMainMenuBar()); +} + +int SalomePyQt::getStudyId() +{ + return QAD_Application::getDesktop()->getActiveStudy()->getStudyId(); +} + +SALOME_Selection* SalomePyQt::getSelection() +{ + return SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); +} + +void SalomePyQt::putInfo( const QString& msg ) +{ + QAD_Application::getDesktop()->putInfo(msg); +} + +void SalomePyQt::putInfo( const QString& msg, int ms ) +{ + QAD_Application::getDesktop()->putInfo(msg, ms); +} + +void SalomePyQt::updateObjBrowser( int studyId, bool updateSelection) +{ + QList& studies = QAD_Application::getDesktop()->getActiveApp()->getStudies(); + for ( QAD_Study* study = studies.first(); study; study = studies.next() ) { + if ( study->getStudyId() == studyId ) { + study->updateObjBrowser( updateSelection ); + break; + } + } +} + +const QString& SalomePyQt::getActiveComponent() +{ + return QAD_Application::getDesktop()->getActiveComponent(); +} + +void SalomePyQt::addStringSetting(QString _name, QString _value, bool _autoValue) +{ + QAD_CONFIG->addSetting(_name, _value, _autoValue); +} + +void SalomePyQt::addIntSetting(QString _name, int _value, bool _autoValue) +{ + QAD_CONFIG->addSetting(_name, _value, _autoValue); +} + +void SalomePyQt::addDoubleSetting(QString _name, double _value, bool _autoValue) +{ + QAD_CONFIG->addSetting(_name, _value, _autoValue); +} + +bool SalomePyQt::removeSettings(QString name) +{ + return QAD_CONFIG->removeSettings( name ); +} + +QString SalomePyQt::getSetting(QString name) +{ + return QAD_CONFIG->getSetting(name); +} diff --git a/src/SALOME_PYQT/SalomePyQt.hxx b/src/SALOME_PYQT/SalomePyQt.hxx new file mode 100644 index 000000000..8d835ac12 --- /dev/null +++ b/src/SALOME_PYQT/SalomePyQt.hxx @@ -0,0 +1,33 @@ +#ifndef _SALOME_PYQT_H +#define _SALOME_PYQT_H + +#include + +#include +#include +#include +#include + +class SalomePyQt +{ +public: + static QWidget* getDesktop(); + static QWorkspace* getMainFrame(); + static QMenuBar* getMainMenuBar(); + static SALOME_Selection* getSelection(); + static int getStudyId(); + static void putInfo( const QString& ); + static void putInfo( const QString&, int ); + + static const QString& getActiveComponent(); + + static void updateObjBrowser( int studyId, bool updateSelection); + + static void addStringSetting(QString _name, QString _value, bool _autoValue); + static void addIntSetting(QString _name, int _value, bool _autoValue); + static void addDoubleSetting(QString _name, double _value, bool _autoValue); + static bool removeSettings(QString name); + static QString getSetting(QString name); +}; + +#endif diff --git a/src/SALOME_PYQT/SalomePyQt.sip b/src/SALOME_PYQT/SalomePyQt.sip new file mode 100644 index 000000000..02b9e4465 --- /dev/null +++ b/src/SALOME_PYQT/SalomePyQt.sip @@ -0,0 +1,45 @@ +%Module SalomePyQt + +%Import qtmod.sip + +class SALOME_Selection : QObject +{ +%HeaderCode +#include +%End + +public: + SALOME_Selection(const QString &); + void Clear(); + void ClearIObjects(); + +signals: + void currentSelectionChanged(); +}; + +class SalomePyQt +{ +%HeaderCode +#include +%End + +public: + static QWidget* getDesktop(); + static QWorkspace* getMainFrame(); + static QMenuBar* getMainMenuBar(); + static SALOME_Selection* getSelection(); + static int getStudyId(); + static void putInfo( const QString& ); + static void putInfo( const QString&, int ); + + static const QString& getActiveComponent(); + + static void updateObjBrowser( int, bool ); + + + static bool removeSettings(QString); + static QString getSetting(QString); + static void addStringSetting(QString, QString, bool); + static void addIntSetting(QString, int, bool); + static void addDoubleSetting(QString, double, bool); +}; diff --git a/src/SALOME_SWIG/Help.py b/src/SALOME_SWIG/Help.py new file mode 100644 index 000000000..46af5616a --- /dev/null +++ b/src/SALOME_SWIG/Help.py @@ -0,0 +1,124 @@ +#============================================================================== +# File : Help.py +# Created : sam nov 10 16:51:38 CET 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +class SalomeDoc: + def __init__(self, aDoc): + self.doc = aDoc + def __repr__(self): + print self.doc + return "---" + def salome(self): + doc_salome = ''' +MODULE : salome +--------------- +module salome gives access to Salome ressources: +variables: + + salome:orb : CORBA + salome.naming_service : instance of naming Service class + methods: + Resolve(name) : find a CORBA object (ior) by its pathname + Register(name) : register a CORBA object under a pathname + salome.lcc : instance of lifeCycleCORBA class + methods: + FindOrLoadComponent(server,name) : + obtain an Engine (CORBA object) + or launch the Engine if not found, + with a Server name and an Engine name + salome.sg + methods: + updateObjBrowser(bool): + getActiveStudyId(): + getActiveStudyName(): + + SelectedCount(): returns number of selected objects + getSelected(i): returns entry of selected object number i + getAllSelected(): returns list of entry of selected objects + AddIObject(Entry): select an existing Interactive object + RemoveIObject(Entry): remove object from selection + ClearIObjects(): clear selection + + Display(*Entry): + DisplayOnly(Entry): + Erase(Entry): + DisplayAll(): + EraseAll(): + + IDToObject(Entry): returns CORBA reference from entry + + salome.myStudyName : active Study Name + salome.myStudyId : active Study Id + salome.myStudy : the active Study itself (CORBA ior) + methods : defined in SALOMEDS.idl + +methods: + salome.DumpStudy(study) : Dump a study, given the ior +--- +''' + print doc_salome + + def geompy(self): + doc_geompy = ''' +MODULE : geompy +--------------- +module geompy provides an encapsulation of GEOM Engine methods +variables: + geompy.geom : a Geometry Engine, found or loaded + at first import of module geompy. + methods : defined in GEOM_Gen.idl + geompy.myBuilder : a study builder + geompy.father : GEOM root in current study (salome.myStudy) + +methods: + addToStudy(aShape, aName) : add the shape into the current study + --- all methods of GEOM_Gen.idl that returns a shape are encapsulated, + with the same interface : shapes are named with their ior +''' + print doc_geompy + + def supervision(self): + doc_supervision = ''' +MODULES : SALOME_SuperVisionEditor and SALOME_SuperVisionExecutor +----------------------------------------------------------------- +this modules provide access to Editor and Executor Engine methods + +See SUPERV.idl + +In order to run the example (supervisionexample.py) + + Type : from supervisionexample import * + supervisionexample.py contains comments + +A new python example avoids references to LifeCycleCORBA + avoids references to NamingService + avoids references to ModuleCatalog + avoids SuperVisionComponent creation + allows G.Input(...) instead of AddInput(G,...) + replaces Editor/Executor with Graph + allows Nodes, Ports and Links CORBA objects + shortens methods names + ... + + See /SuperVisionTest/resources/GraphExample.py + and GraphExample.xml +--- +''' + print doc_supervision + + + +help = SalomeDoc(''' +Availables modules: + salome : gives access to Salome ressources + geompy : encapsulation of GEOM Engine methods + supervision : gives access to SuperVision Engine +To obtain specific help on a module "truc", type: help.truc() +To run an example, type: import example3 +''') + diff --git a/src/SALOME_SWIG/Makefile.in b/src/SALOME_SWIG/Makefile.in new file mode 100644 index 000000000..3475d77dc --- /dev/null +++ b/src/SALOME_SWIG/Makefile.in @@ -0,0 +1,34 @@ +#============================================================================== +# File : Makefile.in +# Created : ven sep 28 17:32:46 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# Libraries targets + +LIB = libSALOME_Swigcmodule.la +LIB_SRC = + +SWIG_DEF = libSALOME_Swig.i +EXPORT_PYSCRIPTS = libSALOME_Swig.py Help.py PyInterp.py salome.py examplevtk1.py supervisionexample.py supervisiongeomexample.py salome_shared_modules.py batchmode_salome.py test_table.py test_big_table.py test_many_objects.py + +LIB_CLIENT_IDL = SALOMEDS.idl \ + SALOME_Exception.idl + +CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -DHAVE_CONFIG_H +LIBS+= $(PYTHON_LIBS) +LDFLAGS+= -lSalomeGUI + +@CONCLUDE@ diff --git a/src/SALOME_SWIG/PyInterp.py b/src/SALOME_SWIG/PyInterp.py new file mode 100644 index 000000000..35c999175 --- /dev/null +++ b/src/SALOME_SWIG/PyInterp.py @@ -0,0 +1,85 @@ +#============================================================================== +# File : PyInterp.py +# Created : mer oct 17 08:42:01 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +import sys +from omniORB import CORBA +from LifeCycleCORBA import * +from libSALOME_Swig import * +import SALOMEDS +from SALOME_NamingServicePy import * + + #-------------------------------------------------------------------------- + +def DumpComponent(Study, SO, offset): + it = Study.NewChildIterator(SO) + Builder = Study.NewBuilder() + while it.More(): + CSO = it.Value() + it.Next() + anAttr = Builder.FindOrCreateAttribute(CSO, "AttributeName") + AtName = anAttr._narrow(SALOMEDS.AttributeName) + t_name = AtName.Value() + if t_name[0] == 1: + ofs = 1 + a = "" + while ofs <= offset: + a = a + "--" + ofs = ofs +1 + print a + ">" + CSO.GetID() + " " + t_name[1] + t_RefSO = CSO.ReferencedObject() + if t_RefSO[0] == 1: + RefSO = t_RefSO[1] + ofs = 1 + a = "" + while ofs <= offset: + a = a + " " + ofs = ofs +1 + print a + ">" + RefSO.GetID() + DumpComponent(Study, CSO, offset+2) + + #-------------------------------------------------------------------------- + +def DumpStudy(Study): + itcomp = Study.NewComponentIterator() + while itcomp.More(): + SC = itcomp.Value() + itcomp.Next() + name = SC.ComponentDataType() + print "-> ComponentDataType is " + name + DumpComponent(Study, SC, 1) + + + #-------------------------------------------------------------------------- + +# initialise the ORB +orb = CORBA.ORB_init([''], CORBA.ORB_ID) + +# create an LifeCycleCORBA instance +lcc = LifeCycleCORBA(orb) + +# create an SALOMEGUI_Swig instance +sg = SALOMEGUI_Swig() + +#create an naming service instance +naming_service = SALOME_NamingServicePy_i(orb) + +# get active study name and id +myStudyName = sg.getActiveStudyName() +print myStudyName + +myStudyId = sg.getActiveStudyId() +print myStudyId + +# get Study Manager reference +obj = naming_service.Resolve('myStudyManager') +myStudyManager = obj._narrow(SALOMEDS.StudyManager) + +# get active study +myStudy = myStudyManager.GetStudyByName(myStudyName) + diff --git a/src/SALOME_SWIG/batchmode_salome.py b/src/SALOME_SWIG/batchmode_salome.py new file mode 100644 index 000000000..050ebeaea --- /dev/null +++ b/src/SALOME_SWIG/batchmode_salome.py @@ -0,0 +1,79 @@ +import salome_shared_modules + +from omniORB import CORBA +from LifeCycleCORBA import * +import SALOMEDS +from SALOME_NamingServicePy import * + +#-------------------------------------------------------------------------- + +def ImportComponentGUI(ComponentName): + libName = "lib" + ComponentName + "_Swig" + command = "from " + libName + " import *" + exec ( command ) + constructor = ComponentName + "GUI_Swig()" + command = "gui = " + constructor + exec ( command ) + return gui + + #-------------------------------------------------------------------------- + +def SalomeGUIgetAllSelected(self): + selNumber = self.SelectedCount() + listSelected = [] + for i in range(selNumber): + listSelected.append(self.getSelected(i)) + return listSelected + #-------------------------------------------------------------------------- + +from libSALOME_Swig import * +###from SalomePyQt import * +class SalomeGUI(SALOMEGUI_Swig): + getAllSelected = SalomeGUIgetAllSelected + + def getDesktop(self) : +# return SalomePyQt.getDesktop() + return None + + def getSelection(self) : +# return SalomePyQt.getSelection() + return None + + #-------------------------------------------------------------------------- + +def IDToObject(id): + mySO = myStudy.FindObjectID(id); + print id + Builder = myStudy.NewBuilder() + anAttr = Builder.FindOrCreateAttribute(mySO, "AttributeIOR") + AtIOR = anAttr._narrow(SALOMEDS.AttributeIOR) + myObj = orb.string_to_object(AtIOR.Value()) + return myObj + +def IDToSObject(id): + mySO = myStudy.FindObjectID(id); + return mySO + #-------------------------------------------------------------------------- + +#-------------------------------------------------------------------------- +# initialise the ORB +orb = CORBA.ORB_init([''], CORBA.ORB_ID) + +# create an LifeCycleCORBA instance +lcc = LifeCycleCORBA(orb) + +#create a naming service instance +naming_service = SALOME_NamingServicePy_i(orb) + +# get Study Manager reference +obj = naming_service.Resolve('myStudyManager') +myStudyManager = obj._narrow(SALOMEDS.StudyManager) + +# create new study +myStudy = myStudyManager.NewStudy("Study1") + +myStudyName = myStudy._get_Name() + +myStudyId = myStudy._get_StudyId() +print myStudyId + diff --git a/src/SALOME_SWIG/examplevtk1.py b/src/SALOME_SWIG/examplevtk1.py new file mode 100644 index 000000000..4d1be6306 --- /dev/null +++ b/src/SALOME_SWIG/examplevtk1.py @@ -0,0 +1,16 @@ +import libSalomePy +ren=libSalomePy.renderer +#iren=libSalomePy.interactor + +from libVTKCommonPython import * +from libVTKGraphicsPython import * +cone = vtkConeSource() +cone.SetResolution(8) +coneMapper = vtkPolyDataMapper() +coneMapper.SetInput(cone.GetOutput()) +coneActor = vtkActor() +coneActor.SetMapper(coneMapper) + +ren.AddActor(coneActor) +iren = vtkRenderWindowInteractor() + diff --git a/src/SALOME_SWIG/libSALOME_Swig.i b/src/SALOME_SWIG/libSALOME_Swig.i new file mode 100644 index 000000000..8c8c40fe9 --- /dev/null +++ b/src/SALOME_SWIG/libSALOME_Swig.i @@ -0,0 +1,14 @@ +//============================================================================= +// File : libSALOME_Swig.i +// Created : ven sep 28 17:39:35 CEST 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +%module libSALOME_Swig + +//%include "SALOME_NamingService.i" +%include "SALOMEGUI_Swig.i" + diff --git a/src/SALOME_SWIG/salome.py b/src/SALOME_SWIG/salome.py new file mode 100644 index 000000000..70e706dfb --- /dev/null +++ b/src/SALOME_SWIG/salome.py @@ -0,0 +1,123 @@ +#============================================================================== +# File : salome.py +# Created : sam nov 10 00:49:00 CET 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +from omniORB import CORBA +from LifeCycleCORBA import * +from libSALOME_Swig import * +import SALOMEDS +from SALOME_NamingServicePy import * + +from SALOME_utilities import * + +#-------------------------------------------------------------------------- + +def DumpComponent(Study, SO, offset): + it = Study.NewChildIterator(SO) + Builder = Study.NewBuilder() + while it.More(): + CSO = it.Value() + it.Next() + anAttr = Builder.FindOrCreateAttribute(CSO, "AttributeName") + AtName = anAttr._narrow(SALOMEDS.AttributeName) + t_name = AtName.Value() + if t_name[0] == 1: + ofs = 1 + a = "" + while ofs <= offset: + a = a + "--" + ofs = ofs +1 + MESSAGE( a + ">" + str(CSO.GetID()) + " " + str(t_name[1]) ) + t_RefSO = CSO.ReferencedObject() + if t_RefSO[0] == 1: + RefSO = t_RefSO[1] + ofs = 1 + a = "" + while ofs <= offset: + a = a + " " + ofs = ofs +1 + MESSAGE( a + ">" + str(RefSO.GetID()) ) + DumpComponent(Study, CSO, offset+2) + + #-------------------------------------------------------------------------- + +def DumpStudy(Study): + itcomp = Study.NewComponentIterator() + while itcomp.More(): + SC = itcomp.Value() + itcomp.Next() + name = SC.ComponentDataType() + MESSAGE( "-> ComponentDataType is " + name ) + DumpComponent(Study, SC, 1) + + + #-------------------------------------------------------------------------- + +def ImportComponentGUI(ComponentName): + libName = "lib" + ComponentName + "_Swig" + command = "from " + libName + " import *" + exec ( command ) + constructor = ComponentName + "GUI_Swig()" + command = "gui = " + constructor + exec ( command ) + return gui + + #-------------------------------------------------------------------------- + +def SalomeGUIgetAllSelected(self): + selNumber = self.SelectedCount() + listSelected = [] + for i in range(selNumber): + listSelected.append(self.getSelected(i)) + return listSelected + +class SalomeGUI(SALOMEGUI_Swig): + getAllSelected = SalomeGUIgetAllSelected + + #-------------------------------------------------------------------------- + +def IDToObject(id): + mySO = myStudy.FindObjectID(id); + Builder = myStudy.NewBuilder() + anAttr = Builder.FindOrCreateAttribute(mySO, "AttributeIOR") + AtIOR = anAttr._narrow(SALOMEDS.AttributeIOR) + myObj = orb.string_to_object(AtIOR.Value()) + return myObj + +def IDToSObject(id): + mySO = myStudy.FindObjectID(id); + return mySO + + #-------------------------------------------------------------------------- + +# initialise the ORB +orb = CORBA.ORB_init([''], CORBA.ORB_ID) + +# create an LifeCycleCORBA instance +lcc = LifeCycleCORBA(orb) + +# create an SALOMEGUI_Swig instance +sg = SalomeGUI() + +#create an naming service instance +naming_service = SALOME_NamingServicePy_i(orb) + +# get active study name and id +myStudyName = sg.getActiveStudyName() +MESSAGE( myStudyName ) + +myStudyId = sg.getActiveStudyId() +MESSAGE( str(myStudyId) ) + +# get Study Manager reference +obj = naming_service.Resolve('myStudyManager') +myStudyManager = obj._narrow(SALOMEDS.StudyManager) + +# get active study +myStudy = myStudyManager.GetStudyByName(myStudyName) + diff --git a/src/SALOME_SWIG/salome_shared_modules.py b/src/SALOME_SWIG/salome_shared_modules.py new file mode 100644 index 000000000..8b3fa2e82 --- /dev/null +++ b/src/SALOME_SWIG/salome_shared_modules.py @@ -0,0 +1,127 @@ +from SALOME_utilities import * + +""" +""" +MESSAGE( "Module salome_shared_modules" ) + +modules={} +try: + # We try to import PyQt module. If present we import it + # as a "shared" module + import qt + modules["qt"]=qt.__dict__ +except: + pass + +# We keep in modules a copy of dictionnary modules +# that need to be imported only once in multi-study context + +# Specific case : omniORB +import omniORB +modules["omniORB"]=omniORB.__dict__.copy() +import omniORB.CORBA +modules["omniORB.CORBA"]=omniORB.CORBA.__dict__.copy() +modules["CORBA"]=modules["omniORB.CORBA"] +import CosNaming +modules["CosNaming"]=CosNaming.__dict__.copy() +# end omniORB + +# +# We search all Python CORBA (omniorb) modules. +# A Python CORBA module has 2 associated Python packages +# These packages are named : and __POA +# + +# +# SALOMEDS must be imported first, at least before any CORBA module +# that references it. +# It seems that import order of related CORBA modules is important +# Perhaps, it's not sufficient so you should complete the list ??? +# +import SALOMEDS +import Engines + +import glob,os,sys + +repertoire=os.path.dirname(__file__) +path=[repertoire,] + +SALOME_ROOT_DIR = os.getenv("SALOME_ROOT_DIR") +if SALOME_ROOT_DIR != None: + path.append(os.path.join(SALOME_ROOT_DIR,"lib","python"+sys.version[:3],"site-packages","salome")) + +SALOME_SITE_DIR = os.getenv("SALOME_SITE_DIR") +if SALOME_SITE_DIR != None: + SALOME_SITE_NAME = os.getenv("SALOME_SITE_NAME") + if SALOME_SITE_NAME != None: + path.append(os.path.join(SALOME_SITE_DIR,"lib","python"+sys.version[:3],"site-packages",SALOME_SITE_NAME)) + +#path=[repertoire, +# os.path.join(repertoire,"..","lib","python"+sys.version[:3],"site-packages","salome"), +# os.path.join(SALOME_ROOT_DIR,"lib","python"+sys.version[:3],"site-packages","salome"), +# os.path.join(SALOME_SITE_DIR,"lib","python"+sys.version[:3],"site-packages","salome"), +# ] + +MESSAGE( str(path) ) + +for rep in path: + # Add rep directory in the Python path to be able to import modules + sys.path[:0]=[rep] + listdir=glob.glob(os.path.join(rep,"*__POA")) + for elem in listdir: + if os.path.isdir(elem): + # Found a directory (Python package) named *__POA + module__POA=os.path.basename(elem) + module=module__POA[:-5] + MESSAGE( "Import CORBA module: " + module + ".\n Directory: " + os.path.abspath(elem)[:-5] ) + mod=__import__(module) + # force the reload of CORBA module to resolve all the include relations between modules + # specific of omniORBpy implementation (1.5) + reload(mod) + modules[module]=mod.__dict__.copy() + # Now we import modules found in shared_modules directory + r=os.path.join(rep,"shared_modules") + MESSAGE( r ) + if os.path.isdir(r): + sys.path[:0]=[r] + listfich=glob.glob(os.path.join(r,"*.py")) + MESSAGE( str(listfich) ) + for m in listfich: + module=os.path.basename(m)[:-3] + MESSAGE( "Import module: " + module + ".\n Location: " + os.path.abspath(m) ) + mod=__import__(module) + modules[module]=mod.__dict__.copy() + # Don't keep r directory in the path to not pollute it + del sys.path[0] + + # Don't keep rep directory in the path to not pollute it + del sys.path[0] + +# End of CORBA modules import + +def import_shared_modules(sysmodules): + """ + This function "imports" shared modules contained in modules dictionnary + in sysmodules. + All these modules are only copied and not completely imported (not executed) + """ + # EDF-CCAR: + # Problem with omniORB : omniORB creates a C Python module named _omnipy + # this module has sub-modules : omni_func, ... + # _omnipy is quite a package but import with Python sub-interpreters does not seem to work + # To make it work we need to add those sub-modules in sysmodules + import _omnipy + sysmodules["_omnipy.omni_func"]=_omnipy.omni_func + sysmodules["_omnipy.poa_func"]=_omnipy.poa_func + sysmodules["_omnipy.poamanager_func"]=_omnipy.poa_func + sysmodules["_omnipy.orb_func"]=_omnipy.orb_func + + import imp + + # All modules in the modules dictionnary are only copied, not completely imported + for nom_module,module_dict in modules.items(): + if sysmodules.has_key(nom_module):continue + m=imp.new_module(nom_module) + m.__dict__.update(module_dict) + sysmodules[nom_module]=m + diff --git a/src/SALOME_SWIG/supervisionexample.py.in b/src/SALOME_SWIG/supervisionexample.py.in new file mode 100644 index 000000000..56bdd9bf5 --- /dev/null +++ b/src/SALOME_SWIG/supervisionexample.py.in @@ -0,0 +1,85 @@ +#============================================================================== +# File : supervisionexample.py +# Created : 23 nov 2001 +# Author : Jean Rahuel +# Project : SALOME +# Copyright : CEA +#============================================================================== + +from SuperV import * + + + +# load this object with Nodes, Links and Datas stored in GraphEssai.xml +# (GraphEssai.xml was created with python in SuperVisionTest and GraphEssai.py) +myGraph = Graph("@ROOT_BUILDDIR@/share/salome/resources/GraphEssai.xml") + +#myGraph = Graph("/home/data/jr_HEAD/build/share/salome/resources/GraphEssai.xml") +# This DataFlow is "valid" : no loop, correct links between Nodes etc... + +print myGraph.IsValid() + +# Get Nodes +myGraph.PrintNodes() +Add,Sub,Mul,Div = myGraph.Nodes() + +# Load Datas +Addx = Add.Input("x",3.) +Addy = Add.Input("y",4.5) +Subx = Sub.Input("x",1.5) + +# Get Output Port +Addz = Add.Port('z') +Subz = Sub.Port('z') +Mulz = Mul.Port('z') +Divz = Div.Port('z') + +# This DataFlow is "executable" : all pending Ports are defined with Datas +print myGraph.IsExecutable() + +# Starts only execution of that DataFlow and gets control immediatly +print myGraph.Run() + +# That DataFlow is running ==> 0 (false) +print myGraph.IsDone() + +# Events of execution : +aStatus,aNode,anEvent,aState = myGraph.Event() +while aStatus : + print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState + aStatus,aNode,anEvent,aState = myGraph.Event() +print myGraph.IsDone() + +# Wait for Completion (but it is already done after event loop ...) +print "Done : ",myGraph.DoneW() + +# Get result +print "Result : ",Divz.ToString() + +# Intermediate results : +print "Intermediate Result Add\z : ",Addz.ToString() +print "Intermediate Result Sub\z : ",Subz.ToString() +print "Intermediate Result Mul\z : ",Mulz.ToString() + +print " " +print "Type : print myGraph.IsDone()" +print " If execution is finished ==> 1 (true)" +print " " +print "Type : print Divz.ToString()" +print " You will get the result" +print " " +print "Type : myGraph.PrintPorts()" +print " to see input and output values of the graph" +print " " +print "Type : Add.PrintPorts()" +print "Type : Sub.PrintPorts()" +print "Type : Mul.PrintPorts()" +print "Type : Div.PrintPorts()" +print " to see input and output values of nodes" + +# Export will create newsupervisionexample.xml and the corresponding .py file +print myGraph.Export("@ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.xml") + +print " " +print "See file @ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.xml" +print "See file @ROOT_BUILDDIR@/share/salome/resources/newsupervisionexample.py" diff --git a/src/SALOME_SWIG/supervisiongeomexample.py.in b/src/SALOME_SWIG/supervisiongeomexample.py.in new file mode 100644 index 000000000..8c56bb1f2 --- /dev/null +++ b/src/SALOME_SWIG/supervisiongeomexample.py.in @@ -0,0 +1,103 @@ + +# Generated python file of Graph GraphGeom2Essai + +from SuperV import * + +import salome + +import geompy + + +geom = lcc.FindOrLoadComponent("FactoryServer", "Geometry") +geom.GetCurrentStudy(salome.myStudyId) + +myBuilder = salome.myStudy.NewBuilder() + +# Graph creation +GraphGeom2Essai = Graph( 'GraphGeom2Essai' ) +print GraphGeom2Essai.SetAuthor( '' ) +print GraphGeom2Essai.SetComment( '' ) +GraphGeom2Essai.Coords( 0 , 0 ) + +# Creation of Nodes +MakeSphere = GraphGeom2Essai.Node( 'Geometry' , 'Geometry' , 'MakeSphere' ) +print MakeSphere.SetAuthor( '' ) +print MakeSphere.SetContainer( 'FactoryServer' ) +print MakeSphere.SetComment( '' ) +MakeSphere.Coords( 26 , 13 ) +MakeCopy = GraphGeom2Essai.Node( 'Geometry' , 'Geometry' , 'MakeCopy' ) +print MakeCopy.SetAuthor( '' ) +print MakeCopy.SetContainer( 'FactoryServer' ) +print MakeCopy.SetComment( '' ) +MakeCopy.Coords( 219 , 12 ) +MakeTranslation = GraphGeom2Essai.Node( 'Geometry' , 'Geometry' , 'MakeTranslation' ) +print MakeTranslation.SetAuthor( '' ) +print MakeTranslation.SetContainer( 'FactoryServer' ) +print MakeTranslation.SetComment( '' ) +MakeTranslation.Coords( 219 , 159 ) +MakeFuse = GraphGeom2Essai.Node( 'Geometry' , 'Geometry' , 'MakeFuse' ) +print MakeFuse.SetAuthor( '' ) +print MakeFuse.SetContainer( 'FactoryServer' ) +print MakeFuse.SetComment( '' ) +MakeFuse.Coords( 465 , 106 ) + +# Creation of intermediate Output variables and of links +MakeSphereshape = MakeSphere.Port( 'shape' ) +MakeCopyshape1 = GraphGeom2Essai.Link( MakeSphereshape , MakeCopy.Port( 'shape1' ) ) +MakeTranslationshape1 = GraphGeom2Essai.Link( MakeSphereshape , MakeTranslation.Port( 'shape1' ) ) +MakeCopyshape = MakeCopy.Port( 'shape' ) +MakeFuseshape1 = GraphGeom2Essai.Link( MakeCopyshape , MakeFuse.Port( 'shape1' ) ) +MakeTranslationshape = MakeTranslation.Port( 'shape' ) +MakeFuseshape2 = GraphGeom2Essai.Link( MakeTranslationshape , MakeFuse.Port( 'shape2' ) ) + +# Creation of Input datas +MakeSpherex1 = MakeSphere.Input( 'x1' , 0) +MakeSpherey1 = MakeSphere.Input( 'y1' , 0) +MakeSpherez1 = MakeSphere.Input( 'z1' , 0) +MakeSphereradius = MakeSphere.Input( 'radius' , 50) +MakeTranslationx1 = MakeTranslation.Input( 'x1' , 80) +MakeTranslationy1 = MakeTranslation.Input( 'y1' , 0) +MakeTranslationz1 = MakeTranslation.Input( 'z1' , 0) + +# Missing Input datas : None + +# Creation of Output variables +MakeFuseshape = MakeFuse.Port( 'shape' ) + +# State of Ports of the Graph +GraphGeom2Essai.PrintPorts() + +# Start asynchronous run +print GraphGeom2Essai.Run() + +# Done ? +print GraphGeom2Essai.IsDone() + +# Events of execution : +aStatus,aNode,anEvent,aState = GraphGeom2Essai.Event() +while aStatus : + print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState + aStatus,aNode,anEvent,aState = GraphGeom2Essai.Event() +print GraphGeom2Essai.IsDone() + +# Waiting end of execution : +print GraphGeom2Essai.DoneW() + +print " " +print "Type print GraphGeom2Essai.IsDone()" +print "1 <==> It's done" +print " " +print "Type print GraphGeom2Essai.DoneW()" +print "Wait until end of execution : 1(success)" +print " " +print "Type GraphGeom2Essai.PrintPorts()" +print " to see input and output values of the graph" +print " " +print "Type MakeSphere.PrintPorts()" +print "Type MakeCopy.PrintPorts()" +print "Type MakeTranslation.PrintPorts()" +print "Type MakeFuse.PrintPorts()" +print " to see input and output values of nodes" +print " " +print "Type print GraphGeom2Essai.Export('File-Name')" +print "You will get a .py and a .xml file of this graph" diff --git a/src/SALOME_SWIG/test_big_table.py b/src/SALOME_SWIG/test_big_table.py new file mode 100644 index 000000000..b451bfcf7 --- /dev/null +++ b/src/SALOME_SWIG/test_big_table.py @@ -0,0 +1,57 @@ +#============================================================================== +# File : test_big_table.py +# Created : 20/01/03 +# Author : Vadim SANDLER +# Project : SALOME +# Copyright : Open CASCADE +# $Header$ +#============================================================================== + +# ============================================================================ +# Test large tables : ~200 curves ( 100 points in each ) +# ============================================================================ +import salome +import math +import SALOMEDS + +# >>> Getting study builder ================================================== +myStudy = salome.myStudy +myBuilder = myStudy.NewBuilder() + +# >>> Creating virtual component ============================================= +myComponent = myStudy.FindComponent("VirtualComponent") +if not myComponent: + myComponent = myBuilder.NewComponent("VirtualComponent") + aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") + aName.SetValue("VirtualComponent") + +# >>> Creating object with Table of real[ 200 * 20 ] ======================== +myTRealObject = myBuilder.NewObject(myComponent) +AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName") +AName.SetValue("Table Of Real") +ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal") +myHorNb = 10 +myVerNb = 200 + +k={} +for j in range(0,myHorNb): + k[j] = j*10+1 +ARealTable.AddRow(k.values()) +ARealTable.SetRowTitle(1, "Frequency") +ARealTable.SetRowUnit(1, "Hz") + +for i in range(1,myVerNb+1): + for j in range(0,myHorNb): + if j % 2 == 1: + k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5 + else: + k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5 + ARealTable.AddRow(k.values()) + ARealTable.SetRowTitle(i+1, "Power " + str(i)) + ARealTable.SetRowUnit(i+1, "Wt") +ARealTable.SetTitle("Very useful data") + +# >>> Updating Object Browser ================================================ +salome.sg.updateObjBrowser(1) + +# ============================================================================ diff --git a/src/SALOME_SWIG/test_many_objects.py b/src/SALOME_SWIG/test_many_objects.py new file mode 100644 index 000000000..410c9929d --- /dev/null +++ b/src/SALOME_SWIG/test_many_objects.py @@ -0,0 +1,77 @@ +#============================================================================== +# File : visu_many_objects.py +# Created : 28/02/03 +# Author : Vadim SANDLER +# Project : SALOME +# Copyright : Open CASCADE +# $Header$ +#============================================================================== + +# ============================================================================ +# Check performance for many objects creations +# ============================================================================ +import salome +import SALOMEDS + +# >>> Getting study builder ================================================== +myStudy = salome.myStudy +myBuilder = myStudy.NewBuilder() + +# >>> Creating virtual component ============================================= +myComponent = myBuilder.NewComponent("VIRTUAL") +AName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") +AName.SetValue("Virtual") +ACmt = myBuilder.FindOrCreateAttribute(myComponent, "AttributeComment") +ACmt.SetValue("Virtual") + +# >>> Creating objects ======================================================= +# TO CHANGE TOTAL NUMBER OF OBJECTS, SET PROPER , , +# IF YOU DON'T WANT TO ADD REFERENCES, SET = 0 +myNb1 = 20 +myNb2 = 5 +myNb3 = 3 +myAddRef = 1 + +if myAddRef == 1: + myContainer = myBuilder.NewObject(myComponent) + AName = myBuilder.FindOrCreateAttribute(myContainer, "AttributeName") + AName.SetValue("References") + ACmt = myBuilder.FindOrCreateAttribute(myContainer, "AttributeComment") + ACmt.SetValue("Container for objects") + +for i in range(0,myNb1): + myObject1 = myBuilder.NewObject(myComponent) + AName = myBuilder.FindOrCreateAttribute(myObject1, "AttributeName") + AName.SetValue("Object "+str(i)) + ACmt = myBuilder.FindOrCreateAttribute(myObject1, "AttributeComment") + ACmt.SetValue("Virtual object "+str(i)) + if myAddRef == 1: + myRefObject = myBuilder.NewObject(myContainer) + myBuilder.Addreference(myRefObject,myObject1); + + for j in range(0,myNb2): + myObject2 = myBuilder.NewObject(myObject1) + AName = myBuilder.FindOrCreateAttribute(myObject2, "AttributeName") + AName.SetValue("Object "+str(i)+"-"+str(j)) + ACmt = myBuilder.FindOrCreateAttribute(myObject2, "AttributeComment") + ACmt.SetValue("Virtual object "+str(i)+"-"+str(j)) + if myAddRef == 1: + myRefObject = myBuilder.NewObject(myContainer) + myBuilder.Addreference(myRefObject,myObject2); + + for k in range(0,myNb3): + myObject3 = myBuilder.NewObject(myObject2) + AName = myBuilder.FindOrCreateAttribute(myObject3, "AttributeName") + AName.SetValue("Object "+str(i)+"-"+str(j)+"-"+str(k)) + ACmt = myBuilder.FindOrCreateAttribute(myObject3, "AttributeComment") + ACmt.SetValue("Virtual object "+str(i)+"-"+str(j)+"-"+str(k)) + if myAddRef == 1: + myRefObject = myBuilder.NewObject(myContainer) + myBuilder.Addreference(myRefObject,myObject3); + +# >>> Updating Object Browser ================================================ +salome.sg.updateObjBrowser(1) + +# ============================================================================ + + diff --git a/src/SALOME_SWIG/test_table.py b/src/SALOME_SWIG/test_table.py new file mode 100644 index 000000000..d33636838 --- /dev/null +++ b/src/SALOME_SWIG/test_table.py @@ -0,0 +1,103 @@ +#============================================================================== +# File : test_table.py +# Created : 20/01/03 +# Author : Vadim SANDLER +# Project : SALOME +# Copyright : Open CASCADE +# $Header$ +#============================================================================== + +# ============================================================================ +# Check attributes creation : Integer, Real, Comment, Tables +# ============================================================================ +import salome +import math +import SALOMEDS + +# >>> Getting study builder ================================================== +myStudy = salome.myStudy +myBuilder = myStudy.NewBuilder() + +# >>> Creating virtual component ============================================= +myComponent = myStudy.FindComponent("VirtualComponent") +if not myComponent: + myComponent = myBuilder.NewComponent("VirtualComponent") + aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") + aName.SetValue("VirtualComponent") + +# >>> Creating object with Table of integer ================================== +myTIntObject = myBuilder.NewObject(myComponent) +AName = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeName") +AName.SetValue("Table Of Integer") +AIntTable = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeTableOfInteger") + +a=[1,2,3,4,5,6,7,8,9,10] +AIntTable.AddRow(a) +a=[110,120,130,140,150,160,170,180,190,200] +AIntTable.AddRow(a) +a=[-1,272,0,0,-642,10000,13,578,-578,99] +AIntTable.AddRow(a) +AIntTable.SetTitle("TEST table of integer") +AIntTable.SetRowTitle(1,"FR") +AIntTable.SetRowUnit(1,"m/h") +AIntTable.SetRowTitle(2,"SR") +AIntTable.SetRowUnit(2,"s") +AIntTable.SetRowTitle(3,"TR") +AIntTable.SetRowUnit(3,"$") +c=["C1","C2","C3","C4","C5","C6","C7","C8","C9","C10"] +AIntTable.SetColumnTitles(c) + +# >>> Creating object with Table of real ===================================== +myTRealObject = myBuilder.NewObject(myComponent) +AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName") +AName.SetValue("Table Of Real") +ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal") + +k={} +l={} +for j in range(0,20): + k[j] = j*10+1 + l[j] = "C"+str(j+1) +ARealTable.AddRow(k.values()) +ARealTable.SetRowTitle(1, "Row 0") +ARealTable.SetRowUnit(1, "Hz") +ARealTable.SetColumnTitles(l.values()) +for i in range(1,11): + for j in range(1,21): + if j % 2 == 1: + k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5 + else: + k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5 + ARealTable.AddRow(k.values()) + ARealTable.SetRowTitle(i+1, "Row " + str(i)) + ARealTable.SetRowUnit(i+1, "Wt") +ARealTable.SetTitle("TEST table of real") + +# >>> Creating object with integer attribute ================================= +myIntObject = myBuilder.NewObject(myComponent) +AName = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeName") +AName.SetValue("Integer") +AInt = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeInteger") +AInt.SetValue(123) + +# >>> Creating object with real attribute ==================================== +myRealObject = myBuilder.NewObject(myComponent) +AName = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeName") +AName.SetValue("Real") +AReal = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeReal") +AReal.SetValue(-56.9634) + +# >>> Creating object with comment attribute ================================= +myCmtObject = myBuilder.NewObject(myComponent) +AName = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeName") +AName.SetValue("Comment") +ACmt = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeComment") +ACmt.SetValue("Just a comment") + +# >>> Updating Object Browser ================================================ +salome.sg.updateObjBrowser(1) + +# ============================================================================ + + + diff --git a/src/SALOME_SWIG/testattr.py b/src/SALOME_SWIG/testattr.py new file mode 100644 index 000000000..ae7fef119 --- /dev/null +++ b/src/SALOME_SWIG/testattr.py @@ -0,0 +1,86 @@ +# importing ===================================================== +import SALOMEDS +#import SALOMEDS_Attributes_idl +import geompy +import salome +# =============================================================== + +# creating new object =========================================== +obj = geompy.myBuilder.NewObject(geompy.father) + +# adding Name attribute ========================================= +A1 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeName") +name = A1._narrow(SALOMEDS.AttributeName) +name.SetValue("First Object") + +# adding Comment attribute ====================================== +A2 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeComment") +comment = A2._narrow(SALOMEDS.AttributeComment) +comment.SetValue("This is Comment attribute") + +# adding IOR attribute ========================================== +#A3 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeIOR") +# ... + +# adding integer attribute ====================================== +A4 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeInteger") +integer = A4._narrow(SALOMEDS.AttributeInteger) +integer.SetValue(12) + +# adding real attribute ========================================= +A5 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeReal") +real = A5._narrow(SALOMEDS.AttributeReal) +real.SetValue(0.25) + +# adding sequence of integer attribute ========================== +A6 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeSequenceOfInteger") +intseq = A6._narrow(SALOMEDS.AttributeSequenceOfInteger) +intseq.Add(1) +intseq.Add(2) +intseq.Add(3) + + +# adding sequence of real attribute ============================= +A7 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeSequenceOfReal") +realseq = A7._narrow(SALOMEDS.AttributeSequenceOfReal) +realseq.Add(0.001) +realseq.Add(0.002) +realseq.Add(0.003) + +# adding PersistentRef attribute ================================ +#A8 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributePersistentRef") +# ... + +# adding Drawable attribute ===================================== +A9 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeDrawable") +drawable = A9._narrow(SALOMEDS.AttributeDrawable) +drawable.SetDrawable(1) + +# adding Selectable attribute =================================== +#A10 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeSelectable") +# ... + +# adding Expandable attribute =================================== +#A11 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeExpandable") +# ... + +# adding Opened attribute ======================================= +#A12 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeOpened") +# ... + +# adding TextColor attribute ==================================== +A13 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeTextColor") +textcolor = A13._narrow(SALOMEDS.AttributeTextColor) + +# ... + +# adding TextHighlightColor of real attribute =================== +#A14 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributeTextHighlightColor") +# ... + +# adding PixMap of real attribute =============================== +#A15 = geompy.myBuilder.FindOrCreateAttribute(obj,"AttributePixMap") +# ... + +# opening OCAF Browser ========================================== +# result = salome.myStudy.OCAFBrowser() diff --git a/src/SUPERVGraph/Makefile.in b/src/SUPERVGraph/Makefile.in new file mode 100644 index 000000000..967802506 --- /dev/null +++ b/src/SUPERVGraph/Makefile.in @@ -0,0 +1,32 @@ +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_HEADERS = \ + SUPERVGraph_ViewFrame.h + +# Libraries targets + +LIB = libSUPERVGraph.la +LIB_SRC = SUPERVGraph.cxx \ + SUPERVGraph_ViewFrame.cxx + +LIB_MOC = SUPERVGraph_moc.cxx \ + SUPERVGraph_ViewFrame_moc.cxx + +LIB_CLIENT_IDL = SALOMEDS.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + SALOME_Exception.idl + + +CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) +LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) -L$(top_builddir)/lib -lSalomeGUI + + +@CONCLUDE@ diff --git a/src/SUPERVGraph/SUPERVGraph.cxx b/src/SUPERVGraph/SUPERVGraph.cxx new file mode 100644 index 000000000..904aa3fcd --- /dev/null +++ b/src/SUPERVGraph/SUPERVGraph.cxx @@ -0,0 +1,24 @@ +using namespace std; +// File : SUPERVGraph.cxx +// Created : Wed Mar 20 11:58:44 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SUPERVGraph +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "SUPERVGraph.h" +#include "SUPERVGraph_ViewFrame.h" + +QAD_ViewFrame* SUPERVGraph::createView(QAD_RightFrame* parent) +{ + return new SUPERVGraph_ViewFrame( parent, "vtkView" ); +} + +extern "C" +{ + QAD_ViewFrame* createView(QAD_RightFrame* parent) + { + return SUPERVGraph::createView(parent); + } +} diff --git a/src/SUPERVGraph/SUPERVGraph.h b/src/SUPERVGraph/SUPERVGraph.h new file mode 100644 index 000000000..d785039d8 --- /dev/null +++ b/src/SUPERVGraph/SUPERVGraph.h @@ -0,0 +1,25 @@ +// File : SUPERVGraph.h +// Created : Wed Mar 20 11:56:18 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SUPERVGraph +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef SUPERVGraph_HeaderFile +#define SUPERVGraph_HeaderFile + +#include "QAD_RightFrame.h" +#include "QAD_ViewFrame.h" + +class SUPERVGraph : public QObject +{ + Q_OBJECT + +public : + + Standard_EXPORT static QAD_ViewFrame* createView ( QAD_RightFrame* parent); + +}; + +#endif diff --git a/src/SUPERVGraph/SUPERVGraph_Graph.cxx b/src/SUPERVGraph/SUPERVGraph_Graph.cxx new file mode 100644 index 000000000..11f3929db --- /dev/null +++ b/src/SUPERVGraph/SUPERVGraph_Graph.cxx @@ -0,0 +1,284 @@ +using namespace std; +// File : SUPERVGraph_Graph.cxx +// Created : 17 / 10 / 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGraph +// Copyright : Open CASCADE + +#include "SUPERVGraph_Graph.h" + +#include "QAD_Settings.h" +#include "QAD_Config.h" + +#include +#include + + +SUPERVGraph_Graph::SUPERVGraph_Graph(QWidget* parent) : + QScrollView(parent), + where(QPoint(0, 0)) +{ + installEventFilter(viewport()); + // viewport()->setBackgroundColor(QColor(165, 255, 176)); + + connect(this, SIGNAL(contentsMoving(int, int)), this, SLOT(Draw(int, int))); + + popup = new QPopupMenu(viewport()); + // if (main->isModify()) { + // pan = popup->insertItem("Add Node", main, SLOT(addNode())); + // pap = popup->insertItem("Add Point", this, SLOT(addPoint())); + // pdl = popup->insertItem("Delete Link", this, SLOT(deleteLink())); + // pif = popup->insertItem("Insert File", main, SLOT(insertFile())); + // pci = popup->insertItem("Change Informations", this, SLOT(changeInformation())); + // popup->insertSeparator(); + // }; + // popup->insertItem("Add in Study", main, SLOT(addStudy())); + // popup->insertItem("Show Informations", this, SLOT(showInformation())); + // popup->insertSeparator(); + // popup->insertItem("Copy (Read Only)", main, SLOT(copyReading())); + // popup->insertItem("Copy (Modifiying)", main, SLOT(copyModifying())); +} + +void SUPERVGraph_Graph::sync() { + // bool editing = main->getDataflow()->IsEditing(); + // if (main->isModify()) { + // popup->setItemEnabled(pci, editing); + // popup->setItemEnabled(pan, editing); + // popup->setItemEnabled(pap, editing); + // popup->setItemEnabled(pdl, editing); + // popup->setItemEnabled(pif, editing); + // }; + + // SUPERVGraph_Node* ihmNode; + // QObjectList* ihmList = queryList("SUPERVGraph_Node"); + // SUPERV_Nodes nodes = main->getDataflow()->Nodes(); + // int n = nodes->length(); + + // for (int i=0; iName(), "SUPERVGraph_Node"); + // if (ihmNode == NULL) { + // ihmNode = new SUPERVGraph_Node(viewport(), main, nodes[i]); + // addChild(ihmNode, nodes[i]->X(), nodes[i]->Y()); + // } else { + // moveChild(ihmNode, nodes[i]->X(), nodes[i]->Y()); + // ihmList->removeRef(ihmNode); + // }; + // ihmNode->sync(); + // }; + + // QObjectListIt i(*ihmList); + // while ((ihmNode=(SUPERVGraph_Node*)i.current()) != 0) { + // ++i; + // ihmNode->close(); + // }; + // delete ihmList; + + // SUPERVGraph_PortIn* pi; + // ihmList = queryList("SUPERVGraph_PortIn"); + // i = *ihmList; + // while ((pi=(SUPERVGraph_PortIn*)i.current()) != 0) { + // ++i; + // pi->sync(true); + // }; + // delete ihmList; + + // SUPERVGraph_PortOut* po; + // ihmList = queryList("SUPERVGraph_PortOut"); + // i = *ihmList; + // while ((po=(SUPERVGraph_PortOut*)i.current()) != 0) { + // ++i; + // po->sync(); + // }; + // delete ihmList; + + // Draw(0, 0); +} + +SUPERVGraph_Graph::~SUPERVGraph_Graph() { +} + +bool SUPERVGraph_Graph::eventFilter(QObject* object, QEvent* event) { + if ((event->type() == QEvent::Move ) || + (event->type() == QEvent::Paint) || + (event->type() == QEvent::Resize) ) { + Draw(0, 0); + }; + return(QScrollView::eventFilter(object, event)); +} + +void SUPERVGraph_Graph::Draw(int x, int y) { + QPainter p(viewport()); + p.eraseRect(viewport()->rect()); + p.setPen(QPen(Qt::black, 2)); + + // SUPERVGraph_Point* c; + // SUPERVGraph_Point* n; + // QObjectList* points = queryList("SUPERVGraph_Point"); + // QObjectListIt i(*points); + // while ((c=(SUPERVGraph_Point*)i.current()) != 0) { + // ++i; + // n=c->getNext(); + // if (n!=c) { + // p.drawLine(contentsToViewport(QPoint(c->getX()+POINT_SIZE_HALF, c->getY()+POINT_SIZE_HALF)), + // contentsToViewport(QPoint(n->getX()+POINT_SIZE_HALF, n->getY()+POINT_SIZE_HALF)) ); + // }; + // }; + // delete points; +} + +void SUPERVGraph_Graph::contentsMousePressEvent(QMouseEvent* e) { + where = viewportToContents(viewport()->mapFromGlobal(e->globalPos())); + // main->showPopup(popup, e); +} + +void SUPERVGraph_Graph::contentsMouseReleaseEvent(QMouseEvent* e) { + // main->sketchPoint(NULL); + + if ( e->button() == Qt::RightButton ) { + QPopupMenu* popup = createPopup(); + if ( popup ) { + popup->exec( QCursor::pos() ); + destroyPopup(); + } + return; + } + +} + +void SUPERVGraph_Graph::contentsMouseMoveEvent(QMouseEvent* e) { + // main->sketchMove(); +} + +float SUPERVGraph_Graph::distance(int xp, int yp, int xl, int yl, int xn, int yn) { + float r, s; + float a, b, c, d; + + float px = (float)(xp); + float py = (float)(yp); + float lx = (float)(xl); + float ly = (float)(yl); + float nx = (float)(xn); + float ny = (float)(yn); + + r = px - lx; + r = r * r; + s = py - ly; + s = s * s; + a = r + s; + + r = px - nx; + r = r * r; + s = py - ny; + s = s * s; + b = r + s; + + r = nx - lx; + r = r * r; + s = ny - ly; + s = s * s; + c = r + s; + + if (c<0.001) { + return(a); + } else { + r = a + c - b; + r = r * r; + d = r / ( 4 * c); + return(a - d); + }; +} + +QPoint SUPERVGraph_Graph::getPoint() { + return(where); +} + +// SUPERVGraph_Point* SUPERVGraph_Graph::findPoint(int x, int y) { +// float m; +// float d = SCROLL_MAX; +// SUPERVGraph_Point* t = NULL; +// SUPERVGraph_Point* c; +// SUPERVGraph_Point* n; +// QObjectList* points = queryList("SUPERVGraph_Point"); +// QObjectListIt i(*points); + +// while ((c=(SUPERVGraph_Point*)i.current()) != 0) { +// ++i; +// n=c->getNext(); +// if (n != c) { +// m = distance(x, y, c->getX(), c->getY(), n->getX(), n->getY()); +// if (m < d) { +// d = m; +// t = c; +// }; +// }; +// }; +// delete points; +// return(t); +// } + +void SUPERVGraph_Graph::addPoint() { + // int x = where.x(); + // int y = where.y(); + // SUPERVGraph_Point* p = findPoint(x, y); + // if (p == NULL) { + // QMessageBox::warning(0, "Supervision Error", "No Link to Add a Point"); + // } else { + // p->addPoint(x, y, true); + // }; +} + +void SUPERVGraph_Graph::deleteLink() { + // SUPERVGraph_Point* p = findPoint(where.x(), where.y()); + // if (p == NULL) { + // QMessageBox::warning(0, "Supervision Error", "No Link to Delete"); + // } else { + // SUPERV_Link l = p->getLink(); + // if (l == NULL) { + // QMessageBox::warning(0, "Supervision Error", "No Link to Delete"); + // } else { + // l->Destroy(); + // main->sync(); + // }; + // }; +} + +void SUPERVGraph_Graph::showInformation() { + // if (Supervision.information(Engines::Node::_narrow(main->getDataflow()), false)) { + // main->sync(); + // }; +} + +void SUPERVGraph_Graph::changeInformation() { + // if (Supervision.information(Engines::Node::_narrow(main->getDataflow()), true)) { + // main->sync(); + // }; +} + +/*! + Creates the popup +*/ +void SUPERVGraph_Graph::onCreatePopup() +{ + if ( myPopup ) { +// if (myPopup->count()<1) { + if ( myPopup->count() > 0 ) + myIDs.append ( myPopup->insertSeparator() ); + int id; + myIDs.append ( id = myPopup->insertItem (tr ("MEN_VP3D_CHANGEBGR")) ); + QAD_ASSERT ( myPopup->connectItem ( id, this, SLOT(onChangeBackgroundColor())) ); +// } + } +} + +void SUPERVGraph_Graph::onChangeBackgroundColor() +{ + QColor previousColor = viewport()->backgroundColor(); + QColor selColor = QColorDialog::getColor ( previousColor, NULL ); + if ( selColor.isValid() ) + viewport()->setBackgroundColor( selColor ); + + QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorRed", selColor.red() ); + QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorGreen", selColor.green() ); + QAD_CONFIG->addSetting( "SUPERVGraph:BackgroundColorBlue", selColor.blue() ); +} diff --git a/src/SUPERVGraph/SUPERVGraph_Graph.h b/src/SUPERVGraph/SUPERVGraph_Graph.h new file mode 100644 index 000000000..510682b59 --- /dev/null +++ b/src/SUPERVGraph/SUPERVGraph_Graph.h @@ -0,0 +1,64 @@ +// File : SUPERVGraph_Graph.h +// Created : 17 / 10 / 2001 +// Author : Francis KLOSS +// Project : SALOME +// Module : SUPERVGraph +// Copyright : Open CASCADE + +#ifndef SUPERVGraph_Graph_HXX +#define SUPERVGraph_Graph_HXX + +#include "QAD.h" +#include "QAD_Popup.h" + +#include +#include + +class QAD_EXPORT SUPERVGraph_Graph: public QScrollView, public QAD_PopupClientServer +{ + Q_OBJECT + +public: + SUPERVGraph_Graph(QWidget* parent); + ~SUPERVGraph_Graph(); + + /* popup management */ + void onCreatePopup(); + + void sync(); + void contentsMousePressEvent(QMouseEvent* e); + void contentsMouseReleaseEvent(QMouseEvent* e); + void contentsMouseMoveEvent(QMouseEvent* e); + + QPoint getPoint(); + +public slots: + void Draw(int x, int y); + +private slots: + void addPoint(); + void deleteLink(); + void showInformation(); + void changeInformation(); + +protected slots: + void onChangeBackgroundColor(); + +protected: + bool eventFilter(QObject* object, QEvent* event); + +private: +// SUPERVGraph_Point* findPoint(int x, int y); + float distance(int xp, int yp, int xl, int yl, int xn, int yn); + +// SUPERVGraph_Main* main; + QPoint where; + QPopupMenu* popup; + int pci; + int pan; + int pap; + int pdl; + int pif; +}; + +#endif diff --git a/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx b/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx new file mode 100644 index 000000000..2d60c2f94 --- /dev/null +++ b/src/SUPERVGraph/SUPERVGraph_ViewFrame.cxx @@ -0,0 +1,291 @@ +using namespace std; +// File : SUPERVGraph_ViewFrame.cxx +// Created : Wed Mar 20 14:03:31 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SUPERVGraph +// Copyright : Open CASCADE 2002 +// $Header$ + + +#include "SUPERVGraph_ViewFrame.h" + +#include "QAD_Settings.h" +#include "QAD_Config.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "SALOME_Selection.h" + +#include "utilities.h" + +//QT Include +#include +#include + +SUPERVGraph_View::SUPERVGraph_View(QWidget* theParent): QWidget(theParent){ + init(theParent); +} +SUPERVGraph_View::SUPERVGraph_View(SUPERVGraph_View* theParent): QWidget(theParent){ + setPopupServer(theParent->getPopupServer()); + init(theParent); +} +void SUPERVGraph_View::init(QWidget* theParent){ + if ( theParent->inherits( "QMainWindow" ) ) { + ( ( QMainWindow* )theParent )->setCentralWidget( this ); + } + else { + QBoxLayout* layout = new QVBoxLayout( theParent ); + layout->addWidget( this ); + } + +} +void SUPERVGraph_View::onCreatePopup(){ + /* + if ( myPopup ) { + QAD_Desktop* Desktop = (QAD_Desktop*) QAD_Application::getDesktop(); + QAD_Study* ActiveStudy = Desktop->getActiveStudy(); + SALOME_Selection* Sel = SALOME_Selection::Selection( ActiveStudy->getSelection() ); + + QString theContext; + QString theParent("Viewer"); + QString theObject; + + Desktop->definePopup( theContext, theParent, theObject ); + Desktop->createPopup( myPopup, theContext, theParent, theObject); + Desktop->customPopup( myPopup, theContext, theParent, theObject ); + if (Sel->IObjectCount() == 0 && myPopup->count()<1) { + int id; + myIDs.append ( id = myPopup->insertItem (tr ("MEN_VP3D_CHANGEBGR")) ); + QAD_ASSERT ( myPopup->connectItem ( id, this, SLOT(onChangeBackgroundColor())) ); + } + } + */ + } +/*! + Constructor +*/ +SUPERVGraph_ViewFrame::SUPERVGraph_ViewFrame(QWidget* parent, const char* name) + : QAD_ViewFrame(parent, name) +{ + myView = 0; + //myView = new SUPERVGraph_View(this); + // Set BackgroundColor + /* + int R = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorRed").toInt(); + int G = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorGreen").toInt(); + int B = QAD_CONFIG->getSetting("SUPERVGraph:BackgroundColorBlue").toInt(); + setBackgroundColor(QColor(R,G,B));*/ +} +SUPERVGraph_ViewFrame::~SUPERVGraph_ViewFrame(){} + +/*! + Returns widget containing 3D-Viewer +*/ +SUPERVGraph_View* SUPERVGraph_ViewFrame::getViewWidget(){ + return myView; +} + + +void SUPERVGraph_ViewFrame::setViewWidget(SUPERVGraph_View* theView) { + myView = theView; + if (myApp) { + myView->setPopupServer(myApp); + } +} + + +/*! + Display/hide Trihedron +*/ +void SUPERVGraph_ViewFrame::onViewTrihedron() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::onViewTrihedron" ) +} + +/*! + Provides top projection of the active view +*/ +void SUPERVGraph_ViewFrame::onViewTop() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::onViewTop" ) +} + +/*! + Provides bottom projection of the active view +*/ +void SUPERVGraph_ViewFrame::onViewBottom() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::onViewBottom" ) +} + +/*! + Provides left projection of the active view +*/ +void SUPERVGraph_ViewFrame::onViewLeft() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::onViewLeft" ) +} + +/*! + Provides right projection of the active view +*/ +void SUPERVGraph_ViewFrame::onViewRight() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::onViewRight" ) +} + +/*! + Provides back projection of the active view +*/ +void SUPERVGraph_ViewFrame::onViewBack() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::onViewBack" ) +} + +/*! + Provides front projection of the active view +*/ +void SUPERVGraph_ViewFrame::onViewFront() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::onViewFront" ) +} + +/*! + Reset the active view +*/ +void SUPERVGraph_ViewFrame::onViewReset() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::onViewReset" ) + if (myView) + myView->ResetView(); +} + +/*! + Rotates the active view +*/ +void SUPERVGraph_ViewFrame::onViewRotate() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::onViewRotate" ) +} + +/*! + Sets a new center of the active view +*/ +void SUPERVGraph_ViewFrame::onViewGlobalPan() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::onViewGlobalPan" ) +} + +/*! + Zooms the active view +*/ +void SUPERVGraph_ViewFrame::onViewZoom() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::onViewZoom" ) +} + +/*! + Moves the active view +*/ +void SUPERVGraph_ViewFrame::onViewPan() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::onViewPan" ) + if (myView != NULL) + myView->ActivatePanning(); +} + +/*! + Fits all obejcts within a rectangular area of the active view +*/ +void SUPERVGraph_ViewFrame::onViewFitArea() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitArea" ) +} + +/*! + Fits all objects in the active view +*/ +void SUPERVGraph_ViewFrame::onViewFitAll() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::onViewFitAll" ) +} + +/*! + Set background of the viewport +*/ +void SUPERVGraph_ViewFrame::setBackgroundColor( const QColor& color) +{ + if (myView) + myView->setPaletteBackgroundColor(color); +} + +/*! + Returns background of the viewport +*/ +QColor SUPERVGraph_ViewFrame::backgroundColor() const +{ + if (myView) + return myView->paletteBackgroundColor(); + return QMainWindow::backgroundColor(); +} + + +void SUPERVGraph_ViewFrame::SetSelectionMode( int mode ) +{ + MESSAGE ( "SUPERVGraph_ViewFrame::SetSelectionMode" ) +} + +void SUPERVGraph_ViewFrame::SetTrihedronSize( int dim ) +{ + MESSAGE ( "SUPERVGraph_ViewFrame::SetTrihedronSize" ) +} + +void SUPERVGraph_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject, + QString newName ) +{ + MESSAGE ( "SUPERVGraph_ViewFrame::rename" ) +} + +void SUPERVGraph_ViewFrame::unHighlightAll() +{ + MESSAGE ( "SUPERVGraph_ViewFrame::unHighlightAll" ) +} + +void SUPERVGraph_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject, + bool highlight, bool immediatly ) +{ + MESSAGE ( "SUPERVGraph_ViewFrame::highlight" ) +} + +bool SUPERVGraph_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject ) +{ + MESSAGE ( "SUPERVGraph_ViewFrame::isInViewer" ) + return false; +} + +bool SUPERVGraph_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject ) +{ + MESSAGE ( "SUPERVGraph_ViewFrame::isVisible" ) + return false; +} + +void SUPERVGraph_ViewFrame::setPopupServer( QAD_Application* App ) +{ + myApp = App; + if (myView) { + myView->setPopupServer(myApp); + } +} + +void SUPERVGraph_ViewFrame::undo(SALOMEDS::Study_var aStudy, + const char* StudyFrameEntry) +{ + MESSAGE ( "SUPERVGraph_ViewFrame::undo" ) +} + +void SUPERVGraph_ViewFrame::redo(SALOMEDS::Study_var aStudy, + const char* StudyFrameEntry) +{ + MESSAGE ( "SUPERVGraph_ViewFrame::redo" ) +} + diff --git a/src/SUPERVGraph/SUPERVGraph_ViewFrame.h b/src/SUPERVGraph/SUPERVGraph_ViewFrame.h new file mode 100644 index 000000000..d574bc4f1 --- /dev/null +++ b/src/SUPERVGraph/SUPERVGraph_ViewFrame.h @@ -0,0 +1,100 @@ +// File : SUPERVGraph_ViewFrame.h +// Created : Wed Mar 20 14:22:27 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : SUPERVGraph +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef SUPERVGraph_ViewFrame_H +#define SUPERVGraph_ViewFrame_H + +#include "QAD.h" +#include "QAD_ViewFrame.h" +#include "QAD_Application.h" + +#include "SALOME_InteractiveObject.hxx" + +class QAD_EXPORT SUPERVGraph_View: public QWidget, public QAD_PopupClientServer{ + Q_OBJECT; + public: + SUPERVGraph_View(QWidget* theParent); + SUPERVGraph_View(SUPERVGraph_View* theParent); + + virtual void ActivatePanning() = 0; + virtual void ResetView() = 0; + protected: + void init(QWidget* theParent); + void onCreatePopup(); +}; + +class QAD_EXPORT SUPERVGraph_ViewFrame : public QAD_ViewFrame { + Q_OBJECT + + public: + SUPERVGraph_ViewFrame(QWidget* parent, const char* name=0 ); + ~SUPERVGraph_ViewFrame(); + + ViewType getTypeView() const{ return VIEW_GRAPHSUPERV;}; + SUPERVGraph_View* getViewWidget(); + void setViewWidget(SUPERVGraph_View* theView); + + void setBackgroundColor( const QColor& ); + QColor backgroundColor() const; + + void SetSelectionMode( int mode ); + + void SetTrihedronSize( int dim ); + + /* popup management */ + void setPopupServer( QAD_Application* ); + + /* interactive object management */ + void highlight( const Handle(SALOME_InteractiveObject)& IObject, + bool highlight, bool immediatly = true ); + void unHighlightAll(); + void rename( const Handle(SALOME_InteractiveObject)& IObject, + QString newName ); + 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) { }; + + /* display */ + void Display(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly = true){}; + void DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject){}; + void Erase(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly = true){}; + void DisplayAll(){}; + void EraseAll(){}; + void Repaint() {}; + + public slots: + void onViewPan(); + void onViewZoom(); + void onViewFitAll(); + void onViewFitArea(); + void onViewGlobalPan(); + void onViewRotate(); + void onViewReset(); + void onViewFront(); + void onViewBack(); + void onViewRight(); + void onViewLeft(); + void onViewBottom(); + void onViewTop(); + void onViewTrihedron(); + + private: + SUPERVGraph_View* myView; + QAD_Application* myApp; +}; +#endif diff --git a/src/Session/Makefile.in b/src/Session/Makefile.in new file mode 100644 index 000000000..1f451a638 --- /dev/null +++ b/src/Session/Makefile.in @@ -0,0 +1,44 @@ +#============================================================================== +# File : Makefile.in +# Created : mar jui 3 12:59:20 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +EXPORT_HEADERS= SALOME_Session_i.hxx +LIB_MOC = \ + InquireServersQThread.h + +# Libraries targets +LIB = libSalomeSession.la +LIB_SRC=\ + InquireServersQThread.cxx \ + SALOME_Session_QThread.cxx \ + SALOME_Session_i.cxx + +# Executables targets +BIN = SALOME_Session_Server SALOME_Session_loader +BIN_SRC = +#***#BIN_SERVER_IDL = SALOME_Session.idl VISU_Gen.idl MED.idl +BIN_SERVER_IDL = SALOME_Session.idl +#***#BIN_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Component.idl SALOME_Registry.idl SALOME_ModuleCatalog.idl SALOME_Component.idl SALOME_Exception.idl VISU_Gen.idl +BIN_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Component.idl SALOME_Registry.idl SALOME_ModuleCatalog.idl SALOME_Component.idl SALOME_Exception.idl + +CPPFLAGS+=$(QT_MT_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) +CXXFLAGS+=$(OCC_CXXFLAGS) +LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lOpUtil -lSalomeLoggerServer -lPlot2d + + +@CONCLUDE@ + diff --git a/src/Session/SALOME_Session_QThread.cxx b/src/Session/SALOME_Session_QThread.cxx new file mode 100644 index 000000000..1c763623d --- /dev/null +++ b/src/Session/SALOME_Session_QThread.cxx @@ -0,0 +1,126 @@ +using namespace std; +//============================================================================= +// File : SALOME_Session_QThread.cxx +// Created : mar jun 19 15:18:31 CEST 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#include +#include + +#include "utilities.h" +#include "SALOME_Session_QThread.hxx" +#include "SALOME_NamingService.hxx" +#include "SALOMEGUI_Application.h" +#include "QAD.h" +#include "QAD_MessageBox.h" +#include "QAD_Application.h" +#include "QAD_Settings.h" +#include "QAD_Config.h" +#include "QAD_Tools.h" +// only to use findFile method : perhaps put it in QAD_Tools ??? +#include "QAD_ResourceMgr.h" +#include + + +#include +#include CORBA_SERVER_HEADER(SALOMEDS) + +//============================================================================= +/*! SALOME_Session_QThread + * constructor + */ +//============================================================================= + +SALOME_Session_QThread::SALOME_Session_QThread(int argc, char ** argv) : QThread() +{ + _qappl = 0 ; + _mw = 0 ; + _argc = argc ; + _argv = argv ; + _NS = 0 ; +} ; + +//============================================================================= +/*! run + * Creates one QApplication for the all the session life. + * Executes the Qt main window of the GUI on a separate thread + */ +//============================================================================= + +void SALOME_Session_QThread::run() +{ + if (_qappl == 0) + { + _qappl = new QApplication(_argc, _argv ); + INFOS("creation QApplication"); + } + + QAD_ASSERT ( QObject::connect(_qappl, SIGNAL(lastWindowClosed()), _qappl, SLOT(quit()) ) ); + _mw = new SALOMEGUI_Application ( "MDTV-Standard", "HDF", "hdf" ); + INFOS("creation SALOMEGUI_Application"); + + if ( !SALOMEGUI_Application::addToDesktop ( _mw, _NS ) ) + { + QAD_MessageBox::error1 ( 0, + QObject::tr("ERR_ERROR"), + QObject::tr("ERR_APP_INITFAILED"), + QObject::tr("BUT_OK") ); + } + else + { + + QFileInfo prgInfo(_argv[0]); + QDir prgDir(prgInfo.dirPath(true)); + QAD_CONFIG->setPrgDir(prgDir); // CWD is program directory + QAD_CONFIG->createConfigFile(false); // Create config file ~/.tr(MEN_APPNAME)/tr(MEN_APPNAME).conf if there's none + QAD_CONFIG->readConfigFile(); // Read config file + + _qappl->setPalette( QAD_Application::getPalette() ); + + /* 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") + _ret = _qappl->exec(); + break; + } + catch(SALOMEDS::StudyBuilder::LockProtection&) { + MESSAGE("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(...) { + MESSAGE("run(): An exception has been caught") + QApplication::restoreOverrideCursor(); + QAD_MessageBox::error1 ( (QWidget*)QAD_Application::getDesktop(), + QObject::tr("ERR_ERROR"), + QObject::tr("ERR_APP_EXCEPTION"), + QObject::tr("BUT_OK") ); + } + } + + QString confMsg = "Settings create $HOME/." + QObject::tr("MEN_APPNAME") + "/" + QObject::tr("MEN_APPNAME") + ".conf"; + MESSAGE (confMsg ) + QAD_CONFIG->createConfigFile(true); + } +} ; + +//============================================================================= +/*! setNamingService + * gives the naming service interface + */ +//============================================================================= +void SALOME_Session_QThread::setNamingService(SALOME_NamingService *ns) +{ + _NS = ns; +} diff --git a/src/Session/SALOME_Session_QThread.hxx b/src/Session/SALOME_Session_QThread.hxx new file mode 100644 index 000000000..6a5eeb9a6 --- /dev/null +++ b/src/Session/SALOME_Session_QThread.hxx @@ -0,0 +1,43 @@ +//============================================================================= +// File : SALOME_Session_QThread.hxx +// Created : mar jun 19 14:38:31 CEST 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#ifndef _SALOME_SESSION_QTHREAD_HXX_ +#define _SALOME_SESSION_QTHREAD_HXX_ + +#include +class QApplication; + +class SALOMEGUI_Application; +class SALOME_NamingService; + + +//! Qt thread class for the GUI +class SALOME_Session_QThread: public QThread +{ + +public: + SALOME_Session_QThread(int argc, char ** argv) ; + + //! launch the Qt main window of the GUI on a separate thread + virtual void run() ; + + //! set the naming service + void setNamingService(SALOME_NamingService *ns); + +protected: + int _argc ; + char ** _argv; + int _ret ; + SALOME_NamingService *_NS; + QApplication *_qappl ; + + SALOMEGUI_Application* _mw ; +} ; + +#endif diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx new file mode 100644 index 000000000..0296ca615 --- /dev/null +++ b/src/Session/SALOME_Session_Server.cxx @@ -0,0 +1,93 @@ +using namespace std; +//============================================================================= +// File : SALOME_Session_Server.cxx +// Created : mar jun 19 13:26:24 CEST 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +/*! \file SALOME_Session_Server.cxx + */ + +using namespace std; +# include "Utils_ORB_INIT.hxx" +# include "Utils_SINGLETON.hxx" + +#include +#include + +// #include +// #include "Qtappl_example.hxx" + +#include +#include CORBA_SERVER_HEADER(SALOME_Session) + +#include "utilities.h" + +#include "SALOME_Session_i.hxx" + +//! CORBA server for SALOME Session +/*! + * SALOME_Session Server launches a SALOME session servant. + * The servant registers to the Naming Service. + * See SALOME_Session.idl for interface specification. + * + * Main services offered by the servant are: + * - launch GUI + * - stop Session (must be idle) + * - get session state + */ + +int main(int argc, char **argv) +{ + + try + { + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + CORBA::ORB_var &orb = init( argc , argv ) ; + + CORBA::Object_var obj =orb->resolve_initial_references("RootPOA") ; + //MESSAGE("orb->resolve_initial_references('Root_POA')") + PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ; + //MESSAGE("POA::_narrow(obj)") + + // servant + + SALOME_Session_i * mySALOME_Session = new SALOME_Session_i(argc, argv, orb, poa) ; + PortableServer::ObjectId_var mySALOME_Sessionid = poa->activate_object(mySALOME_Session) ; + MESSAGE("poa->activate_object(mySALOME_Session)") + + obj = mySALOME_Session->_this() ; + CORBA::String_var sior(orb->object_to_string(obj)) ; + // MESSAGE("sior(orb->object-to-string(obj))") + // cerr << "'" << (char*) sior << "'" << endl ; + + mySALOME_Session->NSregister(); + + mySALOME_Session->_remove_ref() ; + //MESSAGE("mySALOME_Session->_remove_ref()") + + PortableServer::POAManager_var pman = poa->the_POAManager() ; + pman->activate() ; + MESSAGE("pman->activate()") + + orb->run() ; + orb->destroy() ; + } + catch (CORBA::SystemException&) + { + INFOS("Caught CORBA::SystemException.") + } + catch (CORBA::Exception&) + { + INFOS("Caught CORBA::Exception.") + } + catch (...) + { + INFOS("Caught unknown exception.") + } + return 0 ; +} diff --git a/src/Session/SALOME_Session_i.cxx b/src/Session/SALOME_Session_i.cxx new file mode 100644 index 000000000..49acc5897 --- /dev/null +++ b/src/Session/SALOME_Session_i.cxx @@ -0,0 +1,169 @@ +using namespace std; +//============================================================================= +// File : SALOME_Session_i.cxx +// Created : mar jun 19 14:02:45 CEST 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#include "utilities.h" + +#include "SALOME_Session_i.hxx" +#include "SALOME_NamingService.hxx" +#include "SALOME_Session_QThread.hxx" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include + +// Open CASCADE Includes +#include +#include +#include + +//============================================================================= +/*! SALOME_Session_i + * constructor + */ +//============================================================================= + +SALOME_Session_i::SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa) +{ + _argc = argc ; + _argv = argv ; + _IAPPThread = new SALOME_Session_QThread(_argc, _argv) ; + _isGUI = FALSE ; + _runningStudies= 0 ; + _orb = CORBA::ORB::_duplicate(orb) ; + _poa = PortableServer::POA::_duplicate(poa) ; + MESSAGE("constructor end"); +} + +//***//VISU::VISU_Gen_ptr SALOME_Session_i::GetVisuGen(){ +//***// typedef VISU::VISU_Gen_ptr VisuGen(CORBA::ORB_var,PortableServer::POA_var,QMutex*); +//***// MESSAGE("SALOME_Session_i::GetVisuGen"); +//***// OSD_SharedLibrary visuSharedLibrary("libVisuEngine.so"); +//***// if(visuSharedLibrary.DlOpen(OSD_RTLD_LAZY)) +//***// if(OSD_Function osdFun = visuSharedLibrary.DlSymb("GetVisuGen")) +//***// return ((VisuGen (*)) osdFun)(_orb,_poa,&_GUIMutex); +//***// return VISU::VISU_Gen::_nil(); +//***//} + +//============================================================================= +/*! ~SALOME_Session_i + * destructor + */ +//============================================================================= + +SALOME_Session_i::~SALOME_Session_i() +{ + MESSAGE("destructor end"); +} + +//============================================================================= +/*! NSregister + * tries to find the Corba Naming Service and to register the session, + * gives naming service interface to _IAPPThread + */ +//============================================================================= + +void SALOME_Session_i::NSregister() +{ + SALOME::Session_ptr pSession = SALOME::Session::_narrow(_this()); + try + { + _NS = new SALOME_NamingService(_orb); + _NS->Register(pSession, "/Kernel/Session"); + _IAPPThread->setNamingService(_NS); + } + catch (ServiceUnreachable&) + { + INFOS("Caught exception: Naming Service Unreachable"); + exit(1) ; + } + catch (...) + { + INFOS("Caught unknown exception from Naming Service"); + } + MESSAGE("NSregister end"); +} + +//============================================================================= +/*! GetInterface + * Launches the GUI if there is none. + * The Corba method is oneway (corba client does'nt wait for GUI completion) + */ +//============================================================================= + +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 +} + +//============================================================================= +/*! StopSession + * Kills the session if there are no active studies nore GUI + */ +//============================================================================= + +void SALOME_Session_i::StopSession() +{ + qApp->lock(); + QAD_Application::getDesktop()->closeDesktop( true ); + qApp->unlock(); +/* + _GUIMutex.lock(); // get access to boolean _isGUI + if ((! _isGUI) && (! _runningStudies)) + { + MESSAGE("Ask for Session Kill, OK"); + exit(0); + } + else + { + _GUIMutex.unlock() ; // release access to boolean _isGUI + MESSAGE("Ask for Session Kill, NOK"); + if (_isGUI) throw SALOME::Session::GUIActive(); + if (_runningStudies) throw SALOME::Session::RunningStudies(); + } +*/ +} + +//============================================================================= +/*! StatSession + * Send a SALOME::StatSession structure (see idl) to the client + * (number of running studies and presence of GUI) + */ +//============================================================================= + +SALOME::StatSession SALOME_Session_i::GetStatSession() +{ + // update Session state + _GUIMutex.lock(); + _isGUI = _IAPPThread->running(); + _runningStudies = 0; + if (_isGUI) { + qApp->lock(); + if ( QAD_Application::getDesktop() && QAD_Application::getDesktop()->getActiveApp() ) + _runningStudies = QAD_Application::getDesktop()->getActiveApp()->getStudies().count(); + qApp->unlock(); + } + _GUIMutex.unlock(); + // getting stat info + SALOME::StatSession_var myStats = new SALOME::StatSession ; + if (_runningStudies) + myStats->state = SALOME::running ; + else + myStats->state = SALOME::asleep ; + myStats->runningStudies = _runningStudies ; + myStats->activeGUI = _isGUI ; + return myStats._retn() ; +} + diff --git a/src/Session/SALOME_Session_i.hxx b/src/Session/SALOME_Session_i.hxx new file mode 100644 index 000000000..15ae3696c --- /dev/null +++ b/src/Session/SALOME_Session_i.hxx @@ -0,0 +1,62 @@ +//============================================================================= +// File : SALOME_Session_i.hxx +// Created : mar jun 19 13:42:55 CEST 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#ifndef _SALOME_SESSION_I_HXX_ +#define _SALOME_SESSION_I_HXX_ + +#include + +#include +//***//#include CORBA_SERVER_HEADER(VISU_Gen) +#include CORBA_SERVER_HEADER(SALOME_Session) +class SALOME_NamingService; +class SALOME_Session_QThread; + +//! CORBA SALOME Session Servant + +class SALOME_Session_i: public POA_SALOME::Session, + public PortableServer::RefCountServantBase +{ +public: + SALOME_Session_i(int argc, char ** argv, CORBA::ORB_ptr orb, PortableServer::POA_ptr poa) ; + ~SALOME_Session_i() ; + + //! Launch Graphical User Interface + void GetInterface(); + //***//VISU::VISU_Gen_ptr GetVisuGen(); + + //! Stop the Session (must be idle): kill servant & server + void StopSession(); + + //! Get session state + SALOME::StatSession GetStatSession(); + + //! Register the servant to Naming Service + void NSregister(); + + void ping(){}; + +protected: + //! A QT Thread for the GUI + SALOME_Session_QThread *_IAPPThread ; + + //! Naming service interface + SALOME_NamingService *_NS; + + int _argc ; + char **_argv; + CORBA::Boolean _isGUI ; + QMutex _GUIMutex ; + int _runningStudies ; + CORBA::ORB_var _orb; + PortableServer::POA_var _poa; +}; + +#endif + diff --git a/src/Session/runSession b/src/Session/runSession new file mode 100644 index 000000000..cbb98a2da --- /dev/null +++ b/src/Session/runSession @@ -0,0 +1,27 @@ +export SALOME_HOME_DIR=`pwd` +export ORB_HOME_DIR=${HOME}/public/omni + +# OCAF +export CSF_PluginDefaults=${SALOME_HOME_DIR}/../resources +export CSF_ResourcesDefaults=${SALOME_HOME_DIR}/../resources + +export CSF_SALOMEGUIResources=${SALOME_HOME_DIR}/../SALOME/resources +export CSF_SALOMEGUILanguage=en +export CSF_QADResources=${SALOME_HOME_DIR}/../SALOME/resources +export CSF_QADLanguage=en + +export CSF_CatalogueResources=${SALOME_HOME_DIR}/../resources + +export CSF_GeometryResources=${SALOME_HOME_DIR}/../GEOM/resources + +export CSF_MeshResources=${SALOME_HOME_DIR}/../MESH/resources + +export CSF_PATHComponents=${SALOME_HOME_DIR}/../lib + +export LD_LIBRARY_PATH=${SALOME_HOME_DIR}/../lib/:${LD_LIBRARY_PATH} + +runNS.sh +geom& +mesh& +SALOME_Session_Server + diff --git a/src/TOOLSGUI/Makefile.in b/src/TOOLSGUI/Makefile.in new file mode 100644 index 000000000..3d96cb390 --- /dev/null +++ b/src/TOOLSGUI/Makefile.in @@ -0,0 +1,45 @@ +# -* Makefile *- +# +# Author : Marc Tajchman (CEA) +# Date : 5/07/2001 +# $Header$ +# + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= + +# .po files to transform in .qm +PO_FILES = \ + ToolsGUI_icons.po \ + ToolsGUI_msg_en.po + +# Libraries targets +LIB = libToolsGUI.la + +LIB_SRC = ToolsGUI.cxx \ + ToolsGUI_CatalogGeneratorDlg.cxx + +LIB_MOC = ToolsGUI_moc.cxx \ + ToolsGUI_CatalogGeneratorDlg_moc.cxx + +LIB_CLIENT_IDL = SALOME_Exception.idl + +# additionnal information to compil and link file + +CPPFLAGS += $(QT_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) +CXXFLAGS += $(OCC_CXXFLAGS) + +LDFLAGS += -lSalomeGUI $(OCC_LIBS) + + +@CONCLUDE@ + diff --git a/src/TOOLSGUI/ToolsGUI.cxx b/src/TOOLSGUI/ToolsGUI.cxx new file mode 100644 index 000000000..d96bca7ba --- /dev/null +++ b/src/TOOLSGUI/ToolsGUI.cxx @@ -0,0 +1,59 @@ +using namespace std; +// File : ToolsGUI.cxx +// Created : Wed Nov 14 21:59:24 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : TOOLSGUI +// Copyright : Open CASCADE +// $Header$ + +#include "ToolsGUI.h" +#include "ToolsGUI_CatalogGeneratorDlg.h" + +#include "utilities.h" + +#include + +int ToolsGUI::runCommand(string & arg) +{ + int res; + res = system(arg.c_str()); + + if (res == -1) + MESSAGE("fork failed (system command result = 0x" << hex << res << ")" << dec) + else + if (res == 217) + MESSAGE("shell exec failed (system command result = 0x" << hex << res << ")" << dec) + + return res; +} + +bool ToolsGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + QAD_Study* myActiveStudy = parent->getActiveStudy(); + switch (theCommandID) + { + case 5102 : + { + ToolsGUI_CatalogGeneratorDlg* aDlg = new ToolsGUI_CatalogGeneratorDlg(parent); + aDlg->exec(); + delete aDlg; + break; + } + + default: + MESSAGE (" No command associated with this id = " << theCommandID ) + break; + } + return true; +} + +extern "C" +{ + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) + { + //MESSAGE("ToolsGUI::OnGUIEvent "<< theCommandID); + return ToolsGUI::OnGUIEvent(theCommandID, parent); + } + +} diff --git a/src/TOOLSGUI/ToolsGUI.h b/src/TOOLSGUI/ToolsGUI.h new file mode 100644 index 000000000..7837e2837 --- /dev/null +++ b/src/TOOLSGUI/ToolsGUI.h @@ -0,0 +1,50 @@ +// File : ToolsGUI.h +// Created : Wed Nov 14 22:00:04 2001 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : TOOLSGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef ToolsGUI_HeaderFile +#define ToolsGUI_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif + +#include "QAD_Desktop.h" + +class ToolsGUI : public QObject +{ + Q_OBJECT + +public : + +// Methods PUBLIC +// + Standard_EXPORT static int ToolsGUI::runCommand(string & arg); +Standard_EXPORT static bool OnGUIEvent (int theCommandID, QAD_Desktop* parent); + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + +}; + +#endif diff --git a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx new file mode 100644 index 000000000..30cb959ee --- /dev/null +++ b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx @@ -0,0 +1,349 @@ +using namespace std; +// File : ToolsGUI_CatalogGeneratorDlg.cxx +// Created : Thu Apr 25 18:52:40 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : TOOLSGUI +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "ToolsGUI_CatalogGeneratorDlg.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_FileDlg.h" +#include "QAD_MessageBox.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define SPACING_SIZE 6 +#define MARGIN_SIZE 11 +#define MIN_EDIT_SIZE 250 + +//================================================================================= +// class : ToolsGUI_CatalogGeneratorDlg() +// purpose : Constructor +//================================================================================= +ToolsGUI_CatalogGeneratorDlg::ToolsGUI_CatalogGeneratorDlg( QWidget* parent, const char* name ) + : QDialog( parent, name, TRUE, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "ToolsGUI_CatalogGeneratorDlg" ); + resize( 322, 120 ); + setCaption( tr( "TOOLS_CATALOG_GENERATOR" ) ); + setSizeGripEnabled( TRUE ); + + QGridLayout* aTopLayout = new QGridLayout(this); + aTopLayout->setMargin(MARGIN_SIZE); + aTopLayout->setSpacing(SPACING_SIZE); + + QGroupBox* filesGrp = new QGroupBox( tr( "TOOLS_FILES") , this, "filesGrp" ); + filesGrp->setColumnLayout( 0, Qt::Vertical ); + filesGrp->layout()->setSpacing( 0 ); + filesGrp->layout()->setMargin( 0 ); + QGridLayout* filesGrpLayout = new QGridLayout( filesGrp->layout() ); + filesGrpLayout->setAlignment( Qt::AlignTop ); + filesGrpLayout->setSpacing( SPACING_SIZE ); + filesGrpLayout->setMargin( MARGIN_SIZE ); + + myIdlEdit = new QLineEdit( filesGrp, "myIdlEdit" ); + myIdlEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myIdlEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + myXmlEdit = new QLineEdit( filesGrp, "myXmlEdit" ); + myXmlEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myXmlEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + + myBrowseIdlBtn = new QPushButton( tr( "TOOLS_BUT_BROWSE" ), filesGrp, "myBrowseIdlBtn" ); + myBrowseXmlBtn = new QPushButton( tr( "TOOLS_BUT_BROWSE" ), filesGrp, "myBrowseXmlBtn" ); +// QFontMetrics fm(myBrowseIdlBtn->font()); +// myBrowseIdlBtn->setFixedWidth(fm.width(myBrowseIdlBtn->text()) + 10); +// myBrowseXmlBtn->setFixedWidth(fm.width(myBrowseXmlBtn->text()) + 10); + + filesGrpLayout->addWidget( new QLabel( tr( "TOOLS_IDL_FILE" ), filesGrp ), 0, 0); + filesGrpLayout->addWidget( myIdlEdit, 0, 1 ); + filesGrpLayout->addWidget( myBrowseIdlBtn, 0, 2 ); + filesGrpLayout->addWidget( new QLabel( tr( "TOOLS_XML_FILE" ), filesGrp ), 1, 0); + filesGrpLayout->addWidget( myXmlEdit, 1, 1 ); + filesGrpLayout->addWidget( myBrowseXmlBtn, 1, 2 ); + + QGroupBox* supplGrp = new QGroupBox(tr( "TOOLS_SUPPLEMENT" ) , this, "SupplGrp" ); + supplGrp->setColumnLayout( 0, Qt::Vertical ); + supplGrp->layout()->setSpacing( 0 ); + supplGrp->layout()->setMargin( 0 ); + QGridLayout* supplGrpLayout = new QGridLayout( supplGrp->layout() ); + supplGrpLayout->setAlignment( Qt::AlignTop ); + supplGrpLayout->setSpacing( SPACING_SIZE ); + supplGrpLayout->setMargin( MARGIN_SIZE ); + + myAuthorEdit = new QLineEdit( supplGrp , "myAuthorEdit" ); + myAuthorEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myAuthorEdit->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + + OSD_Process aProcess; + myAuthorEdit->setText(aProcess.UserName().ToCString()); + + myVersionEdit = new QLineEdit(supplGrp , "myVersion" ); + myVersionEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myVersionEdit->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + QStringList aList = QStringList::split(QRegExp("\\s+"),tr( "INF_VERSION" )); + myVersionEdit->setText(aList.last()); + QDoubleValidator *validator = new QDoubleValidator(myVersionEdit); + myVersionEdit->setValidator(validator); + + myPngEdit = new QLineEdit(supplGrp , "myCompIcon" ); + myPngEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myPngEdit->setMinimumSize( MIN_EDIT_SIZE, 0 ); + + myBrowsePngBtn = new QPushButton( tr( "TOOLS_BUT_BROWSE" ), supplGrp, "myBrowsePngBtn" ); + + myCompName = new QLineEdit(supplGrp , "myCompName"); + myCompName->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myCompName->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + + myCompType = new QLineEdit(supplGrp , "myCompType"); + myCompType->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myCompType->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + myCompType->setText("OTHER"); + + myCompMultiStd = new QLineEdit(supplGrp , "myCompMultiStd"); + myCompMultiStd->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myCompMultiStd->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + myCompMultiStd->setText("1"); + QIntValidator *ivalidator = new QIntValidator(myVersionEdit); + myCompMultiStd->setValidator(ivalidator); + + supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_AUTHOR" ), supplGrp ), 0, 0); + supplGrpLayout->addWidget( myAuthorEdit, 0, 1 ); + supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_NAME" ), supplGrp ), 0, 2); + supplGrpLayout->addWidget(myCompName,0,3); + supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_TYPE" ), supplGrp ), 0, 4); + supplGrpLayout->addWidget(myCompType,0,5); + supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_VERSION" ), supplGrp ), 1, 0); + supplGrpLayout->addWidget( myVersionEdit, 1, 1); + supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_MULTISTD" ), supplGrp ), 1, 2); + supplGrpLayout->addWidget(myCompMultiStd,1,3); + supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_PNG_FILE" ), supplGrp ), 2, 0); + supplGrpLayout->addMultiCellWidget( myPngEdit, 2,2,1,4 ); + supplGrpLayout->addWidget( myBrowsePngBtn, 2, 5 ); + + + QHBoxLayout* aBtnLayout = new QHBoxLayout; + aBtnLayout->setSpacing( SPACING_SIZE ); + aBtnLayout->setMargin( 0 ); + + myApplyBtn = new QPushButton( tr( "TOOLS_BUT_APPLY" ), this, "myApplyBtn" ); + myApplyBtn->setAutoDefault( true ); + myApplyBtn->setDefault( true ); + myCloseBtn = new QPushButton( tr( "TOOLS_BUT_CLOSE" ), this, "myCloseBtn" ); + myCloseBtn->setAutoDefault( true ); + + aBtnLayout->addWidget( myApplyBtn ); + aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + aBtnLayout->addWidget( myCloseBtn ); + + aTopLayout->addWidget( filesGrp, 0, 0 ); + aTopLayout->addWidget( supplGrp, 1, 0 ); + aTopLayout->addLayout( aBtnLayout, 2, 0 ); + + /* signals and slots connections */ + connect( myApplyBtn, SIGNAL( clicked() ), this, SLOT( onApply() ) ); + connect( myCloseBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( myBrowseIdlBtn, SIGNAL( clicked() ), this, SLOT( onBrowseBtnClicked() ) ); + connect( myBrowseXmlBtn, SIGNAL( clicked() ), this, SLOT( onBrowseBtnClicked() ) ); + connect( myBrowsePngBtn, SIGNAL( clicked() ), this, SLOT( onBrowseBtnClicked() ) ); + connect( myIdlEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( updateButtonState() ) ); + connect( myXmlEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( updateButtonState() ) ); + + updateButtonState(); +} + +//================================================================================= +// function : ~ToolsGUI_CatalogGeneratorDlg() +// purpose : destructor +//================================================================================= +ToolsGUI_CatalogGeneratorDlg::~ToolsGUI_CatalogGeneratorDlg() +{ +} + +//================================================================================= +// function : getIdlFile() +// purpose : gets IDL file name entered +//================================================================================= +QString ToolsGUI_CatalogGeneratorDlg::getIdlFile() +{ + return myIdlEdit->text().stripWhiteSpace(); +} + +//================================================================================= +// function : getXmlFile() +// purpose : gets XML file name entered +//================================================================================= +QString ToolsGUI_CatalogGeneratorDlg::getXmlFile() +{ + return myXmlEdit->text().stripWhiteSpace(); +} + +//================================================================================= +// function : getPngFile() +// purpose : gets PNG file name entered +//================================================================================= +QString ToolsGUI_CatalogGeneratorDlg::getPngFile() +{ + return myPngEdit->text().stripWhiteSpace(); +} + +//================================================================================= +// function : getAuthor() +// purpose : gets author +//================================================================================= +QString ToolsGUI_CatalogGeneratorDlg::getAuthor() +{ + return myAuthorEdit->text().stripWhiteSpace(); +} + +//================================================================================= +// function : getVersion() +// purpose : gets version number +//================================================================================= +QString ToolsGUI_CatalogGeneratorDlg::getVersion() +{ + return myVersionEdit->text().stripWhiteSpace(); +} + +//================================================================================= +// function : getCompName() +// purpose : gets name of the component +//================================================================================= +QString ToolsGUI_CatalogGeneratorDlg::getCompName() +{ + return myCompName->text().stripWhiteSpace(); +} + +//================================================================================= +// function : getCompType() +// purpose : gets type of the component +//================================================================================= +QString ToolsGUI_CatalogGeneratorDlg::getCompMultiStd() +{ + return myCompMultiStd->text().stripWhiteSpace(); +} +//================================================================================= +// function : getComptype() +// purpose : gets type of the component +//================================================================================= +QString ToolsGUI_CatalogGeneratorDlg::getCompType() +{ + return myCompType->text().stripWhiteSpace(); +} + +//================================================================================= +// function : onBrowseBtnClicked() +// purpose : <...> (Browse) buttons slot +//================================================================================= +void ToolsGUI_CatalogGeneratorDlg::onBrowseBtnClicked() +{ + QPushButton* send = (QPushButton*)sender(); + + if ( send == myBrowseIdlBtn ) { + QString file = myIdlEdit->text().stripWhiteSpace(); + file = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + file, + tr("TOOLS_MEN_IMPORT_IDL"), + tr("TOOLS_MEN_IMPORT"), + true); + if ( !file.isEmpty() ) { + myIdlEdit->setText(file); + } + } + else if ( send == myBrowseXmlBtn ) { + QString file = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + myXmlEdit->text().stripWhiteSpace(), + tr("TOOLS_MEN_EXPORT_XML"), + tr("TOOLS_MEN_EXPORT"), + false); + if ( !file.isEmpty() ) { + myXmlEdit->setText(file); + } + } else if ( send == myBrowsePngBtn ) { + QString file = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + myXmlEdit->text().stripWhiteSpace(), + tr("TOOLS_MEN_IMPORT_PNG"), + tr("TOOLS_MEN_IMPORT"), + true); + if ( !file.isEmpty() ) { + myPngEdit->setText(file); + + } + } + updateButtonState(); +} + +//================================================================================= +// function : updateButtonState() +// purpose : Updates button's state +//================================================================================= +void ToolsGUI_CatalogGeneratorDlg::updateButtonState() +{ + myApplyBtn->setEnabled( !myIdlEdit->text().stripWhiteSpace().isEmpty() && + !myXmlEdit->text().stripWhiteSpace().isEmpty() ); +} + +//================================================================================= +// function : onApply() +// purpose : button slot, performs IDL->XML conversion +//================================================================================= +void ToolsGUI_CatalogGeneratorDlg::onApply() +{ + QString XmlFile = getXmlFile(); + QString IdlFile = getIdlFile(); + QString Author = getAuthor(); + QString Version = getVersion(); + QString PngFile = getPngFile(); + QString CompName = getCompName(); //gets component name + QString CompType = getCompType(); //gets component type + QString CompMultiStd = getCompMultiStd(); + + if ( !XmlFile.isEmpty() && !IdlFile.isEmpty() ) { + if ( !QFile::exists( IdlFile ) ) { + QAD_MessageBox::error1( this, + tr("TOOLS_ERR_ERROR"), + tr("TOOLS_ERR_FILE_NOT_EXIST").arg(IdlFile), + tr ("TOOLS_BUT_OK") ); + } + else { + QString command = QString( getenv( "SALOME_ROOT_DIR" ) ) + "/bin/runIDLparser -Wbcatalog=" + XmlFile; + if (!Author.isEmpty()) command += ",author=" + Author; + if (!Version.isEmpty()) command += ",version=" + Version; + if (!PngFile.isEmpty()) { + OSD_Path aPath((Standard_CString)PngFile.latin1()); + TCollection_AsciiString aFile = aPath.Name() + aPath.Extension(); + command += QString(",icon=") + QString(aFile.ToCString()); + } + if (!CompName.isEmpty()) command += ",name=" + CompName; + if (!CompType.isEmpty()) command += ",type=" + CompType; + if (!CompMultiStd.isEmpty()) command += ",multistudy=" + CompMultiStd; + command += " " + IdlFile; + MESSAGE( "shell command is : " << command ); + int res; + res = system( ( char* )( command.latin1() ) ); + if ( res == -1 ) { + MESSAGE( "work failed (system command result = " << res ); + } else if (res == 217) { + MESSAGE( "shell exec failed (system command result = " << res ); + } + } + } +} diff --git a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.h b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.h new file mode 100644 index 000000000..608b9aa4d --- /dev/null +++ b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.h @@ -0,0 +1,62 @@ +// File : ToolsGUI_CatalogGeneratorDlg.h +// Created : Thu Apr 25 18:52:53 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : TOOLSGUI +// Copyright : Open CASCADE 2002 +// $Header$ + + +#ifndef DIALOGBOX_TOOLSGUI_CATALOGGENERATORDLG_H +#define DIALOGBOX_TOOLSGUI_CATALOGGENERATORDLG_H + +#include + +class QLineEdit; +class QPushButton; + +//================================================================================= +// class : ToolsGUI_CatalogGeneratorDlg +// purpose : +//================================================================================= +class ToolsGUI_CatalogGeneratorDlg : public QDialog +{ + Q_OBJECT + +public: + ToolsGUI_CatalogGeneratorDlg( QWidget* parent = 0, const char* name = 0 ); + ~ToolsGUI_CatalogGeneratorDlg(); + + QString getIdlFile(); + QString getXmlFile(); + QString getPngFile(); + QString getAuthor(); + QString getVersion(); + QString getCompName(); + QString getCompType(); + QString getCompMultiStd(); + +protected slots: + void onBrowseBtnClicked(); + void updateButtonState(); + void onApply(); + +private: + QLineEdit* myIdlEdit; + QLineEdit* myXmlEdit; + QLineEdit* myPngEdit; + QLineEdit* myVersionEdit; + QLineEdit* myAuthorEdit; + QLineEdit* myCompName; + QLineEdit* myCompType; + QLineEdit* myCompMultiStd; + QPushButton* myBrowseIdlBtn; + QPushButton* myBrowseXmlBtn; + QPushButton* myBrowsePngBtn; + + QPushButton* myApplyBtn; + QPushButton* myCloseBtn; +}; + +#endif // DIALOGBOX_TOOLSGUI_CATALOGGENERATORDLG_H diff --git a/src/TOOLSGUI/ToolsGUI_icons.po b/src/TOOLSGUI/ToolsGUI_icons.po new file mode 100644 index 000000000..aece94c19 --- /dev/null +++ b/src/TOOLSGUI/ToolsGUI_icons.po @@ -0,0 +1,18 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: SALOME VERSION 0.4\n" +"POT-Creation-Date: 2002-04-25 10:04:12 PM CEST\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: Nicolas REJNERI\n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +# +#============================================================================== +# + +#: ToolsGUI_CatalogGeneratorDlg.cxx:50 +msgid "ToolsGUI_CatalogGeneratorDlg::ICON_SELECT" +msgstr "select1.png" diff --git a/src/TOOLSGUI/ToolsGUI_msg_en.po b/src/TOOLSGUI/ToolsGUI_msg_en.po new file mode 100644 index 000000000..6e5e0c1c9 --- /dev/null +++ b/src/TOOLSGUI/ToolsGUI_msg_en.po @@ -0,0 +1,104 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: SALOME VERSION 0.4\n" +"POT-Creation-Date: 2002-04-25 10:04:12 PM CEST\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: Nicolas REJNERI\n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +# +#============================================================================== +# + +#: ToolsGUI_CatalogGeneratorDlg.cxx:58 +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_FILES" +msgstr "Files" + +#: ToolsGUI_CatalogGeneratorDlg.cxx:58 +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_SUPPLEMENT" +msgstr "Component supplementary data" + +#: ToolsGUI_CatalogGeneratorDlg.cxx:150 +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_MEN_EXPORT" +msgstr "Export" + +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_MEN_IMPORT" +msgstr "Import" + +#: ToolsGUI_CatalogGeneratorDlg.cxx:47 +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_CATALOG_GENERATOR" +msgstr "Catalog generator" + +#: ToolsGUI_CatalogGeneratorDlg.cxx:82 +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_IDL_FILE" +msgstr "IDL : " + +#: ToolsGUI_CatalogGeneratorDlg.cxx:88 +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_XML_FILE" +msgstr "XML : " + +#: ToolsGUI_CatalogGeneratorDlg.cxx:88 +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_PNG_FILE" +msgstr "Icon : " + +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_AUTHOR" +msgstr "Author : " + +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_VERSION" +msgstr "Version : " + +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_COMP_NAME" +msgstr "Name : " + +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_COMP_TYPE" +msgstr "Type : " + +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_COMP_MULTISTD" +msgstr "Multistudy : " + +#: ToolsGUI_CatalogGeneratorDlg.cxx:153 +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_MEN_EXPORT_XML" +msgstr "XML Files ( *.xml )" + +#: ToolsGUI_CatalogGeneratorDlg.cxx:154 +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_MEN_IMPORT_IDL" +msgstr "IDL Files ( *.idl )" + +#: ToolsGUI_CatalogGeneratorDlg.cxx:154 +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_MEN_IMPORT_PNG" +msgstr "PNG Files ( *.png )" + +# +#============================================================================== +# + +#: ToolsGUI_CatalogGeneratorDlg.cxx:107 +msgid "TOOLS_BUT_CLOSE" +msgstr "&Close" + +#: ToolsGUI_CatalogGeneratorDlg.cxx:113 +msgid "TOOLS_BUT_OK" +msgstr "&Ok" + +msgid "TOOLS_BUT_BROWSE" +msgstr "Browse..." + +msgid "TOOLS_BUT_APPLY" +msgstr "&Apply" + +# +#============================================================================== +# + +#: ToolsGUI_CatalogGeneratorDlg.cxx:53 +msgid "TOOLS_WRN_WARNING" +msgstr "Warning" + +msgid "TOOLS_ERR_ERROR" +msgstr "Error" + +msgid "TOOLS_ERR_FILE_NOT_EXIST" +msgstr "%1\nFile doesn't exist" diff --git a/src/TestContainer/Makefile.in b/src/TestContainer/Makefile.in new file mode 100644 index 000000000..13c0c401d --- /dev/null +++ b/src/TestContainer/Makefile.in @@ -0,0 +1,33 @@ +#============================================================================== +# File : Makefile.in +# Created : mar jui 3 12:58:13 CEST 2001 +# Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA +# Project : SALOME +# Copyright : EDF 2001 - CEA 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + +@COMMENCE@ + +EXPORT_PYSCRIPTS = SALOME_TestComponentPy.py TestComponentPy.py + +# Libraries targets + +LIB = libSalomeTestComponentEngine.la +LIB_SRC = SALOME_TestComponent_i.cxx +LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl + +# Executables targets +BIN = TestContainer +BIN_SRC = + +LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSalomeLoggerServer +CPPFLAGS+= -I../Logger + +@CONCLUDE@ diff --git a/src/TestContainer/SALOME_TestComponentPy.py b/src/TestContainer/SALOME_TestComponentPy.py new file mode 100755 index 000000000..5dcf1673b --- /dev/null +++ b/src/TestContainer/SALOME_TestComponentPy.py @@ -0,0 +1,30 @@ +#! /usr/bin/env python + +#============================================================================= +# File : SALOME_TestComponentPy.py +# Created : lun sep 3 17:54:13 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================= + +import sys +from omniORB import CORBA, PortableServer +import CosNaming +import Engines, Engines__POA +from SALOME_ComponentPy import * + +class SALOME_TestComponentPy( Engines__POA.TestComponent, SALOME_ComponentPy_i): + + def Coucou(self, val): + print "SALOME_TestComponentPy Coucou ", val + result = "result from SALOME_TestComponentPy Coucou " + `val` + return result + + def __init__(self, orb, poa, contID, containerName, instanceName, interfaceName): + notif = 0 + SALOME_ComponentPy_i.__init__(self, orb, poa, contID, containerName, + instanceName, interfaceName, notif) + print "SALOME_TestComponentPy::__init__" + diff --git a/src/TestContainer/SALOME_TestComponent_i.cxx b/src/TestContainer/SALOME_TestComponent_i.cxx new file mode 100644 index 000000000..0e981c5dc --- /dev/null +++ b/src/TestContainer/SALOME_TestComponent_i.cxx @@ -0,0 +1,60 @@ +using namespace std; +//============================================================================= +// File : SALOME_TestComponent_i.cxx +// Created : jeu jui 12 12:28:26 CEST 2001 +// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#include "utilities.h" +#include "SALOME_TestComponent_i.hxx" +#include + +Engines_TestComponent_i::Engines_TestComponent_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) : + Engines_Component_i(orb, poa, contId, instanceName, interfaceName) +{ + MESSAGE("activate object") + _thisObj = this ; + _id = _poa->activate_object(_thisObj); + //SCRUTE(this) +} + +Engines_TestComponent_i::Engines_TestComponent_i() +{ +} + +Engines_TestComponent_i::~Engines_TestComponent_i() +{ +} + +char* Engines_TestComponent_i::Coucou(CORBA::Long L) +{ + char s[100]; + sprintf(s, "TestComponent_i : L = %ld", (long) L); + + return CORBA::string_dup(s); +} + +extern "C" +{ + PortableServer::ObjectId * SalomeTestComponentEngine_factory( + CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) + { + MESSAGE("PortableServer::ObjectId * TestComponent_factory()"); + SCRUTE(interfaceName); + Engines_TestComponent_i * myTestComponent + = new Engines_TestComponent_i(orb, poa, contId, instanceName, interfaceName); + return myTestComponent->getId() ; + } +} + diff --git a/src/TestContainer/SALOME_TestComponent_i.hxx b/src/TestContainer/SALOME_TestComponent_i.hxx new file mode 100644 index 000000000..848e74394 --- /dev/null +++ b/src/TestContainer/SALOME_TestComponent_i.hxx @@ -0,0 +1,38 @@ +//============================================================================= +// File : SALOME_TestComponent_i.hxx +// Created : jeu jui 12 12:28:30 CEST 2001 +// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#ifndef _SALOME_TESTCOMPONENT_I_HXX_ +#define _SALOME_TESTCOMPONENT_I_HXX_ + +#include +#include +#include CORBA_SERVER_HEADER(SALOME_TestComponent) +#include "SALOME_Component_i.hxx" + +class Engines_TestComponent_i: + public POA_Engines::TestComponent, + public Engines_Component_i +{ +public: + Engines_TestComponent_i(); + Engines_TestComponent_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName); + + virtual ~Engines_TestComponent_i(); + + char* Coucou(CORBA::Long L); + +private: + +}; + +#endif diff --git a/src/TestContainer/TestComponentPy.py b/src/TestContainer/TestComponentPy.py new file mode 100755 index 000000000..a2547ffa5 --- /dev/null +++ b/src/TestContainer/TestComponentPy.py @@ -0,0 +1,55 @@ +#! /usr/bin/env python + +#============================================================================= +# File : TestComponentPy.py +# Created : lun sep 3 17:54:13 CEST 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================= + +import os +import sys +import string +from omniORB import CORBA +import CosNaming +import Engines + + +#initialise the ORB +orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) + +#obtain a reference to the root naming context +obj = orb.resolve_initial_references("NameService") +rootContext = obj._narrow(CosNaming.NamingContext) + +if rootContext is None: + print "Name Service Reference is invalid" + sys.exit(1) + +#resolve the name /Containers.dir/FactoryServerPy.object +myMachine=string.split(os.getenv( "HOSTNAME" ),'.') +machineName= myMachine[0] +containerName = "FactoryServerPy" +name = [CosNaming.NameComponent("Containers","dir"), + CosNaming.NameComponent(machineName,"dir"), + CosNaming.NameComponent(containerName,"object")] + +try: + obj = rootContext.resolve(name) +except CosNaming.NamingContext.NotFound, ex: + print containerName , " not found in Naming Service" + sys.exit(1) + +container = obj._narrow(Engines.Container) +print container._get_machineName() +comp = container.load_impl("SALOME_TestComponentPy","SALOME_TestComponentPy") +print comp._get_instanceName() +comp.ping() +comptest = comp._narrow(Engines.TestComponent) +if comptest is None: + print "probleme cast" +print comptest.Coucou(1) + + diff --git a/src/TestContainer/TestContainer.cxx b/src/TestContainer/TestContainer.cxx new file mode 100644 index 000000000..6e2723c1f --- /dev/null +++ b/src/TestContainer/TestContainer.cxx @@ -0,0 +1,82 @@ +using namespace std; +//============================================================================= +// File : TestContainer.cxx +// Created : jeu jui 12 13:11:27 CEST 2001 +// Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#include "utilities.h" +#include +#include +#include +#include CORBA_CLIENT_HEADER(SALOME_Component) +#include CORBA_CLIENT_HEADER(SALOME_TestComponent) + +#include "SALOME_NamingService.hxx" +#include "OpUtil.hxx" + +int main (int argc, char * argv[]) +{ + + try + { + // Initializing omniORB + CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); + + // use IOR to find container + //if (argc != 2) { return 1; } + //CORBA::Object_var obj = orb->string_to_object(argv[1]); + //Engines::Container_var iGenFact = Engines::Container::_narrow(obj); + + // Obtain a reference to the root POA + CORBA::Object_var obj = orb->resolve_initial_references("RootPOA") ; + PortableServer::POA_var poa = PortableServer::POA::_narrow(obj) ; + + // Use Name Service to find container + SALOME_NamingService _NS(orb) ; + string containerName = "/Containers/" ; + string hostName = GetHostname(); + containerName += hostName; + + obj = _NS.Resolve(containerName.c_str()) ; + Engines::Container_var iGenFact = Engines::Container::_narrow(obj); + + Engines::TestComponent_var m1; + + for (int iter = 0; iter < 3 ; iter++) + { + MESSAGE("----------------------------------------------------" << iter); + + obj = iGenFact->load_impl("SalomeTestComponent", + "../lib/libSalomeTestComponentEngine.so"); + m1 = Engines::TestComponent::_narrow(obj); + MESSAGE("recup m1"); + SCRUTE(m1->instanceName()); + MESSAGE("Coucou " << m1->Coucou(1L)); + iGenFact->remove_impl(m1) ; + //iGenFact->finalize_removal() ; // unpredictable results ... + sleep(5); + } + // Clean-up. + iGenFact->finalize_removal() ; + orb->destroy(); + } + 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::Exception&) { + INFOS("Caught CORBA::Exception.") + } + catch(...) { + INFOS("Caught unknown exception.") + } + + return 0; +} + diff --git a/src/Utils/Makefile.in b/src/Utils/Makefile.in new file mode 100644 index 000000000..e0769df77 --- /dev/null +++ b/src/Utils/Makefile.in @@ -0,0 +1,47 @@ +#============================================================================== +# File : Makefile.in +# Created : mar jui 3 12:12:54 CEST 2001 +# Author : Marc Tajchman (CEA) +# Project : SALOME +# Copyright : CEA 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= \ + utilities.h \ + OpUtil.hxx \ + Utils_CorbaException.hxx \ + Utils_CommException.hxx \ + Utils_SALOME_Exception.hxx \ + Utils_ORB_INIT.hxx \ + Utils_Identity.hxx \ + Utils_SINGLETON.hxx \ + Utils_DESTRUCTEUR_GENERIQUE.hxx + +EXPORT_PYSCRIPTS = Utils_Identity.py SALOME_utilities.py +# Libraries targets + +BIN_CLIENT_IDL = + +LIB = libOpUtil.la +LIB_SRC = OpUtil.cxx duplicate.cxx \ + Utils_CommException.cxx \ + Utils_SALOME_Exception.cxx \ + Utils_Identity.cxx Utils_ORB_INIT.cxx \ + Utils_DESTRUCTEUR_GENERIQUE.cxx + +LDFLAGS+= -lSalomeLoggerServer + +@CONCLUDE@ + + diff --git a/src/Utils/OpUtil.cxx b/src/Utils/OpUtil.cxx new file mode 100644 index 000000000..72c53a60c --- /dev/null +++ b/src/Utils/OpUtil.cxx @@ -0,0 +1,48 @@ +using namespace std; +#include "utilities.h" +#include "OpUtil.hxx" +#include +#include +#include + +int gethostname(char *name, size_t len); + +string GetHostname() +{ + int ls = 100, r = 0; + char *s; + + while (ls < 10000) { + ls *= 2; + s = new char[ls]; + r = gethostname(s, ls-1); + switch (r) + { + case 0: + break; + default: +#ifdef EINVAL + case EINVAL: +#endif +#ifdef ENAMETOOLONG + case ENAMETOOLONG: +#endif + delete [] s; + continue; + } + } + + if (r != 0) { + s = new char[50]; + strcpy(s, "localhost"); + } + + // remove all after '.' + char *aDot = (strchr(s,'.')); + if (aDot) aDot[0] = '\0'; + + string p = s; + delete [] s; + return p; +} + diff --git a/src/Utils/OpUtil.hxx b/src/Utils/OpUtil.hxx new file mode 100644 index 000000000..306d7fd91 --- /dev/null +++ b/src/Utils/OpUtil.hxx @@ -0,0 +1,9 @@ +#ifndef _OPUTIL_HXX +#define _OPUTIL_HXX + +#include + +string GetHostname(); +const char *duplicate(const char * const); + +#endif diff --git a/src/Utils/SALOME_utilities.py b/src/Utils/SALOME_utilities.py new file mode 100644 index 000000000..0911df2d8 --- /dev/null +++ b/src/Utils/SALOME_utilities.py @@ -0,0 +1,37 @@ +import SALOME_Trace +GLogger = SALOME_Trace.SALOME_Trace() + +def MYTRACE (): + if __debug__: + str = "- Trace " + GLogger.putMessage(str + " : ") + + +def REPERE(): + if __debug__: + GLogger.putMessage(" -------------- \n") + + +def BEGIN_OF(msg): + if __debug__: + REPERE(); MYTRACE(); + GLogger.putMessage("Begin of : "+ msg + "\n") + REPERE(); + + +def END_OF(msg): + if __debug__: + REPERE(); MYTRACE(); + GLogger.putMessage("Normale end of : "+ msg + "\n") + REPERE(); + +def MESSAGE(msg): + if __debug__: + MYTRACE() + GLogger.putMessage(msg + "\n") + +def SCRUTE(var_name, var_value): + MYTRACE(); + GLogger.putMessage(var_name + " = " + str(var_value) + "\n") + + diff --git a/src/Utils/SalomeString.hxx b/src/Utils/SalomeString.hxx new file mode 100644 index 000000000..6a9c18f6d --- /dev/null +++ b/src/Utils/SalomeString.hxx @@ -0,0 +1,35 @@ +# ifndef SALOME_STRING +# define SALOME_STRING + +# include +# include + +class SALOME_STRING : public string +{ +private : + ostringstream _s ; +public : + operator const char*() const + { + return _s.str().c_str() ; + } + SALOME_STRING() : _s() + { + } + template SALOME_STRING( const T &valeur ) : _s() + { + _s << valeur ; + } + template SALOME_STRING &operator<<( const T &valeur ) + { + _s << valeur ; + return *this ; + } +} ; + +// Exemple d'utilisation avec les exceptions SALOME +// SALOME_STRING msgErr; +// msgErr << "ESSAI::ESSAI() : This Object cannot be instanciated by now ! Try "<< 11 << "times just to see what happens "; +// throw SALOME_EXCEPTION (LOCALIZED(msgErr)) ; + +# endif diff --git a/src/Utils/Utils_CommException.cxx b/src/Utils/Utils_CommException.cxx new file mode 100644 index 000000000..2e81c9da1 --- /dev/null +++ b/src/Utils/Utils_CommException.cxx @@ -0,0 +1,31 @@ +using namespace std; +//============================================================================= +// File : Utils_CommException.cxx +// Created : lun nov 5 16:04:47 CET 2001 +// Author : Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +using namespace std; +# include "Utils_CommException.hxx" + +CommException::CommException( void ): SALOME_Exception( "CommException" ) +{ +} + + +CommException::CommException( const char *texte ): SALOME_Exception( texte ) +{ +} + + +CommException::CommException( const CommException &ex ): SALOME_Exception( ex ) +{ +} + + +CommException::~CommException() throw () +{ +} diff --git a/src/Utils/Utils_CommException.hxx b/src/Utils/Utils_CommException.hxx new file mode 100644 index 000000000..7d75040b9 --- /dev/null +++ b/src/Utils/Utils_CommException.hxx @@ -0,0 +1,24 @@ +//============================================================================= +// File : Utils_CommException.hxx +// Created : lun nov 5 16:04:47 CET 2001 +// Author : Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +# if !defined ( __Utils_CommException_H__ ) +# define __Utils_CommException_H__ ) + +# include "Utils_SALOME_Exception.hxx" + +class CommException : public SALOME_Exception +{ +public : + CommException( void ); + CommException( const char *texte ); + CommException( const CommException &ex ); + ~CommException() throw (); +} ; + +# endif /* # if ( !defined __Utils_CommException_H__ ) */ diff --git a/src/Utils/Utils_CorbaException.hxx b/src/Utils/Utils_CorbaException.hxx new file mode 100644 index 000000000..dff27eb08 --- /dev/null +++ b/src/Utils/Utils_CorbaException.hxx @@ -0,0 +1,29 @@ +//============================================================================= +// File : Utils_CorbaException.hxx +// Created : mer déc 19 14:12:19 CET 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#ifndef _UTILS_CORBAEXCEPTION_HXX_ +#define _UTILS_CORBAEXCEPTION_HXX_ + +#include +#include CORBA_SERVER_HEADER(SALOME_Exception) + +/*! + * To raise a CORBA exception from a CORBA servant. + */ +# define THROW_SALOME_CORBA_EXCEPTION(chain, typex) \ + {\ + SALOME::ExceptionStruct ExDescription; \ + ExDescription.text = CORBA::string_dup(chain); \ + ExDescription.type = typex; \ + ExDescription.sourceFile = CORBA::string_dup(__FILE__); \ + ExDescription.lineNumber = __LINE__; \ + throw SALOME::SALOME_Exception(ExDescription); \ + } + +#endif diff --git a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx new file mode 100644 index 000000000..0e102b10c --- /dev/null +++ b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx @@ -0,0 +1,122 @@ +using namespace std; +//============================================================================= +// File : Utils_DESTRUCTEUR_GENERIQUE.cxx +// Created : lun nov 5 16:04:47 CET 2001 +// Author : Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +using namespace std; + +void Nettoyage( void ) ; + +# include +# include "utilities.h" +# include "Utils_DESTRUCTEUR_GENERIQUE.hxx" +# include +extern "C" +{ +# include +} + +static list *Destructeurs=0 ; + + + + +/*! \class ATEXIT_ + * + * Mécanisme pour faire exécuter une seule fois DESTRUCTEUR_GENERIQUE_::Nettoyage + * à la fin du traitement : creation d'un singleton statique de l'objet + * tres specialise ATEXIT_. + * + * La création d'un objet de type ATEXIT_ entraîne l'inscription de la fonction + * Nettoyage() par atexit(). Il suffit donc de créer un singleton statique du type ATEXIT_ + * pour effectuer cet enregistrement une seule fois indépendament de l'utilisateur. + */ + +class ATEXIT_ +{ +public : + /*! + * Allocation dynamique de Destructeurs, une liste chaînée de DESTRUCTEUR_GENERIQUE_* et enregistrement + * de la fonction Nettoyage() par atexit(). + * + * La liste chaînée Destructeurs est détruite dans la fonction Nettoyage. + */ + ATEXIT_( void ) + { + ASSERT (Destructeurs==0); + 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 ! + ASSERT(cr==0) ; + } + + ~ATEXIT_( ) + { + MESSAGE("Destruction ATEXIT") ; + } +}; + + + + +static ATEXIT_ nettoyage ; /* singleton statique */ + + +/*! + * traitement effectué : + * -# exécution de tous les objets de type DESTRUCTEUR_DE_ stockés dans la liste Destructeurs (ce qui détruit les + * singletons correspondant) ; + * -# puis destruction de tous les objets de type DESTRUCTEUR_DE_ stockés dans la liste Destructeurs; + * -# destruction de la liste Destructeurs. + */ + +void Nettoyage( void ) +{ + BEGIN_OF("Nettoyage( void )") ; + ASSERT(Destructeurs) ; + SCRUTE( Destructeurs->size() ) ; + if( Destructeurs->size() ) + { + list::iterator it = Destructeurs->end() ; + + do + { + MESSAGE( "DESTRUCTION d'un SINGLETON") ; + it-- ; + DESTRUCTEUR_GENERIQUE_* ptr = *it ; + //Destructeurs->remove( *it ) ; + (*ptr)() ; + delete ptr ; + }while( it!= Destructeurs->begin() ) ; + + Destructeurs->clear() ; + SCRUTE( Destructeurs->size() ) ; + ASSERT( Destructeurs->size()==0 ) ; + ASSERT( Destructeurs->empty() ) ; + } + + delete Destructeurs; + Destructeurs=0; + END_OF("Nettoyage( void )") ; + return ; +} + + +/*! + * Adds a destruction object to the list of actions to be performed at the end + * of the process + */ +const int DESTRUCTEUR_GENERIQUE_::Ajout( DESTRUCTEUR_GENERIQUE_ &objet ) +{ + // N.B. : l'ordre de creation des SINGLETON etant important + // on n'utilise pas deux fois la meme position pour + // les stocker dans la pile des objets. + ASSERT(Destructeurs) ; + Destructeurs->push_back( &objet ) ; + return Destructeurs->size() ; +} diff --git a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx new file mode 100644 index 000000000..73d27ddd8 --- /dev/null +++ b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx @@ -0,0 +1,116 @@ +//============================================================================= +// File : Utils_DESTRUCTEUR_GENERIQUE.hxx +// Created : Mon Nov 5 17:01:47 CET 2001 +// Author : Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +# if !defined( __DESTRUCTEUR_GENERIQUE__H__ ) +# define __DESTRUCTEUR_GENERIQUE__H__ + +# include "utilities.h" + +/*!\class DESTRUCTEUR_GENERIQUE_ + * + * Definition + * + * The DESTRUCTEUR_GENERIQUE_ abstract class describes the comportement of any destruction object. + * Tis type is used to create a list of miscellaneous destruction object. + * + * Usage + * + * The only way to use the DESTRUCTEUR_GENERIQUE_ class is inheritance : + * class DESTRUCTEUR_SPECIFIQUE_ : public DESTRUCTEUR_GENERIQUE_ + * + * Design description + * + * A generic destructor supply two functionalities : + * -# a static method to add a destruction (objetct) to be performed DESTRUCTEUR_GENERIQUE_::Ajout( + * DESTRUCTEUR_GENERIQUE_ &objet) ; + * The Destruction object is stored in a list of pointer to DESTRUCTEUR_GENERIQUE_ objects. + * -# an object method to execute the destruction : operator()(). + */ + +class DESTRUCTEUR_GENERIQUE_ +{ +public : + virtual ~DESTRUCTEUR_GENERIQUE_() {}//!< virtual destructor + static const int Ajout( DESTRUCTEUR_GENERIQUE_ &objet );//!< adds a destruction object to the list of destructions + virtual void operator()( void )=0 ;//!< performs the destruction +} ; + + + + + + +/*!\class DESTRUCTEUR_DE_ + * + * Purpose + * + * The DESTRUCTEUR_DE_ class allows the user to program - at any moment - the destruction of an object + * at the end of the process. + * + * Usage + * + * In this example the POINT_ ptrPoint will be destroyed at the end of the process (atexit). + * + * POINT_ *ptrPoint = new POINT_ ;
+ * DESTRUCTEUR_DE_ *ptrDestruction = new DESTRUCTEUR_DE_( *ptrPoint ) ; + * + * Note that neither ptrPoint, nor ptrDestruction should be destroyed by the user. + * + * Design description + * + * The destruction object must be created dynamicaly because it suscribes himself in the list of + * destruction to be performed at the end of the process. + * + */ + +template class DESTRUCTEUR_DE_ : public DESTRUCTEUR_GENERIQUE_ +{ +public : + + inline DESTRUCTEUR_DE_( TYPE &objet ); //! programs the destruction at the end of the process, of the object objet + virtual void operator()( void ) ; //!< performs the destruction of the object + virtual ~DESTRUCTEUR_DE_() ; +private : + const TYPE *_PtrObjet ; +} ; + + + + + + +/*! +This method records in _PtrObjet the address of an object to be destroyed at the end of the process +*/ +template DESTRUCTEUR_DE_::DESTRUCTEUR_DE_( TYPE &objet ): _PtrObjet( &objet ) +{ + int k = DESTRUCTEUR_GENERIQUE_::Ajout( *this ) ; + ASSERT(k>=0) ; +} + +template DESTRUCTEUR_DE_::~DESTRUCTEUR_DE_() +{ + ASSERT(_PtrObjet==NULL) ; +} + +/*! +This method really destroys the object pointed by _PtrObjet. It should be called at the end of the process +(i.e. at exit). +*/ +template void DESTRUCTEUR_DE_::operator()( void ) +{ + if ( _PtrObjet ) + { + MESSAGE("deleting _PtrObjet") ; + delete (TYPE*)_PtrObjet ; + _PtrObjet = NULL ; + } +} + +# endif /* # if !defined( __SINGLETON__H__ ) */ diff --git a/src/Utils/Utils_Identity.cxx b/src/Utils/Utils_Identity.cxx new file mode 100644 index 000000000..7d80073cd --- /dev/null +++ b/src/Utils/Utils_Identity.cxx @@ -0,0 +1,142 @@ +using namespace std; +//============================================================================= +// File : Utils_Identity.cxx +// Created : Mon Nov 5 17:02:37 CET 2001 +// Author : Pascale NOYRET, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +# include +# include +# include +# include +# include +# include "utilities.h" +# include "Utils_Identity.hxx" +extern "C" +{ +# include +# include +} + +const char* duplicate( const char *const str ) ; + +const struct utsname get_uname( void ) +{ + struct utsname hostid; + const int retour=uname(&hostid); + ASSERT(retour>=0); + return hostid ; +} + +const char* get_adip( void ) +{ + struct utsname hostid; + const int retour=uname(&hostid); + ASSERT(retour>=0); + + const hostent* pour_adip=gethostbyname(hostid.nodename); + ASSERT(pour_adip!=NULL); + const in_addr ip_addr=*(struct in_addr*)(pour_adip->h_addr) ; + return duplicate(inet_ntoa(ip_addr)); +} +const char* const get_pwname( void ) +{ + struct passwd *papa = getpwuid( getuid() ) ; + return papa->pw_name ; +} + +Identity::Identity( const char *name ): _name(duplicate(name)),\ + _hostid(get_uname()),\ + _adip(get_adip()),\ + _uid(getuid()) ,\ + _pwname(get_pwname()) ,\ + _dir(getcwd(NULL,0)),\ + _pid(getpid()) ,\ + _start(time(NULL)),\ + _cstart(ctime(&_start)) +{ + ; +} + + +Identity::~Identity(void) +{ + delete [] (char*)_name ; + (char*&)_name = NULL ; + + delete [] (char*)_dir ; + (char*&)_dir = NULL ; + + delete [] (char*)_adip ; + (char*&)_adip = NULL ; +} + +/*------------*/ +/* Accessors */ +/*------------*/ + +const char* const Identity::name (void) const +{ + return _name ; +} +const pid_t &Identity::pid(void) const +{ + return _pid ; +} +const struct utsname &Identity::hostid(void) const +{ + return _hostid ; +} +const uid_t &Identity::uid(void) const +{ + return _uid ; +} +const time_t &Identity::start(void) const +{ + return _start ; +} +const char* const Identity::rep (void) const +{ + return _dir ; +} +const char* const Identity::pwname (void) const +{ + return _pwname ; +} +const char* const Identity::adip (void) const +{ + return _adip ; +} + +/*------------------*/ +/* Other methods */ +/*------------------*/ + +const char* Identity::host_char( void ) const +{ + return _hostid.nodename; +} + +const char* Identity::start_char(void) const +{ + return ctime(&_start) ; +} + +ostream & operator<< ( ostream& os , const Identity& monid ) +{ + ASSERT(monid._name!=NULL) ; + os << "Identity :" << endl ; + os << '\t' << "Component name : " << monid._name << endl ; + os << '\t' << "Numero de PID : " << monid._pid << endl; + os << '\t' << "Uid utilisateur : " << monid._uid << endl; + os << '\t' << "nom utilisateur : " << monid._pwname << endl; + os << '\t' << "Nom de machine : " << (monid._hostid).nodename << endl; + os << '\t' << "Adresse IP : " << monid._adip << endl; + os << '\t' << "Heure de lancement : " << monid._cstart ; //ctime(&monid._start) ; + os << '\t' << "Dans le repertoire : " << monid._dir << endl; + + return os ; +} diff --git a/src/Utils/Utils_Identity.hxx b/src/Utils/Utils_Identity.hxx new file mode 100644 index 000000000..69a77ecef --- /dev/null +++ b/src/Utils/Utils_Identity.hxx @@ -0,0 +1,59 @@ +//============================================================================= +// File : Utils_Identity.hxx +// Created : Mon Nov 5 17:02:37 CET 2001 +// Author : Pascale NOYRET, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +# if !defined( __IDENTITE_H__ ) +# define __IDENTITE_H__ + +extern "C" +{ +# include +# include +# include +# include +} + +class Identity +{ + +protected : + const char* const _name ; + const struct utsname _hostid; + const char* const _adip; // Internet address + const uid_t _uid ; + const char* const _pwname ; + const char* const _dir ; + const pid_t _pid ; + const time_t _start; + const char* const _cstart ; + + +private : + Identity( void ); + Identity( const Identity &monid ); + + +public : + Identity(const char *name); + ~Identity(); + friend ostream & operator<< ( ostream& os , const Identity& monid ); + + const char* const name( void ) const; + const pid_t& pid(void) const; + const struct utsname& hostid(void) const; + const char* const adip(void) const; + const uid_t& uid(void) const; + const char* const pwname(void) const; + const time_t& start(void) const; + const char* const rep (void) const; + + const char* host_char(void ) const; + const char* start_char(void) const; + +} ; +# endif /* # if !defined( __IDENTITE_H__ ) */ diff --git a/src/Utils/Utils_Identity.py b/src/Utils/Utils_Identity.py new file mode 100644 index 000000000..cc194d09a --- /dev/null +++ b/src/Utils/Utils_Identity.py @@ -0,0 +1,29 @@ +#! /usr/bin/env python + +#============================================================================== +# File : Utils_Identity.py +# Created : thur 02 May 2002 +# Author : Estelle Deville, CEA +# Project : SALOME +# Copyright : CEA 2002 +# $Header$ +#============================================================================== + +import sys +import os +import socket +import pwd +import time + +class Identity: + def __init__(self,name): + self._name = name + self._pid = os.getpid() + self._machine = os.getenv( "HOSTNAME" ) + self._adip = socket.gethostbyname(self._machine) # IP adress + self._uid = os.getuid() + list = pwd.getpwuid(self._uid) + self._pwname = list[0] # user name + self._tc_start = time.time() + self._cstart = time.ctime(self._tc_start) + self._cdir = os.getcwd() diff --git a/src/Utils/Utils_ORB_INIT.cxx b/src/Utils/Utils_ORB_INIT.cxx new file mode 100644 index 000000000..b1561e912 --- /dev/null +++ b/src/Utils/Utils_ORB_INIT.cxx @@ -0,0 +1,49 @@ +using namespace std; +//============================================================================= +// File : Utils_ORB_INIT.cxx +// Created : lun nov 5 16:04:47 CET 2001 +// Author : Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +using namespace std; +# include "Utils_ORB_INIT.hxx" +# include "utilities.h" + +ORB_INIT::ORB_INIT( void ): _orb( CORBA::ORB::_nil() ) +{ + ; +} + + +ORB_INIT::~ORB_INIT() +{ + if ( ! CORBA::is_nil( _orb ) ) + { + MESSAGE("appel _orb->destroy()") ; + _orb->destroy() ; + MESSAGE("retour _orb->destroy()") ; + } +} + + +CORBA::ORB_var &ORB_INIT::operator() ( int argc , char **argv ) throw( CommException ) +{ + if ( CORBA::is_nil( _orb ) ) + { + try + { + _orb = CORBA::ORB_init( argc , argv ) ; + //set GIOP message size equal to 50Mb for transferring brep shapes as + //sequence of bytes using C++ streams + omniORB::MaxMessageSize(100*1024*1024); + } + catch( const CORBA::Exception &ex ) + { + throw CommException( "Unable to create an ORB connexion" ) ; + } + } + return _orb ; +} diff --git a/src/Utils/Utils_ORB_INIT.hxx b/src/Utils/Utils_ORB_INIT.hxx new file mode 100644 index 000000000..1354f7809 --- /dev/null +++ b/src/Utils/Utils_ORB_INIT.hxx @@ -0,0 +1,43 @@ +//============================================================================= +// File : Utils_ORB_INIT.hxx +// Created : lun nov 5 16:04:47 CET 2001 +// Author : Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + + +# if ! defined( __ORB_INIT_HXX__ ) +# define __ORB_INIT_HXX__ + +# include "CORBA.h" + +#include "Utils_CommException.hxx" + + +/*! + * Ce composant prend en charge la connexion et la deconnexion a l'orb + * Il est souhaitable de l'utiliser dans un SINGLETON. + */ + +class ORB_INIT +{ + +private : + CORBA::ORB_var _orb ; + +public : + ORB_INIT( void ); + ~ORB_INIT(); + CORBA::ORB_var & operator() ( int argc , char **argv ) throw( CommException ) ; + + inline CORBA::ORB_var &orb( void ); +} ; + +inline CORBA::ORB_var &ORB_INIT::orb( void ) +{ + return _orb ; +} + +# endif diff --git a/src/Utils/Utils_SALOME_Exception.cxx b/src/Utils/Utils_SALOME_Exception.cxx new file mode 100644 index 000000000..3a2591bac --- /dev/null +++ b/src/Utils/Utils_SALOME_Exception.cxx @@ -0,0 +1,100 @@ +using namespace std; +//============================================================================= +// File : Utils_SALOME_Exception.cxx +// Created : Mon Nov 5 17:01:47 CET 2001 +// Author : Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +using namespace std; +#include +#include "Utils_SALOME_Exception.hxx" +#include "utilities.h" +extern "C" +{ +#include +#include +#include +} + + +const char* duplicate( const char *const str ) ; + +SALOME_Exception::SALOME_Exception( void ): exception() , _text(0) +{ + MESSAGE( "You must user the standard builder : SALOME_Exception::SALOME_Exception( const char *text )" ) ; + INTERRUPTION(1) ; +} + + + +const char *makeText( const char *text, const char *fileName, const unsigned int lineNumber ) +{ + char *newText = 0 ; + + ASSERT(text) ; + const size_t l1 = 1+strlen(text) ; + ASSERT(l1>1) ; + + const char* prefix = "Salome Exception" ; + const size_t l0 = 2+strlen(prefix) ; + + if ( fileName ) + { + const size_t l2 = 4+strlen(fileName) ; + ASSERT(l2>4) ; + + ASSERT(lineNumber>=1) ; + const size_t l3 = 4+int(log10(float(lineNumber))) ; + + newText = new char [ 1+l0+l1+l2+l3 ] ; + sprintf( newText , "%s in %s [%u] : %s" , prefix, fileName, lineNumber, text ) ; + } + else + { + newText = new char [ 1+l0+l1 ] ; + sprintf( newText , "%s : %s" , prefix, text ) ; + } + ASSERT(newText) ; + return newText ; +} + + +SALOME_Exception::SALOME_Exception( const char *text, const char *fileName, const unsigned int lineNumber ) : exception(), _text( makeText( text , fileName , lineNumber ) ) +{ +} + + +SALOME_Exception::~SALOME_Exception() throw () +{ + if ( _text ) + { + delete [] _text ; + char *& txt = (char*)_text ; + txt = 0 ; + } + ASSERT(_text==NULL) ; +} + + + +SALOME_Exception::SALOME_Exception( const SALOME_Exception &ex ): _text(duplicate(ex._text)) +{ + ; +} + + +ostream & operator<<( ostream &os , const SALOME_Exception &ex ) +{ + os << ex._text ; + return os ; +} + + + +const char* SALOME_Exception::what( void ) const throw () +{ + return _text ; +} diff --git a/src/Utils/Utils_SALOME_Exception.hxx b/src/Utils/Utils_SALOME_Exception.hxx new file mode 100644 index 000000000..4956aecc0 --- /dev/null +++ b/src/Utils/Utils_SALOME_Exception.hxx @@ -0,0 +1,37 @@ +//============================================================================= +// File : Utils_SALOME_Exception.hxx +// Created : Mon Nov 5 17:01:47 CET 2001 +// Author : Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +#if !defined( __Utils_SALOME_Exception_hxx__ ) +#define __Utils_SALOME_Exception_hxx__ + +using namespace std; +# include +# include + +# define LOCALIZED(message) #message , __FILE__ , __LINE__ + +class SALOME_Exception : public exception +{ + +private : + SALOME_Exception( void ); + +protected : + const char* _text ; // pointeur constant et zone pointee constante !!!! + +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 ); + virtual const char *what( void ) const throw () ; +} ; + + +#endif /* #if !defined( __Utils_SALOME_Exception_hxx__ ) */ diff --git a/src/Utils/Utils_SINGLETON.hxx b/src/Utils/Utils_SINGLETON.hxx new file mode 100644 index 000000000..099b6e8a3 --- /dev/null +++ b/src/Utils/Utils_SINGLETON.hxx @@ -0,0 +1,155 @@ +//============================================================================= +// File : Utils_SINGLETON.hxx +// Created : lun nov 5 16:04:47 CET 2001 +// Author : Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + + + + +# if !defined( __SINGLETON__H__ ) +# define __SINGLETON__H__ + +# include "Utils_DESTRUCTEUR_GENERIQUE.hxx" +# include + +/*!\class SINGLETON_ + * + * Definition + * + * A singleton is a data which is created and deleted only once in the application. + * The C++ compiler allow the user to create static data before the first executable statement. + * They are deleted after the last statement.statement. + * + * The SINGLETON_ template class deals with dynamic singleton. It is useful for functor objects. + * For example, an object which, when created, connects the application to a system and + * disconnects the application at deletion. + * + * + * Usage + * + * To create a single instance a POINT_ object : + * + * # include "Utils_SINGLETON.hxx" + * ... + * ptrPoint = SINGLETON_::Instance() ; + * + * + * Design description + * + * -# the user creates an object of class TYPE By using a class method : SINGLETON_::Instance() which + * returns a pointer to the single object ; + * -# this class method uses the default constructor to create an object ; + * -# at the same time, this class method reate a destructor object which is added to the generic list + * of destructors objects to be executed at the end of the application (atexit) ; + * -# at the end of the application process all the deletions are performed by the Nettoyage() C function + * which execute the destructions objects then deletes the destructions objects themselves ; + * -# the Nettoyage() C function is recorded using atexit() C function through the creation of a static + * single object ATEXIT_(). + */ + + +template class SINGLETON_ +{ + +public : + + static TYPE *Instance( void ); //!< Singleton dynamic creation using the default builder + static bool IsAlreadyExisting( void ); //!< returns True if the singleton is already existing + static int Destruction( void ); //!< destroys the Singleton before the end of the application process + +private : + + TYPE _Instance ; + static SINGLETON_ *PtrSingleton ; + + SINGLETON_( void ); + ~SINGLETON_(); + +} ; /* class SINGLETON_ */ + + + + +template SINGLETON_ *SINGLETON_::PtrSingleton=NULL ; + + + +/*! + * The class method Instance : + * -# creates an object of class TYPE ; + * -# creates a destruction object DESTRUCTEUR_DE_ which is appended to the list of destruction objects to be + * executed ; + * -# returns a pointer to the created object. + * + * Note that the two created objects are deleted at the end of the process in the function Nettoyage(). + */ +template TYPE *SINGLETON_::Instance( void ) +{ + if ( ! PtrSingleton ) + { + MESSAGE("SINGLETON_::Instance( void )") ; + PtrSingleton = new SINGLETON_ ; + new DESTRUCTEUR_DE_( PtrSingleton->_Instance ) ; + } + return &PtrSingleton->_Instance ; +} + + +template bool SINGLETON_::IsAlreadyExisting( void ) +{ + return PtrSingleton ? true : false ; +} + + + + +template SINGLETON_::SINGLETON_( void ) +{ + MESSAGE("CREATION d'un SINGLETON_") ; +} + + + + +/*! + The method SINGLETON_::Destruction can be called by the user. If it is not + the function nettoyage() calls it atexit. + + N.B. : the singleton objects are destroyed in the reverse order of there creation. +*/ +template int SINGLETON_::Destruction( void ) +{ + int k = - 1 ; + BEGIN_OF("SINGLETON_::Destruction( void )") ; + if ( PtrSingleton ) + { + MESSAGE("Destruction du SINGLETON_") ; + + + list::iterator k ; + for( k=DESTRUCTEUR_GENERIQUE_::Destructeurs.begin() ; k!=DESTRUCTEUR_GENERIQUE_::Destructeurs.end();k++) + { + if ( *k == PtrSingleton->_Instance ) + { + DESTRUCTEUR_GENERIQUE_::Destructeurs.erase( k ) ; + break ; + } + } + delete PtrSingleton ; + PtrSingleton = NULL ; + } + END_OF("SINGLETON_::Destruction( void )") ; + return k ; +} + + +template SINGLETON_::~SINGLETON_() +{ + MESSAGE("passage dans SINGLETON_::~SINGLETON_( void )") ; +} + +# endif /* # if !defined( __SINGLETON__H__ ) */ diff --git a/src/Utils/duplicate.cxx b/src/Utils/duplicate.cxx new file mode 100644 index 000000000..2afac9248 --- /dev/null +++ b/src/Utils/duplicate.cxx @@ -0,0 +1,32 @@ +using namespace std; +//============================================================================= +// File : duplicate.cxx +// Created : lun nov 5 16:04:47 CET 2001 +// Author : Antoine YESSAYAN, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +/*! + * This function can be changed by strdup() if strdup() is ANSI. + * It is strongly (and only) used in the Registry environment + * (RegistryService, RegistryConnexion, Identity, ...) + */ +extern "C" +{ +#include +#include +} +#include "utilities.h" + +const char* duplicate( const char *const str ) +{ + ASSERT(str!=NULL) ; + const size_t length = strlen( str ) ; + ASSERT(length>0) ; + char *new_str = new char[ 1+length ] ; + ASSERT(new_str) ; + strcpy( new_str , str ) ; + return new_str ; +} diff --git a/src/Utils/utilities.h b/src/Utils/utilities.h new file mode 100644 index 000000000..ffed24cb2 --- /dev/null +++ b/src/Utils/utilities.h @@ -0,0 +1,117 @@ +//============================================================================= +// File : utilities.h +// Created : mar jun 19 13:18:14 CEST 2001 +// Author : Antoine YESSAYAN, Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +/* --- Definition macros file to print informations if _DEBUG_ is defined --- */ + +# ifndef UTILITIES_H +# define UTILITIES_H + +# include +# include + +//VRV: T2.4 - replacement macro for using special CORBA server +#include "SALOME_Trace.hxx" +//VRV: T2.4 - replacement macro for using special CORBA server + +/* --- INFOS is always defined (without _DEBUG_): to be used for warnings, with release version --- */ + +//VRV: T2.4 - replacement of these macros for using special CORBA server + +#define INFOS(msg) { GLogger.putMessage(GLogger << __FILE__<< " [" << __LINE__ << "] : " << msg<< endl << ends ); } +#define PYSCRIPT(msg) { GLogger.putMessage(GLogger<<"---PYSCRIPT--- "< +#include "QAD_Application.h" +#include "QAD_Desktop.h" + +#include "SALOME_Selection.h" +#include "SALOME_Actor.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//VRV: porting on Qt 3.0.5 +#if QT_VERSION >= 0x030005 +#include +#endif +//VRV: porting on Qt 3.0.5 + +//---------------------------------------------------------------------------- +VTKViewer_InteractorStyleSALOME *VTKViewer_InteractorStyleSALOME::New() +{ + // First try to create the object from the vtkObjectFactory + vtkObject* ret = vtkObjectFactory::CreateInstance("VTKViewer_InteractorStyleSALOME"); + if(ret) + { + return (VTKViewer_InteractorStyleSALOME*)ret; + } + // If the factory was unable to create the object, then create it here. + return new VTKViewer_InteractorStyleSALOME; +} + + +//---------------------------------------------------------------------------- +VTKViewer_InteractorStyleSALOME::VTKViewer_InteractorStyleSALOME() +{ + m_Triedron = 0; + this->MotionFactor = 10.0; + this->State = VTK_INTERACTOR_STYLE_CAMERA_NONE; + this->RadianToDegree = 180.0 / vtkMath::Pi(); + this->ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE; + loadCursors(); +} + +//---------------------------------------------------------------------------- +VTKViewer_InteractorStyleSALOME::~VTKViewer_InteractorStyleSALOME() +{ +} + +//---------------------------------------------------------------------------- +void VTKViewer_InteractorStyleSALOME::setTriedron( vtkActorCollection* triedron ) +{ + m_Triedron = triedron; +} + +//---------------------------------------------------------------------------- +void VTKViewer_InteractorStyleSALOME::RotateXY(int dx, int dy) +{ + double rxf; + double ryf; + vtkCamera *cam; + + if (this->CurrentRenderer == NULL) + { + return; + } + + int *size = this->CurrentRenderer->GetRenderWindow()->GetSize(); + this->DeltaElevation = -20.0 / size[1]; + this->DeltaAzimuth = -20.0 / size[0]; + + rxf = (double)dx * this->DeltaAzimuth * this->MotionFactor; + ryf = (double)dy * this->DeltaElevation * this->MotionFactor; + + cam = this->CurrentRenderer->GetActiveCamera(); + cam->Azimuth(rxf); + cam->Elevation(ryf); + cam->OrthogonalizeViewUp(); + this->CurrentRenderer->ResetCameraClippingRange(); + vtkRenderWindowInteractor *rwi = this->Interactor; + if (this->CurrentLight) + { + // get the first light + this->CurrentLight->SetPosition(cam->GetPosition()); + this->CurrentLight->SetFocalPoint(cam->GetFocalPoint()); + } + rwi->Render(); +} + +//---------------------------------------------------------------------------- +void VTKViewer_InteractorStyleSALOME::PanXY(int x, int y, int oldX, int oldY) +{ + TranslateView(x, y, oldX, oldY); + vtkRenderWindowInteractor *rwi = this->Interactor; + if (this->CurrentLight) + { + /* get the first light */ + vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); + this->CurrentLight->SetPosition(cam->GetPosition()); + this->CurrentLight->SetFocalPoint(cam->GetFocalPoint()); + } + + rwi->Render(); +} + +//---------------------------------------------------------------------------- +void VTKViewer_InteractorStyleSALOME::DollyXY(int dx, int dy) +{ + vtkCamera *cam; + double dxf = this->MotionFactor * (double)(dx) / (double)(this->Center[1]); + double dyf = this->MotionFactor * (double)(dy) / (double)(this->Center[1]); + + double zoomFactor = pow((double)1.1, dxf + dyf); + + if (this->CurrentRenderer == NULL) + { + return; + } + + cam = this->CurrentRenderer->GetActiveCamera(); + if (cam->GetParallelProjection()) + { + cam->SetParallelScale(cam->GetParallelScale()/zoomFactor); + } + else + { + cam->Dolly(zoomFactor); + this->CurrentRenderer->ResetCameraClippingRange(); + } + + if (this->CurrentLight) + { + /* get the first light */ + this->CurrentLight->SetPosition(cam->GetPosition()); + this->CurrentLight->SetFocalPoint(cam->GetFocalPoint()); + } + + this->Interactor->Render(); +} + +//---------------------------------------------------------------------------- +void VTKViewer_InteractorStyleSALOME::SpinXY(int x, int y, int oldX, int oldY) +{ + vtkRenderWindowInteractor *rwi = this->Interactor; + vtkCamera *cam; + + if (this->CurrentRenderer == NULL) + { + return; + } + + double newAngle = atan2((double)(y - this->Center[1]), + (double)(x - this->Center[0])); + double oldAngle = atan2((double)(oldY -this->Center[1]), + (double)(oldX - this->Center[0])); + + newAngle *= this->RadianToDegree; + oldAngle *= this->RadianToDegree; + + cam = this->CurrentRenderer->GetActiveCamera(); + cam->Roll(newAngle - oldAngle); + cam->OrthogonalizeViewUp(); + + rwi->Render(); +} + + +//---------------------------------------------------------------------------- +void VTKViewer_InteractorStyleSALOME::OnMouseMove(int vtkNotUsed(ctrl), + int shift, + int x, int y) +{ + myShiftState = shift; + if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) + onOperation(QPoint(x, y)); + else if (ForcedState == VTK_INTERACTOR_STYLE_CAMERA_NONE) + onCursorMove(QPoint(x, y)); +} + + +//---------------------------------------------------------------------------- +void VTKViewer_InteractorStyleSALOME::OnLeftButtonDown(int ctrl, int shift, + int x, int y) +{ + if (this->HasObserver(vtkCommand::LeftButtonPressEvent)) + { + this->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL); + return; + } + this->FindPokedRenderer(x, y); + if (this->CurrentRenderer == NULL) + { + return; + } + myShiftState = shift; + // finishing current viewer operation + if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) { + onFinishOperation(); + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); + } + myOtherPoint = myPoint = QPoint(x, y); + if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) { + startOperation(ForcedState); + } + else { + if (ctrl) + startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM); + else + startOperation(VTK_INTERACTOR_STYLE_CAMERA_SELECT); + } + return; +} +//---------------------------------------------------------------------------- +void VTKViewer_InteractorStyleSALOME::OnLeftButtonUp(int vtkNotUsed(ctrl), + int shift, + int vtkNotUsed(x), + int vtkNotUsed(y)) +{ + myShiftState = shift; + // finishing current viewer operation + if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) { + onFinishOperation(); + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); + } +} + +//---------------------------------------------------------------------------- +void VTKViewer_InteractorStyleSALOME::OnMiddleButtonDown(int ctrl, + int shift, + int x, int y) +{ + if (this->HasObserver(vtkCommand::MiddleButtonPressEvent)) + { + this->InvokeEvent(vtkCommand::MiddleButtonPressEvent,NULL); + return; + } + this->FindPokedRenderer(x, y); + if (this->CurrentRenderer == NULL) + { + return; + } + myShiftState = shift; + // finishing current viewer operation + if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) { + onFinishOperation(); + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); + } + myOtherPoint = myPoint = QPoint(x, y); + if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) { + startOperation(ForcedState); + } + else { + if (ctrl) + startOperation(VTK_INTERACTOR_STYLE_CAMERA_PAN); + } +} +//---------------------------------------------------------------------------- +void VTKViewer_InteractorStyleSALOME::OnMiddleButtonUp(int vtkNotUsed(ctrl), + int shift, + int vtkNotUsed(x), + int vtkNotUsed(y)) +{ + myShiftState = shift; + // finishing current viewer operation + if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) { + onFinishOperation(); + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); + } +} + +//---------------------------------------------------------------------------- +void VTKViewer_InteractorStyleSALOME::OnRightButtonDown(int ctrl, + int shift, + int x, int y) +{ + if (this->HasObserver(vtkCommand::RightButtonPressEvent)) + { + this->InvokeEvent(vtkCommand::RightButtonPressEvent,NULL); + return; + } + this->FindPokedRenderer(x, y); + if (this->CurrentRenderer == NULL) + { + return; + } + myShiftState = shift; + // finishing current viewer operation + if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) { + onFinishOperation(); + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); + } + myOtherPoint = myPoint = QPoint(x, y); + if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) { + startOperation(ForcedState); + } + else { + if (ctrl) + startOperation(VTK_INTERACTOR_STYLE_CAMERA_ROTATE); + } +} + +//---------------------------------------------------------------------------- +void VTKViewer_InteractorStyleSALOME::OnRightButtonUp(int vtkNotUsed(ctrl), + int shift, + int vtkNotUsed(x), + int vtkNotUsed(y)) +{ + myShiftState = shift; + // finishing current viewer operation + if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) { + onFinishOperation(); + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); + } +} + +//---------------------------------------------------------------------------- +void VTKViewer_InteractorStyleSALOME::PrintSelf(ostream& os, vtkIndent indent) +{ + vtkInteractorStyle::PrintSelf(os,indent); + +} + +/* XPM */ +const char* imageZoomCursor[] = { +"32 32 3 1", +". c None", +"a c #000000", +"# c #ffffff", +"................................", +"................................", +".#######........................", +"..aaaaaaa.......................", +"................................", +".............#####..............", +"...........##.aaaa##............", +"..........#.aa.....a#...........", +".........#.a.........#..........", +".........#a..........#a.........", +"........#.a...........#.........", +"........#a............#a........", +"........#a............#a........", +"........#a............#a........", +"........#a............#a........", +".........#...........#.a........", +".........#a..........#a.........", +".........##.........#.a.........", +"........#####.....##.a..........", +".......###aaa#####.aa...........", +"......###aa...aaaaa.......#.....", +".....###aa................#a....", +"....###aa.................#a....", +"...###aa...............#######..", +"....#aa.................aa#aaaa.", +".....a....................#a....", +"..........................#a....", +"...........................a....", +"................................", +"................................", +"................................", +"................................"}; + +const char* imageRotateCursor[] = { +"32 32 3 1", +". c None", +"a c #000000", +"# c #ffffff", +"................................", +"................................", +"................................", +"................................", +"........#.......................", +".......#.a......................", +"......#######...................", +".......#aaaaa#####..............", +"........#..##.a#aa##........##..", +".........a#.aa..#..a#.....##.aa.", +".........#.a.....#...#..##.aa...", +".........#a.......#..###.aa.....", +"........#.a.......#a..#aa.......", +"........#a.........#..#a........", +"........#a.........#a.#a........", +"........#a.........#a.#a........", +"........#a.........#a.#a........", +".........#.........#a#.a........", +"........##a........#a#a.........", +"......##.a#.......#.#.a.........", +"....##.aa..##.....##.a..........", +"..##.aa.....a#####.aa...........", +"...aa.........aaa#a.............", +"................#.a.............", +"...............#.a..............", +"..............#.a...............", +"...............a................", +"................................", +"................................", +"................................", +"................................", +"................................"}; + +// loads cursors for viewer operations - zoom, pan, etc... +void VTKViewer_InteractorStyleSALOME::loadCursors() +{ + myDefCursor = QCursor(ArrowCursor); + myHandCursor = QCursor(PointingHandCursor); + myPanCursor = QCursor(SizeAllCursor); + myZoomCursor = QCursor(QPixmap(imageZoomCursor)); + myRotateCursor = QCursor(QPixmap(imageRotateCursor)); + mySpinCursor = QCursor(QPixmap(imageRotateCursor)); // temporarly !!!!!! + myGlobalPanCursor = QCursor(CrossCursor); + myCursorState = false; +} + +// event filter - controls mouse and keyboard events during viewer operations +bool VTKViewer_InteractorStyleSALOME::eventFilter(QObject* object, QEvent* event) +{ + VTKViewer_RenderWindow* wnd = dynamic_cast(GetInteractor()->GetRenderWindow()); + if ( (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::KeyPress) && object != wnd) + { + qApp->removeEventFilter(this); + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); + } + return QObject::eventFilter(object, event); +} + +// starts Zoom operation (e.g. through menu command) +void VTKViewer_InteractorStyleSALOME::startZoom() +{ + if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) + { + onFinishOperation(); + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); + } + setCursor(VTK_INTERACTOR_STYLE_CAMERA_ZOOM); + ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ZOOM; + qApp->installEventFilter(this); +} + +// starts Pan operation (e.g. through menu command) +void VTKViewer_InteractorStyleSALOME::startPan() +{ + if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) + { + onFinishOperation(); + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); + } + setCursor(VTK_INTERACTOR_STYLE_CAMERA_PAN); + ForcedState = VTK_INTERACTOR_STYLE_CAMERA_PAN; + qApp->installEventFilter(this); +} + +// starts Rotate operation (e.g. through menu command) +void VTKViewer_InteractorStyleSALOME::startRotate() +{ + if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) + { + onFinishOperation(); + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); + } + setCursor(VTK_INTERACTOR_STYLE_CAMERA_ROTATE); + ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ROTATE; + qApp->installEventFilter(this); +} + +// starts Spin operation (e.g. through menu command) +void VTKViewer_InteractorStyleSALOME::startSpin() +{ + if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) + { + onFinishOperation(); + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); + } + setCursor(VTK_INTERACTOR_STYLE_CAMERA_SPIN); + ForcedState = VTK_INTERACTOR_STYLE_CAMERA_SPIN; + qApp->installEventFilter(this); +} + + +// starts Fit Area operation (e.g. through menu command) +void VTKViewer_InteractorStyleSALOME::startFitArea() +{ + if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) + { + onFinishOperation(); + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); + } + setCursor(VTK_INTERACTOR_STYLE_CAMERA_FIT); + ForcedState = VTK_INTERACTOR_STYLE_CAMERA_FIT; + qApp->installEventFilter(this); +} + +// starts Global Panning operation (e.g. through menu command) +void VTKViewer_InteractorStyleSALOME::startGlobalPan() +{ + if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) + { + onFinishOperation(); + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); + } + setCursor(VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN); + ForcedState = VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN; + + // store current zoom scale + vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); + myScale = cam->GetParallelScale(); + + // make fit all + Standard_Boolean TriedronWasVisible = false; + if ( m_Triedron ) { + m_Triedron->InitTraversal(); + vtkActor *ac = m_Triedron->GetNextActor(); + while(!(ac==NULL)) { + if(ac->GetVisibility()) { + TriedronWasVisible = true; + ac->VisibilityOff(); + } + ac = m_Triedron->GetNextActor(); + } + } + this->CurrentRenderer->ResetCamera(); + this->CurrentRenderer->ResetCameraClippingRange(); + if( m_Triedron && TriedronWasVisible ) { + m_Triedron->InitTraversal(); + vtkActor *ac = m_Triedron->GetNextActor(); + while(!(ac==NULL)) { + ac->VisibilityOn(); + ac = m_Triedron->GetNextActor(); + } + } + VTKViewer_RenderWindow* aRW = dynamic_cast(this->Interactor->GetRenderWindow()); + if (aRW) aRW->updateGL(); + + qApp->installEventFilter(this); +} + +// returns TRUE if needs redrawing +bool VTKViewer_InteractorStyleSALOME::needsRedrawing() +{ + return State == VTK_INTERACTOR_STYLE_CAMERA_ZOOM || + State == VTK_INTERACTOR_STYLE_CAMERA_PAN || + State == VTK_INTERACTOR_STYLE_CAMERA_ROTATE || + State == VTK_INTERACTOR_STYLE_CAMERA_SPIN || + State == VTK_INTERACTOR_STYLE_CAMERA_NONE; +} + +// fits viewer contents to rect +void VTKViewer_InteractorStyleSALOME::fitRect(const int left, + const int top, + const int right, + const int bottom) +{ + if (this->CurrentRenderer == NULL) { + return; + } + vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); + + // move camera + int x = (left + right)/2; + int y = (top + bottom)/2; + int *aSize = this->CurrentRenderer->GetRenderWindow()->GetSize(); + int oldX = aSize[0]/2; + int oldY = aSize[1]/2; + TranslateView(oldX, oldY, x, y); + + // zoom camera + double dxf = (double)(aSize[0]) / (double)(abs(right - left)); + double dyf = (double)(aSize[1]) / (double)(abs(bottom - top)); + double zoomFactor = (dxf + dyf)/2 ; + + if (cam->GetParallelProjection()) { + cam->SetParallelScale(cam->GetParallelScale()/zoomFactor); + } else { + cam->Dolly(zoomFactor); + this->CurrentRenderer->ResetCameraClippingRange(); + } + + vtkRenderWindowInteractor *rwi = this->Interactor; + if (this->CurrentLight) { + /* get the first light */ + this->CurrentLight->SetPosition(cam->GetPosition()); + this->CurrentLight->SetFocalPoint(cam->GetFocalPoint()); + } + // rwi->Render(); + VTKViewer_RenderWindow* aRW = dynamic_cast(rwi->GetRenderWindow()); + if (aRW) aRW->updateGL(); +} + + + +// starts viewer operation (!internal usage!) +void VTKViewer_InteractorStyleSALOME::startOperation(int operation) +{ + switch(operation) + { + case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN: + case VTK_INTERACTOR_STYLE_CAMERA_ZOOM: + case VTK_INTERACTOR_STYLE_CAMERA_PAN: + case VTK_INTERACTOR_STYLE_CAMERA_ROTATE: + case VTK_INTERACTOR_STYLE_CAMERA_SPIN: + case VTK_INTERACTOR_STYLE_CAMERA_FIT: + case VTK_INTERACTOR_STYLE_CAMERA_SELECT: + if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) + startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE); + State = operation; + if (State != VTK_INTERACTOR_STYLE_CAMERA_SELECT) + setCursor(operation); + onStartOperation(); + break; + case VTK_INTERACTOR_STYLE_CAMERA_NONE: + default: + setCursor(VTK_INTERACTOR_STYLE_CAMERA_NONE); + State = ForcedState = VTK_INTERACTOR_STYLE_CAMERA_NONE; + break; + } +} + +// sets proper cursor for window when viewer operation is activated +void VTKViewer_InteractorStyleSALOME::setCursor(const int operation) +{ + VTKViewer_RenderWindow* wnd = dynamic_cast< VTKViewer_RenderWindow*>(GetInteractor()->GetRenderWindow()); + switch (operation) + { + case VTK_INTERACTOR_STYLE_CAMERA_ZOOM: + wnd->setCursor(myZoomCursor); + myCursorState = true; + break; + case VTK_INTERACTOR_STYLE_CAMERA_PAN: + wnd->setCursor(myPanCursor); + myCursorState = true; + break; + case VTK_INTERACTOR_STYLE_CAMERA_ROTATE: + wnd->setCursor(myRotateCursor); + myCursorState = true; + break; + case VTK_INTERACTOR_STYLE_CAMERA_SPIN: + wnd->setCursor(mySpinCursor); + myCursorState = true; + break; + case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN: + wnd->setCursor(myGlobalPanCursor); + myCursorState = true; + break; + case VTK_INTERACTOR_STYLE_CAMERA_FIT: + case VTK_INTERACTOR_STYLE_CAMERA_SELECT: + wnd->setCursor(myHandCursor); + myCursorState = true; + break; + case VTK_INTERACTOR_STYLE_CAMERA_NONE: + default: + wnd->setCursor(myDefCursor); + myCursorState = false; + break; + } +} + +// called when viewer operation started (!put necessary initialization here!) +void VTKViewer_InteractorStyleSALOME::onStartOperation() +{ + VTKViewer_RenderWindow* wnd = dynamic_cast< VTKViewer_RenderWindow*>(GetInteractor()->GetRenderWindow()); + switch (State) { + case VTK_INTERACTOR_STYLE_CAMERA_SELECT: + case VTK_INTERACTOR_STYLE_CAMERA_FIT: + { + QPainter p(wnd); + p.setPen(Qt::lightGray); + p.setRasterOp(Qt::XorROP); + p.drawRect(QRect(myPoint, myOtherPoint)); + break; + } + case VTK_INTERACTOR_STYLE_CAMERA_ZOOM: + case VTK_INTERACTOR_STYLE_CAMERA_PAN: + case VTK_INTERACTOR_STYLE_CAMERA_ROTATE: + case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN: + case VTK_INTERACTOR_STYLE_CAMERA_SPIN: + break; + } +} + +// called when viewer operation finished (!put necessary post-processing here!) +void VTKViewer_InteractorStyleSALOME::onFinishOperation() +{ + QAD_Study* aActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* aSel = SALOME_Selection::Selection( aActiveStudy->getSelection() ); + VTKViewer_RenderWindow* wnd = dynamic_cast< VTKViewer_RenderWindow*>(GetInteractor()->GetRenderWindow()); + vtkRenderWindowInteractor *rwi = this->Interactor; + + int aSelectionMode = aSel->SelectionMode(); + bool aSelActiveCompOnly = aSel->IsSelectActiveCompOnly(); + SALOMEDS::SComponent_var aActiveComponent = SALOMEDS::SComponent::_narrow( + aActiveStudy->getStudyDocument()->FindObject(QAD_Application::getDesktop()->getActiveComponent())); + + switch (State) { + case VTK_INTERACTOR_STYLE_CAMERA_SELECT: + case VTK_INTERACTOR_STYLE_CAMERA_FIT: + { + QPainter p(wnd); + p.setPen(Qt::lightGray); + p.setRasterOp(Qt::XorROP); + QRect rect(myPoint, myOtherPoint); + p.drawRect(rect); + rect = rect.normalize(); + if (State == VTK_INTERACTOR_STYLE_CAMERA_FIT) { + // making fit rect opeation + int w, h, x, y; + rwi->GetSize(w, h); + int x1, y1, x2, y2; + x1 = rect.left(); + y1 = h - rect.top() - 1; + x2 = rect.right(); + y2 = h - rect.bottom() - 1; + fitRect(x1, y1, x2, y2); + } + else { + if (myPoint == myOtherPoint) { + // process point selection + int w, h, x, y; + rwi->GetSize(w, h); + x = myPoint.x(); + y = h - myPoint.y() - 1; + vtkActorCollection* listactors = NULL; + this->FindPokedRenderer(x, y); + rwi->StartPickCallback(); + rwi->GetPicker()->Pick(x, y, 0.0, this->CurrentRenderer); + + if ( rwi->GetPicker()->IsA("vtkCellPicker") ) { + vtkCellPicker* picker; + if ( (picker = vtkCellPicker::SafeDownCast(rwi->GetPicker())) ) { + MESSAGE ( " CellId : " << picker->GetCellId() ); + if ( picker->GetCellId() >= 0 ) { + vtkActor* ac = picker->GetActor(); + if ( ac->IsA("SALOME_Actor") ) { + SALOME_Actor* SActor = SALOME_Actor::SafeDownCast( ac ); + MESSAGE ( " NAME Actor : " << SActor->getName() ); + + //Cell selection //////////////////////////////////// NB + if ( aSelectionMode == 3 ) { + if ( SActor->hasIO() ) { + 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; + } + } + if(IsSelected) { + // This IO is already in the selection + //if(shift) { + bool add = aSel->AddOrRemoveIndex( IO, picker->GetCellId(), myShiftState, false ); + //Sel->RemoveIObject(IO); + //} + } else { + if(!myShiftState) { + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + bool add = aSel->AddOrRemoveIndex( IO, picker->GetCellId(), myShiftState, false ); + aSel->AddIObject( IO, false ); + } + } + } + //Edge selection ////////////////////////// NB + else if ( aSelectionMode == 2 ) { + if ( SActor->hasIO() ) { + Handle(SALOME_InteractiveObject) IO = SActor->getIO(); + float pickPosition[3],pcoords[3],closestPoint[3],weights[3],dist1=1000000.0,dist2=0; + int subId,edgeId,pickedID,result; + pickedID = picker->GetCellId(); + picker->GetPickPosition(pickPosition); + MESSAGE("Position = "<GetMapper()->GetInput()); + if (!UGrid) break; + vtkCell* pickedCell = UGrid->GetCell(pickedID); + if (!pickedCell) break; + vtkCell* edge; + vtkLine* line; + for (int i=0;iGetNumberOfEdges();i++) { + edge = pickedCell->GetEdge(i); + if (edge->GetCellType() == 3) { //3 for VTK_LINE + line = (vtkLine*)edge; + result = line->EvaluatePosition(pickPosition,closestPoint,subId,pcoords,dist2,weights); + MESSAGE("edge "<< i <<" dist = " << dist2); + if (dist2 < dist1) { + dist1 = dist2; + edgeId = i; + } + } + } + MESSAGE("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(3, true); + bool add = aSel->AddOrRemoveIndex( IO, pickedID, 0 ); + aSel->SetSelectionMode(2, true); + edgeId = -edgeId; + add = aSel->AddOrRemoveIndex( IO, edgeId, 0, 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())) ) { + MESSAGE ( " PointId : " << picker->GetPointId() ); + if ( picker->GetPointId() >= 0 ) { + vtkActor* ac = picker->GetActor(); + if ( ac->IsA("SALOME_Actor") ) { + SALOME_Actor* SActor = SALOME_Actor::SafeDownCast( ac ); + MESSAGE ( " NAME Actor : " << SActor->getName() ); + if ( SActor->hasIO() ) { + Handle(SALOME_InteractiveObject) IO = SActor->getIO(); +/* if (IO.IsNull()) + break; + if (aSelActiveCompOnly && + strcmp(aActiveComponent->ComponentDataType(), IO->getComponentDataType()) != 0) { + break; + }*/ + // 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(); + } + } else { + //processing rectangle selection + rwi->StartPickCallback(); + + if (!myShiftState) { + this->PropPicked = 0; + this->HighlightProp( NULL ); + aSel->ClearIObjects(); + } + + // Compute bounds + vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); + QRect rect(myPoint, myOtherPoint); + rect = rect.normalize(); + int w, h, x, y; + rwi->GetSize(w, h); + int x1, y1, x2, y2; + x1 = rect.left(); + y1 = h - rect.top() - 1; + x2 = rect.right(); + y2 = h - rect.bottom() - 1; + + switch (aSelectionMode) { + case 1: // Nodes selection + { + if (! rwi->GetPicker()->IsA("vtkPointPicker") ) break; + vtkPointPicker* aPointPicker = vtkPointPicker::SafeDownCast(rwi->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) { + 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); + if ( aPointPicker->GetPointId() >= 0) { // && (!aSel->IsIndexSelected(IO, aPointPicker->GetPointId()))) { + aSel->AddOrRemoveIndex(IO, aPointPicker->GetPointId(), true, false); + aSel->AddIObject(IO, false); + } + } + } + } + } + } + } + } + } + break; + case 2: // edges selection + case 3: // triangles selection + { + if (! rwi->GetPicker()->IsA("vtkCellPicker") ) break; + vtkCellPicker* aCellPicker = vtkCellPicker::SafeDownCast(rwi->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) { + for (int i=0; i < aDataSet->GetNumberOfCells(); i++) { + vtkCell* aCell = aDataSet->GetCell(i); + if (aCell != NULL) { + if (IsInRect(aCell, x1, y1, x2, y2)) { + float* aBounds = aCell->GetBounds(); + float aCenter[3]; + aCenter[0] =(aBounds[0] + aBounds[1])/2; // Center X + aCenter[1] =(aBounds[2] + aBounds[3])/2; // Center Y + aCenter[2] =(aBounds[4] + aBounds[5])/2; // Center Z + float aDisp[3]; + ComputeWorldToDisplay(aCenter[0], + aCenter[1], + aCenter[2], aDisp); + aCellPicker->Pick(aDisp[0], aDisp[1], 0.0, CurrentRenderer); + if (aSelectionMode == 3) { + if ( aCellPicker->GetCellId() >= 0 && + (!aSel->IsIndexSelected(IO, aCellPicker->GetCellId()))) { + aSel->AddOrRemoveIndex( IO, aCellPicker->GetCellId(), true, false); + aSel->AddIObject( IO, false ); + } + } else { + vtkCell* aTriangleCell = aDataSet->GetCell(aCellPicker->GetCellId()); + vtkCell* aEdge; + if (!aSel->IsIndexSelected(IO, aCellPicker->GetCellId())) { + aSel->SetSelectionMode(3, true); + aSel->AddOrRemoveIndex(IO, aCellPicker->GetCellId(), true, false); + } + aSel->SetSelectionMode(2, true); + for (int i=0; i < aTriangleCell->GetNumberOfEdges(); i++) { + aSel->AddOrRemoveIndex( IO, i, true, false); + } + aSel->AddIObject( IO, false ); + } + } + } + } + } + } + } + } + } + } + break; + case 4: // objects selection + { + vtkActorCollection* aListActors = this->CurrentRenderer->GetActors(); + aListActors->InitTraversal(); + vtkActor* aActor; + SALOME_ListIO aListIO; + for (int k = 0; k < aListActors->GetNumberOfItems(); k++) { + aActor = aListActors->GetNextActor(); + if (aActor) { + if (aActor->GetVisibility() == 0) + continue; + if ( aActor->IsA("SALOME_Actor") ) { + SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(aActor); + if ( aSActor->hasIO() && IsInRect(aSActor, x1, y1, x2, y2)) { + Handle(SALOME_InteractiveObject) aIO = aSActor->getIO(); + if (aIO.IsNull()) + continue; + if (aSelActiveCompOnly && + strcmp(aActiveComponent->ComponentDataType(), aIO->getComponentDataType()) != 0) { + continue; + } + if (aListIO.IsEmpty()) { + aListIO.Append( aIO ); + } else { + SALOME_ListIteratorOfListIO It(aListIO); + bool isStored = false; + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IOS = It.Value(); + if( aIO->isSame(IOS) ) { + aIO = IOS; //Added by SRN, fix SAL1307 + isStored = true; + break; + } + } + if (!isStored) + aListIO.Append( aIO ); + } + } + } + } + } + if (!aListIO.IsEmpty()) { + SALOME_ListIteratorOfListIO It(aListIO); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) IOS = It.Value(); + this->PropPicked++; + aSel->AddIObject( IOS, false ); + } + } + } // end case 4 + } //end switch + rwi->EndPickCallback(); + } + aActiveStudy->update3dViewers(); + } + } + break; + case VTK_INTERACTOR_STYLE_CAMERA_ZOOM: + case VTK_INTERACTOR_STYLE_CAMERA_PAN: + case VTK_INTERACTOR_STYLE_CAMERA_ROTATE: + case VTK_INTERACTOR_STYLE_CAMERA_SPIN: + break; + case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN: + { + int w, h, x, y; + rwi->GetSize(w, h); + x = myPoint.x(); + y = h - myPoint.y() - 1; + Place(x, y); + } + break; + } +} + +// called during viewer operation when user moves mouse (!put necessary processing here!) +void VTKViewer_InteractorStyleSALOME::onOperation(QPoint mousePos) +{ + int w, h; + GetInteractor()->GetSize(w, h); + VTKViewer_RenderWindow* wnd = dynamic_cast< VTKViewer_RenderWindow*>(GetInteractor()->GetRenderWindow()); + switch (State) { + case VTK_INTERACTOR_STYLE_CAMERA_PAN: + { + // processing panning + this->FindPokedCamera(mousePos.x(), mousePos.y()); + this->PanXY(mousePos.x(), myPoint.y(), myPoint.x(), mousePos.y()); + myPoint = mousePos; + break; + } + case VTK_INTERACTOR_STYLE_CAMERA_ZOOM: + { + // processing zooming + this->FindPokedCamera(mousePos.x(), mousePos.y()); + this->DollyXY(mousePos.x() - myPoint.x(), mousePos.y() - myPoint.y()); + myPoint = mousePos; + break; + } + case VTK_INTERACTOR_STYLE_CAMERA_ROTATE: + { + // processing rotation + this->FindPokedCamera(mousePos.x(), mousePos.y()); + this->RotateXY(mousePos.x() - myPoint.x(), myPoint.y() - mousePos.y()); + myPoint = mousePos; + break; + } + case VTK_INTERACTOR_STYLE_CAMERA_SPIN: + { + // processing spinning + this->FindPokedCamera(mousePos.x(), mousePos.y()); + this->SpinXY(mousePos.x(), mousePos.y(), myPoint.x(), myPoint.y()); + myPoint = mousePos; + break; + } + case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN: + { + break; + } + case VTK_INTERACTOR_STYLE_CAMERA_SELECT: + { + if (!myCursorState) + setCursor(VTK_INTERACTOR_STYLE_CAMERA_SELECT); + } + case VTK_INTERACTOR_STYLE_CAMERA_FIT: + { + QPainter p(wnd); + p.setPen(Qt::lightGray); + p.setRasterOp(Qt::XorROP); + p.drawRect(QRect(myPoint, myOtherPoint)); + myOtherPoint = mousePos; + p.drawRect(QRect(myPoint, myOtherPoint)); + break; + } + } + this->LastPos[0] = mousePos.x(); + this->LastPos[1] = h - mousePos.y() - 1; +} + +// called when user moves mouse inside viewer window and there is no active viewer operation +// (!put necessary processing here!) +void VTKViewer_InteractorStyleSALOME::onCursorMove(QPoint mousePos) { + // processing highlighting + QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + + vtkRenderWindowInteractor *rwi = this->Interactor; + int w, h, x, y; + rwi->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("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; + + 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 ) { + // 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(); + } + // MESSAGE ( " NAME PREVIEW " << SActor->getName() ); + } + } + } + } + } else { + preview = 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 ); + anActor->SetPreSelected( false ); + } + ac = theActors->GetNextActor(); + } + } + } + this->LastPos[0] = x; + this->LastPos[1] = y; +} + +// called on finsh GlobalPan operation +void VTKViewer_InteractorStyleSALOME::Place(const int theX, const int theY) +{ + if (this->CurrentRenderer == NULL) { + return; + } + + //translate view + int *aSize = this->CurrentRenderer->GetRenderWindow()->GetSize(); + int centerX = aSize[0]/2; + int centerY = aSize[1]/2; + + TranslateView(centerX, centerY, theX, theY); + + // restore zoom scale + vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); + cam->SetParallelScale(myScale); + this->CurrentRenderer->ResetCameraClippingRange(); + + if (this->CurrentLight) { + this->CurrentLight->SetPosition(cam->GetPosition()); + this->CurrentLight->SetFocalPoint(cam->GetFocalPoint()); + } + VTKViewer_RenderWindow* aRW = dynamic_cast(this->Interactor->GetRenderWindow()); + if (aRW) aRW->updateGL(); +} + + + +// Translates view from Point to Point +void VTKViewer_InteractorStyleSALOME::TranslateView(int toX, int toY, int fromX, int fromY) +{ + vtkCamera *cam = this->CurrentRenderer->GetActiveCamera(); + double viewFocus[4], focalDepth, viewPoint[3]; + float newPickPoint[4], oldPickPoint[4], motionVector[3]; + cam->GetFocalPoint(viewFocus); + + this->ComputeWorldToDisplay(viewFocus[0], viewFocus[1], + viewFocus[2], viewFocus); + focalDepth = viewFocus[2]; + + this->ComputeDisplayToWorld(double(toX), double(toY), + focalDepth, newPickPoint); + this->ComputeDisplayToWorld(double(fromX),double(fromY), + focalDepth, oldPickPoint); + + // camera motion is reversed + motionVector[0] = oldPickPoint[0] - newPickPoint[0]; + motionVector[1] = oldPickPoint[1] - newPickPoint[1]; + motionVector[2] = oldPickPoint[2] - newPickPoint[2]; + + cam->GetFocalPoint(viewFocus); + cam->GetPosition(viewPoint); + cam->SetFocalPoint(motionVector[0] + viewFocus[0], + motionVector[1] + viewFocus[1], + motionVector[2] + viewFocus[2]); + cam->SetPosition(motionVector[0] + viewPoint[0], + motionVector[1] + viewPoint[1], + motionVector[2] + viewPoint[2]); +} + + +/// Checks: is the given Actor within display coordinates? +bool VTKViewer_InteractorStyleSALOME::IsInRect(vtkActor* theActor, + const int left, const int top, + const int right, const int bottom) +{ + float* aBounds = theActor->GetBounds(); + float aMin[3], aMax[3]; + ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin); + ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax); + if (aMin[0] > aMax[0]) { + float aBuf = aMin[0]; + aMin[0] = aMax[0]; + aMax[0] = aBuf; + } + if (aMin[1] > aMax[1]) { + float aBuf = aMin[1]; + aMin[1] = aMax[1]; + aMax[1] = aBuf; + } + + return ((aMin[0]>left) && (aMax[0]bottom) && (aMax[1]GetBounds(); + float aMin[3], aMax[3]; + ComputeWorldToDisplay(aBounds[0], aBounds[2], aBounds[4], aMin); + ComputeWorldToDisplay(aBounds[1], aBounds[3], aBounds[5], aMax); + if (aMin[0] > aMax[0]) { + float aBuf = aMin[0]; + aMin[0] = aMax[0]; + aMax[0] = aBuf; + } + if (aMin[1] > aMax[1]) { + float aBuf = aMin[1]; + aMin[1] = aMax[1]; + aMax[1] = aBuf; + } + + return ((aMin[0]>left) && (aMax[0]bottom) && (aMax[1]left) && (aPnt[0]bottom) && (aPnt[1] +#include +#include +#include "SALOME_Actor.h" + + +#define VTK_INTERACTOR_STYLE_CAMERA_NONE 0 +#define VTK_INTERACTOR_STYLE_CAMERA_ROTATE 1 +#define VTK_INTERACTOR_STYLE_CAMERA_PAN 2 +#define VTK_INTERACTOR_STYLE_CAMERA_ZOOM 3 +#define VTK_INTERACTOR_STYLE_CAMERA_SPIN 4 +#define VTK_INTERACTOR_STYLE_CAMERA_FIT 5 +#define VTK_INTERACTOR_STYLE_CAMERA_SELECT 6 +#define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7 + +class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyle +{ + public: + // Description: + // This class must be supplied with a vtkRenderWindowInteractor wrapper or + // parent. This class should not normally be instantiated by application + // programmers. + static VTKViewer_InteractorStyleSALOME *New(); + + void setTriedron( vtkActorCollection* triedron ); + + vtkTypeMacro(VTKViewer_InteractorStyleSALOME, vtkObject); + void PrintSelf(ostream& os, vtkIndent indent); + + // Generic event bindings must be overridden in subclasses + void OnMouseMove (int ctrl, int shift, int x, int y); + void OnLeftButtonDown(int ctrl, int shift, int x, int y); + void OnLeftButtonUp (int ctrl, int shift, int x, int y); + void OnMiddleButtonDown(int ctrl, int shift, int x, int y); + void OnMiddleButtonUp (int ctrl, int shift, int x, int y); + void OnRightButtonDown(int ctrl, int shift, int x, int y); + void OnRightButtonUp (int ctrl, int shift, int x, int y); + + protected: + VTKViewer_InteractorStyleSALOME(); + ~VTKViewer_InteractorStyleSALOME(); + VTKViewer_InteractorStyleSALOME(const VTKViewer_InteractorStyleSALOME&) {}; + void operator=(const VTKViewer_InteractorStyleSALOME&) {}; + + void RotateXY(int dx, int dy); + void PanXY(int x, int y, int oldX, int oldY); + void DollyXY(int dx, int dy); + void SpinXY(int dx, int dy, int oldX, int oldY); + void fitRect(const int left, const int top, const int right, const int bottom); + void Place(const int theX, const int theY); + void TranslateView(int toX, int toY, int fromX, int fromY); + bool IsInRect(vtkActor* theActor, + const int left, const int top, + const int right, const int bottom); + bool IsInRect(vtkCell* theCell, + const int left, const int top, + const int right, const int bottom); + bool IsInRect(float* thePoint, + const int left, const int top, + const int right, const int bottom); + + int State; + float MotionFactor; + float RadianToDegree; // constant: for conv from deg to rad + double myScale; + + SALOME_Actor* preview; + +public: + bool eventFilter(QObject* object, QEvent* event); + void startZoom(); + void startPan(); + void startGlobalPan(); + void startRotate(); + void startFitArea(); + void startSpin(); + bool needsRedrawing(); + +protected: + void loadCursors(); + void startOperation(int operation); + void onStartOperation(); + void onFinishOperation(); + void onOperation(QPoint mousePos); + void onCursorMove(QPoint mousePos); + void setCursor(const int operation); + +protected: + QCursor myDefCursor; + QCursor myPanCursor; + QCursor myZoomCursor; + QCursor myRotateCursor; + QCursor mySpinCursor; + QCursor myHandCursor; + QCursor myGlobalPanCursor; + QPoint myPoint; + QPoint myOtherPoint; + bool myCursorState; + bool myShiftState; + int ForcedState; + vtkActorCollection* m_Triedron; +}; + +#endif diff --git a/src/VTKViewer/VTKViewer_RenderWindow.cxx b/src/VTKViewer/VTKViewer_RenderWindow.cxx new file mode 100644 index 000000000..08c162b30 --- /dev/null +++ b/src/VTKViewer/VTKViewer_RenderWindow.cxx @@ -0,0 +1,835 @@ +using namespace std; +// File : VTKViewer_RenderWindow.cxx +// Created : Wed Mar 20 11:34:28 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : VTKViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "VTKViewer_RenderWindow.h" +#include "utilities.h" +#include "QAD_Settings.h" +#include "QAD_Config.h" +#include "QAD_Desktop.h" +#include "QAD_Study.h" +#include "QAD_Tools.h" +#include "SALOME_Selection.h" + +#include + +#include +#include +#include + +#include + +#include +#include +#include + +#if QT_VERSION > 300 +#include +#endif + +VTKViewer_RenderWindow::VTKViewer_RenderWindow(QWidget *parent, const char *name) : + QGLWidget(parent, name) +{ + mInitialized = false ; + //NRI - 22/02/2002 setFocusPolicy(QWidget::StrongFocus) ; + //NRI - comment rev 1.6 - setFocus(); +} + +VTKViewer_RenderWindow::~VTKViewer_RenderWindow() { + this->ReferenceCount-- ; +} + +void VTKViewer_RenderWindow::PrintSelf(ostream& os, vtkIndent indent) { + this->vtkRenderWindow::PrintSelf(os, indent); + + QGLFormat myFormat = this->format() ; + os << indent << "qGLVersion: " << qGLVersion() << endl ; + os << indent << "doubleBuffer: " << myFormat.doubleBuffer() << endl ; + os << indent << "depth: " << myFormat.depth() << endl ; + os << indent << "rgba: " << myFormat.rgba() << endl ; + os << indent << "alpha: " << myFormat.alpha() << endl ; + os << indent << "accum: " << myFormat.accum() << endl ; + os << indent << "stencil: " << myFormat.stencil() << endl ; + os << indent << "stereo: " << myFormat.stereo() << endl ; + os << indent << "directRendering: " << myFormat.directRendering() << endl ; +} + +void VTKViewer_RenderWindow::Start(void) { + // + // Initialize the QGLWidget part of the widget if it has not + // been initialized so far. + // + if( ! this->mInitialized ) { + this->WindowInitialize() ; + } + this->MakeCurrent() ; +} + +// End the rendering process and display the image. +void VTKViewer_RenderWindow::Frame(void) { + glFlush() ; + if( (! this->AbortRender) && // the render is not being aborted + (! autoBufferSwap() ) && // buffers are not switched automatically + doubleBuffer() && // double buffering is enabled on QGLWidget side + this->vtkRenderWindow::DoubleBuffer && // double buffering is enabled on VTK side + this->SwapBuffers ) { // VTK wants us to swap buffers + QGLWidget::swapBuffers() ; + } +} +void* VTKViewer_RenderWindow::GetGenericDisplayId() { + return ((void*)x11Display()); +} + +void* VTKViewer_RenderWindow::GetGenericWindowId() { + return ((void*)winId()); +} + +void* VTKViewer_RenderWindow::GetGenericContext() { + return ((void*)(this->context())->currentContext()); +} + +// Initialize the window for rendering. +void VTKViewer_RenderWindow::WindowInitialize(void) { + if( ! this->mInitialized ) { + this->initializeGL() ; + this->MakeCurrent() ; + + vtkDebugMacro(<< " glMatrixMode ModelView\n"); + glMatrixMode( GL_MODELVIEW ); + + vtkDebugMacro(<< " zbuffer enabled\n"); + glDepthFunc( GL_LEQUAL ); + glEnable( GL_DEPTH_TEST ); + + vtkDebugMacro(" texture stuff\n"); + glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); + + // initialize blending for transparency + vtkDebugMacro(<< " blend func stuff\n"); + glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + glEnable(GL_BLEND); + + if (this->PointSmoothing) + { + glEnable(GL_POINT_SMOOTH); + } + else + { + glDisable(GL_POINT_SMOOTH); + } + + if (this->LineSmoothing) + { + glEnable(GL_LINE_SMOOTH); + } + else + { + glDisable(GL_LINE_SMOOTH); + } + + if (this->PolygonSmoothing) + { + glEnable(GL_POLYGON_SMOOTH); + } + else + { + glDisable(GL_POLYGON_SMOOTH); + } + + glEnable( GL_NORMALIZE ); + glAlphaFunc(GL_GREATER,0); + + this->Mapped = 1; + + } +} + +void VTKViewer_RenderWindow::SetFullScreen(int arg) { + // + // We do not need to do anything if the FullScreen mode + // is already set to the specified value. + // + if( this->FullScreen == arg ) return ; + + // + // :TODO: Fri Apr 21 16:41:06 2000 Pagey + // This is not implemented in QGLWidget yet. Hence, we + // will ignore it. + // + vtkDebugMacro(<< " QGLWidget::SetFullScreen() not supported by QGLWidget yet.\n") ; +} + +void VTKViewer_RenderWindow::WindowRemap(void) { + // + // :TODO: Fri Apr 21 16:44:35 2000 Pagey + // I am not sure why we would ever need to do this under Qt. + // Hence, I have not done anything here yet. + // + vtkDebugMacro(<< " QGLWidget::WindowRemap() not supported by QGLWidget yet.\n") ; +} + +void VTKViewer_RenderWindow::PrefFullScreen(void) { + // + // :TODO: Fri Apr 21 16:46:30 2000 Pagey + // Since, SetFullScreen() is not supported yet, this is useless. + // + vtkDebugMacro(<< " QGLWidget::PrefFullScreen() not supported by QGLWidget yet.\n") ; +} + +void VTKViewer_RenderWindow::SetSize(int w, int h) { + if ((this->Size[0] != w)||(this->Size[1] != h)) { + this->Modified(); + this->Size[0] = w; + this->Size[1] = h; + } + + if( this->Interactor ) { + this->Interactor->SetSize(w, h) ; + } + + // if we arent mappen then just set the ivars + if (!this->Mapped) { + return; + } + + glViewport( 0, 0, (GLint)w, (GLint)h ) ; +} + +void VTKViewer_RenderWindow::StereoUpdate() { + // + // :NOTE: Fri Apr 21 16:55:32 2000 Pagey + // This routine is taken directly from vtkOpenGLRenderWindow.cxx. + // I am not sure what it does. Hope it works. + // + if (this->StereoRender && (!this->StereoStatus)) + { + switch (this->StereoType) + { + case VTK_STEREO_CRYSTAL_EYES: + { + } + break; + case VTK_STEREO_RED_BLUE: + { + this->StereoStatus = 1; + } + } + } + else if ((!this->StereoRender) && this->StereoStatus) + { + switch (this->StereoType) + { + case VTK_STEREO_CRYSTAL_EYES: + { + this->StereoStatus = 0; + } + break; + case VTK_STEREO_RED_BLUE: + { + this->StereoStatus = 0; + } + } + } +} + +unsigned char *VTKViewer_RenderWindow::GetPixelData(int x1, int y1, int x2, int y2, int front) { + // + // :NOTE: Fri Apr 21 16:58:53 2000 Pagey + // This routine is taken directly from vtkOpenGLRenderWindow.cxx. + // I am not sure what it does. Hope it works. + // + int y_low, y_hi; + int x_low, x_hi; + unsigned char *data = NULL; + + // set the current window + this->MakeCurrent(); + + if (y1 < y2) + { + y_low = y1; + y_hi = y2; + } + else + { + y_low = y2; + y_hi = y1; + } + + if (x1 < x2) + { + x_low = x1; + x_hi = x2; + } + else + { + x_low = x2; + x_hi = x1; + } + + if (front) + { + glReadBuffer(GL_FRONT); + } + else + { + glReadBuffer(GL_BACK); + } + + data = new unsigned char[(x_hi - x_low + 1)*(y_hi - y_low + 1)*3]; + +#ifdef sparc + // We need to read the image data one row at a time and convert it + // from RGBA to RGB to get around a bug in Sun OpenGL 1.1 + long xloop, yloop; + unsigned char *buffer; + unsigned char *p_data = NULL; + + buffer = new unsigned char [4*(x_hi - x_low + 1)]; + p_data = data; + for (yloop = y_low; yloop <= y_hi; yloop++) + { + // read in a row of pixels + glReadPixels(x_low,yloop,(x_hi-x_low+1),1, + GL_RGBA, GL_UNSIGNED_BYTE, buffer); + for (xloop = 0; xloop <= x_hi-x_low; xloop++) + { + *p_data = buffer[xloop*4]; p_data++; + *p_data = buffer[xloop*4+1]; p_data++; + *p_data = buffer[xloop*4+2]; p_data++; + } + } + + delete [] buffer; +#else + // If the Sun bug is ever fixed, then we could use the following + // technique which provides a vast speed improvement on the SGI + + // Calling pack alignment ensures that we can grab the any size window + glPixelStorei( GL_PACK_ALIGNMENT, 1 ); + glReadPixels(x_low, y_low, x_hi-x_low+1, y_hi-y_low+1, GL_RGB, + GL_UNSIGNED_BYTE, data); +#endif + + return data; +} + +void VTKViewer_RenderWindow::SetPixelData(int x1, int y1, int x2, int y2, + unsigned char *data, int front) { + + // + // :NOTE: Fri Apr 21 17:00:16 2000 Pagey + // This routine is taken directly from vtkOpenGLRenderWindow.cxx. + // I am not sure what it does. Hope it works. + // + int y_low, y_hi; + int x_low, x_hi; + + // set the current window + this->MakeCurrent(); + + if (front) + { + glDrawBuffer(GL_FRONT); + } + else + { + glDrawBuffer(GL_BACK); + } + + if (y1 < y2) + { + + y_low = y1; + y_hi = y2; + } + else + { + y_low = y2; + y_hi = y1; + } + + if (x1 < x2) + { + x_low = x1; + x_hi = x2; + } + else + { + x_low = x2; + x_hi = x1; + } + +#ifdef sparc + // We need to read the image data one row at a time and convert it + // from RGBA to RGB to get around a bug in Sun OpenGL 1.1 + long xloop, yloop; + unsigned char *buffer; + unsigned char *p_data = NULL; + + buffer = new unsigned char [4*(x_hi - x_low + 1)]; + + // now write the binary info one row at a time + glDisable(GL_BLEND); + p_data = data; + for (yloop = y_low; yloop <= y_hi; yloop++) + { + for (xloop = 0; xloop <= x_hi - x_low; xloop++) + { + buffer[xloop*4] = *p_data; p_data++; + buffer[xloop*4+1] = *p_data; p_data++; + buffer[xloop*4+2] = *p_data; p_data++; + buffer[xloop*4+3] = 0xff; + } + /* write out a row of pixels */ + glMatrixMode( GL_MODELVIEW ); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode( GL_PROJECTION ); + glPushMatrix(); + glLoadIdentity(); + glRasterPos3f( (2.0 * (GLfloat)(x_low) / this->Size[0] - 1), + (2.0 * (GLfloat)(yloop) / this->Size[1] - 1), + -1.0 ); + glMatrixMode( GL_PROJECTION ); + glPopMatrix(); + glMatrixMode( GL_MODELVIEW ); + glPopMatrix(); + + glDrawPixels((x_hi-x_low+1),1, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + } + glEnable(GL_BLEND); +#else + // If the Sun bug is ever fixed, then we could use the following + // technique which provides a vast speed improvement on the SGI + + // now write the binary info + glMatrixMode( GL_MODELVIEW ); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode( GL_PROJECTION ); + glPushMatrix(); + glLoadIdentity(); + glRasterPos3f( (2.0 * (GLfloat)(x_low) / this->Size[0] - 1), + (2.0 * (GLfloat)(y_low) / this->Size[1] - 1), + -1.0 ); + glMatrixMode( GL_PROJECTION ); + glPopMatrix(); + glMatrixMode( GL_MODELVIEW ); + glPopMatrix(); + + glPixelStorei( GL_UNPACK_ALIGNMENT, 1); + glDisable(GL_BLEND); + glDrawPixels((x_hi-x_low+1), (y_hi - y_low + 1), + GL_RGB, GL_UNSIGNED_BYTE, data); + glEnable(GL_BLEND); +#endif +} + +float *VTKViewer_RenderWindow::GetRGBAPixelData(int x1, int y1, int x2, int y2, int front) +{ + // + // :NOTE: Fri Apr 21 17:00:16 2000 Pagey + // This routine is taken directly from VTKViewer_RenderWindow.cxx. + // I am not sure what it does. Hope it works. + // + int y_low, y_hi; + int x_low, x_hi; + int width, height; + float *data = NULL; + + // set the current window + this->MakeCurrent(); + + if (y1 < y2) + { + y_low = y1; + y_hi = y2; + } + else + { + y_low = y2; + y_hi = y1; + } + + if (x1 < x2) + { + x_low = x1; + x_hi = x2; + } + else + { + x_low = x2; + x_hi = x1; + } + + if (front) + { + glReadBuffer(GL_FRONT); + } + else + { + glReadBuffer(GL_BACK); + } + + width = abs(x_hi - x_low) + 1; + height = abs(y_hi - y_low) + 1; + + data = new float[ (width*height*4) ]; + + glReadPixels( x_low, y_low, width, height, GL_RGBA, GL_FLOAT, data); + + return data; +} + +void VTKViewer_RenderWindow::SetRGBAPixelData(int x1, int y1, int x2, int y2, + float *data, int front, int blend) +{ + // + // :NOTE: Fri Apr 21 17:00:16 2000 Pagey + // This routine is taken directly from VTKViewer_RenderWindow.cxx. + // I am not sure what it does. Hope it works. + // + int y_low, y_hi; + int x_low, x_hi; + int width, height; + + // set the current window + this->MakeCurrent(); + + if (front) + { + glDrawBuffer(GL_FRONT); + } + else + { + glDrawBuffer(GL_BACK); + } + + if (y1 < y2) + { + y_low = y1; + y_hi = y2; + } + else + { + y_low = y2; + y_hi = y1; + } + + if (x1 < x2) + { + x_low = x1; + x_hi = x2; + } + else + { + x_low = x2; + x_hi = x1; + } + + width = abs(x_hi-x_low) + 1; + height = abs(y_hi-y_low) + 1; + + /* write out a row of pixels */ + glMatrixMode( GL_MODELVIEW ); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode( GL_PROJECTION ); + glPushMatrix(); + glLoadIdentity(); + glRasterPos3f( (2.0 * (GLfloat)(x_low) / this->Size[0] - 1), + (2.0 * (GLfloat)(y_low) / this->Size[1] - 1), + -1.0 ); + glMatrixMode( GL_PROJECTION ); + glPopMatrix(); + glMatrixMode( GL_MODELVIEW ); + glPopMatrix(); + + if (!blend) + { + glDisable(GL_BLEND); + glDrawPixels( width, height, GL_RGBA, GL_FLOAT, data); + glEnable(GL_BLEND); + } + else + { + glDrawPixels( width, height, GL_RGBA, GL_FLOAT, data); + } +} + +float *VTKViewer_RenderWindow::GetZbufferData( int x1, int y1, int x2, int y2 ) +{ + int y_low, y_hi; + int x_low, x_hi; + int width, height; + float *z_data = NULL; + + // set the current window + this->MakeCurrent(); + + if (y1 < y2) + { + y_low = y1; + y_hi = y2; + } + else + { + y_low = y2; + y_hi = y1; + } + + if (x1 < x2) + { + x_low = x1; + x_hi = x2; + } + else + { + x_low = x2; + x_hi = x1; + } + + width = abs(x2 - x1)+1; + height = abs(y2 - y1)+1; + + z_data = new float[width*height]; + + glReadPixels( x_low, y_low, + width, height, + GL_DEPTH_COMPONENT, GL_FLOAT, + z_data ); + + return z_data; +} + +void VTKViewer_RenderWindow::SetZbufferData( int x1, int y1, int x2, int y2, + float *buffer ) +{ + int y_low, y_hi; + int x_low, x_hi; + int width, height; + + // set the current window + this->MakeCurrent(); + + if (y1 < y2) + { + y_low = y1; + y_hi = y2; + } + else + { + y_low = y2; + y_hi = y1; + } + + if (x1 < x2) + { + x_low = x1; + x_hi = x2; + } + else + { + x_low = x2; + x_hi = x1; + } + + width = abs(x2 - x1)+1; + height = abs(y2 - y1)+1; + + glMatrixMode( GL_MODELVIEW ); + glPushMatrix(); + glLoadIdentity(); + glMatrixMode( GL_PROJECTION ); + glPushMatrix(); + glLoadIdentity(); + glRasterPos2f( 2.0 * (GLfloat)(x_low) / this->Size[0] - 1, + 2.0 * (GLfloat)(y_low) / this->Size[1] - 1); + glMatrixMode( GL_PROJECTION ); + glPopMatrix(); + glMatrixMode( GL_MODELVIEW ); + glPopMatrix(); + + glDrawPixels( width, height, GL_DEPTH_COMPONENT, GL_FLOAT, buffer); + +} + +void VTKViewer_RenderWindow::MakeCurrent() { + if( this->mInitialized ) { + //const QGLContext* current = this->context()->currentContext(); + //if(!current) + this->makeCurrent(); + } +} + +void VTKViewer_RenderWindow::initializeGL() { + if ( ! this->mInitialized ) { + // + // Construct a format which is similar to the + // format set by vtkOpenGLRenderWindow.cxx + // + QGLFormat myFormat ; + if( this->vtkRenderWindow::DoubleBuffer ) { + myFormat.setDoubleBuffer(true) ; + } else { + myFormat.setDoubleBuffer(false) ; + } + if( this->StereoCapableWindow ) { + myFormat.setStereo(true) ; + } else { + myFormat.setStereo(false) ; + } + myFormat.setRgba(true) ; + myFormat.setDepth(true) ; + myFormat.setDirectRendering(true) ; + + setFormat(myFormat) ; + + glClearColor(0.0, 0.0, 0.0, 0.0) ; + this->mInitialized = true ; + + setMouseTracking(true); + } +} + +void VTKViewer_RenderWindow::paintGL() { + Render() ; +} + +void VTKViewer_RenderWindow::resizeGL(int w, int h) { + SetSize(w, h) ; +} + +void VTKViewer_RenderWindow::setContext( QGLContext *context, + const QGLContext *shareContext, + bool deleteOldContex ) { + mInitialized = false ; + QGLWidget::setContext(context, shareContext, deleteOldContex) ; +} + +void VTKViewer_RenderWindow::mouseMoveEvent( QMouseEvent *event ) { + emit MouseMove(event) ; +} + +void VTKViewer_RenderWindow::mousePressEvent( QMouseEvent *event ) { + //NRI - comment rev 1.6 - setFocus() ; + // + // Emit a ButtonPressed signal for all mouse presses. + // + emit ButtonPressed(event) ; + // + // Emit a signal for the button which was pressed. + // + switch(event->button()) { + case LeftButton: + emit LeftButtonPressed(event) ; + break ; + case MidButton: + emit MiddleButtonPressed(event) ; + break ; + case RightButton: + if ( event->state() == Qt::ControlButton ) { + emit RightButtonPressed(event) ; + } else { + QPopupMenu* popup = createPopup(); + if ( popup ) { + QAD_Tools::checkPopup( popup ); + if ( popup->count()>0 ) { + popup->exec( QCursor::pos() ); + } + destroyPopup(); + } + } + break; + default: + break ; + } + return ; +} + + +void VTKViewer_RenderWindow::mouseReleaseEvent( QMouseEvent *event ) { + // + // Emit a ButtonPressed signal for all mouse releases. + // + emit ButtonReleased(event) ; + // + // Emit a signal for the the mouse button which was + // released. + // + switch(event->button()) { + case LeftButton: + emit LeftButtonReleased(event) ; + break ; + case MidButton: + emit MiddleButtonReleased(event) ; + break ; + case RightButton: + emit RightButtonReleased(event) ; + break; + default: + break ; + } + return ; +} + +void VTKViewer_RenderWindow::keyPressEvent (QKeyEvent * event) { + // + // Let the interactor handle this. + // + emit KeyPressed(event) ; +} + +/*! + Creates the popup +*/ +void VTKViewer_RenderWindow::onCreatePopup() +{ + if ( myPopup ) { + QAD_Desktop* Desktop = (QAD_Desktop*) QAD_Application::getDesktop(); + QAD_Study* myActiveStudy = Desktop->getActiveStudy(); + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + + QString theContext; + QString theParent("Viewer"); + QString theObject; + + Desktop->definePopup( theContext, theParent, theObject ); + Desktop->createPopup( myPopup, theContext, theParent, theObject); + Desktop->customPopup( myPopup, theContext, theParent, theObject ); + +// if (Sel->IObjectCount() == 0 && myPopup->count()<1) { + if ( myPopup->count() > 0 ) + myIDs.append ( myPopup->insertSeparator() ); + int id; + myIDs.append ( id = myPopup->insertItem (tr ("MEN_VP3D_CHANGEBGR")) ); + QAD_ASSERT ( myPopup->connectItem ( id, this, SLOT(onChangeBackgroundColor())) ); +// } + } +} + + +void VTKViewer_RenderWindow::onChangeBackgroundColor() +{ + float red, green, blue; + float backint[3]; + + vtkRendererCollection * theRenderers = GetRenderers(); + theRenderers->InitTraversal(); + vtkRenderer * theRenderer = theRenderers->GetNextItem(); + theRenderer->GetBackground(backint); + + QColor selColor = QColorDialog::getColor ( QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255)), NULL ); + if ( selColor.isValid() ) { + theRenderer->SetBackground( selColor.red()/255., selColor.green()/255., selColor.blue()/255. ); + QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorRed", selColor.red() ); + QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorGreen", selColor.green() ); + QAD_CONFIG->addSetting( "VTKViewer:BackgroundColorBlue", selColor.blue() ); + } +} diff --git a/src/VTKViewer/VTKViewer_RenderWindow.h b/src/VTKViewer/VTKViewer_RenderWindow.h new file mode 100644 index 000000000..53f159368 --- /dev/null +++ b/src/VTKViewer/VTKViewer_RenderWindow.h @@ -0,0 +1,158 @@ +// File : VTKViewer_RenderWindow.h +// Created : Wed Mar 20 11:33:30 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : VTKViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef VTKViewer_RenderWindow_h +#define VTKViewer_RenderWindow_h + +#include +#include +#include + +#include "QAD_Popup.h" + +// ------------------------------------------------------------ +// :TRICKY: Fri Apr 21 22:19:27 2000 Pagey +// The Signal/Slot mechanism used by Qt requires that QGLWidget +// appear as the first class when using multiple inheritance. +// Hence the order of the two classes QGLWidget and vtkRenderWindow +// matters here. Be careful not to change it by accident. +// ------------------------------------------------------------ +class VTK_EXPORT VTKViewer_RenderWindow : +public QGLWidget, virtual public vtkRenderWindow, + public QAD_PopupClientServer +{ + Q_OBJECT + public: + /* popup management */ + void onCreatePopup(); + + /* ------------------------------------------------------------ + * Methods from vtkRenderWindow class. + */ + static VTKViewer_RenderWindow *New(QWidget *parent=0, const char *name=0) { + return new VTKViewer_RenderWindow(parent,name) ; + }; + const char *GetClassName() {return "VTKViewer_RenderWindow";}; + void PrintSelf(ostream& os, vtkIndent indent); + + virtual void Start(void); + virtual void Frame(void); + void WindowInitialize(void); + virtual void SetFullScreen(int); + virtual void WindowRemap(void); + void PrefFullScreen(void); + void SetSize(int,int); + + virtual void *GetGenericDisplayId(); + virtual void *GetGenericWindowId(); + virtual void *GetGenericContext(); + + // stereo rendering stuff + virtual void StereoUpdate(); + + // Description: + // Set/Get the pixel data of an image, transmitted as RGBRGB... + virtual unsigned char *GetPixelData(int x,int y,int x2,int y2,int front); + virtual void SetPixelData(int x,int y,int x2,int y2,unsigned char *,int front); + + // Description: + // Set/Get the pixel data of an image, transmitted as RGBARGBA... + virtual float *GetRGBAPixelData(int x,int y,int x2,int y2,int front); + virtual void SetRGBAPixelData(int x,int y,int x2,int y2,float *,int front, + int blend=0); + + // Description: + // Set/Get the zbuffer data from an image + virtual float *GetZbufferData( int x1, int y1, int x2, int y2 ); + virtual void SetZbufferData( int x1, int y1, int x2, int y2, float *buffer ); + virtual void MakeCurrent(); + + /* ------------------------------------------------------------ + * Methods from QGLWidget class. + */ + virtual void setContext( QGLContext *context, + const QGLContext *shareContext=0, + bool deleteOldContex=TRUE ) ; + + protected slots: + void onChangeBackgroundColor(); + + //NRIprotected: + public: + bool mInitialized ; + VTKViewer_RenderWindow(QWidget *parent, const char *name); + ~VTKViewer_RenderWindow() ; + VTKViewer_RenderWindow(const VTKViewer_RenderWindow&) { } + void operator=(const VTKViewer_RenderWindow&) { } + + /* ------------------------------------------------------------ + * Methods from QGLWidget class. + */ + virtual void initializeGL() ; + virtual void paintGL() ; + virtual void resizeGL(int w, int h) ; + virtual void mouseMoveEvent( QMouseEvent * ) ; + virtual void mousePressEvent( QMouseEvent * ) ; + virtual void mouseReleaseEvent( QMouseEvent * ) ; + virtual void keyPressEvent( QKeyEvent * ) ; + // + // Every focus-in and focus-out event results in a repaint + // through the default implementations of focusInEvent and + // focusOutEvent. This results in a flicker in the vtkQGLRenderWindow + // ever time the cursor moves in or out of the widget. We can + // disble this by calling repaint(FALSE) in the implementation + // of these methods. + // +/* virtual void focusInEvent( QFocusEvent * ) { repaint(FALSE) ; } */ +/* virtual void focusOutEvent( QFocusEvent * ) { repaint(FALSE) ; } */ + // + // If this widget is not the top level widget, it does not + // get focus until it receives its first mouse click. By + // overloading the enterEvent and leaveEvent methods, we + // give keyboard focus to the widget when the mouse enters + // and remove the focus once the mouse leaves. + // + /* virtual void enterEvent( QEvent * ) { setFocus() ; } */ +/* virtual void leaveEvent( QEvent * ) { clearFocus() ; } */ + + /* ------------------------------------------------------------ + * A few signals which will help us write an interactor for this + * render window. + */ + signals: + // + // Mouse moved. + // + void MouseMove(const QMouseEvent *event) ; + // + // Left button pressed/released at the specified location. + // + void LeftButtonPressed(const QMouseEvent *event) ; + void LeftButtonReleased(const QMouseEvent *event) ; + // + // Middle button pressed/released at the specified location. + // + void MiddleButtonPressed(const QMouseEvent *event) ; + void MiddleButtonReleased(const QMouseEvent *event) ; + // + // Right button pressed/released at the specified location. + // + void RightButtonPressed(const QMouseEvent *event) ; + void RightButtonReleased(const QMouseEvent *event) ; + // + // Any mouse button pressed. + // + void ButtonPressed(const QMouseEvent *event) ; + void ButtonReleased(const QMouseEvent *event) ; + // + // Any key pressed. + // + void KeyPressed(QKeyEvent *event) ; +}; + +#endif diff --git a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx new file mode 100644 index 000000000..adb35fa05 --- /dev/null +++ b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx @@ -0,0 +1,1185 @@ +using namespace std; +// File : VTKViewer_RenderWindowInteractor.cxx +// Created : Wed Mar 20 11:32:45 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : VTKViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "VTKViewer_RenderWindowInteractor.h" +#include "VTKViewer_RenderWindow.h" +#include "VTKViewer_InteractorStyleSALOME.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" + +#include "SALOME_Selection.h" +#include "SALOME_Actor.h" + +#include +#include +#include +#include + +// VTK Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// QT Includes +#include + +VTKViewer_RenderWindowInteractor* VTKViewer_RenderWindowInteractor::New() { + vtkObject *ret = vtkObjectFactory::CreateInstance("VTKViewer_RenderWindowInteractor") ; + if( ret ) { + return dynamic_cast(ret) ; + } + return new VTKViewer_RenderWindowInteractor; +} + +VTKViewer_RenderWindowInteractor::VTKViewer_RenderWindowInteractor() { + this->Enabled = 0 ; + this->mTimer = new QTimer( this ) ; + this->displaymode = 0; + + vtkPicker* thepicker = vtkPicker::New(); + thepicker->SetTolerance(0); + this->SetPicker(thepicker); + + connect(mTimer, SIGNAL(timeout()), this, SLOT(TimerFunc())) ; +} + + +VTKViewer_RenderWindowInteractor::~VTKViewer_RenderWindowInteractor() { + delete mTimer ; +} + +void VTKViewer_RenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent) { + vtkRenderWindowInteractor::PrintSelf(os, indent) ; + // + // :NOTE: Fri Apr 21 21:51:05 2000 Pagey + // QGL specific stuff goes here. One should add output + // lines here if any protected members are added to + // the class. + // +} + +// +// We never allow the VTKViewer_RenderWindowInteractor to control +// the event loop. The application always has the control. +// +void VTKViewer_RenderWindowInteractor::Initialize() { + // + // We cannot do much unless there is a render window + // associated with this interactor. + // + if( ! RenderWindow ) { + vtkErrorMacro(<< "VTKViewer_RenderWindowInteractor::Initialize(): No render window attached!") ; + return ; + } + + // + // We cannot hand a render window which is not a VTKViewer_RenderWindow. + // One way to force this is to use dynamic_cast and hope that + // it works. If the dynamic_cast does not work, we flag an error + // and get the hell out. + // + VTKViewer_RenderWindow *my_render_win = dynamic_cast(RenderWindow) ; + if( ! my_render_win ) { + vtkErrorMacro(<< "VTKViewer_RenderWindowInteractor::Initialize() can only handle VTKViewer_RenderWindow.") ; + return ; + } + + // + // If the render window has zero size, then set it to a default + // value of 300x300. + // + int *size = my_render_win->GetSize() ; + size[0] = ((size[0] > 0) ? size[0] : 300); + size[1] = ((size[1] > 0) ? size[1] : 300); + + // + // Enable the interactor. + // + this->Enable() ; + + // + // Start the rendering of the window. + // + my_render_win->Start() ; + + // + // Set our size to that of the render window. + // + this->Size[0] = size[0] ; + this->Size[1] = size[1] ; + + // + // The interactor has been initialized. + // + this->Initialized = 1 ; + + VTKViewer_InteractorStyleSALOME* style = VTKViewer_InteractorStyleSALOME::New(); + this->SetInteractorStyle(style); + + Cell_Actor = vtkActor::New(); + Cell_Actor->PickableOff(); + Cell_Actor->GetProperty()->SetColor(1,1,0); + Cell_Actor->GetProperty()->SetRepresentationToSurface(); + + Edge_Actor = vtkActor::New(); + Edge_Actor->PickableOff(); + Edge_Actor->GetProperty()->SetColor(1,0,0); + Edge_Actor->GetProperty()->SetRepresentationToSurface(); + Edge_Actor->GetProperty()->SetLineWidth(20); + + Point_Actor = vtkActor::New(); + Point_Actor->PickableOff(); + Point_Actor->GetProperty()->SetColor(1,1,0); + Point_Actor->GetProperty()->SetRepresentationToSurface(); + Point_Actor->GetProperty()->SetPointSize(3); + + return ; +} + +void VTKViewer_RenderWindowInteractor::SetSelectionMode(int mode) +{ + Cell_Actor->VisibilityOff(); + Edge_Actor->VisibilityOff(); + Point_Actor->VisibilityOff(); + + selectionmode = mode; + if ( mode == 1 ) { + vtkPointPicker* thepicker = vtkPointPicker::New(); + // thepicker->SetTolerance(0.001); + this->SetPicker(thepicker); + } else if ( mode == 2 ) { + vtkCellPicker* thepicker = vtkCellPicker::New(); + thepicker->SetTolerance(0.001); + this->SetPicker(thepicker); + } else if ( mode == 3 ) { + vtkCellPicker* thepicker = vtkCellPicker::New(); + thepicker->SetTolerance(0.001); + this->SetPicker(thepicker); + } else if ( mode == 4 ) { + vtkPicker* thepicker = vtkPicker::New(); + thepicker->SetTolerance(0.001); + this->SetPicker(thepicker); + } +} + + +void VTKViewer_RenderWindowInteractor::Enable() { + // + // Do not need to do anything if already enabled. + // + if( this->Enabled ) { + return ; + } + + // + // Attach slots to every useful signal of the render window. + // + this->ConnectSlots() ; + + this->Enabled = 1 ; + this->Modified() ; +} + +void VTKViewer_RenderWindowInteractor::Disable() { + if( ! this->Enabled ) { + return ; + } + + this->DisconnectSlots() ; + this->Enabled = 0 ; + this->Modified() ; +} + +// ================================== +void VTKViewer_RenderWindowInteractor::Start() { + // + // We do not allow this interactor to control the + // event loop. Only the QtApplication objects are + // allowed to do that. + // + vtkErrorMacro(<<"VTKViewer_RenderWindowInteractor::Start() not allowed to start event loop.") ; + return ; +} + +void VTKViewer_RenderWindowInteractor::UpdateSize(int w, int h) { + // if the size changed send this on to the RenderWindow + if ((w != this->Size[0])||(h != this->Size[1])) { + this->Size[0] = w; + this->Size[1] = h; + this->RenderWindow->SetSize(w,h); + } +} + +int VTKViewer_RenderWindowInteractor::CreateTimer(int vtkNotUsed(timertype)) { + // + // Start a one-shot timer for 10ms. + // + mTimer->start(10, TRUE) ; + return 1 ; +} + +int VTKViewer_RenderWindowInteractor::DestroyTimer(void) { + // + // :TRICKY: Tue May 2 00:17:32 2000 Pagey + // + // QTimer will automatically expire after 10ms. So + // we do not need to do anything here. In fact, we + // should not even Stop() the QTimer here because doing + // this will skip some of the processing that the TimerFunc() + // does and will result in undesirable effects. For + // example, this will result in vtkLODActor to leave + // the models in low-res mode after the mouse stops + // moving. + // + return 1 ; +} + +void VTKViewer_RenderWindowInteractor::TimerFunc() { + if( ! this->Enabled ) { + return ; + } + + this->InteractorStyle->OnTimer() ; + emit RenderWindowModified() ; +} + +void VTKViewer_RenderWindowInteractor::ConnectSlots() { + ProcessSlotConnections(true) ; +} + +void VTKViewer_RenderWindowInteractor::DisconnectSlots() { + ProcessSlotConnections(false) ; +} + +void VTKViewer_RenderWindowInteractor::ProcessSlotConnections(bool conn) { + // + // We cannot do much unless there is a render window + // associated with this interactor. + // + if( ! RenderWindow ) { + vtkErrorMacro(<< "VTKViewer_RenderWindowInteractor::Initialize(): No render window attached!") ; + return ; + } + + + bool (*slot_func) ( const QObject * sender, + const char * signal, + const QObject * receiver, + const char * member ) ; + if( conn ) { + slot_func = &QObject::connect ; + } else { + slot_func = &QObject::disconnect ; + } + // + // We cannot hand a render window which is not a VTKViewer_RenderWindow. + // One way to force this is to use dynamic_cast and hope that + // it works. If the dynamic_cast does not work, we flag an error + // and get the hell out. + // + VTKViewer_RenderWindow *my_render_win = dynamic_cast(RenderWindow) ; + if( ! my_render_win ) { + vtkErrorMacro(<< "VTKViewer_RenderWindowInteractor::Initialize() can only handle VTKViewer_RenderWindow.") ; + return ; + } + + slot_func ( my_render_win, SIGNAL(ButtonPressed(const QMouseEvent *)), + this, SLOT(ButtonPressed(const QMouseEvent *)) ) ; + slot_func( my_render_win, SIGNAL(ButtonReleased(const QMouseEvent *)), + this, SLOT(ButtonReleased(const QMouseEvent *)) ) ; + + + slot_func( my_render_win, SIGNAL(LeftButtonPressed(const QMouseEvent *)), + this, SLOT(LeftButtonPressed(const QMouseEvent *)) ) ; + slot_func( my_render_win, SIGNAL(LeftButtonReleased(const QMouseEvent *)), + this, SLOT(LeftButtonReleased(const QMouseEvent *)) ) ; + + slot_func( my_render_win, SIGNAL(MiddleButtonPressed(const QMouseEvent *)), + this, SLOT(MiddleButtonPressed(const QMouseEvent *)) ) ; + slot_func( my_render_win, SIGNAL(MiddleButtonReleased(const QMouseEvent *)), + this, SLOT(MiddleButtonReleased(const QMouseEvent *)) ) ; + + slot_func( my_render_win, SIGNAL(RightButtonPressed(const QMouseEvent *)), + this, SLOT(RightButtonPressed(const QMouseEvent *)) ) ; + slot_func( my_render_win, SIGNAL(RightButtonReleased(const QMouseEvent *)), + this, SLOT(RightButtonReleased(const QMouseEvent *)) ) ; + + slot_func( my_render_win, SIGNAL(MouseMove(const QMouseEvent *)), + this, SLOT(MouseMove(const QMouseEvent *)) ) ; + + slot_func( my_render_win, SIGNAL(KeyPressed(QKeyEvent *)), + this, SLOT(KeyPressed(QKeyEvent *)) ) ; + + slot_func( this, SIGNAL(RenderWindowModified()), + my_render_win, SLOT(updateGL()) ) ; + +} + +void VTKViewer_RenderWindowInteractor::MouseMove(const QMouseEvent *event) { + if( ! this->Enabled ) { + return ; + } + this->InteractorStyle->OnMouseMove(0, 0, + event->x(), + event->y()/*this->Size[1] - event->y() - 1*/) ; + VTKViewer_InteractorStyleSALOME* Style = 0; + if (this->InteractorStyle->IsA("VTKViewer_InteractorStyleSALOME")) + Style = VTKViewer_InteractorStyleSALOME::SafeDownCast(this->InteractorStyle); + if (!Style || Style->needsRedrawing() ) + emit RenderWindowModified() ; +} + +void VTKViewer_RenderWindowInteractor::LeftButtonPressed(const QMouseEvent *event) { + if( ! this->Enabled ) { + return ; + } + this->InteractorStyle->OnLeftButtonDown( (event->state() & ControlButton), + (event->state() & ShiftButton), + event->x(), + event->y()) ; +} + +void VTKViewer_RenderWindowInteractor::LeftButtonReleased(const QMouseEvent *event) { + if( ! this->Enabled ) { + return ; + } + this->InteractorStyle->OnLeftButtonUp( (event->state() & ControlButton), + (event->state() & ShiftButton), + event->x(), + event->y() ) ; +} + +void VTKViewer_RenderWindowInteractor::MiddleButtonPressed(const QMouseEvent *event) { + if( ! this->Enabled ) { + return ; + } + this->InteractorStyle->OnMiddleButtonDown( (event->state() & ControlButton), + (event->state() & ShiftButton), + event->x(), + event->y() ) ; +} + +void VTKViewer_RenderWindowInteractor::MiddleButtonReleased(const QMouseEvent *event) { + if( ! this->Enabled ) { + return ; + } + this->InteractorStyle->OnMiddleButtonUp( (event->state() & ControlButton), + (event->state() & ShiftButton), + event->x(), + event->y() ) ; +} + +void VTKViewer_RenderWindowInteractor::RightButtonPressed(const QMouseEvent *event) { + if( ! this->Enabled ) { + return ; + } + this->InteractorStyle->OnRightButtonDown( (event->state() & ControlButton), + (event->state() & ShiftButton), + event->x(), + event->y() ) ; +} + +void VTKViewer_RenderWindowInteractor::RightButtonReleased(const QMouseEvent *event) { + if( ! this->Enabled ) { + return ; + } + this->InteractorStyle->OnRightButtonUp( (event->state() & ControlButton), + (event->state() & ShiftButton), + event->x(), + event->y() ) ; +} + +void VTKViewer_RenderWindowInteractor::ButtonPressed(const QMouseEvent *event) { + return ; +} + +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() ; + } +} + + + +void VTKViewer_RenderWindowInteractor::ChangeRepresentationToWireframe() + // change all actors to wireframe +{ + vtkActorCollection *ac; + vtkActor *anActor, *aPart; + + ac = GetRenderer()->GetActors(); + ChangeRepresentationToWireframe(ac); +} + + + +void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface(vtkActorCollection* ac) +{ + 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() ; +} + +void VTKViewer_RenderWindowInteractor::ChangeRepresentationToSurface() + // change all actors to "surface" or solid +{ + vtkActorCollection *ac; + vtkActor *anActor, *aPart; + + ac = GetRenderer()->GetActors(); + ChangeRepresentationToSurface(ac); +} + +vtkRenderer* VTKViewer_RenderWindowInteractor::GetRenderer() +{ + vtkRendererCollection * theRenderers = this->RenderWindow->GetRenderers(); + theRenderers->InitTraversal(); + return theRenderers->GetNextItem(); +} + +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); + } + } + 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 ); + } + } + emit RenderWindowModified() ; +} + +void VTKViewer_RenderWindowInteractor::Erase(const Handle(SALOME_InteractiveObject)& IObject, bool update) +{ + vtkRenderer* aren; + for (this->RenderWindow->GetRenderers()->InitTraversal(); + (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) { + vtkActorCollection* theActors = aren->GetActors(); + vtkActorCollection* theChildActors = vtkActorCollection::New(); + theActors->InitTraversal(); + vtkActor *ac = theActors->GetNextActor(); + while(!(ac==NULL)) { + if ( ac->IsA("SALOME_Actor") ) { + SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ); + if ( anActor->hasIO() ) { + if ( IObject->isSame( anActor->getIO() ) ) { + anActor->SetVisibility( false ); + anActor->GetChildActors(theChildActors); + } + } + } + ac = theActors->GetNextActor(); + } + + // Erase dependent actors + theChildActors->InitTraversal(); + ac = theChildActors->GetNextActor(); + while(!(ac==NULL)) { + ac->SetVisibility( false ); + ac = theChildActors->GetNextActor(); + } + } + if (update) + emit RenderWindowModified() ; +} + +void VTKViewer_RenderWindowInteractor::Remove(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() ) ) { + aren->RemoveActor(anActor); + } + } + } + ac = theActors->GetNextActor(); + } + } + if (update) + emit RenderWindowModified() ; +} + +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::Display( SALOME_Actor* SActor, bool update) +{ + vtkRenderer* aren; + for (this->RenderWindow->GetRenderers()->InitTraversal(); + (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) { + aren->AddActor( SActor ); + SActor->SetVisibility( true ); + } + + if (update) { + Render(); + emit RenderWindowModified(); + } +} + +void VTKViewer_RenderWindowInteractor::Display(const Handle(SALOME_InteractiveObject)& IObject, 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) + emit RenderWindowModified() ; +} + +void VTKViewer_RenderWindowInteractor::KeyPressed(QKeyEvent *event) { +// MESSAGE ( " vtkQGLRenderWindowInteractor::KeyPressed " ) + +// if (!QAD_Application::getDesktop()->getActiveComponent().isEmpty()) { +// QAD_Application::getDesktop()->onKeyPress( event ); +// } +} + +bool VTKViewer_RenderWindowInteractor::highlight( const Handle(SALOME_InteractiveObject)& IObject, + bool hilight, + 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->GetMapper() == NULL ) { + return false; + } + //highlight or unhilight actors + if ( anActor->hasHighlight() ) { + anActor->highlight(hilight); + } else { + if ( anActor->GetVisibility() == 1 ) { + if (hilight) { + vtkActor2D *actor2D; + vtkProp3D *prop3D; + if ( (prop3D=vtkProp3D::SafeDownCast(anActor)) != NULL ) { + this->InteractorStyle->HighlightProp3D(prop3D); + } else if ( (actor2D=vtkActor2D::SafeDownCast(anActor)) != NULL ) { + this->InteractorStyle->HighlightActor2D(actor2D); + } + //this->InteractorStyle->HighlightProp(anActor); + } else { + this->InteractorStyle->HighlightProp3D(NULL); + this->InteractorStyle->HighlightActor2D(NULL); + //this->InteractorStyle->HighlightProp(NULL); + } + } + } + } + } + } + ac = theActors->GetNextActor(); + } + } + if (update) { + Render(); + 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(); + ac->Update(); + ac = theActors->GetNextActor(); + } + aren->ResetCamera(); + emit RenderWindowModified() ; + } +} + + +bool VTKViewer_RenderWindowInteractor::unHighlightAll() +{ + vtkRenderer* aren; + for (this->RenderWindow->GetRenderers()->InitTraversal(); + (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) { + vtkActorCollection* theActors = aren->GetActors(); + theActors->InitTraversal(); + + if ( theActors->IsItemPresent(Point_Actor) != 0 ) + aren->RemoveActor( Point_Actor ); + if ( theActors->IsItemPresent( Edge_Actor ) != 0 ) + aren->RemoveActor( Edge_Actor ); + if ( theActors->IsItemPresent( Cell_Actor ) != 0 ) + aren->RemoveActor( Cell_Actor ); + + vtkActor *ac = theActors->GetNextActor(); + + while(!(ac==NULL)) { + if ( ac->IsA("SALOME_Actor") ) { + SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ); + if ( anActor->hasIO() ) { + //highlight or unhilight actors + if ( anActor->hasHighlight() ) + anActor->highlight(false); + } + } + ac = theActors->GetNextActor(); + } + } + + emit RenderWindowModified() ; + return false; +} + +//----------------- +// Color methods +//----------------- + +void VTKViewer_RenderWindowInteractor::SetColor(const Handle(SALOME_InteractiveObject)& IObject,QColor thecolor) { + vtkRenderer* aren; + for (this->RenderWindow->GetRenderers()->InitTraversal(); + (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) { + vtkActorCollection* theActors = aren->GetActors(); + theActors->InitTraversal(); + vtkActor *ac = theActors->GetNextActor(); + while(!(ac==NULL)) { + if ( ac->IsA("SALOME_Actor") ) { + SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ); + if ( anActor->hasIO() ) { + if ( IObject->isSame( anActor->getIO() ) ) { + if ( anActor->IsA("GEOM_Actor") ) { + // GEOM actor + anActor->SetColor(float(thecolor.red())/255,float(thecolor.green())/255,float(thecolor.blue())/255); + } + else { + anActor->GetProperty()->SetColor(float(thecolor.red())/255,float(thecolor.green())/255,float(thecolor.blue())/255); + } + } + } + } + ac = theActors->GetNextActor(); + } + } +} + +QColor VTKViewer_RenderWindowInteractor::GetColor(const Handle(SALOME_InteractiveObject)& IObject) { + vtkRenderer* aren; + QColor emptycolor(0,0,0); + for (this->RenderWindow->GetRenderers()->InitTraversal(); + (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) { + vtkActorCollection* theActors = aren->GetActors(); + theActors->InitTraversal(); + vtkActor *ac = theActors->GetNextActor(); + while(!(ac==NULL)) { + if ( ac->IsA("SALOME_Actor") ) { + SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ); + if ( anActor->hasIO() ) { + if ( IObject->isSame( anActor->getIO() ) ) { + if ( anActor->IsA("GEOM_Actor") ) { + // GEOM actor + float r,g,b; + anActor->GetColor(r,g,b); + return QColor(r*255,g*255,b*255); + } + else { + float color[3]; + anActor->GetProperty()->GetColor(color); + return QColor(color[0]*255,color[1]*255,color[2]*255); + } + } + } + } + ac = theActors->GetNextActor(); + } + } + return emptycolor; +} + + + + +bool VTKViewer_RenderWindowInteractor::isInViewer(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() ) ) { + //MESSAGE ( " VTKViewer_RenderWindowInteractor::isInViewer = TRUE" ) + return true; + } + } + } + ac = theActors->GetNextActor(); + } + } + //MESSAGE ( " VTKViewer_RenderWindowInteractor::isInViewer = FALSE" ) + return false; +} + +bool VTKViewer_RenderWindowInteractor::isVisible(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() ) ) { + return anActor->GetVisibility(); + } + } + } + ac = theActors->GetNextActor(); + } + } + return false; +} + +void VTKViewer_RenderWindowInteractor::rename(const Handle(SALOME_InteractiveObject)& IObject, QString newName) +{ + 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(); + } + } + + emit RenderWindowModified() ; +} + +bool VTKViewer_RenderWindowInteractor::highlightCell( const Handle(SALOME_InteractiveObject)& IObject, + bool hilight, + const TColStd_MapOfInteger& MapIndex, + bool update ) +{ + vtkRenderer* aren; + for (this->RenderWindow->GetRenderers()->InitTraversal(); + (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) { + vtkActorCollection* theActors = aren->GetActors(); + + if ( theActors->IsItemPresent(Cell_Actor) != 0 ) + aren->RemoveActor( Cell_Actor ); + + theActors->InitTraversal(); + vtkActor *ac = theActors->GetNextActor(); + for ( ; ac; ac = theActors->GetNextActor() ) { + if ( ac->IsA("SALOME_Actor") ) { + SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ); + if ( anActor->hasIO() ) { + if ( IObject->isSame( anActor->getIO() ) ) { + vtkUnstructuredGrid* Cell_UGrid = vtkUnstructuredGrid::New(); + vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::SafeDownCast( ac->GetMapper()->GetInput() ); + if (UGrid == 0) break; + vtkIdList *ptIds = vtkIdList::New(); ptIds->Allocate(12); + vtkDataSetMapper* Cell_Mapper = vtkDataSetMapper::New(); + Cell_UGrid->SetPoints( UGrid->GetPoints() ); + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + for ( ; ite.More(); ite.Next() ) { + UGrid->GetCellPoints( ite.Key(), ptIds ); + Cell_UGrid->InsertNextCell(ac->GetMapper()->GetInput()->GetCellType( ite.Key() ), ptIds); + } + + + Cell_Mapper->SetInput(Cell_UGrid); + Cell_Actor->SetMapper(Cell_Mapper); + + if ( theActors->IsItemPresent(Cell_Actor) == 0 ) + aren->AddActor( Cell_Actor ); + + if ( hilight ) + Cell_Actor->VisibilityOn(); + else + Cell_Actor->VisibilityOff(); + break; + } + } + } + } + } + if (update) { + this->RenderWindow->Render(); + emit RenderWindowModified() ; + } + return 0; +} + +bool VTKViewer_RenderWindowInteractor::highlightEdge( const Handle(SALOME_InteractiveObject)& IObject, + bool hilight, + const TColStd_MapOfInteger& MapIndex, + bool update ) +{ + vtkRenderer* aren; + for (this->RenderWindow->GetRenderers()->InitTraversal(); + (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) { + vtkActorCollection* theActors = aren->GetActors(); + theActors->InitTraversal(); + vtkActor *ac = theActors->GetNextActor(); + for( ; ac; ac = theActors->GetNextActor() ) { + if ( ac->IsA("SALOME_Actor") ) { + SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ); + if ( anActor->hasIO() ) { + if ( IObject->isSame( anActor->getIO() ) ) { + + vtkUnstructuredGrid* Edge_UGrid = vtkUnstructuredGrid::New(); + vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::SafeDownCast( ac->GetMapper()->GetInput() ); + if (UGrid == 0) break; + + vtkDataSetMapper* Edge_Mapper = vtkDataSetMapper::New(); + vtkCell* pickedCell; + vtkCell* pickedEdge; + int cellId, edgeId; + Edge_UGrid->SetPoints( UGrid->GetPoints() ); + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + int numberOfIndexes = MapIndex.Extent(); + int i, j, npts, *pts, aLen; + + if ( theActors->IsItemPresent(Cell_Actor) != 0 ) { + Cell_Actor->VisibilityOff(); + if ( theActors->IsItemPresent(Edge_Actor) != 0 ) { + vtkUnstructuredGrid* EdgeGrid = vtkUnstructuredGrid::SafeDownCast( Edge_Actor->GetMapper()->GetInput() ); + if (EdgeGrid) { + aLen = EdgeGrid->GetNumberOfCells(); + //SRN: modified traversal of edge cells. + vtkCellArray* cells = EdgeGrid->GetCells(); + for (i=0, cells->InitTraversal(); cells->GetNextCell(npts,pts); i++) { + if(MapIndex.Contains(i)) + Edge_UGrid->InsertNextCell(VTK_LINE, npts, pts); + } + } + } + vtkUnstructuredGrid* CellGrid = vtkUnstructuredGrid::SafeDownCast( Cell_Actor->GetMapper()->GetInput() ); + + bool isOneEdge = (MapIndex.Extent() <= 2); + int edgeId; + + //SRN: modified finding the selected edges + if (CellGrid) { + aLen = CellGrid->GetNumberOfCells(); + for (i=0; iGetCell(i); + int aLen2 = pickedCell->GetNumberOfEdges(); + for(j=0; jGetEdge(j); + Edge_UGrid->InsertNextCell(pickedEdge->GetCellType(), pickedEdge->GetPointIds()); + } + } + } + } + + Edge_Mapper->SetInput(Edge_UGrid); + Edge_Actor->SetMapper(Edge_Mapper); + + if ( theActors->IsItemPresent(Edge_Actor) == 0 ) + aren->AddActor( Edge_Actor ); + + if ( hilight ) + Edge_Actor->VisibilityOn(); + else + Edge_Actor->VisibilityOff(); + } + + break; + } + } + } + } + } + + if (update) { + this->RenderWindow->Render(); + emit RenderWindowModified(); + } + + return 0; +} + +bool VTKViewer_RenderWindowInteractor::highlightPoint(const Handle(SALOME_InteractiveObject)& IObject, + bool hilight, const TColStd_MapOfInteger& MapIndex, + bool update) +{ + vtkRenderer* aren; + for (this->RenderWindow->GetRenderers()->InitTraversal(); + (aren = this->RenderWindow->GetRenderers()->GetNextItem()); ) { + vtkActorCollection* theActors = aren->GetActors(); + + if ( theActors->IsItemPresent(Point_Actor) != 0 ) + aren->RemoveActor( Point_Actor ); + + theActors->InitTraversal(); + vtkActor *ac = theActors->GetNextActor(); + for ( ; ac; ac = theActors->GetNextActor() ) { + if ( ac->IsA("SALOME_Actor") ) { + SALOME_Actor* anActor = SALOME_Actor::SafeDownCast( ac ); + if ( anActor->hasIO() ) { + if ( IObject->isSame( anActor->getIO() ) ) { + vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::SafeDownCast( ac->GetMapper()->GetInput() ); + if (UGrid == 0) break; + vtkUnstructuredGrid* Point_UGrid = vtkUnstructuredGrid::New(); + float pts[3]; + + vtkPoints *Points = vtkPoints::New(); + vtkMaskPoints* verts = vtkMaskPoints::New(); + vtkPolyDataMapper* vertMapper = vtkPolyDataMapper::New(); + + TColStd_MapIteratorOfMapOfInteger ite( MapIndex ); + int i = 0; + // Points->SetNumberOfPoints( MapIndex.Extent() ); + if ( MapIndex.Extent() == 1 ) + Points->SetNumberOfPoints( MapIndex.Extent() + 1 ); + else + Points->SetNumberOfPoints( MapIndex.Extent() ); + + for ( ; ite.More(); ite.Next() ) { + UGrid->GetPoint( ite.Key(), pts) ; + Points->SetPoint(i, pts ); + i++; + // DEBUG : it's not possible to see only one point !!!! + if ( MapIndex.Extent() == 1 ) + Points->SetPoint(i, 0., 0., 0. ); + } + + Point_UGrid->SetPoints(Points); + verts->SetInput(Point_UGrid); + verts->SetGenerateVertices(1); + verts->SetOnRatio(1); + vertMapper->SetInput(verts->GetOutput()); + Point_Actor->SetMapper(vertMapper); + + if ( theActors->IsItemPresent(Point_Actor) == 0 ) { + aren->AddActor( Point_Actor ); + } + + if ( hilight ) + Point_Actor->VisibilityOn(); + else + Point_Actor->VisibilityOff(); + + break; + } + } + } + } + } + + if (update) { + this->RenderWindow->Render(); + emit RenderWindowModified(); + } + return 0; +} diff --git a/src/VTKViewer/VTKViewer_RenderWindowInteractor.h b/src/VTKViewer/VTKViewer_RenderWindowInteractor.h new file mode 100644 index 000000000..92284d85e --- /dev/null +++ b/src/VTKViewer/VTKViewer_RenderWindowInteractor.h @@ -0,0 +1,211 @@ +// File : VTKViewer_RenderWindowInteractor.h +// Created : Wed Mar 20 11:31:36 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : VTKViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef VTKViewer_RenderWindowInteractor_h +#define VTKViewer_RenderWindowInteractor_h + +//=========================================================== +// now we define the C++ class + +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_Actor.h" + +// QT Includes +#include +#include + +// VTK Includes +#include +#include +#include + +// Open CASCADE Includes +#include +#include + +class VTKViewer_RenderWindow ; + +// ------------------------------------------------------------ +// :TRICKY: Fri Apr 21 22:19:27 2000 Pagey +// The Signal/Slot mechanism used by Qt requires that QObject +// appear as the first class when using multiple inheritance. +// Hence the order of the two classes QObject and vtkRenderWindowInteractor +// matters here. Be careful not to change it by accident. +// ------------------------------------------------------------ +class VTK_EXPORT VTKViewer_RenderWindowInteractor : + public QObject, public vtkRenderWindowInteractor +{ + Q_OBJECT +public: + + static VTKViewer_RenderWindowInteractor *New() ; + + vtkTypeMacro(vtkRenderWindowInteractor,vtkObject); + + void PrintSelf(ostream& os, vtkIndent indent); + + // Description: + // Initializes the event handlers without an XtAppContext. This is + // good for when you don`t have a user interface, but you still + // want to have mouse interaction. + virtual void Initialize(); + + // Description: + // This will start up the X event loop and never return. If you + // call this method it will loop processing X events until the + // application is exited. + virtual void Start(); + + // Description: + // Enable/Disable interactions. By default interactors are enabled when + // initialized. Initialize() must be called prior to enabling/disabling + // interaction. These methods are used when a window/widget is being + // shared by multiple renderers and interactors. This allows a "modal" + // display where one interactor is active when its data is to be displayed + // and all other interactors associated with the widget are disabled + // when their data is not displayed. + virtual void Enable(); + virtual void Disable(); + + // Description: + // Event loop notification member for Window size change + virtual void UpdateSize(int x,int y); + + // Description: + // Timer methods must be overridden by platform dependent subclasses. + // flag is passed to indicate if this is first timer set or an update + // as Win32 uses repeating timers, whereas X uses One shot more timer + // if flag==VTKXI_TIMER_FIRST Win32 and X should createtimer + // otherwise Win32 should exit and X should perform AddTimeOut() + virtual int CreateTimer(int ) ; + virtual int DestroyTimer() ; + + // Description: + // This function is called on 'q','e' keypress if exitmethod is not + // specified and should be overidden by platform dependent subclasses + // to provide a termination procedure if one is required. + virtual void TerminateApp(void) { /* empty */ } + + // Description: + // These methods correspond to the the Exit, User and Pick + // callbacks. They allow for the Style to invoke them. + //virtual void ExitCallback(); + //virtual void UserCallback(); + //virtual void StartPickCallback(); + //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 highlight(const Handle(SALOME_InteractiveObject)& IObject, bool hiligth, bool immediatly = true ); + 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); + + + void SetSelectionMode(int mode); + + // Displaymode management + int GetDisplayMode(); + void SetDisplayMode(int); + + // Switch representation wireframe/shading + void SwitchRepresentation(const Handle(SALOME_InteractiveObject)& IObject, bool update = true); + + // Change all actors to wireframe or surface + void ChangeRepresentationToWireframe(); + void ChangeRepresentationToSurface(); + + // Change to wireframe or surface a list of vtkactor + void ChangeRepresentationToWireframe(vtkActorCollection* ListofActors); + void ChangeRepresentationToSurface(vtkActorCollection* ListofActors); + + // Erase Display functions + void EraseAll(); + void DisplayAll(); + void Erase(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly=true); + void Remove(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly=true); + void Display(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly=true); + + void Display( SALOME_Actor* SActor, bool immediatly = true ); + + // Transparency + void SetTransparency(const Handle(SALOME_InteractiveObject)& IObject,float trans); + float GetTransparency(const Handle(SALOME_InteractiveObject)& IObject); + + // Color + void SetColor(const Handle(SALOME_InteractiveObject)& IObject,QColor thecolor); + QColor GetColor(const Handle(SALOME_InteractiveObject)& IObject); + + void Update(); + + vtkRenderer* GetRenderer(); + + protected: + + VTKViewer_RenderWindowInteractor(); + ~VTKViewer_RenderWindowInteractor(); + // + // Timer used during various mouse events to figure + // out mouse movements. + // + QTimer *mTimer ; + + //CAI: Display mode + int displaymode; + + //NRI: Selection mode + int selectionmode; + vtkActor* Point_Actor; + vtkActor* Edge_Actor; //NB + vtkActor* Cell_Actor; + + // + // User for switching to stereo mode. + // + int PositionBeforeStereo[2]; + // + // Connect/disconnect all slots which allow events on the + // render window to be passed to the interactor. + // + void ConnectSlots() ; + void DisconnectSlots() ; + void ProcessSlotConnections(bool conn) ; + + public slots: + void MouseMove(const QMouseEvent *event) ; + void LeftButtonPressed(const QMouseEvent *event) ; + void LeftButtonReleased(const QMouseEvent *event) ; + void MiddleButtonPressed(const QMouseEvent *event) ; + void MiddleButtonReleased(const QMouseEvent *event) ; + void RightButtonPressed(const QMouseEvent *event) ; + void RightButtonReleased(const QMouseEvent *event) ; + void ButtonPressed(const QMouseEvent *event) ; + void ButtonReleased(const QMouseEvent *event) ; + void KeyPressed(QKeyEvent *event) ; + + private slots: + // + // Not all of these slots are needed in VTK_MAJOR_VERSION=3, + // but moc does not understand "#if VTK_MAJOR_VERSION". Hence, + // we have to include all of these for the time being. Once, + // this bug in MOC is fixed, we can separate these. + // + void TimerFunc() ; + signals: + void RenderWindowModified() ; +}; + +#endif + diff --git a/src/VTKViewer/VTKViewer_ViewFrame.cxx b/src/VTKViewer/VTKViewer_ViewFrame.cxx new file mode 100644 index 000000000..a6f7c7d6e --- /dev/null +++ b/src/VTKViewer/VTKViewer_ViewFrame.cxx @@ -0,0 +1,986 @@ +using namespace std; +// File : VTKViewer_ViewFrame.cxx +// Created : Wed Mar 20 11:29:40 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : VTKViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "VTKViewer_ViewFrame.h" +#include "VTKViewer_RenderWindow.h" +#include "VTKViewer_InteractorStyleSALOME.h" + +#include "QAD_Settings.h" +#include "QAD_Config.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "SALOME_Selection.h" +#include "SALOME_InteractiveObject.hxx" + +#include "utilities.h" + +//QT Include +#include +#include +#include +#include + +// VTK Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/*! + Constructor +*/ +VTKViewer_ViewFrame::VTKViewer_ViewFrame(QWidget* parent, const char* name) + : QAD_ViewFrame(parent, name) +{ + m_ViewUp[0] = 0; m_ViewUp[1] = 0; m_ViewUp[2] = -1; + m_ViewNormal[0] = 0; m_ViewNormal[1] = 0; m_ViewNormal[2] = 1; + + // m_InitialSetupDone = false ; + InitialSetup(); + + m_NonIsometricTransform = NULL; + +} + + +static vtkActor* CreateTextActor(char *text) { + + vtkTextSource* XLabel = vtkTextSource::New(); + XLabel->SetForegroundColor(1,1,1); + XLabel->SetBackgroundColor(0,0,0); + XLabel->SetText(text); + + vtkActor* XLabelActor = vtkActor::New(); + + vtkPolyDataMapper* text1Mapper = vtkPolyDataMapper::New(); + text1Mapper->SetInput(XLabel->GetOutput()); + + XLabelActor->SetMapper(text1Mapper); + XLabelActor->SetScale(1,1,1); + + return XLabelActor; +} + +void VTKViewer_ViewFrame::AddVector(float* o,float* p,vtkRenderer* renderer) { + + // Create line + + vtkPoints* myPoints = vtkPoints::New(); + vtkLine* myLine = vtkLine::New(); + + myPoints->InsertNextPoint(o); + myPoints->InsertNextPoint(p); + + (myLine->GetPointIds())->InsertNextId(0); + (myLine->GetPointIds())->InsertNextId(1); + + vtkActor* lineActor = vtkActor::New(); + + vtkCellArray* cell = vtkCellArray::New(); + + cell->InsertNextCell(myLine); + + vtkPolyData* output = vtkPolyData::New(); + + output->SetPoints(myPoints); + output->SetLines(cell); + + vtkPolyDataMapper* mapper = vtkPolyDataMapper::New(); + + mapper->SetInput(output); + + lineActor->SetMapper(mapper); + + // Create CONE + + vtkConeSource* acone = vtkConeSource::New(); + + float dim; + QString Size = QAD_CONFIG->getSetting("Viewer:TrihedronSize"); + if( Size.isEmpty() ) { + dim = 100; + } else { + dim = Size.toFloat(); + } + + acone->SetResolution(2); + // acone->SetAngle(70); + acone->SetRadius(0.02*dim); + acone->SetHeight(0.08*dim); + + vtkActor* coneActor = vtkActor::New(); + + vtkPolyDataMapper* coneMapper = vtkPolyDataMapper::New(); + coneMapper->SetInput(acone->GetOutput()); + + coneActor->SetMapper(coneMapper); + float rot[3]; + rot[0]=0; rot[1]=0; rot[2]=0; + + if(p[0]!=0) { + // x + coneActor->AddPosition(p); + } + else { + if(p[1]!=0) { + // y + coneActor->AddPosition(p); + rot[2]=90; + coneActor->AddOrientation(rot); + } + else { + if(p[2]!=0) { + // z + coneActor->AddPosition(p); + rot[1]=-90; + coneActor->AddOrientation(rot); + } + } + } + + // Create 2d TEXT + + coneActor->GetProperty()->SetInterpolation(1); + coneActor->GetProperty()->SetRepresentationToSurface(); + coneActor->GetProperty()->SetAmbient(1); + coneActor->GetProperty()->SetAmbientColor(1,1,1); + coneActor->GetProperty()->SetDiffuseColor(0.7,0.7,0.7); + coneActor->GetProperty()->SetSpecularColor(0.7,0.7,0.7); + + lineActor->GetProperty()->SetInterpolation(1); + lineActor->GetProperty()->SetRepresentationToSurface(); + lineActor->GetProperty()->SetAmbient(1); + lineActor->GetProperty()->SetAmbientColor(1,1,1); + lineActor->GetProperty()->SetDiffuseColor(0.7,0.7,0.7); + lineActor->GetProperty()->SetSpecularColor(0.7,0.7,0.7); + + coneActor->PickableOff(); + lineActor->PickableOff(); + + m_Triedron->AddItem(coneActor); + m_Triedron->AddItem(lineActor); + + renderer->AddActor(coneActor); + renderer->AddActor(lineActor); +} + +bool VTKViewer_ViewFrame::isTrihedronDisplayed() +{ + m_Triedron->InitTraversal(); + vtkActor *ac = m_Triedron->GetNextActor(); + while(!(ac==NULL)) { + if(ac->GetVisibility()) return true; + ac = m_Triedron->GetNextActor(); + } + return false; +} + +void VTKViewer_ViewFrame::SetTrihedronSize(int size) +{ + m_Triedron->InitTraversal(); + vtkActor* anActor = m_Triedron->GetNextActor(); + while(!(anActor==NULL)) { + m_Renderer->RemoveActor( anActor ); + anActor = m_Triedron->GetNextActor(); + } + + m_Triedron->RemoveAllItems(); + AddAxis(m_Renderer); + m_RW->updateGL(); +} + + +void VTKViewer_ViewFrame::AddAxis(vtkRenderer* renderer) { + + float origine[3]; + float X[3]; + float Y[3]; + float Z[3]; + float dim; + + QString Size = QAD_CONFIG->getSetting("Viewer:TrihedronSize"); + if( Size.isEmpty() ){ + dim = 100; + } else { + dim = Size.toFloat(); + } + + origine[0]=0; origine[1]=0; origine[2]=0; + X[0]=origine[0]+dim; X[1]=origine[0]; X[2]=origine[0]; + Y[0]=origine[0]; Y[1]=origine[0]+dim; Y[2]=origine[0]; + Z[0]=origine[0]; Z[1]=origine[0]; Z[2]=origine[0]+dim; + + AddVector(origine,X,renderer); + AddVector(origine,Y,renderer); + AddVector(origine,Z,renderer); + +} + +/*! + Returns widget containing 3D-Viewer +*/ +QWidget* VTKViewer_ViewFrame::getViewWidget() +{ + return (QWidget*)getRW(); +} + + +void VTKViewer_ViewFrame::setRW(VTKViewer_RenderWindow* rw) { + m_RW = rw; +} + + +void VTKViewer_ViewFrame::InitialSetup() { + // + // Create a render window. + // + m_RW = new VTKViewer_RenderWindow(this,""); + // + // Create a renderer for this widget. + // + m_Renderer = vtkRenderer::New() ; + m_RW->AddRenderer(m_Renderer) ; + + + vtkCamera* camera = vtkCamera::New(); + camera->SetPosition(1,-1,1); + camera->SetParallelProjection(true); + camera->SetRoll(-60); + + // CREATE AXIS + m_Triedron = vtkActorCollection::New(); + AddAxis(m_Renderer); + + // Set BackgroundColor + QString BackgroundColorRed = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorRed"); + QString BackgroundColorGreen = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorGreen"); + QString BackgroundColorBlue = QAD_CONFIG->getSetting("VTKViewer:BackgroundColorBlue"); + + if( !BackgroundColorRed.isEmpty() && !BackgroundColorGreen.isEmpty() && !BackgroundColorBlue.isEmpty() ) + m_Renderer->SetBackground( BackgroundColorRed.toInt()/255., BackgroundColorGreen.toInt()/255., BackgroundColorBlue.toInt()/255. ); + else + m_Renderer->SetBackground( 0, 0 , 0 ); + + // + // Create an interactor. + // + m_RWInteractor = VTKViewer_RenderWindowInteractor::New() ; + m_RWInteractor->SetRenderWindow(m_RW) ; + // + // :TRICKY: Tue May 2 19:29:36 2000 Pagey + // The order of the next two statements is very + // important. The interactor must be initialized + // before rendering. + // + m_RWInteractor->Initialize(); + m_Renderer->Render() ; + m_Renderer->SetActiveCamera(camera); + m_Renderer->ResetCamera(); + camera->Zoom(0.3); + VTKViewer_InteractorStyleSALOME* RWS = dynamic_cast(getRWInteractor()->GetInteractorStyle()); + if (RWS) { + RWS->setTriedron( m_Triedron ); + //SRN: additional initialization, to init CurrentRenderer of vtkInteractorStyle + RWS->FindPokedRenderer(0, 0); + } + + m_RW->updateGL() ; + + setCentralWidget( m_RW ); +} + +VTKViewer_ViewFrame::~VTKViewer_ViewFrame() { + // + // In order to ensure that the interactor unregisters + // this RenderWindow, we assign a NULL RenderWindow to + // it before deleting it. + // + if ( m_NonIsometricTransform ) + m_NonIsometricTransform->Delete() ; + + m_RWInteractor->SetRenderWindow(NULL) ; + m_RWInteractor->Delete() ; + + m_RW->Delete() ; + + // NRI : BugID 1137. + // m_Renderer->Delete() ; +} + + +/*! + Display/hide Trihedron +*/ +void VTKViewer_ViewFrame::onViewTrihedron() +{ + if (isTrihedronDisplayed()) { + m_Triedron->InitTraversal(); + vtkActor *ac = m_Triedron->GetNextActor(); + while(!(ac==NULL)) { + ac->VisibilityOff(); + ac = m_Triedron->GetNextActor(); + } + } + else { + m_Triedron->InitTraversal(); + vtkActor *ac = m_Triedron->GetNextActor(); + while(!(ac==NULL)) { + ac->VisibilityOn(); + ac = m_Triedron->GetNextActor(); + } + m_TriedronVisible = true; + } + m_RW->updateGL(); +} + +/*! + Provides top projection of the active view +*/ +void VTKViewer_ViewFrame::onViewTop() { + vtkCamera* camera = vtkCamera::New(); + camera->SetPosition(0,0,1); + camera->SetParallelProjection(true); + m_Renderer->SetActiveCamera(camera); +// m_Renderer->ResetCamera(); + onViewFitAll(); +// m_RW->updateGL(); +} + +/*! + Provides bottom projection of the active view +*/ +void VTKViewer_ViewFrame::onViewBottom() +{ + vtkCamera* camera = vtkCamera::New(); + camera->SetPosition(0,0,-1); + camera->SetParallelProjection(true); + m_Renderer->SetActiveCamera(camera); +// m_Renderer->ResetCamera(); + onViewFitAll(); +// m_RW->updateGL(); +} + +/*! + Provides left projection of the active view +*/ +void VTKViewer_ViewFrame::onViewLeft() +{ + vtkCamera* camera = vtkCamera::New(); + camera->SetPosition(0,1,0); + camera->SetParallelProjection(true); + m_Renderer->SetActiveCamera(camera); +// m_Renderer->ResetCamera(); + onViewFitAll(); +// m_RW->updateGL(); +} + +/*! + Provides right projection of the active view +*/ +void VTKViewer_ViewFrame::onViewRight() +{ + vtkCamera* camera = vtkCamera::New(); + camera->SetPosition(0,-1,0); + camera->SetParallelProjection(true); + m_Renderer->SetActiveCamera(camera); +// m_Renderer->ResetCamera(); + onViewFitAll(); +// m_RW->updateGL(); +} + +/*! + Provides back projection of the active view +*/ +void VTKViewer_ViewFrame::onViewBack() +{ + vtkCamera* camera = vtkCamera::New(); + camera->SetPosition(-1,0,0); + camera->SetParallelProjection(true); + m_Renderer->SetActiveCamera(camera); +// m_Renderer->ResetCamera(); + onViewFitAll(); +// m_RW->updateGL(); +} + +/*! + Provides front projection of the active view +*/ +void VTKViewer_ViewFrame::onViewFront() +{ + vtkCamera* camera = vtkCamera::New(); + camera->SetPosition(1,0,0); + camera->SetParallelProjection(true); + m_Renderer->SetActiveCamera(camera); +// m_Renderer->ResetCamera(); + onViewFitAll(); +// m_RW->updateGL(); +} + +/*! + Reset the active view +*/ +void VTKViewer_ViewFrame::onViewReset() +{ + vtkCamera* camera = vtkCamera::New(); + camera->SetPosition(1,-1,1); + camera->SetParallelProjection(true); + camera->SetRoll(-60); + m_Renderer->SetActiveCamera(camera); + m_Renderer->ResetCamera(); + m_Renderer->ResetCameraClippingRange(); + camera->Zoom(0.3); + m_RW->updateGL(); +} + +/*! + Rotates the active view +*/ +void VTKViewer_ViewFrame::onViewRotate() +{ + VTKViewer_InteractorStyleSALOME* RWS = dynamic_cast(getRWInteractor()->GetInteractorStyle()); + if (RWS) + RWS->startRotate(); +} + +/*! + Sets a new center of the active view +*/ +void VTKViewer_ViewFrame::onViewGlobalPan() +{ + VTKViewer_InteractorStyleSALOME* RWS = dynamic_cast(getRWInteractor()->GetInteractorStyle()); + if (RWS) + RWS->startGlobalPan(); +} + +/*! + Zooms the active view +*/ +void VTKViewer_ViewFrame::onViewZoom() +{ + VTKViewer_InteractorStyleSALOME* RWS = dynamic_cast(getRWInteractor()->GetInteractorStyle()); + if (RWS) + RWS->startZoom(); +} + +/*! + Moves the active view +*/ +void VTKViewer_ViewFrame::onViewPan() +{ + VTKViewer_InteractorStyleSALOME* RWS = dynamic_cast(getRWInteractor()->GetInteractorStyle()); + if (RWS) + RWS->startPan(); +} + +/*! + Fits all obejcts within a rectangular area of the active view +*/ +void VTKViewer_ViewFrame::onViewFitArea() +{ + + VTKViewer_InteractorStyleSALOME* RWS = dynamic_cast(getRWInteractor()->GetInteractorStyle()); + if (RWS) + RWS->startFitArea(); +} + +/*! + Fits all objects in the active view +*/ +// Reset the camera clipping range to include this entire bounding box +static void ResetCameraClippingRange(vtkRenderer* theRenderer, float bounds[6] ) +{ + //see vtkRenderer::ResetCameraClippingRange(float bounds[6]) method + double vn[3], position[3], a, b, c, d; + double range[2], dist; + int i, j, k; + float center[3]; + float distance; + float width; + + vtkCamera* anActiveCamera = theRenderer->GetActiveCamera(); + if ( anActiveCamera == NULL ) + { + //vtkErrorMacro(<< "Trying to reset clipping range of non-existant camera"); + return; + } + + // Find the plane equation for the camera view plane + anActiveCamera->GetViewPlaneNormal(vn); + anActiveCamera->GetPosition(position); +// a = -vn[0]; +// b = -vn[1]; +// c = -vn[2]; +// d = -(a*position[0] + b*position[1] + c*position[2]); + + // Set the max near clipping plane and the min far clipping plane +// range[0] = a*bounds[0] + b*bounds[2] + c*bounds[4] + d; +// range[1] = 1e-18; + + // Find the closest / farthest bounding box vertex +// for ( k = 0; k < 2; k++ ) +// { +// for ( j = 0; j < 2; j++ ) +// { +// for ( i = 0; i < 2; i++ ) +// { +// dist = a*bounds[i] + b*bounds[2+j] + c*bounds[4+k] + d; +// range[0] = (distrange[1])?(dist):(range[1]); +// } +// } +// } + + center[0] = (bounds[0] + bounds[1])/2.0; + center[1] = (bounds[2] + bounds[3])/2.0; + center[2] = (bounds[4] + bounds[5])/2.0; + width = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) + + (bounds[3]-bounds[2])*(bounds[3]-bounds[2]) + + (bounds[5]-bounds[4])*(bounds[5]-bounds[4])); + distance = sqrt((position[0]-center[0])*(position[0]-center[0]) + + (position[1]-center[1])*(position[1]-center[1]) + + (position[2]-center[2])*(position[2]-center[2])); + range[0] = distance - width/2.0; + range[1] = distance + width/2.0; + + // Give ourselves a little breathing room + range[0] = 0.99*range[0] - (range[1] - range[0])*0.5; + range[1] = 1.01*range[1] + (range[1] - range[0])*0.5; + + // Make sure near is not bigger than far + range[0] = (range[0] >= range[1])?(0.01*range[1]):(range[0]); + + // Make sure near is at least some fraction of far - this prevents near + // from being behind the camera or too close in front. How close is too + // close depends on the resolution of the depth buffer + int ZBufferDepth = 16; + vtkRenderWindow* aRenderWindow = theRenderer->GetRenderWindow(); + if (aRenderWindow) + { + ZBufferDepth = aRenderWindow->GetDepthBufferSize(); + } + // + if ( ZBufferDepth <= 16 ) + { + range[0] = (range[0] < 0.01*range[1])?(0.01*range[1]):(range[0]); + } + else if ( ZBufferDepth <= 24 ) + { + range[0] = (range[0] < 0.01*range[1])?(0.01*range[1]):(range[0]); + } + else + { + range[0] = (range[0] < 0.01*range[1])?(0.01*range[1]):(range[0]); + } + anActiveCamera->SetClippingRange( range ); +} + +static void ResetCamera(vtkRenderer* theRenderer){ + //see vtkRenderer::ResetCamera(float bounds[6]) method + float bounds[6]; + if(!theRenderer) return; + theRenderer->ComputeVisiblePropBounds( bounds ); + + float center[3]; + float distance; + float width; + double vn[3], *vup; + + if ( theRenderer->GetActiveCamera() != NULL ) + { + theRenderer->GetActiveCamera()->GetViewPlaneNormal(vn); + } + else + { + MESSAGE("Trying to reset non-existant camera"); + return; + } + + center[0] = (bounds[0] + bounds[1])/2.0; + center[1] = (bounds[2] + bounds[3])/2.0; + center[2] = (bounds[4] + bounds[5])/2.0; + width = sqrt((bounds[1]-bounds[0])*(bounds[1]-bounds[0]) + + (bounds[3]-bounds[2])*(bounds[3]-bounds[2]) + + (bounds[5]-bounds[4])*(bounds[5]-bounds[4])); + double ang = theRenderer->GetActiveCamera()->GetViewAngle(); + distance = 2.0*width/tan(ang*vtkMath::Pi()/360.0); + // check view-up vector against view plane normal + vup = theRenderer->GetActiveCamera()->GetViewUp(); + if ( fabs(vtkMath::Dot(vup,vn)) > 0.999 ) + { + MESSAGE("Resetting view-up since view plane normal is parallel"); + theRenderer->GetActiveCamera()->SetViewUp(-vup[2], vup[0], vup[1]); + } + + // update the camera + theRenderer->GetActiveCamera()->SetFocalPoint(center[0],center[1],center[2]); + theRenderer->GetActiveCamera()->SetPosition(center[0]+distance*vn[0], + center[1]+distance*vn[1], + center[2]+distance*vn[2]); + // setup default parallel scale + theRenderer->GetActiveCamera()->SetParallelScale(width/2.0); + //workaround on VTK + //theRenderer->ResetCameraClippingRange(bounds); + ResetCameraClippingRange(theRenderer,bounds); +} + +void VTKViewer_ViewFrame::onViewFitAll() +{ + Standard_Boolean TriedronWasVisible = false; + if (isTrihedronDisplayed()) { + m_Triedron->InitTraversal(); + vtkActor *ac = m_Triedron->GetNextActor(); + while(!(ac==NULL)) { + ac->VisibilityOff(); + ac = m_Triedron->GetNextActor(); + } + TriedronWasVisible = true; + } + bool hasVisibleActors = m_Renderer->VisibleActorCount() > 0; + if ( hasVisibleActors ) // if there are visible actors, not to take into account Trihedron + ResetCamera(m_Renderer); + if(TriedronWasVisible) { + m_Triedron->InitTraversal(); + vtkActor *ac = m_Triedron->GetNextActor(); + while(!(ac==NULL)) { + ac->VisibilityOn(); + ac = m_Triedron->GetNextActor(); + } + if ( !hasVisibleActors ) // if there are NO visible actors, fit view to see only Trihedron + ResetCamera(m_Renderer); + } + //m_Renderer->ResetCameraClippingRange(); + m_RW->updateGL(); +} + +/*! + Set background of the viewport +*/ +void VTKViewer_ViewFrame::setBackgroundColor( const QColor& color) +{ + if ( m_Renderer ) + m_Renderer->SetBackground( color.red()/255., color.green()/255., color.blue()/255. ); +} + +/*! + Returns background of the viewport +*/ +QColor VTKViewer_ViewFrame::backgroundColor() const +{ + float backint[3]; + if ( m_Renderer ) { + m_Renderer->GetBackground(backint); + return QColorDialog::getColor ( QColor(int(backint[0]*255), int(backint[1]*255), int(backint[2]*255)), NULL ); + } + return QMainWindow::backgroundColor(); +} + + +void VTKViewer_ViewFrame::SetSelectionMode( int mode ) +{ + m_RWInteractor->SetSelectionMode( mode ); +} + +void VTKViewer_ViewFrame::rename( const Handle(SALOME_InteractiveObject)& IObject, QString newName ) +{ + m_RWInteractor->rename(IObject, newName); +} + +void VTKViewer_ViewFrame::unHighlightAll() +{ + m_RWInteractor->unHighlightAll(); +} + +void VTKViewer_ViewFrame::highlight( const Handle(SALOME_InteractiveObject)& IObject, + bool highlight, + bool update ) +{ + QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection* Sel = SALOME_Selection::Selection( ActiveStudy->getSelection() ); + + if ( Sel->SelectionMode() == 4 ) + m_RWInteractor->highlight(IObject, highlight, update); + else if ( Sel->SelectionMode() == 3 ) { + m_RWInteractor->highlight(IObject, highlight, update); + if ( Sel->HasIndex( IObject ) ) { + TColStd_MapOfInteger MapIndex; + Sel->GetIndex( IObject, MapIndex ); + m_RWInteractor->highlightCell(IObject, highlight, MapIndex, update); + } + } + else if ( Sel->SelectionMode() == 2 ) { + m_RWInteractor->highlight(IObject, highlight, update); + if ( Sel->HasIndex( IObject ) ) { + TColStd_MapOfInteger MapIndex; + Sel->GetIndex( IObject, MapIndex ); + m_RWInteractor->highlightEdge(IObject, highlight, MapIndex, update); + } + } + else if ( Sel->SelectionMode() == 1 ) { + m_RWInteractor->highlight(IObject, highlight, update); + if ( Sel->HasIndex( IObject ) ) { + TColStd_MapOfInteger MapIndex; + Sel->GetIndex( IObject, MapIndex ); + m_RWInteractor->highlightPoint(IObject, highlight, MapIndex, update); + } + } +} + +bool VTKViewer_ViewFrame::isInViewer( const Handle(SALOME_InteractiveObject)& IObject ) +{ + return m_RWInteractor->isInViewer( IObject ); +} + +bool VTKViewer_ViewFrame::isVisible( const Handle(SALOME_InteractiveObject)& IObject ) +{ + return m_RWInteractor->isVisible( IObject ); +} + +void VTKViewer_ViewFrame::setPopupServer( QAD_Application* App ) +{ + m_RW->setPopupServer( App ); +} + +void VTKViewer_ViewFrame::undo(SALOMEDS::Study_var aStudy, + const char* StudyFrameEntry) +{ + 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(); + } +} + +void VTKViewer_ViewFrame::redo(SALOMEDS::Study_var aStudy, + 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)) { + 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(); + } + } + } +} + + +/* 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(); + } + return IO; +} + +/* display */ +void VTKViewer_ViewFrame::Display(const Handle(SALOME_InteractiveObject)& IObject, 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->Display(IO, false); + Sel->AddIObject(IO, false); + break; + } + } + } + ac = theActors->GetNextActor(); + } + if (update) + Repaint(); +} + + +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) +{ + 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) + Repaint(); +} + + +void VTKViewer_ViewFrame::DisplayAll() +{ + m_RWInteractor->DisplayAll(); +} + + +void VTKViewer_ViewFrame::EraseAll() +{ + m_RWInteractor->EraseAll(); +} + + +void VTKViewer_ViewFrame::Repaint() +{ + m_RWInteractor->Render(); + m_RW->updateGL(); +} + +void VTKViewer_ViewFrame::AddActor( SALOME_Actor* theActor, bool update /*=false*/ ) +{ + m_Renderer->AddActor( theActor ); + if (m_NonIsometricTransform != NULL) + { + vtkPolyDataMapper* mapper = NULL; + vtkMapper* initialMapper = theActor->GetInitialMapper(); + if ( initialMapper == NULL ) + initialMapper = theActor->GetMapper(); + if ( initialMapper->IsA("vtkDataSetMapper") ) + { + mapper = vtkDataSetMapper::SafeDownCast( initialMapper )->GetPolyDataMapper (); + if (!mapper) + { + initialMapper->Render(m_Renderer,theActor); + mapper = vtkDataSetMapper::SafeDownCast( initialMapper )->GetPolyDataMapper (); + } + } + else + mapper = vtkPolyDataMapper::SafeDownCast( initialMapper ); + if (mapper) + { + //create Filter + vtkTransformPolyDataFilter *aTransformFilter = vtkTransformPolyDataFilter::New(); + aTransformFilter->SetInput ( mapper->GetInput() ); + aTransformFilter->SetTransform (m_NonIsometricTransform); + + //create new mapper + vtkPolyDataMapper *aMapper = vtkPolyDataMapper::New(); + aMapper->SetInput (aTransformFilter->GetOutput()); + aMapper->ShallowCopy ( theActor->GetMapper()); + + //set new mapper + theActor->SetMapper (aMapper); + + aTransformFilter->Delete(); + aMapper->Delete(); + } + } + theActor->SetVisibility( true ); + + if (update) + m_RWInteractor->Render(); +} diff --git a/src/VTKViewer/VTKViewer_ViewFrame.h b/src/VTKViewer/VTKViewer_ViewFrame.h new file mode 100644 index 000000000..36988eab2 --- /dev/null +++ b/src/VTKViewer/VTKViewer_ViewFrame.h @@ -0,0 +1,129 @@ +// File : VTKViewer_ViewFrame.h +// Created : Wed Mar 20 11:27:26 2002 +// Author : Nicolas REJNERI +// Project : SALOME +// Module : VTKViewer +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef VTKViewer_ViewFrame_H +#define VTKViewer_ViewFrame_H + +#include "VTKViewer_RenderWindowInteractor.h" +#include "VTKViewer_RenderWindow.h" +#include "VTKViewer_NonIsometricTransform.h" + +#include "QAD.h" +#include "QAD_ViewFrame.h" + +// VTK Includes +#include +#include +#include +#include + +class QAD_EXPORT VTKViewer_ViewFrame : public QAD_ViewFrame +{ + Q_OBJECT + + public: + VTKViewer_ViewFrame(QWidget* parent, const char* name=0 ); + ~VTKViewer_ViewFrame(); + + ViewType getTypeView() const{ return VIEW_VTK;}; + QWidget* getViewWidget(); + vtkRenderer* getRenderer() {return m_Renderer;} + + void setRW(VTKViewer_RenderWindow* rw); + VTKViewer_RenderWindow* getRW() {return m_RW;} + VTKViewer_RenderWindowInteractor* getRWInteractor() {return m_RWInteractor;} + + bool isTrihedronDisplayed(); + void SetTrihedronSize( int dim ); + + void setBackgroundColor( const QColor& ); + QColor backgroundColor() const; + + void SetSelectionMode( int mode ); + + /* popup management */ + void setPopupServer( QAD_Application* ); + + /* interactive object management */ + void highlight( const Handle(SALOME_InteractiveObject)& IObject, + bool highlight, bool immediatly = true ); + void unHighlightAll(); + void rename( const Handle(SALOME_InteractiveObject)& IObject, + QString newName ); + 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); + + /* display */ + void Display(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly = true); + void DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject); + void Erase(const Handle(SALOME_InteractiveObject)& IObject, bool immediatly = true); + void DisplayAll(); + void EraseAll(); + void Repaint(); + + /* non-isometric transformation */ + void setNonIsometricTransform (VTKViewer_NonIsometricTransform *NonIsometricTransform) + { + m_NonIsometricTransform = NonIsometricTransform; + } + VTKViewer_NonIsometricTransform * getNonIsometricTransform () + { + if ( m_NonIsometricTransform == NULL ) + m_NonIsometricTransform = VTKViewer_NonIsometricTransform::New(); + return m_NonIsometricTransform; + } + //apply existing transformation on adding SALOME_Actor + void AddActor(SALOME_Actor*, bool update = false); + + private: + void AddVector(float* o,float* p,vtkRenderer* renderer); + void AddAxis(vtkRenderer* renderer); + + public slots: + void onViewPan(); + void onViewZoom(); + void onViewFitAll(); + void onViewFitArea(); + void onViewGlobalPan(); + void onViewRotate(); + void onViewReset(); + void onViewFront(); + void onViewBack(); + void onViewRight(); + void onViewLeft(); + void onViewBottom(); + void onViewTop(); + void onViewTrihedron(); + + private: + double m_ViewUp[3]; + double m_ViewNormal[3]; + + void InitialSetup(); + + vtkRenderer* m_Renderer; + VTKViewer_RenderWindow* m_RW; + VTKViewer_RenderWindowInteractor* m_RWInteractor; + + Standard_Boolean m_TriedronVisible; + vtkActorCollection* m_Triedron; + + VTKViewer_NonIsometricTransform *m_NonIsometricTransform; + +}; +#endif