Version: 9.16.0
YACS::HMI::SceneComposedNodeItem Class Reference

#include <SceneComposedNodeItem.hxx>

Inheritance diagram for YACS::HMI::SceneComposedNodeItem:
Collaboration diagram for YACS::HMI::SceneComposedNodeItem:

Public Member Functions

 SceneComposedNodeItem (QGraphicsScene *scene, SceneItem *parent, QString label, Subject *subject)
 
virtual ~SceneComposedNodeItem ()
 
virtual QRectF childrenBoundingRect () const
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 
virtual void update (GuiEvent event, int type, Subject *son)
 
virtual void autoPosNewChild (AbstractSceneItem *item, const std::list< AbstractSceneItem * > alreadySet, bool isNew=false)
 
virtual void popupMenu (QWidget *caller, const QPoint &globalPos)
 
virtual std::list< AbstractSceneItem * > getChildren ()
 
virtual void removeChildFromList (AbstractSceneItem *child)
 
virtual void reorganize ()
 
virtual void reorganizeShrinkExpand (ShrinkMode theShrinkMode)
 
virtual void shrinkExpandRecursive (bool isExpanding, bool fromHere, ShrinkMode theShrinkMode)
 
virtual void shrinkExpandLink (bool se)
 
virtual void collisionResolv (SceneItem *child, QPointF oldPos)
 
virtual void rebuildLinks ()
 
virtual void updateChildItems ()
 
virtual void arrangeNodes (bool isRecursive)
 generic method to compute a graph for child nodes. implemented in some derived classes More...
 
virtual void arrangeChildNodes ()
 
virtual void adjustColors ()
 
virtual void setShownState (shownState ss)
 
virtual bool hasExpandedChildren (bool recursively)
 
- Public Member Functions inherited from YACS::HMI::SceneNodeItem
 SceneNodeItem (QGraphicsScene *scene, SceneItem *parent, QString label, Subject *subject)
 
virtual ~SceneNodeItem ()
 
virtual void setWidth (qreal width)
 AbstractSceneItem cannot be resized (only ComposedNodeItem can) More...
 
virtual void setHeight (qreal height)
 AbstractSceneItem cannot be resized (only ComposedNodeItem can) More...
 
virtual void addHeader ()
 
virtual SceneHeaderItemgetHeader ()
 
virtual void addProgressItem ()
 
virtual SceneProgressItemgetProgressItem ()
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 
virtual void update (GuiEvent event, int type, Subject *son)
 
virtual qreal getHeaderBottom ()
 
virtual void autoPosNewPort (AbstractSceneItem *item, int nbPorts)
 
virtual void popupMenu (QWidget *caller, const QPoint &globalPos)
 
virtual SceneComposedNodeItemgetParent ()
 
virtual void removeInPortFromList (AbstractSceneItem *inPort)
 
virtual void removeOutPortFromList (AbstractSceneItem *outPort)
 
virtual void setMoving (bool moving)
 
virtual void setTopLeft (QPointF topLeft)
 
virtual void adjustHeader ()
 
virtual ScenePortItemgetCtrlInPortItem ()
 
virtual ScenePortItemgetCtrlOutPortItem ()
 
virtual void updateName ()
 
virtual void arrangeNodes (bool isRecursive)
 generic method to compute a graph for child nodes. implemented in some derived classes More...
 
virtual void arrangeChildNodes ()
 
virtual void reorganizeShrinkExpand (ShrinkMode theShrinkMode)
 
virtual void updateChildItems ()
 
virtual void shrinkExpandLink (bool se)
 
virtual void showOutScopeLinks ()
 
virtual void updateLinks ()
 
virtual void setShownState (shownState ss)
 
bool isExpanded ()
 
void setExpanded (bool e)
 
void setExpandedPos (QPointF epos)
 
qreal getExpandedX ()
 
qreal getExpandedY ()
 
void setExpandedWH ()
 
void setExpandedWH (qreal w, qreal h)
 
qreal getExpandedWidth ()
 
qreal getExpandedHeight ()
 
shownState getShownState ()
 
bool hasProgressBar () const
 
- Public Member Functions inherited from YACS::HMI::SceneObserverItem
 SceneObserverItem (QGraphicsScene *scene, SceneItem *parent, QString label, Subject *subject)
 
virtual ~SceneObserverItem ()
 
virtual void update (GuiEvent event, int type, Subject *son)
 
virtual void select (bool isSelected)
 
virtual void activateSelection (bool selected)
 
virtual SubjectgetSubject ()
 
virtual QString getToolTip ()
 
- Public Member Functions inherited from YACS::HMI::SceneItem
 SceneItem (QGraphicsScene *scene, SceneItem *parent, QString label)
 
virtual ~SceneItem ()
 
virtual QRectF boundingRect () const
 
virtual QRectF childrenBoundingRect () const
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 
virtual void setTopLeft (QPointF topLeft)
 
virtual void checkGeometryChange ()
 
virtual void popupMenu (QWidget *caller, const QPoint &globalPos)
 
void setParent (SceneItem *parent)
 
virtual QString getToolTip ()
 
void setEventPos (QPointF point)
 
virtual void updateChildItems ()
 
virtual void updateLinks ()
 
virtual void shrinkExpandLink (bool se)
 
virtual void shrinkExpandRecursive (bool isExpanding, bool fromHere, ShrinkMode theShrinkMode)
 
bool isAncestorShrinked ()
 
- Public Member Functions inherited from YACS::HMI::AbstractSceneItem
 AbstractSceneItem (QGraphicsScene *scene, SceneItem *parent, QString label)
 
virtual ~AbstractSceneItem ()
 
virtual QRectF boundingRect () const =0
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)=0
 
virtual void setTopLeft (QPointF topLeft)=0
 
int getLevel ()
 
void setLevel ()
 
virtual void checkGeometryChange ()=0
 
virtual void reorganize ()
 
virtual QString getLabel ()
 
virtual void addHeader ()
 
virtual void addProgressItem ()
 
virtual qreal getHeaderBottom ()
 
qreal getWidth ()
 
qreal getHeight ()
 
virtual void setWidth (qreal width)
 AbstractSceneItem cannot be resized (only ComposedNodeItem can) More...
 
virtual void setHeight (qreal height)
 AbstractSceneItem cannot be resized (only ComposedNodeItem can) More...
 
virtual void popupMenu (QWidget *caller, const QPoint &globalPos)=0
 
virtual void activateSelection (bool selected)
 
virtual void setGeometryOptimization (bool optimize)
 
SceneItemgetParent ()
 
- Public Member Functions inherited from YACS::HMI::GuiObserver
 GuiObserver ()
 
virtual ~GuiObserver ()
 
virtual void select (bool isSelected)
 
virtual void update (GuiEvent event, int type, Subject *son)
 
virtual void incrementSubjects (Subject *subject)
 
virtual void decrementSubjects (Subject *subject)
 
int getNbSubjects ()
 
bool isDestructible ()
 

Protected Member Functions

void dragEnterEvent (QGraphicsSceneDragDropEvent *event)
 
void dragLeaveEvent (QGraphicsSceneDragDropEvent *event)
 
void dropEvent (QGraphicsSceneDragDropEvent *event)
 
void updateControlLinks (bool toExpand)
 
virtual QColor getPenColor ()
 
virtual QColor getBrushColor ()
 
