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

@@ -44,13 +44,15 @@ void loadPointsResource()
Gui::Translator::instance()->refresh();
}
namespace PointsGui {
class Module : public Py::ExtensionModule<Module>
namespace PointsGui
{
class Module: public Py::ExtensionModule<Module>
{
public:
Module() : Py::ExtensionModule<Module>("PointsGui")
Module()
: Py::ExtensionModule<Module>("PointsGui")
{
initialize("This module is the PointsGui module."); // register with Python
initialize("This module is the PointsGui module.");// register with Python
}
};
@@ -59,7 +61,7 @@ PyObject* initModule()
return Base::Interpreter().addModule(new Module);
}
} // namespace PointsGui
}// namespace PointsGui
/* Python entry */
@@ -74,7 +76,7 @@ PyMOD_INIT_FUNC(PointsGui)
try {
Base::Interpreter().loadModule("Points");
}
catch(const Base::Exception& e) {
catch (const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
PyMOD_Return(nullptr);
}
@@ -85,14 +87,15 @@ PyMOD_INIT_FUNC(PointsGui)
// instantiating the commands
CreatePointsCommands();
// clang-format off
PointsGui::ViewProviderPoints ::init();
PointsGui::ViewProviderScattered ::init();
PointsGui::ViewProviderStructured ::init();
PointsGui::ViewProviderPython ::init();
PointsGui::Workbench ::init();
Gui::ViewProviderBuilder::add(
Points::PropertyPointKernel::getClassTypeId(),
PointsGui::ViewProviderPoints::getClassTypeId());
// clang-format on
Gui::ViewProviderBuilder::add(Points::PropertyPointKernel::getClassTypeId(),
PointsGui::ViewProviderPoints::getClassTypeId());
// add resources and reloads the translators
loadPointsResource();

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());

View File

@@ -28,12 +28,12 @@
using namespace PointsGui;
DlgPointsReadImp::DlgPointsReadImp(const char *FileName, QWidget* parent, Qt::WindowFlags fl )
: QDialog( parent, fl )
DlgPointsReadImp::DlgPointsReadImp(const char* FileName, QWidget* parent, Qt::WindowFlags fl)
: QDialog(parent, fl)
, ui(new Ui_DlgPointsRead)
{
ui->setupUi(this);
_FileName = FileName;
ui->setupUi(this);
_FileName = FileName;
}
/*

View File

@@ -23,28 +23,31 @@
#ifndef POINTSGUI_DLGREADPOINTS_H
#define POINTSGUI_DLGREADPOINTS_H
#include <memory>
#include <QDialog>
#include <memory>
namespace PointsGui {
namespace PointsGui
{
class Ui_DlgPointsRead;
/** The points read dialog
*/
class DlgPointsReadImp : public QDialog
class DlgPointsReadImp: public QDialog
{
Q_OBJECT
Q_OBJECT
public:
explicit DlgPointsReadImp(const char *FileName, QWidget* parent = nullptr, Qt::WindowFlags fl = Qt::WindowFlags() );
~DlgPointsReadImp() override;
explicit DlgPointsReadImp(const char* FileName,
QWidget* parent = nullptr,
Qt::WindowFlags fl = Qt::WindowFlags());
~DlgPointsReadImp() override;
private:
std::unique_ptr<Ui_DlgPointsRead> ui;
std::string _FileName;
std::unique_ptr<Ui_DlgPointsRead> ui;
std::string _FileName;
};
} // namespace PointsGui
}// namespace PointsGui
#endif // POINTSGUI_DLGREADPOINTS_H
#endif// POINTSGUI_DLGREADPOINTS_H

View File

@@ -28,30 +28,30 @@
#ifdef _PreComp_
// STL
# include <algorithm>
# include <limits>
# include <memory>
#include <algorithm>
#include <limits>
#include <memory>
// boost
# include <boost/math/special_functions/fpclassify.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
// Qt
# include <QDialog>
# include <QInputDialog>
#include <QDialog>
#include <QInputDialog>
// Inventor
# include <Inventor/SbVec2f.h>
# include <Inventor/errors/SoDebugError.h>
# include <Inventor/events/SoMouseButtonEvent.h>
# include <Inventor/nodes/SoCamera.h>
# include <Inventor/nodes/SoCoordinate3.h>
# include <Inventor/nodes/SoDrawStyle.h>
# include <Inventor/nodes/SoIndexedPointSet.h>
# include <Inventor/nodes/SoMaterial.h>
# include <Inventor/nodes/SoMaterialBinding.h>
# include <Inventor/nodes/SoNormal.h>
# include <Inventor/nodes/SoPointSet.h>
#include <Inventor/SbVec2f.h>
#include <Inventor/errors/SoDebugError.h>
#include <Inventor/events/SoMouseButtonEvent.h>
#include <Inventor/nodes/SoCamera.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoIndexedPointSet.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoMaterialBinding.h>
#include <Inventor/nodes/SoNormal.h>
#include <Inventor/nodes/SoPointSet.h>
#endif //_PreComp_
#endif//_PreComp_
#endif // POINTSGUI_PRECOMPILED_H
#endif// POINTSGUI_PRECOMPILED_H

