diff --git a/src/Mod/TechDraw/App/Cosmetic.cpp b/src/Mod/TechDraw/App/Cosmetic.cpp index 60357b7e71..31c90c968d 100644 --- a/src/Mod/TechDraw/App/Cosmetic.cpp +++ b/src/Mod/TechDraw/App/Cosmetic.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #endif // #ifndef _PreComp_ #include @@ -492,7 +493,10 @@ CenterLine::~CenterLine() { } -CenterLine* CenterLine::CenterLineBuilder(DrawViewPart* partFeat, std::vector subNames, int mode) +CenterLine* CenterLine::CenterLineBuilder(DrawViewPart* partFeat, + std::vector subNames, + int mode, + bool flip) { // Base::Console().Message("CL::CLBuilder()\n"); std::pair ends; @@ -516,7 +520,7 @@ CenterLine* CenterLine::CenterLineBuilder(DrawViewPart* partFeat, std::vectorm_start = ends.first; -// cl->m_end = ends.second; cl->m_type = type; cl->m_mode = mode; cl->m_faces = faces; cl->m_edges = edges; cl->m_verts = verts; -// cl->m_flip2Line = false; + cl->m_flip2Line = flip; } return cl; } @@ -732,7 +740,7 @@ std::pair CenterLine::calcEndPoints2Lines(DrawVi double rotate, bool flip) { -// Base::Console().Message("CL::calc2Lines()\n"); +// Base::Console().Message("CL::calc2Lines() - mode: %d flip: %d\n", mode, flip); std::pair result; if (edgeNames.empty()) { Base::Console().Message("CL::calcEndPoints2Lines - no edges!\n"); @@ -760,12 +768,13 @@ std::pair CenterLine::calcEndPoints2Lines(DrawVi Base::Vector3d l2p1 = edges.back()->getStartPoint(); Base::Vector3d l2p2 = edges.back()->getEndPoint(); - if (flip) { + if (flip) { //reverse line 2 Base::Vector3d temp; temp = l2p1; l2p1 = l2p2; l2p2 = temp; } + Base::Vector3d p1 = (l1p1 + l2p1) / 2.0; Base::Vector3d p2 = (l1p2 + l2p2) / 2.0; Base::Vector3d mid = (p1 + p2) / 2.0; @@ -861,7 +870,7 @@ std::pair CenterLine::calcEndPoints2Points(DrawV Base::Vector3d p1 = mid + clDir * (length / 2.0); Base::Vector3d p2 = mid - clDir * (length / 2.0); - if (flip) { + if (flip) { //is flip relevant to 2 point??? Base::Vector3d temp; temp = p1; p1 = p2; diff --git a/src/Mod/TechDraw/App/Cosmetic.h b/src/Mod/TechDraw/App/Cosmetic.h index 0f36518873..c9df65c008 100644 --- a/src/Mod/TechDraw/App/Cosmetic.h +++ b/src/Mod/TechDraw/App/Cosmetic.h @@ -170,7 +170,8 @@ public: static CenterLine* CenterLineBuilder(TechDraw::DrawViewPart* partFeat, std::vector subs, - int mode = 0); + int mode = 0, + bool flip = false); TechDraw::BaseGeom* scaledGeometry(TechDraw::DrawViewPart* partFeat); static std::pair calcEndPoints( TechDraw::DrawViewPart* partFeat, diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp index 8f2c313f58..8e15b781d6 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp @@ -242,64 +242,27 @@ void TaskCenterLine::createCenterLine(void) } else if (ui->rbAligned->isChecked()) { m_mode = CenterLine::CLMODE::ALIGNED; } - - //TODO: call CLBuilder here. - if (m_type == CenterLine::CLTYPE::FACE) { - ends = TechDraw::CenterLine::calcEndPoints(m_partFeat, - m_subNames, - m_mode, - extendBy, - hShift, vShift, rotate); - } else if (m_type == CenterLine::CLTYPE::EDGE) { - ends = TechDraw::CenterLine::calcEndPoints2Lines(m_partFeat, - m_subNames, - m_mode, - extendBy, - hShift, vShift, rotate, m_flipped); - } else if (m_type == CenterLine::CLTYPE::VERTEX) { - ends = TechDraw::CenterLine::calcEndPoints2Points(m_partFeat, - m_subNames, - m_mode, - extendBy, - hShift, vShift, rotate, m_flipped); + + TechDraw::CenterLine* cl = CenterLine::CenterLineBuilder(m_partFeat, + m_subNames, + m_mode, + m_flipped); + if (cl != nullptr) { + cl->setShifts(hShift, vShift); + cl->setExtend(extendBy); + cl->setRotate(rotate); + cl->setFlip(m_flipped); + App::Color ac; + ac.setValue(ui->cpLineColor->color()); + cl->m_format.m_color = ac; + cl->m_format.m_weight = ui->dsbWeight->value(); + cl->m_format.m_style = ui->cboxStyle->currentIndex() + 1; //Qt Styles start at 0:NoLine + cl->m_format.m_visible = true; + m_partFeat->addCenterLine(cl); + } else { + Base::Console().Log("TCL::createCenterLine - CenterLine creation failed!\n"); } - TechDraw::CenterLine* cl = new TechDraw::CenterLine(ends.first, ends.second); - cl->m_start = ends.first; - cl->m_end = ends.second; - - //TODO: cl->setShifts(hShift, vShift); - // cl->setExtend(extendBy); - // cl->setRotate(rotate); - // cl->setFlip(m_flipped); - App::Color ac; - ac.setValue(ui->cpLineColor->color()); - cl->m_format.m_color = ac; - cl->m_format.m_weight = ui->dsbWeight->value(); - cl->m_format.m_style = ui->cboxStyle->currentIndex() + 1; //Qt Styles start at 0:NoLine - cl->m_format.m_visible = true; - - //TODO: CLBuilder replaces this - if (m_type == CenterLine::CLTYPE::FACE) { - cl->m_faces = m_subNames; - } else if (m_type == CenterLine::CLTYPE::EDGE) { - cl->m_edges = m_subNames; - } else if (m_type == CenterLine::CLTYPE::VERTEX) { - cl->m_verts = m_subNames; - } - - cl->m_mode = m_mode; - cl->m_rotate = rotate; - cl->m_vShift = vShift; - cl->m_hShift = hShift; - cl->m_extendBy = extendBy; - cl->m_mode = m_mode; - cl->m_type = m_type; - cl->m_flip2Line = m_flipped; - //end TODO - - m_partFeat->addCenterLine(cl); - m_partFeat->recomputeFeature(); Gui::Command::updateActive(); Gui::Command::commitCommand(); @@ -391,6 +354,7 @@ double TaskCenterLine::getExtendBy(void) void TaskCenterLine::setFlipped(bool b) { +// Base::Console().Message("TCL::setFlipped(%d)\n",b); m_flipped = b; } @@ -458,19 +422,19 @@ void TaskCL2Lines::initUi() void TaskCL2Lines::onFlipToggled(bool b) { - Base::Console().Message("TCL2L::onFlipToggled(%d)\n", b); +// Base::Console().Message("TCL2L::onFlipToggled(%d)\n", b); m_tcl->setFlipped(b); } bool TaskCL2Lines::accept() { - Base::Console().Message("TCL2L::accept()\n"); +// Base::Console().Message("TCL2L::accept()\n"); return true; } bool TaskCL2Lines::reject() { - Base::Console().Message("TCL2L::reject()\n"); +// Base::Console().Message("TCL2L::reject()\n"); return false; } @@ -496,7 +460,7 @@ TaskDlgCenterLine::TaskDlgCenterLine(TechDraw::DrawViewPart* partFeat, cl2Lines = new TaskCL2Lines(widget); linesBox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-2linecenterline"), - widget->windowTitle(), true, 0); + cl2Lines->windowTitle(), true, 0); linesBox->groupLayout()->addWidget(cl2Lines); Content.push_back(linesBox);