Better piece flipping.
This commit is contained in:
parent
d32bbfcfd4
commit
54710608d6
|
@ -243,3 +243,19 @@ void VPPiece::SetPatternLabelData(const VTextManager &data)
|
||||||
{
|
{
|
||||||
VLayoutPiece::SetPatternLabelData(data);
|
VLayoutPiece::SetPatternLabelData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VPPiece::Flip()
|
||||||
|
{
|
||||||
|
QTransform pieceMatrix = GetMatrix();
|
||||||
|
QPointF center = pieceMatrix.map(DetailBoundingRect().center());
|
||||||
|
|
||||||
|
QTransform m;
|
||||||
|
m.translate(center.x(), 0);
|
||||||
|
m.scale(-1, 1);
|
||||||
|
m.translate(-center.x(), 0);
|
||||||
|
|
||||||
|
pieceMatrix *= m;
|
||||||
|
SetMatrix(pieceMatrix);
|
||||||
|
SetMirror(!IsMirror());
|
||||||
|
}
|
||||||
|
|
|
@ -101,6 +101,11 @@ public:
|
||||||
auto GetPatternLabelData() const ->VTextManager;
|
auto GetPatternLabelData() const ->VTextManager;
|
||||||
void SetPatternLabelData(const VTextManager &data);
|
void SetPatternLabelData(const VTextManager &data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Flip horizontally mirror around center of bounding rect
|
||||||
|
*/
|
||||||
|
void Flip();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VPPiece)
|
Q_DISABLE_COPY(VPPiece)
|
||||||
|
|
||||||
|
|
|
@ -570,11 +570,14 @@ void VPMainWindow::InitPropertyTabCurrentPiece()
|
||||||
VPPiecePtr selectedPiece = selectedPieces.first();
|
VPPiecePtr selectedPiece = selectedPieces.first();
|
||||||
if (not selectedPiece.isNull())
|
if (not selectedPiece.isNull())
|
||||||
{
|
{
|
||||||
selectedPiece->SetMirror(checked);
|
if (selectedPiece->IsMirror() != checked)
|
||||||
|
{
|
||||||
|
selectedPiece->Flip();
|
||||||
LayoutWasSaved(false);
|
LayoutWasSaved(false);
|
||||||
emit m_layout->PieceTransformationChanged(selectedPiece);
|
emit m_layout->PieceTransformationChanged(selectedPiece);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Translate
|
// Translate
|
||||||
|
|
Loading…
Reference in New Issue
Block a user