]> Creatis software - cpPlugins.git/blob - libs/cpPipelineEditor/Block.cxx
...
[cpPlugins.git] / libs / cpPipelineEditor / Block.cxx
1 #include <cpPipelineEditor/Block.h>
2 #include <QPainter>
3
4 // -------------------------------------------------------------------------
5 cpPipelineEditor::Block::
6 Block( QGraphicsItem* parent, QGraphicsScene* scene )
7   : Superclass( parent, scene )
8 {
9   this->m_SelectedColor = Qt::darkYellow;
10   this->m_NotSelectedColor = Qt::darkGreen;
11
12   QPainterPath p;
13   p.addRoundedRect( -50, -50, 50, 50, 5, 5 );
14
15   this->setPath( p );
16   this->setPen( QPen( this->m_NotSelectedColor ) );
17   this->setBrush( this->m_NotSelectedColor );
18   this->setFlag( QGraphicsItem::ItemIsMovable );
19   this->setFlag( QGraphicsItem::ItemIsSelectable );
20 }
21
22 // -------------------------------------------------------------------------
23 cpPipelineEditor::Block::
24 ~Block( )
25 {
26 }
27
28 // -------------------------------------------------------------------------
29 void cpPipelineEditor::Block::
30 paint(
31   QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget
32   )
33 {
34   Q_UNUSED( option );
35   Q_UNUSED( widget );
36
37   if( this->isSelected( ) )
38   {
39     painter->setPen( QPen( this->m_SelectedColor ) );
40     painter->setBrush( this->m_SelectedColor );
41   }
42   else
43   {
44     painter->setPen( QPen( this->m_NotSelectedColor ) );
45     painter->setBrush( this->m_NotSelectedColor );
46
47   } // fi
48   painter->drawPath( this->path( ) );
49 }
50
51 // eof - $RCSfile$