From 394085133ccb4dad6e4bf0edc93e97b94b6b4463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Tr=C3=B6ger?= Date: Mon, 13 May 2013 18:05:57 +0200 Subject: [PATCH] add missing files --- .../Assembly/App/opendcm/core/equations.hpp | 2 +- .../App/opendcm/module3d/coincident.hpp | 168 ++++++ .../App/opendcm/module3d/parallel.hpp | 37 +- src/Mod/Assembly/Gui/AlignmentDialog.ui | 111 ++++ .../icons/Assembly_ConstraintAlignment.svg | 337 +++++++++++ .../icons/Assembly_ConstraintCoincidence.svg | 483 ++++++++++++++++ .../icons/Assembly_ConstraintDistance.svg | 369 ++++++++++++ .../icons/Assembly_ConstraintOrientation.svg | 541 ++++++++++++++++++ .../Gui/ViewProviderConstraintFix.cpp | 34 ++ .../Assembly/Gui/ViewProviderConstraintFix.h | 42 ++ 10 files changed, 2109 insertions(+), 15 deletions(-) create mode 100644 src/Mod/Assembly/App/opendcm/module3d/coincident.hpp create mode 100644 src/Mod/Assembly/Gui/AlignmentDialog.ui create mode 100644 src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintAlignment.svg create mode 100644 src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintCoincidence.svg create mode 100644 src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintDistance.svg create mode 100644 src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintOrientation.svg create mode 100644 src/Mod/Assembly/Gui/ViewProviderConstraintFix.cpp create mode 100644 src/Mod/Assembly/Gui/ViewProviderConstraintFix.h diff --git a/src/Mod/Assembly/App/opendcm/core/equations.hpp b/src/Mod/Assembly/App/opendcm/core/equations.hpp index d852e9b56..8f3caae45 100644 --- a/src/Mod/Assembly/App/opendcm/core/equations.hpp +++ b/src/Mod/Assembly/App/opendcm/core/equations.hpp @@ -238,7 +238,7 @@ struct Distance : public Equation { }; //the possible directions -enum Direction { equal, opposite, parallel, perpendicular }; +enum Direction { parallel, equal, opposite, perpendicular }; struct Orientation : public Equation { diff --git a/src/Mod/Assembly/App/opendcm/module3d/coincident.hpp b/src/Mod/Assembly/App/opendcm/module3d/coincident.hpp new file mode 100644 index 000000000..0bbe62b85 --- /dev/null +++ b/src/Mod/Assembly/App/opendcm/module3d/coincident.hpp @@ -0,0 +1,168 @@ +/* + openDCM, dimensional constraint manager + Copyright (C) 2013 Stefan Troeger + + This library is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more detemplate tails. + + You should have received a copy of the GNU Lesser General Public License along + with this library; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef DCM_COINCIDENT_HPP +#define DCM_COINCIDENT_HPP + +#include +#include "distance.hpp" + +namespace dcm { + +namespace details { + +//we need a custom orientation type to allow coincidents with points +struct ci_orientation : public Equation { + + using Equation::operator=; + ci_orientation() : Equation(parallel) {}; + + + template< typename Kernel, typename Tag1, typename Tag2 > + struct type : public PseudoScale { + + typedef typename Kernel::number_type Scalar; + typedef typename Kernel::VectorMap Vector; + typedef std::vector > Vec; + + option_type value; + Scalar calculate(Vector& param1, Vector& param2) { + assert(false); + return 0; + }; + Scalar calculateGradientFirst(Vector& param1, Vector& param2, Vector& dparam1) { + assert(false); + return 0; + }; + Scalar calculateGradientSecond(Vector& param1, Vector& param2, Vector& dparam2) { + assert(false); + return 0; + }; + void calculateGradientFirstComplete(Vector& param1, Vector& param2, Vector& gradient) { + assert(false); + }; + void calculateGradientSecondComplete(Vector& param1, Vector& param2, Vector& gradient) { + assert(false); + }; + }; +}; + +template< typename Kernel > +struct ci_orientation::type< Kernel, tag::point3D, tag::point3D > : public dcm::PseudoScale { + + typedef typename Kernel::number_type Scalar; + typedef typename Kernel::VectorMap Vector; + + option_type value; + Scalar calculate(Vector& param1, Vector& param2) { + return 0; + }; + Scalar calculateGradientFirst(Vector& param1, Vector& param2, Vector& dparam1) { + return 0; + }; + Scalar calculateGradientSecond(Vector& param1, Vector& param2, Vector& dparam2) { + return 0; + }; + void calculateGradientFirstComplete(Vector& param1, Vector& param2, Vector& gradient) { + gradient.setZero(); + }; + void calculateGradientSecondComplete(Vector& param1, Vector& param2, Vector& gradient) { + gradient.setZero(); + }; +}; + +template< typename Kernel > +struct ci_orientation::type< Kernel, tag::point3D, tag::line3D > : public ci_orientation::type< Kernel, tag::point3D, tag::point3D > {}; + +template< typename Kernel > +struct ci_orientation::type< Kernel, tag::point3D, tag::plane3D > : public ci_orientation::type< Kernel, tag::point3D, tag::point3D > {}; + +template< typename Kernel > +struct ci_orientation::type< Kernel, tag::point3D, tag::cylinder3D > : public ci_orientation::type< Kernel, tag::point3D, tag::point3D > {}; + +template< typename Kernel > +struct ci_orientation::type< Kernel, tag::line3D, tag::line3D > : public dcm::Orientation::type< Kernel, tag::line3D, tag::line3D > {}; + +template< typename Kernel > +struct ci_orientation::type< Kernel, tag::line3D, tag::plane3D > : public dcm::Orientation::type< Kernel, tag::line3D, tag::plane3D > {}; + +template< typename Kernel > +struct ci_orientation::type< Kernel, tag::line3D, tag::cylinder3D > : public dcm::Orientation::type< Kernel, tag::line3D, tag::cylinder3D > {}; + +template< typename Kernel > +struct ci_orientation::type< Kernel, tag::plane3D, tag::plane3D > : public dcm::Orientation::type< Kernel, tag::plane3D, tag::plane3D > {}; + +template< typename Kernel > +struct ci_orientation::type< Kernel, tag::plane3D, tag::cylinder3D > : public dcm::Orientation::type< Kernel, tag::plane3D, tag::cylinder3D > {}; + +template< typename Kernel > +struct ci_orientation::type< Kernel, tag::cylinder3D, tag::cylinder3D > : public dcm::Orientation::type< Kernel, tag::cylinder3D, tag::cylinder3D > {}; + +}//details + +struct Coincidence : public dcm::constraint_sequence< fusion::vector2< Distance, details::ci_orientation > > { + //allow to set the distance + Coincidence& operator()(Direction val) { + fusion::at_c<1>(*this) = val; + return *this; + }; + Coincidence& operator=(Direction val) { + fusion::at_c<1>(*this) = val; + return *this; + }; +}; + +struct Alignment : public dcm::constraint_sequence< fusion::vector2< Distance, details::ci_orientation > > { + //allow to set the distance + Alignment& operator()(Direction val) { + fusion::at_c<1>(*this) = val; + return *this; + }; + Alignment& operator()(double val) { + fusion::at_c<0>(*this) = val; + return *this; + }; + Alignment& operator()(double val1, Direction val2) { + fusion::at_c<0>(*this) = val1; + fusion::at_c<1>(*this) = val2; + return *this; + }; + Alignment& operator()(Direction val1, double val2) { + fusion::at_c<0>(*this) = val2; + fusion::at_c<1>(*this) = val1; + return *this; + }; + Alignment& operator=(Direction val) { + fusion::at_c<1>(*this) = val; + return *this; + }; + Alignment& operator=(double val) { + fusion::at_c<0>(*this) = val; + return *this; + }; +}; + +//no standart equation, create our own object +static Coincidence coincidence; +static Alignment alignment; + +}//dcm + + +#endif //DCM_COINCIDENT_HPP diff --git a/src/Mod/Assembly/App/opendcm/module3d/parallel.hpp b/src/Mod/Assembly/App/opendcm/module3d/parallel.hpp index 780dd3f30..2dafc2043 100644 --- a/src/Mod/Assembly/App/opendcm/module3d/parallel.hpp +++ b/src/Mod/Assembly/App/opendcm/module3d/parallel.hpp @@ -38,12 +38,13 @@ inline typename Kernel::number_type calc(const T& d1, const Direction& dir) { switch(dir) { + case parallel: + if(d1.dot(d2) < 0) + return (d1+d2).norm(); case equal: return (d1-d2).norm(); case opposite: return (d1+d2).norm(); - case parallel: - return d1.dot(d2) - d1.norm()*d2.norm(); case perpendicular: return d1.dot(d2); default: @@ -61,15 +62,17 @@ inline typename Kernel::number_type calcGradFirst(const T& d1, typename Kernel::number_type res; switch(dir) { + case parallel: + if(d1.dot(d2) < 0) { + res= ((d1+d2).dot(dd1) / (d1+d2).norm()); + break; + } case equal: res = ((d1-d2).dot(dd1) / (d1-d2).norm()); break; case opposite: res= ((d1+d2).dot(dd1) / (d1+d2).norm()); break; - case parallel: - res = dd1.dot(d2) - d1.dot(dd1)/d1.norm()*d2.norm(); - break; case perpendicular: res = dd1.dot(d2); break; @@ -87,15 +90,17 @@ inline typename Kernel::number_type calcGradSecond(const T& d1, typename Kernel::number_type res; switch(dir) { + case parallel: + if(d1.dot(d2) < 0) { + res = ((d1+d2).dot(dd2) / (d1+d2).norm()); + break; + } case equal: res = ((d1-d2).dot(-dd2) / (d1-d2).norm()); break; case opposite: res = ((d1+d2).dot(dd2) / (d1+d2).norm()); break; - case parallel: - res = d1.dot(dd2) - d2.dot(dd2)/d2.norm()*d1.norm(); - break; case perpendicular: res = d1.dot(dd2); break; @@ -111,15 +116,17 @@ inline void calcGradFirstComp(const T& d1, const Direction& dir) { switch(dir) { + case parallel: + if(d1.dot(d2) < 0) { + const_cast< T& >(grad) = (d1+d2) / (d1+d2).norm(); + return; + } case equal: const_cast< T& >(grad) = (d1-d2) / (d1-d2).norm(); return; case opposite: const_cast< T& >(grad) = (d1+d2) / (d1+d2).norm(); return; - case parallel: - const_cast< T& >(grad) = d2 - d1/d1.norm()*d2.norm(); - return; case perpendicular: const_cast< T& >(grad) = d2; return; @@ -133,15 +140,17 @@ inline void calcGradSecondComp(const T& d1, const Direction& dir) { switch(dir) { + case parallel: + if(d1.dot(d2) < 0) { + const_cast< T& >(grad) = (d2+d1) / (d1+d2).norm(); + return; + } case equal: const_cast< T& >(grad) = (d2-d1) / (d1-d2).norm(); return; case opposite: const_cast< T& >(grad) = (d2+d1) / (d1+d2).norm(); return; - case parallel: - const_cast< T& >(grad) = d1 - d2/d2.norm()*d1.norm(); - return; case perpendicular: const_cast< T& >(grad) = d1; return; diff --git a/src/Mod/Assembly/Gui/AlignmentDialog.ui b/src/Mod/Assembly/Gui/AlignmentDialog.ui new file mode 100644 index 000000000..e02156e12 --- /dev/null +++ b/src/Mod/Assembly/Gui/AlignmentDialog.ui @@ -0,0 +1,111 @@ + + + AlignmentDialog + + + + 0 + 0 + 270 + 95 + + + + Constraint value + + + + + + + + + 0 + 0 + + + + Offset: + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Orientation: + + + + + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + AlignmentDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AlignmentDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintAlignment.svg b/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintAlignment.svg new file mode 100644 index 000000000..f5b69e51a --- /dev/null +++ b/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintAlignment.svg @@ -0,0 +1,337 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintCoincidence.svg b/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintCoincidence.svg new file mode 100644 index 000000000..a0910aaeb --- /dev/null +++ b/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintCoincidence.svg @@ -0,0 +1,483 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintDistance.svg b/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintDistance.svg new file mode 100644 index 000000000..d4d00bb34 --- /dev/null +++ b/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintDistance.svg @@ -0,0 +1,369 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintOrientation.svg b/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintOrientation.svg new file mode 100644 index 000000000..37d12ebc4 --- /dev/null +++ b/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintOrientation.svg @@ -0,0 +1,541 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintFix.cpp b/src/Mod/Assembly/Gui/ViewProviderConstraintFix.cpp new file mode 100644 index 000000000..f3f9d22ef --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintFix.cpp @@ -0,0 +1,34 @@ +/*************************************************************************** + * Copyright (c) 2013 Stefan Tröger * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + +#include "PreCompiled.h" +#include "ViewProviderConstraintFix.h" + +using namespace AssemblyGui; + +PROPERTY_SOURCE(AssemblyGui::ViewProviderConstraintFix, Gui::ViewProviderDocumentObject) + +ViewProviderConstraintFix::ViewProviderConstraintFix() { + + sPixmap = "Assembly_ConstraintLock"; +} + diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintFix.h b/src/Mod/Assembly/Gui/ViewProviderConstraintFix.h new file mode 100644 index 000000000..d4fabcc0c --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintFix.h @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (c) 2013 Stefan Tröger * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#ifndef ASSEMBLYGUI_VIEWPROVIDERCONSTRAINTFIX_H +#define ASSEMBLYGUI_VIEWPROVIDERCONSTRAINTFIX_H + +#include + +namespace AssemblyGui { + +class AssemblyGuiExport ViewProviderConstraintFix : public Gui::ViewProviderDocumentObject { + + PROPERTY_HEADER(AssemblyGui::ViewProviderConstraintFix); + +public: + ViewProviderConstraintFix(); + +}; + +}; + +#endif // VIEWPROVIDERCONSTRAINTFIX_H