- Protected Member Functions inherited from YACS::HMI::SceneNodeItem
virtual QString getMimeFormat ()
 
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event)
 
virtual void updateState ()
 
virtual void setExecState (int execState)
 
QString getHeaderLabel ()
 
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 
virtual QColor getBrushColor ()
 
virtual QString getMimeFormat ()
 
- Protected Member Functions inherited from YACS::HMI::SceneItem
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
 
virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *event)
 
virtual void hoverMoveEvent (QGraphicsSceneHoverEvent *event)
 
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 
virtual QColor getPenColor ()
 
virtual QColor getBrushColor ()
 
QColor hoverColor (QColor origColor)
 
- Protected Member Functions inherited from YACS::HMI::AbstractSceneItem
virtual QRectF childBoundingRect (AbstractSceneItem *child) const
 

Protected Attributes

std::list< AbstractSceneItem * > _children
 
bool _dragOver
 
- Protected Attributes inherited from YACS::HMI::SceneNodeItem
std::list< AbstractSceneItem * > _inPorts
 
std::list< AbstractSceneItem * > _outPorts
 
SceneHeaderNodeItem_header
 
SceneProgressItem_progressItem
 
int _execState
 
bool _moving
 
bool _moved
 
bool _expanded
 
QPointF _prevPos
 
QPointF _expandedPos
 
qreal _expandedWidth
 
qreal _expandedHeight
 
shownState _shownState
 
- Protected Attributes inherited from YACS::HMI::SceneObserverItem
Subject_subject
 
bool _draging
 
bool _dragModifier
 
bool _emphasized
 
- Protected Attributes inherited from YACS::HMI::SceneItem
bool _hover
 
bool _ancestorShrinked
 
QPointF _eventPos
 
- Protected Attributes inherited from YACS::HMI::AbstractSceneItem
SceneItem_parent
 
YACS::HMI::Scene_scene
 
QString _label
 
int _level
 
qreal _width
 
qreal _height
 
qreal _incHeight
 
QColor _penColor
 
QColor _brushColor
 
QColor _hiPenColor
 
QColor _hiBrushColor
 
bool _hasHeader
 
bool _optimize
 
bool _dragable
 
enum Qt::MouseButton _dragButton
 
- Protected Attributes inherited from YACS::HMI::GuiObserver
std::set< Subject * > _subjectSet
 
bool _destructible
 

Additional Inherited Members

- Static Public Member Functions inherited from YACS::HMI::GuiObserver
static std::string eventName (GuiEvent event)
 
static void setEventMap ()
 
- Public Attributes inherited from YACS::HMI::SceneItem
bool _blocX
 
bool _blocY
 
- Static Protected Attributes inherited from YACS::HMI::GuiObserver
static std::map< int, std::string > _eventNameMap
 

Detailed Description

Definition at line 29 of file SceneComposedNodeItem.hxx.

Constructor & Destructor Documentation

◆ SceneComposedNodeItem()

SceneComposedNodeItem::SceneComposedNodeItem ( QGraphicsScene scene,
SceneItem parent,
QString  label,
Subject subject 
)

Definition at line 59 of file SceneComposedNodeItem.cxx.

61 : SceneNodeItem(scene, parent, label, subject)
62{
63 DEBTRACE("SceneComposedNodeItem::SceneComposedNodeItem " <<label.toStdString());
64
67
72 _dragOver = false;
73 setAcceptDrops(true);
74}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
static int DataPort_Width
Definition: Resource.hxx:305
static int Corner_Margin
Definition: Resource.hxx:318
static int DataPort_Height
Definition: Resource.hxx:306
static int Space_Margin
Definition: Resource.hxx:311
static int Header_Height
Definition: Resource.hxx:319
static QColor ComposedNode_hiPen
Definition: Resource.hxx:278
static QColor ComposedNode_hiBrush
Definition: Resource.hxx:276
static QColor ComposedNode_pen
Definition: Resource.hxx:277
SceneNodeItem(QGraphicsScene *scene, SceneItem *parent, QString label, Subject *subject)

References _dragOver, YACS::HMI::AbstractSceneItem::_height, YACS::HMI::AbstractSceneItem::_hiBrushColor, YACS::HMI::AbstractSceneItem::_hiPenColor, YACS::HMI::AbstractSceneItem::_penColor, YACS::HMI::AbstractSceneItem::_width, adjustColors(), YACS::HMI::Resource::ComposedNode_hiBrush, YACS::HMI::Resource::ComposedNode_hiPen, YACS::HMI::Resource::ComposedNode_pen, YACS::HMI::Resource::Corner_Margin, YACS::HMI::Resource::DataPort_Height, YACS::HMI::Resource::DataPort_Width, DEBTRACE, YACS::HMI::Resource::Header_Height, and YACS::HMI::Resource::Space_Margin.

Referenced by update().

◆ ~SceneComposedNodeItem()

SceneComposedNodeItem::~SceneComposedNodeItem ( )
virtual

Definition at line 76 of file SceneComposedNodeItem.cxx.

77{
78}

Member Function Documentation

◆ adjustColors()

void SceneComposedNodeItem::adjustColors ( )
virtual

Definition at line 80 of file SceneComposedNodeItem.cxx.

81{
83 for (list<AbstractSceneItem*>::const_iterator it=_children.begin(); it!=_children.end(); ++it)
84 {
85 if (SceneComposedNodeItem *scnode = dynamic_cast<SceneComposedNodeItem*>(*it))
86 scnode->adjustColors();
87 }
88 }
static QColor ComposedNode_brush
Definition: Resource.hxx:275
std::list< AbstractSceneItem * > _children

References YACS::HMI::AbstractSceneItem::_brushColor, _children, YACS::HMI::AbstractSceneItem::_level, and YACS::HMI::Resource::ComposedNode_brush.

Referenced by SceneComposedNodeItem().

◆ arrangeChildNodes()

void SceneComposedNodeItem::arrangeChildNodes ( )
virtual

Reimplemented from YACS::HMI::SceneNodeItem.

Reimplemented in YACS::HMI::SceneBlocItem.

Definition at line 829 of file SceneComposedNodeItem.cxx.

830{
831 reorganize();
832}

References reorganize().

Referenced by arrangeNodes().

◆ arrangeNodes()

void SceneComposedNodeItem::arrangeNodes ( bool  isRecursive)
virtual

generic method to compute a graph for child nodes. implemented in some derived classes

Reimplemented from YACS::HMI::SceneNodeItem.

Definition at line 784 of file SceneComposedNodeItem.cxx.

