diff --git a/src/Mod/TechDraw/Gui/QGCustomClip.cpp b/src/Mod/TechDraw/Gui/QGCustomClip.cpp
index 55b9f3e34e..81cc055897 100644
--- a/src/Mod/TechDraw/Gui/QGCustomClip.cpp
+++ b/src/Mod/TechDraw/Gui/QGCustomClip.cpp
@@ -35,7 +35,6 @@
#include
#include
-#include
#include "QGCustomClip.h"
using namespace TechDrawGui;
@@ -53,12 +52,7 @@ QGCustomClip::QGCustomClip()
void QGCustomClip::centerAt(QPointF centerPos)
{
- QRectF box = boundingRect();
- double width = box.width();
- double height = box.height();
- double newX = centerPos.x() - width/2.;
- double newY = centerPos.y() - height/2.;
- setPos(newX,newY);
+ centerAt(centerPos.x(),centerPos.y());
}
void QGCustomClip::centerAt(double cX, double cY)
@@ -83,7 +77,6 @@ void QGCustomClip::setRect(double x, double y, double w, double h)
setRect(r);
}
-
QRectF QGCustomClip::rect()
{
return m_rect;
@@ -93,6 +86,8 @@ void QGCustomClip::paint ( QPainter * painter, const QStyleOptionGraphicsItem *
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
+// painter->drawRect(boundingRect()); //good for debugging
+
QGraphicsItemGroup::paint (painter, &myOption, widget);
}
diff --git a/src/Mod/TechDraw/Gui/QGCustomImage.cpp b/src/Mod/TechDraw/Gui/QGCustomImage.cpp
index 0344391443..95a3db155e 100644
--- a/src/Mod/TechDraw/Gui/QGCustomImage.cpp
+++ b/src/Mod/TechDraw/Gui/QGCustomImage.cpp
@@ -31,6 +31,7 @@
#include
#include
+
#include "QGCustomImage.h"
using namespace TechDrawGui;
@@ -55,20 +56,12 @@ void QGCustomImage::centerAt(QPointF centerPos)
void QGCustomImage::centerAt(double cX, double cY)
{
-// QGraphicsItemGroup* g = group();
-// if (g == nullptr) {
-// return;
-// }
- QPointF parentPt(cX,cY);
- QPointF myPt = mapFromParent(parentPt);
-
QRectF br = boundingRect();
- double width = br.width();
- double height = br.height();
- double newX = width/2.0;
- double newY = height/2.0;
- QPointF off(myPt.x() - newX,myPt.y() - newY);
- setOffset(off);
+ double width = br.width() * scale();
+ double height = br.height() * scale();
+ double newX = cX - width/2.;
+ double newY = cY - height/2.;
+ setPos(newX, newY);
}
bool QGCustomImage::load(QString fileSpec)
@@ -76,9 +69,6 @@ bool QGCustomImage::load(QString fileSpec)
bool success = true;
QPixmap px(fileSpec);
m_px = px;
-// if (m_px.isNull()) {
-// Base::Console().Message("TRACE - QGCustomImage::load - pixmap no good\n");
-// }
prepareGeometryChange();
setPixmap(m_px);
return(success);
@@ -88,5 +78,8 @@ void QGCustomImage::paint ( QPainter * painter, const QStyleOptionGraphicsItem *
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
+ //painter->drawRect(boundingRect()); //good for debugging
+
QGraphicsPixmapItem::paint (painter, &myOption, widget);
}
+
diff --git a/src/Mod/TechDraw/Gui/QGIViewImage.cpp b/src/Mod/TechDraw/Gui/QGIViewImage.cpp
index d25c43465f..0c63fa9692 100644
--- a/src/Mod/TechDraw/Gui/QGIViewImage.cpp
+++ b/src/Mod/TechDraw/Gui/QGIViewImage.cpp
@@ -61,13 +61,13 @@ QGIViewImage::QGIViewImage()
m_cliparea = new QGCustomClip();
addToGroup(m_cliparea);
- m_cliparea->setPos(0.,0.);
m_cliparea->setRect(0.,0.,5.,5.);
+ m_cliparea->centerAt(0.,0.);
m_imageItem = new QGCustomImage();
m_imageItem->setTransformationMode(Qt::SmoothTransformation);
m_cliparea->addToGroup(m_imageItem);
- m_imageItem->setPos(0.,0.);
+ m_imageItem->centerAt(0.,0.);
}
QGIViewImage::~QGIViewImage()
@@ -117,11 +117,10 @@ void QGIViewImage::draw()
auto viewImage( dynamic_cast(getViewObject()) );
if (!viewImage)
return;
- QRectF newRect(0.0,0.0,Rez::guiX(viewImage->Width.getValue()),Rez::guiX(viewImage->Height.getValue()));
- double pad = Rez::guiX(1.0);
- m_cliparea->setRect(newRect.adjusted(-pad,-pad,pad,pad));
-
+ QRectF newRect(0.0,0.0,viewImage->Width.getValue(),viewImage->Height.getValue());
+ m_cliparea->setRect(newRect);
drawImage();
+ m_cliparea->centerAt(0.0,0.0);
if (borderVisible) {
drawBorder();
}
@@ -146,4 +145,12 @@ void QGIViewImage::drawImage()
}
}
+void QGIViewImage::rotateView(void)
+{
+ QRectF r = m_cliparea->boundingRect();
+ m_cliparea->setTransformOriginPoint(r.center());
+ double rot = getViewObject()->Rotation.getValue();
+ m_cliparea->setRotation(-rot);
+}
+
diff --git a/src/Mod/TechDraw/Gui/QGIViewImage.h b/src/Mod/TechDraw/Gui/QGIViewImage.h
index 7ca5298f71..e6ded6d010 100644
--- a/src/Mod/TechDraw/Gui/QGIViewImage.h
+++ b/src/Mod/TechDraw/Gui/QGIViewImage.h
@@ -51,6 +51,7 @@ public:
void setViewImageFeature(TechDraw::DrawViewImage *obj);
virtual void draw() override;
+ virtual void rotateView(void) override;
protected:
virtual void drawImage();