[PD and Part] add possibility to create skew prisms
This commit is contained in:
@@ -532,9 +532,14 @@ PROPERTY_SOURCE(PartDesign::Prism, PartDesign::FeaturePrimitive)
|
||||
|
||||
Prism::Prism()
|
||||
{
|
||||
ADD_PROPERTY_TYPE(Polygon,(6.0),"Prism",App::Prop_None,"Number of sides in the polygon, of the prism");
|
||||
ADD_PROPERTY_TYPE(Circumradius,(2.0),"Prism",App::Prop_None,"Circumradius (centre to vertex) of the polygon, of the prism");
|
||||
ADD_PROPERTY_TYPE(Height,(10.0f),"Prism",App::Prop_None,"The height of the prism");
|
||||
ADD_PROPERTY_TYPE(Polygon, (6.0), "Prism", App::Prop_None, "Number of sides in the polygon, of the prism");
|
||||
ADD_PROPERTY_TYPE(Circumradius, (2.0), "Prism", App::Prop_None, "Circumradius (centre to vertex) of the polygon, of the prism");
|
||||
ADD_PROPERTY_TYPE(Height, (10.0f), "Prism", App::Prop_None, "The height of the prism");
|
||||
ADD_PROPERTY_TYPE(FirstSkew, (0.0f), "Prism", App::Prop_None, "Angle in first direction");
|
||||
ADD_PROPERTY_TYPE(SecondSkew, (0.0f), "Prism", App::Prop_None, "Angle in second direction");
|
||||
static const App::PropertyQuantityConstraint::Constraints angleConstraint = { -89.99999, 89.99999, 1.0 };
|
||||
FirstSkew.setConstraints(&angleConstraint);
|
||||
SecondSkew.setConstraints(&angleConstraint);
|
||||
|
||||
primitiveType = FeaturePrimitive::Prism;
|
||||
}
|
||||
@@ -563,11 +568,14 @@ App::DocumentObjectExecReturn* Prism::execute(void)
|
||||
}
|
||||
mkPoly.Add(gp_Pnt(v.x,v.y,v.z));
|
||||
BRepBuilderAPI_MakeFace mkFace(mkPoly.Wire());
|
||||
BRepPrimAPI_MakePrism mkPrism(mkFace.Face(), gp_Vec(0,0,Height.getValue()));
|
||||
// the direction vector for the prism is the height for z and the skew
|
||||
BRepPrimAPI_MakePrism mkPrism(mkFace.Face(),
|
||||
gp_Vec(Height.getValue() * tan(Base::toRadians<double>(FirstSkew.getValue())),
|
||||
Height.getValue() * tan(Base::toRadians<double>(SecondSkew.getValue())),
|
||||
Height.getValue()));
|
||||
return FeaturePrimitive::execute(mkPrism.Shape());
|
||||
}
|
||||
catch (Standard_Failure& e) {
|
||||
|
||||
return new App::DocumentObjectExecReturn(e.GetMessageString());
|
||||
}
|
||||
|
||||
@@ -582,6 +590,10 @@ short int Prism::mustExecute() const
|
||||
return 1;
|
||||
if (Height.isTouched())
|
||||
return 1;
|
||||
if (FirstSkew.isTouched())
|
||||
return 1;
|
||||
if (SecondSkew.isTouched())
|
||||
return 1;
|
||||
|
||||
return FeaturePrimitive::mustExecute();
|
||||
}
|
||||
|
||||
@@ -318,6 +318,8 @@ public:
|
||||
App::PropertyIntegerConstraint Polygon;
|
||||
App::PropertyLength Circumradius;
|
||||
App::PropertyLength Height;
|
||||
App::PropertyAngle FirstSkew;
|
||||
App::PropertyAngle SecondSkew;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
|
||||
@@ -24,30 +24,30 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
# include <Precision.hxx>
|
||||
# include <QMessageBox>
|
||||
# include <QRegExp>
|
||||
# include <QTextStream>
|
||||
# include <QMessageBox>
|
||||
# include <Precision.hxx>
|
||||
# include <sstream>
|
||||
#endif
|
||||
|
||||
#include "TaskPrimitiveParameters.h"
|
||||
#include "ui_TaskPrimitiveParameters.h"
|
||||
#include "ViewProviderDatumCS.h"
|
||||
#include <Mod/PartDesign/App/FeaturePrimitive.h>
|
||||
#include <Mod/PartDesign/App/DatumCS.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include <Mod/Part/App/DatumFeature.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/ViewProviderOrigin.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
#include <App/Origin.h>
|
||||
|
||||
#include <App/Origin.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/ViewProviderOrigin.h>
|
||||
#include <Mod/Part/App/DatumFeature.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include <Mod/PartDesign/App/DatumCS.h>
|
||||
#include <Mod/PartDesign/App/FeaturePrimitive.h>
|
||||
|
||||
using namespace PartDesignGui;
|
||||
|
||||
@@ -192,6 +192,10 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent)
|
||||
ui->prismCircumradius->bind(static_cast<PartDesign::Prism*>(vp->getObject())->Circumradius);
|
||||
ui->prismHeight->setValue(static_cast<PartDesign::Prism*>(vp->getObject())->Height.getValue());
|
||||
ui->prismHeight->bind(static_cast<PartDesign::Prism*>(vp->getObject())->Height);
|
||||
ui->prismXSkew->setValue(static_cast<PartDesign::Prism*>(vp->getObject())->FirstSkew.getValue());
|
||||
ui->prismXSkew->bind(static_cast<PartDesign::Prism*>(vp->getObject())->FirstSkew);
|
||||
ui->prismYSkew->setValue(static_cast<PartDesign::Prism*>(vp->getObject())->SecondSkew.getValue());
|
||||
ui->prismYSkew->bind(static_cast<PartDesign::Prism*>(vp->getObject())->SecondSkew);
|
||||
ui->prismCircumradius->setMaximum(INT_MAX);
|
||||
ui->prismCircumradius->setMinimum(0.0);
|
||||
ui->prismHeight->setMaximum(INT_MAX);
|
||||
@@ -306,6 +310,8 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent)
|
||||
//prism
|
||||
connect(ui->prismCircumradius, SIGNAL(valueChanged(double)), this, SLOT(onPrismCircumradiusChanged(double)));
|
||||
connect(ui->prismHeight, SIGNAL(valueChanged(double)), this, SLOT(onPrismHeightChanged(double)));
|
||||
connect(ui->prismXSkew, SIGNAL(valueChanged(double)), this, SLOT(onPrismXSkewChanged(double)));
|
||||
connect(ui->prismYSkew, SIGNAL(valueChanged(double)), this, SLOT(onPrismYSkewChanged(double)));
|
||||
connect(ui->prismPolygon, SIGNAL(valueChanged(int)), this, SLOT(onPrismPolygonChanged(int)));
|
||||
|
||||
// wedge
|
||||
@@ -520,6 +526,40 @@ void TaskBoxPrimitives::onPrismHeightChanged(double v) {
|
||||
vp->getObject()->getDocument()->recomputeFeature(vp->getObject());
|
||||
}
|
||||
|
||||
void TaskBoxPrimitives::onPrismXSkewChanged(double v) {
|
||||
PartDesign::Prism* sph = static_cast<PartDesign::Prism*>(vp->getObject());
|
||||
// we must assure that if the user incremented from e.g. 85 degree with the
|
||||
// spin buttons he does not end at 90.0 but 89.9999 which is shown rounded to 90 degree
|
||||
if ((v < 90.0) && (v > -90.0)) {
|
||||
sph->FirstSkew.setValue(v);
|
||||
}
|
||||
else {
|
||||
if (v == 90.0)
|
||||
sph->FirstSkew.setValue(89.99999);
|
||||
else if (v == -90.0)
|
||||
sph->FirstSkew.setValue(-89.99999);
|
||||
ui->prismXSkew->setValue(sph->FirstSkew.getQuantityValue());
|
||||
}
|
||||
vp->getObject()->getDocument()->recomputeFeature(vp->getObject());
|
||||
}
|
||||
|
||||
void TaskBoxPrimitives::onPrismYSkewChanged(double v) {
|
||||
PartDesign::Prism* sph = static_cast<PartDesign::Prism*>(vp->getObject());
|
||||
// we must assure that if the user incremented from e.g. 85 degree with the
|
||||
// spin buttons he does not end at 90.0 but 89.9999 which is shown rounded to 90 degree
|
||||
if ((v < 90.0) && (v > -90.0)) {
|
||||
sph->SecondSkew.setValue(v);
|
||||
}
|
||||
else {
|
||||
if (v == 90.0)
|
||||
sph->SecondSkew.setValue(89.99999);
|
||||
else if (v == -90.0)
|
||||
sph->SecondSkew.setValue(-89.99999);
|
||||
ui->prismYSkew->setValue(sph->SecondSkew.getQuantityValue());
|
||||
}
|
||||
vp->getObject()->getDocument()->recomputeFeature(vp->getObject());
|
||||
}
|
||||
|
||||
void TaskBoxPrimitives::onPrismPolygonChanged(int v) {
|
||||
PartDesign::Prism* sph = static_cast<PartDesign::Prism*>(vp->getObject());
|
||||
sph->Polygon.setValue(v);
|
||||
@@ -692,11 +732,15 @@ void TaskBoxPrimitives::setPrimitive(App::DocumentObject *obj)
|
||||
cmd = QString::fromLatin1(
|
||||
"%1.Polygon=%2\n"
|
||||
"%1.Circumradius=%3\n"
|
||||
"%1.Height=%4\n")
|
||||
"%1.Height=%4\n"
|
||||
"%1.FirstSkew=%5\n"
|
||||
"%1.SecondSkew=%6\n")
|
||||
.arg(name)
|
||||
.arg(ui->prismPolygon->value())
|
||||
.arg(ui->prismCircumradius->value().getValue(),0,'f',Base::UnitsApi::getDecimals())
|
||||
.arg(ui->prismHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals());
|
||||
.arg(ui->prismCircumradius->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals())
|
||||
.arg(ui->prismHeight->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals())
|
||||
.arg(ui->prismXSkew->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals())
|
||||
.arg(ui->prismYSkew->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals());
|
||||
break;
|
||||
case 8: // wedge
|
||||
cmd = QString::fromLatin1(
|
||||
|
||||
@@ -85,6 +85,8 @@ public Q_SLOTS:
|
||||
void onTorusAngle3Changed(double);
|
||||
void onPrismCircumradiusChanged(double);
|
||||
void onPrismHeightChanged(double);
|
||||
void onPrismXSkewChanged(double);
|
||||
void onPrismYSkewChanged(double);
|
||||
void onPrismPolygonChanged(int);
|
||||
void onWedgeXmaxChanged(double);
|
||||
void onWedgeXminChanged(double);
|
||||
|
||||
@@ -1200,6 +1200,58 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelXSkew">
|
||||
<property name="text">
|
||||
<string>Angle in first direction:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="Gui::QuantitySpinBox" name="prismXSkew">
|
||||
<property name="toolTip">
|
||||
<string>Angle in first direction</string>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">deg</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-90.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>90.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelYSkew">
|
||||
<property name="text">
|
||||
<string>Angle in second direction:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="Gui::QuantitySpinBox" name="prismYSkew">
|
||||
<property name="toolTip">
|
||||
<string>Angle in second direction</string>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">deg</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-90.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>90.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
@@ -1264,6 +1316,9 @@
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="wedgeXmin">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
@@ -1284,6 +1339,9 @@
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="wedgeYmin">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
@@ -1304,6 +1362,9 @@
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="wedgeZmin">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
@@ -1324,6 +1385,9 @@
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="wedgeX2min">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
@@ -1347,6 +1411,9 @@
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="wedgeZ2min">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true">mm</string>
|
||||
</property>
|
||||
@@ -2158,6 +2225,9 @@
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="regularPolygonPolygon">
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>3</number>
|
||||
</property>
|
||||
|
||||
Reference in New Issue
Block a user