mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Paint the connection text, boxes separately.
This commit is contained in:
parent
8da5ba9296
commit
ab7c580ce7
4 changed files with 60 additions and 4 deletions
|
@ -38,8 +38,6 @@ QWidget( parent )
|
|||
m_scene = new QGraphicsScene( this );
|
||||
m_ui.view->setScene( m_scene );
|
||||
|
||||
m_scene->addSimpleText( "Hello" );
|
||||
|
||||
connect( m_scene, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,10 @@ void ExpressionLink::nodeMoved()
|
|||
|
||||
void ExpressionLink::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
|
||||
{
|
||||
setPen( QPen( Qt::black ) );
|
||||
QPen p;
|
||||
p.setColor( Qt::black );
|
||||
p.setWidth( 5 );
|
||||
setPen( p );
|
||||
|
||||
QGraphicsLineItem::paint( painter, option, widget );
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ QRectF ExpressionNode::boundingRect() const
|
|||
void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
|
||||
{
|
||||
QBrush br;
|
||||
QBrush boxBrush;
|
||||
QPen p;
|
||||
QColor c;
|
||||
|
||||
|
@ -62,7 +63,6 @@ void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *o
|
|||
painter->setPen( p );
|
||||
painter->drawText( header, Qt::AlignCenter, "Something" );
|
||||
|
||||
|
||||
if( option->state & QStyle::State_Selected )
|
||||
{
|
||||
p.setStyle( Qt::DotLine );
|
||||
|
@ -73,6 +73,8 @@ void ExpressionNode::paint( QPainter *painter, const QStyleOptionGraphicsItem *o
|
|||
painter->setPen( p );
|
||||
painter->drawRect( rect );
|
||||
painter->drawRect( header );
|
||||
|
||||
paintConnections( painter );
|
||||
}
|
||||
|
||||
|
||||
|
@ -84,4 +86,55 @@ void ExpressionNode::mouseMoveEvent( QGraphicsSceneMouseEvent *e )
|
|||
QGraphicsItem::mouseMoveEvent( e );
|
||||
}
|
||||
|
||||
void ExpressionNode::paintConnections( QPainter *painter )
|
||||
{
|
||||
QRectF rect = boundingRect();
|
||||
QBrush boxBrush;
|
||||
QPen p;
|
||||
|
||||
boxBrush.setColor( Qt::black );
|
||||
boxBrush.setStyle( Qt::SolidPattern );
|
||||
p.setColor( Qt::black );
|
||||
|
||||
QRectF box = rect;
|
||||
QRectF tbox = rect;
|
||||
qreal wh = 10.0;
|
||||
qreal tw = 25.0;
|
||||
qreal th = 12.0;
|
||||
|
||||
box.setTopLeft( QPoint( 0, rect.height() * 0.5 ) );
|
||||
box.setHeight( wh );
|
||||
box.setWidth( wh );
|
||||
|
||||
painter->fillRect( box, boxBrush );
|
||||
|
||||
tbox.setTopLeft( QPoint( 15, rect.height() * 0.50 ) );
|
||||
tbox.setHeight( th );
|
||||
tbox.setWidth( tw );
|
||||
painter->setPen( p );
|
||||
painter->drawText( tbox, Qt::AlignCenter, "Out" );
|
||||
|
||||
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
qreal x = rect.width() - wh;
|
||||
qreal y = 30 + i * 20;
|
||||
qreal tx = x - 5 - tw;
|
||||
qreal ty = y - 2;
|
||||
|
||||
box.setTopLeft( QPoint( x, y ) );
|
||||
box.setHeight( wh );
|
||||
box.setWidth( wh );
|
||||
|
||||
painter->fillRect( box, boxBrush );
|
||||
|
||||
tbox.setTopLeft( QPoint( tx, ty ) );
|
||||
tbox.setHeight( th );
|
||||
tbox.setWidth( tw );
|
||||
|
||||
QString text = 'A' + i;
|
||||
painter->drawText( tbox, Qt::AlignRight, text );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ protected:
|
|||
void mouseMoveEvent( QGraphicsSceneMouseEvent *e );
|
||||
|
||||
private:
|
||||
void paintConnections( QPainter *painter );
|
||||
|
||||
ExpressionLink *m_link;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue