Path: modernize C++: use override

This commit is contained in:
wmayer
2023-08-04 00:21:30 +02:00
committed by wwmayer
parent ec0c7ab835
commit 4366128cc4
16 changed files with 129 additions and 124 deletions

View File

@@ -29,28 +29,29 @@
#include <Base/Persistence.h>
#include <Base/Placement.h>
#include <Base/Vector3D.h>
#include <Mod/Path/PathGlobal.h>
namespace Path
{
/** The representation of a cnc command in a path */
class PathExport Command : public Base::Persistence
{
TYPESYSTEM_HEADER();
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
//constructors
Command();
Command(const char* name,
const std::map<std::string,double>& parameters);
~Command();
~Command() override;
// from base class
virtual unsigned int getMemSize (void) const;
virtual void Save (Base::Writer &/*writer*/) const;
virtual void Restore(Base::XMLReader &/*reader*/);
unsigned int getMemSize () const override;
void Save (Base::Writer &/*writer*/) const override;
void Restore(Base::XMLReader &/*reader*/) override;
// specific methods
Base::Placement getPlacement (const Base::Vector3d pos = Base::Vector3d()) const; // returns a placement from the x,y,z,a,b,c parameters
Base::Vector3d getCenter (void) const; // returns a 3d vector from the i,j,k parameters
Base::Vector3d getCenter () const; // returns a 3d vector from the i,j,k parameters
void setCenter(const Base::Vector3d&, bool clockwise=true); // sets the center coordinates and the command name
std::string toGCode (int precision=6, bool padzero=true) const; // returns a GCode string representation of the command
void setFromGCode (const std::string&); // sets the parameters from the contents of the given GCode string

View File

@@ -35,29 +35,29 @@ namespace Path
class PathExport Feature : public App::GeoFeature
{
PROPERTY_HEADER(Path::Feature);
PROPERTY_HEADER_WITH_OVERRIDE(Path::Feature);
public:
/// Constructor
Feature(void);
virtual ~Feature();
Feature();
~Feature() override;
/// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const {
const char* getViewProviderName() const override {
return "PathGui::ViewProviderPath";
}
virtual App::DocumentObjectExecReturn *execute(void) {
App::DocumentObjectExecReturn *execute() override {
return App::DocumentObject::StdReturn;
}
virtual short mustExecute(void) const;
virtual PyObject *getPyObject(void);
short mustExecute() const override;
PyObject *getPyObject() override;
PropertyPath Path;
protected:
/// get called by the container when a property has changed
virtual void onChanged (const App::Property* prop);
void onChanged (const App::Property* prop) override;
};

View File

@@ -33,21 +33,21 @@ namespace Path
class PathExport FeatureCompound : public Path::Feature
{
PROPERTY_HEADER(Path::Feature);
PROPERTY_HEADER_WITH_OVERRIDE(Path::Feature);
public:
/// Constructor
FeatureCompound(void);
virtual ~FeatureCompound();
FeatureCompound();
~FeatureCompound() override;
App::PropertyLinkList Group;
App::PropertyBool UsePlacements;
/// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const {
const char* getViewProviderName() const override {
return "PathGui::ViewProviderPathCompound";
}
virtual App::DocumentObjectExecReturn *execute(void);
App::DocumentObjectExecReturn *execute() override;
/// Checks whether the object \a obj is part of this group.
bool hasObject(const DocumentObject* obj) const;
@@ -55,7 +55,7 @@ public:
void addObject(DocumentObject* obj);
/// Removes an object from this group.
void removeObject(DocumentObject* obj);
virtual PyObject *getPyObject(void);
PyObject *getPyObject() override;
};

View File

@@ -37,12 +37,12 @@ namespace Path
class PathExport FeatureShape : public Path::Feature
{
PROPERTY_HEADER(Path::FeatureShape);
PROPERTY_HEADER_WITH_OVERRIDE(Path::FeatureShape);
public:
/// Constructor
FeatureShape();
virtual ~FeatureShape();
~FeatureShape() override;
// Part::PropertyPartShape Shape;
App::PropertyLinkList Sources;
@@ -52,17 +52,17 @@ public:
//@{
/// recalculate the feature
virtual App::DocumentObjectExecReturn *execute();
App::DocumentObjectExecReturn *execute() override;
//@}
/// returns the type name of the ViewProvider
virtual const char* getViewProviderName() const {
const char* getViewProviderName() const override {
return "PathGui::ViewProviderPathShape";
}
protected:
/// get called by the container when a property has changed
//virtual void onChanged (const App::Property* prop);
//void onChanged (const App::Property* prop) override;
};

View File

@@ -37,37 +37,37 @@ namespace Path
class PathExport Toolpath : public Base::Persistence
{
TYPESYSTEM_HEADER();
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
Toolpath();
Toolpath(const Toolpath&);
~Toolpath();
~Toolpath() override;
Toolpath &operator=(const Toolpath&);
// from base class
virtual unsigned int getMemSize (void) const;
virtual void Save (Base::Writer &/*writer*/) const;
virtual void Restore(Base::XMLReader &/*reader*/);
void SaveDocFile (Base::Writer &writer) const;
void RestoreDocFile(Base::Reader &reader);
unsigned int getMemSize () const override;
void Save (Base::Writer &/*writer*/) const override;
void Restore(Base::XMLReader &/*reader*/) override;
void SaveDocFile (Base::Writer &writer) const override;
void RestoreDocFile(Base::Reader &reader) override;
// interface
void clear(void); // clears the internal data
void clear(); // clears the internal data
void addCommand(const Command &Cmd); // adds a command at the end
void insertCommand(const Command &Cmd, int); // inserts a command
void deleteCommand(int); // deletes a command
double getLength(void); // return the Length (mm) of the Path
double getLength(); // return the Length (mm) of the Path
double getCycleTime(double, double, double, double); // return the Cycle Time (s) of the Path
void recalculate(void); // recalculates the points
void recalculate(); // recalculates the points
void setFromGCode(const std::string); // sets the path from the contents of the given GCode string
std::string toGCode(void) const; // gets a gcode string representation from the Path
Base::BoundBox3d getBoundBox(void) const;
std::string toGCode() const; // gets a gcode string representation from the Path
Base::BoundBox3d getBoundBox() const;
// shortcut functions
unsigned int getSize(void) const { return vpcCommands.size(); }
const std::vector<Command*> &getCommands(void) const { return vpcCommands; }
unsigned int getSize() const { return vpcCommands.size(); }
const std::vector<Command*> &getCommands() const { return vpcCommands; }
const Command &getCommand(unsigned int pos) const { return *vpcCommands[pos]; }
// support for rotation

View File

@@ -34,36 +34,36 @@ namespace Path
/** The path property class. */
class PathExport PropertyPath : public App::Property
{
TYPESYSTEM_HEADER();
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
PropertyPath();
~PropertyPath();
~PropertyPath() override;
/** @name Getter/setter */
//@{
/// set the part shape
void setValue(const Toolpath&);
/// get the part shape
const Toolpath &getValue(void) const;
const Toolpath &getValue() const;
//@}
/** @name Python interface */
//@{
PyObject* getPyObject(void);
void setPyObject(PyObject *value);
PyObject* getPyObject() override;
void setPyObject(PyObject *value) override;
//@}
/** @name Save/restore */
//@{
void Save (Base::Writer &writer) const;
void Restore(Base::XMLReader &reader);
void SaveDocFile (Base::Writer &writer) const;
void RestoreDocFile(Base::Reader &reader);
void Save (Base::Writer &writer) const override;
void Restore(Base::XMLReader &reader) override;
void SaveDocFile (Base::Writer &writer) const override;
void RestoreDocFile(Base::Reader &reader) override;
App::Property *Copy(void) const;
void Paste(const App::Property &from);
unsigned int getMemSize (void) const;
App::Property *Copy() const override;
void Paste(const App::Property &from) override;
unsigned int getMemSize () const override;
//@}
private:

View File

@@ -28,6 +28,7 @@
#include <Base/BaseClass.h>
#include <Base/Handle.h>
#include <Base/Vector3D.h>
#include <Mod/Path/PathGlobal.h>
#include <boost/polygon/polygon.hpp>
#include <boost/polygon/voronoi.hpp>
@@ -43,12 +44,12 @@ namespace Path
class PathExport Voronoi
: public Base::BaseClass
{
TYPESYSTEM_HEADER();
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
//constructors
Voronoi();
~Voronoi();
~Voronoi() override;
using color_type = std::size_t;
static const int InvalidIndex = INT_MAX;

View File

@@ -33,14 +33,14 @@ class Voronoi;
class PathExport VoronoiCell
: public Base::BaseClass
{
TYPESYSTEM_HEADER();
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
VoronoiCell(Voronoi::diagram_type *dia = nullptr, long index = Voronoi::InvalidIndex);
VoronoiCell(Voronoi::diagram_type *dia, const Voronoi::diagram_type::cell_type *cell);
~VoronoiCell();
~VoronoiCell() override;
bool isBound(void) const;
bool isBound() const;
Voronoi::point_type sourcePoint() const;
Voronoi::segment_type sourceSegment() const;

View File

@@ -35,14 +35,14 @@ class Voronoi;
class PathExport VoronoiEdge
: public Base::BaseClass
{
TYPESYSTEM_HEADER();
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
VoronoiEdge(Voronoi::diagram_type *dia = nullptr, long index = Voronoi::InvalidIndex);
VoronoiEdge(Voronoi::diagram_type *dia, const Voronoi::diagram_type::edge_type *edge);
~VoronoiEdge();
~VoronoiEdge() override;
bool isBound(void) const;
bool isBound() const;
Base::Reference<Voronoi::diagram_type> dia;
long index;

View File

@@ -35,14 +35,14 @@ class Voronoi;
class PathExport VoronoiVertex
: public Base::BaseClass
{
TYPESYSTEM_HEADER();
TYPESYSTEM_HEADER_WITH_OVERRIDE();
public:
VoronoiVertex(Voronoi::diagram_type *dia = nullptr, long index = Voronoi::InvalidIndex);
VoronoiVertex(Voronoi::diagram_type *dia, const Voronoi::diagram_type::vertex_type *v);
~VoronoiVertex();
~VoronoiVertex() override;
bool isBound(void) const;
bool isBound() const;
Base::Reference<Voronoi::diagram_type> dia;
long index;

View File

@@ -60,22 +60,22 @@ class PathGuiExport TaskDlgPathCompound : public Gui::TaskView::TaskDialog
public:
TaskDlgPathCompound(PathGui::ViewProviderPathCompound *);
~TaskDlgPathCompound();
~TaskDlgPathCompound() override;
public:
/// is called the TaskView when the dialog is opened
virtual void open();
void open() override;
/// is called by the framework if an button is clicked which has no accept or rject role
virtual void clicked(int);
void clicked(int) override;
/// is called by the framework if the dialog is accepted (Ok)
virtual bool accept();
bool accept() override;
/// is called by the framework if the dialog is rejected (Cancel)
virtual bool reject();
bool reject() override;
/// is called by the framework if the user press the help button
virtual void helpRequested();
void helpRequested() override;
/// returns for Close and Help button
virtual QDialogButtonBox::StandardButtons getStandardButtons(void) const
virtual QDialogButtonBox::StandardButtons getStandardButtons() const override
{ return QDialogButtonBox::Ok|QDialogButtonBox::Cancel; }
protected:

View File

@@ -25,30 +25,31 @@
#include <Gui/ViewProviderPythonFeature.h>
#include <Mod/Part/Gui/ViewProviderPlaneParametric.h>
#include <Mod/Path/PathGlobal.h>
namespace PathGui
{
class PathGuiExport ViewProviderArea : public PartGui::ViewProviderPlaneParametric
{
PROPERTY_HEADER(PathGui::ViewProviderArea);
PROPERTY_HEADER_WITH_OVERRIDE(PathGui::ViewProviderArea);
public:
ViewProviderArea();
virtual ~ViewProviderArea();
~ViewProviderArea() override;
/// grouping handling
virtual std::vector<App::DocumentObject*> claimChildren(void) const;
virtual void updateData(const App::Property*);
virtual bool onDelete(const std::vector<std::string> &);
std::vector<App::DocumentObject*> claimChildren() const override;
void updateData(const App::Property*) override;
bool onDelete(const std::vector<std::string> &) override;
/// drag and drop
virtual bool canDragObjects() const;
virtual bool canDragObject(App::DocumentObject*) const;
virtual void dragObject(App::DocumentObject*);
virtual bool canDropObjects() const;
virtual bool canDropObject(App::DocumentObject*) const;
virtual void dropObject(App::DocumentObject*);
bool canDragObjects() const override;
bool canDragObject(App::DocumentObject*) const override;
void dragObject(App::DocumentObject*) override;
bool canDropObjects() const override;
bool canDropObject(App::DocumentObject*) const override;
void dropObject(App::DocumentObject*) override;
};
using ViewProviderAreaPython = Gui::ViewProviderPythonFeatureT<ViewProviderArea>;
@@ -56,22 +57,22 @@ using ViewProviderAreaPython = Gui::ViewProviderPythonFeatureT<ViewProviderArea>
class PathGuiExport ViewProviderAreaView : public PartGui::ViewProviderPlaneParametric
{
PROPERTY_HEADER(PathGui::ViewProviderAreaView);
PROPERTY_HEADER_WITH_OVERRIDE(PathGui::ViewProviderAreaView);
public:
ViewProviderAreaView();
virtual ~ViewProviderAreaView();
virtual std::vector<App::DocumentObject*> claimChildren(void) const;
virtual void updateData(const App::Property*);
virtual bool onDelete(const std::vector<std::string> &);
~ViewProviderAreaView() override;
std::vector<App::DocumentObject*> claimChildren(void) const override;
void updateData(const App::Property*) override;
bool onDelete(const std::vector<std::string> &) override;
/// drag and drop
virtual bool canDragObjects() const;
virtual bool canDragObject(App::DocumentObject*) const;
virtual void dragObject(App::DocumentObject*);
virtual bool canDropObjects() const;
virtual bool canDropObject(App::DocumentObject*) const;
virtual void dropObject(App::DocumentObject*);
bool canDragObjects() const override;
bool canDragObject(App::DocumentObject*) const override;
void dragObject(App::DocumentObject*) override;
bool canDropObjects() const override;
bool canDropObject(App::DocumentObject*) const override;
void dropObject(App::DocumentObject*) override;
};
using ViewProviderAreaViewPython = Gui::ViewProviderPythonFeatureT<ViewProviderAreaView>;

View File

@@ -28,6 +28,7 @@
#include <Gui/ViewProviderGeometryObject.h>
#include <Gui/ViewProviderPythonFeature.h>
#include <Mod/Part/Gui/SoBrepEdgeSet.h>
#include <Mod/Path/PathGlobal.h>
class SoCoordinate3;
@@ -45,7 +46,7 @@ class PathSelectionObserver;
class PathGuiExport ViewProviderPath : public Gui::ViewProviderGeometryObject
{
PROPERTY_HEADER(PathGui::ViewProviderPath);
PROPERTY_HEADER_WITH_OVERRIDE(PathGui::ViewProviderPath);
using inherited = ViewProviderGeometryObject;
public:
@@ -53,7 +54,7 @@ public:
ViewProviderPath();
/// destructor.
~ViewProviderPath();
~ViewProviderPath() override;
// Display properties
App::PropertyInteger LineWidth;
@@ -67,29 +68,29 @@ public:
App::PropertyIntegerConstraint ShowCount;
App::PropertyIntegerConstraint::Constraints ShowCountConstraints;
void attach(App::DocumentObject *pcObject);
void setDisplayMode(const char* ModeName);
std::vector<std::string> getDisplayModes() const;
void updateData(const App::Property*);
void attach(App::DocumentObject *pcObject) override;
void setDisplayMode(const char* ModeName) override;
std::vector<std::string> getDisplayModes() const override;
void updateData(const App::Property*) override;
void recomputeBoundingBox();
virtual QIcon getIcon() const;
virtual QIcon getIcon() const override;
virtual bool useNewSelectionModel(void) const;
virtual std::string getElement(const SoDetail *) const;
SoDetail* getDetail(const char* subelement) const;
bool useNewSelectionModel() const override;
std::string getElement(const SoDetail *) const override;
SoDetail* getDetail(const char* subelement) const override;
void updateShowConstraints();
void updateVisual(bool rebuild = false);
void hideSelection();
virtual void showBoundingBox(bool show);
void showBoundingBox(bool show) override;
friend class PathSelectionObserver;
protected:
virtual void onChanged(const App::Property* prop);
virtual unsigned long getBoundColor() const;
void onChanged(const App::Property* prop) override;
unsigned long getBoundColor() const override;
SoCoordinate3 * pcLineCoords;
SoCoordinate3 * pcMarkerCoords;

View File

@@ -31,20 +31,20 @@ namespace PathGui
class PathGuiExport ViewProviderPathCompound: public ViewProviderPath
{
PROPERTY_HEADER(PathGui::ViewProviderPathCompound);
PROPERTY_HEADER_WITH_OVERRIDE(PathGui::ViewProviderPathCompound);
public:
std::vector<App::DocumentObject*> claimChildren(void)const;
virtual bool canDragObjects() const;
virtual void dragObject(App::DocumentObject*);
virtual bool canDropObjects() const;
virtual void dropObject(App::DocumentObject*);
QIcon getIcon(void) const;
std::vector<App::DocumentObject*> claimChildren() const override;
bool canDragObjects() const override;
void dragObject(App::DocumentObject*) override;
bool canDropObjects() const override;
void dropObject(App::DocumentObject*) override;
QIcon getIcon() const override;
protected:
virtual bool setEdit(int ModNum);
virtual void unsetEdit(int ModNum);
bool setEdit(int ModNum) override;
void unsetEdit(int ModNum) override;
};

View File

@@ -31,24 +31,24 @@ namespace PathGui
class PathGuiExport ViewProviderPathShape: public ViewProviderPath
{
PROPERTY_HEADER(PathGui::ViewProviderPathShape);
PROPERTY_HEADER_WITH_OVERRIDE(PathGui::ViewProviderPathShape);
public:
/// grouping handling
virtual std::vector<App::DocumentObject*> claimChildren(void) const;
virtual void updateData(const App::Property*);
virtual bool onDelete(const std::vector<std::string> &);
std::vector<App::DocumentObject*> claimChildren() const override;
void updateData(const App::Property*) override;
bool onDelete(const std::vector<std::string> &) override;
/// drag and drop
virtual bool canDragObjects() const;
virtual bool canDragObject(App::DocumentObject*) const;
virtual void dragObject(App::DocumentObject*);
virtual bool canDropObjects() const;
virtual bool canDropObject(App::DocumentObject*) const;
virtual void dropObject(App::DocumentObject*);
bool canDragObjects() const override;
bool canDragObject(App::DocumentObject*) const override;
void dragObject(App::DocumentObject*) override;
bool canDropObjects() const override;
bool canDropObject(App::DocumentObject*) const override;
void dropObject(App::DocumentObject*) override;
QIcon getIcon(void) const;
QIcon getIcon() const override;
};
} //namespace PathGui

View File

@@ -28,6 +28,7 @@
#include <Mod/Path/App/Command.h>
#include <Mod/Part/App/TopoShape.h>
#include <Mod/Path/PathGlobal.h>
#include "VolSim.h"