View File

@@ -22,19 +22,19 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <limits>
# include <boost/math/special_functions/fpclassify.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
#include <limits>
# include <Inventor/errors/SoDebugError.h>
# include <Inventor/events/SoMouseButtonEvent.h>
# include <Inventor/nodes/SoCamera.h>
# include <Inventor/nodes/SoCoordinate3.h>
# include <Inventor/nodes/SoDrawStyle.h>
# include <Inventor/nodes/SoIndexedPointSet.h>
# include <Inventor/nodes/SoMaterial.h>
# include <Inventor/nodes/SoMaterialBinding.h>
# include <Inventor/nodes/SoNormal.h>
# include <Inventor/nodes/SoPointSet.h>
#include <Inventor/errors/SoDebugError.h>
#include <Inventor/events/SoMouseButtonEvent.h>
#include <Inventor/nodes/SoCamera.h>
#include <Inventor/nodes/SoCoordinate3.h>
#include <Inventor/nodes/SoDrawStyle.h>
#include <Inventor/nodes/SoIndexedPointSet.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoMaterialBinding.h>
#include <Inventor/nodes/SoNormal.h>
#include <Inventor/nodes/SoPointSet.h>
#endif
#include <App/Document.h>
@@ -56,11 +56,11 @@ using namespace Points;
PROPERTY_SOURCE_ABSTRACT(PointsGui::ViewProviderPoints, Gui::ViewProviderGeometryObject)
App::PropertyFloatConstraint::Constraints ViewProviderPoints::floatRange = {1.0,64.0,1.0};
App::PropertyFloatConstraint::Constraints ViewProviderPoints::floatRange = {1.0, 64.0, 1.0};
ViewProviderPoints::ViewProviderPoints()
{
static const char *osgroup = "Object Style";
static const char* osgroup = "Object Style";
ADD_PROPERTY_TYPE(PointSize, (2.0f), osgroup, App::Prop_None, "Set point size");
PointSize.setConstraints(&floatRange);
@@ -68,8 +68,9 @@ ViewProviderPoints::ViewProviderPoints()
// Create the selection node
pcHighlight = Gui::ViewProviderBuilder::createSelection();
pcHighlight->ref();
if (pcHighlight->selectionMode.getValue() == Gui::SoFCSelection::SEL_OFF)
if (pcHighlight->selectionMode.getValue() == Gui::SoFCSelection::SEL_OFF) {
Selectable.setValue(false);
}
// BBOX
SelectionStyle.setValue(1);
@@ -102,8 +103,8 @@ void ViewProviderPoints::onChanged(const App::Property* prop)
pcPointStyle->pointSize = PointSize.getValue();
}
else if (prop == &SelectionStyle) {
pcHighlight->style = SelectionStyle.getValue() ? Gui::SoFCSelection::BOX
: Gui::SoFCSelection::EMISSIVE;
pcHighlight->style =
SelectionStyle.getValue() ? Gui::SoFCSelection::BOX : Gui::SoFCSelection::EMISSIVE;
}
else {
ViewProviderGeometryObject::onChanged(prop);
@@ -117,7 +118,7 @@ void ViewProviderPoints::setVertexColorMode(App::PropertyColorList* pcProperty)
pcColorMat->diffuseColor.setNum(val.size());
SbColor* col = pcColorMat->diffuseColor.startEditing();
std::size_t i=0;
std::size_t i = 0;
for (const auto& it : val) {
col[i++].setValue(it.r, it.g, it.b);
}
@@ -132,7 +133,7 @@ void ViewProviderPoints::setVertexGreyvalueMode(Points::PropertyGreyValueList* p
pcColorMat->diffuseColor.setNum(val.size());
SbColor* col = pcColorMat->diffuseColor.startEditing();
std::size_t i=0;
std::size_t i = 0;
for (float it : val) {
col[i++].setValue(it, it, it);
}
@@ -147,7 +148,7 @@ void ViewProviderPoints::setVertexNormalMode(Points::PropertyNormalList* pcPrope
pcPointsNormal->vector.setNum(val.size());
SbVec3f* norm = pcPointsNormal->vector.startEditing();
std::size_t i=0;
std::size_t i = 0;
for (const auto& it : val) {
norm[i++].setValue(it.x, it.y, it.z);
}
@@ -159,17 +160,20 @@ void ViewProviderPoints::setDisplayMode(const char* ModeName)
{
int numPoints = pcPointsCoord->point.getNum();
if (strcmp("Color",ModeName) == 0) {
std::map<std::string,App::Property*> Map;
if (strcmp("Color", ModeName) == 0) {
std::map<std::string, App::Property*> Map;
pcObject->getPropertyMap(Map);
for (auto & it : Map) {
for (auto& it : Map) {
Base::Type type = it.second->getTypeId();
if (type == App::PropertyColorList::getClassTypeId()) {
App::PropertyColorList* colors = static_cast<App::PropertyColorList*>(it.second);
if (numPoints != colors->getSize()) {
#ifdef FC_DEBUG
SoDebugError::postWarning("ViewProviderPoints::setDisplayMode",
"The number of points (%d) doesn't match with the number of colors (%d).", numPoints, colors->getSize());
SoDebugError::postWarning(
"ViewProviderPoints::setDisplayMode",
"The number of points (%d) doesn't match with the number of colors (%d).",
numPoints,
colors->getSize());
#endif
// fallback
setDisplayMaskMode("Point");
@@ -182,17 +186,21 @@ void ViewProviderPoints::setDisplayMode(const char* ModeName)
}
}
}
else if (strcmp("Intensity",ModeName) == 0) {
std::map<std::string,App::Property*> Map;
else if (strcmp("Intensity", ModeName) == 0) {
std::map<std::string, App::Property*> Map;
pcObject->getPropertyMap(Map);
for (const auto& it : Map) {
Base::Type type = it.second->getTypeId();
if (type == Points::PropertyGreyValueList::getClassTypeId()) {
Points::PropertyGreyValueList* greyValues = static_cast<Points::PropertyGreyValueList*>(it.second);
Points::PropertyGreyValueList* greyValues =
static_cast<Points::PropertyGreyValueList*>(it.second);
if (numPoints != greyValues->getSize()) {
#ifdef FC_DEBUG
SoDebugError::postWarning("ViewProviderPoints::setDisplayMode",
"The number of points (%d) doesn't match with the number of grey values (%d).", numPoints, greyValues->getSize());
"The number of points (%d) doesn't match with the "
"number of grey values (%d).",
numPoints,
greyValues->getSize());
#endif
// Intensity mode is not possible then set the default () mode instead.
setDisplayMaskMode("Point");
@@ -205,17 +213,21 @@ void ViewProviderPoints::setDisplayMode(const char* ModeName)
}
}
}
else if (strcmp("Shaded",ModeName) == 0) {
std::map<std::string,App::Property*> Map;
else if (strcmp("Shaded", ModeName) == 0) {
std::map<std::string, App::Property*> Map;
pcObject->getPropertyMap(Map);
for (const auto& it : Map) {
Base::Type type = it.second->getTypeId();
if (type == Points::PropertyNormalList::getClassTypeId()) {
Points::PropertyNormalList* normals = static_cast<Points::PropertyNormalList*>(it.second);
Points::PropertyNormalList* normals =
static_cast<Points::PropertyNormalList*>(it.second);
if (numPoints != normals->getSize()) {
#ifdef FC_DEBUG
SoDebugError::postWarning("ViewProviderPoints::setDisplayMode",
"The number of points (%d) doesn't match with the number of normals (%d).", numPoints, normals->getSize());
SoDebugError::postWarning(
"ViewProviderPoints::setDisplayMode",
"The number of points (%d) doesn't match with the number of normals (%d).",
numPoints,
normals->getSize());
#endif
// fallback
setDisplayMaskMode("Point");
@@ -228,7 +240,7 @@ void ViewProviderPoints::setDisplayMode(const char* ModeName)
}
}
}
else if (strcmp("Points",ModeName) == 0) {
else if (strcmp("Points", ModeName) == 0) {
setDisplayMaskMode("Point");
}
@@ -251,17 +263,21 @@ std::vector<std::string> ViewProviderPoints::getDisplayModes() const
#else
if (pcObject) {
std::map<std::string,App::Property*> Map;
std::map<std::string, App::Property*> Map;
pcObject->getPropertyMap(Map);
for (std::map<std::string,App::Property*>::iterator it = Map.begin(); it != Map.end(); ++it) {
for (std::map<std::string, App::Property*>::iterator it = Map.begin(); it != Map.end();
++it) {
Base::Type type = it->second->getTypeId();
if (type == Points::PropertyNormalList::getClassTypeId())
if (type == Points::PropertyNormalList::getClassTypeId()) {
StrList.push_back("Shaded");
else if (type == Points::PropertyGreyValueList::getClassTypeId())
}
else if (type == Points::PropertyGreyValueList::getClassTypeId()) {
StrList.push_back("Intensity");
else if (type == App::PropertyColorList::getClassTypeId())
}
else if (type == App::PropertyColorList::getClassTypeId()) {
StrList.push_back("Color");
}
}
}
#endif
@@ -271,6 +287,7 @@ std::vector<std::string> ViewProviderPoints::getDisplayModes() const
QIcon ViewProviderPoints::getIcon() const
{
// clang-format off
static const char * const Points_Feature_xpm[] = {
"16 16 4 1",
". c none",
@@ -295,38 +312,45 @@ QIcon ViewProviderPoints::getIcon() const
"rr.......rr..rr."};
QPixmap px(Points_Feature_xpm);
return px;
// clang-format on
}
bool ViewProviderPoints::setEdit(int ModNum)
{
if (ModNum == ViewProvider::Transform)
if (ModNum == ViewProvider::Transform) {
return ViewProviderGeometryObject::setEdit(ModNum);
else if (ModNum == ViewProvider::Cutting)
}
else if (ModNum == ViewProvider::Cutting) {
return true;
}
return false;
}
void ViewProviderPoints::unsetEdit(int ModNum)
{
if (ModNum == ViewProvider::Transform)
if (ModNum == ViewProvider::Transform) {
ViewProviderGeometryObject::unsetEdit(ModNum);
}
}
void ViewProviderPoints::clipPointsCallback(void *, SoEventCallback * n)
void ViewProviderPoints::clipPointsCallback(void*, SoEventCallback* n)
{
// When this callback function is invoked we must in either case leave the edit mode
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
Gui::View3DInventorViewer* view = static_cast<Gui::View3DInventorViewer*>(n->getUserData());
view->setEditing(false);
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), clipPointsCallback);
n->setHandled();
std::vector<SbVec2f> clPoly = view->getGLPolygon();
if (clPoly.size() < 3)
if (clPoly.size() < 3) {
return;
if (clPoly.front() != clPoly.back())
}
if (clPoly.front() != clPoly.back()) {
clPoly.push_back(clPoly.front());
}
std::vector<Gui::ViewProvider*> views = view->getViewProvidersOfType(ViewProviderPoints::getClassTypeId());
std::vector<Gui::ViewProvider*> views =
view->getViewProvidersOfType(ViewProviderPoints::getClassTypeId());
for (auto it : views) {
ViewProviderPoints* that = static_cast<ViewProviderPoints*>(it);
if (that->getEditingMode() > -1) {
@@ -386,8 +410,8 @@ void ViewProviderScattered::attach(App::DocumentObject* pcObj)
}
// color shaded ------------------------------------------
if (std::find(modes.begin(), modes.end(), std::string("Color")) != modes.end() ||
std::find(modes.begin(), modes.end(), std::string("Intensity")) != modes.end()) {
if (std::find(modes.begin(), modes.end(), std::string("Color")) != modes.end()
|| std::find(modes.begin(), modes.end(), std::string("Intensity")) != modes.end()) {
SoGroup* pcColorShadedRoot = new SoGroup();
pcColorShadedRoot->addChild(pcPointStyle);
SoMaterialBinding* pcMatBinding = new SoMaterialBinding;
@@ -420,12 +444,13 @@ void ViewProviderScattered::updateData(const App::Property* prop)
}
}
void ViewProviderScattered::cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer)
void ViewProviderScattered::cut(const std::vector<SbVec2f>& picked,
Gui::View3DInventorViewer& Viewer)
{
// create the polygon from the picked points
Base::Polygon2d cPoly;
for (const auto& it : picked) {
cPoly.Add(Base::Vector2d(it[0],it[1]));
cPoly.Add(Base::Vector2d(it[0], it[1]));
}
// get a reference to the point feature
@@ -433,32 +458,36 @@ void ViewProviderScattered::cut(const std::vector<SbVec2f>& picked, Gui::View3DI
const Points::PointKernel& points = fea->Points.getValue();
SoCamera* pCam = Viewer.getSoRenderManager()->getCamera();
SbViewVolume vol = pCam->getViewVolume();
SbViewVolume vol = pCam->getViewVolume();
// search for all points inside/outside the polygon
std::vector<unsigned long> removeIndices;
removeIndices.reserve(points.size());
unsigned long index = 0;
for (Points::PointKernel::const_iterator jt = points.begin(); jt != points.end(); ++jt, ++index) {
SbVec3f pt(jt->x,jt->y,jt->z);
for (Points::PointKernel::const_iterator jt = points.begin(); jt != points.end();
++jt, ++index) {
SbVec3f pt(jt->x, jt->y, jt->z);
// project from 3d to 2d
vol.projectToScreen(pt, pt);
if (cPoly.Contains(Base::Vector2d(pt[0],pt[1])))
if (cPoly.Contains(Base::Vector2d(pt[0], pt[1]))) {
removeIndices.push_back(index);
}
}
if (removeIndices.empty())
return; // nothing needs to be done
if (removeIndices.empty()) {
return;// nothing needs to be done
}
//Remove the points from the cloud and open a transaction object for the undo/redo stuff
Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Cut points"));
// Remove the points from the cloud and open a transaction object for the undo/redo stuff
Gui::Application::Instance->activeDocument()->openCommand(
QT_TRANSLATE_NOOP("Command", "Cut points"));
// sets the points outside the polygon to update the Inventor node
fea->Points.removeIndices(removeIndices);
std::map<std::string,App::Property*> Map;
std::map<std::string, App::Property*> Map;
pcObject->getPropertyMap(Map);
for (const auto& it : Map) {
@@ -470,24 +499,30 @@ void ViewProviderScattered::cut(const std::vector<SbVec2f>& picked, Gui::View3DI
static_cast<Points::PropertyGreyValueList*>(it.second)->removeIndices(removeIndices);
}
else if (type == App::PropertyColorList::getClassTypeId()) {
//static_cast<App::PropertyColorList*>(it->second)->removeIndices(removeIndices);
const std::vector<App::Color>& colors = static_cast<App::PropertyColorList*>(it.second)->getValues();
// static_cast<App::PropertyColorList*>(it->second)->removeIndices(removeIndices);
const std::vector<App::Color>& colors =
static_cast<App::PropertyColorList*>(it.second)->getValues();
if (removeIndices.size() > colors.size())
if (removeIndices.size() > colors.size()) {
break;
}
std::vector<App::Color> remainValue;
remainValue.reserve(colors.size() - removeIndices.size());
std::vector<unsigned long>::iterator pos = removeIndices.begin();
for (std::vector<App::Color>::const_iterator jt = colors.begin(); jt != colors.end(); ++jt) {
for (std::vector<App::Color>::const_iterator jt = colors.begin(); jt != colors.end();
++jt) {
unsigned long index = jt - colors.begin();
if (pos == removeIndices.end())
remainValue.push_back( *jt );
else if (index != *pos)
remainValue.push_back( *jt );
else
if (pos == removeIndices.end()) {
remainValue.push_back(*jt);
}
else if (index != *pos) {
remainValue.push_back(*jt);
}
else {
++pos;
}
}
static_cast<App::PropertyColorList*>(it.second)->setValues(remainValue);
@@ -547,8 +582,8 @@ void ViewProviderStructured::attach(App::DocumentObject* pcObj)
}
// color shaded ------------------------------------------
if (std::find(modes.begin(), modes.end(), std::string("Color")) != modes.end() ||
std::find(modes.begin(), modes.end(), std::string("Intensity")) != modes.end()) {
if (std::find(modes.begin(), modes.end(), std::string("Color")) != modes.end()
|| std::find(modes.begin(), modes.end(), std::string("Intensity")) != modes.end()) {
SoGroup* pcColorShadedRoot = new SoGroup();
pcColorShadedRoot->addChild(pcPointStyle);
SoMaterialBinding* pcMatBinding = new SoMaterialBinding;
@@ -572,12 +607,13 @@ void ViewProviderStructured::updateData(const App::Property* prop)
}
}
void ViewProviderStructured::cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer)
void ViewProviderStructured::cut(const std::vector<SbVec2f>& picked,
Gui::View3DInventorViewer& Viewer)
{
// create the polygon from the picked points
Base::Polygon2d cPoly;
for (const auto& it : picked) {
cPoly.Add(Base::Vector2d(it[0],it[1]));
cPoly.Add(Base::Vector2d(it[0], it[1]));
}
// get a reference to the point feature
@@ -585,7 +621,7 @@ void ViewProviderStructured::cut(const std::vector<SbVec2f>& picked, Gui::View3D
const Points::PointKernel& points = fea->Points.getValue();
SoCamera* pCam = Viewer.getSoRenderManager()->getCamera();
SbViewVolume vol = pCam->getViewVolume();
SbViewVolume vol = pCam->getViewVolume();
// search for all points inside/outside the polygon
Points::PointKernel newKernel;
@@ -593,15 +629,16 @@ void ViewProviderStructured::cut(const std::vector<SbVec2f>& picked, Gui::View3D
bool invalidatePoints = false;
double nan = std::numeric_limits<double>::quiet_NaN();
for (const auto & point : points) {
for (const auto& point : points) {
// valid point?
Base::Vector3d vec(point);
if (!(boost::math::isnan(point.x) || boost::math::isnan(point.y) || boost::math::isnan(point.z))) {
SbVec3f pt(point.x,point.y,point.z);
if (!(boost::math::isnan(point.x) || boost::math::isnan(point.y)
|| boost::math::isnan(point.z))) {
SbVec3f pt(point.x, point.y, point.z);
// project from 3d to 2d
vol.projectToScreen(pt, pt);
if (cPoly.Contains(Base::Vector2d(pt[0],pt[1]))) {
if (cPoly.Contains(Base::Vector2d(pt[0], pt[1]))) {
invalidatePoints = true;
vec.Set(nan, nan, nan);
}
@@ -611,8 +648,9 @@ void ViewProviderStructured::cut(const std::vector<SbVec2f>& picked, Gui::View3D
}
if (invalidatePoints) {
//Remove the points from the cloud and open a transaction object for the undo/redo stuff
Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Cut points"));
// Remove the points from the cloud and open a transaction object for the undo/redo stuff
Gui::Application::Instance->activeDocument()->openCommand(
QT_TRANSLATE_NOOP("Command", "Cut points"));
// sets the points outside the polygon to update the Inventor node
fea->Points.setValue(newKernel);
@@ -625,21 +663,23 @@ void ViewProviderStructured::cut(const std::vector<SbVec2f>& picked, Gui::View3D
// -------------------------------------------------
namespace Gui {
namespace Gui
{
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(PointsGui::ViewProviderPython, PointsGui::ViewProviderScattered)
/// @endcond
// explicit template instantiation
template class PointsGuiExport ViewProviderPythonFeatureT<PointsGui::ViewProviderScattered>;
}
}// namespace Gui
// -------------------------------------------------
void ViewProviderPointsBuilder::buildNodes(const App::Property* prop, std::vector<SoNode*>& nodes) const
void ViewProviderPointsBuilder::buildNodes(const App::Property* prop,
std::vector<SoNode*>& nodes) const
{
SoCoordinate3 *pcPointsCoord=nullptr;
SoPointSet *pcPoints=nullptr;
SoCoordinate3* pcPointsCoord = nullptr;
SoPointSet* pcPoints = nullptr;
if (nodes.empty()) {
pcPointsCoord = new SoCoordinate3();
@@ -648,28 +688,36 @@ void ViewProviderPointsBuilder::buildNodes(const App::Property* prop, std::vecto
nodes.push_back(pcPoints);
}
else if (nodes.size() == 2) {
if (nodes[0]->getTypeId() == SoCoordinate3::getClassTypeId())
if (nodes[0]->getTypeId() == SoCoordinate3::getClassTypeId()) {
pcPointsCoord = static_cast<SoCoordinate3*>(nodes[0]);
if (nodes[1]->getTypeId() == SoPointSet::getClassTypeId())
}
if (nodes[1]->getTypeId() == SoPointSet::getClassTypeId()) {
pcPoints = static_cast<SoPointSet*>(nodes[1]);
}
}
if (pcPointsCoord && pcPoints)
if (pcPointsCoord && pcPoints) {
createPoints(prop, pcPointsCoord, pcPoints);
}
}
void ViewProviderPointsBuilder::createPoints(const App::Property* prop, SoCoordinate3* coords, SoPointSet* points) const
void ViewProviderPointsBuilder::createPoints(const App::Property* prop,
SoCoordinate3* coords,
SoPointSet* points) const
{
const Points::PropertyPointKernel* prop_points = static_cast<const Points::PropertyPointKernel*>(prop);
const Points::PropertyPointKernel* prop_points =
static_cast<const Points::PropertyPointKernel*>(prop);
const Points::PointKernel& cPts = prop_points->getValue();
coords->point.setNum(cPts.size());
SbVec3f* vec = coords->point.startEditing();
// get all points
std::size_t idx=0;
std::size_t idx = 0;
const std::vector<Points::PointKernel::value_type>& kernel = cPts.getBasicPoints();
for (std::vector<Points::PointKernel::value_type>::const_iterator it = kernel.begin(); it != kernel.end(); ++it, idx++) {
for (std::vector<Points::PointKernel::value_type>::const_iterator it = kernel.begin();
it != kernel.end();
++it, idx++) {
vec[idx].setValue(it->x, it->y, it->z);
}
@@ -677,30 +725,36 @@ void ViewProviderPointsBuilder::createPoints(const App::Property* prop, SoCoordi
coords->point.finishEditing();
}
void ViewProviderPointsBuilder::createPoints(const App::Property* prop, SoCoordinate3* coords, SoIndexedPointSet* points) const
void ViewProviderPointsBuilder::createPoints(const App::Property* prop,
SoCoordinate3* coords,
SoIndexedPointSet* points) const
{
const Points::PropertyPointKernel* prop_points = static_cast<const Points::PropertyPointKernel*>(prop);
const Points::PropertyPointKernel* prop_points =
static_cast<const Points::PropertyPointKernel*>(prop);
const Points::PointKernel& cPts = prop_points->getValue();
coords->point.setNum(cPts.size());
SbVec3f* vec = coords->point.startEditing();
// get all points
std::size_t idx=0;
std::size_t idx = 0;
std::vector<int32_t> indices;
indices.reserve(cPts.size());
const std::vector<Points::PointKernel::value_type>& kernel = cPts.getBasicPoints();
for (std::vector<Points::PointKernel::value_type>::const_iterator it = kernel.begin(); it != kernel.end(); ++it, idx++) {
for (std::vector<Points::PointKernel::value_type>::const_iterator it = kernel.begin();
it != kernel.end();
++it, idx++) {
vec[idx].setValue(it->x, it->y, it->z);
// valid point?
if (!(boost::math::isnan(it->x) || boost::math::isnan(it->y) || boost::math::isnan(it->z))) {
if (!(boost::math::isnan(it->x) || boost::math::isnan(it->y)
|| boost::math::isnan(it->z))) {
indices.push_back(idx);
}
}
coords->point.finishEditing();
// get all point indices
idx=0;
idx = 0;
points->coordIndex.setNum(indices.size());
int32_t* pos = points->coordIndex.startEditing();
for (int32_t index : indices) {

View File

@@ -39,24 +39,28 @@ class SoCoordinate3;
class SoNormal;
class SoEventCallback;
namespace App {
class PropertyColorList;
namespace App
{
class PropertyColorList;
}
namespace Gui {
class SoFCSelection;
namespace Gui
{
class SoFCSelection;
}
namespace Points {
class PropertyGreyValueList;
class PropertyNormalList;
class PointKernel;
class Feature;
}
namespace Points
{
class PropertyGreyValueList;
class PropertyNormalList;
class PointKernel;
class Feature;
}// namespace Points
namespace PointsGui {
namespace PointsGui
{
class ViewProviderPointsBuilder : public Gui::ViewProviderBuilder
class ViewProviderPointsBuilder: public Gui::ViewProviderBuilder
{
public:
ViewProviderPointsBuilder() = default;
@@ -71,7 +75,7 @@ public:
* a node representing the point data structure.
* @author Werner Mayer
*/
class PointsGuiExport ViewProviderPoints : public Gui::ViewProviderGeometryObject
class PointsGuiExport ViewProviderPoints: public Gui::ViewProviderGeometryObject
{
PROPERTY_HEADER_WITH_OVERRIDE(PointsGui::ViewProviderPoints);
@@ -93,21 +97,21 @@ public:
void unsetEdit(int ModNum) override;
public:
static void clipPointsCallback(void * ud, SoEventCallback * n);
static void clipPointsCallback(void* ud, SoEventCallback* n);
protected:
void onChanged(const App::Property* prop) override;
void setVertexColorMode(App::PropertyColorList*);
void setVertexGreyvalueMode(Points::PropertyGreyValueList*);
void setVertexNormalMode(Points::PropertyNormalList*);
virtual void cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer) = 0;
virtual void cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer& Viewer) = 0;
protected:
Gui::SoFCSelection * pcHighlight;
SoCoordinate3 * pcPointsCoord;
SoMaterial * pcColorMat;
SoNormal * pcPointsNormal;
SoDrawStyle * pcPointStyle;
Gui::SoFCSelection* pcHighlight;
SoCoordinate3* pcPointsCoord;
SoMaterial* pcColorMat;
SoNormal* pcPointsNormal;
SoDrawStyle* pcPointStyle;
private:
static App::PropertyFloatConstraint::Constraints floatRange;
@@ -118,7 +122,7 @@ private:
* a node representing the scattered point cloud.
* @author Werner Mayer
*/
class PointsGuiExport ViewProviderScattered : public ViewProviderPoints
class PointsGuiExport ViewProviderScattered: public ViewProviderPoints
{
PROPERTY_HEADER_WITH_OVERRIDE(PointsGui::ViewProviderScattered);
@@ -130,15 +134,15 @@ public:
* Extracts the point data from the feature \a pcFeature and creates
* an Inventor node \a SoNode with these data.
*/
void attach(App::DocumentObject *) override;
void attach(App::DocumentObject*) override;
/// Update the point representation
void updateData(const App::Property*) override;
protected:
void cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer) override;
void cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer& Viewer) override;
protected:
SoPointSet * pcPoints;
SoPointSet* pcPoints;
};
/**
@@ -146,7 +150,7 @@ protected:
* a node representing the structured points.
* @author Werner Mayer
*/
class PointsGuiExport ViewProviderStructured : public ViewProviderPoints
class PointsGuiExport ViewProviderStructured: public ViewProviderPoints
{
PROPERTY_HEADER_WITH_OVERRIDE(PointsGui::ViewProviderStructured);
@@ -158,21 +162,20 @@ public:
* Extracts the point data from the feature \a pcFeature and creates
* an Inventor node \a SoNode with these data.
*/
void attach(App::DocumentObject *) override;
void attach(App::DocumentObject*) override;
/// Update the point representation
void updateData(const App::Property*) override;
protected:
void cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer) override;
void cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer& Viewer) override;
protected:
SoIndexedPointSet * pcPoints;
SoIndexedPointSet* pcPoints;
};
using ViewProviderPython = Gui::ViewProviderPythonFeatureT<ViewProviderScattered>;
} // namespace PointsGui
}// namespace PointsGui
#endif // POINTSGUI_VIEWPROVIDERPOINTS_H
#endif// POINTSGUI_VIEWPROVIDERPOINTS_H

View File

@@ -30,7 +30,7 @@
using namespace PointsGui;
#if 0 // needed for Qt's lupdate utility
#if 0// needed for Qt's lupdate utility
qApp->translate("Workbench", "Points tools");
qApp->translate("Workbench", "&Points");
#endif
@@ -45,7 +45,7 @@ Workbench::~Workbench() = default;
Gui::ToolBarItem* Workbench::setupToolBars() const
{
Gui::ToolBarItem* root = StdWorkbench::setupToolBars();
Gui::ToolBarItem* pnt = new Gui::ToolBarItem( root );
Gui::ToolBarItem* pnt = new Gui::ToolBarItem(root);
pnt->setCommand("Points tools");
*pnt << "Points_Import"
<< "Points_Export"
@@ -61,7 +61,7 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
{
// point tools
Gui::ToolBarItem* root = new Gui::ToolBarItem;
Gui::ToolBarItem* pnt = new Gui::ToolBarItem( root );
Gui::ToolBarItem* pnt = new Gui::ToolBarItem(root);
pnt->setCommand("Points tools");
*pnt << "Points_Import"
<< "Points_Export"

View File

@@ -27,26 +27,27 @@
#include <Gui/Workbench.h>
#include <Mod/Points/PointsGlobal.h>
namespace PointsGui {
namespace PointsGui
{
/**
* @author Werner Mayer
*/
class PointsGuiExport Workbench : public Gui::StdWorkbench
class PointsGuiExport Workbench: public Gui::StdWorkbench
{
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
Workbench();
~Workbench() override;
Workbench();
~Workbench() override;
protected:
Gui::ToolBarItem* setupToolBars() const override;
Gui::ToolBarItem* setupCommandBars() const override;
Gui::MenuItem* setupMenuBar() const override;
Gui::ToolBarItem* setupToolBars() const override;
Gui::ToolBarItem* setupCommandBars() const override;
Gui::MenuItem* setupMenuBar() const override;
};
} // namespace PointsGui
}// namespace PointsGui
#endif // POINTS_WORKBENCH_H
#endif// POINTS_WORKBENCH_H