diff --git a/src/Mod/Assembly/App/AppAssembly.cpp b/src/Mod/Assembly/App/AppAssembly.cpp index 773af74c3..babebb0fe 100644 --- a/src/Mod/Assembly/App/AppAssembly.cpp +++ b/src/Mod/Assembly/App/AppAssembly.cpp @@ -35,11 +35,12 @@ #include "ItemPart.h" #include "ConstraintAngle.h" -#include "ConstraintAxis.h" -#include "ConstraintContact.h" +#include "ConstraintCoincidence.h" #include "ConstraintFix.h" #include "ConstraintGroup.h" -#include "ConstraintOffset.h" +#include "ConstraintAlignment.h" +#include "ConstraintDistance.h" +#include "ConstraintOrientation.h" extern struct PyMethodDef Assembly_methods[]; @@ -80,10 +81,11 @@ void AssemblyExport initAssembly() // constraint hirachy Assembly::Constraint ::init(); Assembly::ConstraintAngle ::init(); - Assembly::ConstraintAxis ::init(); - Assembly::ConstraintContact ::init(); + Assembly::ConstraintDistance::init(); + Assembly::ConstraintCoincidence::init(); Assembly::ConstraintFix ::init(); - Assembly::ConstraintOffset ::init(); + Assembly::ConstraintAlignment ::init(); + Assembly::ConstraintOrientation::init(); Assembly::ConstraintGroup ::init(); } diff --git a/src/Mod/Assembly/App/CMakeLists.txt b/src/Mod/Assembly/App/CMakeLists.txt index 5a67cc028..c8cfb1013 100644 --- a/src/Mod/Assembly/App/CMakeLists.txt +++ b/src/Mod/Assembly/App/CMakeLists.txt @@ -30,7 +30,6 @@ generate_from_xml(ItemPy) generate_from_xml(ItemAssemblyPy) generate_from_xml(ItemPartPy) generate_from_xml(ConstraintPy) -generate_from_xml(ConstraintAxisPy) generate_from_xml(ConstraintGroupPy) SET(Features_SRCS @@ -46,14 +45,16 @@ SET(Features_SRCS ConstraintGroup.h ConstraintAngle.cpp ConstraintAngle.h - ConstraintAxis.cpp - ConstraintAxis.h - ConstraintContact.cpp - ConstraintContact.h + ConstraintDistance.cpp + ConstraintDistance.h + ConstraintCoincidence.cpp + ConstraintCoincidence.h ConstraintFix.cpp ConstraintFix.h - ConstraintOffset.cpp - ConstraintOffset.h + ConstraintAlignment.cpp + ConstraintAlignment.h + ConstraintOrientation.cpp + ConstraintOrientation.h ) SOURCE_GROUP("Features" FILES ${Features_SRCS}) @@ -74,8 +75,6 @@ SET(Python_SRCS ItemPartPyImp.cpp ConstraintPy.xml ConstraintPyImp.cpp - ConstraintAxisPy.xml - ConstraintAxisPyImp.cpp ConstraintGroupPy.xml ConstraintGroupPyImp.cpp ) diff --git a/src/Mod/Assembly/App/Constraint.cpp b/src/Mod/Assembly/App/Constraint.cpp index bbfeef4fc..84772447e 100644 --- a/src/Mod/Assembly/App/Constraint.cpp +++ b/src/Mod/Assembly/App/Constraint.cpp @@ -49,6 +49,7 @@ #include "ConstraintPy.h" #include "Item.h" #include "ItemPart.h" +#include "ItemAssembly.h" using namespace Assembly; @@ -74,40 +75,44 @@ short Constraint::mustExecute() const App::DocumentObjectExecReturn *Constraint::execute(void) { - + touch(); return App::DocumentObject::StdReturn; } -void Constraint::init(boost::shared_ptr< Solver > solver) { +boost::shared_ptr Constraint::initLink(ItemAssembly* ass, App::PropertyLinkSub& link) { - //check if we have Assembly::ItemPart's - if( First.getValue()->getTypeId() != ItemPart::getClassTypeId() || - Second.getValue()->getTypeId() != ItemPart::getClassTypeId() ) { - Base::Console().Message("Links are not ItemPart's, the constraint is invalid\n"); - return; + //check if we have Assembly::ItemPart + if( link.getValue()->getTypeId() != ItemPart::getClassTypeId() ) { + Base::Console().Message("Link is not ItemPart, the constraint is invalid\n"); + return boost::shared_ptr(); }; - - //see if the parts are already initialized for the solver - Assembly::ItemPart* part1 = static_cast(First.getValue()); - if(!part1->m_part) { - part1->m_part = solver->createPart(part1->Placement.getValue(), part1->Uid.getValueStr()); - part1->m_part->connectSignal(boost::bind(&ItemPart::setCalculatedPlacement, part1, _1)); - } - - Assembly::ItemPart* part2 = static_cast(Second.getValue()); - if(!part2->m_part) { - part2->m_part = solver->createPart(part2->Placement.getValue(), part2->Uid.getValueStr()); - part2->m_part->connectSignal(boost::bind(&ItemPart::setCalculatedPlacement, part2, _1)); - } - - //let's get the geometrys - m_first_geom = part1->getGeometry3D(First.getSubValues()[0].c_str()); - m_second_geom = part2->getGeometry3D(Second.getSubValues()[0].c_str()); + + Assembly::ItemPart* part = static_cast(link.getValue()); + if(!part) + return boost::shared_ptr(); - if(!m_first_geom || !m_second_geom) { - Base::Console().Message("Unable to initialize geometry\n"); - return; - }; + //get the relevant solver in which the part needs to be added + Assembly::ItemAssembly* p_ass = ass->getParentAssembly(part); + if(!p_ass) + return boost::shared_ptr(); + + boost::shared_ptr solver = p_ass->m_solver; + if(!solver) + return boost::shared_ptr(); + + if(!solver->hasPart(part->Uid.getValueStr())) { + part->m_part = solver->createPart(part->Placement.getValue(), part->Uid.getValueStr()); + part->m_part->connectSignal(boost::bind(&ItemPart::setCalculatedPlacement, part, _1)); + }; + + return part->getGeometry3D(link.getSubValues()[0].c_str()); +} + + +void Constraint::init(ItemAssembly* ass) +{ + m_first_geom = initLink(ass, First); + m_second_geom = initLink(ass, Second); } PyObject *Constraint::getPyObject(void) @@ -120,4 +125,7 @@ PyObject *Constraint::getPyObject(void) } -} \ No newline at end of file +} + + + diff --git a/src/Mod/Assembly/App/Constraint.h b/src/Mod/Assembly/App/Constraint.h index 9dd8064c7..2be02e756 100644 --- a/src/Mod/Assembly/App/Constraint.h +++ b/src/Mod/Assembly/App/Constraint.h @@ -31,6 +31,7 @@ #include #include "Solver.h" +#include "ItemAssembly.h" namespace Assembly @@ -44,6 +45,8 @@ protected: boost::shared_ptr m_constraint; boost::shared_ptr m_first_geom, m_second_geom; + boost::shared_ptr< Geometry3D > initLink(Assembly::ItemAssembly* ass, App::PropertyLinkSub& link); + public: Constraint(); @@ -63,7 +66,7 @@ public: /** @brief initialize the constraint in the assembly solver */ - virtual void init(boost::shared_ptr solver); + virtual void init(ItemAssembly* ass); }; } //namespace Assembly diff --git a/src/Mod/Assembly/App/ConstraintAlignment.cpp b/src/Mod/Assembly/App/ConstraintAlignment.cpp new file mode 100644 index 000000000..f2ad98cd3 --- /dev/null +++ b/src/Mod/Assembly/App/ConstraintAlignment.cpp @@ -0,0 +1,87 @@ +/*************************************************************************** + * Copyright (c) 2010 Juergen Riegel * + * * + * 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" +#ifndef _PreComp_ +#endif + +#include + +#include "ConstraintAlignment.h" + + +using namespace Assembly; + +namespace Assembly { + + +PROPERTY_SOURCE(Assembly::ConstraintAlignment, Assembly::Constraint) + +ConstraintAlignment::ConstraintAlignment() +{ + ADD_PROPERTY(Offset,(0)); + ADD_PROPERTY(Orientation, (long(0))); + + std::vector vec; + vec.push_back("Parallel"); + vec.push_back("Equal"); + vec.push_back("Opposite"); + Orientation.setEnumVector(vec); +} + +short ConstraintAlignment::mustExecute() const +{ + //if (Sketch.isTouched() || + // Length.isTouched()) + // return 1; + return 0; +} + +App::DocumentObjectExecReturn *ConstraintAlignment::execute(void) +{ + + return App::DocumentObject::StdReturn; +} + +void ConstraintAlignment::init(ItemAssembly* ass) { + + //cant use the base class init as we only need one part + Constraint::init(ass); + + //init the constraint + dcm::Direction dir; + switch(Orientation.getValue()) { + case 0: + dir = dcm::parallel; + break; + case 1: + dir = dcm::equal; + break; + default: + dir = dcm::opposite; + }; + + m_constraint = ass->m_solver->createConstraint3D(getNameInDocument(), m_first_geom, m_second_geom, dcm::alignment(dir, Offset.getValue())); +}; + +} \ No newline at end of file diff --git a/src/Mod/Assembly/App/ConstraintAlignment.h b/src/Mod/Assembly/App/ConstraintAlignment.h new file mode 100644 index 000000000..7e5dfc235 --- /dev/null +++ b/src/Mod/Assembly/App/ConstraintAlignment.h @@ -0,0 +1,61 @@ +/*************************************************************************** + * Copyright (c) 2010 Juergen Riegel * + * * + * 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 Assembly_ConstraintAlignment_H +#define Assembly_ConstraintAlignment_H + +#include +#include "Constraint.h" + + +namespace Assembly +{ + +class AssemblyExport ConstraintAlignment : public Assembly::Constraint +{ + PROPERTY_HEADER(Assembly::ConstraintAlignment); + +public: + ConstraintAlignment(); + + App::PropertyFloat Offset; + App::PropertyEnumeration Orientation; + + /** @name methods override feature */ + //@{ + /// recalculate the feature + App::DocumentObjectExecReturn *execute(void); + short mustExecute() const; + /// returns the type name of the view provider + const char* getViewProviderName(void) const { + return "AssemblyGui::ViewProviderConstraintAlignment"; + } + //@} + + virtual void init(ItemAssembly* ass); +}; + +} //namespace PartDesign + + +#endif // PART_ConstraintAlignment_H diff --git a/src/Mod/Assembly/App/ConstraintAngle.cpp b/src/Mod/Assembly/App/ConstraintAngle.cpp index 52d383375..69fa6479f 100644 --- a/src/Mod/Assembly/App/ConstraintAngle.cpp +++ b/src/Mod/Assembly/App/ConstraintAngle.cpp @@ -27,6 +27,7 @@ #include +#include #include "ConstraintAngle.h" @@ -56,4 +57,13 @@ App::DocumentObjectExecReturn *ConstraintAngle::execute(void) return App::DocumentObject::StdReturn; } +void ConstraintAngle::init(ItemAssembly* ass) +{ + //init the parts and geometries + Constraint::init(ass); + + //init the constraint + m_constraint = ass->m_solver->createConstraint3D(getNameInDocument(), m_first_geom, m_second_geom, dcm::angle = Angle.getValue()*M_PI/180.); +} + } \ No newline at end of file diff --git a/src/Mod/Assembly/App/ConstraintAngle.h b/src/Mod/Assembly/App/ConstraintAngle.h index 13b2ae68a..29bce3e25 100644 --- a/src/Mod/Assembly/App/ConstraintAngle.h +++ b/src/Mod/Assembly/App/ConstraintAngle.h @@ -46,10 +46,12 @@ public: App::DocumentObjectExecReturn *execute(void); short mustExecute() const; /// returns the type name of the view provider - //const char* getViewProviderName(void) const { - // return "PartDesignGui::ViewProviderConstraintAngle"; - //} + const char* getViewProviderName(void) const { + return "AssemblyGui::ViewProviderConstraintAngle"; + } //@} + + virtual void init(ItemAssembly* ass); }; } //namespace Assembly diff --git a/src/Mod/Assembly/App/ConstraintAxisPy.xml b/src/Mod/Assembly/App/ConstraintAxisPy.xml deleted file mode 100644 index d54b6080f..000000000 --- a/src/Mod/Assembly/App/ConstraintAxisPy.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - Base class of all objects in Assembly - - - diff --git a/src/Mod/Assembly/App/ConstraintAxisPyImp.cpp b/src/Mod/Assembly/App/ConstraintAxisPyImp.cpp deleted file mode 100644 index a9a0d06bd..000000000 --- a/src/Mod/Assembly/App/ConstraintAxisPyImp.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -#include "PreCompiled.h" - -#include "Mod/Assembly/App/Constraint.h" - -// inclusion of the generated files (generated out of ItemAssemblyPy.xml) -#include "ConstraintAxisPy.h" -#include "ConstraintAxisPy.cpp" - -using namespace Assembly; - -// returns a string which represents the object e.g. when printed in python -std::string ConstraintAxisPy::representation(void) const -{ - return std::string(""); -} - - -PyObject *ConstraintAxisPy::getCustomAttributes(const char* /*attr*/) const -{ - return 0; -} - -int ConstraintAxisPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) -{ - return 0; -} - - diff --git a/src/Mod/Assembly/App/ConstraintCoincidence.cpp b/src/Mod/Assembly/App/ConstraintCoincidence.cpp new file mode 100644 index 000000000..f0ec83382 --- /dev/null +++ b/src/Mod/Assembly/App/ConstraintCoincidence.cpp @@ -0,0 +1,87 @@ +/*************************************************************************** + * Copyright (c) 2012 Juergen Riegel * + * * + * 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" +#ifndef _PreComp_ +#endif + +#include + +#include "ConstraintCoincidence.h" + + +using namespace Assembly; + +namespace Assembly { + + +PROPERTY_SOURCE(Assembly::ConstraintCoincidence, Assembly::Constraint) + +ConstraintCoincidence::ConstraintCoincidence() +{ + + ADD_PROPERTY(Orientation, (long(0))); + + std::vector vec; + vec.push_back("Parallel"); + vec.push_back("Equal"); + vec.push_back("Opposite"); + Orientation.setEnumVector(vec); +} + +short ConstraintCoincidence::mustExecute() const +{ + //if (Sketch.isTouched() || + // Length.isTouched()) + // return 1; + return 0; +} + +App::DocumentObjectExecReturn *ConstraintCoincidence::execute(void) +{ + + return App::DocumentObject::StdReturn; +} + +void ConstraintCoincidence::init(ItemAssembly* ass) { + + //cant use the base class init as we only need one part + Constraint::init(ass); + + //init the constraint + dcm::Direction dir; + switch(Orientation.getValue()) { + case 0: + dir = dcm::parallel; + break; + case 1: + dir = dcm::equal; + break; + default: + dir = dcm::opposite; + }; + + m_constraint = ass->m_solver->createConstraint3D(getNameInDocument(), m_first_geom, m_second_geom, dcm::coincidence = dir); +}; + +} \ No newline at end of file diff --git a/src/Mod/Assembly/App/ConstraintCoincidence.h b/src/Mod/Assembly/App/ConstraintCoincidence.h new file mode 100644 index 000000000..180d9bd4f --- /dev/null +++ b/src/Mod/Assembly/App/ConstraintCoincidence.h @@ -0,0 +1,60 @@ +/*************************************************************************** + * Copyright (c) 2012 Juergen Riegel * + * * + * 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 Assembly_ConstraintCoincidence_H +#define Assembly_ConstraintCoincidence_H + +#include +#include "Constraint.h" + + +namespace Assembly +{ + +class AssemblyExport ConstraintCoincidence : public Assembly::Constraint +{ + PROPERTY_HEADER(Assembly::ConstraintCoincidence); + +public: + ConstraintCoincidence(); + + App::PropertyEnumeration Orientation; + + /** @name methods override feature */ + //@{ + /// recalculate the feature + App::DocumentObjectExecReturn *execute(void); + short mustExecute() const; + /// returns the type name of the view provider + const char* getViewProviderName(void) const { + return "AssemblyGui::ViewProviderConstraintCoincidence"; + } + //@} + + virtual void init(ItemAssembly* ass); +}; + +} //namespace Assembly + + +#endif // Assembly_ConstraintCoincidence_H diff --git a/src/Mod/Assembly/App/ConstraintDistance.cpp b/src/Mod/Assembly/App/ConstraintDistance.cpp new file mode 100644 index 000000000..10ef64745 --- /dev/null +++ b/src/Mod/Assembly/App/ConstraintDistance.cpp @@ -0,0 +1,83 @@ +/*************************************************************************** + * Copyright (c) 2012 Juergen Riegel + * 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" +#ifndef _PreComp_ +#endif + +#include +#include + +#include "ConstraintDistance.h" +#include "ConstraintPy.h" + +#include "ItemPart.h" + +using namespace Assembly; + +namespace Assembly { + + +PROPERTY_SOURCE(Assembly::ConstraintDistance, Assembly::Constraint) + +ConstraintDistance::ConstraintDistance() +{ + ADD_PROPERTY(Distance,(0)); +} + +PyObject *ConstraintDistance::getPyObject(void) +{ + if (PythonObject.is(Py::_None())){ + // ref counter is set to 1 + PythonObject = Py::Object(new ConstraintPy(this),true); + } + return Py::new_reference_to(PythonObject); +} + +short ConstraintDistance::mustExecute() const +{ + //if (Sketch.isTouched() || + // Length.isTouched()) + // return 1; + return 0; +} + +App::DocumentObjectExecReturn *ConstraintDistance::execute(void) +{ + Base::Console().Message("Recalculate axis constraint\n"); + touch(); + return App::DocumentObject::StdReturn; +} + +void ConstraintDistance::init(ItemAssembly* ass) +{ + //init the parts and geometries + Constraint::init(ass); + + //init the constraint + m_constraint = ass->m_solver->createConstraint3D(getNameInDocument(), m_first_geom, m_second_geom, dcm::distance = Distance.getValue()); +} + + +} \ No newline at end of file diff --git a/src/Mod/Assembly/App/ConstraintDistance.h b/src/Mod/Assembly/App/ConstraintDistance.h new file mode 100644 index 000000000..e3f3f22fb --- /dev/null +++ b/src/Mod/Assembly/App/ConstraintDistance.h @@ -0,0 +1,62 @@ +/*************************************************************************** + * Copyright (c) 2012 Juergen Riegel * + * * + * 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 Assembly_ConstraintAxis_H +#define Assembly_ConstraintAxis_H + +#include +#include "Constraint.h" + + +namespace Assembly +{ + +class AssemblyExport ConstraintDistance : public Assembly::Constraint +{ + PROPERTY_HEADER(Assembly::ConstraintAxis); + +public: + ConstraintDistance(); + + App::PropertyFloat Distance; + + PyObject *getPyObject(void); + + /** @name methods override feature */ + //@{ + /// recalculate the feature + App::DocumentObjectExecReturn *execute(void); + short mustExecute() const; + /// returns the type name of the view provider + const char* getViewProviderName(void) const { + return "AssemblyGui::ViewProviderConstraintDistance"; + } + //@} + + virtual void init(ItemAssembly* ass); +}; + +} //namespace Assembly + + +#endif // Assembly_ConstraintAxis_H diff --git a/src/Mod/Assembly/App/ConstraintFix.cpp b/src/Mod/Assembly/App/ConstraintFix.cpp index 033222172..06771fd07 100644 --- a/src/Mod/Assembly/App/ConstraintFix.cpp +++ b/src/Mod/Assembly/App/ConstraintFix.cpp @@ -26,6 +26,8 @@ #endif #include +#include +#include "ItemPart.h" #include "ConstraintFix.h" @@ -37,23 +39,43 @@ namespace Assembly { PROPERTY_SOURCE(Assembly::ConstraintFix, Assembly::Constraint) -ConstraintFix::ConstraintFix() -{ +ConstraintFix::ConstraintFix() { } -short ConstraintFix::mustExecute() const -{ +ConstraintFix::~ConstraintFix() { + + Assembly::ItemPart* part = static_cast(First.getValue()); + if(part && part->m_part) { + part->m_part->fix(false); + } +} + +short ConstraintFix::mustExecute() const { //if (Sketch.isTouched() || // Length.isTouched()) // return 1; return 0; } -App::DocumentObjectExecReturn *ConstraintFix::execute(void) -{ - +App::DocumentObjectExecReturn* ConstraintFix::execute(void) { + return App::DocumentObject::StdReturn; } -} \ No newline at end of file +void ConstraintFix::init(ItemAssembly* ass) { + + //cant use the base class init as we only need one part + initLink(ass, First); + + //get the part + Assembly::ItemPart* part = static_cast(First.getValue()); + if(!part) + return; + + //init the constraint + part->m_part->fix(true); + +}; + +} diff --git a/src/Mod/Assembly/App/ConstraintFix.h b/src/Mod/Assembly/App/ConstraintFix.h index ae7ca4357..8e2a4c59c 100644 --- a/src/Mod/Assembly/App/ConstraintFix.h +++ b/src/Mod/Assembly/App/ConstraintFix.h @@ -37,6 +37,7 @@ class AssemblyExport ConstraintFix : public Assembly::Constraint public: ConstraintFix(); + ~ConstraintFix(); /** @name methods override feature */ //@{ @@ -44,10 +45,12 @@ public: App::DocumentObjectExecReturn *execute(void); short mustExecute() const; /// returns the type name of the view provider - //const char* getViewProviderName(void) const { - // return "AssemblyGui::ViewProviderConstraintFix"; - //} + const char* getViewProviderName(void) const { + return "AssemblyGui::ViewProviderConstraintFix"; + } //@} + + virtual void init(ItemAssembly* ass); }; } //namespace Assembly diff --git a/src/Mod/Assembly/App/ConstraintGroup.cpp b/src/Mod/Assembly/App/ConstraintGroup.cpp index 24beb6901..818f9aa37 100644 --- a/src/Mod/Assembly/App/ConstraintGroup.cpp +++ b/src/Mod/Assembly/App/ConstraintGroup.cpp @@ -56,51 +56,6 @@ PyObject *ConstraintGroup::getPyObject(void) return Py::new_reference_to(PythonObject); } -void ConstraintGroup::addConstraint(Constraint* c) -{ - Base::Console().Message("add constraint to group\n"); - - //add the constraint to our list - const std::vector< App::DocumentObject * > &vals = this->Constraints.getValues(); - std::vector< App::DocumentObject * > newVals(vals); - newVals.push_back(c); - this->Constraints.setValues(newVals); - - //let's retrieve the solver if not already done - ItemAssembly* assembly = NULL; - if(!m_solver || !assembly) { - - typedef std::vector::iterator iter; - std::vector vec = getInList(); - - for(iter it = vec.begin(); it!=vec.end(); it++) { - - if( (*it)->getTypeId() == ItemAssembly::getClassTypeId() ) { - assembly = static_cast(*it); - m_solver = assembly->m_solver; - break; - }; - } - }; - - //check if we have been successfull - if(!m_solver) { - Base::Console().Message("ConstraintGroup: Unable to retrieve assembly solver\n"); - return; - }; - if(!assembly) { - Base::Console().Message("ConstraintGroup: Unable to retrieve assembly\n"); - return; - }; - - //init the constraint - c->init(m_solver); - - //solve the system and propagate the change upstream - m_solver->solve(); - assembly->touch(); -} - short ConstraintGroup::mustExecute() const { @@ -114,7 +69,21 @@ App::DocumentObjectExecReturn *ConstraintGroup::execute(void) { Base::Console().Message("Recalculate constraint group\n"); + touch(); return App::DocumentObject::StdReturn; } +void ConstraintGroup::init(ItemAssembly* ass) { + + std::vector obj = Constraints.getValues(); + + std::vector::iterator it; + for (it = obj.begin(); it != obj.end(); ++it) { + if ((*it)->getTypeId().isDerivedFrom(Assembly::Constraint::getClassTypeId())) { + static_cast(*it)->init(ass); + } + } +} + + } diff --git a/src/Mod/Assembly/App/ConstraintGroup.h b/src/Mod/Assembly/App/ConstraintGroup.h index 167cd3451..8c671ab60 100644 --- a/src/Mod/Assembly/App/ConstraintGroup.h +++ b/src/Mod/Assembly/App/ConstraintGroup.h @@ -38,13 +38,9 @@ namespace Assembly class AssemblyExport ConstraintGroup : public App::DocumentObject { PROPERTY_HEADER(Assembly::ConstraintGroup); - -protected: - boost::shared_ptr m_solver; public: ConstraintGroup(); - void addConstraint(Constraint* c); PyObject *getPyObject(void); @@ -60,6 +56,8 @@ public: return "AssemblyGui::ViewProviderConstraintGroup"; } //@} + + void init(ItemAssembly* ass); }; } //namespace Assembly diff --git a/src/Mod/Assembly/App/ConstraintGroupPy.xml b/src/Mod/Assembly/App/ConstraintGroupPy.xml index 9691e9668..fbc07d2f8 100644 --- a/src/Mod/Assembly/App/ConstraintGroupPy.xml +++ b/src/Mod/Assembly/App/ConstraintGroupPy.xml @@ -13,11 +13,6 @@ Base class of all objects in Assembly - - - Adds a constraint object to the constraint group - - diff --git a/src/Mod/Assembly/App/ConstraintGroupPyImp.cpp b/src/Mod/Assembly/App/ConstraintGroupPyImp.cpp index 19bd9fd63..d315c9b64 100644 --- a/src/Mod/Assembly/App/ConstraintGroupPyImp.cpp +++ b/src/Mod/Assembly/App/ConstraintGroupPyImp.cpp @@ -16,20 +16,6 @@ std::string ConstraintGroupPy::representation(void) const return std::string(""); } -PyObject* ConstraintGroupPy::addConstraint(PyObject * args) -{ - PyObject *pcObj; - if (!PyArg_ParseTuple(args, "O", &pcObj)) - return 0; - - if (PyObject_TypeCheck(pcObj, &(Assembly::ConstraintPy::Type))) { - Base::Console().Message("Add constraint\n"); - Assembly::Constraint *c = static_cast(pcObj)->getConstraintPtr(); - this->getConstraintGroupPtr()->addConstraint(c); - } - Py_Return; -} - PyObject *ConstraintGroupPy::getCustomAttributes(const char* /*attr*/) const { return 0; diff --git a/src/Mod/Assembly/App/ConstraintOrientation.cpp b/src/Mod/Assembly/App/ConstraintOrientation.cpp new file mode 100644 index 000000000..56728dbc9 --- /dev/null +++ b/src/Mod/Assembly/App/ConstraintOrientation.cpp @@ -0,0 +1,93 @@ +/*************************************************************************** + * Copyright (c) 2012 Juergen Riegel + * 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" +#ifndef _PreComp_ +#endif + +#include +#include + +#include "ConstraintOrientation.h" +#include "ConstraintPy.h" + +#include "ItemPart.h" + + +using namespace Assembly; + +namespace Assembly { + + +PROPERTY_SOURCE(Assembly::ConstraintOrientation, Assembly::Constraint) + +ConstraintOrientation::ConstraintOrientation() { + ADD_PROPERTY(Orientation, (long(0))); + + std::vector vec; + vec.push_back("Parallel"); + vec.push_back("Perpendicular"); + vec.push_back("Equal"); + vec.push_back("Opposite"); + Orientation.setEnumVector(vec); +} + +short ConstraintOrientation::mustExecute() const { + //if (Sketch.isTouched() || + // Length.isTouched()) + // return 1; + return 0; +} + +App::DocumentObjectExecReturn* ConstraintOrientation::execute(void) { + Base::Console().Message("Recalculate orientation constraint\n"); + touch(); + return App::DocumentObject::StdReturn; +} + +void ConstraintOrientation::init(ItemAssembly* ass) { + //init the parts and geometries + Constraint::init(ass); + + //init the constraint + dcm::Direction dir; + switch(Orientation.getValue()) { + case 0: + dir = dcm::parallel; + break; + case 1: + dir = dcm::perpendicular; + break; + case 2: + dir = dcm::equal; + break; + default: + dir = dcm::opposite; + }; + + m_constraint = ass->m_solver->createConstraint3D(getNameInDocument(), m_first_geom, m_second_geom, dcm::orientation = dir); +} + + +} diff --git a/src/Mod/Assembly/App/ConstraintOrientation.h b/src/Mod/Assembly/App/ConstraintOrientation.h new file mode 100644 index 000000000..9c356bca9 --- /dev/null +++ b/src/Mod/Assembly/App/ConstraintOrientation.h @@ -0,0 +1,60 @@ +/*************************************************************************** + * Copyright (c) 2012 Juergen Riegel * + * * + * 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 Assembly_ConstraintOrientation_H +#define Assembly_ConstraintOrientation_H + +#include +#include "Constraint.h" + + +namespace Assembly +{ + +class AssemblyExport ConstraintOrientation : public Assembly::Constraint +{ + PROPERTY_HEADER(Assembly::ConstraintOrientation); + +public: + ConstraintOrientation(); + + App::PropertyEnumeration Orientation; + + /** @name methods override feature */ + //@{ + /// recalculate the feature + App::DocumentObjectExecReturn *execute(void); + short mustExecute() const; + /// returns the type name of the view provider + const char* getViewProviderName(void) const { + return "AssemblyGui::ViewProviderConstraintOrientation"; + } + //@} + + virtual void init(ItemAssembly* ass); +}; + +} //namespace Assembly + + +#endif // Assembly_ConstraintAxis_H diff --git a/src/Mod/Assembly/App/ConstraintPyImp.cpp b/src/Mod/Assembly/App/ConstraintPyImp.cpp index e763ea29a..7d684c909 100644 --- a/src/Mod/Assembly/App/ConstraintPyImp.cpp +++ b/src/Mod/Assembly/App/ConstraintPyImp.cpp @@ -12,7 +12,7 @@ using namespace Assembly; // returns a string which represents the object e.g. when printed in python std::string ConstraintPy::representation(void) const { - return std::string(""); + return std::string(""); } diff --git a/src/Mod/Assembly/App/ItemAssembly.cpp b/src/Mod/Assembly/App/ItemAssembly.cpp index 0e86369d0..dd576924c 100644 --- a/src/Mod/Assembly/App/ItemAssembly.cpp +++ b/src/Mod/Assembly/App/ItemAssembly.cpp @@ -32,6 +32,7 @@ #include #include "ItemAssembly.h" +#include "ConstraintGroup.h" #include @@ -42,7 +43,7 @@ namespace Assembly { PROPERTY_SOURCE(Assembly::ItemAssembly, Assembly::Item) -ItemAssembly::ItemAssembly() : m_solver(new Solver) +ItemAssembly::ItemAssembly() { ADD_PROPERTY(Items,(0)); ADD_PROPERTY(Annotations,(0)); @@ -56,6 +57,24 @@ short ItemAssembly::mustExecute() const App::DocumentObjectExecReturn *ItemAssembly::execute(void) { Base::Console().Message("Execute ItemAssembly\n"); + + //create a solver and init all child assemblys with subsolvers + m_solver = boost::shared_ptr(new Solver); + init(boost::shared_ptr()); + + //get the constraint group and init the constraints + typedef std::vector::const_iterator iter; + + const std::vector& vector = Annotations.getValues(); + for(iter it=vector.begin(); it != vector.end(); it++) { + + if( (*it)->getTypeId() == Assembly::ConstraintGroup::getClassTypeId() ) + static_cast(*it)->init(this); + }; + + //solve the system + m_solver->solve(); + this->touch(); return App::DocumentObject::StdReturn; } @@ -101,37 +120,44 @@ PyObject *ItemAssembly::getPyObject(void) return Py::new_reference_to(PythonObject); } -void ItemAssembly::addPart(ItemPart* part) { +bool ItemAssembly::isParentAssembly(ItemPart* part) { - if(part->m_part) { - //TODO: destroy old part - } - - //add the part to our list - const std::vector< App::DocumentObject * > &vals = this->Items.getValues(); - std::vector< App::DocumentObject * > newVals(vals); - newVals.push_back(part); - this->Items.setValues(newVals); + typedef std::vector::const_iterator iter; - part->m_part = m_solver->createPart(part->Placement.getValue(), part->Uid.getValueStr()); + const std::vector& vector = Items.getValues(); + for(iter it=vector.begin(); it != vector.end(); it++) { + + if( (*it)->getTypeId() == Assembly::ItemPart::getClassTypeId() ) + if(*it == part) return true; + }; + + return false; } -void ItemAssembly::addComponent(ItemAssembly* assembly) { +ItemAssembly* ItemAssembly::getParentAssembly(ItemPart* part) { - if(assembly->m_solver) { - //TODO: destroy old solver system - } + typedef std::vector::const_iterator iter; - //add the component to our list - const std::vector< App::DocumentObject * > &vals = this->Items.getValues(); - std::vector< App::DocumentObject * > newVals(vals); - newVals.push_back(assembly); - this->Items.setValues(newVals); + const std::vector& vector = Items.getValues(); + for(iter it=vector.begin(); it != vector.end(); it++) { + + if( (*it)->getTypeId() == Assembly::ItemPart::getClassTypeId() ) { + if(*it == part) + return this; + } + else if ( (*it)->getTypeId() == Assembly::ItemAssembly::getClassTypeId() ) { + + Assembly::ItemAssembly* assembly = static_cast(*it)->getParentAssembly(part); + if(assembly) + return assembly; + } + }; - assembly->m_solver = boost::shared_ptr(m_solver->createSubsystem()); - assembly->m_solver->setTransformation(assembly->Placement.getValue()); + return (ItemAssembly*)NULL; } + + ItemPart* ItemAssembly::getContainingPart(App::DocumentObject* obj) { typedef std::vector::const_iterator iter; @@ -154,5 +180,22 @@ ItemPart* ItemAssembly::getContainingPart(App::DocumentObject* obj) { return NULL; } +void ItemAssembly::init(boost::shared_ptr parent) { + + if(parent) + m_solver = boost::shared_ptr(parent->createSubsystem()); + + typedef std::vector::const_iterator iter; + + const std::vector& vector = Items.getValues(); + for(iter it=vector.begin(); it != vector.end(); it++) { + + if ( (*it)->getTypeId() == Assembly::ItemAssembly::getClassTypeId() ) { + + static_cast(*it)->init(m_solver); + } + }; +} + } \ No newline at end of file diff --git a/src/Mod/Assembly/App/ItemAssembly.h b/src/Mod/Assembly/App/ItemAssembly.h index 58036bbff..4014a5ea7 100644 --- a/src/Mod/Assembly/App/ItemAssembly.h +++ b/src/Mod/Assembly/App/ItemAssembly.h @@ -57,10 +57,12 @@ public: virtual TopoDS_Shape getShape(void) const; - void addPart(Assembly::ItemPart* part); - void addComponent(Assembly::ItemAssembly* assembly); + //the toplevel assembly is the direct parent of the part + bool isParentAssembly(ItemPart* part); + ItemAssembly* getParentAssembly(ItemPart* part); - Assembly::ItemPart* getContainingPart(App::DocumentObject* obj); + ItemPart* getContainingPart(App::DocumentObject* obj); + void init(boost::shared_ptr parent); boost::shared_ptr m_solver; }; diff --git a/src/Mod/Assembly/App/ItemAssemblyPy.xml b/src/Mod/Assembly/App/ItemAssemblyPy.xml index 7e9ba5727..e2f560946 100644 --- a/src/Mod/Assembly/App/ItemAssemblyPy.xml +++ b/src/Mod/Assembly/App/ItemAssemblyPy.xml @@ -13,15 +13,5 @@ Base class of all objects in Assembly - - - Adds a Assembly::ItemPart object to the assembly - - - - - Adds a Assembly::ItemAssembly object to the assembly - - diff --git a/src/Mod/Assembly/App/ItemAssemblyPyImp.cpp b/src/Mod/Assembly/App/ItemAssemblyPyImp.cpp index 5d7ff419c..3a224534d 100644 --- a/src/Mod/Assembly/App/ItemAssemblyPyImp.cpp +++ b/src/Mod/Assembly/App/ItemAssemblyPyImp.cpp @@ -17,41 +17,6 @@ std::string ItemAssemblyPy::representation(void) const } -PyObject* ItemAssemblyPy::addPart(PyObject * args) -{ - PyObject *pcObj; - if (!PyArg_ParseTuple(args, "O", &pcObj)) { - Base::Console().Message("Test 1 fails\n"); - return 0; - } - - if (PyObject_TypeCheck(pcObj, &(Assembly::ItemPartPy::Type))) { - Assembly::ItemPart *c = static_cast(pcObj)->getItemPartPtr(); - getItemAssemblyPtr()->addPart(c); - Base::Console().Message("Add Part\n"); - } - else Base::Console().Message("Test 2 fails\n"); - Py_Return; -} - -PyObject* ItemAssemblyPy::addComponent(PyObject * args) -{ - PyObject *pcObj; - if (!PyArg_ParseTuple(args, "O", &pcObj)) { - Base::Console().Message("Test 1 fails\n"); - return 0; - } - - if (PyObject_TypeCheck(pcObj, &(Assembly::ItemAssemblyPy::Type))) { - Assembly::ItemAssembly *c = static_cast(pcObj)->getItemAssemblyPtr(); - getItemAssemblyPtr()->addComponent(c); - Base::Console().Message("Add Component\n"); - } - else Base::Console().Message("Test 2 fails\n"); - Py_Return; -} - - PyObject *ItemAssemblyPy::getCustomAttributes(const char* /*attr*/) const { return 0; diff --git a/src/Mod/Assembly/App/ItemPart.cpp b/src/Mod/Assembly/App/ItemPart.cpp index 61a5b9fc0..f594ea931 100644 --- a/src/Mod/Assembly/App/ItemPart.cpp +++ b/src/Mod/Assembly/App/ItemPart.cpp @@ -143,17 +143,17 @@ boost::shared_ptr< Geometry3D > ItemPart::getGeometry3D(const char* Type) gp_Dir dir = plane.Axis().Direction(); plane = gp_Pln(plane.Location(), dir.Reversed()); } - geometry = m_part->addGeometry3D(plane, Type, dcm::Global); + geometry = m_part->addGeometry3D(plane, Type, dcm::Local); break; } case GeomAbs_Cylinder: { //Base::Console().Message("cylinder selected\n"); gp_Cylinder cyl = surface.Cylinder(); - geometry = m_part->addGeometry3D(cyl, Type, dcm::Global); + geometry = m_part->addGeometry3D(cyl, Type, dcm::Local); break; } default: - Base::Console().Message("Unsuported Surface Geometrie Type at selection 1\n"); + Base::Console().Message("Unsuported Surface Geometrie Type at selection\n"); return boost::shared_ptr< Geometry3D >(); } @@ -163,24 +163,29 @@ boost::shared_ptr< Geometry3D > ItemPart::getGeometry3D(const char* Type) switch(curve.GetType()) { case GeomAbs_Line: { gp_Lin line = curve.Line(); - geometry = m_part->addGeometry3D(line, Type, dcm::Global); + geometry = m_part->addGeometry3D(line, Type, dcm::Local); break; } default: - //Base::Console().Message("Unsuported Curve Geometrie Type at selection 1\n"); + Base::Console().Message("Unsuported Curve Geometrie Type at selection \n"); return boost::shared_ptr< Geometry3D >(); } } else if(s.ShapeType() == TopAbs_VERTEX) { TopoDS_Vertex v1 = TopoDS::Vertex(s); gp_Pnt point = BRep_Tool::Pnt(v1); - geometry = m_part->addGeometry3D(point, Type, dcm::Global); + geometry = m_part->addGeometry3D(point, Type, dcm::Local); } else { - Base::Console().Message("Unsuported Topologie Type at selection 1\n"); + Base::Console().Message("Unsuported Topologie Type at selection\n"); return boost::shared_ptr< Geometry3D >(); } }; + + std::stringstream s; + s<m_global; + Base::Console().Message("Added geom: %s, %s\n", Type, s.str().c_str()); + return geometry; } diff --git a/src/Mod/Assembly/App/Solver.h b/src/Mod/Assembly/App/Solver.h index fc74051bc..5ddc4c51e 100644 --- a/src/Mod/Assembly/App/Solver.h +++ b/src/Mod/Assembly/App/Solver.h @@ -20,7 +20,6 @@ * * ***************************************************************************/ - #ifndef SOLVER_H #define SOLVER_H diff --git a/src/Mod/Assembly/App/opendcm/core.hpp b/src/Mod/Assembly/App/opendcm/core.hpp index 8d03a1d7f..c58af05a6 100644 --- a/src/Mod/Assembly/App/opendcm/core.hpp +++ b/src/Mod/Assembly/App/opendcm/core.hpp @@ -20,6 +20,11 @@ #ifndef DCM_CORE_H #define DCM_CORE_H +#ifdef _WIN32 + //warning about to long decoraded names, won't affect the code correctness + #pragma warning( disable : 4503 ) +#endif + #include "core/geometry.hpp" #include "core/kernel.hpp" #include "core/system.hpp" diff --git a/src/Mod/Assembly/App/opendcm/core/clustergraph.hpp b/src/Mod/Assembly/App/opendcm/core/clustergraph.hpp index fac9f172c..4fed639dd 100644 --- a/src/Mod/Assembly/App/opendcm/core/clustergraph.hpp +++ b/src/Mod/Assembly/App/opendcm/core/clustergraph.hpp @@ -52,6 +52,8 @@ #include #include +#include + namespace mpl = boost::mpl; namespace fusion = boost::fusion; @@ -362,23 +364,23 @@ public: return std::pair, LocalVertex>(m_clusters[v] = boost::shared_ptr(new ClusterGraph(sp_base::shared_from_this())), v); }; - boost::shared_ptr parent() { - return m_parent; + inline boost::shared_ptr parent() { + return boost::shared_ptr(m_parent); }; - const boost::shared_ptr parent() const { - return m_parent; + inline const boost::shared_ptr parent() const { + return boost::shared_ptr(m_parent); }; bool isRoot() const { - return m_parent ? false : true; + return m_parent.expired(); }; boost::shared_ptr root() { - return isRoot() ? sp_base::shared_from_this() : m_parent->root(); + return isRoot() ? sp_base::shared_from_this() : parent()->root(); }; const boost::shared_ptr root() const { - return isRoot() ? sp_base::shared_from_this() : m_parent->root(); + return isRoot() ? sp_base::shared_from_this() : parent()->root(); }; std::pair clusters() { @@ -1303,8 +1305,8 @@ public: LocalVertex nv = boost::add_vertex(vb, *parent()); //regrouping if needed if(isCluster(v)) { - m_parent->m_clusters[nv] = m_clusters[v]; - m_parent->m_clusters[nv]->m_parent = m_parent; + parent()->m_clusters[nv] = m_clusters[v]; + parent()->m_clusters[nv]->m_parent = m_parent; m_clusters.erase(v); } @@ -1312,7 +1314,7 @@ public: //get all out_edges of this cluster in the parentcluster (because only they can hold relevant global_Edgs) std::vector edge_vec; - LocalVertex this_v = m_parent->getClusterVertex(sp_base::shared_from_this()); + LocalVertex this_v = parent()->getClusterVertex(sp_base::shared_from_this()); std::pair it = boost::out_edges(this_v, *parent()); for(; it.first != it.second; it.first++) { //iterate all global edges and find relevant ones @@ -1323,14 +1325,14 @@ public: GlobalEdge global = global_extractor()(*i); GlobalVertex target; //a bit cumbersome to allow cluster moving - if(m_parent->getContainingVertex(global.source).first == nv) target = global.target; - else if(m_parent->getContainingVertex(global.target).first == nv) target = global.source; + if(parent()->getContainingVertex(global.source).first == nv) target = global.target; + else if(parent()->getContainingVertex(global.target).first == nv) target = global.source; else { i++; continue; } - std::pair res = m_parent->getContainingVertex(target); + std::pair res = parent()->getContainingVertex(target); //get or create the edge between the new vertex and the target LocalEdge e; @@ -1379,7 +1381,7 @@ public: ClusterMap m_clusters; int test; protected: - boost::shared_ptr m_parent; + boost::weak_ptr m_parent; details::IDpointer m_id; @@ -1509,6 +1511,10 @@ protected: }; + +public: + //may hold cluster properties which have Eigen3 objects and therefore need alignment + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; } //namespace solver diff --git a/src/Mod/Assembly/App/opendcm/core/equations.hpp b/src/Mod/Assembly/App/opendcm/core/equations.hpp index 4e078bf55..d852e9b56 100644 --- a/src/Mod/Assembly/App/opendcm/core/equations.hpp +++ b/src/Mod/Assembly/App/opendcm/core/equations.hpp @@ -31,8 +31,12 @@ #include #include #include +#include +#include +#include namespace fusion = boost::fusion; +namespace mpl = boost::mpl; #include "kernel.hpp" @@ -65,8 +69,9 @@ template struct pushed_seq; template -struct op_seq : public seq { - +struct constraint_sequence : public seq { + + //an equation gets added to this equation template typename boost::enable_if< boost::is_base_of< dcm::EQ, T>, typename pushed_seq::type >::type operator &(T val) { @@ -91,13 +96,51 @@ struct op_seq : public seq { //and return our new extendet sequence return vec; }; + + template + void pretty(T type) { + std::cout<<"pretty: "<<__PRETTY_FUNCTION__< + typename boost::enable_if< mpl::is_sequence, typename pushed_seq::type >::type operator &(T val) { + + typedef typename pushed_seq::type Sequence; + typedef typename fusion::result_of::begin::type Begin; + typedef typename fusion::result_of::end::type End; + + typedef typename mpl::distance< typename mpl::begin::type, typename mpl::end::type >::type distanceF; + typedef typename fusion::result_of::advance::type EndF; + + //create the new sequence + Sequence vec; + + //copy the given values into the new sequence + Begin b(vec); + EndF ef(vec); + + fusion::iterator_range range(b, ef); + fusion::copy(val, range); + + //copy the objects value into the new sequence + EndF bb(vec); + End e(vec); + + fusion::iterator_range range2(bb, e); + fusion::copy(*this, range2); + + //and return our new extendet sequence + return vec; + }; }; template struct pushed_seq { - typedef typename boost::mpl::if_, Seq, fusion::vector1 >::type S; - typedef typename fusion::result_of::as_vector< typename boost::mpl::push_back::type >::type vec; - typedef op_seq type; + typedef typename mpl::if_, Seq, fusion::vector1 >::type S1; + typedef typename mpl::if_, T, fusion::vector1 >::type S2; + typedef typename fusion::result_of::as_vector >::type >::type vec; + typedef constraint_sequence type; }; template @@ -116,6 +159,7 @@ struct Equation : public EQ { return operator()(val); }; + //an equation gets added to this equation template typename boost::enable_if< boost::is_base_of< dcm::EQ, T>, typename pushed_seq::type >::type operator &(T val) { @@ -124,6 +168,32 @@ struct Equation : public EQ { fusion::at_c<1>(vec) = *(static_cast(this)); return vec; }; + + //an sequence gets added to this equation (happens only if sequenced equations like coincident are used) + template + typename boost::enable_if< mpl::is_sequence, typename pushed_seq::type >::type operator &(T val) { + + typedef typename pushed_seq::type Sequence; + typedef typename fusion::result_of::begin::type Begin; + typedef typename fusion::result_of::end::type End; + typedef typename fusion::result_of::prior::type EndOld; + + //create the new sequence + Sequence vec; + + //copy the old values into the new sequence + Begin b(vec); + EndOld eo(vec); + + fusion::iterator_range range(b, eo); + fusion::copy(val, range); + + //insert this object at the end of the sequence + fusion::back(vec) = *static_cast(this); + + //and return our new extendet sequence + return vec; + }; }; struct Distance : public Equation { @@ -221,12 +291,15 @@ struct Angle : public Equation { //template definition 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); diff --git a/src/Mod/Assembly/App/opendcm/core/geometry.hpp b/src/Mod/Assembly/App/opendcm/core/geometry.hpp index 045e68589..cca085233 100644 --- a/src/Mod/Assembly/App/opendcm/core/geometry.hpp +++ b/src/Mod/Assembly/App/opendcm/core/geometry.hpp @@ -168,10 +168,10 @@ public: typedef mpl::int_ Dimension; template - Geometry(T geometry, Sys& system); + Geometry(const T& geometry, Sys& system); template - void set(T geometry); + void set(const T& geometry); template typename Visitor::result_type apply(Visitor& vis) { @@ -229,7 +229,7 @@ public: typename Kernel::VectorMap m_parameter; //map to the parameters in the solver template - void init(T& t); + void init(const T& t); void normalize(); @@ -280,7 +280,7 @@ public: template< typename Sys, typename Derived, typename GeometrieTypeList, int Dim> template -Geometry::Geometry(T geometry, Sys& system) +Geometry::Geometry(const T& geometry, Sys& system) : m_isInCluster(false), m_geometry(geometry), m_parameter(NULL,0,DS(0,0)), m_clusterFixed(false), m_init(false) { @@ -294,7 +294,7 @@ Geometry::Geometry(T geometry, Sys& system template< typename Sys, typename Derived, typename GeometrieTypeList, int Dim> template -void Geometry::set(T geometry) { +void Geometry::set(const T& geometry) { m_geometry = geometry; init(geometry); //Base::template emitSignal( ((Derived*)this)->shared_from_this() ); @@ -325,7 +325,7 @@ boost::shared_ptr Geometry::clone template< typename Sys, typename Derived, typename GeometrieTypeList, int Dim> template -void Geometry::init(T& t) { +void Geometry::init(const T& t) { m_BaseParameterCount = geometry_traits::tag::parameters::value; m_parameterCount = m_BaseParameterCount; diff --git a/src/Mod/Assembly/App/opendcm/core/system.hpp b/src/Mod/Assembly/App/opendcm/core/system.hpp index 16c931cf4..c5c9a5523 100644 --- a/src/Mod/Assembly/App/opendcm/core/system.hpp +++ b/src/Mod/Assembly/App/opendcm/core/system.hpp @@ -201,7 +201,7 @@ public: Type1::system_init(*this); Type2::system_init(*this); Type3::system_init(*this); - + }; diff --git a/src/Mod/Assembly/App/opendcm/core/transformation.hpp b/src/Mod/Assembly/App/opendcm/core/transformation.hpp index cec6c0d46..91b7057af 100644 --- a/src/Mod/Assembly/App/opendcm/core/transformation.hpp +++ b/src/Mod/Assembly/App/opendcm/core/transformation.hpp @@ -229,6 +229,9 @@ public: m_rotation.normalize(); return *this; } + +public: + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; template diff --git a/src/Mod/Assembly/App/opendcm/externalize.hpp b/src/Mod/Assembly/App/opendcm/externalize.hpp index 098f1edf5..7306e7f17 100644 --- a/src/Mod/Assembly/App/opendcm/externalize.hpp +++ b/src/Mod/Assembly/App/opendcm/externalize.hpp @@ -20,6 +20,11 @@ #ifndef DCM_EXTERNALIZE_H #define DCM_EXTERNALIZE_H +#ifdef _WIN32 + //warning about to long decoraded names, won't affect the code correctness + #pragma warning( disable : 4503 ) +#endif + #include #include #include diff --git a/src/Mod/Assembly/App/opendcm/module3d.hpp b/src/Mod/Assembly/App/opendcm/module3d.hpp index a62bbb59a..db10e08cd 100644 --- a/src/Mod/Assembly/App/opendcm/module3d.hpp +++ b/src/Mod/Assembly/App/opendcm/module3d.hpp @@ -22,10 +22,16 @@ #define DCM_USE_MODULE3D +#ifdef _WIN32 + //warning about to long decoraded names, won't affect the code correctness + #pragma warning( disable : 4503 ) +#endif + #include "module3d/geometry.hpp" #include "module3d/distance.hpp" #include "module3d/parallel.hpp" #include "module3d/angle.hpp" +#include "module3d/coincident.hpp" #include "module3d/module.hpp" #endif //DCM_MODULE3D_H diff --git a/src/Mod/Assembly/App/opendcm/module3d/angle.hpp b/src/Mod/Assembly/App/opendcm/module3d/angle.hpp index 94d9e9efb..4c9d78850 100644 --- a/src/Mod/Assembly/App/opendcm/module3d/angle.hpp +++ b/src/Mod/Assembly/App/opendcm/module3d/angle.hpp @@ -21,129 +21,133 @@ #define GCM_ANGLE_HPP #include "geometry.hpp" +#include namespace dcm { - + //the calculations( same as we always calculate directions we can outsource the work to this functions) namespace angle_detail { template -inline typename Kernel::number_type calc(T d1, - T d2, - typename Kernel::number_type angle) { +inline typename Kernel::number_type calc(const T& d1, + const T& d2, + const typename Kernel::number_type& angle) { - return d1.dot(d2) / (d1.norm()*d2.norm()) - angle; + return d1.dot(d2) / (d1.norm()*d2.norm()) - std::cos(angle); }; template -inline typename Kernel::number_type calcGradFirst(T d1, - T d2, - T dd1) { +inline typename Kernel::number_type calcGradFirst(const T& d1, + const T& d2, + const T& dd1) { typename Kernel::number_type norm = d1.norm()*d2.norm(); return dd1.dot(d2)/norm - (d1.dot(d2) * (d1.dot(dd1)/d1.norm())*d2.norm()) / std::pow(norm,2); }; template -inline typename Kernel::number_type calcGradSecond(T d1, - T d2, - T dd2) { +inline typename Kernel::number_type calcGradSecond(const T& d1, + const T& d2, + const T& dd2) { typename Kernel::number_type norm = d1.norm()*d2.norm(); return d1.dot(dd2)/norm - (d1.dot(d2) * (d2.dot(dd2)/d2.norm())*d1.norm()) / std::pow(norm,2); }; template -inline void calcGradFirstComp(T d1, - T d2, - T grad) { +inline void calcGradFirstComp(const T& d1, + const T& d2, + const T& grad) { typename Kernel::number_type norm = d1.norm()*d2.norm(); - grad = d2/norm - (d1.dot(d2)/std::pow(norm,2))*d1/d1.norm(); + const_cast< T& >(grad) = d2/norm - (d1.dot(d2)/std::pow(norm,2))*d1/d1.norm(); }; template -inline void calcGradSecondComp(T d1, - T d2, - T grad) { +inline void calcGradSecondComp(const T& d1, + const T& d2, + const T& grad) { typename Kernel::number_type norm = d1.norm()*d2.norm(); - grad = d1/norm - (d1.dot(d2)/std::pow(norm,2))*d2/d2.norm(); + const_cast< T& >(grad) = d1/norm - (d1.dot(d2)/std::pow(norm,2))*d2/d2.norm(); }; } -/* -template< typename Kernel, typename Tag1, typename Tag2 > -struct Angle3D { + + +template< typename Kernel > +struct Angle::type< Kernel, tag::line3D, tag::line3D > : public dcm::PseudoScale { typedef typename Kernel::number_type Scalar; typedef typename Kernel::VectorMap Vector; - Scalar m_angle; - Angle3D(Scalar d = 0.) : m_angle(std::cos(d)) {}; + option_type value; //template definition - void setScale(Scalar scale){ - assert(false); - }; Scalar calculate(Vector& param1, Vector& param2) { - assert(false); + return angle_detail::calc(param1.template segment<3>(3), param2.template segment<3>(3), value); }; Scalar calculateGradientFirst(Vector& param1, Vector& param2, Vector& dparam1) { - assert(false); + return angle_detail::calcGradFirst(param1.template segment<3>(3), param2.template segment<3>(3), dparam1.template segment<3>(3)); }; Scalar calculateGradientSecond(Vector& param1, Vector& param2, Vector& dparam2) { - assert(false); + return angle_detail::calcGradSecond(param1.template segment<3>(3), param2.template segment<3>(3), dparam2.template segment<3>(3)); }; void calculateGradientFirstComplete(Vector& param1, Vector& param2, Vector& gradient) { - assert(false); + gradient.template head<3>().setZero(); + angle_detail::calcGradFirstComp(param1.template segment<3>(3), param2.template segment<3>(3), gradient.template segment<3>(3)); }; void calculateGradientSecondComplete(Vector& param1, Vector& param2, Vector& gradient) { - assert(false); + gradient.template head<3>().setZero(); + angle_detail::calcGradSecondComp(param1.template segment<3>(3), param2.template segment<3>(3), gradient.template segment<3>(3)); }; }; template< typename Kernel > -struct Angle3D< Kernel, tag::line3D, tag::line3D > { +struct Angle::type< Kernel, tag::line3D, tag::plane3D > : public Angle::type {}; + +template< typename Kernel > +struct Angle::type< Kernel, tag::line3D, tag::cylinder3D > : public Angle::type { - typedef typename Kernel::number_type Scalar; typedef typename Kernel::VectorMap Vector; - Scalar m_angle; + void calculateGradientSecondComplete(Vector& param1, Vector& param2, Vector& gradient) { + Angle::type::calculateGradientSecondComplete(param1, param2, gradient); + gradient(6)=0; + }; +}; - Angle3D(Scalar d = 0.) : m_angle(std::cos(d)) {}; +template< typename Kernel > +struct Angle::type< Kernel, tag::plane3D, tag::plane3D > : public Angle::type {}; + +template< typename Kernel > +struct Angle::type< Kernel, tag::plane3D, tag::cylinder3D > : public Angle::type { + + typedef typename Kernel::VectorMap Vector; + + void calculateGradientSecondComplete(Vector& param1, Vector& param2, Vector& gradient) { + Angle::type::calculateGradientSecondComplete(param1, param2, gradient); + gradient(6)=0; + }; +}; + +template< typename Kernel > +struct Angle::type< Kernel, tag::cylinder3D, tag::cylinder3D > : public Angle::type { + + typedef typename Kernel::VectorMap Vector; + + void calculateGradientFirstComplete(Vector& param1, Vector& param2, Vector& gradient) { + Angle::type::calculateGradientFirstComplete(param1, param2, gradient); + gradient(6)=0; + }; - Scalar getEquationScaling(typename Kernel::Vector& local1, typename Kernel::Vector& local2) { - return 1.; - } - - //template definition - Scalar calculate(Vector& param1, Vector& param2) { - return angle::calc(param1.template tail<3>(), param2.template tail<3>(), m_angle); - }; - Scalar calculateGradientFirst(Vector& param1, Vector& param2, Vector& dparam1) { - return angle::calcGradFirst(param1.template tail<3>(), param2.template tail<3>(), dparam1.template tail<3>()); - }; - Scalar calculateGradientSecond(Vector& param1, Vector& param2, Vector& dparam2) { - return angle::calcGradSecond(param1.template tail<3>(), param2.template tail<3>(), dparam2.template tail<3>()); - }; - void calculateGradientFirstComplete(Vector& param1, Vector& param2, Vector& gradient) { - gradient.template head<3>().setZero(); - angle::calcGradFirstComp(param1.template tail<3>(), param2.template tail<3>(), gradient.template tail<3>()); - }; void calculateGradientSecondComplete(Vector& param1, Vector& param2, Vector& gradient) { - gradient.template head<3>().setZero(); - angle::calcGradSecondComp(param1.template tail<3>(), param2.template tail<3>(), gradient.template tail<3>()); + Angle::type::calculateGradientSecondComplete(param1, param2, gradient); + gradient(6)=0; }; }; -//planes like lines have the direction as segment 3-5, so we can use the same implementations -template< typename Kernel > -struct Angle3D< Kernel, tag::plane3D, tag::plane3D > : public Angle3D {}; -template< typename Kernel > -struct Angle3D< Kernel, tag::line3D, tag::plane3D > : public Angle3D {}; -*/ } -#endif //GCM_ANGLE_HPP \ No newline at end of file +#endif //GCM_ANGLE_HPP diff --git a/src/Mod/Assembly/App/opendcm/module3d/clustermath.hpp b/src/Mod/Assembly/App/opendcm/module3d/clustermath.hpp index 13cb030cc..d1311fa43 100644 --- a/src/Mod/Assembly/App/opendcm/module3d/clustermath.hpp +++ b/src/Mod/Assembly/App/opendcm/module3d/clustermath.hpp @@ -135,6 +135,9 @@ private: Scalar calcThreePoints(const typename Kernel::Vector3& p1, const typename Kernel::Vector3& p2, const typename Kernel::Vector3& p3); + +public: + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; diff --git a/src/Mod/Assembly/App/opendcm/module3d/module.hpp b/src/Mod/Assembly/App/opendcm/module3d/module.hpp index f274fac1f..ea6a9c9a1 100644 --- a/src/Mod/Assembly/App/opendcm/module3d/module.hpp +++ b/src/Mod/Assembly/App/opendcm/module3d/module.hpp @@ -99,13 +99,13 @@ struct Module3D { #endif public: template - Geometry3D_id(T geometry, Sys& system); + Geometry3D_id(const T& geometry, Sys& system); template - void set(T geometry, Identifier id); + void set(const T& geometry, Identifier id); //somehow the base class set funtion is not found template - void set(T geometry); + void set(const T& geometry); Identifier& getIdentifier(); void setIdentifier(Identifier id); @@ -117,7 +117,7 @@ struct Module3D { typedef vertex_prop vertex_propertie; template - Geometry3D(T geometry, Sys& system); + Geometry3D(const T& geometry, Sys& system); //allow accessing the internals by module3d classes but not by users friend struct details::ClusterMath; @@ -125,6 +125,10 @@ struct Module3D { friend struct details::SystemSolver; friend struct details::SystemSolver::Rescaler; friend class detail::Constraint; + + public: + //the geometry class itself does not hold an aligned eigen object, but maybe the variant + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; template @@ -290,7 +294,7 @@ template template template template -Module3D::type::Geometry3D_id::Geometry3D_id(T geometry, Sys& system) +Module3D::type::Geometry3D_id::Geometry3D_id(const T& geometry, Sys& system) : detail::Geometry(geometry, system) #ifdef USE_LOGGING , log_id("No ID") @@ -306,7 +310,7 @@ template template template template -void Module3D::type::Geometry3D_id::set(T geometry, Identifier id) { +void Module3D::type::Geometry3D_id::set(const T& geometry, Identifier id) { this->template setProperty >(id); Base::set(geometry); }; @@ -315,7 +319,7 @@ template template template template -void Module3D::type::Geometry3D_id::set(T geometry) { +void Module3D::type::Geometry3D_id::set(const T& geometry) { Base::set(geometry); }; @@ -343,7 +347,7 @@ void Module3D::type::Geometry3D_id::setIdentifier(Id template template template -Module3D::type::Geometry3D::Geometry3D(T geometry, Sys& system) +Module3D::type::Geometry3D::Geometry3D(const T& geometry, Sys& system) : mpl::if_, detail::Geometry, Geometry3D_id >::type(geometry, system) { diff --git a/src/Mod/Assembly/App/opendcm/module3d/parallel.hpp b/src/Mod/Assembly/App/opendcm/module3d/parallel.hpp index 9aad3e8f5..780dd3f30 100644 --- a/src/Mod/Assembly/App/opendcm/module3d/parallel.hpp +++ b/src/Mod/Assembly/App/opendcm/module3d/parallel.hpp @@ -33,9 +33,9 @@ namespace dcm { namespace orientation_detail { template -inline typename Kernel::number_type calc(T d1, - T d2, - Direction dir) { +inline typename Kernel::number_type calc(const T& d1, + const T& d2, + const Direction& dir) { switch(dir) { case equal: @@ -54,10 +54,10 @@ inline typename Kernel::number_type calc(T d1, template -inline typename Kernel::number_type calcGradFirst(T d1, - T d2, - T dd1, - Direction dir) { +inline typename Kernel::number_type calcGradFirst(const T& d1, + const T& d2, + const T& dd1, + const Direction& dir) { typename Kernel::number_type res; switch(dir) { @@ -80,10 +80,10 @@ inline typename Kernel::number_type calcGradFirst(T d1, }; template -inline typename Kernel::number_type calcGradSecond(T d1, - T d2, - T dd2, - Direction dir) { +inline typename Kernel::number_type calcGradSecond(const T& d1, + const T& d2, + const T& dd2, + const Direction& dir) { typename Kernel::number_type res; switch(dir) { @@ -105,45 +105,45 @@ inline typename Kernel::number_type calcGradSecond(T d1, }; template -inline void calcGradFirstComp(T d1, - T d2, - T grad, - Direction dir) { +inline void calcGradFirstComp(const T& d1, + const T& d2, + const T& grad, + const Direction& dir) { switch(dir) { case equal: - grad = (d1-d2) / (d1-d2).norm(); + const_cast< T& >(grad) = (d1-d2) / (d1-d2).norm(); return; case opposite: - grad = (d1+d2) / (d1+d2).norm(); + const_cast< T& >(grad) = (d1+d2) / (d1+d2).norm(); return; case parallel: - grad = d2 - d1/d1.norm()*d2.norm(); + const_cast< T& >(grad) = d2 - d1/d1.norm()*d2.norm(); return; case perpendicular: - grad = d2; + const_cast< T& >(grad) = d2; return; } }; template -inline void calcGradSecondComp(T d1, - T d2, - T grad, - Direction dir) { +inline void calcGradSecondComp(const T& d1, + const T& d2, + const T& grad, + const Direction& dir) { switch(dir) { case equal: - grad = (d2-d1) / (d1-d2).norm(); + const_cast< T& >(grad) = (d2-d1) / (d1-d2).norm(); return; case opposite: - grad = (d2+d1) / (d1+d2).norm(); + const_cast< T& >(grad) = (d2+d1) / (d1+d2).norm(); return; case parallel: - grad = d1 - d2/d2.norm()*d1.norm(); + const_cast< T& >(grad) = d1 - d2/d2.norm()*d1.norm(); return; case perpendicular: - grad = d1; + const_cast< T& >(grad) = d1; return; } }; @@ -271,7 +271,16 @@ struct Orientation::type< Kernel, tag::line3D, tag::plane3D > : public Orientati }; template< typename Kernel > -struct Orientation::type< Kernel, tag::line3D, tag::cylinder3D > : public Orientation::type< Kernel, tag::line3D, tag::line3D > {}; +struct Orientation::type< Kernel, tag::line3D, tag::cylinder3D > : public Orientation::type< Kernel, tag::line3D, tag::line3D > { + + typedef typename Kernel::number_type Scalar; + typedef typename Kernel::VectorMap Vector; + + void calculateGradientSecondComplete(Vector& param1, Vector& param2, Vector& gradient) { + Orientation::type::calculateGradientSecondComplete(param1, param2, gradient); + gradient(6)=0; + }; +}; template< typename Kernel > struct Orientation::type< Kernel, tag::plane3D, tag::plane3D > : public Orientation::type< Kernel, tag::line3D, tag::line3D > {}; @@ -327,4 +336,4 @@ struct Orientation::type< Kernel, tag::cylinder3D, tag::cylinder3D > : public O }; } -#endif +#endif diff --git a/src/Mod/Assembly/App/opendcm/modulePart/module.hpp b/src/Mod/Assembly/App/opendcm/modulePart/module.hpp index c52b74bcb..208cd49cd 100644 --- a/src/Mod/Assembly/App/opendcm/modulePart/module.hpp +++ b/src/Mod/Assembly/App/opendcm/modulePart/module.hpp @@ -103,16 +103,16 @@ struct ModulePart { using Object::m_system; template - Part_base(T geometry, Sys& system, boost::shared_ptr cluster); + Part_base(const T& geometry, Sys& system, boost::shared_ptr cluster); template typename Visitor::result_type apply(Visitor& vis); template - Geom addGeometry3D(T geom, CoordinateFrame frame = Global); + Geom addGeometry3D(const T& geom, CoordinateFrame frame = Global); template - void set(T geometry); + void set(const T& geometry); virtual boost::shared_ptr clone(Sys& newSys); @@ -123,18 +123,22 @@ struct ModulePart { void finishCalculation(); void fix(bool fix_value); + + public: + //we hold a transform and need therefore a aligned new operator + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; struct Part_id : public Part_base { template - Part_id(T geometry, Sys& system, boost::shared_ptr cluster); + Part_id(const T& geometry, Sys& system, boost::shared_ptr cluster); template - typename Part_base::Geom addGeometry3D(T geom, Identifier id, CoordinateFrame frame = Global); + typename Part_base::Geom addGeometry3D(const T& geom, Identifier id, CoordinateFrame frame = Global); template - void set(T geometry, Identifier id); + void set(const T& geometry, Identifier id); bool hasGeometry3D(Identifier id); typename Part_base::Geom getGeometry3D(Identifier id); @@ -148,10 +152,14 @@ struct ModulePart { typedef typename mpl::if_, Part_base, Part_id>::type base; template - Part(T geometry, Sys& system, boost::shared_ptr cluster); + Part(const T& geometry, Sys& system, boost::shared_ptr cluster); friend struct PrepareCluster; friend struct EvaljuateCluster; + + public: + //we hold a transform and need therefore a aligned new operator + EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; @@ -160,11 +168,11 @@ struct ModulePart { inheriter_base(); template - Partptr createPart(T geometry); + Partptr createPart(const T& geometry); void removePart(Partptr p); template - void setTransformation(T geom) { + void setTransformation(const T& geom) { typedef typename system_traits::template getModule::type module3d; details::ClusterMath& cm = ((Sys*)this)->m_cluster->template getClusterProperty(); @@ -215,7 +223,7 @@ struct ModulePart { struct inheriter_id : public inheriter_base { template - Partptr createPart(T geometry, Identifier id); + Partptr createPart(const T& geometry, Identifier id); bool hasPart(Identifier id); Partptr getPart(Identifier id); }; @@ -256,7 +264,7 @@ struct ModulePart { template template template -ModulePart::type::Part_base::Part_base(T geometry, Sys& system, boost::shared_ptr cluster) +ModulePart::type::Part_base::Part_base(const T& geometry, Sys& system, boost::shared_ptr cluster) : Object(system), m_geometry(geometry), m_cluster(cluster) { #ifdef USE_LOGGING @@ -284,7 +292,7 @@ template template template typename ModulePart::template type::Part_base::Geom -ModulePart::type::Part_base::addGeometry3D(T geom, CoordinateFrame frame) { +ModulePart::type::Part_base::addGeometry3D(const T& geom, CoordinateFrame frame) { Geom g(new Geometry3D(geom, *m_system)); if(frame == Local) g->transform(m_transform); @@ -300,7 +308,7 @@ ModulePart::type::Part_base::addGeometry3D(T geom, Coordinate template template template -void ModulePart::type::Part_base::set(T geometry) { +void ModulePart::type::Part_base::set(const T& geometry) { Part_base::m_geometry = geometry; (typename geometry_traits::modell()).template extract::accessor >(geometry, Part_base::m_transform); @@ -355,7 +363,7 @@ void ModulePart::type::Part_base::fix(bool fix_value) { template template template -ModulePart::type::Part_id::Part_id(T geometry, Sys& system, boost::shared_ptr cluster) +ModulePart::type::Part_id::Part_id(const T& geometry, Sys& system, boost::shared_ptr cluster) : Part_base(geometry, system, cluster) { }; @@ -364,7 +372,7 @@ template template template typename ModulePart::template type::Part_base::Geom -ModulePart::type::Part_id::addGeometry3D(T geom, Identifier id, CoordinateFrame frame) { +ModulePart::type::Part_id::addGeometry3D(const T& geom, Identifier id, CoordinateFrame frame) { typename Part_base::Geom g = Part_base::addGeometry3D(geom, frame); g->setIdentifier(id); @@ -374,7 +382,7 @@ ModulePart::type::Part_id::addGeometry3D(T geom, Identifier i template template template -void ModulePart::type::Part_id::set(T geometry, Identifier id) { +void ModulePart::type::Part_id::set(const T& geometry, Identifier id) { Part_base::set(geometry); setIdentifier(id); }; @@ -413,7 +421,7 @@ void ModulePart::type::Part_id::setIdentifier(Identifier id) template template template -ModulePart::type::Part::Part(T geometry, Sys& system, boost::shared_ptr cluster) +ModulePart::type::Part::Part(const T& geometry, Sys& system, boost::shared_ptr cluster) : mpl::if_, Part_base, Part_id>::type(geometry, system, cluster) { @@ -429,13 +437,13 @@ template template template typename ModulePart::template type::Partptr -ModulePart::type::inheriter_base::createPart(T geometry) { +ModulePart::type::inheriter_base::createPart(const T& geometry) { typedef typename system_traits::Cluster Cluster; std::pair, LocalVertex> res = m_this->m_cluster->createCluster(); Partptr p(new Part(geometry, * ((Sys*) this), res.first)); - m_this->m_cluster->template setObject (res.second, p); + m_this->m_cluster->template setObject (res.second, p); m_this->push_back(p); res.first->template setClusterProperty(clusterPart); @@ -487,7 +495,7 @@ template template template typename ModulePart::template type::Partptr -ModulePart::type::inheriter_id::createPart(T geometry, Identifier id) { +ModulePart::type::inheriter_id::createPart(const T& geometry, Identifier id) { Partptr p = inheriter_base::createPart(geometry); p->setIdentifier(id); return p; diff --git a/src/Mod/Assembly/App/opendcm/modulepart.hpp b/src/Mod/Assembly/App/opendcm/modulepart.hpp index b121ea2e3..d4806fba6 100644 --- a/src/Mod/Assembly/App/opendcm/modulepart.hpp +++ b/src/Mod/Assembly/App/opendcm/modulepart.hpp @@ -22,6 +22,11 @@ #define DCM_USE_MODULEPART +#ifdef _WIN32 + //warning about to long decoraded names, won't affect the code correctness + #pragma warning( disable : 4503 ) +#endif + #include "modulePart/geometry.hpp" #include "modulePart/module.hpp" diff --git a/src/Mod/Assembly/App/opendcm/modulestate.hpp b/src/Mod/Assembly/App/opendcm/modulestate.hpp index 3b5ef5f07..ace674aca 100644 --- a/src/Mod/Assembly/App/opendcm/modulestate.hpp +++ b/src/Mod/Assembly/App/opendcm/modulestate.hpp @@ -22,6 +22,11 @@ #define DCM_USE_MODULESTATE +#ifdef _WIN32 + //warning about to long decoraded names, won't affect the code correctness + #pragma warning( disable : 4503 ) +#endif + #include "moduleState/module.hpp" #include "moduleState/traits.hpp" diff --git a/src/Mod/Assembly/Gui/AppAssemblyGui.cpp b/src/Mod/Assembly/Gui/AppAssemblyGui.cpp index c0acd9477..482327b03 100644 --- a/src/Mod/Assembly/Gui/AppAssemblyGui.cpp +++ b/src/Mod/Assembly/Gui/AppAssemblyGui.cpp @@ -36,6 +36,12 @@ #include "ViewProviderPart.h" #include "ViewProviderAssembly.h" #include "ViewProviderConstraintGroup.h" +#include "ViewProviderConstraintFix.h" +#include "ViewProviderConstraintDistance.h" +#include "ViewProviderConstraintAngle.h" +#include "ViewProviderConstraintOrientation.h" +#include "ViewProviderConstraintCoincidence.h" +#include "ViewProviderConstraintAlignment.h" #include @@ -84,6 +90,12 @@ void AssemblyGuiExport initAssemblyGui() AssemblyGui::ViewProviderItemAssembly::init(); AssemblyGui::ViewProviderConstraintGroup::init(); + AssemblyGui::ViewProviderConstraintFix::init(); + AssemblyGui::ViewProviderConstraintDistance::init(); + AssemblyGui::ViewProviderConstraintAngle::init(); + AssemblyGui::ViewProviderConstraintOrientation::init(); + AssemblyGui::ViewProviderConstraintCoincidence::init(); + AssemblyGui::ViewProviderConstraintAlignment::init(); // add resources and reloads the translators loadAssemblyResource(); diff --git a/src/Mod/Assembly/Gui/CMakeLists.txt b/src/Mod/Assembly/Gui/CMakeLists.txt index 133be2982..4779c12e2 100644 --- a/src/Mod/Assembly/Gui/CMakeLists.txt +++ b/src/Mod/Assembly/Gui/CMakeLists.txt @@ -28,6 +28,10 @@ set(AssemblyGui_LIBS qt4_add_resources(AssemblyGui_SRCS Resources/Assembly.qrc) +set(AssemblyGui_UIC_SRCS + AlignmentDialog.ui +) +qt4_wrap_ui(AssemblyGui_UIC_HDRS ${AssemblyGui_UIC_SRCS}) SET(AssemblyGuiViewProvider_SRCS ViewProvider.cpp @@ -38,14 +42,26 @@ SET(AssemblyGuiViewProvider_SRCS ViewProviderAssembly.h ViewProviderConstraintGroup.cpp ViewProviderConstraintGroup.h + ViewProviderConstraintFix.cpp + ViewProviderConstraintFix.h + ViewProviderConstraintDistance.cpp + ViewProviderConstraintDistance.h + ViewProviderConstraintAngle.cpp + ViewProviderConstraintAngle.h + ViewProviderConstraintOrientation.cpp + ViewProviderConstraintOrientation.h + ViewProviderConstraintCoincidence.cpp + ViewProviderConstraintCoincidence.h + ViewProviderConstraintAlignment.cpp + ViewProviderConstraintAlignment.h ) SOURCE_GROUP("ViewProvider" FILES ${AssemblyGuiViewProvider_SRCS}) -SET(AssemblyGuiModule_SRCS +SET(AssemblyGuiModule_SRCS AppAssemblyGui.cpp AppAssemblyGuiPy.cpp Command.cpp - CommandConstraints.cpp + CommandConstraints.cpp Resources/Assembly.qrc qrc_Assembly.cxx PreCompiled.cpp @@ -60,6 +76,7 @@ SET(AssemblyGui_SRCS ${AssemblyGui_SRCS} ${AssemblyGuiViewProvider_SRCS} ${AssemblyGuiModule_SRCS} + ${AssemblyGui_UIC_HDRS} ) add_library(AssemblyGui SHARED ${AssemblyGui_SRCS}) diff --git a/src/Mod/Assembly/Gui/Command.cpp b/src/Mod/Assembly/Gui/Command.cpp index f655e857d..4af10a38c 100644 --- a/src/Mod/Assembly/Gui/Command.cpp +++ b/src/Mod/Assembly/Gui/Command.cpp @@ -77,7 +77,7 @@ void CmdAssemblyAddNewPart::activated(int iMsg) doCommand(Doc,"App.activeDocument().addObject('Assembly::ItemPart','%s')",PartName.c_str()); if(dest){ std::string fatherName = dest->getNameInDocument(); - doCommand(Doc,"App.activeDocument().%s.addPart(App.activeDocument().%s) ",fatherName.c_str(),PartName.c_str()); + doCommand(Doc,"App.activeDocument().%s.Items = App.activeDocument().%s.Items + [App.activeDocument().%s] ",fatherName.c_str(),fatherName.c_str(),PartName.c_str()); } Command::addModule(App,"PartDesign"); Command::addModule(Gui,"PartDesignGui"); @@ -139,7 +139,7 @@ void CmdAssemblyAddNewComponent::activated(int iMsg) doCommand(Doc,"App.activeDocument().addObject('Assembly::ItemAssembly','%s')",CompName.c_str()); if(dest){ std::string fatherName = dest->getNameInDocument(); - doCommand(Doc,"App.activeDocument().%s.addComponent(App.activeDocument().%s) ",fatherName.c_str(), CompName.c_str()); + doCommand(Doc,"App.activeDocument().%s.Items = App.activeDocument().%s.Items + [App.activeDocument().%s] ",fatherName.c_str(),fatherName.c_str(),CompName.c_str()); } } diff --git a/src/Mod/Assembly/Gui/CommandConstraints.cpp b/src/Mod/Assembly/Gui/CommandConstraints.cpp index e46651e4f..198dbff5a 100644 --- a/src/Mod/Assembly/Gui/CommandConstraints.cpp +++ b/src/Mod/Assembly/Gui/CommandConstraints.cpp @@ -24,6 +24,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ # include +#include #endif #include @@ -31,6 +32,7 @@ #include #include #include +#include "ui_AlignmentDialog.h" #include #include @@ -97,22 +99,22 @@ std::string asSubLinkString(Assembly::ItemPart* part, std::string element) { //=========================================================================== -DEF_STD_CMD(CmdAssemblyConstraintAxle); +DEF_STD_CMD(CmdAssemblyConstraintDistance); -CmdAssemblyConstraintAxle::CmdAssemblyConstraintAxle() - :Command("Assembly_ConstraintAxle") +CmdAssemblyConstraintDistance::CmdAssemblyConstraintDistance() + :Command("Assembly_ConstraintDistance") { sAppModule = "Assembly"; sGroup = QT_TR_NOOP("Assembly"); - sMenuText = QT_TR_NOOP("Constraint Axle..."); - sToolTipText = QT_TR_NOOP("set a axle constraint between two objects"); + sMenuText = QT_TR_NOOP("Constraint Distance..."); + sToolTipText = QT_TR_NOOP("Set the distance between two selected entitys"); sWhatsThis = sToolTipText; sStatusTip = sToolTipText; - sPixmap = "actions/Axle_constraint"; + sPixmap = "Assembly_ConstraintDistance"; } -void CmdAssemblyConstraintAxle::activated(int iMsg) +void CmdAssemblyConstraintDistance::activated(int iMsg) { Assembly::ItemAssembly *Asm=0; Assembly::ConstraintGroup *ConstGrp=0; @@ -133,13 +135,23 @@ void CmdAssemblyConstraintAxle::activated(int iMsg) Base::Console().Message("The selected objects need to belong to the active assembly\n"); return; }; + + bool ok; + double d = QInputDialog::getDouble(NULL, QObject::tr("Constraint value"), + QObject::tr("Distance:"), 0., -10000., 10000., 2, &ok); + if(!ok) + return; - openCommand("Insert Constraint Axle"); - std::string ConstrName = getUniqueObjectName("Axle"); - doCommand(Doc,"App.activeDocument().addObject('Assembly::ConstraintAxis','%s')",ConstrName.c_str()); + openCommand("Insert Constraint Distance"); + std::string ConstrName = getUniqueObjectName("Distance"); + doCommand(Doc,"App.activeDocument().addObject('Assembly::ConstraintDistance','%s')",ConstrName.c_str()); doCommand(Doc,"App.activeDocument().ActiveObject.First = %s", asSubLinkString(part1, objs[0].getSubNames()[0]).c_str()); doCommand(Doc,"App.activeDocument().ActiveObject.Second = %s", asSubLinkString(part2, objs[1].getSubNames()[0]).c_str()); - doCommand(Doc,"App.activeDocument().%s.addConstraint(App.activeDocument().ActiveObject)",ConstGrp->getNameInDocument()); + doCommand(Doc,"App.activeDocument().ActiveObject.Distance = %f", d); + doCommand(Doc,"App.activeDocument().%s.Constraints = App.activeDocument().%s.Constraints + [App.activeDocument().ActiveObject]",ConstGrp->getNameInDocument(),ConstGrp->getNameInDocument()); + + commitCommand(); + updateActive(); } @@ -153,7 +165,7 @@ CmdAssemblyConstraintFix::CmdAssemblyConstraintFix() sAppModule = "Assembly"; sGroup = QT_TR_NOOP("Assembly"); sMenuText = QT_TR_NOOP("Constraint Fix..."); - sToolTipText = QT_TR_NOOP("Fixes a part in it's rotation and translation"); + sToolTipText = QT_TR_NOOP("Fix a part in it's rotation and translation"); sWhatsThis = sToolTipText; sStatusTip = sToolTipText; sPixmap = "Assembly_ConstraintLock"; @@ -185,7 +197,257 @@ void CmdAssemblyConstraintFix::activated(int iMsg) std::string ConstrName = getUniqueObjectName("Fix"); doCommand(Doc,"App.activeDocument().addObject('Assembly::ConstraintFix','%s')",ConstrName.c_str()); doCommand(Doc,"App.activeDocument().ActiveObject.First = %s", asSubLinkString(part, objs[0].getSubNames()[0]).c_str()); - doCommand(Doc,"App.activeDocument().%s.addConstraint(App.activeDocument().ActiveObject)",ConstGrp->getNameInDocument()); + doCommand(Doc,"App.activeDocument().%s.Constraints = App.activeDocument().%s.Constraints + [App.activeDocument().ActiveObject]",ConstGrp->getNameInDocument(),ConstGrp->getNameInDocument()); + + commitCommand(); + updateActive(); +} + +/******************************************************************************************/ + + +DEF_STD_CMD(CmdAssemblyConstraintAngle); + +CmdAssemblyConstraintAngle::CmdAssemblyConstraintAngle() + :Command("Assembly_ConstraintAngle") +{ + sAppModule = "Assembly"; + sGroup = QT_TR_NOOP("Assembly"); + sMenuText = QT_TR_NOOP("Constraint Angle..."); + sToolTipText = QT_TR_NOOP("Set the angle between two selected entitys"); + sWhatsThis = sToolTipText; + sStatusTip = sToolTipText; + sPixmap = "Assembly_ConstraintAngle"; +} + + +void CmdAssemblyConstraintAngle::activated(int iMsg) +{ + Assembly::ItemAssembly *Asm=0; + Assembly::ConstraintGroup *ConstGrp=0; + + // retrive the standard objects needed + if(getConstraintPrerequisits(&Asm,&ConstGrp)) + return; + + std::vector objs = Gui::Selection().getSelectionEx(); + if(objs.size() != 2) { + Base::Console().Message("you must select two geometries on two diffrent parts\n"); + return; + }; + + Assembly::ItemPart* part1 = Asm->getContainingPart(objs[0].getObject()); + Assembly::ItemPart* part2 = Asm->getContainingPart(objs[1].getObject()); + if(!part1 || !part2) { + Base::Console().Message("The selected objects need to belong to the active assembly\n"); + return; + }; + + bool ok; + double d = QInputDialog::getDouble(NULL, QObject::tr("Constraint value"), + QObject::tr("Angle:"), 0., 0., 360., 2, &ok); + if(!ok) + return; + + openCommand("Insert Constraint Angle"); + std::string ConstrName = getUniqueObjectName("Angle"); + doCommand(Doc,"App.activeDocument().addObject('Assembly::ConstraintAngle','%s')",ConstrName.c_str()); + doCommand(Doc,"App.activeDocument().ActiveObject.First = %s", asSubLinkString(part1, objs[0].getSubNames()[0]).c_str()); + doCommand(Doc,"App.activeDocument().ActiveObject.Second = %s", asSubLinkString(part2, objs[1].getSubNames()[0]).c_str()); + doCommand(Doc,"App.activeDocument().ActiveObject.Angle = %f", d); + doCommand(Doc,"App.activeDocument().%s.Constraints = App.activeDocument().%s.Constraints + [App.activeDocument().ActiveObject]",ConstGrp->getNameInDocument(),ConstGrp->getNameInDocument()); + + commitCommand(); + updateActive(); + +} + + +/******************************************************************************************/ + + +DEF_STD_CMD(CmdAssemblyConstraintOrientation); + +CmdAssemblyConstraintOrientation::CmdAssemblyConstraintOrientation() + :Command("Assembly_ConstraintOrientation") +{ + sAppModule = "Assembly"; + sGroup = QT_TR_NOOP("Assembly"); + sMenuText = QT_TR_NOOP("Constraint Orientation..."); + sToolTipText = QT_TR_NOOP("Set the orientation of two selected entitys in regard to each other"); + sWhatsThis = sToolTipText; + sStatusTip = sToolTipText; + sPixmap = "Assembly_ConstraintOrientation"; +} + + +void CmdAssemblyConstraintOrientation::activated(int iMsg) +{ + Assembly::ItemAssembly *Asm=0; + Assembly::ConstraintGroup *ConstGrp=0; + + // retrive the standard objects needed + if(getConstraintPrerequisits(&Asm,&ConstGrp)) + return; + + std::vector objs = Gui::Selection().getSelectionEx(); + if(objs.size() != 2) { + Base::Console().Message("you must select two geometries on two diffrent parts\n"); + return; + }; + + Assembly::ItemPart* part1 = Asm->getContainingPart(objs[0].getObject()); + Assembly::ItemPart* part2 = Asm->getContainingPart(objs[1].getObject()); + if(!part1 || !part2) { + Base::Console().Message("The selected objects need to belong to the active assembly\n"); + return; + }; + + QStringList items; + items << QObject::tr("Parallel") << QObject::tr("Perpendicular") << QObject::tr("Equal") << QObject::tr("Opposite"); + + bool ok; + QString item = QInputDialog::getItem(NULL, QObject::tr("Constraint value"), + QObject::tr("Orientation:"), items, 0, false, &ok); + if (!ok || item.isEmpty()) + return; + + openCommand("Insert Constraint Orientation"); + std::string ConstrName = getUniqueObjectName("Orientation"); + doCommand(Doc,"App.activeDocument().addObject('Assembly::ConstraintOrientation','%s')",ConstrName.c_str()); + doCommand(Doc,"App.activeDocument().ActiveObject.First = %s", asSubLinkString(part1, objs[0].getSubNames()[0]).c_str()); + doCommand(Doc,"App.activeDocument().ActiveObject.Second = %s", asSubLinkString(part2, objs[1].getSubNames()[0]).c_str()); + doCommand(Doc,"App.activeDocument().ActiveObject.Orientation = '%s'", item.toStdString().c_str()); + doCommand(Doc,"App.activeDocument().%s.Constraints = App.activeDocument().%s.Constraints + [App.activeDocument().ActiveObject]",ConstGrp->getNameInDocument(),ConstGrp->getNameInDocument()); + + commitCommand(); + updateActive(); + +} + +/******************************************************************************************/ + + +DEF_STD_CMD(CmdAssemblyConstraintCoincidence); + +CmdAssemblyConstraintCoincidence::CmdAssemblyConstraintCoincidence() + :Command("Assembly_ConstraintCoincidence") +{ + sAppModule = "Assembly"; + sGroup = QT_TR_NOOP("Assembly"); + sMenuText = QT_TR_NOOP("Constraint coincidence..."); + sToolTipText = QT_TR_NOOP("Make the selected entitys coincident"); + sWhatsThis = sToolTipText; + sStatusTip = sToolTipText; + sPixmap = "Assembly_ConstraintCoincidence"; +} + + +void CmdAssemblyConstraintCoincidence::activated(int iMsg) +{ + Assembly::ItemAssembly *Asm=0; + Assembly::ConstraintGroup *ConstGrp=0; + + // retrive the standard objects needed + if(getConstraintPrerequisits(&Asm,&ConstGrp)) + return; + + std::vector objs = Gui::Selection().getSelectionEx(); + if(objs.size() != 2) { + Base::Console().Message("you must select two geometries on two diffrent parts\n"); + return; + }; + + Assembly::ItemPart* part1 = Asm->getContainingPart(objs[0].getObject()); + Assembly::ItemPart* part2 = Asm->getContainingPart(objs[1].getObject()); + if(!part1 || !part2) { + Base::Console().Message("The selected objects need to belong to the active assembly\n"); + return; + }; + + QStringList items; + items << QObject::tr("Parallel") << QObject::tr("Equal") << QObject::tr("Opposite"); + + bool ok; + QString item = QInputDialog::getItem(NULL, QObject::tr("Constraint value"), + QObject::tr("Orientation:"), items, 0, false, &ok); + if (!ok || item.isEmpty()) + return; + + openCommand("Insert Constraint Coincidence"); + std::string ConstrName = getUniqueObjectName("Coincidence"); + doCommand(Doc,"App.activeDocument().addObject('Assembly::ConstraintCoincidence','%s')",ConstrName.c_str()); + doCommand(Doc,"App.activeDocument().ActiveObject.First = %s", asSubLinkString(part1, objs[0].getSubNames()[0]).c_str()); + doCommand(Doc,"App.activeDocument().ActiveObject.Second = %s", asSubLinkString(part2, objs[1].getSubNames()[0]).c_str()); + doCommand(Doc,"App.activeDocument().ActiveObject.Orientation = '%s'", item.toStdString().c_str()); + doCommand(Doc,"App.activeDocument().%s.Constraints = App.activeDocument().%s.Constraints + [App.activeDocument().ActiveObject]",ConstGrp->getNameInDocument(),ConstGrp->getNameInDocument()); + + commitCommand(); + updateActive(); + +} + +/******************************************************************************************/ + + +DEF_STD_CMD(CmdAssemblyConstraintAlignment); + +CmdAssemblyConstraintAlignment::CmdAssemblyConstraintAlignment() + :Command("Assembly_ConstraintAlignment") +{ + sAppModule = "Assembly"; + sGroup = QT_TR_NOOP("Assembly"); + sMenuText = QT_TR_NOOP("Constraint allignment..."); + sToolTipText = QT_TR_NOOP("Align the selected entitys"); + sWhatsThis = sToolTipText; + sStatusTip = sToolTipText; + sPixmap = "Assembly_ConstraintAlignment"; +} + + +void CmdAssemblyConstraintAlignment::activated(int iMsg) +{ + Assembly::ItemAssembly *Asm=0; + Assembly::ConstraintGroup *ConstGrp=0; + + // retrive the standard objects needed + if(getConstraintPrerequisits(&Asm,&ConstGrp)) + return; + + std::vector objs = Gui::Selection().getSelectionEx(); + if(objs.size() != 2) { + Base::Console().Message("you must select two geometries on two diffrent parts\n"); + return; + }; + + Assembly::ItemPart* part1 = Asm->getContainingPart(objs[0].getObject()); + Assembly::ItemPart* part2 = Asm->getContainingPart(objs[1].getObject()); + if(!part1 || !part2) { + Base::Console().Message("The selected objects need to belong to the active assembly\n"); + return; + }; + + QStringList items; + items << QObject::tr("Parallel") << QObject::tr("Equal") << QObject::tr("Opposite"); + + QDialog dialog; + Ui_AlignmentDialog ui; + ui.setupUi(&dialog); + ui.comboBox->addItems(items); + if( dialog.exec() != QDialog::Accepted ) + return; + + openCommand("Insert Constraint Alignment"); + std::string ConstrName = getUniqueObjectName("Alignment"); + doCommand(Doc,"App.activeDocument().addObject('Assembly::ConstraintAlignment','%s')",ConstrName.c_str()); + doCommand(Doc,"App.activeDocument().ActiveObject.First = %s", asSubLinkString(part1, objs[0].getSubNames()[0]).c_str()); + doCommand(Doc,"App.activeDocument().ActiveObject.Second = %s", asSubLinkString(part2, objs[1].getSubNames()[0]).c_str()); + doCommand(Doc,"App.activeDocument().ActiveObject.Orientation = '%s'", ui.comboBox->currentText().toStdString().c_str()); + doCommand(Doc,"App.activeDocument().ActiveObject.Offset = %f", ui.doubleSpinBox->value()); + doCommand(Doc,"App.activeDocument().%s.Constraints = App.activeDocument().%s.Constraints + [App.activeDocument().ActiveObject]",ConstGrp->getNameInDocument(),ConstGrp->getNameInDocument()); + + commitCommand(); + updateActive(); } @@ -194,5 +456,9 @@ void CreateAssemblyConstraintCommands(void) Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); rcCmdMgr.addCommand(new CmdAssemblyConstraintFix()); - rcCmdMgr.addCommand(new CmdAssemblyConstraintAxle()); + rcCmdMgr.addCommand(new CmdAssemblyConstraintDistance()); + rcCmdMgr.addCommand(new CmdAssemblyConstraintAngle()); + rcCmdMgr.addCommand(new CmdAssemblyConstraintOrientation()); + rcCmdMgr.addCommand(new CmdAssemblyConstraintCoincidence()); + rcCmdMgr.addCommand(new CmdAssemblyConstraintAlignment()); } diff --git a/src/Mod/Assembly/Gui/Resources/Assembly.qrc b/src/Mod/Assembly/Gui/Resources/Assembly.qrc index d670d8956..b680f4637 100644 --- a/src/Mod/Assembly/Gui/Resources/Assembly.qrc +++ b/src/Mod/Assembly/Gui/Resources/Assembly.qrc @@ -1,7 +1,11 @@ - icons/actions/Axle_constraint.svg icons/Assembly_ConstraintLock.svg + icons/Assembly_ConstraintDistance.svg + icons/Assembly_ConstraintAngle.svg + icons/Assembly_ConstraintOrientation.svg + icons/Assembly_ConstraintCoincidence.svg + icons/Assembly_ConstraintAlignment.svg translations/Assembly_af.qm translations/Assembly_de.qm translations/Assembly_fi.qm diff --git a/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintAngle.svg b/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintAngle.svg new file mode 100644 index 000000000..7d78cca95 --- /dev/null +++ b/src/Mod/Assembly/Gui/Resources/icons/Assembly_ConstraintAngle.svg @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintAlignment.cpp b/src/Mod/Assembly/Gui/ViewProviderConstraintAlignment.cpp new file mode 100644 index 000000000..b602be39e --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintAlignment.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 "ViewProviderConstraintAlignment.h" + +using namespace AssemblyGui; + +PROPERTY_SOURCE(AssemblyGui::ViewProviderConstraintAlignment, Gui::ViewProviderDocumentObject) + +ViewProviderConstraintAlignment::ViewProviderConstraintAlignment() { + + sPixmap = "Assembly_ConstraintAlignment"; +} + diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintAlignment.h b/src/Mod/Assembly/Gui/ViewProviderConstraintAlignment.h new file mode 100644 index 000000000..38d2fadde --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintAlignment.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_VIEWPROVIDERCONSTRAINTAlignment_H +#define ASSEMBLYGUI_VIEWPROVIDERCONSTRAINTAlignment_H + +#include + +namespace AssemblyGui { + +class AssemblyGuiExport ViewProviderConstraintAlignment : public Gui::ViewProviderDocumentObject { + + PROPERTY_HEADER(AssemblyGui::ViewProviderConstraintAlignment); + +public: + ViewProviderConstraintAlignment(); + +}; + +}; + +#endif // VIEWPROVIDERCONSTRAINTFIX_H diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintAngle.cpp b/src/Mod/Assembly/Gui/ViewProviderConstraintAngle.cpp new file mode 100644 index 000000000..229f80869 --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintAngle.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 "ViewProviderConstraintAngle.h" + +using namespace AssemblyGui; + +PROPERTY_SOURCE(AssemblyGui::ViewProviderConstraintAngle, Gui::ViewProviderDocumentObject) + +ViewProviderConstraintAngle::ViewProviderConstraintAngle() { + + sPixmap = "Assembly_ConstraintAngle"; +} + diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintAngle.h b/src/Mod/Assembly/Gui/ViewProviderConstraintAngle.h new file mode 100644 index 000000000..cd68cbe8c --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintAngle.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_VIEWPROVIDERCONSTRAINTANGLE_H +#define ASSEMBLYGUI_VIEWPROVIDERCONSTRAINTANGLE_H + +#include + +namespace AssemblyGui { + +class AssemblyGuiExport ViewProviderConstraintAngle : public Gui::ViewProviderDocumentObject { + + PROPERTY_HEADER(AssemblyGui::ViewProviderConstraintAngle); + +public: + ViewProviderConstraintAngle(); + +}; + +}; + +#endif // VIEWPROVIDERCONSTRAINTFIX_H diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintCoincidence.cpp b/src/Mod/Assembly/Gui/ViewProviderConstraintCoincidence.cpp new file mode 100644 index 000000000..eeca7d5c0 --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintCoincidence.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 "ViewProviderConstraintCoincidence.h" + +using namespace AssemblyGui; + +PROPERTY_SOURCE(AssemblyGui::ViewProviderConstraintCoincidence, Gui::ViewProviderDocumentObject) + +ViewProviderConstraintCoincidence::ViewProviderConstraintCoincidence() { + + sPixmap = "Assembly_ConstraintCoincidence"; +} + diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintCoincidence.h b/src/Mod/Assembly/Gui/ViewProviderConstraintCoincidence.h new file mode 100644 index 000000000..a4cbacd73 --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintCoincidence.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_VIEWPROVIDERCONSTRAINTCoincidence_H +#define ASSEMBLYGUI_VIEWPROVIDERCONSTRAINTCoincidence_H + +#include + +namespace AssemblyGui { + +class AssemblyGuiExport ViewProviderConstraintCoincidence : public Gui::ViewProviderDocumentObject { + + PROPERTY_HEADER(AssemblyGui::ViewProviderConstraintCoincidence); + +public: + ViewProviderConstraintCoincidence(); + +}; + +}; + +#endif // VIEWPROVIDERCONSTRAINTFIX_H diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintDistance.cpp b/src/Mod/Assembly/Gui/ViewProviderConstraintDistance.cpp new file mode 100644 index 000000000..817a6432f --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintDistance.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 "ViewProviderConstraintDistance.h" + +using namespace AssemblyGui; + +PROPERTY_SOURCE(AssemblyGui::ViewProviderConstraintDistance, Gui::ViewProviderDocumentObject) + +ViewProviderConstraintDistance::ViewProviderConstraintDistance() { + + sPixmap = "Assembly_ConstraintDistance"; +} + diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintDistance.h b/src/Mod/Assembly/Gui/ViewProviderConstraintDistance.h new file mode 100644 index 000000000..1c1c1c364 --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintDistance.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_VIEWPROVIDERCONSTRAINTDISTANCE_H +#define ASSEMBLYGUI_VIEWPROVIDERCONSTRAINTDISTANCE_H + +#include + +namespace AssemblyGui { + +class AssemblyGuiExport ViewProviderConstraintDistance : public Gui::ViewProviderDocumentObject { + + PROPERTY_HEADER(AssemblyGui::ViewProviderConstraintDistance); + +public: + ViewProviderConstraintDistance(); + +}; + +}; + +#endif // VIEWPROVIDERCONSTRAINTFIX_H diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintGroup.cpp b/src/Mod/Assembly/Gui/ViewProviderConstraintGroup.cpp index 1a10eda3f..a03662c2d 100644 --- a/src/Mod/Assembly/Gui/ViewProviderConstraintGroup.cpp +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintGroup.cpp @@ -65,7 +65,7 @@ void ViewProviderConstraintGroup::setDisplayMode(const char* ModeName) if ( strcmp("Main",ModeName)==0 ) setDisplayMaskMode("Main"); -// ViewProviderDocumentObject::setDisplayMode( ModeName ); + ViewProviderDocumentObject::setDisplayMode( ModeName ); } std::vector ViewProviderConstraintGroup::getDisplayModes(void) const @@ -74,7 +74,7 @@ std::vector ViewProviderConstraintGroup::getDisplayModes(void) cons std::vector StrList = ViewProviderDocumentObject::getDisplayModes(); // add your own modes -// StrList.push_back("Main"); + StrList.push_back("Main"); return StrList; } diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintOrientation.cpp b/src/Mod/Assembly/Gui/ViewProviderConstraintOrientation.cpp new file mode 100644 index 000000000..4240613c4 --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintOrientation.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 "ViewProviderConstraintOrientation.h" + +using namespace AssemblyGui; + +PROPERTY_SOURCE(AssemblyGui::ViewProviderConstraintOrientation, Gui::ViewProviderDocumentObject) + +ViewProviderConstraintOrientation::ViewProviderConstraintOrientation() { + + sPixmap = "Assembly_ConstraintOrientation"; +} + diff --git a/src/Mod/Assembly/Gui/ViewProviderConstraintOrientation.h b/src/Mod/Assembly/Gui/ViewProviderConstraintOrientation.h new file mode 100644 index 000000000..1109d5d89 --- /dev/null +++ b/src/Mod/Assembly/Gui/ViewProviderConstraintOrientation.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_VIEWPROVIDERCONSTRAINTORIENTATION_H +#define ASSEMBLYGUI_VIEWPROVIDERCONSTRAINTORIENTATION_H + +#include + +namespace AssemblyGui { + +class AssemblyGuiExport ViewProviderConstraintOrientation : public Gui::ViewProviderDocumentObject { + + PROPERTY_HEADER(AssemblyGui::ViewProviderConstraintOrientation); + +public: + ViewProviderConstraintOrientation(); + +}; + +}; + +#endif // VIEWPROVIDERCONSTRAINTFIX_H diff --git a/src/Mod/Assembly/Gui/Workbench.cpp b/src/Mod/Assembly/Gui/Workbench.cpp index 6d042316d..3db61cf6b 100644 --- a/src/Mod/Assembly/Gui/Workbench.cpp +++ b/src/Mod/Assembly/Gui/Workbench.cpp @@ -52,8 +52,12 @@ Gui::ToolBarItem* Workbench::setupToolBars() const Gui::ToolBarItem* root = StdWorkbench::setupToolBars(); Gui::ToolBarItem* part = new Gui::ToolBarItem(root); part->setCommand(QT_TR_NOOP("Assembly")); - //*part << "Assembly_ConstraintFix"; - *part << "Assembly_ConstraintAxle"; + *part << "Assembly_ConstraintFix"; + *part << "Assembly_ConstraintDistance"; + *part << "Assembly_ConstraintOrientation"; + *part << "Assembly_ConstraintAngle"; + *part << "Assembly_ConstraintCoincidence"; + *part << "Assembly_ConstraintAlignment"; *part << "Separator"; *part << "Assembly_AddNewPart"; *part << "Assembly_AddNewComponent"; @@ -70,7 +74,12 @@ Gui::MenuItem* Workbench::setupMenuBar() const Gui::MenuItem* asmCmd = new Gui::MenuItem(); root->insertItem(item, asmCmd); asmCmd->setCommand("&Assembly"); - *asmCmd << "Assembly_ConstraintAxle" + *asmCmd << "Assembly_ConstraintFix" + << "Assembly_ConstraintDistance" + << "Assembly_ConstraintOrientation" + << "Assembly_ConstraintAngle" + << "Assembly_ConstraintCoincidence" + << "Assembly_ConstraintAlignment" << "Separator" << "Assembly_AddNewPart" << "Assembly_AddNewComponent"