Merge pull request #9703 from FlachyJoe/arc_helper_gui

Sketcher: Add command to switch arc helpers
This commit is contained in:
sliptonic
2023-08-21 11:20:16 -05:00
committed by GitHub
15 changed files with 883 additions and 362 deletions

View File

@@ -47,6 +47,7 @@ void CreateSketcherCommandsConstraints();
void CreateSketcherCommandsConstraintAccel();
void CreateSketcherCommandsAlterGeo();
void CreateSketcherCommandsBSpline();
void CreateSketcherCommandsOverlay();
void CreateSketcherCommandsVirtualSpace();
void loadSketcherResource()
@@ -108,6 +109,7 @@ PyMOD_INIT_FUNC(SketcherGui)
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/pointers"));
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/splines"));
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/tools"));
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/overlay"));
// instantiating the commands
CreateSketcherCommands();
@@ -116,6 +118,7 @@ PyMOD_INIT_FUNC(SketcherGui)
CreateSketcherCommandsAlterGeo();
CreateSketcherCommandsConstraintAccel();
CreateSketcherCommandsBSpline();
CreateSketcherCommandsOverlay();
CreateSketcherCommandsVirtualSpace();
SketcherGui::Workbench::init();

View File

@@ -84,6 +84,7 @@ SET(SketcherGui_SRCS
CommandConstraints.cpp
CommandSketcherTools.cpp
CommandSketcherBSpline.cpp
CommandSketcherOverlay.cpp
CommandSketcherVirtualSpace.cpp
CommandAlterGeometry.cpp
Resources/Sketcher.qrc

View File

@@ -49,28 +49,6 @@ using namespace std;
using namespace SketcherGui;
using namespace Sketcher;
bool isSketcherBSplineActive(Gui::Document* doc, bool actsOnSelection)
{
if (doc) {
// checks if a Sketch Viewprovider is in Edit and is in no special mode
if (doc->getInEdit()
&& doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) {
if (static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit())->getSketchMode()
== ViewProviderSketch::STATUS_NONE) {
if (!actsOnSelection) {
return true;
}
else if (Gui::Selection().countObjectsOfType(
Sketcher::SketchObject::getClassTypeId())
> 0) {
return true;
}
}
}
}
return false;
}
void ActivateBSplineHandler(Gui::Document* doc, DrawSketchHandler* handler)
{
std::unique_ptr<DrawSketchHandler> ptr(handler);
@@ -85,14 +63,6 @@ void ActivateBSplineHandler(Gui::Document* doc, DrawSketchHandler* handler)
}
}
void ShowRestoreInformationLayer(const char* visibleelementname)
{
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Sketcher/General");
bool status = hGrp->GetBool(visibleelementname, true);
hGrp->SetBool(visibleelementname, !status);
}
/// For a knot given by (GeoId, PosId) finds the B-Spline and the knot's
/// index within it (by OCC numbering).
/// Returns true if the entities are found, false otherwise.
@@ -131,301 +101,6 @@ bool findBSplineAndKnotIndex(Sketcher::SketchObject* Obj, int knotGeoId,
return false;
}
// Show/Hide B-spline degree
DEF_STD_CMD_A(CmdSketcherBSplineDegree)
CmdSketcherBSplineDegree::CmdSketcherBSplineDegree()
: Command("Sketcher_BSplineDegree")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Show/hide B-spline degree");
sToolTipText = QT_TR_NOOP("Switches between showing and hiding the degree for all B-splines");
sWhatsThis = "Sketcher_BSplineDegree";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_BSplineDegree";
sAccel = "";
eType = ForEdit;
}
void CmdSketcherBSplineDegree::activated(int iMsg)
{
Q_UNUSED(iMsg);
ShowRestoreInformationLayer("BSplineDegreeVisible");
}
bool CmdSketcherBSplineDegree::isActive()
{
return isSketcherBSplineActive(getActiveGuiDocument(), false);
}
// Show/Hide B-spline polygon
DEF_STD_CMD_A(CmdSketcherBSplinePolygon)
CmdSketcherBSplinePolygon::CmdSketcherBSplinePolygon()
: Command("Sketcher_BSplinePolygon")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Show/hide B-spline control polygon");
sToolTipText =
QT_TR_NOOP("Switches between showing and hiding the control polygons for all B-splines");
sWhatsThis = "Sketcher_BSplinePolygon";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_BSplinePolygon";
sAccel = "";
eType = ForEdit;
}
void CmdSketcherBSplinePolygon::activated(int iMsg)
{
Q_UNUSED(iMsg);
ShowRestoreInformationLayer("BSplineControlPolygonVisible");
}
bool CmdSketcherBSplinePolygon::isActive()
{
return isSketcherBSplineActive(getActiveGuiDocument(), false);
}
// Show/Hide B-spline comb
DEF_STD_CMD_A(CmdSketcherBSplineComb)
CmdSketcherBSplineComb::CmdSketcherBSplineComb()
: Command("Sketcher_BSplineComb")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Show/hide B-spline curvature comb");
sToolTipText =
QT_TR_NOOP("Switches between showing and hiding the curvature comb for all B-splines");
sWhatsThis = "Sketcher_BSplineComb";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_BSplineComb";
sAccel = "";
eType = ForEdit;
}
void CmdSketcherBSplineComb::activated(int iMsg)
{
Q_UNUSED(iMsg);
ShowRestoreInformationLayer("BSplineCombVisible");
}
bool CmdSketcherBSplineComb::isActive()
{
return isSketcherBSplineActive(getActiveGuiDocument(), false);
}
//
DEF_STD_CMD_A(CmdSketcherBSplineKnotMultiplicity)
CmdSketcherBSplineKnotMultiplicity::CmdSketcherBSplineKnotMultiplicity()
: Command("Sketcher_BSplineKnotMultiplicity")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Show/hide B-spline knot multiplicity");
sToolTipText =
QT_TR_NOOP("Switches between showing and hiding the knot multiplicity for all B-splines");
sWhatsThis = "Sketcher_BSplineKnotMultiplicity";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_BSplineKnotMultiplicity";
sAccel = "";
eType = ForEdit;
}
void CmdSketcherBSplineKnotMultiplicity::activated(int iMsg)
{
Q_UNUSED(iMsg);
ShowRestoreInformationLayer("BSplineKnotMultiplicityVisible");
}
bool CmdSketcherBSplineKnotMultiplicity::isActive()
{
return isSketcherBSplineActive(getActiveGuiDocument(), false);
}
//
DEF_STD_CMD_A(CmdSketcherBSplinePoleWeight)
CmdSketcherBSplinePoleWeight::CmdSketcherBSplinePoleWeight()
: Command("Sketcher_BSplinePoleWeight")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Show/hide B-spline control point weight");
sToolTipText = QT_TR_NOOP(
"Switches between showing and hiding the control point weight for all B-splines");
sWhatsThis = "Sketcher_BSplinePoleWeight";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_BSplinePoleWeight";
sAccel = "";
eType = ForEdit;
}
void CmdSketcherBSplinePoleWeight::activated(int iMsg)
{
Q_UNUSED(iMsg);
ShowRestoreInformationLayer("BSplinePoleWeightVisible");
}
bool CmdSketcherBSplinePoleWeight::isActive()
{
return isSketcherBSplineActive(getActiveGuiDocument(), false);
}
// Composite drop down menu for show/hide geometry information layer
DEF_STD_CMD_ACLU(CmdSketcherCompBSplineShowHideGeometryInformation)
CmdSketcherCompBSplineShowHideGeometryInformation::
CmdSketcherCompBSplineShowHideGeometryInformation()
: Command("Sketcher_CompBSplineShowHideGeometryInformation")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Show/hide B-spline information layer");
sToolTipText = sMenuText;
sWhatsThis = "Sketcher_CompBSplineShowHideGeometryInformation";
sStatusTip = sToolTipText;
eType = ForEdit;
}
void CmdSketcherCompBSplineShowHideGeometryInformation::activated(int iMsg)
{
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
Gui::Command* cmd;
if (iMsg == 0) {
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineDegree");
}
else if (iMsg == 1) {
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplinePolygon");
}
else if (iMsg == 2) {
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineComb");
}
else if (iMsg == 3) {
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineKnotMultiplicity");
}
else if (iMsg == 4) {
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplinePoleWeight");
}
else {
return;
}
cmd->invoke(0);
// Since the default icon is reset when enabling/disabling the command we have
// to explicitly set the icon of the used command.
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
QList<QAction*> a = pcAction->actions();
assert(iMsg < a.size());
pcAction->setIcon(a[iMsg]->icon());
// we must also set the tooltip of the used command
pcAction->setToolTip(a[iMsg]->toolTip());
}
Gui::Action* CmdSketcherCompBSplineShowHideGeometryInformation::createAction()
{
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
pcAction->setDropDownMenu(true);
applyCommandData(this->className(), pcAction);
QAction* c1 = pcAction->addAction(QString());
c1->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplineDegree"));
QAction* c2 = pcAction->addAction(QString());
c2->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplinePolygon"));
QAction* c3 = pcAction->addAction(QString());
c3->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplineComb"));
QAction* c4 = pcAction->addAction(QString());
c4->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplineKnotMultiplicity"));
QAction* c5 = pcAction->addAction(QString());
c5->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplinePoleWeight"));
_pcAction = pcAction;
languageChange();
pcAction->setIcon(c2->icon());
int defaultId = 1;
pcAction->setProperty("defaultAction", QVariant(defaultId));
return pcAction;
}
void CmdSketcherCompBSplineShowHideGeometryInformation::languageChange()
{
Command::languageChange();
if (!_pcAction) {
return;
}
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
QList<QAction*> a = pcAction->actions();
QAction* c1 = a[0];
c1->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation",
"Show/hide B-spline degree"));
c1->setToolTip(QApplication::translate(
"Sketcher_BSplineDegree",
"Switches between showing and hiding the degree for all B-splines"));
c1->setStatusTip(QApplication::translate(
"Sketcher_BSplineDegree",
"Switches between showing and hiding the degree for all B-splines"));
QAction* c2 = a[1];
c2->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation",
"Show/hide B-spline control polygon"));
c2->setToolTip(QApplication::translate(
"Sketcher_BSplinePolygon",
"Switches between showing and hiding the control polygons for all B-splines"));
c2->setStatusTip(QApplication::translate(
"Sketcher_BSplinePolygon",
"Switches between showing and hiding the control polygons for all B-splines"));
QAction* c3 = a[2];
c3->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation",
"Show/hide B-spline curvature comb"));
c3->setToolTip(QApplication::translate(
"Sketcher_BSplineComb",
"Switches between showing and hiding the curvature comb for all B-splines"));
c3->setStatusTip(QApplication::translate(
"Sketcher_BSplineComb",
"Switches between showing and hiding the curvature comb for all B-splines"));
QAction* c4 = a[3];
c4->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation",
"Show/hide B-spline knot multiplicity"));
c4->setToolTip(QApplication::translate(
"Sketcher_BSplineKnotMultiplicity",
"Switches between showing and hiding the knot multiplicity for all B-splines"));
c4->setStatusTip(QApplication::translate(
"Sketcher_BSplineKnotMultiplicity",
"Switches between showing and hiding the knot multiplicity for all B-splines"));
QAction* c5 = a[4];
c5->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation",
"Show/hide B-spline control point weight"));
c5->setToolTip(QApplication::translate(
"Sketcher_BSplinePoleWeight",
"Switches between showing and hiding the control point weight for all B-splines"));
c5->setStatusTip(QApplication::translate(
"Sketcher_BSplinePoleWeight",
"Switches between showing and hiding the control point weight for all B-splines"));
}
void CmdSketcherCompBSplineShowHideGeometryInformation::updateAction(int /*mode*/)
{}
bool CmdSketcherCompBSplineShowHideGeometryInformation::isActive()
{
return isSketcherBSplineActive(getActiveGuiDocument(), false);
}
// Convert to NURBS
DEF_STD_CMD_A(CmdSketcherConvertToNURBS)
@@ -1403,12 +1078,6 @@ void CreateSketcherCommandsBSpline()
{
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
rcCmdMgr.addCommand(new CmdSketcherBSplineDegree());
rcCmdMgr.addCommand(new CmdSketcherBSplinePolygon());
rcCmdMgr.addCommand(new CmdSketcherBSplineComb());
rcCmdMgr.addCommand(new CmdSketcherBSplineKnotMultiplicity());
rcCmdMgr.addCommand(new CmdSketcherBSplinePoleWeight());
rcCmdMgr.addCommand(new CmdSketcherCompBSplineShowHideGeometryInformation());
rcCmdMgr.addCommand(new CmdSketcherConvertToNURBS());
rcCmdMgr.addCommand(new CmdSketcherIncreaseDegree());
rcCmdMgr.addCommand(new CmdSketcherDecreaseDegree());

View File

@@ -0,0 +1,389 @@
/***************************************************************************
* Copyright (c) 2023 Florian Foinant-Willig <flachyjoe@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <Inventor/SbString.h>
#include <QApplication>
#include <cfloat>
#endif
#include <App/Application.h>
#include <Base/Console.h>
#include <Gui/Action.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/CommandT.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/Notifications.h>
#include <Gui/Selection.h>
#include <Gui/SelectionObject.h>
#include <Mod/Sketcher/App/SketchObject.h>
#include "DrawSketchHandler.h"
#include "Utils.h"
#include "ViewProviderSketch.h"
using namespace std;
using namespace SketcherGui;
using namespace Sketcher;
void ShowRestoreInformationLayer(const char* visibleelementname)
{
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
"User parameter:BaseApp/Preferences/Mod/Sketcher/General");
bool status = hGrp->GetBool(visibleelementname, true);
hGrp->SetBool(visibleelementname, !status);
}
// Show/Hide B-spline degree
DEF_STD_CMD_A(CmdSketcherBSplineDegree)
CmdSketcherBSplineDegree::CmdSketcherBSplineDegree()
: Command("Sketcher_BSplineDegree")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Show/hide B-spline degree");
sToolTipText = QT_TR_NOOP("Switches between showing and hiding the degree for all B-splines");
sWhatsThis = "Sketcher_BSplineDegree";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_BSplineDegree";
sAccel = "";
eType = ForEdit;
}
void CmdSketcherBSplineDegree::activated(int iMsg)
{
Q_UNUSED(iMsg);
ShowRestoreInformationLayer("BSplineDegreeVisible");
}
bool CmdSketcherBSplineDegree::isActive()
{
return isSketcherBSplineActive(getActiveGuiDocument(), false);
}
// Show/Hide B-spline polygon
DEF_STD_CMD_A(CmdSketcherBSplinePolygon)
CmdSketcherBSplinePolygon::CmdSketcherBSplinePolygon()
: Command("Sketcher_BSplinePolygon")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Show/hide B-spline control polygon");
sToolTipText =
QT_TR_NOOP("Switches between showing and hiding the control polygons for all B-splines");
sWhatsThis = "Sketcher_BSplinePolygon";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_BSplinePolygon";
sAccel = "";
eType = ForEdit;
}
void CmdSketcherBSplinePolygon::activated(int iMsg)
{
Q_UNUSED(iMsg);
ShowRestoreInformationLayer("BSplineControlPolygonVisible");
}
bool CmdSketcherBSplinePolygon::isActive()
{
return isSketcherBSplineActive(getActiveGuiDocument(), false);
}
// Show/Hide B-spline comb
DEF_STD_CMD_A(CmdSketcherBSplineComb)
CmdSketcherBSplineComb::CmdSketcherBSplineComb()
: Command("Sketcher_BSplineComb")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Show/hide B-spline curvature comb");
sToolTipText =
QT_TR_NOOP("Switches between showing and hiding the curvature comb for all B-splines");
sWhatsThis = "Sketcher_BSplineComb";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_BSplineComb";
sAccel = "";
eType = ForEdit;
}
void CmdSketcherBSplineComb::activated(int iMsg)
{
Q_UNUSED(iMsg);
ShowRestoreInformationLayer("BSplineCombVisible");
}
bool CmdSketcherBSplineComb::isActive()
{
return isSketcherBSplineActive(getActiveGuiDocument(), false);
}
//
DEF_STD_CMD_A(CmdSketcherBSplineKnotMultiplicity)
CmdSketcherBSplineKnotMultiplicity::CmdSketcherBSplineKnotMultiplicity()
: Command("Sketcher_BSplineKnotMultiplicity")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Show/hide B-spline knot multiplicity");
sToolTipText =
QT_TR_NOOP("Switches between showing and hiding the knot multiplicity for all B-splines");
sWhatsThis = "Sketcher_BSplineKnotMultiplicity";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_BSplineKnotMultiplicity";
sAccel = "";
eType = ForEdit;
}
void CmdSketcherBSplineKnotMultiplicity::activated(int iMsg)
{
Q_UNUSED(iMsg);
ShowRestoreInformationLayer("BSplineKnotMultiplicityVisible");
}
bool CmdSketcherBSplineKnotMultiplicity::isActive()
{
return isSketcherBSplineActive(getActiveGuiDocument(), false);
}
//
DEF_STD_CMD_A(CmdSketcherBSplinePoleWeight)
CmdSketcherBSplinePoleWeight::CmdSketcherBSplinePoleWeight()
: Command("Sketcher_BSplinePoleWeight")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Show/hide B-spline control point weight");
sToolTipText = QT_TR_NOOP(
"Switches between showing and hiding the control point weight for all B-splines");
sWhatsThis = "Sketcher_BSplinePoleWeight";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_BSplinePoleWeight";
sAccel = "";
eType = ForEdit;
}
void CmdSketcherBSplinePoleWeight::activated(int iMsg)
{
Q_UNUSED(iMsg);
ShowRestoreInformationLayer("BSplinePoleWeightVisible");
}
bool CmdSketcherBSplinePoleWeight::isActive()
{
return isSketcherBSplineActive(getActiveGuiDocument(), false);
}
// Composite drop down menu for show/hide BSpline information layer
DEF_STD_CMD_ACLU(CmdSketcherCompBSplineShowHideGeometryInformation)
CmdSketcherCompBSplineShowHideGeometryInformation::
CmdSketcherCompBSplineShowHideGeometryInformation()
: Command("Sketcher_CompBSplineShowHideGeometryInformation")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Show/hide B-spline information layer");
sToolTipText = sMenuText;
sWhatsThis = "Sketcher_CompBSplineShowHideGeometryInformation";
sStatusTip = sToolTipText;
eType = ForEdit;
}
void CmdSketcherCompBSplineShowHideGeometryInformation::activated(int iMsg)
{
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
Gui::Command* cmd;
if (iMsg == 0)
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineDegree");
else if (iMsg == 1)
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplinePolygon");
else if (iMsg == 2)
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineComb");
else if (iMsg == 3)
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplineKnotMultiplicity");
else if (iMsg == 4)
cmd = rcCmdMgr.getCommandByName("Sketcher_BSplinePoleWeight");
else
return;
cmd->invoke(0);
// Since the default icon is reset when enabling/disabling the command we have
// to explicitly set the icon of the used command.
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
QList<QAction*> a = pcAction->actions();
assert(iMsg < a.size());
pcAction->setIcon(a[iMsg]->icon());
// we must also set the tooltip of the used command
pcAction->setToolTip(a[iMsg]->toolTip());
}
Gui::Action* CmdSketcherCompBSplineShowHideGeometryInformation::createAction()
{
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
pcAction->setDropDownMenu(true);
applyCommandData(this->className(), pcAction);
QAction* c1 = pcAction->addAction(QString());
c1->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplineDegree"));
QAction* c2 = pcAction->addAction(QString());
c2->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplinePolygon"));
QAction* c3 = pcAction->addAction(QString());
c3->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplineComb"));
QAction* c4 = pcAction->addAction(QString());
c4->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplineKnotMultiplicity"));
QAction* c5 = pcAction->addAction(QString());
c5->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_BSplinePoleWeight"));
_pcAction = pcAction;
languageChange();
pcAction->setIcon(c2->icon());
int defaultId = 1;
pcAction->setProperty("defaultAction", QVariant(defaultId));
return pcAction;
}
void CmdSketcherCompBSplineShowHideGeometryInformation::languageChange()
{
Command::languageChange();
if (!_pcAction)
return;
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
QList<QAction*> a = pcAction->actions();
QAction* c1 = a[0];
c1->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation",
"Show/hide B-spline degree"));
c1->setToolTip(QApplication::translate(
"Sketcher_BSplineDegree",
"Switches between showing and hiding the degree for all B-splines"));
c1->setStatusTip(QApplication::translate(
"Sketcher_BSplineDegree",
"Switches between showing and hiding the degree for all B-splines"));
QAction* c2 = a[1];
c2->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation",
"Show/hide B-spline control polygon"));
c2->setToolTip(QApplication::translate(
"Sketcher_BSplinePolygon",
"Switches between showing and hiding the control polygons for all B-splines"));
c2->setStatusTip(QApplication::translate(
"Sketcher_BSplinePolygon",
"Switches between showing and hiding the control polygons for all B-splines"));
QAction* c3 = a[2];
c3->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation",
"Show/hide B-spline curvature comb"));
c3->setToolTip(QApplication::translate(
"Sketcher_BSplineComb",
"Switches between showing and hiding the curvature comb for all B-splines"));
c3->setStatusTip(QApplication::translate(
"Sketcher_BSplineComb",
"Switches between showing and hiding the curvature comb for all B-splines"));
QAction* c4 = a[3];
c4->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation",
"Show/hide B-spline knot multiplicity"));
c4->setToolTip(QApplication::translate(
"Sketcher_BSplineKnotMultiplicity",
"Switches between showing and hiding the knot multiplicity for all B-splines"));
c4->setStatusTip(QApplication::translate(
"Sketcher_BSplineKnotMultiplicity",
"Switches between showing and hiding the knot multiplicity for all B-splines"));
QAction* c5 = a[4];
c5->setText(QApplication::translate("CmdSketcherCompBSplineShowHideGeometryInformation",
"Show/hide B-spline control point weight"));
c5->setToolTip(QApplication::translate(
"Sketcher_BSplinePoleWeight",
"Switches between showing and hiding the control point weight for all B-splines"));
c5->setStatusTip(QApplication::translate(
"Sketcher_BSplinePoleWeight",
"Switches between showing and hiding the control point weight for all B-splines"));
}
void CmdSketcherCompBSplineShowHideGeometryInformation::updateAction(int /*mode*/)
{}
bool CmdSketcherCompBSplineShowHideGeometryInformation::isActive()
{
return isSketcherBSplineActive(getActiveGuiDocument(), false);
}
//
DEF_STD_CMD_A(CmdSketcherArcOverlay)
CmdSketcherArcOverlay::CmdSketcherArcOverlay()
: Command("Sketcher_ArcOverlay")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Show/hide circular helper for arcs");
sToolTipText =
QT_TR_NOOP("Switches between showing and hiding the circular helper for all arcs");
sWhatsThis = "Sketcher_ArcOverlay";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_ArcOverlay";
sAccel = "";
eType = ForEdit;
}
void CmdSketcherArcOverlay::activated(int iMsg)
{
Q_UNUSED(iMsg);
ShowRestoreInformationLayer("ArcCircleHelperVisible");
}
bool CmdSketcherArcOverlay::isActive()
{
return isSketchInEdit(getActiveGuiDocument());
}
void CreateSketcherCommandsOverlay()
{
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
rcCmdMgr.addCommand(new CmdSketcherBSplineDegree());
rcCmdMgr.addCommand(new CmdSketcherBSplinePolygon());
rcCmdMgr.addCommand(new CmdSketcherBSplineComb());
rcCmdMgr.addCommand(new CmdSketcherBSplineKnotMultiplicity());
rcCmdMgr.addCommand(new CmdSketcherBSplinePoleWeight());
rcCmdMgr.addCommand(new CmdSketcherCompBSplineShowHideGeometryInformation());
rcCmdMgr.addCommand(new CmdSketcherArcOverlay());
}

