| |
|
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| |
|
| | #include <QApplication>
|
| |
|
| |
|
| | #include <App/Part.h>
|
| | #include <Gui/Application.h>
|
| | #include <Gui/Command.h>
|
| | #include <Gui/Document.h>
|
| | #include <Gui/MDIView.h>
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | namespace
|
| | {
|
| | QString getAutoGroupCommandStr()
|
| |
|
| |
|
| | {
|
| | App::Part* activePart = Gui::Application::Instance->activeView()->getActiveObject<App::Part*>(
|
| | "part"
|
| | );
|
| | if (activePart) {
|
| | QString activePartName = QString::fromLatin1(activePart->getNameInDocument());
|
| | return QStringLiteral(
|
| | "App.ActiveDocument.getObject('%1\')."
|
| | "addObject(App.ActiveDocument.ActiveObject)\n"
|
| | )
|
| | .arg(activePartName);
|
| | }
|
| | return QStringLiteral("# Object created at document root.");
|
| | }
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | DEF_STD_CMD_A(CmdPartCylinder)
|
| |
|
| | CmdPartCylinder::CmdPartCylinder()
|
| | : Command("Part_Cylinder")
|
| | {
|
| | sAppModule = "Part";
|
| | sGroup = QT_TR_NOOP("Part");
|
| | sMenuText = QT_TR_NOOP("Cylinder");
|
| | sToolTipText = QT_TR_NOOP("Creates a solid cylinder");
|
| | sWhatsThis = "Part_Cylinder";
|
| | sStatusTip = sToolTipText;
|
| | sPixmap = "Part_Cylinder_Parametric";
|
| | }
|
| |
|
| | void CmdPartCylinder::activated(int iMsg)
|
| | {
|
| | Q_UNUSED(iMsg);
|
| | QString cmd;
|
| | cmd = qApp->translate("CmdPartCylinder", "Cylinder");
|
| | openCommand((const char*)cmd.toUtf8());
|
| |
|
| | runCommand(Doc, "App.ActiveDocument.addObject(\"Part::Cylinder\",\"Cylinder\")");
|
| | cmd = QStringLiteral("App.ActiveDocument.ActiveObject.Label = \"%1\"")
|
| | .arg(qApp->translate("CmdPartCylinder", "Cylinder"));
|
| | runCommand(Doc, cmd.toUtf8());
|
| | runCommand(Doc, getAutoGroupCommandStr().toUtf8());
|
| | commitCommand();
|
| | updateActive();
|
| | runCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
| | }
|
| |
|
| | bool CmdPartCylinder::isActive()
|
| | {
|
| | if (getActiveGuiDocument()) {
|
| | return true;
|
| | }
|
| | else {
|
| | return false;
|
| | }
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | DEF_STD_CMD_A(CmdPartBox)
|
| |
|
| | CmdPartBox::CmdPartBox()
|
| | : Command("Part_Box")
|
| | {
|
| | sAppModule = "Part";
|
| | sGroup = QT_TR_NOOP("Part");
|
| | sMenuText = QT_TR_NOOP("Cube");
|
| | sToolTipText = QT_TR_NOOP("Creates a solid cube");
|
| | sWhatsThis = "Part_Box";
|
| | sStatusTip = sToolTipText;
|
| | sPixmap = "Part_Box_Parametric";
|
| | }
|
| |
|
| | void CmdPartBox::activated(int iMsg)
|
| | {
|
| | Q_UNUSED(iMsg);
|
| | QString cmd;
|
| | cmd = qApp->translate("CmdPartBox", "Cube");
|
| | openCommand((const char*)cmd.toUtf8());
|
| |
|
| | runCommand(Doc, "App.ActiveDocument.addObject(\"Part::Box\",\"Box\")");
|
| | cmd = QStringLiteral("App.ActiveDocument.ActiveObject.Label = \"%1\"")
|
| | .arg(qApp->translate("CmdPartBox", "Cube"));
|
| | runCommand(Doc, cmd.toUtf8());
|
| | runCommand(Doc, getAutoGroupCommandStr().toUtf8());
|
| | commitCommand();
|
| | updateActive();
|
| | runCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
| | }
|
| |
|
| | bool CmdPartBox::isActive()
|
| | {
|
| | if (getActiveGuiDocument()) {
|
| | return true;
|
| | }
|
| | else {
|
| | return false;
|
| | }
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | DEF_STD_CMD_A(CmdPartSphere)
|
| |
|
| | CmdPartSphere::CmdPartSphere()
|
| | : Command("Part_Sphere")
|
| | {
|
| | sAppModule = "Part";
|
| | sGroup = QT_TR_NOOP("Part");
|
| | sMenuText = QT_TR_NOOP("Sphere");
|
| | sToolTipText = QT_TR_NOOP("Creates a solid sphere");
|
| | sWhatsThis = "Part_Sphere";
|
| | sStatusTip = sToolTipText;
|
| | sPixmap = "Part_Sphere_Parametric";
|
| | }
|
| |
|
| | void CmdPartSphere::activated(int iMsg)
|
| | {
|
| | Q_UNUSED(iMsg);
|
| | QString cmd;
|
| | cmd = qApp->translate("CmdPartSphere", "Sphere");
|
| | openCommand((const char*)cmd.toUtf8());
|
| |
|
| | runCommand(Doc, "App.ActiveDocument.addObject(\"Part::Sphere\",\"Sphere\")");
|
| | cmd = QStringLiteral("App.ActiveDocument.ActiveObject.Label = \"%1\"")
|
| | .arg(qApp->translate("CmdPartSphere", "Sphere"));
|
| | runCommand(Doc, cmd.toUtf8());
|
| | runCommand(Doc, getAutoGroupCommandStr().toUtf8());
|
| | commitCommand();
|
| | updateActive();
|
| | runCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
| | }
|
| |
|
| | bool CmdPartSphere::isActive()
|
| | {
|
| | if (getActiveGuiDocument()) {
|
| | return true;
|
| | }
|
| | else {
|
| | return false;
|
| | }
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | DEF_STD_CMD_A(CmdPartCone)
|
| |
|
| | CmdPartCone::CmdPartCone()
|
| | : Command("Part_Cone")
|
| | {
|
| | sAppModule = "Part";
|
| | sGroup = QT_TR_NOOP("Part");
|
| | sMenuText = QT_TR_NOOP("Cone");
|
| | sToolTipText = QT_TR_NOOP("Creates a solid cone");
|
| | sWhatsThis = "Part_Cone";
|
| | sStatusTip = sToolTipText;
|
| | sPixmap = "Part_Cone_Parametric";
|
| | }
|
| |
|
| | void CmdPartCone::activated(int iMsg)
|
| | {
|
| | Q_UNUSED(iMsg);
|
| | QString cmd;
|
| | cmd = qApp->translate("CmdPartCone", "Cone");
|
| | openCommand((const char*)cmd.toUtf8());
|
| |
|
| | runCommand(Doc, "App.ActiveDocument.addObject(\"Part::Cone\",\"Cone\")");
|
| | cmd = QStringLiteral("App.ActiveDocument.ActiveObject.Label = \"%1\"")
|
| | .arg(qApp->translate("CmdPartCone", "Cone"));
|
| | runCommand(Doc, cmd.toUtf8());
|
| | runCommand(Doc, getAutoGroupCommandStr().toUtf8());
|
| | commitCommand();
|
| | updateActive();
|
| | runCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
| | }
|
| |
|
| | bool CmdPartCone::isActive()
|
| | {
|
| | if (getActiveGuiDocument()) {
|
| | return true;
|
| | }
|
| | else {
|
| | return false;
|
| | }
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | DEF_STD_CMD_A(CmdPartTorus)
|
| |
|
| | CmdPartTorus::CmdPartTorus()
|
| | : Command("Part_Torus")
|
| | {
|
| | sAppModule = "Part";
|
| | sGroup = QT_TR_NOOP("Part");
|
| | sMenuText = QT_TR_NOOP("Torus");
|
| | sToolTipText = QT_TR_NOOP("Creates a solid torus");
|
| | sWhatsThis = "Part_Torus";
|
| | sStatusTip = sToolTipText;
|
| | sPixmap = "Part_Torus_Parametric";
|
| | }
|
| |
|
| | void CmdPartTorus::activated(int iMsg)
|
| | {
|
| | Q_UNUSED(iMsg);
|
| | QString cmd;
|
| | cmd = qApp->translate("CmdPartTorus", "Torus");
|
| | openCommand((const char*)cmd.toUtf8());
|
| |
|
| | runCommand(Doc, "App.ActiveDocument.addObject(\"Part::Torus\",\"Torus\")");
|
| | cmd = QStringLiteral("App.ActiveDocument.ActiveObject.Label = \"%1\"")
|
| | .arg(qApp->translate("CmdPartTorus", "Torus"));
|
| | runCommand(Doc, cmd.toUtf8());
|
| | runCommand(Doc, getAutoGroupCommandStr().toUtf8());
|
| | commitCommand();
|
| | updateActive();
|
| | runCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
| | }
|
| |
|
| | bool CmdPartTorus::isActive()
|
| | {
|
| | if (getActiveGuiDocument()) {
|
| | return true;
|
| | }
|
| | else {
|
| | return false;
|
| | }
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | void CreateParamPartCommands()
|
| | {
|
| | Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
|
| | rcCmdMgr.addCommand(new CmdPartCylinder());
|
| | rcCmdMgr.addCommand(new CmdPartBox());
|
| | rcCmdMgr.addCommand(new CmdPartSphere());
|
| | rcCmdMgr.addCommand(new CmdPartCone());
|
| | rcCmdMgr.addCommand(new CmdPartTorus());
|
| | }
|
| |
|