All: Reformat according to new standard
This commit is contained in:
committed by
Kacper Donat
parent
eafd18dac0
commit
25c3ba7338
@@ -21,8 +21,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
|
||||
# include <QComboBox>
|
||||
#include <QComboBox>
|
||||
|
||||
|
||||
#include <Base/UnitsApi.h>
|
||||
@@ -34,8 +33,8 @@
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
LocationWidget::LocationWidget (QWidget * parent)
|
||||
: QWidget(parent)
|
||||
LocationWidget::LocationWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
box = new QGridLayout();
|
||||
|
||||
@@ -73,8 +72,7 @@ LocationWidget::LocationWidget (QWidget * parent)
|
||||
auto gridLayout = new QGridLayout(this);
|
||||
gridLayout->addLayout(box, 0, 0, 1, 2);
|
||||
|
||||
connect(dValue, qOverload<int>(&QComboBox::activated),
|
||||
this, &LocationWidget::onDirectionActivated);
|
||||
connect(dValue, qOverload<int>(&QComboBox::activated), this, &LocationWidget::onDirectionActivated);
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
@@ -82,7 +80,7 @@ LocationWidget::~LocationWidget() = default;
|
||||
|
||||
QSize LocationWidget::sizeHint() const
|
||||
{
|
||||
return {150,100};
|
||||
return {150, 100};
|
||||
}
|
||||
|
||||
void LocationWidget::changeEvent(QEvent* e)
|
||||
@@ -101,34 +99,39 @@ void LocationWidget::retranslateUi()
|
||||
dLabel->setText(QApplication::translate("Gui::LocationWidget", "Direction:"));
|
||||
|
||||
if (dValue->count() == 0) {
|
||||
dValue->insertItems(0, QStringList()
|
||||
<< QApplication::translate("Gui::LocationDialog", "X")
|
||||
<< QApplication::translate("Gui::LocationDialog", "Y")
|
||||
<< QApplication::translate("Gui::LocationDialog", "Z")
|
||||
<< QApplication::translate("Gui::LocationDialog", "User defined…")
|
||||
dValue->insertItems(
|
||||
0,
|
||||
QStringList() << QApplication::translate("Gui::LocationDialog", "X")
|
||||
<< QApplication::translate("Gui::LocationDialog", "Y")
|
||||
<< QApplication::translate("Gui::LocationDialog", "Z")
|
||||
<< QApplication::translate("Gui::LocationDialog", "User defined…")
|
||||
);
|
||||
|
||||
dValue->setCurrentIndex(2);
|
||||
|
||||
// Vector3d declared to use with QVariant see Gui/propertyeditor/PropertyItem.h
|
||||
dValue->setItemData(0, QVariant::fromValue<Base::Vector3d>(Base::Vector3d(1,0,0)));
|
||||
dValue->setItemData(1, QVariant::fromValue<Base::Vector3d>(Base::Vector3d(0,1,0)));
|
||||
dValue->setItemData(2, QVariant::fromValue<Base::Vector3d>(Base::Vector3d(0,0,1)));
|
||||
dValue->setItemData(0, QVariant::fromValue<Base::Vector3d>(Base::Vector3d(1, 0, 0)));
|
||||
dValue->setItemData(1, QVariant::fromValue<Base::Vector3d>(Base::Vector3d(0, 1, 0)));
|
||||
dValue->setItemData(2, QVariant::fromValue<Base::Vector3d>(Base::Vector3d(0, 0, 1)));
|
||||
}
|
||||
else {
|
||||
dValue->setItemText(0, QApplication::translate("Gui::LocationDialog", "X"));
|
||||
dValue->setItemText(1, QApplication::translate("Gui::LocationDialog", "Y"));
|
||||
dValue->setItemText(2, QApplication::translate("Gui::LocationDialog", "Z"));
|
||||
dValue->setItemText(dValue->count() - 1,
|
||||
QApplication::translate("Gui::LocationDialog", "User defined…"));
|
||||
dValue->setItemText(
|
||||
dValue->count() - 1,
|
||||
QApplication::translate("Gui::LocationDialog", "User defined…")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Base::Vector3d LocationWidget::getPosition() const
|
||||
{
|
||||
return Base::Vector3d(this->xValue->value().getValue(),
|
||||
this->yValue->value().getValue(),
|
||||
this->zValue->value().getValue());
|
||||
return Base::Vector3d(
|
||||
this->xValue->value().getValue(),
|
||||
this->yValue->value().getValue(),
|
||||
this->zValue->value().getValue()
|
||||
);
|
||||
}
|
||||
|
||||
void LocationWidget::setPosition(const Base::Vector3d& v)
|
||||
@@ -145,8 +148,8 @@ void LocationWidget::setDirection(const Base::Vector3d& dir)
|
||||
}
|
||||
|
||||
// check if the user-defined direction is already there
|
||||
for (int i=0; i<dValue->count()-1; i++) {
|
||||
QVariant data = dValue->itemData (i);
|
||||
for (int i = 0; i < dValue->count() - 1; i++) {
|
||||
QVariant data = dValue->itemData(i);
|
||||
if (data.canConvert<Base::Vector3d>()) {
|
||||
const auto val = data.value<Base::Vector3d>();
|
||||
if (val == dir) {
|
||||
@@ -157,23 +160,19 @@ void LocationWidget::setDirection(const Base::Vector3d& dir)
|
||||
}
|
||||
|
||||
// add a new item before the very last item
|
||||
QString display = QStringLiteral("(%1,%2,%3)")
|
||||
.arg(dir.x)
|
||||
.arg(dir.y)
|
||||
.arg(dir.z);
|
||||
dValue->insertItem(dValue->count()-1, display,
|
||||
QVariant::fromValue<Base::Vector3d>(dir));
|
||||
dValue->setCurrentIndex(dValue->count()-2);
|
||||
QString display = QStringLiteral("(%1,%2,%3)").arg(dir.x).arg(dir.y).arg(dir.z);
|
||||
dValue->insertItem(dValue->count() - 1, display, QVariant::fromValue<Base::Vector3d>(dir));
|
||||
dValue->setCurrentIndex(dValue->count() - 2);
|
||||
}
|
||||
|
||||
Base::Vector3d LocationWidget::getDirection() const
|
||||
{
|
||||
QVariant data = dValue->itemData (this->dValue->currentIndex());
|
||||
QVariant data = dValue->itemData(this->dValue->currentIndex());
|
||||
if (data.canConvert<Base::Vector3d>()) {
|
||||
return data.value<Base::Vector3d>();
|
||||
}
|
||||
else {
|
||||
return Base::Vector3d(0,0,1);
|
||||
return Base::Vector3d(0, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,10 +189,14 @@ Base::Vector3d LocationWidget::getUserDirection(bool* ok) const
|
||||
dir.x = iv.vectorX->value();
|
||||
dir.y = iv.vectorY->value();
|
||||
dir.z = iv.vectorZ->value();
|
||||
if (ok) *ok = true;
|
||||
if (ok) {
|
||||
*ok = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ok) *ok = false;
|
||||
if (ok) {
|
||||
*ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
return dir;
|
||||
@@ -202,13 +205,16 @@ Base::Vector3d LocationWidget::getUserDirection(bool* ok) const
|
||||
void LocationWidget::onDirectionActivated(int index)
|
||||
{
|
||||
// last item is selected to define direction by user
|
||||
if (index+1 == dValue->count()) {
|
||||
if (index + 1 == dValue->count()) {
|
||||
bool ok;
|
||||
Base::Vector3d dir = this->getUserDirection(&ok);
|
||||
if (ok) {
|
||||
if (dir.Length() < Base::Vector3d::epsilon()) {
|
||||
QMessageBox::critical(this, LocationDialog::tr("Wrong direction"),
|
||||
LocationDialog::tr("Direction must not be the null vector"));
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
LocationDialog::tr("Wrong direction"),
|
||||
LocationDialog::tr("Direction must not be the null vector")
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -220,9 +226,8 @@ void LocationWidget::onDirectionActivated(int index)
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
LocationDialog::LocationDialog(QWidget* parent, Qt::WindowFlags fl)
|
||||
: QDialog(parent, fl)
|
||||
{
|
||||
}
|
||||
: QDialog(parent, fl)
|
||||
{}
|
||||
|
||||
LocationDialog::~LocationDialog() = default;
|
||||
|
||||
@@ -239,10 +244,14 @@ Base::Vector3d LocationDialog::getUserDirection(bool* ok) const
|
||||
dir.x = iv.vectorX->value();
|
||||
dir.y = iv.vectorY->value();
|
||||
dir.z = iv.vectorZ->value();
|
||||
if (ok) *ok = true;
|
||||
if (ok) {
|
||||
*ok = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ok) *ok = false;
|
||||
if (ok) {
|
||||
*ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
return dir;
|
||||
@@ -267,7 +276,7 @@ Base::Vector3d LocationDialogUiImp::getPosition() const
|
||||
return ui->getPosition();
|
||||
}
|
||||
|
||||
void LocationDialogUiImp::changeEvent(QEvent *e)
|
||||
void LocationDialogUiImp::changeEvent(QEvent* e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslate(this);
|
||||
@@ -279,7 +288,7 @@ void LocationDialogUiImp::changeEvent(QEvent *e)
|
||||
|
||||
void LocationDialogUiImp::directionActivated(int index)
|
||||
{
|
||||
ui->directionActivated(this,index);
|
||||
ui->directionActivated(this, index);
|
||||
}
|
||||
|
||||
#include "moc_InputVector.cpp"
|
||||
|
||||
Reference in New Issue
Block a user