diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user
new file mode 100644
index 0000000000..b5e299361d
--- /dev/null
+++ b/CMakeLists.txt.user
@@ -0,0 +1,430 @@
+
+
+
+
+
+ EnvironmentId
+ {2bb8d980-59c2-4103-9ad9-f84df3b67da6}
+
+
+ ProjectExplorer.Project.ActiveTarget
+ 0
+
+
+ ProjectExplorer.Project.EditorSettings
+
+ true
+ false
+ true
+
+ Cpp
+
+ CppGlobal
+
+
+
+ QmlJS
+
+ QmlJSGlobal
+
+
+ 2
+ UTF-8
+ false
+ 4
+ false
+ 80
+ true
+ true
+ 1
+ true
+ false
+ 0
+ true
+ true
+ 0
+ 8
+ true
+ 1
+ true
+ true
+ true
+ false
+
+
+
+ ProjectExplorer.Project.PluginSettings
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop
+ Desktop
+ {6576b0bd-ff13-47bd-97c2-c8159848c669}
+ 3
+ 0
+ 0
+
+
+ /home/huxster/Target/freecad-qtc-build
+
+
+
+
+ all
+
+ true
+ CMake Build
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ all
+
+ true
+ CMake Build
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Default
+ Default
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+
+ CMAKE_BUILD_TYPE:STRING=Debug
+
+ /home/huxster/Source/build-FreeCAD-src-Desktop-Debug
+
+
+
+
+ all
+
+ true
+ CMake Build
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ all
+
+ true
+ CMake Build
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Debug
+ Debug
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+
+ CMAKE_BUILD_TYPE:STRING=Release
+
+ /home/huxster/Source/build-FreeCAD-src-Desktop-Release
+
+
+
+
+ all
+
+ true
+ CMake Build
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ all
+
+ true
+ CMake Build
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Release
+ Release
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+
+ CMAKE_BUILD_TYPE:STRING=debug
+ CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++
+ CMAKE_C_COMPILER:FILEPATH=/usr/bin/cc
+
+ /home/huxster/Target/freecad-qtc-build
+
+
+ jobs=3
+
+ all
+
+ true
+ CMake Build
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ all
+
+ true
+ CMake Build
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Release with Debug Information
+ Release with Debug Information
+ CMakeProjectManager.CMakeBuildConfiguration
+
+
+
+ CMAKE_BUILD_TYPE:STRING=MinSizeRel
+
+ /home/huxster/Source/build-FreeCAD-src-Desktop-Minimum Size Release
+
+
+
+
+ all
+
+ true
+ CMake Build
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Build
+
+ ProjectExplorer.BuildSteps.Build
+
+
+
+
+
+ all
+
+ true
+ CMake Build
+
+ CMakeProjectManager.MakeStep
+
+ 1
+ Clean
+
+ ProjectExplorer.BuildSteps.Clean
+
+ 2
+ false
+
+ Minimum Size Release
+ Minimum Size Release
+ CMakeProjectManager.CMakeBuildConfiguration
+
+ 5
+
+
+ 0
+ Deploy
+
+ ProjectExplorer.BuildSteps.Deploy
+
+ 1
+ Deploy locally
+
+ ProjectExplorer.DefaultDeployConfiguration
+
+ 1
+
+
+ false
+ false
+ 1000
+
+ true
+
+ false
+ false
+ false
+ false
+ true
+ 0.01
+ 10
+ true
+ 1
+ 25
+
+ 1
+ true
+ false
+ true
+ valgrind
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+
+ FreeCADMainCmd
+
+
+ /home/huxster/Target/freecad-qtc-build/bin
+ 2
+
+ FreeCADMainCmd
+
+ CMakeProjectManager.CMakeRunConfiguration.FreeCADMainCmd
+ 3768
+ false
+ true
+ false
+ false
+ true
+
+
+ false
+ false
+ 1000
+
+ true
+
+ false
+ false
+ false
+ false
+ true
+ 0.01
+ 10
+ true
+ 1
+ 25
+
+ 1
+ true
+ false
+ true
+ valgrind
+
+ 0
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+ 10
+ 11
+ 12
+ 13
+ 14
+
+ FreeCADMain
+
+
+ /home/huxster/Target/freecad-qtc-build/bin
+ 2
+
+ FreeCADMain
+
+ CMakeProjectManager.CMakeRunConfiguration.FreeCADMain
+ 3768
+ false
+ true
+ false
+ false
+ true
+
+ 2
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 1
+
+
+ ProjectExplorer.Project.Updater.FileVersion
+ 18
+
+
+ Version
+ 18
+
+
diff --git a/src/Mod/TechDraw/App/Cosmetic.cpp b/src/Mod/TechDraw/App/Cosmetic.cpp
index ae956f79a9..e771d2d994 100644
--- a/src/Mod/TechDraw/App/Cosmetic.cpp
+++ b/src/Mod/TechDraw/App/Cosmetic.cpp
@@ -42,6 +42,7 @@
#include "Cosmetic.h"
using namespace TechDraw;
+using namespace TechDrawGeometry;
CosmeticVertex::CosmeticVertex()
{
@@ -147,9 +148,15 @@ void CosmeticVertex::dump(char* title)
//******************************************
+//note this ctor has no occEdge or first/last point for geometry!
CosmeticEdge::CosmeticEdge()
{
geometry = new TechDrawGeometry::BaseGeom();
+ geometry->geomType = GENERIC;
+ geometry->classOfEdge = ecHARD;
+ geometry->visible = true;
+ geometry->cosmetic = true;
+
linkGeom = -1;
color = getDefEdgeColor();
width = getDefEdgeWidth();
@@ -163,6 +170,11 @@ CosmeticEdge::CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2)
gp_Pnt gp2(p2.x,p2.y,p2.z);
TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2);
geometry = TechDrawGeometry::BaseGeom::baseFactory(e);
+ geometry->geomType = GENERIC;
+ geometry->classOfEdge = ecHARD;
+ geometry->visible = true;
+ geometry->cosmetic = true;
+
linkGeom = -1;
color = getDefEdgeColor();
width = getDefEdgeWidth();
@@ -173,6 +185,11 @@ CosmeticEdge::CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2)
CosmeticEdge::CosmeticEdge(TopoDS_Edge e)
{
geometry = TechDrawGeometry::BaseGeom::baseFactory(e);
+ geometry->geomType = GENERIC;
+ geometry->classOfEdge = ecHARD;
+ geometry->visible = true;
+ geometry->cosmetic = true;
+
linkGeom = -1;
color = getDefEdgeColor();
width = getDefEdgeWidth();
@@ -259,6 +276,17 @@ bool CosmeticEdge::fromCSV(std::string& lineSpec)
width = atof(values[8].c_str());
style = atoi(values[9].c_str());
visible = atoi(values[10].c_str());
+
+ //dupl of ctor(p1,p2)
+ gp_Pnt gp1(start.x,start.y,start.z);
+ gp_Pnt gp2(end.x,end.y,end.z);
+ TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2);
+ geometry = TechDrawGeometry::BaseGeom::baseFactory(e);
+ geometry->geomType = GENERIC;
+ geometry->classOfEdge = ecHARD;
+ geometry->visible = true;
+ geometry->cosmetic = true;
+
return true;
}
diff --git a/src/Mod/TechDraw/App/Cosmetic.h b/src/Mod/TechDraw/App/Cosmetic.h
index 1b43fb11f8..b22e01233d 100644
--- a/src/Mod/TechDraw/App/Cosmetic.h
+++ b/src/Mod/TechDraw/App/Cosmetic.h
@@ -72,6 +72,8 @@ public:
TechDrawGeometry::BaseGeom* geometry;
+ Base::Vector3d start;
+ Base::Vector3d end;
int linkGeom; //connection to corresponding "real" Edge
App::Color color;
double width;
diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp
index c237431cad..5e7bc69187 100644
--- a/src/Mod/TechDraw/App/DrawViewPart.cpp
+++ b/src/Mod/TechDraw/App/DrawViewPart.cpp
@@ -151,6 +151,7 @@ DrawViewPart::DrawViewPart(void) :
ADD_PROPERTY_TYPE(IsoCount ,(0),sgroup,App::Prop_None,"Number of isoparameters");
ADD_PROPERTY_TYPE(CosmeticVertexList ,(""),sgroup,App::Prop_None,"CosmeticVertex Save/Restore");
+ ADD_PROPERTY_TYPE(CosmeticEdgeList ,(""),sgroup,App::Prop_None,"CosmeticEdge Save/Restore");
geometryObject = nullptr;
getRunControl();
@@ -293,6 +294,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
//this is ghastly! but no convenient method for "object ready"
if (on1) {
rebuildCosmoVertex();
+ rebuildCosmoEdge();
on1 = false;
}
@@ -341,11 +343,6 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
Rotation.getValue());
}
geometryObject = buildGeometryObject(mirroredShape,viewAxis);
- //add back the cosmetic vertices
- for (auto& v: cosmoVertex) {
- int idx = geometryObject->addRandomVertex(v->pageLocation * getScale());
- v->linkGeom = idx;
- }
#if MOD_TECHDRAW_HANDLE_FACES
auto start = chrono::high_resolution_clock::now();
@@ -358,6 +355,19 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
return new App::DocumentObjectExecReturn(e4.GetMessageString());
}
}
+
+ //add back the cosmetic vertices
+ for (auto& v: cosmoVertex) {
+ int idx = geometryObject->addRandomVertex(v->pageLocation * getScale());
+ v->linkGeom = idx;
+ }
+
+ //add back the cosmetic Edges
+ for (auto& e: cosmoEdge) {
+ int idx = geometryObject->addRandomEdge(e->geometry);
+ e->linkGeom = idx;
+ }
+
auto end = chrono::high_resolution_clock::now();
auto diff = end - start;
double diffOut = chrono::duration (diff).count();
@@ -698,18 +708,18 @@ TechDrawGeometry::Vertex* DrawViewPart::getProjVertexByIndex(int idx) const
return geoms.at(idx);
}
-
-//this is never used!!
//! returns existing geometry of 2D Face(idx)
-//version 1 Face has 1 wire
-std::vector DrawViewPart::getProjFaceByIndex(int idx) const
+std::vector DrawViewPart::getFaceEdgesByIndex(int idx) const
{
- (void) idx;
std::vector result;
const std::vector& faces = getFaceGeometry();
- for (auto& f:faces) {
- for (auto& w:f->wires) {
+ if (idx < (int) faces.size()) {
+ TechDrawGeometry::Face* projFace = faces.at(idx);
+ for (auto& w: projFace->wires) {
for (auto& g:w->geoms) {
+ if (g->cosmetic) {
+ Base::Console().Message("DVP::getFaceEdgesByIndex - found cosmetic edge\n");
+ }
result.push_back(g);
}
}
@@ -907,11 +917,30 @@ void DrawViewPart::rebuildCosmoVertex(void)
}
}
+//build cosmoEdge from CosmeticEdgeList
+void DrawViewPart::rebuildCosmoEdge(void)
+{
+// Base::Console().Message("DVP::rebuildCosmoEdge()\n");
+ cosmoEdge.clear();
+ std::vector restoreEdges = CosmeticEdgeList.getValues();
+ for (auto& re: restoreEdges) {
+ if (!re.empty()) {
+ CosmeticEdge* ce = new CosmeticEdge();
+ bool rc = ce->fromCSV(re);
+ if (rc) {
+ cosmoEdge.push_back(ce);
+ } else {
+ delete ce;
+ }
+ }
+ }
+}
+
//! remove features that are useless without this DVP
//! hatches, geomhatches, dimensions,...
void DrawViewPart::unsetupObject()
{
- Base::Console().Message("DVP::unsetupObject()\n");
+// Base::Console().Message("DVP::unsetupObject()\n");
nowUnsetting = true;
App::Document* doc = getDocument();
std::string docName = doc->getName();
@@ -1038,6 +1067,98 @@ void DrawViewPart::clearCV(void)
CosmeticVertexList.setValues(noVerts);
}
+// adds a cosmetic edge to cosmoEdge and CosmeticEdgeList
+int DrawViewPart::addRandomEdge(Base::Vector3d p1, Base::Vector3d p2)
+{
+// Base::Console().Message("DVP::addRandomEdge(%s, %s)\n",
+// DrawUtil::formatVector(p1).c_str(),
+// DrawUtil::formatVector(p2).c_str());
+ int newIdx = -1;
+ TechDraw::CosmeticEdge* rEdge = new TechDraw::CosmeticEdge(p1, p2);
+ cosmoEdge.push_back(rEdge);
+
+ //stuff stringList
+ std::vector saveEdges;
+ const std::vector cosEdges = getCosmeticEdge();
+ for (auto& ce: cosEdges) {
+ std::string csv = ce->toCSV();
+ saveEdges.push_back(csv);
+ }
+ CosmeticEdgeList.setValues(saveEdges);
+ return newIdx;
+}
+
+int DrawViewPart::addRandomEdge(TopoDS_Edge e)
+{
+// Base::Console().Message("DVP::addRandomEdge(TopoDS_Edge)\n");
+ int newIdx = -1;
+ TechDraw::CosmeticEdge* rEdge = new TechDraw::CosmeticEdge(e);
+ cosmoEdge.push_back(rEdge);
+
+ //stuff stringList
+ std::vector saveEdges;
+ const std::vector cosEdges = getCosmeticEdge();
+ for (auto& ce: cosEdges) {
+ std::string csv = ce->toCSV();
+ saveEdges.push_back(csv);
+ }
+ CosmeticEdgeList.setValues(saveEdges);
+ return newIdx;
+}
+
+int DrawViewPart::addRandomEdge(CosmeticEdge* ce)
+{
+// Base::Console().Message("DVP::addRandomEdge(CosmeticEdge)\n");
+ int newIdx = -1;
+ cosmoEdge.push_back(ce);
+
+ //stuff stringList
+ std::vector saveEdges;
+ const std::vector cosEdges = getCosmeticEdge();
+ for (auto& ce: cosEdges) {
+ std::string csv = ce->toCSV();
+ saveEdges.push_back(csv);
+ }
+ CosmeticEdgeList.setValues(saveEdges);
+ return newIdx;
+}
+
+TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByIndex(int idx) const
+{
+// Base::Console().Message("DVP::getCosmeticEdgeByIndex(%d)\n", idx);
+ int cosmoOffset = 1000;
+ int realIdx = idx - cosmoOffset;
+ CosmeticEdge* result = nullptr;
+ const std::vector edges = getCosmeticEdge();
+ if ((unsigned) realIdx < edges.size()) {
+ result = edges.at(realIdx);
+ }
+ return result;
+}
+
+//find the cosmetic edge corresponding to geometry edge idx
+TechDraw::CosmeticEdge* DrawViewPart::getCosmeticEdgeByLink(int idx) const
+{
+// Base::Console().Message("DVP::getCosmeticEdgeByLinkIndex(%d)\n", idx);
+ CosmeticEdge* result = nullptr;
+ const std::vector edges = getCosmeticEdge();
+ for (auto& ce: edges) {
+ if (ce->linkGeom == idx) {
+ result = ce;
+ break;
+ }
+ }
+ return result;
+}
+
+void DrawViewPart::clearCE(void)
+{
+// Base::Console().Message("DVP::clearCE()\n");
+ cosmoEdge.clear();
+ std::vector noEdges;
+ CosmeticEdgeList.setValues(noEdges);
+}
+
PyObject *DrawViewPart::getPyObject(void)
{
if (PythonObject.is(Py::_None())) {
diff --git a/src/Mod/TechDraw/App/DrawViewPart.h b/src/Mod/TechDraw/App/DrawViewPart.h
index 6c7848b69f..06a2bf575a 100644
--- a/src/Mod/TechDraw/App/DrawViewPart.h
+++ b/src/Mod/TechDraw/App/DrawViewPart.h
@@ -69,6 +69,7 @@ class DrawViewSection;
class DrawViewDetail;
class DrawViewBalloon;
class CosmeticVertex;
+class CosmeticEdge;
}
namespace TechDraw
@@ -103,6 +104,7 @@ public:
App::PropertyInteger IsoCount;
App::PropertyStringList CosmeticVertexList;
+ App::PropertyStringList CosmeticEdgeList;
std::vector getHatches(void) const;
std::vector getGeomHatches(void) const;
@@ -121,7 +123,7 @@ public:
TechDrawGeometry::BaseGeom* getProjEdgeByIndex(int idx) const; //get existing geom for edge idx in projection
TechDrawGeometry::Vertex* getProjVertexByIndex(int idx) const; //get existing geom for vertex idx in projection
- std::vector getProjFaceByIndex(int idx) const; //get edges for face idx in projection
+ std::vector getFaceEdgesByIndex(int idx) const; //get edges for face idx in projection
virtual Base::BoundBox3d getBoundingBox() const;
double getBoxX(void) const;
@@ -171,6 +173,14 @@ public:
TechDraw::CosmeticVertex* getCosmeticVertexByLink(int idx) const;
void clearCV(void);
+ virtual int addRandomEdge(Base::Vector3d start, Base::Vector3d end);
+ virtual int addRandomEdge(TopoDS_Edge e);
+ virtual int addRandomEdge(TechDraw::CosmeticEdge*);
+ const std::vector & getCosmeticEdge(void) const { return cosmoEdge; }
+ TechDraw::CosmeticEdge* getCosmeticEdgeByIndex(int idx) const;
+ TechDraw::CosmeticEdge* getCosmeticEdgeByLink(int idx) const;
+ void clearCE(void);
+
protected:
TechDrawGeometry::GeometryObject *geometryObject;
Base::BoundBox3d bbox;
@@ -196,6 +206,9 @@ protected:
std::vector cosmoVertex;
void rebuildCosmoVertex(void);
+ std::vector cosmoEdge;
+ void rebuildCosmoEdge(void);
+
private:
bool nowUnsetting;
bool on1;
diff --git a/src/Mod/TechDraw/App/Geometry.cpp b/src/Mod/TechDraw/App/Geometry.cpp
index 74eab89785..81f0b1accf 100644
--- a/src/Mod/TechDraw/App/Geometry.cpp
+++ b/src/Mod/TechDraw/App/Geometry.cpp
@@ -116,7 +116,8 @@ BaseGeom::BaseGeom() :
classOfEdge(ecNONE),
visible(true),
reversed(false),
- ref3D(-1) //obs?
+ ref3D(-1), //obs?
+ cosmetic(false)
{
}
diff --git a/src/Mod/TechDraw/App/Geometry.h b/src/Mod/TechDraw/App/Geometry.h
index cdf748a85b..b3634d023d 100644
--- a/src/Mod/TechDraw/App/Geometry.h
+++ b/src/Mod/TechDraw/App/Geometry.h
@@ -73,6 +73,7 @@ class TechDrawExport BaseGeom
bool reversed;
int ref3D; //obs?
TopoDS_Edge occEdge; //projected Edge
+ bool cosmetic;
std::vector findEndPoints();
Base::Vector2d getStartPoint();
diff --git a/src/Mod/TechDraw/App/GeometryObject.cpp b/src/Mod/TechDraw/App/GeometryObject.cpp
index a17feb1598..6478b92556 100644
--- a/src/Mod/TechDraw/App/GeometryObject.cpp
+++ b/src/Mod/TechDraw/App/GeometryObject.cpp
@@ -481,6 +481,15 @@ int GeometryObject::addRandomVertex(Base::Vector3d pos)
return idx;
}
+int GeometryObject::addRandomEdge(TechDrawGeometry::BaseGeom* base)
+{
+// Base::Console().Message("GO::addRandomEdge() - cosmetic: %d\n", base->cosmetic);
+ edgeGeom.push_back(base);
+
+ int idx = edgeGeom.size() - 1;
+ return idx;
+}
+
//! empty Face geometry
void GeometryObject::clearFaceGeom()
{
diff --git a/src/Mod/TechDraw/App/GeometryObject.h b/src/Mod/TechDraw/App/GeometryObject.h
index ec5ae78c79..92a9da7dd4 100644
--- a/src/Mod/TechDraw/App/GeometryObject.h
+++ b/src/Mod/TechDraw/App/GeometryObject.h
@@ -41,6 +41,8 @@ namespace TechDraw
class DrawViewPart;
class DrawViewDetail;
class DrawView;
+class CosmeticVertex;
+class CosmeticEdge;
}
namespace TechDrawGeometry
@@ -126,7 +128,7 @@ public:
TopoDS_Shape getHidIso(void) { return hidIso; }
int addRandomVertex(Base::Vector3d pos);
-
+ int addRandomEdge(TechDrawGeometry::BaseGeom* bg);
protected:
//HLR output
diff --git a/src/Mod/TechDraw/Gui/CMakeLists.txt b/src/Mod/TechDraw/Gui/CMakeLists.txt
index 769f0e33e6..567de64c0b 100644
--- a/src/Mod/TechDraw/Gui/CMakeLists.txt
+++ b/src/Mod/TechDraw/Gui/CMakeLists.txt
@@ -42,6 +42,7 @@ set(TechDrawGui_MOC_HDRS
TaskLeaderLine.h
TaskRichAnno.h
TaskCosVertex.h
+ TaskCenterLine.h
QGEPath.h
QGTracker.h
QGILeaderLine.h
@@ -74,6 +75,7 @@ set(TechDrawGui_UIC_SRCS
mrichtextedit.ui
TaskBalloon.ui
TaskCosVertex.ui
+ TaskCenterLine.ui
)
if(BUILD_QT5)
@@ -143,6 +145,9 @@ SET(TechDrawGui_SRCS
TaskCosVertex.ui
TaskCosVertex.cpp
TaskCosVertex.h
+ TaskCenterLine.ui
+ TaskCenterLine.cpp
+ TaskCenterLine.h
DrawGuiUtil.cpp
DrawGuiUtil.h
Rez.cpp
@@ -294,6 +299,7 @@ SET(TechDrawGuiTaskDlgs_SRCS
TaskCosVertex.ui
mrichtextedit.ui
TaskBalloon.ui
+ TaskCenterLine.ui
)
SOURCE_GROUP("TaskDialogs" FILES ${TechDrawGuiTaskDlgs_SRCS})
diff --git a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp
index 313067e5f8..8f109c9b10 100644
--- a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp
+++ b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp
@@ -58,6 +58,7 @@
#include "TaskLeaderLine.h"
#include "TaskRichAnno.h"
#include "TaskCosVertex.h"
+#include "TaskCenterLine.h"
#include "ViewProviderPage.h"
using namespace TechDrawGui;
@@ -582,6 +583,83 @@ bool CmdTechDrawAnnotation::isActive(void)
return DrawGuiUtil::needPage(this);
}
+//===========================================================================
+// TechDraw_Centerline
+//===========================================================================
+
+DEF_STD_CMD_A(CmdTechDrawCenterLine);
+
+CmdTechDrawCenterLine::CmdTechDrawCenterLine()
+ : Command("TechDraw_CenterLine")
+{
+ sAppModule = "TechDraw";
+ sGroup = QT_TR_NOOP("TechDraw");
+ sMenuText = QT_TR_NOOP("Add a centerline to a Face");
+ sToolTipText = QT_TR_NOOP("Add a centerline to a Face");
+ sWhatsThis = "TechDraw_CenterLine";
+ sStatusTip = sToolTipText;
+ sPixmap = "actions/techdraw-centerline";
+}
+
+void CmdTechDrawCenterLine::activated(int iMsg)
+{
+ Q_UNUSED(iMsg);
+
+ Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
+ if (dlg != nullptr) {
+ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"),
+ QObject::tr("Close active task dialog and try again."));
+ return;
+ }
+
+ TechDraw::DrawPage* page = DrawGuiUtil::findPage(this);
+ if (!page) {
+ return;
+ }
+
+ std::vector selection = getSelection().getSelectionEx();
+ TechDraw::DrawViewPart* baseFeat = nullptr;
+ if (!selection.empty()) {
+ baseFeat = dynamic_cast(selection[0].getObject());
+ if( baseFeat == nullptr ) {
+ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
+ QObject::tr("No base View in Selection."));
+ return;
+ }
+ } else {
+ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
+ QObject::tr("You must select a base View for the line."));
+ return;
+ }
+
+ std::vector SubNames;
+
+ std::vector::iterator itSel = selection.begin();
+ for (; itSel != selection.end(); itSel++) {
+ if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
+ baseFeat = static_cast ((*itSel).getObject());
+ SubNames = (*itSel).getSubNames();
+ }
+ }
+ if (SubNames.empty()) {
+ QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
+ QObject::tr("You must select a Face for the center line."));
+ return;
+ }
+
+ Gui::Control().showDialog(new TaskDlgCenterLine(baseFeat,
+ page,
+ SubNames));
+}
+
+bool CmdTechDrawCenterLine::isActive(void)
+{
+ bool havePage = DrawGuiUtil::needPage(this);
+ bool haveView = DrawGuiUtil::needView(this, false);
+ return (havePage && haveView);
+}
+
+
void CreateTechDrawCommandsAnnotate(void)
{
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
@@ -593,6 +671,7 @@ void CreateTechDrawCommandsAnnotate(void)
rcCmdMgr.addCommand(new CmdTechDrawMidpoints());
rcCmdMgr.addCommand(new CmdTechDrawQuadrant());
rcCmdMgr.addCommand(new CmdTechDrawAnnotation());
+ rcCmdMgr.addCommand(new CmdTechDrawCenterLine());
}
//===========================================================================
diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp
index 634019b4d3..4fdff5b6ea 100644
--- a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp
+++ b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp
@@ -213,6 +213,12 @@ void QGIPrimPath::setStyle(Qt::PenStyle s)
m_styleCurrent = s;
}
+void QGIPrimPath::setStyle(int s)
+{
+ m_styleCurrent = (Qt::PenStyle) s;
+}
+
+
void QGIPrimPath::setNormalColor(QColor c)
{
m_colNormal = c;
diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.h b/src/Mod/TechDraw/Gui/QGIPrimPath.h
index c0ce5c0ed3..43c7654d4f 100644
--- a/src/Mod/TechDraw/Gui/QGIPrimPath.h
+++ b/src/Mod/TechDraw/Gui/QGIPrimPath.h
@@ -55,6 +55,7 @@ public:
virtual double getWidth() { return m_width;}
Qt::PenStyle getStyle() { return m_styleCurrent; }
void setStyle(Qt::PenStyle s);
+ void setStyle(int s);
virtual void setNormalColor(QColor c);
protected:
diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp
index ea21c0b6e7..995da01c20 100644
--- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp
+++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp
@@ -441,10 +441,20 @@ void QGIViewPart::drawViewPart()
}
if (showEdge) {
item = new QGIEdge(i);
- addToGroup(item); //item is at scene(0,0), not group(0,0)
- item->setPos(0.0,0.0); //now at group(0,0)
- item->setPath(drawPainterPath(*itEdge));
item->setWidth(lineWidth);
+ if ((*itEdge)->cosmetic == true) {
+ TechDraw::CosmeticEdge* ce = viewPart->getCosmeticEdgeByLink(i);
+ if (ce != nullptr) {
+ item->setNormalColor(ce->color.asValue());
+ item->setWidth(ce->width * lineScaleFactor);
+ // item->setStyle((Qt::PenStyle)ce->style);
+ item->setStyle(ce->style);
+ }
+ }
+ addToGroup(item); //item is at scene(0,0), not group(0,0)
+ item->setPos(0.0,0.0); //now at group(0,0)
+ item->setPath(drawPainterPath(*itEdge));
+// item->setWidth(lineWidth);
item->setZValue(ZVALUE::EDGE);
if(!(*itEdge)->visible) {
item->setWidth(lineWidthHid);
@@ -1057,7 +1067,6 @@ QRectF QGIViewPart::boundingRect() const
// return customChildrenBoundingRect();
return QGIView::boundingRect();
}
-
void QGIViewPart::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
@@ -1067,7 +1076,6 @@ void QGIViewPart::paint ( QPainter * painter, const QStyleOptionGraphicsItem * o
QGIView::paint (painter, &myOption, widget);
}
-
//QGIViewPart derived classes do not need a rotate view method as rotation is handled on App side.
void QGIViewPart::rotateView(void)
{
diff --git a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc
index 23457be130..442ba90f54 100644
--- a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc
+++ b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc
@@ -66,6 +66,7 @@
icons/actions/techdraw-point.svg
icons/actions/techdraw-midpoint.svg
icons/actions/techdraw-quadrant.svg
+ icons/actions/techdraw-centerline.svg
icons/actions/section-up.svg
icons/actions/section-down.svg
icons/actions/section-left.svg
@@ -143,4 +144,4 @@
translations/TechDraw_ar.qm
translations/TechDraw_vi.qm
-
+
diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-centerline.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-centerline.svg
new file mode 100644
index 0000000000..acad530d56
--- /dev/null
+++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-centerline.svg
@@ -0,0 +1,350 @@
+
+
+
+
diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp
new file mode 100644
index 0000000000..fedbb2afdc
--- /dev/null
+++ b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp
@@ -0,0 +1,486 @@
+/***************************************************************************
+ * Copyright (c) 2019 Wandererfan
+#include
+#include
+
+#endif // #ifndef _PreComp_
+
+#include
+#include
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include "DrawGuiStd.h"
+#include "QGVPage.h"
+#include "QGIView.h"
+#include "QGIPrimPath.h"
+#include "MDIViewPage.h"
+#include "ViewProviderPage.h"
+#include "ViewProviderViewPart.h"
+#include "Rez.h"
+
+#include "TaskCenterLine.h"
+
+using namespace Gui;
+using namespace TechDraw;
+using namespace TechDrawGui;
+
+//ctor for edit
+//TaskCenterLine::TaskCenterLine(TechDrawGui::ViewProviderViewPart* partVP) :
+// ui(new Ui_TaskCenterLine),
+// m_partVP(partVp),
+// m_partFeat(nullptr),
+// m_basePage(nullptr),
+// m_createMode(false),
+// m_inProgressLock(false)
+//{
+// if (m_partVP == nullptr) {
+// //should be caught in CMD caller
+// Base::Console().Error("TaskCenterLine - bad parameters. Can not proceed.\n");
+// return;
+// }
+// ui->setupUi(this);
+//
+// m_partFeat = m_partVP->getFeature();
+// m_basePage = m_partFeat->findParentPage();
+
+// //TODO: when/if leaders are allowed to be parented to Page, check for m_partFeat will be removed
+// if ( (m_partFeat == nullptr) ||
+// (m_basePage == nullptr) ) {
+// Base::Console().Error("TaskCenterLine - bad parameters (2). Can not proceed.\n");
+// return;
+// }
+
+// //m_subNames = m_partFeat->get?????();
+
+// setUiEdit();
+
+//// m_mdi = m_partVP->getMDIViewPage();
+//// m_scene = m_mdi->m_scene;
+//// m_view = m_mdi->getQGVPage();
+
+//// connect(ui->pbTracker, SIGNAL(clicked(bool)),
+//// this, SLOT(onTrackerClicked(bool)));
+//// connect(ui->pbCancelEdit, SIGNAL(clicked(bool)),
+//// this, SLOT(onCancelEditClicked(bool)));
+//// ui->pbCancelEdit->setEnabled(false);
+
+// saveState();
+
+//}
+
+//ctor for creation
+TaskCenterLine::TaskCenterLine(TechDraw::DrawViewPart* partFeat,
+ TechDraw::DrawPage* page,
+ std::vector subNames) :
+ ui(new Ui_TaskCenterLine),
+ m_partVP(nullptr),
+ m_partFeat(partFeat),
+ m_basePage(page),
+ m_createMode(true),
+ m_subNames(subNames)
+{
+ if ( (m_basePage == nullptr) ||
+ (m_partFeat == nullptr) ) {
+ //should be caught in CMD caller
+ Base::Console().Error("TaskCenterLine - bad parameters. Can not proceed.\n");
+ return;
+ }
+
+ ui->setupUi(this);
+
+ Gui::Document* activeGui = Gui::Application::Instance->getDocument(m_basePage->getDocument());
+ Gui::ViewProvider* vp = activeGui->getViewProvider(m_basePage);
+ ViewProviderPage* vpp = static_cast(vp);
+ m_mdi = vpp->getMDIViewPage();
+ m_scene = m_mdi->m_scene;
+ m_view = m_mdi->getQGVPage();
+
+ setUiPrimary();
+
+// connect(ui->pbTracker, SIGNAL(clicked(bool)),
+// this, SLOT(onTrackerClicked(bool)));
+// connect(ui->pbCancelEdit, SIGNAL(clicked(bool)),
+// this, SLOT(onCancelEditClicked(bool)));
+}
+
+TaskCenterLine::~TaskCenterLine()
+{
+ delete ui;
+}
+
+void TaskCenterLine::saveState()
+{
+ if (m_partFeat != nullptr) {
+ }
+}
+
+void TaskCenterLine::restoreState()
+{
+ if (m_partFeat != nullptr) {
+ }
+}
+
+void TaskCenterLine::updateTask()
+{
+// blockUpdate = true;
+
+// blockUpdate = false;
+}
+
+void TaskCenterLine::changeEvent(QEvent *e)
+{
+ if (e->type() == QEvent::LanguageChange) {
+ ui->retranslateUi(this);
+ }
+}
+
+void TaskCenterLine::setUiPrimary()
+{
+// Base::Console().Message("TCL::setUiPrimary()\n");
+// enableVPUi(false);
+ setWindowTitle(QObject::tr("New Center Line"));
+
+ if (m_partFeat != nullptr) {
+ std::string baseName = m_partFeat->getNameInDocument();
+ ui->leBaseView->setText(Base::Tools::fromStdString(baseName));
+ for (auto& s: m_subNames) {
+ QString listItem = Base::Tools::fromStdString(s);
+ ui->lstSubList->addItem(listItem);
+ }
+ }
+ ui->cpLineColor->setColor(getCenterColor());
+ ui->dsbWeight->setValue(getCenterWidth());
+ ui->cboxStyle->setCurrentIndex(getCenterStyle());
+ ui->qsbExtend->setValue(getExtendBy());
+}
+
+//void TaskCenterLine::enableVPUi(bool b)
+
+//{
+//}
+
+//void TaskCenterLine::setUiEdit()
+//{
+//// Base::Console().Message("TCL::setUiEdit()\n");
+// enableVPUi(true);
+// setWindowTitle(QObject::tr("Edit Center Line"));
+//}
+
+void TaskCenterLine::addCenterLine(void)
+{
+// TechDraw::CosmeticEdge* ce = new TechDrawCosmeticEdge();
+}
+
+
+//******************************************************************************
+void TaskCenterLine::createCenterLine(void)
+{
+// Base::Console().Message("TCL::createCenterLine()\n");
+
+ Gui::Command::openCommand("Create CenterLine");
+ bool vertical = false;
+ if (ui->rbVertical->isChecked()) {
+ vertical = true;
+ }
+ m_extendBy = ui->qsbExtend->rawValue();
+ //TODO: (if m_partFeat->getGeomTypeFromName(m_subNames.at(0)) == "Face") {
+ TechDraw::CosmeticEdge* ce = makeMidLine(m_subNames.at(0),vertical,m_extendBy);
+ m_partFeat->addRandomEdge(ce);
+ m_partFeat->requestPaint();
+ Gui::Command::updateActive();
+ Gui::Command::commitCommand();
+}
+
+void TaskCenterLine::updateCenterLine(void)
+{
+// Base::Console().Message("TCL::updateCenterLine()\n");
+ Gui::Command::openCommand("Edit CenterLine");
+
+ Gui::Command::updateActive();
+ Gui::Command::commitCommand();
+}
+
+void TaskCenterLine::removeCenterLine(void)
+{
+// Base::Console().Message("TCL::removeCenterLine()\n");
+ if (m_partFeat != nullptr) {
+ if (m_createMode) {
+ //don't know!
+ } else {
+ if (Gui::Command::hasPendingCommand()) {
+ std::vector undos = Gui::Application::Instance->activeDocument()->getUndoVector();
+ Gui::Application::Instance->activeDocument()->undo(1);
+ } else {
+ Base::Console().Log("TaskCenterLine: Edit mode - NO command is active\n");
+ }
+ }
+ }
+}
+
+QGIView* TaskCenterLine::findParentQGIV()
+{
+ QGIView* result = nullptr;
+ if (m_partFeat != nullptr) {
+ Gui::ViewProvider* gvp = QGIView::getViewProvider(m_partFeat);
+ ViewProviderDrawingView* vpdv = dynamic_cast(gvp);
+ if (vpdv != nullptr) {
+ result = vpdv->getQView();
+ }
+ }
+ return result;
+}
+
+void TaskCenterLine::saveButtons(QPushButton* btnOK,
+ QPushButton* btnCancel)
+{
+ m_btnOK = btnOK;
+ m_btnCancel = btnCancel;
+}
+
+void TaskCenterLine::enableTaskButtons(bool b)
+{
+ m_btnOK->setEnabled(b);
+ m_btnCancel->setEnabled(b);
+}
+
+TechDraw::CosmeticEdge* TaskCenterLine::makeMidLine(std::string faceName, bool vert, double ext)
+{
+// Base::Console().Message("TCL::makeMidLine(%s, %d) \n",faceName.c_str(), vert);
+ TechDraw::CosmeticEdge* result = nullptr;
+ double scale = m_partFeat->getScale();
+ Base::Vector3d p1, p2;
+ int idx = TechDraw::DrawUtil::getIndexFromName(faceName);
+ std::vector faceEdges =
+ m_partFeat->getFaceEdgesByIndex(idx);
+ Bnd_Box faceBox;
+ faceBox.SetGap(0.0);
+ for (auto& fe: faceEdges) {
+ if (!fe->cosmetic) {
+ BRepBndLib::Add(fe->occEdge, faceBox);
+ }
+ }
+ double Xmin,Ymin,Zmin,Xmax,Ymax,Zmax;
+ faceBox.Get(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
+
+ double Xspan = fabs(Xmax - Xmin);
+ Xspan = (Xspan / 2.0) + (ext * scale);
+ double Xmid = Xmin + fabs(Xmax - Xmin) / 2.0;
+
+ double Yspan = fabs(Ymax - Ymin);
+ Yspan = (Yspan / 2.0) + (ext * scale);
+ double Ymid = Ymin + fabs(Ymax - Ymin) / 2.0;
+
+ Base::Vector3d bbxCenter(Xmid, Ymid, 0.0);
+
+ if (vert) {
+ Base::Vector3d top(Xmid, Ymid - Yspan, 0.0);
+ Base::Vector3d bottom(Xmid, Ymid + Yspan, 0.0);
+ p1 = top;
+ p2 = bottom;
+ } else {
+ Base::Vector3d left(Xmid - Xspan, Ymid, 0.0);
+ Base::Vector3d right(Xmid + Xspan, Ymid, 0.0);
+ p1 = left;
+ p2 = right;
+ }
+
+ result = new TechDraw::CosmeticEdge(p1,p2);
+ App::Color ac;
+ ac.setValue(ui->cpLineColor->color());
+ result->color = ac;
+ result->width = ui->dsbWeight->value();
+ result->style = ui->cboxStyle->currentIndex();
+ result->visible = true;
+ return result;
+}
+
+double TaskCenterLine::getCenterWidth()
+{
+ Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
+ GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
+ std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
+ auto lg = TechDraw::LineGroup::lineGroupFactory(lgName);
+
+ double width = lg->getWeight("Graphic");
+ delete lg;
+ return width;
+}
+
+Qt::PenStyle TaskCenterLine::getCenterStyle()
+{
+ Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
+ GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
+ Qt::PenStyle centerStyle = static_cast (hGrp->GetInt("CenterLine", 2));
+ return centerStyle;
+}
+
+QColor TaskCenterLine::getCenterColor()
+{
+ Base::Reference hGrp = App::GetApplication().GetUserParameter()
+ .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
+ App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("CenterColor", 0x00000000));
+ return fcColor.asValue();
+}
+
+double TaskCenterLine::getExtendBy(void)
+{
+ return 3.0;
+}
+
+//******************************************************************************
+
+bool TaskCenterLine::accept()
+{
+// Base::Console().Message("TCL::accept()\n");
+
+ Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
+ if (!doc) return false;
+
+ if (!getCreateMode()) {
+ //
+ } else {
+ createCenterLine();
+ }
+// m_mdi->setContextMenuPolicy(m_saveContextPolicy);
+ Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
+
+ return true;
+}
+
+bool TaskCenterLine::reject()
+{
+ if (m_inProgressLock) {
+// Base::Console().Message("TCL::reject - edit in progress!!\n");
+ return false;
+ }
+
+ Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
+ if (!doc) return false;
+
+ if (m_mdi != nullptr) {
+// m_mdi->setContextMenuPolicy(m_saveContextPolicy);
+ }
+ if (getCreateMode() &&
+ (m_partFeat != nullptr) ) {
+ //
+ }
+
+ if (!getCreateMode() &&
+ (m_partFeat != nullptr) ) {
+ //
+ }
+
+ //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;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+TaskDlgCenterLine::TaskDlgCenterLine(TechDraw::DrawViewPart* partFeat,
+ TechDraw::DrawPage* page,
+ std::vector subNames)
+ : TaskDialog()
+{
+ widget = new TaskCenterLine(partFeat,page,subNames);
+ taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-centerline"),
+ widget->windowTitle(), true, 0);
+ taskbox->groupLayout()->addWidget(widget);
+ Content.push_back(taskbox);
+}
+
+//TaskDlgCenterLine::TaskDlgCenterLine(TechDrawGui::ViewProviderViewPart* partVP)
+// : TaskDialog()
+//{
+// widget = new TaskCenterLine(partVP);
+// taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-centerline"),
+// widget->windowTitle(), true, 0);
+// taskbox->groupLayout()->addWidget(widget);
+// Content.push_back(taskbox);
+//}
+
+TaskDlgCenterLine::~TaskDlgCenterLine()
+{
+}
+
+void TaskDlgCenterLine::update()
+{
+// widget->updateTask();
+}
+
+void TaskDlgCenterLine::modifyStandardButtons(QDialogButtonBox* box)
+{
+ QPushButton* btnOK = box->button(QDialogButtonBox::Ok);
+ QPushButton* btnCancel = box->button(QDialogButtonBox::Cancel);
+ widget->saveButtons(btnOK, btnCancel);
+}
+
+//==== calls from the TaskView ===============================================================
+void TaskDlgCenterLine::open()
+{
+}
+
+void TaskDlgCenterLine::clicked(int)
+{
+}
+
+bool TaskDlgCenterLine::accept()
+{
+ widget->accept();
+ return true;
+}
+
+bool TaskDlgCenterLine::reject()
+{
+ widget->reject();
+ return true;
+}
+
+#include
diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.h b/src/Mod/TechDraw/Gui/TaskCenterLine.h
new file mode 100644
index 0000000000..ddd3a7ecd8
--- /dev/null
+++ b/src/Mod/TechDraw/Gui/TaskCenterLine.h
@@ -0,0 +1,181 @@
+/***************************************************************************
+ * Copyright (c) 2019 WandererFan *
+ * *
+ * 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_TASKCENTERLINE_H
+#define TECHDRAWGUI_TASKCENTERLINE_H
+
+#include
+#include
+#include
+#include
+
+/*#include */
+
+/*#include "QGTracker.h"*/
+
+//TODO: make this a proper enum
+#define TRACKERPICK 0
+#define TRACKEREDIT 1
+#define TRACKERCANCEL 2
+#define TRACKERCANCELEDIT 3
+#define TRACKERFINISHED 4
+#define TRACKERSAVE 5
+
+class Ui_TaskCenterLine;
+
+namespace App {
+class DocumentObject;
+}
+
+namespace TechDraw
+{
+class DrawPage;
+class DrawView;
+class DrawViewPart;
+}
+
+namespace TechDrawGeometry
+{
+class Face;
+}
+
+namespace TechDrawGui
+{
+class QGVPage;
+class QGIView;
+class QGIPrimPath;
+class MDIViewPage;
+class ViewProviderViewPart;
+
+class TaskCenterLine : public QWidget
+{
+ Q_OBJECT
+
+public:
+ TaskCenterLine(TechDraw::DrawViewPart* baseFeat,
+ TechDraw::DrawPage* page,
+ std::vector subNames);
+/* TaskCenterLine(TechDrawGui::ViewProviderViewPart* partVP);*/
+ ~TaskCenterLine();
+
+public Q_SLOTS:
+
+public:
+ virtual bool accept();
+ virtual bool reject();
+ virtual void setCreateMode(bool b) { m_createMode = b; }
+ virtual bool getCreateMode(void) { return m_createMode; }
+ void updateTask();
+ void saveButtons(QPushButton* btnOK,
+ QPushButton* btnCancel);
+ void enableTaskButtons(bool b);
+
+
+protected Q_SLOTS:
+
+protected:
+ void changeEvent(QEvent *e);
+
+ void blockButtons(bool b);
+ void setUiPrimary(void);
+/* void setUiEdit(void);*/
+/* void enableVPUi(bool b);*/
+/* void setEditCursor(QCursor c);*/
+
+ void addCenterLine(void);
+ void createCenterLine(void);
+
+
+ QGIView* findParentQGIV();
+ void updateCenterLine(void);
+ void removeCenterLine(void);
+ TechDraw::CosmeticEdge* makeMidLine(std::string subName, bool vert, double ext);
+
+ void saveState(void);
+ void restoreState(void);
+
+ double getCenterWidth();
+ QColor getCenterColor();
+ Qt::PenStyle getCenterStyle();
+ double getExtendBy();
+
+
+private:
+ Ui_TaskCenterLine * ui;
+ bool blockUpdate;
+
+ MDIViewPage* m_mdi;
+ QGraphicsScene* m_scene;
+ QGVPage* m_view;
+ ViewProviderViewPart* m_partVP;
+ TechDraw::DrawViewPart* m_partFeat;
+ TechDraw::DrawPage* m_basePage;
+ bool m_createMode;
+
+ Qt::ContextMenuPolicy m_saveContextPolicy;
+ bool m_inProgressLock;
+
+ QPushButton* m_btnOK;
+ QPushButton* m_btnCancel;
+
+ std::vector m_subNames;
+ double m_extendBy;
+};
+
+class TaskDlgCenterLine : public Gui::TaskView::TaskDialog
+{
+ Q_OBJECT
+
+public:
+ TaskDlgCenterLine(TechDraw::DrawViewPart* baseFeat,
+ TechDraw::DrawPage* page,
+ std::vector subNames);
+/* TaskDlgCenterLine(TechDrawGui::ViewProviderLeader* partVP);*/
+ ~TaskDlgCenterLine();
+
+public:
+ /// is called the TaskView when the dialog is opened
+ virtual void open();
+ /// is called by the framework if an button is clicked which has no accept or reject role
+ virtual void clicked(int);
+ /// is called by the framework if the dialog is accepted (Ok)
+ virtual bool accept();
+ /// is called by the framework if the dialog is rejected (Cancel)
+ virtual bool reject();
+ /// is called by the framework if the user presses the help button
+ virtual void helpRequested() { return;}
+ virtual bool isAllowedAlterDocument(void) const
+ { return false; }
+ void update();
+
+ void modifyStandardButtons(QDialogButtonBox* box);
+
+protected:
+
+private:
+ TaskCenterLine * widget;
+ Gui::TaskView::TaskBox* taskbox;
+};
+
+} //namespace TechDrawGui
+
+#endif // #ifndef TECHDRAWGUI_TASKCENTERLINE_H
diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.ui b/src/Mod/TechDraw/Gui/TaskCenterLine.ui
new file mode 100644
index 0000000000..bb0d719d80
--- /dev/null
+++ b/src/Mod/TechDraw/Gui/TaskCenterLine.ui
@@ -0,0 +1,277 @@
+
+
+ TechDrawGui::TaskCenterLine
+
+
+
+ 0
+ 0
+ 409
+ 405
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 250
+ 0
+
+
+
+ Center Line
+
+
+
+ :/icons/actions/techdraw-centerline.svg:/icons/actions/techdraw-centerline.svg
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ QFrame::Box
+
+
+ QFrame::Raised
+
+
+
-
+
+
-
+
+
-
+
+
+ false
+
+
+ false
+
+
+ Qt::NoFocus
+
+
+ false
+
+
+
+ -
+
+
+ Base View
+
+
+
+ -
+
+
+ Elements
+
+
+
+ -
+
+
+ false
+
+
+
+ 16777215
+ 100
+
+
+
+
+
+
+ -
+
+
-
+
+
+ Vertical
+
+
+ true
+
+
+
+ -
+
+
+ true
+
+
+ Horizontal
+
+
+
+ -
+
+
+ Aligned
+
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ QFormLayout::AllNonFixedFieldsGrow
+
+
-
+
+
+ Color
+
+
+
+ -
+
+
+
+ 0
+ 0
+ 0
+
+
+
+
+ -
+
+
+ Weight
+
+
+
+ -
+
+
+ 0.100000000000000
+
+
+ 0.500000000000000
+
+
+
+ -
+
+
+ Style
+
+
+
+ -
+
+
+ 1
+
+
-
+
+ NoLine
+
+
+ -
+
+ Solid
+
+
+ -
+
+ Dash
+
+
+ -
+
+ Dot
+
+
+ -
+
+ DashDot
+
+
+ -
+
+ DashDotDot
+
+
+
+
+ -
+
+
+ Extend By
+
+
+
+ -
+
+
+ Make the line a little longer.
+
+
+ mm
+
+
+ 3.000000000000000
+
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+
+
+
+ Gui::QuantitySpinBox
+ QWidget
+
+
+
+ Gui::ColorButton
+ QPushButton
+
+
+
+
+
+
+
+
diff --git a/src/Mod/TechDraw/Gui/Workbench.cpp b/src/Mod/TechDraw/Gui/Workbench.cpp
index 35cb439fc4..d97cb5b2c2 100644
--- a/src/Mod/TechDraw/Gui/Workbench.cpp
+++ b/src/Mod/TechDraw/Gui/Workbench.cpp
@@ -156,6 +156,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
*anno << "TechDraw_LeaderLine";
*anno << "TechDraw_RichAnno";
*anno << "TechDraw_CosmeticVertexGrp";
+ *anno << "TechDraw_CenterLine";
// *anno << "TechDraw_CosmeticVertex";
// *anno << "TechDraw_Midpoints";
// *anno << "TechDraw_Quadrant";
@@ -223,6 +224,7 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
*anno << "TechDraw_LeaderLine";
*anno << "TechDraw_RichAnno";
*anno << "TechDraw_CosmeticVertexGrp";
+ *anno << "TechDraw_CenterLine";
// *anno << "TechDraw_CosmeticVertex";
// *anno << "TechDraw_Midpoints";
// *anno << "TechDraw_Quadrant";