46 #include <QGraphicsSceneDragDropEvent>
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);
262 if (!nodeto || !nodefrom)
DEBTRACE(
"CONTROLLINK problem -----------------");
265 if (!to || !from)
DEBTRACE(
"CONTROLLINK problem -----------------");
321 scnode->adjustColors();
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);
381 m.popupMenu(caller, globalPos);
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 " << toExpand <<
" " << 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());
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());
812 DEBTRACE(
"call arrangeNode on child " << (*it)->getName());
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"))
#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.
virtual std::list< Node * > edGetDirectDescendants() const =0
Base class for all nodes.
Control node that emulates the C switch.
Node * edGetNode(int caseId)
virtual void setTopLeft(QPointF topLeft)=0
virtual void addProgressItem()
virtual QRectF childBoundingRect(AbstractSceneItem *child) const
virtual QString getLabel()
YACS::HMI::Scene * _scene
YACS::HMI::GuiEditor * _guiEditor
YACS::HMI::SubjectProc * getSubjectProc()
std::map< YACS::ENGINE::Node *, YACS::HMI::SubjectNode * > _mapOfSubjectNode
static GuiContext * getCurrent()
void CreateNodeFromCatalog(const ItemMimeData *myData, SubjectComposedNode *cnode, bool createNewComponentInstance)
static std::string eventName(GuiEvent event)
virtual bool getControl() const
virtual Subject * getSubject(int i=0) const
bool computePath(LNode from, LNode to)
std::list< linkdef > getListOfCtrlLinkDef()
std::list< linkdef > getListOfDataLinkDef()
LinkPath getPath(LNodePath lnp)
void incrementCost(LNodePath lnp)
static QtGuiContext * getQtCurrent()
YACS::HMI::GenericGui * getGMain()
std::map< YACS::HMI::Subject *, YACS::HMI::SceneItem * > _mapOfSceneItem
static int DataPort_Width
static bool COMPONENT_INSTANCE_NEW
static QColor ComposedNode_brush
static QColor emphasizeBrushColor
static int DataPort_Height
static QColor ComposedNode_hiPen
static QColor ComposedNode_hiBrush
static QColor ComposedNode_pen
virtual void updateChildItems()
virtual void popupMenu(QWidget *caller, const QPoint &globalPos)
virtual void arrangeNodes(bool isRecursive)
generic method to compute a graph for child nodes. implemented in some derived classes
std::list< AbstractSceneItem * > _children
SceneComposedNodeItem(QGraphicsScene *scene, SceneItem *parent, QString label, Subject *subject)
virtual ~SceneComposedNodeItem()
virtual void removeChildFromList(AbstractSceneItem *child)
virtual void reorganize()
void dropEvent(QGraphicsSceneDragDropEvent *event)
virtual void setShownState(shownState ss)
virtual std::list< AbstractSceneItem * > getChildren()
virtual void autoPosNewChild(AbstractSceneItem *item, const std::list< AbstractSceneItem * > alreadySet, bool isNew=false)
void dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
virtual void update(GuiEvent event, int type, Subject *son)
void updateControlLinks(bool toExpand)
virtual QColor getPenColor()
virtual void shrinkExpandRecursive(bool isExpanding, bool fromHere, ShrinkMode theShrinkMode)
virtual bool hasExpandedChildren(bool recursively)
virtual void adjustColors()
virtual void collisionResolv(SceneItem *child, QPointF oldPos)
virtual void arrangeChildNodes()
virtual QRectF childrenBoundingRect() const
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
virtual void reorganizeShrinkExpand(ShrinkMode theShrinkMode)
virtual QColor getBrushColor()
virtual void rebuildLinks()
void dragEnterEvent(QGraphicsSceneDragDropEvent *event)
virtual void shrinkExpandLink(bool se)
virtual void setTopLeft(QPointF topLeft)
virtual void shrinkExpandRecursive(bool isExpanding, bool fromHere, ShrinkMode theShrinkMode)
QColor hoverColor(QColor origColor)
void setParent(SceneItem *parent)
virtual void shrinkExpandLink(bool se)
virtual QRectF boundingRect() const
void setEventPos(QPointF point)
virtual SceneNodeItem * getToNode()
virtual SceneNodeItem * getFromNode()
virtual void updateShape()
virtual void setPath(LinkPath lp)
virtual void setTopLeft(QPointF topLeft)
virtual qreal getHeaderBottom()
SceneHeaderNodeItem * _header
SceneProgressItem * _progressItem
virtual void updateName()
virtual void update(GuiEvent event, int type, Subject *son)
virtual ScenePortItem * getCtrlInPortItem()
std::list< AbstractSceneItem * > _outPorts
shownState getShownState()
virtual void updateChildItems()
virtual void adjustHeader()
virtual SceneProgressItem * getProgressItem()
std::list< AbstractSceneItem * > _inPorts
virtual ScenePortItem * getCtrlOutPortItem()
virtual Subject * getSubject()
virtual void adjustGeometry()
static bool _autoComputeLinks
virtual bool reparent(Subject *parent)
virtual YACS::ENGINE::Node * getNode()
virtual std::string getName()
virtual std::string getProgress()
std::list< LNode > LNodePath
std::list< linkPoint > LinkPath
YACS::HMI::SceneLinkItem * item
std::pair< int, int > from