Restructure the Assembly data model (again)...
This commit is contained in:
parent
09fe593ae0
commit
608dddd998
|
@ -33,7 +33,6 @@
|
|||
#include "Item.h"
|
||||
#include "Product.h"
|
||||
#include "ProductRef.h"
|
||||
#include "PartRef.h"
|
||||
|
||||
#include "Constraint.h"
|
||||
#include "ConstraintGroup.h"
|
||||
|
@ -73,7 +72,6 @@ void AssemblyExport initAssembly()
|
|||
Assembly::Item ::init();
|
||||
Assembly::Product ::init();
|
||||
Assembly::ProductRef ::init();
|
||||
Assembly::PartRef ::init();
|
||||
|
||||
// constraint hirachy
|
||||
Assembly::Constraint ::init();
|
||||
|
|
|
@ -32,15 +32,15 @@ set(Assembly_LIBS
|
|||
|
||||
generate_from_xml(ItemPy)
|
||||
generate_from_xml(ProductRefPy)
|
||||
generate_from_xml(PartRefPy)
|
||||
#generate_from_xml(PartRefPy)
|
||||
generate_from_xml(ConstraintPy)
|
||||
generate_from_xml(ConstraintGroupPy)
|
||||
|
||||
SET(Features_SRCS
|
||||
Item.cpp
|
||||
Item.h
|
||||
PartRef.cpp
|
||||
PartRef.h
|
||||
#PartRef.cpp
|
||||
#PartRef.h
|
||||
Product.cpp
|
||||
Product.h
|
||||
ProductRef.cpp
|
||||
|
@ -84,8 +84,8 @@ SET(Python_SRCS
|
|||
ItemPyImp.cpp
|
||||
ProductRefPy.xml
|
||||
ProductRefPyImp.cpp
|
||||
PartRefPy.xml
|
||||
PartRefPyImp.cpp
|
||||
#PartRefPy.xml
|
||||
#PartRefPyImp.cpp
|
||||
ConstraintPy.xml
|
||||
ConstraintPyImp.cpp
|
||||
ConstraintGroupPy.xml
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include "Constraint.h"
|
||||
#include "ConstraintPy.h"
|
||||
#include "Item.h"
|
||||
#include "PartRef.h"
|
||||
#include "Product.h"
|
||||
|
||||
|
||||
|
@ -76,37 +75,21 @@ struct ConstraintLinkException : std::exception {
|
|||
|
||||
PROPERTY_SOURCE(Assembly::Constraint, App::DocumentObject)
|
||||
|
||||
const char* Constraint::OrientationEnums[] = {"Parallel","Equal","Opposite","Perpendicular",NULL};
|
||||
const char* Constraint::TypeEnums[] = {"Fix","Distance","Orientation","Angle","Align","Coincident","None",NULL};
|
||||
const char* Constraint::SolutionSpaceEnums[] = {"Bidirectional","PositivDirectional","NegativeDirectional",NULL};
|
||||
|
||||
Constraint::Constraint()
|
||||
{
|
||||
ADD_PROPERTY(First, (0));
|
||||
ADD_PROPERTY(Second,(0));
|
||||
ADD_PROPERTY(Value,(0));
|
||||
ADD_PROPERTY(Orientation, (long(0)));
|
||||
Orientation.setEnums(OrientationEnums);
|
||||
ADD_PROPERTY(Type, (long(6)));
|
||||
Type.setEnums(TypeEnums);
|
||||
ADD_PROPERTY(SolutionSpace, (long(0)));
|
||||
|
||||
std::vector<std::string> vec;
|
||||
vec.push_back("Parallel");
|
||||
vec.push_back("Equal");
|
||||
vec.push_back("Opposite");
|
||||
vec.push_back("Perpendicular");
|
||||
Orientation.setEnumVector(vec);
|
||||
|
||||
std::vector<std::string> vec2;
|
||||
vec2.push_back("Fix");
|
||||
vec2.push_back("Distance");
|
||||
vec2.push_back("Orientation");
|
||||
vec2.push_back("Angle");
|
||||
vec2.push_back("Align");
|
||||
vec2.push_back("Coincident");
|
||||
vec2.push_back("None");
|
||||
Type.setEnumVector(vec2);
|
||||
|
||||
std::vector<std::string> vec3;
|
||||
vec3.push_back("Bidirectional");
|
||||
vec3.push_back("Positiv directional");
|
||||
vec3.push_back("Negative directional");
|
||||
SolutionSpace.setEnumVector(vec3);
|
||||
SolutionSpace.setEnums(SolutionSpaceEnums);
|
||||
}
|
||||
|
||||
short Constraint::mustExecute() const
|
||||
|
@ -119,126 +102,9 @@ short Constraint::mustExecute() const
|
|||
|
||||
App::DocumentObjectExecReturn* Constraint::execute(void)
|
||||
{
|
||||
touch();
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
boost::shared_ptr<Geometry3D> Constraint::initLink(App::PropertyLinkSub& link) {
|
||||
|
||||
//empty links are allowed
|
||||
if(!link.getValue())
|
||||
return boost::shared_ptr<Geometry3D>();
|
||||
|
||||
//check if we have Assembly::PartRef
|
||||
if(link.getValue()->getTypeId() != PartRef::getClassTypeId()) {
|
||||
throw ConstraintLinkException();
|
||||
return boost::shared_ptr<Geometry3D>();
|
||||
};
|
||||
|
||||
Assembly::PartRef* part = static_cast<Assembly::PartRef*>(link.getValue());
|
||||
|
||||
if(!part)
|
||||
throw ConstraintPartException();
|
||||
|
||||
//get the relevant solver in which the part needs to be added
|
||||
part->ensureInitialisation();
|
||||
|
||||
return part->getGeometry3D(link.getSubValues()[0].c_str());
|
||||
}
|
||||
|
||||
|
||||
void Constraint::init(Assembly::Product* ass)
|
||||
{
|
||||
Assembly::PartRef* part1, *part2;
|
||||
|
||||
if(First.getValue()) {
|
||||
m_first_geom = initLink(First);
|
||||
part1 = static_cast<Assembly::PartRef*>(First.getValue());
|
||||
}
|
||||
|
||||
if(Second.getValue()) {
|
||||
m_second_geom = initLink(Second);
|
||||
part2= static_cast<Assembly::PartRef*>(Second.getValue());
|
||||
}
|
||||
|
||||
//fix constraint
|
||||
if(Type.getValue() == 0) {
|
||||
if(part1)
|
||||
part1->m_part->fix(true);
|
||||
else if(part2)
|
||||
part2->m_part->fix(true);
|
||||
else
|
||||
throw ConstraintPartException();
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
//all other constraints need poth parts
|
||||
if(!part1 || !part2) {
|
||||
throw ConstraintPartException();
|
||||
};
|
||||
|
||||
//and both geometries
|
||||
if(!m_first_geom || !m_second_geom) {
|
||||
throw ConstraintInitException();
|
||||
};
|
||||
|
||||
//we may need the orientation
|
||||
dcm::Direction dir;
|
||||
|
||||
switch(Orientation.getValue()) {
|
||||
case 0:
|
||||
dir = dcm::parallel;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
dir = dcm::equal;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
dir = dcm::opposite;
|
||||
break;
|
||||
|
||||
default:
|
||||
dir = dcm::perpendicular;
|
||||
};
|
||||
|
||||
//we may need the SolutionSpace
|
||||
dcm::SolutionSpace sspace;
|
||||
|
||||
switch(SolutionSpace.getValue()) {
|
||||
case 0:
|
||||
sspace = dcm::bidirectional;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
sspace = dcm::positiv_directional;
|
||||
break;
|
||||
|
||||
default:
|
||||
sspace = dcm::negative_directional;
|
||||
};
|
||||
|
||||
//distance constraint
|
||||
if(Type.getValue() == 1)
|
||||
m_constraint = ass->m_solver->createConstraint3D(getNameInDocument(), m_first_geom, m_second_geom, (dcm::distance = Value.getValue()) = sspace);
|
||||
|
||||
//orientation constraint
|
||||
if(Type.getValue() == 2)
|
||||
m_constraint = ass->m_solver->createConstraint3D(getNameInDocument(), m_first_geom, m_second_geom, dcm::orientation = dir);
|
||||
|
||||
//angle constraint
|
||||
if(Type.getValue() == 3)
|
||||
m_constraint = ass->m_solver->createConstraint3D(getNameInDocument(), m_first_geom, m_second_geom, dcm::angle = Value.getValue()*M_PI/180.);
|
||||
|
||||
//alignemnt constraint
|
||||
if(Type.getValue() == 4)
|
||||
m_constraint = ass->m_solver->createConstraint3D(getNameInDocument(), m_first_geom, m_second_geom, ((dcm::alignment = dir) = Value.getValue()) = sspace);
|
||||
|
||||
//coincident constraint
|
||||
if(Type.getValue() == 5)
|
||||
m_constraint = ass->m_solver->createConstraint3D(getNameInDocument(), m_first_geom, m_second_geom, dcm::coincidence = dir);
|
||||
}
|
||||
|
||||
PyObject* Constraint::getPyObject(void)
|
||||
{
|
||||
|
|
|
@ -40,13 +40,7 @@ namespace Assembly
|
|||
class AssemblyExport Constraint : public App::DocumentObject
|
||||
{
|
||||
PROPERTY_HEADER(Assembly::Constraint);
|
||||
|
||||
protected:
|
||||
boost::shared_ptr<Constraint3D> m_constraint;
|
||||
boost::shared_ptr<Geometry3D> m_first_geom, m_second_geom;
|
||||
|
||||
boost::shared_ptr< Geometry3D > initLink(App::PropertyLinkSub& link);
|
||||
|
||||
|
||||
public:
|
||||
Constraint();
|
||||
|
||||
|
@ -67,10 +61,11 @@ public:
|
|||
return "AssemblyGui::ViewProviderConstraint";
|
||||
}
|
||||
PyObject *getPyObject(void);
|
||||
|
||||
/** @brief initialize the constraint in the assembly solver
|
||||
*/
|
||||
void init(Assembly::Product* ass);
|
||||
|
||||
private:
|
||||
static const char* OrientationEnums[];
|
||||
static const char* TypeEnums[];
|
||||
static const char* SolutionSpaceEnums[];
|
||||
};
|
||||
|
||||
} //namespace Assembly
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
#include "ConstraintGroupPy.h"
|
||||
#include "ConstraintGroup.h"
|
||||
#include "PartRef.h"
|
||||
#include "Product.h"
|
||||
|
||||
|
||||
|
@ -72,16 +71,6 @@ App::DocumentObjectExecReturn *ConstraintGroup::execute(void)
|
|||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
void ConstraintGroup::init(Product* ass) {
|
||||
|
||||
std::vector<App::DocumentObject*> obj = Constraints.getValues();
|
||||
|
||||
std::vector<App::DocumentObject*>::iterator it;
|
||||
for (it = obj.begin(); it != obj.end(); ++it) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(Assembly::Constraint::getClassTypeId())) {
|
||||
static_cast<Assembly::Constraint*>(*it)->init(ass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ public:
|
|||
}
|
||||
//@}
|
||||
|
||||
void init(Assembly::Product* ass);
|
||||
};
|
||||
|
||||
} //namespace Assembly
|
||||
|
|
|
@ -43,25 +43,6 @@ PROPERTY_SOURCE_ABSTRACT(Assembly::Item, App::GeoFeature)
|
|||
|
||||
Item::Item()
|
||||
{
|
||||
ADD_PROPERTY_TYPE(CreatedBy,(""),0,App::Prop_None,"The creator of the Item");
|
||||
ADD_PROPERTY_TYPE(CreationDate,(Base::TimeInfo::currentDateTimeString()),0,App::Prop_ReadOnly,"Date of creation");
|
||||
ADD_PROPERTY_TYPE(LastModifiedBy,(""),0,App::Prop_None,0);
|
||||
ADD_PROPERTY_TYPE(LastModifiedDate,("Unknown"),0,App::Prop_ReadOnly,"Date of last modification");
|
||||
ADD_PROPERTY_TYPE(Company,(""),0,App::Prop_None,"Additional tag to save the the name of the company");
|
||||
ADD_PROPERTY_TYPE(Comment,(""),0,App::Prop_None,"Additional tag to save a comment");
|
||||
ADD_PROPERTY_TYPE(Meta,(),0,App::Prop_None,"Map with additional meta information");
|
||||
ADD_PROPERTY_TYPE(Material,(),0,App::Prop_None,"Map with material properties");
|
||||
// create the uuid for the document
|
||||
Base::Uuid id;
|
||||
ADD_PROPERTY_TYPE(Id,(""),0,App::Prop_None,"ID (Part-Number) of the Item");
|
||||
ADD_PROPERTY_TYPE(Uid,(id),0,App::Prop_None,"UUID of the Item");
|
||||
|
||||
// license stuff
|
||||
ADD_PROPERTY_TYPE(License,("CC BY 3.0"),0,App::Prop_None,"License string of the Item");
|
||||
ADD_PROPERTY_TYPE(LicenseURL,("http://creativecommons.org/licenses/by/3.0/"),0,App::Prop_None,"URL to the license text/contract");
|
||||
// color and apperance
|
||||
ADD_PROPERTY(Color,(1.0,1.0,1.0,1.0)); // set transparent -> not used
|
||||
ADD_PROPERTY(Visibility,(true));
|
||||
}
|
||||
|
||||
short Item::mustExecute() const
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
namespace Assembly
|
||||
{
|
||||
|
||||
/// Base class of all Assembly objects
|
||||
class AssemblyExport Item : public App::GeoFeature
|
||||
{
|
||||
PROPERTY_HEADER(Assembly::Item);
|
||||
|
@ -40,51 +41,6 @@ public:
|
|||
Item();
|
||||
~Item() {};
|
||||
|
||||
/** @name base properties of all Assembly Items
|
||||
* This properties corospond mostly to the meta information
|
||||
* in the App::Document class
|
||||
*/
|
||||
//@{
|
||||
/// Id e.g. Part number
|
||||
App::PropertyString Id;
|
||||
/// unique identifier of the Item
|
||||
App::PropertyUUID Uid;
|
||||
/// long description of the Item
|
||||
App::PropertyString Description ;
|
||||
/// creators name (utf-8)
|
||||
App::PropertyString CreatedBy;
|
||||
App::PropertyString CreationDate;
|
||||
/// user last modified the document
|
||||
App::PropertyString LastModifiedBy;
|
||||
App::PropertyString LastModifiedDate;
|
||||
/// company name UTF8(optional)
|
||||
App::PropertyString Company;
|
||||
/// long comment or description (UTF8 with line breaks)
|
||||
App::PropertyString Comment;
|
||||
/** License string
|
||||
* Holds the short license string for the Item, e.g. CC-BY
|
||||
* for the Creative Commons license suit.
|
||||
*/
|
||||
App::PropertyString License;
|
||||
/// License descripton/contract URL
|
||||
App::PropertyString LicenseURL;
|
||||
/// Meta descriptons
|
||||
App::PropertyMap Meta;
|
||||
/// Meta descriptons
|
||||
App::PropertyMap Material;
|
||||
//@}
|
||||
|
||||
/** @name Visual properties */
|
||||
//@{
|
||||
/** Base color of the Item
|
||||
If the transparency value is 1.0
|
||||
the color or the next hirachy is used
|
||||
*/
|
||||
App::PropertyColor Color;
|
||||
/// Visibility
|
||||
App::PropertyBool Visibility;
|
||||
//@}
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the feature
|
||||
|
@ -96,8 +52,6 @@ public:
|
|||
}
|
||||
//@}
|
||||
|
||||
virtual TopoDS_Shape getShape(void)const =0 ;
|
||||
|
||||
PyObject *getPyObject(void);
|
||||
|
||||
};
|
||||
|
|
|
@ -52,7 +52,7 @@ struct AssemblyItemException : std::exception {
|
|||
};
|
||||
|
||||
|
||||
PROPERTY_SOURCE(Assembly::PartRef, Assembly::Item)
|
||||
PROPERTY_SOURCE(Assembly::PartRef, App::GeoFeature)
|
||||
|
||||
PartRef::PartRef() {
|
||||
ADD_PROPERTY(Model, (0));
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
#define Assembly_ItemPart_H
|
||||
|
||||
#include <App/PropertyLinks.h>
|
||||
#include "Item.h"
|
||||
#include <App/GeoFeature.h>
|
||||
|
||||
#include "Solver/Solver.h"
|
||||
|
||||
|
||||
|
@ -34,15 +35,15 @@ namespace Assembly
|
|||
|
||||
class Product;
|
||||
|
||||
class AssemblyExport PartRef : public Assembly::Item
|
||||
class AssemblyExport PartRef : public App::GeoFeature
|
||||
{
|
||||
PROPERTY_HEADER(Assembly::PartRef);
|
||||
|
||||
public:
|
||||
PartRef();
|
||||
|
||||
App::PropertyLink Model;
|
||||
App::PropertyLinkList Annotation;
|
||||
App::PropertyLink Item;
|
||||
//App::PropertyLinkList Annotation;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
|
@ -56,7 +57,7 @@ public:
|
|||
PyObject *getPyObject(void);
|
||||
//@}
|
||||
|
||||
virtual TopoDS_Shape getShape(void) const;
|
||||
//virtual TopoDS_Shape getShape(void) const;
|
||||
|
||||
bool holdsObject(App::DocumentObject* obj) const;
|
||||
Product* getParentAssembly();
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include <Base/Exception.h>
|
||||
|
||||
#include "Product.h"
|
||||
#include "PartRef.h"
|
||||
#include "ConstraintGroup.h"
|
||||
|
||||
|
||||
|
@ -46,23 +45,26 @@ PROPERTY_SOURCE(Assembly::Product, Assembly::Item)
|
|||
|
||||
Product::Product() {
|
||||
ADD_PROPERTY(Items,(0));
|
||||
ADD_PROPERTY(Annotations,(0));
|
||||
ADD_PROPERTY(Rigid,(true));
|
||||
#ifdef ASSEMBLY_DEBUG_FACILITIES
|
||||
ADD_PROPERTY(ApplyAtFailure,(false));
|
||||
ADD_PROPERTY(Precision,(1e-6));
|
||||
ADD_PROPERTY(SaveState,(false));
|
||||
ADD_PROPERTY(Iterations,(5e3));
|
||||
ADD_PROPERTY(LogLevel, (long(1)));
|
||||
ADD_PROPERTY_TYPE(CreatedBy,(""),0,App::Prop_None,"The creator of the Item");
|
||||
ADD_PROPERTY_TYPE(CreationDate,(Base::TimeInfo::currentDateTimeString()),0,App::Prop_ReadOnly,"Date of creation");
|
||||
ADD_PROPERTY_TYPE(LastModifiedBy,(""),0,App::Prop_None,0);
|
||||
ADD_PROPERTY_TYPE(LastModifiedDate,("Unknown"),0,App::Prop_ReadOnly,"Date of last modification");
|
||||
ADD_PROPERTY_TYPE(Company,(""),0,App::Prop_None,"Additional tag to save the the name of the company");
|
||||
ADD_PROPERTY_TYPE(Comment,(""),0,App::Prop_None,"Additional tag to save a comment");
|
||||
ADD_PROPERTY_TYPE(Meta,(),0,App::Prop_None,"Map with additional meta information");
|
||||
ADD_PROPERTY_TYPE(Material,(),0,App::Prop_None,"Map with material properties");
|
||||
// create the uuid for the document
|
||||
Base::Uuid id;
|
||||
ADD_PROPERTY_TYPE(Id,(""),0,App::Prop_None,"ID (Part-Number) of the Item");
|
||||
ADD_PROPERTY_TYPE(Uid,(id),0,App::Prop_None,"UUID of the Item");
|
||||
|
||||
// license stuff
|
||||
ADD_PROPERTY_TYPE(License,("CC BY 3.0"),0,App::Prop_None,"License string of the Item");
|
||||
ADD_PROPERTY_TYPE(LicenseURL,("http://creativecommons.org/licenses/by/3.0/"),0,App::Prop_None,"URL to the license text/contract");
|
||||
// color and apperance
|
||||
ADD_PROPERTY(Color,(1.0,1.0,1.0,1.0)); // set transparent -> not used
|
||||
ADD_PROPERTY(Visibility,(true));
|
||||
|
||||
std::vector<std::string> vec;
|
||||
vec.push_back("iteration");
|
||||
vec.push_back("solving");
|
||||
vec.push_back("manipulation");
|
||||
vec.push_back("information");
|
||||
vec.push_back("error");
|
||||
LogLevel.setEnumVector(vec);
|
||||
#endif
|
||||
}
|
||||
|
||||
short Product::mustExecute() const {
|
||||
|
@ -73,108 +75,9 @@ App::DocumentObjectExecReturn* Product::execute(void) {
|
|||
|
||||
Base::Console().Message("Execute\n");
|
||||
|
||||
try {
|
||||
|
||||
//create a solver and init all child assemblys with subsolvers
|
||||
m_solver = boost::shared_ptr<Solver>(new Solver);
|
||||
m_downstream_placement = Base::Placement(Base::Vector3<double>(0,0,0), Base::Rotation());
|
||||
Base::Placement dummy;
|
||||
initSolver(boost::shared_ptr<Solver>(), dummy, false);
|
||||
initConstraints(boost::shared_ptr<Solver>());
|
||||
|
||||
#ifdef ASSEMBLY_DEBUG_FACILITIES
|
||||
|
||||
if(ApplyAtFailure.getValue())
|
||||
m_solver->setOption<dcm::solverfailure>(dcm::ApplyResults);
|
||||
else
|
||||
m_solver->setOption<dcm::solverfailure>(dcm::IgnoreResults);
|
||||
|
||||
m_solver->setOption<dcm::precision>(Precision.getValue());
|
||||
m_solver->setOption<dcm::iterations>(Iterations.getValue());
|
||||
|
||||
if(SaveState.getValue()) {
|
||||
|
||||
ofstream myfile;
|
||||
myfile.open("solverstate.txt");
|
||||
m_solver->saveState(myfile);
|
||||
myfile.close();
|
||||
};
|
||||
|
||||
m_solver->setLoggingFilter(dcm::severity >= (dcm::severity_level)LogLevel.getValue());
|
||||
|
||||
#endif
|
||||
|
||||
//solve the system
|
||||
m_solver->solve();
|
||||
}
|
||||
catch
|
||||
(boost::exception& e) {
|
||||
message.clear();
|
||||
message << "Solver exception " << *boost::get_error_info<boost::errinfo_errno>(e)
|
||||
<< "raised: " << boost::get_error_info<dcm::error_message>(e)->c_str() << std::endl;
|
||||
//throw Base::Exception(message.str().c_str());
|
||||
Base::Console().Error(message.str().c_str());
|
||||
}
|
||||
catch
|
||||
(std::exception& e) {
|
||||
message.clear();
|
||||
message << "Exception raised in assembly solver: " << e.what() << std::endl;
|
||||
//throw Base::Exception(message.str().c_str());
|
||||
Base::Console().Error(message.str().c_str());
|
||||
}
|
||||
catch(Standard_ConstructionError& e) {
|
||||
message.clear();
|
||||
message << "Construction Error raised in assembly solver during execution: ";
|
||||
message << e.GetMessageString()<< std::endl;
|
||||
Base::Console().Error(message.str().c_str());
|
||||
}
|
||||
catch
|
||||
(...) {
|
||||
message.clear();
|
||||
message << "Unknown Exception raised in assembly solver during execution" << std::endl;
|
||||
//throw Base::Exception(message.str().c_str());
|
||||
Base::Console().Error(message.str().c_str());
|
||||
};
|
||||
|
||||
this->touch();
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
TopoDS_Shape Product::getShape(void) const {
|
||||
std::vector<TopoDS_Shape> s;
|
||||
std::vector<App::DocumentObject*> obj = Items.getValues();
|
||||
|
||||
std::vector<App::DocumentObject*>::iterator it;
|
||||
|
||||
for(it = obj.begin(); it != obj.end(); ++it) {
|
||||
if((*it)->getTypeId().isDerivedFrom(Assembly::Item::getClassTypeId())) {
|
||||
TopoDS_Shape aShape = static_cast<Assembly::Item*>(*it)->getShape();
|
||||
|
||||
if(!aShape.IsNull())
|
||||
s.push_back(aShape);
|
||||
}
|
||||
}
|
||||
|
||||
if(s.size() > 0) {
|
||||
TopoDS_Compound aRes = TopoDS_Compound();
|
||||
BRep_Builder aBuilder = BRep_Builder();
|
||||
aBuilder.MakeCompound(aRes);
|
||||
|
||||
for(std::vector<TopoDS_Shape>::iterator it = s.begin(); it != s.end(); ++it) {
|
||||
|
||||
aBuilder.Add(aRes, *it);
|
||||
}
|
||||
|
||||
//if (aRes.IsNull())
|
||||
// throw Base::Exception("Resulting shape is invalid");
|
||||
return aRes;
|
||||
}
|
||||
|
||||
// set empty shape
|
||||
return TopoDS_Compound();
|
||||
|
||||
}
|
||||
|
||||
//PyObject* Product::getPyObject(void) {
|
||||
// if(PythonObject.is(Py::_None())) {
|
||||
|
@ -185,159 +88,7 @@ TopoDS_Shape Product::getShape(void) const {
|
|||
// return Py::new_reference_to(PythonObject);
|
||||
//}
|
||||
|
||||
bool Product::isParentAssembly(PartRef* part) {
|
||||
|
||||
typedef std::vector<App::DocumentObject*>::const_iterator iter;
|
||||
|
||||
const std::vector<App::DocumentObject*>& vector = Items.getValues();
|
||||
|
||||
for(iter it=vector.begin(); it != vector.end(); it++) {
|
||||
|
||||
if((*it)->getTypeId() == Assembly::PartRef::getClassTypeId())
|
||||
if(*it == part)
|
||||
return true;
|
||||
};
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Product* Product::getToplevelAssembly() {
|
||||
|
||||
typedef std::vector<App::DocumentObject*>::const_iterator iter;
|
||||
|
||||
const std::vector<App::DocumentObject*>& vector = getInList();
|
||||
|
||||
for(iter it=vector.begin(); it != vector.end(); it++) {
|
||||
|
||||
if((*it)->getTypeId() == Assembly::Product::getClassTypeId())
|
||||
return static_cast<Assembly::Product*>(*it)->getToplevelAssembly();
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
Product* Product::getParentAssembly(PartRef* part) {
|
||||
|
||||
typedef std::vector<App::DocumentObject*>::const_iterator iter;
|
||||
|
||||
const std::vector<App::DocumentObject*>& vector = Items.getValues();
|
||||
|
||||
for(iter it=vector.begin(); it != vector.end(); it++) {
|
||||
|
||||
if((*it)->getTypeId() == Assembly::PartRef::getClassTypeId()) {
|
||||
if(*it == part)
|
||||
return this;
|
||||
}
|
||||
else if((*it)->getTypeId() == Assembly::Product::getClassTypeId()) {
|
||||
|
||||
Assembly::Product* assembly = static_cast<Assembly::Product*>(*it)->getParentAssembly(part);
|
||||
|
||||
if(assembly)
|
||||
return assembly;
|
||||
}
|
||||
};
|
||||
|
||||
return (Product*)NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::pair<PartRef*, Product*> Product::getContainingPart(App::DocumentObject* obj, bool isTop) {
|
||||
|
||||
typedef std::vector<App::DocumentObject*>::const_iterator iter;
|
||||
|
||||
const std::vector<App::DocumentObject*>& vector = Items.getValues();
|
||||
|
||||
for(iter it=vector.begin(); it != vector.end(); it++) {
|
||||
|
||||
if((*it)->getTypeId() == Assembly::PartRef::getClassTypeId()) {
|
||||
if(static_cast<Assembly::PartRef*>(*it)->holdsObject(obj))
|
||||
return std::make_pair(static_cast<Assembly::PartRef*>(*it), this);
|
||||
}
|
||||
else if((*it)->getTypeId() == Assembly::Product::getClassTypeId()) {
|
||||
|
||||
std::pair<PartRef*, Product*> part = static_cast<Assembly::Product*>(*it)->getContainingPart(obj, false);
|
||||
|
||||
if(part.first && part.second) {
|
||||
|
||||
if(isTop)
|
||||
return part;
|
||||
else
|
||||
return std::make_pair(part.first, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return std::pair<PartRef*, Product*>(NULL, NULL);
|
||||
}
|
||||
|
||||
void Product::initSolver(boost::shared_ptr<Solver> parent, Base::Placement& PL_downstream, bool stopped) {
|
||||
|
||||
if(parent) {
|
||||
if(Rigid.getValue() || stopped) {
|
||||
m_solver = parent->createSubsystem();
|
||||
m_solver->setTransformation(PL_downstream*this->Placement.getValue());
|
||||
stopped = true; //all below belongs to this rigid group
|
||||
|
||||
//connect the recalculated signal in case we need to update the placement
|
||||
m_solver->connectSignal<dcm::recalculated>(boost::bind(&Product::finish, this, _1));
|
||||
}
|
||||
else {
|
||||
m_solver = parent;
|
||||
PL_downstream *= this->Placement.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
//we always need to store the downstream placement as we may be a subassembly in a
|
||||
//non-rigid subassembly
|
||||
m_downstream_placement = PL_downstream;
|
||||
|
||||
typedef std::vector<App::DocumentObject*>::const_iterator iter;
|
||||
const std::vector<App::DocumentObject*>& vector = Items.getValues();
|
||||
|
||||
for(iter it=vector.begin(); it != vector.end(); it++) {
|
||||
|
||||
if((*it)->getTypeId() == Assembly::Product::getClassTypeId()) {
|
||||
|
||||
static_cast<Assembly::Product*>(*it)->initSolver(m_solver, PL_downstream, stopped);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void Product::initConstraints(boost::shared_ptr<Solver> parent) {
|
||||
|
||||
|
||||
|
||||
//get the constraint group and init the constraints
|
||||
typedef std::vector<App::DocumentObject*>::const_iterator iter;
|
||||
|
||||
const std::vector<App::DocumentObject*>& vector = Annotations.getValues();
|
||||
|
||||
for(iter it=vector.begin(); it != vector.end(); it++) {
|
||||
|
||||
if((*it)->getTypeId() == Assembly::ConstraintGroup::getClassTypeId())
|
||||
static_cast<ConstraintGroup*>(*it)->init(this);
|
||||
};
|
||||
|
||||
// iterate down as long as a non-rigid subsystem exists
|
||||
const std::vector<App::DocumentObject*>& vector2 = Items.getValues();
|
||||
|
||||
for(iter it=vector2.begin(); it != vector2.end(); it++) {
|
||||
|
||||
if((*it)->getTypeId() == Assembly::Product::getClassTypeId())
|
||||
static_cast<Assembly::Product*>(*it)->initConstraints(m_solver);
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
//the callback for the recalculated signal
|
||||
void Product::finish(boost::shared_ptr<Solver> subsystem) {
|
||||
|
||||
//assert(subsystem == m_solver);
|
||||
Base::Placement p = m_solver->getTransformation<Base::Placement>();
|
||||
this->Placement.setValue(m_downstream_placement.inverse()*p);
|
||||
};
|
||||
|
||||
} //assembly
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
namespace Assembly
|
||||
{
|
||||
|
||||
class PartRef;
|
||||
|
||||
class AssemblyExport Product : public Assembly::Item
|
||||
{
|
||||
|
@ -41,9 +40,54 @@ class AssemblyExport Product : public Assembly::Item
|
|||
public:
|
||||
Product();
|
||||
|
||||
/// Items of the Product
|
||||
App::PropertyLinkList Items;
|
||||
App::PropertyLinkList Annotations;
|
||||
App::PropertyBool Rigid;
|
||||
|
||||
/** @name base properties of all Assembly Items
|
||||
* This properties corospond mostly to the meta information
|
||||
* in the App::Document class
|
||||
*/
|
||||
//@{
|
||||
/// Id e.g. Part number
|
||||
App::PropertyString Id;
|
||||
/// unique identifier of the Item
|
||||
App::PropertyUUID Uid;
|
||||
/// long description of the Item
|
||||
App::PropertyString Description ;
|
||||
/// creators name (utf-8)
|
||||
App::PropertyString CreatedBy;
|
||||
App::PropertyString CreationDate;
|
||||
/// user last modified the document
|
||||
App::PropertyString LastModifiedBy;
|
||||
App::PropertyString LastModifiedDate;
|
||||
/// company name UTF8(optional)
|
||||
App::PropertyString Company;
|
||||
/// long comment or description (UTF8 with line breaks)
|
||||
App::PropertyString Comment;
|
||||
/** License string
|
||||
* Holds the short license string for the Item, e.g. CC-BY
|
||||
* for the Creative Commons license suit.
|
||||
*/
|
||||
App::PropertyString License;
|
||||
/// License descripton/contract URL
|
||||
App::PropertyString LicenseURL;
|
||||
/// Meta descriptons
|
||||
App::PropertyMap Meta;
|
||||
/// Meta descriptons
|
||||
App::PropertyMap Material;
|
||||
//@}
|
||||
|
||||
/** @name Visual properties */
|
||||
//@{
|
||||
/** Base color of the Item
|
||||
If the transparency value is 1.0
|
||||
the color or the next hirachy is used
|
||||
*/
|
||||
App::PropertyColor Color;
|
||||
/// Visibility
|
||||
App::PropertyBool Visibility;
|
||||
//@}
|
||||
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
|
@ -57,43 +101,6 @@ public:
|
|||
//PyObject *getPyObject(void);
|
||||
//@}
|
||||
|
||||
virtual TopoDS_Shape getShape(void) const;
|
||||
|
||||
bool isParentAssembly(PartRef* part);
|
||||
Product* getToplevelAssembly();
|
||||
Product* getParentAssembly(PartRef* part);
|
||||
|
||||
//returns the PartRef which holds the given document object and the Product, which holds
|
||||
//the this part and is a direct children of this Product. The returned Product is therefore
|
||||
//the "TopLevel" Assembly holding the part of all children of this assembly. If this assembly holds
|
||||
//the children directly, without any subassembly, the returned Product is this.
|
||||
std::pair< PartRef*, Product* > getContainingPart(App::DocumentObject* obj, bool isTop=true);
|
||||
|
||||
//create a new solver for this assembly and initalise all downstream itemassemblys either with a
|
||||
//subsystem (if they are rigid) or with this solver plus the downstream placement
|
||||
void initSolver(boost::shared_ptr<Solver> parent, Base::Placement& pl_downstream, bool stopped);
|
||||
|
||||
//initialise the oen constraint group and go downstream as long as non-rigid itemassemblys exist,
|
||||
//which need to be initialised too
|
||||
void initConstraints(boost::shared_ptr<Solver> parent);
|
||||
|
||||
//read the downstream itemassemblys and set their placement to the propertyplacement
|
||||
void finish(boost::shared_ptr<Solver> subsystem);
|
||||
|
||||
boost::shared_ptr<Solver> m_solver;
|
||||
Base::Placement m_downstream_placement;
|
||||
|
||||
|
||||
#ifdef ASSEMBLY_DEBUG_FACILITIES
|
||||
App::PropertyBool ApplyAtFailure;
|
||||
App::PropertyFloat Precision;
|
||||
App::PropertyBool SaveState;
|
||||
App::PropertyInteger Iterations;
|
||||
App::PropertyEnumeration LogLevel;
|
||||
#endif
|
||||
|
||||
private:
|
||||
std::stringstream message;
|
||||
};
|
||||
|
||||
} //namespace Assembly
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include <App/Part.h>
|
||||
|
||||
#include "ProductRef.h"
|
||||
#include "PartRef.h"
|
||||
#include "ConstraintGroup.h"
|
||||
#include "ProductRefPy.h"
|
||||
|
||||
|
@ -42,13 +41,10 @@ using namespace Assembly;
|
|||
namespace Assembly {
|
||||
|
||||
|
||||
PROPERTY_SOURCE(Assembly::ProductRef, Assembly::Item)
|
||||
PROPERTY_SOURCE(Assembly::ProductRef, Assembly::Item)
|
||||
|
||||
ProductRef::ProductRef() {
|
||||
ADD_PROPERTY(Items,(0));
|
||||
ADD_PROPERTY(Annotations,(0));
|
||||
ADD_PROPERTY(Rigid,(true));
|
||||
|
||||
ADD_PROPERTY(Item,(0));
|
||||
}
|
||||
|
||||
short ProductRef::mustExecute() const {
|
||||
|
|
|
@ -27,13 +27,12 @@
|
|||
#include <App/PropertyStandard.h>
|
||||
|
||||
#include "Item.h"
|
||||
#include "PartRef.h"
|
||||
#include "Solver/Solver.h"
|
||||
|
||||
namespace Assembly
|
||||
{
|
||||
|
||||
class ItemPart;
|
||||
|
||||
|
||||
class AssemblyExport ProductRef : public Assembly::Item
|
||||
{
|
||||
|
@ -42,9 +41,8 @@ class AssemblyExport ProductRef : public Assembly::Item
|
|||
public:
|
||||
ProductRef();
|
||||
|
||||
App::PropertyLinkList Items;
|
||||
App::PropertyLinkList Annotations;
|
||||
App::PropertyBool Rigid;
|
||||
/// The one and only GeomtricObject referenced
|
||||
App::PropertyLink Item;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
|
@ -58,11 +56,6 @@ public:
|
|||
PyObject *getPyObject(void);
|
||||
//@}
|
||||
|
||||
virtual TopoDS_Shape getShape(void) const {return TopoDS_Shape();}
|
||||
|
||||
std::pair< PartRef*, Product* > getContainingPart(App::DocumentObject* obj, bool isTop=true){ return std::pair<PartRef*, Product*>(NULL, NULL);}
|
||||
|
||||
|
||||
};
|
||||
|
||||
} //namespace Assembly
|
||||
|
|
|
@ -3,10 +3,9 @@
|
|||
|
||||
#include "Mod/Assembly/App/ProductRef.h"
|
||||
|
||||
// inclusion of the generated files (generated out of ProductPy.xml)
|
||||
// inclusion of the generated files (generated out of ProductRefPy.xml)
|
||||
#include "ProductRefPy.h"
|
||||
#include "ProductRefPy.cpp"
|
||||
#include <PartRefPy.h>
|
||||
|
||||
using namespace Assembly;
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "Workbench.h"
|
||||
|
||||
#include "ViewProvider.h"
|
||||
#include "ViewProviderPartRef.h"
|
||||
#include "ViewProviderProduct.h"
|
||||
#include "ViewProviderProductRef.h"
|
||||
#include "ViewProviderConstraintGroup.h"
|
||||
|
@ -83,7 +82,6 @@ void AssemblyGuiExport initAssemblyGui()
|
|||
AssemblyGui::Workbench::init();
|
||||
|
||||
AssemblyGui::ViewProviderItem ::init();
|
||||
AssemblyGui::ViewProviderPartRef ::init();
|
||||
AssemblyGui::ViewProviderProduct ::init();
|
||||
AssemblyGui::ViewProviderProductRef ::init();
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ set(AssemblyGui_LIBS
|
|||
)
|
||||
|
||||
set(AssemblyGui_MOC_HDRS
|
||||
TaskAssemblyConstraints.h
|
||||
TaskDlgAssemblyConstraints.h
|
||||
#TaskAssemblyConstraints.h
|
||||
#TaskDlgAssemblyConstraints.h
|
||||
)
|
||||
fc_wrap_cpp(AssemblyGui_MOC_SRCS ${AssemblyGui_MOC_HDRS})
|
||||
SOURCE_GROUP("Moc" FILES ${AssemblyGui_MOC_SRCS})
|
||||
|
@ -38,15 +38,15 @@ SOURCE_GROUP("Moc" FILES ${AssemblyGui_MOC_SRCS})
|
|||
qt4_add_resources(AssemblyGui_SRCS Resources/Assembly.qrc)
|
||||
|
||||
set(AssemblyGui_UIC_SRCS
|
||||
TaskAssemblyConstraints.ui
|
||||
#TaskAssemblyConstraints.ui
|
||||
)
|
||||
qt4_wrap_ui(AssemblyGui_UIC_HDRS ${AssemblyGui_UIC_SRCS})
|
||||
|
||||
SET(AssemblyGuiViewProvider_SRCS
|
||||
ViewProvider.cpp
|
||||
ViewProvider.h
|
||||
ViewProviderPartRef.cpp
|
||||
ViewProviderPartRef.h
|
||||
#ViewProviderPartRef.cpp
|
||||
#ViewProviderPartRef.h
|
||||
ViewProviderProduct.cpp
|
||||
ViewProviderProduct.h
|
||||
ViewProviderProductRef.cpp
|
||||
|
@ -55,10 +55,10 @@ SET(AssemblyGuiViewProvider_SRCS
|
|||
ViewProviderConstraint.h
|
||||
ViewProviderConstraintGroup.cpp
|
||||
ViewProviderConstraintGroup.h
|
||||
TaskDlgAssemblyConstraints.cpp
|
||||
TaskDlgAssemblyConstraints.h
|
||||
TaskAssemblyConstraints.h
|
||||
TaskAssemblyConstraints.cpp
|
||||
#TaskDlgAssemblyConstraints.cpp
|
||||
#TaskDlgAssemblyConstraints.h
|
||||
#TaskAssemblyConstraints.h
|
||||
#TaskAssemblyConstraints.cpp
|
||||
)
|
||||
SOURCE_GROUP("ViewProvider" FILES ${AssemblyGuiViewProvider_SRCS})
|
||||
|
||||
|
|
|
@ -38,9 +38,8 @@
|
|||
|
||||
#include <Mod/Assembly/App/Product.h>
|
||||
#include <Mod/Assembly/App/ProductRef.h>
|
||||
#include <Mod/Assembly/App/PartRef.h>
|
||||
#include <Mod/Assembly/App/ConstraintGroup.h>
|
||||
#include <Mod/Assembly/Gui/TaskDlgAssemblyConstraints.h>
|
||||
//#include <Mod/Assembly/Gui/TaskDlgAssemblyConstraints.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
@ -49,11 +48,11 @@ extern Assembly::Item* ActiveAsmObject;
|
|||
|
||||
// Helper methods ===========================================================
|
||||
|
||||
Assembly::ConstraintGroup* getConstraintGroup(Assembly::ProductRef* Asm)
|
||||
Assembly::ConstraintGroup* getConstraintGroup(Assembly::Product* Asm)
|
||||
{
|
||||
Assembly::ConstraintGroup* ConstGrp = 0;
|
||||
|
||||
std::vector<App::DocumentObject*> Ano = Asm->Annotations.getValues();
|
||||
std::vector<App::DocumentObject*> Ano = Asm->Items.getValues();
|
||||
|
||||
for(std::vector<App::DocumentObject*>::const_iterator it = Ano.begin(); it != Ano.end(); ++it) {
|
||||
if((*it)->getTypeId().isDerivedFrom(Assembly::ConstraintGroup::getClassTypeId())) {
|
||||
|
@ -65,7 +64,7 @@ Assembly::ConstraintGroup* getConstraintGroup(Assembly::ProductRef* Asm)
|
|||
return ConstGrp;
|
||||
}
|
||||
|
||||
bool getConstraintPrerequisits(Assembly::ProductRef** Asm, Assembly::ConstraintGroup** ConstGrp)
|
||||
bool getConstraintPrerequisits(Assembly::Product** Asm, Assembly::ConstraintGroup** ConstGrp)
|
||||
{
|
||||
if(!ActiveAsmObject || !ActiveAsmObject->getTypeId().isDerivedFrom(Assembly::ProductRef::getClassTypeId())) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No active Assembly"),
|
||||
|
@ -73,7 +72,7 @@ bool getConstraintPrerequisits(Assembly::ProductRef** Asm, Assembly::ConstraintG
|
|||
return true;
|
||||
}
|
||||
|
||||
*Asm = static_cast<Assembly::ProductRef*>(ActiveAsmObject);
|
||||
*Asm = static_cast<Assembly::Product*>(ActiveAsmObject);
|
||||
|
||||
// find the Constraint group of the active Assembly
|
||||
*ConstGrp = getConstraintGroup(*Asm);
|
||||
|
@ -97,7 +96,7 @@ bool getConstraintPrerequisits(Assembly::ProductRef** Asm, Assembly::ConstraintG
|
|||
|
||||
}
|
||||
|
||||
std::string asSubLinkString(Assembly::PartRef* part, std::string element)
|
||||
std::string asSubLinkString(Assembly::ProductRef* part, std::string element)
|
||||
{
|
||||
std::string buf;
|
||||
buf += "(App.ActiveDocument.";
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QMessageBox>
|
||||
# include <QRegExp>
|
||||
# include <QString>
|
||||
#endif
|
||||
|
@ -32,7 +33,6 @@
|
|||
#include "TaskAssemblyConstraints.h"
|
||||
|
||||
#include <Constraint.h>
|
||||
#include <PartRef.h>
|
||||
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/Console.h>
|
||||
|
@ -82,10 +82,10 @@ TaskAssemblyConstraints::TaskAssemblyConstraints(ViewProviderConstraint* vp)
|
|||
ass = dynamic_cast<Assembly::PartRef*>(obj->Second.getValue())->getParentAssembly();
|
||||
};
|
||||
|
||||
if(ass)
|
||||
ass->getToplevelAssembly()->execute();
|
||||
else
|
||||
return;
|
||||
//if(ass)
|
||||
// ass->getToplevelAssembly()->execute();
|
||||
//else
|
||||
// return;
|
||||
|
||||
//get the individual constraint settings
|
||||
ui->value->setValue(obj->Value.getValue());
|
||||
|
@ -242,55 +242,55 @@ TaskAssemblyConstraints::~TaskAssemblyConstraints()
|
|||
|
||||
void TaskAssemblyConstraints::onSelectionChanged(const Gui::SelectionChanges& msg)
|
||||
{
|
||||
if(msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
//if(msg.Type == Gui::SelectionChanges::AddSelection) {
|
||||
|
||||
//add it as the first geometry?
|
||||
if(ui->first_geom->text().isEmpty()) {
|
||||
std::vector<Gui::SelectionObject> objs = Gui::Selection().getSelectionEx();
|
||||
Assembly::Constraint* con = dynamic_cast<Assembly::Constraint*>(view->getObject());
|
||||
// //add it as the first geometry?
|
||||
// if(ui->first_geom->text().isEmpty()) {
|
||||
// std::vector<Gui::SelectionObject> objs = Gui::Selection().getSelectionEx();
|
||||
// Assembly::Constraint* con = dynamic_cast<Assembly::Constraint*>(view->getObject());
|
||||
|
||||
if(!ActiveAsmObject || !ActiveAsmObject->getTypeId().isDerivedFrom(Assembly::Product::getClassTypeId())) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No active Assembly"),
|
||||
QObject::tr("You need a active (blue) Assembly to insert a Constraint. Please create a new one or make one active (double click)."));
|
||||
return;
|
||||
}
|
||||
// if(!ActiveAsmObject || !ActiveAsmObject->getTypeId().isDerivedFrom(Assembly::Product::getClassTypeId())) {
|
||||
// QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No active Assembly"),
|
||||
// QObject::tr("You need a active (blue) Assembly to insert a Constraint. Please create a new one or make one active (double click)."));
|
||||
// return;
|
||||
// }
|
||||
|
||||
std::pair<Assembly::PartRef*, Assembly::Product*> part1 = static_cast<Assembly::Product*>(ActiveAsmObject)->getContainingPart(objs.back().getObject());
|
||||
con->First.setValue(part1.first, objs.back().getSubNames());
|
||||
QString str;
|
||||
str = QString::fromAscii(part1.first->getNameInDocument()) + QString::fromAscii(".") + QString::fromStdString(con->First.getSubValues().front());
|
||||
ui->first_geom->setText(str);
|
||||
// std::pair<Assembly::PartRef*, Assembly::Product*> part1 = static_cast<Assembly::Product*>(ActiveAsmObject)->getContainingPart(objs.back().getObject());
|
||||
// con->First.setValue(part1.first, objs.back().getSubNames());
|
||||
// QString str;
|
||||
// str = QString::fromAscii(part1.first->getNameInDocument()) + QString::fromAscii(".") + QString::fromStdString(con->First.getSubValues().front());
|
||||
// ui->first_geom->setText(str);
|
||||
|
||||
App::GetApplication().getActiveDocument()->recompute();
|
||||
setPossibleConstraints();
|
||||
setPossibleOptions();
|
||||
view->draw();
|
||||
return;
|
||||
}
|
||||
// App::GetApplication().getActiveDocument()->recompute();
|
||||
// setPossibleConstraints();
|
||||
// setPossibleOptions();
|
||||
// view->draw();
|
||||
// return;
|
||||
// }
|
||||
|
||||
if(ui->second_geom->text().isEmpty()) {
|
||||
std::vector<Gui::SelectionObject> objs = Gui::Selection().getSelectionEx();
|
||||
Assembly::Constraint* con = dynamic_cast<Assembly::Constraint*>(view->getObject());
|
||||
// if(ui->second_geom->text().isEmpty()) {
|
||||
// std::vector<Gui::SelectionObject> objs = Gui::Selection().getSelectionEx();
|
||||
// Assembly::Constraint* con = dynamic_cast<Assembly::Constraint*>(view->getObject());
|
||||
|
||||
if(!ActiveAsmObject || !ActiveAsmObject->getTypeId().isDerivedFrom(Assembly::Product::getClassTypeId())) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No active Assembly"),
|
||||
QObject::tr("You need a active (blue) Assembly to insert a Constraint. Please create a new one or make one active (double click)."));
|
||||
return;
|
||||
}
|
||||
// if(!ActiveAsmObject || !ActiveAsmObject->getTypeId().isDerivedFrom(Assembly::Product::getClassTypeId())) {
|
||||
// QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No active Assembly"),
|
||||
// QObject::tr("You need a active (blue) Assembly to insert a Constraint. Please create a new one or make one active (double click)."));
|
||||
// return;
|
||||
// }
|
||||
|
||||
std::pair<Assembly::PartRef*, Assembly::Product*> part2 = static_cast<Assembly::Product*>(ActiveAsmObject)->getContainingPart(objs.back().getObject());
|
||||
con->Second.setValue(part2.first, objs.back().getSubNames());
|
||||
QString str;
|
||||
str = QString::fromAscii(part2.first->getNameInDocument()) + QString::fromAscii(".") + QString::fromStdString(con->Second.getSubValues().front());
|
||||
ui->second_geom->setText(str);
|
||||
// std::pair<Assembly::PartRef*, Assembly::Product*> part2 = static_cast<Assembly::Product*>(ActiveAsmObject)->getContainingPart(objs.back().getObject());
|
||||
// con->Second.setValue(part2.first, objs.back().getSubNames());
|
||||
// QString str;
|
||||
// str = QString::fromAscii(part2.first->getNameInDocument()) + QString::fromAscii(".") + QString::fromStdString(con->Second.getSubValues().front());
|
||||
// ui->second_geom->setText(str);
|
||||
|
||||
App::GetApplication().getActiveDocument()->recompute();
|
||||
setPossibleConstraints();
|
||||
setPossibleOptions();
|
||||
view->draw();
|
||||
return;
|
||||
}
|
||||
}
|
||||
// App::GetApplication().getActiveDocument()->recompute();
|
||||
// setPossibleConstraints();
|
||||
// setPossibleOptions();
|
||||
// view->draw();
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
void TaskAssemblyConstraints::on_constraint_selection(bool clicked)
|
||||
|
@ -379,242 +379,242 @@ void TaskAssemblyConstraints::on_clear_second()
|
|||
|
||||
void TaskAssemblyConstraints::setPossibleOptions() {
|
||||
|
||||
//disable all orientations for later easy disabling
|
||||
ui->parallel->setEnabled(false);
|
||||
ui->equal->setEnabled(false);
|
||||
ui->opposite->setEnabled(false);
|
||||
ui->perpendicular->setEnabled(false);
|
||||
////disable all orientations for later easy disabling
|
||||
//ui->parallel->setEnabled(false);
|
||||
//ui->equal->setEnabled(false);
|
||||
//ui->opposite->setEnabled(false);
|
||||
//ui->perpendicular->setEnabled(false);
|
||||
|
||||
//disable solution spaces for later easy enabling
|
||||
ui->bidirectional->setEnabled(false);
|
||||
ui->pos_direction->setEnabled(false);
|
||||
ui->neg_direction->setEnabled(false);
|
||||
////disable solution spaces for later easy enabling
|
||||
//ui->bidirectional->setEnabled(false);
|
||||
//ui->pos_direction->setEnabled(false);
|
||||
//ui->neg_direction->setEnabled(false);
|
||||
|
||||
//this only works if both objects are set
|
||||
Assembly::Constraint* obj = dynamic_cast<Assembly::Constraint*>(view->getObject());
|
||||
////this only works if both objects are set
|
||||
//Assembly::Constraint* obj = dynamic_cast<Assembly::Constraint*>(view->getObject());
|
||||
|
||||
if(obj->First.getValue()) {
|
||||
//if(obj->First.getValue()) {
|
||||
|
||||
Assembly::PartRef* p1 = dynamic_cast<Assembly::PartRef*>(obj->First.getValue());
|
||||
// Assembly::PartRef* p1 = dynamic_cast<Assembly::PartRef*>(obj->First.getValue());
|
||||
|
||||
if(!p1)
|
||||
return;
|
||||
// if(!p1)
|
||||
// return;
|
||||
|
||||
Assembly::Product* ass = p1->getParentAssembly();
|
||||
// Assembly::Product* ass = p1->getParentAssembly();
|
||||
|
||||
//extract the geometries to use for comparison
|
||||
boost::shared_ptr<Geometry3D> g1 = ass->m_solver->getGeometry3D(obj->First.getSubValues()[0].c_str());
|
||||
// //extract the geometries to use for comparison
|
||||
// boost::shared_ptr<Geometry3D> g1 = ass->m_solver->getGeometry3D(obj->First.getSubValues()[0].c_str());
|
||||
|
||||
if(!g1)
|
||||
return;
|
||||
// if(!g1)
|
||||
// return;
|
||||
|
||||
if(obj->Second.getValue()) {
|
||||
// if(obj->Second.getValue()) {
|
||||
|
||||
Assembly::PartRef* p2 = dynamic_cast<Assembly::PartRef*>(obj->Second.getValue());
|
||||
// Assembly::PartRef* p2 = dynamic_cast<Assembly::PartRef*>(obj->Second.getValue());
|
||||
|
||||
if(!p2)
|
||||
return;
|
||||
// if(!p2)
|
||||
// return;
|
||||
|
||||
boost::shared_ptr<Geometry3D> g2 = ass->m_solver->getGeometry3D(obj->Second.getSubValues()[0].c_str());
|
||||
// boost::shared_ptr<Geometry3D> g2 = ass->m_solver->getGeometry3D(obj->Second.getSubValues()[0].c_str());
|
||||
|
||||
if(!g2)
|
||||
return;
|
||||
// if(!g2)
|
||||
// return;
|
||||
|
||||
//distance
|
||||
if(obj->Type.getValue() == 1) {
|
||||
// //distance
|
||||
// if(obj->Type.getValue() == 1) {
|
||||
|
||||
if(isCombination(g1,g2, dcm::geometry::point, dcm::geometry::plane) ||
|
||||
isCombination(g1,g2, dcm::geometry::point, dcm::geometry::cylinder)) {
|
||||
ui->bidirectional->setEnabled(true);
|
||||
ui->pos_direction->setEnabled(true);
|
||||
ui->neg_direction->setEnabled(true);
|
||||
};
|
||||
};
|
||||
// if(isCombination(g1,g2, dcm::geometry::point, dcm::geometry::plane) ||
|
||||
// isCombination(g1,g2, dcm::geometry::point, dcm::geometry::cylinder)) {
|
||||
// ui->bidirectional->setEnabled(true);
|
||||
// ui->pos_direction->setEnabled(true);
|
||||
// ui->neg_direction->setEnabled(true);
|
||||
// };
|
||||
// };
|
||||
|
||||
//align & coincident
|
||||
if(obj->Type.getValue() == 4 || obj->Type.getValue() == 5) {
|
||||
// //align & coincident
|
||||
// if(obj->Type.getValue() == 4 || obj->Type.getValue() == 5) {
|
||||
|
||||
if(isCombination(g1,g2, dcm::geometry::point, dcm::geometry::plane) ||
|
||||
isCombination(g1,g2, dcm::geometry::point, dcm::geometry::cylinder) ||
|
||||
isCombination(g1,g2, dcm::geometry::line, dcm::geometry::plane) ||
|
||||
isCombination(g1,g2, dcm::geometry::line, dcm::geometry::cylinder) ||
|
||||
isCombination(g1,g2, dcm::geometry::plane, dcm::geometry::plane) ||
|
||||
isCombination(g1,g2, dcm::geometry::plane, dcm::geometry::cylinder)) {
|
||||
ui->bidirectional->setEnabled(true);
|
||||
ui->pos_direction->setEnabled(true);
|
||||
ui->neg_direction->setEnabled(true);
|
||||
};
|
||||
// if(isCombination(g1,g2, dcm::geometry::point, dcm::geometry::plane) ||
|
||||
// isCombination(g1,g2, dcm::geometry::point, dcm::geometry::cylinder) ||
|
||||
// isCombination(g1,g2, dcm::geometry::line, dcm::geometry::plane) ||
|
||||
// isCombination(g1,g2, dcm::geometry::line, dcm::geometry::cylinder) ||
|
||||
// isCombination(g1,g2, dcm::geometry::plane, dcm::geometry::plane) ||
|
||||
// isCombination(g1,g2, dcm::geometry::plane, dcm::geometry::cylinder)) {
|
||||
// ui->bidirectional->setEnabled(true);
|
||||
// ui->pos_direction->setEnabled(true);
|
||||
// ui->neg_direction->setEnabled(true);
|
||||
// };
|
||||
|
||||
if(isCombination(g1,g2, dcm::geometry::line, dcm::geometry::cylinder) ||
|
||||
isCombination(g1,g2, dcm::geometry::plane, dcm::geometry::plane) ||
|
||||
isCombination(g1,g2, dcm::geometry::line, dcm::geometry::cylinder) ||
|
||||
isCombination(g1,g2, dcm::geometry::cylinder, dcm::geometry::cylinder)) {
|
||||
ui->parallel->setEnabled(true);
|
||||
ui->equal->setEnabled(true);
|
||||
ui->opposite->setEnabled(true);
|
||||
// if(isCombination(g1,g2, dcm::geometry::line, dcm::geometry::cylinder) ||
|
||||
// isCombination(g1,g2, dcm::geometry::plane, dcm::geometry::plane) ||
|
||||
// isCombination(g1,g2, dcm::geometry::line, dcm::geometry::cylinder) ||
|
||||
// isCombination(g1,g2, dcm::geometry::cylinder, dcm::geometry::cylinder)) {
|
||||
// ui->parallel->setEnabled(true);
|
||||
// ui->equal->setEnabled(true);
|
||||
// ui->opposite->setEnabled(true);
|
||||
|
||||
//ensure that perpendicular is not checked
|
||||
if(ui->perpendicular->isChecked()) {
|
||||
ui->parallel->setChecked(true);
|
||||
obj->Orientation.setValue((long)0);
|
||||
}
|
||||
};
|
||||
// //ensure that perpendicular is not checked
|
||||
// if(ui->perpendicular->isChecked()) {
|
||||
// ui->parallel->setChecked(true);
|
||||
// obj->Orientation.setValue((long)0);
|
||||
// }
|
||||
// };
|
||||
|
||||
if(isCombination(g1,g2, dcm::geometry::line, dcm::geometry::plane) ||
|
||||
isCombination(g1,g2, dcm::geometry::plane, dcm::geometry::cylinder)) {
|
||||
ui->perpendicular->setEnabled(true);
|
||||
// if(isCombination(g1,g2, dcm::geometry::line, dcm::geometry::plane) ||
|
||||
// isCombination(g1,g2, dcm::geometry::plane, dcm::geometry::cylinder)) {
|
||||
// ui->perpendicular->setEnabled(true);
|
||||
|
||||
//ensure that perpendicular is checked
|
||||
if(!ui->perpendicular->isChecked()) {
|
||||
ui->perpendicular->setChecked(true);
|
||||
obj->Orientation.setValue((long)3);
|
||||
}
|
||||
};
|
||||
};
|
||||
// //ensure that perpendicular is checked
|
||||
// if(!ui->perpendicular->isChecked()) {
|
||||
// ui->perpendicular->setChecked(true);
|
||||
// obj->Orientation.setValue((long)3);
|
||||
// }
|
||||
// };
|
||||
// };
|
||||
|
||||
//orientation
|
||||
if(obj->Type.getValue() == 2) {
|
||||
ui->parallel->setEnabled(true);
|
||||
ui->equal->setEnabled(true);
|
||||
ui->opposite->setEnabled(true);
|
||||
ui->perpendicular->setEnabled(true);
|
||||
}
|
||||
// //orientation
|
||||
// if(obj->Type.getValue() == 2) {
|
||||
// ui->parallel->setEnabled(true);
|
||||
// ui->equal->setEnabled(true);
|
||||
// ui->opposite->setEnabled(true);
|
||||
// ui->perpendicular->setEnabled(true);
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
//}
|
||||
};
|
||||
|
||||
void TaskAssemblyConstraints::setPossibleConstraints()
|
||||
{
|
||||
//diasble all constraints for easyer enabling
|
||||
ui->fix->setEnabled(false);
|
||||
ui->distance->setEnabled(false);
|
||||
ui->orientation->setEnabled(false);
|
||||
ui->angle->setEnabled(false);
|
||||
ui->align->setEnabled(false);
|
||||
ui->coincident->setEnabled(false);
|
||||
////diasble all constraints for easyer enabling
|
||||
//ui->fix->setEnabled(false);
|
||||
//ui->distance->setEnabled(false);
|
||||
//ui->orientation->setEnabled(false);
|
||||
//ui->angle->setEnabled(false);
|
||||
//ui->align->setEnabled(false);
|
||||
//ui->coincident->setEnabled(false);
|
||||
|
||||
Assembly::Constraint* obj = dynamic_cast<Assembly::Constraint*>(view->getObject());
|
||||
//Assembly::Constraint* obj = dynamic_cast<Assembly::Constraint*>(view->getObject());
|
||||
|
||||
if(obj->First.getValue()) {
|
||||
//if(obj->First.getValue()) {
|
||||
|
||||
Assembly::PartRef* p1 = dynamic_cast<Assembly::PartRef*>(obj->First.getValue());
|
||||
// Assembly::PartRef* p1 = dynamic_cast<Assembly::PartRef*>(obj->First.getValue());
|
||||
|
||||
if(!p1)
|
||||
return;
|
||||
// if(!p1)
|
||||
// return;
|
||||
|
||||
Assembly::Product* ass = p1->getParentAssembly();
|
||||
// Assembly::Product* ass = p1->getParentAssembly();
|
||||
|
||||
//extract the geometries to use for comparison
|
||||
boost::shared_ptr<Geometry3D> g1 = ass->m_solver->getGeometry3D(obj->First.getSubValues()[0].c_str());
|
||||
// //extract the geometries to use for comparison
|
||||
// boost::shared_ptr<Geometry3D> g1 = ass->m_solver->getGeometry3D(obj->First.getSubValues()[0].c_str());
|
||||
|
||||
//let's see if we have a part, if not give feedback to the user by color
|
||||
if(!g1) {
|
||||
QPalette palette = ui->widget->palette();
|
||||
palette.setColor(ui->first_geom->backgroundRole(), QColor(255, 0, 0, 127));
|
||||
ui->first_geom->setPalette(palette);
|
||||
}
|
||||
else {
|
||||
//set normal color as we ma need to revert the red background
|
||||
ui->first_geom->setPalette(ui->widget->palette());
|
||||
}
|
||||
// //let's see if we have a part, if not give feedback to the user by color
|
||||
// if(!g1) {
|
||||
// QPalette palette = ui->widget->palette();
|
||||
// palette.setColor(ui->first_geom->backgroundRole(), QColor(255, 0, 0, 127));
|
||||
// ui->first_geom->setPalette(palette);
|
||||
// }
|
||||
// else {
|
||||
// //set normal color as we ma need to revert the red background
|
||||
// ui->first_geom->setPalette(ui->widget->palette());
|
||||
// }
|
||||
|
||||
if(obj->Second.getValue()) {
|
||||
// if(obj->Second.getValue()) {
|
||||
|
||||
Assembly::PartRef* p2 = dynamic_cast<Assembly::PartRef*>(obj->Second.getValue());
|
||||
// Assembly::PartRef* p2 = dynamic_cast<Assembly::PartRef*>(obj->Second.getValue());
|
||||
|
||||
if(!p2)
|
||||
return;
|
||||
// if(!p2)
|
||||
// return;
|
||||
|
||||
boost::shared_ptr<Geometry3D> g2 = ass->m_solver->getGeometry3D(obj->Second.getSubValues()[0].c_str());
|
||||
// boost::shared_ptr<Geometry3D> g2 = ass->m_solver->getGeometry3D(obj->Second.getSubValues()[0].c_str());
|
||||
|
||||
//let's see if we have a part, if not give feedback to the user by color
|
||||
if(!g2) {
|
||||
QPalette palette = ui->widget->palette();
|
||||
palette.setColor(ui->second_geom->backgroundRole(), QColor(255, 0, 0, 127));
|
||||
ui->second_geom->setPalette(palette);
|
||||
}
|
||||
else {
|
||||
//set normal color as we ma need to revert the red background
|
||||
ui->second_geom->setPalette(ui->widget->palette());
|
||||
}
|
||||
// //let's see if we have a part, if not give feedback to the user by color
|
||||
// if(!g2) {
|
||||
// QPalette palette = ui->widget->palette();
|
||||
// palette.setColor(ui->second_geom->backgroundRole(), QColor(255, 0, 0, 127));
|
||||
// ui->second_geom->setPalette(palette);
|
||||
// }
|
||||
// else {
|
||||
// //set normal color as we ma need to revert the red background
|
||||
// ui->second_geom->setPalette(ui->widget->palette());
|
||||
// }
|
||||
|
||||
//return only here to allow coloring both line edits red if needed
|
||||
if(!g1 || !g2)
|
||||
return;
|
||||
// //return only here to allow coloring both line edits red if needed
|
||||
// if(!g1 || !g2)
|
||||
// return;
|
||||
|
||||
//check all valid combinaions
|
||||
if(isCombination(g1,g2, dcm::geometry::point, dcm::geometry::point)) {
|
||||
ui->distance->setEnabled(true);
|
||||
ui->coincident->setEnabled(true);
|
||||
};
|
||||
// //check all valid combinaions
|
||||
// if(isCombination(g1,g2, dcm::geometry::point, dcm::geometry::point)) {
|
||||
// ui->distance->setEnabled(true);
|
||||
// ui->coincident->setEnabled(true);
|
||||
// };
|
||||
|
||||
if(isCombination(g1,g2, dcm::geometry::point, dcm::geometry::line)) {
|
||||
ui->distance->setEnabled(true);
|
||||
ui->coincident->setEnabled(true);
|
||||
};
|
||||
// if(isCombination(g1,g2, dcm::geometry::point, dcm::geometry::line)) {
|
||||
// ui->distance->setEnabled(true);
|
||||
// ui->coincident->setEnabled(true);
|
||||
// };
|
||||
|
||||
if(isCombination(g1,g2, dcm::geometry::point, dcm::geometry::plane)) {
|
||||
ui->distance->setEnabled(true);
|
||||
ui->coincident->setEnabled(true);
|
||||
};
|
||||
// if(isCombination(g1,g2, dcm::geometry::point, dcm::geometry::plane)) {
|
||||
// ui->distance->setEnabled(true);
|
||||
// ui->coincident->setEnabled(true);
|
||||
// };
|
||||
|
||||
if(isCombination(g1,g2, dcm::geometry::point, dcm::geometry::cylinder)) {
|
||||
ui->distance->setEnabled(true);
|
||||
ui->coincident->setEnabled(true);
|
||||
};
|
||||
// if(isCombination(g1,g2, dcm::geometry::point, dcm::geometry::cylinder)) {
|
||||
// ui->distance->setEnabled(true);
|
||||
// ui->coincident->setEnabled(true);
|
||||
// };
|
||||
|
||||
if(isCombination(g1,g2, dcm::geometry::line, dcm::geometry::line)) {
|
||||
ui->distance->setEnabled(true);
|
||||
ui->orientation->setEnabled(true);
|
||||
ui->angle->setEnabled(true);
|
||||
ui->coincident->setEnabled(true);
|
||||
ui->align->setEnabled(true);
|
||||
};
|
||||
// if(isCombination(g1,g2, dcm::geometry::line, dcm::geometry::line)) {
|
||||
// ui->distance->setEnabled(true);
|
||||
// ui->orientation->setEnabled(true);
|
||||
// ui->angle->setEnabled(true);
|
||||
// ui->coincident->setEnabled(true);
|
||||
// ui->align->setEnabled(true);
|
||||
// };
|
||||
|
||||
if(isCombination(g1,g2, dcm::geometry::line, dcm::geometry::plane)) {
|
||||
ui->orientation->setEnabled(true);
|
||||
ui->angle->setEnabled(true);
|
||||
ui->coincident->setEnabled(true);
|
||||
ui->align->setEnabled(true);
|
||||
};
|
||||
// if(isCombination(g1,g2, dcm::geometry::line, dcm::geometry::plane)) {
|
||||
// ui->orientation->setEnabled(true);
|
||||
// ui->angle->setEnabled(true);
|
||||
// ui->coincident->setEnabled(true);
|
||||
// ui->align->setEnabled(true);
|
||||
// };
|
||||
|
||||
if(isCombination(g1,g2, dcm::geometry::line, dcm::geometry::cylinder)) {
|
||||
ui->distance->setEnabled(true);
|
||||
ui->orientation->setEnabled(true);
|
||||
ui->angle->setEnabled(true);
|
||||
ui->coincident->setEnabled(true);
|
||||
ui->align->setEnabled(true);
|
||||
};
|
||||
// if(isCombination(g1,g2, dcm::geometry::line, dcm::geometry::cylinder)) {
|
||||
// ui->distance->setEnabled(true);
|
||||
// ui->orientation->setEnabled(true);
|
||||
// ui->angle->setEnabled(true);
|
||||
// ui->coincident->setEnabled(true);
|
||||
// ui->align->setEnabled(true);
|
||||
// };
|
||||
|
||||
if(isCombination(g1,g2, dcm::geometry::plane, dcm::geometry::plane)) {
|
||||
ui->orientation->setEnabled(true);
|
||||
ui->angle->setEnabled(true);
|
||||
ui->coincident->setEnabled(true);
|
||||
ui->align->setEnabled(true);
|
||||
};
|
||||
// if(isCombination(g1,g2, dcm::geometry::plane, dcm::geometry::plane)) {
|
||||
// ui->orientation->setEnabled(true);
|
||||
// ui->angle->setEnabled(true);
|
||||
// ui->coincident->setEnabled(true);
|
||||
// ui->align->setEnabled(true);
|
||||
// };
|
||||
|
||||
if(isCombination(g1,g2, dcm::geometry::plane, dcm::geometry::cylinder)) {
|
||||
ui->orientation->setEnabled(true);
|
||||
ui->angle->setEnabled(true);
|
||||
ui->align->setEnabled(true);
|
||||
};
|
||||
// if(isCombination(g1,g2, dcm::geometry::plane, dcm::geometry::cylinder)) {
|
||||
// ui->orientation->setEnabled(true);
|
||||
// ui->angle->setEnabled(true);
|
||||
// ui->align->setEnabled(true);
|
||||
// };
|
||||
|
||||
if(isCombination(g1,g2, dcm::geometry::cylinder, dcm::geometry::cylinder)) {
|
||||
ui->coincident->setEnabled(true);
|
||||
ui->orientation->setEnabled(true);
|
||||
ui->angle->setEnabled(true);
|
||||
};
|
||||
}
|
||||
else {
|
||||
//return here to allow check for second geometry and color both red if needed
|
||||
if(!g1)
|
||||
return;
|
||||
// if(isCombination(g1,g2, dcm::geometry::cylinder, dcm::geometry::cylinder)) {
|
||||
// ui->coincident->setEnabled(true);
|
||||
// ui->orientation->setEnabled(true);
|
||||
// ui->angle->setEnabled(true);
|
||||
// };
|
||||
// }
|
||||
// else {
|
||||
// //return here to allow check for second geometry and color both red if needed
|
||||
// if(!g1)
|
||||
// return;
|
||||
|
||||
//only fix works
|
||||
ui->fix->setEnabled(true);
|
||||
};
|
||||
}
|
||||
// //only fix works
|
||||
// ui->fix->setEnabled(true);
|
||||
// };
|
||||
//}
|
||||
}
|
||||
|
||||
bool TaskAssemblyConstraints::isCombination(boost::shared_ptr<Geometry3D> g1, boost::shared_ptr<Geometry3D> g2, dcm::geometry::types t1, dcm::geometry::types t2)
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
|
||||
#include "PreCompiled.h"
|
||||
#include "ViewProviderConstraint.h"
|
||||
#include "TaskAssemblyConstraints.h"
|
||||
#include "TaskDlgAssemblyConstraints.h"
|
||||
//#include "TaskAssemblyConstraints.h"
|
||||
//#include "TaskDlgAssemblyConstraints.h"
|
||||
#include "Mod/Assembly/App/Constraint.h"
|
||||
#include "Mod/Assembly/App/PartRef.h"
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
@ -273,7 +273,7 @@ void ViewProviderConstraint::draw()
|
|||
TopLoc_Location l1 = s1.Location();
|
||||
gp_XYZ tr1 = l1.Transformation().TranslationPart();
|
||||
Base::Placement p1(Base::Vector3d(tr1.X(), tr1.Y(), tr1.Z()), Base::Rotation());
|
||||
upstream_placement(p1, part1);
|
||||
// upstream_placement(p1, part1);
|
||||
//p1 = part1->m_part->getGlobal<Base::Placement>() * p1;
|
||||
|
||||
float q0 = (float)p1.getRotation().getValue()[0];
|
||||
|
@ -307,7 +307,7 @@ void ViewProviderConstraint::draw()
|
|||
TopLoc_Location l2 = s2.Location();
|
||||
gp_XYZ tr2 = l2.Transformation().TranslationPart();
|
||||
Base::Placement p2(Base::Vector3d(tr2.X(), tr2.Y(), tr2.Z()), Base::Rotation());
|
||||
upstream_placement(p2, part2);
|
||||
//upstream_placement(p2, part2);
|
||||
|
||||
p2 = p1.inverse()*p2;
|
||||
//p2 = p1.inverse() * (part2->m_part->getGlobal<Base::Placement>() * p2);
|
||||
|
@ -353,58 +353,59 @@ void ViewProviderConstraint::onSelectionChanged(const Gui::SelectionChanges& msg
|
|||
TopoDS_Shape ViewProviderConstraint::getConstraintShape(int link)
|
||||
{
|
||||
|
||||
if(link == 1) {
|
||||
//subshape of first link
|
||||
//**********************
|
||||
App::DocumentObject* obj1 = dynamic_cast<Assembly::Constraint*>(pcObject)->First.getValue();
|
||||
//if(link == 1) {
|
||||
// //subshape of first link
|
||||
// //**********************
|
||||
// App::DocumentObject* obj1 = dynamic_cast<Assembly::Constraint*>(pcObject)->First.getValue();
|
||||
|
||||
if(!obj1)
|
||||
return TopoDS_Shape();
|
||||
// if(!obj1)
|
||||
// return TopoDS_Shape();
|
||||
|
||||
Assembly::PartRef* part1 = static_cast<Assembly::PartRef*>(obj1);
|
||||
// Assembly::PartRef* part1 = static_cast<Assembly::PartRef*>(obj1);
|
||||
|
||||
if(!part1)
|
||||
return TopoDS_Shape();
|
||||
// if(!part1)
|
||||
// return TopoDS_Shape();
|
||||
|
||||
Part::TopoShape ts;
|
||||
App::DocumentObject* feature1 = part1->Model.getValue();
|
||||
// Part::TopoShape ts;
|
||||
// App::DocumentObject* feature1 = part1->Model.getValue();
|
||||
|
||||
if(feature1->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
ts = static_cast<Part::Feature*>(feature1)->Shape.getShape();
|
||||
}
|
||||
else
|
||||
return TopoDS_Shape();
|
||||
// if(feature1->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
// ts = static_cast<Part::Feature*>(feature1)->Shape.getShape();
|
||||
// }
|
||||
// else
|
||||
// return TopoDS_Shape();
|
||||
|
||||
TopoDS_Shape s1 = ts.getSubShape(dynamic_cast<Assembly::Constraint*>(pcObject)->First.getSubValues()[0].c_str());
|
||||
// TopoDS_Shape s1 = ts.getSubShape(dynamic_cast<Assembly::Constraint*>(pcObject)->First.getSubValues()[0].c_str());
|
||||
|
||||
return s1;
|
||||
}
|
||||
else {
|
||||
//subshape of second link
|
||||
//**********************
|
||||
App::DocumentObject* obj2 = dynamic_cast<Assembly::Constraint*>(pcObject)->Second.getValue();
|
||||
// return s1;
|
||||
//}
|
||||
//else {
|
||||
// //subshape of second link
|
||||
// //**********************
|
||||
// App::DocumentObject* obj2 = dynamic_cast<Assembly::Constraint*>(pcObject)->Second.getValue();
|
||||
|
||||
if(!obj2)
|
||||
return TopoDS_Shape();
|
||||
// if(!obj2)
|
||||
// return TopoDS_Shape();
|
||||
|
||||
Assembly::PartRef* part2 = static_cast<Assembly::PartRef*>(obj2);
|
||||
// Assembly::PartRef* part2 = static_cast<Assembly::PartRef*>(obj2);
|
||||
|
||||
if(!part2)
|
||||
return TopoDS_Shape();
|
||||
// if(!part2)
|
||||
// return TopoDS_Shape();
|
||||
|
||||
Part::TopoShape ts2;
|
||||
App::DocumentObject* feature2 = part2->Model.getValue();
|
||||
// Part::TopoShape ts2;
|
||||
// App::DocumentObject* feature2 = part2->Model.getValue();
|
||||
|
||||
if(feature2->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
ts2 = static_cast<Part::Feature*>(feature2)->Shape.getShape();
|
||||
}
|
||||
else
|
||||
return TopoDS_Shape();
|
||||
// if(feature2->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
// ts2 = static_cast<Part::Feature*>(feature2)->Shape.getShape();
|
||||
// }
|
||||
// else
|
||||
// return TopoDS_Shape();
|
||||
|
||||
TopoDS_Shape s2 = ts2.getSubShape(dynamic_cast<Assembly::Constraint*>(pcObject)->Second.getSubValues()[0].c_str());
|
||||
// TopoDS_Shape s2 = ts2.getSubShape(dynamic_cast<Assembly::Constraint*>(pcObject)->Second.getSubValues()[0].c_str());
|
||||
|
||||
return s2;
|
||||
};
|
||||
// return s2;
|
||||
//};
|
||||
return TopoDS_Shape();
|
||||
}
|
||||
|
||||
void ViewProviderConstraint::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
|
@ -415,24 +416,25 @@ void ViewProviderConstraint::setupContextMenu(QMenu* menu, QObject* receiver, co
|
|||
bool ViewProviderConstraint::setEdit(int ModNum)
|
||||
{
|
||||
|
||||
// When double-clicking on the item for this sketch the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
|
||||
TaskDlgAssemblyConstraints* ConstraintsDlg = qobject_cast<TaskDlgAssemblyConstraints*>(dlg);
|
||||
//// When double-clicking on the item for this sketch the
|
||||
//// object unsets and sets its edit mode without closing
|
||||
//// the task panel
|
||||
//Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
|
||||
//TaskDlgAssemblyConstraints* ConstraintsDlg = qobject_cast<TaskDlgAssemblyConstraints*>(dlg);
|
||||
|
||||
// start the edit dialog
|
||||
if(ConstraintsDlg)
|
||||
Gui::Control().showDialog(ConstraintsDlg);
|
||||
else
|
||||
Gui::Control().showDialog(new TaskDlgAssemblyConstraints(this));
|
||||
//// start the edit dialog
|
||||
//if(ConstraintsDlg)
|
||||
// Gui::Control().showDialog(ConstraintsDlg);
|
||||
//else
|
||||
// Gui::Control().showDialog(new TaskDlgAssemblyConstraints(this));
|
||||
|
||||
//show the constraint geometries
|
||||
internal_vp.switch_node(true);
|
||||
pcModeSwitch->whichChild = 0;
|
||||
draw();
|
||||
////show the constraint geometries
|
||||
//internal_vp.switch_node(true);
|
||||
//pcModeSwitch->whichChild = 0;
|
||||
//draw();
|
||||
|
||||
return true;
|
||||
//return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ViewProviderConstraint::unsetEdit(int ModNum)
|
||||
|
|
|
@ -95,9 +95,6 @@ std::vector<std::string> ViewProviderProduct::getDisplayModes(void) const
|
|||
std::vector<App::DocumentObject*> ViewProviderProduct::claimChildren(void)const
|
||||
{
|
||||
std::vector<App::DocumentObject*> temp(static_cast<Assembly::Product*>(getObject())->Items.getValues());
|
||||
temp.insert(temp.end(),
|
||||
static_cast<Assembly::Product*>(getObject())->Annotations.getValues().begin(),
|
||||
static_cast<Assembly::Product*>(getObject())->Annotations.getValues().end());
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
@ -113,28 +110,29 @@ void ViewProviderProduct::setupContextMenu(QMenu* menu, QObject* receiver, const
|
|||
{
|
||||
ViewProviderItem::setupContextMenu(menu, receiver, member); // call the base class
|
||||
|
||||
QAction* toggle = menu->addAction(QObject::tr("Rigid subassembly"), receiver, member);
|
||||
toggle->setData(QVariant(1000)); // identifier
|
||||
toggle->setCheckable(true);
|
||||
toggle->setToolTip(QObject::tr("Set if the subassembly shall be solved as on part (rigid) or if all parts of this assembly are solved for themselfe."));
|
||||
toggle->setStatusTip(QObject::tr("Set if the subassembly shall be solved as on part (rigid) or if all parts of this assembly are solved for themself."));
|
||||
bool prop = static_cast<Assembly::Product*>(getObject())->Rigid.getValue();
|
||||
toggle->setChecked(prop);
|
||||
//QAction* toggle = menu->addAction(QObject::tr("Rigid subassembly"), receiver, member);
|
||||
//toggle->setData(QVariant(1000)); // identifier
|
||||
//toggle->setCheckable(true);
|
||||
//toggle->setToolTip(QObject::tr("Set if the subassembly shall be solved as on part (rigid) or if all parts of this assembly are solved for themselfe."));
|
||||
//toggle->setStatusTip(QObject::tr("Set if the subassembly shall be solved as on part (rigid) or if all parts of this assembly are solved for themself."));
|
||||
//bool prop = static_cast<Assembly::Product*>(getObject())->Rigid.getValue();
|
||||
//toggle->setChecked(prop);
|
||||
}
|
||||
|
||||
bool ViewProviderProduct::setEdit(int ModNum)
|
||||
{
|
||||
if(ModNum == 1000) { // identifier
|
||||
Gui::Command::openCommand("Change subassembly solving behaviour");
|
||||
if(!static_cast<Assembly::Product*>(getObject())->Rigid.getValue())
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"FreeCAD.getDocument(\"%s\").getObject(\"%s\").Rigid = True",getObject()->getDocument()->getName(), getObject()->getNameInDocument());
|
||||
else
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"FreeCAD.getDocument(\"%s\").getObject(\"%s\").Rigid = False",getObject()->getDocument()->getName(), getObject()->getNameInDocument());
|
||||
//if(ModNum == 1000) { // identifier
|
||||
// Gui::Command::openCommand("Change subassembly solving behaviour");
|
||||
// if(!static_cast<Assembly::Product*>(getObject())->Rigid.getValue())
|
||||
// Gui::Command::doCommand(Gui::Command::Doc,"FreeCAD.getDocument(\"%s\").getObject(\"%s\").Rigid = True",getObject()->getDocument()->getName(), getObject()->getNameInDocument());
|
||||
// else
|
||||
// Gui::Command::doCommand(Gui::Command::Doc,"FreeCAD.getDocument(\"%s\").getObject(\"%s\").Rigid = False",getObject()->getDocument()->getName(), getObject()->getNameInDocument());
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
return false;
|
||||
}
|
||||
return ViewProviderItem::setEdit(ModNum); // call the base class
|
||||
// Gui::Command::commitCommand();
|
||||
// return false;
|
||||
//}
|
||||
//return ViewProviderItem::setEdit(ModNum); // call the base class
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ViewProviderProduct::allowDrop(const std::vector<const App::DocumentObject*> &objList,Qt::KeyboardModifiers keys,Qt::MouseButtons mouseBts,const QPoint &pos)
|
||||
|
|
|
@ -93,47 +93,41 @@ std::vector<std::string> ViewProviderProductRef::getDisplayModes(void) const
|
|||
|
||||
std::vector<App::DocumentObject*> ViewProviderProductRef::claimChildren(void)const
|
||||
{
|
||||
std::vector<App::DocumentObject*> temp(static_cast<Assembly::Product*>(getObject())->Items.getValues());
|
||||
temp.insert(temp.end(),
|
||||
static_cast<Assembly::Product*>(getObject())->Annotations.getValues().begin(),
|
||||
static_cast<Assembly::Product*>(getObject())->Annotations.getValues().end());
|
||||
|
||||
return temp;
|
||||
return (static_cast<Assembly::Product*>(getObject())->Items.getValues());
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderProductRef::claimChildren3D(void)const
|
||||
{
|
||||
|
||||
return static_cast<Assembly::Product*>(getObject())->Items.getValues();
|
||||
|
||||
}
|
||||
|
||||
void ViewProviderProductRef::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
ViewProviderItem::setupContextMenu(menu, receiver, member); // call the base class
|
||||
|
||||
QAction* toggle = menu->addAction(QObject::tr("Rigid subassembly"), receiver, member);
|
||||
toggle->setData(QVariant(1000)); // identifier
|
||||
toggle->setCheckable(true);
|
||||
toggle->setToolTip(QObject::tr("Set if the subassembly shall be solved as on part (rigid) or if all parts of this assembly are solved for themselfe."));
|
||||
toggle->setStatusTip(QObject::tr("Set if the subassembly shall be solved as on part (rigid) or if all parts of this assembly are solved for themself."));
|
||||
bool prop = static_cast<Assembly::Product*>(getObject())->Rigid.getValue();
|
||||
toggle->setChecked(prop);
|
||||
//QAction* toggle = menu->addAction(QObject::tr("Rigid subassembly"), receiver, member);
|
||||
//toggle->setData(QVariant(1000)); // identifier
|
||||
//toggle->setCheckable(true);
|
||||
//toggle->setToolTip(QObject::tr("Set if the subassembly shall be solved as on part (rigid) or if all parts of this assembly are solved for themselfe."));
|
||||
//toggle->setStatusTip(QObject::tr("Set if the subassembly shall be solved as on part (rigid) or if all parts of this assembly are solved for themself."));
|
||||
//bool prop = static_cast<Assembly::Product*>(getObject())->Rigid.getValue();
|
||||
//toggle->setChecked(prop);
|
||||
}
|
||||
|
||||
bool ViewProviderProductRef::setEdit(int ModNum)
|
||||
{
|
||||
if(ModNum == 1000) { // identifier
|
||||
Gui::Command::openCommand("Change subassembly solving behaviour");
|
||||
if(!static_cast<Assembly::Product*>(getObject())->Rigid.getValue())
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"FreeCAD.getDocument(\"%s\").getObject(\"%s\").Rigid = True",getObject()->getDocument()->getName(), getObject()->getNameInDocument());
|
||||
else
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"FreeCAD.getDocument(\"%s\").getObject(\"%s\").Rigid = False",getObject()->getDocument()->getName(), getObject()->getNameInDocument());
|
||||
//if(ModNum == 1000) { // identifier
|
||||
// Gui::Command::openCommand("Change subassembly solving behaviour");
|
||||
// if(!static_cast<Assembly::Product*>(getObject())->Rigid.getValue())
|
||||
// Gui::Command::doCommand(Gui::Command::Doc,"FreeCAD.getDocument(\"%s\").getObject(\"%s\").Rigid = True",getObject()->getDocument()->getName(), getObject()->getNameInDocument());
|
||||
// else
|
||||
// Gui::Command::doCommand(Gui::Command::Doc,"FreeCAD.getDocument(\"%s\").getObject(\"%s\").Rigid = False",getObject()->getDocument()->getName(), getObject()->getNameInDocument());
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
return false;
|
||||
}
|
||||
return ViewProviderItem::setEdit(ModNum); // call the base class
|
||||
// Gui::Command::commitCommand();
|
||||
// return false;
|
||||
//}
|
||||
//return ViewProviderItem::setEdit(ModNum); // call the base class
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ViewProviderProductRef::allowDrop(const std::vector<const App::DocumentObject*> &objList,Qt::KeyboardModifiers keys,Qt::MouseButtons mouseBts,const QPoint &pos)
|
||||
|
|
|
@ -54,13 +54,13 @@ 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_Constraint";
|
||||
*part << "Assembly_ConstraintFix";
|
||||
*part << "Assembly_ConstraintDistance";
|
||||
*part << "Assembly_ConstraintOrientation";
|
||||
*part << "Assembly_ConstraintAngle";
|
||||
*part << "Assembly_ConstraintCoincidence";
|
||||
*part << "Assembly_ConstraintAlignment";
|
||||
//*part << "Assembly_Constraint";
|
||||
//*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";
|
||||
|
@ -77,12 +77,14 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
|||
Gui::MenuItem* asmCmd = new Gui::MenuItem();
|
||||
root->insertItem(item, asmCmd);
|
||||
asmCmd->setCommand("&Assembly");
|
||||
*asmCmd << "Assembly_ConstraintFix"
|
||||
<< "Assembly_ConstraintDistance"
|
||||
<< "Assembly_ConstraintOrientation"
|
||||
<< "Assembly_ConstraintAngle"
|
||||
<< "Assembly_ConstraintCoincidence"
|
||||
<< "Assembly_ConstraintAlignment"
|
||||
*asmCmd
|
||||
|
||||
//<< "Assembly_ConstraintFix"
|
||||
// << "Assembly_ConstraintDistance"
|
||||
// << "Assembly_ConstraintOrientation"
|
||||
// << "Assembly_ConstraintAngle"
|
||||
// << "Assembly_ConstraintCoincidence"
|
||||
// << "Assembly_ConstraintAlignment"
|
||||
<< "Separator"
|
||||
<< "Assembly_AddNewPart"
|
||||
<< "Assembly_AddNewComponent"
|
||||
|
|
Loading…
Reference in New Issue
Block a user