0000546: Ellipse added to create primitive dialogue
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5371 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
parent
f124396c78
commit
984ce43fb5
|
@ -156,6 +156,7 @@ void PartExport initPart()
|
|||
Part::CurveNet ::init();
|
||||
Part::Polygon ::init();
|
||||
Part::Circle ::init();
|
||||
Part::Ellipse ::init();
|
||||
Part::Vertex ::init();
|
||||
Part::Line ::init();
|
||||
Part::Ellipsoid ::init();
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
# include <BRepBuilderAPI_MakeSolid.hxx>
|
||||
# include <BRepBuilderAPI_GTransform.hxx>
|
||||
# include <gp_Circ.hxx>
|
||||
# include <gp_Elips.hxx>
|
||||
# include <gp_GTrsf.hxx>
|
||||
# include <GCE2d_MakeSegment.hxx>
|
||||
# include <Geom_Plane.hxx>
|
||||
|
@ -725,3 +726,61 @@ void Wedge::onChanged(const App::Property* prop)
|
|||
}
|
||||
Part::Primitive::onChanged(prop);
|
||||
}
|
||||
|
||||
App::PropertyFloatConstraint::Constraints Ellipse::angleRange = {0.0,360.0,1.0};
|
||||
|
||||
PROPERTY_SOURCE(Part::Ellipse, Part::Primitive)
|
||||
|
||||
|
||||
Ellipse::Ellipse()
|
||||
{
|
||||
ADD_PROPERTY(MajorRadius,(4.0f));
|
||||
ADD_PROPERTY(MinorRadius,(4.0f));
|
||||
ADD_PROPERTY(Angle0,(0.0f));
|
||||
Angle0.setConstraints(&angleRange);
|
||||
ADD_PROPERTY(Angle1,(360.0f));
|
||||
Angle1.setConstraints(&angleRange);
|
||||
}
|
||||
|
||||
Ellipse::~Ellipse()
|
||||
{
|
||||
}
|
||||
|
||||
short Ellipse::mustExecute() const
|
||||
{
|
||||
if (Angle0.isTouched() ||
|
||||
Angle1.isTouched() ||
|
||||
MajorRadius.isTouched() ||
|
||||
MinorRadius.isTouched())
|
||||
return 1;
|
||||
return Part::Feature::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Ellipse::execute(void)
|
||||
{
|
||||
gp_Elips ellipse;
|
||||
ellipse.SetMajorRadius(this->MajorRadius.getValue());
|
||||
ellipse.SetMinorRadius(this->MinorRadius.getValue());
|
||||
|
||||
BRepBuilderAPI_MakeEdge clMakeEdge(ellipse, Base::toRadians<double>(this->Angle0.getValue()),
|
||||
Base::toRadians<double>(this->Angle1.getValue()));
|
||||
const TopoDS_Edge& edge = clMakeEdge.Edge();
|
||||
this->Shape.setValue(edge);
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
void Ellipse::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (!isRestoring()) {
|
||||
if (prop == &MajorRadius || prop == &MinorRadius || prop == &Angle0 || prop == &Angle1){
|
||||
try {
|
||||
App::DocumentObjectExecReturn *ret = recompute();
|
||||
delete ret;
|
||||
}
|
||||
catch (...) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Part::Feature::onChanged(prop);
|
||||
}
|
||||
|
|
|
@ -265,6 +265,31 @@ protected:
|
|||
void onChanged(const App::Property* prop);
|
||||
};
|
||||
|
||||
class Ellipse : public Part::Primitive
|
||||
{
|
||||
PROPERTY_HEADER(Part::Ellipse);
|
||||
|
||||
public:
|
||||
Ellipse();
|
||||
virtual ~Ellipse();
|
||||
|
||||
App::PropertyFloat MajorRadius;
|
||||
App::PropertyFloat MinorRadius;
|
||||
App::PropertyAngle Angle0;
|
||||
App::PropertyAngle Angle1;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the Feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
void onChanged(const App::Property*);
|
||||
//@}
|
||||
|
||||
private:
|
||||
static App::PropertyFloatConstraint::Constraints angleRange;
|
||||
};
|
||||
|
||||
} //namespace Part
|
||||
|
||||
|
||||
|
|
|
@ -312,7 +312,23 @@ void DlgPrimitives::createPrimitive(const QString& placement)
|
|||
.arg(ui.circleAngle1->value(),0,'f',2)
|
||||
.arg(placement);
|
||||
}
|
||||
else if (ui.comboBox1->currentIndex() == 10) { // vertex
|
||||
else if (ui.comboBox1->currentIndex() == 10) { // ellipse
|
||||
name = QString::fromAscii(doc->getUniqueObjectName("Ellipse").c_str());
|
||||
cmd = QString::fromAscii(
|
||||
"App.ActiveDocument.addObject(\"Part::Ellipse\",\"%1\")\n"
|
||||
"App.ActiveDocument.%1.MajorRadius=%2\n"
|
||||
"App.ActiveDocument.%1.MinorRadius=%3\n"
|
||||
"App.ActiveDocument.%1.Angle0=%4\n"
|
||||
"App.ActiveDocument.%1.Angle1=%5\n"
|
||||
"App.ActiveDocument.%1.Placement=%6\n")
|
||||
.arg(name)
|
||||
.arg(ui.ellipseMajorRadius->value(),0,'f',2)
|
||||
.arg(ui.ellipseMinorRadius->value(),0,'f',2)
|
||||
.arg(ui.ellipseAngle0->value(),0,'f',2)
|
||||
.arg(ui.ellipseAngle1->value(),0,'f',2)
|
||||
.arg(placement);
|
||||
}
|
||||
else if (ui.comboBox1->currentIndex() == 11) { // vertex
|
||||
name = QString::fromAscii(doc->getUniqueObjectName("Vertex").c_str());
|
||||
cmd = QString::fromAscii(
|
||||
"App.ActiveDocument.addObject(\"Part::Vertex\",\"%1\")\n"
|
||||
|
@ -326,7 +342,7 @@ void DlgPrimitives::createPrimitive(const QString& placement)
|
|||
.arg(ui.vertexZ->value(),0,'f',2)
|
||||
.arg(placement);
|
||||
}
|
||||
else if (ui.comboBox1->currentIndex() == 11) { // line
|
||||
else if (ui.comboBox1->currentIndex() == 12) { // line
|
||||
name = QString::fromAscii(doc->getUniqueObjectName("Line").c_str());
|
||||
cmd = QString::fromAscii(
|
||||
"App.ActiveDocument.addObject(\"Part::Line\",\"%1\")\n"
|
||||
|
|
|
@ -84,6 +84,11 @@
|
|||
<string>Circle</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Ellipse</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Point</string>
|
||||
|
@ -1320,6 +1325,101 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page">
|
||||
<layout class="QGridLayout" name="gridLayout_11">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelEllMajorRadius">
|
||||
<property name="text">
|
||||
<string>Major radius:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="ellipseMajorRadius">
|
||||
<property name="maximum">
|
||||
<double>1000000000.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>4.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelEllMinorRadius">
|
||||
<property name="text">
|
||||
<string>Minor radius:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="ellipseMinorRadius">
|
||||
<property name="maximum">
|
||||
<double>1000000000.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>2.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelEllAngle1">
|
||||
<property name="text">
|
||||
<string>Angle 1:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="ellipseAngle0">
|
||||
<property name="maximum">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelEllAngle2">
|
||||
<property name="text">
|
||||
<string>Angle 2:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QDoubleSpinBox" name="ellipseAngle1">
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>360.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>131</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page10_vertex">
|
||||
<layout class="QGridLayout" name="gridLayout_9">
|
||||
<item row="0" column="0">
|
||||
|
|
Loading…
Reference in New Issue
Block a user