Skip to content

Commit 7ad9ffc

Browse files
WandererFanchennes
authored andcommitted
[TD]use correct property types and spinboxes for Section
1 parent 50e7087 commit 7ad9ffc

File tree

6 files changed

+117
-72
lines changed

6 files changed

+117
-72
lines changed

src/Mod/TechDraw/App/DrawViewSection.cpp

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
#include <TopoDS_Edge.hxx>
6767
#include <TopoDS_Face.hxx>
6868
#include <TopoDS_Shape.hxx>
69-
#include <chrono>
7069
#include <gp_Ax2.hxx>
7170
#include <gp_Ax3.hxx>
7271
#include <gp_Dir.hxx>
@@ -735,7 +734,7 @@ TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shap
735734
-m_shapeSize,
736735
m_shapeSize);
737736
BRepTools::Write(mkFace.Face(), "DVSSectionPlane.brep");// debug
738-
BRepTools::Write(shape, "DVSShapeToIntersect.brep)");
737+
BRepTools::Write(shape, "DVSShapeToIntersect.brep");
739738
}
740739
BRep_Builder builder;
741740
TopoDS_Compound result;
@@ -759,10 +758,6 @@ TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shap
759758
// move section faces to line up with cut shape
760759
TopoDS_Compound DrawViewSection::alignSectionFaces(TopoDS_Shape faceIntersections)
761760
{
762-
// Base::Console().Message("DVS::alignSectionFaces() - %s -
763-
// faceIntersection.isnull: %d\n",
764-
// getNameInDocument(),
765-
// faceIntersections.IsNull());
766761
TopoDS_Compound sectionFaces;
767762
TopoDS_Shape centeredShape =
768763
ShapeUtils::moveShape(faceIntersections, getOriginalCentroid() * -1.0);
@@ -773,6 +768,10 @@ TopoDS_Compound DrawViewSection::alignSectionFaces(TopoDS_Shape faceIntersection
773768
ShapeUtils::rotateShape(scaledSection, getProjectionCS(), Rotation.getValue());
774769
}
775770

771+
if (debugSection()) {
772+
BRepTools::Write(scaledSection, "DVSScaledSectionFaces.brep");
773+
}
774+
776775
return mapToPage(scaledSection);
777776
}
778777

@@ -796,19 +795,31 @@ TopoDS_Compound DrawViewSection::mapToPage(TopoDS_Shape& shapeToAlign)
796795
TopExp_Explorer expFace(shapeToAlign, TopAbs_FACE);
797796
for (int iFace = 1; expFace.More(); expFace.Next(), iFace++) {
798797
const TopoDS_Face& face = TopoDS::Face(expFace.Current());
798+
if (debugSection()) {
799+
std::stringstream ss;
800+
ss << "DVSFace" << iFace << ".brep";
801+
BRepTools::Write(face, ss.str().c_str());// debug
802+
}
803+
804+
799805
std::vector<TopoDS_Wire> faceWires;
800806
TopExp_Explorer expWires(face, TopAbs_WIRE);
801807
for (; expWires.More(); expWires.Next()) {
802808
const TopoDS_Wire& wire = TopoDS::Wire(expWires.Current());
803-
TopoDS_Shape projectedShape =
804-
GeometryObject::projectSimpleShape(wire, getProjectionCS());
809+
TopoDS_Shape projectedShape = GeometryObject::projectSimpleShape(wire, getProjectionCS());
810+
if (debugSection()) {
811+
std::stringstream ss;
812+
ss << "DVSProjectedWire" << iFace << ".brep";
813+
BRepTools::Write(projectedShape, ss.str().c_str());// debug
814+
}
805815
std::vector<TopoDS_Edge> wireEdges;
806816
// projectedShape is just a bunch of edges. we have to rebuild the wire.
807817
TopExp_Explorer expEdges(projectedShape, TopAbs_EDGE);
808818
for (; expEdges.More(); expEdges.Next()) {
809819
const TopoDS_Edge& edge = TopoDS::Edge(expEdges.Current());
810820
wireEdges.push_back(edge);
811821
}
822+
812823
TopoDS_Wire cleanWire = EdgeWalker::makeCleanWire(wireEdges, 2.0 * EWTOLERANCE);
813824
faceWires.push_back(cleanWire);
814825
}
@@ -1225,6 +1236,33 @@ void DrawViewSection::setupObject()
12251236
DrawViewPart::setupObject();
12261237
}
12271238

