0000536: Parametric Edge in Part wb via create primitives dialogue gui
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5297 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
parent
b3156069ab
commit
431406a5aa
|
@ -157,6 +157,7 @@ void PartExport initPart()
|
|||
Part::Polygon ::init();
|
||||
Part::Circle ::init();
|
||||
Part::Vertex ::init();
|
||||
Part::Edge ::init();
|
||||
Part::Ellipsoid ::init();
|
||||
Part::Plane ::init();
|
||||
Part::Sphere ::init();
|
||||
|
|
|
@ -162,6 +162,70 @@ void Vertex::onChanged(const App::Property* prop)
|
|||
Part::Feature::onChanged(prop);
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Part::Edge, Part::Primitive)
|
||||
|
||||
Edge::Edge()
|
||||
{
|
||||
ADD_PROPERTY_TYPE(X1,(0.0f),"Vertex 1 - Start",App::Prop_None,"X value of the start vertex");
|
||||
ADD_PROPERTY_TYPE(Y1,(0.0f),"Vertex 1 - Start",App::Prop_None,"Y value of the Start vertex");
|
||||
ADD_PROPERTY_TYPE(Z1,(0.0f),"Vertex 1 - Start",App::Prop_None,"Z value of the Start vertex");
|
||||
ADD_PROPERTY_TYPE(X2,(0.0f),"Vertex 2 - Finish",App::Prop_None,"X value of the finish vertex");
|
||||
ADD_PROPERTY_TYPE(Y2,(0.0f),"Vertex 2 - Finish",App::Prop_None,"Y value of the finish vertex");
|
||||
ADD_PROPERTY_TYPE(Z2,(1.0f),"Vertex 2 - Finish",App::Prop_None,"Z value of the finish vertex");
|
||||
}
|
||||
|
||||
Edge::~Edge()
|
||||
{
|
||||
}
|
||||
|
||||
short Edge::mustExecute() const
|
||||
{
|
||||
if (X1.isTouched() ||
|
||||
Y1.isTouched() ||
|
||||
Z1.isTouched() ||
|
||||
X2.isTouched() ||
|
||||
Y2.isTouched() ||
|
||||
Z2.isTouched())
|
||||
return 1;
|
||||
return Part::Feature::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *Edge::execute(void)
|
||||
{
|
||||
gp_Pnt point1;
|
||||
point1.SetX(this->X1.getValue());
|
||||
point1.SetY(this->Y1.getValue());
|
||||
point1.SetZ(this->Z1.getValue());
|
||||
|
||||
gp_Pnt point2;
|
||||
point2.SetX(this->X2.getValue());
|
||||
point2.SetY(this->Y2.getValue());
|
||||
point2.SetZ(this->Z2.getValue());
|
||||
|
||||
BRepBuilderAPI_MakeEdge mkEdge(point1, point2);
|
||||
if (!mkEdge.IsDone())
|
||||
return new App::DocumentObjectExecReturn("Failed to create edge");
|
||||
const TopoDS_Edge& edge = mkEdge.Edge();
|
||||
this->Shape.setValue(edge);
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
void Edge::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (!isRestoring()) {
|
||||
if (prop == &X1 || prop == &Y1 || prop == &Z1 || prop == &X2 || prop == &Y2 || prop == &Z2){
|
||||
try {
|
||||
App::DocumentObjectExecReturn *ret = recompute();
|
||||
delete ret;
|
||||
}
|
||||
catch (...) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Part::Feature::onChanged(prop);
|
||||
}
|
||||
|
||||
PROPERTY_SOURCE(Part::Plane, Part::Primitive)
|
||||
|
||||
Plane::Plane()
|
||||
|
|
|
@ -69,6 +69,30 @@ public:
|
|||
void onChanged(const App::Property*);
|
||||
//@}
|
||||
};
|
||||
|
||||
class PartExport Edge : public Part::Primitive
|
||||
{
|
||||
PROPERTY_HEADER(Part::Edge);
|
||||
|
||||
public:
|
||||
Edge();
|
||||
virtual ~Edge();
|
||||
|
||||
App::PropertyFloat X1;
|
||||
App::PropertyFloat Y1;
|
||||
App::PropertyFloat Z1;
|
||||
App::PropertyFloat X2;
|
||||
App::PropertyFloat Y2;
|
||||
App::PropertyFloat Z2;
|
||||
|
||||
/** @name methods override feature */
|
||||
//@{
|
||||
/// recalculate the Feature
|
||||
App::DocumentObjectExecReturn *execute(void);
|
||||
short mustExecute() const;
|
||||
void onChanged(const App::Property*);
|
||||
//@}
|
||||
};
|
||||
|
||||
class PartExport Plane : public Primitive
|
||||
{
|
||||
|
|
|
@ -108,12 +108,25 @@ DlgPrimitives::DlgPrimitives(QWidget* parent, Qt::WFlags fl)
|
|||
// 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);
|
||||
ui.vertexX->setMaximum(INT_MAX);
|
||||
ui.vertexY->setMaximum(INT_MAX);
|
||||
ui.vertexZ->setMaximum(INT_MAX);
|
||||
ui.vertexX->setMinimum(INT_MIN);
|
||||
ui.vertexY->setMinimum(INT_MIN);
|
||||
ui.vertexZ->setMinimum(INT_MIN);
|
||||
// edge
|
||||
ui.edgeX1->setMaximum(INT_MAX);
|
||||
ui.edgeX1->setMinimum(INT_MIN);
|
||||
ui.edgeY1->setMaximum(INT_MAX);
|
||||
ui.edgeY1->setMinimum(INT_MIN);
|
||||
ui.edgeZ1->setMaximum(INT_MAX);
|
||||
ui.edgeZ1->setMinimum(INT_MIN);
|
||||
ui.edgeX2->setMaximum(INT_MAX);
|
||||
ui.edgeX2->setMinimum(INT_MIN);
|
||||
ui.edgeY2->setMaximum(INT_MAX);
|
||||
ui.edgeY2->setMinimum(INT_MIN);
|
||||
ui.edgeZ2->setMaximum(INT_MAX);
|
||||
ui.edgeZ2->setMinimum(INT_MIN);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -440,9 +453,29 @@ void DlgPrimitives::accept()
|
|||
"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(ui.vertexX->value(),0,'f',2)
|
||||
.arg(ui.vertexY->value(),0,'f',2)
|
||||
.arg(ui.vertexZ->value(),0,'f',2)
|
||||
.arg(this->toPlacement());
|
||||
}
|
||||
else if (ui.comboBox1->currentIndex() == 11) { // edge
|
||||
name = QString::fromAscii(doc->getUniqueObjectName("Edge").c_str());
|
||||
cmd = QString::fromAscii(
|
||||
"App.ActiveDocument.addObject(\"Part::Edge\",\"%1\")\n"
|
||||
"App.ActiveDocument.%1.X1=%2\n"
|
||||
"App.ActiveDocument.%1.Y1=%3\n"
|
||||
"App.ActiveDocument.%1.Z1=%4\n"
|
||||
"App.ActiveDocument.%1.X2=%5\n"
|
||||
"App.ActiveDocument.%1.Y2=%6\n"
|
||||
"App.ActiveDocument.%1.Z2=%7\n"
|
||||
"App.ActiveDocument.%1.Placement=%8\n")
|
||||
.arg(name)
|
||||
.arg(ui.edgeX1->value(),0,'f',2)
|
||||
.arg(ui.edgeY1->value(),0,'f',2)
|
||||
.arg(ui.edgeZ1->value(),0,'f',2)
|
||||
.arg(ui.edgeX2->value(),0,'f',2)
|
||||
.arg(ui.edgeY2->value(),0,'f',2)
|
||||
.arg(ui.edgeZ2->value(),0,'f',2)
|
||||
.arg(this->toPlacement());
|
||||
}
|
||||
|
||||
|
|
|
@ -1171,7 +1171,7 @@
|
|||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>89.99</double>
|
||||
<double>89.989999999999995</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>1.000000000000000</double>
|
||||
|
@ -1281,47 +1281,184 @@
|
|||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="VertexXAxisValue"/>
|
||||
<widget class="QDoubleSpinBox" name="vertexX"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="VertexYAxisValue"/>
|
||||
<widget class="QDoubleSpinBox" name="vertexY"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="VertexZAxisValue"/>
|
||||
<widget class="QDoubleSpinBox" name="vertexZ"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_X_Axis">
|
||||
<property name="text">
|
||||
<string>X Axis Value:</string>
|
||||
<string>X Value:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|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>
|
||||
<string>Y Value:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|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>
|
||||
<string>Z Value:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page11_edge">
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="X1">
|
||||
<property name="text">
|
||||
<string>X</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="Y1">
|
||||
<property name="text">
|
||||
<string>Y</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="Z1">
|
||||
<property name="text">
|
||||
<string>Z</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="Line" name="line_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="Finish_Vertex">
|
||||
<property name="text">
|
||||
<string>Finish Vertex</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="Start_Vertex">
|
||||
<property name="text">
|
||||
<string>Start Vertex</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="X2">
|
||||
<property name="text">
|
||||
<string>X</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="Y2">
|
||||
<property name="text">
|
||||
<string>Y</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="Z2">
|
||||
<property name="text">
|
||||
<string>Z</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="edgeX1">
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="edgeY1">
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QDoubleSpinBox" name="edgeZ1">
|
||||
<property name="suffix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QDoubleSpinBox" name="edgeX2">
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QDoubleSpinBox" name="edgeY2">
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QDoubleSpinBox" name="edgeZ2">
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -1342,6 +1479,15 @@
|
|||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="comboBox1">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maxVisibleItems">
|
||||
<number>14</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Plane</string>
|
||||
|
@ -1397,6 +1543,11 @@
|
|||
<string>Vertex</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Edge</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
|
|
Loading…
Reference in New Issue
Block a user