git-svn-id: svn://db.shs.com.ru/libs@371 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -19,6 +19,10 @@ BlockBusItem::BlockBusItem(const BlockBusItem & other): QGraphicsObject(), Prope
|
||||
max_ep = other.max_ep;
|
||||
pol = other.pol;
|
||||
segments = other.segments;
|
||||
im_bus = other.im_bus;
|
||||
im_end = other.im_end;
|
||||
im_bus_scale = other.im_bus_scale;
|
||||
im_end_scale = other.im_end_scale;
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
@@ -45,6 +49,7 @@ void BlockBusItem::_init() {
|
||||
selPoint = selSegment = state_ = -1;
|
||||
pen_width = 2.;
|
||||
point_size = 3.;
|
||||
im_bus_scale = im_end_scale = 1.;
|
||||
moved = deleted = mark_in = mark_out = new_segment = mm_cancel = lm_point = false;
|
||||
anim_point_size.setTargetObject(this);
|
||||
anim_point_size.setPropertyName("pointSize");
|
||||
@@ -320,7 +325,8 @@ void BlockBusItem::clearBusState() {
|
||||
QByteArray BlockBusItem::save() const {
|
||||
ChunkStream cs;
|
||||
cs << cs.chunk(1, busType()) << cs.chunk(2, busName()) << cs.chunk(3, width()) << cs.chunk(4, pen())
|
||||
<< cs.chunk(5, brush()) << cs.chunk(6, pol) << cs.chunk(7, segments) << cs.chunk(8, props);
|
||||
<< cs.chunk(5, brush()) << cs.chunk(6, pol) << cs.chunk(7, segments) << cs.chunk(8, props)
|
||||
<< cs.chunk(9, im_bus_scale) << cs.chunk(10, im_end_scale);
|
||||
return cs.data();
|
||||
}
|
||||
|
||||
@@ -339,6 +345,8 @@ void BlockBusItem::load(const QByteArray & data) {
|
||||
case 6: pol = cs.getData<QPolygonF>(); break;
|
||||
case 7: segments = cs.getData<QList<QPair<int, int> > >(); break;
|
||||
case 8: props = cs.getData<QList<BlockItem::Property> >(); break;
|
||||
case 9: im_bus_scale = cs.getData<double>(); break;
|
||||
case 10: im_end_scale = cs.getData<double>(); break;
|
||||
}
|
||||
}
|
||||
updateGeometry();
|
||||
@@ -722,7 +730,8 @@ void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidg
|
||||
QTransform tf;
|
||||
tf.translate(sp.x(), sp.y());
|
||||
tf.rotate(-QLineF(sp, ep).angle());
|
||||
tf.translate(0., -im_bus.height() / 2.);
|
||||
tf.translate(0., -im_bus.height() / 2. * im_bus_scale);
|
||||
tf.scale(im_bus_scale, im_bus_scale);
|
||||
/*
|
||||
br.setTransform(tf);
|
||||
p->setPen(QPen(br, im_bus.height(), Qt::SolidLine, Qt::FlatCap, Qt::BevelJoin));
|
||||
@@ -733,7 +742,7 @@ void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidg
|
||||
p->setPen(Qt::NoPen);
|
||||
p->setBrush(br);
|
||||
//p->drawLine(QPointF(0., 0.), QPointF(QLineF(sp, ep).length(), 0.));
|
||||
p->drawRect(QRectF(0., 0., QLineF(sp, ep).length(), im_bus.height()));
|
||||
p->drawRect(QRectF(0., 0., QLineF(sp, ep).length() / qMax<double>(im_bus_scale, 1E-3), im_bus.height()));
|
||||
p->restore();
|
||||
}
|
||||
}
|
||||
@@ -743,7 +752,8 @@ void BlockBusItem::paint(QPainter * p, const QStyleOptionGraphicsItem * o, QWidg
|
||||
QTransform tf;
|
||||
tf.translate(sp.x(), sp.y());
|
||||
tf.rotate(-QLineF(sp, ep).angle());
|
||||
tf.translate(-pen_width, -im_end.height() / 2.);
|
||||
tf.translate(-pen_width, -im_end.height() / 2. * im_end_scale);
|
||||
tf.scale(im_end_scale, im_end_scale);
|
||||
p->save();
|
||||
p->setTransform(tf, true);
|
||||
p->drawImage(0, 0, im_end);
|
||||
|
||||
@@ -30,11 +30,15 @@ public:
|
||||
|
||||
void setGridStep(double gs) {grid_step = gs;}
|
||||
void setEndpointsNumber(int num) {max_ep = num;}
|
||||
void setImages(const QImage & bus, const QImage & end = QImage()) {im_bus = bus; im_end = end;}
|
||||
void setImages(const QImage & bus, const QImage & end = QImage()) {im_bus = bus; im_end = end; update();}
|
||||
void setBusImageScale(double s) {im_bus_scale = s; update();}
|
||||
void setEndpointImageScale(double s) {im_end_scale = s; update();}
|
||||
void setBusType(int type_) {bus_type = type_;}
|
||||
void setBusName(const QString & name) {bus_name = name;}
|
||||
int busType() const {return bus_type;}
|
||||
QString busName() const {return bus_name;}
|
||||
double busImageScale() const {return im_bus_scale;}
|
||||
double endpointImageScale() const {return im_end_scale;}
|
||||
void appendPoint(const QPointF & p);
|
||||
void appendPoint(qreal x, qreal y);
|
||||
void testPoint(QPointF pos, int * sel_point, int * sel_segment);
|
||||
@@ -114,7 +118,7 @@ protected:
|
||||
QPolygonF pol, bpol, pol_s;
|
||||
Qt::KeyboardModifiers mm_mods;
|
||||
bool temp_;
|
||||
double pen_width, grid_step;
|
||||
double pen_width, grid_step, im_bus_scale, im_end_scale;
|
||||
int selPoint, selSegment, max_ep, bus_type, state_;
|
||||
bool moved, deleted, mark_in, mark_out, new_segment, mm_cancel, lm_point;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user