53 QString label,
Subject *subject)
56 DEBTRACE(
"SceneBlocItem::SceneBlocItem " <<label.toStdString());
71 DEBTRACE(
"SceneBlocItem::arrangeChildNodes");
72 clock_t start_t, end_t;
88 GVC_t* aGvc = gvContext();
92 _graph = agopen((
char*)( cnode->
getName().c_str()), Agdirected, NULL);
96 agattr(
_graph, AGRAPH,
const_cast<char*
>(
"compound"),
const_cast<char*
>(
"true"));
97 agattr(
_graph, AGRAPH,
const_cast<char*
>(
"rankdir"),
const_cast<char*
>(
"LR"));
98 agattr(
_graph, AGRAPH,
const_cast<char*
>(
"dpi"),
const_cast<char*
>(
"72"));
99 agattr(
_graph, AGRAPH,
const_cast<char*
>(
"label"),
const_cast<char*
>(
"myLabel"));
100 agattr(
_graph, AGRAPH,
const_cast<char*
>(
"labelloc"),
const_cast<char*
>(
"top"));
101 agattr(
_graph, AGRAPH,
const_cast<char*
>(
"fontsize"),
const_cast<char*
>(
"24"));
102 agattr(
_graph, AGRAPH,
const_cast<char*
>(
"splines"),
const_cast<char*
>(
""));
106 agattr(
_graph, AGNODE,
const_cast<char*
>(
"height"),
const_cast<char*
>(
"" ));
107 agattr(
_graph, AGNODE,
const_cast<char*
>(
"width"),
const_cast<char*
>(
"" ));
108 agattr(
_graph, AGNODE,
const_cast<char*
>(
"shape"),
const_cast<char*
>(
"" ));
109 agattr(
_graph, AGNODE,
const_cast<char*
>(
"fixedsize"),
const_cast<char*
>(
"false" ));
125 gvLayout(aGvc,
_graph,
"dot");
126 DEBTRACE(
"external render for test");
128 gvRenderFilename(aGvc,
_graph,
"dot",
"graph2.dot");
131 catch (std::exception &e)
133 DEBTRACE(
"Exception Graphviz layout: " << e.what());
138 DEBTRACE(
"Unknown Exception Graphviz layout ");
144 double passe = (end_t -start_t);
145 passe = passe/CLOCKS_PER_SEC;
158 gvFreeLayout(aGvc,
_graph);
166 gvFreeContext( aGvc );
172 double passe = (end_t -start_t);
173 passe = passe/CLOCKS_PER_SEC;
187 for (list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
190 DEBTRACE(
"Add node in graph: " << agnameof(aNode));
199 QString height, width;
200 height = QString(
_format.c_str()).arg(lh, 0,
'g', 3);
201 width = QString(
_format.c_str()).arg(lw, 0,
'g', 3);
203 DEBTRACE(agnameof(aNode) <<
" (" << nh <<
"," << nw <<
") = (" << height.toStdString() <<
" ; " << width.toStdString() <<
")");
204 agset(aNode,
const_cast<char*
>(
"height"), height.toLatin1().data());
205 agset(aNode,
const_cast<char*
>(
"width"), width.toLatin1().data());
206 agset(aNode,
const_cast<char*
>(
"shape"),
const_cast<char*
>(
"box") );
207 agset(aNode,
const_cast<char*
>(
"fixedsize"),
const_cast<char*
>(
"true") );
212 Agnode_t* aNode = NULL;
213 for (aNode = agfstnode(
_graph); aNode; aNode = agnxtnode(
_graph, aNode))
215 string aNodeName = agnameof(aNode);
216 DEBTRACE(
"--- tail node " << aNodeName);
217 Agnode_t* aTailNode = aNode;
221 DEBTRACE(
" =========== problem here ! =============================");
229 list<InGate*> setOfInGate = outGate->
edSetInGate();
230 list<InGate*>::const_iterator itin = setOfInGate.begin();
231 for (; itin != setOfInGate.end(); ++itin)
233 Node *inNode = (*itin)->getNode();
235 DEBTRACE(
"--- control link from tail node: --- "<<inName);
240 DEBTRACE(
"--- edge inside the bloc " << inDCNode->getName());
242 Agnode_t* aHeadNode = agnode(
_graph, (
char*)(inDCName.c_str()), 1);
243 Agedge_t* anEdge = agedge(
_graph, aTailNode, aHeadNode, NULL, 1);
244 DEBTRACE(
"--- control link from tail node: --- " << agnameof(aNode) <<
" --> " << inDCName);
253 list<OutPort*>::const_iterator itou = outPortList.begin();
254 for (; itou != outPortList.end(); ++itou)
256 set<InPort*> inPortList = (*itou)->edSetInPort();
257 set<InPort*>::const_iterator itin = inPortList.begin();
258 for (; itin != inPortList.end(); ++itin)
260 Node *inNode = (*itin)->getNode();
262 DEBTRACE(
"------ data link from tail node: ---- ");
265 DEBTRACE(
"--- edge inside the bloc " << inDCNode->getName());
267 Agnode_t* aHeadNode = agnode(
_graph, (
char*)(inDCName.c_str()), 1);
268 Agedge_t* anEdge = agedge(
_graph, aTailNode, aHeadNode, NULL, 1);
269 DEBTRACE(
"------ data link from tail node: ---- " << agnameof(aNode) <<
" --> " << inDCName);
280 DEBTRACE(
"SceneBlocItem::arrangeCanvasNodes");
291 for (list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
294 DEBTRACE(
"Get node in graph: " << agnameof(aNode));
298 qreal xCenter = ND_coord(aNode).x;
299 qreal yCenter = ND_coord(aNode).y;
303 sci->setPos(xOffset + xCenter -halfWidth, yHead + yCenter -halfHeight);
305 if (scni) scni->
setExpandedPos(QPointF(xOffset + xCenter -halfWidth, yHead + yCenter -halfHeight));
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Base class for all composed nodes.
std::string getChildName(const Node *node) const
Node * getChildByName(const std::string &name) const
virtual std::list< Node * > edGetDirectDescendants() const =0
std::string getName() const
Node * isInMyDescendance(Node *nodeToTest) const
Returns the parent of a node that is the direct child of this node.
Base class for all nodes.
ComposedNode * getFather() const
std::list< OutPort * > getSetOfOutPort() const
std::list< InGate * > edSetInGate() const
Base class for all schema objects.
YACS::HMI::SubjectProc * getSubjectProc()
YACS::ENGINE::Proc * getProc()
std::map< YACS::ENGINE::Node *, YACS::HMI::SubjectNode * > _mapOfSubjectNode
static GuiContext * getCurrent()
static QtGuiContext * getQtCurrent()
std::map< YACS::HMI::Subject *, YACS::HMI::SceneItem * > _mapOfSceneItem
virtual void arrangeCanvasNodes(YACS::ENGINE::ComposedNode *cnode)
virtual void arrangeChildNodes()
Auto-arrange nodes inside a schema using Graphviz C API.
virtual void getNodesInfo(YACS::ENGINE::ComposedNode *cnode)
virtual void rebuildLinks()
virtual QRectF boundingRect() const
virtual void checkGeometryChange()
virtual qreal getHeaderBottom()
void setExpandedPos(QPointF epos)
virtual Subject * getSubject()
static bool _autoComputeLinks
virtual YACS::ENGINE::Node * getNode()