Navigation Menu

Skip to content

Commit

Permalink
+ issue #1475: Implement a 3 point arc similar to solidworks in sketcher
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Mar 16, 2014
1 parent 35b10d6 commit d1341f3
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/Mod/Complete/Gui/Workbench.cpp
Expand Up @@ -503,8 +503,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
<< "Sketcher_LeaveSketch"
<< "Separator"
<< "Sketcher_CreatePoint"
<< "Sketcher_CreateArc"
<< "Sketcher_Create3PointArc"
<< "Sketcher_CompCreateArc"
<< "Sketcher_CreateCircle"
<< "Sketcher_CreateLine"
<< "Sketcher_CreatePolyline"
Expand Down
3 changes: 1 addition & 2 deletions src/Mod/PartDesign/Gui/Workbench.cpp
Expand Up @@ -260,8 +260,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
Gui::ToolBarItem* geom = new Gui::ToolBarItem(root);
geom->setCommand("Sketcher geometries");
*geom << "Sketcher_CreatePoint"
<< "Sketcher_CreateArc"
<< "Sketcher_Create3PointArc"
<< "Sketcher_CompCreateArc"
<< "Sketcher_CreateCircle"
<< "Sketcher_CreateLine"
<< "Sketcher_CreatePolyline"
Expand Down
81 changes: 81 additions & 0 deletions src/Mod/Sketcher/Gui/CommandCreateGeo.cpp
Expand Up @@ -24,12 +24,15 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <Inventor/nodes/SoPickStyle.h>
# include <QApplication>
#endif

#include <boost/math/special_functions/fpclassify.hpp>
#include <Base/Console.h>

#include <Gui/Action.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Document.h>
#include <Gui/Command.h>
#include <Gui/MainWindow.h>
Expand Down Expand Up @@ -1502,6 +1505,83 @@ bool CmdSketcherCreate3PointArc::isActive(void)
return isCreateGeoActive(getActiveGuiDocument());
}

DEF_STD_CMD_ACL(CmdSketcherCompCreateArc);

CmdSketcherCompCreateArc::CmdSketcherCompCreateArc()
: Command("Sketcher_CompCreateArc")
{
sAppModule = "Sketcher";
sGroup = QT_TR_NOOP("Sketcher");
sMenuText = QT_TR_NOOP("Create arc");
sToolTipText = QT_TR_NOOP("Create an arc in the sketcher");
sWhatsThis = sToolTipText;
sStatusTip = sToolTipText;
eType = ForEdit;
}

void CmdSketcherCompCreateArc::activated(int iMsg)
{
if (iMsg==0)
ActivateHandler(getActiveGuiDocument(),new DrawSketchHandlerArc());
else if (iMsg==1)
ActivateHandler(getActiveGuiDocument(),new DrawSketchHandler3PointArc());
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 * CmdSketcherCompCreateArc::createAction(void)
{
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
pcAction->setDropDownMenu(true);
applyCommandData(pcAction);

QAction* arc1 = pcAction->addAction(QString());
arc1->setIcon(Gui::BitmapFactory().pixmapFromSvg("Sketcher_CreateArc", QSize(24,24)));
QAction* arc2 = pcAction->addAction(QString());
arc2->setIcon(Gui::BitmapFactory().pixmapFromSvg("Sketcher_Create3PointArc", QSize(24,24)));

_pcAction = pcAction;
languageChange();

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

return pcAction;
}

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

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

QAction* arc1 = a[0];
arc1->setText(QApplication::translate("CmdSketcherCompCreateArc","Center and end points"));
arc1->setToolTip(QApplication::translate("Sketcher_CreateArc","Create an arc by its center and by its end points"));
arc1->setStatusTip(QApplication::translate("Sketcher_CreateArc","Create an arc by its center and by its end points"));
QAction* arc2 = a[1];
arc2->setText(QApplication::translate("CmdSketcherCompCreateArc","End point and rim point"));
arc2->setToolTip(QApplication::translate("Sketcher_Create3PointArc","Create an arc by its end points and a point along the arc"));
arc2->setStatusTip(QApplication::translate("Sketcher_Create3PointArc","Create an arc by its end points and a point along the arc"));
}

bool CmdSketcherCompCreateArc::isActive(void)
{
return isCreateGeoActive(getActiveGuiDocument());
}



// ======================================================================================
Expand Down Expand Up @@ -2432,6 +2512,7 @@ void CreateSketcherCommandsCreateGeo(void)
rcCmdMgr.addCommand(new CmdSketcherCreatePoint());
rcCmdMgr.addCommand(new CmdSketcherCreateArc());
rcCmdMgr.addCommand(new CmdSketcherCreate3PointArc());
rcCmdMgr.addCommand(new CmdSketcherCompCreateArc());
rcCmdMgr.addCommand(new CmdSketcherCreateCircle());
rcCmdMgr.addCommand(new CmdSketcherCreateLine());
rcCmdMgr.addCommand(new CmdSketcherCreatePolyline());
Expand Down
3 changes: 1 addition & 2 deletions src/Mod/Sketcher/Gui/Workbench.cpp
Expand Up @@ -122,8 +122,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
Gui::ToolBarItem* geom = new Gui::ToolBarItem(root);
geom->setCommand("Sketcher geometries");
*geom << "Sketcher_CreatePoint"
<< "Sketcher_CreateArc"
<< "Sketcher_Create3PointArc"
<< "Sketcher_CompCreateArc"
<< "Sketcher_CreateCircle"
<< "Sketcher_CreateLine"
<< "Sketcher_CreatePolyline"
Expand Down

0 comments on commit d1341f3

Please sign in to comment.