785{
786 DEBTRACE("SceneComposedItem::arrangeNodes " << isRecursive);
787
788 bool isExtern = !QtGuiContext::_delayCalc;
789 QtGuiContext::_delayCalc = true; // avoid rebuildLinks
790
791 SubjectComposedNode *scnode = dynamic_cast<SubjectComposedNode*>(getSubject());
792 YASSERT(scnode);
793 ComposedNode *cnode = dynamic_cast<ComposedNode*>(scnode->getNode());
794 YASSERT(cnode);
795
796 if (isRecursive)
797 {
798 list<Node*> children = cnode->edGetDirectDescendants();
799 for (list<Node*>::iterator it = children.begin(); it != children.end(); ++it)
800 {
801 DEBTRACE("child " << (*it)->getName());
802 SceneComposedNodeItem *scni = 0;
803 ComposedNode *cchild = dynamic_cast<ComposedNode*>(*it);
804 if (cchild)
805 {
808 if (sci) scni = dynamic_cast<SceneComposedNodeItem*>(sci);
809 }
810 if (scni && (scni->getShownState() == expandShown))
811 {
812 DEBTRACE("call arrangeNode on child " << (*it)->getName());
813 scni->arrangeNodes(isRecursive);
814 }
815 }
817 }
818 else
820
821 if (isExtern)
822 {
823 QtGuiContext::_delayCalc = false; // allow rebuildLinks
825 rebuildLinks();
826 }
827}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
Base class for all composed nodes.
virtual std::list< Node * > edGetDirectDescendants() const =0
static GuiContext * getCurrent()
Definition: guiContext.hxx:67
std::map< YACS::ENGINE::Node *, YACS::HMI::SubjectNode * > _mapOfSubjectNode
Definition: guiContext.hxx:70
static QtGuiContext * getQtCurrent()
std::map< YACS::HMI::Subject *, YACS::HMI::SceneItem * > _mapOfSceneItem
virtual void arrangeNodes(bool isRecursive)
generic method to compute a graph for child nodes. implemented in some derived classes
static bool _autoComputeLinks
Definition: Scene.hxx:37
virtual YACS::ENGINE::Node * getNode()

References YACS::HMI::Scene::_autoComputeLinks, YACS::HMI::QtGuiContext::_delayCalc, YACS::HMI::QtGuiContext::_mapOfSceneItem, YACS::HMI::GuiContext::_mapOfSubjectNode, arrangeChildNodes(), arrangeNodes(), DEBTRACE, YACS::ENGINE::ComposedNode::edGetDirectDescendants(), YACS::HMI::expandShown, YACS::HMI::GuiContext::getCurrent(), YACS::HMI::SubjectNode::getNode(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::SceneNodeItem::getShownState(), YACS::HMI::SceneObserverItem::getSubject(), rebuildLinks(), and YASSERT.

Referenced by YACS::HMI::GuiEditor::arrangeNodes(), arrangeNodes(), and YACS::HMI::GuiEditor::arrangeProc().

◆ autoPosNewChild()

void SceneComposedNodeItem::autoPosNewChild ( AbstractSceneItem item,
const std::list< AbstractSceneItem * >  alreadySet,
bool  isNew = false 
)
virtual

Definition at line 340 of file SceneComposedNodeItem.cxx.

343{
344 SceneItem *it = dynamic_cast<SceneItem*>(item);
345 YASSERT(it);
346
347 QRectF childrenBox;
348 qreal xLeft = Resource::Corner_Margin;
350 for (list<AbstractSceneItem*>::const_iterator it=alreadySet.begin(); it!=alreadySet.end(); ++it)
351 {
352 childrenBox = childrenBox.united(childBoundingRect(*it));
353 DEBTRACE((*it)->getLabel().toStdString());
354 DEBTRACE("childrenBox valid " << childrenBox.right() << " " << childrenBox.bottom());
355 }
356 if (childrenBox.isValid())
357 yTop = childrenBox.bottom() + 1.; // +1. to avoid collision with bottom (penwidth)
358 //xLeft += childrenBox.right();
359 DEBTRACE("left, top " << xLeft << " " << yTop);
360 QPointF topLeft(xLeft, yTop);
361 if (isNew) _children.push_back(item);
362 if (_eventPos.isNull())
363 {
364 //DEBTRACE("_eventPos.isNull");
365 item->setTopLeft(topLeft);
366 }
367 else
368 {
369 //DEBTRACE("_eventPos " << _eventPos.x() << " " << _eventPos.y());
370 item->setTopLeft(_eventPos);
371 }
372 collisionResolv(it, -it->boundingRect().bottomRight()); // as if the new item was coming from top left (previous position outside)
374 _eventPos.setX(0);
375 _eventPos.setY(0);
376}
virtual void setTopLeft(QPointF topLeft)=0
virtual QRectF childBoundingRect(AbstractSceneItem *child) const
Definition: SceneItem.cxx:173
virtual void collisionResolv(SceneItem *child, QPointF oldPos)
virtual QRectF boundingRect() const
Definition: SceneItem.cxx:215
virtual qreal getHeaderBottom()

References YACS::HMI::Scene::_autoComputeLinks, _children, YACS::HMI::SceneItem::_eventPos, YACS::HMI::SceneItem::boundingRect(), YACS::HMI::AbstractSceneItem::childBoundingRect(), collisionResolv(), YACS::HMI::Resource::Corner_Margin, DEBTRACE, YACS::HMI::SceneNodeItem::getHeaderBottom(), YACS::HMI::QtGuiContext::getQtCurrent(), rebuildLinks(), YACS::HMI::AbstractSceneItem::setTopLeft(), YACS::HMI::Resource::Space_Margin, and YASSERT.

Referenced by reorganize(), and update().

◆ childrenBoundingRect()

QRectF SceneComposedNodeItem::childrenBoundingRect ( ) const
virtual

Reimplemented from YACS::HMI::SceneItem.

Definition at line 90 of file SceneComposedNodeItem.cxx.

91{
92 QRectF ChildrenBRect =QRectF(x(), y(), 5, 5);
93 if (_header) ChildrenBRect = _header->getMinimalBoundingRect();
94 for (list<AbstractSceneItem*>::const_iterator it=_children.begin(); it!=_children.end(); ++it)
95 ChildrenBRect = ChildrenBRect.united(childBoundingRect(*it));
96 ChildrenBRect.setWidth (ChildrenBRect.width() + Resource::Border_Margin);
97 ChildrenBRect.setHeight(ChildrenBRect.height() + Resource::Border_Margin);
98 return ChildrenBRect;
99}
static int Border_Margin
Definition: Resource.hxx:310
virtual QRectF getMinimalBoundingRect() const
SceneHeaderNodeItem * _header

References _children, YACS::HMI::SceneNodeItem::_header, YACS::HMI::Resource::Border_Margin, YACS::HMI::AbstractSceneItem::childBoundingRect(), and YACS::HMI::SceneHeaderNodeItem::getMinimalBoundingRect().

◆ collisionResolv()

void SceneComposedNodeItem::collisionResolv ( SceneItem child,
QPointF  oldPos 
)
virtual

Definition at line 637 of file SceneComposedNodeItem.cxx.

638{
639 //DEBTRACE("SceneComposedNodeItem::collisionResolv " << _label.toStdString());
640 for (list<AbstractSceneItem*>::const_iterator it=_children.begin(); it!=_children.end(); ++it)
641 {
642 SceneNodeItem *other = dynamic_cast<SceneNodeItem*>(*it);
643 if (other && (other != child))
644 {
645 if (child->collidesWithItem(other))
646 {
647 //DEBTRACE("collision detected with " << other->getLabel().toStdString());
648 QRectF otherBR = (other->mapToParent(other->boundingRect())).boundingRect();
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;
655 //DEBTRACE("oldX=" << oldX << " oldY=" << oldY << " newX=" << newX << " newY=" << newY);
656 //DEBTRACE("otherLeft=" << otherBR.left() << " otherRight=" << otherBR.right() <<
657 // " otherTop=" << otherBR.top() << " otherBottom=" << otherBR.bottom());
658 //DEBTRACE("width=" << child->boundingRect().width() <<
659 // " height=" << child->boundingRect().height());
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()));
668 //DEBTRACE("fromTop=" << fromTop << " fromBottom=" << fromBottom
669 // << " fromRight=" << fromRight << " fromLeft=" << fromLeft);
670 bool pushOther =false;
671 bool blocThis = false;
672 if (fromTop)
673 {
674 othY = newY + child->boundingRect().height();
675 pushOther = true;
676 other->_blocY = false;
677 }
678 if (fromLeft)
679 {
680 othX = newX+ child->boundingRect().width();
681 pushOther = true;
682 other->_blocX = false;
683 }
684 if (fromBottom)
685 {
686 if (other->_blocY)
687 {
688 newY = otherBR.bottom() + 1;
689 blocThis = true;
690 _blocY = true;
691 }
692 else
693 {
694 othY = newY - otherBR.height();
696 {
698 other->_blocY = true;
699 newY = otherBR.bottom() + 1;
700 _blocY = true;
701 blocThis = true;
702 }
703 else
704 pushOther = true;
705 }
706 }
707 if (fromRight)
708 {
709 if (other->_blocX)
710 {
711 newX = otherBR.right()+ 1;
712 blocThis = true;
713 _blocX = true;
714 }
715 else
716 {
717 othX = newX - otherBR.width();
718 if (othX < Resource::Space_Margin)
719 {
721 other->_blocX = true;
722 newX = otherBR.right()+ 1;
723 _blocX = true;
724 blocThis = true;
725 }
726 else
727 pushOther = true;
728 }
729 }
730 //DEBTRACE("newX=" << newX << " newY=" << newY);
731 if (blocThis) child->setTopLeft(QPointF(newX, newY));
732 if (pushOther)
733 {
734 other->setTopLeft(QPointF(othX, othY));
735 }
736 }
737 }
738 }
739}
virtual void setTopLeft(QPointF topLeft)
Definition: SceneItem.cxx:241
virtual void setTopLeft(QPointF topLeft)

