Part: Add transform property to SoPreviewShape
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
# include <Inventor/nodes/SoMaterial.h>
|
||||
# include <Inventor/nodes/SoPickStyle.h>
|
||||
# include <Inventor/nodes/SoPolygonOffset.h>
|
||||
# include <Inventor/nodes/SoTransform.h>
|
||||
#endif
|
||||
|
||||
#include "ViewProviderPreviewExtension.h"
|
||||
@@ -53,6 +54,9 @@ SoPreviewShape::SoPreviewShape()
|
||||
SO_NODE_ADD_FIELD(color, (defaultColor));
|
||||
SO_NODE_ADD_FIELD(transparency, (defaultTransparency));
|
||||
SO_NODE_ADD_FIELD(lineWidth, (defaultLineWidth));
|
||||
SO_NODE_ADD_FIELD(transform, (SbMatrix::identity()));
|
||||
|
||||
pcTransform = new SoTransform;
|
||||
|
||||
auto pickStyle = new SoPickStyle;
|
||||
pickStyle->style = SoPickStyle::UNPICKABLE;
|
||||
@@ -103,6 +107,7 @@ SoPreviewShape::SoPreviewShape()
|
||||
annotation->addChild(polygonOffset);
|
||||
annotation->addChild(faceset);
|
||||
|
||||
SoSeparator::addChild(pcTransform);
|
||||
SoSeparator::addChild(pickStyle);
|
||||
SoSeparator::addChild(solidLineStyle);
|
||||
SoSeparator::addChild(material);
|
||||
@@ -119,6 +124,14 @@ void SoPreviewShape::initClass()
|
||||
SO_NODE_INIT_CLASS(SoPreviewShape, SoSeparator, "Separator");
|
||||
}
|
||||
|
||||
void SoPreviewShape::notify(SoNotList* nl)
|
||||
{
|
||||
SoField* field = nl->getLastField();
|
||||
if (field == &transform) {
|
||||
pcTransform->setMatrix(transform.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
EXTENSION_PROPERTY_SOURCE(PartGui::ViewProviderPreviewExtension, Gui::ViewProviderExtension)
|
||||
|
||||
ViewProviderPreviewExtension::ViewProviderPreviewExtension()
|
||||
@@ -224,6 +237,7 @@ void ViewProviderPreviewExtension::updatePreviewShape(Part::TopoShape shape,
|
||||
|
||||
try {
|
||||
updatePreviewShape(preview, shape);
|
||||
preview->transform.setValue(Base::convertTo<SbMatrix>(shape.getTransform()));
|
||||
} catch (Standard_Failure& e) {
|
||||
Base::Console().userTranslatedNotification(
|
||||
tr("Failure while rendering preview: %1. That usually indicates an error with model.")
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
#include <Gui/ViewProviderExtension.h>
|
||||
#include <Gui/ViewProviderExtensionPython.h>
|
||||
#include <Inventor/fields/SoSFMatrix.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
|
||||
namespace PartGui {
|
||||
@@ -59,9 +60,15 @@ public:
|
||||
SoPreviewShape();
|
||||
static void initClass();
|
||||
|
||||
void notify(SoNotList* nl) override;
|
||||
|
||||
SoSFColor color;
|
||||
SoSFFloat transparency;
|
||||
SoSFFloat lineWidth;
|
||||
SoSFMatrix transform;
|
||||
|
||||
private:
|
||||
SoTransform* pcTransform;
|
||||
};
|
||||
|
||||
class PartGuiExport ViewProviderPreviewExtension : public Gui::ViewProviderExtension {
|
||||
|
||||
Reference in New Issue
Block a user