[TD]Complex Section - initial implementation

This commit is contained in:
wandererfan
2022-10-10 10:10:42 -04:00
committed by WandererFan
parent 9d32c892f0
commit 5ddc6ce789
39 changed files with 4656 additions and 773 deletions

View File

@@ -87,6 +87,7 @@ set(TechDrawGui_UIC_SRCS
SymbolChooser.ui
TaskMoveView.ui
TaskProjection.ui
TaskComplexSection.ui
)
if(BUILD_QT5)
@@ -222,6 +223,9 @@ SET(TechDrawGui_SRCS
TaskProjection.cpp
TaskProjection.h
TaskProjection.ui
TaskComplexSection.cpp
TaskComplexSection.h
TaskComplexSection.ui
)
SET(TechDrawGuiView_SRCS
@@ -419,6 +423,7 @@ SET(TechDrawGuiTaskDlgs_SRCS
TaskCustomizeFormat.ui
TaskMoveView.ui
TaskProjection.ui
TaskComplexSection.ui
)
SOURCE_GROUP("MRTE" FILES ${MRTE_SRCS})

View File

@@ -30,8 +30,10 @@
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <App/Link.h>
#include <Base/Console.h>
#include <Base/Tools.h>
#include <Gui/Action.h>
#include <Gui/Application.h>
#include <Gui/Command.h>
@@ -43,14 +45,18 @@
#include <Gui/SelectionObject.h>
#include <Gui/ViewProvider.h>
#include <Gui/WaitCursor.h>
#include <Mod/Spreadsheet/App/Sheet.h>
#include <Mod/TechDraw/App/DrawComplexSection.h>
#include <Mod/TechDraw/App/DrawPage.h>
#include <Mod/TechDraw/App/DrawProjGroup.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/DrawViewArch.h>
#include <Mod/TechDraw/App/DrawViewClip.h>
#include <Mod/TechDraw/App/DrawViewDetail.h>
#include <Mod/TechDraw/App/DrawViewDraft.h>
#include <Mod/TechDraw/App/DrawViewMulti.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Mod/TechDraw/App/DrawViewSymbol.h>
#include <Mod/TechDraw/App/Preferences.h>
@@ -62,6 +68,7 @@
#include "QGVPage.h"
#include "Rez.h"
#include "TaskActiveView.h"
#include "TaskComplexSection.h"
#include "TaskDetail.h"
#include "TaskProjGroup.h"
#include "TaskProjection.h"
@@ -512,6 +519,120 @@ bool CmdTechDrawSectionView::isActive()
return (havePage && haveView && !taskInProgress);
}
//===========================================================================
// TechDraw_ComplexSection
//===========================================================================
DEF_STD_CMD_A(CmdTechDrawComplexSection)
CmdTechDrawComplexSection::CmdTechDrawComplexSection()
: Command("TechDraw_ComplexSection")
{
sAppModule = "TechDraw";
sGroup = QT_TR_NOOP("TechDraw");
sMenuText = QT_TR_NOOP("Insert Complex Section");
sToolTipText = QT_TR_NOOP("Insert a Complex Section");
sWhatsThis = "TechDraw_ComplexSection";
sStatusTip = sToolTipText;
sPixmap = "actions/TechDraw_ComplexSection";
}
void CmdTechDrawComplexSection::activated(int iMsg)
{
Q_UNUSED(iMsg);
TechDraw::DrawPage* page = DrawGuiUtil::findPage(this);
if (!page) {
return;
}
std::string PageName = page->getNameInDocument();
TechDraw::DrawViewPart* baseView(nullptr);
std::vector<App::DocumentObject*> shapes;
std::vector<App::DocumentObject*> xShapes;
App::DocumentObject* profileObject(nullptr);
std::vector<std::string> profileSubs;
Gui::ResolveMode resolve = Gui::ResolveMode::OldStyleElement; //mystery
bool single = false; //mystery
auto selection = getSelection().getSelectionEx(nullptr,
App::DocumentObject::getClassTypeId(),
resolve,
single);
for (auto& sel: selection) {
bool is_linked = false;
auto obj = sel.getObject();
if (obj->isDerivedFrom(TechDraw::DrawPage::getClassTypeId())) {
continue;
}
if (obj->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
//use the dvp's Sources as sources for this ComplexSection &
//check the subelement(s) to see if they can be used as a profile
baseView = static_cast<TechDraw::DrawViewPart*>(obj);
if (!sel.getSubNames().empty()) {
//need to add profile subs as parameter
profileObject = baseView;
profileSubs = sel.getSubNames();
}
continue;
}
if (obj->isDerivedFrom(App::LinkElement::getClassTypeId()) ||
obj->isDerivedFrom(App::LinkGroup::getClassTypeId()) ||
obj->isDerivedFrom(App::Link::getClassTypeId()) ) {
is_linked = true;
}
// If parent of the obj is a link to another document, we possibly need to treat non-link obj as linked, too
// 1st, is obj in another document?
if (obj->getDocument() != this->getDocument()) {
std::set<App::DocumentObject*> parents = obj->getInListEx(true);
for (auto& parent : parents) {
// Only consider parents in the current document, i.e. possible links in this View's document
if (parent->getDocument() != this->getDocument()) {
continue;
}
// 2nd, do we really have a link to obj?
if (parent->isDerivedFrom(App::LinkElement::getClassTypeId()) ||
parent->isDerivedFrom(App::LinkGroup::getClassTypeId()) ||
parent->isDerivedFrom(App::Link::getClassTypeId())) {
// We have a link chain from this document to obj, and obj is in another document -> it's an XLink target
is_linked = true;
}
}
}
if (is_linked) {
xShapes.push_back(obj);
continue;
}
//not a Link and not null. assume to be drawable. Undrawables will be
// skipped later.
if (TechDraw::DrawComplexSection::isProfileObject(obj)) {
profileObject = obj;
} else {
shapes.push_back(obj);
}
}
if (shapes.empty() &&
xShapes.empty() &&
!baseView) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("No Base View, Shapes, Groups or Links in this selection"));
return;
}
if (!profileObject) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("No profile object found in selection"));
return;
}
Gui::Control().showDialog(new TaskDlgComplexSection(page, baseView,
shapes, xShapes,
profileObject, profileSubs));
}
bool CmdTechDrawComplexSection::isActive()
{
return DrawGuiUtil::needPage(this);
}
//===========================================================================
// TechDraw_DetailView
//===========================================================================
@@ -1510,4 +1631,5 @@ void CreateTechDrawCommands()
rcCmdMgr.addCommand(new CmdTechDrawSpreadsheetView());
rcCmdMgr.addCommand(new CmdTechDrawBalloon());
rcCmdMgr.addCommand(new CmdTechDrawProjectShape());
rcCmdMgr.addCommand(new CmdTechDrawComplexSection());
}

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>440</width>
<height>447</height>
<width>450</width>
<height>541</height>
</rect>
</property>
<property name="sizePolicy">
@@ -33,21 +33,34 @@
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,0,1">
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<layout class="QGridLayout" name="gridLayout_2" columnstretch="1,0,0">
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<italic>true</italic>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>Section Line Standard</string>
<string>Detail View Outline Shape</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="Gui::PrefComboBox" name="cbSectionLineStd">
<item row="7" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="13" column="0">
<widget class="Gui::PrefCheckBox" name="cbShowCenterMarks">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -56,43 +69,137 @@
</property>
<property name="minimumSize">
<size>
<width>184</width>
<height>22</height>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="toolTip">
<string>Show arc center marks in views</string>
</property>
<property name="text">
<string>Show Center Marks</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowCenterMarks</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Decorations</cstring>
</property>
</widget>
</item>
<item row="13" column="2">
<widget class="Gui::PrefCheckBox" name="cbPrintCenterMarks">
<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="toolTip">
<string>Standard to be used to draw section lines</string>
<string>Show arc centers in printed output</string>
</property>
<property name="currentIndex">
<number>1</number>
<property name="text">
<string>Print Center Marks</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>SectionLineStandard</cstring>
<cstring>PrintCenterMarks</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Standards</cstring>
<cstring>Mod/TechDraw/Decorations</cstring>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="Gui::PrefComboBox" name="pcbBalloonArrow">
<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="toolTip">
<string>Style for balloon leader line ends</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>BalloonArrow</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Decorations</cstring>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="Gui::PrefComboBox" name="pcbMatting">
<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="toolTip">
<string>Outline shape for detail views</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>MattingStyle</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Decorations</cstring>
</property>
<item>
<property name="text">
<string>ANSI</string>
<string>Circle</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/circular.svg</normaloff>:/icons/circular.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>ISO</string>
<string>Square</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/square.svg</normaloff>:/icons/square.svg</iconset>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<item row="8" column="0">
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Section Line Style</string>
<string>Balloon Shape</string>
</property>
</widget>
</item>
@@ -178,76 +285,87 @@
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_19">
<item row="0" column="0">
<widget class="QLabel" name="label_10">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Section Cut Surface</string>
<string>Section Line Standard</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="Gui::PrefComboBox" name="cbCutSurface">
<item row="0" column="2">
<widget class="Gui::PrefComboBox" name="cbSectionLineStd">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<width>184</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Default appearance of cut surface in section view</string>
<string>Standard to be used to draw section lines</string>
</property>
<property name="currentIndex">
<number>2</number>
<number>1</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>CutSurfaceDisplay</cstring>
<cstring>SectionLineStandard</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Decorations</cstring>
<cstring>Mod/TechDraw/Standards</cstring>
</property>
<item>
<property name="text">
<string>Hide</string>
<string>ANSI</string>
</property>
</item>
<item>
<property name="text">
<string>Solid Color</string>
</property>
</item>
<item>
<property name="text">
<string>SVG Hatch</string>
</property>
</item>
<item>
<property name="text">
<string>PAT Hatch</string>
<string>ISO</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_13">
<item row="6" column="0">
<widget class="QLabel" name="label_20">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="toolTip">
<string>Line group used to set line widths</string>
<string>Line style of detail highlight on base view</string>
</property>
<property name="text">
<string>Line Width Group</string>
<string>Detail Highlight Style</string>
</property>
</widget>
</item>
<item row="3" column="2">
<item row="10" column="0">
<widget class="QLabel" name="label_18">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="toolTip">
<string>Length of horizontal portion of Balloon leader</string>
</property>
<property name="text">
<string>Ballon Leader Kink Length</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="Gui::PrefComboBox" name="pcbLineGroup">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -272,77 +390,7 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>Detail View Outline Shape</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="Gui::PrefComboBox" name="pcbMatting">
<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="toolTip">
<string>Outline shape for detail views</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>MattingStyle</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Decorations</cstring>
</property>
<item>
<property name="text">
<string>Circle</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/circular.svg</normaloff>:/icons/circular.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Square</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/square.svg</normaloff>:/icons/square.svg</iconset>
</property>
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_20">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="toolTip">
<string>Line style of detail highlight on base view</string>
</property>
<property name="text">
<string>Detail Highlight Style</string>
</property>
</widget>
</item>
<item row="5" column="2">
<item row="6" column="2">
<widget class="Gui::PrefComboBox" name="pcbHighlightStyle">
<property name="minimumSize">
<size>
@@ -415,33 +463,8 @@
</item>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Center Line Style</string>
</property>
</widget>
</item>
<item row="6" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="2">
<widget class="Gui::PrefComboBox" name="pcbCenterStyle">
<item row="10" column="2">
<widget class="Gui::PrefUnitSpinBox" name="pdsbBalloonKink">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -455,86 +478,66 @@
</size>
</property>
<property name="toolTip">
<string>Type for centerlines</string>
<string>Length of balloon leader line kink</string>
</property>
<property name="currentIndex">
<number>2</number>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="value">
<double>5.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>CenterLine</cstring>
<cstring>BalloonKink</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Decorations</cstring>
<cstring>Mod/TechDraw/Dimensions</cstring>
</property>
<item>
<property name="text">
<string>NeverShow</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/arrownone.svg</normaloff>:/icons/arrownone.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Continuous</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/continuous-line.svg</normaloff>:/icons/continuous-line.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Dash</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/dash-line.svg</normaloff>:/icons/dash-line.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Dot</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/dot-line.svg</normaloff>:/icons/dot-line.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>DashDot</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/dashDot-line.svg</normaloff>:/icons/dashDot-line.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>DashDotDot</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/dashDotDot-line.svg</normaloff>:/icons/dashDotDot-line.svg</iconset>
</property>
</item>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_5">
<item row="9" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Balloon Shape</string>
<string>Balloon Leader End</string>
</property>
</widget>
</item>
<item row="7" column="2">
<item row="11" column="0">
<widget class="Gui::PrefCheckBox" name="cbPyramidOrtho">
<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="toolTip">
<string>Restrict Filled Triangle line end to vertical or horizontal directions</string>
</property>
<property name="text">
<string>Balloon Orthogonal Triangle</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>PyramidOrtho</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Decorations</cstring>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="Gui::PrefComboBox" name="pcbBalloonShape">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -631,121 +634,101 @@
</item>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_3">
<item row="7" column="2">
<widget class="Gui::PrefComboBox" name="pcbCenterStyle">
<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="toolTip">
<string>Type for centerlines</string>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>CenterLine</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Decorations</cstring>
</property>
<item>
<property name="text">
<string>NeverShow</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/arrownone.svg</normaloff>:/icons/arrownone.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Continuous</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/continuous-line.svg</normaloff>:/icons/continuous-line.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Dash</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/dash-line.svg</normaloff>:/icons/dash-line.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>Dot</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/dot-line.svg</normaloff>:/icons/dot-line.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>DashDot</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/dashDot-line.svg</normaloff>:/icons/dashDot-line.svg</iconset>
</property>
</item>
<item>
<property name="text">
<string>DashDotDot</string>
</property>
<property name="icon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/dashDotDot-line.svg</normaloff>:/icons/dashDotDot-line.svg</iconset>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_19">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Balloon Leader End</string>
<string>Section Cut Surface</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="Gui::PrefComboBox" name="pcbBalloonArrow">
<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="toolTip">
<string>Style for balloon leader line ends</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>BalloonArrow</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Decorations</cstring>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_18">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="toolTip">
<string>Length of horizontal portion of Balloon leader</string>
</property>
<property name="text">
<string>Ballon Leader Kink Length</string>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="Gui::PrefUnitSpinBox" name="pdsbBalloonKink">
<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="toolTip">
<string>Length of balloon leader line kink</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="value">
<double>5.000000000000000</double>
</property>
<property name="prefEntry" stdset="0">
<cstring>BalloonKink</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Dimensions</cstring>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="Gui::PrefCheckBox" name="cbPyramidOrtho">
<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="toolTip">
<string>Restrict Filled Triangle line end to vertical or horizontal directions</string>
</property>
<property name="text">
<string>Balloon Orthogonal Triangle</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>PyramidOrtho</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Decorations</cstring>
</property>
</widget>
</item>
<item row="10" column="2">
<item row="11" column="2">
<widget class="Gui::PrefCheckBox" name="cbAutoHoriz">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -776,71 +759,112 @@
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="Gui::PrefCheckBox" name="cbShowCenterMarks">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Section Line Style</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>Center Line Style</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="Gui::PrefComboBox" name="cbCutSurface">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Default appearance of cut surface in section view</string>
</property>
<property name="currentIndex">
<number>2</number>
</property>
<property name="prefEntry" stdset="0">
<cstring>CutSurfaceDisplay</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Decorations</cstring>
</property>
<item>
<property name="text">
<string>Hide</string>
</property>
</item>
<item>
<property name="text">
<string>Solid Color</string>
</property>
</item>
<item>
<property name="text">
<string>SVG Hatch</string>
</property>
</item>
<item>
<property name="text">
<string>PAT Hatch</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_13">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="toolTip">
<string>Show arc center marks in views</string>
<string>Line group used to set line widths</string>
</property>
<property name="text">
<string>Show Center Marks</string>
<string>Line Width Group</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="Gui::PrefCheckBox" name="cbComplexMarks">
<property name="font">
<font>
<italic>true</italic>
</font>
</property>
<property name="toolTip">
<string>Show or hide marks at direction changes on ComplexSection lines.</string>
</property>
<property name="text">
<string>Complex Section Line Marks</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>ShowCenterMarks</cstring>
<cstring>SectionLineMarks</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Decorations</cstring>
</property>
</widget>
</item>
<item row="12" column="2">
<widget class="Gui::PrefCheckBox" name="cbPrintCenterMarks">
<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="toolTip">
<string>Show arc centers in printed output</string>
</property>
<property name="text">
<string>Print Center Marks</string>
</property>
<property name="prefEntry" stdset="0">
<cstring>PrintCenterMarks</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/TechDraw/Decorations</cstring>
</property>
</widget>
</item>
</layout>
</layout>
</item>
</layout>
</widget>
@@ -854,7 +878,7 @@
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=" font-weight:600;"&gt;Note:&lt;/span&gt; Items in &lt;span style=" font-style:italic;"&gt;italics&lt;/span&gt; are default values for new objects. They have no effect on existing objects.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Note:&lt;/span&gt; Items in &lt;span style=&quot; font-style:italic;&quot;&gt;italics&lt;/span&gt; are default values for new objects. They have no effect on existing objects.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>