References YACS::HMI::SceneItem::_blocX, YACS::HMI::SceneItem::_blocY, _children, YACS::HMI::SceneItem::boundingRect(), YACS::HMI::SceneNodeItem::getHeaderBottom(), YACS::HMI::SceneItem::setTopLeft(), YACS::HMI::SceneNodeItem::setTopLeft(), and YACS::HMI::Resource::Space_Margin.

Referenced by autoPosNewChild().

◆ dragEnterEvent()

void SceneComposedNodeItem::dragEnterEvent ( QGraphicsSceneDragDropEvent *  event)
protected

Definition at line 834 of file SceneComposedNodeItem.cxx.

835{
836 bool accepted = false;
837 const ItemMimeData *myData = dynamic_cast<const ItemMimeData*>(event->mimeData());
838 if (myData)
839 {
840 if (myData->hasFormat("yacs/cataService") ||
841 myData->hasFormat("yacs/cataNode") ||
842 myData->hasFormat("yacs/subjectNode"))
843 {
844 event->setAccepted(true);
845 _dragOver = true;
846 QGraphicsItem::update();
847 return;
848 }
849 }
850 event->setAccepted(accepted);
851}

References _dragOver.

◆ dragLeaveEvent()

void SceneComposedNodeItem::dragLeaveEvent ( QGraphicsSceneDragDropEvent *  event)
protected

Definition at line 853 of file SceneComposedNodeItem.cxx.

854{
855 Q_UNUSED(event);
856 _dragOver = false;
857 QGraphicsItem::update();
858}

References _dragOver.

◆ dropEvent()

void SceneComposedNodeItem::dropEvent ( QGraphicsSceneDragDropEvent *  event)
protected

Definition at line 860 of file SceneComposedNodeItem.cxx.

861{
862 Q_UNUSED(event);
863 _dragOver = false;
864 QGraphicsItem::update();
865
866 const ItemMimeData *myData = dynamic_cast<const ItemMimeData*>(event->mimeData());
867 if (!myData) return;
868 setEventPos(event->scenePos());
869 if (myData->hasFormat("yacs/cataService") || myData->hasFormat("yacs/cataNode"))
870 {
871 SubjectComposedNode *cnode = dynamic_cast<SubjectComposedNode*>(getSubject());
872 bool createNewComponentInstance=Resource::COMPONENT_INSTANCE_NEW;
873 // by default getControl gives false. In this case we use the user preference COMPONENT_INSTANCE_NEW
874 // to create the node. If getControl gives true we invert the user preference
875 if(myData->getControl())
876 createNewComponentInstance=!Resource::COMPONENT_INSTANCE_NEW;
877 QtGuiContext::getQtCurrent()->getGMain()->_guiEditor->CreateNodeFromCatalog(myData, cnode,createNewComponentInstance);
878 }
879 else if(myData->hasFormat("yacs/subjectNode"))
880 {
881 Subject *sub = myData->getSubject();
882 if (!sub) return;
883 SubjectNode *node = dynamic_cast<SubjectNode*>(sub);
884 if (!node) return;
885 if (dynamic_cast<SubjectProc*>(node)) return; // --- do not reparent proc !
886 SubjectComposedNode *cnode = dynamic_cast<SubjectComposedNode*>(getSubject());
887 if (cnode)
888 if (!node->reparent(cnode))
889 Message mess;
890 }
891}
YACS::HMI::GuiEditor * _guiEditor
Definition: GenericGui.hxx:201
void CreateNodeFromCatalog(const ItemMimeData *myData, SubjectComposedNode *cnode, bool createNewComponentInstance)
Definition: GuiEditor.cxx:83
virtual bool getControl() const
virtual Subject * getSubject(int i=0) const
YACS::HMI::GenericGui * getGMain()
static bool COMPONENT_INSTANCE_NEW
Definition: Resource.hxx:206
void setEventPos(QPointF point)
virtual bool reparent(Subject *parent)

References _dragOver, YACS::HMI::GenericGui::_guiEditor, YACS::HMI::Resource::COMPONENT_INSTANCE_NEW, YACS::HMI::GuiEditor::CreateNodeFromCatalog(), YACS::HMI::ItemMimeData::getControl(), YACS::HMI::QtGuiContext::getGMain(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::SceneObserverItem::getSubject(), YACS::HMI::ItemMimeData::getSubject(), YACS::HMI::SubjectNode::reparent(), and YACS::HMI::SceneItem::setEventPos().

◆ getBrushColor()

QColor SceneComposedNodeItem::getBrushColor ( )
protectedvirtual

Reimplemented from YACS::HMI::SceneObserverItem.

Definition at line 903 of file SceneComposedNodeItem.cxx.

904{
905 if (_dragOver)
906 return _hiBrushColor;
907
908 QColor color;
909 if (isSelected())
910 color = _hiBrushColor;
911 else if (_emphasized)
913 else
914 color = _brushColor;
915
916 if (_hover)
917 color = hoverColor(color);
918 return color;
919}
static QColor emphasizeBrushColor
Definition: Resource.hxx:225
QColor hoverColor(QColor origColor)

References YACS::HMI::AbstractSceneItem::_brushColor, _dragOver, YACS::HMI::SceneObserverItem::_emphasized, YACS::HMI::AbstractSceneItem::_hiBrushColor, YACS::HMI::SceneItem::_hover, YACS::HMI::Resource::emphasizeBrushColor, and YACS::HMI::SceneItem::hoverColor().

Referenced by paint().

◆ getChildren()

std::list< AbstractSceneItem * > SceneComposedNodeItem::getChildren ( )
virtual

Definition at line 384 of file SceneComposedNodeItem.cxx.

385{
386 return _children;
387}

References _children.

Referenced by YACS::HMI::LinkMatrix::explore().

◆ getPenColor()

QColor SceneComposedNodeItem::getPenColor ( )
protectedvirtual

Reimplemented from YACS::HMI::SceneItem.

Definition at line 893 of file SceneComposedNodeItem.cxx.

894{
895 if (_dragOver)
896 return Resource::dragOver;
897 if (isSelected())
898 return _hiPenColor;
899 else
900 return _penColor;
901}
static QColor dragOver
Definition: Resource.hxx:300

References _dragOver, YACS::HMI::AbstractSceneItem::_hiPenColor, YACS::HMI::AbstractSceneItem::_penColor, and YACS::HMI::Resource::dragOver.

Referenced by paint().

◆ hasExpandedChildren()

bool SceneComposedNodeItem::hasExpandedChildren ( bool  recursively)
virtual

Definition at line 467 of file SceneComposedNodeItem.cxx.

468{
469 bool res = false;
470 for (list<AbstractSceneItem*>::const_iterator it=_children.begin(); it!=_children.end() && !res; ++it) {
471 SceneItem* item = dynamic_cast<SceneItem*>(*it);
472 SceneNodeItem *sni = dynamic_cast<SceneNodeItem*>(item);
473 if (sni->isExpanded()) {
474 res = true;
475 if (recursively)
476 if (SceneComposedNodeItem *scni = dynamic_cast<SceneComposedNodeItem*>(sni))
477 res = scni->hasExpandedChildren(recursively);
478 }
479 }
480 return res;
481}

References _children, and YACS::HMI::SceneNodeItem::isExpanded().

Referenced by reorganizeShrinkExpand().

◆ paint()

void SceneComposedNodeItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget widget 
)
virtual

Reimplemented from YACS::HMI::SceneNodeItem.

Definition at line 101 of file SceneComposedNodeItem.cxx.

104{
105 //DEBTRACE("SceneComposedNodeItem::paint " << _label.toStdString());
106 // IMN (14/11/2013) below block commented
107 // prevent bad resizing of scene in shrink mode
108 /* if (!isExpanded()) {
109 _width = 2*Resource::Corner_Margin + 2*Resource::DataPort_Width + Resource::Space_Margin;
110 _height = getHeaderBottom() + Resource::Corner_Margin;
111 };*/
112
113 painter->save();
114 painter->setPen(getPenColor());
115 painter->setBrush(getBrushColor());
117 painter->restore();
118}

References YACS::HMI::AbstractSceneItem::_height, YACS::HMI::AbstractSceneItem::_width, YACS::HMI::Resource::Border_Margin, getBrushColor(), and getPenColor().

◆ popupMenu()

void SceneComposedNodeItem::popupMenu ( QWidget caller,
const QPoint &  globalPos 
)
virtual

Reimplemented from YACS::HMI::SceneNodeItem.

Reimplemented in YACS::HMI::SceneProcItem.

Definition at line 378 of file SceneComposedNodeItem.cxx.

379{
381 m.popupMenu(caller, globalPos);
382}

References gui.GraphViewer::m.

◆ rebuildLinks()

void SceneComposedNodeItem::rebuildLinks ( )
virtual

Definition at line 741 of file SceneComposedNodeItem.cxx.

742{
743 DEBTRACE("SceneComposedNodeItem::rebuildLinks " << QtGuiContext::_delayCalc);
745 return;
746 CHRONO(1);
747 CHRONO(2);
748 LinkMatrix matrix(this);
749 matrix.compute();
750 CHRONOSTOP(2);
751 CHRONO(3);
752 list<linkdef> alist = matrix.getListOfDataLinkDef();
753 list<linkdef> blist = matrix.getListOfCtrlLinkDef(); // add list operator ?
754 for (list<linkdef>::const_iterator ii = blist.begin(); ii != blist.end(); ++ii)
755 alist.push_back(*ii);
756
757 CHRONOSTOP(3);
758 CHRONO(4);
759 LinkAStar astar(matrix);
760 for (list<linkdef>::const_iterator it = alist.begin(); it != alist.end(); ++it)
761 {
762 linkdef ali = *it;
763 DEBTRACE("from("<<ali.from.first<<","<<ali.from.second
764 <<") to ("<<ali.to.first<<","<<ali.to.second
765 <<") " << ali.item->getLabel().toStdString());
766 if(ali.from.first<0||ali.from.second<0||ali.to.first<0||ali.to.second<0) continue;
767 CHRONO(5);
768 bool isPath = astar.computePath(LNode(ali.from), LNode(ali.to));
769 CHRONOSTOP(5);
770 CHRONO(6);
771 if (! isPath) DEBTRACE("Link Path not found !");
772 if (! isPath) continue;
773 LNodePath ijPath = astar.givePath();
775 matrix.incrementCost(ijPath);
776 LinkPath apath = matrix.getPath(ijPath);
777// DEBTRACE(apath.size());
778 CHRONOSTOP(6);
779 CHRONO(7);
780 ali.item->setPath(apath);
781 }
782}
#define CHRONO(i)
Definition: chrono.hxx:88
#define CHRONOSTOP(i)
Definition: chrono.hxx:89
virtual QString getLabel()
Definition: SceneItem.cxx:135
virtual void setPath(LinkPath lp)
static bool _addRowCols
Definition: Scene.hxx:40
std::list< LNode > LNodePath
Definition: LinkMatrix.hxx:62
std::list< linkPoint > LinkPath
Definition: LinkMatrix.hxx:77
YACS::HMI::SceneLinkItem * item
Definition: LinkMatrix.hxx:68
std::pair< int, int > from
Definition: LinkMatrix.hxx:66
std::pair< int, int > to
Definition: LinkMatrix.hxx:67

References YACS::HMI::Scene::_addRowCols, YACS::HMI::QtGuiContext::_delayCalc, CHRONO, CHRONOSTOP, YACS::HMI::LinkMatrix::compute(), YACS::HMI::LinkAStar::computePath(), DEBTRACE, YACS::HMI::linkdef::from, YACS::HMI::AbstractSceneItem::getLabel(), YACS::HMI::LinkMatrix::getListOfCtrlLinkDef(), YACS::HMI::LinkMatrix::getListOfDataLinkDef(), YACS::HMI::LinkMatrix::getPath(), YACS::HMI::LinkAStar::givePath(), YACS::HMI::LinkMatrix::incrementCost(), YACS::HMI::linkdef::item, YACS::HMI::SceneLinkItem::setPath(), and YACS::HMI::linkdef::to.

Referenced by YACS::HMI::SceneBlocItem::arrangeCanvasNodes(), arrangeNodes(), autoPosNewChild(), YACS::HMI::SceneNodeItem::mouseReleaseEvent(), YACS::HMI::GuiEditor::rebuildLinks(), reorganizeShrinkExpand(), YACS::HMI::SceneElementaryNodeItem::reorganizeShrinkExpand(), update(), YACS::HMI::SceneElementaryNodeItem::update(), and YACS::HMI::TablePortsEdition::upOrDown().

◆ removeChildFromList()

void SceneComposedNodeItem::removeChildFromList ( AbstractSceneItem child)
virtual

Definition at line 389 of file SceneComposedNodeItem.cxx.

390{
391 _children.remove(child);
392}

References _children.

Referenced by update().

◆ reorganize()

