[TD]use correct property types and spinboxes for Section
This commit is contained in:
@@ -66,7 +66,6 @@
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <chrono>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
@@ -735,7 +734,7 @@ TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shap
|
||||
-m_shapeSize,
|
||||
m_shapeSize);
|
||||
BRepTools::Write(mkFace.Face(), "DVSSectionPlane.brep");// debug
|
||||
BRepTools::Write(shape, "DVSShapeToIntersect.brep)");
|
||||
BRepTools::Write(shape, "DVSShapeToIntersect.brep");
|
||||
}
|
||||
BRep_Builder builder;
|
||||
TopoDS_Compound result;
|
||||
@@ -759,10 +758,6 @@ TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shap
|
||||
// move section faces to line up with cut shape
|
||||
TopoDS_Compound DrawViewSection::alignSectionFaces(TopoDS_Shape faceIntersections)
|
||||
{
|
||||
// Base::Console().Message("DVS::alignSectionFaces() - %s -
|
||||
// faceIntersection.isnull: %d\n",
|
||||
// getNameInDocument(),
|
||||
// faceIntersections.IsNull());
|
||||
TopoDS_Compound sectionFaces;
|
||||
TopoDS_Shape centeredShape =
|
||||
ShapeUtils::moveShape(faceIntersections, getOriginalCentroid() * -1.0);
|
||||
@@ -773,6 +768,10 @@ TopoDS_Compound DrawViewSection::alignSectionFaces(TopoDS_Shape faceIntersection
|
||||
ShapeUtils::rotateShape(scaledSection, getProjectionCS(), Rotation.getValue());
|
||||
}
|
||||
|
||||
if (debugSection()) {
|
||||
BRepTools::Write(scaledSection, "DVSScaledSectionFaces.brep");
|
||||
}
|
||||
|
||||
return mapToPage(scaledSection);
|
||||
}
|
||||
|
||||
@@ -796,12 +795,23 @@ TopoDS_Compound DrawViewSection::mapToPage(TopoDS_Shape& shapeToAlign)
|
||||
TopExp_Explorer expFace(shapeToAlign, TopAbs_FACE);
|
||||
for (int iFace = 1; expFace.More(); expFace.Next(), iFace++) {
|
||||
const TopoDS_Face& face = TopoDS::Face(expFace.Current());
|
||||
if (debugSection()) {
|
||||
std::stringstream ss;
|
||||
ss << "DVSFace" << iFace << ".brep";
|
||||
BRepTools::Write(face, ss.str().c_str());// debug
|
||||
}
|
||||
|
||||
|
||||
std::vector<TopoDS_Wire> faceWires;
|
||||
TopExp_Explorer expWires(face, TopAbs_WIRE);
|
||||
for (; expWires.More(); expWires.Next()) {
|
||||
const TopoDS_Wire& wire = TopoDS::Wire(expWires.Current());
|
||||
TopoDS_Shape projectedShape =
|
||||
GeometryObject::projectSimpleShape(wire, getProjectionCS());
|
||||
TopoDS_Shape projectedShape = GeometryObject::projectSimpleShape(wire, getProjectionCS());
|
||||
if (debugSection()) {
|
||||
std::stringstream ss;
|
||||
ss << "DVSProjectedWire" << iFace << ".brep";
|
||||
BRepTools::Write(projectedShape, ss.str().c_str());// debug
|
||||
}
|
||||
std::vector<TopoDS_Edge> wireEdges;
|
||||
// projectedShape is just a bunch of edges. we have to rebuild the wire.
|
||||
TopExp_Explorer expEdges(projectedShape, TopAbs_EDGE);
|
||||
@@ -809,6 +819,7 @@ TopoDS_Compound DrawViewSection::mapToPage(TopoDS_Shape& shapeToAlign)
|
||||
const TopoDS_Edge& edge = TopoDS::Edge(expEdges.Current());
|
||||
wireEdges.push_back(edge);
|
||||
}
|
||||
|
||||
TopoDS_Wire cleanWire = EdgeWalker::makeCleanWire(wireEdges, 2.0 * EWTOLERANCE);
|
||||
faceWires.push_back(cleanWire);
|
||||
}
|
||||
@@ -1225,6 +1236,33 @@ void DrawViewSection::setupObject()
|
||||
DrawViewPart::setupObject();
|
||||
}
|
||||
|
||||
void DrawViewSection::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop)
|
||||
{
|
||||
if (prop == &SectionOrigin) {
|
||||
// SectionOrigin was PropertyVector but is now PropertyPosition
|
||||
App::PropertyVector tmp;
|
||||
if (strcmp(tmp.getTypeId().getName(), TypeName)==0) {
|
||||
tmp.setContainer(this);
|
||||
tmp.Restore(reader);
|
||||
auto tmpValue = tmp.getValue();
|
||||
SectionOrigin.setValue(tmpValue);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (prop == &SectionNormal) {
|
||||
// Radius was PropertyVector but is now PropertyDirection
|
||||
App::PropertyVector tmp;
|
||||
if (strcmp(tmp.getTypeId().getName(), TypeName)==0) {
|
||||
tmp.setContainer(this);
|
||||
tmp.Restore(reader);
|
||||
auto tmpValue = tmp.getValue();
|
||||
SectionNormal.setValue(tmpValue);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// hatch file routines
|
||||
|
||||
// create geometric hatch lines
|
||||
|
||||
@@ -84,8 +84,8 @@ public:
|
||||
~DrawViewSection() override;
|
||||
|
||||
App::PropertyLink BaseView;
|
||||
App::PropertyVector SectionNormal;
|
||||
App::PropertyVector SectionOrigin;
|
||||
App::PropertyDirection SectionNormal;
|
||||
App::PropertyPosition SectionOrigin;
|
||||
App::PropertyString SectionSymbol;
|
||||
|
||||
|
||||
@@ -118,6 +118,8 @@ public:
|
||||
}
|
||||
void unsetupObject() override;
|
||||
short mustExecute() const override;
|
||||
void handleChangedPropertyType(
|
||||
Base::XMLReader &reader, const char * TypeName, App::Property * prop) override;
|
||||
|
||||
void sectionExec(TopoDS_Shape& s);
|
||||
virtual void makeSectionCut(const TopoDS_Shape& baseShape);
|
||||
|
||||
@@ -171,7 +171,7 @@ void TaskSectionView::setUiEdit()
|
||||
ui->sbScale->setEnabled(false);
|
||||
}
|
||||
|
||||
Base::Vector3d origin = m_section->SectionOrigin.getValue();
|
||||
auto origin = m_section->SectionOrigin.getValue();
|
||||
setUiCommon(origin);
|
||||
|
||||
// convert section normal to view angle
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>370</width>
|
||||
<height>508</height>
|
||||
<width>442</width>
|
||||
<height>528</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@@ -50,7 +50,7 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>22</height>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -67,7 +67,7 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>22</height>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
@@ -87,7 +87,7 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>22</height>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
@@ -299,7 +299,48 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayoutPlane">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0">
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbOrgY">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Z</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="sizePolicy">
|
||||
@@ -319,20 +360,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbOrgX">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
@@ -343,7 +384,7 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>22</height>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
@@ -354,7 +395,29 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbOrgZ">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
@@ -373,69 +436,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbOrgY">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">Z</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbOrgZ">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="keyboardTracking">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include <Gui/QuantitySpinBox.h>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Tools.h>
|
||||
|
||||
@@ -68,13 +70,13 @@ bool CompassWidget::eventFilter(QObject* target, QEvent* event)
|
||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
||||
if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) {
|
||||
dsbAngle->interpretText();
|
||||
slotSpinBoxEnter(dsbAngle->value());
|
||||
slotSpinBoxEnter(dsbAngle->rawValue());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (event->type() == QEvent::FocusOut) {
|
||||
dsbAngle->interpretText();
|
||||
slotSpinBoxEnter(dsbAngle->value());
|
||||
slotSpinBoxEnter(dsbAngle->rawValue());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -128,9 +130,9 @@ void CompassWidget::buildWidget()
|
||||
compassControlLabel->setSizePolicy(sizePolicy2);
|
||||
|
||||
compassControlLayout->addWidget(compassControlLabel);
|
||||
|
||||
dsbAngle = new QDoubleSpinBox(this);
|
||||
dsbAngle = new Gui::QuantitySpinBox(this);
|
||||
dsbAngle->setObjectName(QStringLiteral("dsbAngle"));
|
||||
dsbAngle->setUnit(Base::Unit::Angle);
|
||||
sizePolicy2.setHeightForWidth(dsbAngle->sizePolicy().hasHeightForWidth());
|
||||
dsbAngle->setSizePolicy(sizePolicy2);
|
||||
dsbAngle->setMinimumSize(QSize(75, 26));
|
||||
@@ -138,7 +140,6 @@ void CompassWidget::buildWidget()
|
||||
dsbAngle->setFocusPolicy(Qt::ClickFocus);
|
||||
dsbAngle->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
|
||||
dsbAngle->setKeyboardTracking(false);
|
||||
dsbAngle->setSuffix(QStringLiteral("\302\260"));
|
||||
dsbAngle->setMaximum(360.000000000000000);
|
||||
dsbAngle->setMinimum(-360.000000000000000);
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ class QPushButton;
|
||||
class QVBoxLayout;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Gui {
|
||||
class QuantitySpinBox;
|
||||
}
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
|
||||
@@ -94,7 +98,7 @@ private:
|
||||
|
||||
CompassDialWidget* compassDial;
|
||||
// DoubleSpinBoxNoEnter* dsbAngle;
|
||||
QDoubleSpinBox* dsbAngle;
|
||||
Gui::QuantitySpinBox* dsbAngle;
|
||||
QLabel* compassControlLabel;
|
||||
QPushButton* pbCWAdvance;
|
||||
QPushButton* pbCCWAdvance;
|
||||
|
||||
Reference in New Issue
Block a user