View File

@@ -62,6 +62,7 @@ void DlgPrefsTechDrawAnnotationImp::saveSettings()
ui->cbPrintCenterMarks->onSave();
ui->cbPyramidOrtho->onSave();
ui->cbSectionLineStd->onSave();
ui->cbComplexMarks->onSave();
ui->cbShowCenterMarks->onSave();
ui->pcbLineGroup->onSave();
ui->pcbBalloonArrow->onSave();
@@ -100,6 +101,7 @@ void DlgPrefsTechDrawAnnotationImp::loadSettings()
ui->cbPrintCenterMarks->onRestore();
ui->cbPyramidOrtho->onRestore();
ui->cbSectionLineStd->onRestore();
ui->cbComplexMarks->onRestore();
ui->cbShowCenterMarks->onRestore();
ui->pcbLineGroup->onRestore();
ui->pcbBalloonArrow->onRestore();

View File

@@ -181,6 +181,13 @@ Qt::PenStyle PreferencesGui::sectionLineStyle()
return sectStyle;
}
bool PreferencesGui::sectionLineMarks()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->
GetGroup("Mod/TechDraw/Decorations");
return hGrp->GetBool("SectionLineMarks", true);
}
QString PreferencesGui::weldingDirectory()
{

View File

@@ -62,6 +62,7 @@ static double dimArrowSize();
static double edgeFuzz();
static Qt::PenStyle sectionLineStyle();
static bool sectionLineMarks();
static QString weldingDirectory();

View File

@@ -55,6 +55,7 @@ public:
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr );
virtual void draw();
void setWidth(double w);
double getWidth() { return m_width; }
void setStyle(Qt::PenStyle s);
void setColor(QColor c);
QColor getColor(void) { return m_colNormal; }

View File

