Poistioning and Rotation for QGIVAnnotation

This commit is contained in:
WandererFan
2017-10-30 13:12:04 -04:00
parent d832eb55c9
commit 9c85b1aca3
3 changed files with 18 additions and 7 deletions

View File

@@ -59,12 +59,13 @@ QGCustomText::QGCustomText()
void QGCustomText::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());
// 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);
}
void QGCustomText::centerAt(double cX, double cY)

View File

@@ -162,6 +162,15 @@ void QGIViewAnnotation::drawAnnotation()
m_textItem->setTextWidth(Rez::guiX(viewAnno->MaxWidth.getValue()));
QString qs = QString::fromUtf8(ss.str().c_str());
m_textItem->setHtml(qs);
m_textItem->setPos(0.,0.);
m_textItem->centerAt(0.,0.);
}
void QGIViewAnnotation::rotateView(void)
{
QRectF r = m_textItem->boundingRect();
m_textItem->setTransformOriginPoint(r.center());
double rot = getViewObject()->Rotation.getValue();
m_textItem->setRotation(-rot);
}

View File

@@ -50,6 +50,7 @@ public:
void setViewAnnoFeature(TechDraw::DrawViewAnnotation *obj);
virtual void draw() override;
virtual void rotateView(void) override;
protected:
void drawAnnotation();