Gui: Prepare for clang-format (#16051)
* Gui: Prepare for clang-format * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -23,12 +23,12 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <Inventor/actions/SoGetBoundingBoxAction.h>
|
||||
# include <Inventor/nodes/SoClipPlane.h>
|
||||
# include <Inventor/nodes/SoGroup.h>
|
||||
# include <Inventor/sensors/SoTimerSensor.h>
|
||||
# include <QDockWidget>
|
||||
# include <QPointer>
|
||||
#include <Inventor/actions/SoGetBoundingBoxAction.h>
|
||||
#include <Inventor/nodes/SoClipPlane.h>
|
||||
#include <Inventor/nodes/SoGroup.h>
|
||||
#include <Inventor/sensors/SoTimerSensor.h>
|
||||
#include <QDockWidget>
|
||||
#include <QPointer>
|
||||
#endif
|
||||
|
||||
#include "Clipping.h"
|
||||
@@ -39,7 +39,8 @@
|
||||
|
||||
using namespace Gui::Dialog;
|
||||
|
||||
class Clipping::Private {
|
||||
class Clipping::Private
|
||||
{
|
||||
public:
|
||||
Ui_Clipping ui;
|
||||
QPointer<Gui::View3DInventor> view;
|
||||
@@ -48,30 +49,30 @@ public:
|
||||
SoClipPlane* clipY;
|
||||
SoClipPlane* clipZ;
|
||||
SoClipPlane* clipView;
|
||||
bool flipX{false};
|
||||
bool flipY{false};
|
||||
bool flipZ{false};
|
||||
bool flipX {false};
|
||||
bool flipY {false};
|
||||
bool flipZ {false};
|
||||
SoTimerSensor* sensor;
|
||||
Private()
|
||||
{
|
||||
clipX = new SoClipPlane();
|
||||
clipX->on.setValue(false);
|
||||
clipX->plane.setValue(SbPlane(SbVec3f(1,0,0),0));
|
||||
clipX->plane.setValue(SbPlane(SbVec3f(1, 0, 0), 0));
|
||||
clipX->ref();
|
||||
|
||||
clipY = new SoClipPlane();
|
||||
clipY->on.setValue(false);
|
||||
clipY->plane.setValue(SbPlane(SbVec3f(0,1,0),0));
|
||||
clipY->plane.setValue(SbPlane(SbVec3f(0, 1, 0), 0));
|
||||
clipY->ref();
|
||||
|
||||
clipZ = new SoClipPlane();
|
||||
clipZ->on.setValue(false);
|
||||
clipZ->plane.setValue(SbPlane(SbVec3f(0,0,1),0));
|
||||
clipZ->plane.setValue(SbPlane(SbVec3f(0, 0, 1), 0));
|
||||
clipZ->ref();
|
||||
|
||||
clipView = new SoClipPlane();
|
||||
clipView->on.setValue(false);
|
||||
clipView->plane.setValue(SbPlane(SbVec3f(0,0,1),0));
|
||||
clipView->plane.setValue(SbPlane(SbVec3f(0, 0, 1), 0));
|
||||
clipView->ref();
|
||||
|
||||
node = nullptr;
|
||||
@@ -85,7 +86,7 @@ public:
|
||||
clipView->unref();
|
||||
delete sensor;
|
||||
}
|
||||
static void moveCallback(void * data, SoSensor * sensor)
|
||||
static void moveCallback(void* data, SoSensor* sensor)
|
||||
{
|
||||
Q_UNUSED(sensor);
|
||||
auto self = static_cast<Private*>(data);
|
||||
@@ -93,7 +94,7 @@ public:
|
||||
Gui::View3DInventorViewer* view = self->view->getViewer();
|
||||
SoClipPlane* clip = self->clipView;
|
||||
SbPlane pln = clip->plane.getValue();
|
||||
clip->plane.setValue(SbPlane(view->getViewDirection(),pln.getDistanceFromOrigin()));
|
||||
clip->plane.setValue(SbPlane(view->getViewDirection(), pln.getDistanceFromOrigin()));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -101,27 +102,27 @@ public:
|
||||
/* TRANSLATOR Gui::Dialog::Clipping */
|
||||
|
||||
Clipping::Clipping(Gui::View3DInventor* view, QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, d(new Private)
|
||||
: QDialog(parent)
|
||||
, d(new Private)
|
||||
{
|
||||
// create widgets
|
||||
d->ui.setupUi(this);
|
||||
setupConnections();
|
||||
|
||||
d->ui.clipView->setRange(-INT_MAX,INT_MAX);
|
||||
d->ui.clipView->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.clipView->setSingleStep(0.1f);
|
||||
d->ui.clipX->setRange(-INT_MAX,INT_MAX);
|
||||
d->ui.clipX->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.clipX->setSingleStep(0.1f);
|
||||
d->ui.clipY->setRange(-INT_MAX,INT_MAX);
|
||||
d->ui.clipY->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.clipY->setSingleStep(0.1f);
|
||||
d->ui.clipZ->setRange(-INT_MAX,INT_MAX);
|
||||
d->ui.clipZ->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.clipZ->setSingleStep(0.1f);
|
||||
|
||||
d->ui.dirX->setRange(-INT_MAX,INT_MAX);
|
||||
d->ui.dirX->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.dirX->setSingleStep(0.1f);
|
||||
d->ui.dirY->setRange(-INT_MAX,INT_MAX);
|
||||
d->ui.dirY->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.dirY->setSingleStep(0.1f);
|
||||
d->ui.dirZ->setRange(-INT_MAX,INT_MAX);
|
||||
d->ui.dirZ->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.dirZ->setSingleStep(0.1f);
|
||||
d->ui.dirZ->setValue(1.0f);
|
||||
|
||||
@@ -146,7 +147,7 @@ Clipping::Clipping(Gui::View3DInventor* view, QWidget* parent)
|
||||
d->ui.clipZ->setValue(cnt[2]);
|
||||
|
||||
int minDecimals = 2;
|
||||
float lenx, leny,lenz;
|
||||
float lenx, leny, lenz;
|
||||
box.getSize(lenx, leny, lenz);
|
||||
int steps = 100;
|
||||
float minlen = std::min<float>(lenx, std::min<float>(leny, lenz));
|
||||
@@ -192,7 +193,7 @@ Clipping* Clipping::makeDockWidget(Gui::View3DInventor* view)
|
||||
auto clipping = new Clipping(view);
|
||||
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
|
||||
QDockWidget* dw = pDockMgr->addDockWindow("Clipping", clipping, Qt::LeftDockWidgetArea);
|
||||
dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
|
||||
dw->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
|
||||
dw->show();
|
||||
|
||||
return clipping;
|
||||
@@ -211,6 +212,7 @@ Clipping::~Clipping()
|
||||
|
||||
void Clipping::setupConnections()
|
||||
{
|
||||
// clang-format off
|
||||
connect(d->ui.groupBoxX, &QGroupBox::toggled,
|
||||
this, &Clipping::onGroupBoxXToggled);
|
||||
connect(d->ui.groupBoxY, &QGroupBox::toggled,
|
||||
@@ -243,6 +245,7 @@ void Clipping::setupConnections()
|
||||
this, &Clipping::onDirYValueChanged);
|
||||
connect(d->ui.dirZ, qOverload<double>(&QDoubleSpinBox::valueChanged),
|
||||
this, &Clipping::onDirZValueChanged);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void Clipping::reject()
|
||||
@@ -284,40 +287,40 @@ void Clipping::onGroupBoxZToggled(bool on)
|
||||
void Clipping::onClipXValueChanged(double val)
|
||||
{
|
||||
SbPlane pln = d->clipX->plane.getValue();
|
||||
d->clipX->plane.setValue(SbPlane(pln.getNormal(),d->flipX ? -val : val));
|
||||
d->clipX->plane.setValue(SbPlane(pln.getNormal(), d->flipX ? -val : val));
|
||||
}
|
||||
|
||||
void Clipping::onClipYValueChanged(double val)
|
||||
{
|
||||
SbPlane pln = d->clipY->plane.getValue();
|
||||
d->clipY->plane.setValue(SbPlane(pln.getNormal(),d->flipY ? -val : val));
|
||||
d->clipY->plane.setValue(SbPlane(pln.getNormal(), d->flipY ? -val : val));
|
||||
}
|
||||
|
||||
void Clipping::onClipZValueChanged(double val)
|
||||
{
|
||||
SbPlane pln = d->clipZ->plane.getValue();
|
||||
d->clipZ->plane.setValue(SbPlane(pln.getNormal(),d->flipZ ? -val : val));
|
||||
d->clipZ->plane.setValue(SbPlane(pln.getNormal(), d->flipZ ? -val : val));
|
||||
}
|
||||
|
||||
void Clipping::onFlipClipXClicked()
|
||||
{
|
||||
d->flipX = !d->flipX;
|
||||
SbPlane pln = d->clipX->plane.getValue();
|
||||
d->clipX->plane.setValue(SbPlane(-pln.getNormal(),-pln.getDistanceFromOrigin()));
|
||||
d->clipX->plane.setValue(SbPlane(-pln.getNormal(), -pln.getDistanceFromOrigin()));
|
||||
}
|
||||
|
||||
void Clipping::onFlipClipYClicked()
|
||||
{
|
||||
d->flipY = !d->flipY;
|
||||
SbPlane pln = d->clipY->plane.getValue();
|
||||
d->clipY->plane.setValue(SbPlane(-pln.getNormal(),-pln.getDistanceFromOrigin()));
|
||||
d->clipY->plane.setValue(SbPlane(-pln.getNormal(), -pln.getDistanceFromOrigin()));
|
||||
}
|
||||
|
||||
void Clipping::onFlipClipZClicked()
|
||||
{
|
||||
d->flipZ = !d->flipZ;
|
||||
SbPlane pln = d->clipZ->plane.getValue();
|
||||
d->clipZ->plane.setValue(SbPlane(-pln.getNormal(),-pln.getDistanceFromOrigin()));
|
||||
d->clipZ->plane.setValue(SbPlane(-pln.getNormal(), -pln.getDistanceFromOrigin()));
|
||||
}
|
||||
|
||||
void Clipping::onGroupBoxViewToggled(bool on)
|
||||
@@ -334,7 +337,7 @@ void Clipping::onGroupBoxViewToggled(bool on)
|
||||
void Clipping::onClipViewValueChanged(double val)
|
||||
{
|
||||
SbPlane pln = d->clipView->plane.getValue();
|
||||
d->clipView->plane.setValue(SbPlane(pln.getNormal(),val));
|
||||
d->clipView->plane.setValue(SbPlane(pln.getNormal(), val));
|
||||
}
|
||||
|
||||
void Clipping::onFromViewClicked()
|
||||
@@ -343,7 +346,7 @@ void Clipping::onFromViewClicked()
|
||||
Gui::View3DInventorViewer* view = d->view->getViewer();
|
||||
SbVec3f dir = view->getViewDirection();
|
||||
SbPlane pln = d->clipView->plane.getValue();
|
||||
d->clipView->plane.setValue(SbPlane(dir,pln.getDistanceFromOrigin()));
|
||||
d->clipView->plane.setValue(SbPlane(dir, pln.getDistanceFromOrigin()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,10 +357,12 @@ void Clipping::onAdjustViewdirectionToggled(bool on)
|
||||
d->ui.dirZ->setDisabled(on);
|
||||
d->ui.fromView->setDisabled(on);
|
||||
|
||||
if (on)
|
||||
if (on) {
|
||||
d->sensor->schedule();
|
||||
else
|
||||
}
|
||||
else {
|
||||
d->sensor->unschedule();
|
||||
}
|
||||
}
|
||||
|
||||
void Clipping::onDirXValueChanged(double)
|
||||
@@ -367,9 +372,10 @@ void Clipping::onDirXValueChanged(double)
|
||||
double z = d->ui.dirZ->value();
|
||||
|
||||
SbPlane pln = d->clipView->plane.getValue();
|
||||
SbVec3f normal(x,y,z);
|
||||
if (normal.sqrLength() > 0.0f)
|
||||
d->clipView->plane.setValue(SbPlane(normal,pln.getDistanceFromOrigin()));
|
||||
SbVec3f normal(x, y, z);
|
||||
if (normal.sqrLength() > 0.0f) {
|
||||
d->clipView->plane.setValue(SbPlane(normal, pln.getDistanceFromOrigin()));
|
||||
}
|
||||
}
|
||||
|
||||
void Clipping::onDirYValueChanged(double)
|
||||
@@ -379,9 +385,10 @@ void Clipping::onDirYValueChanged(double)
|
||||
double z = d->ui.dirZ->value();
|
||||
|
||||
SbPlane pln = d->clipView->plane.getValue();
|
||||
SbVec3f normal(x,y,z);
|
||||
if (normal.sqrLength() > 0.0f)
|
||||
d->clipView->plane.setValue(SbPlane(normal,pln.getDistanceFromOrigin()));
|
||||
SbVec3f normal(x, y, z);
|
||||
if (normal.sqrLength() > 0.0f) {
|
||||
d->clipView->plane.setValue(SbPlane(normal, pln.getDistanceFromOrigin()));
|
||||
}
|
||||
}
|
||||
|
||||
void Clipping::onDirZValueChanged(double)
|
||||
@@ -391,9 +398,10 @@ void Clipping::onDirZValueChanged(double)
|
||||
double z = d->ui.dirZ->value();
|
||||
|
||||
SbPlane pln = d->clipView->plane.getValue();
|
||||
SbVec3f normal(x,y,z);
|
||||
if (normal.sqrLength() > 0.0f)
|
||||
d->clipView->plane.setValue(SbPlane(normal,pln.getDistanceFromOrigin()));
|
||||
SbVec3f normal(x, y, z);
|
||||
if (normal.sqrLength() > 0.0f) {
|
||||
d->clipView->plane.setValue(SbPlane(normal, pln.getDistanceFromOrigin()));
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_Clipping.cpp"
|
||||
|
||||
Reference in New Issue
Block a user