23
#include "PreCompiled.h"
28
# include <QStyleOptionGraphicsItem>
31
#include "QGIDecoration.h"
33
#include "PreferencesGui.h"
37
using namespace TechDrawGui;
38
using namespace TechDraw;
40
QGIDecoration::QGIDecoration() :
41
m_colCurrent(Qt::black),
42
m_styleCurrent(Qt::SolidLine),
43
m_brushCurrent(Qt::SolidPattern),
44
m_dragState(DECORNODRAG)
46
setCacheMode(QGraphicsItem::NoCache);
47
setAcceptHoverEvents(false);
48
setFlag(QGraphicsItem::ItemIsSelectable, false);
49
setFlag(QGraphicsItem::ItemIsMovable, false);
50
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
55
void QGIDecoration::draw()
59
void QGIDecoration::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
60
QStyleOptionGraphicsItem myOption(*option);
61
myOption.state &= ~QStyle::State_Selected;
63
QGraphicsItemGroup::paint (painter, &myOption, widget);
66
void QGIDecoration::setWidth(double w)
69
m_pen.setWidthF(m_width);
72
void QGIDecoration::setStyle(Qt::PenStyle s)
75
m_pen.setStyle(m_styleCurrent);
78
void QGIDecoration::setColor(QColor c)
82
m_pen.setColor(m_colCurrent);
83
m_brush.setColor(m_colCurrent);
86
QColor QGIDecoration::prefNormalColor()
88
return PreferencesGui::normalQColor();
91
QColor QGIDecoration::prefPreColor()
93
return PreferencesGui::preselectQColor();
96
QColor QGIDecoration::prefSelectColor()
98
return PreferencesGui::selectQColor();
101
QRectF QGIDecoration::boundingRect() const
103
return childrenBoundingRect();
107
void QGIDecoration::makeMark(double x, double y)
109
QGICMark* cmItem = new QGICMark(-1);
110
cmItem->setParentItem(this);
111
cmItem->setPos(x, y);
112
cmItem->setThick(2.0);
113
cmItem->setSize(40.0);
114
cmItem->setZValue(ZVALUE::VERTEX);
117
void QGIDecoration::makeMark(Base::Vector3d v)
122
void QGIDecoration::mousePressEvent(QGraphicsSceneMouseEvent * event)
125
m_dragState = DECORDRAGSTARTED;
127
QGraphicsItem::mousePressEvent(event);
130
void QGIDecoration::mouseMoveEvent(QGraphicsSceneMouseEvent * event)
132
if (m_dragState == DECORDRAGSTARTED) {
133
m_dragState = DECORDRAGGING;
135
QGraphicsItem::mouseMoveEvent(event);
138
void QGIDecoration::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
141
if (m_dragState == DECORDRAGGING) {
144
m_dragState = DECORNODRAG;
146
QGraphicsItem::mouseReleaseEvent(event);
149
void QGIDecoration::onDragFinished()