mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-04 19:40:53 +01:00
Basic Primitive shapes added (line,rectangle,ellipse). Default style dashed.
Pending work: 1. DXF Export 2. XML Import / Export 3. Properties Edit option (line style/colour/weight) 4. Debugging required git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2873 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
45
sources/qetgraphicsitem/qetshapeitem.cpp
Normal file
45
sources/qetgraphicsitem/qetshapeitem.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "qetshapeitem.h"
|
||||
|
||||
QetShapeItem::QetShapeItem(QPointF p1, QPointF p2, ShapeType type, bool lineAngle,QGraphicsItem *parent) :
|
||||
QetGraphicsItem(parent),
|
||||
_shapeStyle(Qt::DashLine),
|
||||
_lineAngle(lineAngle)
|
||||
{
|
||||
_shapeType = type;
|
||||
_boundingRect = QRectF(p1, p2);
|
||||
}
|
||||
|
||||
QetShapeItem::~QetShapeItem()
|
||||
{
|
||||
}
|
||||
|
||||
void QetShapeItem::setStyle(Qt::PenStyle newStyle)
|
||||
{
|
||||
_shapeStyle = newStyle;
|
||||
}
|
||||
|
||||
QRectF QetShapeItem::boundingRect() const
|
||||
{
|
||||
return _boundingRect;
|
||||
}
|
||||
|
||||
void QetShapeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
QRectF rec = boundingRect();
|
||||
QPen pen(Qt::black);
|
||||
pen.setStyle(_shapeStyle);
|
||||
painter->setPen(pen);
|
||||
switch(_shapeType) {
|
||||
case Line:
|
||||
if (_lineAngle)
|
||||
painter -> drawLine(rec.topRight(), rec.bottomLeft());
|
||||
else
|
||||
painter -> drawLine(rec.topLeft(), rec.bottomRight());
|
||||
break;
|
||||
case Rectangle:
|
||||
painter -> drawRect(rec);
|
||||
break;
|
||||
default: //(case Ellipse:)
|
||||
painter ->drawEllipse(rec);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user