@@ -23,6 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <qmath.h>
#include <QGraphicsScene>
#include <QPainter>
#include <QPainterPath>
#include <QPainterPathStroker>
@@ -43,23 +44,30 @@
#include "QGIView.h"
#include "PreferencesGui.h"
#include "Rez.h"
#include "ZVALUE.h"
#define ANSISTANDARD 0
#define ISOSTANDARD 1
#define SINGLEDIRECTIONMODE 0 //both arrows point along the section normal
#define MULTIDIRECTIONMODE 1 //the arrows point along the normal of their section line segment
using namespace TechDrawGui;
using namespace TechDraw;
QGISectionLine::QGISectionLine()
QGISectionLine::QGISectionLine() :
m_pathMode(false),
m_arrowMode()
{
m_symbol = "";
m_symSize = 0.0;
m_extLen = 1.5 * Rez::guiX(QGIArrow::getPrefArrowSize());
m_extLen = 1.5 * Rez::guiX(QGIArrow::getPrefArrowSize()); //is there a standard for this??
m_arrowSize = QGIArrow::getPrefArrowSize();
m_line = new QGraphicsPathItem();
addToGroup(m_line);
m_extend = new QGraphicsPathItem();
addToGroup(m_extend);
m_arrow1 = new QGIArrow();
addToGroup(m_arrow1);
m_arrow2 = new QGIArrow();
@@ -69,7 +77,7 @@ QGISectionLine::QGISectionLine()
m_symbol2 = new QGCustomText();
addToGroup(m_symbol2);
setWidth(Rez::guiX(0.75));
setWidth(Rez::guiX(0.75)); //a default?
setStyle(getSectionStyle());
setColor(getSectionColor());
@@ -85,14 +93,25 @@ void QGISectionLine::draw()
extensionEndsISO();
}
makeLine();
if (!pathMode()) {
makeSectionLine();
}
makeExtensionLine();
makeArrows();
makeSymbols();
makeChangePointMarks();
update();
}
void QGISectionLine::makeLine()
void QGISectionLine::makeExtensionLine()
{
QPen extendPen;
extendPen.setWidthF(getWidth());
extendPen.setColor(getSectionColor());
extendPen.setStyle(Qt::SolidLine);
extendPen.setCapStyle(Qt::FlatCap);
m_extend->setPen(extendPen);
QPainterPath pp;
pp.moveTo(m_beginExt1);
@@ -100,7 +119,13 @@ void QGISectionLine::makeLine()
pp.moveTo(m_beginExt2);
pp.lineTo(m_endExt2);
m_extend->setPath(pp);
}
//make the traditional straight section line
void QGISectionLine::makeSectionLine()
{
QPainterPath pp;
pp.moveTo(m_start);
pp.lineTo(m_end);
m_line->setPath(pp);
@@ -119,62 +144,56 @@ void QGISectionLine::makeArrows()
//make Euro (ISO) Arrows
void QGISectionLine::makeArrowsISO()
{
double arrowRotation = 0.0;
m_arrowDir.Normalize();
double angle = atan2f(m_arrowDir.y, m_arrowDir.x);
if (angle < 0.0) {
angle = 2 * M_PI + angle;
}
arrowRotation = 360.0 - angle * (180.0/M_PI); //convert to Qt rotation (clockwise degrees)
m_arrow1->setStyle(0);
m_arrow1->setSize(QGIArrow::getPrefArrowSize());
m_arrow1->setPos(m_start);
m_arrow1->draw();
m_arrow1->setRotation(arrowRotation); //rotation = 0 ==> -> horizontal, pointing right
m_arrow2->setStyle(0);
m_arrow2->setSize(QGIArrow::getPrefArrowSize());
m_arrow2->setPos(m_end);
if (m_arrowMode == SINGLEDIRECTIONMODE) {
double arrowRotation = getArrowRotation(m_arrowDir);
m_arrow1->setRotation(arrowRotation); //rotation = 0 ==> -> horizontal, pointing right
m_arrow2->setRotation(arrowRotation);
} else {
double arrowRotation1 = getArrowRotation(m_arrowDir1);
m_arrow1->setRotation(arrowRotation1);
double arrowRotation2 = getArrowRotation(m_arrowDir2);
m_arrow2->setRotation(arrowRotation2);
}
m_arrow1->draw();
m_arrow2->draw();
m_arrow2->setRotation(arrowRotation);
}
//make traditional (ASME) section arrows
void QGISectionLine::makeArrowsTrad()
{
double arrowRotation = 0.0;
m_arrowDir.Normalize();
double angle = atan2f(m_arrowDir.y, m_arrowDir.x);
if (angle < 0.0) {
angle = 2 * M_PI + angle;
}
arrowRotation = 360.0 - angle * (180.0/M_PI); //convert to Qt rotation (clockwise degrees)
QPointF posArrow1, posArrow2;
QPointF offsetDir(m_arrowDir.x, -m_arrowDir.y); //remember Y dir is flipped
double oblique = 1.0;
if ( !DrawUtil::fpCompare((m_arrowDir.x + m_arrowDir.y), 1.0) ) {
oblique = 1.25;
}
double offsetLength = (m_extLen * oblique) + Rez::guiX(QGIArrow::getPrefArrowSize());
QPointF offsetVec = offsetLength * offsetDir;
posArrow1 = m_start + offsetVec;
posArrow2 = m_end + offsetVec;
m_arrow1->setStyle(0);
m_arrow1->setSize(QGIArrow::getPrefArrowSize());
m_arrow1->setPos(posArrow1);
m_arrow1->draw();
m_arrow1->setRotation(arrowRotation); //rotation = 0 ==> -> horizontal, pointing right
m_arrow2->setStyle(0);
m_arrow2->setSize(QGIArrow::getPrefArrowSize());
m_arrow2->setPos(posArrow2);
if (m_arrowMode == SINGLEDIRECTIONMODE) {
double arrowRotation = getArrowRotation(m_arrowDir);
m_arrow1->setRotation(arrowRotation); //rotation = 0 ==> -> horizontal, pointing right
m_arrow2->setRotation(arrowRotation);
m_arrowPos1 = getArrowPosition(m_arrowDir, m_start);
m_arrow1->setPos(m_arrowPos1);
m_arrowPos2 = getArrowPosition(m_arrowDir, m_end);
m_arrow2->setPos(m_arrowPos2);
} else {
double arrowRotation1 = getArrowRotation(m_arrowDir1);
m_arrow1->setRotation(arrowRotation1);
m_arrowPos1 = getArrowPosition(m_arrowDir1, m_start);
m_arrow1->setPos(m_arrowPos1);
double arrowRotation2 = getArrowRotation(m_arrowDir2);
m_arrow2->setRotation(arrowRotation2);
m_arrowPos2 = getArrowPosition(m_arrowDir2, m_end);
m_arrow2->setPos(m_arrowPos2);
}
m_arrow1->draw();
m_arrow2->draw();
m_arrow2->setRotation(arrowRotation);
}
void QGISectionLine::makeSymbols()
@@ -187,10 +206,10 @@ void QGISectionLine::makeSymbols()
}
}
//arrows go at arrowhead position.
void QGISectionLine::makeSymbolsTrad()
{
prepareGeometryChange();
// m_symFont.setPixelSize(QGIView::calculateFontPixelSize(m_symSize));
int fontSize = QGIView::exactFontSize(Base::Tools::toStdString(m_symFont.family()), m_symSize);
m_symFont.setPixelSize(fontSize);
m_symbol1->setFont(m_symFont);
@@ -199,33 +218,28 @@ void QGISectionLine::makeSymbolsTrad()
m_symbol2->setPlainText(QString::fromUtf8(m_symbol));
QRectF symRect = m_symbol1->boundingRect();
double symWidth = symRect.width();
double symHeight = symRect.height();
double symbolFudge = 0.75;
double angle = atan2f(m_arrowDir.y, m_arrowDir.x);
if (angle < 0.0) {
angle = 2 * M_PI + angle;
}
Base::Vector3d adjustVector(cos(angle) * symWidth, sin(angle) * symHeight, 0.0);
adjustVector = DrawUtil::invertY(adjustVector) * symbolFudge;
QPointF qAdjust(adjustVector.x, adjustVector.y);
double gap = 0.5 * symHeight; //symHeight as surrogate for char box
QPointF posSymbol1 = m_arrow1->pos() + qAdjust;
m_symbol1->centerAt(posSymbol1);
QPointF motion1(m_arrowDir1.x, -m_arrowDir1.y); //move in same direction as arrow
QPointF motion2(m_arrowDir2.x, -m_arrowDir2.y); //Qt y coords!
QPointF posSymbol2 = m_arrow2->pos() + qAdjust;
m_symbol2->centerAt(posSymbol2);
QPointF symPos1 = m_arrowPos1 + motion1 * gap;
QPointF symPos2 = m_arrowPos2 + motion2 * gap;
m_symbol1->setTransformOriginPoint(m_symbol1->mapFromParent(posSymbol1));
m_symbol1->setRotation(360.0 - rotation());
m_symbol2->setTransformOriginPoint(m_symbol2->mapFromParent(posSymbol2));
m_symbol1->centerAt(symPos1);
m_symbol2->centerAt(symPos2);
m_symbol1->setTransformOriginPoint(m_symbol1->mapFromParent(symPos1));
m_symbol1->setRotation(360.0 - rotation()); //to Qt angle
m_symbol2->setTransformOriginPoint(m_symbol2->mapFromParent(symPos2));
m_symbol2->setRotation(360.0 - rotation());
}
//symbols go at ends of extensions
void QGISectionLine::makeSymbolsISO()
{
prepareGeometryChange();
// m_symFont.setPixelSize(QGIView::calculateFontPixelSize(m_symSize));
int fontSize = QGIView::exactFontSize(Base::Tools::toStdString(m_symFont.family()), m_symSize);
m_symFont.setPixelSize(fontSize);
m_symbol1->setFont(m_symFont);
@@ -233,79 +247,111 @@ void QGISectionLine::makeSymbolsISO()
m_symbol2->setFont(m_symFont);
m_symbol2->setPlainText(QString::fromUtf8(m_symbol));
QPointF symPosStart, symPosEnd;
//no normalize() for QPointF
QPointF dist = (m_start - m_end);
double lenDist = sqrt(dist.x()*dist.x() + dist.y()*dist.y());
QPointF offsetDir = dist / lenDist;
QRectF symRect = m_symbol1->boundingRect();
double symWidth = symRect.width();
double symHeight = symRect.height();
double gap = 0.5 * symHeight; //symHeight as surrogate for char box
double symbolFudge = 0.75;
double angle = atan2f(offsetDir.y(), offsetDir.x());
if (angle < 0.0) {
angle = 2.0 * M_PI + angle;
}
Base::Vector3d adjustVector(cos(angle) * symWidth, sin(angle) * symHeight, 0.0);
adjustVector = adjustVector * symbolFudge;
QPointF qAdjust(adjustVector.x, adjustVector.y);
QPointF motion1(-m_arrowDir1.x, m_arrowDir1.y); //move away from extension end
QPointF motion2(-m_arrowDir2.x, m_arrowDir2.y); //Qt y coords!
symPosStart = m_start + qAdjust;
symPosEnd = m_end - qAdjust;
QPointF symPos1 = m_endExt1 + motion1 * gap;
QPointF symPos2 = m_endExt2 + motion2 * gap;
m_symbol1->centerAt(symPosStart);
m_symbol2->centerAt(symPosEnd);
m_symbol1->centerAt(symPos1);
m_symbol2->centerAt(symPos2);
m_symbol1->setTransformOriginPoint(m_symbol1->mapFromParent(symPosStart));
m_symbol1->setTransformOriginPoint(m_symbol1->mapFromParent(symPos1));
m_symbol1->setRotation(360.0 - rotation());
m_symbol2->setTransformOriginPoint(m_symbol2->mapFromParent(symPosEnd));
m_symbol2->setTransformOriginPoint(m_symbol2->mapFromParent(symPos2));
m_symbol2->setRotation(360.0 - rotation());
}
//extension lines are on the stock side of the section line
void QGISectionLine::extensionEndsTrad()
{
QPointF offsetDir(m_arrowDir.x, -m_arrowDir.y);
if (m_arrowMode == SINGLEDIRECTIONMODE) {
QPointF offsetDir(m_arrowDir.x, -m_arrowDir.y); //inverted Y
offsetDir = normalizeQPointF(offsetDir);
//extensions for oblique section line needs to be a bit longer
double oblique = 1.0;
if ( !DrawUtil::fpCompare((m_arrowDir.x + m_arrowDir.y), 1.0) ) {
oblique = 1.25;
//draw from section line endpoint
QPointF offsetEnd = m_extLen * offsetDir;
m_beginExt1 = m_start;
m_endExt1 = m_start + offsetEnd;
m_beginExt2 = m_end;
m_endExt2 = m_end + offsetEnd;
} else {
//extension lines run from point on section line to arrowhead
m_beginExt1 = m_start;
m_endExt1 = getArrowPosition(m_arrowDir1, m_start);
m_beginExt2 = m_end;
m_endExt2 = getArrowPosition(m_arrowDir2, m_end);
}
//draw from section line endpoint
QPointF offsetEnd = oblique * m_extLen * offsetDir;
m_beginExt1 = m_start;
m_endExt1 = m_start + offsetEnd;
m_beginExt2 = m_end;
m_endExt2 = m_end + offsetEnd;
}
//the extension lines are on the waste side of the section line!
void QGISectionLine::extensionEndsISO()
{
//lines are offset to other side of section line!
QPointF offsetDir(m_arrowDir.x, -m_arrowDir.y);
offsetDir = offsetDir * -1.0;
if (m_arrowMode == SINGLEDIRECTIONMODE) {
QPointF offsetDir(-m_arrowDir.x, m_arrowDir.y); //reversed and inverted y
offsetDir = normalizeQPointF(offsetDir);
//extensions for oblique section line needs to be a bit longer?
//this is just esthetics
double oblique = 1.0;
if ( !DrawUtil::fpCompare((m_arrowDir.x + m_arrowDir.y), 1.0) ) {
oblique = 1.10;
//draw from section line endpoint less arrow length
QPointF offsetStart = offsetDir * Rez::guiX(QGIArrow::getPrefArrowSize());
QPointF offsetEnd = m_extLen * offsetDir;
m_beginExt1 = m_start + offsetStart;
m_endExt1 = m_start + offsetStart + offsetEnd;
m_beginExt2 = m_end + offsetStart;
m_endExt2 = m_end + offsetStart + offsetEnd;
} else {
//extension lines run in reverse of arrow direction from base of arrowhead for distance m_extLen
QPointF offsetDir1(-m_arrowDir1.x, m_arrowDir1.y); //reversed and inverted y
offsetDir1 = normalizeQPointF(offsetDir1);
QPointF offsetStart1 = offsetDir1 * Rez::guiX(QGIArrow::getPrefArrowSize());
QPointF offsetEnd1 = m_extLen * offsetDir1;
m_beginExt1 = m_start + offsetStart1;
m_endExt1 = m_start + offsetStart1 + offsetEnd1;
QPointF offsetDir2(-m_arrowDir2.x, m_arrowDir2.y); //reversed and inverted y
offsetDir2 = normalizeQPointF(offsetDir2);
QPointF offsetStart2 = offsetDir2 * Rez::guiX(QGIArrow::getPrefArrowSize());
QPointF offsetEnd2 = m_extLen * offsetDir2;
m_beginExt2 = m_end + offsetStart2;
m_endExt2 = m_end + offsetStart2 + offsetEnd2;
}
//draw from section line endpoint less arrow length
QPointF offsetStart = offsetDir * Rez::guiX(QGIArrow::getPrefArrowSize());
QPointF offsetEnd = oblique * m_extLen * offsetDir;
m_beginExt1 = m_start + offsetStart;
m_endExt1 = m_start + offsetStart + offsetEnd;
m_beginExt2 = m_end + offsetStart;
m_endExt2 = m_end + offsetStart + offsetEnd;
}
void QGISectionLine::makeChangePointMarks()
{
// Base::Console().Message("QGISL::makeChangePointMarks()\n");
double segmentLength = 0.50 * QGIArrow::getPrefArrowSize();
QPen cPointPen;
//TODO: this should really be 2.0 * thickLineWidth, but we only have one
//width available (which should be 'thin', for the section line)
cPointPen.setWidthF(2.0 * getWidth());
cPointPen.setColor(getSectionColor());
cPointPen.setStyle(Qt::SolidLine);
for (auto& cPoint : m_changePointData) {
QGraphicsPathItem* cPointItem = new QGraphicsPathItem();
addToGroup(cPointItem);
QPainterPath pPath;
QPointF location = cPoint.getLocation();
QPointF start = location + cPoint.getPreDirection() * segmentLength;
QPointF end = location + cPoint.getPostDirection() * segmentLength;
pPath.moveTo(Rez::guiPt(start));
pPath.lineTo(Rez::guiPt(location));
pPath.lineTo(Rez::guiPt(end));
cPointItem->setPath(pPath);
cPointItem->setPen(cPointPen);
cPointItem->setZValue(ZVALUE::SECTIONLINE + 1);
cPointItem->setPos(0.0, 0.0);
m_changePointMarks.push_back(cPointItem);
}
}
void QGISectionLine::setEnds(Base::Vector3d l1, Base::Vector3d l2)
{
m_l1 = l1;
@@ -333,8 +379,46 @@ void QGISectionLine::setDirection(double xDir, double yDir)
void QGISectionLine::setDirection(Base::Vector3d dir)
{
m_arrowMode = SINGLEDIRECTIONMODE;
m_arrowDir = dir;
m_arrowDir.Normalize();
m_arrowDir1 = dir;
m_arrowDir1.Normalize();
m_arrowDir2 = dir;
m_arrowDir2.Normalize();
}
void QGISectionLine::setArrowDirections(Base::Vector3d dir1, Base::Vector3d dir2)
{
m_arrowMode = MULTIDIRECTIONMODE;
m_arrowDir1 = dir1;
m_arrowDir1.Normalize();
m_arrowDir2 = dir2;
m_arrowDir2.Normalize();
}
//convert an arrow direction vector into a Qt rotation angle degrees
double QGISectionLine::getArrowRotation(Base::Vector3d arrowDir)
{
arrowDir.Normalize();
double angle = atan2f(arrowDir.y, arrowDir.x);
if (angle < 0.0) {
angle = 2 * M_PI + angle;
}
double arrowRotation = 360.0 - angle * (180.0/M_PI); //convert to Qt rotation (clockwise degrees)
return arrowRotation;
}
QPointF QGISectionLine::getArrowPosition(Base::Vector3d arrowDir, QPointF refPoint)
{
QPointF qArrowDir(arrowDir.x, -arrowDir.y); //remember Y dir is flipped
qArrowDir = normalizeQPointF(qArrowDir);
double offsetLength = m_extLen + Rez::guiX(QGIArrow::getPrefArrowSize());
QPointF offsetVec = offsetLength * qArrowDir;
QPointF arrowPos = refPoint + offsetVec;
return arrowPos;
}
void QGISectionLine::setFont(QFont f, double fsize)
@@ -343,6 +427,44 @@ void QGISectionLine::setFont(QFont f, double fsize)
m_symSize = fsize;
}
void QGISectionLine::setPath(QPainterPath& path)
{
m_line->setPath(path);
}
void QGISectionLine::setChangePoints(TechDraw::ChangePointVector changePointData)
{
m_changePointData = changePointData;
clearChangePointMarks();
}
void QGISectionLine::clearChangePoints()
{
clearChangePointMarks();
m_changePointData.clear();
}
void QGISectionLine::clearChangePointMarks()
{
if (!m_changePointMarks.empty()) {
for (auto& cPoint : m_changePointMarks) {
cPoint->hide();
scene()->removeItem(cPoint);
delete cPoint;
}
m_changePointMarks.clear();
}
}
//QPointF does not have length or normalize methods
QPointF QGISectionLine::normalizeQPointF(QPointF inPoint)
{
double x2 = inPoint.x() * inPoint.x();
double y2 = inPoint.y() * inPoint.y();
double root = sqrt(x2 + y2);
return inPoint / root;
}
void QGISectionLine::setSectionColor(QColor c)
{
setColor(c);
@@ -416,11 +538,6 @@ void QGISectionLine::setTools()
m_line->setPen(m_pen);
// m_arrow1->setPen(m_pen);
// m_arrow2->setPen(m_pen);
// m_arrow1->setBrush(m_brush);
// m_arrow2->setBrush(m_brush);
m_arrow1->setNormalColor(m_colCurrent);
m_arrow1->setFillColor(m_colCurrent);
m_arrow1->setPrettyNormal();

View File

@@ -28,9 +28,12 @@
#include <QColor>
#include <QFont>
#include <QPointF>
#include <QPainterPath>
#include <Base/Vector3D.h>
#include <Mod/TechDraw/App/DrawComplexSection.h>
#include "QGCustomText.h"
#include "QGIDecoration.h"
@@ -53,34 +56,46 @@ public:
void setEnds(Base::Vector3d l1, Base::Vector3d l2);
void setBounds(double x1, double y1, double x2, double y2);
void setPath(QPainterPath& path);
void setSymbol(char* sym);
void setDirection(double xDir, double yDir);
void setDirection(Base::Vector3d dir);
void setArrowDirections(Base::Vector3d dir1, Base::Vector3d dir2);
void setFont(QFont f, double fsize);
void setSectionStyle(int style);
void setSectionColor(QColor c);
void setPathMode(bool mode) { m_pathMode = mode; }
bool pathMode() { return m_pathMode; }
void setChangePoints(TechDraw::ChangePointVector changePoints);
void clearChangePoints();
virtual void draw();
protected:
QColor getSectionColor();
Qt::PenStyle getSectionStyle();
void makeLine();
void makeSectionLine();
void makeExtensionLine();
void makeArrows();
void makeArrowsTrad();
void makeArrowsISO();
void makeSymbols();
void makeSymbolsTrad();
void makeSymbolsISO();
void makeChangePointMarks();
void setTools();
int getPrefSectionStandard();
void extensionEndsISO();
void extensionEndsTrad();
double getArrowRotation(Base::Vector3d arrowDir);
QPointF getArrowPosition(Base::Vector3d arrowDir, QPointF refPoint);
void clearChangePointMarks();
static QPointF normalizeQPointF(QPointF inPoint);
private:
char* m_symbol;
QGraphicsPathItem* m_line; //primpath?
QGraphicsPathItem* m_line;
QGraphicsPathItem* m_extend;
QGIArrow* m_arrow1;
QGIArrow* m_arrow2;
QGCustomText* m_symbol1;
@@ -92,15 +107,21 @@ private:
QFont m_symFont;
double m_symSize;
double m_arrowSize;
//QColor m_color;
double m_extLen;
// int m_sectionFormat; //0 = ASME, 1 = ISO
Base::Vector3d m_l1; //end of main section line
Base::Vector3d m_l2; //end of main section line
QPointF m_beginExt1; //start of extension line 1
QPointF m_endExt1; //end of extension line 1
QPointF m_beginExt2; //start of extension line 2
QPointF m_endExt2; //end of extension line 1
bool m_pathMode; //use external path for line
int m_arrowMode; //0 = 1 direction for both arrows, 1 = direction for each arrow
Base::Vector3d m_arrowDir1;
Base::Vector3d m_arrowDir2;
QPointF m_arrowPos1;
QPointF m_arrowPos2;
std::vector<QGraphicsPathItem*> m_changePointMarks;
TechDraw::ChangePointVector m_changePointData;
};
}

View File

@@ -56,6 +56,7 @@
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Mod/TechDraw/App/DrawViewSection.h>
#include <Mod/TechDraw/App/DrawComplexSection.h>
#include <Mod/TechDraw/App/DrawHatch.h>
#include <Mod/TechDraw/App/DrawGeomHatch.h>
#include <Mod/TechDraw/App/DrawViewDetail.h>
@@ -446,10 +447,10 @@ void QGIViewPart::drawViewPart()
if (!vp)
return;
float lineWidth = vp->LineWidth.getValue() * lineScaleFactor;
float lineWidthHid = vp->HiddenWidth.getValue() * lineScaleFactor;
float lineWidthIso = vp->IsoWidth.getValue() * lineScaleFactor;
// float lineWidthExtra = viewPart->ExtraWidth.getValue() * lineScaleFactor;
float lineWidth = vp->LineWidth.getValue() * lineScaleFactor; //thick
float lineWidthHid = vp->HiddenWidth.getValue() * lineScaleFactor; //thin
float lineWidthIso = vp->IsoWidth.getValue() * lineScaleFactor; //graphic
// float lineWidthExtra = viewPart->ExtraWidth.getValue() * lineScaleFactor; //extra
bool showAll = vp->ShowAllEdges.getValue();
prepareGeometryChange();
@@ -803,7 +804,11 @@ void QGIViewPart::drawAllSectionLines()
if (vp->ShowSectionLine.getValue()) {
auto refs = viewPart->getSectionRefs();
for (auto& r:refs) {
drawSectionLine(r, true);
if (r->isDerivedFrom(DrawComplexSection::getClassTypeId())) {
drawComplexSectionLine(r, true);
} else {
drawSectionLine(r, true);
}
}
}
}
@@ -820,8 +825,10 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
return;
auto vp = static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject()));
if (!vp)
if (!vp) {
return;
}
float lineWidthThin = vp->HiddenWidth.getValue() * lineScaleFactor; //thin
if (b) {
QGISectionLine* sectionLine = new QGISectionLine();
@@ -829,7 +836,7 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
sectionLine->setSymbol(const_cast<char*>(viewSection->SectionSymbol.getValue()));
sectionLine->setSectionStyle(vp->SectionLineStyle.getValue());
sectionLine->setSectionColor(vp->SectionLineColor.getValue().asValue<QColor>());
sectionLine->setPathMode(false);
//find the ends of the section line
double scale = viewPart->getScale();
std::pair<Base::Vector3d, Base::Vector3d> sLineEnds = viewSection->sectionLineEnds();
@@ -839,11 +846,8 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
//which way to the arrows point?
Base::Vector3d lineDir = l2 - l1;
lineDir.Normalize();
Base::Vector3d normalDir = viewSection->SectionNormal.getValue();
Base::Vector3d projNormal = viewPart->projectPoint(normalDir);
projNormal.Normalize();
Base::Vector3d arrowDir = viewSection->SectionNormal.getValue();
arrowDir = - viewPart->projectPoint(arrowDir); //arrows point reverse of sectionNormal(extrusion dir)
arrowDir = - viewPart->projectPoint(arrowDir); //arrows point reverse of sectionNormal
sectionLine->setDirection(arrowDir.x, -arrowDir.y); //invert Y
//make the section line a little longer
@@ -853,7 +857,7 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
//set the general parameters
sectionLine->setPos(0.0, 0.0);
sectionLine->setWidth(Rez::guiX(vp->LineWidth.getValue()));
sectionLine->setWidth(lineWidthThin);
double fontSize = Preferences::dimFontSizeMM();
sectionLine->setFont(getFont(), fontSize);
sectionLine->setZValue(ZVALUE::SECTIONLINE);
@@ -862,6 +866,73 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
}
}
void QGIViewPart::drawComplexSectionLine(TechDraw::DrawViewSection* viewSection, bool b)
{
Q_UNUSED(b);
TechDraw::DrawViewPart *viewPart = static_cast<TechDraw::DrawViewPart *>(getViewObject());
if (!viewPart)
return;
if (!viewSection)
return;
auto vp = static_cast<ViewProviderViewPart*>(getViewProvider(getViewObject()));
if (!vp) {
return;
}
float lineWidthThin = vp->HiddenWidth.getValue() * lineScaleFactor; //thin
auto dcs = static_cast<DrawComplexSection*>(viewSection);
BaseGeomPtrVector edges = dcs->makeSectionLineGeometry();
QPainterPath wirePath;
QPainterPath firstSeg = drawPainterPath(edges.front());
wirePath.connectPath(firstSeg);
int edgeCount = edges.size();
//NOTE: if the edges are not in nose to tail order, Qt will insert extra segments
//that will overlap the segments we add. for interupted line styles, this
//will make the line look continuous. This is prevented in
//DrawComplexSection::makeSectionLineGeometry by calling makeNoseToTailWire
for (int i = 1; i < edgeCount; i++) {
QPainterPath edgePath = drawPainterPath(edges.at(i));
wirePath.connectPath(edgePath);
}
std::pair<Base::Vector3d, Base::Vector3d> ends = dcs->sectionLineEnds();
Base::Vector3d vStart = Rez::guiX(ends.first); //already scaled by dcs
Base::Vector3d vEnd = Rez::guiX(ends.second);
QGISectionLine* sectionLine = new QGISectionLine();
addToGroup(sectionLine);
sectionLine->setSymbol(const_cast<char*>(viewSection->SectionSymbol.getValue()));
sectionLine->setSectionStyle(vp->SectionLineStyle.getValue());
sectionLine->setSectionColor(vp->SectionLineColor.getValue().asValue<QColor>());
sectionLine->setPathMode(true);
sectionLine->setPath(wirePath);
sectionLine->setEnds(vStart, vEnd);
if (vp->SectionLineMarks.getValue()) {
sectionLine->setChangePoints(dcs->getChangePointsFromSectionLine());
} else {
sectionLine->clearChangePoints();
}
if (dcs->ProjectionStrategy.isValue("Single")) {
Base::Vector3d arrowDirSingle = viewSection->SectionNormal.getValue();
arrowDirSingle = - viewPart->projectPoint(arrowDirSingle); //arrows are opposite section normal
sectionLine->setDirection(arrowDirSingle.x, -arrowDirSingle.y); //invert y for Qt
} else {
std::pair<Base::Vector3d, Base::Vector3d> dirsPiecewise = dcs->sectionArrowDirs();
dirsPiecewise.first = DrawUtil::invertY(dirsPiecewise.first);
dirsPiecewise.second = DrawUtil::invertY(dirsPiecewise.second);
sectionLine->setArrowDirections(dirsPiecewise.first, dirsPiecewise.second);
}
//set the general parameters
sectionLine->setPos(0.0, 0.0);
sectionLine->setWidth(lineWidthThin);
double fontSize = Preferences::dimFontSizeMM();
sectionLine->setFont(getFont(), fontSize);
sectionLine->setZValue(ZVALUE::SECTIONLINE);
sectionLine->setRotation(- viewPart->Rotation.getValue());
sectionLine->draw();
}
//TODO: use Cosmetic::CenterLine object for this to make it usable for dims.
void QGIViewPart::drawCenterLines(bool b)
{
@@ -885,35 +956,28 @@ void QGIViewPart::drawCenterLines(bool b)
centerLine = new QGICenterLine();
addToGroup(centerLine);
centerLine->setPos(0.0, 0.0);
//this should work from the viewPart's bbox, not the border
// double scale = viewPart->getScale();
double width = Rez::guiX(viewPart->getBoxX());
sectionSpan = width + sectionFudge;
// sectionSpan = m_border->rect().width() + sectionFudge;
xVal = sectionSpan / 2.0;
yVal = 0.0;
centerLine->setIntersection(horiz && vert);
centerLine->setBounds(-xVal, -yVal, xVal, yVal);
centerLine->setWidth(Rez::guiX(vp->HiddenWidth.getValue()));
centerLine->setZValue(ZVALUE::SECTIONLINE);
// centerLine->setRotation(viewPart->Rotation.getValue());
centerLine->draw();
}
if (vert) {
centerLine = new QGICenterLine();
addToGroup(centerLine);
centerLine->setPos(0.0, 0.0);
// double scale = viewPart->getScale();
double height = Rez::guiX(viewPart->getBoxY());
sectionSpan = height + sectionFudge;
// sectionSpan = (m_border->rect().height() - m_label->boundingRect().height()) + sectionFudge;
xVal = 0.0;
yVal = sectionSpan / 2.0;
centerLine->setIntersection(horiz && vert);
centerLine->setBounds(-xVal, -yVal, xVal, yVal);
centerLine->setWidth(Rez::guiX(vp->HiddenWidth.getValue()));
centerLine->setZValue(ZVALUE::SECTIONLINE);
// centerLine->setRotation(viewPart->Rotation.getValue());
centerLine->draw();
}
}