1239+
void DrawViewSection::handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop)
1240+
{
1241+
if (prop == &SectionOrigin) {
1242+
// SectionOrigin was PropertyVector but is now PropertyPosition
1243+
App::PropertyVector tmp;
1244+
if (strcmp(tmp.getTypeId().getName(), TypeName)==0) {
1245+
tmp.setContainer(this);
1246+
tmp.Restore(reader);
1247+
auto tmpValue = tmp.getValue();
1248+
SectionOrigin.setValue(tmpValue);
1249+
}
1250+
return;
1251+
}
1252+
1253+
if (prop == &SectionNormal) {
1254+
// Radius was PropertyVector but is now PropertyDirection
1255+
App::PropertyVector tmp;
1256+
if (strcmp(tmp.getTypeId().getName(), TypeName)==0) {
1257+
tmp.setContainer(this);
1258+
tmp.Restore(reader);
1259+
auto tmpValue = tmp.getValue();
1260+
SectionNormal.setValue(tmpValue);
1261+
}
1262+
return;
1263+
}
1264+
}
1265+
12281266
// hatch file routines
12291267

12301268
// create geometric hatch lines

src/Mod/TechDraw/App/DrawViewSection.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ class TechDrawExport DrawViewSection: public DrawViewPart
8484
~DrawViewSection() override;
8585

8686
App::PropertyLink BaseView;
87-
App::PropertyVector SectionNormal;
88-
App::PropertyVector SectionOrigin;
87+
App::PropertyDirection SectionNormal;
88+
App::PropertyPosition SectionOrigin;
8989
App::PropertyString SectionSymbol;
9090

9191

@@ -118,6 +118,8 @@ class TechDrawExport DrawViewSection: public DrawViewPart
118118
}
119119
void unsetupObject() override;
120120
short mustExecute() const override;
121+
void handleChangedPropertyType(
122+
Base::XMLReader &reader, const char * TypeName, App::Property * prop) override;
121123

122124
void sectionExec(TopoDS_Shape& s);
123125
virtual void makeSectionCut(const TopoDS_Shape& baseShape);

src/Mod/TechDraw/Gui/TaskSectionView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void TaskSectionView::setUiEdit()
171171
ui->sbScale->setEnabled(false);
172172
}
173173

174-
Base::Vector3d origin = m_section->SectionOrigin.getValue();
174+
auto origin = m_section->SectionOrigin.getValue();
175175
setUiCommon(origin);
176176

177177
// convert section normal to view angle

