From 54dd4bca5d0eb605fae21321a06bbdee31dbe886 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Wed, 13 Aug 2014 09:56:22 +0200 Subject: [PATCH] GUI for HP containers. --- src/engine/ComponentInstance.hxx | 1 + src/engine/ComposedNode.cxx | 39 ++ src/engine/ComposedNode.hxx | 1 + src/engine/Container.cxx | 11 + src/engine/Container.hxx | 2 + src/engine/ElementaryNode.cxx | 4 + src/engine/ElementaryNode.hxx | 1 + src/engine/HomogeneousPoolContainer.cxx | 9 + src/engine/HomogeneousPoolContainer.hxx | 1 + src/engine/InlineNode.cxx | 11 + src/engine/InlineNode.hxx | 1 + src/engine/Node.cxx | 38 +- src/engine/Node.hxx | 5 + src/engine/ServerNode.cxx | 8 - src/engine/ServerNode.hxx | 1 - src/engine/ServiceNode.cxx | 11 + src/engine/ServiceNode.hxx | 1 + src/engine/Test/ComponentInstanceTest.cxx | 10 + src/engine/Test/ComponentInstanceTest.hxx | 2 + src/engine/VisitorSaveSchema.cxx | 5 + src/engine_swig/pilot.i | 1 + src/genericgui/CMakeLists.txt | 19 +- src/genericgui/EditionComponent.cxx | 2 +- src/genericgui/EditionContainer.cxx | 28 +- src/genericgui/EditionContainer.hxx | 8 +- src/genericgui/EditionSalomeNode.cxx | 34 +- src/genericgui/EditionSalomeNode.hxx | 3 +- src/genericgui/EditionScript.cxx | 18 +- src/genericgui/EditionScript.hxx | 3 +- src/genericgui/FormAdvParamContainer.cxx | 534 +++++++++++++++++ src/genericgui/FormAdvParamContainer.hxx | 80 +++ src/genericgui/FormAdvParamContainer.ui | 419 +++++++++++++ src/genericgui/FormContainer.cxx | 694 ++-------------------- src/genericgui/FormContainer.hxx | 53 +- src/genericgui/FormContainer.ui | 475 +-------------- src/genericgui/FormContainerBase.cxx | 164 +++++ src/genericgui/FormContainerBase.hxx | 60 ++ src/genericgui/FormContainerDecorator.cxx | 181 ++++++ src/genericgui/FormContainerDecorator.hxx | 76 +++ src/genericgui/FormHPContainer.cxx | 161 +++++ src/genericgui/FormHPContainer.hxx | 66 ++ src/genericgui/FormHPContainer.ui | 554 +++++++++++++++++ src/genericgui/FormParamContainer.ui | 125 ++++ src/genericgui/GenericGui.cxx | 10 + src/genericgui/GenericGui.hxx | 2 + src/genericgui/GuiEditor.cxx | 19 +- src/genericgui/GuiEditor.hxx | 1 + src/genericgui/ItemEdition.cxx | 8 +- src/genericgui/Menus.cxx | 2 + src/hmi/commandsProc.cxx | 86 ++- src/hmi/commandsProc.hxx | 32 +- src/hmi/guiContext.hxx | 2 +- src/hmi/guiObservers.cxx | 133 +++-- src/hmi/guiObservers.hxx | 47 +- src/runtime/CORBAComponent.cxx | 5 + src/runtime/CORBAComponent.hxx | 1 + src/runtime/CppComponent.cxx | 4 + src/runtime/CppComponent.hxx | 1 + src/runtime/SalomeComponent.cxx | 5 + src/runtime/SalomeComponent.hxx | 1 + src/runtime/SalomeContainer.cxx | 20 +- src/runtime/SalomeContainer.hxx | 1 + src/runtime/SalomeHPComponent.cxx | 5 + src/runtime/SalomeHPComponent.hxx | 1 + src/runtime/SalomeHPContainer.cxx | 10 +- src/runtime/SalomeHPContainerTools.cxx | 2 +- src/runtime/SalomePythonComponent.cxx | 5 + src/runtime/SalomePythonComponent.hxx | 1 + 68 files changed, 2988 insertions(+), 1336 deletions(-) create mode 100644 src/genericgui/FormAdvParamContainer.cxx create mode 100644 src/genericgui/FormAdvParamContainer.hxx create mode 100644 src/genericgui/FormAdvParamContainer.ui create mode 100644 src/genericgui/FormContainerBase.cxx create mode 100644 src/genericgui/FormContainerBase.hxx create mode 100644 src/genericgui/FormContainerDecorator.cxx create mode 100644 src/genericgui/FormContainerDecorator.hxx create mode 100644 src/genericgui/FormHPContainer.cxx create mode 100644 src/genericgui/FormHPContainer.hxx create mode 100644 src/genericgui/FormHPContainer.ui create mode 100644 src/genericgui/FormParamContainer.ui diff --git a/src/engine/ComponentInstance.hxx b/src/engine/ComponentInstance.hxx index 839e4d516..ff1fefa78 100644 --- a/src/engine/ComponentInstance.hxx +++ b/src/engine/ComponentInstance.hxx @@ -62,6 +62,7 @@ namespace YACS virtual std::string getFileRepr() const; virtual ServiceNode* createNode(const std::string& name)=0; virtual ComponentInstance *clone() const = 0; + virtual ComponentInstance *cloneAlways() const = 0; virtual std::string getKind() const; virtual std::string getKindForNode() const; static const char KIND[]; diff --git a/src/engine/ComposedNode.cxx b/src/engine/ComposedNode.cxx index aa9f9b584..5bf110794 100644 --- a/src/engine/ComposedNode.cxx +++ b/src/engine/ComposedNode.cxx @@ -109,6 +109,45 @@ void ComposedNode::performDuplicationOfPlacement(const Node& other) } } +void ComposedNode::performShallowDuplicationOfPlacement(const Node& other) +{ + const ComposedNode &otherC=*(dynamic_cast(&other)); + DeploymentTree treeToDup=otherC.getDeploymentTree(); + list< ElementaryNode * > clones=otherC.getRecursiveConstituents(); + vector conts=treeToDup.getAllContainers(); + //iterate on all containers + for(vector::iterator iterCt=conts.begin();iterCt!=conts.end();iterCt++) + { + vector comps=treeToDup.getComponentsLinkedToContainer(*iterCt); + Container *contCloned((*iterCt)); + + //iterate on all component instances linked to the container + for(vector::iterator iterCp=comps.begin();iterCp!=comps.end();iterCp++) + { + vector tasks=treeToDup.getTasksLinkedToComponent(*iterCp); + ComponentInstance *curCloned((*iterCp)); + curCloned->setContainer(contCloned); + for(vector::iterator iterT=tasks.begin();iterT!=tasks.end();iterT++) + { + //No risk for static cast : appendTask called by ComposedNode. + list< ElementaryNode * >::iterator res=find(clones.begin(),clones.end(),(ElementaryNode *)(*iterT)); + //No risk here to because called only on cloning process... + ServiceNode *nodeC=(ServiceNode *)getChildByName(otherC.getChildName(*res)); + nodeC->setComponent(curCloned); + } + } + + // iterate on all tasks linked to the container + vector tasks=treeToDup.getTasksLinkedToContainer(*iterCt); + for(vector::iterator iterT=tasks.begin();iterT!=tasks.end();iterT++) + { + std::list< ElementaryNode * >::iterator res=find(clones.begin(),clones.end(),(ElementaryNode *)(*iterT)); + InlineFuncNode *nodeC=(InlineFuncNode *)getChildByName(otherC.getChildName(*res)); + nodeC->setContainer(contCloned); + } + } +} + bool ComposedNode::isFinished() { if(_state==YACS::DONE)return true; diff --git a/src/engine/ComposedNode.hxx b/src/engine/ComposedNode.hxx index 11bdbf614..fcd0e13f1 100644 --- a/src/engine/ComposedNode.hxx +++ b/src/engine/ComposedNode.hxx @@ -51,6 +51,7 @@ namespace YACS ComposedNode(const std::string& name); ComposedNode(const ComposedNode& other, ComposedNode *father); void performDuplicationOfPlacement(const Node& other); + void performShallowDuplicationOfPlacement(const Node& other); public: virtual ~ComposedNode(); bool isFinished(); diff --git a/src/engine/Container.cxx b/src/engine/Container.cxx index d922a9deb..e3eccbf06 100644 --- a/src/engine/Container.cxx +++ b/src/engine/Container.cxx @@ -30,6 +30,8 @@ using namespace YACS::ENGINE; const char Container::KIND_ENTRY[]="container_kind"; +const char Container::AOC_ENTRY[]="attached_on_cloning"; + Container::Container():_isAttachedOnCloning(false),_proc(0) { } @@ -45,6 +47,15 @@ std::string Container::getDiscreminantStrOfThis(const Task *askingNode) const return oss.str(); } +/*! + * If \a val is equal to true the current container 'this' is not destined to be deeply copied on clone call. + * If \a val is equal to false the current container 'this' is destined to be deeply copied on clone call. + */ +void Container::setAttachOnCloningStatus(bool val) const +{ + _isAttachedOnCloning=val; +} + /*! * By calling this method the current container 'this' is not destined to be deeply copied on clone call. */ diff --git a/src/engine/Container.hxx b/src/engine/Container.hxx index 4dc8b3549..83415f503 100644 --- a/src/engine/Container.hxx +++ b/src/engine/Container.hxx @@ -54,6 +54,7 @@ namespace YACS virtual std::string getPlacementId(const Task *askingNode) const = 0; virtual std::string getFullPlacementId(const Task *askingNode) const = 0; //Edition only methods + virtual void setAttachOnCloningStatus(bool val) const; virtual void attachOnCloning() const; virtual void dettachOnCloning() const; virtual bool isAttachedOnCloning() const; @@ -78,6 +79,7 @@ namespace YACS Proc* getProc() { return _proc; } virtual void shutdown(int level) = 0; static const char KIND_ENTRY[]; + static const char AOC_ENTRY[]; protected: std::string _name; mutable bool _isAttachedOnCloning; diff --git a/src/engine/ElementaryNode.cxx b/src/engine/ElementaryNode.cxx index 933768992..290fa7bab 100644 --- a/src/engine/ElementaryNode.cxx +++ b/src/engine/ElementaryNode.cxx @@ -69,6 +69,10 @@ void ElementaryNode::performDuplicationOfPlacement(const Node& other) { } +void ElementaryNode::performShallowDuplicationOfPlacement(const Node& other) +{ +} + ElementaryNode::~ElementaryNode() { for(list::iterator iter1=_setOfInputPort.begin();iter1!=_setOfInputPort.end();iter1++) diff --git a/src/engine/ElementaryNode.hxx b/src/engine/ElementaryNode.hxx index 62d8e185d..091c7e98a 100644 --- a/src/engine/ElementaryNode.hxx +++ b/src/engine/ElementaryNode.hxx @@ -56,6 +56,7 @@ namespace YACS ElementaryNode(const std::string& name); ElementaryNode(const ElementaryNode& other, ComposedNode *father); void performDuplicationOfPlacement(const Node& other); + void performShallowDuplicationOfPlacement(const Node& other); public: virtual ~ElementaryNode(); void exUpdateState(); diff --git a/src/engine/HomogeneousPoolContainer.cxx b/src/engine/HomogeneousPoolContainer.cxx index c52f564e0..9471e7088 100644 --- a/src/engine/HomogeneousPoolContainer.cxx +++ b/src/engine/HomogeneousPoolContainer.cxx @@ -31,6 +31,15 @@ void HomogeneousPoolContainer::attachOnCloning() const _isAttachedOnCloning=true; } +void HomogeneousPoolContainer::setAttachOnCloningStatus(bool val) const +{ + _isAttachedOnCloning=true; + if(val) + return ; + else + throw Exception("An HomogeneousPoolContainer cannot be detached on cloning #2 !"); +} + void HomogeneousPoolContainer::dettachOnCloning() const { _isAttachedOnCloning=true; diff --git a/src/engine/HomogeneousPoolContainer.hxx b/src/engine/HomogeneousPoolContainer.hxx index b82d7d816..7ac8dec20 100644 --- a/src/engine/HomogeneousPoolContainer.hxx +++ b/src/engine/HomogeneousPoolContainer.hxx @@ -40,6 +40,7 @@ namespace YACS void attachOnCloning() const; void dettachOnCloning() const; bool isAttachedOnCloning() const; + void setAttachOnCloningStatus(bool val) const; // virtual void setSizeOfPool(int sz) = 0; virtual int getSizeOfPool() const = 0; diff --git a/src/engine/InlineNode.cxx b/src/engine/InlineNode.cxx index b2f4b757a..432d53efb 100644 --- a/src/engine/InlineNode.cxx +++ b/src/engine/InlineNode.cxx @@ -117,6 +117,17 @@ void InlineNode::performDuplicationOfPlacement(const Node& other) _container=otherC._container->clone(); } +void InlineNode::performShallowDuplicationOfPlacement(const Node& other) +{ + const InlineNode &otherC=*(dynamic_cast(&other)); + //if other has no container don't clone: this will not have one + if(otherC._container) + { + _container=otherC._container; + _container->incrRef(); + } +} + bool InlineNode::isDeployable() const { if(_mode=="remote") diff --git a/src/engine/InlineNode.hxx b/src/engine/InlineNode.hxx index 402eafe0e..bae4ab31e 100644 --- a/src/engine/InlineNode.hxx +++ b/src/engine/InlineNode.hxx @@ -65,6 +65,7 @@ namespace YACS virtual void setContainer(Container* container); virtual Container* getContainer(); void performDuplicationOfPlacement(const Node& other); + void performShallowDuplicationOfPlacement(const Node& other); bool isDeployable() const; protected: std::string _script; diff --git a/src/engine/Node.cxx b/src/engine/Node.cxx index b8c40da7f..31c2df78e 100644 --- a/src/engine/Node.cxx +++ b/src/engine/Node.cxx @@ -107,13 +107,49 @@ void Node::init(bool start) setState(YACS::READY); } +/*! + * This method clones \a this by : + * + * - deep copying nodes, links, ports, types + * - containers are either deep copied or shallow copied depending on _isAttachedOnCloning attribute. + * - component are either deep copied or shallow copied depending on _isAttachedOnCloning attribute. + * + * So \b this \b method \b clone \b is \b dedicated \b for \b DynParaLoop \b class \b or \b subclasses. + * It \b should \b not \b be \b used \b elsewhere, because + * _isAttachedOnCloning attribute is an attribute in the engine not for GUI/TUI aspects. + * For GUI/TUI manipulation cloneWithoutCompAndContDeepCpy method should be used preferably. + * + * \param [in] father - The new father of the returned clone. + * \param [in] editionOnly ignored + * + * \sa cloneWithoutCompAndContDeepCpy + */ Node *Node::clone(ComposedNode *father, bool editionOnly) const { - Node *ret=simpleClone(father,editionOnly); + Node *ret(simpleClone(father,editionOnly)); ret->performDuplicationOfPlacement(*this); return ret; } +/*! + * This method clones \a this by : + * - deep copying nodes, links, ports, types + * - shallow copy containers + * - shallow copy components + * + * So this method simply ignores isAttachedOnCloning attribute for both containers and components. + * So this method is dedicated for the GUI/TUI users. + * + * \param [in] father - The new father of the returned clone. + * \param [in] editionOnly ignored + */ +Node *Node::cloneWithoutCompAndContDeepCpy(ComposedNode *father, bool editionOnly) const +{ + Node *ret(simpleClone(father,editionOnly)); + ret->performShallowDuplicationOfPlacement(*this); + return ret; +} + //! Change the name of the node /*! * raise an exception if the name is already used in the scope of its father diff --git a/src/engine/Node.hxx b/src/engine/Node.hxx index caff230d9..4101ec559 100644 --- a/src/engine/Node.hxx +++ b/src/engine/Node.hxx @@ -91,7 +91,10 @@ namespace YACS protected: Node(const std::string& name); Node(const Node& other, ComposedNode *father); + //! performs a duplication of placement using clone method of containers and components. clone behaviour is driven by attachOnCloning attribute. virtual void performDuplicationOfPlacement(const Node& other) = 0; + //! performs a also duplication of placement but here containers and components are not copied at all whatever the value of attachedOnCloning. + virtual void performShallowDuplicationOfPlacement(const Node& other) = 0; virtual Node *simpleClone(ComposedNode *father, bool editionOnly=true) const = 0; public: virtual ~Node(); @@ -100,6 +103,8 @@ namespace YACS virtual void resetState(int level); //! \b This method \b MUST \b NEVER \b BE \b VIRTUAL Node *clone(ComposedNode *father, bool editionOnly=true) const; + //! \b This method \b MUST \b NEVER \b BE \b VIRTUAL + Node *cloneWithoutCompAndContDeepCpy(ComposedNode *father, bool editionOnly=true) const; void setState(YACS::StatesForNode theState); // To centralize state changes virtual YACS::StatesForNode getState() const { return _state; } virtual YACS::StatesForNode getEffectiveState() const; diff --git a/src/engine/ServerNode.cxx b/src/engine/ServerNode.cxx index 203651de4..9c5feef42 100644 --- a/src/engine/ServerNode.cxx +++ b/src/engine/ServerNode.cxx @@ -31,14 +31,6 @@ ServerNode::ServerNode(const ServerNode& other, ComposedNode *father):InlineFunc { } -void ServerNode::performDuplicationOfPlacement(const Node& other) -{ - const ServerNode &otherC=*(dynamic_cast(&other)); - //if other has no container don't clone: this will not have one - if(otherC._container) - _container=otherC._container->clone(); -} - void ServerNode::load() { if(_container) diff --git a/src/engine/ServerNode.hxx b/src/engine/ServerNode.hxx index cf6eed064..9e871256b 100644 --- a/src/engine/ServerNode.hxx +++ b/src/engine/ServerNode.hxx @@ -37,7 +37,6 @@ namespace YACS public: ServerNode(const std::string& name); ServerNode(const ServerNode& other, ComposedNode *father); - void performDuplicationOfPlacement(const Node& other); void load(); void accept(Visitor *visitor); virtual ServerNode *createNode(const std::string& name) const = 0; diff --git a/src/engine/ServiceNode.cxx b/src/engine/ServiceNode.cxx index 6d4b167cd..a0192b979 100644 --- a/src/engine/ServiceNode.cxx +++ b/src/engine/ServiceNode.cxx @@ -69,6 +69,17 @@ void ServiceNode::performDuplicationOfPlacement(const Node& other) _component=otherC._component->clone(); } +void ServiceNode::performShallowDuplicationOfPlacement(const Node& other) +{ + const ServiceNode &otherC=*(dynamic_cast(&other)); + //if other has no component don't clone: this will not have one + if(otherC._component) + { + _component=otherC._component; + _component->incrRef(); + } +} + ServiceNode::~ServiceNode() { if(_component) diff --git a/src/engine/ServiceNode.hxx b/src/engine/ServiceNode.hxx index 99bf25ee3..9ca48a8e7 100644 --- a/src/engine/ServiceNode.hxx +++ b/src/engine/ServiceNode.hxx @@ -37,6 +37,7 @@ namespace YACS ServiceNode(const std::string& name); ServiceNode(const ServiceNode& other, ComposedNode *father); void performDuplicationOfPlacement(const Node& other); + void performShallowDuplicationOfPlacement(const Node& other); public: virtual void load(); virtual bool isDeployable() const; diff --git a/src/engine/Test/ComponentInstanceTest.cxx b/src/engine/Test/ComponentInstanceTest.cxx index 6d1330d5e..fe9d055cd 100644 --- a/src/engine/Test/ComponentInstanceTest.cxx +++ b/src/engine/Test/ComponentInstanceTest.cxx @@ -74,6 +74,11 @@ ComponentInstance *ComponentInstanceTest1::clone() const return new ComponentInstanceTest1(*this); } +ComponentInstance *ComponentInstanceTest1::cloneAlways() const +{ + return new ComponentInstanceTest1(*this); +} + ComponentInstanceTest2::ComponentInstanceTest2(const ComponentInstanceTest2& other):ComponentInstance(other),_loaded(false) { } @@ -124,3 +129,8 @@ ComponentInstance *ComponentInstanceTest2::clone() const else return new ComponentInstanceTest2(*this); } + +ComponentInstance *ComponentInstanceTest2::cloneAlways() const +{ + return new ComponentInstanceTest2(*this); +} diff --git a/src/engine/Test/ComponentInstanceTest.hxx b/src/engine/Test/ComponentInstanceTest.hxx index 043226356..c401a0fde 100644 --- a/src/engine/Test/ComponentInstanceTest.hxx +++ b/src/engine/Test/ComponentInstanceTest.hxx @@ -38,6 +38,7 @@ namespace YACS std::string getKindForNode() const; ServiceNode* createNode(const std::string& name); ComponentInstance *clone() const; + ComponentInstance *cloneAlways() const; protected: bool _loaded; }; @@ -54,6 +55,7 @@ namespace YACS std::string getKindForNode() const; ServiceNode* createNode(const std::string& name); ComponentInstance *clone() const; + ComponentInstance *cloneAlways() const; protected: bool _loaded; }; diff --git a/src/engine/VisitorSaveSchema.cxx b/src/engine/VisitorSaveSchema.cxx index 28816d983..e1bb320dd 100644 --- a/src/engine/VisitorSaveSchema.cxx +++ b/src/engine/VisitorSaveSchema.cxx @@ -701,10 +701,15 @@ void VisitorSaveSchema::writeContainers(Proc *proc) string name = it->first; _out << indent(depth) << "" << endl; _out << indent(depth+1) << "second->getKind() << "\"/>" << endl; + _out << indent(depth+1) << "second->isAttachedOnCloning() << "\"/>" << endl; map properties = (it->second)->getProperties(); map::iterator itm; for(itm = properties.begin(); itm != properties.end(); ++itm) { + if((*itm).first==Container::KIND_ENTRY) + continue; + if((*itm).first==Container::AOC_ENTRY) + continue; if((*itm).first!=HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY) { _out << indent(depth+1) << "" << endl; diff --git a/src/engine_swig/pilot.i b/src/engine_swig/pilot.i index a9b18013c..6262f4773 100644 --- a/src/engine_swig/pilot.i +++ b/src/engine_swig/pilot.i @@ -170,6 +170,7 @@ REFCOUNT_TEMPLATE(CompoInstmap,YACS::ENGINE::ComponentInstance) %newobject *::createOutputDataStreamPort; %newobject *::clone; %newobject *::cloneAlways; +%newobject *::cloneWithoutCompAndContDeepCpy; %newobject *::New; //Take ownership : transfer it from C++ (has to be completed) diff --git a/src/genericgui/CMakeLists.txt b/src/genericgui/CMakeLists.txt index af8f6b074..411231c3b 100644 --- a/src/genericgui/CMakeLists.txt +++ b/src/genericgui/CMakeLists.txt @@ -73,6 +73,9 @@ SET(_link_LIBRARIES SET(_uic_files FormComponent.ui FormContainer.ui + FormAdvParamContainer.ui + FormParamContainer.ui + FormHPContainer.ui FormEachLoop.ui FormEditItem.ui FormEditTree.ui @@ -118,7 +121,11 @@ SET(_moc_HEADERS EditionSwitch.hxx EditionWhile.hxx FormComponent.hxx + FormContainerBase.hxx FormContainer.hxx + FormHPContainer.hxx + FormAdvParamContainer.hxx + FormContainerDecorator.hxx FormEachLoop.hxx FormEditItem.hxx FormEditTree.hxx @@ -174,7 +181,7 @@ SET(GenericGui_SOURCES EditionComponent.hxx EditionComponent.cxx EditionContainer.hxx - EditionContainer.cxx + EditionContainer.cxx EditionControlLink.hxx EditionControlLink.cxx EditionDataLink.hxx @@ -218,7 +225,15 @@ SET(GenericGui_SOURCES FormComponent.hxx FormComponent.cxx FormContainer.hxx - FormContainer.cxx + FormContainer.cxx + FormHPContainer.hxx + FormHPContainer.cxx + FormContainerBase.hxx + FormContainerBase.cxx + FormAdvParamContainer.hxx + FormAdvParamContainer.cxx + FormContainerDecorator.hxx + FormContainerDecorator.cxx FormEachLoop.hxx FormEachLoop.cxx FormEditItem.hxx diff --git a/src/genericgui/EditionComponent.cxx b/src/genericgui/EditionComponent.cxx index ea0eea506..7a14c3b0f 100644 --- a/src/genericgui/EditionComponent.cxx +++ b/src/genericgui/EditionComponent.cxx @@ -104,7 +104,7 @@ void EditionComponent::changeContainer(int index) return; } Container *newContainer =proc->containerMap[contName]; - SubjectContainer *scnt = GuiContext::getCurrent()->_mapOfSubjectContainer[newContainer]; + SubjectContainerBase *scnt = GuiContext::getCurrent()->_mapOfSubjectContainer[newContainer]; scompo->associateToContainer(scnt); scompo->select(true); } diff --git a/src/genericgui/EditionContainer.cxx b/src/genericgui/EditionContainer.cxx index 18d026834..f42585b88 100644 --- a/src/genericgui/EditionContainer.cxx +++ b/src/genericgui/EditionContainer.cxx @@ -22,7 +22,7 @@ //#define _DEVDEBUG_ #include "YacsTrace.hxx" -#include "FormContainer.hxx" +#include "FormContainerDecorator.hxx" #include "QtGuiContext.hxx" #include "guiObservers.hxx" #include "Proc.hxx" @@ -36,17 +36,12 @@ using namespace YACS; using namespace YACS::HMI; using namespace YACS::ENGINE; -EditionContainer::EditionContainer(Subject* subject, - QWidget* parent, - const char* name) - : ItemEdition(subject, parent, name) +EditionContainer::EditionContainer(Subject* subject, QWidget* parent, const char* name):ItemEdition(subject, parent, name) { - _wContainer = new FormContainer(this); + _wContainer = new FormContainerDecorator(getContainer(),this); _wid->gridLayout1->addWidget(_wContainer); - connect(_wContainer->cb_resource, SIGNAL(mousePressed()), - this, SLOT(fillContainerPanel())); - connect(_wContainer->tb_container, SIGNAL(toggled(bool)), - this, SLOT(fillContainerPanel())); // --- to update display of current selection + connect(_wContainer, SIGNAL(resourceMousePressed()), this, SLOT(fillContainerPanel())); + connect(_wContainer->tb_container, SIGNAL(toggled(bool)), this, SLOT(fillContainerPanel())); // --- to update display of current selection _wContainer->tb_container->toggle(); } @@ -62,7 +57,7 @@ void EditionContainer::update(GuiEvent event, int type, Subject* son) { case RENAME: case UPDATE: - _wContainer->le_name->setText((son->getName()).c_str()); + _wContainer->setName(son->getName()); fillContainerPanel(); break; default: @@ -73,9 +68,7 @@ void EditionContainer::update(GuiEvent event, int type, Subject* son) void EditionContainer::fillContainerPanel() { DEBTRACE("EditionContainer::fillContainerPanel"); - SubjectContainer *scont = dynamic_cast(_subject); - YASSERT(scont); - _wContainer->FillPanel(scont->getContainer()); + _wContainer->FillPanel(getContainer()); } void EditionContainer::onApply() @@ -99,3 +92,10 @@ void EditionContainer::onCancel() _wContainer->onCancel(); ItemEdition::onCancel(); } + +YACS::ENGINE::Container *EditionContainer::getContainer() +{ + SubjectContainerBase *scont(dynamic_cast(_subject)); + YASSERT(scont); + return scont->getContainer(); +} diff --git a/src/genericgui/EditionContainer.hxx b/src/genericgui/EditionContainer.hxx index 51f8ccc56..f9922cbd5 100644 --- a/src/genericgui/EditionContainer.hxx +++ b/src/genericgui/EditionContainer.hxx @@ -22,7 +22,7 @@ #include "ItemEdition.hxx" -class FormContainer; +class FormContainerDecorator; namespace YACS { @@ -45,8 +45,12 @@ namespace YACS virtual void onApply(); virtual void onCancel(); + private: + + YACS::ENGINE::Container *getContainer(); + protected: - FormContainer *_wContainer; + FormContainerDecorator *_wContainer; }; } } diff --git a/src/genericgui/EditionSalomeNode.cxx b/src/genericgui/EditionSalomeNode.cxx index 00267fda6..6ea6f0cf9 100644 --- a/src/genericgui/EditionSalomeNode.cxx +++ b/src/genericgui/EditionSalomeNode.cxx @@ -45,22 +45,23 @@ EditionSalomeNode::EditionSalomeNode(Subject* subject, const char* name) : EditionElementaryNode(subject, parent, name) { - + // SubjectServiceNode *ssn = dynamic_cast(_subject); + // YASSERT(ssn); + _servNode = dynamic_cast(_subElemNode->getNode()); + YASSERT(_servNode); // --- create property editor panel _propeditor=new PropertyEditor(_subject); _wid->gridLayout1->addWidget(_propeditor); // --- create container and component panels - _wContainer = new FormContainer(this); + _wContainer = new FormContainerDecorator(_servNode->getContainer(),this); _wid->gridLayout1->addWidget(_wContainer); - connect(_wContainer->cb_resource, SIGNAL(mousePressed()), - this, SLOT(fillContainerPanel())); - connect(_wContainer->cb_resource, SIGNAL(activated(int)), - this, SLOT(changeHost(int))); - connect(_wContainer->tb_container, SIGNAL(toggled(bool)), - this, SLOT(fillContainerPanel())); // --- to update display of current selection + connect(_wContainer, SIGNAL(resourceMousePressed()), this, SLOT(fillContainerPanel())); + connect(_wContainer, SIGNAL(resourceActivated(int)), this, SLOT(changeHost(int))); + connect(_wContainer, SIGNAL(containerToggled(bool)), this, SLOT(fillContainerPanel())); + // --- to update display of current selection _wComponent = new FormComponent(this); _wid->gridLayout1->addWidget(_wComponent); @@ -89,11 +90,7 @@ EditionSalomeNode::EditionSalomeNode(Subject* subject, _hbl_method->addWidget(_le_method); _wid->gridLayout1->addLayout(_hbl_method, _wid->gridLayout1->rowCount(), 0, 1, 1); _la_method->setText("Method:"); -// SubjectServiceNode *ssn = dynamic_cast(_subject); -// YASSERT(ssn); - _servNode = - dynamic_cast(_subElemNode->getNode()); - YASSERT(_servNode); + _le_method->setText((_servNode->getMethod()).c_str()); _le_method->setReadOnly(true); @@ -141,7 +138,7 @@ void EditionSalomeNode::update(GuiEvent event, int type, Subject* son) void EditionSalomeNode::synchronize() { EditionElementaryNode::synchronize(); - _wContainer->tb_container->setChecked(FormContainer::_checked); + _wContainer->synchronizeCheckContainer(); _wComponent->tb_component->setChecked(FormComponent::_checked); fillComponentPanel(); fillContainerPanel(); @@ -235,18 +232,17 @@ void EditionSalomeNode::changeContainer(int index) return; } YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(newContainer)); - SubjectContainer *scnt = GuiContext::getCurrent()->_mapOfSubjectContainer[newContainer]; + SubjectContainerBase *scnt(GuiContext::getCurrent()->_mapOfSubjectContainer[newContainer]); - SubjectServiceNode *ssn = dynamic_cast(_subject); - SubjectComponent *sco = - dynamic_cast(ssn->getSubjectReference()->getReference()); + SubjectServiceNode *ssn(dynamic_cast(_subject)); + SubjectComponent *sco(dynamic_cast(ssn->getSubjectReference()->getReference())); YASSERT(sco); sco->associateToContainer(scnt); } void EditionSalomeNode::changeHost(int index) { - string hostName = _wContainer->cb_resource->itemText(index).toStdString(); + string hostName = _wContainer->getHostName(index); DEBTRACE(hostName); } diff --git a/src/genericgui/EditionSalomeNode.hxx b/src/genericgui/EditionSalomeNode.hxx index 3cae9d6af..ff48edf41 100644 --- a/src/genericgui/EditionSalomeNode.hxx +++ b/src/genericgui/EditionSalomeNode.hxx @@ -21,6 +21,7 @@ #define _EDITIONSALOMENODE_HXX_ #include "EditionElementaryNode.hxx" +#include "FormContainerDecorator.hxx" #include #include #include @@ -67,7 +68,7 @@ namespace YACS protected: PropertyEditor* _propeditor; FormComponent *_wComponent; - FormContainer *_wContainer; + FormContainerDecorator *_wContainer; QHBoxLayout *_hbl_method; QLabel *_la_method; QLineEdit *_le_method; diff --git a/src/genericgui/EditionScript.cxx b/src/genericgui/EditionScript.cxx index 0012a4635..41d5968a0 100644 --- a/src/genericgui/EditionScript.cxx +++ b/src/genericgui/EditionScript.cxx @@ -137,9 +137,12 @@ EditionScript::EditionScript(Subject* subject, hboxLayout2->addWidget(cb_container); _portslayout->addWidget(fr_container); - formcontainer = new FormContainer(this); - formcontainer->on_tb_container_toggled(false); + // + YACS::ENGINE::InlineNode *pyNode(dynamic_cast(_subInlineNode->getNode())); + YACS::ENGINE::Container *cont(pyNode->getContainer()); + formcontainer = new FormContainerDecorator(cont,this); _portslayout->addWidget(formcontainer); + //_portslayout->addWidget(formcontainer->getWidget()); //end of insertion of execution mode createTablePorts(_portslayout); @@ -327,10 +330,11 @@ void EditionScript::on_tb_options_toggled(bool checked) if(_checked) { fr_options->show(); - if(_remote) { - fr_container->show(); - formcontainer->show(); - } + if(_remote) + { + fr_container->show(); + formcontainer->show(); + } } else { @@ -409,7 +413,7 @@ void EditionScript::changeContainer(int index) return; } YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(newContainer)); - SubjectContainer *scnt = GuiContext::getCurrent()->_mapOfSubjectContainer[newContainer]; + SubjectContainerBase *scnt(GuiContext::getCurrent()->_mapOfSubjectContainer[newContainer]); _subInlineNode->setContainer(scnt); diff --git a/src/genericgui/EditionScript.hxx b/src/genericgui/EditionScript.hxx index 0055f285a..935a7bdf6 100644 --- a/src/genericgui/EditionScript.hxx +++ b/src/genericgui/EditionScript.hxx @@ -22,6 +22,7 @@ #include "yacsconfig.h" #include "EditionElementaryNode.hxx" +#include "FormContainerDecorator.hxx" #include "FormComponent.hxx" #include @@ -75,7 +76,7 @@ namespace YACS ComboBox* cb_container; QRadioButton* radiolocal; QRadioButton* radioremote; - FormContainer* formcontainer; + FormContainerDecorator* formcontainer; }; } } diff --git a/src/genericgui/FormAdvParamContainer.cxx b/src/genericgui/FormAdvParamContainer.cxx new file mode 100644 index 000000000..4785b8b33 --- /dev/null +++ b/src/genericgui/FormAdvParamContainer.cxx @@ -0,0 +1,534 @@ +// Copyright (C) 2006-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "FormAdvParamContainer.hxx" +#include "FormComponent.hxx" +#include "QtGuiContext.hxx" +#include "Container.hxx" + +#include +#include +#include + +//#define _DEVDEBUG_ +#include "YacsTrace.hxx" + +#include +#include + +using namespace std; +using namespace YACS; +using namespace YACS::HMI; +using namespace YACS::ENGINE; + +FormAdvParamContainer::FormAdvParamContainer(std::map& prop, QWidget *parent):QWidget(parent),_properties(prop) +{ + setupUi(this); + sb_mem->setMaximum(INT_MAX); + sb_cpu->setMaximum(INT_MAX); + sb_nbNodes->setMaximum(INT_MAX); + sb_procNode->setMaximum(INT_MAX); + sb_nbprocpar->setMaximum(INT_MAX); + sb_nbproc->setMaximum(INT_MAX); + + FillPanel("",0); // --- set widgets before signal connexion to avoid false modif detection + + connect(cb_policy, SIGNAL(activated(const QString&)), this, SLOT(onModifyPolicy(const QString&))); + connect(cb_parallel, SIGNAL(activated(const QString&)), this, SLOT(onModifyParLib(const QString&))); + connect(le_workdir, SIGNAL(textChanged(const QString&)), this, SLOT(onModifyWorkDir(const QString&))); + connect(le_contname, SIGNAL(textChanged(const QString&)), this, SLOT(onModifyContName(const QString&))); + connect(le_os, SIGNAL(textChanged(const QString&)), this, SLOT(onModifyOS(const QString&))); + connect(le_hostname, SIGNAL(textChanged(const QString&)), this, SLOT(onModifyHostName(const QString&))); + connect(le_compolist, SIGNAL(textChanged(const QString&)), this, SLOT(onModifyCompoList(const QString&))); + connect(le_resourceList, SIGNAL(textChanged(const QString&)), this, SLOT(onModifyResourceList(const QString&))); + connect(ch_mpi, SIGNAL(clicked(bool)), this, SLOT(onModifyIsMPI(bool))); + connect(sb_mem, SIGNAL(valueChanged(const QString&)), this, SLOT(onModifyMem(const QString&))); + connect(sb_cpu, SIGNAL(valueChanged(const QString&)), this, SLOT(onModifyClock(const QString&))); + connect(sb_nbNodes, SIGNAL(valueChanged(const QString&)), this, SLOT(onModifyNodes(const QString&))); + connect(sb_procNode, SIGNAL(valueChanged(const QString&)), this, SLOT(onModifyProcs(const QString&))); + connect(sb_nbprocpar, SIGNAL(valueChanged(const QString&)), this, SLOT(onModifyProcPar(const QString&))); + connect(sb_nbproc, SIGNAL(valueChanged(const QString&)), this, SLOT(onModifyProcRes(const QString&))); +} + +FormAdvParamContainer::~FormAdvParamContainer() +{ +} + +void FormAdvParamContainer::FillPanel(const std::string& resource, YACS::ENGINE::Container *container) +{ + DEBTRACE("FormContainer::FillPanel"); + _container = container; + if (_container) + { + _properties = _container->getProperties(); + } + else + { + _properties.clear(); + } + + if(_properties.count("type") && _properties["type"]=="multi") + cb_mode->setText("multi"); + else + cb_mode->setText("mono"); + + vector parlibs; + parlibs.push_back(""); + parlibs.push_back("Mpi"); + parlibs.push_back("Dummy"); + cb_parallel->clear(); + for(int i=0; i< parlibs.size(); i++) + cb_parallel->addItem(parlibs[i].c_str()); + if(_properties.count("parallelLib")) + { + int i=0; + for(i=0; i< parlibs.size(); i++) + if(parlibs[i] == _properties["parallelLib"]) + { + cb_parallel->setCurrentIndex(i); + break; + } + } + else + cb_parallel->setCurrentIndex(0); + + if(_properties.count("workingdir")) + le_workdir->setText(_properties["workingdir"].c_str()); + else + le_workdir->setText(""); + + if(_properties.count("container_name")) + le_contname->setText(_properties["container_name"].c_str()); + else + le_contname->setText(""); + + if(_properties.count("isMPI")) + { + DEBTRACE("_properties[isMPI]=" << _properties["isMPI"]); + if ((_properties["isMPI"] == "0") || (_properties["isMPI"] == "false")) + ch_mpi->setCheckState(Qt::Unchecked); + else + ch_mpi->setCheckState(Qt::Checked); + } + else + ch_mpi->setCheckState(Qt::Unchecked); + + if(_properties.count("nb_parallel_procs")) + sb_nbprocpar->setValue(atoi(_properties["nb_parallel_procs"].c_str())); + else + sb_nbprocpar->setValue(0); + + updateResource(resource); + + if (!QtGuiContext::getQtCurrent()->isEdition()) + { + //if the schema is in execution do not allow editing + cb_parallel->setEnabled(false); + le_workdir->setReadOnly(true); + le_contname->setReadOnly(true); + ch_mpi->setEnabled(false); + sb_nbprocpar->setReadOnly(true); + le_hostname->setEnabled(false); + le_os->setEnabled(false); + sb_nbproc->setEnabled(false); + sb_mem->setEnabled(false); + sb_cpu->setEnabled(false); + sb_nbNodes->setEnabled(false); + sb_procNode->setEnabled(false); + cb_policy->setEnabled(false); + le_compolist->setEnabled(false); + le_resourceList->setEnabled(false); + } +} + +void FormAdvParamContainer::onModified() +{ + DEBTRACE("FormContainer::onModified"); + Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject(); + if (!sub) return; + YASSERT(QtGuiContext::getQtCurrent()->_mapOfEditionItem.count(sub)); + QWidget *widget = QtGuiContext::getQtCurrent()->_mapOfEditionItem[sub]; + ItemEdition *item = dynamic_cast(widget); + YASSERT(item); + item->setEdited(true); +} + +void FormAdvParamContainer::updateResource(const std::string &resource) +{ + DEBTRACE("FormContainer::updateResource " << resource); + if(resource.empty()) + { + //the resource is not specified: use automatic and allow editing + if(_properties.count("hostname")) + le_hostname->setText(_properties["hostname"].c_str()); + else + le_hostname->setText(""); + le_hostname->setEnabled(true); + + if(_properties.count("OS")) + le_os->setText(_properties["OS"].c_str()); + else + le_os->setText(""); + le_os->setEnabled(true); + + if(_properties.count("nb_resource_procs")) + sb_nbproc->setValue(atoi(_properties["nb_resource_procs"].c_str())); + else + sb_nbproc->setValue(0); + sb_nbproc->setEnabled(true); + + if(_properties.count("mem_mb")) + sb_mem->setValue(atoi(_properties["mem_mb"].c_str())); + else + sb_mem->setValue(0); + sb_mem->setEnabled(true); + + if(_properties.count("cpu_clock")) + sb_cpu->setValue(atoi(_properties["cpu_clock"].c_str())); + else + sb_cpu->setValue(0); + sb_cpu->setEnabled(true); + + if(_properties.count("nb_node")) + sb_nbNodes->setValue(atoi(_properties["nb_node"].c_str())); + else + sb_nbNodes->setValue(0); + sb_nbNodes->setEnabled(true); + + if(_properties.count("nb_proc_per_node")) + sb_procNode->setValue(atoi(_properties["nb_proc_per_node"].c_str())); + else + sb_procNode->setValue(0); + sb_procNode->setEnabled(true); + + std::vector policies; + policies.push_back("cycl"); + policies.push_back("altcycl"); + policies.push_back("best"); + policies.push_back("first"); + cb_policy->clear(); + for(int i=0; i< policies.size(); i++) + cb_policy->addItem(policies[i].c_str()); + if(_properties.count("policy")) + { + int i=0; + for(i=0; i< policies.size(); i++) + if(policies[i] == _properties["policy"]) + { + cb_policy->setCurrentIndex(i); + break; + } + } + else + cb_policy->setCurrentIndex(1); + cb_policy->setEnabled(true); + + if(_properties.count("component_list")) + le_compolist->setText(_properties["component_list"].c_str()); + else + le_compolist->setText(""); + le_compolist->setEnabled(true); + + if(_properties.count("resource_list")) + le_resourceList->setText(_properties["resource_list"].c_str()); + else + le_resourceList->setText(""); + le_resourceList->setEnabled(true); + } + else + { + //a specific resource has been chosen: properties are those declared in the resources manager + //properties can not be edited + std::map properties(_container->getResourceProperties(resource)); + if(properties.count("hostname")) + le_hostname->setText(properties["hostname"].c_str()); + else + le_hostname->setText(""); + le_hostname->setEnabled(false); + + if(properties.count("OS")) + le_os->setText(properties["OS"].c_str()); + else + le_os->setText(""); + le_os->setEnabled(false); + + if(properties.count("nb_resource_procs")) + sb_nbproc->setValue(atoi(properties["nb_resource_procs"].c_str())); + else + sb_nbproc->setValue(0); + sb_nbproc->setEnabled(false); + + if(properties.count("mem_mb")) + sb_mem->setValue(atoi(properties["mem_mb"].c_str())); + else + sb_mem->setValue(0); + sb_mem->setEnabled(false); + + if(properties.count("cpu_clock")) + sb_cpu->setValue(atoi(properties["cpu_clock"].c_str())); + else + sb_cpu->setValue(0); + sb_cpu->setEnabled(false); + + if(properties.count("nb_node")) + sb_nbNodes->setValue(atoi(properties["nb_node"].c_str())); + else + sb_nbNodes->setValue(0); + sb_nbNodes->setEnabled(false); + + if(properties.count("nb_proc_per_node")) + sb_procNode->setValue(atoi(properties["nb_proc_per_node"].c_str())); + else + sb_procNode->setValue(0); + sb_procNode->setEnabled(false); + + cb_policy->clear(); + cb_policy->setEnabled(false); + + if(properties.count("component_list")) + le_compolist->setText(properties["component_list"].c_str()); + else + le_compolist->setText(""); + le_compolist->setEnabled(false); + + if(properties.count("resource_list")) + le_resourceList->setText(properties["resource_list"].c_str()); + else + le_resourceList->setText(""); + le_resourceList->setEnabled(false); + } +} + +void FormAdvParamContainer::setModeText(const std::string& mode) +{ + cb_mode->setText(mode.c_str()); +} + +void FormAdvParamContainer::onModifyResource(const QString &text) +{ + DEBTRACE("onModifyResource " << text.toStdString()); + if (!_container) return; + std::string resource=text.toStdString(); + if(resource=="automatic")resource=""; + map properties = _container->getProperties(); + _properties["name"] = resource; + if (properties["name"] != resource) + { + // reset resource properties + _properties.erase("hostname"); + _properties.erase("OS"); + _properties.erase("nb_resource_procs"); + _properties.erase("mem_mb"); + _properties.erase("cpu_clock"); + _properties.erase("nb_node"); + _properties.erase("nb_proc_per_node"); + _properties.erase("policy"); + onModified(); + updateResource(resource); + } +} + +void FormAdvParamContainer::onModifyPolicy(const QString &text) +{ + DEBTRACE("onModifyPolicy " << text.toStdString()); + if (!_container) return; + if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set + map properties = _container->getProperties(); + _properties["policy"] = text.toStdString(); + if (properties["policy"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyWorkDir(const QString &text) +{ + DEBTRACE("onModifyWorkDir " << text.toStdString()); + if (!_container) return; + map properties = _container->getProperties(); + _properties["workingdir"] = text.toStdString(); + if (properties["workingdir"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyContName(const QString &text) +{ + DEBTRACE("onModifyContName " << text.toStdString()); + if (!_container) return; + map properties = _container->getProperties(); + _properties["container_name"] = text.toStdString(); + if (properties["container_name"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyOS(const QString &text) +{ + DEBTRACE("onModifyOS " << text.toStdString()); + if (!_container) return; + if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set + map properties = _container->getProperties(); + _properties["OS"] = text.toStdString(); + if (properties["OS"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyParLib(const QString &text) +{ + DEBTRACE("onModifyParLib " << text.toStdString()); + if (!_container) return; + map properties = _container->getProperties(); + _properties["parallelLib"] = text.toStdString(); + if (properties["parallelLib"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyIsMPI(bool isMpi) +{ + DEBTRACE("onModifyIsMPI " << isMpi); + if (!_container) return; + string text = "false"; + if (isMpi) text = "true"; + DEBTRACE(text); + map properties = _container->getProperties(); + _properties["isMPI"] = text; + if (properties["isMPI"] != text) + onModified(); +} + +void FormAdvParamContainer::onModifyMem(const QString &text) +{ + DEBTRACE("onModifyMem " << text.toStdString()); + if (!_container) return; + if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set + map properties = _container->getProperties(); + if(properties.count("mem_mb")==0 )properties["mem_mb"]="0"; //default value + _properties["mem_mb"] = text.toStdString(); + if (properties["mem_mb"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyClock(const QString &text) +{ + DEBTRACE("onModifyClock " << text.toStdString()); + if (!_container) return; + if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set + map properties = _container->getProperties(); + if(properties.count("cpu_clock")==0 )properties["cpu_clock"]="0"; //default value + _properties["cpu_clock"] = text.toStdString(); + if (properties["cpu_clock"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyNodes(const QString &text) +{ + DEBTRACE("onModifyNodes " << text.toStdString()); + if (!_container) return; + if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set + map properties = _container->getProperties(); + if(properties.count("nb_node")==0 )properties["nb_node"]="0"; //default value + _properties["nb_node"] = text.toStdString(); + if (properties["nb_node"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyProcs(const QString &text) +{ + DEBTRACE("onModifyProcs " << text.toStdString()); + if (!_container) return; + if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set + map properties = _container->getProperties(); + if(properties.count("nb_proc_per_node")==0 )properties["nb_proc_per_node"]="0"; //default value + _properties["nb_proc_per_node"] = text.toStdString(); + if (properties["nb_proc_per_node"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyCompos(const QString &text) +{ + DEBTRACE("onModifyCompo " << text.toStdString()); + if (!_container) return; + map properties = _container->getProperties(); + _properties["nb_component_nodes"] = text.toStdString(); + if (properties["nb_component_nodes"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyProcPar(const QString &text) +{ + DEBTRACE("onModifyProcPar " << text.toStdString()); + if (!_container) return; + map properties = _container->getProperties(); + _properties["nb_parallel_procs"] = text.toStdString(); + if (properties["nb_parallel_procs"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyResourceName(const QString &text) +{ + DEBTRACE("onModifyResourceName " << text.toStdString()); + if (!_container) return; + map properties = _container->getProperties(); + _properties["resource_name"] = text.toStdString(); + if (properties["resource_name"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyHostName(const QString &text) +{ + DEBTRACE("onModifyHostName " << text.toStdString()); + if (!_container) return; + if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set + + map properties = _container->getProperties(); + _properties["hostname"] = text.toStdString(); + if (properties["hostname"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyProcRes(const QString &text) +{ + DEBTRACE("onModifyProcRes " << text.toStdString()); + if (!_container) return; + if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set + map properties = _container->getProperties(); + if(properties.count("nb_resource_procs")==0 )properties["nb_resource_procs"]="0"; //default value + _properties["nb_resource_procs"] = text.toStdString(); + if (properties["nb_resource_procs"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyCompoList(const QString &text) +{ + DEBTRACE("onModifyCompoList " << text.toStdString()); + if (!_container) return; + if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set + map properties = _container->getProperties(); + _properties["component_list"] = text.toStdString(); + if (properties["component_list"] != text.toStdString()) + onModified(); +} + +void FormAdvParamContainer::onModifyResourceList(const QString &text) +{ + DEBTRACE("onModifyResourceList " << text.toStdString()); + if (!_container) return; + if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set + map properties = _container->getProperties(); + _properties["resource_list"] = text.toStdString(); + if (properties["resource_list"] != text.toStdString()) + onModified(); +} diff --git a/src/genericgui/FormAdvParamContainer.hxx b/src/genericgui/FormAdvParamContainer.hxx new file mode 100644 index 000000000..7e55cee8a --- /dev/null +++ b/src/genericgui/FormAdvParamContainer.hxx @@ -0,0 +1,80 @@ +// Copyright (C) 2006-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _FORMADVPARAMCONTAINER_HXX_ +#define _FORMADVPARAMCONTAINER_HXX_ + +#include "ui_FormAdvParamContainer.h" + +#include +#include +#include + +namespace YACS +{ + namespace ENGINE + { + class Container; + } +} + +class FormAdvParamContainer : public QWidget, public Ui::fm_advparamcontainer +{ + Q_OBJECT + +public: + FormAdvParamContainer(std::map& prop, QWidget *parent = 0); + virtual ~FormAdvParamContainer(); + + void FillPanel(const std::string& resource, YACS::ENGINE::Container *container); + virtual void onModified(); + void updateResource(const std::string &resource); + void setModeText(const std::string& mode); + +public slots: + void onModifyName(const QString &text); + void onModifyResource(const QString &text); + void onModifyPolicy(const QString &text); + void onModifyWorkDir(const QString &text); + void onModifyContName(const QString &text); + void onModifyOS(const QString &text); + void onModifyParLib(const QString &text); + void onModifyIsMPI(bool isMpi); + void onModifyMem(const QString &text); + void onModifyClock(const QString &text); + void onModifyNodes(const QString &text); + void onModifyProcs(const QString &text); + void onModifyCompos(const QString &text); + void onModifyProcPar(const QString &text); + void onModifyResourceName(const QString &text); + void onModifyHostName(const QString &text); + void onModifyProcRes(const QString &text); + void onModifyCompoList(const QString &text); + void onModifyResourceList(const QString &text); + + +protected: + bool _advanced; + YACS::ENGINE::Container *_container; + std::map& _properties; + +private: +}; + +#endif diff --git a/src/genericgui/FormAdvParamContainer.ui b/src/genericgui/FormAdvParamContainer.ui new file mode 100644 index 000000000..ac8225796 --- /dev/null +++ b/src/genericgui/FormAdvParamContainer.ui @@ -0,0 +1,419 @@ + + + fm_advparamcontainer + + + + 0 + 0 + 393 + 565 + + + + Form + + + + 2 + + + + + + 0 + 0 + + + + Parameters + + + + 2 + + + + + 1 + + + + Container + + + + + + container name: + + + + + + + name of the container when instanciated at runtime + + + + + + + mode: + + + + + + + working dir: + + + + + + + + + + Parallel parameters + + + + + + nb procs: + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Qt::RightToLeft + + + false + + + MPI container + + + + + + + PaCO++ lib: + + + + + + + false + + + + + + + Qt::Horizontal + + + + 50 + 20 + + + + + + + + + + + Qt::Vertical + + + + 20 + 168 + + + + + + + + true + + + + + + + + Resource + + + + + + hostname: + + + + + + + + + + O.S.: + + + + + + + + + + nb procs: + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + + + + mem mb: + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + required memory (megaBytes) + + + + + + + cpu clock: + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + required cpu clock frequency (MHz) + + + + + + + nb nodes: + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + + + + nb proc / node: + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + + + + policy: + + + + + + + + 0 + 0 + + + + Component list: + + + + + + + example: GEOM, SMESH + + + + + + + + 0 + 0 + + + + Restricted resource list: + + + + + + + example: machine1, machine2 + + + + + + + false + + + 3 + + + + + + + + + + + + + + + diff --git a/src/genericgui/FormContainer.cxx b/src/genericgui/FormContainer.cxx index 07598f87e..7e43deee4 100644 --- a/src/genericgui/FormContainer.cxx +++ b/src/genericgui/FormContainer.cxx @@ -18,104 +18,24 @@ // #include "FormContainer.hxx" -#include "FormComponent.hxx" -#include "QtGuiContext.hxx" +#include "FormAdvParamContainer.hxx" #include "Container.hxx" - -#include -#include -#include - //#define _DEVDEBUG_ #include "YacsTrace.hxx" +#include #include + #include using namespace std; -using namespace YACS; -using namespace YACS::HMI; -using namespace YACS::ENGINE; - -bool FormContainer::_checked = false; - -FormContainer::FormContainer(QWidget *parent) -{ - setupUi(this); - _advanced = false; - _properties.clear(); - - QIcon icon; - icon.addFile("icons:icon_down.png"); - icon.addFile("icons:icon_up.png", - QSize(), QIcon::Normal, QIcon::On); - tb_container->setIcon(icon); - on_tb_container_toggled(FormContainer::_checked); - on_ch_advance_stateChanged(0); - - sb_mem->setMaximum(INT_MAX); - sb_cpu->setMaximum(INT_MAX); - sb_nbNodes->setMaximum(INT_MAX); - sb_procNode->setMaximum(INT_MAX); - sb_nbprocpar->setMaximum(INT_MAX); - sb_nbproc->setMaximum(INT_MAX); - - - FillPanel(0); // --- set widgets before signal connexion to avoid false modif detection - - connect(le_name, SIGNAL(textChanged(const QString&)), - this, SLOT(onModifyName(const QString&))); - - connect(cb_resource, SIGNAL(activated(const QString&)), - this, SLOT(onModifyResource(const QString&))); - - connect(cb_policy, SIGNAL(activated(const QString&)), - this, SLOT(onModifyPolicy(const QString&))); - - connect(cb_type, SIGNAL(activated(const QString&)), - this, SLOT(onModifyType(const QString&))); - - connect(cb_parallel, SIGNAL(activated(const QString&)), - this, SLOT(onModifyParLib(const QString&))); - - connect(le_workdir, SIGNAL(textChanged(const QString&)), - this, SLOT(onModifyWorkDir(const QString&))); - - connect(le_contname, SIGNAL(textChanged(const QString&)), - this, SLOT(onModifyContName(const QString&))); - - connect(le_os, SIGNAL(textChanged(const QString&)), - this, SLOT(onModifyOS(const QString&))); - - connect(le_hostname, SIGNAL(textChanged(const QString&)), - this, SLOT(onModifyHostName(const QString&))); - connect(le_compolist, SIGNAL(textChanged(const QString&)), - this, SLOT(onModifyCompoList(const QString&))); - - connect(le_resourceList, SIGNAL(textChanged(const QString&)), - this, SLOT(onModifyResourceList(const QString&))); - - connect(ch_mpi, SIGNAL(clicked(bool)), - this, SLOT(onModifyIsMPI(bool))); - - connect(sb_mem, SIGNAL(valueChanged(const QString&)), - this, SLOT(onModifyMem(const QString&))); - - connect(sb_cpu, SIGNAL(valueChanged(const QString&)), - this, SLOT(onModifyClock(const QString&))); - - connect(sb_nbNodes, SIGNAL(valueChanged(const QString&)), - this, SLOT(onModifyNodes(const QString&))); - - connect(sb_procNode, SIGNAL(valueChanged(const QString&)), - this, SLOT(onModifyProcs(const QString&))); - - connect(sb_nbprocpar, SIGNAL(valueChanged(const QString&)), - this, SLOT(onModifyProcPar(const QString&))); - - connect(sb_nbproc, SIGNAL(valueChanged(const QString&)), - this, SLOT(onModifyProcRes(const QString&))); +FormContainer::FormContainer(QWidget *parent):FormContainerBase(parent),cb_type(new QComboBox(this)) +{ + gridLayout_2_2->addWidget(cb_type); + FormContainer::FillPanel(0); // --- set widgets before signal connexion to avoid false modif detection + connect(cb_type, SIGNAL(activated(const QString&)),this, SLOT(onModifyType(const QString&))); + connect(ch_aoc,SIGNAL(stateChanged(int)),this,SLOT(onModifyAOC(int))); } FormContainer::~FormContainer() @@ -125,596 +45,50 @@ FormContainer::~FormContainer() void FormContainer::FillPanel(YACS::ENGINE::Container *container) { DEBTRACE("FormContainer::FillPanel"); - _container = container; - if (_container) - { - _properties = _container->getProperties(); - le_name->setText(_container->getName().c_str()); - } - else - { - _properties.clear(); - le_name->setText("not defined"); - } - + FormContainerBase::FillPanel(container); + if(container) + ch_aoc->setCheckState(container->isAttachedOnCloning()?Qt::Checked:Qt::Unchecked); cb_type->clear(); cb_type->addItem("mono"); cb_type->addItem("multi"); if(_properties.count("type") && _properties["type"]=="multi") - { cb_type->setCurrentIndex(1); - cb_mode->setText("multi"); - } - else - cb_mode->setText("mono"); - - - vector parlibs; - parlibs.push_back(""); - parlibs.push_back("Mpi"); - parlibs.push_back("Dummy"); - cb_parallel->clear(); - for(int i=0; i< parlibs.size(); i++) - cb_parallel->addItem(parlibs[i].c_str()); - if(_properties.count("parallelLib")) - { - int i=0; - for(i=0; i< parlibs.size(); i++) - if(parlibs[i] == _properties["parallelLib"]) - { - cb_parallel->setCurrentIndex(i); - break; - } - } - else - cb_parallel->setCurrentIndex(0); - - if(_properties.count("workingdir")) - le_workdir->setText(_properties["workingdir"].c_str()); - else - le_workdir->setText(""); - - if(_properties.count("container_name")) - le_contname->setText(_properties["container_name"].c_str()); - else - le_contname->setText(""); - - if(_properties.count("isMPI")) - { - DEBTRACE("_properties[isMPI]=" << _properties["isMPI"]); - if ((_properties["isMPI"] == "0") || (_properties["isMPI"] == "false")) - ch_mpi->setCheckState(Qt::Unchecked); - else - ch_mpi->setCheckState(Qt::Checked); - } - else - ch_mpi->setCheckState(Qt::Unchecked); - - if(_properties.count("nb_parallel_procs")) - sb_nbprocpar->setValue(atoi(_properties["nb_parallel_procs"].c_str())); - else - sb_nbprocpar->setValue(0); - - //Resources - cb_resource->clear(); - cb_resource->addItem("automatic"); // --- when no resource is selected - - //add available resources - list machines = QtGuiContext::getQtCurrent()->getGMain()->getMachineList(); - list::iterator itm = machines.begin(); - for( ; itm != machines.end(); ++itm) - { - cb_resource->addItem(QString((*itm).c_str())); - } - - std::string resource=""; - if(_properties.count("name") && _properties["name"] != "") - { - //a resource has been specified - int index = cb_resource->findText(_properties["name"].c_str()); - if (index > 0) - { - //the resource is found: use it - cb_resource->setCurrentIndex(index); - resource=_properties["name"]; - } - else - { - //the resource has not been found: add a false item - std::string item="Unknown resource ("+_properties["name"]+")"; - cb_resource->addItem(item.c_str()); - cb_resource->setCurrentIndex(cb_resource->count()-1); - } - } - else - cb_resource->setCurrentIndex(0); - updateResource(resource); - - if (!QtGuiContext::getQtCurrent()->isEdition()) - { - //if the schema is in execution do not allow editing - le_name->setReadOnly(true); - cb_type->setEnabled(false); - cb_parallel->setEnabled(false); - le_workdir->setReadOnly(true); - le_contname->setReadOnly(true); - ch_mpi->setEnabled(false); - sb_nbprocpar->setReadOnly(true); - cb_resource->setEnabled(false); - le_hostname->setEnabled(false); - le_os->setEnabled(false); - sb_nbproc->setEnabled(false); - sb_mem->setEnabled(false); - sb_cpu->setEnabled(false); - sb_nbNodes->setEnabled(false); - sb_procNode->setEnabled(false); - cb_policy->setEnabled(false); - le_compolist->setEnabled(false); - le_resourceList->setEnabled(false); - } -} - -void FormContainer::onModified() -{ - DEBTRACE("FormContainer::onModified"); - Subject *sub = QtGuiContext::getQtCurrent()->getSelectedSubject(); - if (!sub) return; - YASSERT(QtGuiContext::getQtCurrent()->_mapOfEditionItem.count(sub)); - QWidget *widget = QtGuiContext::getQtCurrent()->_mapOfEditionItem[sub]; - ItemEdition *item = dynamic_cast(widget); - YASSERT(item); - item->setEdited(true); -} - -void FormContainer::on_tb_container_toggled(bool checked) -{ - DEBTRACE("FormContainer::on_tb_container_toggled " << checked); - _checked = checked; - if (_checked) gb_basic->show(); - else gb_basic->hide(); -} - -void FormContainer::on_ch_advance_stateChanged(int state) -{ - DEBTRACE("FormContainer::on_ch_advance_stateChanged " << state); - if (state) tw_advance->show(); - else tw_advance->hide(); } -void FormContainer::onModifyName(const QString &text) +QString FormContainer::getTypeStr() const { - DEBTRACE("onModifyName " << text.toStdString()); - SubjectContainer *scont = - QtGuiContext::getQtCurrent()->_mapOfSubjectContainer[_container]; - YASSERT(scont); - string name = scont->getName(); - if (name != text.toStdString()) - onModified(); -} - -void FormContainer::updateResource(const std::string &resource) -{ - DEBTRACE("FormContainer::updateResource " << resource); - if (resource=="") - { - //the resource is not specified: use automatic and allow editing - if(_properties.count("hostname")) - le_hostname->setText(_properties["hostname"].c_str()); - else - le_hostname->setText(""); - le_hostname->setEnabled(true); - - if(_properties.count("OS")) - le_os->setText(_properties["OS"].c_str()); - else - le_os->setText(""); - le_os->setEnabled(true); - - if(_properties.count("nb_resource_procs")) - sb_nbproc->setValue(atoi(_properties["nb_resource_procs"].c_str())); - else - sb_nbproc->setValue(0); - sb_nbproc->setEnabled(true); - - if(_properties.count("mem_mb")) - sb_mem->setValue(atoi(_properties["mem_mb"].c_str())); - else - sb_mem->setValue(0); - sb_mem->setEnabled(true); - - if(_properties.count("cpu_clock")) - sb_cpu->setValue(atoi(_properties["cpu_clock"].c_str())); - else - sb_cpu->setValue(0); - sb_cpu->setEnabled(true); - - if(_properties.count("nb_node")) - sb_nbNodes->setValue(atoi(_properties["nb_node"].c_str())); - else - sb_nbNodes->setValue(0); - sb_nbNodes->setEnabled(true); - - if(_properties.count("nb_proc_per_node")) - sb_procNode->setValue(atoi(_properties["nb_proc_per_node"].c_str())); - else - sb_procNode->setValue(0); - sb_procNode->setEnabled(true); - - std::vector policies; - policies.push_back("cycl"); - policies.push_back("altcycl"); - policies.push_back("best"); - policies.push_back("first"); - cb_policy->clear(); - for(int i=0; i< policies.size(); i++) - cb_policy->addItem(policies[i].c_str()); - if(_properties.count("policy")) - { - int i=0; - for(i=0; i< policies.size(); i++) - if(policies[i] == _properties["policy"]) - { - cb_policy->setCurrentIndex(i); - break; - } - } - else - cb_policy->setCurrentIndex(1); - cb_policy->setEnabled(true); - - if(_properties.count("component_list")) - le_compolist->setText(_properties["component_list"].c_str()); - else - le_compolist->setText(""); - le_compolist->setEnabled(true); - - if(_properties.count("resource_list")) - le_resourceList->setText(_properties["resource_list"].c_str()); - else - le_resourceList->setText(""); - le_resourceList->setEnabled(true); - } - else - { - //a specific resource has been chosen: properties are those declared in the resources manager - //properties can not be edited - std::map properties= _container->getResourceProperties(resource); - if(properties.count("hostname")) - le_hostname->setText(properties["hostname"].c_str()); - else - le_hostname->setText(""); - le_hostname->setEnabled(false); - - if(properties.count("OS")) - le_os->setText(properties["OS"].c_str()); - else - le_os->setText(""); - le_os->setEnabled(false); - - if(properties.count("nb_resource_procs")) - sb_nbproc->setValue(atoi(properties["nb_resource_procs"].c_str())); - else - sb_nbproc->setValue(0); - sb_nbproc->setEnabled(false); - - if(properties.count("mem_mb")) - sb_mem->setValue(atoi(properties["mem_mb"].c_str())); - else - sb_mem->setValue(0); - sb_mem->setEnabled(false); - - if(properties.count("cpu_clock")) - sb_cpu->setValue(atoi(properties["cpu_clock"].c_str())); - else - sb_cpu->setValue(0); - sb_cpu->setEnabled(false); - - if(properties.count("nb_node")) - sb_nbNodes->setValue(atoi(properties["nb_node"].c_str())); - else - sb_nbNodes->setValue(0); - sb_nbNodes->setEnabled(false); - - if(properties.count("nb_proc_per_node")) - sb_procNode->setValue(atoi(properties["nb_proc_per_node"].c_str())); - else - sb_procNode->setValue(0); - sb_procNode->setEnabled(false); - - cb_policy->clear(); - cb_policy->setEnabled(false); - - if(properties.count("component_list")) - le_compolist->setText(properties["component_list"].c_str()); - else - le_compolist->setText(""); - le_compolist->setEnabled(false); - - if(properties.count("resource_list")) - le_resourceList->setText(properties["resource_list"].c_str()); - else - le_resourceList->setText(""); - le_resourceList->setEnabled(false); - } -} - -void FormContainer::onModifyResource(const QString &text) -{ - DEBTRACE("onModifyResource " << text.toStdString()); - if (!_container) return; - std::string resource=text.toStdString(); - if(resource=="automatic")resource=""; - map properties = _container->getProperties(); - _properties["name"] = resource; - if (properties["name"] != resource) - { - // reset resource properties - _properties.erase("hostname"); - _properties.erase("OS"); - _properties.erase("nb_resource_procs"); - _properties.erase("mem_mb"); - _properties.erase("cpu_clock"); - _properties.erase("nb_node"); - _properties.erase("nb_proc_per_node"); - _properties.erase("policy"); - onModified(); - updateResource(resource); - } + return QString("Container"); } void FormContainer::onModifyType(const QString &text) { DEBTRACE("onModifyType " << text.toStdString()); - if (!_container) return; + if (!_container) + return; std::string prop=_container->getProperty("type"); _properties["type"] = text.toStdString(); if (_properties["type"] == "mono") - cb_mode->setText("mono"); + _advancedParams->setModeText("mono"); else - cb_mode->setText("multi"); + _advancedParams->setModeText("multi"); if (prop != text.toStdString()) onModified(); } -void FormContainer::onModifyPolicy(const QString &text) -{ - DEBTRACE("onModifyPolicy " << text.toStdString()); - if (!_container) return; - if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set - map properties = _container->getProperties(); - _properties["policy"] = text.toStdString(); - if (properties["policy"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyWorkDir(const QString &text) -{ - DEBTRACE("onModifyWorkDir " << text.toStdString()); - if (!_container) return; - map properties = _container->getProperties(); - _properties["workingdir"] = text.toStdString(); - if (properties["workingdir"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyContName(const QString &text) -{ - DEBTRACE("onModifyContName " << text.toStdString()); - if (!_container) return; - map properties = _container->getProperties(); - _properties["container_name"] = text.toStdString(); - if (properties["container_name"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyOS(const QString &text) -{ - DEBTRACE("onModifyOS " << text.toStdString()); - if (!_container) return; - if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set - map properties = _container->getProperties(); - _properties["OS"] = text.toStdString(); - if (properties["OS"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyParLib(const QString &text) -{ - DEBTRACE("onModifyParLib " << text.toStdString()); - if (!_container) return; - map properties = _container->getProperties(); - _properties["parallelLib"] = text.toStdString(); - if (properties["parallelLib"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyIsMPI(bool isMpi) -{ - DEBTRACE("onModifyIsMPI " << isMpi); - if (!_container) return; - string text = "false"; - if (isMpi) text = "true"; - DEBTRACE(text); - map properties = _container->getProperties(); - _properties["isMPI"] = text; - if (properties["isMPI"] != text) - { - onModified(); - } -} - -void FormContainer::onModifyMem(const QString &text) -{ - DEBTRACE("onModifyMem " << text.toStdString()); - if (!_container) return; - if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set - map properties = _container->getProperties(); - if(properties.count("mem_mb")==0 )properties["mem_mb"]="0"; //default value - _properties["mem_mb"] = text.toStdString(); - if (properties["mem_mb"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyClock(const QString &text) -{ - DEBTRACE("onModifyClock " << text.toStdString()); - if (!_container) return; - if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set - map properties = _container->getProperties(); - if(properties.count("cpu_clock")==0 )properties["cpu_clock"]="0"; //default value - _properties["cpu_clock"] = text.toStdString(); - if (properties["cpu_clock"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyNodes(const QString &text) -{ - DEBTRACE("onModifyNodes " << text.toStdString()); - if (!_container) return; - if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set - map properties = _container->getProperties(); - if(properties.count("nb_node")==0 )properties["nb_node"]="0"; //default value - _properties["nb_node"] = text.toStdString(); - if (properties["nb_node"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyProcs(const QString &text) -{ - DEBTRACE("onModifyProcs " << text.toStdString()); - if (!_container) return; - if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set - map properties = _container->getProperties(); - if(properties.count("nb_proc_per_node")==0 )properties["nb_proc_per_node"]="0"; //default value - _properties["nb_proc_per_node"] = text.toStdString(); - if (properties["nb_proc_per_node"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyCompos(const QString &text) -{ - DEBTRACE("onModifyCompo " << text.toStdString()); - if (!_container) return; - map properties = _container->getProperties(); - _properties["nb_component_nodes"] = text.toStdString(); - if (properties["nb_component_nodes"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyProcPar(const QString &text) -{ - DEBTRACE("onModifyProcPar " << text.toStdString()); - if (!_container) return; - map properties = _container->getProperties(); - _properties["nb_parallel_procs"] = text.toStdString(); - if (properties["nb_parallel_procs"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyResourceName(const QString &text) -{ - DEBTRACE("onModifyResourceName " << text.toStdString()); - if (!_container) return; - map properties = _container->getProperties(); - _properties["resource_name"] = text.toStdString(); - if (properties["resource_name"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyHostName(const QString &text) -{ - DEBTRACE("onModifyHostName " << text.toStdString()); - if (!_container) return; - if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set - - map properties = _container->getProperties(); - _properties["hostname"] = text.toStdString(); - if (properties["hostname"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyProcRes(const QString &text) -{ - DEBTRACE("onModifyProcRes " << text.toStdString()); - if (!_container) return; - if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set - map properties = _container->getProperties(); - if(properties.count("nb_resource_procs")==0 )properties["nb_resource_procs"]="0"; //default value - _properties["nb_resource_procs"] = text.toStdString(); - if (properties["nb_resource_procs"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyCompoList(const QString &text) -{ - DEBTRACE("onModifyCompoList " << text.toStdString()); - if (!_container) return; - if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set - map properties = _container->getProperties(); - _properties["component_list"] = text.toStdString(); - if (properties["component_list"] != text.toStdString()) - { - onModified(); - } -} - -void FormContainer::onModifyResourceList(const QString &text) -{ - DEBTRACE("onModifyResourceList " << text.toStdString()); - if (!_container) return; - if(_properties.count("name") && _properties["name"] != "")return; //do not modify resource parameter when specific resource is set - map properties = _container->getProperties(); - _properties["resource_list"] = text.toStdString(); - if (properties["resource_list"] != text.toStdString()) - { - onModified(); - } -} - - -bool FormContainer::onApply() -{ - SubjectContainer *scont = - QtGuiContext::getQtCurrent()->_mapOfSubjectContainer[_container]; - YASSERT(scont); - bool ret = scont->setName(le_name->text().toStdString()); - DEBTRACE(ret); - if (ret) ret = scont->setProperties(_properties); - return ret; -} - -void FormContainer::onCancel() -{ - SubjectContainer *scont = - QtGuiContext::getQtCurrent()->_mapOfSubjectContainer[_container]; - YASSERT(scont); - FillPanel(scont->getContainer()); +void FormContainer::onModifyAOC(int val) +{ + if (!_container) + return; + bool val2(false); + if(val==Qt::Unchecked) + val2=false; + if(val==Qt::Checked) + val2=true; + bool prop(_container->isAttachedOnCloning()); + int prop2((int)val2); + std::ostringstream oss; oss << prop2; + _properties[YACS::ENGINE::Container::AOC_ENTRY]=oss.str(); + _container->setAttachOnCloningStatus(val2); + if(prop!=val2) + onModified(); } diff --git a/src/genericgui/FormContainer.hxx b/src/genericgui/FormContainer.hxx index 6ca4d114e..08f464ff2 100644 --- a/src/genericgui/FormContainer.hxx +++ b/src/genericgui/FormContainer.hxx @@ -20,11 +20,7 @@ #ifndef _FORMCONTAINER_HXX_ #define _FORMCONTAINER_HXX_ -#include "ui_FormContainer.h" - -#include -#include -#include +#include "FormContainerBase.hxx" namespace YACS { @@ -34,54 +30,21 @@ namespace YACS } } -class FormContainer: public QWidget, public Ui::fm_container +class QComboBox; + +class FormContainer : public FormContainerBase { Q_OBJECT - public: FormContainer(QWidget *parent = 0); virtual ~FormContainer(); - - void FillPanel(YACS::ENGINE::Container *container); - virtual void onModified(); - virtual bool onApply(); - virtual void onCancel(); - void updateResource(const std::string &resource); - -public: - static bool _checked; - + virtual void FillPanel(YACS::ENGINE::Container *container); + QString getTypeStr() const; public slots: - void on_tb_container_toggled(bool checked); - void on_ch_advance_stateChanged(int state); - void onModifyName(const QString &text); - void onModifyResource(const QString &text); - void onModifyPolicy(const QString &text); void onModifyType(const QString &text); - void onModifyWorkDir(const QString &text); - void onModifyContName(const QString &text); - void onModifyOS(const QString &text); - void onModifyParLib(const QString &text); - void onModifyIsMPI(bool isMpi); - void onModifyMem(const QString &text); - void onModifyClock(const QString &text); - void onModifyNodes(const QString &text); - void onModifyProcs(const QString &text); - void onModifyCompos(const QString &text); - void onModifyProcPar(const QString &text); - void onModifyResourceName(const QString &text); - void onModifyHostName(const QString &text); - void onModifyProcRes(const QString &text); - void onModifyCompoList(const QString &text); - void onModifyResourceList(const QString &text); - - -protected: - bool _advanced; - YACS::ENGINE::Container *_container; - std::map _properties; - + void onModifyAOC(int val); private: + QComboBox *cb_type; }; #endif diff --git a/src/genericgui/FormContainer.ui b/src/genericgui/FormContainer.ui index bdc2b372c..bdfd15d3f 100644 --- a/src/genericgui/FormContainer.ui +++ b/src/genericgui/FormContainer.ui @@ -13,7 +13,7 @@ Form - + 2 @@ -63,479 +63,8 @@ - - - - - 0 - 0 - - - - Parameters - - - - 2 - - - - - Name: - - - - - - - identification of the container in schema - - - - - - - Resource: - - - - - - - name of the resource hosting container when manually set - - - - - - - type: - - - - - - - container type - - - 2 - - - - - - - Show Advanced parameters - - - - - - - 1 - - - - Container - - - - - - container name: - - - - - - - name of the container when instanciated at runtime - - - - - - - mode: - - - - - - - working dir: - - - - - - - - - - Parallel parameters - - - - - - nb procs: - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - Qt::RightToLeft - - - false - - - MPI container - - - - - - - PaCO++ lib: - - - - - - - false - - - - - - - Qt::Horizontal - - - - 50 - 20 - - - - - - - - - - - Qt::Vertical - - - - 20 - 168 - - - - - - - - true - - - - - - - - Resource - - - - - - hostname: - - - - - - - - - - O.S.: - - - - - - - - - - nb procs: - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - - - - - mem mb: - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - required memory (megaBytes) - - - - - - - cpu clock: - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - required cpu clock frequency (MHz) - - - - - - - nb nodes: - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - - - - - nb proc / node: - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - - - - - policy: - - - - - - - - 0 - 0 - - - - Component list: - - - - - - - example: GEOM, SMESH - - - - - - - - 0 - 0 - - - - Restricted resource list: - - - - - - - example: machine1, machine2 - - - - - - - false - - - 3 - - - - - - - - - - - - - ComboBox - QComboBox -
FormComponent.hxx
-
-
- - - ch_advance - toggled(bool) - tw_advance - setShown(bool) - - - 140 - 171 - - - 135 - 202 - - - - + diff --git a/src/genericgui/FormContainerBase.cxx b/src/genericgui/FormContainerBase.cxx new file mode 100644 index 000000000..96601a8a2 --- /dev/null +++ b/src/genericgui/FormContainerBase.cxx @@ -0,0 +1,164 @@ +// Copyright (C) 2006-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "FormContainerBase.hxx" +#include "FormAdvParamContainer.hxx" +#include "FormComponent.hxx" +#include "QtGuiContext.hxx" +#include "Container.hxx" + +#include +#include +#include + +//#define _DEVDEBUG_ +#include "YacsTrace.hxx" + +#include +#include + +using namespace std; +using namespace YACS; +using namespace YACS::HMI; +using namespace YACS::ENGINE; + +FormContainerBase::FormContainerBase(QWidget *parent):QWidget(parent),_advancedParams(new FormAdvParamContainer(_properties,this)) +{ + setupUi(this); + _advanced = false; + gridLayout_2->addWidget(_advancedParams); + on_ch_advance_stateChanged(0); + + FillPanel(0); // --- set widgets before signal connexion to avoid false modif detection + connect(le_name, SIGNAL(textChanged(const QString&)), this, SLOT(onModifyName(const QString&))); + connect(cb_resource, SIGNAL(activated(const QString&)), _advancedParams, SLOT(onModifyResource(const QString&))); +} + +FormContainerBase::~FormContainerBase() +{ + delete _advancedParams; +} + +void FormContainerBase::FillPanel(YACS::ENGINE::Container *container) +{ + DEBTRACE("FormContainer::FillPanel"); + _container = container; + if (_container) + { + _properties = _container->getProperties(); + le_name->setText(_container->getName().c_str()); + } + else + { + _properties.clear(); + le_name->setText("not defined"); + } + + //Resources + cb_resource->clear(); + cb_resource->addItem("automatic"); // --- when no resource is selected + + //add available resources + list machines = QtGuiContext::getQtCurrent()->getGMain()->getMachineList(); + list::iterator itm = machines.begin(); + for( ; itm != machines.end(); ++itm) + { + cb_resource->addItem(QString((*itm).c_str())); + } + + std::string resource; + if(_properties.count("name") && _properties["name"] != "") + { + //a resource has been specified + int index = cb_resource->findText(_properties["name"].c_str()); + if (index > 0) + { + //the resource is found: use it + cb_resource->setCurrentIndex(index); + resource=_properties["name"]; + } + else + { + //the resource has not been found: add a false item + std::string item="Unknown resource ("+_properties["name"]+")"; + cb_resource->addItem(item.c_str()); + cb_resource->setCurrentIndex(cb_resource->count()-1); + } + } + else + cb_resource->setCurrentIndex(0); + _advancedParams->FillPanel(resource,container); + + if (!QtGuiContext::getQtCurrent()->isEdition()) + { + //if the schema is in execution do not allow editing + le_name->setReadOnly(true); + cb_resource->setEnabled(false); + } +} + +void FormContainerBase::onModified() +{ + DEBTRACE("FormContainerBase::onModified"); + Subject *sub(QtGuiContext::getQtCurrent()->getSelectedSubject()); + if (!sub) + return; + YASSERT(QtGuiContext::getQtCurrent()->_mapOfEditionItem.count(sub)); + QWidget *widget(QtGuiContext::getQtCurrent()->_mapOfEditionItem[sub]); + ItemEdition *item(dynamic_cast(widget)); + YASSERT(item); + item->setEdited(true); +} + +void FormContainerBase::on_ch_advance_stateChanged(int state) +{ + DEBTRACE("FormContainer::on_ch_advance_stateChanged " << state); + if (state) + _advancedParams->show(); + else + _advancedParams->hide(); +} + +void FormContainerBase::onModifyName(const QString &text) +{ + DEBTRACE("onModifyName " << text.toStdString()); + SubjectContainerBase *scont(QtGuiContext::getQtCurrent()->_mapOfSubjectContainer[_container]); + YASSERT(scont); + string name = scont->getName(); + if (name != text.toStdString()) + onModified(); +} + +bool FormContainerBase::onApply() +{ + SubjectContainerBase *scont(QtGuiContext::getQtCurrent()->_mapOfSubjectContainer[_container]); + YASSERT(scont); + bool ret(scont->setName(le_name->text().toStdString())); + DEBTRACE(ret); + if (ret) + ret = scont->setProperties(_properties); + return ret; +} + +void FormContainerBase::onCancel() +{ + SubjectContainerBase *scont(QtGuiContext::getQtCurrent()->_mapOfSubjectContainer[_container]); + YASSERT(scont); + FillPanel(scont->getContainer()); +} diff --git a/src/genericgui/FormContainerBase.hxx b/src/genericgui/FormContainerBase.hxx new file mode 100644 index 000000000..43cf6d690 --- /dev/null +++ b/src/genericgui/FormContainerBase.hxx @@ -0,0 +1,60 @@ +// Copyright (C) 2006-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _FORMCONTAINERBASE_HXX_ +#define _FORMCONTAINERBASE_HXX_ + +#include "ui_FormParamContainer.h" + +#include + +namespace YACS +{ + namespace ENGINE + { + class Container; + } +} + +class FormAdvParamContainer; + +class FormContainerBase : public QWidget, public Ui::fm_paramcontainer +{ + Q_OBJECT + +public: + FormContainerBase(QWidget *parent = 0); + virtual ~FormContainerBase(); + virtual void FillPanel(YACS::ENGINE::Container *container); + virtual void onModified(); + virtual bool onApply(); + virtual void onCancel(); + virtual QString getTypeStr() const = 0; +public slots: + void on_ch_advance_stateChanged(int state); + void onModifyName(const QString &text); + +protected: + bool _advanced; + YACS::ENGINE::Container *_container; + std::map _properties; + FormAdvParamContainer *_advancedParams; +}; + +#endif diff --git a/src/genericgui/FormContainerDecorator.cxx b/src/genericgui/FormContainerDecorator.cxx new file mode 100644 index 000000000..996f0c9b5 --- /dev/null +++ b/src/genericgui/FormContainerDecorator.cxx @@ -0,0 +1,181 @@ +// Copyright (C) 2006-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "FormContainerDecorator.hxx" +#include "FormContainer.hxx" +#include "FormHPContainer.hxx" + +#include "HomogeneousPoolContainer.hxx" +#include "Exception.hxx" + +//#define _DEVDEBUG_ +#include "YacsTrace.hxx" + +using namespace YACS::ENGINE; + +bool FormContainerDecorator::CHECKED = false; + +FormContainerDecorator::FormContainerDecorator(YACS::ENGINE::Container *cont, QWidget *parent):QWidget(parent),_typ(0) +{ + if(!cont) + throw YACS::Exception("FormContainerDecorator constrctor : container is empty !"); + setupUi(this); + _icon.addFile("icons:icon_down.png"); + _icon.addFile("icons:icon_up.png",QSize(), QIcon::Normal, QIcon::On); + tb_container->setIcon(_icon); + connect(this,SIGNAL(typeOfContainerIsKnown(const QString&)),label,SLOT(setText(const QString &))); + HomogeneousPoolContainer *hpc(dynamic_cast(cont)); + if(!hpc) + _typ=new FormContainer(this); + else + _typ=new FormHPContainer(this); + emit typeOfContainerIsKnown(_typ->getTypeStr()); + _typ->FillPanel(cont); + gridLayout_1->addWidget(_typ); + connectForTyp(); + tb_container->setChecked(CHECKED); + on_tb_container_toggled(CHECKED); +} + +FormContainerDecorator::~FormContainerDecorator() +{ + delete _typ; +} + +void FormContainerDecorator::FillPanel(YACS::ENGINE::Container *container) +{ + checkOK(); + checkAndRepareTypeIfNecessary(container); + _typ->FillPanel(container); +} + +QWidget *FormContainerDecorator::getWidget() +{ + checkOK(); + return _typ; +} + +bool FormContainerDecorator::onApply() +{ + checkOK(); + return _typ->onApply(); +} + +void FormContainerDecorator::onCancel() +{ + checkOK(); + _typ->onCancel(); +} + +void FormContainerDecorator::show() +{ + QWidget::show(); + checkOK(); + _typ->show(); + tb_container->setChecked(CHECKED); + on_tb_container_toggled(CHECKED); +} + +void FormContainerDecorator::hide() +{ + QWidget::hide(); + checkOK(); + _typ->hide(); +} + +void FormContainerDecorator::on_tb_container_toggled(bool checked) +{ + DEBTRACE("FormContainer::on_tb_container_toggled " << checked); + CHECKED = checked; + if (CHECKED) + { + getWidget()->show(); + } + else + { + getWidget()->hide(); + } +} + +void FormContainerDecorator::synchronizeCheckContainer() +{ + checkOK(); + tb_container->setChecked(CHECKED); +} + +std::string FormContainerDecorator::getHostName(int index) const +{ + checkOK(); + return _typ->cb_resource->itemText(index).toStdString(); +} + +void FormContainerDecorator::setName(const std::string& name) +{ + checkOK(); + _typ->le_name->setText(name.c_str()); +} + +void FormContainerDecorator::onResMousePressed() +{ + emit(resourceMousePressed()); +} + +void FormContainerDecorator::onResActivated(int v) +{ + emit(resourceActivated(v)); +} + +void FormContainerDecorator::onContToggled(bool v) +{ + emit(containerToggled(v)); +} + +void FormContainerDecorator::checkOK() const +{ + if(!_typ) + throw YACS::Exception("Null Widget Container !!!!"); +} + +void FormContainerDecorator::checkAndRepareTypeIfNecessary(YACS::ENGINE::Container *container) +{ + checkOK(); + if(!container) + throw YACS::Exception("Null Container !!!!"); + YACS::ENGINE::HomogeneousPoolContainer *cont1(dynamic_cast(container)); + bool isTyp1(dynamic_cast(_typ)!=0); + if((!cont1 && !isTyp1) || (cont1 && isTyp1)) + return ; + QWidget *parent(_typ->parentWidget()); + delete _typ; _typ=0; + if(!cont1) + _typ=new FormContainer(parent); + else + _typ=new FormHPContainer(parent); + gridLayout_1->addWidget(_typ); + emit typeOfContainerIsKnown(_typ->getTypeStr()); + connectForTyp(); + _typ->FillPanel(container); +} + +void FormContainerDecorator::connectForTyp() +{ + connect(_typ->cb_resource,SIGNAL(mousePressed()),this,SLOT(onResMousePressed())); + connect(_typ->cb_resource,SIGNAL(activated(int)),this,SLOT(onResActivated)); + connect(tb_container,SIGNAL(toggled(bool)),this,SLOT(onContToggled())); +} diff --git a/src/genericgui/FormContainerDecorator.hxx b/src/genericgui/FormContainerDecorator.hxx new file mode 100644 index 000000000..a50e5535f --- /dev/null +++ b/src/genericgui/FormContainerDecorator.hxx @@ -0,0 +1,76 @@ +// Copyright (C) 2006-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _FORMCONTAINERDECORATOR_HXX_ +#define _FORMCONTAINERDECORATOR_HXX_ + +#include +#include + +#include "ui_FormContainer.h" + +class FormContainerBase; + +#include + +namespace YACS +{ + namespace ENGINE + { + class Container; + } +} + +class FormContainerDecorator : public QWidget, public Ui::fm_container +{ + Q_OBJECT +public: + FormContainerDecorator(YACS::ENGINE::Container *cont, QWidget *parent = 0); + ~FormContainerDecorator(); + void FillPanel(YACS::ENGINE::Container *container); + QWidget *getWidget(); + bool onApply(); + void onCancel(); + void show(); + void hide(); + void synchronizeCheckContainer(); + std::string getHostName(int index) const; + void setName(const std::string& name); +public: + static bool CHECKED; +public slots: + void on_tb_container_toggled(bool checked); + void onResMousePressed(); + void onResActivated(int); + void onContToggled(bool); +signals: + void typeOfContainerIsKnown(const QString& typeOfCont); + void resourceMousePressed(); + void resourceActivated(int); + void containerToggled(bool);//connect(_wContainer->tb_container, SIGNAL(toggled(bool)), this, SLOT(fillContainerPanel())); // --- to update display of current selection +private: + void checkOK() const; + void checkAndRepareTypeIfNecessary(YACS::ENGINE::Container *container); + void connectForTyp(); +private: + FormContainerBase *_typ; + QIcon _icon; +}; + +#endif diff --git a/src/genericgui/FormHPContainer.cxx b/src/genericgui/FormHPContainer.cxx new file mode 100644 index 000000000..9653e5cec --- /dev/null +++ b/src/genericgui/FormHPContainer.cxx @@ -0,0 +1,161 @@ +// Copyright (C) 2006-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "FormHPContainer.hxx" +#include "FormAdvParamContainer.hxx" +#include "HomogeneousPoolContainer.hxx" +#include "QtGuiContext.hxx" +#include "guiObservers.hxx" +//#define _DEVDEBUG_ +#include "Resource.hxx" +#include "YacsTrace.hxx" + +#include +#include + +#if HAS_QSCI4>0 +#include +#include +#endif + +#include +#include + +using namespace std; + +FormHPContainer::FormHPContainer(QWidget *parent):FormContainerBase(parent),_poolSz(new QLineEdit(this)),_initScriptModified(false) +{ + QIntValidator *iv(new QIntValidator(_poolSz)); iv->setRange(1,std::numeric_limits::max()); + _poolSz->setValidator(iv); + label_15->setText("Size of pool :"); + gridLayout_2_2->addWidget(_poolSz); + FormHPContainer::FillPanel(0); // --- set widgets before signal connexion to avoid false modif detection + connect(_poolSz, SIGNAL(textChanged(const QString&)),this, SLOT(onModifySzOfPool(const QString&))); + ch_aoc->setEnabled(false); + ch_aoc->setCheckState(Qt::Checked); + // +#if HAS_QSCI4>0 + _initScript=new QsciScintilla(_advancedParams->tw_advance); + QsciLexerPython *lex(new QsciLexerPython(_initScript)); + lex->setFont(YACS::HMI::Resource::pythonfont); + _initScript->setLexer(lex); + _initScript->setBraceMatching(QsciScintilla::SloppyBraceMatch); + _initScript->setAutoIndent(1); + _initScript->setIndentationWidth(4); + _initScript->setIndentationGuides(1); + _initScript->setIndentationsUseTabs(0); + _initScript->setAutoCompletionThreshold(2); + _initScript->setMarginWidth(1,0); + _initScript->setFolding(QsciScintilla::PlainFoldStyle); +#else + _initScript=new QTextEdit(this); +#endif + connect(_initScript,SIGNAL(textChanged()),this,SLOT(initSciptChanged())); + QGridLayout *gridLayout(new QGridLayout(_initScript)); + _advancedParams->tw_advance->addTab(_initScript,"Init Script"); +} + +FormHPContainer::~FormHPContainer() +{ +} + +void FormHPContainer::FillPanel(YACS::ENGINE::Container *container) +{ + DEBTRACE("FormHPContainer::FillPanel"); + FormContainerBase::FillPanel(container); + if(!container) + return ; + YACS::ENGINE::HomogeneousPoolContainer *hpc(dynamic_cast(container)); + if(!hpc) + throw YACS::Exception("FormHPContainer::FillPanel : not a HP Container !"); + _poolSz->setText(QString("%1").arg(hpc->getSizeOfPool())); + std::string initScript; + if(_properties.count(YACS::ENGINE::HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY)) + initScript=_properties[YACS::ENGINE::HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY]; + std::string initScript2(BuildWithFinalEndLine(initScript)); + _initScript->blockSignals(true); + _initScript->setText(initScript2.c_str()); + _initScript->blockSignals(false); + if (!YACS::HMI::QtGuiContext::getQtCurrent()->isEdition()) + { + //if the schema is in execution do not allow editing + _poolSz->setEnabled(false); + _initScript->setEnabled(false); + } +} + +QString FormHPContainer::getTypeStr() const +{ + return QString("Container (HP)"); +} + +void FormHPContainer::onModifySzOfPool(const QString& newSz) +{ + if (!_container) + return; + map properties(_container->getProperties()); + uint sz; + bool isOK; + sz=newSz.toUInt(&isOK); + if(!isOK) + return ; + _properties[YACS::ENGINE::HomogeneousPoolContainer::SIZE_OF_POOL_KEY] = newSz.toStdString(); + if(properties[YACS::ENGINE::HomogeneousPoolContainer::SIZE_OF_POOL_KEY] != newSz.toStdString()) + onModified(); +} + +bool FormHPContainer::onApply() +{ + YACS::HMI::SubjectContainerBase *scont(YACS::HMI::QtGuiContext::getQtCurrent()->_mapOfSubjectContainer[_container]); + YASSERT(scont); + bool ret(scont->setName(le_name->text().toStdString())); + std::map properties(_properties); + if(_initScriptModified) + { + std::string text(_initScript->text().toStdString()); + std::string text2(BuildWithFinalEndLine(text)); + properties[YACS::ENGINE::HomogeneousPoolContainer::INITIALIZE_SCRIPT_KEY]=text2; + } + _initScriptModified=false; + DEBTRACE(ret); + if(ret) + ret = scont->setProperties(properties); + return ret; +} + +void FormHPContainer::initSciptChanged() +{ + _initScriptModified=true; + onModified(); +} + +std::string FormHPContainer::BuildWithFinalEndLine(const std::string& script) +{ + if(script.empty()) + return std::string("\n"); + std::size_t sz(script.length()); + if(script[sz-1]!='\n') + { + std::string ret(script); + ret+="\n"; + return ret; + } + else + return script; +} diff --git a/src/genericgui/FormHPContainer.hxx b/src/genericgui/FormHPContainer.hxx new file mode 100644 index 000000000..2f93f1d04 --- /dev/null +++ b/src/genericgui/FormHPContainer.hxx @@ -0,0 +1,66 @@ +// Copyright (C) 2006-2014 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef _FORMHPCONTAINER_HXX_ +#define _FORMHPCONTAINER_HXX_ + +#include "FormContainerBase.hxx" + +namespace YACS +{ + namespace ENGINE + { + class Container; + } +} + +#if HAS_QSCI4>0 +class QsciScintilla; +#endif + +class QTextEdit; +class QLineEdit; + +class FormHPContainer : public FormContainerBase +{ + Q_OBJECT + +public: + FormHPContainer(QWidget *parent = 0); + virtual ~FormHPContainer(); + void FillPanel(YACS::ENGINE::Container *container); + QString getTypeStr() const; + bool onApply(); +public slots: + void onModifySzOfPool(const QString& newSz); + void initSciptChanged(); +public: + static std::string BuildWithFinalEndLine(const std::string& script); +private: + QLineEdit *_poolSz; +#if HAS_QSCI4>0 + QsciScintilla* _initScript; +#else + QTextEdit* _initScript; +#endif + bool _initScriptModified; + bool _initScriptLoaded; +}; + +#endif diff --git a/src/genericgui/FormHPContainer.ui b/src/genericgui/FormHPContainer.ui new file mode 100644 index 000000000..4cd409fa5 --- /dev/null +++ b/src/genericgui/FormHPContainer.ui @@ -0,0 +1,554 @@ + + + fm_hpcontainer + + + + 0 + 0 + 424 + 658 + + + + Form + + + + 2 + + + + + + + ... + + + true + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Container + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + 0 + + + + Parameters + + + + 2 + + + + + Name: + + + + + + + identification of the container in schema + + + + + + + Resource: + + + + + + + name of the resource hosting container when manually set + + + + + + + Size of Pool : + + + + + + + Show Advanced parameters + + + + + + + 1 + + + + Container + + + + + + container name: + + + + + + + name of the container when instanciated at runtime + + + + + + + mode: + + + + + + + working dir: + + + + + + + + + + Parallel parameters + + + + + + nb procs: + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Qt::RightToLeft + + + false + + + MPI container + + + + + + + PaCO++ lib: + + + + + + + false + + + + + + + Qt::Horizontal + + + + 50 + 20 + + + + + + + + + + + Qt::Vertical + + + + 20 + 168 + + + + + + + + true + + + + + + + + Resource + + + + + + hostname: + + + + + + + + + + O.S.: + + + + + + + + + + nb procs: + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + + + + mem mb: + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + required memory (megaBytes) + + + + + + + cpu clock: + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + required cpu clock frequency (MHz) + + + + + + + nb nodes: + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + + + + nb proc / node: + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + 0 + 0 + + + + + + + + policy: + + + + + + + + 0 + 0 + + + + Component list: + + + + + + + example: GEOM, SMESH + + + + + + + + 0 + 0 + + + + Restricted resource list: + + + + + + + example: machine1, machine2 + + + + + + + false + + + 3 + + + + + + + + + 16777215 + 16777215 + + + + Init Script + + + + + + + + + + + + + + + + + + + + + + + + ComboBox + QComboBox +
FormComponent.hxx
+
+
+ + + + ch_advance + toggled(bool) + tw_advance + setShown(bool) + + + 140 + 171 + + + 135 + 202 + + + + +
diff --git a/src/genericgui/FormParamContainer.ui b/src/genericgui/FormParamContainer.ui new file mode 100644 index 000000000..41c36c1dd --- /dev/null +++ b/src/genericgui/FormParamContainer.ui @@ -0,0 +1,125 @@ + + + fm_paramcontainer + + + + 0 + 0 + 420 + 602 + + + + + 350 + 0 + + + + Form + + + + 2 + + + + + + 0 + 0 + + + + Parameters + + + + 2 + + + + + 2 + + + + + Name: + + + + + + + identification of the container in schema + + + + + + + + + 2 + + + + + Resource: + + + + + + + name of the resource hosting container when manually set + + + + + + + + + 2 + + + + + type: + + + + + + + + + 2 + + + + + Show Advanced parameters + + + + + + + Attached on cloning + + + + + + + + + + + + + diff --git a/src/genericgui/GenericGui.cxx b/src/genericgui/GenericGui.cxx index 5094c4b68..dfda19af3 100644 --- a/src/genericgui/GenericGui.cxx +++ b/src/genericgui/GenericGui.cxx @@ -307,6 +307,10 @@ void GenericGui::createActions() tr("Create Container"), tr("Create a New Container"), 0, _parent, false, this, SLOT(onNewContainer())); + _newHPContainerAct = _wrapper->createAction(getMenuId(), tr("Create a New HP Container"), QIcon("icons:container.png"), + tr("Create HP Container"), tr("Create a New Homogeneous Pool Container."), + 0, _parent, false, this, SLOT(onNewHPContainer())); + _selectComponentInstanceAct = _wrapper->createAction(getMenuId(), tr("Select a Component Instance"), QIcon("icons:icon_select.png"), tr("Select a Component Instance"), tr("Select a Component Instance"), 0, _parent, false, this, SLOT(onSelectComponentInstance())); @@ -1951,6 +1955,12 @@ void GenericGui::onNewContainer() _guiEditor->CreateContainer(); } +void GenericGui::onNewHPContainer() +{ + DEBTRACE("GenericGui::onNewHPContainer"); + _guiEditor->CreateHPContainer(); +} + void GenericGui::onNewSalomeComponent() { DEBTRACE("GenericGui::onNewSalomeComponent"); diff --git a/src/genericgui/GenericGui.hxx b/src/genericgui/GenericGui.hxx index b3c9db94a..c56fd29d2 100644 --- a/src/genericgui/GenericGui.hxx +++ b/src/genericgui/GenericGui.hxx @@ -123,6 +123,7 @@ namespace YACS QAction *_createDataTypeAct; QAction *_importDataTypeAct; QAction *_newContainerAct; + QAction *_newHPContainerAct; QAction *_selectComponentInstanceAct; QAction *_newSalomeComponentAct; QAction *_newSalomePythonComponentAct; @@ -260,6 +261,7 @@ namespace YACS void onImportDataType(); void onNewContainer(); + void onNewHPContainer(); void onSelectComponentInstance(); void onNewSalomeComponent(); void onNewSalomePythonComponent(); diff --git a/src/genericgui/GuiEditor.cxx b/src/genericgui/GuiEditor.cxx index 45dc0e33b..57d307f70 100644 --- a/src/genericgui/GuiEditor.cxx +++ b/src/genericgui/GuiEditor.cxx @@ -269,7 +269,7 @@ void GuiEditor::CreateContainer() DEBTRACE("GuiEditor::CreateContainer"); SubjectProc *sproc = QtGuiContext::getQtCurrent()->getSubjectProc(); YASSERT(sproc); - SubjectContainer *scont = 0; + SubjectContainerBase *scont = 0; while (!scont) { std::stringstream name; @@ -281,6 +281,23 @@ void GuiEditor::CreateContainer() } } +void GuiEditor::CreateHPContainer() +{ + DEBTRACE("GuiEditor::CreateHPContainer"); + SubjectProc *sproc = QtGuiContext::getQtCurrent()->getSubjectProc(); + YASSERT(sproc); + SubjectContainerBase *scont = 0; + while (!scont) + { + std::stringstream name; + long newid = GuiContext::getCurrent()->getNewId(); + if (newid > 100000) break; + name.str(""); + name << "container" << newid; + scont = sproc->addHPContainer(name.str()); + } +} + void GuiEditor::CreateComponentInstance() { DEBTRACE("GuiEditor::CreateComponentInstance"); diff --git a/src/genericgui/GuiEditor.hxx b/src/genericgui/GuiEditor.hxx index 627993b81..dc2926cb9 100644 --- a/src/genericgui/GuiEditor.hxx +++ b/src/genericgui/GuiEditor.hxx @@ -59,6 +59,7 @@ namespace YACS void CreateSwitch(); void CreateOptimizerLoop(); void CreateContainer(); + void CreateHPContainer(); void CreateComponentInstance(); SubjectDataPort* CreateInputPort(SubjectElementaryNode* seNode, diff --git a/src/genericgui/ItemEdition.cxx b/src/genericgui/ItemEdition.cxx index 9ca26fe40..2fd7ae1e1 100644 --- a/src/genericgui/ItemEdition.cxx +++ b/src/genericgui/ItemEdition.cxx @@ -115,10 +115,10 @@ ItemEditionBase::ItemEditionBase(Subject* subject) _category = "Component"; _type = "Salome Component"; } - else if (SubjectContainer * sub = dynamic_cast(_subject)) + else if (SubjectContainerBase * sub = dynamic_cast(_subject)) { _category = "Container"; - _type = "Salome Container"; + _type = sub->getLabelForHuman(); } } @@ -402,9 +402,7 @@ void ItemEdition::update(GuiEvent event, int type, Subject* son) son->getName().c_str()); break; case YACS::HMI::CONTAINER: - item = new EditionContainer(son, - QtGuiContext::getQtCurrent()->getStackedWidget(), - son->getName().c_str()); + item = new EditionContainer(son,QtGuiContext::getQtCurrent()->getStackedWidget(),son->getName().c_str()); break; case YACS::HMI::COMPONENT: item = new EditionComponent(son, diff --git a/src/genericgui/Menus.cxx b/src/genericgui/Menus.cxx index 49c996f05..65bdc6b0d 100644 --- a/src/genericgui/Menus.cxx +++ b/src/genericgui/Menus.cxx @@ -225,6 +225,7 @@ void ProcMenu::popupMenu(QWidget *caller, const QPoint &globalPos, const QString menu.addSeparator(); menu.addAction(gmain->_importDataTypeAct); menu.addAction(gmain->_newContainerAct); + menu.addAction(gmain->_newHPContainerAct); QMenu *CNmenu = menu.addMenu(tr("Create Node")); CNmenu->addAction(gmain->_nodeFromCatalogAct); // CNmenu->addSeparator(); @@ -603,6 +604,7 @@ void ContainerDirMenu::popupMenu(QWidget *caller, const QPoint &globalPos, const if (isEdition) { menu.addAction(gmain->_newContainerAct); + menu.addAction(gmain->_newHPContainerAct); } menu.exec(globalPos); } diff --git a/src/hmi/commandsProc.cxx b/src/hmi/commandsProc.cxx index 74b0c2bb1..a10774b48 100644 --- a/src/hmi/commandsProc.cxx +++ b/src/hmi/commandsProc.cxx @@ -49,6 +49,7 @@ #include "PresetPorts.hxx" #include "ComponentDefinition.hxx" #include "SalomeContainer.hxx" +#include "SalomeHPContainer.hxx" #include "SalomeComponent.hxx" #include "TypeCode.hxx" #include "RuntimeSALOME.hxx" @@ -241,7 +242,7 @@ bool CommandAddNodeFromCatalog::localExecute() ComposedNode* father =dynamic_cast (node); if (father && nodeToClone) { - son = nodeToClone->clone(0); + son = nodeToClone->cloneWithoutCompAndContDeepCpy(0); son->setName(_name); service = dynamic_cast(son); } @@ -573,7 +574,7 @@ bool CommandPutInComposedNode::localExecute() //create a ComposedNode (type _type) with name _newParent YACS::ENGINE::Catalog *catalog = YACS::ENGINE::getSALOMERuntime()->getBuiltinCatalog(); Node* nodeToClone = catalog->_composednodeMap[_type]; - composednode = nodeToClone->clone(0); + composednode = nodeToClone->cloneWithoutCompAndContDeepCpy(0); composednode->setName(_newParent); //add the new composednode as child of oldfather oldFather->edAddChild(composednode); @@ -707,8 +708,8 @@ bool CommandCopyNode::localExecute() if (Loop *loop = dynamic_cast(newFather)) if (!loop->edGetDirectDescendants().empty()) throw YACS::Exception("Already a node in a new parent of Loop type"); - //_clone = node->clone(newFather); - _clone = node->clone(0); + //_clone = node->cloneWithoutCompAndContDeepCpy(newFather); + _clone = node->cloneWithoutCompAndContDeepCpy(0); if (!_clone) throw YACS::Exception("Node cannot be cloned"); int nodeSuffix = -1; @@ -899,7 +900,7 @@ bool CommandRenameContainer::localExecute() container->setName(_newName); proc->containerMap[_newName] = container; YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(container)); - SubjectContainer *scont = GuiContext::getCurrent()->_mapOfSubjectContainer[container]; + SubjectContainerBase *scont(GuiContext::getCurrent()->_mapOfSubjectContainer[container]); scont-> update(RENAME, 0, scont); scont->notifyComponentsChange(ASSOCIATE, CONTAINER, scont); } @@ -925,7 +926,7 @@ bool CommandRenameContainer::localReverse() container->setName(_oldName); proc->containerMap[_oldName] = container; YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(container)); - SubjectContainer *scont = GuiContext::getCurrent()->_mapOfSubjectContainer[container]; + SubjectContainerBase *scont(GuiContext::getCurrent()->_mapOfSubjectContainer[container]); scont-> update(RENAME, 0, scont); scont->notifyComponentsChange(ASSOCIATE, CONTAINER, scont); } @@ -3108,22 +3109,19 @@ bool CommandAddControlLink::localReverse() // ---------------------------------------------------------------------------- -CommandAddContainer::CommandAddContainer(std::string name, - std::string refContainer) +CommandAddContainerBase::CommandAddContainerBase(std::string name, std::string refContainer) : Command(), _name(name), _containerToClone(refContainer), _subcont(0) { - DEBTRACE("CommandAddContainer::CommandAddContainer " << name << " " << refContainer); + DEBTRACE("CommandAddContainerBase::CommandAddContainerBase " << name << " " << refContainer); } -std::string CommandAddContainer::dump() +CommandAddContainerBase::~CommandAddContainerBase() { - string ret ="CommandAddContainer " + _name + " " + _containerToClone; - return ret; } -bool CommandAddContainer::localExecute() +bool CommandAddContainerBase::localExecute() { - DEBTRACE("CommandAddContainer::localExecute"); + DEBTRACE("CommandAddContainerBase::localExecute"); try { Proc* proc = GuiContext::getCurrent()->getProc(); @@ -3132,7 +3130,7 @@ bool CommandAddContainer::localExecute() GuiContext::getCurrent()->_lastErrorMessage = "There is already a container with that name"; return false; } - Container *container = new SalomeContainer(); + Container *container(createNewInstance()); if (! _containerToClone.empty()) { if (proc->containerMap.count(_containerToClone)) @@ -3157,15 +3155,15 @@ bool CommandAddContainer::localExecute() } catch (Exception& ex) { - DEBTRACE("CommandAddContainer::localExecute() : " << ex.what()); + DEBTRACE("CommandAddContainerBase::localExecute() : " << ex.what()); setErrorMsg(ex); return false; } } -bool CommandAddContainer::localReverse() +bool CommandAddContainerBase::localReverse() { - DEBTRACE("CommandAddContainer::localReverse"); + DEBTRACE("CommandAddContainerBase::localReverse"); try { Proc* proc = GuiContext::getCurrent()->getProc(); @@ -3188,6 +3186,40 @@ bool CommandAddContainer::localReverse() // ---------------------------------------------------------------------------- +CommandAddContainer::CommandAddContainer(std::string name, std::string refContainer):CommandAddContainerBase(name,refContainer) +{ +} + +std::string CommandAddContainer::dump() +{ + string ret ="CommandAddContainer " + _name + " " + _containerToClone; + return ret; +} + +Container *CommandAddContainer::createNewInstance() const +{ + return new SalomeContainer; +} + +// ---------------------------------------------------------------------------- + +CommandAddHPContainer::CommandAddHPContainer(std::string name, std::string refContainer):CommandAddContainerBase(name,refContainer) +{ +} + +std::string CommandAddHPContainer::dump() +{ + string ret ="CommandAddHPContainer " + _name + " " + _containerToClone; + return ret; +} + +Container *CommandAddHPContainer::createNewInstance() const +{ + return new SalomeHPContainer; +} + +// ---------------------------------------------------------------------------- + CommandSetNodeProperties::CommandSetNodeProperties(std::string position, std::map properties) : Command(), _position(position), _properties(properties) { @@ -3354,11 +3386,11 @@ bool CommandSetContainerProperties::localExecute() Proc* proc = GuiContext::getCurrent()->getProc(); if (proc->containerMap.count(_container)) { - Container *ref = proc->containerMap[_container]; + Container *ref(proc->containerMap[_container]); YASSERT(ref); _oldProp = ref->getProperties(); ref->setProperties(_properties); - SubjectContainer *scont = GuiContext::getCurrent()->_mapOfSubjectContainer[ref]; + SubjectContainerBase *scont(GuiContext::getCurrent()->_mapOfSubjectContainer[ref]); scont->update(UPDATE, 0, scont); scont->notifyComponentsChange(ASSOCIATE, CONTAINER, scont); return true; @@ -3752,7 +3784,7 @@ bool CommandAddComponentInstance::localReverse() YASSERT(!_subcompo->hasServices()); Container *cont = compo->getContainer(); YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(cont)); - SubjectContainer *subcont = GuiContext::getCurrent()->_mapOfSubjectContainer[cont]; + SubjectContainerBase *subcont = GuiContext::getCurrent()->_mapOfSubjectContainer[cont]; subcont->detachComponent(_subcompo); GuiContext::getCurrent()->_mapOfSubjectComponent.erase(compo); proc->removeComponentInstance(compo); @@ -3872,7 +3904,7 @@ bool CommandSetContainer::localExecute() _oldcont = pyNode->getContainer()->getName(); pyNode->setContainer(cont); SubjectNode* snode = GuiContext::getCurrent()->_mapOfSubjectNode[pyNode]; - SubjectContainer *subcont = GuiContext::getCurrent()->_mapOfSubjectContainer[cont]; + SubjectContainerBase *subcont = GuiContext::getCurrent()->_mapOfSubjectContainer[cont]; snode->update(ASSOCIATE, 0, subcont); return true; } @@ -3909,7 +3941,7 @@ bool CommandSetContainer::localReverse() { pyNode->setContainer(cont); SubjectNode* snode = GuiContext::getCurrent()->_mapOfSubjectNode[pyNode]; - SubjectContainer *subcont = GuiContext::getCurrent()->_mapOfSubjectContainer[cont]; + SubjectContainerBase *subcont = GuiContext::getCurrent()->_mapOfSubjectContainer[cont]; snode->update(ASSOCIATE, 0, subcont); return true; } @@ -3970,7 +4002,7 @@ bool CommandAssociateComponentToContainer::localExecute() YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo)); SubjectComponent *scomp = GuiContext::getCurrent()->_mapOfSubjectComponent[compo]; YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(cont)); - SubjectContainer *subcont = GuiContext::getCurrent()->_mapOfSubjectContainer[cont]; + SubjectContainerBase *subcont = GuiContext::getCurrent()->_mapOfSubjectContainer[cont]; scomp->addSubjectReference(subcont); if (scomp->_subRefContainer) subcont->moveComponent(scomp->_subRefContainer); @@ -4013,7 +4045,7 @@ bool CommandAssociateComponentToContainer::localReverse() YASSERT(GuiContext::getCurrent()->_mapOfSubjectComponent.count(compo)); SubjectComponent *scomp = GuiContext::getCurrent()->_mapOfSubjectComponent[compo]; YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(cont)); - SubjectContainer *subcont = GuiContext::getCurrent()->_mapOfSubjectContainer[cont]; + SubjectContainerBase *subcont = GuiContext::getCurrent()->_mapOfSubjectContainer[cont]; scomp->addSubjectReference(subcont); if (scomp->_subRefContainer) subcont->moveComponent(scomp->_subRefContainer); @@ -4120,7 +4152,7 @@ bool CommandAssociateServiceToComponent::localReverse() { //component instance does not exist anymore recreate it ComponentInstance *oldcompo = service->getComponent(); - compo = oldcompo->clone(); + compo = oldcompo->cloneAlways(); compo->setName(_oldInstance); proc->addComponentInstance(compo, _oldInstance); Container *cont = proc->containerMap[_oldcont]; @@ -4256,7 +4288,7 @@ bool CommandAddComponentFromCatalog::localReverse() throw YACS::Exception("Component instance with services attached, not removed"); Container *cont = compo->getContainer(); YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(cont)); - SubjectContainer *subcont = GuiContext::getCurrent()->_mapOfSubjectContainer[cont]; + SubjectContainerBase *subcont = GuiContext::getCurrent()->_mapOfSubjectContainer[cont]; subcont->detachComponent(subCompo); //remove componentInstance from proc, from context if (_createdInstance) diff --git a/src/hmi/commandsProc.hxx b/src/hmi/commandsProc.hxx index 77ca2c1c6..4f203d54b 100644 --- a/src/hmi/commandsProc.hxx +++ b/src/hmi/commandsProc.hxx @@ -54,7 +54,7 @@ namespace YACS class SubjectOutputDataStreamPort; class SubjectLink; class SubjectControlLink; - class SubjectContainer; + class SubjectContainerBase; class SubjectComponent; typedef enum @@ -527,19 +527,37 @@ namespace YACS std::string _inNode; }; - class CommandAddContainer: public Command + class CommandAddContainerBase : public Command { public: - CommandAddContainer(std::string name, - std::string refContainer =""); - SubjectContainer* getSubjectContainer() { return _subcont; }; + CommandAddContainerBase(std::string name, std::string refContainer); + virtual ~CommandAddContainerBase(); + SubjectContainerBase* getSubjectContainer() { return _subcont; } protected: virtual bool localExecute(); virtual bool localReverse(); - virtual std::string dump(); + virtual YACS::ENGINE::Container *createNewInstance() const = 0; std::string _name; std::string _containerToClone; - SubjectContainer *_subcont; + SubjectContainerBase *_subcont; + }; + + class CommandAddContainer : public CommandAddContainerBase + { + public: + CommandAddContainer(std::string name, std::string refContainer =""); + protected: + std::string dump(); + YACS::ENGINE::Container *createNewInstance() const; + }; + + class CommandAddHPContainer : public CommandAddContainerBase + { + public: + CommandAddHPContainer(std::string name, std::string refContainer =""); + protected: + std::string dump(); + YACS::ENGINE::Container *createNewInstance() const; }; class CommandSetContainerProperties: public Command diff --git a/src/hmi/guiContext.hxx b/src/hmi/guiContext.hxx index 874b41b20..4c9a065b3 100644 --- a/src/hmi/guiContext.hxx +++ b/src/hmi/guiContext.hxx @@ -72,7 +72,7 @@ namespace YACS std::map,YACS::HMI::SubjectLink*> _mapOfSubjectLink; std::map,YACS::HMI::SubjectControlLink*> _mapOfSubjectControlLink; std::map _mapOfSubjectComponent; - std::map _mapOfSubjectContainer; + std::map _mapOfSubjectContainer; std::map _mapOfSubjectDataType; std::map _mapOfExecSubjectNode; std::map _mapOfLastComponentInstance; diff --git a/src/hmi/guiObservers.cxx b/src/hmi/guiObservers.cxx index 4888242c4..57d53d1b7 100644 --- a/src/hmi/guiObservers.cxx +++ b/src/hmi/guiObservers.cxx @@ -45,6 +45,7 @@ #include "OutputPort.hxx" #include "InputDataStreamPort.hxx" #include "OutputDataStreamPort.hxx" +#include "SalomeHPContainer.hxx" #include "SalomeContainer.hxx" #include "SalomeComponent.hxx" #include "ComponentDefinition.hxx" @@ -276,7 +277,7 @@ bool Subject::destroy(Subject *son) startnode = proc->getChildName(sclink->getSubjectOutNode()->getNode()); endnode = proc->getChildName(sclink->getSubjectInNode()->getNode()); } - else if (SubjectContainer* scont = dynamic_cast(son)) + else if (SubjectContainerBase* scont = dynamic_cast(son)) { if(scont->getName() == "DefaultContainer") { @@ -621,7 +622,7 @@ void SubjectNode::registerUndoDestroy() Bloc *undoBloc = new Bloc(blocName.str()); undoProc->edAddChild(undoBloc); ComposedNode *newFather = undoBloc; - Node *clone = _node->clone(0); + Node *clone = _node->cloneWithoutCompAndContDeepCpy(0); newFather->edAddChild(clone); // --- register a CommandCopyNode from undoProc @@ -1890,13 +1891,10 @@ void SubjectProc::loadComponents() void SubjectProc::loadContainers() { Proc* aProc = GuiContext::getCurrent()->getProc(); - for (map::const_iterator itCont = aProc->containerMap.begin(); - itCont != aProc->containerMap.end(); ++itCont) - if ( GuiContext::getCurrent()->_mapOfSubjectContainer.find((*itCont).second) - == - GuiContext::getCurrent()->_mapOfSubjectContainer.end() ) + for (map::const_iterator itCont = aProc->containerMap.begin(); itCont != aProc->containerMap.end(); ++itCont) + if ( GuiContext::getCurrent()->_mapOfSubjectContainer.find((*itCont).second) == GuiContext::getCurrent()->_mapOfSubjectContainer.end() ) // engine object for container already exists => add only a subject for it - addSubjectContainer((*itCont).second, (*itCont).second->getName()); + addSubjectContainer((*itCont).second,(*itCont).second->getName()); } SubjectComponent* SubjectProc::addComponent(std::string compoName, std::string containerName) @@ -1912,12 +1910,12 @@ SubjectComponent* SubjectProc::addComponent(std::string compoName, std::string c return 0; } -SubjectContainer* SubjectProc::addContainer(std::string name, std::string ref) +SubjectContainerBase *SubjectProc::addContainer(std::string name, std::string ref) { DEBTRACE("SubjectProc::addContainer " << name << " " << ref); if (! GuiContext::getCurrent()->getProc()->containerMap.count(name)) { - CommandAddContainer *command = new CommandAddContainer(name,ref); + CommandAddContainer *command(new CommandAddContainer(name,ref)); if (command->execute()) { GuiContext::getCurrent()->getInvoc()->add(command); @@ -1930,6 +1928,24 @@ SubjectContainer* SubjectProc::addContainer(std::string name, std::string ref) return 0; } +SubjectContainerBase* SubjectProc::addHPContainer(std::string name, std::string ref) +{ + DEBTRACE("SubjectProc::addContainer " << name << " " << ref); + if (! GuiContext::getCurrent()->getProc()->containerMap.count(name)) + { + CommandAddHPContainer *command(new CommandAddHPContainer(name,ref)); + if (command->execute()) + { + GuiContext::getCurrent()->getInvoc()->add(command); + return command->getSubjectContainer(); + } + else + delete command; + } + else GuiContext::getCurrent()->_lastErrorMessage = "There is already a container with that name"; + return 0; +} + bool SubjectProc::addDataType(YACS::ENGINE::Catalog* catalog, std::string typeName) { DEBTRACE("SubjectProc::addDataType " << typeName); @@ -1954,13 +1970,12 @@ SubjectComponent* SubjectProc::addSubjectComponent(YACS::ENGINE::ComponentInstan return son; } -SubjectContainer* SubjectProc::addSubjectContainer(YACS::ENGINE::Container* cont, - std::string name) +SubjectContainerBase *SubjectProc::addSubjectContainer(YACS::ENGINE::Container *cont, std::string name) { DEBTRACE("SubjectProc::addSubjectContainer " << name); - SubjectContainer *son = new SubjectContainer(cont, this); + SubjectContainerBase *son(SubjectContainerBase::New(cont,this)); // In edition mode do not clone containers - cont->attachOnCloning(); + // cont->attachOnCloning(); // agy : do not use _attachOnCloning attribute in edition mode. This attribute should be used now at runtime. GuiContext::getCurrent()->_mapOfSubjectContainer[cont] = son; update(ADD, CONTAINER, son); return son; @@ -2025,7 +2040,7 @@ void SubjectProc::removeSubjectDataType(std::string typeName) aTypeCode->decrRef(); } -void SubjectProc::removeSubjectContainer(SubjectContainer* scont) +void SubjectProc::removeSubjectContainer(SubjectContainerBase* scont) { YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(scont->getContainer())); erase(scont); // do all the necessary updates @@ -2302,7 +2317,7 @@ bool SubjectInlineNode::setExecutionMode(const std::string& mode) return false; } -bool SubjectInlineNode::setContainer(SubjectContainer* scont) +bool SubjectInlineNode::setContainer(SubjectContainerBase *scont) { DEBTRACE("SubjectInlineNode::setContainer "); Proc *proc = GuiContext::getCurrent()->getProc(); @@ -4236,7 +4251,7 @@ void SubjectComponent::localclean(Command *command) Container* container = _compoInst->getContainer(); if (!container) return; - SubjectContainer *subContainer; + SubjectContainerBase *subContainer(0); YASSERT(GuiContext::getCurrent()->_mapOfSubjectContainer.count(container)); subContainer = GuiContext::getCurrent()->_mapOfSubjectContainer[container]; subContainer->removeSubComponentFromSet(this); @@ -4269,7 +4284,7 @@ void SubjectComponent::setContainer() Container* container = _compoInst->getContainer(); if (container) { - SubjectContainer *subContainer; + SubjectContainerBase *subContainer; if (GuiContext::getCurrent()->_mapOfSubjectContainer.count(container)) subContainer = GuiContext::getCurrent()->_mapOfSubjectContainer[container]; else @@ -4284,7 +4299,7 @@ void SubjectComponent::setContainer() } } -bool SubjectComponent::associateToContainer(SubjectContainer* subcont) +bool SubjectComponent::associateToContainer(SubjectContainerBase *subcont) { DEBTRACE("SubjectComponent::associateToContainer " << getName() << " " << subcont->getName()); CommandAssociateComponentToContainer *command = @@ -4375,16 +4390,25 @@ std::map SubjectComponent::getProperties() // ---------------------------------------------------------------------------- -SubjectContainer::SubjectContainer(YACS::ENGINE::Container* container, Subject *parent) - : Subject(parent), _container(container) +SubjectContainerBase *SubjectContainerBase::New(YACS::ENGINE::Container* container, Subject *parent) +{ + if(!container) + return 0; + if(!dynamic_cast(container)) + return new SubjectContainer(container,parent); + else + return new SubjectHPContainer(dynamic_cast(container),parent); +} + +SubjectContainerBase::SubjectContainerBase(YACS::ENGINE::Container* container, Subject *parent):Subject(parent), _container(container) { _subComponentSet.clear(); _subReferenceMap.clear(); } -SubjectContainer::~SubjectContainer() +SubjectContainerBase::~SubjectContainerBase() { - DEBTRACE("SubjectContainer::~SubjectContainer"); + DEBTRACE("SubjectContainerBase::~SubjectContainerBase"); Proc* aProc = GuiContext::getCurrent()->getProc(); if ( aProc ) { @@ -4403,24 +4427,25 @@ SubjectContainer::~SubjectContainer() } } -std::map SubjectContainer::getProperties() +std::map SubjectContainerBase::getProperties() { return _container->getProperties(); } -bool SubjectContainer::setProperties(std::map properties) +bool SubjectContainerBase::setProperties(std::map properties) { - CommandSetContainerProperties *command = new CommandSetContainerProperties(getName(), properties); + CommandSetContainerProperties *command(new CommandSetContainerProperties(getName(), properties)); if (command->execute()) { GuiContext::getCurrent()->getInvoc()->add(command); return true; } - else delete command; + else + delete command; return false; } -bool SubjectContainer::setName(std::string name) +bool SubjectContainerBase::setName(std::string name) { DEBTRACE("SubjectContainer::setName " << name); if (name == getName()) @@ -4435,7 +4460,7 @@ bool SubjectContainer::setName(std::string name) return false; } -SubjectReference* SubjectContainer::attachComponent(SubjectComponent* component) +SubjectReference* SubjectContainerBase::attachComponent(SubjectComponent* component) { DEBTRACE("SubjectContainer::attachComponent"); SubjectReference *son = new SubjectReference(component, this); @@ -4445,18 +4470,18 @@ SubjectReference* SubjectContainer::attachComponent(SubjectComponent* component) return son; } -void SubjectContainer::detachComponent(SubjectComponent* component) +void SubjectContainerBase::detachComponent(SubjectComponent* component) { DEBTRACE("SubjectContainer::detachComponent"); YASSERT(_subReferenceMap.count(component)); SubjectReference *reference = _subReferenceMap[component]; - update(REMOVECHILDREF, COMPONENT, reference); + update(REMOVECHILDREF, PYTHONNODE, reference); _subComponentSet.erase(component); _subReferenceMap.erase(component); erase(reference); } -void SubjectContainer::moveComponent(SubjectReference* reference) +void SubjectContainerBase::moveComponent(SubjectReference* reference) { DEBTRACE("SubjectContainer::moveComponent"); SubjectContainer* oldcont = dynamic_cast(reference->getParent()); @@ -4470,14 +4495,14 @@ void SubjectContainer::moveComponent(SubjectReference* reference) update(PASTE, COMPONENT, reference); } -void SubjectContainer::removeSubComponentFromSet(SubjectComponent *component) +void SubjectContainerBase::removeSubComponentFromSet(SubjectComponent *component) { DEBTRACE("SubjectContainer::removeSubComponentFromSet"); _subComponentSet.erase(component); _subReferenceMap.erase(component); } -void SubjectContainer::notifyComponentsChange(GuiEvent event, int type, Subject* son) +void SubjectContainerBase::notifyComponentsChange(GuiEvent event, int type, Subject* son) { DEBTRACE("SubjectContainer::notifyComponentsChange"); set::iterator it = _subComponentSet.begin(); @@ -4488,8 +4513,7 @@ void SubjectContainer::notifyComponentsChange(GuiEvent event, int type, Subject* } } - -void SubjectContainer::clean(Command *command) +void SubjectContainerBase::clean(Command *command) { if (_askRegisterUndo) { @@ -4500,9 +4524,9 @@ void SubjectContainer::clean(Command *command) Subject::clean(command); } -void SubjectContainer::localclean(Command *command) +void SubjectContainerBase::localclean(Command *command) { - DEBTRACE("SubjectContainer::localClean "); + DEBTRACE("SubjectContainerBase::localClean "); Proc* aProc = GuiContext::getCurrent()->getProc(); if ( aProc ) { @@ -4526,14 +4550,15 @@ void SubjectContainer::localclean(Command *command) } } -std::string SubjectContainer::getName() +std::string SubjectContainerBase::getName() { return _container->getName(); } -YACS::ENGINE::Container* SubjectContainer::getContainer() const +// ---------------------------------------------------------------------------- + +SubjectContainer::SubjectContainer(YACS::ENGINE::Container *container, Subject *parent):SubjectContainerBase(container,parent) { - return _container; } void SubjectContainer::registerUndoDestroy() @@ -4545,6 +4570,32 @@ void SubjectContainer::registerUndoDestroy() // ---------------------------------------------------------------------------- +SubjectHPContainer::SubjectHPContainer(YACS::ENGINE::HomogeneousPoolContainer *container, Subject *parent):SubjectContainerBase(container,parent) +{ +} + +YACS::ENGINE::Container *SubjectHPContainer::getContainer() const +{ + if(!_container) + return 0; + else + { + YACS::ENGINE::HomogeneousPoolContainer *ret(dynamic_cast(_container)); + if(!ret) + throw Exception("Invalid container type in SubjectHPContainer !"); + return ret; + } +} + +void SubjectHPContainer::registerUndoDestroy() +{ + DEBTRACE("SubjectHPContainer::registerUndoDestroy"); + Command *command = new CommandAddHPContainer(getName(),""); + GuiContext::getCurrent()->getInvoc()->add(command); +} + +// ---------------------------------------------------------------------------- + SubjectDataType::SubjectDataType(YACS::ENGINE::TypeCode *typeCode, Subject *parent, std::string alias) : Subject(parent), _typeCode(typeCode), _alias(alias) { diff --git a/src/hmi/guiObservers.hxx b/src/hmi/guiObservers.hxx index 96916aa40..697bab251 100644 --- a/src/hmi/guiObservers.hxx +++ b/src/hmi/guiObservers.hxx @@ -69,6 +69,7 @@ namespace YACS class Catalog; class ComponentInstance; class Container; + class HomogeneousPoolContainer; class TypeCode; class OutGate; class InGate; @@ -411,13 +412,16 @@ namespace YACS }; class SubjectComponent; - class HMI_EXPORT SubjectContainer: public Subject + class HMI_EXPORT SubjectContainerBase : public Subject { public: - SubjectContainer(YACS::ENGINE::Container* container, Subject *parent); - virtual ~SubjectContainer(); + static SubjectContainerBase *New(YACS::ENGINE::Container* container, Subject *parent); + SubjectContainerBase(YACS::ENGINE::Container* container, Subject *parent); + virtual ~SubjectContainerBase(); virtual std::string getName(); + virtual std::string getLabelForHuman() const = 0; virtual bool setName(std::string name); + virtual YACS::ENGINE::Container *getContainer() const { return _container; } virtual std::map getProperties(); virtual bool setProperties(std::map properties); virtual SubjectReference* attachComponent(SubjectComponent* component); @@ -427,18 +431,33 @@ namespace YACS virtual void notifyComponentsChange(GuiEvent event, int type, Subject* son); virtual void clean(Command *command=0); void localclean(Command *command=0); - YACS::ENGINE::Container* getContainer() const; - bool isUsed() {return !_subComponentSet.empty(); }; - virtual TypeOfElem getType(){return CONTAINER;} - void registerUndoDestroy(); + bool isUsed() { return !_subComponentSet.empty(); } + TypeOfElem getType() { return CONTAINER; } protected: YACS::ENGINE::Container* _container; std::set _subComponentSet; std::map _subReferenceMap; }; + class HMI_EXPORT SubjectContainer: public SubjectContainerBase + { + public: + SubjectContainer(YACS::ENGINE::Container *container, Subject *parent); + void registerUndoDestroy(); + std::string getLabelForHuman() const { return std::string("Salome Container"); } + }; + + class HMI_EXPORT SubjectHPContainer : public SubjectContainerBase + { + public: + SubjectHPContainer(YACS::ENGINE::HomogeneousPoolContainer* container, Subject *parent); + void registerUndoDestroy(); + YACS::ENGINE::Container *getContainer() const; + std::string getLabelForHuman() const { return std::string("Salome Homogeneous Pool Container"); } + }; + class SubjectServiceNode; - class HMI_EXPORT SubjectComponent: public Subject + class HMI_EXPORT SubjectComponent : public Subject { public: friend class SubjectNode; @@ -446,7 +465,7 @@ namespace YACS virtual ~SubjectComponent(); virtual std::string getName(); virtual void setContainer(); - virtual bool associateToContainer(SubjectContainer* subcont); + virtual bool associateToContainer(SubjectContainerBase *subcont); virtual SubjectReference* attachService(SubjectServiceNode* service); virtual void detachService(SubjectServiceNode* service); virtual void moveService(SubjectReference* reference); @@ -494,15 +513,15 @@ namespace YACS void loadContainers(); void loadTypes(); virtual SubjectComponent* addComponent(std::string compoName, std::string containerName=""); - virtual SubjectContainer* addContainer(std::string name, std::string ref=""); + virtual SubjectContainerBase* addContainer(std::string name, std::string ref=""); + virtual SubjectContainerBase* addHPContainer(std::string name, std::string ref=""); virtual bool addDataType(YACS::ENGINE::Catalog* catalog, std::string typeName); SubjectComponent* addSubjectComponent(YACS::ENGINE::ComponentInstance* compo); - SubjectContainer* addSubjectContainer(YACS::ENGINE::Container* cont, - std::string name = ""); + SubjectContainerBase* addSubjectContainer(YACS::ENGINE::Container* cont, std::string name = ""); SubjectDataType* addComSubjectDataType(YACS::ENGINE::TypeCode *type, std::string alias); SubjectDataType* addSubjectDataType(YACS::ENGINE::TypeCode *type, std::string alias); void removeSubjectDataType(std::string typeName); - void removeSubjectContainer(SubjectContainer* scont); + void removeSubjectContainer(SubjectContainerBase* scont); virtual void clean(Command *command=0); void localclean(Command *command=0); void addPostErase(Subject* sub) {_postEraseList.push_back(sub); }; @@ -678,7 +697,7 @@ namespace YACS virtual std::string getScript(); virtual void clean(Command *command=0); void localclean(Command *command=0); - virtual bool setContainer(SubjectContainer* scont); + virtual bool setContainer(SubjectContainerBase *scont); virtual bool setExecutionMode(const std::string& mode); protected: YACS::ENGINE::InlineNode *_inlineNode; diff --git a/src/runtime/CORBAComponent.cxx b/src/runtime/CORBAComponent.cxx index bdfe047de..7ff71f69b 100644 --- a/src/runtime/CORBAComponent.cxx +++ b/src/runtime/CORBAComponent.cxx @@ -187,6 +187,11 @@ ComponentInstance* CORBAComponent::clone() const //return new CORBAComponent(*this); } +ComponentInstance* CORBAComponent::cloneAlways() const +{ + return new CORBAComponent(*this); +} + std::string CORBAComponent::getFileRepr() const { ostringstream stream; diff --git a/src/runtime/CORBAComponent.hxx b/src/runtime/CORBAComponent.hxx index e536a723b..1a2159add 100644 --- a/src/runtime/CORBAComponent.hxx +++ b/src/runtime/CORBAComponent.hxx @@ -44,6 +44,7 @@ namespace YACS virtual bool isLoaded(Task *askingNode) const; virtual ServiceNode* createNode(const std::string& name); virtual ComponentInstance* clone() const; + virtual ComponentInstance* cloneAlways() const; virtual std::string getFileRepr() const; virtual CORBA::Object_ptr getCompoPtr(); public: diff --git a/src/runtime/CppComponent.cxx b/src/runtime/CppComponent.cxx index bb769a3ba..abc73ae62 100644 --- a/src/runtime/CppComponent.cxx +++ b/src/runtime/CppComponent.cxx @@ -223,3 +223,7 @@ ComponentInstance* CppComponent::clone() const return new CppComponent(*this); } +YACS::ENGINE::ComponentInstance *CppComponent::cloneAlways() const +{ + return new CppComponent(*this); +} diff --git a/src/runtime/CppComponent.hxx b/src/runtime/CppComponent.hxx index e5e7ebc05..d10865669 100644 --- a/src/runtime/CppComponent.hxx +++ b/src/runtime/CppComponent.hxx @@ -62,6 +62,7 @@ namespace YACS virtual bool isLoaded(Task *askingNode) const; virtual ServiceNode* createNode(const std::string& name); virtual YACS::ENGINE::ComponentInstance* clone() const; + virtual YACS::ENGINE::ComponentInstance* cloneAlways() const; protected: diff --git a/src/runtime/SalomeComponent.cxx b/src/runtime/SalomeComponent.cxx index 0e9007837..9721d87ef 100644 --- a/src/runtime/SalomeComponent.cxx +++ b/src/runtime/SalomeComponent.cxx @@ -138,6 +138,11 @@ ComponentInstance* SalomeComponent::clone() const return new SalomeComponent(*this); } +ComponentInstance *SalomeComponent::cloneAlways() const +{ + return new SalomeComponent(*this); +} + std::string SalomeComponent::getFileRepr() const { ostringstream stream; diff --git a/src/runtime/SalomeComponent.hxx b/src/runtime/SalomeComponent.hxx index e2ae3d9bb..e812f8762 100644 --- a/src/runtime/SalomeComponent.hxx +++ b/src/runtime/SalomeComponent.hxx @@ -44,6 +44,7 @@ namespace YACS virtual bool setContainer(Container *cont); virtual ServiceNode* createNode(const std::string& name); virtual ComponentInstance* clone() const; + virtual ComponentInstance* cloneAlways() const; virtual std::string getFileRepr() const; virtual CORBA::Object_ptr getCompoPtr(){return CORBA::Object::_duplicate(_objComponent);} virtual void shutdown(int level); diff --git a/src/runtime/SalomeContainer.cxx b/src/runtime/SalomeContainer.cxx index 08f851c41..38b4d5709 100644 --- a/src/runtime/SalomeContainer.cxx +++ b/src/runtime/SalomeContainer.cxx @@ -54,6 +54,8 @@ using namespace std; const char SalomeContainer::KIND[]="Salome"; +const char SalomeContainer::TYPE_PROPERTY_STR[]="type"; + SalomeContainer::SalomeContainer():_launchModeType(new SalomeContainerMonoHelper),_shutdownLevel(999) { } @@ -118,7 +120,14 @@ void SalomeContainer::checkCapabilityToDealWith(const ComponentInstance *inst) c void SalomeContainer::setProperty(const std::string& name, const std::string& value) { - if (name == "type") + if (name == AOC_ENTRY) + { + std::istringstream iss(value); + int val; + iss >> val; + setAttachOnCloningStatus((bool)val); + } + else if (name == TYPE_PROPERTY_STR) { if (value == SalomeContainerMonoHelper::TYPE_NAME) { @@ -132,13 +141,20 @@ void SalomeContainer::setProperty(const std::string& name, const std::string& va } else throw Exception("SalomeContainer::setProperty : type value is not correct (mono or multi): " + value); - return ; } _sct.setProperty(name,value); } std::string SalomeContainer::getProperty(const std::string& name) const { + if (name == TYPE_PROPERTY_STR) + return _launchModeType->getType(); + if (name==AOC_ENTRY) + { + int reti(_isAttachedOnCloning); + std::ostringstream oss; oss << reti; + return oss.str(); + } return _sct.getProperty(name); } diff --git a/src/runtime/SalomeContainer.hxx b/src/runtime/SalomeContainer.hxx index 7fdc9be48..275d09843 100644 --- a/src/runtime/SalomeContainer.hxx +++ b/src/runtime/SalomeContainer.hxx @@ -68,6 +68,7 @@ namespace YACS std::map getResourceProperties(const std::string& name) const; std::map getProperties() const; static const char KIND[]; + static const char TYPE_PROPERTY_STR[]; protected: #ifndef SWIG virtual ~SalomeContainer(); diff --git a/src/runtime/SalomeHPComponent.cxx b/src/runtime/SalomeHPComponent.cxx index 46ab56150..d84261da1 100644 --- a/src/runtime/SalomeHPComponent.cxx +++ b/src/runtime/SalomeHPComponent.cxx @@ -128,6 +128,11 @@ ComponentInstance* SalomeHPComponent::clone() const return new SalomeHPComponent(*this); } +ComponentInstance *SalomeHPComponent::cloneAlways() const +{ + return new SalomeHPComponent(*this); +} + std::string SalomeHPComponent::getFileRepr() const { ostringstream stream; diff --git a/src/runtime/SalomeHPComponent.hxx b/src/runtime/SalomeHPComponent.hxx index 3ca7a1c29..e5fa9ab77 100644 --- a/src/runtime/SalomeHPComponent.hxx +++ b/src/runtime/SalomeHPComponent.hxx @@ -40,6 +40,7 @@ namespace YACS virtual bool setContainer(Container *cont); virtual ServiceNode* createNode(const std::string& name); virtual ComponentInstance* clone() const; + virtual ComponentInstance* cloneAlways() const; virtual std::string getFileRepr() const; virtual CORBA::Object_ptr getCompoPtr(){return CORBA::Object::_duplicate(_objComponent);} virtual void shutdown(int level); diff --git a/src/runtime/SalomeHPContainer.cxx b/src/runtime/SalomeHPContainer.cxx index b3957a847..9143f4a1a 100644 --- a/src/runtime/SalomeHPContainer.cxx +++ b/src/runtime/SalomeHPContainer.cxx @@ -138,7 +138,9 @@ Container *SalomeHPContainer::cloneAlways() const void SalomeHPContainer::setProperty(const std::string& name,const std::string& value) { - if(name==SIZE_OF_POOL_KEY) + if(name==AOC_ENTRY)//no sense to set it ! It is always true ! ignore it ! + return ; + else if(name==SIZE_OF_POOL_KEY) { std::istringstream iss(value); int val(0); @@ -155,7 +157,11 @@ void SalomeHPContainer::setProperty(const std::string& name,const std::string& v std::string SalomeHPContainer::getProperty(const std::string& name) const { - if(name==SIZE_OF_POOL_KEY) + if(name==AOC_ENTRY) + { + return std::string("1"); + } + else if(name==SIZE_OF_POOL_KEY) { std::ostringstream oss; oss << getSizeOfPool(); return oss.str(); diff --git a/src/runtime/SalomeHPContainerTools.cxx b/src/runtime/SalomeHPContainerTools.cxx index d9bdda068..323b20085 100644 --- a/src/runtime/SalomeHPContainerTools.cxx +++ b/src/runtime/SalomeHPContainerTools.cxx @@ -33,7 +33,7 @@ void SalomeHPContainerVectOfHelper::resize(std::size_t sz) return; checkNoCurrentWork(); _whichOccupied.resize(sz); std::fill(_whichOccupied.begin(),_whichOccupied.end(),false); - _launchModeType.clear(); _launchModeType.resize(sz); + _launchModeType.resize(sz); for(std::size_t i=oldSize;i