Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite rotation of paintings #397

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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