View File

@@ -68,6 +68,7 @@ public:
QRectF boundingRect() const override;
virtual void drawAllSectionLines();
virtual void drawSectionLine(TechDraw::DrawViewSection* s, bool b);
virtual void drawComplexSectionLine(TechDraw::DrawViewSection* viewSection, bool b);
virtual void drawCenterLines(bool b);
virtual void drawHighlight(TechDraw::DrawViewDetail* viewDetail, bool b);
virtual void drawMatting();

View File

@@ -51,6 +51,7 @@
<file>icons/actions/TechDraw_View.svg</file>
<file>icons/actions/TechDraw_WeldSymbol.svg</file>
<file>icons/actions/TechDraw_SurfaceFinishSymbols.svg</file>
<file>icons/actions/TechDraw_ComplexSection.svg</file>
<file>icons/arrow-ccw.svg</file>
<file>icons/arrow-cw.svg</file>
<file>icons/arrow-down.svg</file>
@@ -180,6 +181,8 @@
<!-- main wb icon and preferences icons -->
<file>icons/preferences-techdraw.svg</file>
<!-- bitmap images -->
<!-- translations -->
<file>translations/TechDraw_af.qm</file>
<file>translations/TechDraw_ar.qm</file>

View File

@@ -0,0 +1,767 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
id="svg249"
height="64"
width="64"
version="1.1">
<defs
id="defs3">
<marker
style="overflow:visible;"
id="Arrow2Mend"
refX="0.0"
refY="0.0"
orient="auto">
<path
transform="scale(0.6) rotate(180) translate(0,0)"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1"
id="path5645" />
</marker>
<marker
style="overflow:visible;"
id="marker7794"
refX="0.0"
refY="0.0"
orient="auto">
<path
transform="scale(0.4) rotate(180) translate(10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path7792" />
</marker>
<marker
style="overflow:visible;"
id="marker7676"
refX="0.0"
refY="0.0"
orient="auto">
<path
transform="scale(0.4) rotate(180) translate(10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path7674" />
</marker>
<marker
style="overflow:visible;"
id="marker7510"
refX="0.0"
refY="0.0"
orient="auto">
<path
transform="scale(0.4) rotate(180) translate(10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path7508" />
</marker>
<marker
style="overflow:visible;"
id="marker7386"
refX="0.0"
refY="0.0"
orient="auto">
<path
transform="scale(0.4) rotate(180) translate(10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path7384" />
</marker>
<marker
style="overflow:visible;"
id="Arrow1Mend"
refX="0.0"
refY="0.0"
orient="auto">
<path
transform="scale(0.4) rotate(180) translate(10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path5627" />
</marker>
<marker
style="overflow:visible"
id="marker7236"
refX="0.0"
refY="0.0"
orient="auto">
<path
transform="scale(0.6) translate(0,0)"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1"
id="path7234" />
</marker>
<marker
style="overflow:visible"
id="marker7190"
refX="0.0"
refY="0.0"
orient="auto">
<path
transform="scale(0.6) translate(0,0)"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1"
id="path7188" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Sstart"
refX="0.0"
refY="0.0"
orient="auto">
<path
transform="scale(0.2) translate(6,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path5630" />
</marker>
<marker
style="overflow:visible"
id="Arrow2Lstart"
refX="0.0"
refY="0.0"
orient="auto">
<path
transform="scale(1.1) translate(1,0)"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1"
id="path5636" />
</marker>
<marker
style="overflow:visible"
id="Arrow2Mstart"
refX="0.0"
refY="0.0"
orient="auto">
<path
transform="scale(0.6) translate(0,0)"
d="M 8.7185878,4.0337352 L -2.2072895,0.016013256 L 8.7185884,-4.0017078 C 6.9730900,-1.6296469 6.9831476,1.6157441 8.7185878,4.0337352 z "
style="fill-rule:evenodd;stroke-width:0.625;stroke-linejoin:round;stroke:#000000;stroke-opacity:1;fill:#000000;fill-opacity:1"
id="path5642" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart"
refX="0.0"
refY="0.0"
orient="auto">
<path
transform="scale(0.8) translate(12.5,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt;stroke-opacity:1;fill:#000000;fill-opacity:1"
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
id="path5618" />
</marker>
<linearGradient
id="linearGradient3999">
<stop
id="stop4001"
offset="0"
style="stop-color:#34e0e2;stop-opacity:1" />
<stop
id="stop4003"
offset="1"
style="stop-color:#06989a;stop-opacity:1" />
</linearGradient>
<radialGradient
gradientTransform="matrix(-2.774389,0,0,1.969706,112.7623,-872.8854)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient5060"
id="radialGradient5031"
fy="486.64789"
fx="605.71429"
r="117.14286"
cy="486.64789"
cx="605.71429" />
<linearGradient
id="linearGradient5060">
<stop
offset="0"
style="stop-color:#000000;stop-opacity:1"
id="stop5062" />
<stop
offset="1"
style="stop-color:#000000;stop-opacity:0"
id="stop5064" />
</linearGradient>
<radialGradient
gradientTransform="matrix(2.774389,0,0,1.969706,-1891.633,-872.8854)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient5060"
id="radialGradient5029"
fy="486.64789"
fx="605.71429"
r="117.14286"
cy="486.64789"
cx="605.71429" />
<linearGradient
id="linearGradient5048">
<stop
offset="0"
style="stop-color:#000000;stop-opacity:0"
id="stop5050" />
<stop
offset="0.5"
style="stop-color:#000000;stop-opacity:1"
id="stop5056" />
<stop
offset="1"
style="stop-color:#000000;stop-opacity:0"
id="stop5052" />
</linearGradient>
<linearGradient
gradientTransform="matrix(2.774389,0,0,1.969706,-1892.179,-872.8854)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient5048"
id="linearGradient5027"
y2="609.50507"
x2="302.85715"
y1="366.64789"
x1="302.85715" />
<linearGradient
id="linearGradient4542">
<stop
offset="0"
style="stop-color:#000000;stop-opacity:1"
id="stop4544" />
<stop
offset="1"
style="stop-color:#000000;stop-opacity:0"
id="stop4546" />
</linearGradient>
<radialGradient
gradientTransform="matrix(1,0,0,0.284916,0,30.08928)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient4542"
id="radialGradient4548"
fy="42.07798"
fx="24.306795"
r="15.821514"
cy="42.07798"
cx="24.306795" />
<linearGradient
id="linearGradient15662">
<stop
offset="0"
style="stop-color:#ffffff;stop-opacity:1"
id="stop15664" />
<stop
offset="1"
style="stop-color:#f8f8f8;stop-opacity:1"
id="stop15666" />
</linearGradient>
<radialGradient
gradientUnits="userSpaceOnUse"
id="aigrd3"
fy="64.567902"
fx="20.892099"
r="5.257"
cy="64.567902"
cx="20.892099">
<stop
offset="0"
style="stop-color:#f0f0f0;stop-opacity:1"
id="stop15573" />
<stop
offset="1"
style="stop-color:#9a9a9a;stop-opacity:1"
id="stop15575" />
</radialGradient>
<radialGradient
gradientUnits="userSpaceOnUse"
id="aigrd2"
fy="114.5684"
fx="20.892099"
r="5.256"
cy="114.5684"
cx="20.892099">
<stop
offset="0"
style="stop-color:#f0f0f0;stop-opacity:1"
id="stop15566" />
<stop
offset="1"
style="stop-color:#9a9a9a;stop-opacity:1"
id="stop15568" />
</radialGradient>
<linearGradient
id="linearGradient269">
<stop
offset="0"
style="stop-color:#a3a3a3;stop-opacity:1"
id="stop270" />
<stop
offset="1"
style="stop-color:#4c4c4c;stop-opacity:1"
id="stop271" />
</linearGradient>
<linearGradient
id="linearGradient259">
<stop
offset="0"
style="stop-color:#fafafa;stop-opacity:1"
id="stop260" />
<stop
offset="1"
style="stop-color:#bbbbbb;stop-opacity:1"
id="stop261" />
</linearGradient>
<linearGradient
id="linearGradient12512">
<stop
offset="0"
style="stop-color:#ffffff;stop-opacity:1"
id="stop12513" />
<stop
offset="0.5"
style="stop-color:#fff520;stop-opacity:0.89108908"
id="stop12517" />
<stop
offset="1"
style="stop-color:#fff300;stop-opacity:0"
id="stop12514" />
</linearGradient>
<radialGradient
gradientTransform="matrix(0.968273,0,0,1.032767,3.4281936,-47.492271)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient269"
id="radialGradient15656"
fy="3.7561285"
fx="8.824419"
r="37.751713"
cy="3.7561285"
cx="8.824419" />
<radialGradient
gradientTransform="matrix(0.960493,0,0,1.041132,0.07464063,-48.138718)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient259"
id="radialGradient15658"
fy="35.736916"
fx="33.966679"
r="86.70845"
cy="35.736916"
cx="33.966679" />
<radialGradient
gradientTransform="matrix(0.968273,0,0,1.032767,3.4281936,-47.492271)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient15662"
id="radialGradient15668"
fy="7.2678967"
fx="8.1435566"
r="38.158695"
cy="7.2678967"
cx="8.1435566" />
<radialGradient
gradientTransform="matrix(0.229703,0,0,0.229703,4.613529,3.979808)"
gradientUnits="userSpaceOnUse"
xlink:href="#aigrd2"
id="radialGradient2283"
fy="114.5684"
fx="20.892099"
r="5.256"
cy="114.5684"
cx="20.892099" />
<radialGradient
gradientTransform="matrix(0.229703,0,0,0.229703,4.613529,3.979808)"
gradientUnits="userSpaceOnUse"
xlink:href="#aigrd3"
id="radialGradient2285"
fy="64.567902"
fx="20.892099"
r="5.257"
cy="64.567902"
cx="20.892099" />
<linearGradient
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3377-76"
id="linearGradient4343"
y2="41.792759"
x2="44.524982"
y1="14.452502"
x1="18.971846" />
<linearGradient
id="linearGradient3377-76">
<stop
offset="0"
style="stop-color:#faff2b;stop-opacity:1"
id="stop3379-5" />
<stop
offset="0.5"
style="stop-color:#fcb915;stop-opacity:1"
id="stop4345" />
<stop
offset="1"
style="stop-color:#c68708;stop-opacity:1"
id="stop3381-7" />
</linearGradient>
<linearGradient
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3377-76"
id="linearGradient4349"
y2="108.75008"
x2="175.6825"
y1="79.160103"
x1="145.64697" />
<linearGradient
id="linearGradient4482">
<stop
offset="0"
style="stop-color:#faff2b;stop-opacity:1"
id="stop4484" />
<stop
offset="0.5"
style="stop-color:#fcb915;stop-opacity:1"
id="stop4486" />
<stop
offset="1"
style="stop-color:#c68708;stop-opacity:1"
id="stop4488" />
</linearGradient>
<radialGradient
gradientTransform="matrix(0.97435,0.2250379,-0.4623105,2.0016728,48.487554,-127.99883)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3377"
id="radialGradient4351"
fy="97.369568"
fx="135.38333"
r="19.467436"
cy="97.369568"
cx="135.38333" />
<linearGradient
id="linearGradient3377">
<stop
offset="0"
style="stop-color:#faff2b;stop-opacity:1"
id="stop3379" />
<stop
offset="1"
style="stop-color:#ffaa00;stop-opacity:1"
id="stop3381" />
</linearGradient>
<radialGradient
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3377"
id="radialGradient4353"
fy="28.869568"
fx="45.883327"
r="19.467436"
cy="28.869568"
cx="45.883327" />
<linearGradient
id="linearGradient4495">
<stop
offset="0"
style="stop-color:#faff2b;stop-opacity:1"
id="stop4497" />
<stop
offset="1"
style="stop-color:#ffaa00;stop-opacity:1"
id="stop4499" />
</linearGradient>
<radialGradient
r="5.256"
fy="114.5684"
fx="20.892099"
cy="114.5684"
cx="20.892099"
gradientTransform="matrix(0.229703,0,0,0.229703,4.613529,3.979808)"
gradientUnits="userSpaceOnUse"
id="radialGradient2283-4"
xlink:href="#aigrd2-2" />
<radialGradient
id="aigrd2-2"
cx="20.892099"
cy="114.5684"
r="5.256"
fx="20.892099"
fy="114.5684"
gradientUnits="userSpaceOnUse">
<stop
offset="0"
style="stop-color:#F0F0F0"
id="stop15566-3" />
<stop
offset="1.0000000"
style="stop-color:#9a9a9a;stop-opacity:1.0000000;"
id="stop15568-2" />
</radialGradient>
<radialGradient
r="5.257"
fy="64.567902"
fx="20.892099"
cy="64.567902"
cx="20.892099"
gradientTransform="matrix(0.229703,0,0,0.229703,4.613529,3.979808)"
gradientUnits="userSpaceOnUse"
id="radialGradient2285-2"
xlink:href="#aigrd3-1" />
<radialGradient
id="aigrd3-1"
cx="20.892099"
cy="64.567902"
r="5.257"
fx="20.892099"
fy="64.567902"
gradientUnits="userSpaceOnUse">
<stop
offset="0"
style="stop-color:#F0F0F0"
id="stop15573-6" />
<stop
offset="1.0000000"
style="stop-color:#9a9a9a;stop-opacity:1.0000000;"
id="stop15575-8" />
</radialGradient>
<radialGradient
xlink:href="#linearGradient15662-7"
id="radialGradient15668-2"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.2992848,0,0,1.4315068,3.2140525,-64.437909)"
cx="8.1435566"
cy="7.2678967"
fx="8.1435566"
fy="7.2678967"
r="38.158695" />
<linearGradient
id="linearGradient15662-7">
<stop
id="stop15664-6"
offset="0.0000000"
style="stop-color:#ffffff;stop-opacity:1.0000000;" />
<stop
id="stop15666-1"
offset="1.0000000"
style="stop-color:#f8f8f8;stop-opacity:1.0000000;" />
</linearGradient>
<radialGradient
xlink:href="#linearGradient259-5"
id="radialGradient15658-4"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.3214205,0,0,1.4752426,-2.0839021,-66.146883)"
cx="33.966679"
cy="35.736916"
fx="33.966679"
fy="35.736916"
r="86.70845" />
<linearGradient
id="linearGradient259-5">
<stop
id="stop260-5"
offset="0.0000000"
style="stop-color:#fafafa;stop-opacity:1.0000000;" />
<stop
id="stop261-1"
offset="1.0000000"
style="stop-color:#bbbbbb;stop-opacity:1.0000000;" />
</linearGradient>
<radialGradient
xlink:href="#linearGradient269-1"
id="radialGradient15656-7"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(1.3321242,0,0,1.4633899,2.5298271,-65.230893)"
cx="3.3431637"
cy="37.388847"
fx="3.3431637"
fy="37.388847"
r="37.751713" />
<linearGradient
id="linearGradient269-1">
<stop
id="stop270-1"
offset="0.0000000"
style="stop-color:#a3a3a3;stop-opacity:1.0000000;" />
<stop
id="stop271-5"
offset="1.0000000"
style="stop-color:#4c4c4c;stop-opacity:1.0000000;" />
</linearGradient>
<linearGradient
y2="609.50507"
x2="302.85715"
y1="366.64789"
x1="302.85715"
gradientTransform="matrix(2.774389,0,0,1.969706,-1892.179,-872.8854)"
gradientUnits="userSpaceOnUse"
id="linearGradient5027-1"
xlink:href="#linearGradient5048-7" />
<linearGradient
id="linearGradient5048-7">
<stop
id="stop5050-4"
offset="0"
style="stop-color:black;stop-opacity:0;" />
<stop
style="stop-color:black;stop-opacity:1;"
offset="0.5"
id="stop5056-0" />
<stop
id="stop5052-9"
offset="1"
style="stop-color:black;stop-opacity:0;" />
</linearGradient>
<radialGradient
r="117.14286"
fy="486.64789"
fx="605.71429"
cy="486.64789"
cx="605.71429"
gradientTransform="matrix(2.774389,0,0,1.969706,-1891.633,-872.8854)"
gradientUnits="userSpaceOnUse"
id="radialGradient5029-4"
xlink:href="#linearGradient5060-8" />
<linearGradient
id="linearGradient5060-8">
<stop
id="stop5062-8"
offset="0"
style="stop-color:black;stop-opacity:1;" />
<stop
id="stop5064-2"
offset="1"
style="stop-color:black;stop-opacity:0;" />
</linearGradient>
<radialGradient
xlink:href="#linearGradient5060-8"
id="radialGradient3663"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-2.774389,0,0,1.969706,112.7623,-872.8854)"
cx="605.71429"
cy="486.64789"
fx="605.71429"
fy="486.64789"
r="117.14286" />
<radialGradient
xlink:href="#linearGradient5060-8"
id="radialGradient4227"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(-2.774389,0,0,1.969706,112.7623,-872.8854)"
cx="605.71429"
cy="486.64789"
fx="605.71429"
fy="486.64789"
r="117.14286" />
<radialGradient
gradientTransform="matrix(0.35714269,0.7142857,-1.3537553,0.6768774,100.50163,-81.878026)"
gradientUnits="userSpaceOnUse"
r="11.846154"
fy="17.566746"
fx="118.58249"
cy="17.566746"
cx="118.58249"
id="radialGradient4005"
xlink:href="#linearGradient3999" />
</defs>
<metadata
id="metadata4">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:creator>
<cc:Agent>
<dc:title>[agryson] Alexander Gryson</dc:title>
</cc:Agent>
</dc:creator>
<dc:source>http://agryson.net</dc:source>
<cc:license
rdf:resource="https://www.gnu.org/copyleft/lesser.html" />
<dc:title>TechDraw_View</dc:title>
<dc:date>2016-01-14</dc:date>
<dc:relation>http://www.freecadweb.org/wiki/index.php?title=Artwork</dc:relation>
<dc:publisher>
<cc:Agent>
<dc:title>FreeCAD</dc:title>
</cc:Agent>
</dc:publisher>
<dc:identifier>FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_View.svg</dc:identifier>
<dc:rights>
<cc:Agent>
<dc:title>FreeCAD LGPL2+</dc:title>
</cc:Agent>
</dc:rights>
<dc:contributor>
<cc:Agent>
<dc:title>[agryson] Alexander Gryson</dc:title>
</cc:Agent>
</dc:contributor>
</cc:Work>
<cc:License
rdf:about="http://creativecommons.org/licenses/by-sa/2.0/">
<cc:permits
rdf:resource="http://web.resource.org/cc/Reproduction" />
<cc:permits
rdf:resource="http://web.resource.org/cc/Distribution" />
<cc:requires
rdf:resource="http://web.resource.org/cc/Notice" />
<cc:requires
rdf:resource="http://web.resource.org/cc/Attribution" />
<cc:permits
rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
<cc:requires
rdf:resource="http://web.resource.org/cc/ShareAlike" />
</cc:License>
</rdf:RDF>
</metadata>
<g
transform="translate(0,16)"
style="display:inline"
id="layer4" />
<g
id="g5194">
<g
transform="translate(1.0000002)"
id="g9787">
<g
id="g5200"
transform="matrix(0.83344344,1.4435664,-1.4435664,0.83344344,27.489822,-46.272055)">
<g
id="g5186">
<path
transform="matrix(1.2727273,0,0,1.2727273,-115.54545,-3.7272729)"
d="m 134,21 a 11,11 0 0 1 -8.9962,10.81595 11,11 0 0 1 -12.27376,-6.8754 11,11 0 0 1 4.52453,-13.320849 L 123,21 Z"
id="path3211"
style="fill:url(#radialGradient4005);fill-opacity:1;stroke:#042a2a;stroke-width:1.57142854;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4.07999992;stroke-opacity:1" />
<path
transform="matrix(1.090909,0,0,1.0909091,-93.181808,0.090909)"
d="M 134,21 A 11,11 0 0 1 125.00406,31.815903 11,11 0 0 1 112.73023,24.941037 11,11 0 0 1 117.2539,11.62011 L 123,21 Z"
id="path3211-1"
style="fill:none;stroke:#34e0e2;stroke-width:1.83333313;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4.07999992;stroke-opacity:1" />
</g>
<path
style="fill:none;stroke:#042a2a;stroke-width:2;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 35.152416,10.111524 42.230483,21.41264 55.018587,21.35316"
id="path5188" />
</g>
<g
id="g9774"
transform="translate(-2)">
<path
style="fill:#babdb6;stroke:#042a2a;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 44.883046,58.135162 4.044609,-3.211896 v 6.185873 z"
id="path9722" />
<g
id="g9767">
<path
style="fill:none;stroke:#042a2a;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 49.165573,5.9715929 h 9.873606 V 58.194641 h -9.992565"
id="path9698" />
<path
style="fill:#babdb6;stroke:#042a2a;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 45.120964,6.1500317 49.165573,2.9381358 V 9.1240094 Z"
id="path9720" />
<path
style="fill:none;stroke:#babdb6;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 46.905351,5.9715929 H 59.03918 V 58.194641 H 47.381187"
id="path9696" />
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -0,0 +1,360 @@
/***************************************************************************
* Copyright (c) 2022 WandererFan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif // #ifndef _PreComp_
#include <QPushButton>
#include <BRep_Tool.hxx>
#include <gp_Pnt.hxx>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <App/Link.h>
#include <Base/Console.h>
#include <Base/Tools.h>
#include <Base/Quantity.h>
#include <Base/UnitsApi.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
#include <Gui/Control.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/Selection.h>
#include <Gui/ViewProvider.h>
#include <Gui/WaitCursor.h>
#include <Mod/TechDraw/App/DrawPage.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Mod/TechDraw/App/DrawComplexSection.h>
#include <Mod/TechDraw/App/Preferences.h>
#include <Mod/TechDraw/Gui/ui_TaskComplexSection.h>
#include "DrawGuiUtil.h"
#include "TaskComplexSection.h"
using namespace Gui;
using namespace TechDraw;
using namespace TechDrawGui;
TaskComplexSection::TaskComplexSection(TechDraw::DrawPage* page,
TechDraw::DrawViewPart* baseView,
std::vector<App::DocumentObject*> shapes,
std::vector<App::DocumentObject*> xShapes,
App::DocumentObject* profileObject,
std::vector<std::string> profileSubs) :
ui(new Ui_TaskComplexSection),
m_page(page),
m_baseView(baseView),
m_section(nullptr),
m_shapes(shapes),
m_xShapes(xShapes),
m_profileObject(profileObject),
m_profileSubs(profileSubs),
m_sectionName(std::string())
{
ui->setupUi(this);
setUiPrimary();
connect(ui->pbSectionObjects, SIGNAL(clicked()), this, SLOT(onSectionObjectsUseSelectionClicked()));
connect(ui->pbProfileObject, SIGNAL(clicked()), this, SLOT(onProfileObjectsUseSelectionClicked()));
}
void TaskComplexSection::changeEvent(QEvent* event)
{
if (event->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
}
}
void TaskComplexSection::setUiPrimary()
{
setWindowTitle(QObject::tr("New Complex Section"));
ui->dsbXNormal->setEnabled(true);
ui->dsbYNormal->setEnabled(true);
ui->dsbZNormal->setEnabled(true);
std::pair<Base::Vector3d, Base::Vector3d> dirs = DrawGuiUtil::get3DDirAndRot();
ui->dsbXNormal->setValue(dirs.first.x);
ui->dsbYNormal->setValue(dirs.first.y);
ui->dsbZNormal->setValue(dirs.first.z);
m_saveXDir = dirs.second;
ui->leSectionObjects->setText(sourcesToString());
ui->leProfileObject->setText(Base::Tools::fromStdString(m_profileObject->getNameInDocument()) +
QString::fromUtf8(" / ") +
Base::Tools::fromStdString(m_profileObject->Label.getValue()));
if (m_baseView) {
ui->dsbScale->setValue(m_baseView->getScale());
ui->cmbScaleType->setCurrentIndex(m_baseView->ScaleType.getValue());
} else {
ui->dsbScale->setValue(Preferences::scale());
ui->cmbScaleType->setCurrentIndex(Preferences::scaleType());
}
}
void TaskComplexSection::onSectionObjectsUseSelectionClicked()
{
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx();
std::vector<App::DocumentObject*> newSelection;
std::vector<App::DocumentObject*> newXSelection;
for (auto& sel : selection) {
if (sel.getObject()->isDerivedFrom(App::LinkElement::getClassTypeId()) ||
sel.getObject()->isDerivedFrom(App::LinkGroup::getClassTypeId()) ||
sel.getObject()->isDerivedFrom(App::Link::getClassTypeId()) ) {
newXSelection.push_back(sel.getObject());
} else {
newSelection.push_back(sel.getObject());
}
}
m_shapes = newSelection;
m_xShapes = newXSelection;
ui->leSectionObjects->setText(sourcesToString());
}
void TaskComplexSection::onProfileObjectsUseSelectionClicked()
{
std::vector<Gui::SelectionObject> selection = Gui::Selection().getSelectionEx();
//check for single selection and ability to make profile from selected object
if (!selection.empty()) {
m_profileObject = selection.front().getObject();
ui->leProfileObject->setText(Base::Tools::fromStdString(m_profileObject->getNameInDocument()) +
QString::fromUtf8(" / ") +
Base::Tools::fromStdString(m_profileObject->Label.getValue()));
}
}
QString TaskComplexSection::sourcesToString()
{
QString result;
if (m_baseView) {
for (auto& obj : m_baseView->Source.getValues()) {
result += Base::Tools::fromStdString(obj->getNameInDocument()) +
QString::fromUtf8(" / ") +
Base::Tools::fromStdString(obj->Label.getValue()) +
QString::fromUtf8(", ");
}
for (auto& obj : m_baseView->XSource.getValues()) {
result += Base::Tools::fromStdString(obj->getNameInDocument()) +
QString::fromUtf8(" / ") +
Base::Tools::fromStdString(obj->Label.getValue()) +
QString::fromUtf8(", ");
}
} else {
for (auto& obj : m_shapes) {
result += Base::Tools::fromStdString(obj->getNameInDocument()) +
QString::fromUtf8(" / ") +
Base::Tools::fromStdString(obj->Label.getValue()) +
QString::fromUtf8(", ");
}
for (auto& obj : m_xShapes) {
result += Base::Tools::fromStdString(obj->getNameInDocument()) +
QString::fromUtf8(" / ") +
Base::Tools::fromStdString(obj->Label.getValue()) +
QString::fromUtf8(", ");
}
}
return result;
}
void TaskComplexSection::updateUi()
{
}
//pointer to created view is not returned, but stored in m_section
void TaskComplexSection::createComplexSection()
{
// Base::Console().Message("TCS::createComplexSection()\n");
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create ComplexSection"));
if (!m_section) {
m_sectionName = m_page->getDocument()->getUniqueObjectName("ComplexSection");
std::string sectionType = "TechDraw::DrawComplexSection";
Command::doCommand(Command::Doc, "App.ActiveDocument.addObject('%s', '%s')",
sectionType.c_str(), m_sectionName.c_str());
Command::doCommand(Command::Doc, "App.ActiveDocument.%s.addView(App.ActiveDocument.%s)",
m_page->getNameInDocument(), m_sectionName.c_str());
QString qTemp = ui->leSymbol->text();
std::string temp = Base::Tools::toStdString(qTemp);
Command::doCommand(Command::Doc, "App.ActiveDocument.%s.SectionSymbol = '%s'",
m_sectionName.c_str(),
temp.c_str());
std::string lblText = "Section " +
temp +
" - " +
temp;
Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Label = '%s'",
m_sectionName.c_str(),
lblText.c_str());
Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Scale = %0.6f",
m_sectionName.c_str(),
ui->dsbScale->value());
int scaleType = ui->cmbScaleType->currentIndex();
Command::doCommand(Command::Doc, "App.ActiveDocument.%s.ScaleType = %d",
m_sectionName.c_str(), scaleType);
int projectionStrategy = ui->cmbStrategy->currentIndex();
Command::doCommand(Command::Doc, "App.ActiveDocument.%s.ProjectionStrategy = %d",
m_sectionName.c_str(), projectionStrategy);
Command::doCommand(Command::Doc, "App.activeDocument().%s.Direction = FreeCAD.Vector(%.3f, %.3f, %.3f)",
m_sectionName.c_str(), ui->dsbXNormal->value(),
ui->dsbYNormal->value(), ui->dsbZNormal->value());
Command::doCommand(Command::Doc, "App.activeDocument().%s.SectionNormal = FreeCAD.Vector(%.3f, %.3f, %.3f)",
m_sectionName.c_str(), ui->dsbXNormal->value(),
ui->dsbYNormal->value(), ui->dsbZNormal->value());
Command::doCommand(Command::Doc, "App.activeDocument().%s.XDirection = FreeCAD.Vector(%.3f, %.3f, %.3f)",
m_sectionName.c_str(), m_saveXDir.x, m_saveXDir.y, m_saveXDir.z);
Command::doCommand(Command::Doc, "App.activeDocument().%s.SectionOrigin = FreeCAD.Vector(0.0, 0.0, 0.0)",
m_sectionName.c_str());
Command::doCommand(Command::Doc, "App.activeDocument().%s.SectionDirection = 'Aligned'",
m_sectionName.c_str());
App::DocumentObject* newObj = m_page->getDocument()->getObject(m_sectionName.c_str());
m_section = dynamic_cast<TechDraw::DrawComplexSection*>(newObj);
if (!newObj || !m_section) {
throw Base::RuntimeError("TaskComplexSection - new section object not found");
}
if (m_baseView) {
m_section->Source.setValues(m_baseView->Source.getValues());
m_section->XSource.setValues(m_baseView->XSource.getValues());
Command::doCommand(Command::Doc, "App.ActiveDocument.%s.BaseView = App.ActiveDocument.%s",
m_sectionName.c_str(), m_baseView->getNameInDocument());
} else {
m_section->Source.setValues(m_shapes);
m_section->XSource.setValues(m_xShapes);
}
m_section->CuttingToolWireObject.setValue(m_profileObject);
}
Gui::Command::commitCommand();
if (m_section) {
m_section->recomputeFeature();
}
return;
}
void TaskComplexSection::saveButtons(QPushButton* btnOK,
QPushButton* btnCancel)
{
m_btnOK = btnOK;
m_btnCancel = btnCancel;
}
void TaskComplexSection::enableTaskButtons(bool button)
{
m_btnOK->setEnabled(button);
m_btnCancel->setEnabled(button);
}
//******************************************************************************
bool TaskComplexSection::accept()
{
Gui::Document* doc = Gui::Application::Instance->getDocument(m_page->getDocument());
if (!doc)
return false;
createComplexSection();
Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()");
return true;
}
bool TaskComplexSection::reject()
{
Gui::Document* doc = Gui::Application::Instance->getDocument(m_page->getDocument());
if (!doc)
return false;
//make sure any dangling objects are cleaned up
Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().recompute()");
Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()");
return false;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TaskDlgComplexSection::TaskDlgComplexSection(TechDraw::DrawPage* page,
TechDraw::DrawViewPart *baseView,
std::vector<App::DocumentObject*> shapes,
std::vector<App::DocumentObject*> xShapes,
App::DocumentObject* profileObject,
std::vector<std::string> profileSubs)
: TaskDialog()
{
widget = new TaskComplexSection(page, baseView, shapes, xShapes, profileObject, profileSubs);
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_ComplexSection"),
widget->windowTitle(), true, nullptr);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);
}
TaskDlgComplexSection::~TaskDlgComplexSection()
{
}
void TaskDlgComplexSection::update()
{
// widget->updateTask();
}
void TaskDlgComplexSection::modifyStandardButtons(QDialogButtonBox* box)
{
QPushButton* btnOK = box->button(QDialogButtonBox::Ok);
QPushButton* btnCancel = box->button(QDialogButtonBox::Cancel);
widget->saveButtons(btnOK, btnCancel);
}
//==== calls from the TaskView ===============================================================
void TaskDlgComplexSection::open()
{
}
void TaskDlgComplexSection::clicked(int)
{
}
bool TaskDlgComplexSection::accept()
{
widget->accept();
return true;
}
bool TaskDlgComplexSection::reject()
{
widget->reject();
return true;
}
#include <Mod/TechDraw/Gui/moc_TaskComplexSection.cpp>

View File

@@ -0,0 +1,137 @@
/***************************************************************************
* Copyright (c) 2022 WandererFan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef TECHDRAWGUI_TASKCOMPLEXSECTION_H
#define TECHDRAWGUI_TASKCOMPLEXSECTION_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <QString>
#include <Base/Vector3D.h>
#include <Gui/TaskView/TaskDialog.h>
#include <Gui/TaskView/TaskView.h>
namespace App
{
class DocumentObject;
}
namespace TechDraw
{
class DrawPage;
class DrawView;
class DrawViewPart;
class DrawComplexSection;
}
namespace TechDrawGui
{
class Ui_TaskComplexSection;
class TaskComplexSection : public QWidget
{
Q_OBJECT
public:
TaskComplexSection(TechDraw::DrawPage* page,
TechDraw::DrawViewPart* baseView,
std::vector<App::DocumentObject*> shapes,
std::vector<App::DocumentObject*> xShapes,
App::DocumentObject* profileObject,
std::vector<std::string> profileSubs);
~TaskComplexSection() = default;
virtual bool accept();
virtual bool reject();
void saveButtons(QPushButton* btnOK,
QPushButton* btnCancel);
void enableTaskButtons(bool button);
public Q_SLOTS:
void onSectionObjectsUseSelectionClicked();
void onProfileObjectsUseSelectionClicked();
protected:
void changeEvent(QEvent *event) override;
void setUiPrimary();
void updateUi();
private:
void createComplexSection();
QString sourcesToString();
std::unique_ptr<Ui_TaskComplexSection> ui;
TechDraw::DrawPage* m_page;
TechDraw::DrawViewPart* m_baseView;
TechDraw::DrawComplexSection* m_section;
std::vector<App::DocumentObject*> m_shapes;
std::vector<App::DocumentObject*> m_xShapes;
App::DocumentObject* m_profileObject;
std::vector<std::string> m_profileSubs;
std::string m_sectionName;
Base::Vector3d m_saveXDir;
QPushButton* m_btnOK;
QPushButton* m_btnCancel;
};
class TaskDlgComplexSection : public Gui::TaskView::TaskDialog
{
Q_OBJECT
public:
TaskDlgComplexSection(TechDraw::DrawPage* page,
TechDraw::DrawViewPart* baseView,
std::vector<App::DocumentObject*> shapes,
std::vector<App::DocumentObject*> xShapes,
App::DocumentObject* profileObject,
std::vector<std::string> profileSubs);
~TaskDlgComplexSection() override;
public:
/// is called the TaskView when the dialog is opened
void open() override;
/// is called by the framework if an button is clicked which has no accept or reject role
void clicked(int) override;
/// is called by the framework if the dialog is accepted (Ok)
bool accept() override;
/// is called by the framework if the dialog is rejected (Cancel)
bool reject() override;
/// is called by the framework if the user presses the help button
bool isAllowedAlterDocument() const override
{ return false; }
void update();
void modifyStandardButtons(QDialogButtonBox* box) override;
protected:
private:
TaskComplexSection * widget;
Gui::TaskView::TaskBox* taskbox;
};
} //namespace TechDrawGui
#endif // #ifndef TECHDRAWGUI_TASKCOMPLEXSECTION_H

View File

@@ -0,0 +1,296 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TechDrawGui::TaskComplexSection</class>
<widget class="QWidget" name="TechDrawGui::TaskComplexSection">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>370</width>
<height>478</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Complex Section</string>
</property>
<property name="windowIcon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/actions/TechDraw_ComplexSection.svg</normaloff>:/icons/actions/TechDraw_ComplexSection.svg</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Object Selection</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Objects to section</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pbSectionObjects">
<property name="text">
<string>Use Selection</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Profile object</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="leProfileObject">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leSectionObjects">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pbProfileObject">
<property name="text">
<string>Use Selection</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Section Parameters</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gridLayout_4" columnstretch="1,1">
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Identifier</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="cmbScaleType">
<property name="minimumSize">
<size>
<width>0</width>
<height>26</height>
</size>
</property>
<property name="toolTip">
<string>Scale Page/Auto/Custom</string>
</property>
<item>
<property name="text">
<string>Page</string>
</property>
</item>
<item>
<property name="text">
<string>Automatic</string>
</property>
</item>
<item>
<property name="text">
<string>Custom</string>
</property>
</item>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="dsbScale">
<property name="minimumSize">
<size>
<width>0</width>
<height>26</height>
</size>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Scale Type</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Scale</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leSymbol">
<property name="minimumSize">
<size>
<width>0</width>
<height>26</height>
</size>
</property>
<property name="toolTip">
<string>Identifier for this section</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Projection Strategy</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cmbStrategy">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>26</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="currentText">
<string>Single</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Single</string>
</property>
</item>
<item>
<property name="text">
<string>Piecewise</string>
</property>
</item>
<item>
<property name="text">
<string>NoParallel</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Section Normal</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Z</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>X</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Y</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="dsbXNormal">
<property name="minimum">
<double>-2147483647.000000000000000</double>
</property>
<property name="maximum">
<double>2147483647.000000000000000</double>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="dsbYNormal">
<property name="minimum">
<double>-2147483647.000000000000000</double>
</property>
<property name="maximum">
<double>2147483647.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="dsbZNormal">
<property name="minimum">
<double>-2147483647.000000000000000</double>
</property>
<property name="maximum">
<double>2147483647.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="Resources/TechDraw.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -76,6 +76,7 @@ ViewProviderViewPart::ViewProviderViewPart()
static const char *group = "Lines";
static const char *dgroup = "Decoration";
static const char *hgroup = "Highlight";
static const char *sgroup = "Section Line";
//default line weights
@@ -104,12 +105,14 @@ ViewProviderViewPart::ViewProviderViewPart()
ADD_PROPERTY_TYPE(CenterScale, (defScale), dgroup, App::Prop_None, "Center mark size adjustment, if enabled");
//properties that affect Section Line
ADD_PROPERTY_TYPE(ShowSectionLine ,(true) ,dgroup, App::Prop_None, "Show/hide section line if applicable");
ADD_PROPERTY_TYPE(ShowSectionLine ,(true) ,sgroup, App::Prop_None, "Show/hide section line if applicable");
SectionLineStyle.setEnums(LineStyleEnums);
ADD_PROPERTY_TYPE(SectionLineStyle, (PreferencesGui::sectionLineStyle()), dgroup, App::Prop_None,
ADD_PROPERTY_TYPE(SectionLineStyle, (PreferencesGui::sectionLineStyle()), sgroup, App::Prop_None,
"Set section line style if applicable");
ADD_PROPERTY_TYPE(SectionLineColor, (prefSectionColor()), dgroup, App::Prop_None,
ADD_PROPERTY_TYPE(SectionLineColor, (prefSectionColor()), sgroup, App::Prop_None,
"Set section line color if applicable");
ADD_PROPERTY_TYPE(SectionLineMarks, (PreferencesGui::sectionLineMarks()), sgroup, App::Prop_None,
"Show marks at direction changes for ComplexSection");
//properties that affect Detail Highlights
HighlightLineStyle.setEnums(LineStyleEnums);
@@ -139,6 +142,7 @@ void ViewProviderViewPart::onChanged(const App::Property* prop)
prop == &(ShowSectionLine) ||
prop == &(SectionLineStyle) ||
prop == &(SectionLineColor) ||
prop == &(SectionLineMarks) ||
prop == &(HighlightLineStyle) ||
prop == &(HighlightLineColor) ||
prop == &(HorizCenterLine) ||

View File

@@ -22,8 +22,8 @@
#ifndef DRAWINGGUI_VIEWPROVIDERVIEWPART_H
#define DRAWINGGUI_VIEWPROVIDERVIEWPART_H
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <Mod/TechDraw/TechDrawGlobal.h>
#include <App/PropertyUnits.h>
@@ -55,6 +55,7 @@ public:
App::PropertyBool ShowSectionLine;
App::PropertyEnumeration SectionLineStyle;
App::PropertyColor SectionLineColor;
App::PropertyBool SectionLineMarks;
App::PropertyEnumeration HighlightLineStyle;
App::PropertyColor HighlightLineColor;
App::PropertyFloat HighlightAdjust;

View File

@@ -189,6 +189,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
*draw << "TechDraw_ActiveView";
*draw << "TechDraw_ProjectionGroup";
*draw << "TechDraw_SectionView";
*draw << "TechDraw_ComplexSection";
*draw << "TechDraw_DetailView";
*draw << "Separator";
*draw << "TechDraw_DraftView";
@@ -246,6 +247,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
*views << "TechDraw_ActiveView";
*views << "TechDraw_ProjectionGroup";
*views << "TechDraw_SectionView";
*views << "TechDraw_ComplexSection";
*views << "TechDraw_DetailView";
*views << "TechDraw_DraftView";
*views << "TechDraw_ArchView";
@@ -392,6 +394,7 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
// *views << "TechDraw_NewMulti"; //deprecated
*views << "TechDraw_ProjectionGroup";
*views << "TechDraw_SectionView";
*views << "TechDraw_ComplexSection";
*views << "TechDraw_DetailView";
*views << "TechDraw_DraftView";
*views << "TechDraw_SpreadsheetView";