QGIArrow inherits QGIPrimPath
This commit is contained in:
@@ -37,45 +37,43 @@
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
QGIArrow::QGIArrow(QGraphicsScene *scene)
|
||||
QGIArrow::QGIArrow() :
|
||||
m_fill(Qt::SolidPattern),
|
||||
m_size(5.0)
|
||||
{
|
||||
isFlipped = false;
|
||||
m_brush.setStyle(m_fill);
|
||||
|
||||
if(scene) {
|
||||
scene->addItem(this);
|
||||
}
|
||||
|
||||
// Set Cache Mode
|
||||
setCacheMode(QGraphicsItem::NoCache);
|
||||
setAcceptHoverEvents(false);
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
}
|
||||
|
||||
QPainterPath QGIArrow::shape() const
|
||||
{
|
||||
return path();
|
||||
}
|
||||
//QPainterPath QGIArrow::shape() const
|
||||
//{
|
||||
// return path();
|
||||
//}
|
||||
|
||||
void QGIArrow::setHighlighted(bool state)
|
||||
{
|
||||
QPen myPen = pen();
|
||||
QBrush myBrush = brush();
|
||||
if(state) {
|
||||
myPen.setColor(Qt::blue);
|
||||
myBrush.setColor(Qt::blue);
|
||||
} else {
|
||||
myPen.setColor(Qt::black);
|
||||
myBrush.setColor(Qt::black);
|
||||
}
|
||||
setBrush(myBrush);
|
||||
setPen(myPen);
|
||||
}
|
||||
//void QGIArrow::setHighlighted(bool state)
|
||||
//{
|
||||
// QPen myPen = pen();
|
||||
// QBrush myBrush = brush();
|
||||
// if(state) {
|
||||
// myPen.setColor(Qt::blue);
|
||||
// myBrush.setColor(Qt::blue);
|
||||
// } else {
|
||||
// myPen.setColor(Qt::black);
|
||||
// myBrush.setColor(Qt::black);
|
||||
// }
|
||||
// setBrush(myBrush);
|
||||
// setPen(myPen);
|
||||
//}
|
||||
|
||||
QVariant QGIArrow::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
return QGraphicsPathItem::itemChange(change, value);
|
||||
}
|
||||
//QVariant QGIArrow::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
//{
|
||||
// return QGraphicsPathItem::itemChange(change, value);
|
||||
//}
|
||||
|
||||
void QGIArrow::flip(bool state) {
|
||||
isFlipped = state;
|
||||
@@ -84,14 +82,14 @@ void QGIArrow::flip(bool state) {
|
||||
void QGIArrow::draw() {
|
||||
// the center is the end point on a dimension
|
||||
QPainterPath path;
|
||||
QPen pen(Qt::black);
|
||||
pen.setWidth(1);
|
||||
//QPen pen(Qt::black);
|
||||
//pen.setWidth(1);
|
||||
|
||||
QBrush brush(Qt::black);
|
||||
//QBrush brush(Qt::black);
|
||||
//setPen(pen);
|
||||
setBrush(brush);
|
||||
//setBrush(brush);
|
||||
|
||||
float length = -5.; //TODO: Arrow heads sb preference? size & type?
|
||||
float length = -m_size; //TODO: Arrow heads sb preference? size & type?
|
||||
|
||||
if(isFlipped)
|
||||
length *= -1;
|
||||
@@ -103,12 +101,27 @@ void QGIArrow::draw() {
|
||||
// path.moveTo(QPointF(-1,1));
|
||||
// path.lineTo(QPointF(1,-1));
|
||||
setPath(path);
|
||||
}
|
||||
|
||||
void QGIArrow::setSize(double s)
|
||||
{
|
||||
m_size = s;
|
||||
//???
|
||||
}
|
||||
|
||||
void QGIArrow::setStyle(int s)
|
||||
{
|
||||
m_style = s;
|
||||
//???
|
||||
}
|
||||
|
||||
void QGIArrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
QGraphicsPathItem::paint(painter, &myOption, widget);
|
||||
|
||||
m_brush.setColor(m_colCurrent);
|
||||
m_brush.setStyle(m_fill);
|
||||
setBrush(m_brush);
|
||||
QGIPrimPath::paint (painter, &myOption, widget);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user