Fixed rotation
--HG-- branch : feature
This commit is contained in:
parent
99925db9d6
commit
74a49662f6
|
@ -29,6 +29,7 @@
|
|||
#include <QPainter>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QGraphicsView>
|
||||
#include <QTransform>
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -43,6 +44,7 @@
|
|||
#define MIN_FONT_SIZE 12
|
||||
#define MAX_FONT_SIZE 48
|
||||
#define SPACING 2
|
||||
#define TOP_Z 2
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VTextGraphicsItem::VTextGraphicsItem(QGraphicsItem* pParent)
|
||||
|
@ -55,7 +57,7 @@ VTextGraphicsItem::VTextGraphicsItem(QGraphicsItem* pParent)
|
|||
m_rectBoundingBox.setTopLeft(QPointF(0, 0));
|
||||
m_iMinH = MIN_H;
|
||||
SetSize(MIN_W, m_iMinH);
|
||||
setZValue(2);
|
||||
setZValue(TOP_Z);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -137,11 +139,10 @@ void VTextGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VTextGraphicsItem::Reset()
|
||||
{
|
||||
qDebug() << "RESET" << m_eMode << m_liLines.count();
|
||||
m_eMode = mNormal;
|
||||
m_bReleased = false;
|
||||
Update();
|
||||
setZValue(2);
|
||||
setZValue(TOP_Z);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -206,6 +207,7 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME)
|
|||
m_ptStartPos = pos();
|
||||
m_ptStart = pME->scenePos();
|
||||
m_szStart = m_rectBoundingBox.size();
|
||||
m_ptRotCenter = mapToScene(m_rectBoundingBox.center());
|
||||
m_dAngle = GetAngle(pME->scenePos());
|
||||
m_dRotation = rotation();
|
||||
if (m_eMode != mRotate)
|
||||
|
@ -219,9 +221,8 @@ void VTextGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *pME)
|
|||
m_eMode = mMove;
|
||||
}
|
||||
}
|
||||
setZValue(3);
|
||||
setZValue(TOP_Z + 1);
|
||||
UpdateBox();
|
||||
qDebug() << "PRESS" << m_eMode << m_liLines.count();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,8 +263,6 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
|
|||
double dDist = fabs(pME->scenePos().x() - m_ptStart.x()) + fabs(pME->scenePos().y() - m_ptStart.y());
|
||||
bool bShort = (dDist < 2);
|
||||
|
||||
qDebug() << "RELEASE" << m_eMode << dDist << m_liLines.count();
|
||||
|
||||
if (m_eMode == mMove || m_eMode == mResize)
|
||||
{ // when released in mMove or mResize mode
|
||||
if (bShort == true)
|
||||
|
@ -299,7 +298,6 @@ void VTextGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* pME)
|
|||
}
|
||||
}
|
||||
m_bReleased = true;
|
||||
qDebug() << "RELEASE finished" << m_eMode << m_liLines.count();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,8 +380,8 @@ QStringList VTextGraphicsItem::SplitString(const QString &qs, qreal fW, const QF
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
double VTextGraphicsItem::GetAngle(QPointF pt) const
|
||||
{
|
||||
double dX = pt.x() - m_ptStart.x();
|
||||
double dY = pt.y() - m_ptStart.y();
|
||||
double dX = pt.x() - m_ptRotCenter.x();
|
||||
double dY = pt.y() - m_ptRotCenter.y();
|
||||
|
||||
if (fabs(dX) < 1 && fabs(dY) < 1)
|
||||
return 0;
|
||||
|
|
|
@ -92,6 +92,7 @@ private:
|
|||
bool m_bReleased;
|
||||
QPointF m_ptStartPos;
|
||||
QPointF m_ptStart;
|
||||
QPointF m_ptRotCenter;
|
||||
QSizeF m_szStart;
|
||||
double m_dRotation;
|
||||
double m_dAngle;
|
||||
|
|
|
@ -81,8 +81,7 @@ const QString VToolDetail::NodeSplinePath = QStringLiteral("NodeSplinePath");
|
|||
VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32 &id, const Source &typeCreation,
|
||||
VMainGraphicsScene *scene, const QString &drawName, QGraphicsItem *parent)
|
||||
:VAbstractTool(doc, data, id), VNoBrushScalePathItem(parent), dialog(nullptr), sceneDetails(scene),
|
||||
drawName(drawName), seamAllowance(new VNoBrushScalePathItem(this)),
|
||||
dataLabel(new VTextGraphicsItem(this)), patternInfo(new VTextGraphicsItem(this))
|
||||
drawName(drawName), seamAllowance(new VNoBrushScalePathItem(this))
|
||||
{
|
||||
VDetail detail = data->GetDetail(id);
|
||||
for (int i = 0; i< detail.CountNode(); ++i)
|
||||
|
@ -119,8 +118,6 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32
|
|||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);// For keyboard input focus
|
||||
|
||||
qDebug() << "VToolDetail" << patternInfo;
|
||||
|
||||
connect(scene, &VMainGraphicsScene::EnableToolMove, this, &VToolDetail::EnableToolMove);
|
||||
connect(scene, &VMainGraphicsScene::ItemClicked, this, &VToolDetail::ResetChildren);
|
||||
if (typeCreation == Source::FromGui || typeCreation == Source::FromTool)
|
||||
|
@ -133,11 +130,13 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32
|
|||
}
|
||||
setAcceptHoverEvents(true);
|
||||
|
||||
dataLabel = new VTextGraphicsItem(this);
|
||||
connect(dataLabel, &VTextGraphicsItem::SignalMoved, this, &VToolDetail::SaveMoveDetail);
|
||||
connect(dataLabel, &VTextGraphicsItem::SignalResized, this, &VToolDetail::SaveResizeDetail);
|
||||
connect(dataLabel, &VTextGraphicsItem::SignalRotated, this, &VToolDetail::SaveRotationDetail);
|
||||
connect(dataLabel, &VTextGraphicsItem::SignalShrink, this, &VToolDetail::UpdateAll);
|
||||
|
||||
patternInfo = new VTextGraphicsItem(this);
|
||||
connect(patternInfo, &VTextGraphicsItem::SignalMoved, this, &VToolDetail::SaveMovePattern);
|
||||
connect(patternInfo, &VTextGraphicsItem::SignalResized, this, &VToolDetail::SaveResizePattern);
|
||||
connect(patternInfo, &VTextGraphicsItem::SignalRotated, this, &VToolDetail::SaveRotationPattern);
|
||||
|
|
Loading…
Reference in New Issue
Block a user