void SceneComposedNodeItem::reorganize ( )
virtual

Reimplemented from YACS::HMI::AbstractSceneItem.

Definition at line 608 of file SceneComposedNodeItem.cxx.

609{
610 DEBTRACE("SceneComposedNodeItem::reorganize() " << _label.toStdString());
611 list<AbstractSceneItem*> alreadySet;
612 for (list<AbstractSceneItem*>::const_iterator it=_children.begin(); it!=_children.end(); ++it)
613 {
614 autoPosNewChild(*it, alreadySet);
615 alreadySet.push_back(*it);
616 }
617}
virtual void autoPosNewChild(AbstractSceneItem *item, const std::list< AbstractSceneItem * > alreadySet, bool isNew=false)

References _children, YACS::HMI::AbstractSceneItem::_label, autoPosNewChild(), and DEBTRACE.

Referenced by arrangeChildNodes().

◆ reorganizeShrinkExpand()

void SceneComposedNodeItem::reorganizeShrinkExpand ( ShrinkMode  theShrinkMode)
virtual

Reimplemented from YACS::HMI::SceneNodeItem.

Definition at line 429 of file SceneComposedNodeItem.cxx.

429 {
430 DEBTRACE("SceneComposedNodeItem::reorganizeShrinkExpand " << _expanded << " " << _label.toStdString());
431
432 bool toExpand = true;
433 if (theShrinkMode == CurrentNode) {
434 // shrink/expand current node only
435 toExpand = !isExpanded();
436
437 updateControlLinks(toExpand);
438 shrinkExpandRecursive(toExpand, true, theShrinkMode);
439
440 } else {
441 if (!isExpanded())
442 return;
443 // shrink/expand child nodes
444 toExpand = !hasExpandedChildren(theShrinkMode == ElementaryNodes);
445 for (list<AbstractSceneItem*>::const_iterator it=_children.begin(); it!=_children.end(); ++it) {
446 SceneItem* item = dynamic_cast<SceneItem*>(*it);
447 SceneNodeItem *sni = dynamic_cast<SceneNodeItem*>(item);
448 item->shrinkExpandRecursive(toExpand, true, theShrinkMode);
449 }
450 _ancestorShrinked = !toExpand;
454 adjustHeader();
455 rebuildLinks();
456 }
457
459 {
462 SceneComposedNodeItem *proc = dynamic_cast<SceneComposedNodeItem*>(item);
463 proc->rebuildLinks();
464 }
465}
YACS::HMI::SubjectProc * getSubjectProc()
Definition: guiContext.hxx:52
virtual void shrinkExpandRecursive(bool isExpanding, bool fromHere, ShrinkMode theShrinkMode)
virtual bool hasExpandedChildren(bool recursively)
virtual void shrinkExpandRecursive(bool isExpanding, bool fromHere, ShrinkMode theShrinkMode)
@ ElementaryNodes
Definition: SceneItem.hxx:40

References YACS::HMI::SceneItem::_ancestorShrinked, YACS::HMI::Scene::_autoComputeLinks, _children, YACS::HMI::SceneNodeItem::_expanded, YACS::HMI::SceneNodeItem::_expandedHeight, YACS::HMI::SceneNodeItem::_expandedWidth, YACS::HMI::AbstractSceneItem::_height, YACS::HMI::AbstractSceneItem::_label, YACS::HMI::QtGuiContext::_mapOfSceneItem, YACS::HMI::SceneNodeItem::_shownState, YACS::HMI::AbstractSceneItem::_width, YACS::HMI::SceneNodeItem::adjustHeader(), YACS::HMI::CurrentNode, DEBTRACE, YACS::HMI::ElementaryNodes, YACS::HMI::expandShown, YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::GuiContext::getSubjectProc(), hasExpandedChildren(), YACS::HMI::SceneNodeItem::isExpanded(), rebuildLinks(), shrinkExpandRecursive(), YACS::HMI::SceneItem::shrinkExpandRecursive(), and updateControlLinks().

◆ setShownState()

void SceneComposedNodeItem::setShownState ( shownState  ss)
virtual

◆ shrinkExpandLink()

void SceneComposedNodeItem::shrinkExpandLink ( bool  se)
virtual

Reimplemented from YACS::HMI::SceneNodeItem.

Definition at line 598 of file SceneComposedNodeItem.cxx.

598 {
599 DEBTRACE("SceneComposedNodeItem::shrinkExpandLink " << se << " " << _label.toStdString());
600 se = se && isExpanded();
601 foreach (QGraphicsItem *child, childItems()) {
602 if (SceneItem *sci = dynamic_cast<SceneItem*>(child)) {
603 sci->shrinkExpandLink(se);
604 };
605 };
606}

References YACS::HMI::AbstractSceneItem::_label, DEBTRACE, and YACS::HMI::SceneNodeItem::isExpanded().

◆ shrinkExpandRecursive()

void SceneComposedNodeItem::shrinkExpandRecursive ( bool  isExpanding,
bool  fromHere,
ShrinkMode  theShrinkMode 
)
virtual

Reimplemented from YACS::HMI::SceneItem.

Definition at line 483 of file SceneComposedNodeItem.cxx.

484{
485 DEBTRACE("SceneComposedNodeItem::shrinkExpandRecursive " << toExpand << " " << fromHere << " " << isExpanded() << " " << _label.toStdString());
486
487 bool toChangeShrinkState = false;
488 switch (theShrinkMode) {
489 case CurrentNode:
490 if (fromHere)
491 toChangeShrinkState = true;
492 break;
493 case ChildrenNodes:
494 if (fromHere)
495 toChangeShrinkState = true;
496 break;
497 case ElementaryNodes:
498 toChangeShrinkState = false;
499 break;
500 }
501 if (toChangeShrinkState) {
502 if (toExpand != isExpanded())
503 setExpanded(toExpand);
504 } else if (!isExpanded() && theShrinkMode == ElementaryNodes) {
505 return;
506 }
507
508 updateControlLinks(toExpand);
509
510 if (!toExpand)
511 { // ---collapsing: hide first children , then resize
512 for (list<AbstractSceneItem*>::const_iterator it=_children.begin(); it!=_children.end(); ++it)
513 {
514 SceneItem* item = dynamic_cast<SceneItem*>(*it);
515 item->shrinkExpandRecursive(toExpand, false, theShrinkMode);
516 if (theShrinkMode != ElementaryNodes) {
517 item->hide();
518 DEBTRACE("------------------------------- Hide " << item->getLabel().toStdString());
519 item->shrinkExpandLink(false);
520 }
521 }
522
523 if (toChangeShrinkState || theShrinkMode != ElementaryNodes) {
525 {
528 }
529
530 if (fromHere)
531 {
533 }
534 else
535 {
536 _ancestorShrinked = true;
538 }
539
543 else
545
546 if (_shownState == shrinkHidden) // shrink of ancestor
547 setPos(0 ,0);
548 else
549 setPos(_expandedPos);
550 adjustHeader();
551 if (_progressItem)
553 }
554 }
555 else
556 { // --- expanding: resize, then show children
557 if (toChangeShrinkState)
558 _ancestorShrinked = false;
559
560 for (list<AbstractSceneItem*>::const_iterator it=_children.begin(); it!=_children.end(); ++it)
561 {
562 SceneItem* item = dynamic_cast<SceneItem*>(*it);
563 item->shrinkExpandRecursive(isExpanded(), false, theShrinkMode);
564 if (theShrinkMode != ElementaryNodes) {
565 if (isExpanded())
566 {
567 item->show();
568 DEBTRACE("------------------------------- Show " << item->getLabel().toStdString());
569 }
570 else
571 {
572 item->hide();
573 DEBTRACE("------------------------------- Hide " << item->getLabel().toStdString());
574 }
575 item->shrinkExpandLink(fromHere);
576 }
577 }
578
579 if (isExpanded())
580 {
584 }
585 else
586 {
590 }
591 setPos(_expandedPos);
592 adjustHeader();
593 if (_progressItem)
595 }
596}
virtual void shrinkExpandLink(bool se)
@ ChildrenNodes
Definition: SceneItem.hxx:39

References YACS::HMI::SceneItem::_ancestorShrinked, _children, YACS::HMI::SceneNodeItem::_expandedHeight, YACS::HMI::SceneNodeItem::_expandedPos, YACS::HMI::SceneNodeItem::_expandedWidth, YACS::HMI::AbstractSceneItem::_height, YACS::HMI::AbstractSceneItem::_label, YACS::HMI::SceneNodeItem::_progressItem, YACS::HMI::SceneNodeItem::_shownState, YACS::HMI::AbstractSceneItem::_width, YACS::HMI::SceneProgressItem::adjustGeometry(), YACS::HMI::SceneNodeItem::adjustHeader(), YACS::HMI::ChildrenNodes, YACS::HMI::Resource::Corner_Margin, YACS::HMI::CurrentNode, YACS::HMI::Resource::DataPort_Width, DEBTRACE, YACS::HMI::ElementaryNodes, YACS::HMI::expandShown, YACS::HMI::SceneNodeItem::getHeaderBottom(), YACS::HMI::AbstractSceneItem::getLabel(), YACS::HMI::Resource::Header_Height, YACS::HMI::SceneNodeItem::isExpanded(), YACS::HMI::SceneNodeItem::setExpanded(), YACS::HMI::SceneItem::shrinkExpandLink(), YACS::HMI::SceneItem::shrinkExpandRecursive(), YACS::HMI::shrinkHidden, YACS::HMI::shrinkShown, YACS::HMI::Resource::Space_Margin, and updateControlLinks().

Referenced by reorganizeShrinkExpand().

◆ update()

void SceneComposedNodeItem::update ( GuiEvent  event,
int  type,
Subject son 
)
virtual

Reimplemented from YACS::HMI::SceneNodeItem.

Definition at line 120 of file SceneComposedNodeItem.cxx.

121{
122 DEBTRACE("SceneComposedNodeItem::update "<< eventName(event)<<" "<<type<<" "<<son);
123 SceneNodeItem::update(event, type, son);
124 AbstractSceneItem *item;
125 switch (event)
126 {
127 case YACS::HMI::ADD:
128 switch (type)
129 {
130 case YACS::HMI::BLOC:
131 item = new SceneBlocItem(_scene,
132 this,
133 son->getName().c_str(),
134 son);
135 item->addHeader();
136 autoPosNewChild(item, _children, true);
137 break;
143 item = new SceneComposedNodeItem(_scene,
144 this,
145 son->getName().c_str(),
146 son);
147 item->addHeader();
148 if ( !QtGuiContext::getQtCurrent()->isEdition()
149 && (type == YACS::HMI::FORLOOP || type == YACS::HMI::FOREACHLOOP) )
150 {
151 item->addProgressItem();
152 }
153 autoPosNewChild(item, _children, true);
154 break;
167 this,
168 son->getName().c_str(),
169 son);
170 item->addHeader();
171 autoPosNewChild(item, _children, true);
172 break;
175 item = new SceneInPortItem(_scene,
176 _header,
177 son->getName().c_str(),
178 son);
179 _header->autoPosNewPort(item);
180 _inPorts.push_back(item);
182 {
185 SceneComposedNodeItem *proc = dynamic_cast<SceneComposedNodeItem*>(item);
186 proc->rebuildLinks();
187 }
188 break;
191 item = new SceneOutPortItem(_scene,
192 _header,
193 son->getName().c_str(),
194 son);
195 _header->autoPosNewPort(item);
196 _outPorts.push_back(item);
198 {
201 SceneComposedNodeItem *proc = dynamic_cast<SceneComposedNodeItem*>(item);
202 proc->rebuildLinks();
203 }
204 break;
205 default:
206 DEBTRACE("SceneComposedNodeItem::update() ADD, type not handled:" << type);
207 }
208 break;
210 switch (type)
211 {
213 if (SubjectLink* slink = dynamic_cast<SubjectLink*>(son))
214 {
215 SubjectDataPort* soutp = slink->getSubjectOutPort();
216 SubjectDataPort* sinp = slink->getSubjectInPort();
219 ScenePortItem* from = dynamic_cast<ScenePortItem*>(scout);
220 ScenePortItem* to = dynamic_cast<ScenePortItem*>(scin);
221 if (dynamic_cast<SubjectInputDataStreamPort*>(sinp))
222 {
224 this,
225 from, to,
226 son->getName().c_str(),
227 son);
228 item->updateShape();
229 }
230 else
231 {
233 this,
234 from, to,
235 son->getName().c_str(),
236 son);
237 item->updateShape();
238 }
240 {
243 SceneComposedNodeItem *proc = dynamic_cast<SceneComposedNodeItem*>(item);
244 proc->rebuildLinks();
245 }
246 }
247 break;
248 }
249 break;
251 switch (type)
252 {
254 if (SubjectControlLink* slink = dynamic_cast<SubjectControlLink*>(son))
255 {
256 SubjectNode* soutn = slink->getSubjectOutNode();
257 SubjectNode* sinn = slink->getSubjectInNode();
260 SceneNodeItem* nodefrom = dynamic_cast<SceneNodeItem*>(scout);
261 SceneNodeItem* nodeto = dynamic_cast<SceneNodeItem*>(scin);
262 if (!nodeto || !nodefrom) DEBTRACE("CONTROLLINK problem -----------------");
263 ScenePortItem* from = nodefrom->getCtrlOutPortItem();
264 ScenePortItem* to = nodeto->getCtrlInPortItem();
265 if (!to || !from) DEBTRACE("CONTROLLINK problem -----------------");
267 this,
268 from, to,
269 son->getName().c_str(),
270 son);
271 item->updateShape();
273 {
276 SceneComposedNodeItem *proc = dynamic_cast<SceneComposedNodeItem*>(item);
277 proc->rebuildLinks();
278 }
279 }
280 break;
281 }
282 break;
284 //SceneObserverItem::update(event, type, son);
285 break;
287 {
288 SubjectSwitch *sSwitch = dynamic_cast<SubjectSwitch*>(_subject);
289 if (sSwitch)
290 {
291 Switch *aSwitch = dynamic_cast<Switch*>(sSwitch->getNode());
292 Node *node = aSwitch->edGetNode(type);
293 if (node)
294 {
295 if (GuiContext::getCurrent()->_mapOfSubjectNode.count(node))
296 {
298 if (QtGuiContext::getQtCurrent()->_mapOfSceneItem.count(sub))
299 {
301 SceneNodeItem *scnode = dynamic_cast<SceneNodeItem*>(item);
302 if (scnode) scnode->updateName();
303 }
304 }
305 }
306 }
307 }
308 break;
309 case YACS::HMI::CUT:
310 {
312 removeChildFromList(sinode);
313 }
314 break;
315 case YACS::HMI::PASTE:
316 {
318 sinode->setParent(this);
319 sinode->setLevel();
320 if (SceneComposedNodeItem *scnode = dynamic_cast<SceneComposedNodeItem*>(sinode))
321 scnode->adjustColors();
322 autoPosNewChild(sinode, _children, true);
323 }
324 break;
325 case PROGRESS:
326 {
327 if (dynamic_cast<SubjectForLoop*>(son) || dynamic_cast<SubjectForEachLoop*>(son))
328 {
329 if (SceneProgressItem* spitem = getProgressItem())
330 spitem->setProgress(son->getProgress().c_str());
331 }
332 }
333 break;
334 default:
335 ;
336// DEBTRACE("SceneComposedNodeItem::update(), event not handled: "<< eventName(event));
337 }
338}
Base class for all nodes.
Definition: Node.hxx:70
Control node that emulates the C switch.
Definition: Switch.hxx:85
Node * edGetNode(int caseId)
Definition: Switch.cxx:527
virtual void addProgressItem()
Definition: SceneItem.cxx:144
YACS::HMI::Scene * _scene
Definition: SceneItem.hxx:98
static std::string eventName(GuiEvent event)
SceneComposedNodeItem(QGraphicsScene *scene, SceneItem *parent, QString label, Subject *subject)
virtual void removeChildFromList(AbstractSceneItem *child)
virtual void autoPosNewPort(AbstractSceneItem *item)
void setParent(SceneItem *parent)
Definition: SceneItem.cxx:207
virtual void update(GuiEvent event, int type, Subject *son)
virtual ScenePortItem * getCtrlInPortItem()
std::list< AbstractSceneItem * > _outPorts
virtual SceneProgressItem * getProgressItem()
std::list< AbstractSceneItem * > _inPorts
virtual ScenePortItem * getCtrlOutPortItem()
virtual std::string getName()
virtual std::string getProgress()
@ OUTPUTDATASTREAMPORT
@ INPUTDATASTREAMPORT

