23 #include <QStyleOptionGraphicsItem>
34 setFlag(QGraphicsItem::ItemIsMovable,
true);
35 setFlag(QGraphicsItem::ItemIsSelectable,
true);
36 setFlag(QGraphicsItem::ItemSendsGeometryChanges);
46 painter->setPen(Qt::gray);
47 if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus)) {
48 painter->setPen(Qt::DashLine);
57 painter->setPen(Qt::black);
62 painter->setFont(serifFont);
65 painter->drawText(textRect, Qt::AlignCenter,
m_label);
95 throw GUIHelpers::Error(
"ConnectableView::connectInputPort() -> Wrong input port number");
98 throw GUIHelpers::Error(
"ConnectableView::connectInputPort() -> Wrong output port number");
133 double dy = hspace / double(nintervals);
142 for (QGraphicsItem* item : childItems()) {
149 if (nport == nOutPorts && nOutPorts != 0)
151 port->setPos(0.0, ypos);
181 QRegExp capital_letter(
"[A-Z]");
182 QRegExp number(
"[0-9]");
183 int next_capital = capital_letter.indexIn(
name, 1);
184 int next_number = number.indexIn(
name, 1);
185 if (next_capital > 0 && next_capital <
name.size() - 2) {
186 int first_split_index =
187 (next_number > 0 && next_number < next_capital) ? next_number : next_capital;
188 QString result =
name.left(first_split_index) + QString(
"\n")
189 +
name.right(
name.size() - first_split_index);
#define ASSERT(condition)
Defines class ConnectableView.
Defines class DesignerHelper.
Defines class GUIHelpers functions.
Defines class NodeEditorConnection.
Defines class SessionItem.
DefinesStyleUtils namespace.
view of ISampleNode's with rectangular shape and node functionality
virtual QString getLabel() const
QString hyphenate(const QString &name) const
ConnectableView(QGraphicsItem *parent=0, QRectF rect={0, 0, 50, 50})
QList< NodeEditorPort * > getOutputPorts()
void connectInputPort(ConnectableView *other, int port_number)
connects input port with given index with output port of other view
int getInputPortIndex(NodeEditorPort *port)
virtual void update_appearance()
updates visual appearance of the item (color, icons, size etc)
virtual int getNumberOfPorts()
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
virtual void setLabel(const QString &name)
virtual int getNumberOfOutputPorts()
virtual void setPortCoordinates()
virtual QRectF getRectangle() const
virtual int getNumberOfInputPorts()
QList< NodeEditorPort * > m_input_ports
virtual NodeEditorPort * addPort(const QString &name, NodeEditorPort::EPortDirection direction, NodeEditorPort::EPortType port_type)
adds port to view
QList< NodeEditorPort * > m_output_ports
static QGradient getDecorationGradient(const QColor &color, const QRectF &rect)
static int getLabelFontSize()
parent class for graphic representation of all ISampleNode's
virtual void update_appearance()
updates visual appearance of the item (color, icons, size etc)
void setPort2(NodeEditorPort *p)
void setPort1(NodeEditorPort *p)
bool isConnected(NodeEditorPort *)
EPortType
type of ports, same type can be connected together
EPortDirection
port direction
QString displayName() const
Get display name of item, append index if ambigue.
QString const & name(EShape k)
QSize SizeOfLetterM(const QWidget *widget=nullptr)
Returns size of largest letter of default system font.