mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-13 10:04:13 +02:00
Add "rotate group" to actually rotate a selection as a whole
RotateSelectionCommand's existing "Pivoter" action (Space) only ever
bumps each selected item's own rotation property -- QGraphicsItem's
setRotation() spins an item around its own local origin and never
touches pos(). Select three elements arranged in a row and rotate:
each spins 90 degrees individually, but the row stays a row. That's
"rotate each item," not "rotate the group."
Add a rotate_as_group parameter to RotateSelectionCommand (default
false, so the existing action and its one call site are unchanged).
When set, it computes a shared pivot once -- the bounding-box center
of the whole selection -- and queues a second, parallel "pos"
QPropertyUndoCommand alongside the existing "rotation" one, rotating
each item's position around that pivot by the same angle.
Scoped the position change to Element/IndependentTextItem/
DiagramImageItem only: these are the only selectable types with
scene-space pos(). ConductorTextItem, DynamicElementTextItem and
ElementTextItemGroup are all parent-relative children (confirmed by
reading their constructors), so when their owning Element is also
selected and gets its own pos() rotated, they're carried along for
free by Qt's normal parent/child transform propagation -- exactly
what the existing "skip rotation if parent is also selected" guard
already assumes for those three cases.
Exposed as a new, separate action ("Pivoter le groupe", Shift+Space)
next to the existing one rather than changing Space's behavior, since
some workflows may rely on the current per-item rotation.
This commit is contained in:
@@ -21,10 +21,12 @@
|
||||
#include <QUndoCommand>
|
||||
#include <QPointer>
|
||||
#include <QHash>
|
||||
#include <QPointF>
|
||||
|
||||
class Diagram;
|
||||
class ConductorTextItem;
|
||||
class QPropertyUndoCommand;
|
||||
class QGraphicsItem;
|
||||
|
||||
/**
|
||||
@brief The RotateSelectionCommand class
|
||||
@@ -33,13 +35,15 @@ class QPropertyUndoCommand;
|
||||
class RotateSelectionCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
RotateSelectionCommand(Diagram *diagram, qreal angle=90, QUndoCommand *parent=nullptr);
|
||||
RotateSelectionCommand(Diagram *diagram, qreal angle=90, QUndoCommand *parent=nullptr, bool rotate_as_group=false);
|
||||
void undo() override;
|
||||
void redo() override;
|
||||
|
||||
bool isValid();
|
||||
|
||||
private:
|
||||
void addGroupPositionUndo(QGraphicsItem *item, const QPointF &pivot, qreal angle);
|
||||
|
||||
Diagram *m_diagram =nullptr;
|
||||
|
||||
QList<QPointer<ConductorTextItem>> m_cond_text;
|
||||
|
||||
Reference in New Issue
Block a user