FEM: Add cylinder filter function
This commit is contained in:
@@ -187,6 +187,7 @@ PyMOD_INIT_FUNC(Fem)
|
||||
|
||||
Fem::FemPostFunction ::init();
|
||||
Fem::FemPostFunctionProvider ::init();
|
||||
Fem::FemPostCylinderFunction ::init();
|
||||
Fem::FemPostPlaneFunction ::init();
|
||||
Fem::FemPostSphereFunction ::init();
|
||||
|
||||
|
||||
@@ -59,6 +59,44 @@ DocumentObjectExecReturn* FemPostFunction::execute() {
|
||||
return DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// cylinder function
|
||||
PROPERTY_SOURCE(Fem::FemPostCylinderFunction, Fem::FemPostFunction)
|
||||
|
||||
FemPostCylinderFunction::FemPostCylinderFunction() : FemPostFunction()
|
||||
{
|
||||
ADD_PROPERTY(Center, (Base::Vector3d(0.0, 0.0, 0.0)));
|
||||
ADD_PROPERTY(Axis, (Base::Vector3d(0.0, 0.0, 1.0)));
|
||||
ADD_PROPERTY(Radius, (5.));
|
||||
|
||||
m_cylinder = vtkSmartPointer<vtkCylinder>::New();
|
||||
m_implicit = m_cylinder;
|
||||
|
||||
m_cylinder->SetAxis(0., 0., 1.);
|
||||
m_cylinder->SetCenter(0., 0., 0.);
|
||||
m_cylinder->SetRadius(5.);
|
||||
}
|
||||
|
||||
FemPostCylinderFunction::~FemPostCylinderFunction()
|
||||
{
|
||||
}
|
||||
|
||||
void FemPostCylinderFunction::onChanged(const Property* prop)
|
||||
{
|
||||
if (prop == &Axis) {
|
||||
const Base::Vector3d& vec = Axis.getValue();
|
||||
m_cylinder->SetAxis(vec[0], vec[1], vec[2]);
|
||||
}
|
||||
else if (prop == &Center) {
|
||||
const Base::Vector3d& vec = Center.getValue();
|
||||
m_cylinder->SetCenter(vec[0], vec[1], vec[2]);
|
||||
}
|
||||
else if (prop == &Radius) {
|
||||
m_cylinder->SetRadius(Radius.getValue());
|
||||
}
|
||||
|
||||
Fem::FemPostFunction::onChanged(prop);
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
// plane function
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#define Fem_FemPostFunction_H
|
||||
|
||||
#include <vtkBoundingBox.h>
|
||||
#include <vtkCylinder.h>
|
||||
#include <vtkImplicitFunction.h>
|
||||
#include <vtkPlane.h>
|
||||
#include <vtkSmartPointer.h>
|
||||
@@ -81,6 +82,32 @@ protected:
|
||||
void onChanged(const App::Property* prop) override;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class FemExport FemPostCylinderFunction : public FemPostFunction
|
||||
{
|
||||
PROPERTY_HEADER_WITH_OVERRIDE(Fem::FemPostCylinderFunction);
|
||||
|
||||
public:
|
||||
|
||||
FemPostCylinderFunction();
|
||||
~FemPostCylinderFunction() override;
|
||||
|
||||
App::PropertyVector Axis;
|
||||
App::PropertyVectorDistance Center;
|
||||
App::PropertyDistance Radius;
|
||||
|
||||
const char* getViewProviderName() const override {
|
||||
return "FemGui::ViewProviderFemPostCylinderFunction";
|
||||
}
|
||||
|
||||
protected:
|
||||
void onChanged(const App::Property* prop) override;
|
||||
/// get called after a document has been fully restored
|
||||
// void onDocumentRestored() override;
|
||||
|
||||
vtkSmartPointer<vtkCylinder> m_cylinder;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -161,6 +161,7 @@ PyMOD_INIT_FUNC(FemGui)
|
||||
|
||||
FemGui::ViewProviderFemPostFunction ::init();
|
||||
FemGui::ViewProviderFemPostFunctionProvider ::init();
|
||||
FemGui::ViewProviderFemPostCylinderFunction ::init();
|
||||
FemGui::ViewProviderFemPostPlaneFunction ::init();
|
||||
FemGui::ViewProviderFemPostSphereFunction ::init();
|
||||
#endif
|
||||
|
||||
@@ -99,6 +99,7 @@ if(BUILD_FEM_VTK)
|
||||
TaskPostScalarClip.ui
|
||||
TaskPostWarpVector.ui
|
||||
TaskPostCut.ui
|
||||
CylinderWidget.ui
|
||||
PlaneWidget.ui
|
||||
SphereWidget.ui
|
||||
)
|
||||
@@ -269,6 +270,7 @@ SET(FemGui_SRCS_TaskBoxes
|
||||
if(BUILD_FEM_VTK)
|
||||
SET(FemGui_SRCS_TaskBoxes
|
||||
${FemGui_SRCS_TaskBoxes}
|
||||
CylinderWidget.ui
|
||||
PlaneWidget.ui
|
||||
SphereWidget.ui
|
||||
TaskPostClip.ui
|
||||
|
||||
@@ -2104,6 +2104,8 @@ void CmdFemPostFunctions::activated(int iMsg)
|
||||
name = "Plane";
|
||||
else if (iMsg == 1)
|
||||
name = "Sphere";
|
||||
else if (iMsg == 2)
|
||||
name = "Cylinder";
|
||||
else
|
||||
return;
|
||||
|
||||
@@ -2170,6 +2172,18 @@ void CmdFemPostFunctions::activated(int iMsg)
|
||||
FeatName.c_str(),
|
||||
box.GetDiagonalLength() / 2);
|
||||
}
|
||||
else if (iMsg == 2) {
|
||||
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();
|
||||
@@ -2204,6 +2218,9 @@ Gui::Action* CmdFemPostFunctions::createAction()
|
||||
QAction* cmd1 = pcAction->addAction(QString());
|
||||
cmd1->setIcon(Gui::BitmapFactory().iconFromTheme("fem-post-geo-sphere"));
|
||||
|
||||
QAction* cmd2 = pcAction->addAction(QString());
|
||||
cmd2->setIcon(Gui::BitmapFactory().iconFromTheme("fem-post-geo-cylinder"));
|
||||
|
||||
_pcAction = pcAction;
|
||||
languageChange();
|
||||
|
||||
@@ -2235,6 +2252,11 @@ void CmdFemPostFunctions::languageChange()
|
||||
"FEM_PostCreateFunctions", "Create a sphere function, defined by its center and radius"));
|
||||
cmd->setStatusTip(cmd->toolTip());
|
||||
|
||||
cmd = a[2];
|
||||
cmd->setText(QApplication::translate("CmdFemPostFunctions", "Cylinder"));
|
||||
cmd->setToolTip(QApplication::translate(
|
||||
"FEM_PostCreateFunctions", "Create a cylinder function, defined by its center, axis and radius"));
|
||||
cmd->setStatusTip(cmd->toolTip());
|
||||
}
|
||||
|
||||
bool CmdFemPostFunctions::isActive()
|
||||
|
||||
197
src/Mod/Fem/Gui/CylinderWidget.ui
Normal file
197
src/Mod/Fem/Gui/CylinderWidget.ui
Normal file
@@ -0,0 +1,197 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CylinderWidget</class>
|
||||
<widget class="QWidget" name="CylinderWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>280</width>
|
||||
<height>85</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>x</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>y</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>z</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Center</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::PrefQuantitySpinBox" name="centerX">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="Gui::PrefQuantitySpinBox" name="centerY">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="Gui::PrefQuantitySpinBox" name="centerZ">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Axis</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::PrefQuantitySpinBox" name="axisX">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="Gui::PrefQuantitySpinBox" name="axisY">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="Gui::PrefQuantitySpinBox" name="axisZ">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Radius</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::PrefQuantitySpinBox" name="radius">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::QuantitySpinBox</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Gui/QuantitySpinBox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::PrefQuantitySpinBox</class>
|
||||
<extends>Gui::QuantitySpinBox</extends>
|
||||
<header>Gui/PrefWidgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -57,6 +57,7 @@
|
||||
#include "FemSettings.h"
|
||||
#include "TaskPostBoxes.h"
|
||||
|
||||
#include "ui_CylinderWidget.h"
|
||||
#include "ui_PlaneWidget.h"
|
||||
#include "ui_SphereWidget.h"
|
||||
|
||||
@@ -378,6 +379,164 @@ void ViewProviderFemPostFunction::onChanged(const App::Property* prop) {
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
PROPERTY_SOURCE(FemGui::ViewProviderFemPostCylinderFunction, FemGui::ViewProviderFemPostFunction)
|
||||
|
||||
ViewProviderFemPostCylinderFunction::ViewProviderFemPostCylinderFunction()
|
||||
{
|
||||
sPixmap = "fem-post-geo-cylinder";
|
||||
|
||||
setAutoScale(false);
|
||||
|
||||
getGeometryNode()->addChild(ShapeNodes::postCylinder());
|
||||
}
|
||||
|
||||
ViewProviderFemPostCylinderFunction::~ViewProviderFemPostCylinderFunction()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewProviderFemPostCylinderFunction::draggerUpdate(SoDragger* m)
|
||||
{
|
||||
Fem::FemPostCylinderFunction* func = static_cast<Fem::FemPostCylinderFunction*>(getObject());
|
||||
SoJackDragger* dragger = static_cast<SoJackDragger*>(m);
|
||||
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]);
|
||||
func->Axis.setValue(norm[0], norm[1], norm[2]);
|
||||
}
|
||||
|
||||
void ViewProviderFemPostCylinderFunction::updateData(const App::Property* p) {
|
||||
|
||||
Fem::FemPostCylinderFunction* func = static_cast<Fem::FemPostCylinderFunction*>(getObject());
|
||||
if (!isDragging() && (p == &func->Center || p == &func->Radius || p == &func->Axis)) {
|
||||
Base::Vector3d trans = func->Center.getValue();
|
||||
Base::Vector3d axis = func->Axis.getValue();
|
||||
double radius = func->Radius.getValue();
|
||||
|
||||
SbMatrix translate;
|
||||
SbRotation rot(SbVec3f(0,0,1), SbVec3f(axis.x, axis.y, axis.z));
|
||||
translate.setTransform(SbVec3f(trans.x, trans.y, trans.z), rot, SbVec3f(radius,radius,radius));
|
||||
getManipulator()->setMatrix(translate);
|
||||
}
|
||||
|
||||
Gui::ViewProviderDocumentObject::updateData(p);
|
||||
}
|
||||
|
||||
SoTransformManip* ViewProviderFemPostCylinderFunction::setupManipulator()
|
||||
{
|
||||
return new SoJackManip;
|
||||
}
|
||||
|
||||
FunctionWidget* ViewProviderFemPostCylinderFunction::createControlWidget()
|
||||
{
|
||||
return new CylinderWidget();
|
||||
}
|
||||
|
||||
CylinderWidget::CylinderWidget()
|
||||
{
|
||||
ui = new Ui_CylinderWidget();
|
||||
ui->setupUi(this);
|
||||
|
||||
QSize size = ui->centerX->sizeForText(QStringLiteral("000000000000"));
|
||||
ui->centerX->setMinimumWidth(size.width());
|
||||
ui->centerY->setMinimumWidth(size.width());
|
||||
ui->centerZ->setMinimumWidth(size.width());
|
||||
ui->axisX->setMinimumWidth(size.width());
|
||||
ui->axisY->setMinimumWidth(size.width());
|
||||
ui->axisZ->setMinimumWidth(size.width());
|
||||
ui->radius->setMinimumWidth(size.width());
|
||||
|
||||
int UserDecimals = Base::UnitsApi::getDecimals();
|
||||
ui->centerX->setDecimals(UserDecimals);
|
||||
ui->centerY->setDecimals(UserDecimals);
|
||||
ui->centerZ->setDecimals(UserDecimals);
|
||||
ui->axisX->setDecimals(UserDecimals);
|
||||
ui->axisY->setDecimals(UserDecimals);
|
||||
ui->axisZ->setDecimals(UserDecimals);
|
||||
|
||||
connect(ui->centerX, qOverload<double>(&Gui::QuantitySpinBox::valueChanged), this, &CylinderWidget::centerChanged);
|
||||
connect(ui->centerY, qOverload<double>(&Gui::QuantitySpinBox::valueChanged), this, &CylinderWidget::centerChanged);
|
||||
connect(ui->centerZ, qOverload<double>(&Gui::QuantitySpinBox::valueChanged), this, &CylinderWidget::centerChanged);
|
||||
connect(ui->axisX, qOverload<double>(&Gui::QuantitySpinBox::valueChanged), this, &CylinderWidget::axisChanged);
|
||||
connect(ui->axisY, qOverload<double>(&Gui::QuantitySpinBox::valueChanged), this, &CylinderWidget::axisChanged);
|
||||
connect(ui->axisZ, qOverload<double>(&Gui::QuantitySpinBox::valueChanged), this, &CylinderWidget::axisChanged);
|
||||
connect(ui->radius, qOverload<double>(&Gui::QuantitySpinBox::valueChanged), this, &CylinderWidget::radiusChanged);
|
||||
}
|
||||
|
||||
CylinderWidget::~CylinderWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void CylinderWidget::applyPythonCode()
|
||||
{
|
||||
}
|
||||
|
||||
void CylinderWidget::setViewProvider(ViewProviderFemPostFunction* view)
|
||||
{
|
||||
FemGui::FunctionWidget::setViewProvider(view);
|
||||
setBlockObjectUpdates(true);
|
||||
Base::Unit unit = static_cast<Fem::FemPostCylinderFunction*>(getObject())->Center.getUnit();
|
||||
ui->centerX->setUnit(unit);
|
||||
ui->centerY->setUnit(unit);
|
||||
ui->centerZ->setUnit(unit);
|
||||
unit = static_cast<Fem::FemPostCylinderFunction*>(getObject())->Radius.getUnit();
|
||||
ui->radius->setUnit(unit);
|
||||
setBlockObjectUpdates(false);
|
||||
onChange(static_cast<Fem::FemPostCylinderFunction*>(getObject())->Center);
|
||||
onChange(static_cast<Fem::FemPostCylinderFunction*>(getObject())->Radius);
|
||||
onChange(static_cast<Fem::FemPostCylinderFunction*>(getObject())->Axis);
|
||||
}
|
||||
|
||||
void CylinderWidget::onChange(const App::Property& p)
|
||||
{
|
||||
setBlockObjectUpdates(true);
|
||||
if (strcmp(p.getName(), "Axis") == 0) {
|
||||
const Base::Vector3d& vec = static_cast<const App::PropertyVector*>(&p)->getValue();
|
||||
ui->axisX->setValue(vec.x);
|
||||
ui->axisY->setValue(vec.y);
|
||||
ui->axisZ->setValue(vec.z);
|
||||
}
|
||||
else if (strcmp(p.getName(), "Center") == 0) {
|
||||
const Base::Vector3d& vec = static_cast<const App::PropertyVectorDistance*>(&p)->getValue();
|
||||
ui->centerX->setValue(vec.x);
|
||||
ui->centerY->setValue(vec.y);
|
||||
ui->centerZ->setValue(vec.z);
|
||||
}
|
||||
else if (strcmp(p.getName(), "Radius") == 0) {
|
||||
double val = static_cast<const App::PropertyDistance*>(&p)->getValue();
|
||||
ui->radius->setValue(val);
|
||||
}
|
||||
setBlockObjectUpdates(false);
|
||||
}
|
||||
|
||||
void CylinderWidget::centerChanged(double) {
|
||||
if (!blockObjectUpdates()) {
|
||||
Base::Vector3d vec(ui->centerX->value().getValue(), ui->centerY->value().getValue(),
|
||||
ui->centerZ->value().getValue());
|
||||
static_cast<Fem::FemPostCylinderFunction*>(getObject())->Center.setValue(vec);
|
||||
}
|
||||
}
|
||||
|
||||
void CylinderWidget::axisChanged(double)
|
||||
{
|
||||
if (!blockObjectUpdates()) {
|
||||
Base::Vector3d vec(ui->axisX->value().getValue(), ui->axisY->value().getValue(),
|
||||
ui->axisZ->value().getValue());
|
||||
static_cast<Fem::FemPostCylinderFunction*>(getObject())->Axis.setValue(vec);
|
||||
}
|
||||
}
|
||||
|
||||
void CylinderWidget::radiusChanged(double)
|
||||
{
|
||||
if (!blockObjectUpdates()) {
|
||||
static_cast<Fem::FemPostCylinderFunction*>(getObject())->Radius.setValue(ui->radius->value().getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
|
||||
PROPERTY_SOURCE(FemGui::ViewProviderFemPostPlaneFunction, FemGui::ViewProviderFemPostFunction)
|
||||
@@ -395,16 +554,7 @@ ViewProviderFemPostPlaneFunction::ViewProviderFemPostPlaneFunction()
|
||||
setAutoScale(true);
|
||||
|
||||
//setup the visualisation geometry
|
||||
SoCoordinate3* points = new SoCoordinate3();
|
||||
points->point.setNum(4);
|
||||
points->point.set1Value(0, -0.5, -0.5, 0);
|
||||
points->point.set1Value(1, -0.5, 0.5, 0);
|
||||
points->point.set1Value(2, 0.5, 0.5, 0);
|
||||
points->point.set1Value(3, 0.5, -0.5, 0);
|
||||
points->point.set1Value(4, -0.5, -0.5, 0);
|
||||
SoLineSet* line = new SoLineSet();
|
||||
getGeometryNode()->addChild(points);
|
||||
getGeometryNode()->addChild(line);
|
||||
getGeometryNode()->addChild(ShapeNodes::postPlane());
|
||||
}
|
||||
|
||||
ViewProviderFemPostPlaneFunction::~ViewProviderFemPostPlaneFunction() {
|
||||
@@ -588,29 +738,7 @@ ViewProviderFemPostSphereFunction::ViewProviderFemPostSphereFunction() {
|
||||
setAutoScale(false);
|
||||
|
||||
//setup the visualisation geometry
|
||||
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);
|
||||
getGeometryNode()->addChild(ShapeNodes::postSphere());
|
||||
}
|
||||
|
||||
ViewProviderFemPostSphereFunction::~ViewProviderFemPostSphereFunction() {
|
||||
@@ -747,4 +875,109 @@ void SphereWidget::radiusChanged(double) {
|
||||
}
|
||||
}
|
||||
|
||||
namespace FemGui
|
||||
{
|
||||
|
||||
namespace ShapeNodes
|
||||
{
|
||||
|
||||
SoGroup* postCylinder()
|
||||
{
|
||||
SoCoordinate3* points = new SoCoordinate3();
|
||||
int nCirc = 20;
|
||||
int nSide = 8;
|
||||
float h = 3.;
|
||||
points->point.setNum(2*(nCirc + 1 + nSide));
|
||||
|
||||
int idx = 0;
|
||||
// top and bottom
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < nCirc + 1; ++j) {
|
||||
points->point.set1Value(idx, SbVec3f(std::cos(2*M_PI/nCirc*j),
|
||||
std::sin(2*M_PI/nCirc*j),
|
||||
-h/2. + h*i));
|
||||
++idx;
|
||||
}
|
||||
|
||||
}
|
||||
// sides
|
||||
for (int i = 0; i < nSide; ++i) {
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
points->point.set1Value(idx, SbVec3f(std::cos(2*M_PI/nSide*i),
|
||||
std::sin(2*M_PI/nSide*i),
|
||||
-h/2. + h*j));
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
// numVertices
|
||||
int vert[nSide + 2];
|
||||
vert[0] = nCirc + 1;
|
||||
vert[1] = nCirc + 1;
|
||||
for (int i = 0; i < nSide; ++i) {
|
||||
vert[i+2] = 2;
|
||||
}
|
||||
|
||||
SoLineSet* line = new SoLineSet();
|
||||
SoGroup* group = new SoGroup();
|
||||
line->numVertices.setValues(0,nSide + 2, vert);
|
||||
|
||||
group->addChild(points);
|
||||
group->addChild(line);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
SoGroup* postPlane()
|
||||
{
|
||||
SoCoordinate3* points = new SoCoordinate3();
|
||||
points->point.setNum(4);
|
||||
points->point.set1Value(0, -0.5, -0.5, 0);
|
||||
points->point.set1Value(1, -0.5, 0.5, 0);
|
||||
points->point.set1Value(2, 0.5, 0.5, 0);
|
||||
points->point.set1Value(3, 0.5, -0.5, 0);
|
||||
points->point.set1Value(4, -0.5, -0.5, 0);
|
||||
SoGroup* group = new SoGroup();
|
||||
SoLineSet* line = new SoLineSet();
|
||||
|
||||
group->addChild(points);
|
||||
group->addChild(line);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
SoGroup* postSphere()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
SoGroup* group = new SoGroup();
|
||||
SoLineSet* line = new SoLineSet();
|
||||
|
||||
group->addChild(points);
|
||||
group->addChild(line);
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
} //namespace ShapeNodes
|
||||
|
||||
} //namespace FemGui
|
||||
|
||||
#include "moc_ViewProviderFemPostFunction.cpp"
|
||||
|
||||
@@ -31,13 +31,15 @@
|
||||
#include <Mod/Fem/App/FemPostFunction.h>
|
||||
|
||||
|
||||
class SoComposeMatrix;
|
||||
class SoDragger;
|
||||
class SoGroup;
|
||||
class SoMatrixTransform;
|
||||
class SoScale;
|
||||
class SoSphere;
|
||||
class SoSurroundScale;
|
||||
class SoTransformManip;
|
||||
class SoComposeMatrix;
|
||||
class SoMatrixTransform;
|
||||
class SoDragger;
|
||||
class SoSphere;
|
||||
class Ui_CylinderWidget;
|
||||
class Ui_PlaneWidget;
|
||||
class Ui_SphereWidget;
|
||||
|
||||
@@ -151,6 +153,43 @@ private:
|
||||
bool m_autoscale, m_isDragging, m_autoRecompute;
|
||||
};
|
||||
|
||||
// ***************************************************************************
|
||||
class FemGuiExport CylinderWidget : public FunctionWidget {
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
CylinderWidget();
|
||||
~CylinderWidget() override;
|
||||
|
||||
void applyPythonCode() override;
|
||||
void onChange(const App::Property& p) override;
|
||||
void setViewProvider(ViewProviderFemPostFunction* view) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void centerChanged(double);
|
||||
void axisChanged(double);
|
||||
void radiusChanged(double);
|
||||
|
||||
private:
|
||||
Ui_CylinderWidget* ui;
|
||||
};
|
||||
|
||||
class FemGuiExport ViewProviderFemPostCylinderFunction : public ViewProviderFemPostFunction
|
||||
{
|
||||
PROPERTY_HEADER_WITH_OVERRIDE(FemGui::ViewProviderFemPostCylinderFunction);
|
||||
|
||||
public:
|
||||
ViewProviderFemPostCylinderFunction();
|
||||
~ViewProviderFemPostCylinderFunction() override;
|
||||
|
||||
SoTransformManip* setupManipulator() override;
|
||||
FunctionWidget* createControlWidget() override;
|
||||
|
||||
protected:
|
||||
void draggerUpdate(SoDragger* mat) override;
|
||||
void updateData(const App::Property*) override;
|
||||
};
|
||||
|
||||
|
||||
// ***************************************************************************
|
||||
class FemGuiExport PlaneWidget : public FunctionWidget {
|
||||
@@ -231,6 +270,15 @@ protected:
|
||||
void updateData(const App::Property*) override;
|
||||
};
|
||||
|
||||
namespace ShapeNodes
|
||||
{
|
||||
|
||||
SoGroup* postCylinder();
|
||||
SoGroup* postPlane();
|
||||
SoGroup* postSphere();
|
||||
|
||||
} //namespace ShapeNodes
|
||||
|
||||
} //namespace FemGui
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user