From a10c5c370fc312faa96b01a213ea705bbb348535 Mon Sep 17 00:00:00 2001 From: prascle Date: Tue, 13 Jan 2004 15:48:23 +0000 Subject: [PATCH] PR: Merge from MTAJ_br1 13 janvier 2004 (mergefrom_MTAJ_br1_13Jan04) --- bin/orbmodule.py | 7 +- bin/runSalome | 8 +- src/ModuleGenerator/IDLparser.py | 175 ++++++++---------- src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx | 69 ++++++- src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.h | 3 + src/TOOLSGUI/ToolsGUI_msg_en.po | 3 + 6 files changed, 152 insertions(+), 113 deletions(-) diff --git a/bin/orbmodule.py b/bin/orbmodule.py index bd8e73b78..1154b0101 100755 --- a/bin/orbmodule.py +++ b/bin/orbmodule.py @@ -21,7 +21,12 @@ class Server: class NamingServer(Server): XTERM="" - CMD="runNS.sh > /tmp/salomeNS.log 2>&1" + USER=os.getenv('USER') + if USER is None: + USER='anonymous' + LOGDIR="/tmp/logs/" + USER + os.system("mkdir -m 777 -p " + LOGDIR) + CMD="runNS.sh > " + LOGDIR + "/salomeNS.log 2>&1" # ----------------------------------------------------------------------------- diff --git a/bin/runSalome b/bin/runSalome index 7e15dd9f9..3a3d0e2d2 100755 --- a/bin/runSalome +++ b/bin/runSalome @@ -1,9 +1,9 @@ #!/bin/sh -python -i runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --xterm --containers=cpp,python --killall -#python -i runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --logger --xterm -#python -i runSalome.py --modules=GEOM,SMESH,VISU,SUPERV,MED -#python -i runSalome.py --help +python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --xterm --containers=cpp,python --killall +#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --logger --xterm +#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --modules=GEOM,SMESH,VISU,SUPERV,MED +#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --help # ----------------------------------------------------------------------------- # diff --git a/src/ModuleGenerator/IDLparser.py b/src/ModuleGenerator/IDLparser.py index 44af77590..1743563c6 100644 --- a/src/ModuleGenerator/IDLparser.py +++ b/src/ModuleGenerator/IDLparser.py @@ -29,15 +29,37 @@ import pdb from xml.sax.handler import * from omniidl import idlast, idltype, idlvisitor, idlutil, output -#values of this map are used in some nodes defenition -common_data={"AUTHOR" : "", - "ICON" : "", - "VERSION" : "", - "COMP_TYPE": "", - "COMP_NAME": "", - "COMP_MULT": "1" +# parameters not found in IDL file, user's specified in optional parameters +common_data={"AUTHOR" : "", + "ICON" : "", + "VERSION" : "", + "COMP_TYPE" : "", + "COMP_NAME" : "", + "COMP_UNAME" : "", + "COMP_MULT" : "" } +nb_components = 0 + +#-------------------------------------------------- +# extract value of from list +# it's proposed that the matching item +# looks like =, for example, +# catalog=/tmp/myxml.xml +#-------------------------------------------------- +def getParamValue( param_name, default_value, args ): + pattern=param_name+"=" + + res = default_value #initial value + for opt in args: + s = re.compile(pattern).search(opt) + if s: + res = opt[s.end():] + break #found + + return res + + #-------------------------------------------------- # print error message #-------------------------------------------------- @@ -168,7 +190,7 @@ class Tree: #-------------------------------------------------- class inParameter(Tree): - def __init__(self, name=None, type='', comment=''): + def __init__(self, name=None, type='', comment='unknown'): Tree.__init__(self, 'inParameter') if name is None: return @@ -186,7 +208,7 @@ class inParameter(Tree): #-------------------------------------------------- class outParameter(Tree): - def __init__(self, name=None, type='', comment = ''): + def __init__(self, name=None, type='', comment = 'unknown'): Tree.__init__(self, 'outParameter') if name is None: return @@ -205,7 +227,7 @@ class outParameter(Tree): #-------------------------------------------------- class Service(Tree): - def __init__(self, name=None): + def __init__(self, name=None, comment = 'unknown'): Tree.__init__(self, 'component-service') if name is None: return @@ -213,7 +235,7 @@ class Service(Tree): self.addNamedChild('service-name', name) self.addNamedChild('service-author',common_data["AUTHOR"]) self.addNamedChild('service-version',common_data["VERSION"]) - self.addNamedChild('service-comment') + self.addNamedChild('service-comment', comment) self.addNamedChild('service-by-default', "0") self.addNamedChild('inParameter-list') self.addNamedChild('outParameter-list') @@ -304,14 +326,14 @@ class Service(Tree): #-------------------------------------------------- class Interface(Tree): - def __init__(self, name=None): + def __init__(self, name=None, comment='unknown'): Tree.__init__(self) if name is None: return self.addNamedChild('component-interface-name', name) - self.addNamedChild('component-interface-comment'); + self.addNamedChild('component-interface-comment', comment); self.addNamedChild('component-service-list') def createService(self, name): @@ -362,18 +384,17 @@ class Interface(Tree): # implements Component tree #-------------------------------------------------- class Component(Tree): - def __init__(self, name=None): + def __init__(self): Tree.__init__(self, 'component') - - if name is None: return - - self.addNamedChild('component-name', name) - self.addNamedChild('component-type',common_data["COMP_TYPE"]) - self.addNamedChild('component-author',common_data["AUTHOR"]) - self.addNamedChild('component-version',common_data["VERSION"]) - self.addNamedChild('component-comment') + + self.addNamedChild('component-name', common_data["COMP_NAME"]) + self.addNamedChild('component-username', common_data["COMP_UNAME"]) + self.addNamedChild('component-type', common_data["COMP_TYPE"]) + self.addNamedChild('component-author', common_data["AUTHOR"]) + self.addNamedChild('component-version', common_data["VERSION"]) + self.addNamedChild('component-comment', 'unknown') self.addNamedChild('component-multistudy', common_data["COMP_MULT"]) - self.addNamedChild('component-icone',common_data["ICON"]) + self.addNamedChild('component-icone', common_data["ICON"]) self.addNamedChild('constraint') self.addNamedChild('component-interface-list') @@ -387,41 +408,17 @@ class Component(Tree): return i def merge(self, C): - ext=C.getChild('component-author') - int=self.getChild('component-author') - if int is not None and ext is not None and len(ext.content): - int.content = ext.content - - ext=C.getChild('component-type') - int=self.getChild('component-type') - if int is not None and ext is not None and len(ext.content): - int.content = ext.content - - ext=C.getChild('component-icone') - int=self.getChild('component-icone') - if int is not None and ext is not None and len(ext.content): - int.content = ext.content - - ext=C.getChild('component-version') - int=self.getChild('component-version') - if int is not None and ext is not None and len(ext.content): - int.content = ext.content - - ext=C.getChild('component-comment') - int=self.getChild('component-comment') - if int is not None and ext is not None and len(ext.content): - int.content = ext.content - - ext=C.getChild('component-multistudy') - int=self.getChild('component-multistudy') - if int is not None and ext is not None and len(ext.content): - int.content = ext.content - - ext=C.getChild('constraint') - int=self.getChild('constraint') - if int is not None and ext is not None and len(ext.content): - int.content = ext.content - + + for i in ['component-username', 'component-author', + 'component-type', 'component-icone', 'component-version', + 'component-comment', 'component-multistudy', 'constraint']: + ext = C.getChild(i) + int = self.getChild(i) + if int is None: + int = ext + elif ext is not None and len(ext.content): + int.content = ext.content + L_ext = C.getChild('component-interface-list') L_int = self.getChild('component-interface-list') if L_ext is None or L_int is None: @@ -602,8 +599,7 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): if ((s[0] == "Engines") & (s[1] == "Component")): self.EngineType = 1; break - if common_data["COMP_NAME"] : Comp = Component(common_data["COMP_NAME"]) - else : Comp = Component(node.identifier()) + Comp = Component() self.currentInterface = Comp.createInterface(node.identifier()) @@ -612,6 +608,8 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): c.accept(self) if (self.EngineType): + global nb_components + nb_components = nb_components + 1 self.catalog.mergeComponent(Comp) self.EngineType = 0 @@ -648,52 +646,29 @@ class ModuleCatalogVisitor (idlvisitor.AstVisitor): self.currentService.createOutParameter \ (node.identifier(), self.currentType) -#-------------------------------------------------- -# extract value of from list -# it's proposed that the matching item -# looks like =, for example, -# catalog=/tmp/myxml.xml -#-------------------------------------------------- -def getParamValue( param_name, args ): - pattern="^"+param_name+"=" - - res = "" #initial value - for opt in args: - s = re.compile(pattern).search(opt) - if s: - res = opt[s.end():] - break #found - - return res - #-------------------------------------------------- # parse idl and store xml file #-------------------------------------------------- def run(tree, args): - CatalogFileName=getParamValue("catalog",args) - if CatalogFileName is None: - CatalogFileName = 'CatalogModulePersonnel.xml' + print args - if (re.compile(".*?.xml$").match(CatalogFileName, 1) is None): + CatalogFileName=getParamValue("catalog", "CatalogModulePersonnel.xml", args) + print CatalogFileName + if re.compile(".*?.xml$").match(CatalogFileName, 1) is None: CatalogFileName = CatalogFileName + '.xml' #========= Read parameters ====================== - common_data["ICON"] = getParamValue("icon",args) # get icon file - - common_data["AUTHOR"] = getParamValue("author",args) # get author name - if common_data["AUTHOR"] is None: common_data["AUTHOR"] = os.getenv("USER"); + common_data["ICON"] = getParamValue("icon", "", args) + common_data["AUTHOR"] = getParamValue("author", os.getenv("USER"), args) + common_data["VERSION"] = getParamValue("version", "1", args) + common_data["COMP_NAME"] = getParamValue("name", "", args) + common_data["COMP_UNAME"] = getParamValue("username", "", args) + common_data["COMP_TYPE"] = getParamValue("type", "OTHER", args) + common_data["COMP_MULT"] = getParamValue("multistudy", "1", args) + + print common_data - common_data["VERSION"] = getParamValue("version",args) # get version - - common_data["COMP_NAME"] = getParamValue("name",args) # get icon file - - val = getParamValue("type",args) # get icon file - if val: common_data["COMP_TYPE"] = val - - val = getParamValue("multistudy",args) # get icon file - if val : common_data["COMP_MULT"] = val - - remove_comp = getParamValue("remove", args) + remove_comp = getParamValue("remove", "", args) #================================================== @@ -701,9 +676,9 @@ def run(tree, args): print "Importing", CatalogFileName C = Catalog(CatalogFileName) else: - print "Warning : ",CatalogFileName, " was not found." + print "Creating ",CatalogFileName C = Catalog() - + print "Reading idl file" visitor = ModuleCatalogVisitor(C) @@ -735,5 +710,5 @@ def run(tree, args): if __name__ == "__main__": print - print "Usage : omniidl -bIDLparser -Wbcatalog=[,icon=][,version=][,author=][,name=][,multistudy=][,remove=component_name] " + print "Usage : omniidl -bIDLparser [-I]* -Wbcatalog=[,icon=][,version=][,author=][,name=][,username=][,multistudy=] " print diff --git a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx index f117c1b60..5c774aa8e 100644 --- a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx +++ b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.cxx @@ -23,6 +23,7 @@ // // File : ToolsGUI_CatalogGeneratorDlg.cxx // Author : Nicolas REJNERI +// Modified : Marc TAJCHMAN // Module : SALOME // $Header$ @@ -33,6 +34,7 @@ using namespace std; #include "QAD_Desktop.h" #include "QAD_FileDlg.h" #include "QAD_MessageBox.h" +#include "QAD_Tools.h" #include #include #include @@ -107,16 +109,18 @@ ToolsGUI_CatalogGeneratorDlg::ToolsGUI_CatalogGeneratorDlg( QWidget* parent, con supplGrpLayout->setSpacing( SPACING_SIZE ); supplGrpLayout->setMargin( MARGIN_SIZE ); + QSize myMinimumSize(int(MIN_EDIT_SIZE*0.3), 0); + myAuthorEdit = new QLineEdit( supplGrp , "myAuthorEdit" ); myAuthorEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myAuthorEdit->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + myAuthorEdit->setMinimumSize( myMinimumSize ); OSD_Process aProcess; myAuthorEdit->setText(aProcess.UserName().ToCString()); myVersionEdit = new QLineEdit(supplGrp , "myVersion" ); myVersionEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myVersionEdit->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + myVersionEdit->setMinimumSize( myMinimumSize ); QStringList aList = QStringList::split(QRegExp("\\s+"),tr( "INF_VERSION" )); myVersionEdit->setText(aList.last()); QDoubleValidator *validator = new QDoubleValidator(myVersionEdit); @@ -130,16 +134,20 @@ ToolsGUI_CatalogGeneratorDlg::ToolsGUI_CatalogGeneratorDlg( QWidget* parent, con myCompName = new QLineEdit(supplGrp , "myCompName"); myCompName->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myCompName->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + myCompName->setMinimumSize( myMinimumSize ); + + myCompUserName = new QLineEdit(supplGrp , "myCompUserName"); + myCompUserName->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myCompUserName->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); myCompType = new QLineEdit(supplGrp , "myCompType"); myCompType->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myCompType->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + myCompType->setMinimumSize( myMinimumSize ); myCompType->setText("OTHER"); myCompMultiStd = new QLineEdit(supplGrp , "myCompMultiStd"); myCompMultiStd->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - myCompMultiStd->setMinimumSize( MIN_EDIT_SIZE*0.3, 0 ); + myCompMultiStd->setMinimumSize( myMinimumSize ); myCompMultiStd->setText("1"); QIntValidator *ivalidator = new QIntValidator(myVersionEdit); myCompMultiStd->setValidator(ivalidator); @@ -148,12 +156,14 @@ ToolsGUI_CatalogGeneratorDlg::ToolsGUI_CatalogGeneratorDlg( QWidget* parent, con supplGrpLayout->addWidget( myAuthorEdit, 0, 1 ); supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_NAME" ), supplGrp ), 0, 2); supplGrpLayout->addWidget(myCompName,0,3); - supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_TYPE" ), supplGrp ), 0, 4); - supplGrpLayout->addWidget(myCompType,0,5); + supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_USERNAME" ), supplGrp ), 0, 4); + supplGrpLayout->addWidget(myCompUserName,0,5); supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_VERSION" ), supplGrp ), 1, 0); supplGrpLayout->addWidget( myVersionEdit, 1, 1); supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_MULTISTD" ), supplGrp ), 1, 2); supplGrpLayout->addWidget(myCompMultiStd,1,3); + supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_COMP_TYPE" ), supplGrp ), 1, 4); + supplGrpLayout->addWidget(myCompType,1,5); supplGrpLayout->addWidget( new QLabel( tr( "TOOLS_PNG_FILE" ), supplGrp ), 2, 0); supplGrpLayout->addMultiCellWidget( myPngEdit, 2,2,1,4 ); supplGrpLayout->addWidget( myBrowsePngBtn, 2, 5 ); @@ -251,6 +261,15 @@ QString ToolsGUI_CatalogGeneratorDlg::getCompName() return myCompName->text().stripWhiteSpace(); } +//================================================================================= +// function : getCompUserName() +// purpose : gets username of the component +//================================================================================= +QString ToolsGUI_CatalogGeneratorDlg::getCompUserName() +{ + return myCompUserName->text().stripWhiteSpace(); +} + //================================================================================= // function : getCompType() // purpose : gets type of the component @@ -268,6 +287,36 @@ QString ToolsGUI_CatalogGeneratorDlg::getCompType() return myCompType->text().stripWhiteSpace(); } +//================================================================================= +// function : getIdlPath() +// purpose : gets IDL path of modules +//================================================================================= +QString ToolsGUI_CatalogGeneratorDlg::getIdlPath() +{ + SALOME_ModuleCatalog::ModuleCatalog_var aCatalog = + SALOME_ModuleCatalog::ModuleCatalog::_narrow( QAD_Application::getDesktop()->getCatalogue()); + + SALOME_ModuleCatalog::ListOfIAPP_Affich_var list_composants = + aCatalog->GetComponentIconeList(); + + QString IDLpath = ""; + + for (unsigned int ind = 0; ind < list_composants->length();ind++) { + QString modulename = strdup(list_composants[ind].modulename) ; + + QCString dir; + if (dir = getenv( modulename + "_ROOT_DIR")) { + IDLpath = IDLpath + "-I" + QAD_Tools::addSlash( QAD_Tools::addSlash(dir) + + QAD_Tools::addSlash("idl") + + QAD_Tools::addSlash("salome")) + " "; + } + } + + // MESSAGE ( " IDLpath = " << IDLpath); + + return IDLpath; +} + //================================================================================= // function : onBrowseBtnClicked() // purpose : <...> (Browse) buttons slot @@ -326,12 +375,14 @@ void ToolsGUI_CatalogGeneratorDlg::updateButtonState() //================================================================================= void ToolsGUI_CatalogGeneratorDlg::onApply() { + QString IDLpath = getIdlPath(); QString XmlFile = getXmlFile(); QString IdlFile = getIdlFile(); QString Author = getAuthor(); QString Version = getVersion(); QString PngFile = getPngFile(); QString CompName = getCompName(); //gets component name + QString CompUserName = getCompUserName(); //gets component username QString CompType = getCompType(); //gets component type QString CompMultiStd = getCompMultiStd(); @@ -345,13 +396,14 @@ void ToolsGUI_CatalogGeneratorDlg::onApply() else { QString command = ""; if ( getenv("KERNEL_ROOT_DIR") ) - command = QString( getenv( "KERNEL_ROOT_DIR" ) ) + "/bin/runIDLparser -Wbcatalog=" + XmlFile; + command = QString( getenv( "KERNEL_ROOT_DIR" ) ) + "/bin/salome/runIDLparser " + IDLpath + " -Wbcatalog=" + XmlFile; else { QAD_MessageBox::error1( this, tr("TOOLS_ERR_ERROR"), tr("KERNEL_ROOT_DIR variable is not defined"), tr("TOOLS_BUT_OK") ); } + if (!Author.isEmpty()) command += ",author=" + Author; if (!Version.isEmpty()) command += ",version=" + Version; if (!PngFile.isEmpty()) { @@ -360,6 +412,7 @@ void ToolsGUI_CatalogGeneratorDlg::onApply() command += QString(",icon=") + QString(aFile.ToCString()); } if (!CompName.isEmpty()) command += ",name=" + CompName; + if (!CompUserName.isEmpty()) command += ",username=" + CompUserName; if (!CompType.isEmpty()) command += ",type=" + CompType; if (!CompMultiStd.isEmpty()) command += ",multistudy=" + CompMultiStd; command += " " + IdlFile; diff --git a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.h b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.h index d0e593458..9d474ac67 100644 --- a/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.h +++ b/src/TOOLSGUI/ToolsGUI_CatalogGeneratorDlg.h @@ -46,12 +46,14 @@ public: ToolsGUI_CatalogGeneratorDlg( QWidget* parent = 0, const char* name = 0 ); ~ToolsGUI_CatalogGeneratorDlg(); + QString getIdlPath(); QString getIdlFile(); QString getXmlFile(); QString getPngFile(); QString getAuthor(); QString getVersion(); QString getCompName(); + QString getCompUserName(); QString getCompType(); QString getCompMultiStd(); @@ -67,6 +69,7 @@ private: QLineEdit* myVersionEdit; QLineEdit* myAuthorEdit; QLineEdit* myCompName; + QLineEdit* myCompUserName; QLineEdit* myCompType; QLineEdit* myCompMultiStd; QPushButton* myBrowseIdlBtn; diff --git a/src/TOOLSGUI/ToolsGUI_msg_en.po b/src/TOOLSGUI/ToolsGUI_msg_en.po index 7859d5e12..09ad7be89 100644 --- a/src/TOOLSGUI/ToolsGUI_msg_en.po +++ b/src/TOOLSGUI/ToolsGUI_msg_en.po @@ -76,6 +76,9 @@ msgstr "Version : " msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_COMP_NAME" msgstr "Name : " +msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_COMP_USERNAME" +msgstr "UserName : " + msgid "ToolsGUI_CatalogGeneratorDlg::TOOLS_COMP_TYPE" msgstr "Type : " -- 2.39.2