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