SemanticGraphGlobalItem.cpp
Go to the documentation of this file.
2 
3 #include <QGraphicsSceneContextMenuEvent>
4 #include <QPainter>
5 
7 
8 namespace armarx
9 {
10 
12  {
13  }
14 
15  void
16  SemanticGraphGlobalItem::paint(QPainter* painter,
17  const QStyleOptionGraphicsItem* option,
18  QWidget* widget)
19  {
20  if (selected)
21  {
22  this->setPen(QPen(borderColor, 4.0f));
23  this->setBrush(QBrush(fillColor));
24  }
25  else
26  {
27  this->setPen(QPen(borderColor, 2.0f));
28  this->setBrush(QBrush(fillColor));
29  }
30  QGraphicsRectItem::paint(painter, option, widget);
31 
32  // Add text to the ellipse
33  QRectF rect = this->rect();
34  painter->setPen(fontColor);
35 
36  QFont font;
37  if (selected)
38  {
39  font.setBold(true);
40  }
41  else
42  {
43  font.setBold(false);
44  }
45  painter->setFont(font);
46  painter->drawText(rect, Qt::AlignCenter, text);
47  }
48 
49  void
50  SemanticGraphGlobalItem::mousePressEvent(QGraphicsSceneMouseEvent* event)
51  {
52  ARMARX_VERBOSE << "Pressed node: " << text.toStdString();
53  if (event->button() == Qt::LeftButton)
54  {
55  emit onLeftClick(this);
56  }
57  }
58 
59 } // namespace armarx
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:187
armarx::SemanticGraphGlobalItem::borderColor
QColor borderColor
Definition: SemanticGraphGlobalItem.h:25
armarx::SemanticGraphGlobalItem::SemanticGraphGlobalItem
SemanticGraphGlobalItem()
Definition: SemanticGraphGlobalItem.cpp:11
armarx::SemanticGraphGlobalItem::onLeftClick
void onLeftClick(SemanticGraphGlobalItem *)
armarx::SemanticGraphGlobalItem::selected
bool selected
Definition: SemanticGraphGlobalItem.h:22
armarx::SemanticGraphGlobalItem::mousePressEvent
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
Definition: SemanticGraphGlobalItem.cpp:50
armarx::SemanticGraphGlobalItem::fontColor
QColor fontColor
Definition: SemanticGraphGlobalItem.h:26
option
#define option(type, fn)
armarx::SemanticGraphGlobalItem::text
QString text
Definition: SemanticGraphGlobalItem.h:21
armarx::SemanticGraphGlobalItem::paint
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
Definition: SemanticGraphGlobalItem.cpp:16
Logging.h
SemanticGraphGlobalItem.h
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::SemanticGraphGlobalItem::fillColor
QColor fillColor
Definition: SemanticGraphGlobalItem.h:24