*
*/
+PropertyInterface::~PropertyInterface()
+{
+}
+
void PropertyInterface::setProperty(const std::string& name, const std::string& value)
{
DEBTRACE("PropertyInterface::setProperty " << name << " " << value);
class YACSLIBENGINE_EXPORT PropertyInterface
{
public:
+ virtual ~PropertyInterface();
+
virtual void setProperty(const std::string& name,const std::string& value);
virtual std::string getProperty(const std::string& name);
std::map<std::string,std::string> getProperties() { return _propertyMap; };
*/
%feature("ref") YACS::ENGINE::RefCounter ""
%feature("unref") YACS::ENGINE::RefCounter "$this->decrRef();"
+
+// Unfortunately, class ComponentInstance inherits from RefCounter AND PropertyInterface. Thus the ref and
+// unref features are ambiguous and with swig 2.0.7 at least, we must re-specify those features for class
+// ComponentInstance unless the instances are destroyed when the Swig object is unref'ed.
+%feature("ref") YACS::ENGINE::ComponentInstance ""
+%feature("unref") YACS::ENGINE::ComponentInstance "$this->decrRef();"
/*
* End of Reference counting section
*/
tr("Put node in block"), tr("Put node in block"),
0, _parent, false, this, SLOT(onPutInBloc()));
+ _putGraphInOptimizerLoopAct = _wrapper->createAction(getMenuId(), tr("Optimizer Loop"), QIcon("icons:paste.png"),
+ tr("Optimizer Loop"), tr("Optimizer Loop"),
+ 0, _parent, false, this, SLOT(onPutGraphInOptimizerLoop()));
+
_arrangeLocalNodesAct = _wrapper->createAction(getMenuId(), tr("arrange nodes on that bloc level, without recursion"), QIcon("icons:arrange_nodes.png"),
tr("arrange local nodes"), tr("arrange nodes on that bloc level, without recursion"),
0, _parent, false, this, SLOT(onArrangeLocalNodes()));
_guiEditor->PutSubjectInBloc();
}
+void GenericGui::putGraphInForeachLoop(std::string type)
+{
+ DEBTRACE("GenericGui::PutGraphInForeachLoop");
+ _guiEditor->PutGraphInForeachLoop(type);
+}
+
+void GenericGui::onPutGraphInOptimizerLoop()
+{
+ DEBTRACE("GenericGui::onPutGraphInOptimizerLoop");
+ _guiEditor->PutGraphInOptimizerLoop();
+}
+
void GenericGui::onArrangeLocalNodes()
{
DEBTRACE("GenericGui::onArrangeLocalNodes");
CatalogWidget* getCatalogWidget() { return _catalogsWidget; };
std::list<std::string> getMachineList();
void createForEachLoop(std::string type="double");
+ void putGraphInForeachLoop(std::string type);
virtual void loadSchema(const std::string& filename,bool edit=true, bool arrangeLocalNodes=false);
virtual void onHelpContextModule( const QString&, const QString&, const QString& = QString() );
void createContext(YACS::ENGINE::Proc* proc,
QAction *_copyItemAct;
QAction *_pasteItemAct;
QAction *_putInBlocAct;
+ QAction *_putGraphInOptimizerLoopAct;
QAction *_arrangeLocalNodesAct;
QAction *_arrangeRecurseNodesAct;
QAction *_computeLinkAct;
void onCopyItem();
void onPasteItem();
void onPutInBloc();
-
+ void onPutGraphInOptimizerLoop();
void onArrangeLocalNodes();
void onArrangeRecurseNodes();
void onRebuildLinks();
std::stringstream tryname;
long newid=0;
while (newid < 100000)
- {
- tryname.str("");
- tryname << "Bloc" << newid;
- if(names.find(tryname.str()) == names.end())break;
- newid++;
- }
-
+ {
+ tryname.str("");
+ tryname << "Bloc" << newid;
+ if(names.find(tryname.str()) == names.end())break;
+ newid++;
+ }
+
if (!snode->putInComposedNode(tryname.str(),"Bloc"))
Message mess;
Message mess("Put in Bloc not possible for this kind of object");
}
+void GuiEditor::PutGraphInForeachLoop(std::string typeNode)
+{
+ // put graph in Bloc node before
+ std::string blocname = PutGraphInBloc();
+
+ Proc* proc = GuiContext::getCurrent()->getProc();
+ Node* bloc = proc->getChildByShortName(blocname);
+ SubjectNode * sbloc = GuiContext::getCurrent()->_mapOfSubjectNode[bloc];
+ //put the built bloc into target node
+ sbloc->putInComposedNode("ForEachLoop_"+typeNode,"ForEachLoop_"+typeNode);
+}
+
+void GuiEditor::PutGraphInOptimizerLoop()
+{
+ // put graph in Bloc node before
+ std::string blocname = PutGraphInBloc();
+
+ Proc* proc = GuiContext::getCurrent()->getProc();
+ Node* bloc = proc->getChildByShortName(blocname);
+ SubjectNode * sbloc = GuiContext::getCurrent()->_mapOfSubjectNode[bloc];
+ //put the built bloc into target node
+ sbloc->putInComposedNode("OptimizerLoop0","OptimizerLoop");
+}
+
+std::string GuiEditor::PutGraphInBloc()
+{
+ Proc* proc = GuiContext::getCurrent()->getProc();
+ std::list<Node *> children = proc->getChildren();
+
+ //get the set of children node names
+ std::set<std::string> names;
+ for (std::list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
+ names.insert((*it)->getName());
+
+ //get the next numbered name
+ std::stringstream tryname;
+ long newid=0;
+ while (newid < 100000)
+ {
+ tryname.str("");
+ tryname << "Bloc" << newid;
+ if(names.find(tryname.str()) == names.end())break;
+ newid++;
+ }
+ std::string blocname = tryname.str();
+
+ //put one by one the child nodes of Proc node into a new Bloc node
+ SubjectNode * snode;
+ for (std::list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
+ {
+ snode = GuiContext::getCurrent()->_mapOfSubjectNode[(*it)];
+ snode->saveLinks();
+ snode->putInComposedNode(blocname,"Bloc", false);
+ }
+ for (std::list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
+ {
+ snode = 0;
+ snode = GuiContext::getCurrent()->_mapOfSubjectNode[(*it)];
+ snode->restoreLinks();
+ }
+ return blocname;
+}
+
void GuiEditor::rebuildLinks()
{
// --- only global link redraw for now...
void CopySubject();
void PasteSubject();
void PutSubjectInBloc();
+ std::string PutGraphInBloc();
+ void PutGraphInForeachLoop(std::string typeNode);
+ void PutGraphInOptimizerLoop();
void shrinkExpand();
void rebuildLinks();
void arrangeNodes(bool isRecursive);
gmain->createForEachLoop(act->text().toStdString());
}
+void MenusBase::putGraphInForeachAction(QAction* act)
+{
+ DEBTRACE(act->text().toStdString());
+ GenericGui *gmain = QtGuiContext::getQtCurrent()->getGMain();
+ gmain->putGraphInForeachLoop(act->text().toStdString());
+}
+
void MenusBase::addHeader(QMenu &m, const QString &h)
{
m.addAction(_dummyAct);
m.addSeparator();
}
-void MenusBase::addForEachMenu(QMenu *m, QActionGroup* actgroup)
+void MenusBase::buildForEachMenu(QMenu *m, QActionGroup* actgroup)
{
QPixmap pixmap;
pixmap.load("icons:new_foreach_loop_node.png");
act=actgroup->addAction((*it).first.c_str());
ForEachMenu->addAction(act);
}
+}
+void MenusBase::addForEachMenu(QMenu *m, QActionGroup* actgroup)
+{
+ buildForEachMenu(m, actgroup);
connect(actgroup, SIGNAL(triggered(QAction*)), this, SLOT(foreachAction(QAction*)));
+}
+void MenusBase::addForEachMenuToPutGraph(QMenu *m, QActionGroup* actgroup)
+{
+ buildForEachMenu(m, actgroup);
+ connect(actgroup, SIGNAL(triggered(QAction*)), this, SLOT(putGraphInForeachAction(QAction*)));
}
//=======================================================================================
QMenu menu(m, caller);
addHeader(menu, m);
QActionGroup actgroup(this);
+ QActionGroup actgroup2(this);
if (isEdition)
{
menu.addAction(gmain->_runLoadedSchemaAct);
CNmenu->addAction(gmain->_OptimizerLoopAct);
menu.addSeparator();
menu.addAction(gmain->_pasteItemAct);
+
+ QMenu *PINmenu = menu.addMenu(tr("Put Graph Content in Node"));
+ addForEachMenuToPutGraph(PINmenu,&actgroup2);
+ PINmenu->addAction(gmain->_putGraphInOptimizerLoopAct);
+
menu.addSeparator();
}
menu.addAction(gmain->_getYacsContainerLogAct);
const QPoint &globalPos,
const QString& m = "MenuBase");
virtual void addForEachMenu(QMenu *m, QActionGroup* actgroup);
+ virtual void addForEachMenuToPutGraph(QMenu *m, QActionGroup* actgroup);
protected slots:
void dummyAction();
void foreachAction(QAction*);
+ void putGraphInForeachAction(QAction*);
protected:
+ virtual void buildForEachMenu(QMenu *m, QActionGroup* actgroup);
virtual void addHeader(QMenu &m, const QString &h);
QAction *_dummyAct;
};
// ----------------------------------------------------------------------------
CommandPutInComposedNode::CommandPutInComposedNode(std::string position,
- std::string newParent,std::string type)
- : Command(), _position(position), _newParent(newParent), _type(type)
+ std::string newParent,
+ std::string type,
+ bool toSaveRestoreLinks)
+ : Command(), _position(position), _newParent(newParent), _type(type), _toSaveRestoreLinks(toSaveRestoreLinks)
{
DEBTRACE("CommandPutInComposedNode::CommandPutInComposedNode " << _position << " " << _newParent);
_newpos ="";
std::string CommandPutInComposedNode::dump()
{
- string ret ="CommandPutInComposedNode " + _position + " " + _newParent + " " + _type;
+ string save = _toSaveRestoreLinks ? "true" : "false";
+ string ret ="CommandPutInComposedNode " + _position + " " + _newParent + " " + _type + " " + save;
return ret;
}
SubjectNode * snode = GuiContext::getCurrent()->_mapOfSubjectNode[node];
Subject *subo = GuiContext::getCurrent()->_mapOfSubjectNode[oldFather];
SubjectComposedNode* sop = dynamic_cast<SubjectComposedNode*>(subo);
- //save existing links
- snode->saveLinks();
+ if (_toSaveRestoreLinks)
+ snode->saveLinks(); //save existing links
//remove external links
snode->removeExternalLinks();
snode->removeExternalControlLinks();
//refresh node views
sop->update(CUT, ProcInvoc::getTypeOfNode(node), snode);
- //create a ComposedNode (type _type) with name _newParent
- YACS::ENGINE::Catalog *catalog = YACS::ENGINE::getSALOMERuntime()->getBuiltinCatalog();
- Node* nodeToClone = catalog->_composednodeMap[_type];
- Node* composednode = nodeToClone->clone(0);
- composednode->setName(_newParent);
- //add the new composednode as child of oldfather
- oldFather->edAddChild(composednode);
- //create the subject composednode
- SubjectNode *scomposednode = sop->addSubjectNode(composednode,"",catalog,"",_type);
+ // try to find a node with the given name:
+ // success: use it as target composed node
+ // fail: create such a node and use it
+ std::list<Node*> children = proc->getChildren();
+ Node* composednode = 0;
+ SubjectNode *scomposednode = 0;
+ for (list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
+ {
+ if ( _newParent == (*it)->getName() )
+ {
+ //get an existing ComposedNode with name _newParent
+ composednode = (*it);
+ break;
+ }
+ }
+ // target node was found
+ if ( composednode )
+ {
+ scomposednode = GuiContext::getCurrent()->_mapOfSubjectNode[composednode];
+ }
+ // creation of target node
+ else
+ {
+ //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->setName(_newParent);
+ //add the new composednode as child of oldfather
+ oldFather->edAddChild(composednode);
+ //create the subject composednode
+ scomposednode = sop->addSubjectNode(composednode,"",catalog,"",_type);
+ }
//add the old node as child of new composednode
(dynamic_cast<YACS::ENGINE::ComposedNode*>(composednode))->edAddChild(node);
//add the subject node to subject composednode
(dynamic_cast<SubjectComposedNode*>(scomposednode))->houseKeepingAfterCutPaste(false, snode);
snode->setParent(scomposednode);
- //restore links
- snode->restoreLinks();
+ if (_toSaveRestoreLinks)
+ snode->restoreLinks(); //restore links
//refresh all views
scomposednode->update(PASTE, ProcInvoc::getTypeOfNode(node), snode);
snode->recursiveUpdate(RENAME, 0, snode);
{
public:
CommandPutInComposedNode(std::string position,
- std::string newParent,std::string type);
+ std::string newParent,
+ std::string type,
+ bool toSaveRestoreLinks=true);
protected:
virtual bool localExecute();
virtual bool localReverse();
std::string _newParent;
std::string _type;
std::string _newpos;
+ bool _toSaveRestoreLinks;
};
class CommandCopyNode: public Command
}
}
-bool SubjectNode::putInComposedNode(std::string name,std::string type)
+bool SubjectNode::putInComposedNode(std::string name,std::string type, bool toSaveRestoreLinks)
{
Proc *proc = GuiContext::getCurrent()->getProc();
string position = "";
if (proc != dynamic_cast<Proc*>(_node)) position = proc->getChildName(_node);
- CommandPutInComposedNode *command = new CommandPutInComposedNode(position, name, type);
+ CommandPutInComposedNode *command = new CommandPutInComposedNode(position, name, type, toSaveRestoreLinks);
if (command->execute())
{
GuiContext::getCurrent()->getInvoc()->add(command);
virtual void removeExternalControlLinks();
virtual void saveLinks();
virtual void restoreLinks();
- virtual bool putInComposedNode(std::string name,std::string type);
+ virtual bool putInComposedNode(std::string name,std::string type, bool toSaveRestoreLinks=true);
virtual int isValid();
void setExecState(int execState);
static bool tryCreateLink(SubjectNode *subOutNode, SubjectNode *subInNode);
{
ob=convertNeutralPyObject(type,data);
std::string s=convertPyObjectToString(ob);
+
+ // Note (Renaud Barate, 8 jan 2013): With Python 2.7, this call to Py_DECREF causes a crash
+ // (SIGSEGV) when ob is a sequence and the call is not protected with the global interpreter
+ // lock. I thus added the call to PyGILState_Ensure / PyGILState_Release. It worked fine in
+ // Python 2.6 without this call. If anyone finds the real reason of this bug and another fix,
+ // feel free to change this code.
+ PyGILState_STATE gstate = PyGILState_Ensure();
Py_DECREF(ob);
+ PyGILState_Release(gstate);
return s;
}
else
int Yacsgui::_oldStudyId = -1;
Yacsgui::Yacsgui() :
- SalomeWrap_Module( "YACS" ), // default name
- LightApp_Module( "YACS" )
+ SalomeWrap_Module( "YACS" ) // default name
{
DEBTRACE("Yacsgui::Yacsgui");
_wrapper = 0;
<source>Put node in block</source>
<translation>Poser le noeud au bloc</translation>
</message>
+ <message>
+ <source>Put Graph Content in Node</source>
+ <translation type="unfinished">Put Graph Content in Node</translation>
+ </message>
<message>
<source>arrange nodes on that bloc level, without recursion</source>
<translation>ranger les noeuds au niveau de ce bloc, sans récursion </translation>
using namespace std;
SalomeWrap_Module::SalomeWrap_Module(const char* name) :
- SalomeApp_Module( name ),
- LightApp_Module( name )
+ SalomeApp_Module( name )
{
_mapOfViewWindow.clear();
}