@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 $@
#============================================================
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:
--- /dev/null
+#!/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)
*/
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)
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) {
// Get the PID of the Container
-CORBA::Long Engines_Container_i::getPID() {
+long Engines_Container_i::getPID() {
return (long)getpid();
}
// File : HDFexception.hxx
// Module : SALOME
+#ifndef __HDFexception_H__
+#define __HDFexception_H__
+
/* Exception */
#include <iostream>
std::cerr << message << std::endl;
}
};
+
+#endif
#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;
//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 ) ;
{
INFOS("Caught unknown exception.");
}
+ return 0 ;
}
INFOS("Normal Exit"); // without this trace, Splash remains on screen !
delete myThreadTrace;
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" ;
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
QString test_component_multistudy ;
QString test_component_icon ;
QString test_component_impltype;
+ QString test_component_version;
+ QString test_component_comment;
QString test_interface_name;
ParserInterfaces interfaces;
ParserPathPrefixes prefixes;
bool implementationType;
+ std::string version;
+ std::string comment;
};
typedef std::vector<ParserComponent> ParserComponents ;
_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);
}
_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);
using namespace std;
-#if defined __GNUC__
- #if __GNUC__ == 2
- #define __GNUC_2__
- #endif
-#endif
-
int SALOME_POINT_SIZE = 3;
SALOME_Actor::SALOME_Actor(){
myIsHighlighted = myIsPreselected = false;
- myRepresentation = 1;
+ myRepresentation = VTK_WIREFRAME;
myDisplayMode = myRepresentation - 1;
myProperty = vtkProperty::New();
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 );
+}
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();
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;
{
if ( myPopup ) {
QAD_Desktop* Desktop = (QAD_Desktop*) QAD_Application::getDesktop();
- QAD_Study* myActiveStudy = Desktop->getActiveStudy();
QString theContext;
QString theParent("Viewer");
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();
+}
+
+
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;
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
getCurves( clist );
for ( int i = 0; i < clist.count(); i++ ) {
updateCurve( clist.at( i ), false );
- }
+ }
myPlot->replot();
}
/*!
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();
}
}
{
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();
+}
+
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& );
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& );
// 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()
#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
// $Header$
#include "SALOMEDS_AttributeDrawable_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
+
using namespace std;
CORBA::Boolean SALOMEDS_AttributeDrawable_i::IsDrawable() {
#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);
};
-
#endif
// $Header$
#include "SALOMEDS_AttributeExpandable_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
+
using namespace std;
CORBA::Boolean SALOMEDS_AttributeExpandable_i::IsExpandable() {
#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);
#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()
// 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);
// $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()
#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);
// $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
#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 );
// $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
#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
#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()
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);
}
#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);
// $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();
#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*);
};
-
#endif
// $Header$
#include "SALOMEDS_AttributeLocalID_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
+
using namespace std;
CORBA::Long SALOMEDS_AttributeLocalID_i::Value() {
#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);
};
-
#endif
#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() {
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() {
#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*);
-
};
// $Header$
#include "SALOMEDS_AttributeOpened_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
+
using namespace std;
CORBA::Boolean SALOMEDS_AttributeOpened_i::IsOpened() {
#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);
#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()
#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);
};
-
#endif
// $Header$
#include "SALOMEDS_AttributePixMap_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
#include <TCollection_AsciiString.hxx>
+
using namespace std;
CORBA::Boolean SALOMEDS_AttributePixMap_i::HasPixMap() {
#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);
#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() {
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');
}
#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();
};
-
-
-
#endif
// $Header$
#include "SALOMEDS_AttributeReal_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
#include <sstream>
using namespace std;
#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*);
// $Header$
#include "SALOMEDS_AttributeSelectable_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
+
using namespace std;
CORBA::Boolean SALOMEDS_AttributeSelectable_i::IsSelectable() {
#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);
};
-
#endif
// $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)
{
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);
}
#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);
// $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)
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) {
else CasCadeSeq->Append(r);
adr = strtok(NULL, " ");
}
- delete(aCopy);
+ free(aCopy);
Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(_myAttr)->Assign(CasCadeSeq);
}
#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);
char* Store();
void Restore(const char*);
+
};
// 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() {
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,
}
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");
SetLocked(Standard_True);
}
SetModified(0);
- delete(aCopy);
+ free(aCopy);
}
#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);
// 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'
return aString;
}
-
-
void SALOMEDS_AttributeTableOfInteger_i::SetTitle(const char* theTitle) {
CheckLocked();
Handle(SALOMEDS_TableOfIntegerAttribute) aTable = Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(_myAttr);
#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)
// $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);
return aString;
}
-
-
void SALOMEDS_AttributeTableOfReal_i::SetTitle(const char* theTitle) {
CheckLocked();
Handle(SALOMEDS_TableOfRealAttribute) aTable = Handle(SALOMEDS_TableOfRealAttribute)::DownCast(_myAttr);
#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);
#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)
return aString;
}
-
-
void SALOMEDS_AttributeTableOfString_i::SetTitle(const char* theTitle) {
CheckLocked();
Handle(SALOMEDS_TableOfStringAttribute) aTable = Handle(SALOMEDS_TableOfStringAttribute)::DownCast(_myAttr);
#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)
// 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();
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);
}
#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);
+
};
// $Header$
#include "SALOMEDS_AttributeTextColor_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
#include <TColStd_HArray1OfReal.hxx>
+
using namespace std;
SALOMEDS::Color SALOMEDS_AttributeTextColor_i::TextColor() {
#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);
// $Header$
#include "SALOMEDS_AttributeTextHighlightColor_i.hxx"
-#include "SALOMEDS_SObject_i.hxx"
#include <TColStd_HArray1OfReal.hxx>
+
using namespace std;
SALOMEDS::Color SALOMEDS_AttributeTextHighlightColor_i::TextHighlightColor() {
#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);
// 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;
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() {
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;
if (!aLabel.FindAttribute(aNode->ID(), aDepNode)) aDepNode = TDataStd_TreeNode::Set(aLabel, aNode->ID());
aNode->SetFirst(aDepNode);
}
- delete(aCopy);
}
#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();
};
+
#endif
#include "SALOMEDS_AttributeUserID_i.hxx"
#include <TCollection_ExtendedString.hxx>
-#include "SALOMEDS_SObject_i.hxx"
+
using namespace std;
char* SALOMEDS_AttributeUserID_i::Value() {
#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
#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) {
// 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;
}
//============================================================================
void SALOMEDS_ChildIterator_i::Next()
{
_it.Next();
+ TCollection_AsciiString anEntry;
+ TDF_Tool::Entry(_it.Value(),anEntry);
+ //cout<<"SALOMEDS_ChildIterator_i::Next - "<<anEntry.ToCString()<<endl;
}
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();
}
#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();
virtual void Next();
virtual SALOMEDS::SObject_ptr Value();
};
+
+
#endif
// 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();
}
#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
// $Header$
#include "SALOMEDS_SComponentIterator_i.hxx"
-using namespace std;
+#include "SALOMEDS_SComponent_i.hxx"
+using namespace std;
//============================================================================
/*! Function : constructor
*/
//============================================================================
-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);
}
//============================================================================
//============================================================================
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();
}
#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();
virtual void Next();
virtual SALOMEDS::SComponent_ptr Value();
};
+
+
#endif
// $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)
{
}
* 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
#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
// 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
//============================================================================
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 :
char* SALOMEDS_SObject_i::GetID()
{
TCollection_AsciiString anEntry;
- TDF_Tool::Entry (_lab,anEntry);
+ TDF_Tool::Entry(_lab,anEntry);
return CORBA::string_dup(anEntry.ToCString());
}
//============================================================================
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();
}
//============================================================================
//============================================================================
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();
}
//============================================================================
//============================================================================
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;
}
* 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;
-
}
//============================================================================
//============================================================================
char* SALOMEDS_SObject_i::Name()
{
- return CORBA::string_dup(_name);
+ return CORBA::string_dup(_name.c_str());
}
//============================================================================
* Purpose :
*/
//============================================================================
-void SALOMEDS_SObject_i::Name(const char* name)
+void SALOMEDS_SObject_i::Name(const char* theName)
{
- _name = CORBA::string_dup(name);
+ _name = theName;
}
//============================================================================
//============================================================================
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();
}
//============================================================================
*/
//============================================================================
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("");
}
//============================================================================
*/
//============================================================================
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("");
}
//============================================================================
*/
//============================================================================
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));
+}
+
#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
// 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.
// 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);
}
//============================================================================
{
}
+
+//============================================================================
+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)
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();
}
//============================================================================
* 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());
}
//============================================================================
*/
//============================================================================
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);
}
//============================================================================
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();
}
//============================================================================
//============================================================================
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();
}
//============================================================================
* 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();
}
* 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)) {
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);
* 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);
}
}
//============================================================================
//============================================================================
-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();
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();
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();
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");
}
* 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();
}
*/
//============================================================================
-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;
}
*/
//============================================================================
-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));
}
//============================================================================
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);
}
//============================================================================
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");
}
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 {
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);
//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);
}
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);
//============================================================================
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);
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
//============================================================================
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();
}
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);
}
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);
}
}
//============================================================================
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);
}
//============================================================================
//============================================================================
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);
}
//============================================================================
*/
//============================================================================
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();
}
//============================================================================
{
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);
{
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);
{
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());
}
#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
// 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);
#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
//===========================================================================
//============================================================================
//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);
}
//============================================================================
* 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;
}
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");
}
//============================================================================
* 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);
}
* 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();
}
//============================================================================
* 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();
}
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();
}
* 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);
+ }
}
//=============================================================================
* 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);
}
//============================================================================
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();
}
//============================================================================
*/
//============================================================================
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();
}
//============================================================================
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
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
}
}
* 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);
}
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);
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()) {
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
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
// 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())
}
}
- 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);
*/
//============================================================================
-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();
}
//============================================================================
//============================================================================
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);
}
//============================================================================
* 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);
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();
//============================================================================
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;
// }
_OCAFApp->Close(_clipboard);
}
+
_clipboard = aTargetDocument;
return true;
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,
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();
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);
}
}
// 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;
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())
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();
}
// 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,
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
*/
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,
// 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;
}
//============================================================================
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())
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);
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();
}
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();
}
//============================================================================
// 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();
}
/* looks also for eventual children */
- bool found = false ;
+ bool found;
addSO = _FindObject( CSO, anObjectName, found ) ;
if( found) {
length++ ;
* 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
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");
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
}
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);
}
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);
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;
{
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
//============================================================================
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);
}
//============================================================================
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();
}
//============================================================================
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
//============================================================================
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();
}
//============================================================================
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()){
-//============================================================================
-/*! 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 :
{
SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator();
+ const CORBA::ORB_var& anORB = GetORB();
for (; itcomponent->More(); itcomponent->Next()) {
SALOMEDS::SComponent_var sco = itcomponent->Value();
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) ;
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);
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);
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++)
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();
}
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();
}
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 (...) {}
#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()
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();
// 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
// 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
}
+//============================================================================
+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 :
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);
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();
}
//============================================================================
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();
}
//============================================================================
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();
}
#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);
// Author : Yves FRICAUD
// Module : SALOME
+using namespace std;
#include "SALOMEDS_UseCaseIterator_i.hxx"
#include "SALOMEDS_SObject_i.hxx"
#include "utilities.h"
-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);
}
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();
}
#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();
virtual void Next();
virtual SALOMEDS::SObject_ptr Value();
};
+
+
#endif
#endif
-static QMutex myMutex(false);
+static QMutex myMutex(true);
PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState):
{
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);
}
int PyInterp_base::simpleRun(const char *command)
{
- if(strcmp(command,"") != 0){
+ if( !_atFirst && strcmp(command,"") != 0 ) {
_history.push_back(command);
_ith = _history.end();
}
#include "SALOME_Event.hxx"
// QT Includes
+#include <qaccel.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qmessagebox.h>
#include <qlineedit.h>
#include <qdatetime.h>
#include <qthread.h>
-
+#include <qtooltip.h>
#include <qstringlist.h>
#if QT_VERSION > 300
# 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;
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 )
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: ") + moduleversion;
toolb->setToggleButton( true );
+ QToolTip::add(toolb, ttip, this->toolTipGroup(), modulecomment);
myComponentButton.append(toolb);
}
else
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();
}
}
}
+/* 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
void Desktop_AppSelectionDlg::onHelp()
{
}
-
void onComboActiveComponent( const QString & , bool isLoadData);
void onCascade();
+ void onKeyAccel( int id );
/* NRI void onHelpWindowClosed(); */
protected:
bool _islibso;
ComponentMap myComponents;
+ QMap<int, int> myAccelMap;
};
/********************************************************************
/*!
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++) {
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;
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 ) {
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 );
*/
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() );
}
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;
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,
// 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 {
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;
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;
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 {
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 {
}
// add other attributes
if (Item) {
- QAD_ObjectBrowserItem* subItem;
// Selectable
if ( SC->FindAttribute(anAttr, "AttributeSelectable") ) {
aSelectable = SALOMEDS::AttributeSelectable::_narrow(anAttr);
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
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;
}
}
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,
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 );
// 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( "" );
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;
}
}
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 );
SALOMEDS::AttributeTableOfInteger_var aTableInt;
SALOMEDS::AttributeTableOfReal_var aTableReal;
SALOMEDS::AttributeComment_var aComment;
+ CORBA::String_var aString;
// Integer
if ( SO->FindAttribute( anAttr, "AttributeInteger" ) ) {
// 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() ;
// 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() ;
// 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;
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 );
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 );
}
#include <qmap.h>
#include <qclipboard.h>
#include <qthread.h>
+#include <qdragobject.h>
// NRI : Temporary added
// IDL Headers
#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
{
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();
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);
*/
void QAD_PyEditor::handleReturn()
{
- int ret;
int para=paragraphs()-2;
// NRI : Temporary added
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 );
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( QKeyEvent* e )
{
- 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) ||
// NRI //
}
-void QAD_PyEditor::customEvent(QCustomEvent *e)
+void QAD_PyEditor::customEvent(QCustomEvent* e)
{
switch( e->type() ) {
case PYTHON_OK:
_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;
}
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();
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;
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
// !!! 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
*/
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
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] );
}
}
/*!
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();
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");
// 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.
// 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++) {
// 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)
{
// 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;
//============================================================================
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();
// 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();
}
// 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();
//=======================================================================
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() )
{
// 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,
// 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
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 );
+}
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();
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 );
+}
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 );