Version: 8.3.0
YACS::HMI::SceneElementaryNodeItem Class Reference

#include <SceneElementaryNodeItem.hxx>

Inheritance diagram for YACS::HMI::SceneElementaryNodeItem:
Collaboration diagram for YACS::HMI::SceneElementaryNodeItem:

Public Member Functions

 SceneElementaryNodeItem (QGraphicsScene *scene, SceneItem *parent, QString label, Subject *subject)
 
virtual ~SceneElementaryNodeItem ()
 
virtual void setWidth (qreal width)
 SceneElementaryNodeItem cannot be resized (only ComposedNodeItem can) More...
 
virtual void setHeight (qreal height)
 SceneElementaryNodeItem cannot be resized (only ComposedNodeItem can) More...
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 
virtual void update (GuiEvent event, int type, Subject *son)
 
virtual void popupMenu (QWidget *caller, const QPoint &globalPos)
 
virtual void autoPosNewPort (AbstractSceneItem *item, int nbPorts)
 
virtual void reorganize ()
 
virtual void reorganizeShrinkExpand (ShrinkMode theShrinkMode)
 
virtual void shrinkExpandRecursive (bool isExpanding, bool fromHere, ShrinkMode theShrinkMode)
 
virtual void setShownState (shownState ss)
 
- Public Member Functions inherited from YACS::HMI::SceneNodeItem
 SceneNodeItem (QGraphicsScene *scene, SceneItem *parent, QString label, Subject *subject)
 
virtual ~SceneNodeItem ()
 
virtual void addHeader ()
 
virtual SceneHeaderItemgetHeader ()
 
virtual void addProgressItem ()
 
virtual SceneProgressItemgetProgressItem ()
 
virtual qreal getHeaderBottom ()
 
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 updateChildItems ()
 
virtual void shrinkExpandLink (bool se)
 
virtual void showOutScopeLinks ()
 
virtual void updateLinks ()
 
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 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 checkGeometryChange ()
 
void setParent (SceneItem *parent)
 
void setEventPos (QPointF point)
 
bool isAncestorShrinked ()
 
- Public Member Functions inherited from YACS::HMI::AbstractSceneItem
 AbstractSceneItem (QGraphicsScene *scene, SceneItem *parent, QString label)
 
virtual ~AbstractSceneItem ()
 
int getLevel ()
 
void setLevel ()
 
virtual QString getLabel ()
 
qreal getWidth ()
 
qreal getHeight ()
 
virtual void setGeometryOptimization (bool optimize)
 
SceneItemgetParent ()
 
- Public Member Functions inherited from YACS::HMI::GuiObserver
 GuiObserver ()
 
virtual ~GuiObserver ()
 
virtual void incrementSubjects (Subject *subject)
 
virtual void decrementSubjects (Subject *subject)
 
int getNbSubjects ()
 
bool isDestructible ()
 

Protected Attributes

int _maxPorts
 
- 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
 
- 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 ()
 
- Static Protected Attributes inherited from YACS::HMI::GuiObserver
static std::map< int, std::string > _eventNameMap
 

Detailed Description

Definition at line 29 of file SceneElementaryNodeItem.hxx.

Constructor & Destructor Documentation

SceneElementaryNodeItem::~SceneElementaryNodeItem ( )
virtual

Definition at line 59 of file SceneElementaryNodeItem.cxx.

60 {
61 }

Member Function Documentation

void SceneElementaryNodeItem::autoPosNewPort ( AbstractSceneItem item,
int  nbPorts 
)
virtual

Reimplemented from YACS::HMI::SceneNodeItem.

Definition at line 144 of file SceneElementaryNodeItem.cxx.

References YACS::HMI::AbstractSceneItem::_height, YACS::HMI::AbstractSceneItem::_incHeight, YACS::HMI::AbstractSceneItem::_label, _maxPorts, YACS::HMI::SceneNodeItem::_shownState, YACS::HMI::Resource::Border_Margin, YACS::HMI::Resource::Corner_Margin, YACS::HMI::Resource::DataPort_Height, YACS::HMI::Resource::DataPort_Width, DEBTRACE, YACS::HMI::expandShown, YACS::HMI::Resource::Header_Height, YACS::HMI::AbstractSceneItem::setTopLeft(), and YACS::HMI::Resource::Space_Margin.

Referenced by reorganize(), and update().

144  {
145  DEBTRACE("SceneElementaryNodeItem::autoPosNewPort "<< _label.toStdString());
146  SceneInPortItem* inPortItem = dynamic_cast<SceneInPortItem*>(item);
147  SceneOutPortItem* outPortItem = dynamic_cast<SceneOutPortItem*>(item);
148 
149  bool toShow = (_shownState == expandShown);
150  if (toShow) {
151  qreal x;
152  if (inPortItem) {
154  inPortItem->show();
155  } else {
157  outPortItem->show();
158  };
160 
161  if (_maxPorts <= nbPorts) {
162  _maxPorts = nbPorts+1;
165  _incHeight = _height; // must just be more than the actual increment of height
166  DEBTRACE("SceneElementaryNodeItem::autoPosNewPort _height=" << _height);
167  };
168 
169  item->setTopLeft(QPointF(x, y));
170 
171  } else {
173  qreal y = Resource::Corner_Margin;
174  if (inPortItem) {
175  item->setTopLeft(QPointF(Resource::Corner_Margin, y));
176  inPortItem->hide();
177  } else {
178  item->setTopLeft(QPointF(Resource::Corner_Margin + Resource::DataPort_Width + Resource::Space_Margin, y));
179  outPortItem->hide();
180  };
181  };
182 }
void SceneElementaryNodeItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget widget 
)
virtual

Reimplemented from YACS::HMI::SceneNodeItem.

Definition at line 73 of file SceneElementaryNodeItem.cxx.

References YACS::HMI::AbstractSceneItem::_height, YACS::HMI::AbstractSceneItem::_width, YACS::HMI::Resource::Border_Margin, YACS::HMI::SceneObserverItem::getBrushColor(), YACS::HMI::SceneItem::getPenColor(), gui.graph::h(), YACS::HMI::Resource::Thickness, and gui.logview::w.

76 {
77  //DEBTRACE("SceneElementaryNodeItem::paint");
78  painter->save();
79  QPen pen(getPenColor());
80  pen.setWidth(Resource::Thickness);
81  painter->setPen(pen);
82  painter->setBrush(getBrushColor());
85  painter->drawRect(QRectF(Resource::Border_Margin, Resource::Border_Margin, w, h));
86  painter->restore();
87 }
void SceneElementaryNodeItem::popupMenu ( QWidget caller,
const QPoint &  globalPos 
)
virtual

Reimplemented from YACS::HMI::SceneNodeItem.

Definition at line 184 of file SceneElementaryNodeItem.cxx.

References gui.GraphViewer::m, and YACS::HMI::ElementaryNodeMenu::popupMenu().

185 {
187  m.popupMenu(caller, globalPos);
188 }
void SceneElementaryNodeItem::reorganize ( )
virtual

Reimplemented from YACS::HMI::AbstractSceneItem.

Definition at line 253 of file SceneElementaryNodeItem.cxx.

References YACS::HMI::AbstractSceneItem::_label, YACS::HMI::QtGuiContext::_mapOfSceneItem, YACS::HMI::GuiContext::_mapOfSubjectDataPort, _maxPorts, YACS::HMI::SceneObserverItem::_subject, autoPosNewPort(), DEBTRACE, YACS::HMI::QtGuiContext::getQtCurrent(), YACS::ENGINE::Node::getSetOfInPort(), YACS::ENGINE::Node::getSetOfOutPort(), YACS::HMI::SceneNodeItem::updateLinks(), and YASSERT.

Referenced by setShownState(), shrinkExpandRecursive(), and update().

254 {
255  DEBTRACE("SceneElementaryNodeItem::reorganize() " << _label.toStdString());
256 
257  SubjectNode* snode = dynamic_cast<SubjectNode*>(_subject);
258  ElementaryNode* father = dynamic_cast<ElementaryNode*>(snode->getNode());
259  YASSERT(father);
260 
261  _maxPorts = 0;
262 
263  list<InPort*> plisti = father->getSetOfInPort();
264  list<InPort*>::iterator iti = plisti.begin();
265  int nbPorts = 0;
266  for (; iti != plisti.end(); ++iti)
267  {
270  autoPosNewPort(item, nbPorts);
271  nbPorts++;
272  }
273 
274  list<OutPort*> plisto = father->getSetOfOutPort();
275  list<OutPort*>::iterator ito = plisto.begin();
276  nbPorts = 0;
277  for (; ito != plisto.end(); ++ito)
278  {
281  autoPosNewPort(item, nbPorts);
282  nbPorts++;
283  }
284  updateLinks();
285 }
void SceneElementaryNodeItem::reorganizeShrinkExpand ( ShrinkMode  theShrinkMode)
virtual
void SceneElementaryNodeItem::setHeight ( qreal  height)
virtual

SceneElementaryNodeItem cannot be resized (only ComposedNodeItem can)

Reimplemented from YACS::HMI::SceneNodeItem.

Definition at line 69 of file SceneElementaryNodeItem.cxx.

70 {
71 }
void SceneElementaryNodeItem::setShownState ( shownState  ss)
virtual

Reimplemented from YACS::HMI::SceneNodeItem.

Definition at line 287 of file SceneElementaryNodeItem.cxx.

References YACS::HMI::SceneItem::_ancestorShrinked, YACS::HMI::SceneNodeItem::_shownState, reorganize(), and YACS::HMI::shrinkHidden.

288 {
289  _shownState = ss;
290  if (_shownState == shrinkHidden)
291  {
292  _ancestorShrinked = true;
293  hide();
294  }
295  else
296  {
297  _ancestorShrinked = false;
298  show();
299  }
300  reorganize();
301 }
void SceneElementaryNodeItem::setWidth ( qreal  width)
virtual

SceneElementaryNodeItem cannot be resized (only ComposedNodeItem can)

Reimplemented from YACS::HMI::SceneNodeItem.

Definition at line 64 of file SceneElementaryNodeItem.cxx.

65 {
66 }
void SceneElementaryNodeItem::shrinkExpandRecursive ( bool  isExpanding,
bool  fromHere,
ShrinkMode  theShrinkMode 
)
virtual

Reimplemented from YACS::HMI::SceneItem.

Definition at line 205 of file SceneElementaryNodeItem.cxx.

References YACS::HMI::SceneItem::_ancestorShrinked, YACS::HMI::SceneNodeItem::_expandedPos, YACS::HMI::AbstractSceneItem::_label, YACS::HMI::SceneNodeItem::_shownState, YACS::HMI::ChildrenNodes, YACS::HMI::CurrentNode, DEBTRACE, YACS::HMI::ElementaryNodes, YACS::HMI::expandShown, YACS::HMI::SceneNodeItem::isExpanded(), reorganize(), YACS::HMI::SceneNodeItem::setExpanded(), YACS::HMI::shrinkHidden, and YACS::HMI::shrinkShown.

Referenced by reorganizeShrinkExpand().

