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 {
PROPERTY_SOURCE(Assembly::Item, Part::Feature)
PROPERTY_SOURCE_ABSTRACT(Assembly::Item, App::GeoFeature)
Item::Item()
{

View File

@ -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);
};

View File

@ -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();
}
}
}

View File

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

View File

@ -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();
}
}

View File

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

View File

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

View File

@ -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);