diff --git a/qad/blockview/blockbase.cpp b/qad/blockview/blockbase.cpp index 1a2bb13..d93d87c 100644 --- a/qad/blockview/blockbase.cpp +++ b/qad/blockview/blockbase.cpp @@ -28,7 +28,7 @@ QDataStream & operator <<(QDataStream & s, const QGraphicsItem * item) { } else if (ipath) { s << int(4) << (ipath->pen()) << (ipath->path()); } else if (ipixmap) { - s << int(5) << (ipixmap->pixmap()); + s << int(7) << (ipixmap->pixmap()) << (ipixmap->transform()); } else { s << int(-1); return s; @@ -94,6 +94,11 @@ QDataStream & operator >>(QDataStream & s, QGraphicsItem *& item) { npixmap = new QGraphicsPixmapItem(); item = npixmap; {QPixmap _v; s >> _v; npixmap->setPixmap(_v);} break; + case 7: + npixmap = new QGraphicsPixmapItem(); item = npixmap; + {QPixmap _v; s >> _v; npixmap->setPixmap(_v);} + {QTransform _t; s >> _t; npixmap->setTransform(_t);} + break; } if (item) { {QPointF _v; s >> _v; item->setPos(_v);} diff --git a/qad/blockview/drawtools.cpp b/qad/blockview/drawtools.cpp index 195135a..ee36882 100644 --- a/qad/blockview/drawtools.cpp +++ b/qad/blockview/drawtools.cpp @@ -261,6 +261,8 @@ actions_Z_up(this), actions_Z_top(this), actions_Z_down(this), actions_Z_bottom( connect(ui->spinHeight, SIGNAL(editingFinished()), this, SLOT(changeFinished())); connect(ui->spinThick, SIGNAL(valueChanged(double)), this, SLOT(propertyChanged())); connect(ui->spinThick, SIGNAL(editingFinished()), this, SLOT(changeFinished())); + connect(ui->spinScale, SIGNAL(valueChanged(double)), this, SLOT(propertyChanged())); + connect(ui->spinScale, SIGNAL(editingFinished()), this, SLOT(changeFinished())); connect(ui->comboText, SIGNAL(editTextChanged(QString)), this, SLOT(propertyChanged())); connect(ui->comboText->lineEdit(), SIGNAL(editingFinished()), this, SLOT(changeFinished())); connect(ui->colorButtonPen, SIGNAL(colorChanged(QColor)), this, SLOT(propertyChanged())); @@ -586,6 +588,7 @@ void DrawTools::selectionChanged() { size_item.assignObject(iatext); } else if (ipixmap) { ui->stackedProperties->setCurrentIndex(2); + ui->spinScale->setValue(sqrt(ipixmap->transform().determinant())); setPenBrushEnabled(false, false); size_item.assignObject(ipixmap); } else if (irect || iell) { @@ -666,6 +669,16 @@ void DrawTools::propertyChanged() { iatext->setBrush(ui->colorButtonPen->color()); iatext->setAlignment(align); } else if (ipixmap) { + QTransform t = ipixmap->transform(); + double det = sqrt(t.determinant()); + QSizeF os = ipixmap->boundingRect().size() * det; + if (det != 0.) t.scale(1. / det, 1. / det); + det = ui->spinScale->value(); + t.scale(det, det); + ipixmap->setTransform(t); + QSizeF ns = ipixmap->boundingRect().size() * det; + QSizeF ds = (os - ns) / 2.; + ipixmap->setPos(ipixmap->pos() + QPointF(ds.width(), ds.height())); } else if (irect || iell) { QAbstractGraphicsShapeItem * ishape(0); if (irect) { diff --git a/qad/blockview/drawtools.ui b/qad/blockview/drawtools.ui index 7449dcf..c7f57fb 100644 --- a/qad/blockview/drawtools.ui +++ b/qad/blockview/drawtools.ui @@ -6,7 +6,7 @@ 0 0 - 656 + 712 111 @@ -14,7 +14,16 @@ Form - + + 0 + + + 0 + + + 0 + + 0 @@ -24,7 +33,16 @@ - + + 0 + + + 0 + + + 0 + + 0 @@ -87,7 +105,16 @@ - + + 0 + + + 0 + + + 0 + + 0 @@ -136,7 +163,16 @@ - + + 0 + + + 0 + + + 0 + + 0 @@ -383,7 +419,16 @@ - + + 0 + + + 0 + + + 0 + + 0 @@ -502,11 +547,26 @@ - + + 0 + + + 0 + + + 0 + + 0 + + + 0 + 0 + + Load image ... @@ -516,6 +576,57 @@ + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 20 + 1 + + + + + + + + + 0 + 0 + + + + Scale: + + + + + + + + 0 + 0 + + + + 3 + + + 999.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + +