change inheritance of Item (again)

This commit is contained in:
jriegel 2012-05-17 17:20:44 +02:00 committed by Stefan Tröger
parent fbd763a8f4
commit f5cfa8d72a
8 changed files with 36 additions and 18 deletions

View File

@ -36,7 +36,7 @@ using namespace Assembly;
namespace Assembly { namespace Assembly {
PROPERTY_SOURCE(Assembly::Item, Part::Feature) PROPERTY_SOURCE_ABSTRACT(Assembly::Item, App::GeoFeature)
Item::Item() Item::Item()
{ {

View File

@ -25,13 +25,14 @@
#define Assembly_Item_H #define Assembly_Item_H
#include <App/PropertyStandard.h> #include <App/PropertyStandard.h>
#include <Mod/Part/App/PartFeature.h> #include <App/GeoFeature.h>
#include <TopoDS_Shape.hxx>
namespace Assembly namespace Assembly
{ {
class AssemblyExport Item : public Part::Feature class AssemblyExport Item : public App::GeoFeature
{ {
PROPERTY_HEADER(Assembly::Item); PROPERTY_HEADER(Assembly::Item);
@ -72,6 +73,8 @@ public:
} }
//@} //@}
virtual TopoDS_Shape getShape(void)const =0 ;
PyObject *getPyObject(void); PyObject *getPyObject(void);
}; };

View File

@ -53,6 +53,12 @@ short ItemAssembly::mustExecute() const
} }
App::DocumentObjectExecReturn *ItemAssembly::execute(void) App::DocumentObjectExecReturn *ItemAssembly::execute(void)
{
return App::DocumentObject::StdReturn;
}
TopoDS_Shape ItemAssembly::getShape(void) const
{ {
std::vector<TopoDS_Shape> s; std::vector<TopoDS_Shape> s;
std::vector<App::DocumentObject*> obj = Items.getValues(); std::vector<App::DocumentObject*> obj = Items.getValues();
@ -60,7 +66,7 @@ App::DocumentObjectExecReturn *ItemAssembly::execute(void)
std::vector<App::DocumentObject*>::iterator it; std::vector<App::DocumentObject*>::iterator it;
for (it = obj.begin(); it != obj.end(); ++it) { for (it = obj.begin(); it != obj.end(); ++it) {
if ((*it)->getTypeId().isDerivedFrom(Assembly::Item::getClassTypeId())) { 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()) if (!aShape.IsNull())
s.push_back(aShape); s.push_back(aShape);
} }
@ -75,15 +81,13 @@ App::DocumentObjectExecReturn *ItemAssembly::execute(void)
aBuilder.Add(aRes, *it); aBuilder.Add(aRes, *it);
} }
if (aRes.IsNull()) //if (aRes.IsNull())
throw Base::Exception("Resulting shape is invalid"); // throw Base::Exception("Resulting shape is invalid");
this->Shape.setValue(aRes); return aRes;
} }
else {
// set empty shape // set empty shape
this->Shape.setValue(TopoDS_Shape()); return TopoDS_Compound();
}
return App::DocumentObject::StdReturn;
} }
} }

View File

@ -50,6 +50,8 @@ public:
return "AssemblyGui::ViewProviderItemAssembly"; return "AssemblyGui::ViewProviderItemAssembly";
} }
//@} //@}
virtual TopoDS_Shape getShape(void) const;
}; };
} //namespace Assembly } //namespace Assembly

View File

@ -28,6 +28,7 @@
#include <Base/Placement.h> #include <Base/Placement.h>
#include "ItemPart.h" #include "ItemPart.h"
#include <Mod/Part/App/PartFeature.h>
using namespace Assembly; using namespace Assembly;
@ -53,13 +54,19 @@ short ItemPart::mustExecute() const
App::DocumentObjectExecReturn *ItemPart::execute(void) App::DocumentObjectExecReturn *ItemPart::execute(void)
{ {
App::DocumentObject* obj = Model.getValue();
if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
this->Shape.setValue(static_cast<Part::Feature*>(obj)->Shape.getValue());
}
return App::DocumentObject::StdReturn; return App::DocumentObject::StdReturn;
} }
TopoDS_Shape ItemPart::getShape(void) const
{
App::DocumentObject* obj = Model.getValue();
if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
return static_cast<Part::Feature*>(obj)->Shape.getValue();
}
return TopoDS_Shape();
}
} }

View File

@ -51,6 +51,8 @@ public:
return "AssemblyGui::ViewProviderItemPart"; return "AssemblyGui::ViewProviderItemPart";
} }
//@} //@}
virtual TopoDS_Shape getShape(void) const;
}; };
} //namespace Assembly } //namespace Assembly

View File

@ -34,7 +34,7 @@
using namespace AssemblyGui; using namespace AssemblyGui;
PROPERTY_SOURCE(AssemblyGui::ViewProviderItem,PartGui::ViewProviderPart) PROPERTY_SOURCE(AssemblyGui::ViewProviderItem,Gui::ViewProviderGeometryObject)
ViewProviderItem::ViewProviderItem() ViewProviderItem::ViewProviderItem()
{ {

View File

@ -24,13 +24,13 @@
#ifndef ASSEMBLYGUI_ViewProvider_H #ifndef ASSEMBLYGUI_ViewProvider_H
#define ASSEMBLYGUI_ViewProvider_H #define ASSEMBLYGUI_ViewProvider_H
#include <Mod/Part/Gui/ViewProvider.h> #include <Gui/ViewProviderGeometryObject.h>
class SoGroup; class SoGroup;
namespace AssemblyGui { namespace AssemblyGui {
class AssemblyGuiExport ViewProviderItem : public PartGui::ViewProviderPart class AssemblyGuiExport ViewProviderItem : public Gui::ViewProviderGeometryObject
{ {
PROPERTY_HEADER(AssemblyGui::ViewProviderItem); PROPERTY_HEADER(AssemblyGui::ViewProviderItem);