Skip to content

Commit

Permalink
Part: add/update GUI commands
Browse files Browse the repository at this point in the history
* Updated translation contexts for  Gui commands for JoinFeatures.
* Added Gui commands for Split tools: BooleanFragments, Slice, XOR.
Icons.
  • Loading branch information
DeepSOIC committed Jul 29, 2016
1 parent c069987 commit e9b31dd
Show file tree
Hide file tree
Showing 6 changed files with 693 additions and 11 deletions.
130 changes: 121 additions & 9 deletions src/Mod/Part/Gui/Command.cpp
Expand Up @@ -33,6 +33,7 @@
# include <TopoDS_Shape.hxx>
# include <TopExp_Explorer.hxx>
# include <Inventor/events/SoMouseButtonEvent.h>
# include <Standard_Version.hxx>
#endif

#include <Base/Console.h>
Expand Down Expand Up @@ -569,25 +570,25 @@ void CmdPartCompJoinFeatures::languageChange()
Gui::Command* joinConnect = rcCmdMgr.getCommandByName("Part_JoinConnect");
if (joinConnect) {
QAction* cmd0 = a[0];
cmd0->setText(QApplication::translate("PartCompJoinFeatures", joinConnect->getMenuText()));
cmd0->setToolTip(QApplication::translate("Part_JoinConnect", joinConnect->getToolTipText()));
cmd0->setStatusTip(QApplication::translate("Part_JoinConnect", joinConnect->getStatusTip()));
cmd0->setText(QApplication::translate("Part_JoinFeatures", joinConnect->getMenuText()));
cmd0->setToolTip(QApplication::translate("Part_JoinFeatures", joinConnect->getToolTipText()));
cmd0->setStatusTip(QApplication::translate("Part_JoinFeatures", joinConnect->getStatusTip()));
}

Gui::Command* joinEmbed = rcCmdMgr.getCommandByName("Part_JoinEmbed");
if (joinEmbed) {
QAction* cmd1 = a[1];
cmd1->setText(QApplication::translate("PartCompJoinFeatures", joinEmbed->getMenuText()));
cmd1->setToolTip(QApplication::translate("Part_JoinEmbed", joinEmbed->getToolTipText()));
cmd1->setStatusTip(QApplication::translate("Part_JoinEmbed", joinEmbed->getStatusTip()));
cmd1->setText(QApplication::translate("Part_JoinFeatures", joinEmbed->getMenuText()));
cmd1->setToolTip(QApplication::translate("Part_JoinFeatures", joinEmbed->getToolTipText()));
cmd1->setStatusTip(QApplication::translate("Part_JoinFeatures", joinEmbed->getStatusTip()));
}

Gui::Command* joinCutout = rcCmdMgr.getCommandByName("Part_JoinCutout");
if (joinCutout) {
QAction* cmd2 = a[2];
cmd2->setText(QApplication::translate("PartCompJoinFeatures", joinCutout->getMenuText()));
cmd2->setToolTip(QApplication::translate("Part_JoinCutout", joinCutout->getToolTipText()));
cmd2->setStatusTip(QApplication::translate("Part_JoinCutout", joinCutout->getStatusTip()));
cmd2->setText(QApplication::translate("Part_JoinFeatures", joinCutout->getMenuText()));
cmd2->setToolTip(QApplication::translate("Part_JoinFeatures", joinCutout->getToolTipText()));
cmd2->setStatusTip(QApplication::translate("Part_JoinFeatures", joinCutout->getStatusTip()));
}
}

Expand All @@ -599,6 +600,116 @@ bool CmdPartCompJoinFeatures::isActive(void)
return false;
}

//===========================================================================
// Part_CompSplitFeatures (dropdown toolbar button for BooleanFragments, Slice)
//===========================================================================

DEF_STD_CMD_ACL(CmdPartCompSplitFeatures);

CmdPartCompSplitFeatures::CmdPartCompSplitFeatures()
: Command("Part_CompSplitFeatures")
{
sAppModule = "Part";
sGroup = QT_TR_NOOP("Part");
sMenuText = QT_TR_NOOP("Split objects...");
sToolTipText = QT_TR_NOOP("Shape splitting tools. Compsolid creation tools. OCC 6.9.0 or later is required.");
sWhatsThis = "Part_CompSplitFeatures";
sStatusTip = sToolTipText;
}

void CmdPartCompSplitFeatures::activated(int iMsg)
{
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
if (iMsg==0)
rcCmdMgr.runCommandByName("Part_BooleanFragments");
else if (iMsg==1)
rcCmdMgr.runCommandByName("Part_Slice");
else if (iMsg==2)
rcCmdMgr.runCommandByName("Part_XOR");
else
return;

// Since the default icon is reset when enabing/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());
}

