From a3209e1aee00730d13359eeed595cb93b6b127f9 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 21 Feb 2016 16:18:28 +0100 Subject: [PATCH] + do some code cleanup and renaming in Points module --- src/Mod/Points/App/AppPoints.cpp | 7 ++-- src/Mod/Points/App/AppPointsPy.cpp | 14 +++---- src/Mod/Points/App/CMakeLists.txt | 4 +- src/Mod/Points/App/PointsAlgos.cpp | 2 +- src/Mod/Points/App/PointsAlgos.h | 2 +- src/Mod/Points/App/PointsFeature.cpp | 23 ----------- src/Mod/Points/App/PointsFeature.h | 24 ----------- .../App/{ViewFeature.cpp => Structured.cpp} | 40 ++++++++++++------- .../App/{ViewFeature.h => Structured.h} | 26 +++++++----- src/Mod/Points/Gui/AppPointsGui.cpp | 2 +- src/Mod/Points/Gui/ViewProvider.cpp | 12 +++--- src/Mod/Points/Gui/ViewProvider.h | 12 +++--- src/Mod/ReverseEngineering/Gui/Command.cpp | 12 +++--- 13 files changed, 76 insertions(+), 104 deletions(-) rename src/Mod/Points/App/{ViewFeature.cpp => Structured.cpp} (72%) rename src/Mod/Points/App/{ViewFeature.h => Structured.h} (75%) diff --git a/src/Mod/Points/App/AppPoints.cpp b/src/Mod/Points/App/AppPoints.cpp index 2fddf9af9..99b69cab0 100644 --- a/src/Mod/Points/App/AppPoints.cpp +++ b/src/Mod/Points/App/AppPoints.cpp @@ -33,7 +33,7 @@ #include "PointsPy.h" #include "Properties.h" #include "PropertyPointKernel.h" -#include "ViewFeature.h" +#include "Structured.h" namespace Points { extern PyObject* initModule(); @@ -57,9 +57,8 @@ PyMODINIT_FUNC initPoints() // add data types Points::Feature ::init(); - Points::Organized ::init(); + Points::Structured ::init(); Points::FeatureCustom ::init(); - Points::OrganizedCustom ::init(); + Points::StructuredCustom ::init(); Points::FeaturePython ::init(); - Points::ViewFeature ::init(); } diff --git a/src/Mod/Points/App/AppPointsPy.cpp b/src/Mod/Points/App/AppPointsPy.cpp index a46e2ccae..fc42d2a01 100644 --- a/src/Mod/Points/App/AppPointsPy.cpp +++ b/src/Mod/Points/App/AppPointsPy.cpp @@ -48,7 +48,7 @@ #include "Points.h" #include "PointsPy.h" #include "PointsAlgos.h" -#include "PointsFeature.h" +#include "Structured.h" #include "Properties.h" namespace Points { @@ -107,9 +107,9 @@ private: Points::Feature *pcFeature = 0; if (reader->hasProperties()) { - // is organized in a grid structure? - if (reader->isOrganized()) { - pcFeature = new Points::OrganizedCustom(); + // Scattered or structured points? + if (reader->isStructured()) { + pcFeature = new Points::StructuredCustom(); App::PropertyInteger* width = static_cast (pcFeature->getPropertyByName("Width")); @@ -214,9 +214,9 @@ private: Points::Feature *pcFeature = 0; if (reader->hasProperties()) { - // is organized in a grid structure? - if (reader->isOrganized()) { - pcFeature = new Points::OrganizedCustom(); + // Scattered or structured points? + if (reader->isStructured()) { + pcFeature = new Points::StructuredCustom(); App::PropertyInteger* width = static_cast (pcFeature->getPropertyByName("Width")); diff --git a/src/Mod/Points/App/CMakeLists.txt b/src/Mod/Points/App/CMakeLists.txt index d0c4a25a5..79a3ca085 100644 --- a/src/Mod/Points/App/CMakeLists.txt +++ b/src/Mod/Points/App/CMakeLists.txt @@ -47,8 +47,8 @@ SET(Points_SRCS Properties.h PropertyPointKernel.cpp PropertyPointKernel.h - ViewFeature.cpp - ViewFeature.h + Structured.cpp + Structured.h ) add_library(Points SHARED ${Points_SRCS}) diff --git a/src/Mod/Points/App/PointsAlgos.cpp b/src/Mod/Points/App/PointsAlgos.cpp index 5998eef1b..bc139b829 100644 --- a/src/Mod/Points/App/PointsAlgos.cpp +++ b/src/Mod/Points/App/PointsAlgos.cpp @@ -177,7 +177,7 @@ bool Reader::hasNormals() const return (!normals.empty()); } -bool Reader::isOrganized() const +bool Reader::isStructured() const { return (width > 1 && height > 1); } diff --git a/src/Mod/Points/App/PointsAlgos.h b/src/Mod/Points/App/PointsAlgos.h index dd62cc593..a6843e290 100644 --- a/src/Mod/Points/App/PointsAlgos.h +++ b/src/Mod/Points/App/PointsAlgos.h @@ -59,7 +59,7 @@ public: bool hasColors() const; const std::vector& getNormals() const; bool hasNormals() const; - bool isOrganized() const; + bool isStructured() const; int getWidth() const; int getHeight() const; diff --git a/src/Mod/Points/App/PointsFeature.cpp b/src/Mod/Points/App/PointsFeature.cpp index dc1a06b46..af616a2b2 100644 --- a/src/Mod/Points/App/PointsFeature.cpp +++ b/src/Mod/Points/App/PointsFeature.cpp @@ -96,20 +96,6 @@ void Feature::onChanged(const App::Property* prop) // --------------------------------------------------------- -PROPERTY_SOURCE(Points::Organized, Points::Feature) - -Organized::Organized() -{ - ADD_PROPERTY_TYPE(Width,(1),"Organized points",App::Prop_ReadOnly,"Width of the frame"); - ADD_PROPERTY_TYPE(Height,(1),"Organized points",App::Prop_ReadOnly,"Height of the frame"); -} - -Organized::~Organized() -{ -} - -// --------------------------------------------------------- - namespace App { /// @cond DOXERR PROPERTY_SOURCE_TEMPLATE(Points::FeatureCustom, Points::Feature) @@ -119,15 +105,6 @@ PROPERTY_SOURCE_TEMPLATE(Points::FeatureCustom, Points::Feature) template class PointsExport FeatureCustomT; } -namespace App { -/// @cond DOXERR -PROPERTY_SOURCE_TEMPLATE(Points::OrganizedCustom, Points::Organized) -/// @endcond - -// explicit template instantiation -template class PointsExport FeatureCustomT; -} - // --------------------------------------------------------- namespace App { diff --git a/src/Mod/Points/App/PointsFeature.h b/src/Mod/Points/App/PointsFeature.h index e643d176a..763341ad5 100644 --- a/src/Mod/Points/App/PointsFeature.h +++ b/src/Mod/Points/App/PointsFeature.h @@ -77,31 +77,7 @@ public: PropertyPointKernel Points; /**< The point kernel property. */ }; -/** Feature for organized points. - */ -class PointsExport Organized : public Feature -{ - PROPERTY_HEADER(Points::Organized); - -public: - /// Constructor - Organized(void); - virtual ~Organized(void); - - App::PropertyInteger Width; - App::PropertyInteger Height; - - /** @name methods overide Feature */ - //@{ - /// returns the type name of the ViewProvider - virtual const char* getViewProviderName(void) const { - return "PointsGui::ViewProviderOrganized"; - } - //@} -}; - typedef App::FeatureCustomT FeatureCustom; -typedef App::FeatureCustomT OrganizedCustom; typedef App::FeaturePythonT FeaturePython; } //namespace Points diff --git a/src/Mod/Points/App/ViewFeature.cpp b/src/Mod/Points/App/Structured.cpp similarity index 72% rename from src/Mod/Points/App/ViewFeature.cpp rename to src/Mod/Points/App/Structured.cpp index 4004e5013..00ca45dc8 100644 --- a/src/Mod/Points/App/ViewFeature.cpp +++ b/src/Mod/Points/App/Structured.cpp @@ -32,13 +32,13 @@ #include -#include "ViewFeature.h" +#include "Structured.h" using namespace Points; //=========================================================================== -// ViewFeature +// Structured //=========================================================================== /* import Points @@ -55,30 +55,31 @@ for i in range(21): p.addPoints(pts) doc=App.ActiveDocument -pts=doc.addObject('Points::ViewFeature','View') +pts=doc.addObject('Points::Structured','View') pts.Points=p pts.Width=21 pts.Height=21 */ -PROPERTY_SOURCE(Points::ViewFeature, Points::Feature) +// --------------------------------------------------------- -ViewFeature::ViewFeature() +PROPERTY_SOURCE(Points::Structured, Points::Feature) + +Structured::Structured() { - App::PropertyType type = static_cast(App::Prop_None); - ADD_PROPERTY_TYPE(Width ,(0), "View", type, "The width of the point view"); - ADD_PROPERTY_TYPE(Height,(0), "View", type, "The height of the point view"); - ADD_PROPERTY_TYPE(Direction ,(Base::Vector3d(0,0,1)), "View", type, "The direction of the point view"); - - Width.setStatus(App::Property::ReadOnly, true); - Height.setStatus(App::Property::ReadOnly, true); +// App::PropertyType type = static_cast(App::Prop_None); + App::PropertyType type = static_cast(App::Prop_ReadOnly); + ADD_PROPERTY_TYPE(Width,(1),"Structured points", type, "Width of the image"); + ADD_PROPERTY_TYPE(Height,(1),"Structured points", type, "Height of the image"); + //Width.setStatus(App::Property::ReadOnly, true); + //Height.setStatus(App::Property::ReadOnly, true); } -ViewFeature::~ViewFeature() +Structured::~Structured() { } -App::DocumentObjectExecReturn *ViewFeature::execute(void) +App::DocumentObjectExecReturn *Structured::execute(void) { std::size_t size = Height.getValue() * Width.getValue(); if (size != Points.getValue().size()) @@ -86,3 +87,14 @@ App::DocumentObjectExecReturn *ViewFeature::execute(void) this->Points.touch(); return App::DocumentObject::StdReturn; } + +// --------------------------------------------------------- + +namespace App { +/// @cond DOXERR +PROPERTY_SOURCE_TEMPLATE(Points::StructuredCustom, Points::Structured) +/// @endcond + +// explicit template instantiation +template class PointsExport FeatureCustomT; +} diff --git a/src/Mod/Points/App/ViewFeature.h b/src/Mod/Points/App/Structured.h similarity index 75% rename from src/Mod/Points/App/ViewFeature.h rename to src/Mod/Points/App/Structured.h index a49e65bb6..d8f61f717 100644 --- a/src/Mod/Points/App/ViewFeature.h +++ b/src/Mod/Points/App/Structured.h @@ -30,27 +30,35 @@ namespace Points { -/*! For the ViewFeature class it is expected that the Point property has Width*Height vertices +/*! For the Structured class it is expected that the Point property has Width*Height vertices and that with respect to their x,y coordinates they are ordered in a grid structure. If a point is marked invalid then one of its coordinates is set to NaN. */ -class PointsExport ViewFeature : public Points::Feature +class PointsExport Structured : public Feature { - PROPERTY_HEADER(Points::ViewFeature); + PROPERTY_HEADER(Points::Structured); public: /// Constructor - ViewFeature(void); - virtual ~ViewFeature(void); + Structured(void); + virtual ~Structured(void); + + App::PropertyInteger Width; /**< The width of the structured cloud. */ + App::PropertyInteger Height; /**< The height of the structured cloud. */ + + /** @name methods overide Feature */ + //@{ /// recalculate the Feature virtual App::DocumentObjectExecReturn *execute(void); + /// returns the type name of the ViewProvider + virtual const char* getViewProviderName(void) const { + return "PointsGui::ViewProviderStructured"; + } //@} - - App::PropertyInteger Width; /**< The width of the view. */ - App::PropertyInteger Height; /**< The height of the view. */ - App::PropertyVector Direction; /**< The direction of the view. */ }; +typedef App::FeatureCustomT StructuredCustom; + } //namespace Points diff --git a/src/Mod/Points/Gui/AppPointsGui.cpp b/src/Mod/Points/Gui/AppPointsGui.cpp index 17d689d91..610119218 100644 --- a/src/Mod/Points/Gui/AppPointsGui.cpp +++ b/src/Mod/Points/Gui/AppPointsGui.cpp @@ -89,7 +89,7 @@ PyMODINIT_FUNC initPointsGui() PointsGui::ViewProviderPoints ::init(); PointsGui::ViewProviderScattered ::init(); - PointsGui::ViewProviderOrganized ::init(); + PointsGui::ViewProviderStructured ::init(); PointsGui::ViewProviderPython ::init(); PointsGui::Workbench ::init(); Gui::ViewProviderBuilder::add( diff --git a/src/Mod/Points/Gui/ViewProvider.cpp b/src/Mod/Points/Gui/ViewProvider.cpp index dc620f52c..a3d35e0fc 100644 --- a/src/Mod/Points/Gui/ViewProvider.cpp +++ b/src/Mod/Points/Gui/ViewProvider.cpp @@ -472,20 +472,20 @@ void ViewProviderScattered::cut(const std::vector& picked, Gui::View3DI // ------------------------------------------------- -PROPERTY_SOURCE(PointsGui::ViewProviderOrganized, PointsGui::ViewProviderPoints) +PROPERTY_SOURCE(PointsGui::ViewProviderStructured, PointsGui::ViewProviderPoints) -ViewProviderOrganized::ViewProviderOrganized() +ViewProviderStructured::ViewProviderStructured() { pcPoints = new SoIndexedPointSet(); pcPoints->ref(); } -ViewProviderOrganized::~ViewProviderOrganized() +ViewProviderStructured::~ViewProviderStructured() { pcPoints->unref(); } -void ViewProviderOrganized::attach(App::DocumentObject* pcObj) +void ViewProviderStructured::attach(App::DocumentObject* pcObj) { // call parent's attach to define display modes ViewProviderGeometryObject::attach(pcObj); @@ -531,7 +531,7 @@ void ViewProviderOrganized::attach(App::DocumentObject* pcObj) } } -void ViewProviderOrganized::updateData(const App::Property* prop) +void ViewProviderStructured::updateData(const App::Property* prop) { ViewProviderPoints::updateData(prop); if (prop->getTypeId() == Points::PropertyPointKernel::getClassTypeId()) { @@ -543,7 +543,7 @@ void ViewProviderOrganized::updateData(const App::Property* prop) } } -void ViewProviderOrganized::cut(const std::vector& picked, Gui::View3DInventorViewer &Viewer) +void ViewProviderStructured::cut(const std::vector& picked, Gui::View3DInventorViewer &Viewer) { // create the polygon from the picked points Base::Polygon2D cPoly; diff --git a/src/Mod/Points/Gui/ViewProvider.h b/src/Mod/Points/Gui/ViewProvider.h index ec82604f8..52fc7f72d 100644 --- a/src/Mod/Points/Gui/ViewProvider.h +++ b/src/Mod/Points/Gui/ViewProvider.h @@ -142,17 +142,17 @@ protected: }; /** - * The ViewProviderOrganized class creates - * a node representing the organized points. + * The ViewProviderStructured class creates + * a node representing the structured points. * @author Werner Mayer */ -class PointsGuiExport ViewProviderOrganized : public ViewProviderPoints +class PointsGuiExport ViewProviderStructured : public ViewProviderPoints { - PROPERTY_HEADER(PointsGui::ViewProviderOrganized); + PROPERTY_HEADER(PointsGui::ViewProviderStructured); public: - ViewProviderOrganized(); - virtual ~ViewProviderOrganized(); + ViewProviderStructured(); + virtual ~ViewProviderStructured(); /** * Extracts the point data from the feature \a pcFeature and creates diff --git a/src/Mod/ReverseEngineering/Gui/Command.cpp b/src/Mod/ReverseEngineering/Gui/Command.cpp index 1e5143560..db268810e 100644 --- a/src/Mod/ReverseEngineering/Gui/Command.cpp +++ b/src/Mod/ReverseEngineering/Gui/Command.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include @@ -221,15 +221,15 @@ CmdViewTriangulation::CmdViewTriangulation() { sAppModule = "Reen"; sGroup = QT_TR_NOOP("Reverse Engineering"); - sMenuText = QT_TR_NOOP("View triangulation"); - sToolTipText = QT_TR_NOOP("View triangulation"); - sToolTipText = QT_TR_NOOP("View triangulation"); + sMenuText = QT_TR_NOOP("Structured point clouds"); + sToolTipText = QT_TR_NOOP("Triangulation of structured point clouds"); + sToolTipText = QT_TR_NOOP("Triangulation of structured point clouds"); sWhatsThis = "Reen_ViewTriangulation"; } void CmdViewTriangulation::activated(int iMsg) { - std::vector obj = Gui::Selection().getObjectsOfType(Points::ViewFeature::getClassTypeId()); + std::vector obj = Gui::Selection().getObjectsOfType(Points::Structured::getClassTypeId()); addModule(App,"ReverseEngineering"); openCommand("View triangulation"); try { @@ -263,7 +263,7 @@ void CmdViewTriangulation::activated(int iMsg) bool CmdViewTriangulation::isActive(void) { - return Gui::Selection().countObjectsOfType(Points::ViewFeature::getClassTypeId()) > 0; + return (Gui::Selection().countObjectsOfType(Points::Structured::getClassTypeId()) > 0); } void CreateReverseEngineeringCommands(void)