46 #include <QGraphicsSceneDragDropEvent>
56 using namespace YACS::ENGINE;
57 using namespace YACS::HMI;
60 QString label,
Subject *subject)
63 DEBTRACE(
"SceneComposedNodeItem::SceneComposedNodeItem " <<label.toStdString());
83 for (list<AbstractSceneItem*>::const_iterator it=
_children.begin(); it!=
_children.end(); ++it)
86 scnode->adjustColors();
92 QRectF ChildrenBRect =QRectF(x(), y(), 5, 5);
94 for (list<AbstractSceneItem*>::const_iterator it=
_children.begin(); it!=
_children.end(); ++it)
102 const QStyleOptionGraphicsItem *option,
122 DEBTRACE(
"SceneComposedNodeItem::update "<<
eventName(event)<<
" "<<type<<
" "<<son);
206 DEBTRACE(
"SceneComposedNodeItem::update() ADD, type not handled:" << type);
213 if (
SubjectLink* slink = dynamic_cast<SubjectLink*>(son))
221 if (dynamic_cast<SubjectInputDataStreamPort*>(sinp))
262 if (!nodeto || !nodefrom)
DEBTRACE(
"CONTROLLINK problem -----------------");
265 if (!to || !from)
DEBTRACE(
"CONTROLLINK problem -----------------");
321 scnode->adjustColors();
327 if (dynamic_cast<SubjectForLoop*>(son) || dynamic_cast<SubjectForEachLoop*>(son))
341 const std::list<AbstractSceneItem*> alreadySet,
350 for (list<AbstractSceneItem*>::const_iterator it=alreadySet.begin(); it!=alreadySet.end(); ++it)
353 DEBTRACE((*it)->getLabel().toStdString());
354 DEBTRACE(
"childrenBox valid " << childrenBox.right() <<
" " << childrenBox.bottom());
356 if (childrenBox.isValid())
357 yTop = childrenBox.bottom() + 1.;
359 DEBTRACE(
"left, top " << xLeft <<
" " << yTop);
360 QPointF topLeft(xLeft, yTop);
397 std::list<SubjectControlLink*> lscl=
dynamic_cast<SubjectNode*
>(
getSubject())->getSubjectControlLinks();
398 for (std::list<SubjectControlLink*>::const_iterator it = lscl.begin(); it != lscl.end(); ++it) {
401 bool b1 =
true, b2 =
true;
432 bool toExpand =
true;
445 for (list<AbstractSceneItem*>::const_iterator it=
_children.begin(); it!=
_children.end(); ++it) {
470 for (list<AbstractSceneItem*>::const_iterator it=
_children.begin(); it!=
_children.end() && !res; ++it) {
477 res = scni->hasExpandedChildren(recursively);
485 DEBTRACE(
"SceneComposedNodeItem::shrinkExpandRecursive " << isExpanding <<
" " << fromHere <<
" " <<
isExpanded() <<
" " <<
_label.toStdString());
487 bool toChangeShrinkState =
false;
488 switch (theShrinkMode) {
491 toChangeShrinkState =
true;
495 toChangeShrinkState =
true;
498 toChangeShrinkState =
false;
501 if (toChangeShrinkState) {
512 for (list<AbstractSceneItem*>::const_iterator it=
_children.begin(); it!=
_children.end(); ++it)
518 DEBTRACE(
"------------------------------- Hide " << item->
getLabel().toStdString());
557 if (toChangeShrinkState)
560 for (list<AbstractSceneItem*>::const_iterator it=
_children.begin(); it!=
_children.end(); ++it)
568 DEBTRACE(
"------------------------------- Show " << item->
getLabel().toStdString());
573 DEBTRACE(
"------------------------------- Hide " << item->
getLabel().toStdString());
599 DEBTRACE(
"SceneComposedNodeItem::shrinkExpandLink " << se <<
" " <<
_label.toStdString());
602 if (
SceneItem *sci = dynamic_cast<SceneItem*>(child)) {
603 sci->shrinkExpandLink(se);
610 DEBTRACE(
"SceneComposedNodeItem::reorganize() " <<
_label.toStdString());
611 list<AbstractSceneItem*> alreadySet;
612 for (list<AbstractSceneItem*>::const_iterator it=
_children.begin(); it!=
_children.end(); ++it)
615 alreadySet.push_back(*it);
640 for (list<AbstractSceneItem*>::const_iterator it=
_children.begin(); it!=
_children.end(); ++it)
643 if (other && (other != child))
645 if (child->collidesWithItem(other))
649 qreal oldX = oldPos.x();
650 qreal oldY = oldPos.y();
651 qreal newX = child->pos().x();
652 qreal newY = child->pos().y();
653 qreal othX = otherBR.left()+0.5;
654 qreal othY = otherBR.top()+0.5;
660 bool fromTop = (((oldY + child->
boundingRect().height()) <= otherBR.top()+1) &&
661 ((newY + child->
boundingRect().height()) >= otherBR.top()));
662 bool fromBottom = (( oldY >= otherBR.bottom()) &&
663 ( newY <= otherBR.bottom()));
664 bool fromRight = (( oldX >= otherBR.right()) &&
665 ( newX <= otherBR.right()));
666 bool fromLeft = (((oldX+ child->
boundingRect().width()) <= otherBR.left()+1) &&
667 ((newX+ child->
boundingRect().width()) >= otherBR.left()));
670 bool pushOther =
false;
671 bool blocThis =
false;
688 newY = otherBR.bottom() + 1;
694 othY = newY - otherBR.height();
699 newY = otherBR.bottom() + 1;
711 newX = otherBR.right()+ 1;
717 othX = newX - otherBR.width();
722 newX = otherBR.right()+ 1;
731 if (blocThis) child->
setTopLeft(QPointF(newX, newY));
754 for (list<linkdef>::const_iterator ii = blist.begin(); ii != blist.end(); ++ii)
755 alist.push_back(*ii);
760 for (list<linkdef>::const_iterator it = alist.begin(); it != alist.end(); ++it)
764 <<
") to ("<<ali.
to.first<<
","<<ali.
to.second
766 if(ali.
from.first<0||ali.
from.second<0||ali.
to.first<0||ali.
to.second<0)
continue;
771 if (! isPath)
DEBTRACE(
"Link Path not found !");
772 if (! isPath)
continue;
786 DEBTRACE(
"SceneComposedItem::arrangeNodes " << isRecursive);
799 for (list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
801 DEBTRACE(
"child " << (*it)->getName());
810 if (scni && (scni->getShownState() ==
expandShown))
812 DEBTRACE(
"call arrangeNode on child " << (*it)->getName());
813 scni->arrangeNodes(isRecursive);
836 bool accepted =
false;
840 if (myData->hasFormat(
"yacs/cataService") ||
841 myData->hasFormat(
"yacs/cataNode") ||
842 myData->hasFormat(
"yacs/subjectNode"))
844 event->setAccepted(
true);
846 QGraphicsItem::update();
850 event->setAccepted(accepted);
857 QGraphicsItem::update();
864 QGraphicsItem::update();
869 if (myData->hasFormat(
"yacs/cataService") || myData->hasFormat(
"yacs/cataNode"))
879 else if(myData->hasFormat(
"yacs/subjectNode"))
885 if (dynamic_cast<SubjectProc*>(node))
return;
928 if (
SceneItem *sci = dynamic_cast<SceneItem*>(child))