FEM Post: Update function manipulators
Update includes view and transformation handling
This commit is contained in:
@@ -69,13 +69,13 @@ PROPERTY_SOURCE(Fem::FemPostPlaneFunction, Fem::FemPostFunction)
|
||||
FemPostPlaneFunction::FemPostPlaneFunction(void): FemPostFunction() {
|
||||
|
||||
ADD_PROPERTY(Origin,(Base::Vector3d(0.0,0.0,0.0)));
|
||||
ADD_PROPERTY(Normal,(Base::Vector3d(1.0,0.0,0.0)));
|
||||
ADD_PROPERTY(Normal,(Base::Vector3d(0.0,0.0,1.0)));
|
||||
|
||||
m_plane = vtkPlane::New();
|
||||
m_implicit = m_plane;
|
||||
|
||||
m_plane->SetOrigin(0., 0., 0.);
|
||||
m_plane->SetNormal(1., 0., 0.);
|
||||
m_plane->SetNormal(0., 0., 1.);
|
||||
}
|
||||
|
||||
FemPostPlaneFunction::~FemPostPlaneFunction() {
|
||||
|
||||
@@ -947,6 +947,22 @@ void CmdFemPostFunctions::activated(int iMsg)
|
||||
doCommand(Doc,"App.ActiveDocument.%s.Functions = __list__", provider->getNameInDocument());
|
||||
doCommand(Doc,"del __list__");
|
||||
|
||||
//set the default values, for this get the bounding box
|
||||
vtkBoundingBox box = pipeline->getBoundingBox();
|
||||
|
||||
double center[3];
|
||||
box.GetCenter(center);
|
||||
|
||||
if (iMsg==0)
|
||||
doCommand(Doc,"App.ActiveDocument.%s.Origin = App.Vector(%f, %f, %f)", FeatName.c_str(), center[0],
|
||||
center[1], center[2]);
|
||||
else if (iMsg==1) {
|
||||
doCommand(Doc,"App.ActiveDocument.%s.Center = App.Vector(%f, %f, %f)", FeatName.c_str(), center[0],
|
||||
center[1] + box.GetLength(1)/2, center[2] + box.GetLength(2)/2);
|
||||
doCommand(Doc,"App.ActiveDocument.%s.Radius = %f", FeatName.c_str(), box.GetDiagonalLength()/2);
|
||||
}
|
||||
|
||||
|
||||
this->updateActive();
|
||||
//most of the times functions are added inside of a filter, make sure this still works
|
||||
if(Gui::Application::Instance->activeDocument()->getInEdit() == NULL)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<<<<<<< f24874396c47b854461779051d98df0c6567b0a2
|
||||
<<<<<<< 90bd13697472f7f895b8e12b9d1050220d69f763
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
|
||||
* *
|
||||
@@ -50,6 +50,7 @@
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
#include <Gui/Utilities.h>
|
||||
#include <Gui/Action.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
|
||||
#include <SMESH_Mesh.hxx>
|
||||
#include <SMESHDS_Mesh.hxx>
|
||||
@@ -806,7 +807,7 @@ CmdFemPostCreateClipFilter::CmdFemPostCreateClipFilter()
|
||||
sToolTipText = QT_TR_NOOP("Define/create a clip filter which uses functions to define the cliped region");
|
||||
sWhatsThis = "Fem_PostCreateClipFilter";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "fem-fem-mesh-create-node-by-poly";
|
||||
sPixmap = "fem-clip";
|
||||
}
|
||||
|
||||
void CmdFemPostCreateClipFilter::activated(int iMsg)
|
||||
@@ -830,7 +831,7 @@ CmdFemPostCreateScalarClipFilter::CmdFemPostCreateScalarClipFilter()
|
||||
sToolTipText = QT_TR_NOOP("Define/create a clip filter which clips a field with a scalar value");
|
||||
sWhatsThis = "Fem_PostCreateScalarClipFilter";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "fem-fem-mesh-create-node-by-poly";
|
||||
sPixmap = "fem-clip-scalar";
|
||||
}
|
||||
|
||||
void CmdFemPostCreateScalarClipFilter::activated(int iMsg)
|
||||
@@ -856,7 +857,7 @@ CmdFemPostWarpVectorFilter::CmdFemPostWarpVectorFilter()
|
||||
sToolTipText = QT_TR_NOOP("Warp the geometry along a vector field by a certain factor");
|
||||
sWhatsThis = "Fem_PostCreateWarpVectorFilter";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "fem-fem-mesh-create-node-by-poly";
|
||||
sPixmap = "fem-warp";
|
||||
}
|
||||
|
||||
void CmdFemPostWarpVectorFilter::activated(int iMsg)
|
||||
@@ -880,7 +881,7 @@ CmdFemPostCutFilter::CmdFemPostCutFilter()
|
||||
sToolTipText = QT_TR_NOOP("Cut the data along an implicit function");
|
||||
sWhatsThis = "Fem_PostCreateCutFilter";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "fem-fem-mesh-create-node-by-poly";
|
||||
sPixmap = "fem-cut";
|
||||
}
|
||||
|
||||
void CmdFemPostCutFilter::activated(int iMsg)
|
||||
@@ -974,12 +975,15 @@ Gui::Action * CmdFemPostFunctions::createAction(void)
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
QAction* cmd0 = pcAction->addAction(QString());
|
||||
pcAction->addAction(QString());
|
||||
cmd0->setIcon(Gui::BitmapFactory().pixmap("fem-plane"));
|
||||
|
||||
QAction* cmd1 = pcAction->addAction(QString());
|
||||
cmd1->setIcon(Gui::BitmapFactory().pixmap("fem-sphere"));
|
||||
|
||||
_pcAction = pcAction;
|
||||
languageChange();
|
||||
|
||||
pcAction->setIcon(cmd0->icon());
|
||||
pcAction->setIcon(cmd1->icon());
|
||||
int defaultId = 0;
|
||||
pcAction->setProperty("defaultAction", QVariant(defaultId));
|
||||
|
||||
@@ -1059,9 +1063,6 @@ Gui::Action * CmdFemPostApllyChanges::createAction(void)
|
||||
return pcAction;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
DEF_STD_CMD_A(CmdFemPostPipelineFromResult);
|
||||
|
||||
@@ -1074,7 +1075,7 @@ CmdFemPostPipelineFromResult::CmdFemPostPipelineFromResult()
|
||||
sToolTipText = QT_TR_NOOP("Creates a post processing pipeline from a result object");
|
||||
sWhatsThis = "Fem_PostPipelineFromResult";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "fem-fem-mesh-create-node-by-poly";
|
||||
sPixmap = "fem-data";
|
||||
}
|
||||
|
||||
void CmdFemPostPipelineFromResult::activated(int iMsg)
|
||||
@@ -1107,6 +1108,7 @@ bool CmdFemPostPipelineFromResult::isActive(void)
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@@ -2087,6 +2089,22 @@ void CmdFemPostFunctions::activated(int iMsg)
|
||||
doCommand(Doc,"App.ActiveDocument.%s.Functions = __list__", provider->getNameInDocument());
|
||||
doCommand(Doc,"del __list__");
|
||||
|
||||
//set the default values, for this get the bounding box
|
||||
vtkBoundingBox box = pipeline->getBoundingBox();
|
||||
|
||||
double center[3];
|
||||
box.GetCenter(center);
|
||||
|
||||
if (iMsg==0)
|
||||
doCommand(Doc,"App.ActiveDocument.%s.Origin = App.Vector(%f, %f, %f)", FeatName.c_str(), center[0],
|
||||
center[1], center[2]);
|
||||
else if (iMsg==1) {
|
||||
doCommand(Doc,"App.ActiveDocument.%s.Center = App.Vector(%f, %f, %f)", FeatName.c_str(), center[0],
|
||||
center[1] + box.GetLength(1)/2, center[2] + box.GetLength(2)/2);
|
||||
doCommand(Doc,"App.ActiveDocument.%s.Radius = %f", FeatName.c_str(), box.GetDiagonalLength()/2);
|
||||
}
|
||||
|
||||
|
||||
this->updateActive();
|
||||
//most of the times functions are added inside of a filter, make sure this still works
|
||||
if(Gui::Application::Instance->activeDocument()->getInEdit() == NULL)
|
||||
@@ -2278,4 +2296,4 @@ void CreateFemCommands(void)
|
||||
rcCmdMgr.addCommand(new CmdFemPostCutFilter);
|
||||
#endif
|
||||
}
|
||||
>>>>>>> Add icons for fem post processing
|
||||
>>>>>>> Update function manipulators
|
||||
|
||||
@@ -36,11 +36,14 @@
|
||||
#include <Inventor/manips/SoCenterballManip.h>
|
||||
#include <Inventor/manips/SoTransformerManip.h>
|
||||
#include <Inventor/manips/SoTransformBoxManip.h>
|
||||
#include <Inventor/manips/SoHandleBoxManip.h>
|
||||
#include <Inventor/manips/SoTabBoxManip.h>
|
||||
#include <Inventor/actions/SoSearchAction.h>
|
||||
#include <Inventor/engines/SoDecomposeMatrix.h>
|
||||
#include <Inventor/draggers/SoCenterballDragger.h>
|
||||
#include <Inventor/draggers/SoTransformerDragger.h>
|
||||
#include <Inventor/draggers/SoTransformBoxDragger.h>
|
||||
#include <Inventor/draggers/SoHandleBoxDragger.h>
|
||||
#include <QMessageBox>
|
||||
#endif
|
||||
|
||||
@@ -58,6 +61,7 @@
|
||||
#include <App/PropertyUnits.h>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <math.h>
|
||||
|
||||
#include "ui_PlaneWidget.h"
|
||||
#include "ui_SphereWidget.h"
|
||||
@@ -97,15 +101,52 @@ std::vector< App::DocumentObject* > ViewProviderFemPostFunctionProvider::claimCh
|
||||
return claimChildren();
|
||||
}
|
||||
|
||||
void ViewProviderFemPostFunctionProvider::onChanged(const App::Property* prop) {
|
||||
Gui::ViewProviderDocumentObject::onChanged(prop);
|
||||
|
||||
updateSize();
|
||||
}
|
||||
|
||||
void ViewProviderFemPostFunctionProvider::updateData(const App::Property* prop) {
|
||||
Gui::ViewProviderDocumentObject::updateData(prop);
|
||||
|
||||
if(strcmp(prop->getName(), "Functions") == 0) {
|
||||
updateSize();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderFemPostFunctionProvider::updateSize() {
|
||||
|
||||
std::vector< App::DocumentObject* > vec = claimChildren();
|
||||
for(std::vector< App::DocumentObject* >::iterator it = vec.begin(); it != vec.end(); ++it) {
|
||||
|
||||
if(!(*it)->isDerivedFrom(Fem::FemPostFunction::getClassTypeId()))
|
||||
continue;
|
||||
|
||||
ViewProviderFemPostFunction* vp = static_cast<FemGui::ViewProviderFemPostFunction*>(Gui::Application::Instance->getViewProvider(*it));
|
||||
vp->AutoScaleFactorX.setValue(SizeX.getValue());
|
||||
vp->AutoScaleFactorY.setValue(SizeY.getValue());
|
||||
vp->AutoScaleFactorZ.setValue(SizeZ.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PROPERTY_SOURCE(FemGui::ViewProviderFemPostFunction, Gui::ViewProviderDocumentObject)
|
||||
|
||||
ViewProviderFemPostFunction::ViewProviderFemPostFunction() : m_autoscale(false), m_isDragging(false)
|
||||
{
|
||||
|
||||
ADD_PROPERTY_TYPE(AutoScaleFactorX, (1), "AutoScale", App::Prop_Hidden, "Automatic scaling factor");
|
||||
ADD_PROPERTY_TYPE(AutoScaleFactorY, (1), "AutoScale", App::Prop_Hidden, "Automatic scaling factor");
|
||||
ADD_PROPERTY_TYPE(AutoScaleFactorZ, (1), "AutoScale", App::Prop_Hidden, "Automatic scaling factor");
|
||||
|
||||
m_geometrySeperator = new SoSeparator();
|
||||
m_geometrySeperator->ref();
|
||||
|
||||
m_transform = new SoTransform();
|
||||
m_transform->ref();
|
||||
|
||||
m_scale = new SoScale();
|
||||
m_scale->ref();
|
||||
m_scale->scaleFactor = SbVec3f(1,1,1);
|
||||
@@ -116,33 +157,27 @@ ViewProviderFemPostFunction::~ViewProviderFemPostFunction()
|
||||
m_geometrySeperator->unref();
|
||||
m_manip->unref();
|
||||
m_scale->unref();
|
||||
m_transform->unref();
|
||||
}
|
||||
|
||||
void ViewProviderFemPostFunction::attach(App::DocumentObject *pcObj)
|
||||
{
|
||||
ViewProviderDocumentObject::attach(pcObj);
|
||||
Fem::FemPostPlaneFunction* func = static_cast<Fem::FemPostPlaneFunction*>(getObject());
|
||||
|
||||
|
||||
// setup the graph for editing the function unit geometry
|
||||
SoMaterial* color = new SoMaterial();
|
||||
color->diffuseColor.setValue(0,0,1);
|
||||
color->transparency.setValue(0.5);
|
||||
|
||||
SoTransform* trans = new SoTransform;
|
||||
const Base::Vector3d& norm = func->Normal.getValue();
|
||||
const Base::Vector3d& base = func->Origin.getValue();
|
||||
SbRotation rot(SbVec3f(0,0,1), SbVec3f(norm.x,norm.y,norm.z));
|
||||
trans->rotation.setValue(rot);
|
||||
trans->translation.setValue(base.x,base.y,base.z);
|
||||
trans->center.setValue(0.0f,0.0f,0.0f);
|
||||
|
||||
m_transform = new SoTransform;
|
||||
|
||||
m_manip = setupManipulator();
|
||||
m_manip->ref();
|
||||
|
||||
SoSeparator* pcEditNode = new SoSeparator();
|
||||
|
||||
pcEditNode->addChild(color);
|
||||
pcEditNode->addChild(trans);
|
||||
pcEditNode->addChild(m_transform);
|
||||
pcEditNode->addChild(m_geometrySeperator);
|
||||
|
||||
m_geometrySeperator->insertChild(m_scale, 0);
|
||||
@@ -154,7 +189,7 @@ void ViewProviderFemPostFunction::attach(App::DocumentObject *pcObj)
|
||||
SoSearchAction sa;
|
||||
sa.setInterest(SoSearchAction::FIRST);
|
||||
sa.setSearchingAll(FALSE);
|
||||
sa.setNode(trans);
|
||||
sa.setNode(m_transform);
|
||||
sa.apply(pcEditNode);
|
||||
SoPath * path = sa.getPath();
|
||||
if (path) {
|
||||
@@ -272,6 +307,16 @@ void ViewProviderFemPostFunction::unsetEdit(int ModNum) {
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderFemPostFunction::onChanged(const App::Property* prop) {
|
||||
|
||||
Gui::ViewProviderDocumentObject::onChanged(prop);
|
||||
|
||||
if(m_autoscale)
|
||||
m_scale->scaleFactor = SbVec3f(AutoScaleFactorX.getValue(), AutoScaleFactorY.getValue(), AutoScaleFactorZ.getValue());
|
||||
}
|
||||
|
||||
|
||||
|
||||
//#################################################################################################
|
||||
|
||||
PROPERTY_SOURCE(FemGui::ViewProviderFemPostPlaneFunction, FemGui::ViewProviderFemPostFunction)
|
||||
@@ -314,6 +359,19 @@ void ViewProviderFemPostPlaneFunction::draggerUpdate(SoDragger* m) {
|
||||
dragger->rotation.getValue().multVec(norm,norm);
|
||||
func->Origin.setValue(center[0], center[1], center[2]);
|
||||
func->Normal.setValue(norm[0],norm[1],norm[2]);
|
||||
|
||||
SbVec3f c = static_cast<SoCenterballManip*>(getManipulator())->center.getValue();
|
||||
SbVec3f t = static_cast<SoCenterballManip*>(getManipulator())->translation.getValue();
|
||||
SbVec3f s = static_cast<SoCenterballManip*>(getManipulator())->scaleFactor.getValue();
|
||||
SbVec3f rt, irt;
|
||||
dragger->rotation.getValue().multVec(t,rt);
|
||||
dragger->rotation.getValue().inverse().multVec(t,irt);
|
||||
Base::Console().Message("Center: %f, %f, %f\n", c[0], c[1], c[2]);
|
||||
Base::Console().Message("Translation: %f, %f, %f\n", t[0], t[1], t[2]);
|
||||
Base::Console().Message("Rot Translation: %f, %f, %f\n", rt[0], rt[1], rt[2]);
|
||||
Base::Console().Message("I Rot Translation: %f, %f, %f\n", irt[0], irt[1], irt[2]);
|
||||
Base::Console().Message("Normal %f, %f, %f\n", norm[0], norm[1], norm[2]);
|
||||
Base::Console().Message("Scale %f, %f, %f\n", s[0], s[1], s[2]);
|
||||
}
|
||||
|
||||
void ViewProviderFemPostPlaneFunction::updateData(const App::Property* p) {
|
||||
@@ -321,16 +379,24 @@ void ViewProviderFemPostPlaneFunction::updateData(const App::Property* p) {
|
||||
Fem::FemPostPlaneFunction* func = static_cast<Fem::FemPostPlaneFunction*>(getObject());
|
||||
|
||||
if(!isDragging() && (p == &func->Origin || p == &func->Normal)) {
|
||||
|
||||
Base::Vector3d trans = func->Origin.getValue();
|
||||
Base::Vector3d norm = func->Normal.getValue();
|
||||
Base::Console().Message("Translation: %f, %f, %f\n", trans.x, trans.y, trans.z);
|
||||
Base::Console().Message("Normal %f, %f, %f\n", norm.x, norm.y, norm.z);
|
||||
|
||||
const Base::Vector3d& trans = func->Origin.getValue();
|
||||
const Base::Vector3d& norm = func->Normal.getValue();
|
||||
norm = norm / norm.Length();
|
||||
SbRotation rot(SbVec3f(0.,0.,1.), SbVec3f(norm.x, norm.y, norm.z));
|
||||
|
||||
Base::Console().Message("Updated propertes\n");
|
||||
static_cast<SoCenterballManip*>(getManipulator())->center.setValue(SbVec3f(trans[0], trans[1], trans[2]));
|
||||
static_cast<SoCenterballManip*>(getManipulator())->rotation.setValue(rot);
|
||||
}
|
||||
SbMatrix t, translate;
|
||||
t.setRotate(rot);
|
||||
translate.setTranslate(SbVec3f(trans.x, trans.y, trans.z));
|
||||
t.multRight(translate);
|
||||
getManipulator()->setMatrix(t);
|
||||
|
||||
Base::Console().Message("Matrix:\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n%f %f %f %f\n\n", t[0][0], t[0][1], t[0][2], t[0][3],
|
||||
t[1][0], t[1][1], t[1][2], t[1][3], t[2][0], t[2][1], t[2][2], t[2][3], t[3][0], t[3][1], t[3][2], t[3][3]);
|
||||
}
|
||||
Gui::ViewProviderDocumentObject::updateData(p);
|
||||
}
|
||||
|
||||
@@ -413,13 +479,32 @@ ViewProviderFemPostSphereFunction::ViewProviderFemPostSphereFunction() {
|
||||
|
||||
sPixmap = "fem-sphere";
|
||||
|
||||
setAutoScale(true);
|
||||
setAutoScale(false);
|
||||
|
||||
//setup the visualisation geometry
|
||||
m_sphereNode = new SoSphere;
|
||||
m_sphereNode->ref();
|
||||
|
||||
getGeometryNode()->addChild(m_sphereNode);
|
||||
SoCoordinate3* points = new SoCoordinate3();
|
||||
points->point.setNum(2*84);
|
||||
int idx = 0;
|
||||
for(int i=0; i<4; i++) {
|
||||
for(int j=0; j<21; j++) {
|
||||
points->point.set1Value(idx, SbVec3f(std::sin(2*M_PI/20*j) * std::cos(M_PI/4*i),
|
||||
std::sin(2*M_PI/20*j) * std::sin(M_PI/4*i),
|
||||
std::cos(2*M_PI/20*j) ));
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
for(int i=0; i<4; i++) {
|
||||
for(int j=0; j<21; j++) {
|
||||
points->point.set1Value(idx, SbVec3f(std::sin(M_PI/4*i) * std::cos(2*M_PI/20*j),
|
||||
std::sin(M_PI/4*i) * std::sin(2*M_PI/20*j),
|
||||
std::cos(M_PI/4*i) ));
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
|
||||
SoLineSet* line = new SoLineSet();
|
||||
getGeometryNode()->addChild(points);
|
||||
getGeometryNode()->addChild(line);
|
||||
}
|
||||
|
||||
ViewProviderFemPostSphereFunction::~ViewProviderFemPostSphereFunction() {
|
||||
@@ -428,7 +513,21 @@ ViewProviderFemPostSphereFunction::~ViewProviderFemPostSphereFunction() {
|
||||
}
|
||||
|
||||
SoTransformManip* ViewProviderFemPostSphereFunction::setupManipulator() {
|
||||
return new SoTransformBoxManip();
|
||||
SoHandleBoxManip* manip = new SoHandleBoxManip();
|
||||
manip->getDragger()->setPart("extruder1", new SoSeparator);
|
||||
manip->getDragger()->setPart("extruder2", new SoSeparator);
|
||||
manip->getDragger()->setPart("extruder3", new SoSeparator);
|
||||
manip->getDragger()->setPart("extruder4", new SoSeparator);
|
||||
manip->getDragger()->setPart("extruder5", new SoSeparator);
|
||||
manip->getDragger()->setPart("extruder6", new SoSeparator);
|
||||
manip->getDragger()->setPart("extruder1Active", new SoSeparator);
|
||||
manip->getDragger()->setPart("extruder2Active", new SoSeparator);
|
||||
manip->getDragger()->setPart("extruder3Active", new SoSeparator);
|
||||
manip->getDragger()->setPart("extruder4Active", new SoSeparator);
|
||||
manip->getDragger()->setPart("extruder5Active", new SoSeparator);
|
||||
manip->getDragger()->setPart("extruder6Active", new SoSeparator);
|
||||
|
||||
return manip;
|
||||
}
|
||||
|
||||
|
||||
@@ -437,34 +536,34 @@ void ViewProviderFemPostSphereFunction::draggerUpdate(SoDragger* m) {
|
||||
Base::Console().Message("dragger udate\n");
|
||||
|
||||
Fem::FemPostSphereFunction* func = static_cast<Fem::FemPostSphereFunction*>(getObject());
|
||||
SoTransformBoxDragger* dragger = static_cast<SoTransformBoxDragger*>(m);
|
||||
SoHandleBoxDragger* dragger = static_cast<SoHandleBoxDragger*>(m);
|
||||
|
||||
// the new axis of the plane
|
||||
SbRotation rot, scaleDir;
|
||||
const SbVec3f& center = dragger->translation.getValue();
|
||||
|
||||
SbVec3f norm(0,0,1);
|
||||
dragger->rotation.getValue().multVec(norm,norm);
|
||||
func->Center.setValue(center[0], center[1], center[2]);
|
||||
func->Radius.setValue(dragger->scaleFactor.getValue()[0]);
|
||||
}
|
||||
|
||||
void ViewProviderFemPostSphereFunction::updateData(const App::Property* p) {
|
||||
/*
|
||||
|
||||
Fem::FemPostSphereFunction* func = static_cast<Fem::FemPostSphereFunction*>(getObject());
|
||||
|
||||
if(!isDragging() && (p == &func->Origin || p == &func->Normal)) {
|
||||
if(!isDragging() && (p == &func->Center || p == &func->Radius)) {
|
||||
|
||||
Base::Vector3d trans = func->Center.getValue();
|
||||
double radius = func->Radius.getValue();
|
||||
|
||||
const Base::Vector3d& trans = func->Origin.getValue();
|
||||
const Base::Vector3d& norm = func->Normal.getValue();
|
||||
SbRotation rot(SbVec3f(0.,0.,1.), SbVec3f(norm.x, norm.y, norm.z));
|
||||
|
||||
Base::Console().Message("Updated propertes\n");
|
||||
static_cast<SoCenterballManip*>(getManipulator())->center.setValue(SbVec3f(trans[0], trans[1], trans[2]));
|
||||
static_cast<SoCenterballManip*>(getManipulator())->rotation.setValue(rot);
|
||||
}
|
||||
SbMatrix t, translate;
|
||||
t.setScale(radius);
|
||||
translate.setTranslate(SbVec3f(trans.x, trans.y, trans.z));
|
||||
t.multRight(translate);
|
||||
getManipulator()->setMatrix(t);
|
||||
|
||||
Gui::ViewProviderDocumentObject::updateData(p);*/
|
||||
}
|
||||
Gui::ViewProviderDocumentObject::updateData(p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -101,8 +101,17 @@ public:
|
||||
ViewProviderFemPostFunctionProvider();
|
||||
virtual ~ViewProviderFemPostFunctionProvider();
|
||||
|
||||
App::PropertyFloat SizeX;
|
||||
App::PropertyFloat SizeY;
|
||||
App::PropertyFloat SizeZ;
|
||||
|
||||
protected:
|
||||
virtual std::vector< App::DocumentObject* > claimChildren(void) const;
|
||||
virtual std::vector< App::DocumentObject* > claimChildren3D(void) const;
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
virtual void updateData(const App::Property*);
|
||||
|
||||
void updateSize();
|
||||
};
|
||||
|
||||
class FemGuiExport ViewProviderFemPostFunction : public Gui::ViewProviderDocumentObject
|
||||
@@ -113,6 +122,10 @@ public:
|
||||
/// constructor.
|
||||
ViewProviderFemPostFunction();
|
||||
~ViewProviderFemPostFunction();
|
||||
|
||||
App::PropertyFloat AutoScaleFactorX;
|
||||
App::PropertyFloat AutoScaleFactorY;
|
||||
App::PropertyFloat AutoScaleFactorZ;
|
||||
|
||||
void attach(App::DocumentObject *pcObject);
|
||||
bool doubleClicked(void);
|
||||
@@ -125,6 +138,7 @@ public:
|
||||
protected:
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
|
||||
void setAutoScale(bool value) {m_autoscale = value;};
|
||||
bool autoScale() {return m_autoscale;};
|
||||
@@ -135,6 +149,8 @@ protected:
|
||||
virtual void draggerUpdate(SoDragger* m) {};
|
||||
SoTransformManip* getManipulator() {return m_manip;};
|
||||
SoSeparator* getGeometryNode() {return m_geometrySeperator;};
|
||||
SoScale* getScaleNode() {return m_scale;};
|
||||
SoTransform* getTransformNode() {return m_transform;};
|
||||
|
||||
private:
|
||||
static void dragStartCallback(void * data, SoDragger * d);
|
||||
@@ -144,6 +160,7 @@ private:
|
||||
SoSeparator* m_geometrySeperator;
|
||||
SoTransformManip* m_manip;
|
||||
SoScale* m_scale;
|
||||
SoTransform* m_transform;
|
||||
bool m_autoscale, m_isDragging, m_autoRecompute;
|
||||
};
|
||||
|
||||
|
||||
@@ -23,8 +23,10 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#include "ViewProviderFemPostPipeline.h"
|
||||
#include "ViewProviderFemPostFunction.h"
|
||||
#include <Mod/Fem/App/FemPostPipeline.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Gui/Application.h>
|
||||
|
||||
using namespace FemGui;
|
||||
|
||||
@@ -58,3 +60,35 @@ std::vector< App::DocumentObject* > ViewProviderFemPostPipeline::claimChildren3D
|
||||
return claimChildren();
|
||||
}
|
||||
|
||||
void ViewProviderFemPostPipeline::updateData(const App::Property* prop) {
|
||||
FemGui::ViewProviderFemPostObject::onChanged(prop);
|
||||
|
||||
if(strcmp(prop->getName(), "ModificationTime") == 0) {
|
||||
updateFunctionSize();
|
||||
}
|
||||
else if(strcmp(prop->getName(), "Function") == 0) {
|
||||
updateFunctionSize();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ViewProviderFemPostPipeline::updateFunctionSize() {
|
||||
|
||||
//we need to get the bounding box and set the function provider size
|
||||
Fem::FemPostPipeline* obj = static_cast<Fem::FemPostPipeline*>(getObject());
|
||||
|
||||
if(!obj->Function.getValue() || !obj->Function.getValue()->isDerivedFrom(Fem::FemPostFunctionProvider::getClassTypeId()))
|
||||
return;
|
||||
|
||||
//get the functtion provider
|
||||
FemGui::ViewProviderFemPostFunctionProvider* vp = static_cast<FemGui::ViewProviderFemPostFunctionProvider*>(
|
||||
Gui::Application::Instance->getViewProvider(obj->Function.getValue()));
|
||||
|
||||
if(obj->providesPolyData()) {
|
||||
vtkBoundingBox box = obj->getBoundingBox();
|
||||
|
||||
vp->SizeX.setValue(box.GetLength(0)*1.2);
|
||||
vp->SizeY.setValue(box.GetLength(1)*1.2);
|
||||
vp->SizeZ.setValue(box.GetLength(2)*1.2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,10 @@ public:
|
||||
|
||||
virtual std::vector< App::DocumentObject* > claimChildren(void) const;
|
||||
virtual std::vector< App::DocumentObject* > claimChildren3D(void) const;
|
||||
virtual void updateData(const App::Property* prop);
|
||||
|
||||
protected:
|
||||
void updateFunctionSize();
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user