port the placement dialog to the inputfield
This commit is contained in:
parent
9f7c784437
commit
8ff14c8fdb
|
@ -160,6 +160,7 @@ void InputField::newInput(const QString & text)
|
|||
QPixmap pixmap = BitmapFactory().pixmapFromSvg(":/icons/button_invalid.svg", QSize(sizeHint().height(),sizeHint().height()));
|
||||
iconLabel->setPixmap(pixmap);
|
||||
parseError(QString::fromAscii(ErrorText.c_str()));
|
||||
validInput = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -169,6 +170,7 @@ void InputField::newInput(const QString & text)
|
|||
QPixmap pixmap = BitmapFactory().pixmapFromSvg(":/icons/button_invalid.svg", QSize(sizeHint().height(),sizeHint().height()));
|
||||
iconLabel->setPixmap(pixmap);
|
||||
parseError(QString::fromAscii("Wrong unit"));
|
||||
validInput = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -176,6 +178,7 @@ void InputField::newInput(const QString & text)
|
|||
QPixmap pixmap = BitmapFactory().pixmapFromSvg(":/icons/button_valid.svg", QSize(sizeHint().height(),sizeHint().height()));
|
||||
iconLabel->setPixmap(pixmap);
|
||||
ErrorText = "";
|
||||
validInput = true;
|
||||
|
||||
if (res.getValue() > Maximum){
|
||||
res.setValue(Maximum);
|
||||
|
@ -325,13 +328,25 @@ void InputField::setValue(const Base::Quantity& quant)
|
|||
double dFactor;
|
||||
setText(quant.getUserString(dFactor,actUnitStr));
|
||||
actUnitValue = quant.getValue()/dFactor;
|
||||
validInput = true;
|
||||
}
|
||||
|
||||
void InputField::setValue(const double& value)
|
||||
{
|
||||
setValue(Base::Quantity(value, actUnit));
|
||||
}
|
||||
|
||||
|
||||
void InputField::setUnit(const Base::Unit& unit)
|
||||
{
|
||||
actUnit = unit;
|
||||
}
|
||||
|
||||
Base::Unit InputField::getUnit()
|
||||
{
|
||||
return actUnit;
|
||||
}
|
||||
|
||||
/// get the value of the singleStep property
|
||||
double InputField::singleStep(void)const
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2013 Juergen Riegel *
|
||||
* Copyright (c) 2013 Juergen Riegel *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
|
@ -65,8 +65,17 @@ public:
|
|||
|
||||
/// set the field with a quantity
|
||||
void setValue(const Base::Quantity&);
|
||||
//set a numerical value which gets converted to a quantity with the currently set unit type
|
||||
void setValue(const double&);
|
||||
|
||||
/// get the current value
|
||||
Base::Quantity getQuantity(void)const{return this->actQuantity;}
|
||||
|
||||
/// gives the current state of the user input, gives true if it is a valid input with correct quantity
|
||||
/// (shown by the green pixmap), returns false if the input is a unparsable string or has a wrong unit
|
||||
/// (shown by the red pixmap in the gui)
|
||||
bool hasValidInput() { return validInput;};
|
||||
|
||||
/** sets the Unit this field is working with.
|
||||
* After setting the Unit the field will only accept
|
||||
* user input with this unit type. Or if the user input
|
||||
|
@ -74,6 +83,7 @@ public:
|
|||
* Quantity.
|
||||
*/
|
||||
void setUnit(const Base::Unit&);
|
||||
Base::Unit getUnit();
|
||||
|
||||
/// set the input field to the last used value (works only if the setParamGrpPath() was called)
|
||||
void setToLastUsedValue(void);
|
||||
|
@ -153,6 +163,7 @@ private:
|
|||
QLabel* iconLabel;
|
||||
QByteArray m_sPrefGrp;
|
||||
std::string ErrorText;
|
||||
bool validInput;
|
||||
|
||||
/// handle to the parameter group for defaults and history
|
||||
ParameterGrp::handle _handle;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "PreCompiled.h"
|
||||
#include <QSignalMapper>
|
||||
#include <QDockWidget>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "Placement.h"
|
||||
#include "ui_Placement.h"
|
||||
|
@ -81,22 +82,17 @@ Placement::Placement(QWidget* parent, Qt::WFlags fl)
|
|||
propertyName = "Placement"; // default name
|
||||
ui = new Ui_PlacementComp(this);
|
||||
ui->applyPlacementChange->hide();
|
||||
|
||||
ui->xPos->setDecimals(Base::UnitsApi::getDecimals());
|
||||
ui->yPos->setDecimals(Base::UnitsApi::getDecimals());
|
||||
ui->zPos->setDecimals(Base::UnitsApi::getDecimals());
|
||||
ui->xCnt->setDecimals(Base::UnitsApi::getDecimals());
|
||||
ui->yCnt->setDecimals(Base::UnitsApi::getDecimals());
|
||||
ui->zCnt->setDecimals(Base::UnitsApi::getDecimals());
|
||||
ui->yawAngle->setDecimals(Base::UnitsApi::getDecimals());
|
||||
ui->pitchAngle->setDecimals(Base::UnitsApi::getDecimals());
|
||||
ui->rollAngle->setDecimals(Base::UnitsApi::getDecimals());
|
||||
ui->angle->setDecimals(Base::UnitsApi::getDecimals());
|
||||
|
||||
ui->angle->setSuffix(QString::fromUtf8(" \xc2\xb0"));
|
||||
ui->yawAngle->setSuffix(QString::fromUtf8(" \xc2\xb0"));
|
||||
ui->pitchAngle->setSuffix(QString::fromUtf8(" \xc2\xb0"));
|
||||
ui->rollAngle->setSuffix(QString::fromUtf8(" \xc2\xb0"));
|
||||
|
||||
ui->xPos->setUnit(Base::Unit::Length);
|
||||
ui->yPos->setUnit(Base::Unit::Length);
|
||||
ui->zPos->setUnit(Base::Unit::Length);
|
||||
ui->xCnt->setValue(Base::Quantity(0, Base::Unit::Length));
|
||||
ui->yCnt->setValue(Base::Quantity(0, Base::Unit::Length));
|
||||
ui->zCnt->setValue(Base::Quantity(0, Base::Unit::Length));
|
||||
ui->angle->setUnit(Base::Unit::Angle);
|
||||
ui->yawAngle->setUnit(Base::Unit::Angle);
|
||||
ui->pitchAngle->setUnit(Base::Unit::Angle);
|
||||
ui->rollAngle->setUnit(Base::Unit::Angle);
|
||||
|
||||
// create a signal mapper in order to have one slot to perform the change
|
||||
signalMapper = new QSignalMapper(this);
|
||||
|
@ -136,6 +132,17 @@ void Placement::slotActiveDocument(const Gui::Document& doc)
|
|||
documents.insert(doc.getDocument()->getName());
|
||||
}
|
||||
|
||||
bool Placement::hasValidInputs()
|
||||
{
|
||||
QList<Gui::InputField*> sb = this->findChildren<Gui::InputField*>();
|
||||
for (QList<Gui::InputField*>::iterator it = sb.begin(); it != sb.end(); ++it) {
|
||||
if(!(*it)->hasValidInput())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Placement::revertTransformation()
|
||||
{
|
||||
for (std::set<std::string>::iterator it = documents.begin(); it != documents.end(); ++it) {
|
||||
|
@ -290,6 +297,15 @@ void Placement::accept()
|
|||
|
||||
void Placement::on_applyButton_clicked()
|
||||
{
|
||||
//only process things when we have valid inputs!
|
||||
if(!hasValidInputs()) {
|
||||
QMessageBox msg;
|
||||
msg.setIcon(QMessageBox::Critical);
|
||||
msg.setText(QString::fromAscii("There are input fields with incorrect input, please ensure valid placement values!"));
|
||||
msg.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
// If there are listeners to the 'placementChanged' signal we rely
|
||||
// on that the listener updates any placement. If no listeners
|
||||
// are connected the placement is applied to all selected objects
|
||||
|
@ -302,10 +318,10 @@ void Placement::on_applyButton_clicked()
|
|||
/*emit*/ placementChanged(data, incr, true);
|
||||
|
||||
if (ui->applyIncrementalPlacement->isChecked()) {
|
||||
QList<QDoubleSpinBox*> sb = this->findChildren<QDoubleSpinBox*>();
|
||||
for (QList<QDoubleSpinBox*>::iterator it = sb.begin(); it != sb.end(); ++it) {
|
||||
QList<Gui::InputField*> sb = this->findChildren<Gui::InputField*>();
|
||||
for (QList<Gui::InputField*>::iterator it = sb.begin(); it != sb.end(); ++it) {
|
||||
(*it)->blockSignals(true);
|
||||
(*it)->setValue(0.0);
|
||||
(*it)->setValue(0);
|
||||
(*it)->blockSignals(false);
|
||||
}
|
||||
}
|
||||
|
@ -313,10 +329,10 @@ void Placement::on_applyButton_clicked()
|
|||
|
||||
void Placement::on_resetButton_clicked()
|
||||
{
|
||||
QList<QDoubleSpinBox*> sb = this->findChildren<QDoubleSpinBox*>();
|
||||
for (QList<QDoubleSpinBox*>::iterator it = sb.begin(); it != sb.end(); ++it) {
|
||||
QList<Gui::InputField*> sb = this->findChildren<Gui::InputField*>();
|
||||
for (QList<Gui::InputField*>::iterator it = sb.begin(); it != sb.end(); ++it) {
|
||||
(*it)->blockSignals(true);
|
||||
(*it)->setValue(0.0);
|
||||
(*it)->setValue(0);
|
||||
(*it)->blockSignals(false);
|
||||
}
|
||||
|
||||
|
@ -343,22 +359,22 @@ void Placement::setPlacement(const Base::Placement& p)
|
|||
void Placement::setPlacementData(const Base::Placement& p)
|
||||
{
|
||||
signalMapper->blockSignals(true);
|
||||
ui->xPos->setValue(p.getPosition().x);
|
||||
ui->yPos->setValue(p.getPosition().y);
|
||||
ui->zPos->setValue(p.getPosition().z);
|
||||
ui->xPos->setValue(Base::Quantity(p.getPosition().x, Base::Unit::Length));
|
||||
ui->yPos->setValue(Base::Quantity(p.getPosition().y, Base::Unit::Length));
|
||||
ui->zPos->setValue(Base::Quantity(p.getPosition().z, Base::Unit::Length));
|
||||
|
||||
double Y,P,R;
|
||||
p.getRotation().getYawPitchRoll(Y,P,R);
|
||||
ui->yawAngle->setValue(Y);
|
||||
ui->pitchAngle->setValue(P);
|
||||
ui->rollAngle->setValue(R);
|
||||
ui->yawAngle->setValue(Base::Quantity(Y, Base::Unit::Angle));
|
||||
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);
|
||||
ui->angle->setValue(angle*180.0/D_PI);
|
||||
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);
|
||||
|
@ -398,18 +414,18 @@ Base::Placement Placement::getPlacementData() const
|
|||
Base::Vector3d pos;
|
||||
Base::Vector3d cnt;
|
||||
|
||||
pos = Base::Vector3d(ui->xPos->value(),ui->yPos->value(),ui->zPos->value());
|
||||
cnt = Base::Vector3d(ui->xCnt->value(),ui->yCnt->value(),ui->zCnt->value());
|
||||
pos = Base::Vector3d(ui->xPos->getQuantity().getValue(),ui->yPos->getQuantity().getValue(),ui->zPos->getQuantity().getValue());
|
||||
cnt = Base::Vector3d(ui->xCnt->getQuantity().getValue(),ui->yCnt->getQuantity().getValue(),ui->zCnt->getQuantity().getValue());
|
||||
|
||||
if (index == 0) {
|
||||
Base::Vector3d dir = getDirection();
|
||||
rot.setValue(Base::Vector3d(dir.x,dir.y,dir.z),Base::toRadians(ui->angle->value()));
|
||||
rot.setValue(Base::Vector3d(dir.x,dir.y,dir.z),Base::toRadians(ui->angle->getQuantity().getValue()));
|
||||
}
|
||||
else if (index == 1) {
|
||||
rot.setYawPitchRoll(
|
||||
ui->yawAngle->value(),
|
||||
ui->pitchAngle->value(),
|
||||
ui->rollAngle->value());
|
||||
ui->yawAngle->getQuantity().getValue(),
|
||||
ui->pitchAngle->getQuantity().getValue(),
|
||||
ui->rollAngle->getQuantity().getValue());
|
||||
}
|
||||
|
||||
Base::Placement p(pos, rot, cnt);
|
||||
|
@ -425,29 +441,29 @@ QString Placement::getPlacementString() const
|
|||
Base::Vector3d dir = getDirection();
|
||||
cmd = QString::fromAscii(
|
||||
"App.Placement(App.Vector(%1,%2,%3), App.Rotation(App.Vector(%4,%5,%6),%7), App.Vector(%8,%9,%10))")
|
||||
.arg(ui->xPos->value(),0,'g',ui->xPos->decimals())
|
||||
.arg(ui->yPos->value(),0,'g',ui->yPos->decimals())
|
||||
.arg(ui->zPos->value(),0,'g',ui->zPos->decimals())
|
||||
.arg(dir.x,0,'g',Base::UnitsApi::getDecimals())
|
||||
.arg(dir.y,0,'g',Base::UnitsApi::getDecimals())
|
||||
.arg(dir.z,0,'g',Base::UnitsApi::getDecimals())
|
||||
.arg(ui->angle->value(),0,'g',ui->angle->decimals())
|
||||
.arg(ui->xCnt->value(),0,'g',ui->xCnt->decimals())
|
||||
.arg(ui->yCnt->value(),0,'g',ui->yCnt->decimals())
|
||||
.arg(ui->zCnt->value(),0,'g',ui->zCnt->decimals());
|
||||
.arg(ui->xPos->getQuantity().getValue())
|
||||
.arg(ui->yPos->getQuantity().getValue())
|
||||
.arg(ui->zPos->getQuantity().getValue())
|
||||
.arg(dir.x)
|
||||
.arg(dir.y)
|
||||
.arg(dir.z)
|
||||
.arg(ui->angle->getQuantity().getValue())
|
||||
.arg(ui->xCnt->getQuantity().getValue())
|
||||
.arg(ui->yCnt->getQuantity().getValue())
|
||||
.arg(ui->zCnt->getQuantity().getValue());
|
||||
}
|
||||
else if (index == 1) {
|
||||
cmd = QString::fromAscii(
|
||||
"App.Placement(App.Vector(%1,%2,%3), App.Rotation(%4,%5,%6), App.Vector(%7,%8,%9))")
|
||||
.arg(ui->xPos->value(),0,'g',ui->xPos->decimals())
|
||||
.arg(ui->yPos->value(),0,'g',ui->yPos->decimals())
|
||||
.arg(ui->zPos->value(),0,'g',ui->zPos->decimals())
|
||||
.arg(ui->yawAngle->value(),0,'g',ui->yawAngle->decimals())
|
||||
.arg(ui->pitchAngle->value(),0,'g',ui->pitchAngle->decimals())
|
||||
.arg(ui->rollAngle->value(),0,'g',ui->rollAngle->decimals())
|
||||
.arg(ui->xCnt->value(),0,'g',ui->xCnt->decimals())
|
||||
.arg(ui->yCnt->value(),0,'g',ui->yCnt->decimals())
|
||||
.arg(ui->zCnt->value(),0,'g',ui->zCnt->decimals());
|
||||
.arg(ui->xPos->getQuantity().getValue())
|
||||
.arg(ui->yPos->getQuantity().getValue())
|
||||
.arg(ui->zPos->getQuantity().getValue())
|
||||
.arg(ui->yawAngle->getQuantity().getValue())
|
||||
.arg(ui->pitchAngle->getQuantity().getValue())
|
||||
.arg(ui->rollAngle->getQuantity().getValue())
|
||||
.arg(ui->xCnt->getQuantity().getValue())
|
||||
.arg(ui->yCnt->getQuantity().getValue())
|
||||
.arg(ui->zCnt->getQuantity().getValue());
|
||||
}
|
||||
|
||||
return cmd;
|
||||
|
|
|
@ -73,6 +73,7 @@ private:
|
|||
void applyPlacement(const QString& p, bool incremental);
|
||||
void revertTransformation();
|
||||
void slotActiveDocument(const Gui::Document&);
|
||||
bool hasValidInputs();
|
||||
|
||||
Q_SIGNALS:
|
||||
void placementChanged(const QVariant &, bool, bool);
|
||||
|
|
|
@ -6,10 +6,16 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>271</width>
|
||||
<height>410</height>
|
||||
<width>277</width>
|
||||
<height>474</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Placement</string>
|
||||
</property>
|
||||
|
@ -26,55 +32,7 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="zPos">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-2147480000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>2147480000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="yPos">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-2147480000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>2147480000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="xPos">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-2147480000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>2147480000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -87,7 +45,7 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="TextLabelZ">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
|
@ -100,7 +58,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="TextLabelY">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
|
@ -126,6 +84,15 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::InputField" name="xPos"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::InputField" name="yPos"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::InputField" name="zPos"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -141,54 +108,6 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="zCnt">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-2147480000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>2147480000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="yCnt">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-2147480000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>2147480000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="xCnt">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-2147480000.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>2147480000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
|
@ -241,6 +160,15 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::InputField" name="xCnt"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::InputField" name="yCnt"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::InputField" name="zCnt"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -277,16 +205,6 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="angle">
|
||||
<property name="minimum">
|
||||
<double>-360.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="textLabelAngle">
|
||||
<property name="sizePolicy">
|
||||
|
@ -320,6 +238,9 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::InputField" name="angle"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -340,26 +261,6 @@
|
|||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="yawAngle">
|
||||
<property name="minimum">
|
||||
<double>-360.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="pitchAngle">
|
||||
<property name="minimum">
|
||||
<double>-360.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="TextLabelZ_3">
|
||||
<property name="sizePolicy">
|
||||
|
@ -373,16 +274,6 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="rollAngle">
|
||||
<property name="minimum">
|
||||
<double>-360.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="TextLabelZ_4">
|
||||
<property name="sizePolicy">
|
||||
|
@ -409,6 +300,15 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::InputField" name="yawAngle"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::InputField" name="pitchAngle"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::InputField" name="rollAngle"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -458,6 +358,12 @@
|
|||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="applyIncrementalPlacement">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply incremental changes to object placement</string>
|
||||
</property>
|
||||
|
@ -531,19 +437,16 @@
|
|||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::InputField</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header location="global">Gui/InputField.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>xPos</tabstop>
|
||||
<tabstop>yPos</tabstop>
|
||||
<tabstop>zPos</tabstop>
|
||||
<tabstop>rotationInput</tabstop>
|
||||
<tabstop>direction</tabstop>
|
||||
<tabstop>angle</tabstop>
|
||||
<tabstop>yawAngle</tabstop>
|
||||
<tabstop>pitchAngle</tabstop>
|
||||
<tabstop>rollAngle</tabstop>
|
||||
<tabstop>xCnt</tabstop>
|
||||
<tabstop>yCnt</tabstop>
|
||||
<tabstop>zCnt</tabstop>
|
||||
<tabstop>applyPlacementChange</tabstop>
|
||||
<tabstop>applyIncrementalPlacement</tabstop>
|
||||
<tabstop>oKButton</tabstop>
|
||||
|
|
|
@ -309,11 +309,6 @@ Transform::Transform(QWidget* parent, Qt::WFlags fl)
|
|||
ui->applyPlacementChange->hide();
|
||||
ui->applyIncrementalPlacement->hide();
|
||||
|
||||
ui->angle->setSuffix(QString::fromUtf8(" \xc2\xb0"));
|
||||
ui->yawAngle->setSuffix(QString::fromUtf8(" \xc2\xb0"));
|
||||
ui->pitchAngle->setSuffix(QString::fromUtf8(" \xc2\xb0"));
|
||||
ui->rollAngle->setSuffix(QString::fromUtf8(" \xc2\xb0"));
|
||||
|
||||
ui->closeButton->setText(tr("Cancel"));
|
||||
this->setWindowTitle(tr("Transform"));
|
||||
|
||||
|
@ -323,8 +318,8 @@ Transform::Transform(QWidget* parent, Qt::WFlags fl)
|
|||
signalMapper->setMapping(this, 0);
|
||||
|
||||
int id = 1;
|
||||
QList<QDoubleSpinBox*> sb = this->findChildren<QDoubleSpinBox*>();
|
||||
for (QList<QDoubleSpinBox*>::iterator it = sb.begin(); it != sb.end(); ++it) {
|
||||
QList<Gui::InputField*> sb = this->findChildren<Gui::InputField*>();
|
||||
for (QList<Gui::InputField*>::iterator it = sb.begin(); it != sb.end(); ++it) {
|
||||
connect(*it, SIGNAL(valueChanged(double)), signalMapper, SLOT(map()));
|
||||
signalMapper->setMapping(*it, id++);
|
||||
}
|
||||
|
@ -349,9 +344,9 @@ void Transform::setTransformStrategy(TransformStrategy* ts)
|
|||
delete strategy;
|
||||
strategy = ts;
|
||||
Base::Vector3d cnt = strategy->getRotationCenter();
|
||||
ui->xCnt->setValue(cnt.x);
|
||||
ui->yCnt->setValue(cnt.y);
|
||||
ui->zCnt->setValue(cnt.z);
|
||||
ui->xCnt->setValue(Base::Quantity(cnt.x, Base::Unit::Length));
|
||||
ui->yCnt->setValue(Base::Quantity(cnt.y, Base::Unit::Length));
|
||||
ui->zCnt->setValue(Base::Quantity(cnt.z, Base::Unit::Length));
|
||||
this->setDisabled(strategy->transformObjects().empty());
|
||||
}
|
||||
|
||||
|
@ -388,17 +383,17 @@ void Transform::on_applyButton_clicked()
|
|||
strategy->commitTransform(mat);
|
||||
|
||||
// nullify the values
|
||||
QList<QDoubleSpinBox*> sb = this->findChildren<QDoubleSpinBox*>();
|
||||
for (QList<QDoubleSpinBox*>::iterator it = sb.begin(); it != sb.end(); ++it) {
|
||||
QList<Gui::InputField*> sb = this->findChildren<Gui::InputField*>();
|
||||
for (QList<Gui::InputField*>::iterator it = sb.begin(); it != sb.end(); ++it) {
|
||||
(*it)->blockSignals(true);
|
||||
(*it)->setValue(0.0);
|
||||
(*it)->blockSignals(false);
|
||||
}
|
||||
|
||||
Base::Vector3d cnt = strategy->getRotationCenter();
|
||||
ui->xCnt->setValue(cnt.x);
|
||||
ui->yCnt->setValue(cnt.y);
|
||||
ui->zCnt->setValue(cnt.z);
|
||||
ui->xCnt->setValue(Base::Quantity(cnt.x, Base::Unit::Length));
|
||||
ui->yCnt->setValue(Base::Quantity(cnt.y, Base::Unit::Length));
|
||||
ui->zCnt->setValue(Base::Quantity(cnt.z, Base::Unit::Length));
|
||||
}
|
||||
|
||||
void Transform::directionActivated(int index)
|
||||
|
@ -420,18 +415,18 @@ Base::Placement Transform::getPlacementData() const
|
|||
Base::Vector3d pos;
|
||||
Base::Vector3d cnt;
|
||||
|
||||
pos = Base::Vector3d(ui->xPos->value(),ui->yPos->value(),ui->zPos->value());
|
||||
cnt = Base::Vector3d(ui->xCnt->value(),ui->yCnt->value(),ui->zCnt->value());
|
||||
pos = Base::Vector3d(ui->xPos->getQuantity().getValue(),ui->yPos->getQuantity().getValue(),ui->zPos->getQuantity().getValue());
|
||||
cnt = Base::Vector3d(ui->xCnt->getQuantity().getValue(),ui->yCnt->getQuantity().getValue(),ui->zCnt->getQuantity().getValue());
|
||||
|
||||
if (index == 0) {
|
||||
Base::Vector3d dir = getDirection();
|
||||
rot.setValue(Base::Vector3d(dir.x,dir.y,dir.z),ui->angle->value()*D_PI/180.0);
|
||||
rot.setValue(Base::Vector3d(dir.x,dir.y,dir.z),ui->angle->getQuantity().getValue()*D_PI/180.0);
|
||||
}
|
||||
else if (index == 1) {
|
||||
rot.setYawPitchRoll(
|
||||
ui->yawAngle->value(),
|
||||
ui->pitchAngle->value(),
|
||||
ui->rollAngle->value());
|
||||
ui->yawAngle->getQuantity().getValue(),
|
||||
ui->pitchAngle->getQuantity().getValue(),
|
||||
ui->rollAngle->getQuantity().getValue());
|
||||
}
|
||||
|
||||
Base::Placement p(pos, rot, cnt);
|
||||
|
|
Loading…
Reference in New Issue
Block a user