Salome HOME
PR: merge from tag mergeto_trunk_17Jan05
authorprascle <prascle>
Mon, 17 Jan 2005 15:18:27 +0000 (15:18 +0000)
committerprascle <prascle>
Mon, 17 Jan 2005 15:18:27 +0000 (15:18 +0000)
114 files changed:
bin/salome/runIDLparser.in
doc/salome/tui/Makefile.in
doc/salome/tui/pythfilter.py [new file with mode: 0644]
idl/SALOME_ModuleCatalog.idl
src/Container/Container_i.cxx
src/HDFPersist/HDFexception.hxx
src/Loader/SALOME_Session_Loader.cxx
src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx
src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx
src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx
src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx
src/OBJECT/SALOME_Actor.cxx
src/OCCViewer/OCCViewer_ViewFrame.cxx
src/OCCViewer/OCCViewer_ViewFrame.h
src/OCCViewer/OCCViewer_ViewPort.h
src/OCCViewer/OCCViewer_ViewPort3d.cxx
src/OCCViewer/OCCViewer_ViewPort3d.h
src/Plot2d/Plot2d_ViewFrame.cxx
src/Plot2d/Plot2d_ViewFrame.h
src/SALOMEDS/SALOMEDS_AttributeComment_i.cxx
src/SALOMEDS/SALOMEDS_AttributeComment_i.hxx
src/SALOMEDS/SALOMEDS_AttributeDrawable_i.cxx
src/SALOMEDS/SALOMEDS_AttributeDrawable_i.hxx
src/SALOMEDS/SALOMEDS_AttributeExpandable_i.cxx
src/SALOMEDS/SALOMEDS_AttributeExpandable_i.hxx
src/SALOMEDS/SALOMEDS_AttributeExternalFileDef_i.cxx
src/SALOMEDS/SALOMEDS_AttributeExternalFileDef_i.hxx
src/SALOMEDS/SALOMEDS_AttributeFileType_i.cxx
src/SALOMEDS/SALOMEDS_AttributeFileType_i.hxx
src/SALOMEDS/SALOMEDS_AttributeFlags_i.cxx
src/SALOMEDS/SALOMEDS_AttributeFlags_i.hxx
src/SALOMEDS/SALOMEDS_AttributeGraphic_i.cxx
src/SALOMEDS/SALOMEDS_AttributeGraphic_i.hxx
src/SALOMEDS/SALOMEDS_AttributeIOR_i.cxx
src/SALOMEDS/SALOMEDS_AttributeIOR_i.hxx
src/SALOMEDS/SALOMEDS_AttributeInteger_i.cxx
src/SALOMEDS/SALOMEDS_AttributeInteger_i.hxx
src/SALOMEDS/SALOMEDS_AttributeLocalID_i.cxx
src/SALOMEDS/SALOMEDS_AttributeLocalID_i.hxx
src/SALOMEDS/SALOMEDS_AttributeName_i.cxx
src/SALOMEDS/SALOMEDS_AttributeName_i.hxx
src/SALOMEDS/SALOMEDS_AttributeOpened_i.cxx
src/SALOMEDS/SALOMEDS_AttributeOpened_i.hxx
src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.cxx
src/SALOMEDS/SALOMEDS_AttributePersistentRef_i.hxx
src/SALOMEDS/SALOMEDS_AttributePixMap_i.cxx
src/SALOMEDS/SALOMEDS_AttributePixMap_i.hxx
src/SALOMEDS/SALOMEDS_AttributePythonObject_i.cxx
src/SALOMEDS/SALOMEDS_AttributePythonObject_i.hxx
src/SALOMEDS/SALOMEDS_AttributeReal_i.cxx
src/SALOMEDS/SALOMEDS_AttributeReal_i.hxx
src/SALOMEDS/SALOMEDS_AttributeSelectable_i.cxx
src/SALOMEDS/SALOMEDS_AttributeSelectable_i.hxx
src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.cxx
src/SALOMEDS/SALOMEDS_AttributeSequenceOfInteger_i.hxx
src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.cxx
src/SALOMEDS/SALOMEDS_AttributeSequenceOfReal_i.hxx
src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.cxx
src/SALOMEDS/SALOMEDS_AttributeStudyProperties_i.hxx
src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.cxx
src/SALOMEDS/SALOMEDS_AttributeTableOfInteger_i.hxx
src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.cxx
src/SALOMEDS/SALOMEDS_AttributeTableOfReal_i.hxx
src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.cxx
src/SALOMEDS/SALOMEDS_AttributeTableOfString_i.hxx
src/SALOMEDS/SALOMEDS_AttributeTarget_i.cxx
src/SALOMEDS/SALOMEDS_AttributeTarget_i.hxx
src/SALOMEDS/SALOMEDS_AttributeTextColor_i.cxx
src/SALOMEDS/SALOMEDS_AttributeTextColor_i.hxx
src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.cxx
src/SALOMEDS/SALOMEDS_AttributeTextHighlightColor_i.hxx
src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.cxx
src/SALOMEDS/SALOMEDS_AttributeTreeNode_i.hxx
src/SALOMEDS/SALOMEDS_AttributeUserID_i.cxx
src/SALOMEDS/SALOMEDS_AttributeUserID_i.hxx
src/SALOMEDS/SALOMEDS_Callback_i.hxx
src/SALOMEDS/SALOMEDS_ChildIterator_i.cxx
src/SALOMEDS/SALOMEDS_ChildIterator_i.hxx
src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx
src/SALOMEDS/SALOMEDS_GenericAttribute_i.hxx
src/SALOMEDS/SALOMEDS_SComponentIterator_i.cxx
src/SALOMEDS/SALOMEDS_SComponentIterator_i.hxx
src/SALOMEDS/SALOMEDS_SComponent_i.cxx
src/SALOMEDS/SALOMEDS_SComponent_i.hxx
src/SALOMEDS/SALOMEDS_SObject_i.cxx
src/SALOMEDS/SALOMEDS_SObject_i.hxx
src/SALOMEDS/SALOMEDS_Server.cxx
src/SALOMEDS/SALOMEDS_StudyBuilder_i.cxx
src/SALOMEDS/SALOMEDS_StudyBuilder_i.hxx
src/SALOMEDS/SALOMEDS_StudyManager_i.cxx
src/SALOMEDS/SALOMEDS_StudyManager_i.hxx
src/SALOMEDS/SALOMEDS_Study_i.cxx
src/SALOMEDS/SALOMEDS_Study_i.hxx
src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.cxx
src/SALOMEDS/SALOMEDS_UseCaseBuilder_i.hxx
src/SALOMEDS/SALOMEDS_UseCaseIterator_i.cxx
src/SALOMEDS/SALOMEDS_UseCaseIterator_i.hxx
src/SALOMEGUI/PyInterp_base.cxx
src/SALOMEGUI/QAD_Desktop.cxx
src/SALOMEGUI/QAD_Desktop.h
src/SALOMEGUI/QAD_DirListDlg.cxx
src/SALOMEGUI/QAD_ObjectBrowser.cxx
src/SALOMEGUI/QAD_PyEditor.cxx
src/SALOMEGUI/QAD_PyEditor.h
src/SALOMEGUI/QAD_ViewFrame.h
src/SALOMEGUI/SALOMEGUI_TableDlg.cxx
src/Session/SALOME_Session_Server.cxx
src/Session/Session_ServerThread.cxx
src/TOOLSDS/SALOMEDS_Tool.cxx
src/TOOLSDS/SALOMEDS_Tool.hxx
src/VTKViewer/VTKViewer_InteractorStyleSALOME.cxx
src/VTKViewer/VTKViewer_InteractorStyleSALOME.h
src/VTKViewer/VTKViewer_ViewFrame.cxx
src/VTKViewer/VTKViewer_ViewFrame.h

index 79e309eb2231493f5aa62c2019646a91500c564a..9f3afa8619ce53879cbaae1b44bb6b1424147d8e 100644 (file)
@@ -36,10 +36,8 @@ fi
 @ENVSCRIPT@
 
 cd $DIR
-
-#PYTHONPATH=${PYTHONPATH}:${SALOME_HOME_DIR}/bin
 #============================================================
 
 # omiidl ====================================================
-omniidl -bIDLparser -I ${KERNEL_ROOT_DIR}/idl $@
+omniidl -bIDLparser -I ${KERNEL_ROOT_DIR}/idl/salome $@
 #============================================================
index 5949e81b8cac33d3bf5573d098c90c7e25974d46..3f4811e43e6b41c6859461091c1f3cd608e8a092 100644 (file)
@@ -26,6 +26,7 @@ docs:
        cp -fr $(srcdir)/KERNEL/sources/static/*.* ./KERNEL/
        cp -fr $(srcdir)/KERNEL/sources/ KERNEL/
        cp -fr $(srcdir)/KERNEL/HTML/ KERNEL/
+       cp -f $(srcdir)/pythfilter.py KERNEL/
        rm -fr INPUT
 
 clean:
diff --git a/doc/salome/tui/pythfilter.py b/doc/salome/tui/pythfilter.py
new file mode 100644 (file)
index 0000000..ee72cd8
--- /dev/null
@@ -0,0 +1,547 @@
+#!/usr/bin/env python
+
+import getopt
+import glob
+import os.path
+import shutil
+import string
+import sys
+import token
+import tokenize
+
+from stat import *
+
+OUTSIDE          = 0
+BUILD_COMMENT    = 1
+BUILD_CLASS_DECL = 2
+BUILD_CLASS_BODY = 3
+BUILD_DEF_DECL   = 4
+BUILD_DEF_BODY   = 5
+IMPORT           = 6
+IMPORT_OP        = 7
+IMPORT_APPEND    = 8
+
+# Output file stream
+outfile = sys.stdout
+
+# Output buffer
+outbuffer = []
+
+out_row = 0
+out_col = 0
+
+# Variables used by rec_name_n_param()
+name         = ""
+param        = ""
+doc_string   = ""
+record_state = 0
+bracket_counter = 0
+
+# Tuple: (row,column)
+class_spos  = (0,0)
+def_spos    = (0,0)
+import_spos = (0,0)
+
+# Which import was used? ("import" or "from")
+import_token = ""
+
+# Comment block buffer
+comment_block = []
+comment_finished = 0
+
+# Imported modules
+modules = []
+
+# Program state
+stateStack = [OUTSIDE]
+
+# Keep track of whether module has a docstring
+module_has_docstring = False
+
+# Keep track of member protection
+protection_level = "public"
+private_member = False
+
+# Keep track of the module namespace
+namespace = ""
+
+######################################################################
+# Output string s. '\n' may only be at the end of the string (not
+# somewhere in the middle).
+#
+# In: s    - String
+#     spos - Startpos
+######################################################################
+def output(s,spos, immediate=0):
+    global outbuffer, out_row, out_col, outfile
+
+    os = string.rjust(s,spos[1]-out_col+len(s))
+    if immediate:
+        outfile.write(os)
+    else:
+        outbuffer.append(os)
+    if (s[-1:]=="\n"):
+        out_row = out_row+1
+        out_col = 0
+    else:
+        out_col = spos[1]+len(s)
+
+
+######################################################################
+# Records a name and parameters. The name is either a class name or
+# a function name. Then the parameter is either the base class or
+# the function parameters.
+# The name is stored in the global variable "name", the parameters
+# in "param".
+# The variable "record_state" holds the current state of this internal
+# state machine.
+# The recording is started by calling start_recording().
+#
+# In: type, tok
+######################################################################
+def rec_name_n_param(type, tok):
+    global record_state,name,param,doc_string,bracket_counter
+    s = record_state
+    # State 0: Do nothing.
+    if   (s==0):
+         return
+    # State 1: Remember name.
+    elif (s==1):
+        name = tok
+        record_state = 2
+    # State 2: Wait for opening bracket or colon
+    elif (s==2):
+        if (tok=='('):
+            bracket_counter = 1
+            record_state=3
+        if (tok==':'): record_state=4
+    # State 3: Store parameter (or base class) and wait for an ending bracket
+    elif (s==3):
+        if (tok=='*' or tok=='**'):
+            tok=''
+        if (tok=='('):
+            bracket_counter = bracket_counter+1
+        if (tok==')'):
+            bracket_counter = bracket_counter-1
+        if bracket_counter==0:
+            record_state=4
+        else:
+            param=param+tok
+    # State 4: Look for doc string
+    elif (s==4):
+        if (type==token.NEWLINE or type==token.INDENT or type==token.SLASHEQUAL):
+            return
+        elif (tok==":"):
+            return
+        elif (type==token.STRING):
+            while tok[:1]=='r' or tok[:1]=='u':
+                tok=tok[1:]
+            while tok[:1]=='"':
+                tok=tok[1:]
+            while tok[-1:]=='"':
+                tok=tok[:-1]
+            doc_string=tok
+        record_state=0
+
+######################################################################
+# Starts the recording of a name & param part.
+# The function rec_name_n_param() has to be fed with tokens. After
+# the necessary tokens are fed the name and parameters can be found
+# in the global variables "name" und "param".
+######################################################################
+def start_recording():
+    global record_state,param,name, doc_string
+    record_state=1
+    name=""
+    param=""
+    doc_string=""
+
+######################################################################
+# Test if recording is finished
+######################################################################
+def is_recording_finished():
+    global record_state
+    return record_state==0
+
+######################################################################
+## Gather comment block
+######################################################################
+def gather_comment(type,tok,spos):
+    global comment_block,comment_finished
+    if (type!=tokenize.COMMENT):
+        comment_finished = 1
+    else:
+        # Output old comment block if a new one is started.
+        if (comment_finished):
+            print_comment(spos)
+            comment_finished=0
+        if (tok[0:2]=="##" and tok[0:3]!="###"):
+            comment_block.append(tok[2:])
+
+######################################################################
+## Output comment block and empty buffer.
+######################################################################
+def print_comment(spos):
+    global comment_block,comment_finished
+    if (comment_block!=[]):
+        output("/**\n",spos)
+        for c in comment_block:
+            output(c,spos)
+        output("*/\n",spos)
+    comment_block    = []
+    comment_finished = 0
+
+######################################################################
+def set_state(s):
+    global stateStack
+    stateStack[len(stateStack)-1]=s
+
+######################################################################
+def get_state():
+    global stateStack
+    return stateStack[len(stateStack)-1]
+
+######################################################################
+def push_state(s):
+    global stateStack
+    stateStack.append(s)
+
+######################################################################
+def pop_state():
+    global stateStack
+    stateStack.pop()
+
+
+######################################################################
+def tok_eater(type, tok, spos, epos, line):
+    global stateStack,name,param,class_spos,def_spos,import_spos
+    global doc_string, modules, import_token, module_has_docstring
+    global protection_level, private_member
+
+    rec_name_n_param(type,tok)
+    if (string.replace(string.strip(tok)," ","")=="##private:"):
+         protection_level = "private"
+         output("private:\n",spos)
+    elif (string.replace(string.strip(tok)," ","")=="##protected:"):
+         protection_level = "protected"
+         output("protected:\n",spos)
+    elif (string.replace(string.strip(tok)," ","")=="##public:"):
+         protection_level = "public"
+         output("public:\n",spos)
+    else:
+         gather_comment(type,tok,spos)
+
+    state = get_state()
+
+#    sys.stderr.write("%d: %s\n"%(state, tok))
+
+    # OUTSIDE
+    if   (state==OUTSIDE):
+        if  (tok=="class"):
+            start_recording()
+            class_spos = spos
+            push_state(BUILD_CLASS_DECL)
+        elif (tok=="def"):
+            start_recording()
+            def_spos = spos
+            push_state(BUILD_DEF_DECL)
+        elif (tok=="import") or (tok=="from"):
+            import_token = tok
+            import_spos = spos
+            modules     = []
+            push_state(IMPORT)
+        elif (spos[1] == 0 and tok[:3] == '"""'):
+            # Capture module docstring as namespace documentation
+            module_has_docstring = True
+            #comment_block.append("\\namespace %s\n" % namespace)
+            comment_block.append(tok[3:-3])
+            print_comment(spos)
+
+    # IMPORT
+    elif (state==IMPORT):
+        if (type==token.NAME):
+            modules.append(tok)
+            set_state(IMPORT_OP)
+    # IMPORT_OP
+    elif (state==IMPORT_OP):
+        if (tok=="."):
+            set_state(IMPORT_APPEND)
+        elif (tok==","):
+            set_state(IMPORT)
+        else:
+            for m in modules:
+                output('#include "'+m.replace('.',os.sep)+'.py"\n', import_spos, immediate=1)
+                if import_token=="from":
+                    output('using namespace '+m.replace('.', '::')+';\n', import_spos)
+            pop_state()
+    # IMPORT_APPEND
+    elif (state==IMPORT_APPEND):
+        if (type==token.NAME):
+            modules[len(modules)-1]+="."+tok
+            set_state(IMPORT_OP)
+    # BUILD_CLASS_DECL
+    elif (state==BUILD_CLASS_DECL):
+        if (is_recording_finished()):
+            s = "class "+name
+            if (param!=""): s = s+" : public "+param.replace('.','::')
+            if (doc_string!=""): comment_block.append(doc_string)
+            print_comment(class_spos)
+            output(s+"\n",class_spos)
+            output("{\n",(class_spos[0]+1,class_spos[1]))
+            protection_level = "public"
+            output("  public:\n",(class_spos[0]+2,class_spos[1]))
+            set_state(BUILD_CLASS_BODY)
+    # BUILD_CLASS_BODY
+    elif (state==BUILD_CLASS_BODY):
+        if (type!=token.INDENT and type!=token.NEWLINE and type!=40 and
+            type!=tokenize.NL and type!=tokenize.COMMENT and
+            (spos[1]<=class_spos[1])):
+            output("}; // end of class\n",(out_row+1,class_spos[1]))
+            pop_state()
+        elif (tok=="def"):
+            start_recording()
+            def_spos = spos
+            push_state(BUILD_DEF_DECL)
+    # BUILD_DEF_DECL
+    elif (state==BUILD_DEF_DECL):
+        if (is_recording_finished()):
+            s = ''
+            # Do we document a class method? then remove the 'self' parameter
+            if BUILD_CLASS_BODY in stateStack:
+                params = param.split(",")
+                if params[0] == 'self':
+                    param = string.join(params[1:], ",")
+                else:
+                    s = 'static '
+                    if params[0] == 'cls':
+                        param = string.join(params[1:], ",")
+               s = s+name+"("+param+");\n"
+                if len(name) > 1 \
+                   and name[0:2] == '__' \
+                   and name[len(name)-2:len(name)] != '__' \
+                   and protection_level != 'private':
+                       private_member = True
+                       output("  private:\n",(def_spos[0]+2,def_spos[1]))
+            else:
+               s = name+"("+param+");\n"
+            if (doc_string!=""): comment_block.append(doc_string)
+            print_comment(def_spos)
+            output(s,def_spos)
+#       output("{\n",(def_spos[0]+1,def_spos[1]))
+            set_state(BUILD_DEF_BODY)
+    # BUILD_DEF_BODY
+    elif (state==BUILD_DEF_BODY):
+        if (type!=token.INDENT and type!=token.NEWLINE \
+            and type!=40 and type!=tokenize.NL \
+            and (spos[1]<=def_spos[1])):
+#            output("} // end of method/function\n",(out_row+1,def_spos[1]))
+            if private_member and protection_level != 'private':
+                private_member = False
+                output("  " + protection_level + ":\n",(def_spos[0]+2,def_spos[1]))
+            pop_state()
+#       else:
+#            output(tok,spos)
+
+
+def dump(filename):
+    f = open(filename)
+    r = f.readlines()
+    for s in r:
+        sys.stdout.write(s)
+
+def filter(filename):
+    global name, module_has_docstring
+    global namespace,outbuffer
+    outbuffer=[]
+
+    path,name = os.path.split(filename)
+    root,ext  = os.path.splitext(name)
+
+
+    if namespace:
+       if root == "__init__":
+          root=namespace
+       else:
+          root=namespace+"::"+root 
+    else:
+       root=root 
+
+    output("namespace "+root+" {\n",(0,0))
+
+    # set module name for tok_eater to use if there's a module doc string
+    package=namespace
+    name = root
+    namespace = root
+
+    sys.stderr.write("namespace: "+namespace+'\n')
+    sys.stderr.write("root: "+root+'\n')
+    sys.stderr.write('Filtering "'+filename+'"...')
+
+    f = open(filename)
+    tokenize.tokenize(f.readline, tok_eater)
+    f.close()
+    print_comment((0,0))
+
+    output("\n",(0,0))
+    output("}  // end of namespace\n",(0,0))
+
+    if not module_has_docstring:
+        # Put in default namespace documentation
+        output('/** \\namespace '+root+' \n',(0,0))
+        output('    \\brief Module "%s" */\n'%(root),(0,0))
+
+    for s in outbuffer:
+        outfile.write(s)
+    namespace=package
+    module_has_docstring = False
+
+
+def filterFile(filename, out=sys.stdout):
+    global outfile
+
+    outfile = out
+
+    try:
+        root,ext  = os.path.splitext(filename)
+
+        if ext==".py":
+            filter(filename)
+        else:
+            dump(filename)
+
+        sys.stderr.write("OK\n")
+    except IOError,e:
+        sys.stderr.write(e[1]+"\n")
+
+
+######################################################################
+
+# preparePath
+def preparePath(path):
+    """Prepare a path.
+
+    Checks if the path exists and creates it if it does not exist.
+    """
+    if not os.path.exists(path):
+        parent = os.path.dirname(path)
+        if parent!="":
+            preparePath(parent)
+        os.mkdir(path)
+
+# isNewer
+def isNewer(file1,file2):
+    """Check if file1 is newer than file2.
+
+    file1 must be an existing file.
+    """
+    if not os.path.exists(file2):
+        return True
+    return os.stat(file1)[ST_MTIME]>os.stat(file2)[ST_MTIME]
+
+# convert
+def convert(srcpath, destpath):
+    """Convert a Python source tree into a C+ stub tree.
+
+    All *.py files in srcpath (including sub-directories) are filtered
+    and written to destpath. If destpath exists, only the files
+    that have been modified are filtered again. Files that were deleted
+    from srcpath are also deleted in destpath if they are still present.
+    The function returns the number of processed *.py files.
+    """
+    global namespace
+    count=0
+    l=os.listdir(srcpath)
+    if "__init__.py" in l:
+       if namespace:
+         namespace=namespace+"::"+os.path.split(srcpath)[1]
+       else:
+         namespace=os.path.split(srcpath)[1]
+       print "It's a package:",namespace
+    sp = os.path.join(srcpath,"*")
+    sfiles = glob.glob(sp)
+    dp = os.path.join(destpath,"*")
+    dfiles = glob.glob(dp)
+    leftovers={}
+    for df in dfiles:
+        leftovers[os.path.basename(df)]=1
+
+    for srcfile in sfiles:
+        basename = os.path.basename(srcfile)
+        if basename in leftovers:
+            del leftovers[basename]
+
+        # Is it a subdirectory?
+        if os.path.isdir(srcfile):
+            package=namespace
+            sdir = os.path.join(srcpath,basename)
+            ddir = os.path.join(destpath,basename)
+            count+=convert(sdir, ddir)
+            namespace=package
+            continue
+        # Check the extension (only *.py will be converted)
+        root, ext = os.path.splitext(srcfile)
+        if ext.lower()!=".py":
+            continue
+
+        destfile = os.path.join(destpath,basename)
+        if destfile==srcfile:
+            print "WARNING: Input and output names are identical!"
+            sys.exit(1)
+
+        count+=1
+#        sys.stdout.write("%s\015"%(srcfile))
+
+        if isNewer(srcfile, destfile):
+            preparePath(os.path.dirname(destfile))
+            out=open(destfile,"w")
+            filterFile(srcfile, out)
+            out.close()
+#            os.system("python %s -f %s>%s"%(sys.argv[0],srcfile,destfile))
+
+    # Delete obsolete files in destpath
+    for df in leftovers:
+        dname=os.path.join(destpath,df)
+        if os.path.isdir(dname):
+            try:
+                shutil.rmtree(dname)
+            except:
+                print "Can't remove obsolete directory '%s'"%dname
+        else:
+            try:
+                os.remove(dname)
+            except:
+                print "Can't remove obsolete file '%s'"%dname
+
+    return count
+
+
+######################################################################
+######################################################################
+######################################################################
+
+filter_file = False
+
+try:
+    opts, args = getopt.getopt(sys.argv[1:], "hf", ["help"])
+except getopt.GetoptError,e:
+    print e
+    sys.exit(1)
+
+for o,a in opts:
+    if o=="-f":
+        filter_file = True
+
+if filter_file:
+    # Filter the specified file and print the result to stdout
+    filename = string.join(args)
+    filterFile(filename)
+else:
+
+    if len(args)!=2:
+        sys.stderr.write("%s options input output\n"%(os.path.basename(sys.argv[0])))
+        sys.exit(1)
+
+    # Filter an entire Python source tree
+    print '"%s" -> "%s"\n'%(args[0],args[1])
+    c=convert(args[0],args[1])
+    print "%d files"%(c)
index 1bac5ce711c059ce661c9424de8e64f6278864bd..6ff8899094aa108462d5814e800e91796d8d3cf0 100644 (file)
@@ -169,9 +169,11 @@ This struct contains GUI elements used for representation of the module in %IAPP
 */
   struct IAPP_Affich
   {
-    string modulename; /*!<Name of the module.*/
+    string modulename;     /*!<Name of the module.*/
     string moduleusername; /*!<UserName of the module.*/
-    string moduleicone; /*!<Icone representing the module.*/
+    string moduleicone;    /*!<Icone representing the module.*/
+    string moduleversion;  /*!<Version of the module.*/
+    string modulecomment;  /*!<Comment to the module.*/
   };
 /*!
 List of pair GUI elements (component name, component icone)
index ca47f23d9da2532f8aa3c385cf20e820ec7a2e30..e36089f5e2493ec8ea9ac850cd2cfcdcaca35441 100644 (file)
@@ -210,9 +210,29 @@ Engines::Container_ptr Engines_Container_i::start_impl(
     shstr += " " ;
     shstr += _argv[ 3 ] ;
   }
-  shstr += " > /tmp/" ;
-  shstr += ContainerName ;
-  shstr += ".log 2>&1 &" ;
+
+  // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir. 
+  // "/tmp/logs/$USER" was created by  runSalome.py -> orbmodule.py.
+  string tempfilename = "/tmp/logs/";
+  tempfilename += getenv( "USER" ) ;
+  tempfilename += "/" ;
+  tempfilename += ContainerName ;
+  tempfilename += ".log" ;
+  FILE* f = fopen ( tempfilename.c_str(), "a" );
+  if ( f ) { // check if file can be opened for writing
+    fclose( f );
+    shstr += " > " ;
+    shstr += tempfilename;
+    shstr += " 2>&1 &" ;
+  }
+  else { // if file can't be opened - use a guaranteed temp file name
+    char* tmpFileName = tempnam( NULL, ContainerName );
+    shstr += " > ";
+    shstr += tmpFileName;
+    shstr += " 2>&1 &";
+    free( tmpFileName );    
+  }
+
   MESSAGE("system(" << shstr << ")") ;
   int status = system( shstr.c_str() ) ;
   if (status == -1) {
@@ -448,7 +468,7 @@ void SigIntHandler(int what , siginfo_t * siginfo ,
 
 // Get the PID of the Container
 
-CORBA::Long Engines_Container_i::getPID() {
+long Engines_Container_i::getPID() {
     return (long)getpid();
 }
 
index c62f6a18f02fc830c0f7b8900de1fce50b42b13f..bdefea71b9a50c720da4b8d03865405accc0079b 100644 (file)
@@ -24,6 +24,9 @@
 //  File   : HDFexception.hxx
 //  Module : SALOME
 
+#ifndef __HDFexception_H__
+#define __HDFexception_H__
+
 /* Exception */
 #include <iostream>
 
@@ -35,3 +38,5 @@ public :
     std::cerr << message << std::endl;
   }
 };
+
+#endif
index 4456b95ed10b6a19c2bda376085e455542dd948b..cc69f08688763a7010c3f5ea43a2b5d625c15280 100644 (file)
 #include "InquireServersQThread.h"
 using namespace std;
 
+void MessageOutput( QtMsgType type, const char *msg )
+{
+  switch ( type ) {
+  case QtDebugMsg:
+    MESSAGE( "Debug: " << msg );
+    break;
+  case QtWarningMsg:
+    MESSAGE( "Warning: " << msg );
+    break;
+  case QtFatalMsg:
+    MESSAGE( "Fatal: " << msg );
+    break;
+  }
+}
+
 int main(int argc, char **argv)
 {
   CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv) ;
   SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
+  qInstallMsgHandler( MessageOutput );
 //VRV: T2.4 - Trace management improvement
   QApplication myQApp(argc, argv) ;
   InquireServersGUI myIS;
@@ -46,7 +62,7 @@ int main(int argc, char **argv)
 //VRV: T2.4 - Trace management improvement
   if (myIS.withGUI()) {
     try
-      {        
+      {
        SALOME_NamingService &NS = *SINGLETON_<SALOME_NamingService>::Instance() ;
        ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting()) ;
        NS.init_orb( orb ) ;
@@ -86,6 +102,7 @@ int main(int argc, char **argv)
       {
        INFOS("Caught unknown exception.");
       }
+    return 0 ;
   }
   INFOS("Normal Exit"); // without this trace, Splash remains on screen !
   delete myThreadTrace;
index 0a8f27f4e3d7acb9991bfb1bddb358ba5cf996e3..d698f6459d8033555bc695ea4c103e726cbd4175 100644 (file)
@@ -61,6 +61,8 @@ SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler()
   test_component_multistudy = "component-multistudy";
   test_component_icon       = "component-icone" ;
   test_component_impltype   = "component-impltype";
+  test_component_version    = "component-version";
+  test_component_comment    = "component-comment";
 
   test_interface_name       = "component-interface-name" ;
   
@@ -256,6 +258,18 @@ bool SALOME_ModuleCatalog_Handler::endElement(const QString&,
      return true;
    }
 
+  // tag test_component_version
+   if((qName.compare(test_component_version)==0)) {
+     _aModule.version = content ;
+     return true;
+   }
+
+  // tag test_component_comment
+   if((qName.compare(test_component_comment)==0)) {
+     _aModule.comment = content ;
+     return true;
+   }
+
    // interface identification
 
    // tag test_interface_name
index 775966ae7b59f4969f2027c5422434b4cc938302..43701c9832ae8484f1da24c37aaef75e6ca73d7e 100644 (file)
@@ -116,6 +116,8 @@ private:
   QString test_component_multistudy ;
   QString test_component_icon ;
   QString test_component_impltype;
+  QString test_component_version;
+  QString test_component_comment;
 
   QString test_interface_name;
 
index 2fac493679dcc5b1a7d9a8ec893e2877fad6af58..c23dde27ef3b3a9e7ba92bc500217f3cfceef159 100644 (file)
@@ -96,6 +96,8 @@ struct ParserComponent
   ParserInterfaces    interfaces;
   ParserPathPrefixes  prefixes;
   bool                implementationType;
+  std::string         version;
+  std::string         comment;
 };
 
 typedef std::vector<ParserComponent> ParserComponents ;
index 7018c1cacb2a7a5a04bc093864c428796133113d..845e341dcda6f62634e35b2b1331cb52710ff745 100644 (file)
@@ -301,6 +301,8 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList()
     _list_components_icone[ind].modulename=(_personal_module_list[ind].name).c_str();
     _list_components_icone[ind].moduleusername=(_personal_module_list[ind].username).c_str();
     _list_components_icone[ind].moduleicone=(_personal_module_list[ind].icon).c_str();
+    _list_components_icone[ind].moduleversion=(_personal_module_list[ind].version).c_str();
+    _list_components_icone[ind].modulecomment=(_personal_module_list[ind].comment).c_str();
     //if(MYDEBUG) SCRUTE(_list_components_icone[ind].modulename); 
     //if(MYDEBUG) SCRUTE(_list_components_icone[ind].moduleicone);
   }
@@ -325,6 +327,8 @@ SALOME_ModuleCatalogImpl::GetComponentIconeList()
       _list_components_icone[indice].modulename=_general_module_list[ind].name.c_str();  
       _list_components_icone[indice].moduleusername=_general_module_list[ind].username.c_str();  
       _list_components_icone[indice].moduleicone=_general_module_list[ind].icon.c_str(); 
+      _list_components_icone[indice].moduleversion=_general_module_list[ind].version.c_str();
+      _list_components_icone[indice].modulecomment=_general_module_list[ind].comment.c_str();
       //if(MYDEBUG) SCRUTE(_list_components_icone[indice].modulename) ;
       //if(MYDEBUG) SCRUTE(_list_components_icone[indice].moduleicone);
       
index b2040b2a3ef5f4c16fbdd48edffb0bdd307f0278..4b0b088e8d4753486b90dd04fbb7250d2880bf74 100644 (file)
 
 using namespace std;
 
-#if defined __GNUC__
-  #if __GNUC__ == 2
-    #define __GNUC_2__
-  #endif
-#endif
-
 int SALOME_POINT_SIZE = 3;
 
 
@@ -65,7 +59,7 @@ vtkStandardNewMacro(SALOME_Actor);
 SALOME_Actor::SALOME_Actor(){
   myIsHighlighted = myIsPreselected = false;
 
-  myRepresentation = 1;
+  myRepresentation = VTK_WIREFRAME;
   myDisplayMode = myRepresentation - 1;
 
   myProperty = vtkProperty::New();
index caa2d2f2761a0567109e04db53bf57bcba097254..90645fdb2256e293b762c5a2810737ff2e8ed581 100644 (file)
@@ -1135,3 +1135,94 @@ void OCCViewer_ViewFrame::AfterDisplay( SALOME_Displayer* d )
   d->AfterDisplay( this, SALOME_OCCViewType() );
 }
 
+#define INCREMENT_FOR_OP 10
+
+//=======================================================================
+// name    : onPanLeft
+// Purpose : Performs incremental panning to the left
+//=======================================================================
+void OCCViewer_ViewFrame::onPanLeft()
+{
+  myViewPort->incrementalPan( -INCREMENT_FOR_OP, 0 );
+}
+
+//=======================================================================
+// name    : onPanRight
+// Purpose : Performs incremental panning to the right
+//=======================================================================
+void OCCViewer_ViewFrame::onPanRight()
+{
+  myViewPort->incrementalPan( INCREMENT_FOR_OP, 0 );
+}
+
+//=======================================================================
+// name    : onPanUp
+// Purpose : Performs incremental panning to the top
+//=======================================================================
+void OCCViewer_ViewFrame::onPanUp()
+{
+  myViewPort->incrementalPan( 0, INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onPanDown
+// Purpose : Performs incremental panning to the bottom
+//=======================================================================
+void OCCViewer_ViewFrame::onPanDown()
+{
+  myViewPort->incrementalPan( 0, -INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onZoomIn
+// Purpose : Performs incremental zooming in
+//=======================================================================
+void OCCViewer_ViewFrame::onZoomIn()
+{
+  myViewPort->incrementalZoom( INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onZoomOut
+// Purpose : Performs incremental zooming out
+//=======================================================================
+void OCCViewer_ViewFrame::onZoomOut()
+{
+  myViewPort->incrementalZoom( -INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onRotateLeft
+// Purpose : Performs incremental rotating to the left
+//=======================================================================
+void OCCViewer_ViewFrame::onRotateLeft()
+{
+  myViewPort->incrementalRotate( -INCREMENT_FOR_OP, 0 );
+}
+
+//=======================================================================
+// name    : onRotateRight
+// Purpose : Performs incremental rotating to the right
+//=======================================================================
+void OCCViewer_ViewFrame::onRotateRight()
+{
+  myViewPort->incrementalRotate( INCREMENT_FOR_OP, 0 );
+}
+
+//=======================================================================
+// name    : onRotateUp
+// Purpose : Performs incremental rotating to the top
+//=======================================================================
+void OCCViewer_ViewFrame::onRotateUp()
+{
+  myViewPort->incrementalRotate( 0, -INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onRotateDown
+// Purpose : Performs incremental rotating to the bottom
+//=======================================================================
+void OCCViewer_ViewFrame::onRotateDown()
+{
+  myViewPort->incrementalRotate( 0, INCREMENT_FOR_OP );
+}
index 42b3c0685ff07ace1318b84245de1abd2593d975..9f6b4a55dce51baa622bbcc5359a21b4d7665bcc 100644 (file)
@@ -153,6 +153,17 @@ public slots:
   void                        onViewTrihedron();
   void                        onAdjustTrihedron();
 
+  void                        onPanLeft();
+  void                        onPanRight();
+  void                        onPanUp();
+  void                        onPanDown();
+  void                        onZoomIn();
+  void                        onZoomOut();
+  void                        onRotateLeft();
+  void                        onRotateRight();
+  void                        onRotateUp();
+  void                        onRotateDown();
+
 protected:
 
   void                        initViewPort();
index 7b7a6552c8147ec079ed9fd45f9e25ba50cefe44..6f80c7816025573f780a351ea09be051a94b9589 100644 (file)
@@ -129,7 +129,12 @@ public:
   
   virtual void   fitAll( bool withZ = true ) = 0;
   virtual void   reset() = 0;
-  
+
+  virtual void    incrementalPan   ( const int incrX, const int incrY ) = 0;
+  virtual void    incrementalZoom  ( const int incr ) = 0;
+  virtual void    incrementalRotate( const int incrX, const int incrY ) = 0;
+
+  /* background color */
   virtual QColor  backgroundColor() const;
   virtual void    setBackgroundColor( const QColor& color) = 0;
 
index 68a73d4a5b47cde0a8660cbb9e84de4349643bb7..0ace89025e595e3354be5a7024d17fe80f65a3fc 100644 (file)
@@ -84,7 +84,6 @@ void OCCViewer_ViewPort3d::onCreatePopup()
 {
   if ( myPopup ) {     
     QAD_Desktop*     Desktop = (QAD_Desktop*) QAD_Application::getDesktop();
-    QAD_Study*   myActiveStudy = Desktop->getActiveStudy();
     
     QString theContext;
     QString theParent("Viewer");
@@ -385,3 +384,35 @@ void OCCViewer_ViewPort3d::reset()
       myActiveView->Reset();
     }
 }
+
+/*!
+  Incremental panning
+*/
+void OCCViewer_ViewPort3d::incrementalPan( const int incrX, const int incrY )
+{
+  this->pan( incrX, incrY );
+}
+
+/*!
+  Incremental zooming
+*/
+void OCCViewer_ViewPort3d::incrementalZoom( const int incr )
+{
+  int cx = width()  / 2;
+  int cy = height() / 2;
+  this->zoom( cx, cy, cx + incr, cy + incr );
+}
+
+/*!
+  Incremental rotating
+*/
+void OCCViewer_ViewPort3d::incrementalRotate( const int incrX, const int incrY )
+{
+  int cx = width()  / 2;
+  int cy = height() / 2;
+  this->startRotation( cx, cy );
+  this->rotate( cx + incrX, cy + incrY );
+  this->endRotation();
+}
+
+
index 446cb65cad2dfa0e5117b8381cd38b57d921f0f1..e36ca9de2a62a31e9544fd3363af0b842bf15216 100644 (file)
@@ -71,6 +71,10 @@ class QAD_EXPORT OCCViewer_ViewPort3d: public OCCViewer_ViewPort
   void                   fitAll( bool withZ = true );
   void                   reset();
 
+  void                    incrementalPan   ( const int incrX, const int incrY );
+  void                    incrementalZoom  ( const int incr );
+  void                    incrementalRotate( const int incrX, const int incrY );
+
   /* background */
   void                   setBackgroundColor( const QColor& color);     
   QColor                 backgroundColor() const;
index 49f5cbdd347110ef3cfc45ad419fe947f644a2f8..cde7a39613c5c7df7f04684a70a18f7b4cf821ad 100644 (file)
@@ -387,6 +387,21 @@ void Plot2d_ViewFrame::Erase( const Handle(SALOME_InteractiveObject)& IObject, b
   Plot2d_Curve* curve = getCurveByIO( IObject );
   if ( curve )
     eraseCurve( curve, update );
+  // it can be table or container object selected
+  QAD_Study* activeStudy = QAD_Application::getDesktop()->getActiveStudy();
+  SALOMEDS::SObject_var aSO = activeStudy->getStudyDocument()->FindObjectID(IObject->getEntry());
+  if ( !aSO->_is_nil() ) {
+    SALOMEDS::ChildIterator_var aIter = activeStudy->getStudyDocument()->NewChildIterator( aSO );
+    for ( ; aIter->More(); aIter->Next() ) {
+      SALOMEDS::SObject_var aChildSO = aIter->Value();
+      SALOMEDS::SObject_var refSO;
+      if ( aChildSO->ReferencedObject( refSO ) && !refSO->_is_nil() )
+       aChildSO = refSO;
+      curve = getCurveByIO( new SALOME_InteractiveObject( aChildSO->GetID(), "", "" ) );
+      if ( curve )
+       eraseCurve( curve, update );
+    }
+  }
 }
 /*!
   Actually this method just re-displays all curves which are presented in the viewer
@@ -397,7 +412,7 @@ void Plot2d_ViewFrame::DisplayAll()
   getCurves( clist );
   for ( int i = 0; i < clist.count(); i++ ) {
     updateCurve( clist.at( i ), false );
-  }
+   }
   myPlot->replot();
 }
 /*!
@@ -1432,29 +1447,11 @@ void Plot2d_ViewFrame::plotMouseMoved( const QMouseEvent& me )
 
   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();
+      this->incrementalZoom( dx, dy ); 
       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();
+      this->incrementalPan( dx, dy );
       myPnt = me.pos();
     }
   }
@@ -1795,3 +1792,94 @@ void  Plot2d_ViewFrame::AfterDisplay( SALOME_Displayer* d )
 {
   d->AfterDisplay( this, SALOME_Plot2dViewType() );
 }
+
+#define INCREMENT_FOR_OP 10
+
+//=======================================================================
+// Plot2d_ViewFrame::onPanLeft
+// Performs incremental panning to the left
+//=======================================================================
+void Plot2d_ViewFrame::onPanLeft()
+{
+  this->incrementalPan( -INCREMENT_FOR_OP, 0 );
+}
+
+//=======================================================================
+// Plot2d_ViewFrame::onPanRight
+// Performs incremental panning to the right
+//=======================================================================
+void Plot2d_ViewFrame::onPanRight()
+{
+  this->incrementalPan( INCREMENT_FOR_OP, 0 );
+}
+
+//=======================================================================
+// Plot2d_ViewFrame::onPanUp
+// Performs incremental panning to the top
+//=======================================================================
+void Plot2d_ViewFrame::onPanUp()
+{
+  this->incrementalPan( 0, -INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// Plot2d_ViewFrame::onPanDown
+// Performs incremental panning to the bottom
+//=======================================================================
+void Plot2d_ViewFrame::onPanDown()
+{
+  this->incrementalPan( 0, INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// Plot2d_ViewFrame::onZoomIn
+// Performs incremental zooming in
+//=======================================================================
+void Plot2d_ViewFrame::onZoomIn()
+{
+  this->incrementalZoom( INCREMENT_FOR_OP, INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// Plot2d_ViewFrame::onZoomOut
+// Performs incremental zooming out
+//=======================================================================
+void Plot2d_ViewFrame::onZoomOut()
+{
+  this->incrementalZoom( -INCREMENT_FOR_OP, -INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// Plot2d_ViewFrame::incrementalPan
+// Incremental zooming operation
+//=======================================================================
+void Plot2d_ViewFrame::incrementalPan( const int incrX, const int incrY ) {
+  QwtDiMap xMap = myPlot->canvasMap( QwtPlot::xBottom );
+  QwtDiMap yMap = myPlot->canvasMap( QwtPlot::yLeft );
+  
+  myPlot->setAxisScale( QwtPlot::yLeft,
+                       myPlot->invTransform( QwtPlot::yLeft, yMap.i1()-incrY ),
+                       myPlot->invTransform( QwtPlot::yLeft, yMap.i2()-incrY ) );
+  myPlot->setAxisScale( QwtPlot::xBottom,
+                       myPlot->invTransform( QwtPlot::xBottom, xMap.i1()-incrX ),
+                       myPlot->invTransform( QwtPlot::xBottom, xMap.i2()-incrX ) );
+  myPlot->replot();
+}
+
+//=======================================================================
+// Plot2d_ViewFrame::incrementalZoom
+// Incremental panning operation
+//=======================================================================
+void Plot2d_ViewFrame::incrementalZoom( const int incrX, const int incrY ) {
+  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() + incrY ) );
+  myPlot->setAxisScale( QwtPlot::xBottom,
+                      myPlot->invTransform( QwtPlot::xBottom, xMap.i1() ),
+                      myPlot->invTransform( QwtPlot::xBottom, xMap.i2() - incrX ) );
+  myPlot->replot();
+}
+
index 04c87155c3e41817d99b090d64ea509c8b122532..275c432fb843a4d25e7c4c9613ca3fee3ae5b926 100644 (file)
@@ -124,6 +124,9 @@ public:
   void    setVerScaleMode( const int mode, bool update = true );
   int     getVerScaleMode() const { return myYMode; }
 
+  void    incrementalPan ( const int incrX, const int incrY );
+  void    incrementalZoom( const int incrX, const int incrY );
+
 protected:
   void    createActions();
   int     testOperation( const QMouseEvent& );
@@ -155,6 +158,13 @@ public slots:
   void    onFitData();
   void    onChangeBackground();
 
+  void    onPanLeft();
+  void    onPanRight();
+  void    onPanUp();
+  void    onPanDown();
+  void    onZoomIn();
+  void    onZoomOut();
+
 protected slots:
   void    onLegendClicked( long key );
   void    plotMousePressed( const QMouseEvent& );
index 6563d8fd4a709c47e48228229e14e66e094b4ab0..d84186658944e0d699ac14a1d514aeddd029982e 100644 (file)
 //  Module : SALOME
 //  $Header$
 
+#include <TCollection_ExtendedString.hxx>
+#include <TCollection_AsciiString.hxx>
+
 #include "SALOMEDS_AttributeComment_i.hxx"
 
-#include <TCollection_ExtendedString.hxx>
-#include "SALOMEDS_SObject_i.hxx"
 using namespace std;
 
 char* SALOMEDS_AttributeComment_i::Value()
index 0171acb756522c6829a8b0a573824cd41a9bf527..762a96fe99f3c4b911838c69126155f419f30cb8 100644 (file)
 #ifndef SALOMEDS_AttributeComment_i_HeaderFile
 #define SALOMEDS_AttributeComment_i_HeaderFile
 
-// IDL headers
 #include <TDataStd_Comment.hxx>
+
+#include "SALOMEDS_GenericAttribute_i.hxx"
+
+// IDL headers
 #include <SALOMEconfig.h>
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeComment,TDataStd_Comment,true);
 
+class SALOMEDS_AttributeComment_i: 
+  public virtual POA_SALOMEDS::AttributeComment,
+  public virtual SALOMEDS_TAttributeComment_i
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeComment,TDataStd_Comment);
+public:
   char* Value();
-  void SetValue(const char* value);
-
+  void SetValue(const char* theValue);
+  
   char* Store();
   void Restore(const char*);
-
 };
 
 
-
 #endif
index dc23dcd37c96b7cd70fffe03a4b96d14d2c7fd06..26f6578210ba9c5434ab9176e3035f04fba0191a 100644 (file)
@@ -27,7 +27,7 @@
 //  $Header$
 
 #include "SALOMEDS_AttributeDrawable_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
+
 using namespace std;
 
 CORBA::Boolean SALOMEDS_AttributeDrawable_i::IsDrawable() {
index 6f41440e53fa371d85d08ee5f8070a9c3db4f4f0..7fb12ac348736f6a3e68666ecbf432c28eccd71b 100644 (file)
 #ifndef SALOMEDS_AttributeDrawable_i_HeaderFile
 #define SALOMEDS_AttributeDrawable_i_HeaderFile
 
-// IDL headers
-
 #include "SALOMEDS_DrawableAttribute.hxx"
+#include "SALOMEDS_GenericAttribute_i.hxx"
+
+// IDL headers
 #include <SALOMEconfig.h>
 #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 {
+DEFINE_DERIVED_ATTR(AttributeDrawable,SALOMEDS_DrawableAttribute,false);
+
+class SALOMEDS_AttributeDrawable_i: 
+  public virtual POA_SALOMEDS::AttributeDrawable,
+  public virtual SALOMEDS_TAttributeDrawable_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeDrawable,SALOMEDS_DrawableAttribute);
 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);
 
@@ -55,5 +53,4 @@ public:
 };
 
 
-
 #endif
index ddff1d495507d41b6a48e9826470dfd599d178bb..70601d33fea9e5ce0e955f18cb71e163fa05211c 100644 (file)
@@ -27,7 +27,7 @@
 //  $Header$
 
 #include "SALOMEDS_AttributeExpandable_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
+
 using namespace std;
 
 CORBA::Boolean SALOMEDS_AttributeExpandable_i::IsExpandable() {
index 0c18dd2eb19160852339d3fb67adcb8ab7f51148..a8c57c00eec55a3b9d44da37b87143f09c96f713 100644 (file)
 #define SALOMEDS_AttributeExpandable_i_HeaderFile
 
 // IDL headers
-
-#include "SALOMEDS_ExpandableAttribute.hxx"
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "SALOMEDS_ExpandableAttribute.hxx"
 #include "SALOMEDS_GenericAttribute_i.hxx"
 
-class SALOMEDS_AttributeExpandable_i: public virtual POA_SALOMEDS::AttributeExpandable,
-  public virtual SALOMEDS_GenericAttribute_i {
+DEFINE_DERIVED_ATTR(AttributeExpandable,SALOMEDS_ExpandableAttribute,false);
+
+class SALOMEDS_AttributeExpandable_i: 
+  public virtual POA_SALOMEDS::AttributeExpandable,
+  public virtual SALOMEDS_TAttributeExpandable_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeExpandable,SALOMEDS_ExpandableAttribute);
 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);
 
index a6c424c1744ea4179ab841fc5163ab2ead9072f5..9c60c8886ce335271ab5ffc140163c951af389a5 100644 (file)
@@ -29,7 +29,8 @@
 #include "SALOMEDS_AttributeExternalFileDef_i.hxx"
 
 #include <TCollection_ExtendedString.hxx>
-#include "SALOMEDS_SObject_i.hxx"
+#include <TCollection_AsciiString.hxx>
+
 using namespace std;
 
 char* SALOMEDS_AttributeExternalFileDef_i::Value()
index b6d5244a7242bdc85caa825225796d046467fd23..12b2033565a3a4abbbbb7d810b2ad93989c99b3c 100644 (file)
 // IDL headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
 #include "SALOMEDS_GenericAttribute_i.hxx"
 #include "SALOMEDS_ExternalFileDef.hxx"
 
-class SALOMEDS_AttributeExternalFileDef_i: public virtual POA_SALOMEDS::AttributeExternalFileDef,
-                                  public virtual SALOMEDS_GenericAttribute_i {
-public:
-  
-  SALOMEDS_AttributeExternalFileDef_i(const Handle(SALOMEDS_ExternalFileDef)& theCommentAttr, CORBA::ORB_ptr orb) 
-  {
-    _myOrb = CORBA::ORB::_duplicate(orb);
-    _myAttr = theCommentAttr;
-  }
-  ~SALOMEDS_AttributeExternalFileDef_i() {};
+DEFINE_DERIVED_ATTR(AttributeExternalFileDef,SALOMEDS_ExternalFileDef,false);
 
+class SALOMEDS_AttributeExternalFileDef_i: 
+  public virtual POA_SALOMEDS::AttributeExternalFileDef,
+  public virtual SALOMEDS_TAttributeExternalFileDef_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeExternalFileDef,SALOMEDS_ExternalFileDef);
+public:
   char* Value();
   void SetValue(const char* value);
   
index 9411fbb676e1f73973cf6f042619b96c9e0ae2bc..b6237f309617c92fba7195deed44f40dd1689ff3 100644 (file)
@@ -27,9 +27,9 @@
 //  $Header$
 
 #include "SALOMEDS_AttributeFileType_i.hxx"
-
 #include <TCollection_ExtendedString.hxx>
-#include "SALOMEDS_SObject_i.hxx"
+#include <TCollection_AsciiString.hxx>
+
 using namespace std;
 
 char* SALOMEDS_AttributeFileType_i::Value()
index 324c5cb9a51610bb7650cfddb636dc412aa9e862..e31e23b2ee27a7a0eb05e47be1836ddc843b8d0f 100644 (file)
 #ifndef SALOMEDS_AttributeFileType_i_HeaderFile
 #define SALOMEDS_AttributeFileType_i_HeaderFile
 
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDS_FileType.hxx"
+
 // IDL headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
-#include "SALOMEDS_GenericAttribute_i.hxx"
-#include "SALOMEDS_FileType.hxx"
 
-class SALOMEDS_AttributeFileType_i: public virtual POA_SALOMEDS::AttributeFileType,
-                                  public virtual SALOMEDS_GenericAttribute_i {
-public:
-  
-  SALOMEDS_AttributeFileType_i(const Handle(SALOMEDS_FileType)& theCommentAttr, CORBA::ORB_ptr orb) 
-  {
-    _myOrb = CORBA::ORB::_duplicate(orb);
-    _myAttr = theCommentAttr;
-  }
-  ~SALOMEDS_AttributeFileType_i() {};
+DEFINE_DERIVED_ATTR(AttributeFileType,SALOMEDS_FileType,true);
 
+class SALOMEDS_AttributeFileType_i: 
+  public virtual POA_SALOMEDS::AttributeFileType,
+  public virtual SALOMEDS_TAttributeFileType_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeFileType,SALOMEDS_FileType);
+public:
   char* Value();
   void SetValue(const char* value);
   
index d8eee23cbe58fd6aa7a8ac77e9c124d2b821062d..43f2fd9473d81d64721e6448a6e0c8b4386cb7d2 100644 (file)
 //  $Header$
 
 #include "SALOMEDS_AttributeFlags_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
 
 using namespace std;
 
-/*
-  Class       : SALOMEDS_AttributeFlags_i
-  Description : This class is intended for storing different object attributes that
-                have only two states (0 and 1).
-                
-                Avalable attributes:
-                
-                IS_VISIBLE - is equal to 1 if object is visible in 3D view (0 - overwise).
-                             This attribute is valid for active view only.
-*/
-
-//=======================================================================
-// function : SALOMEDS_AttributeFlags_i::SALOMEDS_AttributeFlags_i
-// purpose  : Constructor
-//=======================================================================
-SALOMEDS_AttributeFlags_i::SALOMEDS_AttributeFlags_i(
-  const Handle(SALOMEDS_FlagsAttribute)& attr, CORBA::ORB_ptr orb )
-{
-  _myOrb = CORBA::ORB::_duplicate( orb );
-  _myAttr = attr;
-}
-
-//=======================================================================
-// function : SALOMEDS_AttributeFlags_i::~SALOMEDS_AttributeFlags_i
-// purpose  : Destructor
-//=======================================================================
-SALOMEDS_AttributeFlags_i::~SALOMEDS_AttributeFlags_i()
-{
-}
-
 //=======================================================================
 // function : SALOMEDS_AttributeFlags_i::GetFlags
 // purpose  : Get all flags as integer value
index 6a02145458aa5f059460bc44bcaf92fb2d495eaf..228654562aaf5d0fb29679c732cae5c24ab09d7f 100644 (file)
 #define SALOMEDS_AttributeFlags_i_HeaderFile
 
 // IDL headers
-
-#include "SALOMEDS_FlagsAttribute.hxx"
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "SALOMEDS_FlagsAttribute.hxx"
 #include "SALOMEDS_GenericAttribute_i.hxx"
 
 /*
                              This attribute is valid for active view only.
 */
 
-class SALOMEDS_AttributeFlags_i: public virtual POA_SALOMEDS::AttributeFlags,
-                                 public virtual SALOMEDS_GenericAttribute_i
+DEFINE_DERIVED_ATTR(AttributeFlags,SALOMEDS_FlagsAttribute,true);
+
+class SALOMEDS_AttributeFlags_i: 
+  public virtual POA_SALOMEDS::AttributeFlags,
+  public virtual SALOMEDS_TAttributeFlags_i
 {
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeFlags,SALOMEDS_FlagsAttribute);
 public:
-  
-                      SALOMEDS_AttributeFlags_i( const Handle(SALOMEDS_FlagsAttribute)&,
-                                                 CORBA::ORB_ptr orb );
-  virtual             ~SALOMEDS_AttributeFlags_i();
 
   CORBA::Long         GetFlags();
   void                SetFlags( CORBA::Long theFlags );
index 3ac440514862fbf9b4d83908dfec2c7ccf2afbf3..7865b25019a687fe1df5058f40a6bacecfd3388c 100644 (file)
 //  $Header$
 
 #include "SALOMEDS_AttributeGraphic_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
 
 using namespace std;
 
-/*
-  Class       : SALOMEDS_AttributeGraphic_i
-  Description : This class is intended for storing information about
-                graphic representation of objects in dirrent views
-*/
-
-//=======================================================================
-// function : SALOMEDS_AttributeGraphic_i::SALOMEDS_AttributeGraphic_i
-// purpose  : Constructor
-//=======================================================================
-SALOMEDS_AttributeGraphic_i::SALOMEDS_AttributeGraphic_i(
-  const Handle(SALOMEDS_GraphicAttribute)& attr, CORBA::ORB_ptr orb )
-{
-  _myOrb = CORBA::ORB::_duplicate( orb );
-  _myAttr = attr;
-}
-
-//=======================================================================
-// function : SALOMEDS_AttributeGraphic_i::~SALOMEDS_AttributeGraphic_i
-// purpose  : Destructor
-//=======================================================================
-SALOMEDS_AttributeGraphic_i::~SALOMEDS_AttributeGraphic_i()
-{
-}
-
 //=======================================================================
 // function : SALOMEDS_AttributeGraphic_i::~SetVisibility
 // purpose  : Set visibility of object in given view
index 70644c6097faa3fad87bef7f8f00a547fc3b1098..718b2861987224c02347ea8549f419cde2c61eae 100644 (file)
 #define SALOMEDS_AttributeGraphic_i_HeaderFile
 
 // IDL headers
-
-#include "SALOMEDS_GraphicAttribute.hxx"
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "SALOMEDS_GraphicAttribute.hxx"
 #include "SALOMEDS_GenericAttribute_i.hxx"
 
 /*
                 graphic representation of objects in dirrent views
 */
 
-class SALOMEDS_AttributeGraphic_i: public virtual POA_SALOMEDS::AttributeGraphic,
-                                   public virtual SALOMEDS_GenericAttribute_i
+DEFINE_DERIVED_ATTR(AttributeGraphic,SALOMEDS_GraphicAttribute,true);
+
+class SALOMEDS_AttributeGraphic_i: 
+  public virtual POA_SALOMEDS::AttributeGraphic,
+  public virtual SALOMEDS_TAttributeGraphic_i
 {
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeGraphic,SALOMEDS_GraphicAttribute);
 public:
-  
-                      SALOMEDS_AttributeGraphic_i( const Handle(SALOMEDS_GraphicAttribute)&,
-                                                   CORBA::ORB_ptr orb );
-  virtual             ~SALOMEDS_AttributeGraphic_i();
 
   void                SetVisibility( CORBA::Long    theViewId,
                                      CORBA::Boolean theValue );
   CORBA::Boolean      GetVisibility( CORBA::Long    theViewId );
-
 };
 
 #endif
index 6cf5e337466fdc06114075e97d59cbedd74f141e..be6969df4bb3d35f32bbd27204d8984f8ea945ac 100644 (file)
 
 #include "SALOMEDS_AttributeIOR_i.hxx"
 
-
 #include <TCollection_ExtendedString.hxx>
 #include "SALOMEDS_SObject_i.hxx"
 #include "SALOMEDS_Study_i.hxx"
+
 using namespace std;
 
 char* SALOMEDS_AttributeIOR_i::Value()
@@ -44,12 +44,13 @@ char* SALOMEDS_AttributeIOR_i::Value()
 void SALOMEDS_AttributeIOR_i::SetValue(const char* value) 
 {
   CheckLocked();
+  const CORBA::ORB_var& anORB = _mySObject->GetORB();
 
-  SALOMEDS::Study_var aStudy = SALOMEDS_Study_i::GetStudy(_myAttr->Label(), _myOrb);
+  SALOMEDS::Study_var aStudy = SALOMEDS_Study_i::GetStudy(_myAttr->Label(),anORB);
   aStudy->AddCreatedPostponed(value);
   aStudy->AddPostponed(Value());
 
   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);
+  SALOMEDS_Study_i::IORUpdated(Handle(SALOMEDS_IORAttribute)::DownCast(_myAttr),anORB);
 }
index 895ff7076662ae47af39a67e09527b87f017d6aa..5e60bd6cb04a052eff8a19a9dc2678ab414b094f 100644 (file)
 #ifndef SALOMEDS_AttributeIOR_i_HeaderFile
 #define SALOMEDS_AttributeIOR_i_HeaderFile
 
-#include <SALOMEconfig.h>
-#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() {};
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
 
+DEFINE_DERIVED_ATTR(AttributeIOR,SALOMEDS_IORAttribute,true);
+
+class SALOMEDS_AttributeIOR_i: 
+  public virtual POA_SALOMEDS::AttributeIOR,
+  public virtual SALOMEDS_TAttributeIOR_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeIOR,SALOMEDS_IORAttribute);
+public:
   char* Value();
   void SetValue(const char* value);
   
index 8245e3723b71f188d124c265fe6e729839fad15a..8e40d859067ffa3ad0da72299960ffe0571b5417 100644 (file)
@@ -27,9 +27,8 @@
 //  $Header$
 
 #include "SALOMEDS_AttributeInteger_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
-using namespace std;
 
+using namespace std;
 
 CORBA::Long SALOMEDS_AttributeInteger_i::Value() {
   return Handle(TDataStd_Integer)::DownCast(_myAttr)->Get();
index be877a73565027dfb3c606191c499fe0d2821372..0339a2cce9a71ddbd25b220fd78c347afd0f5c52 100644 (file)
 #ifndef SALOMEDS_AttributeInteger_i_HeaderFile
 #define SALOMEDS_AttributeInteger_i_HeaderFile
 
-// IDL headers
-
 #include <TDataStd_Integer.hxx>
+
+#include "SALOMEDS_GenericAttribute_i.hxx"
+
+// IDL headers
 #include <SALOMEconfig.h>
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeInteger,TDataStd_Integer,true);
 
+class SALOMEDS_AttributeInteger_i: 
+  public virtual POA_SALOMEDS::AttributeInteger,
+  public virtual SALOMEDS_TAttributeInteger_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeInteger,TDataStd_Integer);
+public:
   CORBA::Long Value();
-  void SetValue(CORBA::Long value);
+  void SetValue(CORBA::Long theValue);
 
   char* Store();
   void Restore(const char*);
@@ -56,5 +54,4 @@ public:
 };
 
 
-
 #endif
index b6aac228078334b81686530d62449e20e693f1da..77cef467817bd66d604b18344e0f889729442235 100644 (file)
@@ -27,7 +27,7 @@
 //  $Header$
 
 #include "SALOMEDS_AttributeLocalID_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
+
 using namespace std;
 
 CORBA::Long SALOMEDS_AttributeLocalID_i::Value() {
index 7b0d5c1485830ead49e6de066a42164a694ab60b..a2d41abf922dbfa77fa78c9ae328baaacd2a3323 100644 (file)
 #define SALOMEDS_AttributeLocalID_i_HeaderFile
 
 // IDL headers
-
-#include "SALOMEDS_LocalIDAttribute.hxx"
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "SALOMEDS_LocalIDAttribute.hxx"
 #include "SALOMEDS_GenericAttribute_i.hxx"
 
-class SALOMEDS_AttributeLocalID_i: public virtual POA_SALOMEDS::AttributeLocalID,
-  public virtual SALOMEDS_GenericAttribute_i {
+DEFINE_DERIVED_ATTR(AttributeLocalID,SALOMEDS_LocalIDAttribute,true);
+
+class SALOMEDS_AttributeLocalID_i: 
+  public virtual POA_SALOMEDS::AttributeLocalID,
+  public virtual SALOMEDS_TAttributeLocalID_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeLocalID,SALOMEDS_LocalIDAttribute);
 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);
 
@@ -55,5 +54,4 @@ public:
 };
 
 
-
 #endif
index bc003247852983b883d05b2f318cb31ec54ba685..b495f26bfb805f077a8fe3715307d9b10b22e535 100644 (file)
@@ -28,7 +28,8 @@
 
 #include "SALOMEDS_AttributeName_i.hxx"
 #include <TCollection_ExtendedString.hxx>
-#include "SALOMEDS_SObject_i.hxx"
+#include <TCollection_AsciiString.hxx>
+
 using namespace std;
 
 char* SALOMEDS_AttributeName_i::Value() {
@@ -37,11 +38,9 @@ char* SALOMEDS_AttributeName_i::Value() {
   return c_s._retn();
 }
 
-void SALOMEDS_AttributeName_i::SetValue(const char* value) {
+void SALOMEDS_AttributeName_i::SetValue(const char* theValue) {
   CheckLocked();
-  //CORBA::String_var Str = CORBA::string_dup(value);
-  //Handle(TDataStd_Name)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
-  Handle(TDataStd_Name)::DownCast(_myAttr)->Set(TCollection_ExtendedString((char*)value));
+  Handle(TDataStd_Name)::DownCast(_myAttr)->Set(TCollection_ExtendedString((char*)theValue));
 }
 
 char* SALOMEDS_AttributeName_i::Store() {
index d2a149258e69cf1fac9336b4d120aaaed47c2249..ffcebc20fbf5bf583456e90ef354574c56c35a88 100644 (file)
 #ifndef SALOMEDS_AttributeName_i_HeaderFile
 #define SALOMEDS_AttributeName_i_HeaderFile
 
-// IDL headers
-
 #include <TDataStd_Name.hxx>
+
+#include "SALOMEDS_GenericAttribute_i.hxx"
+
+// IDL headers
 #include <SALOMEconfig.h>
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeName,TDataStd_Name,true);
 
+class SALOMEDS_AttributeName_i: 
+  public virtual POA_SALOMEDS::AttributeName,
+  public virtual SALOMEDS_TAttributeName_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeName,TDataStd_Name);
+public:
   char* Value();
   void SetValue(const char* value);
 
   char* Store();
   void Restore(const char*);
-
 };
 
 
index 842d1ce1d7e5fd368bd2213cf20532a39fe0794a..5471006e5dd79a90186db6da551505ddbd0bc706 100644 (file)
@@ -27,7 +27,7 @@
 //  $Header$
 
 #include "SALOMEDS_AttributeOpened_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
+
 using namespace std;
 
 CORBA::Boolean SALOMEDS_AttributeOpened_i::IsOpened() {
index ea75a4990dc0d621ad62a65b145c8632908d93e0..0ad905ca6ff93cf6559349ab3511c09ba4bff161 100644 (file)
 #define SALOMEDS_AttributeOpened_i_HeaderFile
 
 // IDL headers
-
-#include "SALOMEDS_OpenedAttribute.hxx"
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "SALOMEDS_OpenedAttribute.hxx"
 #include "SALOMEDS_GenericAttribute_i.hxx"
 
-class SALOMEDS_AttributeOpened_i: public virtual POA_SALOMEDS::AttributeOpened,
-  public virtual SALOMEDS_GenericAttribute_i {
+DEFINE_DERIVED_ATTR(AttributeOpened,SALOMEDS_OpenedAttribute,false);
+
+class SALOMEDS_AttributeOpened_i: 
+  public virtual POA_SALOMEDS::AttributeOpened,
+  public virtual SALOMEDS_TAttributeOpened_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeOpened,SALOMEDS_OpenedAttribute);
 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);
 
index c550587aef9cd6eca4872f65a757cacbcc1bcd7d..67281220b84d6b2cfb43d5f271fb220b9ab7e17e 100644 (file)
@@ -28,7 +28,8 @@
 
 #include "SALOMEDS_AttributePersistentRef_i.hxx"
 #include <TCollection_ExtendedString.hxx>
-#include "SALOMEDS_SObject_i.hxx"
+#include <TCollection_AsciiString.hxx>
+
 using namespace std;
 
 char* SALOMEDS_AttributePersistentRef_i::Value()
index 5d986a15ed262eb6a3a75643275d0c100b0d8462..40cb201490f36460830b166c4f64de47a3ad238a 100644 (file)
 #ifndef SALOMEDS_AttributePersistentRef_i_HeaderFile
 #define SALOMEDS_AttributePersistentRef_i_HeaderFile
 
-#include <SALOMEconfig.h>
-#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() {};
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+DEFINE_DERIVED_ATTR(AttributePersistentRef,SALOMEDS_PersRefAttribute,false);
 
+class SALOMEDS_AttributePersistentRef_i: 
+  public virtual POA_SALOMEDS::AttributePersistentRef,
+  public virtual SALOMEDS_TAttributePersistentRef_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributePersistentRef,SALOMEDS_PersRefAttribute);
+public:
   char* Value();
   void SetValue(const char* value);
 
@@ -54,5 +52,4 @@ public:
 };
 
 
-
 #endif
index 140d0ea4829db3da63934182b4821d025bd47e24..8fc0f2be1a1d51ce757ea1767a085f0f8a29a40f 100644 (file)
@@ -27,8 +27,8 @@
 //  $Header$
 
 #include "SALOMEDS_AttributePixMap_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
 #include <TCollection_AsciiString.hxx>
+
 using namespace std;
 
 CORBA::Boolean SALOMEDS_AttributePixMap_i::HasPixMap() {
index 16696a4a5d81e1ecd891c4002a59c02876d490a4..c17fa5c2f1a6863d7746ea9398f52ce4ae6182af 100644 (file)
 #define SALOMEDS_AttributePixMap_i_HeaderFile
 
 // IDL headers
-#include "SALOMEDS_PixMapAttribute.hxx"
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "SALOMEDS_PixMapAttribute.hxx"
 #include "SALOMEDS_GenericAttribute_i.hxx"
 
-class SALOMEDS_AttributePixMap_i: public virtual POA_SALOMEDS::AttributePixMap,
-                               public virtual SALOMEDS_GenericAttribute_i {
+DEFINE_DERIVED_ATTR(AttributePixMap,SALOMEDS_PixMapAttribute,false);
+
+class SALOMEDS_AttributePixMap_i: 
+  public virtual POA_SALOMEDS::AttributePixMap,
+  public virtual SALOMEDS_TAttributePixMap_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributePixMap,SALOMEDS_PixMapAttribute);
 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);
index c3be0fedce7ea9c47d1c4a42e0b5ab81fb247417..2faab629daf2678ed678212a5c9c01908b5827d2 100644 (file)
 #include "SALOMEDS_AttributePythonObject_i.hxx"
 #include <TCollection_ExtendedString.hxx>
 #include <TColStd_HArray1OfCharacter.hxx>
-#include "SALOMEDS_SObject_i.hxx"
+
 using namespace std;
 
 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);
+  Handle(SALOMEDS_PythonObjectAttribute)::DownCast(_myAttr)->SetObject(const_cast<char*>(theSequence), IsScript);
 }
 
 char* SALOMEDS_AttributePythonObject_i::GetObject() {
@@ -39,8 +38,6 @@ char* SALOMEDS_AttributePythonObject_i::Store() {
   return aResult;
 }
 
-void SALOMEDS_AttributePythonObject_i::Restore(const char* value) {
-  char* aString = CORBA::string_dup(value);
-  SetObject(aString + 1, aString[0]=='s');
-  delete(aString);
+void SALOMEDS_AttributePythonObject_i::Restore(const char* theValue) {
+  SetObject(&theValue[1], theValue[0]=='s');
 }
index 1db4b14eacaa83a466669922253bb70e6832cafc..615690b978b204e9459701e53bfb2da2582c95c4 100644 (file)
 #define SALOMEDS_AttributePythonObject_i_HeaderFile
 
 // IDL headers
-
 #include <SALOMEconfig.h>
 #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() {};
+DEFINE_DERIVED_ATTR(AttributePythonObject,SALOMEDS_PythonObjectAttribute,true);
 
+class SALOMEDS_AttributePythonObject_i: 
+  public virtual POA_SALOMEDS::AttributePythonObject,
+  public virtual SALOMEDS_TAttributePythonObject_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributePythonObject,SALOMEDS_PythonObjectAttribute);
+public:
   virtual void SetObject(const char* theSequence, CORBA::Boolean IsScript);
   virtual char* GetObject();
   virtual CORBA::Boolean IsScript();
@@ -39,7 +36,4 @@ public:
 
 };
 
-
-
-
 #endif
index 62b52968025ae5f7fae37021754b4411db192463..ca74454ee442e74fbc77c0a5b68738cf785dda66 100644 (file)
@@ -27,7 +27,6 @@
 //  $Header$
 
 #include "SALOMEDS_AttributeReal_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
 #include <sstream>
 
 using namespace std;
index 42263a1612a7909f6e9b66c327e5cdbbdebdfa79..a7fa861e6601dfcc2a30a10964f924b89e91fd5f 100644 (file)
 #ifndef SALOMEDS_AttributeReal_i_HeaderFile
 #define SALOMEDS_AttributeReal_i_HeaderFile
 
-// IDL headers
 #include <TDataStd_Real.hxx>
+
+#include "SALOMEDS_GenericAttribute_i.hxx"
+
+// IDL headers
 #include <SALOMEconfig.h>
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeReal,TDataStd_Real,true);
 
+class SALOMEDS_AttributeReal_i: 
+  public virtual POA_SALOMEDS::AttributeReal,
+  public virtual SALOMEDS_TAttributeReal_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeReal,TDataStd_Real);
+public:
   CORBA::Double Value();
-  void SetValue(CORBA::Double value);
+  void SetValue(CORBA::Double theValue);
 
   char* Store();
   void Restore(const char*);
index aa41a7281ad6af9fd7f87c3755ed481c786c8407..1ae041186057b1edcf421a40e4f132af8e236e53 100644 (file)
@@ -27,7 +27,7 @@
 //  $Header$
 
 #include "SALOMEDS_AttributeSelectable_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
+
 using namespace std;
 
 CORBA::Boolean SALOMEDS_AttributeSelectable_i::IsSelectable() {
index c844f03bf44fce1a4ce425a93b83dcdac4c943ec..f7158eedad40bc7110f49a58b57a6bfa99f82bd6 100644 (file)
 #ifndef SALOMEDS_AttributeSelectable_i_HeaderFile
 #define SALOMEDS_AttributeSelectable_i_HeaderFile
 
-// IDL headers
-
 #include "SALOMEDS_SelectableAttribute.hxx"
+#include "SALOMEDS_GenericAttribute_i.hxx"
+
+// IDL headers
 #include <SALOMEconfig.h>
 #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 {
+DEFINE_DERIVED_ATTR(AttributeSelectable,SALOMEDS_SelectableAttribute,false);
+
+class SALOMEDS_AttributeSelectable_i: 
+  public virtual POA_SALOMEDS::AttributeSelectable,
+  public virtual SALOMEDS_TAttributeSelectable_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeSelectable,SALOMEDS_SelectableAttribute);
 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);
 
@@ -55,5 +53,4 @@ public:
 };
 
 
-
 #endif
index 6f202da149aaad1a633e792303bba5ef7ace2d0a..33b8fbd1e3a54c4ee12a75c28e81e293096d7ce3 100644 (file)
 //  $Header$
 
 #include "SALOMEDS_AttributeSequenceOfInteger_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
 #include <TColStd_HSequenceOfInteger.hxx>
-using namespace std;
 
+using namespace std;
 
 void SALOMEDS_AttributeSequenceOfInteger_i::Assign(const SALOMEDS::LongSeq& other) 
 {
@@ -97,13 +96,13 @@ char* SALOMEDS_AttributeSequenceOfInteger_i::Store() {
 void SALOMEDS_AttributeSequenceOfInteger_i::Restore(const char* value) {
   Handle(TColStd_HSequenceOfInteger) CasCadeSeq = new TColStd_HSequenceOfInteger;
   
-  char* aCopy = CORBA::string_dup(value);
+  char* aCopy = strdup(value);
   char* adr = strtok(aCopy, " ");
   while (adr) {
     CORBA::Long l =  atol(adr);
     CasCadeSeq->Append(l);
     adr = strtok(NULL, " ");
   }
-  delete(aCopy);
+  free(aCopy);
   Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq);
 }
index 06b24a7c56ad5691cdd18c4936b127f3aba47856..d561d229d68555b8df72dd61cf94998487f60fed 100644 (file)
 #ifndef SALOMEDS_AttributeSequenceOfInteger_i_HeaderFile
 #define SALOMEDS_AttributeSequenceOfInteger_i_HeaderFile
 
-// IDL headers
 #include "SALOMEDS_SequenceOfIntegerAttribute.hxx"
+#include "SALOMEDS_GenericAttribute_i.hxx"
+
+// IDL headers
 #include <SALOMEconfig.h>
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeSequenceOfInteger,SALOMEDS_SequenceOfIntegerAttribute,true);
 
+class SALOMEDS_AttributeSequenceOfInteger_i: 
+  public virtual POA_SALOMEDS::AttributeSequenceOfInteger,
+  public virtual SALOMEDS_TAttributeSequenceOfInteger_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeSequenceOfInteger,SALOMEDS_SequenceOfIntegerAttribute);
+public:
   void Assign(const SALOMEDS::LongSeq& other);
   SALOMEDS::LongSeq* CorbaSequence();
   void Add(CORBA::Long value);
index a3fe11e24bb2131b37ac7f9a3f8b51d85b0e489f..308ec01c0f0947b10a9f4cf77a4f94cdc44865f4 100644 (file)
@@ -27,8 +27,8 @@
 //  $Header$
 
 #include "SALOMEDS_AttributeSequenceOfReal_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
 #include <TColStd_HSequenceOfReal.hxx>
+
 using namespace std;
 
 void SALOMEDS_AttributeSequenceOfReal_i::Assign(const SALOMEDS::DoubleSeq& other) 
@@ -96,7 +96,7 @@ char* SALOMEDS_AttributeSequenceOfReal_i::Store() {
 void SALOMEDS_AttributeSequenceOfReal_i::Restore(const char* value) {
   Handle(TColStd_HSequenceOfReal) CasCadeSeq = new TColStd_HSequenceOfReal;
   
-  char* aCopy =  CORBA::string_dup(value);
+  char* aCopy = strdup(value);
   char* adr = strtok(aCopy, " ");
   char *err = NULL;
   while (adr) {
@@ -105,6 +105,6 @@ void SALOMEDS_AttributeSequenceOfReal_i::Restore(const char* value) {
     else CasCadeSeq->Append(r);
     adr = strtok(NULL, " ");
   }
-  delete(aCopy);
+  free(aCopy);
   Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq);
 }
index 044fbc460a75bce48d3a3871079b9d8f0fd9f2ce..4c7fa6a17d99cd102ffb868c579ebf1ed3875545 100644 (file)
 #ifndef SALOMEDS_AttributeSequenceOfSequenceOfReal_i_HeaderFile
 #define SALOMEDS_AttributeSequenceOfSequenceOfReal_i_HeaderFile
 
-// IDL headers
 #include "SALOMEDS_SequenceOfRealAttribute.hxx"
+#include "SALOMEDS_GenericAttribute_i.hxx"
+
+// IDL headers
 #include <SALOMEconfig.h>
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeSequenceOfReal,SALOMEDS_SequenceOfRealAttribute,true);
 
+class SALOMEDS_AttributeSequenceOfReal_i: 
+  public virtual POA_SALOMEDS::AttributeSequenceOfReal,
+  public virtual SALOMEDS_TAttributeSequenceOfReal_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeSequenceOfReal,SALOMEDS_SequenceOfRealAttribute);
+public:
   void Assign(const SALOMEDS::DoubleSeq& other);
   SALOMEDS::DoubleSeq* CorbaSequence();
   void Add(CORBA::Double value);
@@ -57,6 +54,7 @@ public:
 
   char* Store();
   void Restore(const char*);
+
 };
 
 
index 1e87e8428d4ec5317cd402be87380ffab93f28be..b08b9d5c4c93892d19858113074e2fb4b0ac8214 100644 (file)
@@ -9,20 +9,23 @@
 //  Module : SALOME
 //  $Header$
 
-#include "SALOMEDS_AttributeStudyProperties_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
 #include <TColStd_HSequenceOfExtendedString.hxx>
 #include <TColStd_HSequenceOfInteger.hxx>
-using namespace std;
+#include <TCollection_ExtendedString.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#include "SALOMEDS_AttributeStudyProperties_i.hxx"
 
 #define CREATION_MODE_NOTDEFINED 0
 #define CREATION_MODE_SCRATCH 1
 #define CREATION_MODE_COPY 2
 
+using namespace std;
+
 void SALOMEDS_AttributeStudyProperties_i::SetUserName(const char* theName) {
   CheckLocked();
   Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
-  aProp->SetFirstName((char*)theName);
+  aProp->SetFirstName(const_cast<char*>(theName));
 }
 
 char* SALOMEDS_AttributeStudyProperties_i::GetUserName() {
@@ -111,7 +114,7 @@ void SALOMEDS_AttributeStudyProperties_i::SetModification(const char* theName,
                                                          CORBA::Long theYear) {
   CheckLocked();
   Handle(SALOMEDS_StudyPropertiesAttribute) aProp = Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(_myAttr);
-  aProp->SetUserName((char*)theName);
+  aProp->SetUserName(const_cast<char*>(theName));
   aProp->SetModificationDate((int)theMinute, (int)theHour, (int)theDay, (int)theMonth, (int)theYear);
 }
 void SALOMEDS_AttributeStudyProperties_i::GetModificationsList(SALOMEDS::StringSeq_out theNames,
@@ -185,7 +188,7 @@ char* SALOMEDS_AttributeStudyProperties_i::Store() {
 }
 
 void SALOMEDS_AttributeStudyProperties_i::Restore(const char* value) {
-  char* aCopy = CORBA::string_dup(value);
+  char* aCopy = strdup(value);
   if (aCopy[0] == 'f') SetCreationMode("from scratch");
   else if (aCopy[0] == 'c') SetCreationMode("copy from");
   else SetCreationMode("none");
@@ -227,5 +230,5 @@ void SALOMEDS_AttributeStudyProperties_i::Restore(const char* value) {
     SetLocked(Standard_True);
   }
   SetModified(0);
-  delete(aCopy);
+  free(aCopy);
 }
index 2d7ebeb3b6fcc194d7d88dc101c5e9ee42c07b5f..b7e1d00202c602e50ff1d59a4263b0971fc4381c 100644 (file)
 #define SALOMEDS_AttributeStudyProperties_i_HeaderFile
 
 // IDL headers
-#include <SALOMEDS_StudyPropertiesAttribute.hxx>
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "SALOMEDS_StudyPropertiesAttribute.hxx"
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeStudyProperties,SALOMEDS_StudyPropertiesAttribute,false);
 
+class SALOMEDS_AttributeStudyProperties_i: 
+  public virtual POA_SALOMEDS::AttributeStudyProperties,
+  public virtual SALOMEDS_TAttributeStudyProperties_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeStudyProperties,SALOMEDS_StudyPropertiesAttribute);
+public:
   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);
index 716a491391183bbcb6e69d935125134782f1e720..380741f4925947d18586216fd2c60a768b273160 100644 (file)
@@ -9,16 +9,18 @@
 //  Module : SALOME
 //  $Header$
 
-#include "SALOMEDS_AttributeTableOfInteger_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
 #include <TColStd_HSequenceOfInteger.hxx>
+#include <TCollection_AsciiString.hxx>
 #include <Standard_Failure.hxx>
 #include <Standard_ErrorHandler.hxx>
+
+#include "SALOMEDS_AttributeTableOfInteger_i.hxx"
 #include "Utils_ExceptHandlers.hxx"
 
 #include <stdexcept>
 #include <strstream>
 #include <string>
+
 using namespace std;
 
 #define SEPARATOR '\1'
@@ -44,8 +46,6 @@ static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString)
   return aString;
 }
 
-
-
 void SALOMEDS_AttributeTableOfInteger_i::SetTitle(const char* theTitle) {
   CheckLocked();
   Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
index 6b3ca5238be6df314781b0bb805929cf913a04a3..03f996572cb77d113e25bcaaf9e43fb4c8174a98 100644 (file)
 #ifndef SALOMEDS_AttributeTableOfInteger_i_HeaderFile
 #define SALOMEDS_AttributeTableOfInteger_i_HeaderFile
 
-// IDL headers
 #include "SALOMEDS_TableOfIntegerAttribute.hxx"
+#include "SALOMEDS_GenericAttribute_i.hxx"
+
+// IDL headers
 #include <SALOMEconfig.h>
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeTableOfInteger,SALOMEDS_TableOfIntegerAttribute,true);
 
+class SALOMEDS_AttributeTableOfInteger_i: 
+  public virtual POA_SALOMEDS::AttributeTableOfInteger,
+  public virtual SALOMEDS_TAttributeTableOfInteger_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeTableOfInteger,SALOMEDS_TableOfIntegerAttribute);
+public:
   virtual void SetTitle(const char* theTitle);
   virtual char* GetTitle();
   virtual void SetRowTitle(CORBA::Long theIndex, const char* theTitle)
index 7308441ae94dc6d5b2f826cf02a4528c9f4c05f1..c550cf38b9838af8e4bb34a724682172045ad041 100644 (file)
@@ -10,8 +10,9 @@
 //  $Header$
 
 #include "SALOMEDS_AttributeTableOfReal_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
+
 #include <TColStd_HSequenceOfReal.hxx>
+#include <TCollection_AsciiString.hxx>
 #include <Standard_Failure.hxx>
 #include <Standard_ErrorHandler.hxx>
 
 #include <string>
 
 #include "Utils_ExceptHandlers.hxx"
-using namespace std;
 UNEXPECT_CATCH(ATR_IncorrectIndex, SALOMEDS::AttributeTableOfReal::IncorrectIndex);
 UNEXPECT_CATCH(ATR_IncorrectArgumentLength, SALOMEDS::AttributeTableOfReal::IncorrectArgumentLength);
 
 #define SEPARATOR '\1'
 
+using namespace std;
+
 static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString)
 {
   TCollection_ExtendedString aString(theString);
@@ -43,8 +45,6 @@ static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString)
   return aString;
 }
 
-
-
 void SALOMEDS_AttributeTableOfReal_i::SetTitle(const char* theTitle) {
   CheckLocked();
   Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
index a3e8056b8cfd8e8581bce47bab3fee45404fdb98..9726ec82a67445c45e765d70605750bc7460db52 100644 (file)
 #ifndef SALOMEDS_AttributeTableOfReal_i_HeaderFile
 #define SALOMEDS_AttributeTableOfReal_i_HeaderFile
 
-// IDL headers
 #include "SALOMEDS_TableOfRealAttribute.hxx"
+#include "SALOMEDS_GenericAttribute_i.hxx"
+
+// IDL headers
 #include <SALOMEconfig.h>
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeTableOfReal,SALOMEDS_TableOfRealAttribute,true);
 
- virtual void SetTitle(const char* theTitle);
+class SALOMEDS_AttributeTableOfReal_i: 
+  public virtual POA_SALOMEDS::AttributeTableOfReal,
+  public virtual SALOMEDS_TAttributeTableOfReal_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeTableOfReal,SALOMEDS_TableOfRealAttribute);
+public:
+  virtual void SetTitle(const char* theTitle);
   virtual char* GetTitle();
   virtual void SetRowTitle(CORBA::Long theIndex, const char* theTitle)
     throw (SALOMEDS::AttributeTableOfReal::IncorrectIndex);
index 2f5a95796845f581fb210df3280ecf5f37bc9fae..8527cf8db7e8a12b903f27f3641eecca8a672818 100644 (file)
@@ -10,9 +10,6 @@
 
 #include <TCollection_ExtendedString.hxx>
 #include <TCollection_AsciiString.hxx>
-
-#include "SALOMEDS_AttributeTableOfString_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
 #include <TColStd_HSequenceOfExtendedString.hxx>
 
 #include <Standard_Failure.hxx>
 #include <strstream>
 #include <string>
 
+#include "SALOMEDS_AttributeTableOfString_i.hxx"
+
 #include "Utils_ExceptHandlers.hxx"
-using namespace std;
+
 UNEXPECT_CATCH(ATS_IncorrectIndex, SALOMEDS::AttributeTableOfString::IncorrectIndex);
 UNEXPECT_CATCH(ATS_IncorrectArgumentLength, SALOMEDS::AttributeTableOfString::IncorrectArgumentLength);
 
+using namespace std;
 #define SEPARATOR '\1'
 
 static TCollection_ExtendedString getUnit(TCollection_ExtendedString theString)
@@ -46,8 +46,6 @@ static TCollection_ExtendedString getTitle(TCollection_ExtendedString theString)
   return aString;
 }
 
-
-
 void SALOMEDS_AttributeTableOfString_i::SetTitle(const char* theTitle) {
   CheckLocked();
   Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
index f3a87deeabc1130f08dd4781beaac5861b1dcece..cc2e84125556e00d2db3567fcc4a6bf52918ede8 100644 (file)
 #ifndef SALOMEDS_AttributeTableOfString_i_HeaderFile
 #define SALOMEDS_AttributeTableOfString_i_HeaderFile
 
-// IDL headers
 #include "SALOMEDS_TableOfStringAttribute.hxx"
+#include "SALOMEDS_GenericAttribute_i.hxx"
+
+// IDL headers
 #include <SALOMEconfig.h>
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeTableOfString,SALOMEDS_TableOfStringAttribute,true);
 
+class SALOMEDS_AttributeTableOfString_i: 
+  public virtual POA_SALOMEDS::AttributeTableOfString,
+  public virtual SALOMEDS_TAttributeTableOfString_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeTableOfString,SALOMEDS_TableOfStringAttribute);
+public:
   virtual void SetTitle(const char* theTitle);
   virtual char* GetTitle();
   virtual void SetRowTitle(CORBA::Long theIndex, const char* theTitle)
index a70357e4697490a1532cec10a2144f78f632ce66..80b1c2e66a8ba7c2b952c349eb05ce883c53e9fd 100644 (file)
 //  Module : SALOME
 //  $Header$
 
+#include <TDF_ListIteratorOfLabelList.hxx>
+#include <TDF_LabelList.hxx>
+#include <TDF_Label.hxx>
+#include <TDF_Tool.hxx>
+
 #include "SALOMEDS_AttributeTarget_i.hxx"
 #include "SALOMEDS_SObject_i.hxx"
-#include <TDF_LabelList.hxx>
-#include <TDF_ListIteratorOfLabelList.hxx>
+
 using namespace std;
 
-void SALOMEDS_AttributeTarget_i::Add(SALOMEDS::SObject_ptr anObject) {
+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);
+  _myAttr->Append(aLabel);
 }
 
 SALOMEDS::Study::ListOfSObject* SALOMEDS_AttributeTarget_i::Get() {
   TDF_LabelList aLList;
+
+  _myAttr->Get(aLList);
   SALOMEDS::Study::ListOfSObject_var aSList = new SALOMEDS::Study::ListOfSObject;
-  (Handle(SALOMEDS_TargetAttribute)::DownCast(_myAttr))->Get(aLList);
+
   if (aLList.Extent() == 0) 
     return aSList._retn();
+
   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);
+  SALOMEDS_Study_i* aStudy = _mySObject->GetStudyServant();
+  for(int index = 0; anIter.More(); anIter.Next(), index++){
+    const TDF_Label& aLabel = anIter.Value();
+    SALOMEDS_SObject_i* anSO = SALOMEDS_SObject_i::New(aStudy,aLabel);
     aSList[index] = anSO->_this();
   }
   return aSList._retn();
@@ -56,6 +65,7 @@ SALOMEDS::Study::ListOfSObject* SALOMEDS_AttributeTarget_i::Get() {
 
 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);
+  CORBA::String_var anID = anObject->GetID();
+  TDF_Tool::Label(_myAttr->Label().Data(),anID.inout(),aLabel,1);
+  _myAttr->Remove(aLabel);
 }
index 14228b4d819597f6e81428d766e48af4e06a0b97..d6181dbcba4f6569d5ea91c714f72ed6be30e10c 100644 (file)
 #define SALOMEDS_AttributeTarget_i_HeaderFile
 
 // IDL headers
-
-#include "SALOMEDS_TargetAttribute.hxx"
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "SALOMEDS_TargetAttribute.hxx"
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeTarget,SALOMEDS_TargetAttribute,false);
 
+class SALOMEDS_AttributeTarget_i: 
+  public virtual POA_SALOMEDS::AttributeTarget,
+  public virtual SALOMEDS_TAttributeTarget_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeTarget,SALOMEDS_TargetAttribute);
+public:
   virtual void Add(SALOMEDS::SObject_ptr anObject) ;
   virtual SALOMEDS::Study::ListOfSObject* Get();
   virtual void Remove(SALOMEDS::SObject_ptr anObject);
+
 };
 
 
index f1c5b65efcdf69d57b4fc05a38dc7ceda7c0af04..32a79e68c1f626fb5901c82cf0e8e7ed998711fc 100644 (file)
@@ -27,8 +27,8 @@
 //  $Header$
 
 #include "SALOMEDS_AttributeTextColor_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
 #include <TColStd_HArray1OfReal.hxx>
+
 using namespace std;
 
 SALOMEDS::Color SALOMEDS_AttributeTextColor_i::TextColor() {
index 46b50ff12dc3c0938daa4ff5ca2223c9d32f6ee7..765eb1c166508e9b7f7dff5b4c8221eecee96c54 100644 (file)
 #define SALOMEDS_AttributeTextColor_i_HeaderFile
 
 // IDL headers
-#include "SALOMEDS_TextColorAttribute.hxx"
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "SALOMEDS_TextColorAttribute.hxx"
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeTextColor,SALOMEDS_TextColorAttribute,false);
 
+class SALOMEDS_AttributeTextColor_i: 
+  public virtual POA_SALOMEDS::AttributeTextColor,
+  public virtual SALOMEDS_TAttributeTextColor_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeTextColor,SALOMEDS_TextColorAttribute);
+public:
   SALOMEDS::Color TextColor();
   void SetTextColor(const SALOMEDS::Color& value);
 
index f50028358f664bf92df9dd6b130064b822ca8998..672d81c450e9fd92753193a248c0f1e0ac205390 100644 (file)
@@ -27,8 +27,8 @@
 //  $Header$
 
 #include "SALOMEDS_AttributeTextHighlightColor_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
 #include <TColStd_HArray1OfReal.hxx>
+
 using namespace std;
 
 SALOMEDS::Color SALOMEDS_AttributeTextHighlightColor_i::TextHighlightColor() {
index 2ca180ffe3775f41a424e07c4a46678894be50e2..aa3ead5d2b14ec1fad975a3f54476f2b4be5a14b 100644 (file)
 #define SALOMEDS_AttributeTextHighlightColor_i_HeaderFile
 
 // IDL headers
-#include "SALOMEDS_TextHighlightColorAttribute.hxx"
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include "SALOMEDS_TextHighlightColorAttribute.hxx"
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeTextHighlightColor,SALOMEDS_TextHighlightColorAttribute,false);
 
+class SALOMEDS_AttributeTextHighlightColor_i: 
+  public virtual POA_SALOMEDS::AttributeTextHighlightColor,
+  public virtual SALOMEDS_TAttributeTextHighlightColor_i 
+{
+  DEFINE_DERIVED_ATTR_METH_DEFAULT(AttributeTextHighlightColor,SALOMEDS_TextHighlightColorAttribute);
+public:
   SALOMEDS::Color TextHighlightColor();
   void SetTextHighlightColor(const SALOMEDS::Color& value);
 
index 196d54b0683b15dd710792656c6c6afdb9c9ac96..15449d603ec039ba62bc2b69da7c34c66cf37e71 100644 (file)
 //  Module : SALOME
 //  $Header$
 
-#include "SALOMEDS_AttributeTreeNode_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
-#include "utilities.h"
 #include <TDocStd_Document.hxx>
 #include <TDF_Tool.hxx>
+
+#include "SALOMEDS_AttributeTreeNode_i.hxx"
+
+#include "utilities.h"
+
 using namespace std;
 
 static Handle(TDataStd_TreeNode) GetNode(SALOMEDS::AttributeTreeNode_ptr value,
-                                        const Handle(TDataStd_TreeNode)& aNode) {
+                                        const Handle(TDataStd_TreeNode)& aNode) 
+{
   Handle(TDataStd_TreeNode) aResult = new TDataStd_TreeNode;
   CORBA::String_var aString = CORBA::string_dup(value->Label());
   TDF_Label aLabel;
@@ -51,138 +54,126 @@ static Handle(TDataStd_TreeNode) GetNode(SALOMEDS::AttributeTreeNode_ptr value,
   return aResult;
 }
 
-void SALOMEDS_AttributeTreeNode_i::SetFather(SALOMEDS::AttributeTreeNode_ptr value) {
+void SALOMEDS_AttributeTreeNode_i::SetFather(SALOMEDS::AttributeTreeNode_ptr theValue) {
   CheckLocked();
-  Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
-  aNode->SetFather(GetNode(value, aNode));
+  _myAttr->SetFather(GetNode(theValue,_myAttr));
 }
 
 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFather() {
-  return Handle(TDataStd_TreeNode)::DownCast(_myAttr)->HasFather();
+  return _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();
+  SALOMEDS_AttributeTreeNode_i* aTreeNode = 
+    new SALOMEDS_AttributeTreeNode_i(_myAttr->Father(),_mySObject);
+  return aTreeNode->_this();
 }
 
-void SALOMEDS_AttributeTreeNode_i::SetPrevious(SALOMEDS::AttributeTreeNode_ptr value) {
+void SALOMEDS_AttributeTreeNode_i::SetPrevious(SALOMEDS::AttributeTreeNode_ptr theValue) {
   CheckLocked();
-  Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
-  aNode->SetPrevious(GetNode(value, aNode));
+  _myAttr->SetPrevious(GetNode(theValue,_myAttr));
 }
 
 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasPrevious() {
-  return Handle(TDataStd_TreeNode)::DownCast(_myAttr)->HasPrevious();
+  return _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();
+  SALOMEDS_AttributeTreeNode_i* aTreeNode = 
+    new SALOMEDS_AttributeTreeNode_i(_myAttr->Previous(),_mySObject);
+  return aTreeNode->_this();
 }
 
-void SALOMEDS_AttributeTreeNode_i::SetNext(SALOMEDS::AttributeTreeNode_ptr value) {
+void SALOMEDS_AttributeTreeNode_i::SetNext(SALOMEDS::AttributeTreeNode_ptr theValue) {
   CheckLocked();
-  Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
-  aNode->SetNext(GetNode(value, aNode));
+  _myAttr->SetNext(GetNode(theValue,_myAttr));
 }
 
 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasNext() {
-  return Handle(TDataStd_TreeNode)::DownCast(_myAttr)->HasNext();
+  return _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();
+  SALOMEDS_AttributeTreeNode_i* aTreeNode = 
+    new SALOMEDS_AttributeTreeNode_i(_myAttr->Next(),_mySObject);
+  return aTreeNode->_this();
 }
 
-void SALOMEDS_AttributeTreeNode_i::SetFirst(SALOMEDS::AttributeTreeNode_ptr value) {
+void SALOMEDS_AttributeTreeNode_i::SetFirst(SALOMEDS::AttributeTreeNode_ptr theValue) {
   CheckLocked();
-  Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
-  aNode->SetFirst(GetNode(value, aNode));
+  _myAttr->SetFirst(GetNode(theValue,_myAttr));
 }
 
 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::HasFirst() {
-  return Handle(TDataStd_TreeNode)::DownCast(_myAttr)->HasFirst();
+  return _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();
+  SALOMEDS_AttributeTreeNode_i* aTreeNode = 
+    new SALOMEDS_AttributeTreeNode_i(_myAttr->First(),_mySObject);
+  return aTreeNode->_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()));
+  _myAttr->SetTreeID(Standard_GUID(_myAttr->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();
+  _myAttr->ID().ToCString(aGUID);
+  return CORBA::string_dup(aGUID);
 }
 
-void SALOMEDS_AttributeTreeNode_i::Append(SALOMEDS::AttributeTreeNode_ptr value) {
+void SALOMEDS_AttributeTreeNode_i::Append(SALOMEDS::AttributeTreeNode_ptr theValue) {
   CheckLocked();
-  Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
-  aNode->Append(GetNode(value, aNode));
+  _myAttr->Append(GetNode(theValue,_myAttr));
 }
 
-void SALOMEDS_AttributeTreeNode_i::Prepend(SALOMEDS::AttributeTreeNode_ptr value) {
+void SALOMEDS_AttributeTreeNode_i::Prepend(SALOMEDS::AttributeTreeNode_ptr theValue) {
   CheckLocked();
-  Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
-  aNode->Prepend(GetNode(value, aNode));
+  _myAttr->Prepend(GetNode(theValue,_myAttr));
 }
 
-void SALOMEDS_AttributeTreeNode_i::InsertBefore(SALOMEDS::AttributeTreeNode_ptr value) {
+void SALOMEDS_AttributeTreeNode_i::InsertBefore(SALOMEDS::AttributeTreeNode_ptr theValue) {
   CheckLocked();
-  Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
-  aNode->InsertBefore(GetNode(value, aNode));
+  _myAttr->InsertBefore(GetNode(theValue,_myAttr));
 }
 
-void SALOMEDS_AttributeTreeNode_i::InsertAfter(SALOMEDS::AttributeTreeNode_ptr value) {
+void SALOMEDS_AttributeTreeNode_i::InsertAfter(SALOMEDS::AttributeTreeNode_ptr theValue) {
   CheckLocked();
-  Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
-  aNode->InsertAfter(GetNode(value, aNode));
+  _myAttr->InsertAfter(GetNode(theValue,_myAttr));
 }
 
 void SALOMEDS_AttributeTreeNode_i::Remove() {
   CheckLocked();
-  Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
-  aNode->Remove();
+  _myAttr->Remove();
 }
 
 CORBA::Long SALOMEDS_AttributeTreeNode_i::Depth() {
-  Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
-  return aNode->Depth();
+  return _myAttr->Depth();
 }
 
 CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsRoot() {
-  Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
-  return aNode->IsRoot();
+  return _myAttr->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::IsDescendant(SALOMEDS::AttributeTreeNode_ptr theValue) {
+  return _myAttr->IsDescendant(GetNode(theValue,_myAttr));
 }
 
-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::IsFather(SALOMEDS::AttributeTreeNode_ptr theValue) {
+  return _myAttr->IsFather(GetNode(theValue,_myAttr));
 }
 
-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));
+CORBA::Boolean SALOMEDS_AttributeTreeNode_i::IsChild(SALOMEDS::AttributeTreeNode_ptr theValue) {
+  return _myAttr->IsChild(GetNode(theValue,_myAttr));
 }
 
 char* SALOMEDS_AttributeTreeNode_i::Label() {
   TCollection_AsciiString aLabelName;
   TDF_Tool::Entry(_myAttr->Label(),aLabelName);
-  return CORBA::String_var(CORBA::string_dup(aLabelName.ToCString()))._retn();
+  return CORBA::string_dup(aLabelName.ToCString());
 }
 
 char* SALOMEDS_AttributeTreeNode_i::Store() {
@@ -204,7 +195,7 @@ void SALOMEDS_AttributeTreeNode_i::Restore(const char* value) {
   Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
   Handle(TDF_Data) DF = TDocStd_Document::Get(_myAttr->Label())->GetData();
   
-  char* aCopy = CORBA::string_dup(value);
+  char* aCopy = strdup(value);
   char* adr = strtok(aCopy, " ");
   
   TDF_Label aLabel;
@@ -236,5 +227,4 @@ void SALOMEDS_AttributeTreeNode_i::Restore(const char* value) {
     if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID());
     aNode->SetFirst(aDepNode);
   }
-  delete(aCopy);
 }
index 14e134b275fd0fd2abbb707b5bd537b5e76ef45e..718ffc641ab17ff62411d6700a3bbdc0fbd4ea19 100644 (file)
 #define SALOMEDS_AttributeTreeNode_i_HeaderFile
 
 // IDL headers
-#include <TDataStd_TreeNode.hxx>
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include <TDataStd_TreeNode.hxx>
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeTreeNode,TDataStd_TreeNode,false);
 
+class SALOMEDS_AttributeTreeNode_i: 
+  public virtual POA_SALOMEDS::AttributeTreeNode,
+  public virtual SALOMEDS_TAttributeTreeNode_i
+{
+  DEFINE_DERIVED_ATTR_METH(AttributeTreeNode,TDataStd_TreeNode::GetDefaultTreeID());
+
+public:
   void SetFather(SALOMEDS::AttributeTreeNode_ptr value);
   CORBA::Boolean HasFather();
   SALOMEDS::AttributeTreeNode_ptr GetFather();
@@ -77,4 +76,5 @@ public:
 
 };
 
+
 #endif
index 5c8524045abadce4231e2b5913b2ba2e6205695d..6a3d2d3cd4d501b14809839b7cdd473bfb9167e7 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "SALOMEDS_AttributeUserID_i.hxx"
 #include <TCollection_ExtendedString.hxx>
-#include "SALOMEDS_SObject_i.hxx"
+
 using namespace std;
 
 char* SALOMEDS_AttributeUserID_i::Value() {
index e080658af56e7a985450235dd187a42f29cf326f..d23f6d5893f67ecb63b16fb689686154d71c2f38 100644 (file)
 #define SALOMEDS_AttributeUserID_i_HeaderFile
 
 // IDL headers
-
-#include <TDataStd_UAttribute.hxx>
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
+
+#include <TDataStd_UAttribute.hxx>
 #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() {};
+DEFINE_DERIVED_ATTR(AttributeUserID,TDataStd_UAttribute,false);
 
+class SALOMEDS_AttributeUserID_i: 
+  public virtual POA_SALOMEDS::AttributeUserID,
+  public virtual SALOMEDS_TAttributeUserID_i
+{
+  DEFINE_DERIVED_ATTR_METH(AttributeUserID,"FFFFFFFF-D9CD-11d6-945D-1050DA506788");
+
+public:
   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;
-  }
-
   char* Store();
   void Restore(const char*);
 
 };
 
 
-
-
 #endif
index 572ba5b401fbb12c22c0195baf02d9be95d86398..315db4767fe3fc02cb7780cc4c9e064e49816c7d 100644 (file)
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS)
 
-class SALOMEDS_Callback_i: public POA_SALOMEDS::Callback,
-                          public PortableServer::RefCountServantBase {
-
+class SALOMEDS_Callback_i: public virtual POA_SALOMEDS::Callback,
+                          public virtual 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);
+ SALOMEDS_Callback_i(SALOMEDS::UseCaseBuilder_ptr theBuilder) {
+   _builder = SALOMEDS::UseCaseBuilder::_duplicate(theBuilder);
  }
 
  virtual void OnAddSObject(SALOMEDS::SObject_ptr theObject) {
index ed181e31fd27b3604fda5586ff8feba275dd4bf7..c1dca11d9f41fd6e6a46322d83ea747f99b91d05 100644 (file)
 //  Module : SALOME
 //  $Header$
 
+#include <TDF_Tool.hxx>
+
 #include "SALOMEDS_ChildIterator_i.hxx"
 #include "SALOMEDS_SObject_i.hxx"
 #include "utilities.h"
-using namespace std;
-
 
+using namespace std;
 
 //============================================================================
 /*! Function : constructor
  *  Purpose  :
  */
 //============================================================================
-SALOMEDS_ChildIterator_i::SALOMEDS_ChildIterator_i(TDF_Label lab,
-                                                  CORBA::ORB_ptr orb) 
-  : _lab(lab)
+SALOMEDS_ChildIterator_i::SALOMEDS_ChildIterator_i(SALOMEDS_Study_i* theStudy,
+                                                  const TDF_Label& theLabel): 
+  _it(theLabel),
+  _lab(theLabel),
+  _study(theStudy)
 {
-  _orb = CORBA::ORB::_duplicate(orb);
-  _it.Initialize (lab);
+  TCollection_AsciiString anEntry;
+  TDF_Tool::Entry(theLabel,anEntry);
+  //cout<<"SALOMEDS_ChildIterator_i::New - "<<anEntry.ToCString()<<endl;
 }
 
 //============================================================================
@@ -93,6 +97,9 @@ CORBA::Boolean SALOMEDS_ChildIterator_i::More()
 void SALOMEDS_ChildIterator_i::Next()
 {
   _it.Next();
+  TCollection_AsciiString anEntry;
+  TDF_Tool::Entry(_it.Value(),anEntry);
+  //cout<<"SALOMEDS_ChildIterator_i::Next - "<<anEntry.ToCString()<<endl;
 }
 
 
@@ -104,9 +111,6 @@ void SALOMEDS_ChildIterator_i::Next()
 
 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;
+  return SALOMEDS_SObject_i::New(_study,_it.Value())->_this();
 }
 
index d7bdcac51ed84d04365e162550f3b6e543872f2c..cf9b71ce971bc4315db27423ca37a9c85d7e1ef4 100644 (file)
 #ifndef __SALOMEDS_CHILDITERATOR_I_H__
 #define __SALOMEDS_CHILDITERATOR_I_H__
 
-// std C++ headers
-#include <iostream.h>
-
 // IDL headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS)
 
-
-
 // Cascade headers
 #include <TDF_ChildIterator.hxx>
 #include <TDF_Label.hxx>
-#include <stdio.h>
+
+class SALOMEDS_Study_i;
 
 class SALOMEDS_ChildIterator_i: public POA_SALOMEDS::ChildIterator,
-                               public PortableServer::RefCountServantBase {
+                               public PortableServer::RefCountServantBase 
+{
+  SALOMEDS_ChildIterator_i(); // Not implemented
+  void operator=(const SALOMEDS_ChildIterator_i&); // Not implemented
+
 private:
-  CORBA::ORB_ptr           _orb;
+  SALOMEDS_Study_i*        _study;
   TDF_Label                _lab;
   TDF_ChildIterator        _it;
+
 public:
+  SALOMEDS_ChildIterator_i(SALOMEDS_Study_i* theStudy,
+                          const TDF_Label& theLabel);
 
-  //! standard constructor  
-  SALOMEDS_ChildIterator_i(TDF_Label lab,CORBA::ORB_ptr);
-  
-  //! standard destructor
   ~SALOMEDS_ChildIterator_i();
   
   virtual void Init();
@@ -63,4 +62,6 @@ public:
   virtual void Next();
   virtual SALOMEDS::SObject_ptr Value();
 };
+
+
 #endif
index 8c6f980de6f7fbf2fee85bafc11ce759440294fe..b9a24946ad537f915a15731d50889cc301bd6eba 100644 (file)
 //  Module : SALOME
 //  $Header$
 
-#include <TDataStd_TreeNode.hxx>
-#include <TDataStd_UAttribute.hxx>
-
-#include "SALOMEDS_AttributeDrawable_i.hxx"
-#include "SALOMEDS_AttributeSelectable_i.hxx"
-#include "SALOMEDS_AttributeOpened_i.hxx"
-#include "SALOMEDS_AttributeFlags_i.hxx"
-#include "SALOMEDS_AttributeGraphic_i.hxx"
-#include "SALOMEDS_AttributeTextColor_i.hxx"
-#include "SALOMEDS_AttributeTextHighlightColor_i.hxx"
-#include "SALOMEDS_AttributePixMap_i.hxx"
-#include "SALOMEDS_AttributeExpandable_i.hxx"
-#include "SALOMEDS_AttributeLocalID_i.hxx"
-#include "SALOMEDS_AttributeTarget_i.hxx"
-#include "SALOMEDS_AttributeTableOfInteger_i.hxx"
-#include "SALOMEDS_AttributeTableOfReal_i.hxx"
-#include "SALOMEDS_AttributeTableOfString_i.hxx"
-#include "SALOMEDS_AttributeStudyProperties_i.hxx"
-#include "SALOMEDS_AttributePythonObject_i.hxx"
-#include "SALOMEDS_AttributeTreeNode_i.hxx"
-#include "SALOMEDS_AttributeUserID_i.hxx"
-#include "SALOMEDS_AttributeExternalFileDef_i.hxx"
-#include "SALOMEDS_AttributeFileType_i.hxx"
-#include "SALOMEDS_StudyBuilder_i.hxx"
-
-#include "SALOMEDS_SequenceOfRealAttribute.hxx"
-#include "SALOMEDS_SequenceOfIntegerAttribute.hxx"
-#include "SALOMEDS_IORAttribute.hxx"
-#include "SALOMEDS_PersRefAttribute.hxx"
-#include "SALOMEDS_DrawableAttribute.hxx"
-#include "SALOMEDS_SelectableAttribute.hxx"
-#include "SALOMEDS_ExpandableAttribute.hxx"
-#include "SALOMEDS_OpenedAttribute.hxx"
-#include "SALOMEDS_FlagsAttribute.hxx"
-#include "SALOMEDS_GraphicAttribute.hxx"
-#include "SALOMEDS_TextColorAttribute.hxx"
-#include "SALOMEDS_TextHighlightColorAttribute.hxx"
-#include "SALOMEDS_PixMapAttribute.hxx"
-#include "SALOMEDS_LocalIDAttribute.hxx"
-#include "SALOMEDS_PythonObjectAttribute.hxx"
-#include "SALOMEDS_TargetAttribute.hxx"
-#include "SALOMEDS_StudyPropertiesAttribute.hxx"
-#include "SALOMEDS_TableOfIntegerAttribute.hxx"
-#include "SALOMEDS_TableOfRealAttribute.hxx"
-#include "SALOMEDS_TableOfStringAttribute.hxx"
-#include "SALOMEDS_ExternalFileDef.hxx"
-#include "SALOMEDS_FileType.hxx"
-#include "Utils_ExceptHandlers.hxx"
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDS_SObject_i.hxx"
+#include "SALOMEDS_Study_i.hxx"
 
 using namespace std;
 
-#define RegisteredAttributes 28
-
-UNEXPECT_CATCH(GALockProtection, SALOMEDS::GenericAttribute::LockProtection);
-
-const char AttributesTypeNames[RegisteredAttributes][30] = {
-  "AttributeReal", "AttributeInteger",
-  "AttributeSequenceOfReal", "AttributeSequenceOfInteger",
-  "AttributeName", "AttributeComment",
-  "AttributeIOR", "AttributePersistentRef",
-  "AttributeDrawable", "AttributeSelectable",
-  "AttributeExpandable", "AttributeOpened",
-  "AttributeTextColor", "AttributeTextHighlightColor", "AttributePixMap",
-  "AttributeTreeNode", "AttributeLocalID",
-  "AttributeTarget",
-  "AttributeTableOfInteger", "AttributeTableOfReal", "AttributeTableOfString",
-  "AttributeStudyProperties",
-  "AttributePythonObject",
-  "AttributeUserID",
-  "AttributeExternalFileDef", "AttributeFileType",
-  "AttributeFlags",
-  "AttributeGraphic"
-};
-
-const Standard_GUID AttributesGUIDs[RegisteredAttributes] = {
-  TDataStd_Real::GetID(), TDataStd_Integer::GetID(),
-  SALOMEDS_SequenceOfRealAttribute::GetID(), SALOMEDS_SequenceOfIntegerAttribute::GetID(),
-  TDataStd_Name::GetID(), TDataStd_Comment::GetID(),
-  SALOMEDS_IORAttribute::GetID(), SALOMEDS_PersRefAttribute::GetID(),
-  SALOMEDS_DrawableAttribute::GetID(), SALOMEDS_SelectableAttribute::GetID(),
-  SALOMEDS_ExpandableAttribute::GetID(), SALOMEDS_OpenedAttribute::GetID(),
-  SALOMEDS_TextColorAttribute::GetID(), SALOMEDS_TextHighlightColorAttribute::GetID(), SALOMEDS_PixMapAttribute::GetID(),
-  TDataStd_TreeNode::GetDefaultTreeID(), SALOMEDS_LocalIDAttribute::GetID(),
-  SALOMEDS_TargetAttribute::GetID(),
-  SALOMEDS_TableOfIntegerAttribute::GetID(), SALOMEDS_TableOfRealAttribute::GetID(), SALOMEDS_TableOfStringAttribute::GetID(),
-  SALOMEDS_StudyPropertiesAttribute::GetID(),
-  SALOMEDS_PythonObjectAttribute::GetID(),
-  Standard_GUID("FFFFFFFF-D9CD-11d6-945D-1050DA506788"),
-  SALOMEDS_ExternalFileDef::GetID(), SALOMEDS_FileType::GetID(),
-  SALOMEDS_FlagsAttribute::GetID(),
-  SALOMEDS_GraphicAttribute::GetID()
-};
-
-void SALOMEDS_GenericAttribute_i::CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection) {
-  Unexpect aCatch(GALockProtection);
-  if (!_myAttr.IsNull() && _myAttr->IsValid() && !CORBA::is_nil(_myOrb)) {
-    Handle(SALOMEDS_IORAttribute) Att;
-    if (_myAttr->Label().Root().FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){
-      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()) {
-//       MESSAGE("Locked document modification !!!");
-       throw SALOMEDS::GenericAttribute::LockProtection();
-      }
-    }
-  }
+
+SALOMEDS_GenericAttribute_i::SALOMEDS_GenericAttribute_i(const Handle(TDF_Attribute)& theAttr,
+                                                        SALOMEDS_SObject_i* theSObject):
+  _myBasicAttr(theAttr),
+  _mySObject(theSObject)
+{
 }
 
-SALOMEDS::SObject_ptr SALOMEDS_GenericAttribute_i::GetSObject() {
-  if (_myAttr.IsNull() || _myAttr->Label().IsNull()) return SALOMEDS::SObject::_nil();
-  SALOMEDS_SObject_i *  so_servant = new SALOMEDS_SObject_i (_myAttr->Label(),_myOrb);
-  SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); 
-  return so._retn();
+
+SALOMEDS_GenericAttribute_i::~SALOMEDS_GenericAttribute_i()
+{
 }
 
-Standard_GUID SALOMEDS_GenericAttribute_i::GetGUID(const char* theType) {
-  Standard_Integer i;
-  for(i = 0; i < RegisteredAttributes; i++) {
-    if (strcmp(AttributesTypeNames[i], theType) == 0) return AttributesGUIDs[i];
-  }
-
-  if (strncmp(theType, "AttributeTreeNodeGUID",21) == 0) {
-    char* aGUIDString = new char[40];
-    sprintf(aGUIDString, &(theType[21]));
-    Standard_GUID aGUID = Standard_GUID(aGUIDString); // create tree node GUID by name
-    delete(aGUIDString);
-    return aGUID;
-  }
-  return Standard_GUID();
+
+char* SALOMEDS_GenericAttribute_i::Store()
+{
+  return CORBA::string_dup("");
 }
 
-char* SALOMEDS_GenericAttribute_i::Type() {
-  if (_myAttr.IsNull()) return "";
-  int i;
-  for(i = 0; i < RegisteredAttributes; i++) {
-    if (_myAttr->ID() == AttributesGUIDs[i]) {
-      CORBA::String_var aString(AttributesTypeNames[i]);
-      return aString._retn();
-    }
-  }
-  Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(_myAttr);
-  if (!aNode.IsNull()) {
-    char* aNodeName = new char[60];
-    char aGUID[40];
-    aNode->ID().ToCString(aGUID);
-    sprintf(aNodeName, "AttributeTreeNodeGUID%s",aGUID);
-    return aNodeName;
-  }
-
-  Handle(TDataStd_UAttribute) aUAttr = Handle(TDataStd_UAttribute)::DownCast(_myAttr);
-  if (!aUAttr.IsNull()) {
-    char* aUAttrName = new char[60];
-    char aGUID[40];
-    aUAttr->ID().ToCString(aGUID);
-    sprintf(aUAttrName, "AttributeUserID_%s",aGUID); 
-    return aUAttrName;
-  }
-
-  return "";
+
+void SALOMEDS_GenericAttribute_i::Restore(const char*)
+{
 }
 
-SALOMEDS::GenericAttribute_ptr SALOMEDS_GenericAttribute_i::CreateAttribute(CORBA::ORB_ptr theOrb,
-                                                                           const Handle(TDF_Attribute)& theAttr) {
-
-  __ReturnCORBAAttribute(TDataStd_Real, AttributeReal);
-  __ReturnCORBAAttribute(TDataStd_Integer, AttributeInteger);
-  __ReturnCORBAAttribute(SALOMEDS_SequenceOfRealAttribute, AttributeSequenceOfReal);
-  __ReturnCORBAAttribute(SALOMEDS_SequenceOfIntegerAttribute, AttributeSequenceOfInteger);
-  __ReturnCORBAAttribute(TDataStd_Name, AttributeName);
-  __ReturnCORBAAttribute(TDataStd_Comment, AttributeComment);
-  __ReturnCORBAAttribute(SALOMEDS_IORAttribute, AttributeIOR);
-  __ReturnCORBAAttribute(SALOMEDS_PersRefAttribute, AttributePersistentRef);
-  __ReturnCORBAAttribute(SALOMEDS_DrawableAttribute, AttributeDrawable);
-  __ReturnCORBAAttribute(SALOMEDS_SelectableAttribute, AttributeSelectable);
-  __ReturnCORBAAttribute(SALOMEDS_ExpandableAttribute, AttributeExpandable);
-  __ReturnCORBAAttribute(SALOMEDS_OpenedAttribute, AttributeOpened);
-  __ReturnCORBAAttribute(SALOMEDS_TextColorAttribute, AttributeTextColor);
-  __ReturnCORBAAttribute(SALOMEDS_TextHighlightColorAttribute, AttributeTextHighlightColor);
-  __ReturnCORBAAttribute(SALOMEDS_PixMapAttribute, AttributePixMap);
-  __ReturnCORBAAttribute(SALOMEDS_LocalIDAttribute, AttributeLocalID);
-  __ReturnCORBAAttribute(SALOMEDS_TargetAttribute, AttributeTarget);
-  __ReturnCORBAAttribute(SALOMEDS_TableOfIntegerAttribute, AttributeTableOfInteger);
-  __ReturnCORBAAttribute(SALOMEDS_TableOfRealAttribute, AttributeTableOfReal);
-  __ReturnCORBAAttribute(SALOMEDS_TableOfStringAttribute, AttributeTableOfString);
-  __ReturnCORBAAttribute(SALOMEDS_StudyPropertiesAttribute, AttributeStudyProperties);
-  __ReturnCORBAAttribute(SALOMEDS_PythonObjectAttribute, AttributePythonObject);
-  __ReturnCORBAAttribute(SALOMEDS_ExternalFileDef, AttributeExternalFileDef);
-  __ReturnCORBAAttribute(SALOMEDS_FileType, AttributeFileType);
-  __ReturnCORBAAttribute(SALOMEDS_FlagsAttribute, AttributeFlags);
-  __ReturnCORBAAttribute(SALOMEDS_GraphicAttribute, AttributeGraphic);
-
-  Handle(TDataStd_TreeNode) aNode = Handle(TDataStd_TreeNode)::DownCast(theAttr);
-  if (!aNode.IsNull()) {
-    SALOMEDS_AttributeTreeNode_i* Attr = new SALOMEDS_AttributeTreeNode_i(aNode, theOrb); \
-    return Attr->AttributeTreeNode::_this(); \
-  }
-
-  Handle(TDataStd_UAttribute) aUAttr = Handle(TDataStd_UAttribute)::DownCast(theAttr);
-  if (!aUAttr.IsNull()) {
-    SALOMEDS_AttributeUserID_i* Attr = new SALOMEDS_AttributeUserID_i(aUAttr, theOrb); \
-    return Attr->AttributeUserID::_this(); \
-  }
-  return SALOMEDS::GenericAttribute::_nil();
+
+char* SALOMEDS_GenericAttribute_i::Type() 
+{
+  return CORBA::string_dup(SALOMEDS::GetType(_myBasicAttr).c_str());
+}
+
+
+SALOMEDS::SObject_ptr SALOMEDS_GenericAttribute_i::GetSObject()
+{
+  return _mySObject->_this();;
+}
+
+
+void SALOMEDS_GenericAttribute_i::CheckLocked() 
+  throw (SALOMEDS::GenericAttribute::LockProtection) 
+{
+  _mySObject->GetStudyServant()->CheckLocked();
 }
index 2e4af4382fb204d4e83330260e36158b866d7a27..80a7c96e081a6dc03fa81f8be07b4e7a9e555be3 100644 (file)
 #ifndef _GENERIC_ATTRIBUTE_I_HXX_
 #define _GENERIC_ATTRIBUTE_I_HXX_
 
+#include <TDF_Attribute.hxx>
+#include <Standard_GUID.hxx>
+
 // IDL headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS)
-#include <TDF_Attribute.hxx>
-#include "SALOMEDS_SObject_i.hxx"
 
-class SALOMEDS_GenericAttribute_i: public POA_SALOMEDS::GenericAttribute,
-                                  public PortableServer::RefCountServantBase {
+class SALOMEDS_SObject_i;
+
+class SALOMEDS_GenericAttribute_i:
+  public virtual POA_SALOMEDS::GenericAttribute,
+  public virtual PortableServer::RefCountServantBase 
+{ 
+private: 
+  friend class SALOMEDS_SObject_i;
+
+  SALOMEDS_GenericAttribute_i(); // Not implemented
+  void operator=(const SALOMEDS_GenericAttribute_i&);  //Not implemented
+
 protected:
-  Handle(TDF_Attribute) _myAttr;
-  CORBA::ORB_ptr        _myOrb;
-public:
-  SALOMEDS_GenericAttribute_i() {};
-  
-  void CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection);
+  SALOMEDS_SObject_i* _mySObject;
+  Handle(TDF_Attribute) _myBasicAttr;
 
-  char* Store() {return "";};
+  SALOMEDS_GenericAttribute_i(const Handle(TDF_Attribute)& theAttr,
+                             SALOMEDS_SObject_i* theSObject);
+  
+  virtual ~SALOMEDS_GenericAttribute_i();
 
-  void Restore(const char*) {};
+  void SetBasicAttribute(const Handle(TDF_Attribute)& theAttr){
+    _myBasicAttr = theAttr;
+  }
   
-  char* Type();
+public:
+  void Restore(const char*);
 
+  char* Store();
+
+  char* Type();
+  
   SALOMEDS::SObject_ptr GetSObject();
 
-  ~SALOMEDS_GenericAttribute_i() {};
+  void CheckLocked() 
+    throw (SALOMEDS::GenericAttribute::LockProtection);
+
+  virtual void SetAttribute(const Handle(TDF_Attribute)& theAttr) = 0;
 
-  static Standard_GUID GetGUID(const char* theType);
+  virtual const Handle(TDF_Attribute)& GetAttribute() const = 0;
 
-  static SALOMEDS::GenericAttribute_ptr CreateAttribute(CORBA::ORB_ptr theOrb, const Handle(TDF_Attribute)& theAttr);
 };
 
-// defines for creation attributes objects
 
-//MESSAGE("*** Create new CORBA attribute for "<<#CORBA_Name);
-#define __ReturnCORBAAttribute(OCAF_Name, CORBA_Name) if (theAttr->ID() == OCAF_Name::GetID()) { \
-    SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(Handle(OCAF_Name)::DownCast(theAttr), theOrb); \
-    return Attr->CORBA_Name::_this(); \
-  }
+template<class TDFAttribute, class TStoreTDFAttribute, bool TIsCheckLockedStudy = true>
+class SALOMEDS_TGenericAttribute_i:
+  public virtual SALOMEDS_GenericAttribute_i
+{
+public:
+  typedef TDFAttribute TAttr;
+  typedef TStoreTDFAttribute TStoreAttr;
 
-//MESSAGE("Create New Attribute "<<#CORBA_Name);
-#define __FindOrCreateAttribute(OCAF_Name, CORBA_Name) if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \
-    Handle(OCAF_Name) anAttr; \
-    if (!Lab.FindAttribute(OCAF_Name::GetID(), anAttr)) { \
-      anAttr = new OCAF_Name; \
-      Lab.AddAttribute(anAttr); \
-    } \
-    SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(anAttr, _orb); \
-    return Attr->CORBA_Name::_this(); \
+  virtual void SetAttribute(const Handle(TDF_Attribute)& theAttr){
+    _myAttr = TStoreAttr::DownCast(theAttr);
+    SetBasicAttribute(theAttr);
   }
+  virtual const Handle(TDF_Attribute)& GetAttribute() const{
+    return _myAttr;
+  }
+  static bool IsCheckLockedStudy(){
+    return TIsCheckLockedStudy;
+  }
+  static Handle(TDF_Attribute) NewAttribute(){
+    return new TAttr;
+  }
+
+protected:
+  TStoreAttr _myAttr;
 
-//MESSAGE("Create New Attribute "<<#CORBA_Name);
-#define __FindOrCreateAttributeLocked(OCAF_Name, CORBA_Name) if (strcmp(aTypeOfAttribute, #CORBA_Name) == 0) { \
-    Handle(OCAF_Name) anAttr; \
-    if (!Lab.FindAttribute(OCAF_Name::GetID(), anAttr)) { \
-      CheckLocked(); \
-      anAttr = new OCAF_Name; \
-      Lab.AddAttribute(anAttr); \
-    } \
-    SALOMEDS_##CORBA_Name##_i* Attr = new SALOMEDS_##CORBA_Name##_i(anAttr, _orb); \
-    return Attr->CORBA_Name::_this(); \
+  SALOMEDS_TGenericAttribute_i(const Handle(TDF_Attribute)& theAttr,
+                              SALOMEDS_SObject_i* theSObject):
+    SALOMEDS_GenericAttribute_i(theAttr,theSObject),
+    _myAttr(TStoreAttr::DownCast(theAttr))
+  {
   }
+  
+private: 
+  friend class SALOMEDS_SObject_i;
+
+  SALOMEDS_TGenericAttribute_i(); //Not implemented
+  void operator=(const SALOMEDS_TGenericAttribute_i&);  //Not implemented
+
+};
+
+
+#define DEFINE_DERIVED_ATTR(TName,TAttr,TCheck) \
+  typedef SALOMEDS_TGenericAttribute_i<TAttr,Handle_##TAttr,TCheck> \
+    SALOMEDS_T##TName##_i
+
+
+#define DEFINE_DERIVED_ATTR_METH_BASE(TName) \
+public: \
+  friend class SALOMEDS_SObject_i; \
+  static SALOMEDS_GenericAttribute_i* \
+    NewInstance(const Handle(TDF_Attribute)& theAttr, \
+                SALOMEDS_SObject_i* theSObject) \
+      { return new SALOMEDS_##TName##_i(theAttr,theSObject);} \
+private: \
+  SALOMEDS_##TName##_i(const Handle(TDF_Attribute)& theAttr, \
+                       SALOMEDS_SObject_i* theSObject): \
+    SALOMEDS_GenericAttribute_i(theAttr,theSObject), \
+    SALOMEDS_T##TName##_i(theAttr,theSObject) \
+    {} \
+  void operator=(const SALOMEDS_##TName##_i&); \
+  SALOMEDS_##TName##_i()
+
+
+#define DEFINE_DERIVED_ATTR_METH_DEFAULT(TName,TAttr) \
+DEFINE_DERIVED_ATTR_METH_BASE(TName); \
+public: \
+  static Standard_GUID GetGUID(){ return TAttr::GetID(); } \
+private:
+
+
+#define DEFINE_DERIVED_ATTR_METH(TName,theGUID) \
+DEFINE_DERIVED_ATTR_METH_BASE(TName); \
+public: \
+  static Standard_GUID GetGUID(){ return theGUID; } \
+private:
+
 
 #endif
index 1cd09ebe6164c3f6e7d2aa7e0db9fe50ff0731ed..541d90b493dc4ab09fe247fb0b952d859c491a42 100644 (file)
@@ -27,8 +27,9 @@
 //  $Header$
 
 #include "SALOMEDS_SComponentIterator_i.hxx"
-using namespace std;
+#include "SALOMEDS_SComponent_i.hxx"
 
+using namespace std;
 
 //============================================================================
 /*! Function : constructor
@@ -36,12 +37,12 @@ using namespace std;
  */
 //============================================================================
 
-SALOMEDS_SComponentIterator_i::SALOMEDS_SComponentIterator_i(const Handle(TDocStd_Document) aDoc, 
-                                                            CORBA::ORB_ptr orb) 
+SALOMEDS_SComponentIterator_i::SALOMEDS_SComponentIterator_i(SALOMEDS_Study_i* theStudy,
+                                                            const Handle(TDocStd_Document)& theDocument): 
+  _it(theDocument->Main()),
+  _lab(theDocument->Main()),
+  _study(theStudy)
 {
-  _orb = CORBA::ORB::_duplicate(orb);
-  _lab = aDoc->Main();
-  _it.Initialize (_lab);
 }
 
 //============================================================================
@@ -96,8 +97,6 @@ void SALOMEDS_SComponentIterator_i::Next()
 //============================================================================
 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;
+  return SALOMEDS_SComponent_i::New(_study,_it.Value())->_this();
 }
 
index 7d3d29249885f2520a82b2b26bca1fe48a40b734..ca2f51f478fca7e7e255035ca7b6273193569f63 100644 (file)
 #ifndef __SALOMEDS_SCOMPONENTITERATOR_I_H__
 #define __SALOMEDS_SCOMPONENTITERATOR_I_H__
 
-// std C++ headers
-#include <iostream.h>
-
 // IDL headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS)
 
-//SALOMEDS headers
-#include "SALOMEDS_SComponent_i.hxx"
-
 // Cascade headers
 #include <TDocStd_Document.hxx>
 #include <TDF_ChildIterator.hxx>
 #include <TDF_Label.hxx>
-#include <stdio.h>
 
-class SALOMEDS_SComponentIterator_i:public POA_SALOMEDS::SComponentIterator,
-                                   public PortableServer::RefCountServantBase {
+class SALOMEDS_Study_i;
 
-private:
+class SALOMEDS_SComponentIterator_i:public virtual POA_SALOMEDS::SComponentIterator,
+                                   public virtual PortableServer::RefCountServantBase 
+{
+  SALOMEDS_SComponentIterator_i(); // Not implemented
+  void operator=(const SALOMEDS_SComponentIterator_i&); // Not implemented
 
-  CORBA::ORB_ptr           _orb;
+private:
   TDF_ChildIterator        _it;
   TDF_Label                _lab;
+  SALOMEDS_Study_i*        _study;
 
 public:
-  
-  SALOMEDS_SComponentIterator_i(const Handle(TDocStd_Document) adoc, CORBA::ORB_ptr);
+  SALOMEDS_SComponentIterator_i(SALOMEDS_Study_i* theStudy,
+                               const Handle(TDocStd_Document)& theDocument);
   
   ~SALOMEDS_SComponentIterator_i();
   
@@ -65,4 +62,6 @@ public:
   virtual void Next();
   virtual SALOMEDS::SComponent_ptr Value();  
 };
+
+
 #endif
index ee89975662afd00cd7372111b4d40724f009ec58..53cfc55503879957f78cf02c81b6dc2a6baddbd8 100644 (file)
 //  $Header$
 
 #include "SALOMEDS_SComponent_i.hxx"
+#include "SALOMEDS_Study_i.hxx"
+
 #include "utilities.h"
+
 using namespace std;
 
+SALOMEDS_SComponent_i* SALOMEDS_SComponent_i::New(SALOMEDS_Study_i* theStudy,
+                                                 const TDF_Label& theLabel)
+{
+  SALOMEDS_SComponent_i* aSComponent = NULL;
+  SALOMEDS_Study_i::TSObjectMap& anSObjectMap = theStudy->GetSObjectMap();
+  SALOMEDS_Study_i::TSObjectMap::const_iterator anIter = anSObjectMap.find(theLabel);
+  //cout<<"SALOMEDS_SComponent_i::New - "<<theLabel.Tag()<<" - "<<anSObjectMap.size()<<endl;
+  if(anIter != anSObjectMap.end()){
+    SALOMEDS_SObject_i* aSObject = anIter->second;
+    aSComponent = dynamic_cast<SALOMEDS_SComponent_i*>(aSObject);
+  }
+  if(aSComponent == NULL){
+    aSComponent = new SALOMEDS_SComponent_i(theStudy,theLabel);
+    anSObjectMap[theLabel] = aSComponent;
+  }
+  return aSComponent;
+}
 
 //============================================================================
 /*! Function : constructor
  *  Purpose  : 
  */
 //============================================================================
-SALOMEDS_SComponent_i::SALOMEDS_SComponent_i(const TDF_Label lab, CORBA::ORB_ptr orb)
-  :SALOMEDS_SObject_i(lab,orb)
+SALOMEDS_SComponent_i::SALOMEDS_SComponent_i(SALOMEDS_Study_i* theStudy,
+                                            const TDF_Label& theLabel):
+  SALOMEDS_SObject_i(theStudy,theLabel)
 {
 }
   
@@ -97,7 +118,7 @@ CORBA::Boolean SALOMEDS_SComponent_i::ComponentIOR(CORBA::String_out IOR)
  *  Purpose  : 
  */
 //============================================================================
-Standard_Boolean SALOMEDS_SComponent_i::IsA(const TDF_Label Lab)
+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
index 9695e22507d7e4a0b3a848076bf812fc373dbf14..3373a4175265dc8e5f774c3720cc463823d562ce 100644 (file)
 #ifndef __SALOMEDS_SCOMPONENT_I_H__
 #define __SALOMEDS_SCOMPONENT_I_H__
 
-// std C++ headers
-#include <iostream.h>
-
-// IDL headers
-#include <SALOMEconfig.h>
-#include CORBA_SERVER_HEADER(SALOMEDS)
-
-//SALOMEDS headers
 #include "SALOMEDS_SObject_i.hxx"
-#include "SALOMEDS_IORAttribute.hxx"
-
-// Cascade headers
-#include <TDF_Label.hxx>
-#include <TDataStd_Name.hxx>
-#include <TDataStd_Comment.hxx>
-#include <TCollection_AsciiString.hxx> 
-#include <TDF_Tool.hxx>
-#include <stdio.h>
 
-class SALOMEDS_SComponent_i: public POA_SALOMEDS::SComponent,
-                            public SALOMEDS_SObject_i
+class SALOMEDS_SComponent_i: public virtual POA_SALOMEDS::SComponent,
+                            public virtual SALOMEDS_SObject_i
 {
-public:
+  SALOMEDS_SComponent_i(); // Not implemented
+  void operator=(const SALOMEDS_SComponent_i&); // Not implemented
+
+  SALOMEDS_SComponent_i(SALOMEDS_Study_i* theStudy,
+                       const TDF_Label& theLabel);
   
-  SALOMEDS_SComponent_i(const TDF_Label lab, CORBA::ORB_ptr);
+public:
+  static SALOMEDS_SComponent_i* New(SALOMEDS_Study_i* theStudy,
+                                   const TDF_Label& theLabel);
   
   ~SALOMEDS_SComponent_i();
   
-
   virtual char* ComponentDataType();
-  virtual CORBA::Boolean ComponentIOR(CORBA::String_out theID);
 
-  static Standard_Boolean IsA(const TDF_Label Lab);
-    
+  virtual CORBA::Boolean ComponentIOR(CORBA::String_out theID);
+  
+  static Standard_Boolean IsA(const TDF_Label& Lab);
 
 };
+
+
 #endif
index 00e37cfad17527ac8821206c5fe8a5e2b2ecc0af..62b2f3d89077cb89cae6c7ab19454368010d7fdb 100644 (file)
 //  Module : SALOME
 //  $Header$
 
-#include "utilities.h"
+#include <TDF_Tool.hxx>
+#include <TDF_Attribute.hxx>
+#include <TDF_Reference.hxx>
+#include <Standard_GUID.hxx>
+#include <Standard_NoSuchObject.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDataStd_Comment.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_Real.hxx>
+#include <TDataStd_TreeNode.hxx>
+#include <TDataStd_UAttribute.hxx>
+
+#include <TCollection_AsciiString.hxx>
+#include <TDF_AttributeIterator.hxx>
+
 #include "SALOMEDS_SObject_i.hxx"
+
 //SALOMEDS Headers
+#include "SALOMEDS_Study_i.hxx"
+#include "SALOMEDS_StudyManager_i.hxx"
 #include "SALOMEDS_SComponent_i.hxx"
-#include "SALOMEDS_GenericAttribute_i.hxx"
-#include "SALOMEDS_IORAttribute.hxx"
-#include <TDF_AttributeIterator.hxx>
+
+#include "SALOMEDS_AttributeComment_i.hxx"
+
+#include "SALOMEDS_AttributeTreeNode_i.hxx"
+#include "SALOMEDS_AttributeUserID_i.hxx"
+
+#include "SALOMEDS_AttributePersistentRef_i.hxx"
+#include "SALOMEDS_AttributeIOR_i.hxx"
+#include "SALOMEDS_AttributeExternalFileDef_i.hxx"
+#include "SALOMEDS_AttributeFileType_i.hxx"
+#include "SALOMEDS_AttributeName_i.hxx"
+#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx"
+#include "SALOMEDS_AttributeSequenceOfReal_i.hxx"
+#include "SALOMEDS_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_AttributeTarget_i.hxx"
+#include "SALOMEDS_AttributeLocalID_i.hxx"
+#include "SALOMEDS_AttributeStudyProperties_i.hxx"
+#include "SALOMEDS_AttributePythonObject_i.hxx"
+
+#include "SALOMEDS_AttributeGraphic_i.hxx"
+#include "SALOMEDS_AttributeFlags_i.hxx"
+
+#include "Utils_ExceptHandlers.hxx"
+UNEXPECT_CATCH(GALockProtection, SALOMEDS::GenericAttribute::LockProtection);
+
+#include "utilities.h"
+
 using namespace std;
+using namespace SALOMEDS;
+
+
+inline bool operator<(const Standard_GUID& theLeft, const Standard_GUID& theRight)
+{
+  char aLeft[40] = "";
+  theLeft.ToCString(aLeft);
+
+  char aRight[40] = "";
+  theRight.ToCString(aRight);
+  
+  return strcmp(aLeft,aRight) < 0;
+}
+
+
+namespace SALOMEDS{
+
+  const char* Str(const TCollection_ExtendedString& theString)
+  {
+    return TCollection_AsciiString(theString).ToCString();
+  }
+
+  typedef std::string TAttributeID;
+
+  typedef Standard_GUID (*TGetGUID)();
+  typedef bool (*TIsCheckLockedStudy)();
+  typedef Handle(TDF_Attribute) (*TNewAttribute)();
+  typedef SALOMEDS_GenericAttribute_i* (*TNewInstance)(const Handle(TDF_Attribute)&, SALOMEDS_SObject_i*);
+  
+  struct TAttrFun{
+    TAttrFun(const TGetGUID& theGetGUID,
+            const TIsCheckLockedStudy& theIsCheckLockedStudy,
+            const TNewAttribute& theNewAttribute,
+            const TNewInstance& theNewInstance):
+      myGetGUID(theGetGUID),
+      myIsCheckLockedStudy(theIsCheckLockedStudy),
+      myNewAttribute(theNewAttribute),
+      myNewInstance(theNewInstance)
+    {
+    }
+
+    TGetGUID myGetGUID;
+    TIsCheckLockedStudy myIsCheckLockedStudy;
+    TNewAttribute myNewAttribute;
+    TNewInstance myNewInstance;
+  };
+  
+  typedef std::map<TAttributeID,TAttrFun> TAttrID2FunMap;
+  static TAttrID2FunMap __AttrID2FunMap__;
+  
+  
+  typedef std::map<Standard_GUID,TAttributeID> TGUID2AttrIDMap;
+  static TGUID2AttrIDMap __GUID2AttrIDMap__;
+  
+  bool Init()
+  {
+    
+#define ADD_ATTRID2FUNMAP_ITEM(theName) \
+    __AttrID2FunMap__.insert( \
+      TAttrID2FunMap::value_type(#theName,TAttrFun( \
+       &(SALOMEDS_##theName##_i::GetGUID), \
+       &(SALOMEDS_##theName##_i::IsCheckLockedStudy), \
+       &(SALOMEDS_##theName##_i::NewAttribute), \
+       &(SALOMEDS_##theName##_i::NewInstance) \
+    )))
+                                                      
+    ADD_ATTRID2FUNMAP_ITEM(AttributeName);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeComment); 
+    ADD_ATTRID2FUNMAP_ITEM(AttributeIOR);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeReal);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeInteger);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeSequenceOfInteger);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeSequenceOfReal);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeTableOfInteger);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeTableOfReal);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeTableOfString);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeLocalID);
+    ADD_ATTRID2FUNMAP_ITEM(AttributePythonObject);
+    
+    ADD_ATTRID2FUNMAP_ITEM(AttributeUserID);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeTreeNode);
+
+    ADD_ATTRID2FUNMAP_ITEM(AttributePersistentRef);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeDrawable);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeSelectable);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeExpandable);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeOpened);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeTextColor);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeTextHighlightColor);
+    ADD_ATTRID2FUNMAP_ITEM(AttributePixMap);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeTarget);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeStudyProperties);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeExternalFileDef);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeFileType);
+
+    ADD_ATTRID2FUNMAP_ITEM(AttributeGraphic);
+    ADD_ATTRID2FUNMAP_ITEM(AttributeFlags);
+
+    TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.begin();
+    TAttrID2FunMap::const_iterator anEnd = __AttrID2FunMap__.end();
+    for(; anIter != anEnd; anIter++){
+      const TAttrID2FunMap::key_type& aKey = anIter->first;
+      const TAttrID2FunMap::data_type& aValue = anIter->second;
+      __GUID2AttrIDMap__[aValue.myGetGUID()] = aKey;
+    };
+
+#undef ADD_ATTRID2FUNMAP_ITEM
+    return true;
+  }
+  
+
+  static bool __IsInitilized__ = Init();
+
+
+  //============================================================================
+  bool GetAttrFun(const Standard_GUID& theGUID, TAttrFun& theAttrFun)
+  {
+    TGUID2AttrIDMap::const_iterator anIter = __GUID2AttrIDMap__.find(theGUID);
+    if(anIter != __GUID2AttrIDMap__.end())
+    {
+      const TAttributeID& anAttributeID = anIter->second;
+      TAttrID2FunMap::const_iterator anIter2 = __AttrID2FunMap__.find(anAttributeID);
+      if(anIter2 != __AttrID2FunMap__.end())
+      {
+       theAttrFun = anIter2->second;
+       return true;
+      }
+    }
+    return false;
+  }
+
+
+  //============================================================================
+  Standard_GUID GetGUID(const char* theType)
+  {
+    TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.find(theType);
+    if(anIter != __AttrID2FunMap__.end()){
+      const TAttrID2FunMap::data_type& aValue = anIter->second;
+      return aValue.myGetGUID();
+    }
+    // create tree node GUID by name
+    if(strncmp(theType,"AttributeTreeNodeGUID",21) == 0){
+      char aGUIDString[40] = "";
+      sprintf(aGUIDString,&theType[21]);
+      return aGUIDString;
+    }
+    
+    return Standard_GUID();
+  }
+
+
+  //============================================================================
+  std::string GetType(const Handle(TDF_Attribute)& theAttr)
+  {
+    if(theAttr.IsNull())
+      return CORBA::string_dup("");
+    
+    Standard_GUID aGUID = theAttr->ID();
+    TGUID2AttrIDMap::const_iterator anIter = __GUID2AttrIDMap__.find(aGUID);
+    if(anIter != __GUID2AttrIDMap__.end())
+    {
+      const TAttributeID& anAttributeID = anIter->second;
+      return anAttributeID;
+    }
+    
+    char aType[60] = "";
+    {
+      Handle(TDataStd_TreeNode) anAttr = Handle(TDataStd_TreeNode)::DownCast(theAttr);
+      if (!anAttr.IsNull()) {
+       char aGUID[40] = "";
+       anAttr->ID().ToCString(aGUID);
+       sprintf(aType, "AttributeTreeNodeGUID%s",aGUID);
+       return aType;
+      }
+    }
+    {
+      Handle(TDataStd_UAttribute) anAttr = Handle(TDataStd_UAttribute)::DownCast(theAttr);
+      if (!anAttr.IsNull()) {
+       char aGUID[40] = "";
+       anAttr->ID().ToCString(aGUID);
+       sprintf(aType, "AttributeUserID_%s",aGUID); 
+       return aType;
+      }
+    }
+    return aType;
+  }
+  
+}  
+  
+//============================================================================
+SALOMEDS_SObject_i* SALOMEDS_SObject_i::New(SALOMEDS_Study_i* theStudy,
+                                           const TDF_Label& theLabel)
+{
+  SALOMEDS_SObject_i* aSObject = NULL;
+  SALOMEDS_Study_i::TSObjectMap& anSObjectMap = theStudy->GetSObjectMap();
+  SALOMEDS_Study_i::TSObjectMap::const_iterator anIter = anSObjectMap.find(theLabel);
+  if(anIter != anSObjectMap.end())
+    aSObject = anIter->second;
+  else{
+    TCollection_AsciiString anEntry;
+    TDF_Tool::Entry(theLabel,anEntry);
+    //cout<<"SALOMEDS_SObject_i::New - "<<anEntry.ToCString()<<endl;
+    aSObject = new SALOMEDS_SObject_i(theStudy,theLabel);
+    anSObjectMap[theLabel] = aSObject;
+  }
+  return aSObject;
+}
 
 //============================================================================
 /*! Function : constructor
  *  Purpose  : 
  */
 //============================================================================
-SALOMEDS_SObject_i::SALOMEDS_SObject_i(const TDF_Label lab, CORBA::ORB_ptr orb)
-  :_lab(lab)
+SALOMEDS_SObject_i::SALOMEDS_SObject_i(SALOMEDS_Study_i* theStudy,
+                                      const TDF_Label& theLabel):
+  _lab(theLabel),
+  _study(theStudy)
 {
-  _orb = CORBA::ORB::_duplicate(orb);
-  _value = NULL;
-  _type = NULL;
-  _name = NULL;
-  _liste_ba_type.resize(0);
 }
-  
 
 //============================================================================
 /*! Function : destructor
@@ -58,12 +313,23 @@ SALOMEDS_SObject_i::SALOMEDS_SObject_i(const TDF_Label lab, CORBA::ORB_ptr orb)
 //============================================================================
 SALOMEDS_SObject_i::~SALOMEDS_SObject_i()
 {
-  CORBA::string_free(_value);
-  CORBA::string_free(_type);
-  CORBA::string_free(_name);
 }
   
-  
+
+//============================================================================
+CORBA::ORB_var SALOMEDS_SObject_i::GetORB() const
+{
+  return _study->GetORB();
+}
+
+
+//============================================================================
+PortableServer::POA_var SALOMEDS_SObject_i::GetPOA() const
+{
+  return _study->GetPOA();
+}
+
+
 //============================================================================
 /*! Function :
  *  Purpose  : 
@@ -72,7 +338,7 @@ SALOMEDS_SObject_i::~SALOMEDS_SObject_i()
 char* SALOMEDS_SObject_i::GetID()
 {
   TCollection_AsciiString anEntry;
-  TDF_Tool::Entry (_lab,anEntry);
+  TDF_Tool::Entry(_lab,anEntry);
   return CORBA::string_dup(anEntry.ToCString());
 }
   
@@ -83,14 +349,11 @@ char* SALOMEDS_SObject_i::GetID()
 //============================================================================
 SALOMEDS::SComponent_ptr SALOMEDS_SObject_i::GetFatherComponent()
 {
-  TDF_Label LF = _lab;
-  while (!SALOMEDS_SComponent_i::IsA(LF) && !LF.IsRoot()) {
-    LF = LF.Father();
+  TDF_Label aSCompLabel = _lab;
+  while(!SALOMEDS_SComponent_i::IsA(aSCompLabel) && !aSCompLabel.IsRoot()){
+    aSCompLabel = aSCompLabel.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;
+  return SALOMEDS_SComponent_i::New(_study,aSCompLabel)->_this();
 }
   
 //============================================================================
@@ -100,11 +363,7 @@ SALOMEDS::SComponent_ptr SALOMEDS_SObject_i::GetFatherComponent()
 //============================================================================
 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;
+  return SALOMEDS_SObject_i::New(_study,_lab.Father())->_this();
 }
 
 //============================================================================
@@ -114,76 +373,21 @@ SALOMEDS::SObject_ptr SALOMEDS_SObject_i::GetFather()
 //============================================================================
 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...
-  }
-  MESSAGE("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;
-  if (_lab.FindAttribute(SALOMEDS_GenericAttribute_i::GetGUID(aTypeOfAttribute), anAttr)) {
-    anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(_orb, anAttr));
-    return Standard_True;
-  }
-  return Standard_False;
+  return _study->_this();
 }
 
-//============================================================================
-/*! 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 = SALOMEDS_GenericAttribute_i::CreateAttribute(_orb, anAttr);
-      if (!CORBA::is_nil(anAttribute)) {
-       SeqOfAttr->length(++i);
-       SeqOfAttr[i - 1] = anAttribute;
-      }
-    }
-  }
-  return SeqOfAttr._retn();
-}
-
-
 //============================================================================
 /*! Function : ReferencedObject
  *  Purpose  : 
  */
 //============================================================================
-CORBA::Boolean SALOMEDS_SObject_i::ReferencedObject(SALOMEDS::SObject_out obj)
+CORBA::Boolean SALOMEDS_SObject_i::ReferencedObject(SALOMEDS::SObject_out theSObject)
 {
-  Handle(TDF_Reference) Ref;
-  if (!_lab.FindAttribute(TDF_Reference::GetID(),Ref))
+  Handle(TDF_Reference) aRef;
+  if (!_lab.FindAttribute(TDF_Reference::GetID(),aRef))
     return false;
   
-  SALOMEDS_SObject_i *  so_servant = new SALOMEDS_SObject_i (Ref->Get(),_orb);
-  obj  = SALOMEDS::SObject::_narrow(so_servant->_this()); 
+  theSObject = SALOMEDS_SObject_i::New(_study,aRef->Get())->_this(); 
   return true;
 }
 
@@ -192,15 +396,14 @@ CORBA::Boolean SALOMEDS_SObject_i::ReferencedObject(SALOMEDS::SObject_out obj)
  *  Purpose  : 
  */
 //============================================================================
-CORBA::Boolean SALOMEDS_SObject_i::FindSubObject(CORBA::Long atag, SALOMEDS::SObject_out obj)
+CORBA::Boolean SALOMEDS_SObject_i::FindSubObject(CORBA::Long theTag, SALOMEDS::SObject_out theSObject)
 {
-  TDF_Label L = _lab.FindChild(atag,false);
-  if (L.IsNull()) return false;
+  TDF_Label aLabel = _lab.FindChild(theTag,false);
+  if(aLabel.IsNull()) 
+    return false;
   
-  SALOMEDS_SObject_i *  so_servant = new SALOMEDS_SObject_i (L,_orb);
-  obj  = SALOMEDS::SObject::_narrow(so_servant->_this()); 
+  theSObject = SALOMEDS_SObject_i::New(_study,aLabel)->_this(); 
   return true;
-    
 }  
 
 //============================================================================
@@ -210,7 +413,7 @@ CORBA::Boolean SALOMEDS_SObject_i::FindSubObject(CORBA::Long atag, SALOMEDS::SOb
 //============================================================================
 char* SALOMEDS_SObject_i::Name()
 {
-  return CORBA::string_dup(_name);
+  return CORBA::string_dup(_name.c_str());
 }
   
 //============================================================================
@@ -218,9 +421,9 @@ char* SALOMEDS_SObject_i::Name()
  *  Purpose  : 
  */
 //============================================================================
-void  SALOMEDS_SObject_i::Name(const char* name)
+void  SALOMEDS_SObject_i::Name(const char* theName)
 {
-  _name = CORBA::string_dup(name);
+  _name = theName;
 }
   
 //============================================================================
@@ -250,16 +453,15 @@ CORBA::Short SALOMEDS_SObject_i::Depth()
 //============================================================================
 CORBA::Object_ptr SALOMEDS_SObject_i::GetObject()
 {
-  CORBA::Object_ptr obj = CORBA::Object::_nil();
   try {
-    Handle(SALOMEDS_IORAttribute) Att;
-    if (_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)) {
-      TCollection_AsciiString ch(Att->Get());
-      char* IOR = CORBA::string_dup(ch.ToCString());
-      obj = _orb->string_to_object(IOR);
+    Handle(SALOMEDS_IORAttribute) anAttr;
+    if(_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),anAttr)){
+      CORBA::ORB_var anORB = _study->GetStudyManager()->GetORB();
+      return anORB->string_to_object(Str(anAttr->Get()));
     }
-  } catch(...) {}
-  return obj;
+  }catch(...){
+  }
+  return CORBA::Object::_nil();
 }
 
 //============================================================================
@@ -268,12 +470,11 @@ CORBA::Object_ptr SALOMEDS_SObject_i::GetObject()
  */
 //============================================================================
 char* SALOMEDS_SObject_i::GetName() {
-  CORBA::String_var aStr = CORBA::string_dup( "" );
-  Handle(TDataStd_Name) aName;
-  if (_lab.FindAttribute(TDataStd_Name::GetID(), aName)) {
-    aStr = CORBA::string_dup(TCollection_AsciiString(aName->Get()).ToCString());
-  }
-  return aStr._retn();
+  Handle(TDataStd_Name) anAttr;
+  if(_lab.FindAttribute(TDataStd_Name::GetID(),anAttr))
+    return CORBA::string_dup(Str(anAttr->Get()));
+
+  return CORBA::string_dup("");
 }
 
 //============================================================================
@@ -282,12 +483,11 @@ char* SALOMEDS_SObject_i::GetName() {
  */
 //============================================================================
 char* SALOMEDS_SObject_i::GetComment() {
-  CORBA::String_var aStr = CORBA::string_dup( "" );
-  Handle(TDataStd_Comment) aComment;
-  if (_lab.FindAttribute(TDataStd_Comment::GetID(), aComment)) {
-    aStr = CORBA::string_dup(TCollection_AsciiString(aComment->Get()).ToCString());
-  }
-  return aStr._retn();
+  Handle(TDataStd_Comment) anAttr;
+  if(_lab.FindAttribute(TDataStd_Comment::GetID(), anAttr))
+    return CORBA::string_dup(Str(anAttr->Get()));
+
+  return CORBA::string_dup("");
 }
 
 //============================================================================
@@ -296,10 +496,232 @@ char* SALOMEDS_SObject_i::GetComment() {
  */
 //============================================================================
 char* SALOMEDS_SObject_i::GetIOR() {
-  CORBA::String_var aStr = CORBA::string_dup( "" );
-  Handle(SALOMEDS_IORAttribute) anIOR;
-  if (_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anIOR)) {
-    aStr = CORBA::string_dup(TCollection_AsciiString(anIOR->Get()).ToCString());
+  Handle(SALOMEDS_IORAttribute) anAttr;
+  if(_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),anAttr))
+    return CORBA::string_dup(Str(anAttr->Get()));
+
+  return CORBA::string_dup("");
+}
+
+
+//============================================================================
+/*! Function : GetAllAttributes
+ *  Purpose  : Returns list of all attributes for this sobject
+ */
+//============================================================================
+SALOMEDS_GenericAttribute_i* 
+SALOMEDS_SObject_i::_FindGenAttribute(const Handle(TDF_Attribute)& theAttr)
+{
+  SALOMEDS_GenericAttribute_i* anGenAttr = NULL;
+
+  Standard_GUID aGUID = theAttr->ID();
+
+  TGUID2AttrIDMap::const_iterator anIter = __GUID2AttrIDMap__.find(aGUID);
+  if(anIter != __GUID2AttrIDMap__.end())
+  {
+    const ::TAttributeID& anAttributeID = anIter->second;
+    TAttrMap::const_iterator anIter = myAttrMap.find(anAttributeID);
+    if(anIter != myAttrMap.end())
+      anGenAttr = anIter->second;
+
+    if(anGenAttr != NULL){
+      if(anGenAttr->GetAttribute() != theAttr)
+       anGenAttr->SetAttribute(theAttr);
+    }else{
+      anGenAttr = _CreateGenAttribute(theAttr,anAttributeID.c_str());
+    }
+  }
+
+  return anGenAttr;
+}
+
+
+SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes()
+{
+  SALOMEDS::ListOfAttributes_var aSeqOfAttr = new SALOMEDS::ListOfAttributes;
+  if(_lab.NbAttributes() > 0){
+    Standard_Integer i = 0;
+    for(TDF_AttributeIterator iter(_lab); iter.More(); iter.Next()) {
+      Handle(TDF_Attribute) anAttr = iter.Value();
+      if(SALOMEDS_GenericAttribute_i* anGenAttr = _FindGenAttribute(anAttr))
+      {
+       aSeqOfAttr->length(++i);
+       aSeqOfAttr[i-1] = anGenAttr->_this();
+      }
+    }
+  }
+
+  return aSeqOfAttr._retn();
+}
+
+
+//============================================================================
+/*! Function : FindAttribute
+ *  Purpose  : Find attribute of given type on this SObject
+ */
+//============================================================================
+SALOMEDS_GenericAttribute_i* 
+SALOMEDS_SObject_i::_CreateGenAttribute(const Handle(TDF_Attribute)& theAttr,
+                                       const char* theType) 
+{
+  
+  TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.find(theType);
+  if(anIter != __AttrID2FunMap__.end()){
+    const TAttrID2FunMap::data_type& aValue = anIter->second;
+    
+    if(aValue.myIsCheckLockedStudy())
+      _study->CheckLocked();
+    
+    return aValue.myNewInstance(theAttr,this);
+  }
+  
+  if(strncmp(theType,"AttributeTreeNode",17) == 0){
+    return new SALOMEDS_AttributeTreeNode_i(theAttr,this);
+  }
+  
+  if(strncmp(theType,"AttributeUserID",15) == 0){
+    return new SALOMEDS_AttributeUserID_i(theAttr,this);
+  }
+  
+  return NULL;
+}
+
+
+SALOMEDS_GenericAttribute_i* 
+SALOMEDS_SObject_i::_FindGenAttribute(const char* theType)
+{
+  SALOMEDS_GenericAttribute_i* anGenAttr = NULL;
+  TAttrMap::const_iterator anIter = myAttrMap.find(theType);
+  if(anIter != myAttrMap.end())
+    anGenAttr = anIter->second;
+
+  Standard_GUID aGUID = ::GetGUID(theType);
+  Handle(TDF_Attribute) anAttr;
+
+  if(_lab.FindAttribute(aGUID,anAttr)){
+    if(anGenAttr != NULL){
+      if(anGenAttr->GetAttribute() != anAttr)
+       anGenAttr->SetAttribute(anAttr);
+    }else{
+      anGenAttr = _CreateGenAttribute(anAttr,theType);
+    }
+    if(anGenAttr != NULL)
+      myAttrMap[theType] = anGenAttr;
+  }else{
+    myAttrMap.erase(theType);
+    //if(anGenAttr != NULL)
+    //  anGenAttr->Destroy();
   }
-  return aStr._retn();
+
+  return anGenAttr;
+}
+
+
+SALOMEDS::GenericAttribute_ptr 
+SALOMEDS_SObject_i::_FindCORBAAttribute(const char* theType)
+{
+  if(SALOMEDS_GenericAttribute_i* anGenAttr = _FindGenAttribute(theType))
+    return anGenAttr->_this();
+  return SALOMEDS::GenericAttribute::_nil();
+}
+
+
+CORBA::Boolean 
+SALOMEDS_SObject_i::FindAttribute(SALOMEDS::GenericAttribute_out theAttribute, 
+                                 const char* theType)
+{
+  theAttribute = _FindCORBAAttribute(theType);
+  return !CORBA::is_nil(theAttribute);
 }
+
+
+//============================================================================
+/*! Function : FindAttribute
+ *  Purpose  : Find attribute of given type on this SObject
+ */
+//============================================================================
+Handle(TDF_Attribute) 
+  SALOMEDS_SObject_i::_AddAttribute(const char* theType) 
+{
+  Handle(TDF_Attribute) anAttr;
+  TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.find(theType);
+  if(anIter != __AttrID2FunMap__.end()){
+    const TAttrID2FunMap::data_type& aValue = anIter->second;
+    
+    if(aValue.myIsCheckLockedStudy())
+      _study->CheckLocked();
+    
+    anAttr = aValue.myNewAttribute();
+    _lab.AddAttribute(anAttr);
+    return anAttr;
+  }
+  
+  if(strncmp(theType, "AttributeTreeNode",17) == 0){
+    Standard_GUID aGUID;
+    if(strcmp(theType, "AttributeTreeNode") == 0){
+      aGUID = TDataStd_TreeNode::GetDefaultTreeID();
+    }else{
+      char aString[40] = "";
+      sprintf(aString, &theType[21]);
+      aGUID = Standard_GUID(aString); // create tree node GUID by name
+    }
+    if(!_lab.FindAttribute(aGUID,anAttr)){
+      _study->CheckLocked();
+      anAttr = TDataStd_TreeNode::Set(_lab,aGUID);
+      _lab.AddAttribute(anAttr);
+      return anAttr;
+    }
+  }
+  
+  if(strncmp(theType, "AttributeUserID",15) == 0){
+    Standard_GUID aGUID = SALOMEDS_AttributeUserID_i::GetGUID();
+    if(!_lab.FindAttribute(aGUID,anAttr)){
+      _study->CheckLocked();
+      anAttr = TDataStd_UAttribute::Set(_lab,aGUID);
+      _lab.AddAttribute(anAttr);
+      return anAttr;
+    }
+  }
+  
+  
+  return anAttr;
+}
+
+
+SALOMEDS::GenericAttribute_ptr 
+SALOMEDS_SObject_i::FindOrCreateAttribute(const char* theType)
+{
+  if(SALOMEDS_GenericAttribute_i* anGenAttr = _FindGenAttribute(theType))
+    return anGenAttr->_this();
+  Handle(TDF_Attribute) anAttr = _AddAttribute(theType);
+  if(!anAttr.IsNull()){
+    if(SALOMEDS_GenericAttribute_i* anGenAttr = _CreateGenAttribute(anAttr,theType)){
+      return anGenAttr->_this();
+    }
+  }
+  return SALOMEDS::GenericAttribute::_nil();
+}
+
+
+//============================================================================
+/*! Function : FindAttribute
+ *  Purpose  : Find attribute of given type on this SObject
+ */
+//============================================================================
+void SALOMEDS_SObject_i::RemoveAttribute(const char* theType)
+{
+  _study->CheckLocked();
+  if(strcmp(theType, "AttributeIOR") == 0) { // postponed removing of CORBA objects
+    Handle(SALOMEDS_IORAttribute) anAttr;
+    if(_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
+      _study->AddPostponed(Str(anAttr->Get()));
+    else 
+      return;
+  }
+  TAttrMap::iterator anIter = myAttrMap.find(theType);
+  if(anIter != myAttrMap.end()){
+    myAttrMap.erase(anIter);
+  }
+  _lab.ForgetAttribute(::GetGUID(theType));
+}
+
index 1b6a29060bd7568815cd7c78997fa537494ac2c9..d7562acf75dc68096bb94f1798d8cfdca2be1c55 100644 (file)
 #ifndef __SALOMEDS_SOBJECT_I_H__
 #define __SALOMEDS_SOBJECT_I_H__
 
-// std C++ headers
-#include <iostream.h>
-#include <vector>
+#include <map>
 #include <string>
 
+// Cascade headers
+#include <TDF_Label.hxx>
+#include <TDocStd_Document.hxx>
+#include <Standard_GUID.hxx>
+
 // IDL headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS)
 
-// Cascade headers
-#include <TDF_Label.hxx>
-#include <stdio.h>
-#include <TDF_Tool.hxx>
-#include <TDF_Reference.hxx>
-#include <Standard_GUID.hxx>
-#include <Standard_NoSuchObject.hxx>
-#include <TDataStd_Name.hxx>
-#include <TDataStd_Comment.hxx>
-#include <TDataStd_Integer.hxx>
-#include <TDataStd_Real.hxx>
+class SALOMEDS_Study_i;
+class SALOMEDS_GenericAttribute_i;
 
-#include <TCollection_AsciiString.hxx>
 
-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<string>           _liste_ba_type;
+namespace SALOMEDS
+{
+  const char* Str(const TCollection_ExtendedString& theString);
+
+  std::string GetType(const Handle(TDF_Attribute)& theAttr);
+
+  Standard_GUID GetGUID(const char* theType);
+
+}
+
 
+class SALOMEDS_SObject_i: public virtual POA_SALOMEDS::SObject,
+                         public virtual PortableServer::RefCountServantBase 
+{
 public:
-  
-  SALOMEDS_SObject_i(const TDF_Label, CORBA::ORB_ptr);
-  
-  ~SALOMEDS_SObject_i();
-  
-  virtual char* GetID();
+  static SALOMEDS_SObject_i* New(SALOMEDS_Study_i* theStudy,
+                                const TDF_Label& theLabel);
+
+  virtual SALOMEDS::SObject_ptr GetFather() ;
   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(CORBA::Long atag, SALOMEDS::SObject_out obj );
+  virtual CORBA::Boolean ReferencedObject(SALOMEDS::SObject_out theSObject);
+  virtual CORBA::Boolean FindSubObject(CORBA::Long theTag, SALOMEDS::SObject_out theSObject);
 
-  virtual SALOMEDS::Study_ptr    GetStudy() ;
-  virtual char* Name();
-  virtual void  Name(const char*);
+  virtual SALOMEDS::Study_ptr GetStudy();
   virtual SALOMEDS::ListOfAttributes* GetAllAttributes();
 
   virtual CORBA::Object_ptr GetObject();
 
+  virtual char* GetID();
+  virtual CORBA::Short Tag();
+  virtual CORBA::Short Depth();
+
+  virtual char* Name();
+  virtual void Name(const char* theName);
+
   virtual char* GetName();
   virtual char* GetComment();
   virtual char* GetIOR();
 
-  virtual CORBA::Short Tag();
-  virtual CORBA::Short Depth();
+  CORBA::Boolean 
+  FindAttribute(SALOMEDS::GenericAttribute_out theAttribute, 
+               const char* theTypeOfAttribute);
+  
+  SALOMEDS::GenericAttribute_ptr 
+  FindOrCreateAttribute(const char* theTypeOfAttribute);
+
+  void RemoveAttribute(const char* theTypeOfAttribute);
 
-  static char* AttributeIDToType(Standard_GUID);
+  SALOMEDS_Study_i* GetStudyServant(){ return _study;}
+
+  CORBA::ORB_var GetORB() const;
+
+  PortableServer::POA_var GetPOA() const;
   
-  static Standard_GUID           ReturnGUIDForAttribute(const char* aTypeOfAttribute);
+protected:
+  friend class SALOMEDS_GenericAttribute_i;
+
+  SALOMEDS_GenericAttribute_i* 
+  _FindGenAttribute(const Handle(TDF_Attribute)& theAttr);
+
+  SALOMEDS_GenericAttribute_i* 
+  _CreateGenAttribute(const Handle(TDF_Attribute)& theAttr,
+                     const char* theTypeOfAttribute);
+
+  SALOMEDS_GenericAttribute_i* 
+  _FindGenAttribute(const char* theTypeOfAttribute);
+
+  SALOMEDS::GenericAttribute_ptr 
+  _FindCORBAAttribute(const char* theTypeOfAttribute);
+
+  Handle(TDF_Attribute) 
+    _AddAttribute(const char* theTypeOfAttribute);
+
+  SALOMEDS_Study_i* _study;
+  std::string _name;
+  TDF_Label _lab;
+
+  typedef std::string TAttributeID;
+  typedef SALOMEDS_GenericAttribute_i* TAttrHolder;
+  typedef std::map<TAttributeID,TAttrHolder> TAttrMap;
+  TAttrMap myAttrMap;
+
+  SALOMEDS_SObject_i(SALOMEDS_Study_i* theStudy, 
+                    const TDF_Label& theLabel);
+  
+  ~SALOMEDS_SObject_i();
+
+private:
+  SALOMEDS_SObject_i(); // Not implemented
+  void operator=(const SALOMEDS_SObject_i&); // Not implemented
+
 };
+
+
 #endif
index 11be220654bbb55fb295c09ec34430591caa1f76..b0e8863bd48be5bf4c4b3ae6ea2603f3d1404ac6 100644 (file)
@@ -143,7 +143,7 @@ int main(int argc, char** argv)
       // 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);
+      SALOMEDS_StudyManager_i * myStudyManager_i = new  SALOMEDS_StudyManager_i(orb,poa);
  
       // Activate the objects.  This tells the POA that the objects are
       // ready to accept requests.
index b5f8c37e24e3757173b9893208234b494017a2ea..e875fb894a1c5e10ef913e57d4231c282500a3bc 100644 (file)
 //  Module : SALOME
 //  $Header$
 
-#include "utilities.h"
+#include "SALOMEDS_StudyBuilder_i.hxx"
+#include "SALOMEDS_StudyManager_i.hxx"
 #include "SALOMEDS_Study_i.hxx"
-//#include "SALOMEDS_StudyBuilder_i.hxx"
+
 #include "SALOMEDS_SObject_i.hxx"
 #include "SALOMEDS_SComponent_i.hxx"
 
+#include "SALOMEDS_TargetAttribute.hxx"
 #include "SALOMEDS_IORAttribute.hxx"
 #include "SALOMEDS_PersRefAttribute.hxx"
-#include "SALOMEDS_TargetAttribute.hxx"
+#include "SALOMEDS_LocalIDAttribute.hxx"
 #include "SALOMEDS_StudyPropertiesAttribute.hxx"
-#include "SALOMEDS_PythonObjectAttribute.hxx"
-#include "SALOMEDS_ExternalFileDef.hxx"
-#include "SALOMEDS_FileType.hxx"
+
+#include "SALOMEDS_Tool.hxx"
+
+#include "Utils_CorbaException.hxx"
+#include "Utils_ExceptHandlers.hxx"
+
 #include <TDF_ChildIterator.hxx>
 #include <TDF_Label.hxx>
 #include <TDataStd_Name.hxx>
 #include <TDF_Data.hxx>
 #include <TDataStd_ChildNodeIterator.hxx>
 #include <TDF_ListIteratorOfAttributeList.hxx>
-#include "SALOMEDS_AttributePersistentRef_i.hxx"
-#include "SALOMEDS_AttributeIOR_i.hxx"
-#include "SALOMEDS_AttributeExternalFileDef_i.hxx"
-#include "SALOMEDS_AttributeFileType_i.hxx"
-#include "SALOMEDS_AttributeComment_i.hxx"
-#include "SALOMEDS_AttributeName_i.hxx"
-#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx"
-#include "SALOMEDS_AttributeSequenceOfReal_i.hxx"
-#include "SALOMEDS_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_AttributeFlags_i.hxx"
-#include "SALOMEDS_AttributeGraphic_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 "SALOMEDS_Tool.hxx"
-#include "Utils_CorbaException.hxx"
-#include "Utils_ExceptHandlers.hxx"
 
 #include <HDFOI.hxx>
 #include <stdlib.h> 
 
-using namespace std;
-
 #define USE_CASE_LABEL_TAG            2
 #define DIRECTORYID 16661
 #define FILELOCALID 26662 
 
+#include "utilities.h"
+
+using namespace std;
+
 UNEXPECT_CATCH(SBSalomeException, SALOME::SALOME_Exception);
 UNEXPECT_CATCH(SBLockProtection, SALOMEDS::StudyBuilder::LockProtection);
+
 //============================================================================
 /*! Function : constructor
  *  Purpose  :
  */
 //============================================================================
-SALOMEDS_StudyBuilder_i::SALOMEDS_StudyBuilder_i(const Handle(TDocStd_Document) doc, 
-                                                CORBA::ORB_ptr orb) : _doc(doc)
+SALOMEDS_StudyBuilder_i::SALOMEDS_StudyBuilder_i(SALOMEDS_Study_i* theStudy,
+                                                const Handle(TDocStd_Document)& theDocument):
+  _study(theStudy),
+  _doc(theDocument)
 {
-  _orb = CORBA::ORB::_duplicate(orb);
 }
 
 //============================================================================
@@ -113,6 +91,21 @@ SALOMEDS_StudyBuilder_i::~SALOMEDS_StudyBuilder_i()
 {
 }
 
+
+//============================================================================
+CORBA::ORB_var SALOMEDS_StudyBuilder_i::GetORB() const
+{
+  return _study->GetORB();
+}
+
+
+//============================================================================
+PortableServer::POA_var SALOMEDS_StudyBuilder_i::GetPOA() const
+{
+  return _study->GetPOA();
+}
+
+
 //============================================================================
 /*! Function : NewComponent
  *  Purpose  : Create a new component (Scomponent)
@@ -138,13 +131,12 @@ SALOMEDS_StudyBuilder_i::NewComponent(const char* DataType)
    TDataStd_Comment::Set(NL,Standard_CString(DataType));
    //  TDataStd_Comment::Set(NL,Standard_CString(CORBA::string_dup(DataType)));
 
-  SALOMEDS_SComponent_i *  so_servant = new SALOMEDS_SComponent_i (NL,_orb);
-  SALOMEDS::SComponent_var so;
-  so= SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); 
+  SALOMEDS_SComponent_i* aServant = SALOMEDS_SComponent_i::New(_study,NL);
+  SALOMEDS::SComponent_var aSComponent = aServant->_this(); 
 
-  if(!CORBA::is_nil(_callbackOnAdd)) _callbackOnAdd->OnAddSObject(so);
+  OnAddSObject(aSComponent);
 
-  return so;
+  return aSComponent._retn();
 }
 
 //============================================================================
@@ -152,21 +144,22 @@ SALOMEDS_StudyBuilder_i::NewComponent(const char* DataType)
  *  Purpose  : Add IOR attribute of a Scomponent
  */
 //============================================================================
-void SALOMEDS_StudyBuilder_i::DefineComponentInstance(SALOMEDS::SComponent_ptr aComponent,
-                                                CORBA::Object_ptr IOR)
+void SALOMEDS_StudyBuilder_i::DefineComponentInstance(SALOMEDS::SComponent_ptr theComponent,
+                                                     CORBA::Object_ptr theObject)
 {
   CheckLocked();
+
+  if(CORBA::is_nil(theComponent) || CORBA::is_nil(theObject))
+    return;
+
   //Find label
   TDF_Label Lab;
-  ASSERT(!CORBA::is_nil(aComponent));
-  CORBA::String_var compid = aComponent->GetID();
-  TDF_Tool::Label(_doc->GetData(),compid,Lab);
-
-  //add IOR definition 
-  ASSERT(!CORBA::is_nil(IOR));
-  CORBA::String_var iorstr = _orb->object_to_string(IOR);
-  SALOMEDS_IORAttribute::Set(Lab,(char*)iorstr,_orb);
-  
+  CORBA::String_var aString = theComponent->GetID();
+  TDF_Tool::Label(_doc->GetData(),const_cast<char*>(aString.in()),Lab);
+
+  //add theObject definition 
+  aString = GetORB()->object_to_string(theObject);
+  SALOMEDS_IORAttribute::Set(Lab,const_cast<char*>(aString.in()),GetORB());
 }
 
 //============================================================================
@@ -175,11 +168,10 @@ void SALOMEDS_StudyBuilder_i::DefineComponentInstance(SALOMEDS::SComponent_ptr a
  */
 //============================================================================
 void 
-SALOMEDS_StudyBuilder_i::RemoveComponent(SALOMEDS::SComponent_ptr aComponent)
+SALOMEDS_StudyBuilder_i::RemoveComponent(SALOMEDS::SComponent_ptr theComponent)
 {
   CheckLocked();
-  ASSERT(!CORBA::is_nil(aComponent));
-  RemoveObject(aComponent);
+  RemoveObject(theComponent);
 }
 
 //============================================================================
@@ -191,31 +183,33 @@ SALOMEDS::SObject_ptr
 SALOMEDS_StudyBuilder_i::NewObject(SALOMEDS::SObject_ptr theFatherObject)
 {
   CheckLocked();
-  TCollection_AsciiString anEntry;
+
+  if(CORBA::is_nil(theFatherObject)) 
+    return SALOMEDS::SObject::_nil();
+
   //Find label of father
-  TDF_Label Lab;
+  TDF_Label aLabel;
+  TCollection_AsciiString anEntry;
   
-  ASSERT(!CORBA::is_nil(theFatherObject));
-  CORBA::String_var fatherid = theFatherObject->GetID();
-  TDF_Tool::Label(_doc->GetData(),fatherid,Lab);
+  CORBA::String_var aFatherID = theFatherObject->GetID();
+  TDF_Tool::Label(_doc->GetData(),aFatherID,aLabel);
 
   //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()) {
+  for (TDF_ChildIterator it(aLabel); it.More(); it.Next()) {
     if (it.Value().Tag() > imax)
       imax = it.Value().Tag();
   }
   imax++;
-  TDF_Label NewLab = Lab.FindChild(imax);
+  TDF_Label aNewLabel = aLabel.FindChild(imax);
   
-  SALOMEDS_SObject_i *  so_servant = new SALOMEDS_SObject_i (NewLab,_orb);
-  SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); 
+  SALOMEDS_SObject_i* aServant = SALOMEDS_SObject_i::New(_study,aNewLabel);
+  SALOMEDS::SObject_var aSObject = aServant->_this(); 
 
-  if(!CORBA::is_nil(_callbackOnAdd)) _callbackOnAdd->OnAddSObject(so);
+  OnAddSObject(aSObject);
 
-  return so;
+  return aSObject._retn();
 }
 
 //============================================================================
@@ -225,24 +219,27 @@ SALOMEDS_StudyBuilder_i::NewObject(SALOMEDS::SObject_ptr theFatherObject)
 //============================================================================
 SALOMEDS::SObject_ptr 
 SALOMEDS_StudyBuilder_i::NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject,
-                                       CORBA::Long atag)
+                                       CORBA::Long theTag)
 {
   CheckLocked();
+
+  if(CORBA::is_nil(theFatherObject)) 
+    return SALOMEDS::SObject::_nil();
+
   //Find label of father
   TDF_Label Lab;
+  CORBA::String_var aFatherID = theFatherObject->GetID();
+  TDF_Tool::Label(_doc->GetData(),aFatherID,Lab);
 
-  ASSERT(!CORBA::is_nil(theFatherObject));
-  CORBA::String_var fatherid = theFatherObject->GetID();
-  TDF_Tool::Label(_doc->GetData(),fatherid,Lab);
   //Create or find label
-  TDF_Label NewLab = Lab.FindChild(atag,1);
+  TDF_Label aNewLab = Lab.FindChild(theTag,1);
 
-  SALOMEDS_SObject_i *  so_servant = new SALOMEDS_SObject_i (NewLab,_orb);
-  SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); 
+  SALOMEDS_SObject_i* aServant = SALOMEDS_SObject_i::New(_study,aNewLab);
+  SALOMEDS::SObject_var aSObject = aServant->_this(); 
 
-  if(!CORBA::is_nil(_callbackOnAdd)) _callbackOnAdd->OnAddSObject(so);
+  OnAddSObject(aSObject);
 
-  return so;
+  return aSObject._retn();
 }
 
 //============================================================================
@@ -250,25 +247,31 @@ SALOMEDS_StudyBuilder_i::NewObjectToTag(SALOMEDS::SObject_ptr theFatherObject,
  *  Purpose  :
  */
 //============================================================================
-void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr anObject)
+void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr theSObject)
 {
   CheckLocked();
-  if(!CORBA::is_nil(_callbackOnRemove)) _callbackOnRemove->OnRemoveSObject(anObject);
+
+  if(CORBA::is_nil(theSObject))
+    return;
+
+  OnRemoveSObject(theSObject);
 
   TDF_Label Lab;
-  ASSERT(!CORBA::is_nil(anObject));
-  TDF_Tool::Label(_doc->GetData(),anObject->GetID(),Lab);
+  CORBA::String_var aString(theSObject->GetID());
+  TDF_Tool::Label(_doc->GetData(),const_cast<char*>(aString.in()),Lab);
 
   Handle(TDF_Reference) aReference;
-  if (Lab.FindAttribute(TDF_Reference::GetID(), aReference)) {
+  if(Lab.FindAttribute(TDF_Reference::GetID(),aReference)){
     Handle(SALOMEDS_TargetAttribute) aTarget;
-    if (aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget))
+    if(aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget))
       aTarget->Remove(Lab);
   }
 
   Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects
-  if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
-    SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
+  if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)){
+    SALOMEDS::Study_ptr aStudy = SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB());
+    aStudy->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
+  }
 
   Lab.ForgetAllAttributes();
 }
@@ -278,14 +281,18 @@ void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr anObject)
  *  Purpose  :
  */
 //============================================================================
-void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr anObject)
+void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr theSObject)
 {
   CheckLocked();
-  if(!CORBA::is_nil(_callbackOnRemove)) _callbackOnRemove->OnRemoveSObject(anObject);
+
+  if(CORBA::is_nil(theSObject))
+    return;
+
+  OnRemoveSObject(theSObject);
 
   TDF_Label Lab;
-  ASSERT(!CORBA::is_nil(anObject));
-  TDF_Tool::Label(_doc->GetData(),anObject->GetID(),Lab);
+  CORBA::String_var aString(theSObject->GetID());
+  TDF_Tool::Label(_doc->GetData(),aString,Lab);
 
   Handle(TDF_Reference) aReference;
   if (Lab.FindAttribute(TDF_Reference::GetID(), aReference)) {
@@ -293,21 +300,28 @@ void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr anO
     if (aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget))
       aTarget->Remove(Lab);
   }
+
   Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects
-  if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
-    SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
+  if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)){
+    SALOMEDS::Study_ptr aStudy = SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB());
+    aStudy->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
+  }
 
   TDF_ChildIterator it(Lab, Standard_True);
   for(;it.More();it.Next()) {
     TDF_Label aLabel = it.Value();
+
     if (aLabel.FindAttribute(TDF_Reference::GetID(), aReference)) {
       Handle(SALOMEDS_TargetAttribute) aTarget;
       if (aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget))
        aTarget->Remove(aLabel);
     }
+
     Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects
-    if (aLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
-      SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
+    if (aLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)){
+      SALOMEDS::Study_ptr aStudy = SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB());
+      aStudy->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
+    }
   }
 
   Lab.ForgetAllAttributes(Standard_True);
@@ -318,42 +332,36 @@ void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr anO
  *  Purpose  :
  */
 //============================================================================
-static void  Translate_persistentID_to_IOR(TDF_Label                  Lab,
-                                          SALOMEDS::Driver_ptr       driver,
-                                          CORBA::ORB_ptr             orb,
-                                          CORBA::Boolean             isMultiFile,
-                                          CORBA::Boolean             isASCII)
+static void  Translate_persistentID_to_IOR(TDF_Label theLabel,
+                                          SALOMEDS::Driver_ptr theDriver,
+                                          CORBA::ORB_ptr theORB,
+                                          SALOMEDS_Study_i* theStudy,
+                                          CORBA::Boolean theIsMultiFile,
+                                          CORBA::Boolean theIsASCII)
 {
-  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)) {  
+  if(CORBA::is_nil(theDriver))
+    return;
 
+  for (TDF_ChildIterator  aChildIter (theLabel); aChildIter.More(); aChildIter.Next()){
+    TDF_Label aCurrentLabel = aChildIter.Value();
+    Handle(TDF_Attribute) anAttr;
+    if(aCurrentLabel.FindAttribute(SALOMEDS_PersRefAttribute::GetID(),anAttr)){
       Handle(SALOMEDS_LocalIDAttribute) anID;
-      if (current.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(), anID)) 
+      if (aCurrentLabel.FindAttribute(SALOMEDS_LocalIDAttribute::GetID(),anID)) 
        if (anID->Get() == FILELOCALID) continue;        //SRN: This attribute store a file name, skip it 
 
-      TCollection_ExtendedString res;   
-      res = Handle(TDataStd_Comment)::DownCast(Att)->Get();
+      TCollection_ExtendedString res = Handle(TDataStd_Comment)::DownCast(anAttr)->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, isASCII);
+      SALOMEDS_SObject_i* aServant = SALOMEDS_SObject_i::New(theStudy,aCurrentLabel);
+      SALOMEDS::SObject_var aSObject = aServant->_this(); 
 
-      TCollection_ExtendedString value(ior_string); 
-      SALOMEDS_IORAttribute::Set (current,value,orb); 
-      
-      //TCollection_AsciiString anEntry;TDF_Tool::Entry (current,anEntry); //SRN: No use here
-      //delete persistent_string;
-      //delete ior_string;
+      CORBA::String_var anIOR = 
+       theDriver->LocalPersistentIDToIOR(aSObject,ch.ToCString(),theIsMultiFile,theIsASCII);
+      SALOMEDS_IORAttribute::Set (aCurrentLabel,const_cast<char*>(anIOR.in()),theORB); 
     }
-    Translate_persistentID_to_IOR (current,driver,orb,isMultiFile, isASCII);
+
+    Translate_persistentID_to_IOR(aCurrentLabel,theDriver,theORB,theStudy,theIsMultiFile,theIsASCII);
   }
 }
 
@@ -364,62 +372,59 @@ static void  Translate_persistentID_to_IOR(TDF_Label                  Lab,
 //============================================================================
 
 //============================================================================
-void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO, 
-                                      SALOMEDS::Driver_ptr aDriver) throw(SALOME::SALOME_Exception)
+void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr theSComponent, 
+                                      SALOMEDS::Driver_ptr theDriver) 
+  throw(SALOME::SALOME_Exception)
 {
   Unexpect aCatch(SBSalomeException);
+
+  if(CORBA::is_nil(theSComponent))
+    return;
+
   TDF_Label Lab;
-  ASSERT(!CORBA::is_nil(anSCO));
-  CORBA::String_var scoid = anSCO->GetID();
-  TDF_Tool::Label(_doc->GetData(),scoid,Lab);
-  Handle(TDF_Attribute) Att;
+  CORBA::String_var aString = theSComponent->GetID();
+  TDF_Tool::Label(_doc->GetData(),const_cast<char*>(aString.in()),Lab);
   
   //Find the current Url of the study  
+  Handle(TDF_Attribute) Att;
   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");
+    if(CORBA::is_nil(theDriver))
+      return;
+
+    int aLocked = theSComponent->GetStudy()->GetProperties()->IsLocked();
+    if(aLocked) 
+      theSComponent->GetStudy()->GetProperties()->SetLocked(false);
     
-    // 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);
+      if(aLocked) 
+       theSComponent->GetStudy()->GetProperties()->SetLocked(true);
       return;
     }
-    DefineComponentInstance (anSCO, aDriver);
+    DefineComponentInstance (theSComponent,theDriver);
     
-    TCollection_AsciiString aHDFPath(Res);
+    TCollection_AsciiString aHDFPath(Handle(TDataStd_Comment)::DownCast(Att)->Get());
     
-    char* aHDFUrl;
     bool isASCII = false;
-    if (HDFascii::isASCII(aHDFPath.ToCString())) {
+    std::ostringstream anURLStream;
+    if(HDFascii::isASCII(aHDFPath.ToCString())){
       isASCII = true;
-      char* aResultPath = HDFascii::ConvertFromASCIIToHDF(aHDFPath.ToCString());
-      aHDFUrl = new char[strlen(aResultPath) + 19];
-      sprintf(aHDFUrl, "%shdf_from_ascii.hdf", aResultPath);
-      delete(aResultPath);
+      auto_ptr<char> aResultPath(HDFascii::ConvertFromASCIIToHDF(aHDFPath.ToCString()));
+      anURLStream<<aResultPath.get()<<"hdf_from_ascii.hdf";
     } else {
-      aHDFUrl = CORBA::string_dup(aHDFPath.ToCString());
+      anURLStream<<aHDFPath.ToCString();
     }
+    std::string aHDFUrl = anURLStream.str();
 
     //Open the Study HDF file 
-    HDFfile *hdf_file = new HDFfile(aHDFUrl); 
+    auto_ptr<HDFfile> hdf_file(new HDFfile(const_cast<char*>(aHDFUrl.c_str())));
     
     char aMultifileState[2];
     char ASCIIfileState[2];
     try {
-      CORBA::String_var scoid = anSCO->GetID();
+      CORBA::String_var scoid = theSComponent->GetID();
       hdf_file->OpenOnDisk(HDF_RDONLY);
-      HDFgroup *hdf_group = new HDFgroup("DATACOMPONENT",hdf_file);
+      HDFgroup *hdf_group = new HDFgroup("DATACOMPONENT",hdf_file.get());
       hdf_group->OpenOnDisk();
       HDFgroup *hdf_sco_group = new HDFgroup(scoid, hdf_group);
       hdf_sco_group->OpenOnDisk();
@@ -430,12 +435,14 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO,
        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");
+       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);
+      } else 
+       aStreamFile = new SALOMEDS::TMPFile(0);
       
       HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group);
       multifile_hdf_dataset->OpenOnDisk();
@@ -446,28 +453,25 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO,
       ascii_hdf_dataset->ReadFromDisk(ASCIIfileState);
       
       // 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;
-       }
+      std::string aDir(aHDFPath.ToCString());
+      aDir.substr(0,aDir.find('/'));
       
       CORBA::Boolean aResult = (ASCIIfileState[0]=='A')?
-       aDriver->LoadASCII(anSCO, aStreamFile.in(), aDir, aMultifileState[0]=='M'):
-         aDriver->Load(anSCO, aStreamFile.in(), aDir, aMultifileState[0]=='M');
+       theDriver->LoadASCII(theSComponent, aStreamFile.in(), aDir.c_str(), aMultifileState[0]=='M'):
+         theDriver->Load(theSComponent, aStreamFile.in(), aDir.c_str(), aMultifileState[0]=='M');
       if(!aResult) {
-       RemoveAttribute( anSCO, "AttributeIOR" );
-
+       RemoveAttribute( theSComponent, "AttributeIOR" );
+       if (isASCII) {
+         SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
+         aFilesToRemove->length(1);
+         std::string aDir = SALOMEDS_Tool::GetDirFromPath(aHDFUrl);
+         aFilesToRemove[0] = CORBA::string_dup(&aHDFUrl[strlen(aDir.c_str())]);
+         SALOMEDS_Tool::RemoveTemporaryFiles(aDir,aFilesToRemove,true);
+       }
        MESSAGE("Can't load component");
-       //THROW_SALOME_CORBA_EXCEPTION("Unable to load component data",SALOME::BAD_PARAM);
-       throw HDFexception("Unable to load component");
+       THROW_SALOME_CORBA_EXCEPTION("Unable to load component data",SALOME::BAD_PARAM);
       }
       
-      delete(aDir);
-
       multifile_hdf_dataset->CloseOnDisk();
       multifile_hdf_dataset = 0;
       ascii_hdf_dataset->CloseOnDisk();
@@ -477,39 +481,40 @@ void SALOMEDS_StudyBuilder_i::LoadWith(SALOMEDS::SComponent_ptr anSCO,
       hdf_group->CloseOnDisk();
       hdf_group = 0;
       hdf_file->CloseOnDisk();
-      delete hdf_file;
       
       if (isASCII) {
        SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
        aFilesToRemove->length(1);
-       aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str())]));
-       SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str(), aFilesToRemove, true);
+       std::string aDir = SALOMEDS_Tool::GetDirFromPath(aHDFUrl);
+       aFilesToRemove[0] = CORBA::string_dup(&aHDFUrl[strlen(aDir.c_str())]);
+       SALOMEDS_Tool::RemoveTemporaryFiles(aDir,aFilesToRemove,true);
       }
-      delete aHDFUrl;
     }
     catch (HDFexception) {
       INFOS("No persistent file Name");
-      delete hdf_file;
       if (isASCII) {
        SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
        aFilesToRemove->length(1);
-       aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str())]));
-       SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str(), aFilesToRemove, true);
+       std::string aDir = SALOMEDS_Tool::GetDirFromPath(aHDFUrl);
+       aFilesToRemove[0] = CORBA::string_dup(&aHDFUrl[strlen(aDir.c_str())]);
+       SALOMEDS_Tool::RemoveTemporaryFiles(aDir,aFilesToRemove,true);
       }
-      delete aHDFUrl;
-      if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true);
-      THROW_SALOME_CORBA_EXCEPTION("No persistent file Name found",SALOME::BAD_PARAM);   
+      if(aLocked)
+       theSComponent->GetStudy()->GetProperties()->SetLocked(true);
+      THROW_SALOME_CORBA_EXCEPTION("No persistent file Name found",SALOME::BAD_PARAM);
     }
     
     try {
-      Translate_persistentID_to_IOR (Lab,aDriver,_orb, aMultifileState[0]=='M', ASCIIfileState[0] == 'A');
+      Translate_persistentID_to_IOR(Lab,theDriver,GetORB(),_study, aMultifileState[0]=='M', ASCIIfileState[0] == 'A');
     } catch (SALOME::SALOME_Exception) {
       INFOS("Can't translate PersRef to IOR");
-      if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true);
+      if (aLocked) 
+       theSComponent->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);
+    if(aLocked)
+      theSComponent->GetStudy()->GetProperties()->SetLocked(true);
   } else
     MESSAGE("No persistent file Name");
 }
@@ -531,69 +536,18 @@ void SALOMEDS_StudyBuilder_i::Load(SALOMEDS::SObject_ptr sco)
  *  existing one
  */
 //============================================================================
-SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SALOMEDS::SObject_ptr anObject, 
-                                                                             const char* aTypeOfAttribute)
+SALOMEDS::GenericAttribute_ptr 
+SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SALOMEDS::SObject_ptr theObject, 
+                                              const char* theTypeOfAttribute)
 {
-  TDF_Label Lab;
-  ASSERT(!CORBA::is_nil(anObject));
-  CORBA::String_var anobid = anObject->GetID();
-  TDF_Tool::Label(_doc->GetData(),anobid,Lab);
-
-  __FindOrCreateAttributeLocked(TDataStd_Real, AttributeReal)
-  __FindOrCreateAttributeLocked(TDataStd_Integer, AttributeInteger)
-  __FindOrCreateAttributeLocked(SALOMEDS_SequenceOfRealAttribute, AttributeSequenceOfReal)
-  __FindOrCreateAttributeLocked(SALOMEDS_SequenceOfIntegerAttribute, AttributeSequenceOfInteger)
-  __FindOrCreateAttributeLocked(TDataStd_Name, AttributeName)
-  __FindOrCreateAttributeLocked(TDataStd_Comment, AttributeComment)
-  __FindOrCreateAttributeLocked(SALOMEDS_IORAttribute, AttributeIOR)
-  __FindOrCreateAttributeLocked(SALOMEDS_PixMapAttribute, AttributePixMap)
-  __FindOrCreateAttributeLocked(SALOMEDS_LocalIDAttribute, AttributeLocalID)
-  __FindOrCreateAttributeLocked(SALOMEDS_TableOfIntegerAttribute, AttributeTableOfInteger)
-  __FindOrCreateAttributeLocked(SALOMEDS_TableOfRealAttribute, AttributeTableOfReal)
-  __FindOrCreateAttributeLocked(SALOMEDS_TableOfStringAttribute, AttributeTableOfString)
-  __FindOrCreateAttributeLocked(SALOMEDS_PythonObjectAttribute, AttributePythonObject)
-
-  __FindOrCreateAttribute(SALOMEDS_PersRefAttribute, AttributePersistentRef)
-  __FindOrCreateAttribute(SALOMEDS_DrawableAttribute, AttributeDrawable)
-  __FindOrCreateAttribute(SALOMEDS_SelectableAttribute, AttributeSelectable)
-  __FindOrCreateAttribute(SALOMEDS_ExpandableAttribute, AttributeExpandable)
-  __FindOrCreateAttribute(SALOMEDS_OpenedAttribute, AttributeOpened)
-  __FindOrCreateAttribute(SALOMEDS_TextColorAttribute, AttributeTextColor)
-  __FindOrCreateAttribute(SALOMEDS_TextHighlightColorAttribute, AttributeTextHighlightColor)
-  __FindOrCreateAttribute(SALOMEDS_TargetAttribute, AttributeTarget)
-  __FindOrCreateAttribute(SALOMEDS_StudyPropertiesAttribute, AttributeStudyProperties)
-  __FindOrCreateAttribute(SALOMEDS_ExternalFileDef, AttributeExternalFileDef)
-  __FindOrCreateAttribute(SALOMEDS_FileType, AttributeFileType)
-  __FindOrCreateAttribute(SALOMEDS_FlagsAttribute, AttributeFlags)
-  __FindOrCreateAttribute(SALOMEDS_GraphicAttribute, AttributeGraphic)    
-
-  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]));
-      aTreeNodeGUID = Standard_GUID(aGUIDString); // create tree node GUID by name
-      delete(aGUIDString);
-    }
-    Handle(TDataStd_TreeNode) anAttr;
-    if (!Lab.FindAttribute(aTreeNodeGUID, anAttr)) {
-      CheckLocked();
-      anAttr = TDataStd_TreeNode::Set(Lab, aTreeNodeGUID);
-    }
-    SALOMEDS_AttributeTreeNode_i* aTreeNodeAttr = new SALOMEDS_AttributeTreeNode_i(anAttr, _orb);
-    return aTreeNodeAttr->AttributeTreeNode::_this();
-  }
-
-  if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 ) {
-    Handle(TDataStd_UAttribute) anAttr;
-    if (!Lab.FindAttribute(SALOMEDS_AttributeUserID_i::DefaultID(), anAttr)) {
-      CheckLocked();
-      anAttr = TDataStd_UAttribute::Set(Lab, SALOMEDS_AttributeUserID_i::DefaultID());
+  if(!CORBA::is_nil(theObject)){
+    PortableServer::POA_var aPOA = GetPOA();
+    PortableServer::ServantBase_var aServant = SALOMEDS::GetServant(theObject,aPOA);
+    if(aServant.in() != NULL){
+      if(SALOMEDS_SObject_i* anSObject = dynamic_cast<SALOMEDS_SObject_i*>(aServant.in())){
+       return anSObject->FindOrCreateAttribute(theTypeOfAttribute);
+      }
     }
-    SALOMEDS_AttributeUserID_i* aUAttr = new SALOMEDS_AttributeUserID_i(anAttr, _orb);
-    return aUAttr->AttributeUserID::_this();
   }
   return SALOMEDS::GenericAttribute::_nil();
 }
@@ -604,18 +558,17 @@ SALOMEDS::GenericAttribute_ptr SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SA
  */
 //============================================================================
 
-CORBA::Boolean SALOMEDS_StudyBuilder_i::FindAttribute(SALOMEDS::SObject_ptr anObject, 
-                                                             SALOMEDS::GenericAttribute_out anAttribute
-                                                             const char* aTypeOfAttribute)
+CORBA::Boolean SALOMEDS_StudyBuilder_i::FindAttribute(SALOMEDS::SObject_ptr theObject, 
+                                                     SALOMEDS::GenericAttribute_out theAttr
+                                                     const char* theTypeOfAttribute)
 {
-  TDF_Label Lab;
-  ASSERT(!CORBA::is_nil(anObject));
-  CORBA::String_var anobid = anObject->GetID();
-  TDF_Tool::Label(_doc->GetData(),anobid,Lab);
-  Handle(TDF_Attribute) anAttr;
-  if (Lab.FindAttribute(SALOMEDS_GenericAttribute_i::GetGUID(aTypeOfAttribute), anAttr)) {
-    anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(_orb, anAttr));
-    return Standard_True;
+  if(!CORBA::is_nil(theObject)){
+    PortableServer::ServantBase_var aServant = SALOMEDS::GetServant(theObject,GetPOA());
+    if(aServant.in() != NULL){
+      if(SALOMEDS_SObject_i* anSObject = dynamic_cast<SALOMEDS_SObject_i*>(aServant.in())){
+       return anSObject->FindAttribute(theAttr,theTypeOfAttribute);
+      }
+    }
   }
   return Standard_False;
 }
@@ -626,23 +579,26 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::FindAttribute(SALOMEDS::SObject_ptr anOb
  */
 //============================================================================
 
-void SALOMEDS_StudyBuilder_i::RemoveAttribute(SALOMEDS::SObject_ptr anObject, 
+void SALOMEDS_StudyBuilder_i::RemoveAttribute(SALOMEDS::SObject_ptr theSObject, 
                                              const char* aTypeOfAttribute)
 {
   CheckLocked();
+
+  if(CORBA::is_nil(theSObject))
+    return;
+
   TDF_Label Lab;
-  ASSERT(!CORBA::is_nil(anObject));
-  CORBA::String_var anobid = anObject->GetID();
+  CORBA::String_var anobid = theSObject->GetID();
   TDF_Tool::Label(_doc->GetData(),anobid,Lab);
   
   if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0) { // postponed removing of CORBA objects
     Handle(SALOMEDS_IORAttribute) anAttr;
     if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
-      SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
+      SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
     else return;
   }
 
-  Lab.ForgetAttribute (SALOMEDS_GenericAttribute_i::GetGUID(aTypeOfAttribute));
+  Lab.ForgetAttribute(SALOMEDS::GetGUID(aTypeOfAttribute));
 }
 
 //============================================================================
@@ -655,19 +611,22 @@ SALOMEDS_StudyBuilder_i::Addreference(SALOMEDS::SObject_ptr me,
                                      SALOMEDS::SObject_ptr theReferencedObject)
 {
   CheckLocked();
+  if(CORBA::is_nil(me) || CORBA::is_nil(theReferencedObject))
+    return;
+
   TDF_Label Lab;
-  ASSERT(!CORBA::is_nil(me));
   CORBA::String_var meid = me->GetID();
   TDF_Tool::Label(_doc->GetData(),meid,Lab);  
+
   TDF_Label RefLab;
-  ASSERT(!CORBA::is_nil(theReferencedObject));
   CORBA::String_var roid = theReferencedObject->GetID();
   TDF_Tool::Label(_doc->GetData(),roid,RefLab);
-  TDF_Reference::Set(Lab,RefLab);
 
+  TDF_Reference::Set(Lab,RefLab);
   SALOMEDS_TargetAttribute::Set(RefLab)->Append(Lab);
 
-  if(!CORBA::is_nil(_callbackOnRemove) && Lab.IsDescendant(_doc->Main())) _callbackOnRemove->OnRemoveSObject(me);
+  if(Lab.IsDescendant(_doc->Main())) 
+    OnRemoveSObject(me);
 }
 
 //============================================================================
@@ -680,23 +639,21 @@ void SALOMEDS_StudyBuilder_i::RemoveReference(SALOMEDS::SObject_ptr me)
   SALOMEDS::SObject_var theReferencedObject;
   if(!me->ReferencedObject(theReferencedObject)) return;  //No reference is found
 
+  if(CORBA::is_nil(me) || CORBA::is_nil(theReferencedObject))
+    return;
+
   CheckLocked();
   TDF_Label Lab;
-  ASSERT(!CORBA::is_nil(me));
   CORBA::String_var meid = me->GetID();
   TDF_Tool::Label(_doc->GetData(),meid,Lab);  
 
   Lab.ForgetAttribute(TDF_Reference::GetID());  
 
-  //SRN: 30 Aug, 2004 : fix from Ecole l'ete version 
-
-  TDF_Label RefLab;
-  ASSERT(!CORBA::is_nil(theReferencedObject));
+  TDF_Label RefLab;  
   CORBA::String_var roid = theReferencedObject->GetID();
   TDF_Tool::Label(_doc->GetData(),roid,RefLab);
-       
-  Handle(SALOMEDS_TargetAttribute) aTarget;
-  if(RefLab.FindAttribute(SALOMEDS_TargetAttribute::GetID(), aTarget)) aTarget->Remove(Lab);
+
+  RemoveAttribute(theReferencedObject, "AttributeTarget");
 }
 
 
@@ -712,11 +669,10 @@ 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_SObject_i* aServant = SALOMEDS_SObject_i::New(_study,_doc->Main());
+  SALOMEDS::SObject_var anObject = aServant->_this(); 
   SALOMEDS::Study_var aStudy = anObject->GetStudy();
 
   try { 
@@ -748,7 +704,8 @@ void SALOMEDS_StudyBuilder_i::AddDirectory(const char* thePath)
     anObject = aStudy->FindObjectByPath(aFatherPath.ToCString()); //Check if the father directory exists
   }
   catch(...) { ; }
-  if(anObject->_is_nil()) throw SALOMEDS::Study::StudyInvalidDirectory(); 
+  if(anObject->_is_nil()) 
+    throw SALOMEDS::Study::StudyInvalidDirectory(); 
 
   SALOMEDS::SObject_var aNewObject = NewObject(anObject);
   TDF_Tool::Label(_doc->GetData(), aNewObject->GetID(), aLabel);
@@ -762,7 +719,8 @@ void SALOMEDS_StudyBuilder_i::AddDirectory(const char* thePath)
   //Set LocalID attribute to identify the directory object
   SALOMEDS::GenericAttribute_var anAttr = FindOrCreateAttribute(aNewObject, "AttributeLocalID");
   SALOMEDS::AttributeLocalID_var aPersRef = SALOMEDS::AttributeLocalID::_narrow(anAttr);
-  if(aPersRef->_is_nil()) throw SALOMEDS::Study::StudyInvalidDirectory();
+  if(aPersRef->_is_nil()) 
+    throw SALOMEDS::Study::StudyInvalidDirectory();
 
   aPersRef->SetValue(DIRECTORYID);
 }
@@ -776,8 +734,11 @@ void SALOMEDS_StudyBuilder_i::AddDirectory(const char* thePath)
 void SALOMEDS_StudyBuilder_i::SetGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID)
 {
   CheckLocked();
+
+  if(CORBA::is_nil(anObject))
+    return;
+
   TDF_Label aLabel;
-  ASSERT(!CORBA::is_nil(anObject));
   CORBA::String_var anEntry = anObject->GetID();
   TDF_Tool::Label(_doc->GetData(), anEntry, aLabel);
   TDataStd_UAttribute::Set(aLabel, (char*)theGUID);
@@ -790,8 +751,10 @@ void SALOMEDS_StudyBuilder_i::SetGUID(SALOMEDS::SObject_ptr anObject, const char
 //============================================================================
 bool SALOMEDS_StudyBuilder_i::IsGUID(SALOMEDS::SObject_ptr anObject, const char* theGUID)
 {
+  if(CORBA::is_nil(anObject))
+    return false;
+
   TDF_Label aLabel;
-  ASSERT(!CORBA::is_nil(anObject));
   CORBA::String_var anEntry = anObject->GetID();
   TDF_Tool::Label(_doc->GetData(), anEntry, aLabel);
   return aLabel.IsAttribute((char*)theGUID);
@@ -834,7 +797,7 @@ void SALOMEDS_StudyBuilder_i::CommitCommand() throw (SALOMEDS::StudyBuilder::Loc
     AbortCommand();
     throw SALOMEDS::StudyBuilder::LockProtection();
   } else {
-    SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->RemovePostponed(_doc->GetUndoLimit());
+    SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->RemovePostponed(_doc->GetUndoLimit());
 
     int aModif = anAttr->GetModified();
     if (aModif < 0) aModif = 1000; // if user make undo and then - new transaction "modify" will never be zero
@@ -860,7 +823,7 @@ CORBA::Boolean SALOMEDS_StudyBuilder_i::HasOpenCommand()
 //============================================================================
 void SALOMEDS_StudyBuilder_i::AbortCommand()
 {
-  SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(0);
+  SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->UndoPostponed(0);
   
   _doc->AbortCommand();
 }
@@ -882,7 +845,7 @@ void SALOMEDS_StudyBuilder_i::Undo() throw (SALOMEDS::StudyBuilder::LockProtecti
     MESSAGE("Locked document modification !!!");
     throw SALOMEDS::StudyBuilder::LockProtection();
   } else {
-    SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(1);
+    SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->UndoPostponed(1);
     _doc->Undo();
     anAttr->SetModified(anAttr->GetModified()-1);
   }
@@ -907,7 +870,7 @@ void SALOMEDS_StudyBuilder_i::Redo() throw (SALOMEDS::StudyBuilder::LockProtecti
     throw SALOMEDS::StudyBuilder::LockProtection();
   } else {
     _doc->Redo();
-    SALOMEDS_Study_i::GetStudy(_doc->Main(), _orb)->UndoPostponed(-1);
+    SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->UndoPostponed(-1);
     anAttr->SetModified(anAttr->GetModified()+1);
   }
  }
@@ -960,9 +923,12 @@ void  SALOMEDS_StudyBuilder_i::UndoLimit(CORBA::Long n)
 //============================================================================
 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;
+  return _study->SetOnAddSObject(theCallback);
+}
+
+void SALOMEDS_StudyBuilder_i::OnAddSObject(SALOMEDS::SObject_ptr theObject)
+{
+  _study->OnAddSObject(theObject);
 }
 
 //============================================================================
@@ -972,9 +938,12 @@ SALOMEDS::Callback_ptr SALOMEDS_StudyBuilder_i::SetOnAddSObject(SALOMEDS::Callba
 //============================================================================
 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;
+  return _study->SetOnRemoveSObject(theCallback);
+}
+
+void SALOMEDS_StudyBuilder_i::OnRemoveSObject(SALOMEDS::SObject_ptr theObject)
+{
+  _study->OnRemoveSObject(theObject);
 }
 
 //============================================================================
@@ -983,14 +952,7 @@ SALOMEDS::Callback_ptr SALOMEDS_StudyBuilder_i::SetOnRemoveSObject(SALOMEDS::Cal
  */
 //============================================================================
 void SALOMEDS_StudyBuilder_i::CheckLocked() throw (SALOMEDS::StudyBuilder::LockProtection) {
-  Unexpect aCatch(SBLockProtection);
-  if (_doc->HasOpenCommand()) return;
-  Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
-  if (!_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(), anAttr)) {
-    anAttr = new SALOMEDS_StudyPropertiesAttribute;
-    _doc->Main().AddAttribute(anAttr);
-    }
-  if (anAttr->IsLocked()) throw SALOMEDS::StudyBuilder::LockProtection();
+  _study->CheckLocked();
 }
 
 //============================================================================
@@ -1003,9 +965,12 @@ void SALOMEDS_StudyBuilder_i::SetName(SALOMEDS::SObject_ptr theSO, const char* t
 {
   Unexpect aCatch(SBLockProtection);
   CheckLocked();
+
+  if(CORBA::is_nil(theSO))
+    return;
+
   //Find label
   TDF_Label aLabel;
-  ASSERT(!CORBA::is_nil(theSO));
   CORBA::String_var aSOID = theSO->GetID();
   TDF_Tool::Label(_doc->GetData(), aSOID, aLabel);
   TDataStd_Name::Set(aLabel, (char*)theValue);
@@ -1021,9 +986,12 @@ void SALOMEDS_StudyBuilder_i::SetComment(SALOMEDS::SObject_ptr theSO, const char
 {
   Unexpect aCatch(SBLockProtection);
   CheckLocked();
+
+  if(CORBA::is_nil(theSO))
+    return;
+
    //Find label
   TDF_Label aLabel;
-  ASSERT(!CORBA::is_nil(theSO));
   CORBA::String_var aSOID = theSO->GetID();
   TDF_Tool::Label(_doc->GetData(), aSOID, aLabel);
   TDataStd_Comment::Set(aLabel, (char*)theValue);
@@ -1039,10 +1007,13 @@ void SALOMEDS_StudyBuilder_i::SetIOR(SALOMEDS::SObject_ptr theSO, const char* th
 {
   Unexpect aCatch(SBLockProtection);
   CheckLocked();
+
+  if(CORBA::is_nil(theSO))
+    return;
+
   //Find label
   TDF_Label aLabel;
-  ASSERT(!CORBA::is_nil(theSO));
   CORBA::String_var aSOID = theSO->GetID();
   TDF_Tool::Label(_doc->GetData(), aSOID, aLabel);
-  SALOMEDS_IORAttribute::Set(aLabel, TCollection_ExtendedString((char*)theValue), _orb);
+  SALOMEDS_IORAttribute::Set(aLabel, TCollection_ExtendedString((char*)theValue),GetORB());
 }
index 2b51ac83896758fa61250863855e4777b5136a56..b2bddafa5903ee0ab6ed71089a04dc0c9f1b32d6 100644 (file)
 #ifndef __SALOMEDS_STUDYBUIlDER_I_H__
 #define __SALOMEDS_STUDYBUILDER_I_H__
 
-
-// std C++ headers
-#include <iostream.h>
-
 // IDL headers
 #include <SALOMEconfig.h>
 #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 <TDocStd_Document.hxx>
 
-class SALOMEDS_StudyBuilder_i: public POA_SALOMEDS::StudyBuilder,
-                         public PortableServer::RefCountServantBase {
-private:
-  CORBA::ORB_ptr           _orb;
+class SALOMEDS_Study_i;
+class SALOMEDS_Callback_i;
+
+class SALOMEDS_StudyBuilder_i: public virtual POA_SALOMEDS::StudyBuilder,
+                              public virtual PortableServer::RefCountServantBase 
+{
+  SALOMEDS_StudyBuilder_i(); // Not implemented
+  void operator=(const SALOMEDS_StudyBuilder_i&); // Not implemented
+
+  SALOMEDS_Study_i*        _study;
   Handle(TDocStd_Document) _doc;  // OCAF Document
-  SALOMEDS::Callback_var   _callbackOnAdd;
-  SALOMEDS::Callback_var   _callbackOnRemove;
+
+  void OnAddSObject(SALOMEDS::SObject_ptr theObject);
+  void OnRemoveSObject(SALOMEDS::SObject_ptr theObject);
+
 public:
-    
-  SALOMEDS_StudyBuilder_i(const Handle(TDocStd_Document), CORBA::ORB_ptr);
+  SALOMEDS_StudyBuilder_i(SALOMEDS_Study_i* theStudy,
+                         const Handle(TDocStd_Document)& theDocument);
 
   ~SALOMEDS_StudyBuilder_i();
 
+  CORBA::ORB_var GetORB() const;
+  PortableServer::POA_var GetPOA() const;
+
   //! NewComponent
   /*!
     \param ComponentDataType    
index 4e2e56a67b185a9ed760dbb49b33958cbe670496..2da9950d8a249afe2365c5b5ea098f00a80494f8 100644 (file)
 //  Module : SALOME
 //  $Header$
 
-#include "utilities.h"
-#include "SALOME_LifeCycleCORBA.hxx"
-#include "SALOMEDS_StudyManager_i.hxx"
-#include "SALOMEDS_Study_i.hxx"
-#include "SALOMEDS_SComponent_i.hxx"
+#include <memory>
+#include <sstream>
 
-#include "SALOMEDS_IORAttribute.hxx"
-#include "SALOMEDS_PersRefAttribute.hxx"
-#include "SALOMEDS_Tool.hxx"
+#include <OSD_Process.hxx>
+#include <Quantity_Date.hxx>
 
 #include <TDF_Label.hxx>
 #include <TDataStd_Name.hxx>
 #include <TDataStd_Comment.hxx>
+#include <TDataStd_Integer.hxx>
 #include <TDataStd_TreeNode.hxx>
 #include <TDataStd_UAttribute.hxx> 
+#include <TDF_ChildIterator.hxx>
 #include <TDF_Tool.hxx>
 #include <TDF_Reference.hxx>
 #include <TDF_Data.hxx>
 #include <TDF_RelocationTable.hxx>
 #include <TDF_AttributeIterator.hxx>
-//  #include <TDocStd_Owner.hxx>
-#include <TColStd_HArray1OfCharacter.hxx>
 #include <TCollection_ExtendedString.hxx>
-#include "HDFexplorer.hxx"
-#include "SALOMEDS_SequenceOfRealAttribute.hxx"
-#include "SALOMEDS_SequenceOfIntegerAttribute.hxx"
-#include <TColStd_HSequenceOfReal.hxx>
-#include <TColStd_HSequenceOfInteger.hxx>
-#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 <TCollection_AsciiString.hxx>
+
+#include "SALOMEDS_StudyManager_i.hxx"
+#include "SALOME_LifeCycleCORBA.hxx"
+#include "SALOMEDS_SObject_i.hxx"
+#include "SALOMEDS_Study_i.hxx"
+
+#include "SALOMEDS_IORAttribute.hxx"
+#include "SALOMEDS_PersRefAttribute.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 <OSD_Process.hxx>
-#include <Quantity_Date.hxx>
 
-#include "Utils_CorbaException.hxx"
+#include "SALOMEDS_Tool.hxx"
+#include "HDFexplorer.hxx"
 
-#include <strstream>
+// IDL headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
 
 #include "SALOME_GenericObj_i.hh"
-
+#include "Utils_CorbaException.hxx"
 #include "Utils_ExceptHandlers.hxx"
-using namespace std;
 
 UNEXPECT_CATCH(SalomeException,SALOME::SALOME_Exception);
 UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection);
@@ -87,6 +74,41 @@ UNEXPECT_CATCH(LockProtection, SALOMEDS::StudyBuilder::LockProtection);
 #define AUTO_SAVE_GUID                "128268A3-71C9-4036-89B1-F81BD6A4FCF2"
 #define AUTO_SAVE_TAG                 "0:8"
 #define AUTO_SAVE_TIME_OUT_IN_SECONDS 1200
+
+#include "utilities.h"
+
+using namespace std;
+
+//===========================================================================
+namespace SALOMEDS{
+
+  CORBA::Object_var 
+  GetObject(const TDF_Label& theLabel, CORBA::ORB_ptr theORB)
+  {
+    try {
+      Handle(SALOMEDS_IORAttribute) anAttr;
+      if(theLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(),anAttr))
+       return theORB->string_to_object(TCollection_AsciiString(anAttr->Get()).ToCString());
+    }catch(...){
+    }
+    return CORBA::Object::_nil();
+  }
+
+
+  PortableServer::ServantBase_var 
+  GetServant(CORBA::Object_ptr theObject, PortableServer::POA_ptr thePOA)
+  {
+    if(CORBA::is_nil(theObject))
+      return NULL;
+    try{
+      return thePOA->reference_to_servant(theObject);
+    }catch(...){
+      return NULL;
+    }
+  }
+
+}
+
 //===========================================================================
 //Function : LoadAttributes
 //===========================================================================
@@ -127,44 +149,30 @@ static void ReadAttributes(SALOMEDS::Study_ptr theStudy,
 //============================================================================
 //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,
-                                          CORBA::Boolean             isASCII)
+static void Translate_IOR_to_persistentID (SALOMEDS::Study_ptr theStudy,
+                                          SALOMEDS::StudyBuilder_ptr theBuilder,
+                                          SALOMEDS::SObject_ptr theSObject,
+                                          SALOMEDS::Driver_ptr theEngine,
+                                          CORBA::Boolean theIsMultiFile,
+                                          CORBA::Boolean theIsASCII)
 {
   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());
-    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, isASCII);
-      
-//       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 "<<persistent_string);
-      persistent_string = 0;
-      curid = 0;
+  SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(theSObject);
+  for (; anIter->More(); anIter->Next()){
+    SALOMEDS::GenericAttribute_var anAttr;
+    SALOMEDS::SObject_var aSObject = anIter->Value();
+    if(aSObject->FindAttribute(anAttr,"AttributeIOR")){
+      SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
+      CORBA::String_var aString = anIOR->Value();
+      CORBA::String_var aPersistentID = 
+       theEngine->IORToLocalPersistentID(aSObject,aString,theIsMultiFile,theIsASCII);
+      anAttr = theBuilder->FindOrCreateAttribute(aSObject,"AttributePersistentRef");
+      SALOMEDS::AttributePersistentRef_var aPersistentRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr);
+      aPersistentRef->SetValue(aPersistentID);
+      aString = aSObject->GetID();
     }
-    Translate_IOR_to_persistentID (study,SB,current,engine,isMultiFile, isASCII);
+    Translate_IOR_to_persistentID(theStudy,theBuilder,aSObject,theEngine,theIsMultiFile,theIsASCII);
   }
-  CORBA::string_free(persistent_string);
-  CORBA::string_free(curid);
 }
 
 //============================================================================
@@ -215,14 +223,16 @@ static void BuildTree (SALOMEDS::Study_ptr theStudy,HDFgroup* hdf_current_group)
  *  Purpose  : SALOMEDS_StudyManager_i constructor 
  */
 //============================================================================
-SALOMEDS_StudyManager_i::SALOMEDS_StudyManager_i(CORBA::ORB_ptr orb) 
+SALOMEDS_StudyManager_i::SALOMEDS_StudyManager_i(CORBA::ORB_ptr theORB, 
+                                                PortableServer::POA_ptr thePOA):
+  _orb(CORBA::ORB::_duplicate(theORB)),
+  _poa(PortableServer::POA::_duplicate(thePOA)),
+  _OCAFApp(new SALOMEDS_OCAFApplication()),
+  _name_service(theORB)
 { 
-  _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");
+  _name_service.Create_Directory("/Study");
   _IDcounter = 0;
 }
 
@@ -234,9 +244,7 @@ SALOMEDS_StudyManager_i::SALOMEDS_StudyManager_i(CORBA::ORB_ptr orb)
 SALOMEDS_StudyManager_i::~SALOMEDS_StudyManager_i()
 {
   // Destroy directory to register open studies
-  _name_service->Destroy_Directory("/Study");
-  // Destroy OCAF document
-  delete &_OCAFApp;
+  _name_service.Destroy_Directory("/Study");
 }
 
 //============================================================================
@@ -245,9 +253,9 @@ SALOMEDS_StudyManager_i::~SALOMEDS_StudyManager_i()
  *             context name
  */
 //============================================================================
-void SALOMEDS_StudyManager_i::register_name(char * name) {
-  SALOMEDS::StudyManager_ptr g = SALOMEDS::StudyManager::_narrow(_this());
-  _name_service->Register(g, name);
+void SALOMEDS_StudyManager_i::register_name(char * theName) {
+  SALOMEDS::StudyManager_var aManager(_this());
+  _name_service.Register(aManager.in(),theName);
 }
 
 
@@ -256,40 +264,43 @@ void SALOMEDS_StudyManager_i::register_name(char * name) {
  *  Purpose  : Create a New Study of name study_name
  */
 //============================================================================
-SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name) 
+SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* theStudyName) 
 {
-  Handle(TDocStd_Document) Doc;
-  _OCAFApp->NewDocument("SALOME_STUDY",Doc); 
+  Handle(TDocStd_Document) aDocument;
+  _OCAFApp->NewDocument("SALOME_STUDY",aDocument); 
 
   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());
+  SALOMEDS_Study_i* aStudyServant = new SALOMEDS_Study_i(this,aDocument,theStudyName); 
+  SALOMEDS::Study_var aStudy = aStudyServant->_this();
 
   //Study->StudyId( _OCAFApp->NbDocuments() ); 
   _IDcounter++;
-  Study->StudyId( _IDcounter );
+  aStudyServant->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);
-
+  if(!_name_service.Change_Directory("/Study")){
+    MESSAGE( "Unable to access the study directory" );
+  }else
+    _name_service.Register(aStudy, theStudyName);
+                                                  
   // 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((char*)IORStudy),_orb);
+  CORBA::String_var anIOR = _orb->object_to_string(aStudy);
+  SALOMEDS_IORAttribute::Set(aDocument->Main().Root(),const_cast<char*>(anIOR.in()),_orb);
 
   // set Study properties
-  SALOMEDS::AttributeStudyProperties_ptr aProp = Study->GetProperties();
+  SALOMEDS::AttributeStudyProperties_var aProp = aStudyServant->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->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;
+  return aStudy._retn();
 }
 
 //============================================================================
@@ -297,107 +308,96 @@ SALOMEDS::Study_ptr SALOMEDS_StudyManager_i::NewStudy(const char* study_name)
  *  Purpose  : Open a Study from it's persistent reference
  */
 //============================================================================
-SALOMEDS::Study_ptr  SALOMEDS_StudyManager_i::Open(const char* aUrl)
+SALOMEDS::Study_ptr  SALOMEDS_StudyManager_i::Open(const char* theURL)
      throw(SALOME::SALOME_Exception)
 {
   Unexpect aCatch(SalomeException);
   MESSAGE("Begin of SALOMEDS_StudyManager_i::Open");
-  // open the HDFFile 
-  HDFfile *hdf_file =0;         
-  HDFgroup *hdf_group_study_structure =0;
 
-  char* aHDFUrl;
   bool isASCII = false;
-  if (HDFascii::isASCII(aUrl)) {
+  std::ostringstream anURLStream;
+  if (HDFascii::isASCII(theURL)) {
     isASCII = true;
-    char* aResultPath = HDFascii::ConvertFromASCIIToHDF(aUrl);
-    aHDFUrl = new char[strlen(aResultPath) + 19];
-    sprintf(aHDFUrl, "%shdf_from_ascii.hdf", aResultPath);
-    delete(aResultPath);
+    auto_ptr<char> aResultPath(HDFascii::ConvertFromASCIIToHDF(theURL));
+    anURLStream<<aResultPath.get()<<"hdf_from_ascii.hdf";
   } else {
-    aHDFUrl = CORBA::string_dup(aUrl);
+    anURLStream<<theURL;
   }
+  std::string aHDFUrl = anURLStream.str();
+
+  // open the HDFFile (all related hdf objects will be deleted     )
+  auto_ptr<HDFfile> hdf_file(new HDFfile(const_cast<char*>(aHDFUrl.c_str())));
 
-  hdf_file = new HDFfile(aHDFUrl);
   try {
     hdf_file->OpenOnDisk(HDF_RDONLY);// mpv: was RDWR, but opened file can be write-protected too
-  }
-  catch (HDFexception)
-    {
-//        MESSAGE( "HDFexception ! " );
-//        cerr << "HDFexception ! " << endl;
-      delete aHDFUrl;
-//       char eStr[strlen(aUrl)+17];
-      char *eStr = new char[strlen(aUrl)+17+1];
-      sprintf(eStr,"Can't open file %s",aUrl);
-      THROW_SALOME_CORBA_EXCEPTION(CORBA::string_dup(eStr),SALOME::BAD_PARAM);
-      
-    } 
+  }catch(HDFexception){
+    std::ostringstream aStream;
+    aStream<<"Can't open file "<<theURL;
+    std::string eStr = aStream.str();
+    THROW_SALOME_CORBA_EXCEPTION(eStr.c_str(),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()); 
+  SALOMEDS_Study_i* aStudyServant = new SALOMEDS_Study_i(this,Doc,theURL);  
+  SALOMEDS::Study_var aStudy = aStudyServant->_this(); 
 
-  //  Study->StudyId( _OCAFApp->NbDocuments() ); 
+  //  aStudy->StudyId( _OCAFApp->NbDocuments() ); 
   _IDcounter++;
-  Study->StudyId( _IDcounter );
+  aStudy->StudyId( _IDcounter );
 
   // Assign the value of the URL in the study object
-  Study->URL (aUrl);
-  SCRUTE(aUrl);
+  aStudy->URL(theURL);
+  SCRUTE(theURL);
 
   // 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);
+  CORBA::String_var anIOR = _orb->object_to_string(aStudy);
+  SALOMEDS_IORAttribute::Set(Doc->Main().Root(),const_cast<char*>(anIOR.in()),_orb);
 
-  SALOMEDS_PersRefAttribute::Set(Doc->Main(),(char*)aUrl); 
+  SALOMEDS_PersRefAttribute::Set(Doc->Main(),const_cast<char*>(theURL)); 
 
   if (!hdf_file->ExistInternalObject("STUDY_STRUCTURE")) {
-    delete aHDFUrl;
     MESSAGE("SALOMEDS_StudyManager::Open : the study is empty");
-    return Study;
+    return aStudy._retn();
   }
 
   //Create  the Structure of the OCAF Document
-  hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file);
+  HDFgroup *hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file.get());
 
   Handle(TDF_Data) DF = Doc->GetData();
 
-  try {
-    BuildTree (Study,hdf_group_study_structure);
-  }
-  catch (HDFexception)
-    {
-//        MESSAGE( "HDFexception ! " );
-//        cerr << "HDFexception ! " << endl;
-      delete aHDFUrl;
-      char *eStr=new char[strlen(aUrl)+17];
-      sprintf(eStr,"Can't open file %s",aUrl);
-      THROW_SALOME_CORBA_EXCEPTION(CORBA::string_dup(eStr),SALOME::BAD_PARAM);
-    } 
+  try{
+    BuildTree (aStudy,hdf_group_study_structure);
+  }catch(HDFexception){
+    std::ostringstream aStream;
+    aStream<<"Can't open file "<<theURL;
+    std::string eStr = aStream.str();
+    THROW_SALOME_CORBA_EXCEPTION(eStr.c_str(),SALOME::BAD_PARAM);
+  } 
   
   hdf_file->CloseOnDisk();
 
   // 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, CORBA::string_dup(Study->Name()));
-
+  if(!_name_service.Change_Directory("/Study")){
+    MESSAGE( "Unable to access the study directory" );
+  }else{
+    CORBA::String_var aString(aStudy->Name());
+    _name_service.Register(aStudy,aString.in());
+  }
 
   if (isASCII) {
     SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
     aFilesToRemove->length(1);
-    aFilesToRemove[0] = CORBA::string_dup(&(aHDFUrl[strlen(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str())]));
-    SALOMEDS_Tool::RemoveTemporaryFiles(SALOMEDS_Tool::GetDirFromPath(aHDFUrl).c_str(), aFilesToRemove, true);
+    std::string aDir = SALOMEDS_Tool::GetDirFromPath(aHDFUrl);
+    aFilesToRemove[0] = CORBA::string_dup(&aHDFUrl[strlen(aDir.c_str())]);
+    SALOMEDS_Tool::RemoveTemporaryFiles(aDir,aFilesToRemove,true);
   }
-  delete aHDFUrl;
-  delete hdf_file; // all related hdf objects will be deleted
-  return Study;
+
+  return aStudy._retn();
 }
 
 
@@ -416,9 +416,11 @@ void  SALOMEDS_StudyManager_i::Close(SALOMEDS::Study_ptr aStudy)
   aStudy->RemovePostponed(-1);
   
   // Destroy study name in the naming service
-  if(_name_service->Change_Directory("/Study")) 
-    _name_service->Destroy_Name(aStudy->Name());
-  
+  if(_name_service.Change_Directory("/Study")){
+    CORBA::String_var aString(aStudy->Name());
+    _name_service.Destroy_Name(aString.in());
+  }
+
   aStudy->Close();
 }
 
@@ -427,26 +429,24 @@ void  SALOMEDS_StudyManager_i::Close(SALOMEDS::Study_ptr aStudy)
  *  Purpose  : Save a Study to it's persistent reference
  */
 //============================================================================
-void SALOMEDS_StudyManager_i::Save(SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile)
+void SALOMEDS_StudyManager_i::Save(SALOMEDS::Study_ptr theStudy, 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, false);
-    }
+  CORBA::String_var anURL = theStudy->URL();
+  if(strcmp(anURL.in(),"") == 0){
+    MESSAGE( "No path specified to save the study. Nothing done");
+  }else{
+    _SaveAs(anURL,theStudy,theMultiFile,false);
+  }
 }
 
-void SALOMEDS_StudyManager_i::SaveASCII(SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile)
+void SALOMEDS_StudyManager_i::SaveASCII(SALOMEDS::Study_ptr theStudy, 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, true);
-    }
+  CORBA::String_var anURL = theStudy->URL();
+  if(strcmp(anURL.in(),"") == 0){
+    MESSAGE( "No path specified to save the study. Nothing done");
+  }else{
+    _SaveAs(anURL,theStudy,theMultiFile,true);
+  }
 }
 
 //=============================================================================
@@ -454,15 +454,15 @@ void SALOMEDS_StudyManager_i::SaveASCII(SALOMEDS::Study_ptr aStudy, CORBA::Boole
  *  Purpose  : Save a study to the persistent reference aUrl
  */
 //============================================================================
-void SALOMEDS_StudyManager_i::SaveAs(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile)
+void SALOMEDS_StudyManager_i::SaveAs(const char* aUrl, SALOMEDS::Study_ptr theStudy, CORBA::Boolean theMultiFile)
 {
-  _SaveAs(aUrl,aStudy,theMultiFile, false);
+  _SaveAs(aUrl,theStudy,theMultiFile, false);
 
 }
 
-void SALOMEDS_StudyManager_i::SaveAsASCII(const char* aUrl, SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile)
+void SALOMEDS_StudyManager_i::SaveAsASCII(const char* aUrl, SALOMEDS::Study_ptr theStudy, CORBA::Boolean theMultiFile)
 {
-  _SaveAs(aUrl,aStudy,theMultiFile, true);
+  _SaveAs(aUrl,theStudy,theMultiFile, true);
 }
 
 //============================================================================
@@ -473,25 +473,20 @@ void SALOMEDS_StudyManager_i::SaveAsASCII(const char* aUrl, SALOMEDS::Study_ptr
 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<string> _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]) ;
-       }
+  SALOMEDS::ListOfOpenStudies_var aStudyList = new SALOMEDS::ListOfOpenStudies;
+
+  if(!_name_service.Change_Directory("/Study")){
+    MESSAGE("No active study in this session");
+  }else{
+    vector<string> aList = _name_service.list_directory();
+    aStudyList->length(aList.size());
+    for(unsigned int ind = 0; ind < aList.size(); ind++){
+      aStudyList[ind] = CORBA::string_dup(aList[ind].c_str());
+      SCRUTE(aStudyList[ind]) ;
     }
-  return _list_open_studies._retn();
+  }
+
+  return aStudyList._retn();
 }
 
 //============================================================================
@@ -500,33 +495,25 @@ SALOMEDS::ListOfOpenStudies*  SALOMEDS_StudyManager_i::GetOpenStudies()
  */
 //============================================================================
 SALOMEDS::Study_ptr  
-SALOMEDS_StudyManager_i::GetStudyByName(const char* aStudyName) 
+SALOMEDS_StudyManager_i::GetStudyByName(const char* theStudyName) 
 {
-  SALOMEDS::Study_var Study;
+  SALOMEDS::Study_var aStudy;
 
   // 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...
-    }
+  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)
-    {
+  if(_name_service.Find(theStudyName) > 0){
     // Study found
-    CORBA::Object_ptr obj= _name_service->Resolve(theStudyName) ;
-    Study = SALOMEDS::Study::_narrow(obj);
+    CORBA::Object_ptr anObj = _name_service.Resolve(theStudyName) ;
+    aStudy = SALOMEDS::Study::_narrow(anObj);
     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;
+  }else{
+    MESSAGE("Study " << theStudyName << " not found in the naming service");
+  }
+  return aStudy._retn();
 }
 
 //============================================================================
@@ -537,39 +524,30 @@ SALOMEDS_StudyManager_i::GetStudyByName(const char* aStudyName)
 SALOMEDS::Study_ptr  
 SALOMEDS_StudyManager_i::GetStudyByID(CORBA::Short aStudyID) 
 {
-  SALOMEDS::Study_var Study;
-  vector<string> _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");
-         }
+  SALOMEDS::Study_var aStudy;
+
+  if(!_name_service.Change_Directory("/Study")){
+    MESSAGE("No active study in this session");
+  }else{
+    vector<string> aList = _name_service.list_directory();
+    for(unsigned int ind = 0; ind < aList.size(); ind++){
+      const char* aStudyName = aList[ind].c_str();
+      MESSAGE( "GetStudyByID = " << aStudyName );
+      if(_name_service.Find(aStudyName) > 0){
+       CORBA::Object_ptr anObj = _name_service.Resolve(aStudyName) ;
+       aStudy = SALOMEDS::Study::_narrow(anObj);
+       MESSAGE( " aStudyID : " << aStudyID << "-" << aStudy->StudyId() );
+       if(aStudyID == aStudy->StudyId()){
+         MESSAGE("Study with studyID = " << aStudyID << " found in the naming service");
+         return aStudy._retn();
        }
-      Study = SALOMEDS::Study::_narrow( CORBA::Object::_nil()); 
+      }else{
+       MESSAGE("Study " << aStudyName << " not found in the naming service");
+      }
     }
-  return Study;
+  }
+  
+  return aStudy._retn();
 }
 //============================================================================
 /*! Function : SaveAttributes
@@ -584,26 +562,26 @@ static void SaveAttributes(SALOMEDS::SObject_ptr SO, HDFgroup *hdf_group_sobject
     if (strcmp(anAttrList[a]->Type(), "AttributeIOR") == 0) continue; // never write AttributeIOR to file
     if (strcmp(anAttrList[a]->Type(), "AttributeExternalFileDef") == 0) continue; // never write ExternalFileDef to file
     if (strcmp(anAttrList[a]->Type(), "AttributeFileType") == 0) continue; // never write FileType to file
-    CORBA::String_var aSaveStr = CORBA::string_dup(anAttrList[a]->Store());
-    size[0] = (hdf_int32) strlen(aSaveStr) + 1;
+    CORBA::String_var aSaveStr(anAttrList[a]->Store());
+    size[0] = (hdf_int32) strlen(aSaveStr.in()) + 1;
     HDFdataset *hdf_dataset = new HDFdataset(anAttrList[a]->Type(),hdf_group_sobject,HDF_STRING,size,1);
     hdf_dataset->CreateOnDisk();
     hdf_dataset->WriteOnDisk(aSaveStr);
     hdf_dataset->CloseOnDisk();
-    //MESSAGE("********** Write Attribute "<<anAttrList[a]->Type()<<" : "<<aSaveStr<<" done");
-    hdf_dataset=0; //will be deleted by hdf_sco_group destructor
+    //cout<<"********** Write Attribute "<<anAttrList[a]->Type()<<" : "<<aSaveStr<<" done"<<endl;
+    hdf_dataset = 0; //will be deleted by hdf_sco_group destructor
   }
 
   // Reference attribute has no CORBA attribute representation, so, GetAllAttributes can not return this attribute
   SALOMEDS::SObject_var RefSO;
   if(SO->ReferencedObject(RefSO)) {
-    CORBA::String_var attribute_reference = CORBA::string_dup(RefSO->GetID());
+    CORBA::String_var attribute_reference(RefSO->GetID());
     size[0] = strlen(attribute_reference) + 1 ; 
     HDFdataset *hdf_dataset = new HDFdataset("Reference",hdf_group_sobject,HDF_STRING,size,1);
     hdf_dataset->CreateOnDisk();
     hdf_dataset->WriteOnDisk(attribute_reference);
     hdf_dataset->CloseOnDisk();
-    hdf_dataset =0; // will be deleted by father hdf object destructor
+    hdf_dataset = 0; // will be deleted by father hdf object destructor
   }
 }
 
@@ -612,65 +590,54 @@ static void SaveAttributes(SALOMEDS::SObject_ptr SO, HDFgroup *hdf_group_sobject
  *  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;
-
+void SALOMEDS_StudyManager_i::_SaveProperties(SALOMEDS::Study_ptr aStudy, HDFgroup *hdf_group) 
+{
   // 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);
+  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);
+                        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;
+  aProp->GetModificationsList(aNames,aMinutes,aHours,aDays,aMonths,aYears,true);
+
+  std::ostringstream aPropertyList;
+  aPropertyList<<(strlen(aProp->GetCreationMode()) != 0? aProp->GetCreationMode()[0] : '0');
+  aPropertyList<<(aProp->IsLocked()? 'l': 'u');
+
+  int aLength = aNames->length();
+  for(int anIndex = 0; anIndex  < aLength; anIndex++) {
+    aPropertyList<<std::setw(2)<<aMinutes[anIndex];
+    aPropertyList<<std::setw(2)<<aHours[anIndex];
+    aPropertyList<<std::setw(2)<<aDays[anIndex];
+    aPropertyList<<std::setw(2)<<aMonths[anIndex];
+    aPropertyList<<std::setw(4)<<aYears[anIndex];
+    aPropertyList<<aNames[anIndex];
+    aPropertyList<<char(0x1);
   }
-  aProperty[a] = 0;
+  std::string aProperty = aPropertyList.str();
 
-  name_len = (hdf_int32) a;
-//    MESSAGE("*** Property: "<<aProperty);
-  size[0] = name_len + 1 ; 
-  hdf_dataset = new HDFdataset("AttributeStudyProperties",hdf_group,HDF_STRING,size,1);
+  hdf_size size[] = {aProperty.size() + 1};
+  HDFdataset *hdf_dataset = new HDFdataset("AttributeStudyProperties",hdf_group,HDF_STRING,size,1);
   hdf_dataset->CreateOnDisk();
-  hdf_dataset->WriteOnDisk(aProperty);
+  hdf_dataset->WriteOnDisk(const_cast<char*>(aProperty.c_str()));
   MESSAGE("attribute StudyProperties " <<  aProperty << " wrote on file");
   hdf_dataset->CloseOnDisk();
-  hdf_dataset=0; //will be deleted by hdf_sco_group destructor
-  //delete(aProperty); 
-  delete [] aProperty;
+  hdf_dataset = 0; //will be deleted by hdf_sco_group destructor
   aProp->SetModified(0);
 }
 
@@ -697,13 +664,8 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl,
 
   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);
@@ -719,29 +681,31 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl,
       for (; itcomponent1->More(); itcomponent1->Next())
        {
          SALOMEDS::SComponent_var sco = itcomponent1->Value();
-
          // if there is an associated Engine call its method for saving
          CORBA::String_var IOREngine;
          try {
+           
            if (!sco->ComponentIOR(IOREngine)) {
              SALOMEDS::GenericAttribute_var aGeneric;
-             SALOMEDS::AttributeComment_var aName;
-             if(sco->FindAttribute(aGeneric, "AttributeComment"))
-               aName = SALOMEDS::AttributeComment::_narrow(aGeneric);
-           
+             SALOMEDS::AttributeName_var aName;
+             if(sco->FindAttribute(aGeneric, "AttributeName"))
+               aName = SALOMEDS::AttributeName::_narrow(aGeneric);
+
              if (!aName->_is_nil()) {
                
                CORBA::String_var aCompType = aName->Value();
 
+               
                CORBA::String_var aFactoryType;
                if (strcmp(aCompType, "SUPERV") == 0) aFactoryType = "SuperVisionContainer";
                else aFactoryType = "FactoryServer";
                
                Engines::Component_var aComp =
-                 SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component(aFactoryType, aCompType);
+                 SALOME_LifeCycleCORBA(&_name_service).FindOrLoad_Component(aFactoryType, aCompType);
+               
                if (aComp->_is_nil()) {
                  Engines::Component_var aComp =
-                   SALOME_LifeCycleCORBA(_name_service).FindOrLoad_Component("FactoryServerPy", aCompType);
+                   SALOME_LifeCycleCORBA(&_name_service).FindOrLoad_Component("FactoryServerPy", aCompType);
                }
                
                if (!aComp->_is_nil()) {
@@ -902,21 +866,20 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl,
          hdf_sco_group2->CreateOnDisk();
           SaveAttributes(SC, hdf_sco_group2);
          // ComponentDataType treatment
-         component_name = SC->ComponentDataType();
+         CORBA::String_var component_name = SC->ComponentDataType();
          MESSAGE("Component data type " << component_name << " treated");
          
-         name_len = (hdf_int32) strlen(component_name);
+         name_len = (hdf_int32) strlen(component_name.in());
          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);
+         hdf_dataset->WriteOnDisk(const_cast<char*>(component_name.in()));
          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
@@ -951,9 +914,9 @@ void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl,
       hdf_group_study_structure->CloseOnDisk();
       hdf_file->CloseOnDisk();
 
-      _name_service->Change_Directory("/Study");
-      _name_service->Destroy_Name(anOldName);
-      _name_service->Register(aStudy, aStudy->Name());
+      _name_service.Change_Directory("/Study");
+      _name_service.Destroy_Name(anOldName);
+      _name_service.Register(aStudy, aStudy->Name());
 
       aStudy->IsSaved(true);
       hdf_group_study_structure =0; // will be deleted by hdf_file destructor
@@ -981,9 +944,6 @@ void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS::Study_ptr aStudy,
   // 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()) 
@@ -1006,7 +966,7 @@ void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS::Study_ptr aStudy,
        }
       }
 
-      CORBA::String_var scoid = CORBA::string_dup(SO->GetID());
+      CORBA::String_var scoid(SO->GetID());
       hdf_group_sobject = new HDFgroup(scoid,hdf_group_datatype);
       hdf_group_sobject->CreateOnDisk();
       SaveAttributes(SO, hdf_group_sobject);
@@ -1023,15 +983,13 @@ void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS::Study_ptr aStudy,
  */
 //============================================================================
 
-const char *SALOMEDS_StudyManager_i::_SubstituteSlash(const char *aUrl)
+std::string SALOMEDS_StudyManager_i::_SubstituteSlash(const char *theUrl)
 {
   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 CORBA::string_dup(ch.ToCString());
+  TCollection_ExtendedString aUrl(const_cast<char*>(theUrl));
+  aUrl.ChangeAll(ToExtCharacter('/'),ToExtCharacter(':'));
+  TCollection_AsciiString ch(aUrl);
+  return ch.ToCString();
 }
 
 //============================================================================
@@ -1041,41 +999,23 @@ const char *SALOMEDS_StudyManager_i::_SubstituteSlash(const char *aUrl)
 //============================================================================
 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;
+
+  if(aComponent->_is_nil()) 
+    return false;
+
+  if(aComponent == theObject) 
+    return false;
 
   CORBA::String_var IOREngine;
-  if (!aComponent->ComponentIOR(IOREngine)) return false;
+  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;
-  Standard_Boolean a = Engine->CanCopy(theObject);
-  return a;
-}
-
-//============================================================================
-/*! 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()); 
-      SALOMEDS::Study_var aStudy = aSO->GetStudy();
-      if(CORBA::is_nil(aStudy)) continue;  //The clipboard document ( hopefully :) )
-      if (aStudy->StudyId() == theStudy->StudyId()) break;
-      aDocument.Nullify();
-    }
-  }
+  if (CORBA::is_nil(Engine)) 
+    return false;
 
-  return aDocument;
+  return Engine->CanCopy(theObject);
 }
 
 //============================================================================
@@ -1083,11 +1023,12 @@ Handle(TDocStd_Document) SALOMEDS_StudyManager_i::GetDocumentOfStudy(SALOMEDS::S
  *  Purpose  : 
  */
 //============================================================================
-void SALOMEDS_StudyManager_i::CopyLabel(const SALOMEDS::Study_ptr theSourceStudy,
+void SALOMEDS_StudyManager_i::CopyLabel(SALOMEDS_Study_i* theSourceStudy,
                                        const SALOMEDS::Driver_ptr theEngine,
                                        const Standard_Integer theSourceStartDepth,
                                        const TDF_Label& theSource,
-                                       const TDF_Label& theDestinationMain) {
+                                       const TDF_Label& theDestinationMain) 
+{
   int a;
   TDF_Label aTargetLabel = theDestinationMain;
   TDF_Label aAuxTargetLabel = theDestinationMain.Father().FindChild(2);
@@ -1123,18 +1064,15 @@ void SALOMEDS_StudyManager_i::CopyLabel(const SALOMEDS::Study_ptr theSourceStudy
       TCollection_AsciiString anEntry;
       TDF_Tool::Entry(theSource, anEntry);
       SALOMEDS::SObject_var aSO = theSourceStudy->FindObjectID(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);
-//        }
+      CORBA::Long 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();
@@ -1151,50 +1089,58 @@ void SALOMEDS_StudyManager_i::CopyLabel(const SALOMEDS::Study_ptr theSourceStudy
 //============================================================================
 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
+  // copy only SObjects and attributes without component help
   SALOMEDS::GenericAttribute_var anAttribute;
-  aStructureOnly = !theObject->FindAttribute(anAttribute, "AttributeIOR");
+  bool aStructureOnly = !theObject->FindAttribute(anAttribute, "AttributeIOR");
 
-  // get component-engine
-  SALOMEDS::Study_var aStudy = theObject->GetStudy();
+  PortableServer::ServantBase_var aServant = GetServant(theObject,_poa);
+  SALOMEDS_SObject_i* aSObject = dynamic_cast<SALOMEDS_SObject_i*>(aServant.in());
+  if(aSObject == NULL) 
+    return false;
 
-  SALOMEDS::Driver_var Engine;
+  SALOMEDS_Study_i* aStudy = aSObject->GetStudyServant();
+  SALOMEDS::Driver_var anEngine;
+  CORBA::String_var aString;
   if (!aStructureOnly) {
     SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent();
-    CORBA::String_var IOREngine;
-    if (!aComponent->ComponentIOR(IOREngine)) return false;
+    if(!aComponent->ComponentIOR(aString)) 
+      return false;
 
-    CORBA::Object_var obj = _orb->string_to_object(IOREngine);
-    Engine = SALOMEDS::Driver::_narrow(obj) ;
+    CORBA::Object_var anObj = _orb->string_to_object(aString);
+    anEngine = SALOMEDS::Driver::_narrow(anObj) ;
   }
+
   // CAF document of current study usage
-  Handle(TDocStd_Document) aDocument = GetDocumentOfStudy(aStudy);
-  if (aDocument.IsNull()) return false;
+  Handle(TDocStd_Document) aDocument = aStudy->GetDocument();
+  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(Engine->ComponentDataType()));
+  if(!aStructureOnly){
+    aString = anEngine->ComponentDataType();
+    TDataStd_Comment::Set(aTargetDocument->Main().Root(),const_cast<char*>(aString.in()));
   }
   // set to the Root label integer attribute: study id
-  TDataStd_Integer::Set(aTargetDocument->Main().Root(), aStudy->StudyId());
+  TDataStd_Integer::Set(aTargetDocument->Main().Root(),aStudy->StudyId());
+
   // iterate all theObject's label children
   TDF_Label aStartLabel;
-  char* aStartID = CORBA::string_dup(theObject->GetID());
-  TDF_Tool::Label(aDocument->GetData(), aStartID, aStartLabel);
-  delete(aStartID);
+  aString = theObject->GetID();
+  TDF_Tool::Label(aDocument->GetData(),const_cast<char*>(aString.in()),aStartLabel);
   Standard_Integer aSourceStartDepth = aStartLabel.Depth();
   
   // copy main source label
-  CopyLabel(aStudy, Engine, aSourceStartDepth, aStartLabel, aTargetDocument->Main());
+  CopyLabel(aStudy,anEngine,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());
+  TDF_ChildIterator anIterator(aStartLabel,Standard_True);
+  for(; anIterator.More(); anIterator.Next()){
+    CopyLabel(aStudy,anEngine,aSourceStartDepth,anIterator.Value(),aTargetDocument->Main());
   }
+
   // done: free old clipboard document and 
   if (!_clipboard.IsNull()) {
 //      Handle(TDocStd_Owner) anOwner;
@@ -1204,6 +1150,7 @@ CORBA::Boolean SALOMEDS_StudyManager_i::Copy(SALOMEDS::SObject_ptr theObject) {
 //      }
     _OCAFApp->Close(_clipboard);
   }
+
   _clipboard = aTargetDocument;
 
   return true;
@@ -1223,22 +1170,26 @@ CORBA::Boolean SALOMEDS_StudyManager_i::CanPaste(SALOMEDS::SObject_ptr theObject
     return false;
 
   SALOMEDS::SComponent_var aComponent = theObject->GetFatherComponent();
-  if (aComponent->_is_nil()) return false;
+  if(aComponent->_is_nil()) 
+    return false;
   
   CORBA::String_var IOREngine;
-  if (!aComponent->ComponentIOR(IOREngine)) return false;
+  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(TCollection_AsciiString(aCompName->Get()).ToCString(), anObjID->Get());
+  if (CORBA::is_nil(Engine)) 
+    return false;
+
+  return Engine->CanPaste(TCollection_AsciiString(aCompName->Get()).ToCString(),anObjID->Get());
 }
 //============================================================================
 /*! Function : PasteLabel
  *  Purpose  :
  */
 //============================================================================
-TDF_Label SALOMEDS_StudyManager_i::PasteLabel(const SALOMEDS::Study_ptr theDestinationStudy,
+TDF_Label SALOMEDS_StudyManager_i::PasteLabel(SALOMEDS_Study_i* theDestinationStudy,
                                              const SALOMEDS::Driver_ptr theEngine,
                                              const TDF_Label& theSource,
                                              const TDF_Label& theDestinationStart,
@@ -1266,9 +1217,8 @@ TDF_Label SALOMEDS_StudyManager_i::PasteLabel(const SALOMEDS::Study_ptr theDesti
     aAuxSourceLabel.FindAttribute(TDataStd_Integer::GetID(), anObjID);
     Handle(TDataStd_Comment) aComponentName;
     theSource.Root().FindAttribute(TDataStd_Comment::GetID(), aComponentName);
-    CORBA::String_var aCompName = CORBA::string_dup(TCollection_AsciiString(aComponentName->Get()).ToCString());
-
-    if (theEngine->CanPaste(aCompName, anObjID->Get())) {
+    std::string aCompName = TCollection_AsciiString(aComponentName->Get()).ToCString();
+    if (theEngine->CanPaste(aCompName.c_str(),anObjID->Get())) {
       SALOMEDS::TMPFile_var aTMPFil = new SALOMEDS::TMPFile();
       TCollection_ExtendedString aTMPStr = aNameAttribute->Get();
       int aLen = aTMPStr.Length();
@@ -1276,20 +1226,17 @@ TDF_Label SALOMEDS_StudyManager_i::PasteLabel(const SALOMEDS::Study_ptr theDesti
       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(anEntry.ToCString());
-      if (isFirstElement) {
+      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);
+      }else 
+       theEngine->PasteInto(aTMPFil.in(),anObjID->Get(),aPastedSO);
     }
   }
 
@@ -1310,23 +1257,21 @@ TDF_Label SALOMEDS_StudyManager_i::PasteLabel(const SALOMEDS::Study_ptr theDesti
   // 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() + 1];
-    strcpy(anEntry, TCollection_AsciiString(aCommentAttribute->Get()).ToCString());
-    char* aNameStart = strchr(anEntry, ' ');
-    if (aNameStart) {
-      *aNameStart = '\0';
-      aNameStart++;
-    }
+    std::string anEntry(TCollection_AsciiString(aCommentAttribute->Get()).ToCString());
+    std::size_t aNameStart = anEntry.find(' ');
     if (theCopiedStudyID == theDestinationStudy->StudyId()) { // if copy to the same study, reanimate reference
       TDF_Label aRefLabel;
-      TDF_Tool::Label(aTargetLabel.Data(), anEntry, aRefLabel);
+      TDF_Tool::Label(aTargetLabel.Data(),const_cast<char*>(anEntry.c_str()),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);
+      if(aNameStart != std::string::npos)
+       TDataStd_Name::Set(aTargetLabel, &anEntry[aNameStart+1]);
+      else
+       TDataStd_Name::Set(aTargetLabel, 
+                          TCollection_ExtendedString("Reference to:") +
+                          const_cast<char*>(anEntry.c_str()));
     }
-    delete [] anEntry;
   }
 
   return aTargetLabel;
@@ -1340,7 +1285,13 @@ SALOMEDS::SObject_ptr SALOMEDS_StudyManager_i::Paste(SALOMEDS::SObject_ptr theOb
      throw(SALOMEDS::StudyBuilder::LockProtection)
 {
   Unexpect aCatch(LockProtection);
-  SALOMEDS::Study_var aStudy = theObject->GetStudy();
+
+  PortableServer::ServantBase_var aServant = GetServant(theObject,_poa);
+  SALOMEDS_SObject_i* aSObject = dynamic_cast<SALOMEDS_SObject_i*>(aServant.in());
+  if(aSObject == NULL) 
+    return false;
+
+  SALOMEDS_Study_i* aStudy = aSObject->GetStudyServant();
 
   // if study is locked, then paste can't be done
   if (aStudy->GetProperties()->IsLocked())
@@ -1354,42 +1305,45 @@ SALOMEDS::SObject_ptr SALOMEDS_StudyManager_i::Paste(SALOMEDS::SObject_ptr theOb
   Handle(TDataStd_Integer) aStudyIDAttribute;
   if (!_clipboard->Main().Root().FindAttribute(TDataStd_Integer::GetID(), aStudyIDAttribute))
     return SALOMEDS::SObject::_nil();
-  int aCStudyID = aStudyIDAttribute->Get();
 
   // get component-engine
-  SALOMEDS::Driver_var Engine;
   SALOMEDS::SComponent_var aComponent;
+  SALOMEDS::Driver_var anEngine;
+  CORBA::String_var aString;
   if (!aStructureOnly) {
     aComponent = theObject->GetFatherComponent();
-    CORBA::String_var IOREngine;
-    if (!aComponent->ComponentIOR(IOREngine)) return SALOMEDS::SObject::_nil();
-    CORBA::Object_var obj = _orb->string_to_object(IOREngine);
-    Engine = SALOMEDS::Driver::_narrow(obj) ;
+    if(!aComponent->ComponentIOR(aString)) 
+      return SALOMEDS::SObject::_nil();
+
+    CORBA::Object_var anObj = _orb->string_to_object(aString);
+    anEngine = SALOMEDS::Driver::_narrow(anObj) ;
   }
 
   // CAF document of current study usage
-  Handle(TDocStd_Document) aDocument = GetDocumentOfStudy(aStudy);
-  if (aDocument.IsNull()) return SALOMEDS::SObject::_nil();
+  Handle(TDocStd_Document) aDocument = aStudy->GetDocument();
+  if (aDocument.IsNull()) 
+    return SALOMEDS::SObject::_nil();
+
   // fill root inserted SObject
   TDF_Label aStartLabel;
+  int aCStudyID = aStudyIDAttribute->Get();
   if (aStructureOnly) {
     TDF_Label anObjectLabel;
-    TDF_Tool::Label(aDocument->GetData(), theObject->GetID(), anObjectLabel);
-    aStartLabel = PasteLabel(aStudy, Engine, _clipboard->Main(), anObjectLabel, aCStudyID, false);
+    TDF_Tool::Label(aDocument->GetData(),theObject->GetID(),anObjectLabel);
+    aStartLabel = PasteLabel(aStudy,anEngine,_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);
+    TDF_Tool::Label(aDocument->GetData(),aComponent->GetID(),aComponentLabel);
+    aStartLabel = PasteLabel(aStudy,anEngine,_clipboard->Main(),aComponentLabel,aCStudyID,true);
   }
 
   // paste all sublebels
-  TDF_ChildIterator anIterator(_clipboard->Main(), Standard_True);
+  TDF_ChildIterator anIterator(_clipboard->Main(),Standard_True);
   for(; anIterator.More(); anIterator.Next()) {
-    PasteLabel(aStudy, Engine, anIterator.Value(), aStartLabel, aCStudyID, false);
+    PasteLabel(aStudy,anEngine,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()); 
+  SALOMEDS_SObject_i* aSObjectServant = SALOMEDS_SObject_i::New(aStudy,aStartLabel);
 
-  return so._retn();
+  return aSObjectServant->_this();
 }
index 2c45ce203061f643c6d8b06ee17aeaaa0ce0c57e..7b11df5ef50a226b62f88858c04b485411fb05bc 100644 (file)
 
 // std C++ headers
 #include <iostream.h>
+#include <stdlib.h>
 
 // IDL headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS)
 
 // Cascade headers
-#include "SALOMEDS_OCAFApplication.hxx"
 #include <TDocStd_Document.hxx>
 #include <TDF_Attribute.hxx>
 #include <TDataStd_Name.hxx>
 #include <TDF_Label.hxx>
 #include <TDocStd_Document.hxx>
+#include <Standard_NotImplemented.hxx>
 
-// Naming Service header
+#include "SALOMEDS_OCAFApplication.hxx"
 #include "SALOME_NamingService.hxx"
 
 // HDF
-#include <iostream.h>
 #include "HDFOI.hxx"
-#include <stdlib.h>
 
-//Standard not implemented
-#include <Standard_NotImplemented.hxx>
+class SALOMEDS_Study_i;
 
+namespace SALOMEDS{
 
-class SALOMEDS_StudyManager_i: public POA_SALOMEDS::StudyManager,
-                              public PortableServer::RefCountServantBase {
-private:
+  // To convert IOR from SALOMEDS_IORAttribute to CORBA::Object
+  CORBA::Object_var 
+  GetObject(const TDF_Label&, CORBA::ORB_ptr);
+  
+  // To convert CORBA::Object to  PortableServer::ServantBase
+  PortableServer::ServantBase_var 
+  GetServant(CORBA::Object_ptr, PortableServer::POA_ptr);
+  
+}
 
-  CORBA::ORB_ptr _orb;
+
+class SALOMEDS_StudyManager_i: 
+  public virtual POA_SALOMEDS::StudyManager,
+  public virtual PortableServer::RefCountServantBase 
+{
+  SALOMEDS_StudyManager_i(); // Not implemented
+  void operator=(const SALOMEDS_StudyManager_i&); // Not implemented
+
+private:
+  CORBA::ORB_var _orb;
+  PortableServer::POA_var _poa;
+  SALOME_NamingService _name_service;
   Handle (SALOMEDS_OCAFApplication) _OCAFApp;  
-  SALOME_NamingService* _name_service;
-  int _IDcounter;
   Handle(TDocStd_Document) _clipboard;
+  int _IDcounter;
 
   // _SaveAs private function called by Save and SaveAs
   virtual void _SaveAs(const char* aUrl,
@@ -76,18 +91,21 @@ private:
                           SALOMEDS::SObject_ptr SC, 
                           HDFgroup *hdf_group_datatype);
   // _SubstituteSlash function called by Open and GetStudyByName
-  virtual const char *_SubstituteSlash(const char *aUrl);
+  virtual std::string _SubstituteSlash(const char *aUrl);
 
   virtual void _SaveProperties(SALOMEDS::Study_ptr aStudy, HDFgroup *hdf_group);
 
 public:
-
   //! standard constructor
-  SALOMEDS_StudyManager_i(CORBA::ORB_ptr orb);
+  SALOMEDS_StudyManager_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA);
 
   //! standard destructor
   virtual  ~SALOMEDS_StudyManager_i(); 
 
+  CORBA::ORB_var GetORB() const { return _orb; }
+
+  PortableServer::POA_var GetPOA() const { return _poa; }
+
  //! method to Register study Manager in the naming service
   /*!
     \param char* arguments, the context to register the study manager in the NS
@@ -151,16 +169,13 @@ public:
   */ 
   virtual SALOMEDS::Study_ptr GetStudyByID(CORBA::Short aStudyID) ;
 
-
-  Handle(TDocStd_Document) GetDocumentOfStudy(SALOMEDS::Study_ptr theStudy);
-  
-  void CopyLabel(const SALOMEDS::Study_ptr theSourceStudy, 
+  void CopyLabel(SALOMEDS_Study_i* 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,
+  TDF_Label PasteLabel(SALOMEDS_Study_i* theDestinationStudy,
                       const SALOMEDS::Driver_ptr theEngine,
                       const TDF_Label& theSource,
                       const TDF_Label& theDestinationStart,
index 4b7287aadea8475e0f051201decb257842af3a0f..e8161cc02f6132906ddaad8f5a3236f211f0c07d 100644 (file)
 //  Module : SALOME
 //  $Header$
 
-#include "utilities.h"
-#include "SALOMEDS_Study_i.hxx"
-
-#include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx"
-#include <TColStd_SequenceOfExtendedString.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
 #include <TDataStd_ChildNodeIterator.hxx>
 #include <TDocStd_Application.hxx>
 #include <TDocStd_Owner.hxx>
 #include <CDM_Document.hxx>
 #include <CDM_Application.hxx>
 #include <TDF_ChildIDIterator.hxx>
-#include <SALOME_GenericObj_i.hh>
+
+#include <TColStd_SequenceOfExtendedString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+
+#include "SALOMEDS_Study_i.hxx"
+
+#include "SALOMEDS_StudyManager_i.hxx"
+#include "SALOMEDS_Callback_i.hxx"
+#include "SALOMEDS_SObject_i.hxx"
+
+#include "SALOMEDS_StudyBuilder_i.hxx"
+#include "SALOMEDS_ChildIterator_i.hxx"
+
+#include "SALOMEDS_UseCaseBuilder_i.hxx"
+#include "SALOMEDS_SComponentIterator_i.hxx"
+
+#include "SALOME_GenericObj_i.hh"
 #include "SALOMEDS_LocalIDAttribute.hxx"
 #include "SALOMEDS_PersRefAttribute.hxx"
-#include "SALOMEDS_UseCaseIterator_i.hxx"
-using namespace std;
 
+#include "SALOMEDS_StudyPropertiesAttribute.hxx"
+#include "SALOMEDS_DataMapIteratorOfDataMapStringLabel.hxx"
+
+#include "utilities.h"
 
 #define DIRECTORYID 16661
 #define FILEID "FILE: "
 #define FILELOCALID 26662 
 
+using namespace std;
+
+
+bool operator<(const TDF_Label& theLeft, const TDF_Label& theRight)
+{
+  TColStd_ListOfInteger aTagLeftList;
+  TDF_Tool::TagList(theLeft,aTagLeftList);
+  TColStd_ListIteratorOfListOfInteger anLeftIter(aTagLeftList);
+
+  TColStd_ListOfInteger aTagRightList;
+  TDF_Tool::TagList(theRight,aTagRightList);
+  TColStd_ListIteratorOfListOfInteger anRightIter(aTagRightList);
+
+  for(;;){
+    Standard_Boolean aLeftMore = anLeftIter.More();
+    Standard_Boolean aRightMore = anRightIter.More();
+    
+    if(!aLeftMore && !aRightMore)
+      return Standard_False;
+
+    if(!aLeftMore)
+      return Standard_True;
+
+    if(!aRightMore)
+      return Standard_False;
+
+    Standard_Integer aLeftTag = anLeftIter.Value();
+    anLeftIter.Next();
+
+    Standard_Integer aRightTag = anRightIter.Value();
+    anRightIter.Next();
+
+    if(aLeftTag == aRightTag)
+      continue;
+
+    return aLeftTag < aRightTag;
+  }
+
+  return Standard_False;
+}
+
+
 //============================================================================
 /*! 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)
+SALOMEDS_Study_i::SALOMEDS_Study_i(SALOMEDS_StudyManager_i* theStudyManager,
+                                  const Handle(TDocStd_Document)& theDoc,
+                                  const char* theStudyName):
+  _StudyManager(theStudyManager),
+  _doc(theDoc),
+  _isSaved(false),
+  _URL(NULL),
+  _StudyId(-1),
+  _autoFill(true),
+  myNbUndos(0)
 {
-  _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;
+  _UseCaseBuilder = new SALOMEDS_UseCaseBuilder_i(this,_doc);
+  SALOMEDS::UseCaseBuilder_var aUseCaseBuilder = _UseCaseBuilder->_this();
+
+  _Builder = new SALOMEDS_StudyBuilder_i(this,_doc);
+  SALOMEDS::StudyBuilder_var aStudyBuilder = _Builder->_this(); 
+
+  SALOMEDS_Callback_i* aCallBackServant = new SALOMEDS_Callback_i(aUseCaseBuilder);
+  _callbackOnAdd = aCallBackServant->_this();
+  _callbackOnRemove = _callbackOnAdd;
+
+  _name = new char[strlen(theStudyName) +1];
+  strcpy(_name,theStudyName);
   myNbPostponed.Append(0);
-  myNbUndos = 0;
 }
   
 //============================================================================
@@ -82,6 +149,83 @@ SALOMEDS_Study_i::~SALOMEDS_Study_i()
   delete [] _URL ;
 }  
 
+//============================================================================
+CORBA::ORB_var SALOMEDS_Study_i::GetORB() const
+{
+  return _StudyManager->GetORB();
+}
+
+//============================================================================
+PortableServer::POA_var SALOMEDS_Study_i::GetPOA() const
+{
+  return _StudyManager->GetPOA();
+}
+
+//============================================================================
+/*! Function : SetOnAddSObject
+ *  Purpose  : 
+ */
+//============================================================================
+SALOMEDS::Callback_ptr SALOMEDS_Study_i::SetOnAddSObject(SALOMEDS::Callback_ptr theCallback)
+{
+  SALOMEDS::Callback_var aRet = _callbackOnAdd;
+  _callbackOnAdd = SALOMEDS::Callback::_duplicate(theCallback);
+  return aRet._retn();
+}
+
+//============================================================================
+/*! Function : SetOnNewSObject
+ *  Purpose  : 
+ */
+//============================================================================
+SALOMEDS::Callback_ptr SALOMEDS_Study_i::SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback)
+{
+  SALOMEDS::Callback_var aRet = _callbackOnRemove;
+  _callbackOnAdd = SALOMEDS::Callback::_duplicate(theCallback);
+  return aRet._retn();
+}
+
+//============================================================================
+void SALOMEDS_Study_i::OnAddSObject(SALOMEDS::SObject_ptr theObject)
+{
+  if(!CORBA::is_nil(_callbackOnAdd.in()))
+    _callbackOnAdd->OnAddSObject(theObject);
+}
+
+//============================================================================
+void SALOMEDS_Study_i::OnRemoveSObject(SALOMEDS::SObject_ptr theObject)
+{
+  if(!CORBA::is_nil(_callbackOnRemove.in()))
+    _callbackOnRemove->OnRemoveSObject(theObject);
+}
+
+//============================================================================
+void SALOMEDS_Study_i::CheckLocked()
+{
+  if(_doc->HasOpenCommand()) 
+    return;
+
+  Handle(SALOMEDS_StudyPropertiesAttribute) anAttr;
+  if(_doc->Main().FindAttribute(SALOMEDS_StudyPropertiesAttribute::GetID(),anAttr))
+    if(anAttr->IsLocked())
+      throw SALOMEDS::StudyBuilder::LockProtection();
+}
+
+
+//============================================================================
+char* SALOMEDS_Study_i::ConvertObjectToIOR(CORBA::Object_ptr theObject)
+{
+  return GetORB()->object_to_string(theObject); 
+}
+
+
+//============================================================================
+CORBA::Object_ptr SALOMEDS_Study_i::ConvertIORToObject(const char* theIOR) 
+{ 
+  return GetORB()->string_to_object(theIOR); 
+}
+
+
 //============================================================================
 /*! Function : GetPersistentReference
  *  Purpose  : Get persistent reference of study (idem URL())
@@ -138,7 +282,6 @@ SALOMEDS::SComponent_ptr SALOMEDS_Study_i::FindComponent (const char* aComponent
   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); 
@@ -228,10 +371,10 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectID(const char* anObjectID)
   TDF_Label Lab;
   TDF_Tool::Label(_doc->GetData(), (char*)anObjectID, Lab);
   
-  if (Lab.IsNull()) return SALOMEDS::SObject::_nil();
-  SALOMEDS_SObject_i *  so_servant = new SALOMEDS_SObject_i (Lab,_orb);
-  SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); 
-  return so;
+  if (Lab.IsNull()) 
+    return SALOMEDS::SObject::_nil();
+
+  return SALOMEDS_SObject_i::New(this,Lab)->_this();
 
 }
 
@@ -246,11 +389,10 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::CreateObjectID(const char* anObjectID)
   TDF_Label Lab;
   TDF_Tool::Label(_doc->GetData(), (char*)anObjectID, Lab, Standard_True);
   
-  if (Lab.IsNull()) return SALOMEDS::SObject::_nil();
-  SALOMEDS_SObject_i *  so_servant = new SALOMEDS_SObject_i (Lab,_orb);
-  SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); 
-  return so;
+  if (Lab.IsNull()) 
+    return SALOMEDS::SObject::_nil();
 
+  return SALOMEDS_SObject_i::New(this,Lab)->_this();
 }
 
 //============================================================================
@@ -274,7 +416,6 @@ SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char*
   // 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();
@@ -297,7 +438,7 @@ SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char*
       }
       
       /* looks also for eventual children */
-      bool found = false ;
+      bool found;
       addSO = _FindObject( CSO, anObjectName, found ) ;
       if( found) {
        length++ ;
@@ -316,17 +457,18 @@ SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindObjectByName( const char*
  *  Purpose  : Find an Object with IOR = anObjectIOR
  */
 //============================================================================
-SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
+SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* theObjectIOR)
 {
   // 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);
+  char* anIOR = const_cast<char*>(theObjectIOR);
+  if (myIORLabels.IsBound(anIOR)) {
+    SALOMEDS_SObject_i* aResult = SALOMEDS_SObject_i::New(this,myIORLabels.Find(anIOR));
     // 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();
+      myIORLabels.UnBind(anIOR);
+    } else 
+      return aResult->_this();
   }
   // Iterate to all components defined in the study
   // After testing the component name, iterate in all objects defined under
@@ -336,23 +478,20 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectIOR(const char* anObjectIOR)
 
   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){
+      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 aVal = IOR->Value();
+       if (strcmp(aVal,theObjectIOR) == 0){
+         _find = true;
+         RefSO = SALOMEDS::SObject::_narrow(SC);
        }
-       if (!_find) 
-         RefSO =  _FindObjectIOR(SC,anObjectIOR, _find);
       }
+      if (!_find) 
+       RefSO =  _FindObjectIOR(SC,theObjectIOR,_find);
+    }
   }
   if (!RefSO->_is_nil()) MESSAGE("SALOMEDS_Study_i::FindObjectIOR: found label with old methods");
 
@@ -372,9 +511,7 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
   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();
+    return SALOMEDS_SObject_i::New(this,_current)->_this();
   }
 
   if(aPath.Value(1) != '/')  //Relative path 
@@ -390,9 +527,7 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
   }
   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();
+      return SALOMEDS_SObject_i::New (this,_doc->Main())->_this();
     }
     anIterator.Initialize(_doc->Main(), Standard_False);
   }
@@ -408,9 +543,7 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
        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();
+           return SALOMEDS_SObject_i::New(this,aLabel)->_this();
          }
 
          anIterator.Initialize(aLabel, Standard_False);
@@ -433,18 +566,22 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::FindObjectByPath(const char* thePath)
 char* SALOMEDS_Study_i::GetObjectPath(CORBA::Object_ptr theObject)
 {
   TCollection_AsciiString aPath("");
-  if(CORBA::is_nil(theObject)) return CORBA::string_dup(aPath.ToCString());
+  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());
+    CORBA::String_var anIOR = GetORB()->object_to_string(theObject);
+    anObject = FindObjectIOR(anIOR);
+    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());
+    if(anAttr->_is_nil()) 
+      return CORBA::string_dup(aPath.ToCString());
     TCollection_AsciiString aValue(aName->Value());
     aValue.Prepend("/");
     aValue += aPath;
@@ -474,7 +611,7 @@ 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;
+  bool isInvalid = false;
   SALOMEDS::SObject_var aSO;
   
   if(aPath.Value(1) != '/') { //Relative path 
@@ -509,10 +646,11 @@ void SALOMEDS_Study_i::SetContext(const char* thePath)
 //============================================================================
 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());
+  if(_current.IsNull()) 
+    throw SALOMEDS::Study::StudyInvalidContext();   
+  SALOMEDS_SObject_i* aServant = SALOMEDS_SObject_i::New(this,_current);
+  SALOMEDS::SObject_var aSObject = aServant->_this(); 
+  return GetObjectPath(aSObject);
 }
 
 //============================================================================
@@ -670,10 +808,8 @@ SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject
   TDF_Tool::Label(_doc->GetData(), 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;
+  SALOMEDS_ChildIterator_i* aServant = new SALOMEDS_ChildIterator_i(this,Lab);
+  return aServant->_this();
 }
 
 
@@ -684,11 +820,19 @@ SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject
 //============================================================================
 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;
+  SALOMEDS_SComponentIterator_i* aServant = new SALOMEDS_SComponentIterator_i(this,_doc);
+  return aServant->_this();
 }
 
+//============================================================================
+/*! Function : GetUseCaseBuilder
+ *  Purpose  : Returns a UseCase builder
+ */
+//============================================================================
+SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder() 
+{
+  return _UseCaseBuilder->_this();
+}
 
 //============================================================================
 /*! Function : NewBuilder
@@ -697,19 +841,7 @@ SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
 //============================================================================
 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;
-
+  return _Builder->_this();
 }
  
 //============================================================================
@@ -814,10 +946,10 @@ SALOMEDS::SObject_ptr SALOMEDS_Study_i::_FindObject(SALOMEDS::SObject_ptr SO,
                                                    const char* anObjectName, 
                                                    bool& _find)
 {
+  _find = false;
   // 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()){
@@ -968,19 +1100,6 @@ SALOMEDS::ListOfDates* SALOMEDS_Study_i::GetModificationsDate() {
 
 
 
-//============================================================================
-/*! 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  : 
@@ -990,6 +1109,7 @@ void SALOMEDS_Study_i::Close()
 {
   SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
 
+  const CORBA::ORB_var& anORB = GetORB();
   for (; itcomponent->More(); itcomponent->Next()) {
     SALOMEDS::SComponent_var sco = itcomponent->Value();
          
@@ -999,7 +1119,7 @@ void SALOMEDS_Study_i::Close()
     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);
+      CORBA::Object_var obj = anORB->string_to_object(IOREngine);
       if (!CORBA::is_nil(obj)) {
        SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ;
        
@@ -1027,11 +1147,11 @@ void SALOMEDS_Study_i::Close()
 void SALOMEDS_Study_i::AddPostponed(const char* theIOR) {
   if (!NewBuilder()->HasOpenCommand()) return;
   try {
-    CORBA::Object_var obj = _orb->string_to_object(theIOR);
+    CORBA::Object_var obj = GetORB()->string_to_object(theIOR);
     if (!CORBA::is_nil(obj)) {
       SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ;
       if (!CORBA::is_nil(aGeneric)) {
-       TCollection_AsciiString anIOR((char*)theIOR);
+       TCollection_AsciiString anIOR(const_cast<char*>(theIOR));
        anIOR.Prepend("d");
        myPostponedIORs.Append(anIOR); // add prefix: deleted
        myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1);
@@ -1043,11 +1163,11 @@ void SALOMEDS_Study_i::AddPostponed(const char* theIOR) {
 void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR) {
   if (!NewBuilder()->HasOpenCommand()) return;
   try {
-    CORBA::Object_var obj = _orb->string_to_object(theIOR);
+    CORBA::Object_var obj = GetORB()->string_to_object(theIOR);
     if (!CORBA::is_nil(obj)) {
       SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj) ;
       if (!CORBA::is_nil(aGeneric)) {
-       TCollection_AsciiString anIOR((char*)theIOR);
+       TCollection_AsciiString anIOR(const_cast<char*>(theIOR));
        anIOR.Prepend("c");
        myPostponedIORs.Append(anIOR); // add prefix: created
        myNbPostponed.SetValue(myNbPostponed.Length(), myNbPostponed.Last() + 1);
@@ -1068,6 +1188,7 @@ void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit) {
   int aUndoLimit = theUndoLimit;
   if (theUndoLimit < 0) aUndoLimit = 0;
 
+  const CORBA::ORB_var& anORB = GetORB();
   if (myNbUndos > 0) { // remove undone
     anOld = 0;
     for(anIndex = 1; anIndex < myNbPostponed.Length() - myNbUndos; anIndex++)
@@ -1077,7 +1198,7 @@ void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit) {
     for(anIndex = anOld + 1; anIndex <= aNew; anIndex++) {
       TCollection_AsciiString anIOR = myPostponedIORs(anIndex);
       if (anIOR.Value(1) == 'c') {
-       CORBA::Object_var obj = _orb->string_to_object(anIOR.Split(1).ToCString());
+       CORBA::Object_var obj = anORB->string_to_object(anIOR.Split(1).ToCString());
        SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
        if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
       }
@@ -1095,7 +1216,7 @@ void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit) {
     for(anIndex = 1; anIndex <= anOld; anIndex++) {
       TCollection_AsciiString anIOR = myPostponedIORs(anIndex);
       if (anIOR.Value(1) == 'd') {
-       CORBA::Object_var obj = _orb->string_to_object(anIOR.Split(1).ToCString());
+       CORBA::Object_var obj = anORB->string_to_object(anIOR.Split(1).ToCString());
        SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
        if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
       }
@@ -1110,7 +1231,7 @@ void SALOMEDS_Study_i::RemovePostponed(const CORBA::Long theUndoLimit) {
       Handle(SALOMEDS_IORAttribute) anAttr = Handle(SALOMEDS_IORAttribute)::DownCast(anIter.Value());
       CORBA::String_var anIOR = CORBA::string_dup(TCollection_AsciiString(anAttr->Get()).ToCString());
       try {
-       CORBA::Object_var obj = _orb->string_to_object(anIOR);
+       CORBA::Object_var obj = anORB->string_to_object(anIOR);
        SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj);
        if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy();
       } catch (...) {}
index ad314b4972af87cf784c6f35a49bfaed7f4beb96..f70e7107fb893c3795fa7dd09f14f20c6c6b0de3 100644 (file)
 #define __SALOMEDS_STUDY_I_H__
 
 // std C++ headers
-#include <iostream.h>
+#include <map>
+#include <string>
 
 // IDL headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS)
 
 // Cascade headers
-#include <TDocStd_Document.hxx>
 #include <TDF_Tool.hxx>
 #include <TDF_Data.hxx>
 #include <TDF_Label.hxx>
-#include <stdio.h>
+#include <TDocStd_Document.hxx>
 #include <TColStd_SequenceOfInteger.hxx>
 #include <TColStd_SequenceOfAsciiString.hxx>
 
 //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_IORAttribute.hxx"
 
-#include "SALOMEDS_Callback_i.hxx"
+class SALOMEDS_StudyManager_i;
+class SALOMEDS_UseCaseBuilder_i;
+class SALOMEDS_StudyBuilder_i;
+class SALOMEDS_SObject_i;
 
-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;
 
-  // data structures for postponed destroying of CORBA object functionality
-  TColStd_SequenceOfAsciiString myPostponedIORs; // ordered set of IORs
-  TColStd_SequenceOfInteger myNbPostponed; // number of IOR in the each transaction
-  int myNbUndos; // number of current Undos, made by user
+bool operator<(const TDF_Label& theLeft, const TDF_Label& theRight);
 
-  TDF_Label                _current;
-  bool                     _autoFill;  
 
+class SALOMEDS_Study_i: public virtual POA_SALOMEDS::Study,
+                       public virtual PortableServer::RefCountServantBase 
+{
 public:
+  typedef TDF_Label TSObjectID;
+  typedef SALOMEDS_SObject_i* TSObjectHolder;
+  typedef std::map<TSObjectID,TSObjectHolder> TSObjectMap;
 
-  //! standard constructor
-  SALOMEDS_Study_i(const Handle(TDocStd_Document), 
-                  CORBA::ORB_ptr, 
-                  const char* study_name);
+  SALOMEDS_Study_i(SALOMEDS_StudyManager_i* theStudyManager,
+                  const Handle(TDocStd_Document)& theDoc,
+                  const char* theStudyName);
   
-  //! standard destructor
   virtual ~SALOMEDS_Study_i(); 
   
+
+  SALOMEDS_StudyManager_i* GetStudyManager(){ return _StudyManager; }
+
+  Handle(TDocStd_Document) GetDocument(){ return _doc; }
+
+  TSObjectMap& GetSObjectMap(){ return mySObjectMap;}
+
+  CORBA::ORB_var GetORB() const;
+
+  PortableServer::POA_var GetPOA() const;
+  
+  SALOMEDS::Callback_ptr SetOnAddSObject(SALOMEDS::Callback_ptr theCallback);
+
+  SALOMEDS::Callback_ptr SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback);
+
+  void OnAddSObject(SALOMEDS::SObject_ptr theObject);
+
+  void OnRemoveSObject(SALOMEDS::SObject_ptr theObject);
+
+  void CheckLocked();
+
+
+  virtual char* ConvertObjectToIOR(CORBA::Object_ptr theObject);
+
+  virtual CORBA::Object_ptr ConvertIORToObject(const char* theIOR);
+
   //! method to Get persistent reference of study (idem URL())
   /*!
     \sa URL()
@@ -285,9 +292,6 @@ public:
 
   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();
@@ -303,5 +307,46 @@ public:
                                                         // if theUndoLimit==0, removes all
   virtual void UndoPostponed(const CORBA::Long theWay); // theWay = 1: resurrect objects,
                                                 // theWay = -1: get back to the list of postponed
+private:
+  friend class SALOMEDS_StudyBuilder_i;
+  friend class SALOMEDS_SObject_i;
+  SALOMEDS_StudyManager_i* _StudyManager;
+
+  TSObjectMap mySObjectMap;
+
+  SALOMEDS_UseCaseBuilder_i* _UseCaseBuilder;
+  SALOMEDS_StudyBuilder_i* _Builder;
+  SALOMEDS::Callback_var   _callbackOnAdd;
+  SALOMEDS::Callback_var   _callbackOnRemove;
+
+  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
+  CORBA::Short             _StudyId;
+
+  SALOMEDS_DataMapStringLabel myIORLabels;
+
+  // data structures for postponed destroying of CORBA object functionality
+  TColStd_SequenceOfAsciiString myPostponedIORs; // ordered set of IORs
+  TColStd_SequenceOfInteger myNbPostponed; // number of IOR in the each transaction
+  int myNbUndos; // number of current Undos, made by user
+
+  TDF_Label                _current;
+  bool                     _autoFill;  
+
+  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);
+
+  SALOMEDS_Study_i(); // Not implemented
+  void operator=(const SALOMEDS_Study_i&); // Not implemented
+
 };
+
+
 #endif
index e04481fdb942a9012b60cf87e1b8a31cd09e10e1..81454daa7d8ff39698eec8e1beb399bc70b30649 100644 (file)
@@ -9,11 +9,10 @@
 //  Module : SALOME
 
 #include "SALOMEDS_UseCaseBuilder_i.hxx"
-#include "SALOMEDS_AttributeComment_i.hxx"
+#include "SALOMEDS_Study_i.hxx"
 #include "SALOMEDS_SObject_i.hxx"
-#include "SALOMEDS_SComponent_i.hxx"
 #include "SALOMEDS_UseCaseIterator_i.hxx"
-#include "utilities.h"
+
 #include <TDF_Label.hxx>
 #include <TDF_Tool.hxx>
 #include <TDF_Data.hxx>
 #include <TDataStd_ChildNodeIterator.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TDF_ChildIterator.hxx>
-using namespace std;
+
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_Name.hxx>
+#include <Standard_GUID.hxx>
 
 #define USE_CASE_LABEL_TAG           2
 #define USE_CASE_GUID                "AA43BB12-D9CD-11d6-945D-0050DA506788"
 
+#include "utilities.h"
+
+using namespace std;
 
 //============================================================================
 /*! Function : constructor
  *  Purpose  :
  */
 //============================================================================
-SALOMEDS_UseCaseBuilder_i::SALOMEDS_UseCaseBuilder_i(const Handle(TDocStd_Document)& theDocument,
-                                                    CORBA::ORB_ptr orb)
-:_doc(theDocument)
+SALOMEDS_UseCaseBuilder_i::SALOMEDS_UseCaseBuilder_i(SALOMEDS_Study_i* theStudy,
+                                                    const Handle(TDocStd_Document)& theDocument):
+  _doc(theDocument),
+  _study(theStudy)
 {
-  _orb = CORBA::ORB::_duplicate(orb);
   if(_doc.IsNull()) return;
 
   TDF_Label aLabel = _doc->Main().Root().FindChild(USE_CASE_LABEL_TAG); //Iterate all use cases
@@ -68,6 +73,21 @@ SALOMEDS_UseCaseBuilder_i::~SALOMEDS_UseCaseBuilder_i()
 }
 
 
+//============================================================================
+CORBA::ORB_var SALOMEDS_UseCaseBuilder_i::GetORB() const
+{
+  return _study->GetORB();
+}
+
+
+//============================================================================
+PortableServer::POA_var SALOMEDS_UseCaseBuilder_i::GetPOA() const
+{
+  return _study->GetPOA();
+}
+
+
+//============================================================================
 //============================================================================
 /*! Function : Append
  *  Purpose  : 
@@ -272,7 +292,7 @@ CORBA::Boolean SALOMEDS_UseCaseBuilder_i::SetName(const char* theName) {
   if(_root.IsNull()) return 0;
 
   Handle(TDataStd_Name) aNameAttrib;
-  TCollection_ExtendedString aName((char*)theName);
+  TCollection_ExtendedString aName(const_cast<char*>(theName));
 
   if (!_root->FindAttribute(TDataStd_Name::GetID(), aNameAttrib))
     aNameAttrib = TDataStd_Name::Set(_root->Label(), aName);
@@ -299,9 +319,7 @@ SALOMEDS::SObject_ptr SALOMEDS_UseCaseBuilder_i::GetCurrentObject()
   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();
+  return SALOMEDS_SObject_i::New(_study,aCurrent)->_this();
 }
 
 //============================================================================
@@ -368,12 +386,9 @@ SALOMEDS::SObject_ptr SALOMEDS_UseCaseBuilder_i::AddUseCase(const char* theName)
   TDF_Label aChild = aLabel.FindChild(anInteger->Get());
   aNode = TDataStd_TreeNode::Set(aChild, aBasicGUID);
   aFatherNode->Append(aNode);
-  TDataStd_Name::Set(aChild, TCollection_ExtendedString((char*)theName));
+  TDataStd_Name::Set(aChild, TCollection_ExtendedString(const_cast<char*>(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();
+  return SALOMEDS_SObject_i::New(_study,aChild)->_this();
 }
 
 //============================================================================
@@ -392,8 +407,6 @@ SALOMEDS::UseCaseIterator_ptr SALOMEDS_UseCaseBuilder_i::GetUseCaseIterator(SALO
     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(); 
+  SALOMEDS_UseCaseIterator_i* aServant = new SALOMEDS_UseCaseIterator_i(_study,aLabel,USE_CASE_GUID,Standard_False);
+  return aServant->_this(); 
 }
index f245aa7264781017456110ded591e097b4171353..796c803794533ccb4ee77c0b28c951f97a7b915d 100644 (file)
@@ -11,9 +11,6 @@
 #ifndef __SALOMEDS_USECaseBuilder_I_H__
 #define __SALOMEDS_USECaseBuilder_I_H__
 
-// std C++ headers
-#include <iostream.h>
-
 // IDL headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS)
 // Cascade headers
 #include <TDataStd_TreeNode.hxx>
 #include <TDocStd_Document.hxx>
-#include <Standard_GUID.hxx>
-#include <stdio.h>
+
+class SALOMEDS_Study_i;
 
 class SALOMEDS_UseCaseBuilder_i: public POA_SALOMEDS::UseCaseBuilder,
-                               public PortableServer::RefCountServantBase {
-private:
+                                public PortableServer::RefCountServantBase 
+{
+  SALOMEDS_UseCaseBuilder_i(); // Not implemented
+  void operator=(const SALOMEDS_UseCaseBuilder_i&); // Not implemented
 
-  CORBA::ORB_ptr                _orb;
+private:
   Handle(TDataStd_TreeNode)     _root;
   Handle(TDocStd_Document)      _doc;
+  SALOMEDS_Study_i*             _study;
 
 public:
-
-  //! standard constructor  
-  SALOMEDS_UseCaseBuilder_i(const Handle(TDocStd_Document)& theDocument,
-                           CORBA::ORB_ptr);
+  SALOMEDS_UseCaseBuilder_i(SALOMEDS_Study_i* theStudy,
+                           const Handle(TDocStd_Document)& theDocument);
   
-  //! standard destructor
   ~SALOMEDS_UseCaseBuilder_i();
   
+  CORBA::ORB_var GetORB() const;
+  PortableServer::POA_var GetPOA() const;
+
   virtual CORBA::Boolean Append(SALOMEDS::SObject_ptr theObject);
 
   virtual CORBA::Boolean Remove(SALOMEDS::SObject_ptr theObject);
index 07f79bf75aff2dfed6b0e9d9141ae60b31208df2..f4c89cc96ebb6b593cd3152ce703f6740b492a15 100644 (file)
@@ -8,10 +8,10 @@
 //  Author : Yves FRICAUD
 //  Module : SALOME
 
+using namespace std;
 #include "SALOMEDS_UseCaseIterator_i.hxx"
 #include "SALOMEDS_SObject_i.hxx"
 #include "utilities.h"
-using namespace std;
 
 
 
@@ -20,14 +20,14 @@ using namespace std;
  *  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)
+SALOMEDS_UseCaseIterator_i::SALOMEDS_UseCaseIterator_i(SALOMEDS_Study_i* theStudy,
+                                                      const TDF_Label& theLabel, 
+                                                      const Standard_GUID& theGUID, 
+                                                      const Standard_Boolean theIsAllLevels):
+  _guid(theGUID), 
+  _levels(theIsAllLevels),
+  _study(theStudy)
 {
-  _orb = CORBA::ORB::_duplicate(orb);
-
   if(theLabel.FindAttribute(_guid, _node)) {
     _it.Initialize (_node, _levels);
   }
@@ -82,8 +82,6 @@ void SALOMEDS_UseCaseIterator_i::Next()
 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();
+  return SALOMEDS_SObject_i::New(_study,L)->_this();
 }
 
index f936a222fc3c32591ab9b8123b2d226423d55a1b..3e17772073ef39a4049bbeff405a9dc8405a3117 100644 (file)
 #ifndef __SALOMEDS_USECASEITERATOR_I_H__
 #define __SALOMEDS_USECASEITERATOR_I_H__
 
-// std C++ headers
-#include <iostream.h>
-
 // IDL headers
 #include <SALOMEconfig.h>
 #include CORBA_SERVER_HEADER(SALOMEDS)
 
-
-
 // Cascade headers
-#include <TDF_ChildIterator.hxx>
 #include <TDataStd_ChildNodeIterator.hxx>
 #include <TDataStd_TreeNode.hxx>
 #include <Standard_GUID.hxx>
-#include <stdio.h>
+
+class SALOMEDS_Study_i;
 
 class SALOMEDS_UseCaseIterator_i: public POA_SALOMEDS::UseCaseIterator,
-                               public PortableServer::RefCountServantBase {
+                                 public PortableServer::RefCountServantBase 
+{
+  SALOMEDS_UseCaseIterator_i(); // Not implemented
+  void operator=(const SALOMEDS_UseCaseIterator_i&); // Not implemented
+
 private:
   Standard_GUID                 _guid;
   Standard_Boolean              _levels;
-  CORBA::ORB_ptr                _orb;
   Handle(TDataStd_TreeNode)     _node;
   TDataStd_ChildNodeIterator    _it;
+  SALOMEDS_Study_i*             _study;
 
 public:
-
   //! standard constructor  
-  SALOMEDS_UseCaseIterator_i(const TDF_Label& theLabel, 
+  SALOMEDS_UseCaseIterator_i(SALOMEDS_Study_i* theStudy,
+                            const TDF_Label& theLabel, 
                             const Standard_GUID& theGUID, 
-                            const Standard_Boolean allLevels,
-                            CORBA::ORB_ptr);
+                            const Standard_Boolean theIsAllLevels);
   
   //! standard destructor
   ~SALOMEDS_UseCaseIterator_i();
@@ -52,4 +50,6 @@ public:
   virtual void Next();
   virtual SALOMEDS::SObject_ptr Value();
 };
+
+
 #endif
index 08990e6e5559658968c07892cc0ceea050e9097c..199381a547aec1c97baca02d3585a2f4ce0eb045 100644 (file)
@@ -34,7 +34,7 @@ static int MYPYDEBUG = 0;
 #endif
 
 
-static QMutex myMutex(false);
+static QMutex myMutex(true);
 
 
 PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState): 
@@ -248,11 +248,17 @@ int PyInterp_base::run(const char *command)
 {
   if(_atFirst){
     int ret = 0;
-    _atFirst = false;
     ret = simpleRun("from Help import *");
-    if (ret) return ret;
+    if (ret) { 
+      _atFirst = false;
+      return ret;
+    }
     ret = simpleRun("import salome");
-    if (ret) return ret;
+    if (ret) { 
+      _atFirst = false;
+      return ret;
+    }
+    _atFirst = false;
   }
   return simpleRun(command);
 }
@@ -260,7 +266,7 @@ int PyInterp_base::run(const char *command)
 
 int PyInterp_base::simpleRun(const char *command)
 {
-  if(strcmp(command,"") != 0){
+  if( !_atFirst && strcmp(command,"") != 0 ) {
     _history.push_back(command);
     _ith = _history.end();
   }
index 69bde6093a0dd6315c543f5fa8cf04c5af67f9e5..5fa319a2803321ef960b8d416aa81a6b1e6d52ab 100644 (file)
@@ -77,6 +77,7 @@
 #include "SALOME_Event.hxx"
 
 // QT Includes
+#include <qaccel.h>
 #include <qlabel.h>
 #include <qlayout.h>
 #include <qmessagebox.h>
@@ -97,7 +98,7 @@
 #include <qlineedit.h>
 #include <qdatetime.h>
 #include <qthread.h>
-
+#include <qtooltip.h>
 #include <qstringlist.h>
 
 #if QT_VERSION > 300
@@ -119,6 +120,18 @@ extern "C"
 # include <string.h>
 }
 
+enum { voPanLeft, 
+       voPanRight, 
+       voPanUp,
+       voPanDown, 
+       voZoomIn, 
+       voZoomOut, 
+       voZoomFit, 
+       voRotateLeft, 
+       voRotateRight, 
+       voRotateUp, 
+       voRotateDown };
+
 QAD_ResourceMgr* QAD_Desktop::resourceMgr = 0;
 QPalette*       QAD_Desktop::palette = 0;
 
@@ -292,6 +305,8 @@ myAboutToClose( false )
     QString iconfile = CORBA::string_dup(list_composants[ind].moduleicone) ;
     QString modulename = CORBA::string_dup(list_composants[ind].modulename) ;
     QString moduleusername = CORBA::string_dup(list_composants[ind].moduleusername) ;
+    QString moduleversion = CORBA::string_dup(list_composants[ind].moduleversion) ;
+    QString modulecomment = CORBA::string_dup(list_composants[ind].modulecomment) ;
 
     //    MESSAGE ( " MODULE = " << modulename )
     //    MESSAGE ( " MODULE icon = " << iconfile )
@@ -313,7 +328,10 @@ myAboutToClose( false )
        QToolButton * toolb = 
          new QToolButton( QIconSet( Icone ), moduleusername, QString::null, this, 
                           SLOT( onButtonActiveComponent () ),tbComponent );
+       QString ttip = QString("<b>") + moduleusername + QString("</b>");
+       if ( !moduleversion.isEmpty() ) ttip += QString("<br>Version:&nbsp;") + moduleversion;
        toolb->setToggleButton( true );
+       QToolTip::add(toolb, ttip, this->toolTipGroup(), modulecomment);
        myComponentButton.append(toolb);
       }
     else
@@ -1061,6 +1079,37 @@ void QAD_Desktop::createActions()
     QAD_ASSERT( connect( helpAboutAction, SIGNAL(activated()), this, SLOT( onHelpAbout() )));
     helpAboutAction->addTo( &myHelpPopup );
     myStdActions.insert(HelpAboutId, helpAboutAction );
+
+    /* additional key accelerators */
+    QAccel* accel = new QAccel( this );
+    // pan left
+    myAccelMap[ accel->insertItem( CTRL+Key_Left ) ]  = voPanLeft;
+    // pan right
+    myAccelMap[ accel->insertItem( CTRL+Key_Right ) ] = voPanRight;
+    // pan up
+    myAccelMap[ accel->insertItem( CTRL+Key_Up ) ]    = voPanUp;
+    // pan down
+    myAccelMap[ accel->insertItem( CTRL+Key_Down ) ]  = voPanDown;
+    // zoom in
+    myAccelMap[ accel->insertItem( CTRL+Key_Plus ) ]  = voZoomIn;
+    // zoom out
+    myAccelMap[ accel->insertItem( CTRL+Key_Minus ) ] = voZoomOut;
+    // zoom in
+    myAccelMap[ accel->insertItem( CTRL+Key_Equal ) ] = voZoomIn;
+    // fit all
+    myAccelMap[ accel->insertItem( CTRL+Key_Asterisk ) ] = voZoomFit;
+    // fit all
+    myAccelMap[ accel->insertItem( CTRL+SHIFT+Key_Asterisk ) ] = voZoomFit;
+    // rotate left
+    myAccelMap[ accel->insertItem( ALT+Key_Left ) ]   = voRotateLeft;
+    // rotate right
+    myAccelMap[ accel->insertItem( ALT+Key_Right ) ]  = voRotateRight;
+    // rotate up
+    myAccelMap[ accel->insertItem( ALT+Key_Up ) ]     = voRotateUp;
+    // rotate down
+    myAccelMap[ accel->insertItem( ALT+Key_Down ) ]   = voRotateDown;
+    // connect signal to slot
+    connect( accel, SIGNAL( activated(int) ), this, SLOT( onKeyAccel(int) ) );
   }
   updateActions();
 }
@@ -4057,6 +4106,52 @@ void QAD_Desktop::onViewPopupStatusText( int id )
   }
 }
 
+/* Processes additinal key accelerators, e.g. viewer incremental transfomrations */
+void QAD_Desktop::onKeyAccel( int id )
+{
+  if ( myAccelMap.find( id ) != myAccelMap.end() ) {
+    int cmd = myAccelMap[ id ];
+    if ( myActiveApp != 0 && myActiveApp->getActiveStudy() != 0 && myActiveApp->getActiveStudy()->getActiveStudyFrame() != 0 ) {
+      QAD_ViewFrame* vf = myActiveApp->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
+      switch ( cmd ) {
+      case voPanLeft:
+       vf->onPanLeft();
+       break;
+      case voPanRight:
+       vf->onPanRight();
+       break;
+      case voPanUp:
+       vf->onPanUp();
+       break;
+      case voPanDown:
+       vf->onPanDown();
+       break;
+      case voZoomIn:
+       vf->onZoomIn();
+       break;
+      case voZoomOut:
+       vf->onZoomOut();
+       break;
+      case voZoomFit:
+       vf->onViewFitAll();
+       break;
+      case voRotateLeft:
+       vf->onRotateLeft();
+       break;
+      case voRotateRight:
+       vf->onRotateRight();
+       break;
+      case voRotateUp:
+       vf->onRotateUp();
+       break;
+      case voRotateDown:
+       vf->onRotateDown();
+       break;
+      }
+    }
+  }
+}
+
 /*********************************************************************
 ** Class: AppSelectionDlg
 ** Descr: Dialog for the selection of the application when several
@@ -4155,4 +4250,3 @@ void Desktop_AppSelectionDlg::onAppSelected( int id )
 void Desktop_AppSelectionDlg::onHelp()
 {
 }
-
index 83bc083c972ceb6c8f30bb1c09f3831fae75a4d8..35c71416e8726c46d93ec3ed892c600cc6bb0473 100644 (file)
@@ -268,6 +268,7 @@ protected slots:
     void             onComboActiveComponent( const QString & , bool isLoadData);
     void              onCascade(); 
 
+    void              onKeyAccel( int id );
 /* NRI   void              onHelpWindowClosed(); */
 
 protected:
@@ -346,6 +347,7 @@ private:
     bool                                    _islibso;
 
     ComponentMap                            myComponents;
+    QMap<int, int>                          myAccelMap;
 };
 
 /********************************************************************
index 542df51cf581cfa7abe3446dbe864a832b33c039..a0479d94492917011876b13c5946d98c29b3ad26 100644 (file)
@@ -142,9 +142,41 @@ void QAD_DirListDlg::setPathList(const QStringList& list) {
 /*!
   Validates entered path, returns true if OK
 */
+#ifndef WNT
+#include <pwd.h>
+#endif
 bool QAD_DirListDlg::validate() {
   if (myEdited) {
     QString dirPath = myEdit->text().stripWhiteSpace();
+#ifndef WNT
+    if ( dirPath.startsWith( "~") ) {
+      dirPath = dirPath.remove(0,1);
+      QString user;
+      int slashPos = dirPath.find("/");
+      if ( slashPos >= 0 ) {
+       user = dirPath.left(slashPos);
+       dirPath = dirPath.mid(slashPos);
+      }
+      else {
+       user = dirPath;
+       dirPath = "";
+      }
+      if ( user.isEmpty() )
+       user = getenv( "USER" );
+
+      struct passwd* user_data = getpwnam( user.latin1() );
+      if ( user_data == NULL ) {
+       // unknown user or something another error
+       QAD_MessageBox::error1(this, 
+                              tr("ERR_ERROR"),
+                              tr("Unknown user %1").arg(user), 
+                              tr("BUT_OK"));
+       myEdit->setFocus();
+        return false;
+      }
+      dirPath = user_data->pw_dir + dirPath;
+    }
+#endif
     QDir dir(dirPath);
     QListBoxItem* found = 0;
     for (unsigned i = 0; i < myDirList->count()-1; i++) {
index 91cc38a5985680873e67a74f818ed4a372e0331b..8dbcba9f0d6b94e5fec3c78812ecb2fec4ca7f91 100644 (file)
@@ -496,6 +496,7 @@ void QAD_ObjectBrowser::onCreatePopup()
   QAD_Study*   myActiveStudy = Desktop->getActiveStudy();
   SALOME_Selection*      Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() );
 
+  bool canExpand = false;
   /* VSR : Creation of common POPUP menu for Object Browser/Use Case Browser */
   if ( Sel->IObjectCount() > 0 ) {
     QString theContext;
@@ -518,8 +519,7 @@ void QAD_ObjectBrowser::onCreatePopup()
                             SLOT( onEditAttribute() ) );
       }
 
-      bool canExpand = false;
-      for ( QListViewItemIterator it( getListView() ); it.current() && !canExpand; ++it )
+      for ( QListViewItemIterator it( currentPage() == myListView ? myListView : myUseCaseView ); it.current() && !canExpand; ++it )
        canExpand = canExpand || ( it.current()->isSelected() && hasCollapsed( it.current() ) );
 
       if ( canExpand ) {
@@ -545,16 +545,19 @@ void QAD_ObjectBrowser::onCreatePopup()
       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 )
+      if ( isRoot ) {
        myPopup->clear();
+       if ( canExpand ) {
+         myPopup->insertItem( tr( "EXPAND_ALL_CMD" ),
+                              this,
+                              SLOT( onExpandAll() ) );
+       }
+      }
       QPopupMenu *UseCasePopup = new QPopupMenu( myPopup );
       if ( isOne )
        UseCasePopup->insertItem( tr( "UC_NEW_ID" ), this, SLOT( onUseCasePopupMenu( int ) ), 0, UC_NEW_EMPTY_ID );
@@ -582,7 +585,7 @@ void QAD_ObjectBrowser::onCreatePopup()
 */
 void QAD_ObjectBrowser::onExpandAll()
 {
-  for ( QListViewItemIterator it( getListView() ); it.current(); ++it )
+  for ( QListViewItemIterator it( currentPage() == myListView ? myListView : myUseCaseView ); it.current(); ++it )
     if ( it.current()->isSelected() )
       expand( it.current() );  
 }
@@ -680,7 +683,8 @@ void QAD_ObjectBrowser::Update( SALOMEDS::SObject_ptr SO,
     SALOMEDS::SObject_var             CSO = it->Value();
     SALOMEDS::SObject_var             RefSO;
     QString                           ior = "";
-    QString                           CSOEntry = CORBA::string_dup( CSO->GetID() );
+    CORBA::String_var                 aString(CSO->GetID());
+    QString                           CSOEntry(aString.in());
     SALOMEDS::GenericAttribute_var    anAttr;
     SALOMEDS::AttributeName_var       aName;
     SALOMEDS::AttributeComment_var    aCmnt;
@@ -695,22 +699,23 @@ void QAD_ObjectBrowser::Update( SALOMEDS::SObject_ptr SO,
     SALOMEDS::AttributeTextHighlightColor_var  aTextHighlightColor;
 
     QAD_ObjectBrowserItem*            Item = 0;
-    QAD_ObjectBrowserItem*            subItem;
     QString                           valueString;
    
     if ( CSO->ReferencedObject(RefSO) && !RefSO->_is_nil() ) {
       
-      QString RefSOEntry = CORBA::string_dup( RefSO->GetID() );
+      aString = RefSO->GetID();
+      QString RefSOEntry(aString.in());
       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 = CORBA::string_dup( anIOR->Value() );
+         aString = anIOR->Value();
+          ior = aString.in();
         }
        valueString = getValueFromObject( RefSO );
-//      AddItem (Item, QString(" * ") + CORBA::string_dup( aName->Value() ), RefSOEntry, ior, 2, CSOEntry);
+       aString = aName->Value();
        Item = AddItem(theParentItem, 
-                      QString(" * ") + CORBA::string_dup( aName->Value() ), 
+                      QString(" * ") + aString.in(), 
                       RefSOEntry, 
                       ior, 
                       2, 
@@ -727,12 +732,14 @@ void QAD_ObjectBrowser::Update( SALOMEDS::SObject_ptr SO,
       // getting IOR
       if (CSO->FindAttribute(anAttr, "AttributeIOR"))  {
         anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-        ior = CORBA::string_dup( anIOR->Value() );
+       aString = anIOR->Value();
+       ior = aString.in();
       }
       // getting Name and adding new Item
       if (CSO->FindAttribute(anAttr, "AttributeName") ) {
         aName = SALOMEDS::AttributeName::_narrow(anAttr);
-        Item = AddItem(theParentItem, CORBA::string_dup( aName->Value() ), CSOEntry, ior, 0, "", valueString);
+       aString = aName->Value();
+        Item = AddItem(theParentItem, aString.in(), CSOEntry, ior, 0, "", valueString);
        myListViewMap[ CSOEntry ].append( Item );
       } 
       else {
@@ -826,9 +833,11 @@ void QAD_ObjectBrowser::Update()
   for (; itcomp->More(); itcomp->Next()) {
     QAD_ObjectBrowserItem*   Item     = 0;
     SALOMEDS::SComponent_var SC       = itcomp->Value();
-    QString                  dataType = CORBA::string_dup( SC->ComponentDataType() );
+    CORBA::String_var        aString  = SC->ComponentDataType();
+    QString                  dataType = aString.in();
     QString                  ior      = "";
-    QString                  SCEntry  = CORBA::string_dup( SC->GetID() );
+    aString = SC->GetID();
+    QString                  SCEntry  = aString.in();
 
     SALOMEDS::GenericAttribute_var    anAttr;
     SALOMEDS::AttributeName_var       aName;
@@ -845,7 +854,8 @@ void QAD_ObjectBrowser::Update()
 
     if (SC->FindAttribute(anAttr, "AttributeIOR")) {
       anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
-      ior = CORBA::string_dup( anIOR->Value() );
+      aString = anIOR->Value();
+      ior = aString.in();
     }
 
     bool caseIAPP = false;
@@ -856,7 +866,8 @@ void QAD_ObjectBrowser::Update()
       if ( ShowIAPP.compare("true") == 0 ) {
        if (SC->FindAttribute(anAttr, "AttributeName")) {
           aName = SALOMEDS::AttributeName::_narrow(anAttr);
-         Item = AddItem (myListView, CORBA::string_dup( aName->Value() ), SCEntry, ior, 1, "");
+         aString = aName->Value();
+         Item = AddItem (myListView, aString.in(), SCEntry.latin1(), ior, 1, "");
          myListViewMap[ SCEntry ].append( Item );
        } 
         else {
@@ -870,7 +881,8 @@ void QAD_ObjectBrowser::Update()
       caseIAPP = false;
       if (SC->FindAttribute(anAttr, "AttributeName")) {
         aName = SALOMEDS::AttributeName::_narrow(anAttr);
-       Item = AddItem (myListView, CORBA::string_dup( aName->Value() ), SCEntry, ior, 1, "");
+       aString = aName->Value();
+       Item = AddItem (myListView, aString.in(), SCEntry, ior, 1, "");
        myListViewMap[ SCEntry ].append( Item );
       } 
       else {
@@ -883,7 +895,6 @@ void QAD_ObjectBrowser::Update()
     }
     // add other attributes 
     if (Item) {
-      QAD_ObjectBrowserItem* subItem;
       // Selectable
       if ( SC->FindAttribute(anAttr, "AttributeSelectable") ) {
         aSelectable = SALOMEDS::AttributeSelectable::_narrow(anAttr);
@@ -985,7 +996,8 @@ void QAD_ObjectBrowser::UpdateUseCaseBrowser() {
   QAD_ObjectBrowserItem* root = ( QAD_ObjectBrowserItem* )myUseCaseView->firstChild();
   SALOMEDS::UseCaseBuilder_var  UCBuilder = myStudy->GetUseCaseBuilder();
   SALOMEDS::SObject_var SOCurrent = UCBuilder->GetCurrentObject();
-  QString UCName = CORBA::string_dup( UCBuilder->GetName() );
+  CORBA::String_var aString = UCBuilder->GetName();
+  QString UCName = aString.in();
   if ( UCName.isEmpty() )
     UCName = QString( tr( "Root" ) );
   // creating root item if is not yet created
@@ -1003,7 +1015,8 @@ void QAD_ObjectBrowser::UpdateUseCaseBrowser() {
   if ( !UCIter->_is_nil() ) {
     for ( ; UCIter->More(); UCIter->Next() ) {
       SALOMEDS::SObject_var UCObject = UCIter->Value();
-      QString UCEntry = CORBA::string_dup( UCObject->GetID() );
+      aString = UCObject->GetID();
+      QString UCEntry = aString.in();
       ucList[ UCEntry ] = UCObject;
     }
   }
@@ -1051,29 +1064,32 @@ void QAD_ObjectBrowser::UpdateUCItem( SALOMEDS::SObject_var UCObject, QAD_Object
   SALOMEDS::AttributeTextHighlightColor_var  aTextHighlightColor;
   QString                                    valueString;
   QString                                    ior = "";
-  QString                                    UCEntry = CORBA::string_dup( UCObject->GetID() );
+  CORBA::String_var                          aString = UCObject->GetID();
+  QString                                    UCEntry = aString.in();
 
   SALOMEDS::UseCaseBuilder_var               UCBuilder = myStudy->GetUseCaseBuilder();
   SALOMEDS::SObject_var                      SOCurrent = UCBuilder->GetCurrentObject();
+  bool                                       isUseCase = UCBuilder->IsUseCase( UCObject );
 
-  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 = CORBA::string_dup( RefSO->GetID() );
+    aString = RefSO->GetID();
+    QString RefSOEntry = aString.in();
     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 = CORBA::string_dup( anIOR->Value() );
+       aString = anIOR->Value();
+       ior = aString.in();
       }
       valueString = getValueFromObject( RefSO );
+      aString = aName->Value();
       if ( !UCSubItem ) {
        UCSubItem = AddItem( UCItem, 
-                            QString( " * " ) + CORBA::string_dup( aName->Value() ), 
+                            QString( " * " ) + aString.in(), 
                             RefSOEntry, 
                             ior, 
                             2, 
@@ -1082,7 +1098,7 @@ void QAD_ObjectBrowser::UpdateUCItem( SALOMEDS::SObject_var UCObject, QAD_Object
        myUseCaseMap[ RefSOEntry ].append( UCSubItem );
       }
       else {
-       UCSubItem->setName( QString( " * " ) + CORBA::string_dup( aName->Value() ) );
+       UCSubItem->setName( QString( " * " ) + aString.in() );
        UCSubItem->setEntry( RefSOEntry );
        UCSubItem->setIOR( ior );
        UCSubItem->setReference( UCEntry );
@@ -1097,17 +1113,19 @@ void QAD_ObjectBrowser::UpdateUCItem( SALOMEDS::SObject_var UCObject, QAD_Object
     // getting IOR
     if ( UCObject->FindAttribute( anAttr, "AttributeIOR" ) )  {
       anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr );
-      ior = CORBA::string_dup( anIOR->Value() );
+      aString = anIOR->Value();
+      ior = aString.in();
     }
     // getting Name and adding new Item
     if ( UCObject->FindAttribute( anAttr, "AttributeName" ) ) {
       aName = SALOMEDS::AttributeName::_narrow( anAttr );
+      aString = aName->Value();
       if ( !UCSubItem ) {
-       UCSubItem = AddItem( UCItem, CORBA::string_dup( aName->Value() ), UCEntry, ior, 0, "", valueString );
+       UCSubItem = AddItem( UCItem, aString.in(), UCEntry, ior, isUseCase ? 1 : 0, "", valueString );
        myUseCaseMap[ UCEntry ].append( UCSubItem );
       }
       else {
-       UCSubItem->setName( CORBA::string_dup( aName->Value() ) );
+       UCSubItem->setName( aString.in() );
        UCSubItem->setEntry( UCEntry );
        UCSubItem->setIOR( ior );
        UCSubItem->setReference( "" );
@@ -1172,7 +1190,8 @@ void QAD_ObjectBrowser::UpdateUCItem( SALOMEDS::SObject_var UCObject, QAD_Object
     if ( !UCIter->_is_nil() ) {
       for ( ; UCIter->More(); UCIter->Next() ) {
        SALOMEDS::SObject_var UCSubObject = UCIter->Value();
-       QString UCSubEntry = CORBA::string_dup( UCSubObject->GetID() );
+       aString = UCSubObject->GetID();
+       QString UCSubEntry = aString.in();
        ucList[ UCSubEntry ] = UCSubObject;
       }
     }
@@ -1436,20 +1455,17 @@ void QAD_ObjectBrowser::onSelectedItem()
          if ( !obj->_is_nil() ) {
            SALOMEDS::SComponent_var comp = obj->GetFatherComponent();
            if ( !comp->_is_nil() ) {
-             //Standard_CString datatype = comp->ComponentDataType();
-             const char* datatype = comp->ComponentDataType();
-             //              newIO = new SALOME_InteractiveObject( CORBA::string_dup(theEntry),
-             //                                                    datatype,
-             //                                                    CORBA::string_dup(theName) );
-             newIO = new SALOME_InteractiveObject( theEntry, datatype, theName );
-             newIO->setReference( CORBA::string_dup(theRef) );
+             CORBA::String_var datatype(comp->ComponentDataType());
+             newIO = new SALOME_InteractiveObject( theEntry.latin1(),
+                                                   datatype.in(),
+                                                   theName.latin1() );
+             newIO->setReference( theRef.latin1() );
             }
          } else {
-           //newIO = new SALOME_InteractiveObject( CORBA::string_dup(theEntry),
-           //                                            "",
-           //                                            CORBA::string_dup(theName) );
-           newIO = new SALOME_InteractiveObject( theEntry, "", theName );
-           newIO->setReference( CORBA::string_dup(theRef) );
+           newIO = new SALOME_InteractiveObject( theEntry.latin1(),
+                                                 "",
+                                                 theName.latin1() );
+           newIO->setReference( theRef.latin1() );
          }
           if (!newIO.IsNull()) {
            DeltaPos.Append( newIO );
@@ -1542,6 +1558,7 @@ QString QAD_ObjectBrowser::getValueFromObject( SALOMEDS::SObject_ptr SO )
   SALOMEDS::AttributeTableOfInteger_var aTableInt;
   SALOMEDS::AttributeTableOfReal_var    aTableReal;
   SALOMEDS::AttributeComment_var        aComment;
+  CORBA::String_var aString;
 
   // Integer
   if ( SO->FindAttribute( anAttr, "AttributeInteger" ) ) {
@@ -1558,7 +1575,8 @@ QString QAD_ObjectBrowser::getValueFromObject( SALOMEDS::SObject_ptr SO )
   // Table of integer
   if ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ) {
     aTableInt = SALOMEDS::AttributeTableOfInteger::_narrow( anAttr );
-    QString tlt = QString( aTableInt->GetTitle() );
+    aString = aTableInt->GetTitle();
+    QString tlt( aString.in() );
     if ( !tlt.isEmpty() )
       tlt += " ";
     int nbRows  = aTableInt->GetNbRows() ; 
@@ -1569,7 +1587,8 @@ QString QAD_ObjectBrowser::getValueFromObject( SALOMEDS::SObject_ptr SO )
   // Table of real
   if ( SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) {
     aTableReal = SALOMEDS::AttributeTableOfReal::_narrow( anAttr );
-    QString tlt = QString( aTableReal->GetTitle() );
+    aString = aTableReal->GetTitle();
+    QString tlt( aString.in() );
     if ( !tlt.isEmpty() )
       tlt += " ";
     int nbRows  = aTableReal->GetNbRows() ; 
@@ -1580,7 +1599,8 @@ QString QAD_ObjectBrowser::getValueFromObject( SALOMEDS::SObject_ptr SO )
   // Comment
   if ( SO->FindAttribute(anAttr, "AttributeComment") ) {
     aComment = SALOMEDS::AttributeComment::_narrow( anAttr );
-    QString val = QString( aComment->Value() );
+    aString = aComment->Value();
+    QString val = QString( aString.in() );
     return val;
   }
   return QString::null;
@@ -1823,6 +1843,7 @@ void QAD_ObjectBrowser::onUseCasePopupMenu( int action )
   SALOME_Selection* Sel    = SALOME_Selection::Selection( myActiveStudy->getSelection() );
   SALOMEDS::UseCaseBuilder_var UCBuilder = myStudy->GetUseCaseBuilder();
   SALOMEDS::SObject_var Current = UCBuilder->GetCurrentObject();
+  CORBA::String_var aString;
 
   QList<QListViewItem> ucSelected; 
   ucSelected.setAutoDelete( false );
@@ -1852,15 +1873,16 @@ void QAD_ObjectBrowser::onUseCasePopupMenu( int action )
   if ( action == UC_RENAME_ID ) {
     if ( ucSelected.count() == 1 ) {
       QAD_ObjectBrowserItem* useCaseItem = ( QAD_ObjectBrowserItem* )( ucSelected.at( 0 ) );
+      aString = UCBuilder->GetName();
       if ( isRootItem( useCaseItem ) ) {
-       QString name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), UCBuilder->GetName() );
+       QString name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aString.in() );
        if ( !name.isEmpty() ) {
-         bool ok = UCBuilder->SetName( name.latin1() );
+         UCBuilder->SetName( name.latin1() );
          myActiveStudy->updateUseCaseBrowser( );
        }
       }
       else/* if ( UCBuilder->IsUseCase( myStudy->FindObjectID( (( QAD_ObjectBrowserItem* )( ucSelected.at(0) ))->getEntry() ) ) )*/ {
-       QString name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), CORBA::string_dup( useCaseItem->getName() ) );
+       QString name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aString.in() );
        if ( !name.isEmpty() ) {
          myActiveStudy->renameIObject( Sel->firstIObject(), name );
        }
index f5258e1a05a9b6bf35d6b397129e6f8aaf0fd31b..bfd4ec997fb5a1df366b9195e1ca724b22a68afb 100644 (file)
@@ -38,6 +38,7 @@
 #include <qmap.h>
 #include <qclipboard.h>
 #include <qthread.h>
+#include <qdragobject.h>
 
 // NRI : Temporary added
 // IDL Headers
@@ -57,12 +58,12 @@ static int MYDEBUG = 0;
 #endif
 
 
-#define SIZEPR 4
 enum { IdCopy, IdPaste, IdClear, IdSelectAll };
 
 
-static QString PROMPT = ">>> ";
-
+static QString READY_PROMPT = ">>> ";
+static QString DOTS_PROMPT  = "... ";
+#define PROMPT_SIZE _currentPrompt.length()
 
 class TInitEditorThread : public QThread
 {
@@ -135,7 +136,7 @@ protected:
       if(MYDEBUG) MESSAGE("TExecCommand::run() - myInterp = "<<myInterp<<"; myCommand = '"<<myCommand.latin1()<<"' - "<<ret);
       if(ret < 0)
        anId = QAD_PyEditor::PYTHON_ERROR;
-      if(ret > 0)
+      else if(ret > 0)
        anId = QAD_PyEditor::PYTHON_INCOMPLETE;
       myListener->myError = myInterp->getverr().c_str();
       myListener->myOutput = myInterp->getvout().c_str();
@@ -182,7 +183,7 @@ QAD_PyEditor::QAD_PyEditor(QAD_PyInterp*& theInterp, QMutex* theMutex,
   myInitEditorThread = new TInitEditorThread(myInterp,myStudyMutex,myInitEditorMutex,this);
   myExecCommandThread = new TExecCommandThread(myInterp,myStudyMutex,myExecCommandMutex,this);
 
-  _currentPrompt = PROMPT;
+  _currentPrompt = READY_PROMPT;
   setPalette( QAD_Application::getPalette(true) );
   setWordWrap(NoWrap);
 
@@ -235,7 +236,6 @@ void QAD_PyEditor::setText(QString s)
 */
 void QAD_PyEditor::handleReturn()
 {
-  int ret;
   int para=paragraphs()-2;
 
   // NRI : Temporary added
@@ -248,24 +248,78 @@ void QAD_PyEditor::handleReturn()
                            QObject::tr("WRN_STUDY_LOCKED"),
                            QObject::tr("BUT_OK") );
 
-    _currentPrompt = ">>> ";
+    _currentPrompt = READY_PROMPT;
     setText(_currentPrompt);
     
     return;
   }  
   // NRI
 
-  _buf.append(text(para).remove(0,SIZEPR));
+  _buf.append(text(para).remove(0,PROMPT_SIZE));
   _buf.truncate( _buf.length() - 1 );
   setReadOnly( true );
   viewport()->setCursor( waitCursor );
   myExecCommandThread->exec(_buf.latin1());
 }
 
+/*
+   Processes drop event: paste dragged text
+*/
+void QAD_PyEditor::contentsDropEvent( QDropEvent* event )
+{
+  event->acceptAction();
+  QString text;
+  if ( QTextDrag::decode( event, text ) ) {
+    int par, col;
+    int endLine = paragraphs() -1;
+    col = charAt( event->pos(), &par );
+    
+    if ( col >= 0 && par >= 0 ) {
+      if ( par != endLine || col < PROMPT_SIZE ) {
+       par = endLine;
+       col = paragraphLength( endLine );
+      }
+      setCursorPosition( par, col );
+      insertAt( text, par, col );
+      removeSelection();
+    }
+  }
+}
+
+/*
+   Processes middle button release event - paste clipboard's contents
+*/
+void QAD_PyEditor::contentsMouseReleaseEvent( QMouseEvent* event )
+{
+  if ( event->button() == LeftButton ) {
+    QTextEdit::contentsMouseReleaseEvent(event);
+    copy();
+  }
+  if ( event->button() == MidButton ) {
+    if (QApplication::clipboard()->supportsSelection()) {
+      int par, col;
+      int endLine = paragraphs() -1;
+      col = charAt( event->pos(), &par );
+      if ( col >= 0 && par >= 0 ) {
+       if ( par != endLine || col < PROMPT_SIZE )
+         setCursorPosition( endLine, paragraphLength( endLine ) );
+       else
+         setCursorPosition( par, col );
+       QApplication::clipboard()->setSelectionMode(TRUE);
+       paste();
+       QApplication::clipboard()->setSelectionMode(FALSE);
+      }
+    }
+  }
+  else {
+    QTextEdit::contentsMouseReleaseEvent(event);
+  }
+}
+
 /*
    Processes own popup menu
 */
-void QAD_PyEditor::mousePressEvent (QMouseEvent * event)
+void QAD_PyEditor::mousePressEvent (QMouseEvent* event)
 {
   if ( event->button() == RightButton ) {
     QPopupMenu *popup = new QPopupMenu( this );
@@ -303,225 +357,372 @@ void QAD_PyEditor::mousePressEvent (QMouseEvent * event)
     else if ( r == idMap[ IdClear ] ) {
       clear();
       setText(myBanner);
+      _currentPrompt = READY_PROMPT;
       setText(_currentPrompt);
     }
     else if ( r == idMap[ IdSelectAll ] ) {
       selectAll();
     }
-    return;
   }
   else {
     QTextEdit::mousePressEvent(event);
   }
 }
 
-/*!
-    Called when a Mouse release event
-*/
-void QAD_PyEditor::mouseReleaseEvent ( QMouseEvent * e )
-{
-  //  MESSAGE("mouseReleaseEvent");
-  int curPara, curCol; // for cursor position
-  int endPara, endCol; // for last edited line
-  getCursorPosition(&curPara, &curCol);
-  endPara = paragraphs() -1;
-  if (e->button() != MidButton)
-    QTextEdit::mouseReleaseEvent(e);
-  else if ((curPara == endPara) && (curCol >= SIZEPR))
-    QTextEdit::mouseReleaseEvent(e);
-}
-
-/*!
-    Called when a drop event (Drag & Drop)
-*/
-  void QAD_PyEditor::dropEvent (QDropEvent *e)
-{
-  MESSAGE("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;
+  // prompt may be '>>> ' or for '... '
+  return ( str.find( READY_PROMPT ) == 0 || str.find( DOTS_PROMPT ) == 0 );
 }
 
 
 /*!
     Called when a keyPress event
 */
-void QAD_PyEditor::keyPressEvent( QKeyEvent *e )
+void QAD_PyEditor::keyPressEvent( QKeyEvente )
 {
-  int curLine, curCol; // for cursor position
-  int endLine, endCol; // for last edited line
+  // get cursor position
+  int curLine, curCol;
   getCursorPosition(&curLine, &curCol);
-  endLine = paragraphs() -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)
+
+  // get last edited line
+  int endLine = paragraphs() -1;
+
+  // get pressed key code
+  int aKey = e->key();
+
+  // check if <Ctrl> is pressed
+  bool ctrlPressed = e->state() & ControlButton;
+  // check if <Shift> is pressed
+  bool shftPressed = e->state() & ShiftButton;
+  // check if <Alt> is pressed
+  bool altPressed = e->state() & AltButton;
+
+  // process <Ctrl>+<C> key-bindings
+  if ( aKey == Key_C && ctrlPressed ) {
+    _buf.truncate(0);
+    setText("\n");
+    _currentPrompt = READY_PROMPT;
+    setText(_currentPrompt);
+    return;
+  }
+
+  // check for printed key
+  aKey = ( aKey < Key_Space || aKey > Key_ydiaeresis ) ? aKey : 0;
+
+  switch ( aKey ) {
+  case 0 :
+    // any printed key
     {
-    case 0 :
-      {
-       if (curLine <endLine || curCol < SIZEPR )
-         moveCursor(QTextEdit::MoveEnd, false);
-       QTextEdit::keyPressEvent( e );
-       break;
+      if ( curLine < endLine || curCol < PROMPT_SIZE )
+       moveCursor( QTextEdit::MoveEnd, false );
+      QTextEdit::keyPressEvent( e );
+      break;
+    }
+  case Key_Return:
+  case Key_Enter:
+    // <Enter> key
+    {
+      moveCursor( QTextEdit::MoveEnd, false );
+      QTextEdit::keyPressEvent( e );
+      break;
+    }
+  case Key_Up:
+    // <Up> arrow key: process as follows:
+    // - without <Ctrl>, <Shift> modifiers: previous command in history
+    // - with <Ctrl> modifier key pressed:  move cursor one row up without selection
+    // - with <Shift> modifier key pressed: move cursor one row up with selection
+    // - with <Ctrl>+<Shift> modifier keys pressed: scroll one row up
+    {
+      if ( ctrlPressed && shftPressed ) {
+       scrollBy( 0, -QFontMetrics( font() ).lineSpacing() );
       }
-    case Key_Return:
-    case Key_Enter:
-      {
-       if (curLine <endLine)
-         moveCursor(QTextEdit::MoveEnd, false);
-       else
-         moveCursor(QTextEdit::MoveLineEnd, false);
-       QTextEdit::keyPressEvent( e );
-       break;
+      else if ( shftPressed ) {
+       if ( curLine > 0 )
+         moveCursor( QTextEdit::MoveUp, true );
+      }
+      else if ( ctrlPressed ) {
+       moveCursor( QTextEdit::MoveUp, false );
       }
-    case Key_Up:
-      {
-       // if Cntr+Key_Up event then move cursor up
-       if (ctrlPressed) {
-           moveCursor(QTextEdit::MoveUp, false);
-        }
-       // if Shift+Key_Up event then move cursor up and select the text
-       else if ( shftPressed && curLine > 0 ){
-           moveCursor(QTextEdit::MoveUp, true);
+      else { 
+       QString histLine = _currentPrompt;
+       if ( ! _isInHistory ) {
+         _isInHistory = true;
+         _currentCommand = text( endLine ).remove( 0, PROMPT_SIZE );
+         _currentCommand.truncate( _currentCommand.length() - 1 );
        }
-       // scroll the commands stack up
-       else { 
-          QString histLine = _currentPrompt;
-         if (! _isInHistory)
-           {
-             _isInHistory = true;
-             _currentCommand = text(endLine).remove(0,SIZEPR);
-             _currentCommand.truncate( _currentCommand.length() - 1 );
-           }
-         QString previousCommand = myInterp->getPrevious();
-         if (previousCommand.compare(BEGIN_HISTORY_PY) != 0)
-           {
-             removeParagraph(endLine);
-             histLine.append(previousCommand);
-             insertParagraph(histLine, -1);
-           }
-         moveCursor(QTextEdit::MoveEnd, false);
+       QString previousCommand = myInterp->getPrevious();
+       if ( previousCommand.compare( BEGIN_HISTORY_PY ) != 0 ) {
+         removeParagraph( endLine );
+         histLine.append( previousCommand );
+         insertParagraph( histLine, -1 );
        }
-       break;
+       moveCursor( QTextEdit::MoveEnd, false );
+      }
+      break;
+    }
+  case Key_Down:
+    // <Down> arrow key: process as follows:
+    // - without <Ctrl>, <Shift> modifiers: next command in history
+    // - with <Ctrl> modifier key pressed:  move cursor one row down without selection
+    // - with <Shift> modifier key pressed: move cursor one row down with selection
+    // - with <Ctrl>+<Shift> modifier keys pressed: scroll one row down
+    {
+      if ( ctrlPressed && shftPressed ) {
+       scrollBy( 0, QFontMetrics( font() ).lineSpacing() );
+      }
+      else if ( shftPressed ) {
+       if ( curLine < endLine )
+         moveCursor( QTextEdit::MoveDown, true );
       }
-    case Key_Down:
-      {
-       // if Cntr+Key_Down event then move cursor down
-       if (ctrlPressed) {
-         moveCursor(QTextEdit::MoveDown, false);
+      else if ( ctrlPressed ) {
+       moveCursor( QTextEdit::MoveDown, false );
+      }
+      else { 
+       QString histLine = _currentPrompt;
+       QString nextCommand = myInterp->getNext();
+       if ( nextCommand.compare( TOP_HISTORY_PY ) != 0 ) {
+         removeParagraph( endLine );
+         histLine.append( nextCommand );
+         insertParagraph( histLine, -1 );
        }
-       // if Shift+Key_Down event then move cursor down and select the text
-       else if ( shftPressed && curLine < endLine ) {
-         moveCursor(QTextEdit::MoveDown, true);
+       else {
+         if (_isInHistory) {
+           _isInHistory = false;
+           removeParagraph( endLine );
+           histLine.append( _currentCommand );
+           insertParagraph( histLine, -1 );
+         }
+       }
+       moveCursor( QTextEdit::MoveEnd, false );
+      }
+      break;
+    }
+  case Key_Left:
+    // <Left> arrow key: process as follows:
+    // - without <Ctrl>, <Shift> modifiers: move one symbol left (taking into account prompt)
+    // - with <Ctrl> modifier key pressed:  move one word left (taking into account prompt)
+    // - with <Shift> modifier key pressed: move one symbol left with selection
+    // - with <Ctrl>+<Shift> modifier keys pressed: move one word left with selection
+    {
+      if ( !shftPressed && isCommand( text( curLine ) ) && curCol <= PROMPT_SIZE ) {
+       setCursorPosition( curLine-1, 0 );
+       moveCursor( QTextEdit::MoveLineEnd, false );
+      }
+      else {
+       QTextEdit::keyPressEvent( e );
+      }
+      break;
+    }
+  case Key_Right:
+    // <Right> arrow key: process as follows:
+    // - without <Ctrl>, <Shift> modifiers: move one symbol right (taking into account prompt)
+    // - with <Ctrl> modifier key pressed:  move one word right (taking into account prompt)
+    // - with <Shift> modifier key pressed: move one symbol right with selection
+    // - with <Ctrl>+<Shift> modifier keys pressed: move one word right with selection
+    {
+      if ( !shftPressed ) {
+       if ( curCol < paragraphLength( curLine ) ) {
+         if ( isCommand( text( curLine ) ) && curCol < PROMPT_SIZE ) {
+           setCursorPosition( curLine, PROMPT_SIZE );
+           break;
+         }
        }
-       // scroll the commands stack down
        else {
+         if ( curLine < endLine && isCommand( text( curLine+1 ) ) ) {
+           setCursorPosition( curLine+1, PROMPT_SIZE );
+           break;
+         }
+       }
+      }
+      QTextEdit::keyPressEvent( e );
+      break;
+    }
+  case Key_PageUp:
+    // <PageUp> key: process as follows:
+    // - without <Ctrl>, <Shift> modifiers: first command in history
+    // - with <Ctrl> modifier key pressed:  move cursor one page up without selection
+    // - with <Shift> modifier key pressed: move cursor one page up with selection
+    // - with <Ctrl>+<Shift> modifier keys pressed: scroll one page up
+    {
+      if ( ctrlPressed && shftPressed ) {
+       scrollBy( 0, -visibleHeight() );
+      }
+      else if ( shftPressed ) {
+       if ( curLine > 0 )
+         moveCursor( QTextEdit::MovePgUp, true );
+      }
+      else if ( ctrlPressed ) {
+       moveCursor( QTextEdit::MovePgUp, false );
+      }
+      else { 
        QString histLine = _currentPrompt;
-         QString nextCommand = myInterp->getNext();
-         if (nextCommand.compare(TOP_HISTORY_PY) != 0)
-           {
-             removeParagraph(endLine);
-             histLine.append(nextCommand);
-             insertParagraph(histLine, -1);
-           }
-         else
-           if (_isInHistory)
-             {
-               _isInHistory = false;
-               removeParagraph(endLine);
-               histLine.append(_currentCommand);
-               insertParagraph(histLine, -1);
-             }
-         moveCursor(QTextEdit::MoveEnd, false);
+       if ( ! _isInHistory ) {
+         _isInHistory = true;
+         _currentCommand = text( endLine ).remove( 0, PROMPT_SIZE );
+         _currentCommand.truncate( _currentCommand.length() - 1 );
+       }
+       QString firstCommand = myInterp->getPrevious();
+       QString pcmd;
+       while ( ( pcmd = QString( myInterp->getPrevious() ) ).compare( BEGIN_HISTORY_PY ) != 0 )
+         firstCommand = pcmd;
+       if ( firstCommand.compare( BEGIN_HISTORY_PY ) != 0 ) {
+         removeParagraph( endLine );
+         histLine.append( firstCommand );
+         insertParagraph( histLine, -1 );
        }
-       break;
+       moveCursor( QTextEdit::MoveEnd, false );
       }
-    case Key_Left:
-      {
-       if (!shftPressed && isCommand(text(curLine)) && curCol <= SIZEPR )
-         {
-           setCursorPosition((curLine -1), SIZEPR);
-           moveCursor(QTextEdit::MoveLineEnd, false);
-         }
-       else QTextEdit::keyPressEvent( e );
-       break;
+      break;
+    }
+  case Key_PageDown:
+    // <PageDown> key: process as follows:
+    // - without <Ctrl>, <Shift> modifiers: last command in history
+    // - with <Ctrl> modifier key pressed:  move cursor one page down without selection
+    // - with <Shift> modifier key pressed: move cursor one page down with selection
+    // - with <Ctrl>+<Shift> modifier keys pressed: scroll one page down
+    {
+      if ( ctrlPressed && shftPressed ) {
+       scrollBy( 0, visibleHeight() );
       }
-    case Key_Right:
-      {
-       if (!shftPressed && isCommand(text(curLine)) 
-           && curCol < SIZEPR) setCursorPosition(curLine, SIZEPR);
-       QTextEdit::keyPressEvent( e );
-       break;
+      else if ( shftPressed ) {
+       if ( curLine < endLine )
+         moveCursor( QTextEdit::MovePgDown, true );
+      }
+      else if ( ctrlPressed ) {
+       moveCursor( QTextEdit::MovePgDown, false );
       }
-    case Key_Home: 
-      {
-       horizontalScrollBar()->setValue( horizontalScrollBar()->minValue() );
-       if (isCommand(text(curLine))) {
-         setCursorPosition(curLine, SIZEPR);
-         if ( curCol > SIZEPR && shftPressed )
-           setSelection( curLine, SIZEPR, curLine, curCol );
-         else
-           selectAll( false );
+      else { 
+       if ( _isInHistory ) {
+         QString histLine = _currentPrompt;
+         while ( QString( myInterp->getNext() ).compare( TOP_HISTORY_PY ) != 0 );
+         _isInHistory = false;
+         removeParagraph( endLine );
+         histLine.append( _currentCommand );
+         insertParagraph( histLine, -1 );
        }
-       else moveCursor(QTextEdit::MoveLineStart, shftPressed);
-       break;
+       moveCursor( QTextEdit::MoveEnd, false );
       }
-    case Key_End:
-      {
-       moveCursor(QTextEdit::MoveLineEnd, shftPressed);
-       break;
-      }  
-    case Key_Backspace :
-      {
-       if ((curLine == endLine) && (curCol > SIZEPR))
-         QTextEdit::keyPressEvent( e );
-       break;
+      break;
+    }
+  case Key_Home: 
+    // <Home> key: process as follows:
+    // - without <Ctrl>, <Shift> modifiers: move cursor to the beginning of the current line without selection
+    // - with <Ctrl> modifier key pressed:  move cursor to the very first symbol without selection
+    // - with <Shift> modifier key pressed: move cursor to the beginning of the current line with selection
+    // - with <Ctrl>+<Shift> modifier keys pressed: move cursor to the very first symbol with selection
+    {
+      if ( ctrlPressed ) { 
+       moveCursor( QTextEdit::MoveHome, shftPressed );
+      }
+      else {
+       if ( isCommand( text( curLine ) ) ) {
+         int ps1, ps2, cs1, cs2;
+         bool hasSelection = hasSelectedText();
+         if ( hasSelection )
+           getSelection( &ps1, &cs1, &ps2, &cs2 );
+         removeSelection();
+         horizontalScrollBar()->setValue( horizontalScrollBar()->minValue() );
+         if ( curCol > PROMPT_SIZE && shftPressed ) 
+           setSelection( curLine, PROMPT_SIZE, curLine, ( hasSelection && ps1 == ps2 && ps1 == curLine && cs2 > PROMPT_SIZE ) ? cs2 : curCol );
+         setCursorPosition( curLine, PROMPT_SIZE );
+       }
+       else {
+         moveCursor( QTextEdit::MoveLineStart, shftPressed );
+       }
+      }
+      break;
+    }
+  case Key_End:
+    // <End> key: process as follows:
+    // - without <Ctrl>, <Shift> modifiers: move cursor to the end of the current line without selection
+    // - with <Ctrl> modifier key pressed:  move cursor to the very last symbol without selection
+    // - with <Shift> modifier key pressed: move cursor to the end of the current line with selection
+    // - with <Ctrl>+<Shift> modifier keys pressed: move cursor to the very last symbol with selection
+    {
+      if ( ctrlPressed ) { 
+       moveCursor( QTextEdit::MoveEnd, shftPressed );
       }
-    case Key_Delete :
-      {
-       if ((curLine == endLine) && (curCol > SIZEPR-1))
+      else {
+       moveCursor( QTextEdit::MoveLineEnd, shftPressed );
+      }
+      break;
+    }  
+  case Key_Backspace :
+    // <Backspace> key: process as follows
+    // - without any modifiers : delete symbol before the cursor / selection (taking into account prompt)
+    // - with <Ctrl> modifier key pressed: delete previous word
+    // works only for last (command) line
+    {
+      if ( curLine == endLine && ( curCol > PROMPT_SIZE || curCol >= PROMPT_SIZE && hasSelectedText() ) ) {
+       if ( ctrlPressed && !hasSelectedText() ) {
+         QString txt = text( curLine );
+         int ind = curCol-1;
+         while ( ind > 0 && txt[ ind ] == ' ' ) ind--;
+         ind = txt.findRev( ' ', ind ) + 1;
+         if ( ind > PROMPT_SIZE-1 ) {
+           setSelection( curLine, ind, curLine, curCol );
+           removeSelectedText();
+         }
+         else {
+           QTextEdit::keyPressEvent( e );
+         }
+       }
+       else {
          QTextEdit::keyPressEvent( e );
-       break;
+       }
       }
-    case Key_Insert :
-      {
-       if ( ctrlPressed )
-         copy();
-       else if ( shftPressed ) {
-         moveCursor(QTextEdit::MoveEnd, false);
-         paste();
+      break;
+    }
+  case Key_Delete :
+    // <Delete> key: process as follows
+    // - without any modifiers : delete symbol after the cursor / selection (taking into account prompt)
+    // - with <Ctrl> modifier key pressed: delete next word
+    // works only for last (command) line
+    {
+      if ( curLine == endLine && curCol > PROMPT_SIZE-1 ) {
+       if ( ctrlPressed && !hasSelectedText() ) {
+         QString txt = text( curLine );
+         int ind = curCol;
+         while ( ind < txt.length()-1 && txt[ ind ] == ' ' ) ind++;
+         ind = txt.find( ' ', ind );
+         while ( ind < txt.length()-1 && txt[ ind ] == ' ' ) ind++;
+         if ( ind > PROMPT_SIZE-1 ) {
+           setSelection( curLine, curCol, curLine, ind );
+           removeSelectedText();
+         }
+         else {
+           QTextEdit::keyPressEvent( e );
+         }
        }
-       else
+       else {
          QTextEdit::keyPressEvent( e );
-       break;
+       }
       }
+      break;
     }
-  if ( e->key() == Key_C && ( e->state() & ControlButton ) )
+  case Key_Insert :
+    // <Insert> key: process as follows
+    // - with <Ctrl> modifier key pressed:  copy()
+    // - with <Shift> modifier key pressed: paste() to the command line
     {
-      _buf.truncate(0);
-      setText("\n");
-      _currentPrompt = ">>> ";
-      setText(_currentPrompt);
+      if ( ctrlPressed ) {
+       copy();
+      }
+      else if ( shftPressed ) {
+       if ( curLine != endLine || curCol < PROMPT_SIZE )
+         moveCursor( QTextEdit::MoveEnd, false );
+       paste();
+      }
+      else
+       QTextEdit::keyPressEvent( e );
+      break;
     }
-
+  }
   // NRI : DEBUG PAS TERRIBLE //
   if (( e->key() == Key_F3) || 
       ( e->key() == Key_F4) ||
@@ -531,7 +732,7 @@ void QAD_PyEditor::keyPressEvent( QKeyEvent *e )
   // NRI //
 }
 
-void QAD_PyEditor::customEvent(QCustomEvent *e)
+void QAD_PyEditor::customEvent(QCustomEvente)
 {
   switch( e->type() ) {
   case PYTHON_OK:
@@ -540,14 +741,14 @@ void QAD_PyEditor::customEvent(QCustomEvent *e)
       _buf.truncate(0);
       setText(myOutput);
       setText(myError);
-      _currentPrompt = ">>> ";
+      _currentPrompt = READY_PROMPT;
       setText(_currentPrompt);
       break;
     }
   case PYTHON_INCOMPLETE:
     {
       _buf.append("\n");
-      _currentPrompt = "... ";
+      _currentPrompt = DOTS_PROMPT;
       setText(_currentPrompt);
       break;
     }
index fd7ff49554fd2e7da8a7263471c657f512a533b4..941a340df0d1028836e8be324358044ac69f7b11 100644 (file)
@@ -59,11 +59,11 @@ public:
   bool isCommand(const QString& str) const;
   
 protected:
-  virtual void keyPressEvent (QKeyEvent * e);
-  virtual void mousePressEvent (QMouseEvent * e);
-  virtual void mouseReleaseEvent (QMouseEvent * e);
-  virtual void dropEvent (QDropEvent *e);
-  virtual void customEvent (QCustomEvent *e);
+  virtual void contentsDropEvent( QDropEvent* event );
+  virtual void contentsMouseReleaseEvent( QMouseEvent* event );
+  virtual void keyPressEvent (QKeyEvent* event);
+  virtual void mousePressEvent (QMouseEvent* event);
+  virtual void customEvent (QCustomEvent* event);
   
 public slots:
   void handleReturn();
index cdc9961aee19d3ac330decc1020d5babb77cc4d2..7ea86fb5fa03f17337564136d8f9782aea7c0ebe 100644 (file)
@@ -94,7 +94,11 @@ public:
   virtual void           Activate( QAD_Study* ) {}
   // this method is called when parent window of view frame is activated
 
-protected slots:
+public slots:
+  /* basic view operations,
+     most of them are pure virtual
+     and should be redefined in derived classes
+  */
   virtual void           onViewPan() = 0; 
   virtual void           onViewZoom() = 0;
   virtual void           onViewFitAll() = 0;
@@ -111,6 +115,19 @@ protected slots:
   virtual void           onViewTrihedron() = 0; 
   virtual void           onViewDump();
 
+  /* view incremental transformation operations.
+     virtual, can be redefined in derived classes
+  */
+  virtual void           onPanLeft()     {}
+  virtual void           onPanRight()    {}
+  virtual void           onPanUp()       {}
+  virtual void           onPanDown()     {}
+  virtual void           onZoomIn()      {}
+  virtual void           onZoomOut()     {}
+  virtual void           onRotateLeft()  {}
+  virtual void           onRotateRight() {}
+  virtual void           onRotateUp()    {}
+  virtual void           onRotateDown()  {}
 };
 
 #endif
index a70b74df42e613d01c916114645fb32ce9666e36..1b24930b363a6c1f9c73fd0f63f8185c6e8b5831 100644 (file)
@@ -579,9 +579,10 @@ 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] );
+      myTable->horizontalHeader()->setLabel( i+1, tlts[i].isNull() ? "" : tlts[i] ) :
+      myTable->verticalHeader()->setLabel( i+1, tlts[i].isNull() ? "" : tlts[i] );
   }
+  setUnitsTitle( tr( "UNITS_TLT" ) );
 }
 /*!
   Sets columns titles
@@ -606,7 +607,7 @@ void SALOMEGUI_TableWidget::getColTitles( QStringList& tlts )
 */
 void SALOMEGUI_TableWidget::setUnitsTitle( const QString& tlt ) {
   // !!! first column contains units !!!
-  myOrientation == Horizontal ? myTable->horizontalHeader()->setLabel( 0, tlt ) : myTable->verticalHeader()->setLabel( 0, tlt );
+  myOrientation == Horizontal ? myTable->horizontalHeader()->setLabel( 0, tlt.isNull() ? "" : tlt ) : myTable->verticalHeader()->setLabel( 0, tlt.isNull() ? "" : tlt );
 }
 /*!
   Sets units
@@ -614,7 +615,7 @@ void SALOMEGUI_TableWidget::setUnitsTitle( const QString& tlt ) {
 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] );
+    myOrientation == Horizontal ? myTable->setText( i, 0, units[i].isNull() ? "" : units[i] ) : myTable->setText( 0, i, units[i].isNull() ? "" : units[i] );
   }
 }
 /*!
index 17a9718598616bf14d34ba49484d8af36baffc53..a1106986d74ded6e6e48d8e4d768f2afd384fa64 100644 (file)
@@ -90,6 +90,21 @@ static int MYDEBUG = 0;
 static int MYDEBUG = 0;
 #endif
 
+void MessageOutput( QtMsgType type, const char *msg )
+{
+  switch ( type ) {
+  case QtDebugMsg:
+    MESSAGE( "Debug: " << msg );
+    break;
+  case QtWarningMsg:
+    MESSAGE( "Warning: " << msg );
+    break;
+  case QtFatalMsg:
+    MESSAGE( "Fatal: " << msg );
+    break;
+  }
+}
+
 int main(int argc, char **argv)
 {
   SALOME_Event::GetSessionThread();
@@ -97,6 +112,7 @@ int main(int argc, char **argv)
   int orbArgc = 1;
   CORBA::ORB_var &orb = init( orbArgc , argv ) ;
   SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
+  qInstallMsgHandler( MessageOutput );
   try
     {
       CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
index 886aef9b903390e66d89c6e244e36a38a021ff15..a4fb054cc63898788ceb807d0c12fe67163b3d0d 100644 (file)
@@ -226,7 +226,7 @@ void Session_ServerThread::ActivateSALOMEDS(int argc,
       // longer needed.    
 
       SALOMEDS_StudyManager_i * myStudyManager_i
-       = new  SALOMEDS_StudyManager_i(_orb);
+       = new  SALOMEDS_StudyManager_i(_orb,_root_poa);
       
       // Activate the objects.  This tells the POA that the objects are
       // ready to accept requests.
index 81d646b6069826aa1d8cdc2ec0c08ec34cc6fc8b..e250257af13543478515d606348f082965e72b12 100644 (file)
@@ -93,11 +93,11 @@ std::string SALOMEDS_Tool::GetTmpDir()
 // function : RemoveTemporaryFiles
 // purpose  : Removes files listed in theFileList
 //============================================================================
-void SALOMEDS_Tool::RemoveTemporaryFiles(const char* theDirectory, 
+void SALOMEDS_Tool::RemoveTemporaryFiles(const std::string& theDirectory, 
                                         const SALOMEDS::ListOfFileNames& theFiles,
                                         const bool IsDirDeleted)
 {
-  TCollection_AsciiString aDirName(const_cast<char*>(theDirectory));
+  TCollection_AsciiString aDirName(const_cast<char*>(theDirectory.c_str()));
 
   int i, aLength = theFiles.length();
   for(i=0; i<aLength; i++) {
@@ -130,7 +130,7 @@ void SALOMEDS_Tool::RemoveTemporaryFiles(const char* theDirectory,
 // purpose  : converts the files from a list 'theFiles' to the stream
 //============================================================================
 SALOMEDS::TMPFile* 
-SALOMEDS_Tool::PutFilesToStream(const char* theFromDirectory,
+SALOMEDS_Tool::PutFilesToStream(const std::string& theFromDirectory,
                                const SALOMEDS::ListOfFileNames& theFiles,
                                const int theNamesOnly)
 {
@@ -139,7 +139,8 @@ SALOMEDS_Tool::PutFilesToStream(const char* theFromDirectory,
 //    return NULL;
     return (new SALOMEDS::TMPFile);
 
-  TCollection_AsciiString aTmpDir(const_cast<char*>(theFromDirectory)); //Get a temporary directory for saved a file
+  //Get a temporary directory for saved a file
+  TCollection_AsciiString aTmpDir(const_cast<char*>(theFromDirectory.c_str()));
 
   long aBufferSize = 0;
   long aCurrentPos;
@@ -242,11 +243,14 @@ SALOMEDS_Tool::PutFilesToStream(const char* theFromDirectory,
 //============================================================================
 SALOMEDS::ListOfFileNames_var 
 SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
-                               const char* theToDirectory,
+                               const std::string& theToDirectory,
                                const int theNamesOnly)
 {
-  if(theStream.length() == 0) return NULL;
-  TCollection_AsciiString aTmpDir(const_cast<char*>(theToDirectory)); //Get a temporary directory for saving a file
+  if(theStream.length() == 0) 
+    return NULL;
+
+  //Get a temporary directory for saving a file
+  TCollection_AsciiString aTmpDir(const_cast<char*>(theToDirectory.c_str()));
 
   unsigned char *aBuffer = (unsigned char*)theStream.NP_data();
 
@@ -294,9 +298,10 @@ SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
 // function : GetNameFromPath
 // purpose  : Returns the name by the path
 //============================================================================
-std::string SALOMEDS_Tool::GetNameFromPath(const char* thePath) {
-  if (thePath == NULL) return string("");
-  OSD_Path aPath = OSD_Path(TCollection_AsciiString((char*)thePath));
+std::string SALOMEDS_Tool::GetNameFromPath(const std::string& thePath) {
+  if(thePath == "") 
+    return "";
+  OSD_Path aPath = OSD_Path(TCollection_AsciiString(const_cast<char*>(thePath.c_str())));
   TCollection_AsciiString aNameString(aPath.Name());
   return aNameString.ToCString();
 }
@@ -305,9 +310,10 @@ std::string SALOMEDS_Tool::GetNameFromPath(const char* thePath) {
 // function : GetDirFromPath
 // purpose  : Returns the dir by the path
 //============================================================================
-std::string SALOMEDS_Tool::GetDirFromPath(const char* thePath) {
-  if (thePath == NULL) return string("");
-  OSD_Path aPath = OSD_Path(TCollection_AsciiString((char*)thePath));
+std::string SALOMEDS_Tool::GetDirFromPath(const std::string& thePath) {
+  if(thePath == "") 
+    return "";
+  OSD_Path aPath = OSD_Path(TCollection_AsciiString(const_cast<char*>(thePath.c_str())));
   TCollection_AsciiString aDirString(aPath.Trek());
   aDirString.ChangeAll('|','/');
   return aDirString.ToCString();
@@ -337,10 +343,10 @@ bool SALOMEDS_Tool::GetFlag( const int             theFlag,
 //=======================================================================
 bool SALOMEDS_Tool::SetFlag( const int           theFlag,
                              SALOMEDS::Study_var theStudy,
-                             const char*         theEntry,
+                             const std::string&  theEntry,
                              const bool          theValue )
 {
-  SALOMEDS::SObject_var anObj = theStudy->FindObjectID( theEntry );
+  SALOMEDS::SObject_var anObj = theStudy->FindObjectID(theEntry.c_str());
 
   if ( !anObj->_is_nil() )
   {
index ecc4df6bc53b9840a16f8e52b7eb22f28146cb78..e3d1d39930add8b3e25f9c14ff6fcf5b3523ba8c 100644 (file)
@@ -29,27 +29,27 @@ public:
  
   // Removes files which are in <theDirectory>, the files for deletion are listed in <theFiles>
   // if <IsDirDeleted> is true <theDirectory> is also deleted if it is empty
-  static void RemoveTemporaryFiles(const char* theDirectory,
+  static void RemoveTemporaryFiles(const std::string& theDirectory,
                                   const SALOMEDS::ListOfFileNames& theFiles,
                                   const bool IsDirDeleted);
 
   // Converts files listed in <theFiles> which are in <theFromDirectory> into a byte sequence TMPFile
-  static SALOMEDS::TMPFile* PutFilesToStream(const char* theFromDirectory, 
+  static SALOMEDS::TMPFile* PutFilesToStream(const std::string& theFromDirectory, 
                                             const SALOMEDS::ListOfFileNames& theFiles,
                                             const int theNamesOnly = 0);
 
   // Converts a byte sequence <theStream> to files and places them in <theToDirectory>
   static SALOMEDS::ListOfFileNames_var PutStreamToFiles(const SALOMEDS::TMPFile& theStream,
-                                                     const char* theToDirectory,
-                                                    const int theNamesOnly = 0);
+                                                       const std::string& 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 std::string GetNameFromPath(const char* thePath);
+  static std::string GetNameFromPath(const std::string& thePath);
 
   // Returns the directory by the path
   // for an example: if thePath = "/tmp/aaa/doc1.hdf" the function returns "/tmp/aaa"
-  static std::string GetDirFromPath(const char* thePath);
+  static std::string GetDirFromPath(const std::string& thePath);
 
   // Retrieves specified flaf from "AttributeFlags" attribute
   static bool GetFlag( const int             theFlag,
@@ -59,7 +59,7 @@ public:
   // Sets/Unsets specified flaf from "AttributeFlags" attribute
   static bool SetFlag( const int           theFlag,
                        SALOMEDS::Study_var theStudy,
-                       const char*         theEntry,
+                       const std::string&  theEntry,
                        const bool          theValue );
 
   // Get all children of object. If theObj is null all objects of study are returned
index 276a5bc6d747826e1f3c58eb7e7c583acb81ed39..0fd4d7c52d16fafdd40ca2e66fc4506077661f39 100644 (file)
@@ -1474,6 +1474,20 @@ Handle(VTKViewer_Filter) VTKViewer_InteractorStyleSALOME::GetFilter( const int t
   return IsFilterPresent( theId ) ? myFilters[ theId ] : Handle(VTKViewer_Filter)();
 }
 
+void VTKViewer_InteractorStyleSALOME::IncrementalPan( const int incrX, const int incrY )
+{
+  this->PanXY( incrX, incrY, 0, 0 );
+}
+
+void VTKViewer_InteractorStyleSALOME::IncrementalZoom( const int incr )
+{
+  this->DollyXY( incr, incr );
+}
+
+void VTKViewer_InteractorStyleSALOME::IncrementalRotate( const int incrX, const int incrY )
+{
+  this->RotateXY( incrX, -incrY );
+}
 
 
 
index 851aeafdfc6cddbd827b45ed205e68ea758349e9..2952537a3e737e14b101a74e51cd4acdc8841fa0 100644 (file)
@@ -93,6 +93,9 @@ class VTKViewer_InteractorStyleSALOME : public QObject, public vtkInteractorStyl
                                     const int     theId,
                                     const bool    theIsNode = false );
   
+  void                     IncrementalPan   ( const int incrX, const int incrY );
+  void                     IncrementalZoom  ( const int incr );
+  void                     IncrementalRotate( const int incrX, const int incrY );
 
  protected:
   VTKViewer_InteractorStyleSALOME();
index 1dc5b8db490bd521e1721652a1ca718896c9fb5b..067cc6aee5640bf9f8d1166ac8ef0e4af10de2f0 100644 (file)
@@ -841,6 +841,97 @@ void VTKViewer_ViewFrame::redisplayAll( QAD_Study* theQADStudy, const bool theTo
     Repaint();
 }
 
+#define INCREMENT_FOR_OP 10
+
+//=======================================================================
+// name    : onPanLeft
+// Purpose : Performs incremental panning to the left
+//=======================================================================
+void VTKViewer_ViewFrame::onPanLeft()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalPan( -INCREMENT_FOR_OP, 0 );
+}
+
+//=======================================================================
+// name    : onPanRight
+// Purpose : Performs incremental panning to the right
+//=======================================================================
+void VTKViewer_ViewFrame::onPanRight()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalPan( INCREMENT_FOR_OP, 0 );
+}
+
+//=======================================================================
+// name    : onPanUp
+// Purpose : Performs incremental panning to the top
+//=======================================================================
+void VTKViewer_ViewFrame::onPanUp()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalPan( 0, INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onPanDown
+// Purpose : Performs incremental panning to the bottom
+//=======================================================================
+void VTKViewer_ViewFrame::onPanDown()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalPan( 0, -INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onZoomIn
+// Purpose : Performs incremental zooming in
+//=======================================================================
+void VTKViewer_ViewFrame::onZoomIn()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalZoom( INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onZoomOut
+// Purpose : Performs incremental zooming out
+//=======================================================================
+void VTKViewer_ViewFrame::onZoomOut()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalZoom( -INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onRotateLeft
+// Purpose : Performs incremental rotating to the left
+//=======================================================================
+void VTKViewer_ViewFrame::onRotateLeft()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalRotate( -INCREMENT_FOR_OP, 0 );
+}
+
+//=======================================================================
+// name    : onRotateRight
+// Purpose : Performs incremental rotating to the right
+//=======================================================================
+void VTKViewer_ViewFrame::onRotateRight()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalRotate( INCREMENT_FOR_OP, 0 );
+}
+
+//=======================================================================
+// name    : onRotateUp
+// Purpose : Performs incremental rotating to the top
+//=======================================================================
+void VTKViewer_ViewFrame::onRotateUp()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalRotate( 0, -INCREMENT_FOR_OP );
+}
+
+//=======================================================================
+// name    : onRotateDown
+// Purpose : Performs incremental rotating to the bottom
+//=======================================================================
+void VTKViewer_ViewFrame::onRotateDown()
+{
+  m_RWInteractor->GetInteractorStyleSALOME()->IncrementalRotate( 0, INCREMENT_FOR_OP );
+}
 
 
 
index 6a8d79b25d316ea8b09768ebe5ba86fe1f814d04..cef0aaa5f324a05fc2666f790f2c5f349dcb5c72 100644 (file)
@@ -128,6 +128,17 @@ public slots:
   void                              onViewTrihedron(); 
   void                              onAdjustTrihedron();
  
+  void                              onPanLeft();
+  void                              onPanRight();
+  void                              onPanUp();
+  void                              onPanDown();
+  void                              onZoomIn();
+  void                              onZoomOut();
+  void                              onRotateLeft();
+  void                              onRotateRight();
+  void                              onRotateUp();
+  void                              onRotateDown();
+
 private:
   void                              InitialSetup();
   void                              redisplayAll( QAD_Study*, const bool = true );