View File

@@ -220,17 +220,20 @@
</qresource>
<qresource>
<file>icons/splines/Sketcher_BSplineApproximate.svg</file>
<file>icons/splines/Sketcher_BSplineComb.svg</file>
<file>icons/splines/Sketcher_BSplineDecreaseDegree.svg</file>
<file>icons/splines/Sketcher_BSplineDecreaseKnotMultiplicity.svg</file>
<file>icons/splines/Sketcher_BSplineDegree.svg</file>
<file>icons/splines/Sketcher_BSplineIncreaseDegree.svg</file>
<file>icons/splines/Sketcher_BSplineIncreaseKnotMultiplicity.svg</file>
<file>icons/splines/Sketcher_BSplineInsertKnot.svg</file>
<file>icons/splines/Sketcher_JoinCurves.svg</file>
<file>icons/splines/Sketcher_BSplineKnotMultiplicity.svg</file>
<file>icons/splines/Sketcher_BSplinePoleWeight.svg</file>
<file>icons/splines/Sketcher_BSplinePolygon.svg</file>
</qresource>
<qresource>
<file>icons/overlay/Sketcher_BSplineComb.svg</file>
<file>icons/overlay/Sketcher_BSplineDegree.svg</file>
<file>icons/overlay/Sketcher_BSplineKnotMultiplicity.svg</file>
<file>icons/overlay/Sketcher_BSplinePoleWeight.svg</file>
<file>icons/overlay/Sketcher_BSplinePolygon.svg</file>
<file>icons/overlay/Sketcher_ArcOverlay.svg</file>
</qresource>
<qresource>
<file>icons/tools/Sketcher_Clone.svg</file>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 19 KiB

