forked from ZiQiangWang/ImagePorc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TransRotateZoom.cpp
131 lines (107 loc) · 3.42 KB
/
TransRotateZoom.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "TransRotateZoom.h"
#include "ui_TransRotateZoom.h"
#include "Types.h"
#include "Picture.h"
#include "Commands.h"
#include <QDebug>
TransRotateZoom::TransRotateZoom(Picture *pic, QWidget *parent) :
QDialog(parent),
ui(new Ui::TransRotateZoom)
{
ui->setupUi(this);
this->setAttribute(Qt::WA_DeleteOnClose);
this->move(20,100);
m_pic = pic;
rotate = new _RotateZoom(0,0,0,0,0,1.0);
connect(this,&TransRotateZoom::state_changed,pic,&Picture::RotateZoom);
connect(this,&TransRotateZoom::rejected,pic,&Picture::PopUpRecord);
connect(this,&TransRotateZoom::accepted,this,&TransRotateZoom::proc_accept);
pic->PushBackRecord();
}
TransRotateZoom::~TransRotateZoom()
{
delete ui;
}
void TransRotateZoom::proc_accept()
{
QUndoCommand *command = new CommandImage(m_pic,"变换-旋转-缩放-平移");
m_pic->getUndoStack()->push(command);
}
void TransRotateZoom::Transform()
{
}
void TransRotateZoom::on_horizontalSlider_rotate_valueChanged(int value)
{
rotate->angle = 0-value;
emit state_changed(rotate);
}
void TransRotateZoom::on_horizontalSlider_per_rotate_valueChanged(int value)
{
rotate->per_angle = value;
emit state_changed(rotate);
}
void TransRotateZoom::on_horizontalSlider_perspective_valueChanged(int value)
{
rotate->perspective = value;
emit state_changed(rotate);
}
void TransRotateZoom::on_horizontalSlider_offset_x_valueChanged(int value)
{
ui->doubleSpinBox_offset_x->setValue((double)value/100);
rotate->x = (double)value/100;
emit state_changed(rotate);
}
void TransRotateZoom::on_doubleSpinBox_offset_x_valueChanged(const QString &value)
{
QString temp = value;
int num = temp.remove(QChar('.'),Qt::CaseInsensitive).toInt();
ui->horizontalSlider_offset_x->setValue(num);
}
void TransRotateZoom::on_horizontalSlider_offset_y_valueChanged(int value)
{
ui->doubleSpinBox_offset_y->setValue((double)value/100);
rotate->y = (double)value/100;
emit state_changed(rotate);
}
void TransRotateZoom::on_doubleSpinBox_offset_y_valueChanged(const QString &value)
{
QString temp = value;
int num = temp.remove(QChar('.'),Qt::CaseInsensitive).toInt();
ui->horizontalSlider_offset_y->setValue(num);
}
void TransRotateZoom::on_horizontalSlider_zoom_valueChanged(int value)
{
ui->doubleSpinBox_zoom->setValue((double)value/100);
rotate->scale = (double)value/100;
emit state_changed(rotate);
}
void TransRotateZoom::on_doubleSpinBox_zoom_valueChanged(const QString &value)
{
QString temp = value;
int num = temp.remove(QChar('.'),Qt::CaseInsensitive).toInt();
ui->horizontalSlider_zoom->setValue(num);
}
void TransRotateZoom::on_pushButton_reset_rotate_clicked()
{
ui->horizontalSlider_rotate->setValue(0);
ui->horizontalSlider_per_rotate->setValue(0);
ui->horizontalSlider_perspective->setValue(0);
}
void TransRotateZoom::on_pushButton_reset_offset_clicked()
{
ui->horizontalSlider_offset_x->setValue(0);
ui->horizontalSlider_offset_y->setValue(0);
}
void TransRotateZoom::on_pushButton_reset_zoom_clicked()
{
ui->horizontalSlider_zoom->setValue(100);
}
void TransRotateZoom::on_pushButton_reset_clicked()
{
ui->horizontalSlider_rotate->setValue(0);
ui->horizontalSlider_per_rotate->setValue(0);
ui->horizontalSlider_perspective->setValue(0);
ui->horizontalSlider_offset_x->setValue(0);
ui->horizontalSlider_offset_y->setValue(0);
ui->horizontalSlider_zoom->setValue(100);
}