+ 0000452: in "Part" added create "vertex" to the create primitives dialgue gui
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5049 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
parent
87ca80eb7f
commit
b005a7cf0b
|
@ -156,6 +156,7 @@ void PartExport initPart()
|
|||
Part::CurveNet ::init();
|
||||
Part::Polygon ::init();
|
||||
Part::Circle ::init();
|
||||
Part::Vertex ::init();
|
||||
Part::Ellipsoid ::init();
|
||||
Part::Plane ::init();
|
||||
Part::Sphere ::init();
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
# include <BRepPrim_Wedge.hxx>
|
||||
# include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
# include <BRepBuilderAPI_MakeFace.hxx>
|
||||
# include <BRepBuilderAPI_MakeVertex.hxx>
|
||||
# include <BRepBuilderAPI_MakeWire.hxx>
|
||||
# include <BRepBuilderAPI_GTransform.hxx>
|
||||
# include <gp_Circ.hxx>
|
||||
|
@ -49,7 +50,9 @@
|
|||
# include <Handle_Geom2d_TrimmedCurve.hxx>
|
||||
# include <Precision.hxx>
|
||||
# include <Standard_Real.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopoDS_Solid.hxx>
|
||||
# include <TopoDS_Vertex.hxx>
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -106,6 +109,58 @@ void Primitive::onChanged(const App::Property* prop)
|
|||
Part::Feature::onChanged(prop);
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Part::Vertex, Part::Primitive)
|
||||
|
||||
Vertex::Vertex()
|
||||
{
|
||||
ADD_PROPERTY(X,(0.0f));
|
||||
ADD_PROPERTY(Y,(0.0f));
|
||||
ADD_PROPERTY(Z,(0.0f));
|
||||
}
|
||||
|
||||
Vertex::~Vertex()
|
||||
{
|
||||
}
|
||||
|
||||
short Vertex::mustExecute() const
|
||||
{
|
||||
if (X.isTouched() ||
|
||||
Y.isTouched() ||
|
||||
Z.isTouched())
|
||||
return 1;
|
||||
return Part::Feature::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Vertex::execute(void)
|
||||
{
|
||||
gp_Pnt point;
|
||||
point.SetX(this->X.getValue());
|
||||
point.SetY(this->Y.getValue());
|
||||
point.SetZ(this->Z.getValue());
|
||||
|
||||
BRepBuilderAPI_MakeVertex MakeVertex(point);
|
||||
const TopoDS_Vertex& vertex = MakeVertex.Vertex();
|
||||
this->Shape.setValue(vertex);
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
|
||||
void Vertex::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (!isRestoring()) {
|
||||
if (prop == &X || prop == &Y || prop == &Z){
|
||||
try {
|
||||
App::DocumentObjectExecReturn *ret = recompute();
|
||||
delete ret;
|
||||
}
|
||||
catch (...) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Part::Feature::onChanged(prop);
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Part::Plane, Part::Primitive)
|
||||
|
||||
Plane::Plane()
|
||||
|
|
|
@ -49,6 +49,27 @@ protected:
|
|||
void onChanged (const App::Property* prop);
|
||||
};
|
||||
|
||||
class PartExport Vertex : public Part::Primitive
|
||||
{
|
||||
PROPERTY_HEADER(Part::Vertex);
|
||||
|
||||
public:
|
||||
Vertex();
|
||||
virtual ~Vertex();
|
||||
|
||||
App::PropertyFloat X;
|
||||
App::PropertyFloat Y;
|
||||
App::PropertyFloat Z;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the Feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
void onChanged(const App::Property*);
|
||||
//@}
|
||||
};
|
||||
|
||||
class PartExport Plane : public Primitive
|
||||
{
|
||||
PROPERTY_HEADER(Part::Plane);
|
||||
|
|
|
@ -104,6 +104,13 @@ DlgPrimitives::DlgPrimitives(QWidget* parent, Qt::WFlags fl)
|
|||
ui.helixRadius->setMaximum(INT_MAX);
|
||||
// circle
|
||||
ui.circleRadius->setMaximum(INT_MAX);
|
||||
// vertex
|
||||
ui.VertexXAxisValue->setMaximum(INT_MAX);
|
||||
ui.VertexYAxisValue->setMaximum(INT_MAX);
|
||||
ui.VertexZAxisValue->setMaximum(INT_MAX);
|
||||
ui.VertexXAxisValue->setMinimum(-INT_MAX);
|
||||
ui.VertexYAxisValue->setMinimum(-INT_MAX);
|
||||
ui.VertexZAxisValue->setMinimum(-INT_MAX);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -365,8 +372,21 @@ void DlgPrimitives::accept()
|
|||
.arg(ui.circleAngle1->value(),0,'f',2)
|
||||
.arg(this->toPlacement());
|
||||
}
|
||||
else if (ui.comboBox1->currentIndex() == 10) { // vertex
|
||||
name = QString::fromAscii(doc->getUniqueObjectName("Vertex").c_str());
|
||||
cmd = QString::fromAscii(
|
||||
"App.ActiveDocument.addObject(\"Part::Vertex\",\"%1\")\n"
|
||||
"App.ActiveDocument.%1.X=%2\n"
|
||||
"App.ActiveDocument.%1.Y=%3\n"
|
||||
"App.ActiveDocument.%1.Z=%4\n"
|
||||
"App.ActiveDocument.%1.Placement=%5\n")
|
||||
.arg(name)
|
||||
.arg(ui.VertexXAxisValue->value(),0,'f',2)
|
||||
.arg(ui.VertexYAxisValue->value(),0,'f',2)
|
||||
.arg(ui.VertexZAxisValue->value(),0,'f',2)
|
||||
.arg(this->toPlacement());
|
||||
}
|
||||
|
||||
|
||||
// Execute the Python block
|
||||
QString prim = tr("Create %1").arg(ui.comboBox1->currentText());
|
||||
Gui::Application::Instance->activeDocument()->openCommand(prim.toUtf8());
|
||||
|
|
|
@ -107,7 +107,7 @@
|
|||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<widget class="QWidget" name="page0_plane">
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
|
@ -177,7 +177,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="WStackPage1">
|
||||
<widget class="QWidget" name="Page1_box">
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
|
@ -267,7 +267,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="WStackPage2">
|
||||
<widget class="QWidget" name="Page2_cylinder">
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
|
@ -374,7 +374,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="WStackPage3">
|
||||
<widget class="QWidget" name="Page3_cone">
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
|
@ -498,7 +498,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="WStackPage4">
|
||||
<widget class="QWidget" name="Page4_sphere">
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
|
@ -637,7 +637,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="WStackPage5">
|
||||
<widget class="QWidget" name="Page5_ellipsoid">
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
|
@ -790,7 +790,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="WStackPage6">
|
||||
<widget class="QWidget" name="Page6_torus">
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
|
@ -946,7 +946,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_3">
|
||||
<widget class="QWidget" name="page7_wedge">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
|
@ -1078,7 +1078,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_2">
|
||||
<widget class="QWidget" name="page8_helix">
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
|
@ -1185,7 +1185,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_4circle">
|
||||
<widget class="QWidget" name="page9_circle">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="circleParameters">
|
||||
|
@ -1269,6 +1269,59 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page10_vertex">
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>201</width>
|
||||
<height>76</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="VertexXAxisValue"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="VertexYAxisValue"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="VertexZAxisValue"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_X_Axis">
|
||||
<property name="text">
|
||||
<string>X Axis Value:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_Y_Axis">
|
||||
<property name="text">
|
||||
<string>Y Axis Value:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_Z_Axis">
|
||||
<property name="text">
|
||||
<string>Z Axis Value:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -1339,6 +1392,11 @@
|
|||
<string>Circle</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Vertex</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
|
@ -1366,21 +1424,21 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="TextLabel3">
|
||||
<widget class="QLabel" name="TextLabel_Z">
|
||||
<property name="text">
|
||||
<string>Z:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="TextLabel1">
|
||||
<widget class="QLabel" name="TextLabel_X">
|
||||
<property name="text">
|
||||
<string>X:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="TextLabel1_3">
|
||||
<widget class="QLabel" name="TextLabel_Direction">
|
||||
<property name="text">
|
||||
<string>Direction:</string>
|
||||
</property>
|
||||
|
@ -1397,7 +1455,7 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="TextLabel2">
|
||||
<widget class="QLabel" name="TextLabel_Y">
|
||||
<property name="text">
|
||||
<string>Y:</string>
|
||||
</property>
|
||||
|
|
Loading…
Reference in New Issue
Block a user