View File

@@ -414,6 +414,26 @@ bool SketcherGui::isCommandActive(Gui::Document* doc, bool actsOnSelection)
return false;
}
bool SketcherGui::isSketcherBSplineActive(Gui::Document* doc, bool actsOnSelection)
{
if (doc) {
// checks if a Sketch Viewprovider is in Edit and is in no special mode
if (doc->getInEdit()
&& doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) {
if (static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit())->getSketchMode()
== ViewProviderSketch::STATUS_NONE) {
if (!actsOnSelection)
return true;
else if (Gui::Selection().countObjectsOfType(
Sketcher::SketchObject::getClassTypeId())
> 0)
return true;
}
}
}
return false;
}
SketcherGui::ViewProviderSketch*
SketcherGui::getInactiveHandlerEditModeSketchViewProvider(Gui::Document* doc)
{

View File

@@ -145,6 +145,8 @@ bool isSketchInEdit(Gui::Document* doc);
/// sketcher is no special state or a sketchHandler is active.
bool isCommandActive(Gui::Document* doc, bool actsOnSelection = false);
bool isSketcherBSplineActive(Gui::Document* doc, bool actsOnSelection);
SketcherGui::ViewProviderSketch* getInactiveHandlerEditModeSketchViewProvider(Gui::Document* doc);
SketcherGui::ViewProviderSketch* getInactiveHandlerEditModeSketchViewProvider();
@@ -162,6 +164,7 @@ bool showCursorCoords();
bool useSystemDecimals();
std::string lengthToDisplayFormat(double value, int digits);
std::string angleToDisplayFormat(double value, int digits);
}// namespace SketcherGui
/// converts a 2D vector into a 3D vector in the XY plane

