[Sketcher] Add missing GUI elements for B-spline by knots

Commented out the periodic version for now since they don't work completely well.

This commit is part of a project funded by the Open Toolchain Foundation under the title "Open Toolchain Foundation - Curve drawing tool in Sketcher Workbench"
This commit is contained in:
Ajinkya Dahale
2023-03-08 13:46:36 +05:30
committed by abdullahtahiriyo
parent 944c31cf7b
commit ab64e2251d
2 changed files with 82 additions and 6 deletions

View File

@@ -921,6 +921,66 @@ bool CmdSketcherCreatePeriodicBSpline::isActive()
return isCommandActive(getActiveGuiDocument());
}
/// @brief Macro that declares a new sketcher command class 'CmdSketcherCreateBSplineByInterpolation'
DEF_STD_CMD_AU(CmdSketcherCreateBSplineByInterpolation)
CmdSketcherCreateBSplineByInterpolation::CmdSketcherCreateBSplineByInterpolation()
: Command("Sketcher_CreateBSplineByInterpolation")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Interpolate B-spline");
sToolTipText = QT_TR_NOOP("Create a B-spline by interpolation, i.e. via knots in the sketch.");
sWhatsThis = "Sketcher_CreateBSplineByInterpolation";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_CreateBSplineByInterpolation";
sAccel = "G, B, I"; // TODO: Finalize this. What about Periodic?
eType = ForEdit;
}
CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateBSplineByInterpolation,"Sketcher_CreateBSplineByInterpolation")
void CmdSketcherCreateBSplineByInterpolation::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(),new DrawSketchHandlerBSplineByInterpolation(0) );
}
bool CmdSketcherCreateBSplineByInterpolation::isActive()
{
return isCommandActive(getActiveGuiDocument());
}
// /// @brief Macro that declares a new sketcher command class 'CmdSketcherCreatePeriodicBSplineByInterpolation'
// DEF_STD_CMD_AU(CmdSketcherCreatePeriodicBSplineByInterpolation)
// CmdSketcherCreatePeriodicBSplineByInterpolation::CmdSketcherCreatePeriodicBSplineByInterpolation()
// : Command("Sketcher_CreatePeriodicBSplineByInterpolation")
// {
// sAppModule = "Sketcher";
// sGroup = "Sketcher";
// sMenuText = QT_TR_NOOP("Interpolate periodic B-spline");
// sToolTipText = QT_TR_NOOP("Create a periodic B-spline by interpolation, i.e. via knots in the sketch.");
// sWhatsThis = "Sketcher_Create_Periodic_BSplineByInterpolation";
// sStatusTip = sToolTipText;
// sPixmap = "Sketcher_Create_Periodic_BSplineByInterpolation";
// sAccel = "G, B, O"; // TODO: Finalize this. What about Periodic?
// eType = ForEdit;
// }
// CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreatePeriodicBSplineByInterpolation,"Sketcher_CreatePeriodicBSplineByInterpolation")
// void CmdSketcherCreatePeriodicBSplineByInterpolation::activated(int iMsg)
// {
// Q_UNUSED(iMsg);
// ActivateHandler(getActiveGuiDocument(),new DrawSketchHandlerBSplineByInterpolation(1) );
// }
// bool CmdSketcherCreatePeriodicBSplineByInterpolation::isActive()
// {
// return isCommandActive(getActiveGuiDocument());
// }
/// @brief Macro that declares a new sketcher command class 'CmdSketcherCompCreateBSpline'
DEF_STD_CMD_ACLU(CmdSketcherCompCreateBSpline)
@@ -955,9 +1015,9 @@ void CmdSketcherCompCreateBSpline::activated(int iMsg)
else if (iMsg == 2) {
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerBSplineByInterpolation(0));
}
else if (iMsg == 3) {
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerBSplineByInterpolation(1));
}
// else if (iMsg == 3) {
// ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerBSplineByInterpolation(1));
// }
else {
return;
}
@@ -986,8 +1046,8 @@ Gui::Action * CmdSketcherCompCreateBSpline::createAction()
QAction* bsplinebyknot = pcAction->addAction(QString());
bsplinebyknot->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CreateBSplineByInterpolation"));
QAction* periodicbsplinebyknot = pcAction->addAction(QString());
periodicbsplinebyknot->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_Create_Periodic_BSplineByInterpolation"));
// QAction* periodicbsplinebyknot = pcAction->addAction(QString());
// periodicbsplinebyknot->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_Create_Periodic_BSplineByInterpolation"));
_pcAction = pcAction;
languageChange();
@@ -1012,11 +1072,15 @@ void CmdSketcherCompCreateBSpline::updateAction(int mode)
case Normal:
a[0]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CreateBSpline"));
a[1]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_Create_Periodic_BSpline"));
a[2]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CreateBSplineByInterpolation"));
// a[3]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_Create_Periodic_BSplineByInterpolation"));
getAction()->setIcon(a[index]->icon());
break;
case Construction:
a[0]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CreateBSpline_Constr"));
a[1]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_Create_Periodic_BSpline_Constr"));
a[2]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_CreateBSplineByInterpolation_Constr"));
// a[3]->setIcon(Gui::BitmapFactory().iconFromTheme("Sketcher_Create_Periodic_BSplineByInterpolation_Constr"));
getAction()->setIcon(a[index]->icon());
break;
}
@@ -1039,6 +1103,14 @@ void CmdSketcherCompCreateBSpline::languageChange()
periodicbspline->setText(QApplication::translate("Sketcher_Create_Periodic_BSpline","Periodic B-spline by control points"));
periodicbspline->setToolTip(QApplication::translate("Sketcher_Create_Periodic_BSpline","Create a periodic B-spline by control points"));
periodicbspline->setStatusTip(QApplication::translate("Sketcher_Create_Periodic_BSpline","Create a periodic B-spline by control points"));
QAction* bsplinebyknot = a[2];
bsplinebyknot->setText(QApplication::translate("Sketcher_CreateBSplineByInterpolation","B-spline by knots"));
bsplinebyknot->setToolTip(QApplication::translate("Sketcher_CreateBSplineByInterpolation","Create a B-spline by knots"));
bsplinebyknot->setStatusTip(QApplication::translate("Sketcher_CreateBSplineByInterpolation","Create a B-spline by knots"));
// QAction* periodicbsplinebyknot = a[3];
// periodicbsplinebyknot->setText(QApplication::translate("Sketcher_Create_Periodic_BSplineByInterpolation","Periodic B-spline by knots"));
// periodicbsplinebyknot->setToolTip(QApplication::translate("Sketcher_Create_Periodic_BSplineByInterpolation","Create a periodic B-spline by knots"));
// periodicbsplinebyknot->setStatusTip(QApplication::translate("Sketcher_Create_Periodic_BSplineByInterpolation","Create a periodic B-spline by knots"));
}
bool CmdSketcherCompCreateBSpline::isActive()
@@ -1938,6 +2010,8 @@ void CreateSketcherCommandsCreateGeo()
rcCmdMgr.addCommand(new CmdSketcherCreateArcOfParabola());
rcCmdMgr.addCommand(new CmdSketcherCreateBSpline());
rcCmdMgr.addCommand(new CmdSketcherCreatePeriodicBSpline());
rcCmdMgr.addCommand(new CmdSketcherCreateBSplineByInterpolation());
// rcCmdMgr.addCommand(new CmdSketcherCreatePeriodicBSplineByInterpolation());
rcCmdMgr.addCommand(new CmdSketcherCompCreateBSpline());
rcCmdMgr.addCommand(new CmdSketcherCreateLine());
rcCmdMgr.addCommand(new CmdSketcherCreatePolyline());

View File

@@ -211,7 +211,9 @@ inline void SketcherAddWorkspaceArcs<Gui::MenuItem>(Gui::MenuItem& geom)
<< "Sketcher_CreateArcOfHyperbola"
<< "Sketcher_CreateArcOfParabola"
<< "Sketcher_CreateBSpline"
<< "Sketcher_CreatePeriodicBSpline";
<< "Sketcher_CreatePeriodicBSpline"
<< "Sketcher_CreateBSplineByInterpolation";
// << "Sketcher_CreatePeriodicBSplineByInterpolation";
}
template <>