| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | #include <Inventor/SbString.h> |
| | #include <QApplication> |
| |
|
| | #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/Selection.h> |
| | #include <Gui/Selection/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); |
| | } |
| |
|
| | |
| | DEF_STD_CMD_A(CmdSketcherBSplineDegree) |
| |
|
| | CmdSketcherBSplineDegree::CmdSketcherBSplineDegree() |
| | : Command("Sketcher_BSplineDegree") |
| | { |
| | sAppModule = "Sketcher"; |
| | sGroup = "Sketcher"; |
| | sMenuText = QT_TR_NOOP("Toggle B-Spline Degree"); |
| | sToolTipText = QT_TR_NOOP("Toggles the visibility of 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 isCommandActive(getActiveGuiDocument()); |
| | } |
| |
|
| | |
| | DEF_STD_CMD_A(CmdSketcherBSplinePolygon) |
| |
|
| | CmdSketcherBSplinePolygon::CmdSketcherBSplinePolygon() |
| | : Command("Sketcher_BSplinePolygon") |
| | { |
| | sAppModule = "Sketcher"; |
| | sGroup = "Sketcher"; |
| | sMenuText = QT_TR_NOOP("Toggle B-Spline Control Polygon"); |
| | sToolTipText = QT_TR_NOOP("Toggles the visibility of 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 isCommandActive(getActiveGuiDocument()); |
| | } |
| |
|
| | |
| | DEF_STD_CMD_A(CmdSketcherBSplineComb) |
| |
|
| | CmdSketcherBSplineComb::CmdSketcherBSplineComb() |
| | : Command("Sketcher_BSplineComb") |
| | { |
| | sAppModule = "Sketcher"; |
| | sGroup = "Sketcher"; |
| | sMenuText = QT_TR_NOOP("Toggle B-Spline Curvature Comb"); |
| | sToolTipText = QT_TR_NOOP("Toggles the visibility of 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 isCommandActive(getActiveGuiDocument()); |
| | } |
| |
|
| | |
| | DEF_STD_CMD_A(CmdSketcherBSplineKnotMultiplicity) |
| |
|
| | CmdSketcherBSplineKnotMultiplicity::CmdSketcherBSplineKnotMultiplicity() |
| | : Command("Sketcher_BSplineKnotMultiplicity") |
| | { |
| | sAppModule = "Sketcher"; |
| | sGroup = "Sketcher"; |
| | sMenuText = QT_TR_NOOP("Toggle B-spline knot multiplicity"); |
| | sToolTipText = QT_TR_NOOP("Toggles the visibility of 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 isCommandActive(getActiveGuiDocument()); |
| | } |
| |
|
| | |
| | DEF_STD_CMD_A(CmdSketcherBSplinePoleWeight) |
| |
|
| | CmdSketcherBSplinePoleWeight::CmdSketcherBSplinePoleWeight() |
| | : Command("Sketcher_BSplinePoleWeight") |
| | { |
| | sAppModule = "Sketcher"; |
| | sGroup = "Sketcher"; |
| | sMenuText = QT_TR_NOOP("Toggle B-Spline Control Point Weight"); |
| | sToolTipText = QT_TR_NOOP("Toggles the visibility of control point weights 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 isCommandActive(getActiveGuiDocument()); |
| | } |
| |
|
| | |
| | DEF_STD_CMD_ACLU(CmdSketcherCompBSplineShowHideGeometryInformation) |
| |
|
| | CmdSketcherCompBSplineShowHideGeometryInformation::CmdSketcherCompBSplineShowHideGeometryInformation() |
| | : Command("Sketcher_CompBSplineShowHideGeometryInformation") |
| | { |
| | sAppModule = "Sketcher"; |
| | sGroup = "Sketcher"; |
| | sMenuText = QT_TR_NOOP("Toggle B-Spline Information Layer"); |
| | sToolTipText = QT_TR_NOOP("Toggles the visibility of the information layer for all B-splines"); |
| | 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); |
| |
|
| | |
| | |
| | Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction); |
| | QList<QAction*> a = pcAction->actions(); |
| |
|
| | assert(iMsg < a.size()); |
| | pcAction->setIcon(a[iMsg]->icon()); |
| | |
| | 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", "Toggle B-Spline Degree") |
| | ); |
| | c1->setToolTip( |
| | QApplication::translate( |
| | "Sketcher_BSplineDegree", |
| | "Toggles the visibility of the degree for all B-splines" |
| | ) |
| | ); |
| | c1->setStatusTip( |
| | QApplication::translate( |
| | "Sketcher_BSplineDegree", |
| | "Toggles the visibility of the degree for all B-splines" |
| | ) |
| | ); |
| | QAction* c2 = a[1]; |
| | c2->setText( |
| | QApplication::translate( |
| | "CmdSketcherCompBSplineShowHideGeometryInformation", |
| | "Toggle B-Spline Control Polygon" |
| | ) |
| | ); |
| | c2->setToolTip( |
| | QApplication::translate( |
| | "Sketcher_BSplinePolygon", |
| | "Toggles the visibility of the control polygons for all B-splines" |
| | ) |
| | ); |
| | c2->setStatusTip( |
| | QApplication::translate( |
| | "Sketcher_BSplinePolygon", |
| | "Toggles the visibility of the control polygons for all B-splines" |
| | ) |
| | ); |
| | QAction* c3 = a[2]; |
| | c3->setText( |
| | QApplication::translate( |
| | "CmdSketcherCompBSplineShowHideGeometryInformation", |
| | "Toggle B-Spline Curvature Comb" |
| | ) |
| | ); |
| | c3->setToolTip( |
| | QApplication::translate( |
| | "Sketcher_BSplineComb", |
| | "Toggles the visibility of the curvature comb for all B-splines" |
| | ) |
| | ); |
| | c3->setStatusTip( |
| | QApplication::translate( |
| | "Sketcher_BSplineComb", |
| | "Toggles the visibility of the curvature comb for all B-splines" |
| | ) |
| | ); |
| | QAction* c4 = a[3]; |
| | c4->setText( |
| | QApplication::translate( |
| | "CmdSketcherCompBSplineShowHideGeometryInformation", |
| | "Toggle B-Spline Knot Multiplicity" |
| | ) |
| | ); |
| | c4->setToolTip( |
| | QApplication::translate( |
| | "Sketcher_BSplineKnotMultiplicity", |
| | "Toggles the visibility of the knot multiplicity for all B-splines" |
| | ) |
| | ); |
| | c4->setStatusTip( |
| | QApplication::translate( |
| | "Sketcher_BSplineKnotMultiplicity", |
| | "Toggles the visibility of the knot multiplicity for all B-splines" |
| | ) |
| | ); |
| |
|
| | QAction* c5 = a[4]; |
| | c5->setText( |
| | QApplication::translate( |
| | "CmdSketcherCompBSplineShowHideGeometryInformation", |
| | "Toggle B-Spline Control Point Weight" |
| | ) |
| | ); |
| | c5->setToolTip( |
| | QApplication::translate( |
| | "Sketcher_BSplinePoleWeight", |
| | "Toggles the visibility of the control point weight for all B-splines" |
| | ) |
| | ); |
| | c5->setStatusTip( |
| | QApplication::translate( |
| | "Sketcher_BSplinePoleWeight", |
| | "Toggles the visibility of the control point weight for all B-splines" |
| | ) |
| | ); |
| | } |
| |
|
| | void CmdSketcherCompBSplineShowHideGeometryInformation::updateAction(int ) |
| | {} |
| |
|
| | bool CmdSketcherCompBSplineShowHideGeometryInformation::isActive() |
| | { |
| | return isCommandActive(getActiveGuiDocument()); |
| | } |
| |
|
| | |
| | DEF_STD_CMD_A(CmdSketcherArcOverlay) |
| |
|
| | CmdSketcherArcOverlay::CmdSketcherArcOverlay() |
| | : Command("Sketcher_ArcOverlay") |
| | { |
| | sAppModule = "Sketcher"; |
| | sGroup = "Sketcher"; |
| | sMenuText = QT_TR_NOOP("Toggle Circular Helper for Arcs"); |
| | sToolTipText = QT_TR_NOOP("Toggles the visibility of the circular helpers 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()); |
| | } |
| |
|