src/Mod/TechDraw/Gui/TaskSectionView.ui

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>370</width>
10-
<height>508</height>
9+
<width>442</width>
10+
<height>528</height>
1111
</rect>
1212
</property>
1313
<property name="sizePolicy">
@@ -50,7 +50,7 @@
5050
<property name="minimumSize">
5151
<size>
5252
<width>0</width>
53-
<height>22</height>
53+
<height>24</height>
5454
</size>
5555
</property>
5656
</widget>
@@ -67,7 +67,7 @@
6767
<property name="minimumSize">
6868
<size>
6969
<width>0</width>
70-
<height>22</height>
70+
<height>24</height>
7171
</size>
7272
</property>
7373
<property name="toolTip">
@@ -87,7 +87,7 @@
8787
<property name="minimumSize">
8888
<size>
8989
<width>0</width>
90-
<height>22</height>
90+
<height>24</height>
9191
</size>
9292
</property>
9393
<property name="toolTip">
@@ -299,9 +299,9 @@
299299
</property>
300300
<layout class="QVBoxLayout" name="verticalLayoutPlane">
301301
<item>
302-
<layout class="QGridLayout" name="gridLayout_2">
303-
<item row="0" column="0">
304-
<widget class="QLabel" name="label_10">
302+
<layout class="QGridLayout" name="gridLayout" columnstretch="1,0">
303+
<item row="1" column="1">
304+
<widget class="Gui::QuantitySpinBox" name="sbOrgY">
305305
<property name="sizePolicy">
306306
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
307307
<horstretch>0</horstretch>
@@ -310,30 +310,20 @@
310310
</property>
311311
<property name="minimumSize">
312312
<size>
313-
<width>0</width>
314-
<height>0</height>
313+
<width>150</width>
314+
<height>24</height>
315315
</size>
316316
</property>
317-
<property name="text">
318-
<string notr="true">X</string>
319-
</property>
320-
</widget>
321-
</item>
322-
<item row="0" column="1">
323-
<spacer name="horizontalSpacer_3">
324-
<property name="orientation">
325-
<enum>Qt::Horizontal</enum>
317+
<property name="keyboardTracking">
318+
<bool>false</bool>
326319
</property>
327-
<property name="sizeHint" stdset="0">
328-
<size>
329-
<width>40</width>
330-
<height>20</height>
331-
</size>
320+
<property name="unit" stdset="0">
321+
<string notr="true"/>
332322
</property>
333-
</spacer>
323+
</widget>
334324
</item>
335-
<item row="0" column="2">
336-
<widget class="Gui::QuantitySpinBox" name="sbOrgX">
325+
<item row="2" column="0">
326+
<widget class="QLabel" name="label_12">
337327
<property name="sizePolicy">
338328
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
339329
<horstretch>0</horstretch>
@@ -342,20 +332,17 @@
342332
</property>
343333
<property name="minimumSize">
344334
<size>
345-
<width>150</width>
346-
<height>22</height>
335+
<width>0</width>
336+
<height>0</height>
347337
</size>
348338
</property>
349-
<property name="keyboardTracking">
350-
<bool>false</bool>
351-
</property>
352-
<property name="unit" stdset="0">
353-
<string notr="true"/>
339+
<property name="text">
340+
<string notr="true">Z</string>
354341
</property>
355342
</widget>
356343
</item>
357-
<item row="1" column="0" colspan="2">
358-
<widget class="QLabel" name="label_11">
344+
<item row="0" column="0">
345+
<widget class="QLabel" name="label_10">
359346
<property name="sizePolicy">
360347
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
361348
<horstretch>0</horstretch>
@@ -369,12 +356,25 @@
369356
</size>
370357
</property>
371358
<property name="text">
372-
<string notr="true">Y</string>
359+
<string notr="true">X</string>
373360
</property>
374361
</widget>
375362
</item>
376-
<item row="1" column="2">
377-
<widget class="Gui::QuantitySpinBox" name="sbOrgY">
363+
<item row="3" column="0">
364+
<spacer name="verticalSpacer">
365+
<property name="orientation">
366+
<enum>Qt::Vertical</enum>
367+
</property>
368+
<property name="sizeHint" stdset="0">
369+
<size>
370+
<width>20</width>
371+
<height>40</height>
372+
</size>
373+
</property>
374+
</spacer>
375+
</item>
376+
<item row="0" column="1">
377+
<widget class="Gui::QuantitySpinBox" name="sbOrgX">
378378
<property name="sizePolicy">
379379
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
380380
<horstretch>0</horstretch>
@@ -384,7 +384,7 @@
384384
<property name="minimumSize">
385385
<size>
386386
<width>150</width>
387-
<height>22</height>
387+
<height>24</height>
388388
</size>
389389
</property>
390390
<property name="keyboardTracking">
@@ -395,8 +395,8 @@
395395
</property>
396396
</widget>
397397
</item>
398-
<item row="2" column="0" colspan="2">
399-
<widget class="QLabel" name="label_12">
398+
<item row="2" column="1">
399+
<widget class="Gui::QuantitySpinBox" name="sbOrgZ">
400400
<property name="sizePolicy">
401401
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
402402
<horstretch>0</horstretch>
@@ -405,17 +405,20 @@
405405
</property>
406406
<property name="minimumSize">
407407
<size>
408-
<width>0</width>
409-
<height>0</height>
408+
<width>150</width>
409+
<height>24</height>
410410
</size>
411411
</property>
412-
<property name="text">
413-
<string notr="true">Z</string>
412+
<property name="keyboardTracking">
413+
<bool>false</bool>
414+
</property>
415+
<property name="unit" stdset="0">
416+
<string notr="true"/>
414417
</property>
415418
</widget>
416419
</item>
417-
<item row="2" column="2">
418-
<widget class="Gui::QuantitySpinBox" name="sbOrgZ">
420+
<item row="1" column="0">
421+
<widget class="QLabel" name="label_11">
419422
<property name="sizePolicy">
420423
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
421424
<horstretch>0</horstretch>
@@ -424,15 +427,12 @@
424427
</property>
425428
<property name="minimumSize">
426429
<size>
427-
<width>150</width>
428-
<height>22</height>
430+
<width>0</width>
431+
<height>0</height>
429432
</size>
430433
</property>
431-
<property name="keyboardTracking">
432-
<bool>false</bool>
433-
</property>
434-
<property name="unit" stdset="0">
435-
<string notr="true"/>
434+
<property name="text">
435+
<string notr="true">Y</string>
436436
</property>
437437
</widget>
438438
</item>