Gui::Action * CmdPartCompSplitFeatures::createAction(void)
{
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
pcAction->setDropDownMenu(true);
applyCommandData(this->className(), pcAction);

QAction* cmd0 = pcAction->addAction(QString());
cmd0->setIcon(Gui::BitmapFactory().pixmap("Part_BooleanFragments"));
QAction* cmd1 = pcAction->addAction(QString());
cmd1->setIcon(Gui::BitmapFactory().pixmap("Part_Slice"));
QAction* cmd2 = pcAction->addAction(QString());
cmd2->setIcon(Gui::BitmapFactory().pixmap("Part_XOR"));

_pcAction = pcAction;
languageChange();

pcAction->setIcon(cmd0->icon());
int defaultId = 0;
pcAction->setProperty("defaultAction", QVariant(defaultId));

return pcAction;
}

void CmdPartCompSplitFeatures::languageChange()
{
Command::languageChange();

if (!_pcAction)
return;

Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();

Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
QList<QAction*> a = pcAction->actions();

Gui::Command* splitBoolFragments = rcCmdMgr.getCommandByName("Part_BooleanFragments");
if (splitBoolFragments) {
QAction* cmd0 = a[0];
cmd0->setText(QApplication::translate("Part_SplitFeatures", splitBoolFragments->getMenuText()));
cmd0->setToolTip(QApplication::translate("Part_SplitFeatures", splitBoolFragments->getToolTipText()));
cmd0->setStatusTip(QApplication::translate("Part_SplitFeatures", splitBoolFragments->getStatusTip()));
}

Gui::Command* splitSlice = rcCmdMgr.getCommandByName("Part_Slice");
if (splitSlice) {
QAction* cmd1 = a[1];
cmd1->setText(QApplication::translate("Part_SplitFeatures", splitSlice->getMenuText()));
cmd1->setToolTip(QApplication::translate("Part_SplitFeatures", splitSlice->getToolTipText()));
cmd1->setStatusTip(QApplication::translate("Part_SplitFeatures", splitSlice->getStatusTip()));
}

Gui::Command* splitXOR = rcCmdMgr.getCommandByName("Part_XOR");
if (splitXOR) {
QAction* cmd2 = a[2];
cmd2->setText(QApplication::translate("Part_SplitFeatures", splitXOR->getMenuText()));
cmd2->setToolTip(QApplication::translate("Part_SplitFeatures", splitXOR->getToolTipText()));
cmd2->setStatusTip(QApplication::translate("Part_SplitFeatures", splitXOR->getStatusTip()));
}
}

bool CmdPartCompSplitFeatures::isActive(void)
{
if (getActiveGuiDocument())
#if OCC_VERSION_HEX < 0x060900
return false;
#else
return true;
#endif
else
return false;
}

//===========================================================================
// Part_Compound
//===========================================================================
Expand Down Expand Up @@ -1909,6 +2020,7 @@ void CreatePartCommands(void)
rcCmdMgr.addCommand(new CmdPartCut());
rcCmdMgr.addCommand(new CmdPartFuse());
rcCmdMgr.addCommand(new CmdPartCompJoinFeatures());
rcCmdMgr.addCommand(new CmdPartCompSplitFeatures());
rcCmdMgr.addCommand(new CmdPartCompound());
rcCmdMgr.addCommand(new CmdPartSection());
//rcCmdMgr.addCommand(new CmdPartBox2());
Expand Down
3 changes: 3 additions & 0 deletions src/Mod/Part/Gui/Resources/Part.qrc
Expand Up @@ -5,6 +5,7 @@
<file>icons/PartFeatureImport.xpm</file>
<file>icons/Part_Attachment.svg</file>
<file>icons/Part_Booleans.svg</file>
<file>icons/Part_BooleanFragments.svg</file>
<file>icons/Part_Box.svg</file>
<file>icons/Part_Chamfer.svg</file>
<file>icons/Part_Common.svg</file>
Expand All @@ -28,10 +29,12 @@
<file>icons/Part_CrossSections.svg</file>
<file>icons/Part_Shapebuilder.png</file>
<file>icons/Part_ShapeInfo.svg</file>
<file>icons/Part_Slice.svg</file>
<file>icons/Part_Sphere.svg</file>
<file>icons/Part_Sweep.svg</file>
<file>icons/Part_Thickness.svg</file>
<file>icons/Part_Torus.svg</file>
<file>icons/Part_XOR.svg</file>
<file>icons/preferences-part_design.svg</file>
<file>icons/Tree_Part.svg</file>
<file>icons/Part_CheckGeometry.svg</file>
Expand Down
206 changes: 206 additions & 0 deletions src/Mod/Part/Gui/Resources/icons/Part_BooleanFragments.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e9b31dd

Please sign in to comment.