diff --git a/src/Gui/ExpressionCompleter.cpp b/src/Gui/ExpressionCompleter.cpp index 6b46121597fa..e7d59e69440e 100644 --- a/src/Gui/ExpressionCompleter.cpp +++ b/src/Gui/ExpressionCompleter.cpp @@ -488,7 +488,7 @@ void ExpressionCompleter::slotUpdate(const QString & prefix, int pos) trim = prefixEnd - pos; // Extract last tokens that can be rebuilt to a variable - ssize_t i = static_cast(tokens.size()) - 1; + long i = static_cast(tokens.size()) - 1; // First, check if we have unclosing string starting from the end bool stringing = false; @@ -515,7 +515,7 @@ void ExpressionCompleter::slotUpdate(const QString & prefix, int pos) } if(!stringing) { - i = static_cast(tokens.size()) - 1; + i = static_cast(tokens.size()) - 1; for(;i>=0;--i) { int token = get<0>(tokens[i]); if (token != '.' && token != '#' && @@ -529,13 +529,13 @@ void ExpressionCompleter::slotUpdate(const QString & prefix, int pos) } // Set prefix start for use when replacing later - if (i == static_cast(tokens.size())) + if (i == static_cast(tokens.size())) prefixStart = prefixEnd; else prefixStart = start + get<1>(tokens[i]); // Build prefix from tokens - while (i < static_cast(tokens.size())) { + while (i < static_cast(tokens.size())) { completionPrefix += get<2>(tokens[i]); ++i; } diff --git a/src/Mod/Draft/draftguitools/gui_fillets.py b/src/Mod/Draft/draftguitools/gui_fillets.py index d73e09e7a5b1..a54de74ff717 100644 --- a/src/Mod/Draft/draftguitools/gui_fillets.py +++ b/src/Mod/Draft/draftguitools/gui_fillets.py @@ -95,13 +95,8 @@ def Activated(self, name="Fillet"): "Create chamfer")) self.ui.check_chamfer.show() - # TODO: change to Qt5 style - QtCore.QObject.connect(self.ui.check_delete, - QtCore.SIGNAL("stateChanged(int)"), - self.set_delete) - QtCore.QObject.connect(self.ui.check_chamfer, - QtCore.SIGNAL("stateChanged(int)"), - self.set_chamfer) + self.ui.check_delete.stateChanged.connect(self.set_delete) + self.ui.check_chamfer.stateChanged.connect(self.set_chamfer) # TODO: somehow we need to set up the trackers # to show a preview of the fillet. diff --git a/src/Mod/Draft/draftguitools/gui_trackers.py b/src/Mod/Draft/draftguitools/gui_trackers.py index 1f055ab4d93e..cf453d325327 100644 --- a/src/Mod/Draft/draftguitools/gui_trackers.py +++ b/src/Mod/Draft/draftguitools/gui_trackers.py @@ -1059,6 +1059,19 @@ def update(self): """Redraw the grid.""" # Resize the grid to make sure it fits # an exact pair number of main lines + if self.space == 0: + self.lines1.numVertices.deleteValues(0) + self.lines2.numVertices.deleteValues(0) + FreeCAD.Console.PrintWarning("Draft Grid: Spacing value is zero\n") + return + if self.mainlines == 0: + self.lines1.numVertices.deleteValues(0) + self.lines2.numVertices.deleteValues(0) + return + if self.numlines == 0: + self.lines1.numVertices.deleteValues(0) + self.lines2.numVertices.deleteValues(0) + return numlines = self.numlines // self.mainlines // 2 * 2 * self.mainlines bound = (numlines // 2) * self.space border = (numlines//2 + self.mainlines/2) * self.space diff --git a/src/Mod/Image/Gui/ViewProviderImagePlane.cpp b/src/Mod/Image/Gui/ViewProviderImagePlane.cpp index 1ecbb16c3569..eac136d5fd94 100644 --- a/src/Mod/Image/Gui/ViewProviderImagePlane.cpp +++ b/src/Mod/Image/Gui/ViewProviderImagePlane.cpp @@ -23,7 +23,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ - #include +# include # include # include # include diff --git a/src/Mod/Mesh/App/AppMeshPy.cpp b/src/Mod/Mesh/App/AppMeshPy.cpp index c6675395d2e5..5066b4212dfd 100644 --- a/src/Mod/Mesh/App/AppMeshPy.cpp +++ b/src/Mod/Mesh/App/AppMeshPy.cpp @@ -244,7 +244,7 @@ class Module : public Py::ExtensionModule // collect all object types that can be exported as mesh std::vector objectList; - for (auto it : list) { + for (const auto& it : list) { PyObject *item = it.ptr(); if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) { auto obj( static_cast(item)->getDocumentObjectPtr() ); diff --git a/src/Mod/Mesh/App/Core/Builder.cpp b/src/Mod/Mesh/App/Core/Builder.cpp index 3dddec8687da..74002995413d 100644 --- a/src/Mod/Mesh/App/Core/Builder.cpp +++ b/src/Mod/Mesh/App/Core/Builder.cpp @@ -275,11 +275,14 @@ struct MeshFastBuilder::Private { } bool operator<(const Vertex& rhs) const { - if (x != rhs.x) + if (x != rhs.x) return x < rhs.x; - else if (y != rhs.y) return y < rhs.y; - else if (z != rhs.z) return z < rhs.z; - else return false; + else if (y != rhs.y) + return y < rhs.y; + else if (z != rhs.z) + return z < rhs.z; + else + return false; } }; diff --git a/src/Mod/Mesh/App/Core/Degeneration.cpp b/src/Mod/Mesh/App/Core/Degeneration.cpp index fd64e8a85879..9af888ef4c1b 100644 --- a/src/Mod/Mesh/App/Core/Degeneration.cpp +++ b/src/Mod/Mesh/App/Core/Degeneration.cpp @@ -301,13 +301,18 @@ struct MeshFacet_Less if (y1 > y2) { tmp = y1; y1 = y2; y2 = tmp; } - if (x0 < y0) + if (x0 < y0) return true; - else if (x0 > y0) return false; - else if (x1 < y1) return true; - else if (x1 > y1) return false; - else if (x2 < y2) return true; - else return false; + else if (x0 > y0) + return false; + else if (x1 < y1) + return true; + else if (x1 > y1) + return false; + else if (x2 < y2) + return true; + else + return false; } }; @@ -1104,12 +1109,8 @@ bool MeshFixRangePoint::Fixup() // 'DeleteFacets' will segfault. But setting all point indices to 0 works. std::vector invalid = eval.GetIndices(); if (!invalid.empty()) { - const MeshFacetArray& rFaces = _rclMesh.GetFacets(); for (std::vector::iterator it = invalid.begin(); it != invalid.end(); ++it) { - MeshFacet& face = const_cast(rFaces[*it]); - face._aulPoints[0] = 0; - face._aulPoints[1] = 0; - face._aulPoints[2] = 0; + _rclMesh.SetFacetPoints(*it, 0, 0, 0); } _rclMesh.DeleteFacets(invalid); diff --git a/src/Mod/Mesh/App/Core/Elements.h b/src/Mod/Mesh/App/Core/Elements.h index 5f176bc6496b..97971623abbf 100644 --- a/src/Mod/Mesh/App/Core/Elements.h +++ b/src/Mod/Mesh/App/Core/Elements.h @@ -121,9 +121,9 @@ class MeshExport MeshPoint: public Base::Vector3f */ //@{ void SetFlag (TFlagType tF) const - { const_cast(this)->_ucFlag |= static_cast(tF); } + { _ucFlag |= static_cast(tF); } void ResetFlag (TFlagType tF) const - { const_cast(this)->_ucFlag &= ~static_cast(tF); } + { _ucFlag &= ~static_cast(tF); } bool IsFlag (TFlagType tF) const { return (_ucFlag & static_cast(tF)) == static_cast(tF); } void ResetInvalid () const @@ -133,7 +133,7 @@ class MeshExport MeshPoint: public Base::Vector3f bool IsValid () const { return !IsFlag(INVALID); } void SetProperty(unsigned long uP) const - { const_cast(this)->_ulProp = uP; } + { _ulProp = uP; } //@} // Assignment @@ -145,8 +145,8 @@ class MeshExport MeshPoint: public Base::Vector3f inline bool operator < (const MeshPoint &rclPt) const; public: - unsigned char _ucFlag; /**< Flag member */ - unsigned long _ulProp; /**< Free usable property */ + mutable unsigned char _ucFlag; /**< Flag member */ + mutable unsigned long _ulProp; /**< Free usable property */ }; /** @@ -250,15 +250,15 @@ class MeshFacet */ //@{ void SetFlag (TFlagType tF) const - { const_cast(this)->_ucFlag |= static_cast(tF); } + { _ucFlag |= static_cast(tF); } void ResetFlag (TFlagType tF) const - { const_cast(this)->_ucFlag &= ~static_cast(tF); } + { _ucFlag &= ~static_cast(tF); } bool IsFlag (TFlagType tF) const { return (_ucFlag & static_cast(tF)) == static_cast(tF); } void ResetInvalid () const { ResetFlag(INVALID); } void SetProperty(unsigned long uP) const - { const_cast(this)->_ulProp = uP; } + { _ulProp = uP; } /** * Marks a facet as invalid. Should be used only temporary from within an algorithm * (e.g. deletion of several facets) but must not be set permanently. @@ -346,8 +346,8 @@ class MeshFacet } public: - unsigned char _ucFlag; /**< Flag member. */ - unsigned long _ulProp; /**< Free usable property. */ + mutable unsigned char _ucFlag; /**< Flag member. */ + mutable unsigned long _ulProp; /**< Free usable property. */ PointIndex _aulPoints[3]; /**< Indices of corner points. */ FacetIndex _aulNeighbours[3]; /**< Indices of neighbour facets. */ }; @@ -427,7 +427,7 @@ class MeshExport MeshGeomFacet /** * Calculates the facet normal for storing internally. */ - inline void CalcNormal (); + inline void CalcNormal () const; /** * Arrange the facet normal so the both vectors have the same orientation. */ @@ -552,8 +552,8 @@ class MeshExport MeshGeomFacet bool IsCoplanar(const MeshGeomFacet &facet) const; protected: - Base::Vector3f _clNormal; /**< Normal of the facet. */ - bool _bNormalCalculated; /**< True if the normal is already calculated. */ + mutable Base::Vector3f _clNormal; /**< Normal of the facet. */ + mutable bool _bNormalCalculated; /**< True if the normal is already calculated. */ public: Base::Vector3f _aclPoints[3]; /**< Geometric corner points. */ @@ -795,7 +795,7 @@ inline float MeshGeomFacet::DistancePlaneToPoint (const Base::Vector3f &rclPoint return float(fabs(rclPoint.DistanceToPlane(_aclPoints[0], GetNormal()))); } -inline void MeshGeomFacet::CalcNormal () +inline void MeshGeomFacet::CalcNormal () const { _clNormal = (_aclPoints[1] - _aclPoints[0]) % (_aclPoints[2] - _aclPoints[0]); _clNormal.Normalize(); @@ -805,7 +805,7 @@ inline void MeshGeomFacet::CalcNormal () inline Base::Vector3f MeshGeomFacet::GetNormal () const { if (_bNormalCalculated == false) - const_cast(this)->CalcNormal(); + CalcNormal(); return _clNormal; } diff --git a/src/Mod/Mesh/App/Core/Iterator.h b/src/Mod/Mesh/App/Core/Iterator.h index 07e74ed2f2c4..e687b323f493 100644 --- a/src/Mod/Mesh/App/Core/Iterator.h +++ b/src/Mod/Mesh/App/Core/Iterator.h @@ -259,7 +259,7 @@ class MeshExport MeshPointIterator protected: const MeshKernel& _rclMesh; const MeshPointArray& _rclPAry; - MeshPoint _clPoint; + mutable MeshPoint _clPoint; MeshPointArray::_TConstIterator _clIter; bool _bApply; Base::Matrix4D _clTrf; @@ -443,10 +443,11 @@ inline void MeshPointIterator::Transform( const Base::Matrix4D& rclTrf ) } inline const MeshPoint& MeshPointIterator::Dereference () const -{ // We change only the value of the point but not the actual iterator - const_cast(this)->_clPoint = *_clIter; +{ + // We change only the value of the point but not the actual iterator + _clPoint = *_clIter; if ( _bApply ) - const_cast(this)->_clPoint = _clTrf * _clPoint; + _clPoint = _clTrf * _clPoint; return _clPoint; } diff --git a/src/Mod/Mesh/App/Core/KDTree.cpp b/src/Mod/Mesh/App/Core/KDTree.cpp index 2620f8565d5d..a0be6002399a 100644 --- a/src/Mod/Mesh/App/Core/KDTree.cpp +++ b/src/Mod/Mesh/App/Core/KDTree.cpp @@ -45,6 +45,10 @@ struct Point3d { } + Point3d(Point3d&& pnt) : p(pnt.p), i(pnt.i) + { + } + ~Point3d() { } @@ -70,6 +74,12 @@ struct Point3d this->i = other.i; } + inline void operator=(Point3d&& other) + { + this->p = other.p; + this->i = other.i; + } + Base::Vector3f p; PointIndex i; }; diff --git a/src/Mod/Mesh/App/Core/MeshIO.cpp b/src/Mod/Mesh/App/Core/MeshIO.cpp index a2e8a4b1dc59..d83241392ef4 100644 --- a/src/Mod/Mesh/App/Core/MeshIO.cpp +++ b/src/Mod/Mesh/App/Core/MeshIO.cpp @@ -57,39 +57,7 @@ using namespace MeshCore; -char *upper(char * string) -{ - int i; - int l; - - if (string != nullptr) { - l = std::strlen(string); - for (i=0; i MeshInput::supportedMeshFormats() return fmt; } +MeshIO::Format MeshInput::getFormat(const char* FileName) +{ + Base::FileInfo fi(FileName); + if (fi.hasExtension("bms")) { + return MeshIO::Format::BMS; + } + else if (fi.hasExtension("ply")) { + return MeshIO::Format::PLY; + } + else if (fi.hasExtension("stl")) { + return MeshIO::Format::STL; + } + else if (fi.hasExtension("ast")) { + return MeshIO::Format::ASTL; + } + else if (fi.hasExtension("obj")) { + return MeshIO::Format::OBJ; + } + else if (fi.hasExtension("off")) { + return MeshIO::Format::OFF; + } + else if (fi.hasExtension("smf")) { + return MeshIO::Format::SMF; + } + else { + throw Base::FileException("File extension not supported",FileName); + } +} + bool MeshInput::LoadAny(const char* FileName) { // ask for read permission @@ -219,6 +214,8 @@ bool MeshInput::LoadFormat(std::istream &str, MeshIO::Format fmt) return LoadAsciiSTL(str); case MeshIO::BSTL: return LoadBinarySTL(str); + case MeshIO::STL: + return LoadSTL(str); case MeshIO::OBJ: return LoadOBJ(str); case MeshIO::SMF: @@ -262,7 +259,7 @@ bool MeshInput::LoadSTL (std::istream &rstrIn) if (!rstrIn.read(szBuf, ulBytes)) return (ulCt==0); szBuf[ulBytes] = 0; - upper(szBuf); + boost::algorithm::to_upper(szBuf); try { if ((strstr(szBuf, "SOLID") == nullptr) && (strstr(szBuf, "FACET") == nullptr) && (strstr(szBuf, "NORMAL") == nullptr) && @@ -300,7 +297,7 @@ bool MeshInput::LoadSTL (std::istream &rstrIn) /** Loads an OBJ file. */ bool MeshInput::LoadOBJ (std::istream &rstrIn) { - boost::regex rx_m("^mtllib\\s+([\\x21-\\x7E]+)\\s*$"); + boost::regex rx_m("^mtllib\\s+(.+)\\s*$"); boost::regex rx_u("^usemtl\\s+([\\x21-\\x7E]+)\\s*$"); boost::regex rx_g("^g\\s+([\\x21-\\x7E]+)\\s*$"); boost::regex rx_p("^v\\s+([-+]?[0-9]*)\\.?([0-9]+([eE][-+]?[0-9]+)?)" @@ -1343,8 +1340,7 @@ bool MeshInput::LoadAsciiSTL (std::istream &rstrIn) // count facets while (std::getline(rstrIn, line)) { - for (std::string::iterator it = line.begin(); it != line.end(); ++it) - *it = toupper(*it); + boost::algorithm::to_upper(line); if (line.find("ENDFACET") != std::string::npos) ulFacetCt++; // prevent from reading EOF (as I don't know how to reread the file then) @@ -1366,8 +1362,7 @@ bool MeshInput::LoadAsciiSTL (std::istream &rstrIn) ulVertexCt = 0; while (std::getline(rstrIn, line)) { - for (std::string::iterator it = line.begin(); it != line.end(); ++it) - *it = toupper(*it); + boost::algorithm::to_upper(line); if (boost::regex_match(line.c_str(), what, rx_f)) { fX = (float)std::atof(what[1].first); fY = (float)std::atof(what[4].first); @@ -1527,8 +1522,7 @@ bool MeshInput::LoadInventor (std::istream &rstrIn) bool points = false; bool facets = false; while (std::getline(rstrIn, line) && !facets) { - for (std::string::iterator it = line.begin(); it != line.end(); ++it) - *it = toupper(*it); + boost::algorithm::to_upper(line); // read the normals if they are defined if (!normals && line.find("NORMAL {") != std::string::npos) { @@ -1540,8 +1534,7 @@ bool MeshInput::LoadInventor (std::istream &rstrIn) // This is a special case to support also file formats directly written by // Inventor 2.1 classes. std::getline(rstrIn, line); - for (std::string::iterator it = line.begin(); it != line.end(); ++it) - *it = toupper(*it); + boost::algorithm::to_upper(line); std::string::size_type pos = line.find("VECTOR ["); if (pos != std::string::npos) line = line.substr(pos+8); // 8 = length of 'VECTOR [' @@ -1567,8 +1560,7 @@ bool MeshInput::LoadInventor (std::istream &rstrIn) // This is a special case to support also file formats directly written by // Inventor 2.1 classes. std::getline(rstrIn, line); - for (std::string::iterator it = line.begin(); it != line.end(); ++it) - *it = toupper(*it); + boost::algorithm::to_upper(line); std::string::size_type pos = line.find("POINT ["); if (pos != std::string::npos) line = line.substr(pos+7); // 7 = length of 'POINT [' @@ -1595,8 +1587,7 @@ bool MeshInput::LoadInventor (std::istream &rstrIn) // Furthermore we must check whether more than one triple is given per line, which // is handled in the while-loop. std::getline(rstrIn, line); - for (std::string::iterator it = line.begin(); it != line.end(); ++it) - *it = toupper(*it); + boost::algorithm::to_upper(line); std::string::size_type pos = line.find("COORDINDEX ["); if (pos != std::string::npos) line = line.substr(pos+12); // 12 = length of 'COORDINDEX [' @@ -1660,7 +1651,7 @@ bool MeshInput::LoadNastran (std::istream &rstrIn) int badElementCounter = 0; while (std::getline(rstrIn, line)) { - upper(ltrim(line)); + boost::algorithm::to_upper(ltrim(line)); if (line.empty()) { // Skip all the following tests } diff --git a/src/Mod/Mesh/App/Core/MeshIO.h b/src/Mod/Mesh/App/Core/MeshIO.h index d7ff5c42e11b..acd08f446be0 100644 --- a/src/Mod/Mesh/App/Core/MeshIO.h +++ b/src/Mod/Mesh/App/Core/MeshIO.h @@ -44,6 +44,7 @@ namespace MeshIO { BMS, ASTL, BSTL, + STL, OBJ, OFF, IDTF, @@ -74,7 +75,7 @@ struct MeshExport Material { Material() : binding(MeshIO::OVERALL) {} MeshIO::Binding binding; - std::string library; + mutable std::string library; std::vector diffuseColor; }; @@ -134,6 +135,7 @@ class MeshExport MeshInput bool LoadCadmouldFE (std::ifstream &rstrIn); static std::vector supportedMeshFormats(); + static MeshIO::Format getFormat(const char* FileName); protected: MeshKernel &_rclMesh; /**< reference to mesh data structure */ diff --git a/src/Mod/Mesh/App/Core/MeshKernel.cpp b/src/Mod/Mesh/App/Core/MeshKernel.cpp index cca4dd085ffe..d30b8c329c80 100644 --- a/src/Mod/Mesh/App/Core/MeshKernel.cpp +++ b/src/Mod/Mesh/App/Core/MeshKernel.cpp @@ -1053,7 +1053,7 @@ void MeshKernel::Smooth(int iterations, float stepsize) LaplaceSmoothing(*this).Smooth(iterations); } -void MeshKernel::RecalcBoundBox () +void MeshKernel::RecalcBoundBox () const { _clBoundBox.SetVoid(); for (MeshPointArray::_TConstIterator pI = _aclPointArray.begin(); pI != _aclPointArray.end(); pI++) diff --git a/src/Mod/Mesh/App/Core/MeshKernel.h b/src/Mod/Mesh/App/Core/MeshKernel.h index fc7b4abb3259..6c9a03206092 100644 --- a/src/Mod/Mesh/App/Core/MeshKernel.h +++ b/src/Mod/Mesh/App/Core/MeshKernel.h @@ -100,7 +100,7 @@ class MeshExport MeshKernel /** Forces a recalculation of the bounding box. This method should be called after * the removal of points.or after a transformation of the data structure. */ - void RecalcBoundBox (); + void RecalcBoundBox () const; /** Returns the point at the given index. This method is rather slow and should be * called occasionally only. For fast access the MeshPointIterator interfsce should @@ -124,6 +124,9 @@ class MeshExport MeshKernel /** Returns the point indices of the given facet index. */ inline void GetFacetPoints (FacetIndex ulFaIndex, PointIndex &rclP0, PointIndex &rclP1, PointIndex &rclP2) const; + /** Returns the point indices of the given facet index. */ + inline void SetFacetPoints (FacetIndex ulFaIndex, PointIndex rclP0, + PointIndex rclP1, PointIndex rclP2); /** Returns the point indices of the given facet indices. */ std::vector GetFacetPoints(const std::vector&) const; /** Returns the facet indices that share the given point indices. */ @@ -446,7 +449,7 @@ class MeshExport MeshKernel MeshPointArray _aclPointArray; /**< Holds the array of geometric points. */ MeshFacetArray _aclFacetArray; /**< Holds the array of facets. */ - Base::BoundBox3f _clBoundBox; /**< The current calculated bounding box. */ + mutable Base::BoundBox3f _clBoundBox; /**< The current calculated bounding box. */ bool _bValid; /**< Current state of validality. */ // friends @@ -555,9 +558,19 @@ inline void MeshKernel::GetFacetPoints (FacetIndex ulFaIndex, PointIndex &rclP0, { assert(ulFaIndex < _aclFacetArray.size()); const MeshFacet& rclFacet = _aclFacetArray[ulFaIndex]; - rclP0 = rclFacet._aulPoints[0]; - rclP1 = rclFacet._aulPoints[1]; - rclP2 = rclFacet._aulPoints[2]; + rclP0 = rclFacet._aulPoints[0]; + rclP1 = rclFacet._aulPoints[1]; + rclP2 = rclFacet._aulPoints[2]; +} + +inline void MeshKernel::SetFacetPoints (FacetIndex ulFaIndex, PointIndex rclP0, + PointIndex rclP1, PointIndex rclP2) +{ + assert(ulFaIndex < _aclFacetArray.size()); + MeshFacet& rclFacet = _aclFacetArray[ulFaIndex]; + rclFacet._aulPoints[0] = rclP0; + rclFacet._aulPoints[1] = rclP1; + rclFacet._aulPoints[2] = rclP2; } diff --git a/src/Mod/Mesh/App/Core/Triangulation.cpp b/src/Mod/Mesh/App/Core/Triangulation.cpp index bb4fc1510a05..504c6726a245 100644 --- a/src/Mod/Mesh/App/Core/Triangulation.cpp +++ b/src/Mod/Mesh/App/Core/Triangulation.cpp @@ -606,10 +606,16 @@ struct Vertex2d_Less bool operator()(const Base::Vector3f& p, const Base::Vector3f& q) const { if (fabs(p.x - q.x) < MeshDefinitions::_fMinPointDistanceD1) { - if (fabs(p.y - q.y) < MeshDefinitions::_fMinPointDistanceD1) { - return false; - } else return p.y < q.y; - } else return p.x < q.x; + if (fabs(p.y - q.y) < MeshDefinitions::_fMinPointDistanceD1) { + return false; + } + else { + return p.y < q.y; + } + } + else { + return p.x < q.x; + } } }; struct Vertex2d_EqualTo diff --git a/src/Mod/Mesh/Gui/DlgSmoothing.cpp b/src/Mod/Mesh/Gui/DlgSmoothing.cpp index 1f2fbecdf2d4..ee89b4db3c31 100644 --- a/src/Mod/Mesh/Gui/DlgSmoothing.cpp +++ b/src/Mod/Mesh/Gui/DlgSmoothing.cpp @@ -107,7 +107,7 @@ bool DlgSmoothing::smoothSelection() const void DlgSmoothing::on_checkBoxSelection_toggled(bool on) { - /*emit*/ toggledSelection(on); + Q_EMIT toggledSelection(on); } // ------------------------------------------------ diff --git a/src/Mod/Mesh/Gui/MeshEditor.cpp b/src/Mod/Mesh/Gui/MeshEditor.cpp index fe94a47568c1..7bf35c8b980c 100644 --- a/src/Mod/Mesh/Gui/MeshEditor.cpp +++ b/src/Mod/Mesh/Gui/MeshEditor.cpp @@ -342,9 +342,9 @@ void MeshFaceAddition::showMarker(SoPickedPoint* pp) void MeshFaceAddition::addFacetCallback(void * ud, SoEventCallback * n) { - MeshFaceAddition* that = reinterpret_cast(ud); + MeshFaceAddition* that = static_cast(ud); ViewProviderFace* face = that->faceView; - Gui::View3DInventorViewer* view = reinterpret_cast(n->getUserData()); + Gui::View3DInventorViewer* view = static_cast(n->getUserData()); const SoEvent* ev = n->getEvent(); // If we are in navigation mode then ignore all but key events @@ -653,8 +653,8 @@ float MeshFillHole::findClosestPoint(const SbLine& ray, const TBoundary& polygon void MeshFillHole::fileHoleCallback(void * ud, SoEventCallback * n) { - MeshFillHole* self = reinterpret_cast(ud); - Gui::View3DInventorViewer* view = reinterpret_cast(n->getUserData()); + MeshFillHole* self = static_cast(ud); + Gui::View3DInventorViewer* view = static_cast(n->getUserData()); const SoEvent* ev = n->getEvent(); if (ev->getTypeId() == SoLocation2Event::getClassTypeId()) { diff --git a/src/Mod/Mesh/Gui/MeshSelection.cpp b/src/Mod/Mesh/Gui/MeshSelection.cpp index 8e2936326cb5..a6225086ee9e 100644 --- a/src/Mod/Mesh/Gui/MeshSelection.cpp +++ b/src/Mod/Mesh/Gui/MeshSelection.cpp @@ -453,8 +453,8 @@ void MeshSelection::setRemoveComponentOnClick(bool on) void MeshSelection::selectGLCallback(void * ud, SoEventCallback * n) { // When this callback function is invoked we must leave the edit mode - Gui::View3DInventorViewer* view = reinterpret_cast(n->getUserData()); - MeshSelection* self = reinterpret_cast(ud); + Gui::View3DInventorViewer* view = static_cast(n->getUserData()); + MeshSelection* self = static_cast(ud); self->stopInteractiveCallback(view); n->setHandled(); std::vector polygon = view->getGLPolygon(); @@ -534,7 +534,7 @@ void MeshSelection::pickFaceCallback(void * ud, SoEventCallback * n) // handle only mouse button events if (n->getEvent()->isOfType(SoMouseButtonEvent::getClassTypeId())) { const SoMouseButtonEvent * mbe = static_cast(n->getEvent()); - Gui::View3DInventorViewer* view = reinterpret_cast(n->getUserData()); + Gui::View3DInventorViewer* view = static_cast(n->getUserData()); // Mark all incoming mouse button events as handled, especially, to deactivate the selection node n->getAction()->setHandled(); @@ -553,7 +553,7 @@ void MeshSelection::pickFaceCallback(void * ud, SoEventCallback * n) if (!vp || !vp->getTypeId().isDerivedFrom(ViewProviderMesh::getClassTypeId())) return; ViewProviderMesh* mesh = static_cast(vp); - MeshSelection* self = reinterpret_cast(ud); + MeshSelection* self = static_cast(ud); std::list views = self->getViewProviders(); if (std::find(views.begin(), views.end(), mesh) == views.end()) return; diff --git a/src/Mod/Mesh/Gui/ViewProvider.cpp b/src/Mod/Mesh/Gui/ViewProvider.cpp index 20e276bef968..dde3cc86807b 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.cpp +++ b/src/Mod/Mesh/Gui/ViewProvider.cpp @@ -741,14 +741,20 @@ void ViewProviderMesh::setupContextMenu(QMenu* menu, QObject* receiver, const ch QAction* act = menu->addAction(QObject::tr("Display components")); act->setCheckable(true); act->setChecked(pcMatBinding->value.getValue() == SoMaterialBinding::PER_FACE && - highlightMode == "Component"); + highlightMode == HighlighMode::Component); func->toggle(act, boost::bind(&ViewProviderMesh::setHighlightedComponents, this, bp::_1)); QAction* seg = menu->addAction(QObject::tr("Display segments")); seg->setCheckable(true); seg->setChecked(pcMatBinding->value.getValue() == SoMaterialBinding::PER_FACE && - highlightMode == "Segment"); + highlightMode == HighlighMode::Segment); func->toggle(seg, boost::bind(&ViewProviderMesh::setHighlightedSegments, this, bp::_1)); + + QAction* col = menu->addAction(QObject::tr("Display colors")); + col->setVisible(canHighlightColors()); + col->setCheckable(true); + col->setChecked(highlightMode == HighlighMode::Color); + func->toggle(col, boost::bind(&ViewProviderMesh::setHighlightedColors, this, bp::_1)); } bool ViewProviderMesh::setEdit(int ModNum) @@ -913,7 +919,7 @@ void ViewProviderMesh::clipMeshCallback(void * ud, SoEventCallback * n) Gui::WaitCursor wc; // When this callback function is invoked we must in either case leave the edit mode - Gui::View3DInventorViewer* view = reinterpret_cast(n->getUserData()); + Gui::View3DInventorViewer* view = static_cast(n->getUserData()); view->setEditing(false); view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), clipMeshCallback,ud); n->setHandled(); @@ -974,7 +980,7 @@ void ViewProviderMesh::trimMeshCallback(void * ud, SoEventCallback * n) Gui::WaitCursor wc; // When this callback function is invoked we must in either case leave the edit mode - Gui::View3DInventorViewer* view = reinterpret_cast(n->getUserData()); + Gui::View3DInventorViewer* view = static_cast(n->getUserData()); view->setEditing(false); view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), trimMeshCallback,ud); n->setHandled(); @@ -1035,7 +1041,7 @@ void ViewProviderMesh::partMeshCallback(void * ud, SoEventCallback * cb) Gui::WaitCursor wc; // When this callback function is invoked we must in either case leave the edit mode - Gui::View3DInventorViewer* view = reinterpret_cast(cb->getUserData()); + Gui::View3DInventorViewer* view = static_cast(cb->getUserData()); view->setEditing(false); view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), partMeshCallback,ud); cb->setHandled(); @@ -1099,7 +1105,7 @@ void ViewProviderMesh::segmMeshCallback(void * ud, SoEventCallback * cb) Gui::WaitCursor wc; // When this callback function is invoked we must in either case leave the edit mode - Gui::View3DInventorViewer* view = reinterpret_cast(cb->getUserData()); + Gui::View3DInventorViewer* view = static_cast(cb->getUserData()); view->setEditing(false); view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), segmMeshCallback,ud); cb->setHandled(); @@ -1160,7 +1166,7 @@ void ViewProviderMesh::segmMeshCallback(void * ud, SoEventCallback * cb) void ViewProviderMesh::selectGLCallback(void * ud, SoEventCallback * n) { // When this callback function is invoked we must in either case leave the edit mode - Gui::View3DInventorViewer* view = reinterpret_cast(n->getUserData()); + Gui::View3DInventorViewer* view = static_cast(n->getUserData()); view->setEditing(false); view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), selectGLCallback,ud); n->setHandled(); @@ -1332,7 +1338,7 @@ std::vector ViewProviderMesh::getVisibleFacetsAfterZoom(const void ViewProviderMesh::renderGLCallback(void * ud, SoAction * action) { if (action->isOfType(SoGLRenderAction::getClassTypeId())) { - ViewProviderMesh* mesh = reinterpret_cast(ud); + ViewProviderMesh* mesh = static_cast(ud); Gui::SoVisibleFaceAction fa; fa.apply(mesh->getRoot()); } @@ -1411,11 +1417,6 @@ std::vector ViewProviderMesh::getVisibleFacets(const SbViewpor root->ref(); root->addChild(camera); -#if 0 - SoCallback* cb = new SoCallback; - cb->setCallback(renderGLCallback, const_cast(this)); - root->addChild(cb); -#else SoLightModel* lm = new SoLightModel(); lm->model = SoLightModel::BASE_COLOR; root->addChild(lm); @@ -1438,20 +1439,13 @@ std::vector ViewProviderMesh::getVisibleFacets(const SbViewpor //root->addChild(hints); root->addChild(mat); root->addChild(bind); -#endif root->addChild(this->getCoordNode()); root->addChild(this->getShapeNode()); // Coin3d's off-screen renderer doesn't work out-of-the-box any more on most recent Linux systems. // So, use FreeCAD's offscreen renderer now. -#if 0 - Gui::SoFCOffscreenRenderer& renderer = Gui::SoFCOffscreenRenderer::instance(); - renderer.setViewportRegion(vp); - renderer.setBackgroundColor(SbColor(0.0f, 0.0f, 0.0f)); -#else Gui::SoQtOffscreenRenderer renderer(vp); renderer.setBackgroundColor(SbColor4f(0.0f, 0.0f, 0.0f)); -#endif QImage img; renderer.render(root); @@ -1569,7 +1563,7 @@ void ViewProviderMesh::segmentMesh(const MeshCore::MeshKernel& toolMesh, const B void ViewProviderMesh::faceInfoCallback(void * ud, SoEventCallback * n) { const SoMouseButtonEvent * mbe = (SoMouseButtonEvent *)n->getEvent(); - Gui::View3DInventorViewer* view = reinterpret_cast(n->getUserData()); + Gui::View3DInventorViewer* view = static_cast(n->getUserData()); // Mark all incoming mouse button events as handled, especially, to deactivate the selection node n->getAction()->setHandled(); @@ -1651,7 +1645,7 @@ void ViewProviderMesh::faceInfoCallback(void * ud, SoEventCallback * n) void ViewProviderMesh::fillHoleCallback(void * ud, SoEventCallback * n) { const SoMouseButtonEvent * mbe = (SoMouseButtonEvent *)n->getEvent(); - Gui::View3DInventorViewer* view = reinterpret_cast(n->getUserData()); + Gui::View3DInventorViewer* view = static_cast(n->getUserData()); // Mark all incoming mouse button events as handled, especially, to deactivate the selection node n->getAction()->setHandled(); @@ -1697,7 +1691,7 @@ void ViewProviderMesh::markPartCallback(void * ud, SoEventCallback * n) // handle only mouse button events if (n->getEvent()->isOfType(SoMouseButtonEvent::getClassTypeId())) { const SoMouseButtonEvent * mbe = static_cast(n->getEvent()); - Gui::View3DInventorViewer* view = reinterpret_cast(n->getUserData()); + Gui::View3DInventorViewer* view = static_cast(n->getUserData()); // Mark all incoming mouse button events as handled, especially, to deactivate the selection node n->getAction()->setHandled(); @@ -1786,7 +1780,7 @@ void ViewProviderMesh::fillHole(Mesh::FacetIndex uFacet) // get the boundary to the picked facet std::list aBorder; - Mesh::Feature* fea = reinterpret_cast(this->getObject()); + Mesh::Feature* fea = static_cast(this->getObject()); const MeshCore::MeshKernel& rKernel = fea->Mesh.getValue().getKernel(); MeshCore::MeshRefPointToFacets cPt2Fac(rKernel); MeshCore::MeshAlgorithm meshAlg(rKernel); @@ -2148,11 +2142,11 @@ void ViewProviderMesh::unhighlightSelection() void ViewProviderMesh::setHighlightedComponents(bool on) { if (on) { - highlightMode = "Component"; + highlightMode = HighlighMode::Component; highlightComponents(); } else { - highlightMode.clear(); + highlightMode = HighlighMode::None; unhighlightSelection(); } } @@ -2183,11 +2177,11 @@ void ViewProviderMesh::highlightComponents() void ViewProviderMesh::setHighlightedSegments(bool on) { if (on) { - highlightMode = "Segment"; + highlightMode = HighlighMode::Segment; highlightSegments(); } else { - highlightMode.clear(); + highlightMode = HighlighMode::None; unhighlightSelection(); } } @@ -2239,6 +2233,52 @@ void ViewProviderMesh::highlightSegments(const std::vector& colors) } } +void ViewProviderMesh::setHighlightedColors(bool on) +{ + if (on) { + highlightMode = HighlighMode::Color; + highlightColors(); + } + else { + highlightMode = HighlighMode::None; + unhighlightSelection(); + } +} + +void ViewProviderMesh::highlightColors() +{ + const Mesh::MeshObject& rMesh = static_cast(pcObject)->Mesh.getValue(); + { + App::PropertyColorList* prop = Base::freecad_dynamic_cast(pcObject->getPropertyByName("FaceColors")); + if (prop && prop->getSize() == int(rMesh.countFacets())) { + setColorPerFace(prop); + } + } + { + App::PropertyColorList* prop = Base::freecad_dynamic_cast(pcObject->getPropertyByName("VertexColors")); + if (prop && prop->getSize() == int(rMesh.countPoints())) { + setColorPerVertex(prop); + } + } +} + +bool ViewProviderMesh::canHighlightColors() const +{ + const Mesh::MeshObject& rMesh = static_cast(pcObject)->Mesh.getValue(); + { + App::PropertyColorList* prop = Base::freecad_dynamic_cast(pcObject->getPropertyByName("FaceColors")); + if (prop && prop->getSize() == int(rMesh.countFacets())) + return true; + } + { + App::PropertyColorList* prop = Base::freecad_dynamic_cast(pcObject->getPropertyByName("VertexColors")); + if (prop && prop->getSize() == int(rMesh.countPoints())) + return true; + } + + return false; +} + PyObject* ViewProviderMesh::getPyObject() { if (!pyViewObject) diff --git a/src/Mod/Mesh/Gui/ViewProvider.h b/src/Mod/Mesh/Gui/ViewProvider.h index 9f0e4ea47f3c..934122e5a424 100644 --- a/src/Mod/Mesh/Gui/ViewProvider.h +++ b/src/Mod/Mesh/Gui/ViewProvider.h @@ -191,6 +191,9 @@ class MeshGuiExport ViewProviderMesh : public Gui::ViewProviderGeometryObject void setHighlightedComponents(bool); void highlightSegments(); void setHighlightedSegments(bool); + void setHighlightedColors(bool); + void highlightColors(); + bool canHighlightColors() const; App::PropertyColorList* getColorProperty() const; void tryColorPerVertexOrFace(bool); void setColorPerVertex(const App::PropertyColorList*); @@ -218,7 +221,13 @@ class MeshGuiExport ViewProviderMesh : public Gui::ViewProviderGeometryObject static void panCamera(SoCamera*, float, const SbPlane&, const SbVec2f&, const SbVec2f&); protected: - std::string highlightMode; + enum class HighlighMode { + None, + Component, + Segment, + Color + }; + HighlighMode highlightMode; Gui::SoFCSelection * pcHighlight; SoGroup * pcShapeGroup; SoDrawStyle * pcLineStyle; diff --git a/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp b/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp index ce99ac21ce81..86d5aa8cddae 100644 --- a/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp +++ b/src/Mod/Mesh/Gui/ViewProviderCurvature.cpp @@ -447,7 +447,7 @@ class Annotation static void run(void * data, SoSensor * sensor) { - Annotation* self = reinterpret_cast(data); + Annotation* self = static_cast(data); self->show(); delete self; delete sensor; @@ -497,7 +497,7 @@ class Annotation void ViewProviderMeshCurvature::curvatureInfoCallback(void * ud, SoEventCallback * n) { - Gui::View3DInventorViewer* view = reinterpret_cast(n->getUserData()); + Gui::View3DInventorViewer* view = static_cast(n->getUserData()); const SoEvent* ev = n->getEvent(); if (ev->getTypeId() == SoMouseButtonEvent::getClassTypeId()) { const SoMouseButtonEvent * mbe = static_cast(ev); diff --git a/src/Mod/Mesh/Init.py b/src/Mod/Mesh/Init.py index e717b86636cf..019cbfc2f48f 100644 --- a/src/Mod/Mesh/Init.py +++ b/src/Mod/Mesh/Init.py @@ -1,20 +1,22 @@ -# FreeCAD init script of the Mesh module -# (c) 2004 Werner Mayer LGPL - -# Append the open handler -FreeCAD.addImportType("STL Mesh (*.stl *.ast)", "Mesh") -FreeCAD.addImportType("Binary Mesh (*.bms)","Mesh") -FreeCAD.addImportType("Alias Mesh (*.obj)","Mesh") -FreeCAD.addImportType("Object File Format Mesh (*.off)","Mesh") -FreeCAD.addImportType("Stanford Triangle Mesh (*.ply)","Mesh") -FreeCAD.addImportType("Simple Model Format (*.smf)","Mesh") - -FreeCAD.addExportType("STL Mesh (*.stl *.ast)", "Mesh") -FreeCAD.addExportType("Binary Mesh (*.bms)","Mesh") -FreeCAD.addExportType("Alias Mesh (*.obj)","Mesh") -FreeCAD.addExportType("Object File Format Mesh (*.off)","Mesh") -FreeCAD.addExportType("Stanford Triangle Mesh (*.ply)","Mesh") -FreeCAD.addExportType("Additive Manufacturing Format (*.amf)","Mesh") -FreeCAD.addExportType("Simple Model Format (*.smf)","Mesh") - -FreeCAD.__unit_test__ += [ "MeshTestsApp" ] +# FreeCAD init script of the Mesh module +# (c) 2004 Werner Mayer LGPL + +import FreeCAD + +# Append the open handler +FreeCAD.addImportType("STL Mesh (*.stl *.ast)", "Mesh") +FreeCAD.addImportType("Binary Mesh (*.bms)", "Mesh") +FreeCAD.addImportType("Alias Mesh (*.obj)", "Mesh") +FreeCAD.addImportType("Object File Format Mesh (*.off)", "Mesh") +FreeCAD.addImportType("Stanford Triangle Mesh (*.ply)", "Mesh") +FreeCAD.addImportType("Simple Model Format (*.smf)", "Mesh") + +FreeCAD.addExportType("STL Mesh (*.stl *.ast)", "Mesh") +FreeCAD.addExportType("Binary Mesh (*.bms)", "Mesh") +FreeCAD.addExportType("Alias Mesh (*.obj)", "Mesh") +FreeCAD.addExportType("Object File Format Mesh (*.off)", "Mesh") +FreeCAD.addExportType("Stanford Triangle Mesh (*.ply)", "Mesh") +FreeCAD.addExportType("Additive Manufacturing Format (*.amf)", "Mesh") +FreeCAD.addExportType("Simple Model Format (*.smf)", "Mesh") + +FreeCAD.__unit_test__ += [ "MeshTestsApp" ] diff --git a/src/Mod/Part/Gui/TaskAttacher.cpp b/src/Mod/Part/Gui/TaskAttacher.cpp index bb946d218380..28ce2ac5ff07 100644 --- a/src/Mod/Part/Gui/TaskAttacher.cpp +++ b/src/Mod/Part/Gui/TaskAttacher.cpp @@ -380,7 +380,7 @@ void TaskAttacher::onSelectionChanged(const Gui::SelectionChanges& msg) if ((refs[r] == selObj) && (refnames[r] == subname)) return; - if (autoNext && iActiveRef > 0 && iActiveRef == (ssize_t) refnames.size()){ + if (autoNext && iActiveRef > 0 && iActiveRef == static_cast(refnames.size())){ if (refs[iActiveRef-1] == selObj && refnames[iActiveRef-1].length() != 0 && subname.length() == 0){ //A whole object was selected by clicking it twice. Fill it @@ -390,7 +390,7 @@ void TaskAttacher::onSelectionChanged(const Gui::SelectionChanges& msg) iActiveRef--; } } - if (iActiveRef < (ssize_t) refs.size()) { + if (iActiveRef < static_cast(refs.size())) { refs[iActiveRef] = selObj; refnames[iActiveRef] = subname; } else { diff --git a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp index 7138a469f420..bbaa4d4cd4e9 100644 --- a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp @@ -527,7 +527,7 @@ void ComboLinks::clear() App::PropertyLinkSub &ComboLinks::getLink(int index) const { - if (index < 0 || index > (ssize_t) linksInList.size()-1) + if (index < 0 || index > static_cast(linksInList.size())-1) throw Base::IndexError("ComboLinks::getLink:Index out of range"); if (linksInList[index]->getValue() && doc && !(doc->isIn(linksInList[index]->getValue()))) throw Base::ValueError("Linked object is not in the document; it may have been deleted"); diff --git a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp index 887ca2d3a670..c6c9dcfd2de8 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderShapeBinder.cpp @@ -165,13 +165,13 @@ void ViewProviderShapeBinder::highlightReferences(const bool on, bool /*auxiliar if (e.compare(0, 4, "Edge") == 0) { int idx = std::stoi(e.substr(4)) - 1; assert(idx >= 0); - if (idx < (ssize_t)lcolors.size()) + if (idx < static_cast(lcolors.size())) lcolors[idx] = App::Color(1.0, 0.0, 1.0); // magenta } else if (e.compare(0, 4, "Face") == 0) { int idx = std::stoi(e.substr(4)) - 1; assert(idx >= 0); - if (idx < (ssize_t)fcolors.size()) + if (idx < static_cast(fcolors.size())) fcolors[idx] = App::Color(1.0, 0.0, 1.0); // magenta } } diff --git a/src/Mod/Points/App/PointsAlgos.cpp b/src/Mod/Points/App/PointsAlgos.cpp index 3f92776e42a9..126ade2a7eeb 100644 --- a/src/Mod/Points/App/PointsAlgos.cpp +++ b/src/Mod/Points/App/PointsAlgos.cpp @@ -213,19 +213,25 @@ void AscReader::read(const std::string& filename) namespace Points { class Converter { public: - virtual ~Converter() { - } - virtual std::string toString(float) const = 0; + Converter() = default; + virtual ~Converter() = default; + virtual std::string toString(double) const = 0; virtual double toDouble(Base::InputStream&) const = 0; virtual int getSizeOf() const = 0; + +private: + Converter(const Converter&) = delete; + Converter(Converter&&) = delete; + Converter& operator= (const Converter&) = delete; + Converter& operator= (Converter&&) = delete; }; template class ConverterT : public Converter { public: - virtual std::string toString(float f) const { + virtual std::string toString(double f) const { T c = static_cast(f); std::ostringstream oss; - oss.precision(6); + oss.precision(7); oss.setf(std::ostringstream::showpoint); oss << c; return oss.str(); @@ -1818,7 +1824,7 @@ void PcdWriter::write(const std::string& filename) std::size_t numPoints = points.size(); const std::vector& pts = points.getBasicPoints(); - Eigen::MatrixXf data(numPoints, fields.size()); + Eigen::MatrixXd data(numPoints, fields.size()); if (placement.isIdentity()) { for (std::size_t i=0; isbScale->value().getValue()); - QString qScaleType = ui->cmbScaleType->currentText(); - std::string sScaleType = Base::Tools::toStdString(qScaleType); - Command::doCommand(Command::Doc,"App.ActiveDocument.%s.ScaleType = '%s'", - m_sectionName.c_str(), - sScaleType.c_str()); + int scaleType = ui->cmbScaleType->currentIndex(); + Command::doCommand(Command::Doc,"App.ActiveDocument.%s.ScaleType = %d", + m_sectionName.c_str(), scaleType); App::DocumentObject* newObj = m_base->getDocument()->getObject(m_sectionName.c_str()); m_section = dynamic_cast(newObj); @@ -487,11 +485,9 @@ void TaskSectionView::updateSectionView(void) Command::doCommand(Command::Doc,"App.ActiveDocument.%s.Scale = %0.6f", m_sectionName.c_str(), ui->sbScale->value().getValue()); - QString qScaleType = ui->cmbScaleType->currentText(); - std::string sScaleType = Base::Tools::toStdString(qScaleType); - Command::doCommand(Command::Doc,"App.ActiveDocument.%s.ScaleType = '%s'", - m_sectionName.c_str(), - sScaleType.c_str()); + int scaleType = ui->cmbScaleType->currentIndex(); + Command::doCommand(Command::Doc,"App.ActiveDocument.%s.ScaleType = %d", + m_sectionName.c_str(), scaleType); m_section->setCSFromBase(m_dirName.c_str()); } Gui::Command::commitCommand(); diff --git a/src/Mod/Test/BaseTests.py b/src/Mod/Test/BaseTests.py index ceabdd2576e3..2d658e32b744 100644 --- a/src/Mod/Test/BaseTests.py +++ b/src/Mod/Test/BaseTests.py @@ -369,6 +369,13 @@ class MatrixTestCase(unittest.TestCase): def setUp(self): self.mat = FreeCAD.Matrix() + def testOrder(self): + self.mat = FreeCAD.Matrix(1.0,2.0,3.0,4.0) + self.assertEqual(self.mat.A11, 1.0) + self.assertEqual(self.mat.A12, 2.0) + self.assertEqual(self.mat.A13, 3.0) + self.assertEqual(self.mat.A14, 4.0) + def testScalar(self): res = self.mat * 0.0 for i in range(16):