kblackbox
kbbgraphicsitemlaser.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "kbbgraphicsitemlaser.h"
00032
00033 #include <QGraphicsSceneMouseEvent>
00034
00035
00036
00037 #include "kbbgraphicsitem.h"
00038 #include "kbbgraphicsitemborder.h"
00039 #include "kbbitemwithposition.h"
00040 #include "kbbscalablegraphicwidget.h"
00041 #include "kbbthememanager.h"
00042
00043
00044
00045
00046
00047
00048
00049 KBBGraphicsItemLaser::KBBGraphicsItemLaser(KBBScalableGraphicWidget* parent, KBBThemeManager* themeManager, const int borderPosition, const int columns, const int rows) : KBBGraphicsItemBorder(borderPosition, columns, rows, 0), KBBGraphicsItem(((borderPosition<columns) ? KBBScalableGraphicWidget::laser0 : ((borderPosition<columns + rows) ? KBBScalableGraphicWidget::laser90 : ((borderPosition<2*columns + rows) ? KBBScalableGraphicWidget::laser180 : KBBScalableGraphicWidget::laser270))) , parent->scene(), themeManager), KBBItemWithPosition()
00050 {
00051 m_widget = parent;
00052
00053 const int radius = KBBScalableGraphicWidget::RATIO/2;
00054 if (rotation()==90) {
00055 setPos(m_centerX - 3*radius, m_centerY - radius);
00056 } else if (rotation()==180) {
00057 setPos(m_centerX - radius, m_centerY - 3*radius);
00058 } else {
00059 setPos(m_centerX - radius, m_centerY - radius);
00060 }
00061
00062 setAcceptsHoverEvents(true);
00063 }
00064
00065
00066
00067
00068
00069
00070
00071 const int KBBGraphicsItemLaser::position ()
00072 {
00073 return m_borderPosition;
00074 }
00075
00076
00077
00078
00079
00080
00081
00082 void KBBGraphicsItemLaser::hoverEnterEvent (QGraphicsSceneHoverEvent*)
00083 {
00084 m_widget->drawRay(position());
00085 }
00086
00087
00088 void KBBGraphicsItemLaser::hoverLeaveEvent (QGraphicsSceneHoverEvent*)
00089 {
00090 m_widget->removeRay();
00091 }
00092
00093
00094 void KBBGraphicsItemLaser::mousePressEvent (QGraphicsSceneMouseEvent* event)
00095 {
00096 if (event->buttons()==Qt::LeftButton) {
00097 m_widget->mouseBorderClick(position());
00098 }
00099 }