From d09d0b60369c20c6977cfbfef202f7267188e982 Mon Sep 17 00:00:00 2001 From: edi271 Date: Thu, 4 Nov 2021 14:46:07 +0100 Subject: [PATCH] Next31TechDrawTools --- src/Mod/TechDraw/Gui/AppTechDrawGui.cpp | 2 + src/Mod/TechDraw/Gui/CMakeLists.txt | 6 + src/Mod/TechDraw/Gui/CommandExtensionDims.cpp | 2196 +++++++++++++++++ src/Mod/TechDraw/Gui/CommandExtensionPack.cpp | 1754 ++++++++++++- src/Mod/TechDraw/Gui/Resources/TechDraw.qrc | 31 + .../Resources/icons/TechDraw_ExtensionArc.svg | 179 ++ ...echDraw_ExtensionCascadeHorizDimension.svg | 283 +++ ...hDraw_ExtensionCascadeObliqueDimension.svg | 283 +++ ...TechDraw_ExtensionCascadeVertDimension.svg | 283 +++ ...TechDraw_ExtensionChangeLineAttributes.svg | 114 + ...raw_ExtensionCreateHorizChainDimension.svg | 161 ++ ...w_ExtensionCreateHorizChamferDimension.svg | 150 ++ ...raw_ExtensionCreateHorizCoordDimension.svg | 197 ++ .../TechDraw_ExtensionCreateLengthArc.svg | 190 ++ ...w_ExtensionCreateObliqueChainDimension.svg | 166 ++ ...w_ExtensionCreateObliqueCoordDimension.svg | 202 ++ ...Draw_ExtensionCreateVertChainDimension.svg | 161 ++ ...aw_ExtensionCreateVertChamferDimension.svg | 146 ++ ...Draw_ExtensionCreateVertCoordDimension.svg | 197 ++ .../TechDraw_ExtensionDecreaseDecimal.svg | 142 ++ .../TechDraw_ExtensionDrawCosmCircle.svg | 142 ++ .../icons/TechDraw_ExtensionExtendLine.svg | 167 ++ .../icons/TechDraw_ExtensionHoleCircle.svg | 253 ++ .../TechDraw_ExtensionIncreaseDecimal.svg | 136 + .../TechDraw_ExtensionInsertDiameter.svg | 158 ++ .../icons/TechDraw_ExtensionInsertSquare.svg | 165 ++ .../icons/TechDraw_ExtensionLineParallel.svg | 91 + .../TechDraw_ExtensionLinePerpendicular.svg | 90 + .../TechDraw_ExtensionLockUnlockView.svg | 252 ++ ...chDraw_ExtensionPosHorizChainDimension.svg | 135 + ...Draw_ExtensionPosObliqueChainDimension.svg | 144 ++ ...echDraw_ExtensionPosVertChainDimension.svg | 135 + .../TechDraw_ExtensionPositionSectionView.svg | 116 + ...TechDraw_ExtensionSelectLineAttributes.svg | 214 ++ .../icons/TechDraw_ExtensionShortenLine.svg | 166 ++ ...TechDraw_ExtensionVertexAtIntersection.svg | 96 + .../TechDraw/Gui/TaskSelectLineAttributes.cpp | 404 +++ .../TechDraw/Gui/TaskSelectLineAttributes.h | 143 ++ .../TechDraw/Gui/TaskSelectLineAttributes.ui | 321 +++ src/Mod/TechDraw/Gui/Workbench.cpp | 180 +- 40 files changed, 10200 insertions(+), 151 deletions(-) create mode 100644 src/Mod/TechDraw/Gui/CommandExtensionDims.cpp create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionArc.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCascadeHorizDimension.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCascadeObliqueDimension.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCascadeVertDimension.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionChangeLineAttributes.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateHorizChainDimension.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateHorizChamferDimension.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateHorizCoordDimension.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateLengthArc.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateObliqueChainDimension.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateObliqueCoordDimension.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateVertChainDimension.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateVertChamferDimension.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateVertCoordDimension.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionDecreaseDecimal.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionDrawCosmCircle.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionExtendLine.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionHoleCircle.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionIncreaseDecimal.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionInsertDiameter.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionInsertSquare.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionLineParallel.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionLinePerpendicular.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionLockUnlockView.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPosHorizChainDimension.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPosObliqueChainDimension.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPosVertChainDimension.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPositionSectionView.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionSelectLineAttributes.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionShortenLine.svg create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionVertexAtIntersection.svg create mode 100644 src/Mod/TechDraw/Gui/TaskSelectLineAttributes.cpp create mode 100644 src/Mod/TechDraw/Gui/TaskSelectLineAttributes.h create mode 100644 src/Mod/TechDraw/Gui/TaskSelectLineAttributes.ui diff --git a/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp b/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp index 4e84646f4e..62dcbfc0b7 100644 --- a/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp +++ b/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp @@ -75,6 +75,7 @@ void CreateTechDrawCommands(void); void CreateTechDrawCommandsDims(void); void CreateTechDrawCommandsDecorate(void); void CreateTechDrawCommandsAnnotate(void); +void CreateTechDrawCommandsExtensionDims(void); void CreateTechDrawCommandsExtensions(void); void loadTechDrawResource() @@ -121,6 +122,7 @@ PyMOD_INIT_FUNC(TechDrawGui) CreateTechDrawCommandsDims(); CreateTechDrawCommandsDecorate(); CreateTechDrawCommandsAnnotate(); + CreateTechDrawCommandsExtensionDims(); CreateTechDrawCommandsExtensions(); TechDrawGui::Workbench::init(); diff --git a/src/Mod/TechDraw/Gui/CMakeLists.txt b/src/Mod/TechDraw/Gui/CMakeLists.txt index f0c7d73fba..59ed6c6c49 100644 --- a/src/Mod/TechDraw/Gui/CMakeLists.txt +++ b/src/Mod/TechDraw/Gui/CMakeLists.txt @@ -67,6 +67,7 @@ set(TechDrawGui_UIC_SRCS TaskActiveView.ui TaskBalloon.ui TaskCosmeticLine.ui + TaskSelectLineAttributes.ui TaskCosVertex.ui TaskCenterLine.ui TaskDetail.ui @@ -109,6 +110,7 @@ SET(TechDrawGui_SRCS CommandCreateDims.cpp CommandDecorate.cpp CommandAnnotate.cpp + CommandExtensionDims.cpp CommandExtensionPack.cpp Resources/TechDraw.qrc PreCompiled.cpp @@ -182,6 +184,9 @@ SET(TechDrawGui_SRCS TaskWeldingSymbol.ui TaskWeldingSymbol.cpp TaskWeldingSymbol.h + TaskSelectLineAttributes.ui + TaskSelectLineAttributes.cpp + TaskSelectLineAttributes.h DrawGuiUtil.cpp DrawGuiUtil.h Rez.cpp @@ -371,6 +376,7 @@ SET(TechDrawGuiTaskDlgs_SRCS TaskActiveView.ui TaskDetail.ui TaskCosmeticLine.ui + TaskSelectLineAttributes.ui ) SOURCE_GROUP("TaskDialogs" FILES ${TechDrawGuiTaskDlgs_SRCS}) diff --git a/src/Mod/TechDraw/Gui/CommandExtensionDims.cpp b/src/Mod/TechDraw/Gui/CommandExtensionDims.cpp new file mode 100644 index 0000000000..797fddf2e6 --- /dev/null +++ b/src/Mod/TechDraw/Gui/CommandExtensionDims.cpp @@ -0,0 +1,2196 @@ +/*************************************************************************** + * Copyright (c) 2021 edi * + * * + * 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_ +# include +# include +# include +# include +# 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 +# include +# include +# include +# include + +#include //needed ? + + +#include "DrawGuiUtil.h" +#include "MDIViewPage.h" +#include "ViewProviderPage.h" +#include "TaskLinkDim.h" + +#include "TaskSelectLineAttributes.h" + +///////////////////////////// +#include // needed +#include +///////////////////////////// + +using namespace TechDrawGui; +using namespace TechDraw; +using namespace std; + +//internal structures and sort functions +struct dimVertex{ + // save a dimension defining vertex and its point + std::string name; + Base::Vector3d point; +}; + +struct { + bool operator()(dimVertex a, dimVertex b) const {return a.point.x < b.point.x;} +} sortX; + +struct { + bool operator()(dimVertex a, dimVertex b) const {return a.point.y < b.point.y;} +} sortY; + +//internal helper functions +void _selectDimensionAttributes(Gui::Command* cmd); +std::vector_getDimensions(std::vector selection,std::string needDimType); +Base::Vector3d _getTrianglePoint(Base::Vector3d p1, Base::Vector3d d, Base::Vector3d p2); +std::vector _getVertexInfo(TechDraw::DrawViewPart* objFeat, + std::vector subNames); +TechDraw::DrawViewDimension* _createLinDimension(Gui::Command* cmd, + TechDraw::DrawViewPart* objFeat, + std::string startVertex, + std::string endVertex, + std::string dimType); +bool _checkSelection(Gui::Command* cmd, + std::vector& selection, + std::string message); +bool _checkSelAndObj(Gui::Command* cmd, + std::vector& selection, + TechDraw::DrawViewPart*& objFeat, + std::string message); + +//=========================================================================== +// TechDraw_ExtensionInsertDiameter +//=========================================================================== + +void execInsertPraefixChar(Gui::Command* cmd,std::string praefixChar){ + // insert a praefix character into the format specifier + std::vector selection; + if (_checkSelection(cmd,selection,"TechDraw Insert Praefix Character")){ + for (auto selected : selection){ + auto object = selected.getObject(); + if (object->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())){ + auto dim = dynamic_cast(selected.getObject()); + std::string formatSpec = dim->FormatSpec.getStrValue(); + formatSpec = praefixChar+formatSpec; + dim->FormatSpec.setValue(formatSpec); + } + } + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionInsertDiameter) + +CmdTechDrawExtensionInsertDiameter::CmdTechDrawExtensionInsertDiameter() + : Command("TechDraw_ExtensionInsertDiameter") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Insert '⌀' sign"); + sToolTipText = QT_TR_NOOP("Insert '⌀' sign in a measure\n\ + - select many measures\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionInsertDiameter"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionInsertDiameter"; +} + +void CmdTechDrawExtensionInsertDiameter::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execInsertPraefixChar(this,"⌀"); +} + +bool CmdTechDrawExtensionInsertDiameter::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionInsertSquare +//=========================================================================== + +DEF_STD_CMD_A(CmdTechDrawExtensionInsertSquare) + +CmdTechDrawExtensionInsertSquare::CmdTechDrawExtensionInsertSquare() + : Command("TechDraw_ExtensionInsertSquare") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Insert '〼' sign"); + sToolTipText = QT_TR_NOOP("Insert '〼' sign in a measure\n\ + - select many measures\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionInsertSquare"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionInsertSquare"; +} + +void CmdTechDrawExtensionInsertSquare::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execInsertPraefixChar(this,"〼"); +} + +bool CmdTechDrawExtensionInsertSquare::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionInsertPraefixGroup +//=========================================================================== + +DEF_STD_CMD_ACL(CmdTechDrawExtensionInsertPraefixGroup) + +CmdTechDrawExtensionInsertPraefixGroup::CmdTechDrawExtensionInsertPraefixGroup() + : Command("TechDraw_ExtensionInsertPraefixGroup") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Insert a '⌀' sign in a measure"); + sToolTipText = QT_TR_NOOP("Insert a '⌀' sign in a measure:\n\ + - select many measures\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionInsertPraefixGroup"; + sStatusTip = sToolTipText; +} + +void CmdTechDrawExtensionInsertPraefixGroup::activated(int iMsg) +{ +// Base::Console().Message("CMD::ExtensionLinePPGroup - activated(%d)\n", 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; + } + + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + pcAction->setIcon(pcAction->actions().at(iMsg)->icon()); + switch(iMsg) { + case 0: //insert "⌀" as praefix + execInsertPraefixChar(this,"⌀"); + break; + case 1: //insert "〼" as praefix + execInsertPraefixChar(this,"〼"); + break; + default: + Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg); + }; +} + +Gui::Action * CmdTechDrawExtensionInsertPraefixGroup::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionInsertDiameter")); + p1->setObjectName(QString::fromLatin1("TechDraw_ExtensionInsertDiameter")); + p1->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionInsertDiameter")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionInsertSquare")); + p2->setObjectName(QString::fromLatin1("TechDraw_ExtensionInsertSquare")); + p2->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionInsertSquare")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdTechDrawExtensionInsertPraefixGroup::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("TechDraw_Extension","Insert '⌀' sign in a measure")); + arc1->setToolTip(QApplication::translate("TechDraw_Extension","Insert a '⌀' sign in a measure:\n\ + - select many measures\n\ + - click this button")); + arc1->setStatusTip(arc1->toolTip()); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("TechDraw_Extension","Insert a '〼' sign in a measure")); + arc2->setToolTip(QApplication::translate("TechDraw_Extension","Insert a '〼' sign in a measure:\n\ + - select many measures\n\ + - click this button")); + arc2->setStatusTip(arc2->toolTip()); +} + +bool CmdTechDrawExtensionInsertPraefixGroup::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, true); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionIncreaseDecimal +//=========================================================================== + +void execIncreaseDecreaseDecimal(Gui::Command* cmd, int delta){ + // increase or decrease number of decimal places of a measure + std::vector selection; + if (_checkSelection(cmd,selection,"TechDraw Increase/Decrease Decimal")){ + std::string numStr; + for (auto selected : selection){ + auto object = selected.getObject(); + if (object->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())){ + auto dim = dynamic_cast(selected.getObject()); + std::string formatSpec = dim->FormatSpec.getStrValue(); + std::string searchStr ("%."); + int numFound = formatSpec.find(searchStr)+2; + numStr = formatSpec[numFound]; + int numInt = std::stoi(numStr,nullptr); + numInt = numInt+delta; + if (numInt >= 0 && numInt <= 9){ + numStr = std::to_string(numInt); + formatSpec.replace(numFound,1,numStr); + dim->FormatSpec.setValue(formatSpec); + } + } + } + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionIncreaseDecimal) + +CmdTechDrawExtensionIncreaseDecimal::CmdTechDrawExtensionIncreaseDecimal() + : Command("TechDraw_ExtensionIncreaseDecimal") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Increase Decimal Places"); + sToolTipText = QT_TR_NOOP("Increase Decimal Places of a Measure\n\ + - select many measures\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionIncreaseDecimal"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionIncreaseDecimal"; +} + +void CmdTechDrawExtensionIncreaseDecimal::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execIncreaseDecreaseDecimal(this,1); +} + +bool CmdTechDrawExtensionIncreaseDecimal::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionDecreaseDecimal +//=========================================================================== + +DEF_STD_CMD_A(CmdTechDrawExtensionDecreaseDecimal) + +CmdTechDrawExtensionDecreaseDecimal::CmdTechDrawExtensionDecreaseDecimal() + : Command("TechDraw_ExtensionDecreaseDecimal") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Decrease Decimal Places"); + sToolTipText = QT_TR_NOOP("Decrease Decimal Places of a Measure\n\ + - select many measures\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionDecreaseDecimal"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionDecreaseDecimal"; +} + +void CmdTechDrawExtensionDecreaseDecimal::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execIncreaseDecreaseDecimal(this,-1); +} + +bool CmdTechDrawExtensionDecreaseDecimal::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionIncreaseDecreaseGroup +//=========================================================================== + +DEF_STD_CMD_ACL(CmdTechDrawExtensionIncreaseDecreaseGroup) + +CmdTechDrawExtensionIncreaseDecreaseGroup::CmdTechDrawExtensionIncreaseDecreaseGroup() + : Command("TechDraw_ExtensionIncreaseDecreaseGroup") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Increase Decimal Places"); + sToolTipText = QT_TR_NOOP("Increase Decimal Places of a Measure\n\ + - select many measures\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionIncreaseDecreaseGroup"; + sStatusTip = sToolTipText; +} + +void CmdTechDrawExtensionIncreaseDecreaseGroup::activated(int iMsg) +{ +// Base::Console().Message("CMD::ExtensionIncreaseDecreaseGroup - activated(%d)\n", 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; + } + + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + pcAction->setIcon(pcAction->actions().at(iMsg)->icon()); + switch(iMsg) { + case 0: //increase decimal places + execIncreaseDecreaseDecimal(this,1); + break; + case 1: //decrease decimal places + execIncreaseDecreaseDecimal(this,-1); + break; + default: + Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg); + }; +} + +Gui::Action * CmdTechDrawExtensionIncreaseDecreaseGroup::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionIncreaseDecimal")); + p1->setObjectName(QString::fromLatin1("TechDraw_ExtensionIncreaseDecimal")); + p1->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionIncreaseDecimal")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionDecreaseDecimal")); + p2->setObjectName(QString::fromLatin1("TechDraw_ExtensionDecreaseDecimal")); + p2->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionDecreaseDecimal")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdTechDrawExtensionIncreaseDecreaseGroup::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("TechDraw_Extension","Increase Decimal Places")); + arc1->setToolTip(QApplication::translate("TechDraw_Extension","Increase Decimal Places of a Measure\n\ + - select many measures\n\ + - click this button")); + arc1->setStatusTip(arc1->toolTip()); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("TechDraw_Extension","Decrease Decimal Places")); + arc2->setToolTip(QApplication::translate("TechDraw_Extension","Decrease Decimal Places of a Measure\n\ + - select many measures\n\ + - click this button")); + arc2->setStatusTip(arc2->toolTip()); +} + +bool CmdTechDrawExtensionIncreaseDecreaseGroup::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, true); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionPosHorizChainDimension +//=========================================================================== + +void execPosHorizChainDimension(Gui::Command* cmd){ + // position a horizontal dimension chain + std::vector selection; + if (_checkSelection(cmd,selection,"TechDraw PosHorizChainDimension")){ + std::vector validDimension; + validDimension = _getDimensions(selection,"DistanceX"); + if( validDimension.empty() ) { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("TechDraw PosHorizChainDimension"), + QObject::tr("No horizontal dimensions selected")); + return; + } + float yMaster = validDimension[0]->Y.getValue(); + for (auto dim : validDimension){ + dim->Y.setValue(yMaster); + pointPair pp = dim->getLinearPoints(); + Base::Vector3d p1 = pp.first; + Base::Vector3d p2 = pp.second; + dim->X.setValue((p1.x+p2.x)/2.0); + } + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionPosHorizChainDimension) + +CmdTechDrawExtensionPosHorizChainDimension::CmdTechDrawExtensionPosHorizChainDimension() + : Command("TechDraw_ExtensionPosHorizChainDimension") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Position Horizontal Chain Dimension"); + sToolTipText = QT_TR_NOOP("Arranges the selected horizontal dimensions on the same line:\n\ + - select two or more measures\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionPosHorizChainDimension"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionPosHorizChainDimension"; +} + +void CmdTechDrawExtensionPosHorizChainDimension::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execPosHorizChainDimension(this); +} + +bool CmdTechDrawExtensionPosHorizChainDimension::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionPosVertChainDimension +//=========================================================================== + +void execPosVertChainDimension(Gui::Command* cmd){ + // position a vertical dimension chain + std::vector selection; + if (_checkSelection(cmd,selection,"TechDraw PosVertChainDimension")){ + std::vector validDimension; + validDimension = _getDimensions(selection,"DistanceY"); + if( validDimension.empty() ) { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("TechDraw PosVertChainDimension"), + QObject::tr("No vertical dimensions selected")); + return; + } + float xMaster = validDimension[0]->X.getValue(); + for (auto dim : validDimension){ + dim->X.setValue(xMaster); + pointPair pp = dim->getLinearPoints(); + Base::Vector3d p1 = pp.first; + Base::Vector3d p2 = pp.second; + dim->Y.setValue((p1.y+p2.y)/-2.0); + } + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionPosVertChainDimension) + +CmdTechDrawExtensionPosVertChainDimension::CmdTechDrawExtensionPosVertChainDimension() + : Command("TechDraw_ExtensionPosVertChainDimension") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Position Vertical Chain Dimension"); + sToolTipText = QT_TR_NOOP("Arranges the selected vertical dimensions on the same line:\n\ + - select two or more measures\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionPosVertChainDimension"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionPosVertChainDimension"; +} + +void CmdTechDrawExtensionPosVertChainDimension::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execPosVertChainDimension(this); +} + +bool CmdTechDrawExtensionPosVertChainDimension::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionPosObliqueChainDimension +//=========================================================================== + +void execPosObliqueChainDimension(Gui::Command* cmd){ + // position an oblique dimension chain + std::vector selection; + if (_checkSelection(cmd,selection,"TechDraw PosObliqueChainDimension")){ + std::vector validDimension; + validDimension = _getDimensions(selection,"Distance"); + if( validDimension.empty() ) { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("TechDraw PosObliqueChainDimension"), + QObject::tr("No oblique dimensions selected")); + return; + } + float xMaster = validDimension[0]->X.getValue(); + float yMaster = validDimension[0]->Y.getValue(); + Base::Vector3d pMaster(xMaster,yMaster,0.0); + pointPair pp = validDimension[0]->getLinearPoints(); + Base::Vector3d dirMaster = pp.second-pp.first; + dirMaster.y = -dirMaster.y; + for (auto dim : validDimension){ + float xDim = dim->X.getValue(); + float yDim = dim->Y.getValue(); + Base::Vector3d pDim(xDim,yDim,0.0); + Base::Vector3d p3 = _getTrianglePoint(pMaster,dirMaster,pDim); + dim->X.setValue(p3.x); + dim->Y.setValue(p3.y); + } + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionPosObliqueChainDimension) + +CmdTechDrawExtensionPosObliqueChainDimension::CmdTechDrawExtensionPosObliqueChainDimension() + : Command("TechDraw_ExtensionPosObliqueChainDimension") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Position Oblique Chain Dimension"); + sToolTipText = QT_TR_NOOP("Arranges the selected oblique dimensions on the same line:\n\ + - select two or more measures\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionPosObliqueChainDimension"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionPosObliqueChainDimension"; +} + +void CmdTechDrawExtensionPosObliqueChainDimension::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execPosObliqueChainDimension(this); + ///Base::Console().Message("TechDraw_ExtensionPosObliqueChainDimension started\n"); +} + +bool CmdTechDrawExtensionPosObliqueChainDimension::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionPosChainDimensionGroup +//=========================================================================== + +DEF_STD_CMD_ACL(CmdTechDrawExtensionPosChainDimensionGroup) + +CmdTechDrawExtensionPosChainDimensionGroup::CmdTechDrawExtensionPosChainDimensionGroup() + : Command("TechDraw_ExtensionPosChainDimensionGroup") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Position Horizontal Chain Dimension"); + sToolTipText = QT_TR_NOOP("Arranges the selected horizontal dimensions on the same line:\n\ + - select two or more measures\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionPosChainDimensionGroup"; + sStatusTip = sToolTipText; +} + +void CmdTechDrawExtensionPosChainDimensionGroup::activated(int iMsg) +{ +// Base::Console().Message("CMD::ExtensionPosChainDimensionGroup - activated(%d)\n", 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; + } + + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + pcAction->setIcon(pcAction->actions().at(iMsg)->icon()); + switch(iMsg) { + case 0: //position horizontal chain dimensions + execPosHorizChainDimension(this); + break; + case 1: //position vertical chain dimensions + execPosVertChainDimension(this); + break; + case 2: //position oblique chain dimensions + execPosObliqueChainDimension(this); + break; + default: + Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg); + }; +} + +Gui::Action * CmdTechDrawExtensionPosChainDimensionGroup::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionPosHorizChainDimension")); + p1->setObjectName(QString::fromLatin1("TechDraw_ExtensionPosHorizChainDimension")); + p1->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionPosHorizChainDimension")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionPosVertChainDimension")); + p2->setObjectName(QString::fromLatin1("TechDraw_ExtensionPosVertChainDimension")); + p2->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionPosVertChainDimension")); + QAction* p3 = pcAction->addAction(QString()); + p3->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionPosObliqueChainDimension")); + p3->setObjectName(QString::fromLatin1("TechDraw_ExtensionPosObliqueChainDimension")); + p3->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionPosObliqueChainDimension")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdTechDrawExtensionPosChainDimensionGroup::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("TechDraw_Extension","Position Horizontal Chain Dimensions")); + arc1->setToolTip(QApplication::translate("TechDraw_Extension", + "Arranges the selected horizontal dimensions on the same line:\n\ + - select two or more measures\n\ + - click this button")); + arc1->setStatusTip(arc1->toolTip()); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("TechDraw_Extension","Position Vertical Chain Dimensions")); + arc2->setToolTip(QApplication::translate("TechDraw_Extension", + "Arranges the selected vertical dimensions on the same line:\n\ + - select two or more measures\n\ + - click this button")); + arc2->setStatusTip(arc2->toolTip()); + QAction* arc3 = a[2]; + arc3->setText(QApplication::translate("TechDraw_Extension","Position Oblique Chain Dimensions")); + arc3->setToolTip(QApplication::translate("TechDraw_Extension", + "Arranges the selected oblique dimensions on the same line:\n\ + - select two or more measures\n\ + - click this button")); + arc3->setStatusTip(arc3->toolTip()); +} + +bool CmdTechDrawExtensionPosChainDimensionGroup::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, true); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCascadeHorizDimension +//=========================================================================== + +void execCascadeHorizDimension(Gui::Command* cmd){ + // cascade horizontal dimensions + std::vector selection; + if (_checkSelection(cmd,selection,"TechDraw CascadeHorizDimension")){ + std::vector validDimension; + validDimension = _getDimensions(selection,"DistanceX"); + if( validDimension.empty() ) { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("TechDraw CascadeHorizDimension"), + QObject::tr("No horizontal dimensions selected")); + return; + } + float yMaster = validDimension[0]->Y.getValue(); + float dimDistance = 7; + if (signbit(yMaster)) + dimDistance = -dimDistance; + for (auto dim : validDimension){ + dim->Y.setValue(yMaster); + pointPair pp = dim->getLinearPoints(); + Base::Vector3d p1 = pp.first; + Base::Vector3d p2 = pp.second; + dim->X.setValue((p1.x+p2.x)/2.0); + yMaster = yMaster+dimDistance; + } + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionCascadeHorizDimension) + +CmdTechDrawExtensionCascadeHorizDimension::CmdTechDrawExtensionCascadeHorizDimension() + : Command("TechDraw_ExtensionCascadeHorizDimension") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Cascade Horizontal Dimensions"); + sToolTipText = QT_TR_NOOP("Spaces (vertically), the selected horizontal dimensions:\n\ + - select two or more horizontal dimensions\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCascadeHorizDimension"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionCascadeHorizDimension"; +} + +void CmdTechDrawExtensionCascadeHorizDimension::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execCascadeHorizDimension(this); +} + +bool CmdTechDrawExtensionCascadeHorizDimension::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCascadeVertDimension +//=========================================================================== + +void execCascadeVertDimension(Gui::Command* cmd){ + // cascade horizontal dimensions + std::vector selection; + if (_checkSelection(cmd,selection,"TechDraw CascadeVertDimension")){ + std::vector validDimension; + validDimension = _getDimensions(selection,"DistanceY"); + if( validDimension.empty() ) { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("TechDraw CascadeVertDimension"), + QObject::tr("No vertical dimensions selected")); + return; + } + float xMaster = validDimension[0]->X.getValue(); + float dimDistance = 7; + if (signbit(xMaster)) + dimDistance = -dimDistance; + for (auto dim : validDimension){ + dim->X.setValue(xMaster); + pointPair pp = dim->getLinearPoints(); + Base::Vector3d p1 = pp.first; + Base::Vector3d p2 = pp.second; + dim->Y.setValue((p1.y+p2.y)/-2.0); + xMaster = xMaster+dimDistance; + } + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionCascadeVertDimension) + +CmdTechDrawExtensionCascadeVertDimension::CmdTechDrawExtensionCascadeVertDimension() + : Command("TechDraw_ExtensionCascadeVertDimension") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Cascade Vertical Dimensions"); + sToolTipText = QT_TR_NOOP("Spaces (horizontally), the selected vertical dimensions:\n\ + - select two or more vertical dimensions\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCascadeVertDimension"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionCascadeVertDimension"; +} + +void CmdTechDrawExtensionCascadeVertDimension::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execCascadeVertDimension(this); +} + +bool CmdTechDrawExtensionCascadeVertDimension::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCascadeObliqueDimension +//=========================================================================== + +void execCascadeObliqueDimension(Gui::Command* cmd){ + // cascade oblique dimensions + std::vector selection; + if (_checkSelection(cmd,selection,"TechDraw CascadeObliqueDimension")){ + std::vector validDimension; + validDimension = _getDimensions(selection,"Distance"); + if( validDimension.empty() ) { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("TechDraw CascadeObliqueDimension"), + QObject::tr("No oblique dimensions selected")); + return; + } + float xMaster = validDimension[0]->X.getValue(); + float yMaster = validDimension[0]->Y.getValue(); + Base::Vector3d pMaster(xMaster,yMaster,0.0); + pointPair pp = validDimension[0]->getLinearPoints(); + Base::Vector3d dirMaster = pp.second-pp.first; + dirMaster.y = -dirMaster.y; + Base::Vector3d origin(0.0,0.0,0.0); + Base::Vector3d ipDelta = _getTrianglePoint(pMaster,dirMaster,origin); + Base::Vector3d delta = ipDelta.Normalize()*7.0; + int i = 0; + for (auto dim : validDimension){ + float xDim = dim->X.getValue(); + float yDim = dim->Y.getValue(); + Base::Vector3d pDim(xDim,yDim,0.0); + Base::Vector3d p3 = _getTrianglePoint(pMaster,dirMaster,pDim); + p3 = p3+delta*i; + dim->X.setValue(p3.x); + dim->Y.setValue(p3.y); + i = i+1; + } + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionCascadeObliqueDimension) + +CmdTechDrawExtensionCascadeObliqueDimension::CmdTechDrawExtensionCascadeObliqueDimension() + : Command("TechDraw_ExtensionCascadeObliqueDimension") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Cascade Oblique Dimensions"); + sToolTipText = QT_TR_NOOP("Cascade oblique dimensions\n\ + - select some parallel oblique measures\n\ + - the first selected maesure defines the position\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCascadeObliqueDimension"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionCascadeObliqueDimension"; +} + +void CmdTechDrawExtensionCascadeObliqueDimension::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execCascadeObliqueDimension(this); + ///Base::Console().Message("TechDraw_ExtensionPosObliqueChainDimension started\n"); +} + +bool CmdTechDrawExtensionCascadeObliqueDimension::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCascadeDimensionGroup +//=========================================================================== + +DEF_STD_CMD_ACL(CmdTechDrawExtensionCascadeDimensionGroup) + +CmdTechDrawExtensionCascadeDimensionGroup::CmdTechDrawExtensionCascadeDimensionGroup() + : Command("TechDraw_ExtensionCascadeDimensionGroup") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Cascade Horizontal Dimensions"); + sToolTipText = QT_TR_NOOP("Cascade Horizontal Dimensions\n\ + - select many horizontal dimensions\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCascadeDimensionGroup"; + sStatusTip = sToolTipText; +} + +void CmdTechDrawExtensionCascadeDimensionGroup::activated(int iMsg) +{ +// Base::Console().Message("CMD::ExtensionCascadeDimansionGroup - activated(%d)\n", 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; + } + + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + pcAction->setIcon(pcAction->actions().at(iMsg)->icon()); + switch(iMsg) { + case 0: //cascade horizontal dimensions + execCascadeHorizDimension(this); + break; + case 1: //cascade vertical dimensions + execCascadeVertDimension(this); + break; + case 2: //cascade oblique dimensions + execCascadeObliqueDimension(this); + break; + default: + Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg); + }; +} + +Gui::Action * CmdTechDrawExtensionCascadeDimensionGroup::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionCascadeHorizDimension")); + p1->setObjectName(QString::fromLatin1("TechDraw_ExtensionCascadeHorizDimension")); + p1->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionCascadeHorizDimension")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionCascadeVertDimension")); + p2->setObjectName(QString::fromLatin1("TechDraw_ExtensionCascadeVertDimension")); + p2->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionCascadeVertDimension")); + QAction* p3 = pcAction->addAction(QString()); + p3->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionCascadeObliqueDimension")); + p3->setObjectName(QString::fromLatin1("TechDraw_ExtensionCascadeObliqueDimension")); + p3->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionCascadeObliqueDimension")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdTechDrawExtensionCascadeDimensionGroup::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("TechDraw_Extension","Cascade Horizontal Dimensions")); + arc1->setToolTip(QApplication::translate("TechDraw_Extension", + "Spaces (vertically), the selected horizontal dimensions:\n\ + - select two or more horizontal dimensions\n\ + - click this button")); + arc1->setStatusTip(arc1->toolTip()); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("TechDraw_Extension","Cascade Vertical Dimensions")); + arc2->setToolTip(QApplication::translate("TechDraw_Extension", + "Spaces (horizontally), the selected vertical dimensions:\n\ + - select two or more vertical dimensions\n\ + - click this button")); + arc2->setStatusTip(arc2->toolTip()); + QAction* arc3 = a[2]; + arc3->setText(QApplication::translate("TechDraw_Extension","Cascade Oblique Dimensions")); + arc3->setToolTip(QApplication::translate("TechDraw_Extension", + "Cascade oblique dimensions\n\ + - select some parallel oblique measures\n\ + - the first selected maesure defines the position\n\ + - click this button")); + arc3->setStatusTip(arc3->toolTip()); +} + +bool CmdTechDrawExtensionCascadeDimensionGroup::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, true); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCreateHorizChainDimension +//=========================================================================== + +void execCreateHorizChainDimension(Gui::Command* cmd){ + //create a horizontal chain dimension + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSelAndObj(cmd,selection,objFeat,"TechDraw Create Horizontal Chain Dimension")) + return; + const std::vector subNames = selection[0].getSubNames(); + std::vector allVertexes; + allVertexes = _getVertexInfo(objFeat,subNames); + if (!allVertexes.empty()){ + if (allVertexes.size() > 1){ + std::sort(allVertexes.begin(),allVertexes.end(),sortX); + float yMaster = 0.0; + for(long unsigned int n=0;ngetLinearPoints(); + Base::Vector3d mid = (pp.first + pp.second)/2.0; + dim->X.setValue(mid.x); + if(n == 0) + yMaster = -mid.y; + dim->Y.setValue(yMaster); + } + } + } + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); + cmd->getSelection().clearSelection(); +} + +DEF_STD_CMD_A(CmdTechDrawExtensionCreateHorizChainDimension) + +CmdTechDrawExtensionCreateHorizChainDimension::CmdTechDrawExtensionCreateHorizChainDimension() + : Command("TechDraw_ExtensionCreateHorizChainDimension") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create Horizontal Chain Dimension"); + sToolTipText = QT_TR_NOOP("Create a horizontal chain dimension\n\ + - Select three or more vertexes\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCreateHorizChainDimension"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionCreateHorizChainDimension"; +} + +void CmdTechDrawExtensionCreateHorizChainDimension::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execCreateHorizChainDimension(this); + //execSortieren(this); +} + +bool CmdTechDrawExtensionCreateHorizChainDimension::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCreateVertChainDimension +//=========================================================================== + +void execCreateVertChainDimension(Gui::Command* cmd){ + //create a vertical chain dimension + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSelAndObj(cmd,selection,objFeat,"TechDraw Create Vertical Chain Dimension")) + return; + const std::vector subNames = selection[0].getSubNames(); + std::vector allVertexes; + allVertexes = _getVertexInfo(objFeat,subNames); + if (!allVertexes.empty()){ + if (allVertexes.size() > 1){ + std::sort(allVertexes.begin(),allVertexes.end(),sortY); + float xMaster = 0.0; + for(long unsigned int n=0;ngetLinearPoints(); + Base::Vector3d mid = (pp.first + pp.second)/2.0; + if(n == 0) + xMaster = mid.x; + dim->X.setValue(xMaster); + dim->Y.setValue(-mid.y); + } + } + } + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); + cmd->getSelection().clearSelection(); +} + +DEF_STD_CMD_A(CmdTechDrawExtensionCreateVertChainDimension) + +CmdTechDrawExtensionCreateVertChainDimension::CmdTechDrawExtensionCreateVertChainDimension() + : Command("TechDraw_ExtensionCreateVertChainDimension") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create Vertical Chain Dimension"); + sToolTipText = QT_TR_NOOP("Create vertical chain dimension\n\ + - Select three or more vertexes\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCreateVertChainDimension"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionCreateVertChainDimension"; +} + +void CmdTechDrawExtensionCreateVertChainDimension::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execCreateVertChainDimension(this); +} + +bool CmdTechDrawExtensionCreateVertChainDimension::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCreateObliqueChainDimension +//=========================================================================== + +void execCreateObliqueChainDimension(Gui::Command* cmd){ + // create an oblique chain dimension + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSelAndObj(cmd,selection,objFeat,"TechDraw Create Oblique Chain Dimension")) + return; + const std::vector subNames = selection[0].getSubNames(); + std::vector allVertexes, carrierVertexes; + allVertexes = _getVertexInfo(objFeat,subNames); + if (!allVertexes.empty()){ + if (allVertexes.size() > 1){ + Base::Vector3d pMaster = allVertexes[0].point; + Base::Vector3d dirMaster = pMaster-allVertexes[1].point; + Base::Vector3d origin(0.0,0.0,0.0); + Base::Vector3d delta = _getTrianglePoint(pMaster,dirMaster,origin); + delta = delta.Normalize()*7.0; + double scale = objFeat->getScale(); + for (dimVertex oldVertex : allVertexes){ + Base::Vector3d nextPoint = _getTrianglePoint(pMaster,dirMaster,oldVertex.point); + nextPoint.y = -nextPoint.y; + oldVertex.point.y = -oldVertex.point.y; + if ((oldVertex.point-nextPoint).Length() > 0.01){ + std::string vertTag = objFeat->addCosmeticVertex(nextPoint/scale); + int vertNumber = objFeat->add1CVToGV(vertTag); + std::stringstream ss; + ss << "Vertex" << vertNumber; + dimVertex newVertex; + newVertex.name = ss.str(); + newVertex.point = nextPoint; + carrierVertexes.push_back(newVertex); + std::string edgeTag = objFeat->addCosmeticEdge(oldVertex.point/scale, nextPoint/scale); + auto edge = objFeat->getCosmeticEdge(edgeTag); + edge->m_format.m_style = 1; + edge->m_format.m_weight = 0.15; + edge->m_format.m_color = App::Color(0.0f,0.0f,0.0f); + } else + carrierVertexes.push_back(oldVertex); + } + std::sort(carrierVertexes.begin(),carrierVertexes.end(),sortX); + for(long unsigned int n=0;ngetLinearPoints(); + Base::Vector3d mid = (pp.first + pp.second)/2.0+delta; + dim->X.setValue(mid.x); + dim->Y.setValue(-mid.y); + } + } + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); + cmd->getSelection().clearSelection(); + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionCreateObliqueChainDimension) + +CmdTechDrawExtensionCreateObliqueChainDimension::CmdTechDrawExtensionCreateObliqueChainDimension() + : Command("TechDraw_ExtensionCreateObliqueChainDimension") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create Oblique Chain Dimension"); + sToolTipText = QT_TR_NOOP("Create an oblique dimension chain\n\ + - select three or more vertexes\n\ + - the first two define the direction\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCreateObliqueChainDimension"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionCreateObliqueChainDimension"; +} + +void CmdTechDrawExtensionCreateObliqueChainDimension::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execCreateObliqueChainDimension(this); +} + +bool CmdTechDrawExtensionCreateObliqueChainDimension::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCreateChainDimensionGroup +//=========================================================================== + +DEF_STD_CMD_ACL(CmdTechDrawExtensionCreateChainDimensionGroup) + +CmdTechDrawExtensionCreateChainDimensionGroup::CmdTechDrawExtensionCreateChainDimensionGroup() + : Command("TechDraw_ExtensionCreateChainDimensionGroup") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create Chain Dimensions"); + sToolTipText = QT_TR_NOOP("Create a horizontal chain dimension\n\ + - Select three or more vertexes\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCreateChainDimensionGroup"; + sStatusTip = sToolTipText; +} + +void CmdTechDrawExtensionCreateChainDimensionGroup::activated(int iMsg) +{ +// Base::Console().Message("CMD::ExtensionCascadeDimansionGroup - activated(%d)\n", 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; + } + + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + pcAction->setIcon(pcAction->actions().at(iMsg)->icon()); + switch(iMsg) { + case 0: //create horizontal chain dimensions + execCreateHorizChainDimension(this); + break; + case 1: //create vertical chain dimensions + execCreateVertChainDimension(this); + break; + case 2: //create oblique chain dimensions + execCreateObliqueChainDimension(this); + break; + default: + Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg); + }; +} + +Gui::Action * CmdTechDrawExtensionCreateChainDimensionGroup::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionCreateHorizChainDimension")); + p1->setObjectName(QString::fromLatin1("TechDraw_ExtensionCreateHorizChainDimension")); + p1->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionCreateHorizChainDimension")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionCreateVertChainDimension")); + p2->setObjectName(QString::fromLatin1("TechDraw_ExtensionCreateVertChainDimension")); + p2->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionCreateVertChainDimension")); + QAction* p3 = pcAction->addAction(QString()); + p3->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionCreateObliqueChainDimension")); + p3->setObjectName(QString::fromLatin1("TechDraw_ExtensionCreateObliqueChainDimension")); + p3->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionCreateObliqueChainDimension")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdTechDrawExtensionCreateChainDimensionGroup::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("TechDraw_Extension","Create Horizontal Chain Dimensions")); + arc1->setToolTip(QApplication::translate("TechDraw_Extension", + "Create a horizontal chain dimension\n\ + - Select three or more vertexes\n\ + - click this button")); + arc1->setStatusTip(arc1->toolTip()); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("TechDraw_Extension","Create Vertical Chain Dimensions")); + arc2->setToolTip(QApplication::translate("TechDraw_Extension", + "Create vertical chain dimension\n\ + - Select three or more vertexes\n\ + - click this button")); + arc2->setStatusTip(arc2->toolTip()); + QAction* arc3 = a[2]; + arc3->setText(QApplication::translate("TechDraw_Extension","Create Oblique Chain Dimensions")); + arc3->setToolTip(QApplication::translate("TechDraw_Extension", + "Create an oblique dimension chain\n\ + - select three or more vertexes\n\ + - the first two define the direction\n\ + - click this button")); + arc3->setStatusTip(arc3->toolTip()); +} + +bool CmdTechDrawExtensionCreateChainDimensionGroup::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, true); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCreateHorizCoordDimension +//=========================================================================== + +void execCreateHorizCoordDimension(Gui::Command* cmd){ + //create horizontal coordinate dimensions + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSelAndObj(cmd,selection,objFeat,"TechDraw Create Horizontal Coord Dimension")) + return; + const std::vector subNames = selection[0].getSubNames(); + std::vector allVertexes; + allVertexes = _getVertexInfo(objFeat,subNames); + if (!allVertexes.empty()){ + if (allVertexes.size() > 1){ + std::sort(allVertexes.begin(),allVertexes.end(),sortX); + float yMaster = allVertexes[0].point.y-7.0; + float dimDistance = 7.0; + if (signbit(yMaster)) + dimDistance = -dimDistance; + for(long unsigned int n=0;ngetLinearPoints(); + Base::Vector3d mid = (pp.first + pp.second)/2.0; + dim->X.setValue(mid.x); + dim->Y.setValue(-yMaster-dimDistance*n); + } + } + } + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); + cmd->getSelection().clearSelection(); +} + +DEF_STD_CMD_A(CmdTechDrawExtensionCreateHorizCoordDimension) + +CmdTechDrawExtensionCreateHorizCoordDimension::CmdTechDrawExtensionCreateHorizCoordDimension() + : Command("TechDraw_ExtensionCreateHorizCoordDimension") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create Horizontal Coordinate Dimension"); + sToolTipText = QT_TR_NOOP("Create horizontal coordinate dimensions\n\ + - select three or more vertexes\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCreateHorizCoordDimension"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionCreateHorizCoordDimension"; +} + +void CmdTechDrawExtensionCreateHorizCoordDimension::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execCreateHorizCoordDimension(this); +} + +bool CmdTechDrawExtensionCreateHorizCoordDimension::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCreateVertCoordDimension +//=========================================================================== + +void execCreateVertCoordDimension(Gui::Command* cmd){ + //create vertical coordinate dimensions + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSelAndObj(cmd,selection,objFeat,"TechDraw Create Vertical Coord Dimension")) + return; + const std::vector subNames = selection[0].getSubNames(); + std::vector allVertexes; + allVertexes = _getVertexInfo(objFeat,subNames); + if (!allVertexes.empty()){ + if (allVertexes.size() > 1){ + std::sort(allVertexes.begin(),allVertexes.end(),sortY); + std::reverse(allVertexes.begin(),allVertexes.end()); + float xMaster = allVertexes[0].point.x+7.0; + float dimDistance = 7.0; + if (signbit(xMaster)) + dimDistance = -dimDistance; + for(long unsigned int n=0;ngetLinearPoints(); + Base::Vector3d mid = (pp.first + pp.second)/2.0; + dim->X.setValue(xMaster+dimDistance*n); + dim->Y.setValue(-mid.y); + } + } + } + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); + cmd->getSelection().clearSelection(); +} + +DEF_STD_CMD_A(CmdTechDrawExtensionCreateVertCoordDimension) + +CmdTechDrawExtensionCreateVertCoordDimension::CmdTechDrawExtensionCreateVertCoordDimension() + : Command("TechDraw_ExtensionCreateVertCoordDimension") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create Vertical Coordinate Dimension"); + sToolTipText = QT_TR_NOOP("Create vertical coordinate dimensions\n\ + - select three or more vertexes\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCreateVertCoordDimension"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionCreateVertCoordDimension"; +} + +void CmdTechDrawExtensionCreateVertCoordDimension::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execCreateVertCoordDimension(this); +} + +bool CmdTechDrawExtensionCreateVertCoordDimension::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCreateObliqueCoordDimension +//=========================================================================== + +void execCreateObliqueCoordDimension(Gui::Command* cmd){ + //create oblique coordinate dimensions + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSelAndObj(cmd,selection,objFeat,"TechDraw Create Oblique Coord Dimension")) + return; + const std::vector subNames = selection[0].getSubNames(); + std::vector allVertexes, carrierVertexes; + allVertexes = _getVertexInfo(objFeat,subNames); + if (!allVertexes.empty()){ + if (allVertexes.size() > 1){ + Base::Vector3d pMaster = allVertexes[0].point; + Base::Vector3d dirMaster = pMaster-allVertexes[1].point; + Base::Vector3d origin(0.0,0.0,0.0); + Base::Vector3d delta = _getTrianglePoint(pMaster,dirMaster,origin); + delta = delta.Normalize()*7.0; + double scale = objFeat->getScale(); + for (dimVertex oldVertex : allVertexes){ + Base::Vector3d nextPoint = _getTrianglePoint(pMaster,dirMaster,oldVertex.point); + nextPoint.y = -nextPoint.y; + oldVertex.point.y = -oldVertex.point.y; + if ((oldVertex.point-nextPoint).Length() > 0.01){ + std::string vertTag = objFeat->addCosmeticVertex(nextPoint/scale); + int vertNumber = objFeat->add1CVToGV(vertTag); + std::stringstream ss; + ss << "Vertex" << vertNumber; + dimVertex newVertex; + newVertex.name = ss.str(); + newVertex.point = nextPoint; + carrierVertexes.push_back(newVertex); + std::string edgeTag = objFeat->addCosmeticEdge(oldVertex.point/scale, nextPoint/scale); + auto edge = objFeat->getCosmeticEdge(edgeTag); + edge->m_format.m_style = 1; + edge->m_format.m_weight = 0.15; + edge->m_format.m_color = App::Color(0.0f,0.0f,0.0f); + } else + carrierVertexes.push_back(oldVertex); + } + std::sort(carrierVertexes.begin(),carrierVertexes.end(),sortX); + for(long unsigned int n=0;ngetLinearPoints(); + Base::Vector3d mid = (pp.first + pp.second)/2.0+delta*(n+1); + dim->X.setValue(mid.x); + dim->Y.setValue(-mid.y); + } + } + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); + cmd->getSelection().clearSelection(); + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionCreateObliqueCoordDimension) + +CmdTechDrawExtensionCreateObliqueCoordDimension::CmdTechDrawExtensionCreateObliqueCoordDimension() + : Command("TechDraw_ExtensionCreateObliqueCoordDimension") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create Oblique Coordinate Dimension"); + sToolTipText = QT_TR_NOOP("Create an oblique coordinate dimension\n\ + - select three or more vertexes\n\ + - the first two define the direction\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCreateObliqueCoordDimension"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionCreateObliqueCoordDimension"; +} + +void CmdTechDrawExtensionCreateObliqueCoordDimension::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execCreateObliqueCoordDimension(this); +} + +bool CmdTechDrawExtensionCreateObliqueCoordDimension::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCreateCoordDimensionGroup +//=========================================================================== + +DEF_STD_CMD_ACL(CmdTechDrawExtensionCreateCoordDimensionGroup) + +CmdTechDrawExtensionCreateCoordDimensionGroup::CmdTechDrawExtensionCreateCoordDimensionGroup() + : Command("TechDraw_ExtensionCreateCoordDimensionGroup") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create Coordinate Dimensions"); + sToolTipText = QT_TR_NOOP("Create horizontal coordinate dimensions\n\ + - select three or more vertexes\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCreateCoordDimensionGroup"; + sStatusTip = sToolTipText; +} + +void CmdTechDrawExtensionCreateCoordDimensionGroup::activated(int iMsg) +{ +// Base::Console().Message("CMD::ExtensionCascadeDimansionGroup - activated(%d)\n", 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; + } + + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + pcAction->setIcon(pcAction->actions().at(iMsg)->icon()); + switch(iMsg) { + case 0: //create horizontal coordinate dimensions + execCreateHorizCoordDimension(this); + break; + case 1: //create vertical coordinate dimensions + execCreateVertCoordDimension(this); + break; + case 2: //create oblique coordinate dimensions + execCreateObliqueCoordDimension(this); + break; + default: + Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg); + }; +} + +Gui::Action * CmdTechDrawExtensionCreateCoordDimensionGroup::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionCreateHorizCoordDimension")); + p1->setObjectName(QString::fromLatin1("TechDraw_ExtensionCreateHorizCoordDimension")); + p1->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionCreateHorizCoordDimension")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionCreateVertCoordDimension")); + p2->setObjectName(QString::fromLatin1("TechDraw_ExtensionCreateVertCoordDimension")); + p2->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionCreateVertCoordDimension")); + QAction* p3 = pcAction->addAction(QString()); + p3->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionCreateObliqueCoordDimension")); + p3->setObjectName(QString::fromLatin1("TechDraw_ExtensionCreateObliqueCoordDimension")); + p3->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionCreateObliqueCoordDimension")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdTechDrawExtensionCreateCoordDimensionGroup::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("TechDraw_Extension","Create Horizontal Coordinate Dimensions")); + arc1->setToolTip(QApplication::translate("TechDraw_Extension", + "Create horizontal coordinate dimensions\n\ + - select three or more vertexes\n\ + - click this button")); + arc1->setStatusTip(arc1->toolTip()); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("TechDraw_Extension","Create Vertical Coordinate Dimensions")); + arc2->setToolTip(QApplication::translate("TechDraw_Extension", + "Create vertical coordinate dimensions\n\ + - select three or more vertexes\n\ + - click this button")); + arc2->setStatusTip(arc2->toolTip()); + QAction* arc3 = a[2]; + arc3->setText(QApplication::translate("TechDraw_Extension","Create Oblique Coordinate Dimensions")); + arc3->setToolTip(QApplication::translate("TechDraw_Extension", + "Create an oblique coordinate dimension\n\ + - select three or more vertexes\n\ + - the first two define the direction\n\ + - click this button")); + arc3->setStatusTip(arc3->toolTip()); +} + +bool CmdTechDrawExtensionCreateCoordDimensionGroup::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, true); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCreateHorizChamferDimension +//=========================================================================== + +void execCreateHorizChamferDimension(Gui::Command* cmd){ + //create a horizontal chamfer dimension + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSelAndObj(cmd,selection,objFeat,"TechDraw Create Horizontal Chamfer Dimension")) + return; + const std::vector subNames = selection[0].getSubNames(); + std::vector allVertexes; + allVertexes = _getVertexInfo(objFeat,subNames); + if (!allVertexes.empty()){ + if (allVertexes.size() > 1){ + const float Pi180 = 180.0/3.14159; + TechDraw::DrawViewDimension* dim; + dim = _createLinDimension(cmd,objFeat,allVertexes[0].name,allVertexes[1].name,"DistanceX"); + float yMax = std::max(abs(allVertexes[0].point.y),abs(allVertexes[1].point.y))+7.0; + if (signbit(allVertexes[0].point.y)) + yMax = -yMax; + TechDraw::pointPair pp = dim->getLinearPoints(); + Base::Vector3d mid = (pp.first + pp.second)/2.0; + dim->X.setValue(mid.x); + dim->Y.setValue(-yMax); + float dx = allVertexes[0].point.x-allVertexes[1].point.x; + float dy = allVertexes[0].point.y-allVertexes[1].point.y; + float alpha = round(abs(atan(dy/dx))*Pi180); + std::string sAlpha = std::to_string((int) alpha); + std::string formatSpec = dim->FormatSpec.getStrValue(); + formatSpec = formatSpec+"x"+sAlpha+"°"; + dim->FormatSpec.setValue(formatSpec); + objFeat->requestPaint(); + cmd->getSelection().clearSelection(); + } + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionCreateHorizChamferDimension) + +CmdTechDrawExtensionCreateHorizChamferDimension::CmdTechDrawExtensionCreateHorizChamferDimension() + : Command("TechDraw_ExtensionCreateHorizChamferDimension") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create Horizontal Chamfer Dimension"); + sToolTipText = QT_TR_NOOP("Create Horizontal Chamfer Dimension\n\ + - select two vertexes\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCreateHorizChamferDimension"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionCreateHorizChamferDimension"; +} + +void CmdTechDrawExtensionCreateHorizChamferDimension::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execCreateHorizChamferDimension(this); +} + +bool CmdTechDrawExtensionCreateHorizChamferDimension::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCreateVertChamferDimension +//=========================================================================== + +void execCreateVertChamferDimension(Gui::Command* cmd){ + //create a vertical chamfer dimension + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSelAndObj(cmd,selection,objFeat,"TechDraw Create Vertical Chamfer Dimension")) + return; + const std::vector subNames = selection[0].getSubNames(); + std::vector allVertexes; + allVertexes = _getVertexInfo(objFeat,subNames); + if (!allVertexes.empty()){ + if (allVertexes.size() > 1){ + const float Pi180 = 180.0/3.14159; + TechDraw::DrawViewDimension* dim; + dim = _createLinDimension(cmd,objFeat,allVertexes[0].name,allVertexes[1].name,"DistanceY"); + float xMax = std::max(abs(allVertexes[0].point.x),abs(allVertexes[1].point.x))+7.0; + if (signbit(allVertexes[0].point.x)) + xMax = -xMax; + TechDraw::pointPair pp = dim->getLinearPoints(); + Base::Vector3d mid = (pp.first + pp.second)/2.0; + dim->X.setValue(xMax); + dim->Y.setValue(-mid.y); + float dx = allVertexes[0].point.x-allVertexes[1].point.x; + float dy = allVertexes[0].point.y-allVertexes[1].point.y; + float alpha = round(abs(atan(dx/dy))*Pi180); + std::string sAlpha = std::to_string((int) alpha); + std::string formatSpec = dim->FormatSpec.getStrValue(); + formatSpec = formatSpec+"x"+sAlpha+"°"; + dim->FormatSpec.setValue(formatSpec); + objFeat->requestPaint(); + cmd->getSelection().clearSelection(); + } + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionCreateVertChamferDimension) + +CmdTechDrawExtensionCreateVertChamferDimension::CmdTechDrawExtensionCreateVertChamferDimension() + : Command("TechDraw_ExtensionCreateVertChamferDimension") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create Vertical Chamfer Dimension"); + sToolTipText = QT_TR_NOOP("Create Vertical Chamfer Dimension\n\ + - select two vertexes\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCreateVertChamferDimension"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionCreateVertChamferDimension"; +} + +void CmdTechDrawExtensionCreateVertChamferDimension::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execCreateVertChamferDimension(this); +} + +bool CmdTechDrawExtensionCreateVertChamferDimension::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionChamferDimensionGroup +//=========================================================================== + +DEF_STD_CMD_ACL(CmdTechDrawExtensionChamferDimensionGroup) + +CmdTechDrawExtensionChamferDimensionGroup::CmdTechDrawExtensionChamferDimensionGroup() + : Command("TechDraw_ExtensionChamferDimensionGroup") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create Horizontal Chamfer Dimension"); + sToolTipText = QT_TR_NOOP("Create Horizontal Chamfer Dimension\n\ + - select two vertexes\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionChamferDimensionGroup"; + sStatusTip = sToolTipText; +} + +void CmdTechDrawExtensionChamferDimensionGroup::activated(int iMsg) +{ +// Base::Console().Message("CMD::ExtensionIncreaseDecreaseGroup - activated(%d)\n", 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; + } + + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + pcAction->setIcon(pcAction->actions().at(iMsg)->icon()); + switch(iMsg) { + case 0: //create a horizontal chamfer dimension + execCreateHorizChamferDimension(this); + break; + case 1: //create a vertical chamfer dimension + execCreateVertChamferDimension(this); + break; + default: + Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg); + }; +} + +Gui::Action * CmdTechDrawExtensionChamferDimensionGroup::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionCreateHorizChamferDimension")); + p1->setObjectName(QString::fromLatin1("TechDraw_ExtensionCreateHorizChamferDimension")); + p1->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionCreateHorizChamferDimension")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionCreateVertChamferDimension")); + p2->setObjectName(QString::fromLatin1("TechDraw_ExtensionCreateVertChamferDimension")); + p2->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionCreateVertChamferDimension")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdTechDrawExtensionChamferDimensionGroup::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("TechDraw_Extension","Create Horizontal Chamfer Dimension")); + arc1->setToolTip(QApplication::translate("TechDraw_Extension","Create Horizontal Chamfer Dimension\n\ + - select two vertexes\n\ + - click this button")); + arc1->setStatusTip(arc1->toolTip()); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("TechDraw_Extension","Create Vertical Chamfer Dimension")); + arc2->setToolTip(QApplication::translate("TechDraw_Extension","Create Vertical Chamfer Dimension\n\ + - select two vertexes\n\ + - click this button")); + arc2->setStatusTip(arc2->toolTip()); +} + +bool CmdTechDrawExtensionChamferDimensionGroup::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, true); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionCreateLengthArc +//=========================================================================== + +DEF_STD_CMD_A(CmdTechDrawExtensionCreateLengthArc) + +CmdTechDrawExtensionCreateLengthArc::CmdTechDrawExtensionCreateLengthArc() + : Command("TechDraw_ExtensionCreateLengthArc") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create Development/length arc"); + sToolTipText = QT_TR_NOOP("Create Development/length arc\n\ + - select one arc\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCreateLengthArc"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionCreateLengthArc"; +} + +void CmdTechDrawExtensionCreateLengthArc::activated(int iMsg){ + // create a development/length arc dimension + Q_UNUSED(iMsg); + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSelAndObj(this,selection,objFeat,"TechDraw Create Development/length arc")) + return; + const std::vector subNames = selection[0].getSubNames(); + int geoId = TechDraw::DrawUtil::getIndexFromName(subNames[0]); + TechDraw::BaseGeom* geom = objFeat->getGeomByIndex(geoId); + std::string geoType = TechDraw::DrawUtil::getGeomTypeFromName(subNames[0]); + if (geoType == "Edge"){ + if (geom->geomType == TechDraw::ARCOFCIRCLE){ + TechDraw::AOC* arcTag = static_cast(geom); + float radius = arcTag->radius; + Base::Vector3d centerPt = arcTag->center; + centerPt.y = -centerPt.y; + Base::Vector3d startPt = arcTag->startPnt; + startPt.y = -startPt.y; + Base::Vector3d endPt = arcTag->endPnt; + endPt.y = -endPt.y; + std::stringstream startName, endName, formatSpec; + double scale = objFeat->getScale(); + std::string startVertTag = objFeat->addCosmeticVertex(startPt/scale); + int startVertNumber = objFeat->add1CVToGV(startVertTag); + startName << "Vertex" << startVertNumber; + std::string endVertTag = objFeat->addCosmeticVertex(endPt/scale); + int endVertNumber = objFeat->add1CVToGV(endVertTag); + endName << "Vertex" << endVertNumber; + TechDraw::DrawViewDimension* dim; + dim = _createLinDimension(this,objFeat,startName.str(),endName.str(),"Distance"); + TechDraw::pointPair pp = dim->getLinearPoints(); + Base::Vector3d mid = (pp.first + pp.second)/2.0; + dim->X.setValue(mid.x); + dim->Y.setValue(-mid.y); + Base::Vector3d radVec1 = startPt-centerPt; + Base::Vector3d radVec2 = endPt-centerPt; + float alpha = acos((radVec1*radVec2)/(radVec1.Length()*radVec2.Length())); + float arcLength = alpha*radius/scale; + dim->Arbitrary.setValue(true); + formatSpec << "∩ " << arcLength; + dim->FormatSpec.setValue(formatSpec.str()); + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); + getSelection().clearSelection(); + } + } +} + +bool CmdTechDrawExtensionCreateLengthArc::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// internal helper routines +//=========================================================================== + +bool _checkSelection(Gui::Command* cmd, + std::vector& selection, + std::string message){ + // check selection of getSelectionEx() + bool OK = true; + selection = cmd->getSelection().getSelectionEx(); + if( selection.empty() ) { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr(message.c_str()), + QObject::tr("Selection is empty")); + OK = false; + } + return OK; +} + +bool _checkSelAndObj(Gui::Command* cmd, + std::vector& selection, + TechDraw::DrawViewPart*& objFeat, + std::string message){ + // check selection of getSelectionEx() and selection[0].getObject() + bool OK = true; + OK = _checkSelection(cmd,selection,message); + if (OK) { + objFeat = dynamic_cast(selection[0].getObject()); + if( objFeat == nullptr ) { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr(message.c_str()), + QObject::tr("No object selected")); + OK = false; + } + } + return OK; +} + +TechDraw::DrawViewDimension* _createLinDimension(Gui::Command* cmd, + TechDraw::DrawViewPart* objFeat, + std::string startVertex, + std::string endVertex, + std::string dimType) + // create a new linear dimension +{ + TechDraw::DrawPage* page = objFeat->findParentPage(); + std::string PageName = page->getNameInDocument(); + TechDraw::DrawViewDimension* dim = 0; + std::string FeatName = cmd->getUniqueObjectName("Dimension"); + std::vector objs; + std::vector subs; + objs.push_back(objFeat); + objs.push_back(objFeat); + subs.push_back(startVertex); + subs.push_back(endVertex); + cmd->openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension")); + cmd->doCommand(cmd->Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str()); + cmd->doCommand(cmd->Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str(),dimType.c_str()); + dim = dynamic_cast(cmd->getDocument()->getObject(FeatName.c_str())); + if (!dim) + throw Base::TypeError("CmdTechDrawExtensionCreateLinDimension - dim not found\n"); + dim->References2D.setValues(objs, subs); + cmd->doCommand(cmd->Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + cmd->commitCommand(); + dim->recomputeFeature(); + return dim; +} + +std::vector _getVertexInfo(TechDraw::DrawViewPart* objFeat, + std::vector subNames){ + // get subNames and coordinates of all selected vertexes + std::vector vertexes; + dimVertex nextVertex; + for (std::string name : subNames){ + std::string geoType = TechDraw::DrawUtil::getGeomTypeFromName(name); + if (geoType == "Vertex"){ + int geoId = TechDraw::DrawUtil::getIndexFromName(name); + TechDraw::Vertex* vert = objFeat->getProjVertexByIndex(geoId); + nextVertex.name = name; + nextVertex.point.x = vert->point().x; + nextVertex.point.y = vert->point().y; + nextVertex.point.z = 0.0; + vertexes.push_back(nextVertex); + } + } + return vertexes; +} + +Base::Vector3d _getTrianglePoint(Base::Vector3d p1, Base::Vector3d dir, Base::Vector3d p2){ + // get third point of a perpendicular triangle + // p1, p2 ...vertexes of hypothenusis, dir ...direction of one kathete, p3 ...3rd vertex + float a = -dir.y; + float b = dir.x; + float c1 = p1.x*a+p1.y*b; + float c2 = -p2.x*b+p2.y*a; + float ab = a*a+b*b; + float x = (c1*a-c2*b)/ab; + float y = (c2*a+c1*b)/ab; + Base::Vector3d p3(x,y,0.0); + return p3; +} + +std::vector_getDimensions(std::vector selection,std::string needDimType){ + // get all selected dimensions of type needDimType + std::vector validDimension; + for (auto selected : selection){ + auto object = selected.getObject(); + if (object->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())){ + auto dim = dynamic_cast(selected.getObject()); + std::string dimType = dim->Type.getValueAsString(); + if (dimType == needDimType) + validDimension.push_back(dim); + } + } + return validDimension; +} + +//------------------------------------------------------------------------------ +void CreateTechDrawCommandsExtensionDims(void) +{ + Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); + + rcCmdMgr.addCommand(new CmdTechDrawExtensionInsertPraefixGroup()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionInsertDiameter()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionInsertSquare()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionIncreaseDecreaseGroup()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionIncreaseDecimal()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionDecreaseDecimal()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionPosChainDimensionGroup()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionPosHorizChainDimension()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionPosVertChainDimension()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionPosObliqueChainDimension()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCascadeDimensionGroup()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCascadeHorizDimension()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCascadeVertDimension()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCascadeObliqueDimension()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCreateChainDimensionGroup()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCreateHorizChainDimension()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCreateVertChainDimension()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCreateObliqueChainDimension()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCreateCoordDimensionGroup()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCreateHorizCoordDimension()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCreateVertCoordDimension()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCreateObliqueCoordDimension()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionChamferDimensionGroup()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCreateHorizChamferDimension()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCreateVertChamferDimension()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCreateLengthArc()); +} \ No newline at end of file diff --git a/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp b/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp index 0363e6e3d0..22155e8b56 100644 --- a/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp +++ b/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp @@ -67,53 +67,135 @@ #include "ViewProviderPage.h" #include "TaskLinkDim.h" +#include "TaskSelectLineAttributes.h" + +///////////////////////////// +#include // needed +#include +///////////////////////////// + using namespace TechDrawGui; using namespace TechDraw; using namespace std; +lineAttributes activeAttributes; // container holding global line attributes + //internal helper functions bool _circulation(Base::Vector3d A, Base::Vector3d B, Base::Vector3d C); +Base::Vector3d _circleCenter(Base::Vector3d p1, Base::Vector3d p2, Base::Vector3d p3); void _createThreadCircle(std::string Name, TechDraw::DrawViewPart* objFeat, float factor); void _createThreadLines(std::vector SubNames, TechDraw::DrawViewPart* objFeat, float factor); -void _setStyleAndWeight(TechDraw::CosmeticEdge* cosEdge, int style, float weight); +void _setLineAttributes(TechDraw::CosmeticEdge* cosEdge); +void _setLineAttributes(TechDraw::CenterLine* cosEdge); +void _setLineAttributes(TechDraw::CosmeticEdge* cosEdge, int style, float weight, App::Color color); +void _intersection(TechDraw::BaseGeom* geom1, TechDraw::BaseGeom* geom2, std::vector& interPoints); +void _intersectionLL(TechDraw::BaseGeom* geom1, TechDraw::BaseGeom* geom2, std::vector& interPoints); +void _intersectionCL(TechDraw::BaseGeom* geom1, TechDraw::BaseGeom* geom2, std::vector& interPoints); +void _intersectionCC(TechDraw::BaseGeom* geom1, TechDraw::BaseGeom* geom2, std::vector& interPoints); +float _getAngle(Base::Vector3d center, Base::Vector3d point); +std::vector _getVertexPoints(std::vector SubNames,TechDraw::DrawViewPart* objFeat); +bool _checkSel(Gui::Command* cmd, + std::vector& selection, + TechDraw::DrawViewPart*& objFeat, + std::string message); + +//=========================================================================== +// TechDraw_ExtensionHoleCircle +//=========================================================================== + +void execHoleCircle(Gui::Command* cmd){ + //create centerlines of a hole/bolt circle + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSel(cmd,selection,objFeat,"TechDraw Hole Circle")) + return; + const std::vector SubNames = selection[0].getSubNames(); + std::vector Circles; + for (std::string Name : SubNames){ + int GeoId = TechDraw::DrawUtil::getIndexFromName(Name); + std::string GeoType = TechDraw::DrawUtil::getGeomTypeFromName(Name); + TechDraw::BaseGeom* geom = objFeat->getGeomByIndex(GeoId); + if (GeoType == "Edge"){ + if (geom->geomType == TechDraw::CIRCLE || + geom->geomType == TechDraw::ARCOFCIRCLE){ + TechDraw::Circle* cgen = static_cast(geom); + Circles.push_back(cgen); + } + } + } + if (Circles.size() <= 2) { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("TechDraw Hole Circle"), + QObject::tr("Less then three circles selected")); + return; + } + double scale = objFeat->getScale(); + Base::Vector3d bigCenter = _circleCenter(Circles[0]->center, + Circles[1]->center, + Circles[2]->center); + float bigRadius = (Circles[0]->center-bigCenter).Length(); + TechDraw::BaseGeom* bigCircle = new TechDraw::Circle(bigCenter/scale,bigRadius/scale); + std::string bigCircleTag = objFeat->addCosmeticEdge(bigCircle); + TechDraw::CosmeticEdge* ceCircle = objFeat->getCosmeticEdge(bigCircleTag); + _setLineAttributes(ceCircle); + for (TechDraw::Circle* oneCircle : Circles){ + Base::Vector3d oneCircleCenter = oneCircle->center; + float oneRadius = oneCircle->radius; + Base::Vector3d delta = (oneCircle->center-bigCenter).Normalize()*(oneRadius+2); + Base::Vector3d startPt = oneCircleCenter+delta; + Base::Vector3d endPt = oneCircleCenter-delta; + startPt.y = -startPt.y; + endPt.y = -endPt.y; + std::string oneLineTag = objFeat->addCosmeticEdge(startPt/scale,endPt/scale); + TechDraw::CosmeticEdge* ceLine = objFeat->getCosmeticEdge(oneLineTag); + _setLineAttributes(ceLine); + } + cmd->getSelection().clearSelection(); + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); +} + +DEF_STD_CMD_A(CmdTechDrawExtensionHoleCircle) + +CmdTechDrawExtensionHoleCircle::CmdTechDrawExtensionHoleCircle() + : Command("TechDraw_ExtensionHoleCircle") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Draw bolt circle centerlines"); + sToolTipText = QT_TR_NOOP("Draw the centerlines of a bolt circle\n\ + - pick favoured line attributes\n\ + - select at least three cirles of a bolt circle\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionHoleCircle"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionHoleCircle"; +} + +void CmdTechDrawExtensionHoleCircle::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execHoleCircle(this); + //Base::Console().Message("HoleCircle gestartet\n"); +} + +bool CmdTechDrawExtensionHoleCircle::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} //=========================================================================== // TechDraw_ExtensionCircleCenterLines //=========================================================================== -DEF_STD_CMD_A(CmdTechDrawExtensionCircleCenterLines) - -CmdTechDrawExtensionCircleCenterLines::CmdTechDrawExtensionCircleCenterLines() - : Command("TechDraw_ExtensionCircleCenterLines") -{ - sAppModule = "TechDraw"; - sGroup = QT_TR_NOOP("TechDraw"); - sMenuText = QT_TR_NOOP("Draw circle centerlines"); - sToolTipText = QT_TR_NOOP("Draw circle centerline cross at circles\n\ - - select many circles or arcs\n\ - - click this button"); - sWhatsThis = "TechDraw_ExtensionCircleCenterLines"; - sStatusTip = sToolTipText; - sPixmap = "TechDraw_ExtensionCircleCenterLines"; -} - -void CmdTechDrawExtensionCircleCenterLines::activated(int iMsg) -{ - Q_UNUSED(iMsg); - auto selection = getSelection().getSelectionEx(); - if( selection.empty() ) { - QMessageBox::warning(Gui::getMainWindow(), - QObject::tr("TechDraw Circle Centerlines"), - QObject::tr("Selection is empty")); +void execCircleCenterLines(Gui::Command* cmd){ + // create centerline cross at circles + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSel(cmd,selection,objFeat,"TechDraw Circle Centerlines")) return; - } - auto objFeat = dynamic_cast(selection[0].getObject()); - if( objFeat == nullptr ) { - QMessageBox::warning(Gui::getMainWindow(), - QObject::tr("TechDraw Circle Centerlines"), - QObject::tr("No object selected")); - return; - } double scale = objFeat->getScale(); const std::vector SubNames = selection[0].getSubNames(); for (std::string Name : SubNames) { @@ -134,17 +216,40 @@ void CmdTechDrawExtensionCircleCenterLines::activated(int iMsg) std::string line1tag = objFeat->addCosmeticEdge(right/scale, left/scale); std::string line2tag = objFeat->addCosmeticEdge(top/scale, bottom/scale); TechDraw::CosmeticEdge* horiz = objFeat->getCosmeticEdge(line1tag); - _setStyleAndWeight(horiz,4,0.35f); + _setLineAttributes(horiz); TechDraw::CosmeticEdge* vert = objFeat->getCosmeticEdge(line2tag); - _setStyleAndWeight(vert,4,0.35f); + _setLineAttributes(vert); } } } - getSelection().clearSelection(); + cmd->getSelection().clearSelection(); objFeat->refreshCEGeoms(); objFeat->requestPaint(); } +DEF_STD_CMD_A(CmdTechDrawExtensionCircleCenterLines) + +CmdTechDrawExtensionCircleCenterLines::CmdTechDrawExtensionCircleCenterLines() + : Command("TechDraw_ExtensionCircleCenterLines") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Draw circle center lines"); + sToolTipText = QT_TR_NOOP("Draw circle center line cross at circles\n\ + - pick favoured line attributes\n\ + - select many circles or arcs\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCircleCenterLines"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionCircleCenterLines"; +} + +void CmdTechDrawExtensionCircleCenterLines::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execCircleCenterLines(this); +} + bool CmdTechDrawExtensionCircleCenterLines::isActive(void) { bool havePage = DrawGuiUtil::needPage(this); @@ -152,10 +257,127 @@ bool CmdTechDrawExtensionCircleCenterLines::isActive(void) return (havePage && haveView); } +//=========================================================================== +// TechDraw_ExtensionCircleCenterLinesGroup +//=========================================================================== + +DEF_STD_CMD_ACL(CmdTechDrawExtensionCircleCenterLinesGroup) + +CmdTechDrawExtensionCircleCenterLinesGroup::CmdTechDrawExtensionCircleCenterLinesGroup() + : Command("TechDraw_ExtensionCircleCenterLinesGroup") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Insert Circle Center Line"); + sToolTipText = QT_TR_NOOP("Draw circle center line cross at circles\n\ + - pick favoured line attributes\n\ + - select many circles or arcs\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionCircleCenterLinesGroup"; + sStatusTip = sToolTipText; + +} + +void CmdTechDrawExtensionCircleCenterLinesGroup::activated(int 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; + } + + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + pcAction->setIcon(pcAction->actions().at(iMsg)->icon()); + switch(iMsg) { + case 0: //circle center lines + execCircleCenterLines(this); + break; + case 1: //bolt circle center lines + execHoleCircle(this); + break; + default: + Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg); + }; +} + +Gui::Action * CmdTechDrawExtensionCircleCenterLinesGroup::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionCircleCenterLines")); + p1->setObjectName(QString::fromLatin1("TechDraw_ExtensionCircleCenterLines")); + p1->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionCircleCenterLines")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionHoleCircle")); + p2->setObjectName(QString::fromLatin1("TechDraw_ExtensionHoleCircle")); + p2->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionHoleCircle")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdTechDrawExtensionCircleCenterLinesGroup::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("TechDraw_Extension","Add Centerlines to Circles")); + arc1->setToolTip(QApplication::translate("TechDraw_Extension", + "Draw circle center line cross at circles\n\ + - pick favoured line attributes\n\ + - select many circles or arcs\n\ + - click this button")); + arc1->setStatusTip(arc1->toolTip()); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("TechDraw_Extension","Add Centerlines to Boltcircle")); + arc2->setToolTip(QApplication::translate("TechDraw_Extension", + "Draw the centerlines of a bolt circle\n\ + - pick favoured line attributes\n\ + - select at least three cirles of a bolt circle\n\ + - click this buttone")); + arc2->setStatusTip(arc2->toolTip()); +} + +bool CmdTechDrawExtensionCircleCenterLinesGroup::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, true); + return (havePage && haveView); +} + //=========================================================================== // TechDraw_ExtensionThreadHoleSide //=========================================================================== +void execThreadHoleSide(Gui::Command* cmd){ + // create symbolic thread in a hole seen from side + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSel(cmd,selection,objFeat,"TechDraw Thread Hole Side")) + return; + const std::vector SubNames = selection[0].getSubNames(); + if (SubNames.size() >= 2) { + _createThreadLines(SubNames, objFeat, 1.176f); + } + cmd->getSelection().clearSelection(); + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); +} + DEF_STD_CMD_A(CmdTechDrawExtensionThreadHoleSide) CmdTechDrawExtensionThreadHoleSide::CmdTechDrawExtensionThreadHoleSide() @@ -165,6 +387,7 @@ CmdTechDrawExtensionThreadHoleSide::CmdTechDrawExtensionThreadHoleSide() sGroup = QT_TR_NOOP("TechDraw"); sMenuText = QT_TR_NOOP("Cosmetic thread hole side view"); sToolTipText = QT_TR_NOOP("Draw cosmetic thread hole side view\n\ + - pick favoured line attributes\n\ - select two parallel lines\n\ - click this button"); sWhatsThis = "TechDraw_ExtensionThreadHoleSide"; @@ -175,27 +398,7 @@ CmdTechDrawExtensionThreadHoleSide::CmdTechDrawExtensionThreadHoleSide() void CmdTechDrawExtensionThreadHoleSide::activated(int iMsg) { Q_UNUSED(iMsg); - auto selection = getSelection().getSelectionEx(); - if( selection.empty() ) { - QMessageBox::warning(Gui::getMainWindow(), - QObject::tr("TechDraw Thread Hole Side"), - QObject::tr("Selection is empty")); - return; - } - TechDraw::DrawViewPart* objFeat = dynamic_cast(selection[0].getObject()); - if( objFeat == nullptr ) { - QMessageBox::warning(Gui::getMainWindow(), - QObject::tr("TechDraw Thread Hole Side"), - QObject::tr("No object selected")); - return; - } - const std::vector SubNames = selection[0].getSubNames(); - if (SubNames.size() >= 2) { - _createThreadLines(SubNames, objFeat, 1.176f); - } - getSelection().clearSelection(); - objFeat->refreshCEGeoms(); - objFeat->requestPaint(); + execThreadHoleSide(this); } bool CmdTechDrawExtensionThreadHoleSide::isActive(void) @@ -209,6 +412,21 @@ bool CmdTechDrawExtensionThreadHoleSide::isActive(void) // TechDraw_ExtensionThreadBoltSide //=========================================================================== +void execThreadBoltSide(Gui::Command* cmd){ + // create symbolic thread at a bolt seen from side + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSel(cmd,selection,objFeat,"TechDraw Thread Bolt Side")) + return; + const std::vector SubNames = selection[0].getSubNames(); + if (SubNames.size() >= 2) { + _createThreadLines(SubNames, objFeat, 0.85f); + } + cmd->getSelection().clearSelection(); + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); +} + DEF_STD_CMD_A(CmdTechDrawExtensionThreadBoltSide) CmdTechDrawExtensionThreadBoltSide::CmdTechDrawExtensionThreadBoltSide() @@ -217,7 +435,8 @@ CmdTechDrawExtensionThreadBoltSide::CmdTechDrawExtensionThreadBoltSide() sAppModule = "TechDraw"; sGroup = QT_TR_NOOP("TechDraw"); sMenuText = QT_TR_NOOP("Cosmetic thread bolt side view"); - sToolTipText = QT_TR_NOOP("Draw cosmetic screw thread side view\n\ + sToolTipText = QT_TR_NOOP("Thread Screw/pin/shaft side view/section\n\ + - pick favoured line attributes\n\ - select two parallel lines\n\ - click this button"); sWhatsThis = "TechDraw_ExtensionThreadBoltSide"; @@ -228,27 +447,7 @@ CmdTechDrawExtensionThreadBoltSide::CmdTechDrawExtensionThreadBoltSide() void CmdTechDrawExtensionThreadBoltSide::activated(int iMsg) { Q_UNUSED(iMsg); - auto selection = getSelection().getSelectionEx(); - if( selection.empty() ) { - QMessageBox::warning(Gui::getMainWindow(), - QObject::tr("TechDraw Thread Bolt Side"), - QObject::tr("Selection is empty")); - return; - } - TechDraw::DrawViewPart* objFeat = dynamic_cast(selection[0].getObject()); - if( objFeat == nullptr ) { - QMessageBox::warning(Gui::getMainWindow(), - QObject::tr("TechDraw Thread Bolt Side"), - QObject::tr("No object selected")); - return; - } - const std::vector SubNames = selection[0].getSubNames(); - if (SubNames.size() >= 2) { - _createThreadLines(SubNames, objFeat, 0.85f); - } - getSelection().clearSelection(); - objFeat->refreshCEGeoms(); - objFeat->requestPaint(); + execThreadBoltSide(this); } bool CmdTechDrawExtensionThreadBoltSide::isActive(void) @@ -262,6 +461,21 @@ bool CmdTechDrawExtensionThreadBoltSide::isActive(void) // TechDraw_ExtensionThreadHoleBottom //=========================================================================== +void execThreadHoleBottom(Gui::Command* cmd){ + // create symbolic thread in a hole seen from bottom + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSel(cmd,selection,objFeat,"TechDraw Thread Hole Bottom")) + return; + const std::vector SubNames = selection[0].getSubNames(); + for (std::string Name : SubNames) { + _createThreadCircle(Name, objFeat, 1.177f); + } + cmd->getSelection().clearSelection(); + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); +} + DEF_STD_CMD_A(CmdTechDrawExtensionThreadHoleBottom) CmdTechDrawExtensionThreadHoleBottom::CmdTechDrawExtensionThreadHoleBottom() @@ -269,8 +483,9 @@ CmdTechDrawExtensionThreadHoleBottom::CmdTechDrawExtensionThreadHoleBottom() { sAppModule = "TechDraw"; sGroup = QT_TR_NOOP("TechDraw"); - sMenuText = QT_TR_NOOP("Cosmetic thread hole bottom view"); - sToolTipText = QT_TR_NOOP("Draw cosmetic hole thread ground view\n\ + sMenuText = QT_TR_NOOP("Cosmetic hole thread ground view"); + sToolTipText = QT_TR_NOOP("Draw cosmetic hole threads ground view\n\ + - pick favoured line attributes\n\ - select many circles\n\ - click this button"); sWhatsThis = "TechDraw_ExtensionThreadHoleBottom"; @@ -281,27 +496,7 @@ CmdTechDrawExtensionThreadHoleBottom::CmdTechDrawExtensionThreadHoleBottom() void CmdTechDrawExtensionThreadHoleBottom::activated(int iMsg) { Q_UNUSED(iMsg); - auto selection = getSelection().getSelectionEx(); - if( selection.empty() ) { - QMessageBox::warning(Gui::getMainWindow(), - QObject::tr("TechDraw Thread Hole Bottom"), - QObject::tr("Selection is empty")); - return; - } - auto objFeat = dynamic_cast(selection[0].getObject()); - if( objFeat == nullptr ) { - QMessageBox::warning(Gui::getMainWindow(), - QObject::tr("TechDraw Thread Hole Bottom"), - QObject::tr("No object selected")); - return; - } - const std::vector SubNames = selection[0].getSubNames(); - for (std::string Name : SubNames) { - _createThreadCircle(Name, objFeat, 1.177f); - } - getSelection().clearSelection(); - objFeat->refreshCEGeoms(); - objFeat->requestPaint(); + execThreadHoleBottom(this); } bool CmdTechDrawExtensionThreadHoleBottom::isActive(void) @@ -315,6 +510,21 @@ bool CmdTechDrawExtensionThreadHoleBottom::isActive(void) // TechDraw_ExtensionThreadBoltBottom //=========================================================================== +void execThreadBoltBottom(Gui::Command* cmd){ + // create symbolic thread at a bolt seen from bottom + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSel(cmd,selection,objFeat,"TechDraw Thread Bolt Bottom")) + return; + const std::vector SubNames = selection[0].getSubNames(); + for (std::string Name : SubNames) { + _createThreadCircle(Name, objFeat, 0.85f); + } + cmd->getSelection().clearSelection(); + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); +} + DEF_STD_CMD_A(CmdTechDrawExtensionThreadBoltBottom) CmdTechDrawExtensionThreadBoltBottom::CmdTechDrawExtensionThreadBoltBottom() @@ -322,8 +532,9 @@ CmdTechDrawExtensionThreadBoltBottom::CmdTechDrawExtensionThreadBoltBottom() { sAppModule = "TechDraw"; sGroup = QT_TR_NOOP("TechDraw"); - sMenuText = QT_TR_NOOP("Cosmetic thread bolt bottom view"); - sToolTipText = QT_TR_NOOP("Draw cosmetic screw thread ground view\n\ + sMenuText = QT_TR_NOOP("Screw/pin/shaft thread in plan"); + sToolTipText = QT_TR_NOOP("Draw the technical symbol of the thread in the screw/pin/shaft plant\n\ + - pick favoured line attributes\n\ - select many circles\n\ - click this button"); sWhatsThis = "TechDraw_ExtensionThreadBoltBottom"; @@ -334,27 +545,7 @@ CmdTechDrawExtensionThreadBoltBottom::CmdTechDrawExtensionThreadBoltBottom() void CmdTechDrawExtensionThreadBoltBottom::activated(int iMsg) { Q_UNUSED(iMsg); - auto selection = getSelection().getSelectionEx(); - if( selection.empty() ) { - QMessageBox::warning(Gui::getMainWindow(), - QObject::tr("TechDraw Tread Bolt Bottom"), - QObject::tr("Selection is empty")); - return; - } - auto objFeat = dynamic_cast(selection[0].getObject()); - if( objFeat == nullptr ) { - QMessageBox::warning(Gui::getMainWindow(), - QObject::tr("TechDraw Tread Bolt Bottom"), - QObject::tr("No object selected")); - return; - } - const std::vector SubNames = selection[0].getSubNames(); - for (std::string Name : SubNames) { - _createThreadCircle(Name, objFeat, 0.85f); - } - getSelection().clearSelection(); - objFeat->refreshCEGeoms(); - objFeat->requestPaint(); + execThreadBoltBottom(this); } bool CmdTechDrawExtensionThreadBoltBottom::isActive(void) @@ -364,10 +555,1281 @@ bool CmdTechDrawExtensionThreadBoltBottom::isActive(void) return (havePage && haveView); } +//=========================================================================== +// TechDraw_ExtensionThreadsGroup +//=========================================================================== + +DEF_STD_CMD_ACL(CmdTechDrawExtensionThreadsGroup) + +CmdTechDrawExtensionThreadsGroup::CmdTechDrawExtensionThreadsGroup() + : Command("TechDraw_ExtensionThreadsGroup") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Cosmetic thread hole side view"); + sToolTipText = QT_TR_NOOP("Draw cosmetic thread hole side view\n\ + - pick favoured line attributes\n\ + - select two parallel lines\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionThreadsGroup"; + sStatusTip = sToolTipText; +} + +void CmdTechDrawExtensionThreadsGroup::activated(int iMsg) +{ +// Base::Console().Message("CMD::TechDrawExtensionThreadsGroup - activated(%d)\n", 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; + } + + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + pcAction->setIcon(pcAction->actions().at(iMsg)->icon()); + switch(iMsg) { + case 0: //thread hole side view + execThreadHoleSide(this); + break; + case 1: //thread hole bottom view + execThreadHoleBottom(this); + break; + case 2: //thread bolt side view + execThreadBoltSide(this); + break; + case 3: //thread bolt bottom view + execThreadBoltBottom(this); + break; + default: + Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg); + }; +} + +Gui::Action * CmdTechDrawExtensionThreadsGroup::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionThreadHoleSide")); + p1->setObjectName(QString::fromLatin1("TechDraw_ExtensionThreadHoleSide")); + p1->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionThreadHoleSide")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionThreadHoleBottom")); + p2->setObjectName(QString::fromLatin1("TechDraw_ExtensionThreadHoleBottom")); + p2->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionThreadHoleBottom")); + QAction* p3 = pcAction->addAction(QString()); + p3->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionThreadBoltSide")); + p3->setObjectName(QString::fromLatin1("TechDraw_ExtensionThreadBoltSide")); + p3->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionThreadBoltSide")); + QAction* p4 = pcAction->addAction(QString()); + p4->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionThreadBoltBottom")); + p4->setObjectName(QString::fromLatin1("TechDraw_ExtensionThreadBoltBottom")); + p4->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionThreadBoltBottom")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdTechDrawExtensionThreadsGroup::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("TechDraw_Extension","Create Thread Hole Side View")); + arc1->setToolTip(QApplication::translate("TechDraw_Extension", + "Draw cosmetic thread hole side view\n\ + - pick favoured line attributes\n\ + - select two parallel lines\n\ + - click this button")); + arc1->setStatusTip(arc1->toolTip()); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("TechDraw_Extension","Create Thread Hole Bottom View")); + arc2->setToolTip(QApplication::translate("TechDraw_Extension", + "Draw cosmetic hole threads ground view\n\ + - pick favoured line attributes\n\ + - select many circles\n\ + - click this button")); + arc2->setStatusTip(arc2->toolTip()); + QAction* arc3 = a[2]; + arc3->setText(QApplication::translate("TechDraw_Extension","Create Thread Bolt Side View")); + arc3->setToolTip(QApplication::translate("TechDraw_Extension", + "Thread Screw/pin/shaft side view/section\n\ + - pick favoured line attributes\n\ + - select two parallel lines\n\ + - click this button")); + arc3->setStatusTip(arc3->toolTip()); + QAction* arc4 = a[3]; + arc4->setText(QApplication::translate("TechDraw_Extension","Create Thread Bolt Bottom View")); + arc4->setToolTip(QApplication::translate("TechDraw_Extension", + "Draw the technical symbol of the thread in the screw/pin/shaft plant\n\ + - pick favoured line attributes\n\ + - select many circles\n\ + - click this button")); + arc4->setStatusTip(arc4->toolTip()); +} + +bool CmdTechDrawExtensionThreadsGroup::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, true); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionSelectLineAttributes +//=========================================================================== + +DEF_STD_CMD_A(CmdTechDrawExtensionSelectLineAttributes) + +CmdTechDrawExtensionSelectLineAttributes::CmdTechDrawExtensionSelectLineAttributes() + : Command("TechDraw_ExtensionSelectLineAttributes") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Select line attributes"); + sToolTipText = QT_TR_NOOP("Select the line attributes\n\ + - click this button\n\ + - select line attributes in opened window"); + sWhatsThis = "TechDraw_ExtensionSelectLineAttributes"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionSelectLineAttributes"; +} + +void CmdTechDrawExtensionSelectLineAttributes::activated(int iMsg) +{ + Q_UNUSED(iMsg); + Gui::Control().showDialog(new TaskDlgSelectLineAttributes(& activeAttributes)); +} + +bool CmdTechDrawExtensionSelectLineAttributes::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionChangeLineAttributes +//=========================================================================== + +DEF_STD_CMD_A(CmdTechDrawExtensionChangeLineAttributes) + +CmdTechDrawExtensionChangeLineAttributes::CmdTechDrawExtensionChangeLineAttributes() + : Command("TechDraw_ExtensionChangeLineAttributes") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Change the line attributes"); + sToolTipText = QT_TR_NOOP("Change the attributes of selected lines\n\ + - pick favoured line attributes\n\ + - select many cosmetic or center lines\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionChangeLineAttributes"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionChangeLineAttributes"; +} + +void CmdTechDrawExtensionChangeLineAttributes::activated(int iMsg){ + // change attributes (type, width, color) of a cosmetic or centerline + Q_UNUSED(iMsg); + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSel(this,selection,objFeat,"TechDraw Change Line Attributes")) + return; + const std::vector subNames = selection[0].getSubNames(); + for (std::string name : subNames){ + int num = DrawUtil::getIndexFromName(name); + BaseGeom* baseGeo = objFeat->getGeomByIndex(num); + if (baseGeo != nullptr){ + if (baseGeo->cosmetic){ + if (baseGeo->source() == 1){ + TechDraw::CosmeticEdge* cosEdgeTag = objFeat->getCosmeticEdgeBySelection(name); + _setLineAttributes(cosEdgeTag); + } else if (baseGeo->source() == 2){ + TechDraw::CenterLine* centerLineTag = objFeat->getCenterLineBySelection(name); + _setLineAttributes(centerLineTag); + } + } + } + } + getSelection().clearSelection(); + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); +} + +bool CmdTechDrawExtensionChangeLineAttributes::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionVertexAtIntersection +//=========================================================================== + +DEF_STD_CMD_A(CmdTechDrawExtensionVertexAtIntersection) + +CmdTechDrawExtensionVertexAtIntersection::CmdTechDrawExtensionVertexAtIntersection() + : Command("TechDraw_ExtensionVertexAtIntersection") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create Vertex(es) at Intersection"); + sToolTipText = QT_TR_NOOP("Create the vertexes at intersection of lines\n\ + - select two lines/circles/arcs\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionVertexAtIntersection"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionVertexAtIntersection"; +} + +void CmdTechDrawExtensionVertexAtIntersection::activated(int iMsg) +{ + Q_UNUSED(iMsg); + //Base::Console().Message("VertexAtIntersection gestartet\n"); + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSel(this,selection,objFeat,"TechDraw Create Vertex at Intersection")) + return; + const std::vector SubNames = selection[0].getSubNames(); + std::vector interPoints; + if (SubNames.size() >=2){ + std::string GeoType1 = TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]); + std::string GeoType2 = TechDraw::DrawUtil::getGeomTypeFromName(SubNames[1]); + if (GeoType1 == "Edge" && GeoType2 == "Edge"){ + int GeoId1 = TechDraw::DrawUtil::getIndexFromName(SubNames[0]); + TechDraw::BaseGeom* geom1 = objFeat->getGeomByIndex(GeoId1); + int GeoId2 = TechDraw::DrawUtil::getIndexFromName(SubNames[1]); + TechDraw::BaseGeom* geom2 = objFeat->getGeomByIndex(GeoId2); + _intersection(geom1, geom2, interPoints); + if (!interPoints.empty()){ + double scale = objFeat->getScale(); + std::string id1 = objFeat->addCosmeticVertex(interPoints[0]/scale); + objFeat->add1CVToGV(id1); + if (interPoints.size() >= 2){ + std::string id2 = objFeat->addCosmeticVertex(interPoints[1]/scale); + objFeat->add1CVToGV(id2); + } + } + } + } + getSelection().clearSelection(); + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); +} + +bool CmdTechDrawExtensionVertexAtIntersection::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionDrawArc +//=========================================================================== + +void execDrawCosmArc(Gui::Command* cmd){ + //draw a cosmetic arc of circle + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSel(cmd,selection,objFeat,"TechDraw Draw Cosmetic Arc of Circle")) + return; + const std::vector SubNames = selection[0].getSubNames(); + std::vector vertexPoints; + vertexPoints = _getVertexPoints(SubNames,objFeat); + if (vertexPoints.size() >= 3){ + double scale = objFeat->getScale(); + float arcRadius = (vertexPoints[1]-vertexPoints[0]).Length(); + float angle1 = _getAngle(vertexPoints[0],vertexPoints[1]); + float angle2 = _getAngle(vertexPoints[0],vertexPoints[2]); + TechDraw::BaseGeom* baseGeo = new TechDraw::AOC(vertexPoints[0]/scale, arcRadius/scale, -angle2, -angle1); + std::string arcTag = objFeat->addCosmeticEdge(baseGeo); + TechDraw::CosmeticEdge* arcEdge = objFeat->getCosmeticEdge(arcTag); + _setLineAttributes(arcEdge); + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); + cmd->getSelection().clearSelection(); + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionArc) + +CmdTechDrawExtensionArc::CmdTechDrawExtensionArc() + : Command("TechDraw_ExtensionArc") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Draw an cosmetic arc (center and two vertexes)"); + sToolTipText = QT_TR_NOOP("Draw an arc rotating math. positive\n\ + - select three vertexes:\n\ + - center, start, end\n\ + - start defines the radius\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionArc"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionArc"; +} + +void CmdTechDrawExtensionArc::activated(int iMsg) +{ + Q_UNUSED(iMsg); + //Base::Console().Message("Cosmetic Arc gestartet\n"); + execDrawCosmArc(this); +} + +bool CmdTechDrawExtensionArc::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionDrawCosmCircle +//=========================================================================== + +void execDrawCosmCircle(Gui::Command* cmd){ + //draw a cosmetic circle + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSel(cmd,selection,objFeat,"TechDraw Draw Cosmetic Circle")) + return; + const std::vector SubNames = selection[0].getSubNames(); + std::vector vertexPoints; + vertexPoints = _getVertexPoints(SubNames,objFeat); + if (vertexPoints.size() >= 2){ + double scale = objFeat->getScale(); + float circleRadius = (vertexPoints[1]-vertexPoints[0]).Length(); + TechDraw::BaseGeom* baseGeo = new TechDraw::Circle(vertexPoints[0]/scale, circleRadius/scale); + std::string cicleTag = objFeat->addCosmeticEdge(baseGeo); + TechDraw::CosmeticEdge* circleEdge = objFeat->getCosmeticEdge(cicleTag); + _setLineAttributes(circleEdge); + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); + cmd->getSelection().clearSelection(); + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionDrawCosmCircle) + +CmdTechDrawExtensionDrawCosmCircle::CmdTechDrawExtensionDrawCosmCircle() + : Command("TechDraw_ExtensionDrawCosmCircle") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Draw an cosmetic circumference (center and 1 vertex)"); + sToolTipText = QT_TR_NOOP("Draw a cosmetic circumference using two vertices\n\ + - choose the line attributes\n\ + - select the first vertex (center) -> in sequence the second (radius)\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionDrawCosmCircle"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionDrawCosmCircle"; +} + +void CmdTechDrawExtensionDrawCosmCircle::activated(int iMsg) +{ + Q_UNUSED(iMsg); + //Base::Console().Message("Cosmetic Circle gestartet\n"); + execDrawCosmCircle(this); +} + +bool CmdTechDrawExtensionDrawCosmCircle::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionDrawCirclesGroup +//=========================================================================== + +DEF_STD_CMD_ACL(CmdTechDrawExtensionDrawCirclesGroup) + +CmdTechDrawExtensionDrawCirclesGroup::CmdTechDrawExtensionDrawCirclesGroup() + : Command("TechDraw_ExtensionDrawCirclesGroup") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Draw an cosmetic circumference (center and 1 vertex)"); + sToolTipText = QT_TR_NOOP("Draw a cosmetic circumference using two vertices\n\ + - choose the line attributes\n\ + - select the first vertex (center) -> in sequence the second (radius)\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionDrawCirclesGroup"; + sStatusTip = sToolTipText; +} + +void CmdTechDrawExtensionDrawCirclesGroup::activated(int iMsg) +{ +// Base::Console().Message("CMD::ExtensionDrawCirclesGroup - activated(%d)\n", 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; + } + + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + pcAction->setIcon(pcAction->actions().at(iMsg)->icon()); + switch(iMsg) { + case 0: //draw cosmetic circle + execDrawCosmCircle(this); + break; + case 1: //draw cosmetic arc + execDrawCosmArc(this); + break; + default: + Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg); + }; +} + +Gui::Action * CmdTechDrawExtensionDrawCirclesGroup::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionDrawCosmCircle")); + p1->setObjectName(QString::fromLatin1("TechDraw_ExtensionDrawCosmCircle")); + p1->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionDrawCosmCircle")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionArc")); + p2->setObjectName(QString::fromLatin1("TechDraw_ExtensionArc")); + p2->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionArc")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdTechDrawExtensionDrawCirclesGroup::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("TechDraw_Extension","Draw Cosmetic Circle")); + arc1->setToolTip(QApplication::translate("TechDraw_Extension", + "Draw a cosmetic circumference using two vertices\n\ + - choose the line attributes\n\ + - select the first vertex (center) -> in sequence the second (radius)\n\ + - click this button")); + arc1->setStatusTip(arc1->toolTip()); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("TechDraw_Extension","Draw Cosmetic Arc")); + arc2->setToolTip(QApplication::translate("TechDraw_Extension", + "Draw an arc rotating math. positive\n\ + - select three vertexes:\n\ + - center, start, end\n\ + - start defines the radius\n\ + - click this buttonc")); + arc2->setStatusTip(arc2->toolTip()); +} + +bool CmdTechDrawExtensionDrawCirclesGroup::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, true); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionLineParallel +//=========================================================================== + +void execLineParallelPerpendicular(Gui::Command* cmd, bool isParallel){ + // create a line parallel or perpendicular to another line + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSel(cmd,selection,objFeat,"TechDraw Create Line Parallel/Perpendicular")) + return; + const std::vector SubNames = selection[0].getSubNames(); + if (SubNames.size() >= 2){ + std::string GeoType1 = TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]); + std::string GeoType2 = TechDraw::DrawUtil::getGeomTypeFromName(SubNames[1]); + if (GeoType1 == "Edge" && GeoType2 == "Vertex"){ + double scale = objFeat->getScale(); + int GeoId1 = TechDraw::DrawUtil::getIndexFromName(SubNames[0]); + TechDraw::BaseGeom* geom1 = objFeat->getGeomByIndex(GeoId1); + int GeoId2 = TechDraw::DrawUtil::getIndexFromName(SubNames[1]); + TechDraw::Generic* lineGen = static_cast(geom1); + Base::Vector3d lineStart = lineGen->points.at(0); + Base::Vector3d lineEnd = lineGen->points.at(1); + TechDraw::Vertex* vert = objFeat->getProjVertexByIndex(GeoId2); + Base::Vector3d vertexPoint(vert->point().x,vert->point().y,0.0); + Base::Vector3d halfVector = (lineEnd-lineStart)/2.0; + if (!isParallel){ + float dummy = halfVector.x; + halfVector.x = -halfVector.y; + halfVector.y = dummy; + } + Base::Vector3d startPoint = vertexPoint+halfVector; + Base::Vector3d endPoint = vertexPoint-halfVector; + startPoint.y = -startPoint.y; + endPoint.y = -endPoint.y; + std::string lineTag = objFeat->addCosmeticEdge(startPoint/scale, endPoint/scale); + TechDraw::CosmeticEdge* lineEdge = objFeat->getCosmeticEdge(lineTag); + _setLineAttributes(lineEdge); + objFeat->refreshCEGeoms(); + objFeat->requestPaint(); + cmd->getSelection().clearSelection(); + } + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionLineParallel) + +CmdTechDrawExtensionLineParallel::CmdTechDrawExtensionLineParallel() + : Command("TechDraw_ExtensionLineParallel") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create a line parallel to another line"); + sToolTipText = QT_TR_NOOP("Create a line parallel to another line through a vertex\n\ + - choose the line attributes\n\ + - select one line\n\ + - select one vertex\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionLineParallel"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionLineParallel"; +} + +void CmdTechDrawExtensionLineParallel::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execLineParallelPerpendicular(this,true); +} + +bool CmdTechDrawExtensionLineParallel::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionLinePerpendicular +//=========================================================================== + +DEF_STD_CMD_A(CmdTechDrawExtensionLinePerpendicular) + +CmdTechDrawExtensionLinePerpendicular::CmdTechDrawExtensionLinePerpendicular() + : Command("TechDraw_ExtensionLinePerpendicular") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create a line perpendicular to another line"); + sToolTipText = QT_TR_NOOP("Create a line perpendicular to another line through a vertex\n\ + - choose the line attributes\n\ + - select one line\n\ + - select one vertex\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionLinePerpendicular"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionLinePerpendicular"; +} + +void CmdTechDrawExtensionLinePerpendicular::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execLineParallelPerpendicular(this,false); + ///Base::Console().Message("Create perpendiculararallel line started\n"); +} + +bool CmdTechDrawExtensionLinePerpendicular::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionLinePPGroup +//=========================================================================== + +DEF_STD_CMD_ACL(CmdTechDrawExtensionLinePPGroup) + +CmdTechDrawExtensionLinePPGroup::CmdTechDrawExtensionLinePPGroup() + : Command("TechDraw_ExtensionLinePPGroup") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Create a line parallel to another line"); + sToolTipText = QT_TR_NOOP("Create a line parallel to another line through a vertex\n\ + - choose the line attributes\n\ + - select one line\n\ + - select one vertex\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionLinePPGroup"; + sStatusTip = sToolTipText; +} + +void CmdTechDrawExtensionLinePPGroup::activated(int iMsg) +{ +// Base::Console().Message("CMD::ExtensionLinePPGroup - activated(%d)\n", 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; + } + + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + pcAction->setIcon(pcAction->actions().at(iMsg)->icon()); + switch(iMsg) { + case 0: //create parallel line + execLineParallelPerpendicular(this,true); + break; + case 1: //create perpendicular line + execLineParallelPerpendicular(this,false); + break; + default: + Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg); + }; +} + +Gui::Action * CmdTechDrawExtensionLinePPGroup::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionLineParallel")); + p1->setObjectName(QString::fromLatin1("TechDraw_ExtensionLineParallel")); + p1->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionLineParallel")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionLinePerpendicular")); + p2->setObjectName(QString::fromLatin1("TechDraw_ExtensionLinePerpendicular")); + p2->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionLinePerpendicular")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdTechDrawExtensionLinePPGroup::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("TechDraw_Extension","Create parallel Line")); + arc1->setToolTip(QApplication::translate("TechDraw_Extension", + "Create a line parallel to another line through a vertex\n\ + - choose the line attributes\n\ + - select one line\n\ + - select one vertex\n\ + - click this button")); + arc1->setStatusTip(arc1->toolTip()); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("TechDraw_Extension","Create perpendicular Line")); + arc2->setToolTip(QApplication::translate("TechDraw_Extension", + "Create a line perpendicular to another line through a vertex\n\ + - choose the line attributes\n\ + - select one line\n\ + - select one vertex\n\ + - click this button")); + arc2->setStatusTip(arc2->toolTip()); +} + +bool CmdTechDrawExtensionLinePPGroup::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, true); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionLockUnlockView +//=========================================================================== + +DEF_STD_CMD_A(CmdTechDrawExtensionLockUnlockView) + +CmdTechDrawExtensionLockUnlockView::CmdTechDrawExtensionLockUnlockView() + : Command("TechDraw_ExtensionLockUnlockView") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Lock/Unlock a View"); + sToolTipText = QT_TR_NOOP("Lock/Unlock a View\n\ + - select a view\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionLockUnlockView"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionLockUnlockView"; +} + +void CmdTechDrawExtensionLockUnlockView::activated(int iMsg){ + // lock/unlock a selected view + Q_UNUSED(iMsg); + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSel(this,selection,objFeat,"TechDraw Lock/Unlock View")) + return; + if (objFeat->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())){ + auto objFeat = dynamic_cast(selection[0].getObject()); + bool lockPosition = objFeat->LockPosition.getValue(); + lockPosition = !lockPosition; + objFeat->LockPosition.setValue(lockPosition); + } +} + +bool CmdTechDrawExtensionLockUnlockView::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionPositionSectionView +//=========================================================================== + +DEF_STD_CMD_A(CmdTechDrawExtensionPositionSectionView) + +CmdTechDrawExtensionPositionSectionView::CmdTechDrawExtensionPositionSectionView() + : Command("TechDraw_ExtensionPositionSectionView") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Orthogonal projection group: section view positioning"); + sToolTipText = QT_TR_NOOP("Position a section view at same x or y as its base view\n\ + - select a section view\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionPositionSectionView"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionPositionSectionView"; +} + +void CmdTechDrawExtensionPositionSectionView::activated(int iMsg){ + // position a section view + Q_UNUSED(iMsg); + Base::Console().Message("PositionSectionView started\n"); + auto selection = getSelection().getSelectionEx(); + if( selection.empty() ) { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr("TechDraw Lock/Unlock View"), + QObject::tr("Selection is empty")); + return; + } + float xPos, yPos; + TechDraw::DrawViewPart* baseView; + auto objFeat = selection[0].getObject(); + if (objFeat->isDerivedFrom(TechDraw::DrawViewSection::getClassTypeId())){ + TechDraw::DrawViewSection* sectionView = dynamic_cast(objFeat); + baseView = sectionView->getBaseDVP(); + if (baseView->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())){ + std::vector parentViews = baseView->getInList(); + if (!parentViews.empty()){ + TechDraw::DrawProjGroup* groupBase = dynamic_cast(parentViews[0]); + xPos = groupBase->X.getValue(); + yPos = groupBase->Y.getValue(); + } + } + else { + xPos = baseView->X.getValue(); + yPos = baseView->Y.getValue(); + } + std::string direction = sectionView->SectionDirection.getValueAsString(); + if ((direction == "Right") || (direction == "Left")) + sectionView->Y.setValue(yPos); + else if ((direction == "Up") || (direction == "Down")) + sectionView->X.setValue(xPos); + } +} + +bool CmdTechDrawExtensionPositionSectionView::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionExtendLine +//=========================================================================== + +void execExtendShortenLine(Gui::Command* cmd, bool extend){ + // extend or shorten a cosmetic or a center line + std::vector selection; + TechDraw::DrawViewPart* objFeat; + if (!_checkSel(cmd,selection,objFeat,"TechDraw Create Line Parallel/Perpendicular")) + return; + const std::vector subNames = selection[0].getSubNames(); + if (!subNames.empty()){ + std::string name = subNames[0]; + int num = DrawUtil::getIndexFromName(name); + std::string geoType = TechDraw::DrawUtil::getGeomTypeFromName(name); + if (geoType == "Edge"){ + TechDraw::BaseGeom* baseGeo = objFeat->getGeomByIndex(num); + if (baseGeo != nullptr){ + if (baseGeo->geomType == TechDraw::GENERIC){ + TechDraw::Generic* genLine = static_cast(baseGeo); + Base::Vector3d P0 = genLine->points.at(0); + Base::Vector3d P1 = genLine->points.at(1); + if (baseGeo->cosmetic){ + std::string uniTag = baseGeo->getCosmeticTag(); + int oldStyle; + float oldWeight; + App::Color oldColor; + std::vector toDelete; + toDelete.push_back(uniTag); + if (baseGeo->source() == 1){ + auto cosEdge = objFeat->getCosmeticEdge(uniTag); + oldStyle = cosEdge->m_format.m_style; + oldWeight = cosEdge->m_format.m_weight; + oldColor = cosEdge->m_format.m_color; + objFeat->removeCosmeticEdge(toDelete); + } + else if (baseGeo->source() == 2){ + auto centerEdge = objFeat->getCenterLine(uniTag); + oldStyle = centerEdge->m_format.m_style; + oldWeight = centerEdge->m_format.m_weight; + oldColor = centerEdge->m_format.m_color; + objFeat->removeCenterLine(toDelete); + } + double scale = objFeat->getScale(); + Base::Vector3d direction = (P1-P0).Normalize(); + Base::Vector3d delta = direction*2.0; + Base::Vector3d startPt, endPt; + if (extend){ + startPt = P0-delta; + endPt = P1+delta; + } else { + startPt = P0+delta; + endPt = P1-delta; + } + startPt.y = -startPt.y; + endPt.y = -endPt.y; + std::string lineTag = objFeat->addCosmeticEdge(startPt/scale,endPt/scale); + TechDraw::CosmeticEdge* lineEdge = objFeat->getCosmeticEdge(lineTag); + _setLineAttributes(lineEdge,oldStyle,oldWeight,oldColor); + cmd->getSelection().clearSelection(); + objFeat->refreshCEGeoms(); + objFeat->refreshCLGeoms(); + objFeat->requestPaint(); + } + } + } + } + } +} + +DEF_STD_CMD_A(CmdTechDrawExtensionExtendLine) + +CmdTechDrawExtensionExtendLine::CmdTechDrawExtensionExtendLine() + : Command("TechDraw_ExtensionExtendLine") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Extend a Line"); + sToolTipText = QT_TR_NOOP("Extend a line at both ends\n\ + - select one cosmetic or centerline\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionExtendLine"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionExtendLine"; +} + +void CmdTechDrawExtensionExtendLine::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execExtendShortenLine(this,true); + ///Base::Console().Message("ExtendLine started\n"); +} + +bool CmdTechDrawExtensionExtendLine::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionShortenLine +//=========================================================================== + +DEF_STD_CMD_A(CmdTechDrawExtensionShortenLine) + +CmdTechDrawExtensionShortenLine::CmdTechDrawExtensionShortenLine() + : Command("TechDraw_ExtensionShortenLine") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Shorten a Line"); + sToolTipText = QT_TR_NOOP("Shorten a line at both ends\n\ + - select one cosmetic or centerline\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionShortenLine"; + sStatusTip = sToolTipText; + sPixmap = "TechDraw_ExtensionShortenLine"; +} + +void CmdTechDrawExtensionShortenLine::activated(int iMsg) +{ + Q_UNUSED(iMsg); + execExtendShortenLine(this,false); + ///Base::Console().Message("ShortenLine started\n"); +} + +bool CmdTechDrawExtensionShortenLine::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this); + return (havePage && haveView); +} + +//=========================================================================== +// TechDraw_ExtensionExtendShortenLineGroup +//=========================================================================== + +DEF_STD_CMD_ACL(CmdTechDrawExtendShortenLineGroup) + +CmdTechDrawExtendShortenLineGroup::CmdTechDrawExtendShortenLineGroup() + : Command("TechDraw_ExtensionExtendShortenLineGroup") +{ + sAppModule = "TechDraw"; + sGroup = QT_TR_NOOP("TechDraw"); + sMenuText = QT_TR_NOOP("Extend a Line"); + sToolTipText = QT_TR_NOOP("Extend a line at both ends\n\ + - select one cosmetic or centerline\n\ + - click this button"); + sWhatsThis = "TechDraw_ExtensionExtendShortenLineGroup"; + sStatusTip = sToolTipText; +} + +void CmdTechDrawExtendShortenLineGroup::activated(int iMsg) +{ +// Base::Console().Message("CMD::ExtendShortenLineGroup - activated(%d)\n", 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; + } + + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + pcAction->setIcon(pcAction->actions().at(iMsg)->icon()); + switch(iMsg) { + case 0: //extend a line + execExtendShortenLine(this,true); + break; + case 1: //shorten line + execExtendShortenLine(this,false); + break; + default: + Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg); + }; +} + +Gui::Action * CmdTechDrawExtendShortenLineGroup::createAction(void) +{ + Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); + pcAction->setDropDownMenu(true); + applyCommandData(this->className(), pcAction); + + QAction* p1 = pcAction->addAction(QString()); + p1->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionExtendLine")); + p1->setObjectName(QString::fromLatin1("TechDraw_ExtensionExtendLine")); + p1->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionExtendLine")); + QAction* p2 = pcAction->addAction(QString()); + p2->setIcon(Gui::BitmapFactory().iconFromTheme("TechDraw_ExtensionShortenLine")); + p2->setObjectName(QString::fromLatin1("TechDraw_ExtensionShortenLine")); + p2->setWhatsThis(QString::fromLatin1("TechDraw_ExtensionShortenLine")); + + _pcAction = pcAction; + languageChange(); + + pcAction->setIcon(p1->icon()); + int defaultId = 0; + pcAction->setProperty("defaultAction", QVariant(defaultId)); + + return pcAction; +} + +void CmdTechDrawExtendShortenLineGroup::languageChange() +{ + Command::languageChange(); + + if (!_pcAction) + return; + Gui::ActionGroup* pcAction = qobject_cast(_pcAction); + QList a = pcAction->actions(); + + QAction* arc1 = a[0]; + arc1->setText(QApplication::translate("TechDraw_Extension","Extend a Line")); + arc1->setToolTip(QApplication::translate("TechDraw_Extension", + "Extend a line at both ends\n\ + - select one cosmetic or centerline\n\ + - click this button")); + arc1->setStatusTip(arc1->toolTip()); + QAction* arc2 = a[1]; + arc2->setText(QApplication::translate("TechDraw_Extension","Shorten a Line")); + arc2->setToolTip(QApplication::translate("TechDraw_Extension", + "Shorten a line at both ends\n\ + - select one cosmetic or centerline\n\ + - click this button")); + arc2->setStatusTip(arc2->toolTip()); +} + +bool CmdTechDrawExtendShortenLineGroup::isActive(void) +{ + bool havePage = DrawGuiUtil::needPage(this); + bool haveView = DrawGuiUtil::needView(this, true); + return (havePage && haveView); +} + //=========================================================================== // internal helper routines //=========================================================================== +bool _checkSel(Gui::Command* cmd, + std::vector& selection, + TechDraw::DrawViewPart*& objFeat, + std::string message){ + // check selection of getSelectionEx() and selection[0].getObject() + bool OK = true; + selection = cmd->getSelection().getSelectionEx(); + if( selection.empty() ) { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr(message.c_str()), + QObject::tr("Selection is empty")); + OK = false; + } + if (OK) { + objFeat = dynamic_cast(selection[0].getObject()); + if( objFeat == nullptr ) { + QMessageBox::warning(Gui::getMainWindow(), + QObject::tr(message.c_str()), + QObject::tr("No object selected")); + OK = false; + } + } + return OK; +} + +std::vector _getVertexPoints(std::vector SubNames,TechDraw::DrawViewPart* objFeat){ + // get vertex points as Vector3d + std::vector vertexPoints; + for (std::string Name : SubNames){ + std::string GeoType = TechDraw::DrawUtil::getGeomTypeFromName(Name); + if (GeoType == "Vertex"){ + int GeoId = TechDraw::DrawUtil::getIndexFromName(Name); + TechDraw::Vertex* vert = objFeat->getProjVertexByIndex(GeoId); + Base::Vector3d onePoint(vert->point().x,vert->point().y,0); + vertexPoints.push_back(onePoint); + } + } + return vertexPoints; +} + +float _getAngle(Base::Vector3d center, Base::Vector3d point){ + // get angle between x-axis and the vector from center to point + const float Pi180 = 180.0/3.14159; + Base::Vector3d vecCP = point-center; + float dy = vecCP.y; + float sign = -1.0; + if (dy < 0.0) + sign = -sign; + float angle = acos(vecCP.Normalize().x)*Pi180*sign; + if (angle < 0.0) + angle = 360+angle; + return angle; +} + +void _intersection(TechDraw::BaseGeom* geom1, TechDraw::BaseGeom* geom2, std::vector& interPoints){ + // find intersection vertex(es) between two edges + #define unknown 0 + #define isLine 1 + #define isCircle 2 + Base::Console().Message("_intersection gestartet\n"); + int edge1(unknown), edge2(unknown); + if (geom1->geomType == TechDraw::CIRCLE || + geom1->geomType == TechDraw::ARCOFCIRCLE) + edge1 = isCircle; + else if (geom1->geomType == TechDraw::GENERIC) + edge1 = isLine; + if (geom2->geomType == TechDraw::CIRCLE || + geom2->geomType == TechDraw::ARCOFCIRCLE) + edge2 = isCircle; + else if (geom2->geomType == TechDraw::GENERIC) + edge2 = isLine; + if (edge1 == isLine && edge2 == isLine) + _intersectionLL(geom1,geom2,interPoints); + else if (edge1 == isCircle && edge2 == isLine) + _intersectionCL(geom1,geom2,interPoints); + else if (edge1 == isLine && edge2 == isCircle) + _intersectionCL(geom2,geom1,interPoints); + else if (edge1 == isCircle && edge2 == isCircle) + _intersectionCC(geom2,geom1,interPoints); +} + +void _intersectionLL(TechDraw::BaseGeom* geom1, TechDraw::BaseGeom* geom2, std::vector& interPoints){ + // find intersection vertex of two lines + // Taken from: + TechDraw::Generic* gen1 = static_cast(geom1); + TechDraw::Generic* gen2 = static_cast(geom2); + Base::Vector3d startPnt1 = gen1->points.at(0); + Base::Vector3d endPnt1 = gen1->points.at(1); + Base::Vector3d startPnt2 = gen2->points.at(0); + Base::Vector3d endPnt2 = gen2->points.at(1); + Base::Vector3d dir1 = endPnt1-startPnt1; + Base::Vector3d dir2 = endPnt2-startPnt2; + float a1 = -dir1.y; + float b1 = dir1.x; + float c1 = -startPnt1.x*dir1.y+startPnt1.y*dir1.x; + float a2 = -dir2.y; + float b2 = dir2.x; + float c2 = -startPnt2.x*dir2.y+startPnt2.y*dir2.x; + float denom = a1*b2-a2*b1; + if (abs(denom)>=0.01){ + float xIntersect = (c1*b2-c2*b1)/denom; + float yIntersect = (a1*c2-a2*c1)/denom; + yIntersect = -yIntersect; + Base::Vector3d interPoint(xIntersect,yIntersect,0.0); + interPoints.push_back(interPoint); + } +} + +void _intersectionCL(TechDraw::BaseGeom* geom1, TechDraw::BaseGeom* geom2, std::vector& interPoints){ + // find intersection vertex(es) between one circle and one line + // Taken from: + TechDraw::Circle* gen1 = static_cast(geom1); + TechDraw::Generic* gen2 = static_cast(geom2); + Base::Vector3d cirleCenter = gen1->center; + Base::Vector3d startPnt = gen2->points.at(0); + Base::Vector3d endPnt = gen2->points.at(1); + Base::Vector3d dir = endPnt-startPnt; + float r0 = gen1->radius; + float x0 = cirleCenter.x; + float y0 = cirleCenter.y; + float a = -dir.y; + float b = dir.x; + float c = -startPnt.x*dir.y+startPnt.y*dir.x; + float d = c-a*x0-b*y0; + float ab = a*a+b*b; + float rootArg = r0*r0*ab-d*d; + if (rootArg > 0){ + if (rootArg < 0.01){ + float x1 = x0+a*d/ab; + float y1 = -y0+b*d/ab; + Base::Vector3d interPoint1(x1,y1,0.0); + interPoints.push_back(interPoint1); + } + else { + float root = sqrt(rootArg); + float x1 = x0+(a*d+b*root)/ab; + float y1 = -y0-(b*d-a*root)/ab; + float x2 = x0+(a*d-b*root)/ab; + float y2 = -y0-(b*d+a*root)/ab; + Base::Vector3d interPoint1(x1,y1,0.0); + interPoints.push_back(interPoint1); + Base::Vector3d interPoint2(x2,y2,0.0); + interPoints.push_back(interPoint2); + } + } +} + +void _intersectionCC(TechDraw::BaseGeom* geom1, TechDraw::BaseGeom* geom2, std::vector& interPoints){ + // find intersection vertex(es) between two circles + // Taken from: + TechDraw::Circle* gen1 = static_cast(geom1); + TechDraw::Circle* gen2 = static_cast(geom2); + Base::Vector3d Center1 = gen1->center; + Base::Vector3d Center2 = gen2->center; + float r1 = gen1->radius; + float r2 = gen2->radius; + float d12 = (Center2-Center1).Length(); + Base::Vector3d m = (Center2-Center1).Normalize(); + Base::Vector3d n(-m.y,m.x,0.0); + float d0 = (r1*r1-r2*r2+d12*d12)/(2*d12); + float rootArg = r1*r1-d0*d0; + if (rootArg > 0){ + if (rootArg < 0.1){ + Base::Vector3d interPoint1 = -Center1+m*d0; + interPoint1.y = -interPoint1.y; + interPoints.push_back(interPoint1); + } + else { + float e0 = sqrt(rootArg); + Base::Vector3d interPoint1 = Center1+m*d0+n*e0; + interPoint1.y = -interPoint1.y; + interPoints.push_back(interPoint1); + Base::Vector3d interPoint2 = Center1+m*d0-n*e0; + interPoint2.y = -interPoint2.y; + interPoints.push_back(interPoint2); + } + } +} + +Base::Vector3d _circleCenter(Base::Vector3d p1, Base::Vector3d p2, Base::Vector3d p3){ + // Circle through 3 points, calculate center point + // copied from ...Sketcher/Gui/CommandCreatGeo.cpp + Base::Vector3d u = p2-p1; + Base::Vector3d v = p3-p2; + Base::Vector3d w = p1-p3; + + double uu = u*u; + double vv = v*v; + double ww = w*w; + + double uv = -(u*v); + double vw = -(v*w); + double uw = -(u*w); + + double w0 = (2 * sqrt(uu * ww - uw * uw) * uw / (uu * ww)); + double w1 = (2 * sqrt(uu * vv - uv * uv) * uv / (uu * vv)); + double w2 = (2 * sqrt(vv * ww - vw * vw) * vw / (vv * ww)); + + double wx = w0 + w1 + w2; + + if( wx == 0) + THROWM(Base::ValueError,"Points are collinear"); + + double x = (w0*p1.x + w1*p2.x + w2*p3.x)/wx; + double y = (w0*p1.y + w1*p2.y + w2*p3.y)/wx; + + return Base::Vector3d(x, y, 0.0); +} + bool _circulation(Base::Vector3d A, Base::Vector3d B, Base::Vector3d C){ // test the circulation of the triangle A-B-C if (A.x*B.y+A.y*C.x+B.x*C.y-C.x*B.y-C.y*A.x-B.x*A.y > 0.0) @@ -390,7 +1852,7 @@ void _createThreadCircle(std::string Name, TechDraw::DrawViewPart* objFeat, floa TechDraw::BaseGeom* threadArc = new TechDraw::AOC(center/scale, radius*factor/scale, 255.0, 165.0); std::string arcTag = objFeat->addCosmeticEdge(threadArc); TechDraw::CosmeticEdge* arc = objFeat->getCosmeticEdge(arcTag); - _setStyleAndWeight(arc,1,0.35f); + _setLineAttributes(arc); } } } @@ -429,8 +1891,8 @@ void _createThreadLines(std::vector SubNames, TechDraw::DrawViewPar std::string line1Tag = objFeat->addCosmeticEdge((start1+delta)/scale, (end1+delta)/scale); TechDraw::CosmeticEdge* cosTag0 = objFeat->getCosmeticEdge(line0Tag); TechDraw::CosmeticEdge* cosTag1 = objFeat->getCosmeticEdge(line1Tag); - _setStyleAndWeight(cosTag0,1,0.35f); - _setStyleAndWeight(cosTag1,1,0.35f); + _setLineAttributes(cosTag0); + _setLineAttributes(cosTag1); } else { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("TechDraw Thread Hole Side"), @@ -440,10 +1902,25 @@ void _createThreadLines(std::vector SubNames, TechDraw::DrawViewPar } } -void _setStyleAndWeight(TechDraw::CosmeticEdge* cosEdge, int style, float weight) { - // set style and weight of a cosmetic edge +void _setLineAttributes(TechDraw::CosmeticEdge* cosEdge) { + // set line attributes of a cosmetic edge + cosEdge->m_format.m_style = activeAttributes.getStyle(); + cosEdge->m_format.m_weight = activeAttributes.getWidthValue(); + cosEdge->m_format.m_color = activeAttributes.getColorValue(); +} + +void _setLineAttributes(TechDraw::CenterLine* cosEdge) { + // set line attributes of a cosmetic edge + cosEdge->m_format.m_style = activeAttributes.getStyle(); + cosEdge->m_format.m_weight = activeAttributes.getWidthValue(); + cosEdge->m_format.m_color = activeAttributes.getColorValue(); +} + +void _setLineAttributes(TechDraw::CosmeticEdge* cosEdge, int style, float weight, App::Color color) { + // set line attributes of a cosmetic edge cosEdge->m_format.m_style = style; cosEdge->m_format.m_weight = weight; + cosEdge->m_format.m_color = color; } //------------------------------------------------------------------------------ @@ -451,7 +1928,24 @@ void CreateTechDrawCommandsExtensions(void) { Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); + rcCmdMgr.addCommand(new CmdTechDrawExtensionSelectLineAttributes()); + rcCmdMgr.addCommand(new CmdTechDrawExtendShortenLineGroup()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionExtendLine()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionShortenLine()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionLockUnlockView()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionPositionSectionView()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionChangeLineAttributes()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionCircleCenterLinesGroup()); rcCmdMgr.addCommand(new CmdTechDrawExtensionCircleCenterLines()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionHoleCircle()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionVertexAtIntersection()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionDrawCirclesGroup()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionDrawCosmCircle()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionArc()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionLinePPGroup()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionLineParallel()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionLinePerpendicular()); + rcCmdMgr.addCommand(new CmdTechDrawExtensionThreadsGroup()); rcCmdMgr.addCommand(new CmdTechDrawExtensionThreadHoleSide()); rcCmdMgr.addCommand(new CmdTechDrawExtensionThreadBoltSide()); rcCmdMgr.addCommand(new CmdTechDrawExtensionThreadHoleBottom()); diff --git a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc index 887953a5dd..2927cf1a7e 100644 --- a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc +++ b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc @@ -27,11 +27,42 @@ icons/TechDraw_3PtAngleDimension.svg icons/TechDraw_DiameterDimension.svg icons/TechDraw_HorizontalDimension.svg + icons/TechDraw_ExtensionSelectLineAttributes.svg + icons/TechDraw_ExtensionExtendLine.svg + icons/TechDraw_ExtensionShortenLine.svg + icons/TechDraw_ExtensionLockUnlockView.svg + icons/TechDraw_ExtensionPositionSectionView.svg + icons/TechDraw_ExtensionChangeLineAttributes.svg + icons/TechDraw_ExtensionPosHorizChainDimension.svg + icons/TechDraw_ExtensionPosVertChainDimension.svg + icons/TechDraw_ExtensionPosObliqueChainDimension.svg + icons/TechDraw_ExtensionCascadeHorizDimension.svg + icons/TechDraw_ExtensionCascadeVertDimension.svg + icons/TechDraw_ExtensionCascadeObliqueDimension.svg icons/TechDraw_ExtensionCircleCenterLines.svg + icons/TechDraw_ExtensionHoleCircle.svg + icons/TechDraw_ExtensionVertexAtIntersection.svg + icons/TechDraw_ExtensionDrawCosmCircle.svg + icons/TechDraw_ExtensionArc.svg + icons/TechDraw_ExtensionLineParallel.svg + icons/TechDraw_ExtensionLinePerpendicular.svg icons/TechDraw_ExtensionThreadHoleSide.svg icons/TechDraw_ExtensionThreadBoltSide.svg icons/TechDraw_ExtensionThreadHoleBottom.svg icons/TechDraw_ExtensionThreadBoltBottom.svg + icons/TechDraw_ExtensionInsertDiameter.svg + icons/TechDraw_ExtensionInsertSquare.svg + icons/TechDraw_ExtensionCreateHorizChainDimension.svg + icons/TechDraw_ExtensionCreateVertChainDimension.svg + icons/TechDraw_ExtensionCreateObliqueChainDimension.svg + icons/TechDraw_ExtensionCreateHorizCoordDimension.svg + icons/TechDraw_ExtensionCreateVertCoordDimension.svg + icons/TechDraw_ExtensionCreateObliqueCoordDimension.svg + icons/TechDraw_ExtensionCreateHorizChamferDimension.svg + icons/TechDraw_ExtensionCreateVertChamferDimension.svg + icons/TechDraw_ExtensionCreateLengthArc.svg + icons/TechDraw_ExtensionIncreaseDecimal.svg + icons/TechDraw_ExtensionDecreaseDecimal.svg icons/TechDraw_LengthDimension.svg icons/TechDraw_RadiusDimension.svg icons/TechDraw_Balloon.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionArc.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionArc.svg new file mode 100644 index 0000000000..efeaa5dfb2 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionArc.svg @@ -0,0 +1,179 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCascadeHorizDimension.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCascadeHorizDimension.svg new file mode 100644 index 0000000000..f48ff73ead --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCascadeHorizDimension.svg @@ -0,0 +1,283 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCascadeObliqueDimension.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCascadeObliqueDimension.svg new file mode 100644 index 0000000000..ed41b63640 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCascadeObliqueDimension.svg @@ -0,0 +1,283 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCascadeVertDimension.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCascadeVertDimension.svg new file mode 100644 index 0000000000..745849c0f6 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCascadeVertDimension.svg @@ -0,0 +1,283 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionChangeLineAttributes.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionChangeLineAttributes.svg new file mode 100644 index 0000000000..07764ad84f --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionChangeLineAttributes.svg @@ -0,0 +1,114 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateHorizChainDimension.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateHorizChainDimension.svg new file mode 100644 index 0000000000..55718dcf11 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateHorizChainDimension.svg @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateHorizChamferDimension.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateHorizChamferDimension.svg new file mode 100644 index 0000000000..05608956d4 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateHorizChamferDimension.svg @@ -0,0 +1,150 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateHorizCoordDimension.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateHorizCoordDimension.svg new file mode 100644 index 0000000000..36c0f3db8a --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateHorizCoordDimension.svg @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateLengthArc.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateLengthArc.svg new file mode 100644 index 0000000000..c883a3979e --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateLengthArc.svg @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateObliqueChainDimension.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateObliqueChainDimension.svg new file mode 100644 index 0000000000..fa28c84cb8 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateObliqueChainDimension.svg @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateObliqueCoordDimension.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateObliqueCoordDimension.svg new file mode 100644 index 0000000000..96963c8e5d --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateObliqueCoordDimension.svg @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateVertChainDimension.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateVertChainDimension.svg new file mode 100644 index 0000000000..6d82d0352b --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateVertChainDimension.svg @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateVertChamferDimension.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateVertChamferDimension.svg new file mode 100644 index 0000000000..b8f99f6e55 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateVertChamferDimension.svg @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateVertCoordDimension.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateVertCoordDimension.svg new file mode 100644 index 0000000000..d513201caf --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionCreateVertCoordDimension.svg @@ -0,0 +1,197 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionDecreaseDecimal.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionDecreaseDecimal.svg new file mode 100644 index 0000000000..256e1d3499 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionDecreaseDecimal.svg @@ -0,0 +1,142 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionDrawCosmCircle.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionDrawCosmCircle.svg new file mode 100644 index 0000000000..94038641d5 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionDrawCosmCircle.svg @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionExtendLine.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionExtendLine.svg new file mode 100644 index 0000000000..353d76107a --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionExtendLine.svg @@ -0,0 +1,167 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionHoleCircle.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionHoleCircle.svg new file mode 100644 index 0000000000..2cfd5a9c56 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionHoleCircle.svg @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionIncreaseDecimal.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionIncreaseDecimal.svg new file mode 100644 index 0000000000..6c4addd4e2 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionIncreaseDecimal.svg @@ -0,0 +1,136 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionInsertDiameter.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionInsertDiameter.svg new file mode 100644 index 0000000000..bba2dc60db --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionInsertDiameter.svg @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionInsertSquare.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionInsertSquare.svg new file mode 100644 index 0000000000..515cb9942f --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionInsertSquare.svg @@ -0,0 +1,165 @@ + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionLineParallel.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionLineParallel.svg new file mode 100644 index 0000000000..adb22a3572 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionLineParallel.svg @@ -0,0 +1,91 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionLinePerpendicular.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionLinePerpendicular.svg new file mode 100644 index 0000000000..66c3b7feea --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionLinePerpendicular.svg @@ -0,0 +1,90 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionLockUnlockView.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionLockUnlockView.svg new file mode 100644 index 0000000000..561204d863 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionLockUnlockView.svg @@ -0,0 +1,252 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPosHorizChainDimension.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPosHorizChainDimension.svg new file mode 100644 index 0000000000..570e6530f0 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPosHorizChainDimension.svg @@ -0,0 +1,135 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPosObliqueChainDimension.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPosObliqueChainDimension.svg new file mode 100644 index 0000000000..4c7e2b3fdc --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPosObliqueChainDimension.svg @@ -0,0 +1,144 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPosVertChainDimension.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPosVertChainDimension.svg new file mode 100644 index 0000000000..c677e380cf --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPosVertChainDimension.svg @@ -0,0 +1,135 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPositionSectionView.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPositionSectionView.svg new file mode 100644 index 0000000000..fd3e4b8e70 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionPositionSectionView.svg @@ -0,0 +1,116 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionSelectLineAttributes.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionSelectLineAttributes.svg new file mode 100644 index 0000000000..2615601bcf --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionSelectLineAttributes.svg @@ -0,0 +1,214 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionShortenLine.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionShortenLine.svg new file mode 100644 index 0000000000..4ee3b822e2 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionShortenLine.svg @@ -0,0 +1,166 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionVertexAtIntersection.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionVertexAtIntersection.svg new file mode 100644 index 0000000000..3e312b9de3 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_ExtensionVertexAtIntersection.svg @@ -0,0 +1,96 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.cpp b/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.cpp new file mode 100644 index 0000000000..8cfc489ce2 --- /dev/null +++ b/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.cpp @@ -0,0 +1,404 @@ +/*************************************************************************** + * Copyright (c) 2021 edi * + * * + * 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_ +#include +#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 +#include + +#include + +#include "DrawGuiStd.h" +#include "PreferencesGui.h" +#include "QGVPage.h" +#include "QGIView.h" +#include "QGIPrimPath.h" +#include "MDIViewPage.h" +#include "ViewProviderPage.h" +#include "ViewProviderViewPart.h" +#include "Rez.h" + +#include "TaskSelectLineAttributes.h" + +using namespace Gui; +using namespace TechDraw; +using namespace TechDrawGui; + +#define solid 1 +#define dashed 2 +#define dotted 3 +#define dashdotted 4 + +//enum EdgeType{solid, dashed, dotted, dashdotted}; +//enum EdgeWidth{small, middle, thick }; +#define small 1 +#define middle 2 +#define thick 3 +//enum EdgeColor{black, grey, red, green, blue, magenta, cyan, yellow}; + +#define black 1 +#define grey 2 +#define red 3 +#define green 4 +#define blue 5 +#define magenta 6 +#define cyan 7 +#define yellow 8 + +//=========================================================================== +// managing global line attributes +//=========================================================================== + +lineAttributes::lineAttributes(void) +{ + style = dotted; + width = middle; + color = black; +} + +void lineAttributes::setStyle(int newStyle) +{ + style = newStyle; +} + +int lineAttributes::getStyle(void) +{ + return style; +} + +void lineAttributes::setWidth(float newWidth) +{ + width = newWidth; +} + +int lineAttributes::getWidth(void) +{ + return width; +} + +float lineAttributes::getWidthValue(void) +{ + switch(width){ + case small: + return 0.18f; + break; + case middle: + return 0.35f; + break; + case thick: + return 0.5f; + break; + default: + return 0.35f; + } +} + +void lineAttributes::setColor(int newColor) +{ + color = newColor; +} + +int lineAttributes::getColor(void) +{ + return color; +} + +App::Color lineAttributes::getColorValue(void) +{ + switch(color){ + case black: + return App::Color(0.0,0.0,0.0); + break; + case grey: + return App::Color(0.7,0.7,0.7); + break; + case red: + return App::Color(1.0,0.0,0.0); + break; + case green: + return App::Color(0.0,1.0,0.0); + break; + case blue: + return App::Color(0.0,0.0,1.0); + break; + case magenta: + return App::Color(1.0,0.0,1.0); + break; + case cyan: + return App::Color(0.0,1.0,1.0); + break; + case yellow: + return App::Color(1.0,1.0,0.0); + break; + default: + return App::Color(0.0,0.0,0.0); + } +} + +//=========================================================================== +// TaskSelectLineAttributes +//=========================================================================== + +TaskSelectLineAttributes::TaskSelectLineAttributes(lineAttributes * ptActiveAttributes) : + ui(new Ui_TaskSelectLineAttributes), + activeAttributes(ptActiveAttributes) + +{ + + ui->setupUi(this); + + setUiEdit(); +} + +TaskSelectLineAttributes::~TaskSelectLineAttributes() +{ + +} + +void TaskSelectLineAttributes::updateTask() +{ +// blockUpdate = true; + +// blockUpdate = false; +} + + +void TaskSelectLineAttributes::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::LanguageChange) { + ui->retranslateUi(this); + } +} + +void TaskSelectLineAttributes::setUiEdit() +{ + setWindowTitle(QObject::tr("Select Line Attributes")); + int lineStyle = activeAttributes->getStyle(); + switch(lineStyle){ + case solid: + ui->rbSolid->setChecked(true); + break; + case dashed: + ui->rbDashed->setChecked(true); + break; + case dotted: + ui->rbDotted->setChecked(true); + break; + case dashdotted: + ui->rbDashDotted->setChecked(true); + break; + default: + ui->rbDashDotted->setChecked(true); + } + + int lineWidth = activeAttributes->getWidth(); + switch(lineWidth){ + case small: + ui->rbThin->setChecked(true); + break; + case middle: + ui->rbMiddle->setChecked(true); + break; + case thick: + ui->rbThick->setChecked(true); + break; + default: + ui->rbMiddle->setChecked(true); + } + + int lineColor = activeAttributes->getColor(); + switch(lineColor){ + case black: + ui->rbBlack->setChecked(true); + break; + case grey: + ui->rbGrey->setChecked(true); + break; + case red: + ui->rbRed->setChecked(true); + break; + case green: + ui->rbGreen->setChecked(true); + break; + case blue: + ui->rbBlue->setChecked(true); + break; + case magenta: + ui->rbMagenta->setChecked(true); + break; + case cyan: + ui->rbCyan->setChecked(true); + break; + case yellow: + ui->rbGreen->setChecked(true); + break; + default: + ui->rbBlack->setChecked(true); + } +} + +bool TaskSelectLineAttributes::accept() +{ + if (ui->rbSolid->isChecked()){ + activeAttributes->setStyle(solid); + } + else if (ui->rbDashed->isChecked()){ + activeAttributes->setStyle(dashed); + } + else if (ui->rbDotted->isChecked()){ + activeAttributes->setStyle(dotted); + } + else if (ui->rbDashDotted->isChecked()){ + activeAttributes->setStyle(dashdotted); + } + else { + activeAttributes->setStyle(dashdotted); + } + + if (ui->rbThin->isChecked()){ + activeAttributes->setWidth(small); + } + else if (ui->rbMiddle->isChecked()){ + activeAttributes->setWidth(middle); + } + else if (ui->rbThick->isChecked()){ + activeAttributes->setWidth(thick); + } + else { + activeAttributes->setWidth(middle); + } + + if (ui->rbBlack->isChecked()){ + activeAttributes->setColor(black); + } + else if (ui->rbGrey->isChecked()){ + activeAttributes->setColor(grey); + } + else if (ui->rbRed->isChecked()){ + activeAttributes->setColor(red); + } + else if (ui->rbGreen->isChecked()){ + activeAttributes->setColor(green); + } + else if (ui->rbBlue->isChecked()){ + activeAttributes->setColor(blue); + } + else if (ui->rbMagenta->isChecked()){ + activeAttributes->setColor(magenta); + } + else if (ui->rbCyan->isChecked()){ + activeAttributes->setColor(cyan); + } + else if (ui->rbYellow->isChecked()){ + activeAttributes->setColor(yellow); + } + else { + activeAttributes->setColor(black); + } + + return true; +} + +bool TaskSelectLineAttributes::reject() +{ + //there's nothing to do. + Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + return false; +} + +//=========================================================================== +// TaskDlgSelectLineAttributes +//=========================================================================== + +TaskDlgSelectLineAttributes::TaskDlgSelectLineAttributes(lineAttributes * ptActiveAttributes) + : TaskDialog() +{ + widget = new TaskSelectLineAttributes(ptActiveAttributes); + taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("TechDraw_ExtensionSelectLineAttributes"), + widget->windowTitle(), true, 0); + taskbox->groupLayout()->addWidget(widget); + Content.push_back(taskbox); +} + +TaskDlgSelectLineAttributes::~TaskDlgSelectLineAttributes() +{ +} + +void TaskDlgSelectLineAttributes::update() +{ +// widget->updateTask(); +} + +//==== calls from the TaskView =============================================================== +void TaskDlgSelectLineAttributes::open() +{ +} + +void TaskDlgSelectLineAttributes::clicked(int) +{ +} + +bool TaskDlgSelectLineAttributes::accept() +{ + widget->accept(); + return true; +} + +bool TaskDlgSelectLineAttributes::reject() +{ + widget->reject(); + return true; +} + + +#include \ No newline at end of file diff --git a/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.h b/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.h new file mode 100644 index 0000000000..dbd51da5cc --- /dev/null +++ b/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.h @@ -0,0 +1,143 @@ +/*************************************************************************** + * Copyright (c) 2021 edi * + * * + * 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_TASKSELECTLINEATTRIBUTES_H +#define TECHDRAWGUI_TASKSELECTLINEATTRIBUTES_H + +#include +#include +#include +#include + +#include + +#include + +class Ui_TaskSelectLineAttributes; + +namespace App { +class DocumentObject; +} + +namespace TechDraw +{ +class DrawPage; +class DrawView; +class DrawViewPart; +class CosmeticEdge; +class LineFormat; +} + +namespace TechDraw +{ +class Face; +} + +namespace TechDrawGui +{ +class QGVPage; +class QGIView; +class QGIPrimPath; +class MDIViewPage; +class ViewProviderViewPart; + +class lineAttributes { + int style; + int width; + int color; + + public: + + lineAttributes(void); + void setStyle(int); + int getStyle(void); + void setWidth(float); + int getWidth(void); + float getWidthValue(void); + void setColor(int); + int getColor(void); + App::Color getColorValue(void); + +}; // class lineAttributes + +class TaskSelectLineAttributes : public QWidget +{ + Q_OBJECT + +public: + TaskSelectLineAttributes(lineAttributes * ptActiveAttributes); + ~TaskSelectLineAttributes(); + +public Q_SLOTS: + +public: + virtual bool accept(); + virtual bool reject(); + void updateTask(); + lineAttributes* activeAttributes; + +protected Q_SLOTS: + +protected: + void changeEvent(QEvent *e); + + void setUiEdit(void); + +private: + std::unique_ptr ui; + +}; // class TaskSelectLineAttributes + +class TaskDlgSelectLineAttributes : public Gui::TaskView::TaskDialog +{ + Q_OBJECT + +public: + TaskDlgSelectLineAttributes(lineAttributes * ptActiveAttributes); + ~TaskDlgSelectLineAttributes(); + +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(); + +protected: + +private: + TaskSelectLineAttributes* widget; + + Gui::TaskView::TaskBox* taskbox; +}; // class TaskDlgSelectLineAttributes + +} // namespace TechDrawGui + +#endif // #ifndef TECHDRAWGUI_TASKSELECTLINEATTRIBUTES_H diff --git a/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.ui b/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.ui new file mode 100644 index 0000000000..0397a4b81a --- /dev/null +++ b/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.ui @@ -0,0 +1,321 @@ + + + TechDrawGui::TaskSelectLineAttributes + + + + 0 + 0 + 350 + 331 + + + + + 0 + 0 + + + + + 250 + 0 + + + + Line attributes + + + + #+++++++++++++++++++++++++++++++++++++++++++++ + + + + + Linestyles: + + + + #------------------------- + + + + solid + + + true + + + Set Line style to solid + + + bgLineStyles + + + + #------------------------------------ + + + + dashed + + + true + + + bgLineStyles + + + + #------------------------------------ + + + + dotted + + + true + + + bgLineStyles + + + + #------------------------------------- + + + + dash dotted + + + true + + + true + + + bgLineStyles + + + + #-------------------------------------- + # lineStyles + + ############################################ + + #---------------------------------------------- + + + + + Lineswidth: + + + + #------------------------- + + + + small + + + true + + + bgLineWidth + + + + #------------------------------------ + + + + middle + + + true + + + true + + + bgLineWidth + + + + #------------------------------------ + + + + thick + + + true + + + bgLineWidth + + + + # lineWidth + + ############################################ + + #---------------------------------------------- + + + + + Linecolors: + + + + #------------------------- + + + + black + + + true + + + true + + + bgLineColor + + + + #------------------------- + + + + blue + + + true + + + bgLineColor + + + + #------------------------------------ + + + + grey + + + true + + + bgLineColor + + + + #------------------------------------ + + + + magenta + + + true + + + bgLineColor + + + + #------------------------------------ + + + + red + + + true + + + bgLineColor + + + + #------------------------------------ + + + + cyan + + + true + + + bgLineColor + + + + #------------------------------------ + + + + green + + + true + + + bgLineColor + + + + #------------------------------------ + + + + yellow + + + true + + + bgLineColor + + + + # lineWidth + + ############################################ + # QVBoxLayout + + + + + true + + + + + true + + + + + true + + + + + + Gui::QuantitySpinBox + QWidget +
Gui/QuantitySpinBox.h
+
+
+ + + + +
diff --git a/src/Mod/TechDraw/Gui/Workbench.cpp b/src/Mod/TechDraw/Gui/Workbench.cpp index fea254971a..40408cce24 100644 --- a/src/Mod/TechDraw/Gui/Workbench.cpp +++ b/src/Mod/TechDraw/Gui/Workbench.cpp @@ -83,14 +83,53 @@ Gui::MenuItem* Workbench::setupMenuBar() const *dimensions << "TechDraw_LinkDimension"; *dimensions << "TechDraw_LandmarkDimension"; - // toolattributes + // extension: attributes and modifications Gui::MenuItem* toolattrib = new Gui::MenuItem; - toolattrib->setCommand("Extensions: Centerlines/Threading"); - *toolattrib << "TechDraw_ExtensionCircleCenterLines"; - *toolattrib << "TechDraw_ExtensionThreadHoleSide"; - *toolattrib << "TechDraw_ExtensionThreadBoltSide"; - *toolattrib << "TechDraw_ExtensionThreadHoleBottom"; - *toolattrib << "TechDraw_ExtensionThreadBoltBottom"; + toolattrib->setCommand("Extensions: attributes and modifications"); + *toolattrib << "TechDraw_ExtensionSelectLineAttributes"; + *toolattrib << "TechDraw_ExtensionExtendLine"; + *toolattrib << "TechDraw_ExtensionShortenLine"; + *toolattrib << "TechDraw_ExtensionLockUnlockView"; + *toolattrib << "TechDraw_ExtensionPositionSectionView"; + *toolattrib << "TechDraw_ExtensionChangeLineAttributes"; + *toolattrib << "TechDraw_ExtensionPosHorizChainDimension"; + *toolattrib << "TechDraw_ExtensionPosVertChainDimension"; + *toolattrib << "TechDraw_ExtensionPosObliqueChainDimension"; + *toolattrib << "TechDraw_ExtensionCascadeHorizDimension"; + *toolattrib << "TechDraw_ExtensionCascadeVertDimension"; + *toolattrib << "TechDraw_ExtensionCascadeObliqueDimension"; + + // extension: centerlines and threading + Gui::MenuItem* toolcenter = new Gui::MenuItem; + toolcenter->setCommand("Extensions: centerlines and threading"); + *toolcenter << "TechDraw_ExtensionCircleCenterLines"; + *toolcenter << "TechDraw_ExtensionHoleCircle"; + *toolcenter << "TechDraw_ExtensionVertexAtIntersection"; + *toolcenter << "TechDraw_ExtensionDrawCosmCircle"; + *toolcenter << "TechDraw_ExtensionArc"; + *toolcenter << "TechDraw_ExtensionLineParallel"; + *toolcenter << "TechDraw_ExtensionLinePerpendicular"; + *toolcenter << "TechDraw_ExtensionThreadHoleSide"; + *toolcenter << "TechDraw_ExtensionThreadBoltSide"; + *toolcenter << "TechDraw_ExtensionThreadHoleBottom"; + *toolcenter << "TechDraw_ExtensionThreadBoltBottom"; + + // extension: dimensions + Gui::MenuItem* tooldimensions = new Gui::MenuItem; + tooldimensions->setCommand("Extensions: dimensions"); + *tooldimensions << "TechDraw_ExtensionInsertDiameter"; + *tooldimensions << "TechDraw_ExtensionInsertSquare"; + *tooldimensions << "TechDraw_ExtensionCreateHorizChainDimension"; + *tooldimensions << "TechDraw_ExtensionCreateVertChainDimension"; + *tooldimensions << "TechDraw_ExtensionCreateObliqueChainDimension"; + *tooldimensions << "TechDraw_ExtensionCreateHorizCoordDimension"; + *tooldimensions << "TechDraw_ExtensionCreateVertCoordDimension"; + *tooldimensions << "TechDraw_ExtensionCreateObliqueCoordDimension"; + *tooldimensions << "TechDraw_ExtensionCreateHorizChamferDimension"; + *tooldimensions << "TechDraw_ExtensionCreateVertChamferDimension"; + *tooldimensions << "TechDraw_ExtensionCreateLengthArc"; + *tooldimensions << "TechDraw_ExtensionIncreaseDecimal"; + *tooldimensions << "TechDraw_ExtensionDecreaseDecimal"; // annotations Gui::MenuItem* annotations = new Gui::MenuItem; @@ -137,6 +176,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const *draw << "Separator"; *draw << dimensions; *draw << toolattrib; + *draw << toolcenter; + *draw << tooldimensions; *draw << "Separator"; *draw << "TechDraw_ExportPageSVG"; *draw << "TechDraw_ExportPageDXF"; @@ -200,13 +241,62 @@ Gui::ToolBarItem* Workbench::setupToolBars() const *dims << "TechDraw_LandmarkDimension"; // *dims << "TechDraw_Dimension" - Gui::ToolBarItem *attribs = new Gui::ToolBarItem(root); - attribs->setCommand("TechDraw Tool Attributes"); - *attribs << "TechDraw_ExtensionCircleCenterLines"; - *attribs << "TechDraw_ExtensionThreadHoleSide"; - *attribs << "TechDraw_ExtensionThreadBoltSide"; - *attribs << "TechDraw_ExtensionThreadHoleBottom"; - *attribs << "TechDraw_ExtensionThreadBoltBottom"; + Gui::ToolBarItem *extattribs = new Gui::ToolBarItem(root); + extattribs->setCommand("TechDraw Attributes"); + *extattribs << "TechDraw_ExtensionSelectLineAttributes"; + *extattribs << "TechDraw_ExtensionExtendShortenLineGroup"; +// *extattribs << "TechDraw_ExtensionExtendLine"; +// *extattribs << "TechDraw_ExtensionShortenLine"; + *extattribs << "TechDraw_ExtensionLockUnlockView"; + *extattribs << "TechDraw_ExtensionPositionSectionView"; + *extattribs << "TechDraw_ExtensionChangeLineAttributes"; + *extattribs << "TechDraw_ExtensionPosChainDimensionGroup"; +// *extattribs << "TechDraw_ExtensionPosHorizChainDimension"; +// *extattribs << "TechDraw_ExtensionPosVertChainDimension"; +// *extattribs << "TechDraw_ExtensionPosObliqueChainDimension"; + *extattribs << "TechDraw_ExtensionCascadeDimensionGroup"; +// *extattribs << "TechDraw_ExtensionCascadeHorizDimension"; +// *extattribs << "TechDraw_ExtensionCascadeVertDimension"; +// *extattribs << "TechDraw_ExtensionCascadeObliqueDimension"; + + Gui::ToolBarItem *extcenter = new Gui::ToolBarItem(root); + extcenter->setCommand("TechDraw Centerlines"); + *extcenter << "TechDraw_ExtensionCircleCenterLinesGroup"; +// *extcenter << "TechDraw_ExtensionCircleCenterLines"; +// *extcenter << "TechDraw_ExtensionHoleCircle"; + *extcenter << "TechDraw_ExtensionVertexAtIntersection"; + *extcenter << "TechDraw_ExtensionDrawCirclesGroup"; +// *extcenter << "TechDraw_ExtensionDrawCosmCircle"; +// *extcenter << "TechDraw_ExtensionArc"; + *extcenter << "TechDraw_ExtensionLinePPGroup"; +// *extcenter << "TechDraw_ExtensionLineParallel"; +// *extcenter << "TechDraw_ExtensionLinePerpendicular"; + *extcenter << "TechDraw_ExtensionThreadsGroup"; +// *extcenter << "TechDraw_ExtensionThreadHoleSide"; +// *extcenter << "TechDraw_ExtensionThreadHoleBottom"; +// *extcenter << "TechDraw_ExtensionThreadBoltSide"; +// *extcenter << "TechDraw_ExtensionThreadBoltBottom"; + + Gui::ToolBarItem *extdimensions = new Gui::ToolBarItem(root); + extdimensions->setCommand("TechDraw Extend Dimensions"); + *extdimensions << "TechDraw_ExtensionInsertPraefixGroup"; +// *extdimensions << "TechDraw_ExtensionInsertDiameter"; +// *extdimensions << "TechDraw_ExtensionInsertSquare"; + *extdimensions << "TechDraw_ExtensionCreateChainDimensionGroup"; +// *extdimensions << "TechDraw_ExtensionCreateHorizChainDimension"; +// *extdimensions << "TechDraw_ExtensionCreateVertChainDimension"; +// *extdimensions << "TechDraw_ExtensionCreateObliqueChainDimension"; + *extdimensions << "TechDraw_ExtensionCreateCoordDimensionGroup"; +// *extdimensions << "TechDraw_ExtensionCreateHorizCoordDimension"; +// *extdimensions << "TechDraw_ExtensionCreateVertCoordDimension"; +// *extdimensions << "TechDraw_ExtensionCreateObliqueCoordDimension"; + *extdimensions << "TechDraw_ExtensionChamferDimensionGroup"; +// *extdimensions << "TechDraw_ExtensionCreateHorizChamferDimension"; +// *extdimensions << "TechDraw_ExtensionCreateVertChamferDimension"; + *extdimensions << "TechDraw_ExtensionCreateLengthArc"; + *extdimensions << "TechDraw_ExtensionIncreaseDecreaseGroup"; +// *extdimensions << "TechDraw_ExtensionIncreaseDecimal"; +// *extdimensions << "TechDraw_ExtensionDecreaseDecimal"; Gui::ToolBarItem *file = new Gui::ToolBarItem(root); file->setCommand("TechDraw File Access"); @@ -282,14 +372,62 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const *dims << "TechDraw_LandmarkDimension"; // *dims << "TechDraw_Dimension"; - Gui::ToolBarItem *attribs = new Gui::ToolBarItem(root); - attribs->setCommand("TechDraw Tool Attributes"); - *attribs << "TechDraw_ExtensionCircleCenterLines"; - *attribs << "TechDraw_ExtensionThreadHoleSide"; - *attribs << "TechDraw_ExtensionThreadBoltSide"; - *attribs << "TechDraw_ExtensionThreadHoleBottom"; - *attribs << "TechDraw_ExtensionThreadBoltBottom"; + Gui::ToolBarItem *extattribs = new Gui::ToolBarItem(root); + extattribs->setCommand("TechDraw Attributes"); + *extattribs << "TechDraw_ExtensionSelectLineAttributes"; + *extattribs << "TechDraw_ExtensionExtendShortenLineGroup"; +// *extattribs << "TechDraw_ExtensionExtendLine"; +// *extattribs << "TechDraw_ExtensionShortenLine"; + *extattribs << "TechDraw_ExtensionLockUnlockView"; + *extattribs << "TechDraw_ExtensionPositionSectionView"; + *extattribs << "TechDraw_ExtensionChangeLineAttributes"; + *extattribs << "TechDraw_ExtensionPosChainDimensionGroup"; +// *extattribs << "TechDraw_ExtensionPosHorizChainDimension"; +// *extattribs << "TechDraw_ExtensionPosVertChainDimension"; +// *extattribs << "TechDraw_ExtensionPosObliqueChainDimension"; + *extattribs << "TechDraw_ExtensionCascadeDimensionGroup"; +// *extattribs << "TechDraw_ExtensionCascadeHorizDimension"; +// *extattribs << "TechDraw_ExtensionCascadeVertDimension"; +// *extattribs << "TechDraw_ExtensionCascadeObliqueDimension"; + Gui::ToolBarItem *extcenter = new Gui::ToolBarItem(root); + extcenter->setCommand("TechDraw Centerlines"); + *extcenter << "TechDraw_ExtensionCircleCenterLinesGroup"; +// *extcenter << "TechDraw_ExtensionCircleCenterLines"; +// *extcenter << "TechDraw_ExtensionHoleCircle"; + *extcenter << "TechDraw_ExtensionVertexAtIntersection"; + *extcenter << "TechDraw_ExtensionDrawCirclesGroup"; +// *extcenter << "TechDraw_ExtensionDrawCosmCircle"; +// *extcenter << "TechDraw_ExtensionArc"; + *extcenter << "TechDraw_ExtensionLinePPGroup"; +// *extcenter << "TechDraw_ExtensionLineParallel"; +// *extcenter << "TechDraw_ExtensionLinePerpendicular"; + *extcenter << "TechDraw_ExtensionThreadsGroup"; +// *extcenter << "TechDraw_ExtensionThreadHoleSide"; +// *extcenter << "TechDraw_ExtensionThreadHoleBottom"; +// *extcenter << "TechDraw_ExtensionThreadBoltSide"; +// *extcenter << "TechDraw_ExtensionThreadBoltBottom"; + + Gui::ToolBarItem *extdimensions = new Gui::ToolBarItem(root); + extdimensions->setCommand("TechDraw Extend Dimensions"); + *extdimensions << "TechDraw_ExtensionInsertPraefixGroup"; +// *extdimensions << "TechDraw_ExtensionInsertDiameter"; +// *extdimensions << "TechDraw_ExtensionInsertSquare"; + *extdimensions << "TechDraw_ExtensionCreateChainDimensionGroup"; +// *extdimensions << "TechDraw_ExtensionCreateHorizChainDimension"; +// *extdimensions << "TechDraw_ExtensionCreateVertChainDimension"; +// *extdimensions << "TechDraw_ExtensionCreateObliqueChainDimension"; + *extdimensions << "TechDraw_ExtensionCreateCoordDimensionGroup"; +// *extdimensions << "TechDraw_ExtensionCreateHorizCoordDimension"; +// *extdimensions << "TechDraw_ExtensionCreateVertCoordDimension"; +// *extdimensions << "TechDraw_ExtensionCreateObliqueCoordDimension"; + *extdimensions << "TechDraw_ExtensionChamferDimensionGroup"; +// *extdimensions << "TechDraw_ExtensionCreateHorizChamferDimension"; +// *extdimensions << "TechDraw_ExtensionCreateVertChamferDimension"; + *extdimensions << "TechDraw_ExtensionCreateLengthArc"; + *extdimensions << "TechDraw_ExtensionIncreaseDecreaseGroup"; +// *extdimensions << "TechDraw_ExtensionIncreaseDecimal"; +// *extdimensions << "TechDraw_ExtensionDecreaseDecimal"; Gui::ToolBarItem *file = new Gui::ToolBarItem(root); file->setCommand("TechDraw File Access");