element-editor: add rotation with smaller increments for "line", "polygon", "text" and "dynamic_text" with shortcut <Ctrl>+<Space>

This commit is contained in:
plc-user
2025-02-16 16:31:18 +01:00
parent 3fc5469aee
commit 51225d5f59
4 changed files with 94 additions and 0 deletions

View File

@@ -607,6 +607,71 @@ void RotateElementsCommand::redo()
}
RotateFineElementsCommand::RotateFineElementsCommand(ElementScene *scene, QUndoCommand *parent) :
ElementEditionCommand(QObject::tr("Pivoter la selection", "undo caption"), scene, nullptr, parent)
{
m_items = scene->selectedItems();
}
/**
@brief RotateFineElementsCommand::undo
*/
void RotateFineElementsCommand::undo()
{
for (QGraphicsItem *item : m_items)
{
if (item->type() == PartLine::Type) {
PartLine* line = qgraphicsitem_cast<PartLine*>(item);
line->setRotation(-5);
}
else if (item->type() == PartPolygon::Type) {
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
poly->setRotation(-5);
}
else if (item->type() == PartText::Type) {
PartText* text = qgraphicsitem_cast<PartText*>(item);
text->setRotation(-5);
}
else if (item->type() == PartDynamicTextField::Type) {
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
dyntext->setRotation(-5);
}
else {
//item->setRotation(-5);
}
}
}
/**
@brief RotateFineElementsCommand::redo
*/
void RotateFineElementsCommand::redo()
{
for (QGraphicsItem *item : m_items)
{
if (item->type() == PartLine::Type) {
PartLine* line = qgraphicsitem_cast<PartLine*>(item);
line->setRotation(+5);
}
else if (item->type() == PartPolygon::Type) {
PartPolygon* poly = qgraphicsitem_cast<PartPolygon*>(item);
poly->setRotation(+5);
}
else if (item->type() == PartText::Type) {
PartText* text = qgraphicsitem_cast<PartText*>(item);
text->setRotation(+5);
}
else if (item->type() == PartDynamicTextField::Type) {
PartDynamicTextField* dyntext = qgraphicsitem_cast<PartDynamicTextField*>(item);
dyntext->setRotation(+5);
}
else {
//item->setRotation(+5);
}
}
}
MirrorElementsCommand::MirrorElementsCommand(ElementScene *scene, QUndoCommand *parent) :
ElementEditionCommand(QObject::tr("Miroir de sélection", "undo caption"), scene, nullptr, parent)
{