diff --git a/src/App/FeaturePython.cpp b/src/App/FeaturePython.cpp index d7c33c3ca4..f479cced2f 100644 --- a/src/App/FeaturePython.cpp +++ b/src/App/FeaturePython.cpp @@ -48,7 +48,12 @@ FeaturePythonImp::~FeaturePythonImp() #undef FC_PY_ELEMENT #define FC_PY_ELEMENT(_name) py_##_name = Py::None(); - FC_PY_FEATURE_PYTHON + try { + FC_PY_FEATURE_PYTHON + } + catch (Py::Exception& e) { + e.clear(); + } } void FeaturePythonImp::init(PyObject *pyobj) { diff --git a/src/App/Material.cpp b/src/App/Material.cpp index 89ce94badf..d45a628e31 100644 --- a/src/App/Material.cpp +++ b/src/App/Material.cpp @@ -36,17 +36,23 @@ using namespace App; // Material //=========================================================================== Material::Material() + : shininess{0.2000f} + , transparency{} { setType(STEEL); setType(USER_DEFINED); } Material::Material(const char* MatName) + : shininess{0.2000f} + , transparency{} { set(MatName); } Material::Material(const MaterialType MatType) + : shininess{0.2000f} + , transparency{} { setType(MatType); } diff --git a/src/App/MetadataPyImp.cpp b/src/App/MetadataPyImp.cpp index 5c0785f985..6a8c3ea98d 100644 --- a/src/App/MetadataPyImp.cpp +++ b/src/App/MetadataPyImp.cpp @@ -50,7 +50,7 @@ std::string MetadataPy::representation(void) const PyObject* MetadataPy::PyMake(struct _typeobject*, PyObject* args, PyObject*) // Python wrapper { - // create a new instance of MetadataPy and the Twin object + // create a new instance of MetadataPy and the Twin object const char* filename; if (!PyArg_ParseTuple(args, "s", &filename)) return nullptr; @@ -75,13 +75,13 @@ int MetadataPy::PyInit(PyObject* args, PyObject* /*kwd*/) PyErr_Clear(); const char* file; if (PyArg_ParseTuple(args, "s", &file)) { - App::Metadata* a = new Metadata(file); - *(getMetadataPtr()) = *a; + App::Metadata a(file); + *(getMetadataPtr()) = a; return 0; } // Copy constructor - PyErr_Clear(); + PyErr_Clear(); PyObject* o; if (PyArg_ParseTuple(args, "O!", &(App::MetadataPy::Type), &o)) { App::Metadata* a = static_cast(o)->getMetadataPtr(); diff --git a/src/Base/TimeInfo.cpp b/src/Base/TimeInfo.cpp index 8e8b163060..4782c81e83 100644 --- a/src/Base/TimeInfo.cpp +++ b/src/Base/TimeInfo.cpp @@ -103,6 +103,8 @@ TimeInfo TimeInfo::null() TimeInfo ti; ti.timebuffer.time = 0; ti.timebuffer.millitm = 0; + ti.timebuffer.timezone = 0; + ti.timebuffer.dstflag = 0; return ti; } diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 912121ea78..e4cbb2d93f 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -2516,11 +2516,13 @@ bool StdViewZoomOut::isActive(void) { return (qobject_cast(getMainWindow()->activeWindow())); } -class SelectionCallbackHandler { + +namespace { +class SelectionCallbackHandler { private: static std::unique_ptr currentSelectionHandler; - QCursor* prevSelectionCursor; + QCursor prevSelectionCursor; typedef void (*FnCb)(void * userdata, SoEventCallback * node); FnCb fnCb; void* userData; @@ -2531,7 +2533,8 @@ public: // Takes the viewer, a selection mode, a cursor, a function pointer to be called on success and a void pointer for user data to be passed to the given function. // The selection handler class stores all necessary previous states, registers a event callback and starts the selection in the given mode. // If there is still a selection handler active, this call will generate a message and returns. - static void Create(View3DInventorViewer* viewer, View3DInventorViewer::SelectionMode selectionMode, const QCursor& cursor, FnCb doFunction= NULL, void* ud=NULL) + static void Create(View3DInventorViewer* viewer, View3DInventorViewer::SelectionMode selectionMode, + const QCursor& cursor, FnCb doFunction= nullptr, void* ud=nullptr) { if (currentSelectionHandler) { @@ -2544,7 +2547,7 @@ public: { currentSelectionHandler->userData = ud; currentSelectionHandler->fnCb = doFunction; - currentSelectionHandler->prevSelectionCursor = new QCursor(viewer->cursor()); + currentSelectionHandler->prevSelectionCursor = viewer->cursor(); viewer->setEditingCursor(cursor); viewer->addEventCallback(SoEvent::getClassTypeId(), SelectionCallbackHandler::selectionCallback, currentSelectionHandler.get()); @@ -2552,9 +2555,11 @@ public: viewer->setSelectionEnabled(false); viewer->startSelection(selectionMode); } - }; + } - void* getUserData() { return userData; }; + void* getUserData() const { + return userData; + } // Implements the event handler. In the normal case the provided function is called. // Also supports aborting the selection mode by pressing (releasing) the Escape key. @@ -2571,11 +2576,11 @@ public: const SoKeyboardEvent * ke = static_cast(ev); const SbBool press = ke->getState() == SoButtonEvent::DOWN ? true : false; if (ke->getKey() == SoKeyboardEvent::ESCAPE) { - - if (!press) { + + if (!press) { view->abortSelection(); restoreState(selectionHandler, view); - } + } } } else if (ev->isOfType(SoMouseButtonEvent::getClassTypeId())) { @@ -2586,7 +2591,8 @@ public: if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::UP) { - if (selectionHandler && selectionHandler->fnCb) selectionHandler->fnCb(selectionHandler->getUserData(), n); + if (selectionHandler && selectionHandler->fnCb) + selectionHandler->fnCb(selectionHandler->getUserData(), n); restoreState(selectionHandler, view); } // No other mouse events available from Coin3D to implement right mouse up abort @@ -2595,14 +2601,18 @@ public: static void restoreState(SelectionCallbackHandler * selectionHandler, View3DInventorViewer* view) { - if(selectionHandler) selectionHandler->fnCb = NULL; - view->setEditingCursor(*selectionHandler->prevSelectionCursor); - view->removeEventCallback(SoEvent::getClassTypeId(), SelectionCallbackHandler::selectionCallback, selectionHandler); - view->setSelectionEnabled(selectionHandler->prevSelectionEn); + if (selectionHandler) + { + selectionHandler->fnCb = nullptr; + view->setEditingCursor(selectionHandler->prevSelectionCursor); + view->removeEventCallback(SoEvent::getClassTypeId(), SelectionCallbackHandler::selectionCallback, selectionHandler); + view->setSelectionEnabled(selectionHandler->prevSelectionEn); + } Application::Instance->commandManager().testActive(); - currentSelectionHandler = NULL; + currentSelectionHandler = nullptr; } }; +} std::unique_ptr SelectionCallbackHandler::currentSelectionHandler = std::unique_ptr(); //=========================================================================== diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index f43f5418d4..e468843f54 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -2873,7 +2873,7 @@ void View3DInventorViewer::animatedViewAll(int steps, int ms) if (sphere.getRadius() == 0) return; - SbVec3f direction, pos; + SbVec3f direction, pos(0.0f, 0.0f, 0.0f); camrot.multVec(SbVec3f(0, 0, -1), direction); bool isOrthographic = false; diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 492beaa78b..ded9701fc2 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -1321,7 +1321,7 @@ Py::Object View3DInventorPy::dumpNode(const Py::Tuple& args) } //FIXME: Once View3DInventor inherits from PropertyContainer we can use PropertyEnumeration. -const char* StereoTypeEnums[]= {"None","Anaglyph","QuadBuffer","InterleavedRows","InterleavedColumns",NULL}; +const char* StereoTypeEnums[]= {"Mono","Anaglyph","QuadBuffer","InterleavedRows","InterleavedColumns",nullptr}; Py::Object View3DInventorPy::setStereoType(const Py::Tuple& args) { @@ -1370,7 +1370,9 @@ Py::Object View3DInventorPy::getStereoType(const Py::Tuple& args) throw Py::Exception(); try { - int mode = (int)(getView3DIventorPtr()->getViewer()->stereoMode()); + int mode = int(getView3DIventorPtr()->getViewer()->stereoMode()); + if (mode < 0 || mode > 4) + throw Py::ValueError("Invalid stereo mode"); return Py::String(StereoTypeEnums[mode]); } catch (const Base::Exception& e) { diff --git a/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp b/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp index b7b33fe1fa..24293c0e1e 100644 --- a/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp +++ b/src/Mod/Part/Gui/DlgProjectionOnSurface.cpp @@ -371,7 +371,6 @@ void PartGui::DlgProjectionOnSurface::store_current_selected_parts(std::vectorgetNameInDocument(); auto currentShape = aPart->Shape.getShape().getSubShape(itName->c_str()); transform_shape_to_global_position(currentShape, aPart); diff --git a/src/Mod/Part/Gui/DlgProjectionOnSurface.h b/src/Mod/Part/Gui/DlgProjectionOnSurface.h index 26e0248931..373311217d 100644 --- a/src/Mod/Part/Gui/DlgProjectionOnSurface.h +++ b/src/Mod/Part/Gui/DlgProjectionOnSurface.h @@ -89,11 +89,11 @@ private: std::vector aProjectedWireInParametricSpaceVec; TopoDS_Face aProjectedFace; TopoDS_Shape aProjectedSolid; - Part::Feature* partFeature; + Part::Feature* partFeature = nullptr; std::string partName; - bool is_selectable; - long transparency; - float exrudeValue; + bool is_selectable = false; + long transparency = 0; + float exrudeValue = 0.0f; }; //from Gui::SelectionObserver diff --git a/src/Mod/Robot/App/Robot6Axis.cpp b/src/Mod/Robot/App/Robot6Axis.cpp index d63b302850..96f7b7aab4 100644 --- a/src/Mod/Robot/App/Robot6Axis.cpp +++ b/src/Mod/Robot/App/Robot6Axis.cpp @@ -137,18 +137,21 @@ void Robot6Axis::readKinematic(const char * FileName) { char buf[120]; std::ifstream in(FileName); - if(!in)return; + if (!in) + return; + std::vector destination; AxisDefinition temp[6]; // over read the header in.getline(buf,119,'\n'); // read 6 Axis - for( int i = 0; i<6; i++){ + for (int i = 0; i < 6; i++) { in.getline(buf,79,'\n'); destination.clear(); split(std::string(buf),',',destination); - if(destination.size() < 8) continue; + if (destination.size() < 8) + continue; // transfer the values in kinematic structure temp[i].a = atof(destination[0].c_str()); temp[i].alpha = atof(destination[1].c_str()); diff --git a/src/Mod/Robot/App/Robot6Axis.h b/src/Mod/Robot/App/Robot6Axis.h index a1cb2703b8..e69633ae8b 100644 --- a/src/Mod/Robot/App/Robot6Axis.h +++ b/src/Mod/Robot/App/Robot6Axis.h @@ -23,26 +23,27 @@ #ifndef ROBOT_ROBOT6AXLE_H #define ROBOT_ROBOT6AXLE_H - + #include "kdl_cp/chain.hpp" #include "kdl_cp/jntarray.hpp" - + #include #include +#include namespace Robot { /// Definition of the Axis properties struct AxisDefinition { - double a; // a of the Denavit-Hartenberg parameters (mm) - double alpha; // alpha of the Denavit-Hartenberg parameters (°) - double d; // d of the Denavit-Hartenberg parameters (mm) - double theta; // a of the Denavit-Hartenberg parameters (°) - double rotDir; // rotational direction (1|-1) - double maxAngle; // soft ends + in ° - double minAngle; // soft ends - in ° - double velocity; // max vlocity of the axle in °/s + double a = 0.0; // a of the Denavit-Hartenberg parameters (mm) + double alpha = 0.0; // alpha of the Denavit-Hartenberg parameters (°) + double d = 0.0; // d of the Denavit-Hartenberg parameters (mm) + double theta = 0.0; // a of the Denavit-Hartenberg parameters (°) + double rotDir = 0.0; // rotational direction (1|-1) + double maxAngle = 0.0; // soft ends + in ° + double minAngle = 0.0; // soft ends - in ° + double velocity = 0.0; // max vlocity of the axle in °/s }; @@ -56,40 +57,39 @@ public: Robot6Axis(); ~Robot6Axis(); - // from base class + // from base class virtual unsigned int getMemSize (void) const; - virtual void Save (Base::Writer &/*writer*/) const; + virtual void Save (Base::Writer &/*writer*/) const; virtual void Restore(Base::XMLReader &/*reader*/); - // interface + // interface /// set the kinematic parameters of the robot void setKinematic(const AxisDefinition KinDef[6]); /// read the kinematic parameters of the robot from a file void readKinematic(const char * FileName); /// set the robot to that position, calculates the Axis - bool setTo(const Base::Placement &To); - bool setAxis(int Axis,double Value); - double getAxis(int Axis); + bool setTo(const Base::Placement &To); + bool setAxis(int Axis,double Value); + double getAxis(int Axis); double getMaxAngle(int Axis); double getMinAngle(int Axis); - /// calculate the new Tcp out of the Axis - bool calcTcp(void); - Base::Placement getTcp(void); + /// calculate the new Tcp out of the Axis + bool calcTcp(void); + Base::Placement getTcp(void); //void setKinematik(const std::vector > &KinTable); protected: - KDL::Chain Kinematic; - KDL::JntArray Actuall; - KDL::JntArray Min; - KDL::JntArray Max; - KDL::Frame Tcp; - - double Velocity[6]; - double RotDir [6]; + KDL::Chain Kinematic; + KDL::JntArray Actuall; + KDL::JntArray Min; + KDL::JntArray Max; + KDL::Frame Tcp; + double Velocity[6]; + double RotDir [6]; }; } //namespace Part