Points: apply clang-formatting

This commit is contained in:
wmayer
2023-09-01 17:33:18 +02:00
committed by wwmayer
parent 047c39cb4c
commit c91b82db0b
32 changed files with 2829 additions and 2359 deletions

View File

@@ -22,9 +22,9 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <algorithm>
# include <QInputDialog>
# include <Inventor/events/SoMouseButtonEvent.h>
#include <Inventor/events/SoMouseButtonEvent.h>
#include <QInputDialog>
#include <algorithm>
#endif
#include <App/Application.h>
@@ -45,8 +45,8 @@
#include <Gui/WaitCursor.h>
#include "../App/PointsFeature.h"
#include "../App/Structured.h"
#include "../App/Properties.h"
#include "../App/Structured.h"
#include "../App/Tools.h"
#include "DlgPointsReadImp.h"
@@ -61,34 +61,40 @@
DEF_STD_CMD_A(CmdPointsImport)
CmdPointsImport::CmdPointsImport()
: Command("Points_Import")
: Command("Points_Import")
{
sAppModule = "Points";
sGroup = QT_TR_NOOP("Points");
sMenuText = QT_TR_NOOP("Import points...");
sToolTipText = QT_TR_NOOP("Imports a point cloud");
sWhatsThis = "Points_Import";
sStatusTip = QT_TR_NOOP("Imports a point cloud");
sPixmap = "Points_Import_Point_cloud";
sAppModule = "Points";
sGroup = QT_TR_NOOP("Points");
sMenuText = QT_TR_NOOP("Import points...");
sToolTipText = QT_TR_NOOP("Imports a point cloud");
sWhatsThis = "Points_Import";
sStatusTip = QT_TR_NOOP("Imports a point cloud");
sPixmap = "Points_Import_Point_cloud";
}
void CmdPointsImport::activated(int iMsg)
{
Q_UNUSED(iMsg);
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(),
QString(), QString(), QString::fromLatin1("%1 (*.asc *.pcd *.ply);;%2 (*.*)")
.arg(QObject::tr("Point formats"), QObject::tr("All Files")));
if (fn.isEmpty())
QString fn = Gui::FileDialog::getOpenFileName(
Gui::getMainWindow(),
QString(),
QString(),
QString::fromLatin1("%1 (*.asc *.pcd *.ply);;%2 (*.*)")
.arg(QObject::tr("Point formats"), QObject::tr("All Files")));
if (fn.isEmpty()) {
return;
}
if (!fn.isEmpty()) {
fn = Base::Tools::escapeEncodeFilename(fn);
Gui::Document* doc = getActiveGuiDocument();
openCommand(QT_TRANSLATE_NOOP("Command", "Import points"));
addModule(Command::App, "Points");
doCommand(Command::Doc, "Points.insert(\"%s\", \"%s\")",
fn.toUtf8().data(), doc->getDocument()->getName());
doCommand(Command::Doc,
"Points.insert(\"%s\", \"%s\")",
fn.toUtf8().data(),
doc->getDocument()->getName());
commitCommand();
updateActive();
@@ -97,24 +103,26 @@ void CmdPointsImport::activated(int iMsg)
bool CmdPointsImport::isActive()
{
if (getActiveGuiDocument())
if (getActiveGuiDocument()) {
return true;
else
}
else {
return false;
}
}
DEF_STD_CMD_A(CmdPointsExport)
CmdPointsExport::CmdPointsExport()
: Command("Points_Export")
: Command("Points_Export")
{
sAppModule = "Points";
sGroup = QT_TR_NOOP("Points");
sMenuText = QT_TR_NOOP("Export points...");
sToolTipText = QT_TR_NOOP("Exports a point cloud");
sWhatsThis = "Points_Export";
sStatusTip = QT_TR_NOOP("Exports a point cloud");
sPixmap = "Points_Export_Point_cloud";
sAppModule = "Points";
sGroup = QT_TR_NOOP("Points");
sMenuText = QT_TR_NOOP("Export points...");
sToolTipText = QT_TR_NOOP("Exports a point cloud");
sWhatsThis = "Points_Export";
sStatusTip = QT_TR_NOOP("Exports a point cloud");
sPixmap = "Points_Export_Point_cloud";
}
void CmdPointsExport::activated(int iMsg)
@@ -122,18 +130,25 @@ void CmdPointsExport::activated(int iMsg)
Q_UNUSED(iMsg);
addModule(Command::App, "Points");
std::vector<App::DocumentObject*> points = getSelection().getObjectsOfType(Points::Feature::getClassTypeId());
std::vector<App::DocumentObject*> points =
getSelection().getObjectsOfType(Points::Feature::getClassTypeId());
for (auto point : points) {
QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(),
QString(), QString(), QString::fromLatin1("%1 (*.asc *.pcd *.ply);;%2 (*.*)")
.arg(QObject::tr("Point formats"), QObject::tr("All Files")));
if (fn.isEmpty())
QString fn = Gui::FileDialog::getSaveFileName(
Gui::getMainWindow(),
QString(),
QString(),
QString::fromLatin1("%1 (*.asc *.pcd *.ply);;%2 (*.*)")
.arg(QObject::tr("Point formats"), QObject::tr("All Files")));
if (fn.isEmpty()) {
break;
}
if (!fn.isEmpty()) {
fn = Base::Tools::escapeEncodeFilename(fn);
doCommand(Command::Doc, "Points.export([App.ActiveDocument.%s], \"%s\")",
point->getNameInDocument(), fn.toUtf8().data());
doCommand(Command::Doc,
"Points.export([App.ActiveDocument.%s], \"%s\")",
point->getNameInDocument(),
fn.toUtf8().data());
}
}
}
@@ -146,15 +161,15 @@ bool CmdPointsExport::isActive()
DEF_STD_CMD_A(CmdPointsTransform)
CmdPointsTransform::CmdPointsTransform()
:Command("Points_Transform")
: Command("Points_Transform")
{
sAppModule = "Points";
sGroup = QT_TR_NOOP("Points");
sMenuText = QT_TR_NOOP("Transform Points");
sToolTipText = QT_TR_NOOP("Test to transform a point cloud");
sWhatsThis = "Points_Transform";
sStatusTip = QT_TR_NOOP("Test to transform a point cloud");
sPixmap = "Test1";
sAppModule = "Points";
sGroup = QT_TR_NOOP("Points");
sMenuText = QT_TR_NOOP("Transform Points");
sToolTipText = QT_TR_NOOP("Test to transform a point cloud");
sWhatsThis = "Points_Transform";
sStatusTip = QT_TR_NOOP("Test to transform a point cloud");
sPixmap = "Test1";
}
void CmdPointsTransform::activated(int iMsg)
@@ -166,12 +181,14 @@ void CmdPointsTransform::activated(int iMsg)
trans.setRotation(Base::Rotation(Base::Vector3d(0.0, 0.0, 1.0), 1.570796));
openCommand(QT_TRANSLATE_NOOP("Command", "Transform points"));
//std::vector<App::DocumentObject*> points = getSelection().getObjectsOfType(Points::Feature::getClassTypeId());
//for (std::vector<App::DocumentObject*>::const_iterator it = points.begin(); it != points.end(); ++it) {
// Base::Placement p = static_cast<Points::Feature*>(*it)->Placement.getValue();
// p._rot *= Base::Rotation(Base::Vector3d(0.0, 0.0, 1.0), 1.570796);
// static_cast<Points::Feature*>(*it)->Placement.setValue(p);
//}
// std::vector<App::DocumentObject*> points =
// getSelection().getObjectsOfType(Points::Feature::getClassTypeId()); for
// (std::vector<App::DocumentObject*>::const_iterator it = points.begin(); it != points.end();
// ++it) {
// Base::Placement p = static_cast<Points::Feature*>(*it)->Placement.getValue();
// p._rot *= Base::Rotation(Base::Vector3d(0.0, 0.0, 1.0), 1.570796);
// static_cast<Points::Feature*>(*it)->Placement.setValue(p);
// }
commitCommand();
}
@@ -183,15 +200,15 @@ bool CmdPointsTransform::isActive()
DEF_STD_CMD_A(CmdPointsConvert)
CmdPointsConvert::CmdPointsConvert()
:Command("Points_Convert")
: Command("Points_Convert")
{
sAppModule = "Points";
sGroup = QT_TR_NOOP("Points");
sMenuText = QT_TR_NOOP("Convert to points...");
sToolTipText = QT_TR_NOOP("Convert to points");
sWhatsThis = "Points_Convert";
sStatusTip = QT_TR_NOOP("Convert to points");
sPixmap = "Points_Convert";
sAppModule = "Points";
sGroup = QT_TR_NOOP("Points");
sMenuText = QT_TR_NOOP("Convert to points...");
sToolTipText = QT_TR_NOOP("Convert to points");
sWhatsThis = "Points_Convert";
sStatusTip = QT_TR_NOOP("Convert to points");
sPixmap = "Points_Convert";
}
void CmdPointsConvert::activated(int iMsg)
@@ -202,13 +219,22 @@ void CmdPointsConvert::activated(int iMsg)
int decimals = Base::UnitsApi::getDecimals();
double tolerance_from_decimals = pow(10., -decimals);
double minimal_tolerance = tolerance_from_decimals < STD_OCC_TOLERANCE ? STD_OCC_TOLERANCE : tolerance_from_decimals;
double minimal_tolerance =
tolerance_from_decimals < STD_OCC_TOLERANCE ? STD_OCC_TOLERANCE : tolerance_from_decimals;
bool ok;
double tol = QInputDialog::getDouble(Gui::getMainWindow(), QObject::tr("Distance"),
QObject::tr("Enter maximum distance:"), 0.1, minimal_tolerance, 10.0, decimals, &ok, Qt::MSWindowsFixedSizeDialogHint);
if (!ok)
double tol = QInputDialog::getDouble(Gui::getMainWindow(),
QObject::tr("Distance"),
QObject::tr("Enter maximum distance:"),
0.1,
minimal_tolerance,
10.0,
decimals,
&ok,
Qt::MSWindowsFixedSizeDialogHint);
if (!ok) {
return;
}
Gui::WaitCursor wc;
openCommand(QT_TRANSLATE_NOOP("Command", "Convert to points"));
@@ -230,7 +256,8 @@ void CmdPointsConvert::activated(int iMsg)
}
Py::Module commands(module, true);
commands.callMemberFunction("make_points_from_geometry", Py::TupleN(list, Py::Float(tol)));
commands.callMemberFunction("make_points_from_geometry",
Py::TupleN(list, Py::Float(tol)));
return true;
}
@@ -239,10 +266,12 @@ void CmdPointsConvert::activated(int iMsg)
Base::PyGILStateLocker lock;
try {
if (run_python(geoObject, tol))
if (run_python(geoObject, tol)) {
commitCommand();
else
}
else {
abortCommand();
}
}
catch (const Py::Exception&) {
abortCommand();
@@ -259,23 +288,25 @@ bool CmdPointsConvert::isActive()
DEF_STD_CMD_A(CmdPointsPolyCut)
CmdPointsPolyCut::CmdPointsPolyCut()
:Command("Points_PolyCut")
: Command("Points_PolyCut")
{
sAppModule = "Points";
sGroup = QT_TR_NOOP("Points");
sMenuText = QT_TR_NOOP("Cut point cloud");
sToolTipText = QT_TR_NOOP("Cuts a point cloud with a picked polygon");
sWhatsThis = "Points_PolyCut";
sStatusTip = QT_TR_NOOP("Cuts a point cloud with a picked polygon");
sPixmap = "PolygonPick";
sAppModule = "Points";
sGroup = QT_TR_NOOP("Points");
sMenuText = QT_TR_NOOP("Cut point cloud");
sToolTipText = QT_TR_NOOP("Cuts a point cloud with a picked polygon");
sWhatsThis = "Points_PolyCut";
sStatusTip = QT_TR_NOOP("Cuts a point cloud with a picked polygon");
sPixmap = "PolygonPick";
}
void CmdPointsPolyCut::activated(int iMsg)
{
Q_UNUSED(iMsg);
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(Points::Feature::getClassTypeId());
for (std::vector<App::DocumentObject*>::iterator it = docObj.begin(); it != docObj.end(); ++it) {
std::vector<App::DocumentObject*> docObj =
Gui::Selection().getObjectsOfType(Points::Feature::getClassTypeId());
for (std::vector<App::DocumentObject*>::iterator it = docObj.begin(); it != docObj.end();
++it) {
if (it == docObj.begin()) {
Gui::Document* doc = getActiveGuiDocument();
Gui::MDIView* view = doc->getActiveView();
@@ -283,14 +314,15 @@ void CmdPointsPolyCut::activated(int iMsg)
Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer();
viewer->setEditing(true);
viewer->startSelection(Gui::View3DInventorViewer::Lasso);
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(), PointsGui::ViewProviderPoints::clipPointsCallback);
viewer->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
PointsGui::ViewProviderPoints::clipPointsCallback);
}
else {
return;
}
}
Gui::ViewProvider* pVP = getActiveGuiDocument()->getViewProvider( *it );
Gui::ViewProvider* pVP = getActiveGuiDocument()->getViewProvider(*it);
pVP->startEditing(Gui::ViewProvider::Cutting);
}
}
@@ -304,15 +336,15 @@ bool CmdPointsPolyCut::isActive()
DEF_STD_CMD_A(CmdPointsMerge)
CmdPointsMerge::CmdPointsMerge()
:Command("Points_Merge")
: Command("Points_Merge")
{
sAppModule = "Points";
sGroup = QT_TR_NOOP("Points");
sMenuText = QT_TR_NOOP("Merge point clouds");
sToolTipText = QT_TR_NOOP("Merge several point clouds into one");
sWhatsThis = "Points_Merge";
sStatusTip = QT_TR_NOOP("Merge several point clouds into one");
sPixmap = "Points_Merge";
sAppModule = "Points";
sGroup = QT_TR_NOOP("Points");
sMenuText = QT_TR_NOOP("Merge point clouds");
sToolTipText = QT_TR_NOOP("Merge several point clouds into one");
sWhatsThis = "Points_Merge";
sStatusTip = QT_TR_NOOP("Merge several point clouds into one");
sPixmap = "Points_Merge";
}
void CmdPointsMerge::activated(int iMsg)
@@ -321,16 +353,18 @@ void CmdPointsMerge::activated(int iMsg)
App::Document* doc = App::GetApplication().getActiveDocument();
doc->openTransaction("Merge point clouds");
Points::Feature* pts = static_cast<Points::Feature*>(doc->addObject("Points::Feature", "Merged Points"));
Points::Feature* pts =
static_cast<Points::Feature*>(doc->addObject("Points::Feature", "Merged Points"));
Points::PointKernel* kernel = pts->Points.startEditing();
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(Points::Feature::getClassTypeId());
std::vector<App::DocumentObject*> docObj =
Gui::Selection().getObjectsOfType(Points::Feature::getClassTypeId());
for (auto it : docObj) {
const Points::PointKernel& k = static_cast<Points::Feature*>(it)->Points.getValue();
std::size_t numPts = kernel->size();
kernel->resize(numPts + k.size());
for (std::size_t i=0; i<k.size(); ++i) {
kernel->setPoint(i+numPts, k.getPoint(i));
for (std::size_t i = 0; i < k.size(); ++i) {
kernel->setPoint(i + numPts, k.getPoint(i));
}
}
@@ -348,8 +382,8 @@ void CmdPointsMerge::activated(int iMsg)
displayMode = "Intensity";
}
if (auto vp = dynamic_cast<Gui::ViewProviderDocumentObject*>
(Gui::Application::Instance->getViewProvider(pts))) {
if (auto vp = dynamic_cast<Gui::ViewProviderDocumentObject*>(
Gui::Application::Instance->getViewProvider(pts))) {
vp->DisplayMode.setValue(displayMode.c_str());
}
@@ -365,15 +399,15 @@ bool CmdPointsMerge::isActive()
DEF_STD_CMD_A(CmdPointsStructure)
CmdPointsStructure::CmdPointsStructure()
:Command("Points_Structure")
: Command("Points_Structure")
{
sAppModule = "Points";
sGroup = QT_TR_NOOP("Points");
sMenuText = QT_TR_NOOP("Structured point cloud");
sToolTipText = QT_TR_NOOP("Convert points to structured point cloud");
sWhatsThis = "Points_Structure";
sStatusTip = QT_TR_NOOP("Convert points to structured point cloud");
sPixmap = "Points_Structure";
sAppModule = "Points";
sGroup = QT_TR_NOOP("Points");
sMenuText = QT_TR_NOOP("Structured point cloud");
sToolTipText = QT_TR_NOOP("Convert points to structured point cloud");
sWhatsThis = "Points_Structure";
sStatusTip = QT_TR_NOOP("Convert points to structured point cloud");
sPixmap = "Points_Structure";
}
void CmdPointsStructure::activated(int iMsg)
@@ -383,11 +417,13 @@ void CmdPointsStructure::activated(int iMsg)
App::Document* doc = App::GetApplication().getActiveDocument();
doc->openTransaction("Structure point cloud");
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(Points::Feature::getClassTypeId());
std::vector<App::DocumentObject*> docObj =
Gui::Selection().getObjectsOfType(Points::Feature::getClassTypeId());
for (auto it : docObj) {
std::string name = it->Label.getValue();
name += " (Structured)";
Points::Structured* output = static_cast<Points::Structured*>(doc->addObject("Points::Structured", name.c_str()));
Points::Structured* output =
static_cast<Points::Structured*>(doc->addObject("Points::Structured", name.c_str()));
output->Label.setValue(name);
// Already sorted, so just make a copy
@@ -398,7 +434,7 @@ void CmdPointsStructure::activated(int iMsg)
const Points::PointKernel& k = input->Points.getValue();
kernel->resize(k.size());
for (std::size_t i=0; i<k.size(); ++i) {
for (std::size_t i = 0; i < k.size(); ++i) {
kernel->setPoint(i, k.getPoint(i));
}
output->Points.finishEditing();
@@ -418,7 +454,7 @@ void CmdPointsStructure::activated(int iMsg)
// Count the number of different x or y values to get the size
std::set<double> countX, countY;
for (std::size_t i=0; i<k.size(); ++i) {
for (std::size_t i = 0; i < k.size(); ++i) {
Base::Vector3d pnt = k.getPoint(i);
countX.insert(pnt.x);
countY.insert(pnt.y);
@@ -433,9 +469,10 @@ void CmdPointsStructure::activated(int iMsg)
// Pre-fill the vector with <nan, nan, nan> points and afterwards replace them
// with valid point coordinates
double nan = std::numeric_limits<double>::quiet_NaN();
std::vector<Base::Vector3d> sortedPoints(width_l * height_l, Base::Vector3d(nan, nan, nan));
std::vector<Base::Vector3d> sortedPoints(width_l * height_l,
Base::Vector3d(nan, nan, nan));
for (std::size_t i=0; i<k.size(); ++i) {
for (std::size_t i = 0; i < k.size(); ++i) {
Base::Vector3d pnt = k.getPoint(i);
double xi = (pnt.x - bbox.MinX) / dx;
double yi = (pnt.y - bbox.MinY) / dy;
@@ -472,7 +509,7 @@ bool CmdPointsStructure::isActive()
void CreatePointsCommands()
{
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
rcCmdMgr.addCommand(new CmdPointsImport());
rcCmdMgr.addCommand(new CmdPointsExport());
rcCmdMgr.addCommand(new CmdPointsTransform());