2) Possibility to put the graph in "for loop", "while loop" and "bloc" nodes was added.
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()));
+ _putGraphInBlocAct = _wrapper->createAction(getMenuId(), tr("Bloc"), QIcon("icons:new_block_node.png"),
+ tr("Bloc"), tr("Bloc"),
+ 0, _parent, false, this, SLOT(onPutGraphInBloc()));
+
+ _putGraphInForLoopAct = _wrapper->createAction(getMenuId(), tr("For Loop"), QIcon("icons:new_for_loop_node.png"),
+ tr("For Loop"), tr("For Loop"),
+ 0, _parent, false, this, SLOT(onPutGraphInForLoop()));
+
+ _putGraphInWhileLoopAct = _wrapper->createAction(getMenuId(), tr("While Loop"), QIcon("icons:new_while_loop_node.png"),
+ tr("While Loop"), tr("While Loop"),
+ 0, _parent, false, this, SLOT(onPutGraphInWhileLoop()));
+
+ _putGraphInOptimizerLoopAct = _wrapper->createAction(getMenuId(), tr("Optimizer Loop"), QIcon("icons:new_for_loop_node.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"),
_guiEditor->PutSubjectInBloc();
}
+void GenericGui::onPutGraphInBloc()
+{
+ DEBTRACE("GenericGui::onPutGraphInBloc");
+ _guiEditor->PutGraphInBloc();
+ _guiEditor->arrangeNodes(false);
+}
+
+void GenericGui::onPutGraphInForLoop()
+{
+ DEBTRACE("GenericGui::onPutGraphInForLoop");
+ _guiEditor->PutGraphInNode("ForLoop");
+}
+
void GenericGui::putGraphInForeachLoop(std::string type)
{
DEBTRACE("GenericGui::PutGraphInForeachLoop");
- _guiEditor->PutGraphInForeachLoop(type);
+ _guiEditor->PutGraphInNode("ForEachLoop_"+type);
+}
+
+void GenericGui::onPutGraphInWhileLoop()
+{
+ DEBTRACE("GenericGui::onPutGraphInWhileLoop");
+ _guiEditor->PutGraphInNode("WhileLoop");
}
void GenericGui::onPutGraphInOptimizerLoop()
{
DEBTRACE("GenericGui::onPutGraphInOptimizerLoop");
- _guiEditor->PutGraphInOptimizerLoop();
+ _guiEditor->PutGraphInNode("OptimizerLoop");
}
void GenericGui::onArrangeLocalNodes()
QAction *_copyItemAct;
QAction *_pasteItemAct;
QAction *_putInBlocAct;
+ QAction *_putGraphInBlocAct;
+ QAction *_putGraphInForLoopAct;
+ QAction *_putGraphInWhileLoopAct;
QAction *_putGraphInOptimizerLoopAct;
QAction *_arrangeLocalNodesAct;
QAction *_arrangeRecurseNodesAct;
void onCopyItem();
void onPasteItem();
void onPutInBloc();
+ void onPutGraphInBloc();
+ void onPutGraphInForLoop();
+ void onPutGraphInWhileLoop();
void onPutGraphInOptimizerLoop();
void onArrangeLocalNodes();
void onArrangeRecurseNodes();
}
}
-void GuiEditor::CreateNode(std::string typeNode)
+SubjectNode* GuiEditor::CreateNode(std::string typeNode)
{
DEBTRACE("GuiEditor::CreateNode " << typeNode);
YACS::ENGINE::Catalog *catalog = YACS::ENGINE::getSALOMERuntime()->getBuiltinCatalog();
if (!sub)
{
DEBTRACE("GuiEditor::CreateNode : invalid selection!");
- return;
+ return 0;
}
DEBTRACE(sub->getName());
if (!cnode)
{
DEBTRACE("GuiEditor::CreateNode : no ComposedNode selected!");
- return;
+ return 0;
}
- _createNode(catalog, cnode, typeNode, "", Resource::COMPONENT_INSTANCE_NEW);
+ return _createNode(catalog, cnode, typeNode, "", Resource::COMPONENT_INSTANCE_NEW);
}
-void GuiEditor::_createNode(YACS::ENGINE::Catalog* catalog,
- SubjectComposedNode *cnode,
- std::string service,
- std::string compoName,
- bool createNewComponentInstance)
+SubjectNode* GuiEditor::_createNode(YACS::ENGINE::Catalog* catalog,
+ SubjectComposedNode *cnode,
+ std::string service,
+ std::string compoName,
+ bool createNewComponentInstance)
{
+ SubjectNode* aNewNode = 0;
+
// --- find a name not used
string name = service;
map<int, SubjectNode*>::reverse_iterator rit = bodyMap.rbegin();
swCase = (*rit).first + 1;
}
- if (!aSwitch->addNode(catalog, compoName, service, name, createNewComponentInstance, swCase))
+ aNewNode = aSwitch->addNode(catalog, compoName, service, name, createNewComponentInstance, swCase);
+ if (!aNewNode)
Message mess;
}
else if (cnode && (dynamic_cast<SubjectBloc*>(cnode) == 0) && cnode->getChild() != 0)
{
//the bloc has been successfully created. Add the new node
SubjectBloc* newbloc = dynamic_cast<SubjectBloc*>(cnode->getChild());
- if (!newbloc->addNode(catalog, compoName, service, name, createNewComponentInstance))
+ aNewNode = newbloc->addNode(catalog, compoName, service, name, createNewComponentInstance);
+ if (!aNewNode)
Message mess;
}
else
}
}
else if (cnode)
- if (!cnode->addNode(catalog, compoName, service, name, createNewComponentInstance))
+ aNewNode = cnode->addNode(catalog, compoName, service, name, createNewComponentInstance);
+ if (!aNewNode)
Message mess;
+ return aNewNode;
}
void GuiEditor::AddTypeFromCatalog(const ItemMimeData* myData)
Message mess("Put in Bloc not possible for this kind of object");
}
-void GuiEditor::PutGraphInForeachLoop(std::string typeNode)
+void GuiEditor::PutGraphInNode(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");
+ // create a target node
+ SubjectNode * snode = CreateNode(typeNode);
+ // put the built bloc into target node
+ sbloc->putInComposedNode(snode->getName(), typeNode);
+ // arrange local nodes in Proc
+ YACS::HMI::SubjectProc* subproc = QtGuiContext::getQtCurrent()->getSubjectProc();
+ QtGuiContext::getQtCurrent()->setSelectedSubject(subproc);
+ arrangeNodes(false);
}
std::string GuiEditor::PutGraphInBloc()
{
Proc* proc = GuiContext::getCurrent()->getProc();
- std::list<Node *> children = proc->getChildren();
+ std::list<Node *> children = proc->edGetDirectDescendants();
//get the set of children node names
std::set<std::string> names;
//get the next numbered name
std::stringstream tryname;
- long newid=0;
+ long newid = GuiContext::getCurrent()->getNewId();
while (newid < 100000)
{
tryname.str("");
{
snode = GuiContext::getCurrent()->_mapOfSubjectNode[(*it)];
snode->saveLinks();
- snode->putInComposedNode(blocname,"Bloc", false);
+ snode->putInComposedNode(blocname, "Bloc", false);
}
for (std::list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
{
snode = GuiContext::getCurrent()->_mapOfSubjectNode[(*it)];
snode->restoreLinks();
}
+ // arrange local nodes in Proc
+ YACS::HMI::SubjectProc* subproc = QtGuiContext::getQtCurrent()->getSubjectProc();
+ QtGuiContext::getQtCurrent()->setSelectedSubject(subproc);
+ arrangeNodes(false);
return blocname;
}
namespace HMI
{
class Subject;
+ class SubjectNode;
class SubjectElementaryNode;
class SubjectComposedNode;
class SubjectDataPort;
SubjectComposedNode *cnode,
bool createNewComponentInstance);
void AddTypeFromCatalog(const ItemMimeData* myData);
- void CreateNode(std::string typeNode);
+ SubjectNode* CreateNode(std::string typeNode);
void CreateBloc();
void CreateForLoop();
void CreateForEachLoop(std::string type );
void PasteSubject();
void PutSubjectInBloc();
std::string PutGraphInBloc();
- void PutGraphInForeachLoop(std::string typeNode);
- void PutGraphInOptimizerLoop();
+ void PutGraphInNode(std::string typeNode);
void shrinkExpand();
void rebuildLinks();
void arrangeNodes(bool isRecursive);
QString asciiFilter(const QString & name);
protected:
- void _createNode(YACS::ENGINE::Catalog* catalog,
+ SubjectNode* _createNode(YACS::ENGINE::Catalog* catalog,
SubjectComposedNode *cnode,
std::string service,
std::string compoName,
QPixmap pixmap;
pixmap.load("icons:new_foreach_loop_node.png");
- QMenu *ForEachMenu=m->addMenu(QIcon(pixmap),"ForEachLoop");
+ QMenu *ForEachMenu=m->addMenu(QIcon(pixmap),"ForEach Loop");
Proc* proc = GuiContext::getCurrent()->getProc();
std::map<std::string, TypeCode*>::const_iterator it = proc->typeMap.begin();
menu.addAction(gmain->_pasteItemAct);
QMenu *PINmenu = menu.addMenu(tr("Put Graph Content in Node"));
+ PINmenu->addAction(gmain->_putGraphInBlocAct);
+ PINmenu->addSeparator();
+ PINmenu->addAction(gmain->_putGraphInForLoopAct);
addForEachMenuToPutGraph(PINmenu,&actgroup2);
+ PINmenu->addAction(gmain->_putGraphInWhileLoopAct);
PINmenu->addAction(gmain->_putGraphInOptimizerLoopAct);
menu.addSeparator();