mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-20 03:16:10 +00:00
file for Apply Transform dialog (implementation and user interface)
This commit is contained in:
parent
8e0ce5ad84
commit
95aa28c429
338
src/meshlabplugins/meshfilter/transform.ui
Normal file
338
src/meshlabplugins/meshfilter/transform.ui
Normal file
@ -0,0 +1,338 @@
|
||||
<ui version="4.0" >
|
||||
<author></author>
|
||||
<comment></comment>
|
||||
<exportmacro></exportmacro>
|
||||
<class>TransformDialog</class>
|
||||
<widget class="QDialog" name="TransformDialog" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>549</width>
|
||||
<height>450</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="moveBox" >
|
||||
<property name="title" >
|
||||
<string>Move</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="yMoveLBL" >
|
||||
<property name="text" >
|
||||
<string>Y</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>yMoveLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="xMoveLBL" >
|
||||
<property name="text" >
|
||||
<string>X</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>xMoveLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="zMoveLBL" >
|
||||
<property name="text" >
|
||||
<string>Z</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>zMoveLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QLineEdit" name="zMoveLE" />
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="yMoveLE" />
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="xMoveLE" />
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="rotateBox" >
|
||||
<property name="title" >
|
||||
<string>Rotate</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="xAxisRB" >
|
||||
<property name="text" >
|
||||
<string>X</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="yAxisRB" >
|
||||
<property name="text" >
|
||||
<string>Y</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="zAxisRB" >
|
||||
<property name="text" >
|
||||
<string>Z</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDial" name="rotateDial" >
|
||||
<property name="maximum" >
|
||||
<number>359</number>
|
||||
</property>
|
||||
<property name="sliderPosition" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="wrapping" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="notchesVisible" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="rotateLE" >
|
||||
<property name="maxLength" >
|
||||
<number>359</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="scaleBox" >
|
||||
<property name="title" >
|
||||
<string>Scale</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="yScaleLE" />
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QLineEdit" name="zScaleLE" />
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="xScaleLBL" >
|
||||
<property name="text" >
|
||||
<string>X</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>xScaleLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="zScaleLBL" >
|
||||
<property name="text" >
|
||||
<string>Z</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>zScaleLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="xScaleLE" />
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="yScaleLBL" >
|
||||
<property name="text" >
|
||||
<string>Y</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>yScaleLE</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2" >
|
||||
<widget class="QCheckBox" name="uniformScaleCB" >
|
||||
<property name="text" >
|
||||
<string>Uniform</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="isMoveRB" >
|
||||
<property name="text" >
|
||||
<string>Move</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="isRotateRB" >
|
||||
<property name="text" >
|
||||
<string>Rotate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="isScaleRB" >
|
||||
<property name="text" >
|
||||
<string>Scale</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QCheckBox" name="previewCB" >
|
||||
<property name="text" >
|
||||
<string>Preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>131</width>
|
||||
<height>31</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="okButton" >
|
||||
<property name="text" >
|
||||
<string>OK</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancelButton" >
|
||||
<property name="text" >
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<tabstops>
|
||||
<tabstop>isMoveRB</tabstop>
|
||||
<tabstop>isRotateRB</tabstop>
|
||||
<tabstop>isScaleRB</tabstop>
|
||||
<tabstop>xAxisRB</tabstop>
|
||||
<tabstop>yAxisRB</tabstop>
|
||||
<tabstop>zAxisRB</tabstop>
|
||||
<tabstop>rotateDial</tabstop>
|
||||
<tabstop>rotateLE</tabstop>
|
||||
<tabstop>xScaleLE</tabstop>
|
||||
<tabstop>yScaleLE</tabstop>
|
||||
<tabstop>zScaleLE</tabstop>
|
||||
<tabstop>xMoveLE</tabstop>
|
||||
<tabstop>yMoveLE</tabstop>
|
||||
<tabstop>zMoveLE</tabstop>
|
||||
<tabstop>previewCB</tabstop>
|
||||
<tabstop>okButton</tabstop>
|
||||
<tabstop>cancelButton</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>cancelButton</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>TransformDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel" >
|
||||
<x>472</x>
|
||||
<y>415</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel" >
|
||||
<x>269</x>
|
||||
<y>404</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
245
src/meshlabplugins/meshfilter/transformdialog.h
Normal file
245
src/meshlabplugins/meshfilter/transformdialog.h
Normal file
@ -0,0 +1,245 @@
|
||||
#ifndef TRANSFORM_DIALOG_H
|
||||
#define TRANSFORM_DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QButtonGroup>
|
||||
#include <QDoubleValidator>
|
||||
#include "ui_transform.h"
|
||||
#include <vcg/math/matrix44.h>
|
||||
|
||||
using vcg::Matrix44f;
|
||||
|
||||
/*
|
||||
|
||||
$Log$
|
||||
Revision 1.1 2006/01/15 13:55:11 mariolatronico
|
||||
file for Apply Transform dialog (implementation and user interface)
|
||||
|
||||
|
||||
*/
|
||||
|
||||
class TransformDialog : public QDialog, Ui::TransformDialog {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public slots:
|
||||
|
||||
void selectTransform(QAbstractButton* button) {
|
||||
|
||||
if (button->text() == QString("Move") ) {
|
||||
|
||||
moveBox->setEnabled(true);
|
||||
rotateBox->setEnabled(false); resetRotate();
|
||||
scaleBox->setEnabled(false); resetScale();
|
||||
whichTransform = TR_MOVE;
|
||||
}
|
||||
|
||||
if (button->text() == QString("Rotate") ) {
|
||||
|
||||
moveBox->setEnabled(false); resetMove();
|
||||
rotateBox->setEnabled(true);
|
||||
scaleBox->setEnabled(false); resetScale();
|
||||
whichTransform = TR_ROTATE;
|
||||
|
||||
}
|
||||
|
||||
if (button->text() == QString("Scale") ) {
|
||||
|
||||
rotateBox->setEnabled(false); resetRotate();
|
||||
moveBox->setEnabled(false); resetMove();
|
||||
scaleBox->setEnabled(true); // Scale
|
||||
whichTransform = TR_SCALE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// decorator
|
||||
int exec() {
|
||||
|
||||
resetMove();
|
||||
resetRotate();
|
||||
resetScale();
|
||||
// default to Move transform
|
||||
isMoveRB->setChecked(true);
|
||||
selectTransform(isMoveRB);
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
void on_uniformScaleCB_stateChanged(int state) {
|
||||
if (state == Qt::Checked)
|
||||
uniformScale = true;
|
||||
else
|
||||
uniformScale = false;
|
||||
// in uniformScale is false we must enable Y and Z LineEdit
|
||||
yScaleLE->setEnabled( ! uniformScale );
|
||||
zScaleLE->setEnabled( ! uniformScale );
|
||||
}
|
||||
|
||||
void rotateAxisChange(QAbstractButton* axis) {
|
||||
|
||||
if (axis->text() == QString("X") )
|
||||
rotateAxis = AXIS_X;
|
||||
if (axis->text() == QString("Y") )
|
||||
rotateAxis = AXIS_Y;
|
||||
if (axis->text() == QString("Z") )
|
||||
rotateAxis = AXIS_Z;
|
||||
|
||||
|
||||
}
|
||||
void updateRotateLE(int value) {
|
||||
QString strValue;
|
||||
strValue.setNum(value);
|
||||
rotateLE->setText(strValue);
|
||||
}
|
||||
|
||||
void on_okButton_pressed() {
|
||||
|
||||
Matrix44f currentMatrix;
|
||||
currentMatrix.SetIdentity();
|
||||
float xVal, yVal, zVal;
|
||||
|
||||
if (whichTransform == TR_MOVE) {
|
||||
xVal = xMoveLE->text().toFloat();
|
||||
yVal = yMoveLE->text().toFloat();
|
||||
zVal = zMoveLE->text().toFloat();
|
||||
currentMatrix.SetTranslate(xVal, yVal, zVal);
|
||||
qDebug("xVal %f\t yVal %f\t zVal %f\t", xVal, yVal, zVal);
|
||||
}
|
||||
if (whichTransform == TR_ROTATE) {
|
||||
vcg::Point3f axisPoint;
|
||||
if ( rotateAxis == AXIS_X ) {
|
||||
axisPoint[0] = 1.0; axisPoint[1] = 0.0; axisPoint[2] = 0.0;
|
||||
}
|
||||
if ( rotateAxis == AXIS_Y ) {
|
||||
axisPoint[0] = 0.0; axisPoint[1] = 1.0; axisPoint[2] = 0.0;
|
||||
}
|
||||
if ( rotateAxis == AXIS_Z ) {
|
||||
axisPoint[0] = 0.0; axisPoint[1] = 0.0; axisPoint[2] = 1.0;
|
||||
}
|
||||
float rotateVal = rotateLE->text().toFloat();
|
||||
qDebug("Axis : %f\t %f\t %f\t", axisPoint[0], axisPoint[1], axisPoint[2]);
|
||||
qDebug("Value: %f", rotateVal);
|
||||
currentMatrix.SetRotate(rotateVal, axisPoint);
|
||||
|
||||
}
|
||||
if (whichTransform == TR_SCALE) {
|
||||
|
||||
xVal = xScaleLE->text().toFloat();
|
||||
|
||||
if ( ! uniformScale) {
|
||||
yVal = yScaleLE->text().toFloat();
|
||||
zVal = zScaleLE->text().toFloat();
|
||||
}
|
||||
else
|
||||
yVal = zVal = xVal;
|
||||
|
||||
currentMatrix.SetScale(xVal, yVal, zVal);
|
||||
qDebug("xVal %f\t yVal %f\t zVal %f\t", xVal, yVal, zVal);
|
||||
}
|
||||
|
||||
matrix = matrix * currentMatrix;
|
||||
|
||||
accept();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
TransformDialog() : QDialog()
|
||||
{
|
||||
setupUi(this);
|
||||
whichTransformBG = new QButtonGroup(this);
|
||||
rotateBG = new QButtonGroup(this);
|
||||
|
||||
|
||||
whichTransformBG->addButton(isMoveRB);
|
||||
whichTransformBG->addButton(isRotateRB);
|
||||
whichTransformBG->addButton(isScaleRB);
|
||||
|
||||
rotateBG->addButton(xAxisRB);
|
||||
rotateBG->addButton(yAxisRB);
|
||||
rotateBG->addButton(zAxisRB);
|
||||
|
||||
rotateLE->setInputMask("000.000");
|
||||
|
||||
rotateValidator = new QDoubleValidator(this);
|
||||
rotateValidator->setRange(0.0, 359.999, 3); // from 0 to 359.999 with 3 decimals
|
||||
rotateLE->setValidator(rotateValidator);
|
||||
|
||||
|
||||
connect(rotateDial,SIGNAL(valueChanged(int)),
|
||||
this, SLOT(updateRotateLE(int)));
|
||||
|
||||
connect(whichTransformBG,SIGNAL(buttonClicked(QAbstractButton* )),
|
||||
this, SLOT(selectTransform(QAbstractButton* )));
|
||||
connect(rotateBG, SIGNAL(buttonClicked(QAbstractButton* )),
|
||||
this, SLOT(rotateAxisChange(QAbstractButton* )));
|
||||
|
||||
connect(cancelButton, SIGNAL(clicked()),
|
||||
this, SLOT(reject()));
|
||||
|
||||
|
||||
rotateAxis = AXIS_X;
|
||||
matrix.SetIdentity();
|
||||
uniformScale = false;
|
||||
resetMove();
|
||||
resetScale();
|
||||
resetRotate();
|
||||
}
|
||||
|
||||
~TransformDialog() {
|
||||
delete whichTransformBG;
|
||||
delete rotateBG;
|
||||
delete rotateValidator;
|
||||
}
|
||||
|
||||
Matrix44f &getTransformation() {
|
||||
return matrix;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private: // members
|
||||
|
||||
QButtonGroup *whichTransformBG;
|
||||
QButtonGroup *rotateBG;
|
||||
QDoubleValidator *rotateValidator;
|
||||
enum AxisType {AXIS_X,AXIS_Y,AXIS_Z} rotateAxis;
|
||||
enum TransformType { TR_MOVE, TR_ROTATE, TR_SCALE } whichTransform;
|
||||
Matrix44f matrix;
|
||||
bool uniformScale; // same scale for X,Y,Z
|
||||
private: // functions
|
||||
|
||||
void resetMove() {
|
||||
|
||||
xMoveLE->setText("0.0");
|
||||
yMoveLE->setText("0.0");
|
||||
zMoveLE->setText("0.0");
|
||||
|
||||
}
|
||||
|
||||
void resetRotate() {
|
||||
rotateDial->setValue(0);
|
||||
xAxisRB->setChecked(true);
|
||||
}
|
||||
|
||||
void resetScale() {
|
||||
|
||||
xScaleLE->setText("1.0");
|
||||
yScaleLE->setText("1.0");
|
||||
zScaleLE->setText("1.0");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // TRANSFORM_DIALOG_H
|
||||
Loading…
x
Reference in New Issue
Block a user