View File

@@ -87,16 +87,16 @@ Gui::MenuItem* Workbench::setupMenuBar() const
bsplines->setCommand("Sketcher B-spline tools");
addSketcherWorkbenchBSplines(*bsplines);
Gui::MenuItem* virtualspace = new Gui::MenuItem();
virtualspace->setCommand("Sketcher virtual space");
addSketcherWorkbenchVirtualSpace(*virtualspace);
Gui::MenuItem* visual = new Gui::MenuItem();
visual->setCommand("Sketcher visual");
addSketcherWorkbenchVisual(*visual);
Gui::MenuItem* sketch = new Gui::MenuItem;
root->insertItem(item, sketch);
sketch->setCommand("S&ketch");
addSketcherWorkbenchSketchActions(*sketch);
addSketcherWorkbenchSketchEditModeActions(*sketch);
*sketch << geom << cons << consaccel << bsplines << virtualspace;
*sketch << geom << cons << consaccel << bsplines << visual;
return root;
}
@@ -134,10 +134,10 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
bspline->setCommand("Sketcher B-spline tools");
addSketcherWorkbenchBSplines(*bspline);
Gui::ToolBarItem* virtualspace =
Gui::ToolBarItem* visual =
new Gui::ToolBarItem(root, Gui::ToolBarItem::DefaultVisibility::Unavailable);
virtualspace->setCommand("Sketcher virtual space");
addSketcherWorkbenchVirtualSpace(*virtualspace);
visual->setCommand("Sketcher visual");
addSketcherWorkbenchVisual(*visual);
Gui::ToolBarItem* edittools =
new Gui::ToolBarItem(root, Gui::ToolBarItem::DefaultVisibility::Unavailable);
@@ -500,12 +500,7 @@ inline void SketcherAddWorkbenchBSplines(T& bspline);
template<>
inline void SketcherAddWorkbenchBSplines<Gui::MenuItem>(Gui::MenuItem& bspline)
{
bspline << "Sketcher_BSplineDegree"
<< "Sketcher_BSplinePolygon"
<< "Sketcher_BSplineComb"
<< "Sketcher_BSplineKnotMultiplicity"
<< "Sketcher_BSplinePoleWeight"
<< "Sketcher_BSplineConvertToNURBS"
bspline << "Sketcher_BSplineConvertToNURBS"
<< "Sketcher_BSplineIncreaseDegree"
<< "Sketcher_BSplineDecreaseDegree"
<< "Sketcher_BSplineIncreaseKnotMultiplicity"
@@ -517,8 +512,7 @@ inline void SketcherAddWorkbenchBSplines<Gui::MenuItem>(Gui::MenuItem& bspline)
template<>
inline void SketcherAddWorkbenchBSplines<Gui::ToolBarItem>(Gui::ToolBarItem& bspline)
{
bspline << "Sketcher_CompBSplineShowHideGeometryInformation"
<< "Sketcher_BSplineConvertToNURBS"
bspline << "Sketcher_BSplineConvertToNURBS"
<< "Sketcher_BSplineIncreaseDegree"
<< "Sketcher_BSplineDecreaseDegree"
<< "Sketcher_CompModifyKnotMultiplicity"
@@ -527,18 +521,22 @@ inline void SketcherAddWorkbenchBSplines<Gui::ToolBarItem>(Gui::ToolBarItem& bsp
}
template<typename T>
inline void SketcherAddWorkbenchVirtualSpace(T& virtualspace);
inline void SketcherAddWorkbenchVisual(T& visual);
template<>
inline void SketcherAddWorkbenchVirtualSpace<Gui::MenuItem>(Gui::MenuItem& virtualspace)
inline void SketcherAddWorkbenchVisual<Gui::MenuItem>(Gui::MenuItem& visual)
{
virtualspace << "Sketcher_SwitchVirtualSpace";
visual << "Sketcher_SwitchVirtualSpace"
<< "Sketcher_CompBSplineShowHideGeometryInformation"
<< "Sketcher_ArcOverlay";
}
template<>
inline void SketcherAddWorkbenchVirtualSpace<Gui::ToolBarItem>(Gui::ToolBarItem& virtualspace)
inline void SketcherAddWorkbenchVisual<Gui::ToolBarItem>(Gui::ToolBarItem& visual)
{
virtualspace << "Sketcher_SwitchVirtualSpace";
visual << "Sketcher_SwitchVirtualSpace"
<< "Sketcher_CompBSplineShowHideGeometryInformation"
<< "Sketcher_ArcOverlay";
}
template<typename T>
@@ -582,9 +580,9 @@ void addSketcherWorkbenchBSplines(Gui::MenuItem& bspline)
SketcherAddWorkbenchBSplines(bspline);
}
void addSketcherWorkbenchVirtualSpace(Gui::MenuItem& virtualspace)
void addSketcherWorkbenchVisual(Gui::MenuItem& visual)
{
SketcherAddWorkbenchVirtualSpace(virtualspace);
SketcherAddWorkbenchVisual(visual);
}
void addSketcherWorkbenchSketchActions(Gui::ToolBarItem& sketch)
@@ -617,9 +615,9 @@ void addSketcherWorkbenchBSplines(Gui::ToolBarItem& bspline)
SketcherAddWorkbenchBSplines(bspline);
}
void addSketcherWorkbenchVirtualSpace(Gui::ToolBarItem& virtualspace)
void addSketcherWorkbenchVisual(Gui::ToolBarItem& visual)
{
SketcherAddWorkbenchVirtualSpace(virtualspace);
SketcherAddWorkbenchVisual(visual);
}
void addSketcherWorkbenchEditTools(Gui::ToolBarItem& edittools)

