Skip to content

Commit

Permalink
Part: new tools - JoinFeatures (Connect, Embed and Cutout)
Browse files Browse the repository at this point in the history
Attributions:
Mark (quick61) - icons
Yorik - help with internationalization
Everyone who appeared in forum thread "A new Part tool is being born...
JoinFeatures!" - for endorsement!
http://forum.freecadweb.org/viewtopic.php?f=22&t=11112
  • Loading branch information
DeepSOIC authored and wwmayer committed Jun 4, 2015
1 parent 5ced7e5 commit 37fbcb6
Show file tree
Hide file tree
Showing 11 changed files with 1,166 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/Mod/Part/App/CMakeLists.txt
Expand Up @@ -265,6 +265,7 @@ SET(Part_Scripts
Init.py
TestPartApp.py
MakeBottle.py
JoinFeatures.py
)

add_library(Part SHARED ${Part_SRCS})
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Part/CMakeLists.txt
Expand Up @@ -11,6 +11,7 @@ INSTALL(
MakeBottle.py
TestPartApp.py
TestPartGui.py
JoinFeatures.py
DESTINATION
Mod/Part
)
97 changes: 97 additions & 0 deletions src/Mod/Part/Gui/Command.cpp
Expand Up @@ -39,6 +39,7 @@
#include <Base/Exception.h>
#include <App/Document.h>
#include <App/DocumentObjectGroup.h>
#include <Gui/Action.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
Expand Down Expand Up @@ -490,6 +491,101 @@ bool CmdPartFuse::isActive(void)
return getSelection().countObjectsOfType(Part::Feature::getClassTypeId())>=2;
}

//===========================================================================
// Part_CompJoinFeatures (dropdown toolbar button for Connect, Embed and Cutout)
//===========================================================================

DEF_STD_CMD_ACL(CmdPartCompJoinFeatures);

CmdPartCompJoinFeatures::CmdPartCompJoinFeatures()
: Command("Part_CompJoinFeatures")
{
sAppModule = "Part";
sGroup = QT_TR_NOOP("Part");
sMenuText = QT_TR_NOOP("Join objects...");
sToolTipText = QT_TR_NOOP("Join walled objects");
sWhatsThis = "Part_CompJoinFeatures";
sStatusTip = sToolTipText;
}

void CmdPartCompJoinFeatures::activated(int iMsg)
{
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
if (iMsg==0)
rcCmdMgr.runCommandByName("Part_JoinConnect");
else if (iMsg==1)
rcCmdMgr.runCommandByName("Part_JoinEmbed");
else if (iMsg==2)
rcCmdMgr.runCommandByName("Part_JoinCutout");
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 * CmdPartCompJoinFeatures::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_JoinConnect"));
QAction* cmd1 = pcAction->addAction(QString());
cmd1->setIcon(Gui::BitmapFactory().pixmap("Part_JoinEmbed"));
QAction* cmd2 = pcAction->addAction(QString());
cmd2->setIcon(Gui::BitmapFactory().pixmap("Part_JoinCutout"));

_pcAction = pcAction;
languageChange();

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

return pcAction;
}

void CmdPartCompJoinFeatures::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();

QAction* cmd0 = a[0];
cmd0->setText(QApplication::translate("PartCompJoinFeatures", rcCmdMgr.getCommandByName("Part_JoinConnect")->getMenuText()));
cmd0->setToolTip(QApplication::translate("Part_JoinConnect", rcCmdMgr.getCommandByName("Part_JoinConnect")->getToolTipText()));
cmd0->setStatusTip(QApplication::translate("Part_JoinConnect", rcCmdMgr.getCommandByName("Part_JoinConnect")->getStatusTip()));
QAction* cmd1 = a[1];
cmd1->setText(QApplication::translate("PartCompJoinFeatures", rcCmdMgr.getCommandByName("Part_JoinEmbed")->getMenuText()));
cmd1->setToolTip(QApplication::translate("Part_JoinEmbed", rcCmdMgr.getCommandByName("Part_JoinEmbed")->getToolTipText()));
cmd1->setStatusTip(QApplication::translate("Part_JoinEmbed", rcCmdMgr.getCommandByName("Part_JoinEmbed")->getStatusTip()));
QAction* cmd2 = a[2];
cmd2->setText(QApplication::translate("PartCompJoinFeatures", rcCmdMgr.getCommandByName("Part_JoinCutout")->getMenuText()));
cmd2->setToolTip(QApplication::translate("Part_JoinCutout", rcCmdMgr.getCommandByName("Part_JoinCutout")->getToolTipText()));
cmd2->setStatusTip(QApplication::translate("Part_JoinCutout", rcCmdMgr.getCommandByName("Part_JoinCutout")->getStatusTip()));
}

bool CmdPartCompJoinFeatures::isActive(void)
{
if (getActiveGuiDocument())
return true;
else
return false;
}

//===========================================================================
// Part_Compound
//===========================================================================
Expand Down Expand Up @@ -1747,6 +1843,7 @@ void CreatePartCommands(void)
rcCmdMgr.addCommand(new CmdPartCommon());
rcCmdMgr.addCommand(new CmdPartCut());
rcCmdMgr.addCommand(new CmdPartFuse());
rcCmdMgr.addCommand(new CmdPartCompJoinFeatures());
rcCmdMgr.addCommand(new CmdPartCompound());
rcCmdMgr.addCommand(new CmdPartSection());
//rcCmdMgr.addCommand(new CmdPartBox2());
Expand Down
4 changes: 4 additions & 0 deletions src/Mod/Part/Gui/Resources/Part.qrc
Expand Up @@ -59,6 +59,10 @@
<file>icons/Tree_Part_Prism.svg</file>
<file>icons/Tree_Part_Wedge.svg</file>
<file>icons/Part_Shape_from_Mesh.svg</file>
<file>icons/Part_JoinBypass.svg</file>
<file>icons/Part_JoinConnect.svg</file>
<file>icons/Part_JoinCutout.svg</file>
<file>icons/Part_JoinEmbed.svg</file>
<file>translations/Part_af.qm</file>
<file>translations/Part_de.qm</file>
<file>translations/Part_fi.qm</file>
Expand Down
203 changes: 203 additions & 0 deletions src/Mod/Part/Gui/Resources/icons/Part_JoinBypass.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 37fbcb6

Please sign in to comment.