diff options
| author | Mikko Syrjä <mikko@3d-system.fi> | 2019-02-23 20:39:30 +0200 |
|---|---|---|
| committer | Mikko Syrjä <mikko@3d-system.fi> | 2019-02-23 20:39:30 +0200 |
| commit | 498b1b9a56b399225d3a70742fdcb01245aa91c4 (patch) | |
| tree | 2fd8596e3e049b46aad818cbe029a48c9df3e7e0 /symbol.cpp | |
| parent | 07599f27937b8af9a3d3a46f17e34b51d6eada2c (diff) | |
| download | symedit-498b1b9a56b399225d3a70742fdcb01245aa91c4.tar.gz symedit-498b1b9a56b399225d3a70742fdcb01245aa91c4.zip | |
Implement rotations.
Diffstat (limited to 'symbol.cpp')
| -rw-r--r-- | symbol.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -238,5 +238,20 @@ const SymEditSymbol::Item& SymEditSymbol::GetItem(int index) const */ void SymEditSymbol::RotateSymbol(int dir) { - //## + auto rotate = [](QPoint& point, int dir) + { + double length = sqrt(point.x() * point.x() + point.y() * point.y()); + double angle = atan2(point.y(), point.x()); + angle += (dir > 0 ? -M_PI / 2.0 : M_PI / 2.0); + double x = cos(angle) * length, y = sin(angle) * length; + point.setX(static_cast<int>(x + (x > 0.0 ? 0.5 : -0.5))); + point.setY(static_cast<int>(y + (y > 0.0 ? 0.5 : -0.5))); + }; + + for ( auto& item : Items ) + { + rotate(item.Point, dir); + if ( item.Operation != 'R' ) + rotate(item.Value, dir); + } } |