View File

@@ -60,7 +60,7 @@ SketcherGuiExport void addSketcherWorkbenchGeometries(Gui::MenuItem& geom);
SketcherGuiExport void addSketcherWorkbenchConstraints(Gui::MenuItem& cons);
SketcherGuiExport void addSketcherWorkbenchTools(Gui::MenuItem& consaccel);
SketcherGuiExport void addSketcherWorkbenchBSplines(Gui::MenuItem& bspline);
SketcherGuiExport void addSketcherWorkbenchVirtualSpace(Gui::MenuItem& virtualspace);
SketcherGuiExport void addSketcherWorkbenchVisual(Gui::MenuItem& visual);
SketcherGuiExport void addSketcherWorkbenchSketchActions(Gui::ToolBarItem& sketch);
SketcherGuiExport void addSketcherWorkbenchSketchEditModeActions(Gui::ToolBarItem& sketch);
@@ -68,7 +68,7 @@ SketcherGuiExport void addSketcherWorkbenchGeometries(Gui::ToolBarItem& geom);
SketcherGuiExport void addSketcherWorkbenchConstraints(Gui::ToolBarItem& cons);
SketcherGuiExport void addSketcherWorkbenchTools(Gui::ToolBarItem& consaccel);
SketcherGuiExport void addSketcherWorkbenchBSplines(Gui::ToolBarItem& bspline);
SketcherGuiExport void addSketcherWorkbenchVirtualSpace(Gui::ToolBarItem& virtualspace);
SketcherGuiExport void addSketcherWorkbenchVisual(Gui::ToolBarItem& visual);
SketcherGuiExport void addSketcherWorkbenchEditTools(Gui::ToolBarItem& edittools);
}// namespace SketcherGui