-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgraphicsscene.cpp
43 lines (35 loc) · 1.08 KB
/
graphicsscene.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "graphicsscene.h"
#include <QPainter>
QPointF GraphicsScene::overlayPos( ) const {
return( m_overlayPos );
}
GraphicsScene::GraphicsScene( QObject *parent ) : QGraphicsScene( parent ) {
m_overlay = false;
m_overlayPen = QPen( Qt::green );
m_overlayPos = QPointF( -1, -1 );
}
void GraphicsScene::setOverlayPen( const QPen &overlayPen ) {
m_overlayPen = overlayPen;
update( );
}
void GraphicsScene::setOverlayPos( QPointF pos ) {
m_overlayPos = pos;
update( );
}
bool GraphicsScene::overlay( ) const {
return( m_overlay );
}
void GraphicsScene::setOverlay( bool overlay ) {
m_overlay = overlay;
update( );
}
void GraphicsScene::drawForeground( QPainter *painter, const QRectF &rect ) {
if( m_overlay ) {
painter->setRenderHint( QPainter::Antialiasing );
painter->setPen( m_overlayPen );
// painter->setOpacity( 1.0 );
painter->drawLine( m_overlayPos.x( ), 0, m_overlayPos.x( ), height( ) ); /* vertical */
painter->drawLine( 0, m_overlayPos.y( ), width( ), m_overlayPos.y( ) ); /* horizontal */
}
QGraphicsScene::drawForeground( painter, rect );
}