References YACS::HMI::Scene::_autoComputeLinks, _children, YACS::HMI::SceneNodeItem::_header, YACS::HMI::SceneNodeItem::_inPorts, YACS::HMI::QtGuiContext::_mapOfSceneItem, YACS::HMI::GuiContext::_mapOfSubjectNode, YACS::HMI::SceneNodeItem::_outPorts, YACS::HMI::AbstractSceneItem::_scene, YACS::HMI::SceneObserverItem::_subject, YACS::HMI::ADD, YACS::HMI::ADDCONTROLLINK, YACS::HMI::AbstractSceneItem::addHeader(), YACS::HMI::ADDLINK, YACS::HMI::AbstractSceneItem::addProgressItem(), autoPosNewChild(), YACS::HMI::SceneHeaderNodeItem::autoPosNewPort(), YACS::HMI::BLOC, YACS::HMI::CONTROLLINK, YACS::HMI::CORBANODE, YACS::HMI::CPPNODE, YACS::HMI::CUT, YACS::HMI::DATALINK, DEBTRACE, YACS::ENGINE::Switch::edGetNode(), YACS::HMI::GuiObserver::eventName(), YACS::HMI::FOREACHLOOP, YACS::HMI::FORLOOP, YACS::HMI::SceneNodeItem::getCtrlInPortItem(), YACS::HMI::SceneNodeItem::getCtrlOutPortItem(), YACS::HMI::GuiContext::getCurrent(), YACS::HMI::Subject::getName(), YACS::HMI::SubjectNode::getNode(), YACS::HMI::Subject::getProgress(), YACS::HMI::SceneNodeItem::getProgressItem(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::GuiContext::getSubjectProc(), YACS::HMI::INPUTDATASTREAMPORT, YACS::HMI::INPUTPORT, YACS::HMI::OPTIMIZERLOOP, YACS::HMI::OUTNODE, YACS::HMI::OUTPUTDATASTREAMPORT, YACS::HMI::OUTPUTPORT, YACS::HMI::PASTE, YACS::HMI::PRESETNODE, YACS::HMI::PROGRESS, YACS::HMI::PYFUNCNODE, YACS::HMI::PYTHONNODE, rebuildLinks(), YACS::HMI::REMOVE, removeChildFromList(), YACS::HMI::SALOMENODE, YACS::HMI::SALOMEPYTHONNODE, SceneComposedNodeItem(), YACS::HMI::SETCASE, YACS::HMI::AbstractSceneItem::setLevel(), YACS::HMI::SceneItem::setParent(), YACS::HMI::STUDYINNODE, YACS::HMI::STUDYOUTNODE, YACS::HMI::SWITCH, YACS::HMI::SceneNodeItem::update(), YACS::HMI::SceneNodeItem::updateName(), YACS::HMI::SceneLinkItem::updateShape(), YACS::HMI::WHILELOOP, and YACS::HMI::XMLNODE.

Referenced by gui.graph.MyCanvas::customEvent().

◆ updateChildItems()

void SceneComposedNodeItem::updateChildItems ( )
virtual

Reimplemented from YACS::HMI::SceneNodeItem.

Definition at line 921 of file SceneComposedNodeItem.cxx.

922{
924 if(!_header)
925 return;
926 foreach (QGraphicsItem *child, _header->childItems())
927 {
928 if (SceneItem *sci = dynamic_cast<SceneItem*>(child))
929 {
930 sci->updateLinks();
931 }
932 }
933}
virtual void updateChildItems()

References YACS::HMI::SceneNodeItem::_header, and YACS::HMI::SceneNodeItem::updateChildItems().

◆ updateControlLinks()

void SceneComposedNodeItem::updateControlLinks ( bool  toExpand)
protected

Definition at line 394 of file SceneComposedNodeItem.cxx.

395{
396 //update control links
397 std::list<SubjectControlLink*> lscl=dynamic_cast<SubjectNode*>(getSubject())->getSubjectControlLinks();
398 for (std::list<SubjectControlLink*>::const_iterator it = lscl.begin(); it != lscl.end(); ++it) {
400
401 bool b1 = true, b2 = true;
402
403 SceneNodeItem* no = lk->getFromNode();
404 if (no) {
405 SceneComposedNodeItem* scni = dynamic_cast<SceneComposedNodeItem*>(no);
406 if (scni) {
407 b1 = scni!=this;
408 };
409 };
410
411 no = lk->getToNode();
412 if (no) {
413 SceneComposedNodeItem* scni = dynamic_cast<SceneComposedNodeItem*>(no);
414 if (scni) {
415 b2 = scni!=this;
416 };
417 };
418
419 if (b1 && b2) {
420 if (toExpand) {
421 lk->show();
422 } else {
423 lk->hide();
424 };
425 };
426 };
427}
virtual SceneNodeItem * getToNode()
virtual SceneNodeItem * getFromNode()

References YACS::HMI::QtGuiContext::_mapOfSceneItem, YACS::HMI::SceneLinkItem::getFromNode(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::SceneObserverItem::getSubject(), and YACS::HMI::SceneLinkItem::getToNode().

Referenced by reorganizeShrinkExpand(), and shrinkExpandRecursive().

Member Data Documentation

◆ _children

◆ _dragOver

bool YACS::HMI::SceneComposedNodeItem::_dragOver
protected

The documentation for this class was generated from the following files: