Gui: in placement dialog use spin boxes for rotation axis
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#ifndef _PreComp_
|
||||
#include <QClipboard>
|
||||
#include <QDockWidget>
|
||||
#include <QKeyEvent>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaObject>
|
||||
#include <QSignalMapper>
|
||||
@@ -85,13 +86,14 @@ public:
|
||||
/* TRANSLATOR Gui::Dialog::Placement */
|
||||
|
||||
Placement::Placement(QWidget* parent, Qt::WindowFlags fl)
|
||||
: Gui::LocationDialog(parent, fl)
|
||||
: QDialog(parent, fl)
|
||||
, changeProperty(false)
|
||||
{
|
||||
selectionObjects = Gui::Selection().getSelectionEx();
|
||||
|
||||
propertyName = "Placement"; // default name
|
||||
ui = new Ui_PlacementComp(this);
|
||||
ui = new Ui_Placement();
|
||||
ui->setupUi(this);
|
||||
ui->gridLayout->removeItem(ui->vSpacer);
|
||||
|
||||
ui->xPos->setUnit(Base::Unit::Length);
|
||||
@@ -108,7 +110,6 @@ Placement::Placement(QWidget* parent, Qt::WindowFlags fl)
|
||||
|
||||
// create a signal mapper in order to have one slot to perform the change
|
||||
signalMapper = new QSignalMapper(this);
|
||||
connect(this, SIGNAL(directionChanged()), signalMapper, SLOT(map()));
|
||||
signalMapper->setMapping(this, 0);
|
||||
|
||||
int id = 1;
|
||||
@@ -649,22 +650,23 @@ void Placement::bindObject()
|
||||
ui->yPos->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Base.y")));
|
||||
ui->zPos->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Base.z")));
|
||||
|
||||
ui->xAxis->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Axis.x")));
|
||||
ui->yAxis->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Axis.y")));
|
||||
ui->zAxis->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Axis.z")));
|
||||
ui->angle->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Angle")));
|
||||
|
||||
ui->yawAngle ->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Yaw")));
|
||||
ui->pitchAngle->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Pitch")));
|
||||
ui->rollAngle ->bind(App::ObjectIdentifier::parse(obj, propertyName + std::string(".Rotation.Roll")));
|
||||
}
|
||||
}
|
||||
|
||||
void Placement::directionActivated(int index)
|
||||
{
|
||||
if (ui->directionActivated(this, index)) {
|
||||
Q_EMIT directionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Base::Vector3d Placement::getDirection() const
|
||||
{
|
||||
return ui->getDirection();
|
||||
double x = ui->xAxis->value().getValue();
|
||||
double y = ui->yAxis->value().getValue();
|
||||
double z = ui->zAxis->value().getValue();
|
||||
return Base::Vector3d(x, y, z);
|
||||
}
|
||||
|
||||
void Placement::setPlacement(const Base::Placement& p)
|
||||
@@ -685,35 +687,14 @@ void Placement::setPlacementData(const Base::Placement& p)
|
||||
ui->pitchAngle->setValue(Base::Quantity(P, Base::Unit::Angle));
|
||||
ui->rollAngle->setValue(Base::Quantity(R, Base::Unit::Angle));
|
||||
|
||||
// check if the user-defined direction is already there
|
||||
bool newitem = true;
|
||||
double angle;
|
||||
Base::Vector3d axis;
|
||||
p.getRotation().getValue(axis, angle);
|
||||
p.getRotation().getRawValue(axis, angle);
|
||||
ui->xAxis->setValue(axis.x);
|
||||
ui->yAxis->setValue(axis.y);
|
||||
ui->zAxis->setValue(axis.z);
|
||||
ui->angle->setValue(Base::Quantity(angle*180.0/D_PI, Base::Unit::Angle));
|
||||
Base::Vector3d dir(axis.x,axis.y,axis.z);
|
||||
for (int i=0; i<ui->direction->count()-1; i++) {
|
||||
QVariant data = ui->direction->itemData (i);
|
||||
if (data.canConvert<Base::Vector3d>()) {
|
||||
const Base::Vector3d val = data.value<Base::Vector3d>();
|
||||
if (val == dir) {
|
||||
ui->direction->setCurrentIndex(i);
|
||||
newitem = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newitem) {
|
||||
// add a new item before the very last item
|
||||
QString display = QString::fromLatin1("(%1,%2,%3)")
|
||||
.arg(dir.x)
|
||||
.arg(dir.y)
|
||||
.arg(dir.z);
|
||||
ui->direction->insertItem(ui->direction->count()-1, display,
|
||||
QVariant::fromValue<Base::Vector3d>(dir));
|
||||
ui->direction->setCurrentIndex(ui->direction->count()-2);
|
||||
}
|
||||
signalMapper->blockSignals(false);
|
||||
}
|
||||
|
||||
@@ -798,7 +779,7 @@ QString Placement::getPlacementString() const
|
||||
void Placement::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslate(this);
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
else {
|
||||
QDialog::changeEvent(e);
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
#ifndef GUI_PLACEMENT_H
|
||||
#define GUI_PLACEMENT_H
|
||||
|
||||
#include <Gui/InputVector.h>
|
||||
#include <QDialog>
|
||||
#include <Base/Placement.h>
|
||||
#include <Gui/SelectionObject.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
@@ -38,7 +39,7 @@ namespace Dialog {
|
||||
|
||||
class Ui_Placement;
|
||||
class TaskPlacement;
|
||||
class GuiExport Placement : public Gui::LocationDialog
|
||||
class GuiExport Placement : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
void reject() override;
|
||||
|
||||
void bindObject();
|
||||
Base::Vector3d getDirection() const override;
|
||||
Base::Vector3d getDirection() const;
|
||||
void setPlacement(const Base::Placement&);
|
||||
Base::Placement getPlacement() const;
|
||||
void showDefaultButtons(bool);
|
||||
@@ -75,7 +76,6 @@ private:
|
||||
Base::Placement getPlacementData() const;
|
||||
Base::Vector3d getCenterData() const;
|
||||
QString getPlacementString() const;
|
||||
void directionActivated(int) override;
|
||||
void applyPlacement(const Base::Placement& p, bool incremental);
|
||||
void applyPlacement(const QString& p, bool incremental);
|
||||
void revertTransformation();
|
||||
@@ -84,12 +84,10 @@ private:
|
||||
|
||||
Q_SIGNALS:
|
||||
void placementChanged(const QVariant &, bool, bool);
|
||||
void directionChanged();
|
||||
|
||||
private:
|
||||
using Ui_PlacementComp = Gui::LocationUi<Ui_Placement>;
|
||||
using Connection = boost::signals2::connection;
|
||||
Ui_PlacementComp* ui;
|
||||
Ui_Placement* ui;
|
||||
QSignalMapper* signalMapper;
|
||||
Connection connectAct;
|
||||
Base::Placement ref;
|
||||
|
||||
@@ -292,13 +292,15 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="direction">
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Gui::QuantitySpinBox" name="xAxis"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="yAxis"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="zAxis"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="textLabelAngle">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
@@ -311,7 +313,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="angle"/>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -525,7 +527,9 @@
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>rotationInput</tabstop>
|
||||
<tabstop>direction</tabstop>
|
||||
<tabstop>xAxis</tabstop>
|
||||
<tabstop>yAxis</tabstop>
|
||||
<tabstop>zAxis</tabstop>
|
||||
<tabstop>applyIncrementalPlacement</tabstop>
|
||||
<tabstop>oKButton</tabstop>
|
||||
<tabstop>applyButton</tabstop>
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QKeyEvent>
|
||||
#include <QSignalMapper>
|
||||
|
||||
#include <App/GeoFeature.h>
|
||||
@@ -280,9 +281,10 @@ void DefaultTransformStrategy::onSelectionChanged(const Gui::SelectionChanges& m
|
||||
/* TRANSLATOR Gui::Dialog::Transform */
|
||||
|
||||
Transform::Transform(QWidget* parent, Qt::WindowFlags fl)
|
||||
: Gui::LocationDialog(parent, fl), strategy(nullptr)
|
||||
: QDialog(parent, fl), strategy(nullptr)
|
||||
{
|
||||
ui = new Ui_TransformComp(this);
|
||||
ui = new Ui_Placement();
|
||||
ui->setupUi(this);
|
||||
ui->resetButton->hide();
|
||||
ui->applyIncrementalPlacement->hide();
|
||||
|
||||
@@ -291,7 +293,6 @@ Transform::Transform(QWidget* parent, Qt::WindowFlags fl)
|
||||
|
||||
// create a signal mapper in order to have one slot to perform the change
|
||||
auto signalMapper = new QSignalMapper(this);
|
||||
connect(this, SIGNAL(directionChanged()), signalMapper, SLOT(map()));
|
||||
signalMapper->setMapping(this, 0);
|
||||
|
||||
int id = 1;
|
||||
@@ -373,16 +374,12 @@ void Transform::on_applyButton_clicked()
|
||||
ui->zCnt->setValue(Base::Quantity(cnt.z, Base::Unit::Length));
|
||||
}
|
||||
|
||||
void Transform::directionActivated(int index)
|
||||
{
|
||||
if (ui->directionActivated(this, index)) {
|
||||
Q_EMIT directionChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Base::Vector3d Transform::getDirection() const
|
||||
{
|
||||
return ui->getDirection();
|
||||
double x = ui->xAxis->value().getValue();
|
||||
double y = ui->yAxis->value().getValue();
|
||||
double z = ui->zAxis->value().getValue();
|
||||
return Base::Vector3d(x, y, z);
|
||||
}
|
||||
|
||||
Base::Placement Transform::getPlacementData() const
|
||||
@@ -413,7 +410,7 @@ Base::Placement Transform::getPlacementData() const
|
||||
void Transform::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslate(this);
|
||||
ui->retranslateUi(this);
|
||||
ui->closeButton->setText(tr("Cancel"));
|
||||
this->setWindowTitle(tr("Transform"));
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
#ifndef GUI_TRANSFORM_H
|
||||
#define GUI_TRANSFORM_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <set>
|
||||
#include <Base/Placement.h>
|
||||
|
||||
#include "InputVector.h"
|
||||
#include "Selection.h"
|
||||
#include "TaskView/TaskDialog.h"
|
||||
#include "TaskView/TaskView.h"
|
||||
@@ -68,7 +68,7 @@ private:
|
||||
};
|
||||
|
||||
class Ui_Placement;
|
||||
class GuiExport Transform : public Gui::LocationDialog
|
||||
class GuiExport Transform : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
void setTransformStrategy(TransformStrategy* ts);
|
||||
|
||||
protected:
|
||||
Base::Vector3d getDirection() const override;
|
||||
Base::Vector3d getDirection() const;
|
||||
void changeEvent(QEvent *e) override;
|
||||
|
||||
public Q_SLOTS:
|
||||
@@ -92,14 +92,9 @@ private Q_SLOTS:
|
||||
|
||||
private:
|
||||
Base::Placement getPlacementData() const;
|
||||
void directionActivated(int) override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void directionChanged();
|
||||
|
||||
private:
|
||||
using Ui_TransformComp = Gui::LocationUi<Ui_Placement>;
|
||||
Ui_TransformComp* ui;
|
||||
Ui_Placement* ui;
|
||||
Base::Placement pm;
|
||||
std::set<App::DocumentObject*> selection;
|
||||
TransformStrategy* strategy;
|
||||
|
||||
Reference in New Issue
Block a user