change inheritance of Item (again)
This commit is contained in:
parent
fbd763a8f4
commit
f5cfa8d72a
|
@ -36,7 +36,7 @@ using namespace Assembly;
|
|||
namespace Assembly {
|
||||
|
||||
|
||||
PROPERTY_SOURCE(Assembly::Item, Part::Feature)
|
||||
PROPERTY_SOURCE_ABSTRACT(Assembly::Item, App::GeoFeature)
|
||||
|
||||
Item::Item()
|
||||
{
|
||||
|
|
|
@ -25,13 +25,14 @@
|
|||
#define Assembly_Item_H
|
||||
|
||||
#include <App/PropertyStandard.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <App/GeoFeature.h>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
|
||||
namespace Assembly
|
||||
{
|
||||
|
||||
class AssemblyExport Item : public Part::Feature
|
||||
class AssemblyExport Item : public App::GeoFeature
|
||||
{
|
||||
PROPERTY_HEADER(Assembly::Item);
|
||||
|
||||
|
@ -72,6 +73,8 @@ public:
|
|||
}
|
||||
//@}
|
||||
|
||||
virtual TopoDS_Shape getShape(void)const =0 ;
|
||||
|
||||
PyObject *getPyObject(void);
|
||||
};
|
||||
|
||||
|
|
|
@ -53,6 +53,12 @@ short ItemAssembly::mustExecute() const
|
|||
}
|
||||
|
||||
App::DocumentObjectExecReturn *ItemAssembly::execute(void)
|
||||
{
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
TopoDS_Shape ItemAssembly::getShape(void) const
|
||||
{
|
||||
std::vector<TopoDS_Shape> s;
|
||||
std::vector<App::DocumentObject*> obj = Items.getValues();
|
||||
|
@ -60,7 +66,7 @@ App::DocumentObjectExecReturn *ItemAssembly::execute(void)
|
|||
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)->Shape.getValue();
|
||||
TopoDS_Shape aShape = static_cast<Assembly::Item*>(*it)->getShape();
|
||||
if (!aShape.IsNull())
|
||||
s.push_back(aShape);
|
||||
}
|
||||
|
@ -75,15 +81,13 @@ App::DocumentObjectExecReturn *ItemAssembly::execute(void)
|
|||
|
||||
aBuilder.Add(aRes, *it);
|
||||
}
|
||||
if (aRes.IsNull())
|
||||
throw Base::Exception("Resulting shape is invalid");
|
||||
this->Shape.setValue(aRes);
|
||||
//if (aRes.IsNull())
|
||||
// throw Base::Exception("Resulting shape is invalid");
|
||||
return aRes;
|
||||
}
|
||||
else {
|
||||
// set empty shape
|
||||
this->Shape.setValue(TopoDS_Shape());
|
||||
}
|
||||
return App::DocumentObject::StdReturn;
|
||||
// set empty shape
|
||||
return TopoDS_Compound();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -50,6 +50,8 @@ public:
|
|||
return "AssemblyGui::ViewProviderItemAssembly";
|
||||
}
|
||||
//@}
|
||||
|
||||
virtual TopoDS_Shape getShape(void) const;
|
||||
};
|
||||
|
||||
} //namespace Assembly
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <Base/Placement.h>
|
||||
|
||||
#include "ItemPart.h"
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
|
||||
using namespace Assembly;
|
||||
|
@ -52,14 +53,20 @@ short ItemPart::mustExecute() const
|
|||
}
|
||||
|
||||
App::DocumentObjectExecReturn *ItemPart::execute(void)
|
||||
{
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
TopoDS_Shape ItemPart::getShape(void) const
|
||||
{
|
||||
App::DocumentObject* obj = Model.getValue();
|
||||
|
||||
if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
this->Shape.setValue(static_cast<Part::Feature*>(obj)->Shape.getValue());
|
||||
return static_cast<Part::Feature*>(obj)->Shape.getValue();
|
||||
}
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
return TopoDS_Shape();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -51,6 +51,8 @@ public:
|
|||
return "AssemblyGui::ViewProviderItemPart";
|
||||
}
|
||||
//@}
|
||||
|
||||
virtual TopoDS_Shape getShape(void) const;
|
||||
};
|
||||
|
||||
} //namespace Assembly
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
using namespace AssemblyGui;
|
||||
|
||||
PROPERTY_SOURCE(AssemblyGui::ViewProviderItem,PartGui::ViewProviderPart)
|
||||
PROPERTY_SOURCE(AssemblyGui::ViewProviderItem,Gui::ViewProviderGeometryObject)
|
||||
|
||||
ViewProviderItem::ViewProviderItem()
|
||||
{
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
#ifndef ASSEMBLYGUI_ViewProvider_H
|
||||
#define ASSEMBLYGUI_ViewProvider_H
|
||||
|
||||
#include <Mod/Part/Gui/ViewProvider.h>
|
||||
#include <Gui/ViewProviderGeometryObject.h>
|
||||
|
||||
class SoGroup;
|
||||
|
||||
namespace AssemblyGui {
|
||||
|
||||
class AssemblyGuiExport ViewProviderItem : public PartGui::ViewProviderPart
|
||||
class AssemblyGuiExport ViewProviderItem : public Gui::ViewProviderGeometryObject
|
||||
{
|
||||
PROPERTY_HEADER(AssemblyGui::ViewProviderItem);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user