42 using namespace YACS::ENGINE;
43 using namespace YACS::HMI;
51 QString label,
Subject *subject)
54 DEBTRACE(
"SceneBlocItem::SceneBlocItem " <<label.toStdString());
69 DEBTRACE(
"SceneBlocItem::arrangeChildNodes");
70 clock_t start_t, end_t;
87 setlocale(LC_NUMERIC,
"C");
94 _graph = agopen((
char*)( cnode->
getName().c_str()), Agdirected, NULL);
98 agattr(
_graph, AGRAPH, const_cast<char*>(
"compound"), const_cast<char*>(
"true"));
99 agattr(
_graph, AGRAPH, const_cast<char*>(
"rankdir"), const_cast<char*>(
"LR"));
100 agattr(
_graph, AGRAPH, const_cast<char*>(
"dpi"), const_cast<char*>(
"72"));
101 agattr(
_graph, AGRAPH, const_cast<char*>(
"label"), const_cast<char*>(
"myLabel"));
102 agattr(
_graph, AGRAPH, const_cast<char*>(
"labelloc"), const_cast<char*>(
"top"));
103 agattr(
_graph, AGRAPH, const_cast<char*>(
"fontsize"), const_cast<char*>(
"24"));
104 agattr(
_graph, AGRAPH, const_cast<char*>(
"splines"), const_cast<char*>(
""));
108 agattr(
_graph, AGNODE, const_cast<char*>(
"height"), const_cast<char*>(
"" ));
109 agattr(
_graph, AGNODE, const_cast<char*>(
"width"), const_cast<char*>(
"" ));
110 agattr(
_graph, AGNODE, const_cast<char*>(
"shape"), const_cast<char*>(
"" ));
111 agattr(
_graph, AGNODE, const_cast<char*>(
"fixedsize"), const_cast<char*>(
"false" ));
127 gvLayout(aGvc,
_graph,
"dot");
128 DEBTRACE(
"external render for test");
130 gvRenderFilename(aGvc,
_graph,
"dot",
"graph2.dot");
133 catch (std::exception &e)
135 DEBTRACE(
"Exception Graphviz layout: " << e.what());
140 DEBTRACE(
"Unknown Exception Graphviz layout ");
146 double passe = (end_t -start_t);
147 passe = passe/CLOCKS_PER_SEC;
160 gvFreeLayout(aGvc,
_graph);
168 gvFreeContext( aGvc );
174 double passe = (end_t -start_t);
175 passe = passe/CLOCKS_PER_SEC;
189 for (list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
192 DEBTRACE(
"Add node in graph: " << agnameof(aNode));
201 QString height, width;
202 height = QString(
_format.c_str()).arg(lh, 0,
'g', 3);
203 width = QString(
_format.c_str()).arg(lw, 0,
'g', 3);
205 DEBTRACE(agnameof(aNode) <<
" (" << nh <<
"," << nw <<
") = (" << height.toStdString() <<
" ; " << width.toStdString() <<
")");
206 agset(aNode, const_cast<char*>(
"height"), height.toLatin1().data());
207 agset(aNode, const_cast<char*>(
"width"), width.toLatin1().data());
208 agset(aNode, const_cast<char*>(
"shape"), const_cast<char*>(
"box") );
209 agset(aNode, const_cast<char*>(
"fixedsize"), const_cast<char*>(
"true") );
215 for (aNode = agfstnode(
_graph); aNode; aNode = agnxtnode(
_graph, aNode))
217 string aNodeName = agnameof(aNode);
218 DEBTRACE(
"--- tail node " << aNodeName);
219 Agnode_t* aTailNode = aNode;
223 DEBTRACE(
" =========== problem here ! =============================");
231 list<InGate*> setOfInGate = outGate->
edSetInGate();
232 list<InGate*>::const_iterator itin = setOfInGate.begin();
233 for (; itin != setOfInGate.end(); ++itin)
235 Node *inNode = (*itin)->getNode();
237 DEBTRACE(
"--- control link from tail node: --- "<<inName);
242 DEBTRACE(
"--- edge inside the bloc " << inDCNode->getName());
244 Agnode_t* aHeadNode = agnode(
_graph, (
char*)(inDCName.c_str()), 1);
245 Agedge_t* anEdge = agedge(
_graph, aTailNode, aHeadNode, NULL, 1);
246 DEBTRACE(
"--- control link from tail node: --- " << agnameof(aNode) <<
" --> " << inDCName);
255 list<OutPort*>::const_iterator itou = outPortList.begin();
256 for (; itou != outPortList.end(); ++itou)
258 set<InPort*> inPortList = (*itou)->edSetInPort();
259 set<InPort*>::const_iterator itin = inPortList.begin();
260 for (; itin != inPortList.end(); ++itin)
262 Node *inNode = (*itin)->getNode();
264 DEBTRACE(
"------ data link from tail node: ---- ");
267 DEBTRACE(
"--- edge inside the bloc " << inDCNode->getName());
269 Agnode_t* aHeadNode = agnode(
_graph, (
char*)(inDCName.c_str()), 1);
270 Agedge_t* anEdge = agedge(
_graph, aTailNode, aHeadNode, NULL, 1);
271 DEBTRACE(
"------ data link from tail node: ---- " << agnameof(aNode) <<
" --> " << inDCName);
282 DEBTRACE(
"SceneBlocItem::arrangeCanvasNodes");
293 for (list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
296 DEBTRACE(
"Get node in graph: " << agnameof(aNode));
300 qreal xCenter = ND_coord(aNode).x;
301 qreal yCenter = ND_coord(aNode).y;
305 sci->setPos(xOffset + xCenter -halfWidth, yHead + yCenter -halfHeight);
307 if (scni) scni->
setExpandedPos(QPointF(xOffset + xCenter -halfWidth, yHead + yCenter -halfHeight));