206 {
207  DEBTRACE("SceneElementaryNodeItem::shrinkExpandRecursive " << toExpand << " " << fromHere << " " << isExpanded() << " " << _label.toStdString());
208 
209  bool toChangeShrinkState = false;
210  switch (theShrinkMode) {
211  case CurrentNode:
212  if (fromHere)
213  toChangeShrinkState = true;
214  break;
215  case ChildrenNodes:
216  if (fromHere)
217  toChangeShrinkState = true;
218  break;
219  case ElementaryNodes:
220  toChangeShrinkState = true;
221  break;
222  }
223  if (toChangeShrinkState && toExpand != isExpanded())
224  setExpanded(toExpand);
225 
226  if (toExpand) {
227  if (toChangeShrinkState) {
228  _ancestorShrinked = false;
230  } else {
231  if (isExpanded())
233  else
235  }
236  } else {
237  if (fromHere || theShrinkMode==ElementaryNodes) {
239  } else {
240  _ancestorShrinked = true;
242  }
243  }
244 
245  if (_shownState == shrinkHidden) // shrink of ancestor
246  setPos(0, 0);
247  else
248  setPos(_expandedPos);
249 
250  reorganize();
251 }
void SceneElementaryNodeItem::update ( GuiEvent  event,
int  type,
Subject son 
)
virtual

Reimplemented from YACS::HMI::SceneNodeItem.

Definition at line 89 of file SceneElementaryNodeItem.cxx.

References YACS::HMI::Scene::_autoComputeLinks, YACS::HMI::SceneNodeItem::_inPorts, YACS::HMI::QtGuiContext::_mapOfSceneItem, YACS::HMI::SceneNodeItem::_outPorts, YACS::HMI::AbstractSceneItem::_scene, YACS::HMI::ADD, autoPosNewPort(), DEBTRACE, YACS::HMI::GuiObserver::eventName(), YACS::HMI::Subject::getName(), YACS::HMI::QtGuiContext::getQtCurrent(), YACS::HMI::GuiContext::getSubjectProc(), YACS::HMI::INPUTDATASTREAMPORT, YACS::HMI::INPUTPORT, YACS::HMI::OUTPUTDATASTREAMPORT, YACS::HMI::OUTPUTPORT, YACS::HMI::SceneComposedNodeItem::rebuildLinks(), YACS::HMI::REMOVE, reorganize(), YACS::HMI::SYNCHRO, and YACS::HMI::SceneNodeItem::update().

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

90 {
91  DEBTRACE("SceneElementaryNodeItem::update "<< eventName(event)<<" "<<type<<" "<<son);
92  SceneNodeItem::update(event, type, son);
93  SceneItem *item;
94  switch (event)
95  {
96  case YACS::HMI::ADD:
97  switch (type)
98  {
101  item = new SceneInPortItem(_scene,
102  this,
103  son->getName().c_str(),
104  son);
105  autoPosNewPort(item, _inPorts.size());
106  _inPorts.push_back(item);
108  {
111  SceneComposedNodeItem *proc = dynamic_cast<SceneComposedNodeItem*>(item);
112  proc->rebuildLinks();
113  }
114  break;
117  item = new SceneOutPortItem(_scene,
118  this,
119  son->getName().c_str(),
120  son);
121  autoPosNewPort(item, _outPorts.size());
122  _outPorts.push_back(item);
124  {
127  SceneComposedNodeItem *proc = dynamic_cast<SceneComposedNodeItem*>(item);
128  proc->rebuildLinks();
129  }
130  break;
131 // default:
132 // DEBTRACE("SceneElementaryNodeItem::update() ADD, type not handled:" << type);
133  }
134  break;
135  case YACS::HMI::REMOVE:
136  case YACS::HMI::SYNCHRO:
137  reorganize();
138  break;
139 // default:
140 // DEBTRACE("SceneElementaryNodeItem::update(), event not handled:" << eventName(event));
141  }
142 }

Member Data Documentation

int YACS::HMI::SceneElementaryNodeItem::_maxPorts
protected

Definition at line 49 of file SceneElementaryNodeItem.hxx.

Referenced by autoPosNewPort(), reorganize(), and SceneElementaryNodeItem().


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