COPASI API  4.16.103
CQStyledGraphicsItem.cpp
Go to the documentation of this file.
1 // Copyright (C) 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
9 #include <layout/CLGlyphs.h>
11 
12 #include <QtGui/QPen>
13 #include <QtGui/QBrush>
14 
16  : CQCopasiGraphicsItem(resolver, resolver != NULL ? resolver->resolveStyle(go) : NULL)
17  , mWasMoved(false)
18 {
19  setFlag(QGraphicsItem::ItemIsMovable);
20  setFlag(QGraphicsItem::ItemIsSelectable);
21  setFlag(QGraphicsItem::ItemSendsGeometryChanges);
22  setData(COPASI_LAYOUT_KEY, QString(go->getKey().c_str()));
24 }
25 
27 {
28 }
29 
30 void CQStyledGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
31 {
32  CQLayoutScene * currentScene = dynamic_cast<CQLayoutScene *>(scene());
33 
34  if (mWasMoved && currentScene)
35  {
36  QPointF currentPos = pos();
37  currentScene->updatePosition(data(COPASI_LAYOUT_KEY).toString(), currentPos);
38  mWasMoved = false;
39  }
40  else
41  {
42  QGraphicsItem::mouseReleaseEvent(event);
43  }
44 }
45 
46 QVariant CQStyledGraphicsItem::itemChange(GraphicsItemChange change, const QVariant &value)
47 {
48  CQLayoutScene * currentScene = dynamic_cast<CQLayoutScene *>(scene());
49 
50  if (change == ItemPositionHasChanged && currentScene)
51  {
52  mWasMoved = true;
53  }
54 
55  return QGraphicsItem::itemChange(change, value);
56 }
#define COPASI_LAYOUT_KEY
const CLBoundingBox & getBoundingBox() const
CQStyledGraphicsItem(const CLGraphicalObject *go, const CLRenderResolver *resolver=NULL)
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
static void fillGroupFromStyle(QGraphicsItemGroup *group, const CLBoundingBox *bounds, const CLStyle *style, const CLRenderResolver *resolver)
virtual const std::string & getKey() const
void updatePosition(const QString &key, const QPointF &newPos)
const CLRenderResolver * mpResolver
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value)