1 /* ***** BEGIN LICENSE BLOCK *****
7 * Copyright (c) 2008 BBC Research
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 * ***** END LICENSE BLOCK ***** */
31 #include "transformDialog.h"
33 TransformDialog::TransformDialog(const QString
&name
, QWidget
*parent
) :
39 zoomLabel
= new QLabel(tr("Zoom"));
41 zoomReset
= new QPushButton();
42 zoomReset
->setText(tr("Reset"));
43 connect(zoomReset
, SIGNAL(clicked()), this, SLOT(resetZoom()));
45 zoomNumber
= new QDoubleSpinBox
;
46 zoomNumber
->setMinimum(0.1);
47 zoomNumber
->setMaximum(32);
48 zoomNumber
->setSingleStep(0.1);
49 connect(zoomNumber
, SIGNAL(valueChanged(double)), this, SLOT(zoomNumberChanged(double)));
51 zoomSlider
= new QSlider
;
52 zoomSlider
->setOrientation(Qt::Horizontal
);
53 zoomSlider
->setMinimum(1);
54 zoomSlider
->setMaximum(320);
55 zoomSlider
->setValue(100);
56 connect(zoomSlider
, SIGNAL(valueChanged(int)), this, SLOT(zoomSliderChanged(int)));
59 rotationLabel
= new QLabel(tr("Rotation"));
61 rotationReset
= new QPushButton
;
62 rotationReset
->setText(tr("Reset"));
63 connect(rotationReset
, SIGNAL(clicked()), this, SLOT(resetRotation()));
65 rotationNumber
= new QSpinBox
;
66 rotationNumber
->setMinimum(-360);
67 rotationNumber
->setMaximum(360);
68 rotationNumber
->setValue(0);
69 connect(rotationNumber
, SIGNAL(valueChanged(int)), this, SLOT(rotationValueChanged(int)));
71 rotationSlider
= new QSlider
;
72 rotationSlider
->setOrientation(Qt::Horizontal
);
73 rotationSlider
->setMinimum(-360);
74 rotationSlider
->setMaximum(360);
75 rotationSlider
->setValue(0);
76 connect(rotationSlider
, SIGNAL(valueChanged(int)), this, SLOT(rotationValueChanged(int)));
79 QGridLayout
*layout
= new QGridLayout
;
80 layout
->addWidget(zoomLabel
, 0, 0);
81 layout
->addWidget(zoomReset
, 0, 1);
82 layout
->addWidget(zoomNumber
, 0, 2);
83 layout
->addWidget(zoomSlider
, 0, 3);
85 layout
->addWidget(rotationLabel
, 1, 0);
86 layout
->addWidget(rotationReset
, 1, 1);
87 layout
->addWidget(rotationNumber
, 1, 2);
88 layout
->addWidget(rotationSlider
, 1, 3);
93 //----------------------------------------------------------------------------------
95 void TransformDialog::resetZoom(void)
98 zoomNumber
->setValue(1.0);
99 zoomSlider
->setValue(10);
101 if (zoomRatio
!= 1.0) {
103 emit(zoomChanged(zoomRatio
));
107 //a number is entered into the zoom box
108 void TransformDialog::zoomNumberChanged(double value
)
111 zoomSlider
->setValue((int)(value
* 10));
113 if (zoomRatio
!= value
) {
114 emit(zoomChanged(value
));
119 //the zoom slider is moved
120 void TransformDialog::zoomSliderChanged(int value
)
123 float ratio
= (float)value
/ 10.0;
124 zoomNumber
->setValue(ratio
);
126 if (zoomRatio
!= ratio
) {
127 emit(zoomChanged(ratio
));
132 //----------------------------------------------------------------------------------
134 void TransformDialog::resetRotation(void)
137 rotationNumber
->setValue(0);
138 rotationSlider
->setValue(0);
142 emit(rotationChanged(rotation
));
146 //a number is entered into the zoom box, or the slider moved
147 //these can be handles by the same function as they are both integers
148 void TransformDialog::rotationValueChanged(int value
)
151 rotationSlider
->setValue(value
);
152 rotationNumber
->setValue(value
);
154 if (rotation
!= value
) {
155 emit(rotationChanged(value
));
160 //----------------------------------------------------------------------------------
162 void TransformDialog::setZoom(float value
)
166 zoomNumber
->setValue(zoomRatio
);
167 zoomSlider
->setValue((int)(zoomRatio
* 10));
170 void TransformDialog::setRotation(int value
)
174 rotationSlider
->setValue(value
);
175 rotationNumber
->setValue(value
);