src/Mod/TechDraw/Gui/Widgets/CompassWidget.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737

3838
#include <Mod/TechDraw/TechDrawGlobal.h>
3939

40+
#include <Gui/QuantitySpinBox.h>
41+
4042
#include <Base/Console.h>
4143
#include <Base/Tools.h>
4244

@@ -68,13 +70,13 @@ bool CompassWidget::eventFilter(QObject* target, QEvent* event)
6870
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
6971
if (keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter) {
7072
dsbAngle->interpretText();
71-
slotSpinBoxEnter(dsbAngle->value());
73+
slotSpinBoxEnter(dsbAngle->rawValue());
7274
return true;
7375
}
7476
}
7577
else if (event->type() == QEvent::FocusOut) {
7678
dsbAngle->interpretText();
77-
slotSpinBoxEnter(dsbAngle->value());
79+
slotSpinBoxEnter(dsbAngle->rawValue());
7880
return true;
7981
}
8082
}
@@ -128,17 +130,16 @@ void CompassWidget::buildWidget()
128130
compassControlLabel->setSizePolicy(sizePolicy2);
129131

130132
compassControlLayout->addWidget(compassControlLabel);
131-
132-
dsbAngle = new QDoubleSpinBox(this);
133+
dsbAngle = new Gui::QuantitySpinBox(this);
133134
dsbAngle->setObjectName(QStringLiteral("dsbAngle"));
135+
dsbAngle->setUnit(Base::Unit::Angle);
134136
sizePolicy2.setHeightForWidth(dsbAngle->sizePolicy().hasHeightForWidth());
135137
dsbAngle->setSizePolicy(sizePolicy2);
136138
dsbAngle->setMinimumSize(QSize(75, 26));
137139
dsbAngle->setMouseTracking(true);
138140
dsbAngle->setFocusPolicy(Qt::ClickFocus);
139141
dsbAngle->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
140142
dsbAngle->setKeyboardTracking(false);
141-
dsbAngle->setSuffix(QStringLiteral("\302\260"));
142143
dsbAngle->setMaximum(360.000000000000000);
143144
dsbAngle->setMinimum(-360.000000000000000);
144145

0 commit comments

Comments
 (0)