Version: 8.3.0
YACS::HMI::SceneCtrlPortItem Class Reference

#include <SceneCtrlPortItem.hxx>

Inheritance diagram for YACS::HMI::SceneCtrlPortItem:
Collaboration diagram for YACS::HMI::SceneCtrlPortItem:

Public Member Functions

 SceneCtrlPortItem (QGraphicsScene *scene, SceneItem *parent, QString label)
 
virtual ~SceneCtrlPortItem ()
 
virtual void setText (QString label)
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 
virtual SceneNodeItemgetParentNode ()
 
SubjectNodegetSubjectNode ()
 
- 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 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 ()
 
int getLevel ()
 
void setLevel ()
 
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 activateSelection (bool selected)
 
virtual void setGeometryOptimization (bool optimize)
 
SceneItemgetParent ()
 
- Public Member Functions inherited from YACS::HMI::ScenePortItem
 ScenePortItem (QString label)
 
virtual ~ScenePortItem ()
 

Protected Member Functions

virtual QString getMimeFormat ()
 
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 
virtual void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 
- Protected Member Functions inherited from YACS::HMI::SceneItem
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

bool _draging
 
bool _dragModifier
 
- 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::ScenePortItem
SceneTextItem_text
 

Additional Inherited Members

- Public Attributes inherited from YACS::HMI::SceneItem
bool _blocX
 
bool _blocY
 

Detailed Description

Definition at line 33 of file SceneCtrlPortItem.hxx.

Constructor & Destructor Documentation

SceneCtrlPortItem::~SceneCtrlPortItem ( )
virtual

Definition at line 62 of file SceneCtrlPortItem.cxx.

63 {
64 }

Member Function Documentation

QString SceneCtrlPortItem::getMimeFormat ( )
protectedvirtual

Reimplemented in YACS::HMI::SceneCtrlOutPortItem.

Definition at line 106 of file SceneCtrlPortItem.cxx.

Referenced by mouseMoveEvent().

107 {
108  return "yacs/subjectGate";
109 }
SceneNodeItem * SceneCtrlPortItem::getParentNode ( )
virtual
SubjectNode * SceneCtrlPortItem::getSubjectNode ( )

Definition at line 99 of file SceneCtrlPortItem.cxx.

References getParentNode(), and YACS::HMI::SceneObserverItem::getSubject().

Referenced by mouseMoveEvent(), and mousePressEvent().

100 {
101  SceneNodeItem* nodeItem = getParentNode();
102  if (!nodeItem) return 0;
103  return dynamic_cast<SubjectNode*>(nodeItem->getSubject());
104 }
void SceneCtrlPortItem::mouseMoveEvent ( QGraphicsSceneMouseEvent *  event)
protectedvirtual

creation of mime data if drag detected. setData mime type must be coherent with SchemaModel::mimeTypes to allow drop on port item in tree view

Definition at line 132 of file SceneCtrlPortItem.cxx.

References YACS::HMI::AbstractSceneItem::_dragButton, _draging, _dragModifier, DEBTRACE, getMimeFormat(), getSubjectNode(), paint(), and YACS::HMI::ItemMimeData::setSubject().

133 {
134  if (_draging)
135  {
136  //DEBTRACE("_draging");
137  if (QLineF(event->screenPos(),
138  event->buttonDownScreenPos(_dragButton)).length()
139  < QApplication::startDragDistance())
140  {
141  return;
142  }
143  DEBTRACE("in drag");
144  QDrag *drag = new QDrag(event->widget());
145  ItemMimeData *mime = new ItemMimeData;
146  drag->setMimeData(mime);
147  mime->setSubject(getSubjectNode());
148  mime->setData(getMimeFormat(), "_subject");
149 
150  QPixmap pixmap(34, 34);
151  pixmap.fill(Qt::white);
152 
153  QPainter painter(&pixmap);
154  painter.translate(15, 15);
155  painter.setRenderHint(QPainter::Antialiasing);
156  paint(&painter, 0, 0);
157  painter.end();
158 
159  pixmap.setMask(pixmap.createHeuristicMask());
160 
161  drag->setPixmap(pixmap);
162  drag->setHotSpot(QPoint(15, 20));
163 
164  drag->exec();
165  setCursor(Qt::ArrowCursor);
166  _draging = false;
167  _dragModifier= false;
168  }
169 }
void SceneCtrlPortItem::mousePressEvent ( QGraphicsSceneMouseEvent *  event)
protectedvirtual

When Zooming, filter all mouse events to items: do not work, scene do not receive...

Reimplemented from YACS::HMI::SceneItem.

Definition at line 111 of file SceneCtrlPortItem.cxx.

References YACS::HMI::AbstractSceneItem::_dragable, YACS::HMI::AbstractSceneItem::_dragButton, _draging, _dragModifier, YACS::HMI::AbstractSceneItem::_label, YACS::HMI::AbstractSceneItem::_scene, DEBTRACE, YACS::HMI::QtGuiContext::getQtCurrent(), getSubjectNode(), YACS::HMI::QtGuiContext::isEdition(), YACS::HMI::Scene::isZooming(), and YACS::HMI::Subject::select().

112 {
113  DEBTRACE("SceneCtrlPortItem::mousePressEvent " << _label.toStdString()
114  << " " << acceptedMouseButtons ());
115  if (!_scene->isZooming())
116  {
117  getSubjectNode()->select(true);
118  if (_dragable && (event->button() == _dragButton) && QtGuiContext::getQtCurrent()->isEdition())
119  {
120  setCursor(Qt::ClosedHandCursor);
121  _draging = true;
122  _dragModifier= event->modifiers() & Qt::ControlModifier;
123  }
124  }
125 }
void SceneCtrlPortItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  event)
protectedvirtual

Definition at line 171 of file SceneCtrlPortItem.cxx.

References _draging, and _dragModifier.

172 {
173  if (_draging)
174  {
175  setCursor(Qt::ArrowCursor);
176  }
177  _draging = false;
178  _dragModifier= false;
179 }
void SceneCtrlPortItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget widget 
)
virtual

Reimplemented from YACS::HMI::SceneItem.

Definition at line 66 of file SceneCtrlPortItem.cxx.

References YACS::HMI::AbstractSceneItem::_parent, YACS::HMI::Resource::CtrlPort_Height, YACS::HMI::Resource::CtrlPort_Width, YACS::HMI::SceneItem::getPenColor(), YACS::HMI::SceneHeaderNodeItem::getValidColor(), YACS::HMI::Resource::Radius, and YACS::HMI::Resource::Thickness.

Referenced by mouseMoveEvent().

69 {
70  //DEBTRACE("ScenePortItem::paint");
71  painter->save();
72 
73  QPen pen(getPenColor());
74  pen.setWidth(Resource::Thickness);
75  painter->setPen(pen);
76  SceneHeaderNodeItem* hd = dynamic_cast<SceneHeaderNodeItem*>(_parent);
77  painter->setBrush(hd->getValidColor());
79 
80  painter->restore();
81 }
void SceneCtrlPortItem::setText ( QString  label)
virtual

Implements YACS::HMI::ScenePortItem.

Definition at line 83 of file SceneCtrlPortItem.cxx.

References YACS::HMI::AbstractSceneItem::_scene, and YACS::HMI::ScenePortItem::_text.

Referenced by SceneCtrlPortItem().

84 {
85  if (!_text)
87  this,
88  label, true );
89 }

Member Data Documentation

bool YACS::HMI::SceneCtrlPortItem::_draging
protected

Definition at line 51 of file SceneCtrlPortItem.hxx.

Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().

bool YACS::HMI::SceneCtrlPortItem::_dragModifier
protected

Definition at line 52 of file SceneCtrlPortItem.hxx.

Referenced by mouseMoveEvent(), mousePressEvent(), and mouseReleaseEvent().


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