Skip to content

Commit

Permalink
Merge pull request #397 from ra3xdh/203-rotate-symbol-bug
Browse files Browse the repository at this point in the history
Rewrite rotation of paintings
  • Loading branch information
ra3xdh authored Dec 11, 2023
2 parents bc69b2c + 3b31674 commit 28fe600
Show file tree
Hide file tree
Showing 19 changed files with 3,718 additions and 3,410 deletions.
3,040 changes: 1,556 additions & 1,484 deletions qucs/mouseactions.cpp

Large diffs are not rendered by default.

41 changes: 26 additions & 15 deletions qucs/paintings/arrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,22 +439,33 @@ void Arrow::Bounding(int& _x1, int& _y1, int& _x2, int& _y2)

// --------------------------------------------------------------------------
// Rotates around the center.
void Arrow::rotate()
void Arrow::rotate(int xc, int yc)
{
cx += (x2>>1) - (y2>>1);
cy += (x2>>1) + (y2>>1);

int tmp = x2;
x2 = y2;
y2 = -tmp;

tmp = xp1;
xp1 = yp1;
yp1 = -tmp;

tmp = xp2;
xp2 = yp2;
yp2 = -tmp;
int xr1 = cx - xc;
int yr1 = cy - yc;
int xr2 = cx + x2 - xc;
int yr2 = cy + y2 - yc;

int tmp = xr2;
xr2 = yr2;
yr2 = -tmp;

tmp = xr1;
xr1 = yr1;
yr1 = -tmp;

cx = xr1 + xc;
cy = yr1 + yc;
x2 = xr2 - xr1;
y2 = yr2 - yr1;

tmp = xp1;
xp1 = yp1;
yp1 = -tmp;

tmp = xp2;
xp2 = yp2;
yp2 = -tmp;
}

// --------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion qucs/paintings/arrow.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Arrow : public Painting {
bool resizeTouched(float, float, float);
void MouseResizeMoving(int, int, Schematic*);

void rotate();
void rotate(int, int);
void mirrorX();
void mirrorY();
bool Dialog();
Expand Down
24 changes: 18 additions & 6 deletions qucs/paintings/ellipse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,25 @@ bool qucs::Ellipse::getSelected(float fX, float fY, float w)

// --------------------------------------------------------------------------
// Rotates around the center.
void qucs::Ellipse::rotate()
void qucs::Ellipse::rotate(int xc, int yc)
{
cy += (y2-x2) >> 1;
cx += (x2-y2) >> 1;
int tmp = x2;
x2 = y2;
y2 = tmp;
int xr1 = cx - xc;
int yr1 = cy - yc;
int xr2 = cx + x2 - xc;
int yr2 = cy + y2 - yc;

int tmp = xr2;
xr2 = yr2;
yr2 = -tmp;

tmp = xr1;
xr1 = yr1;
yr1 = -tmp;

cx = xr1 + xc;
cy = yr1 + yc;
x2 = xr2 - xr1;
y2 = yr2 - yr1;
}

// --------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion qucs/paintings/ellipse.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class Ellipse : public Painting {
bool resizeTouched(float, float, float);
void MouseResizeMoving(int, int, Schematic*);

void rotate();
void rotate(int, int);
void mirrorX();
void mirrorY();
bool Dialog();
Expand Down
31 changes: 22 additions & 9 deletions qucs/paintings/ellipsearc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,16 +345,29 @@ bool EllipseArc::getSelected(float fX, float fY, float w)

// --------------------------------------------------------------------------
// Rotates around the center.
void EllipseArc::rotate()
// Rotates around the center.
void EllipseArc::rotate(int xc, int yc)
{
cy += (y2-x2) >> 1;
cx += (x2-y2) >> 1;
int tmp = x2;
x2 = y2;
y2 = tmp;

Angle += 16*90;
if(Angle >= 16*360) Angle -= 16*360;
int xr1 = cx - xc;
int yr1 = cy - yc;
int xr2 = cx + x2 - xc;
int yr2 = cy + y2 - yc;

int tmp = xr2;
xr2 = yr2;
yr2 = -tmp;

tmp = xr1;
xr1 = yr1;
yr1 = -tmp;

cx = xr1 + xc;
cy = yr1 + yc;
x2 = xr2 - xr1;
y2 = yr2 - yr1;

Angle += 16*90;
if(Angle >= 16*360) Angle -= 16*360;
}

// --------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion qucs/paintings/ellipsearc.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class EllipseArc : public Painting {
bool resizeTouched(float, float, float);
void MouseResizeMoving(int, int, Schematic*);

void rotate();
void rotate(int, int);
void mirrorX();
void mirrorY();
bool Dialog();
Expand Down
25 changes: 18 additions & 7 deletions qucs/paintings/graphicline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,25 @@ void GraphicLine::Bounding(int& _x1, int& _y1, int& _x2, int& _y2)

// --------------------------------------------------------------------------
// Rotates around the center.
void GraphicLine::rotate()
void GraphicLine::rotate(int xc, int yc)
{
cx += (x2>>1) - (y2>>1);
cy += (x2>>1) + (y2>>1);

int tmp = x2;
x2 = y2;
y2 = -tmp;
int xr1 = cx - xc;
int yr1 = cy - yc;
int xr2 = cx + x2 - xc;
int yr2 = cy + y2 - yc;

int tmp = xr2;
xr2 = yr2;
yr2 = -tmp;

tmp = xr1;
xr1 = yr1;
yr1 = -tmp;

cx = xr1 + xc;
cy = yr1 + yc;
x2 = xr2 - xr1;
y2 = yr2 - yr1;
}

// --------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion qucs/paintings/graphicline.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GraphicLine : public Painting {
bool resizeTouched(float, float, float);
void MouseResizeMoving(int, int, Schematic*);

void rotate();
void rotate(int, int);
void mirrorX();
void mirrorY();
bool Dialog();
Expand Down
Loading

0 comments on commit 28fe600

Please sign in to comment.