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