- Ellipse introduction button via (center,majaxis extreme, a point in edge), ellipse is always CCW so that Z axis goes in the positive direction of the sketch - Backwards compatibility with files of previous versions of ellipse not defining a phi angle - Art by Jim (all the icons you see and the XPMs shown on creation of an ellipse) - Element Widget support for ellipses - Box selection for ellipses - Point on Ellipse constraint based on the gardener's method based on Ulrich's function proposal (radcan simplified, i.e. with simplify_radical sage function) - Tangent: Ellipse to Line based on DeepSOIC's geometric formulation (radcan simplified) Sketcher New Feature: Internal Alignment Constraint - The element to which internal alignment is applied has to be selected last. - All other elements are added in the order of priority, taking into account existing elements - Art by Jim (beautiful icons). Sketcher New Feature: Tool to show/hide/restore the internal geometry of an element - New functionality for show/hide internal geometry: toggles between hiding all unused internal geometry elements and showing all internal geometry. The restore function is implicit to the showing all internal geometry Sketcher New Feature: Arc of Ellipse support - Part::Geometry + Python implementation - ArcOfEllipse creation method - Art by Jim (all the icons you see and the XPMs shown on creation of arc of ellipse elements) - Sketcher Element widget for ArcOfEllipse. Bug fix: Select elements associated to constraints works now for foci internal alignment constraints
254 lines
8.3 KiB
C++
254 lines
8.3 KiB
C++
/***************************************************************************
|
|
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
|
|
* *
|
|
* This file is part of the FreeCAD CAx development system. *
|
|
* *
|
|
* This library is free software; you can redistribute it and/or *
|
|
* modify it under the terms of the GNU Library General Public *
|
|
* License as published by the Free Software Foundation; either *
|
|
* version 2 of the License, or (at your option) any later version. *
|
|
* *
|
|
* This library is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
* GNU Library General Public License for more details. *
|
|
* *
|
|
* You should have received a copy of the GNU Library General Public *
|
|
* License along with this library; see the file COPYING.LIB. If not, *
|
|
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
|
* Suite 330, Boston, MA 02111-1307, USA *
|
|
* *
|
|
***************************************************************************/
|
|
|
|
|
|
#include "PreCompiled.h"
|
|
|
|
#ifndef _PreComp_
|
|
# include <qobject.h>
|
|
#endif
|
|
|
|
#include "Workbench.h"
|
|
#include <Mod/Sketcher/Gui/Workbench.h>
|
|
#include <Gui/Application.h>
|
|
#include <Gui/Command.h>
|
|
#include <Gui/MenuManager.h>
|
|
#include <Gui/ToolBarManager.h>
|
|
#include <Gui/Control.h>
|
|
|
|
using namespace PartDesignGui;
|
|
|
|
#if 0 // needed for Qt's lupdate utility
|
|
qApp->translate("Workbench", "Part Design");
|
|
qApp->translate("Gui::TaskView::TaskWatcherCommands", "Face tools");
|
|
qApp->translate("Gui::TaskView::TaskWatcherCommands", "Sketch tools");
|
|
qApp->translate("Gui::TaskView::TaskWatcherCommands", "Create Geometry");
|
|
#endif
|
|
|
|
/// @namespace PartDesignGui @class Workbench
|
|
TYPESYSTEM_SOURCE(PartDesignGui::Workbench, Gui::StdWorkbench)
|
|
|
|
Workbench::Workbench()
|
|
{
|
|
}
|
|
|
|
Workbench::~Workbench()
|
|
{
|
|
}
|
|
|
|
void Workbench::activated()
|
|
{
|
|
Gui::Workbench::activated();
|
|
|
|
|
|
std::vector<Gui::TaskView::TaskWatcher*> Watcher;
|
|
|
|
//Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
|
|
// "FROM Robot SELECT TrajectoryObject COUNT 1"
|
|
// "FROM Robot SELECT RobotObject COUNT 1",
|
|
// RobotAndTrac,
|
|
// "Trajectory tools",
|
|
// "Robot_InsertWaypoint"
|
|
//));
|
|
|
|
//Watcher.push_back(new TaskWatcherRobot);
|
|
|
|
const char* Edge[] = {
|
|
"PartDesign_Fillet",
|
|
"PartDesign_Chamfer",
|
|
0};
|
|
Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
|
|
"SELECT Part::Feature SUBELEMENT Edge COUNT 1..",
|
|
Edge,
|
|
"Edge tools",
|
|
"Part_Box"
|
|
));
|
|
|
|
const char* Face[] = {
|
|
"Sketcher_NewSketch",
|
|
"PartDesign_Fillet",
|
|
"PartDesign_Chamfer",
|
|
"PartDesign_Draft",
|
|
0};
|
|
Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
|
|
"SELECT Part::Feature SUBELEMENT Face COUNT 1",
|
|
Face,
|
|
"Face tools",
|
|
"Part_Box"
|
|
));
|
|
|
|
const char* Faces[] = {
|
|
"PartDesign_Fillet",
|
|
"PartDesign_Chamfer",
|
|
"PartDesign_Draft",
|
|
0};
|
|
Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
|
|
"SELECT Part::Feature SUBELEMENT Face COUNT 2..",
|
|
Faces,
|
|
"Face tools",
|
|
"Part_Box"
|
|
));
|
|
|
|
const char* Sketch[] = {
|
|
"Sketcher_NewSketch",
|
|
"Sketcher_EditSketch",
|
|
"PartDesign_Pad",
|
|
"PartDesign_Pocket",
|
|
"PartDesign_Revolution",
|
|
"PartDesign_Groove",
|
|
0};
|
|
Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
|
|
"SELECT Sketcher::SketchObject COUNT 1",
|
|
Sketch,
|
|
"Sketch tools",
|
|
"Part_Box"
|
|
));
|
|
|
|
const char* Transformed[] = {
|
|
"PartDesign_Mirrored",
|
|
"PartDesign_LinearPattern",
|
|
"PartDesign_PolarPattern",
|
|
// "PartDesign_Scaled",
|
|
"PartDesign_MultiTransform",
|
|
0};
|
|
Watcher.push_back(new Gui::TaskView::TaskWatcherCommands(
|
|
"SELECT PartDesign::SketchBased",
|
|
Transformed,
|
|
"Transformation tools",
|
|
"PartDesign_MultiTransform"
|
|
));
|
|
|
|
const char* Empty[] = {
|
|
"Sketcher_NewSketch",
|
|
"Part_Box",
|
|
"Part_Cylinder",
|
|
0};
|
|
Watcher.push_back(new Gui::TaskView::TaskWatcherCommandsEmptySelection(
|
|
Empty,
|
|
"Create Geometry",
|
|
"Part_Box"
|
|
));
|
|
|
|
|
|
addTaskWatcher(Watcher);
|
|
Gui::Control().showTaskView();
|
|
}
|
|
|
|
void Workbench::deactivated()
|
|
{
|
|
Gui::Workbench::deactivated();
|
|
removeTaskWatcher();
|
|
|
|
}
|
|
|
|
Gui::MenuItem* Workbench::setupMenuBar() const
|
|
{
|
|
Gui::MenuItem* root = StdWorkbench::setupMenuBar();
|
|
Gui::MenuItem* item = root->findItem("&Windows");
|
|
|
|
Gui::MenuItem* geom = new Gui::MenuItem();
|
|
geom->setCommand("Sketcher geometries");
|
|
SketcherGui::addSketcherWorkbenchGeometries( *geom );
|
|
|
|
Gui::MenuItem* cons = new Gui::MenuItem();
|
|
cons->setCommand("Sketcher constraints");
|
|
SketcherGui::addSketcherWorkbenchConstraints( *cons );
|
|
|
|
Gui::MenuItem* consaccel = new Gui::MenuItem();
|
|
consaccel->setCommand("Sketcher tools");
|
|
SketcherGui::addSketcherWorkbenchTools(*consaccel);
|
|
|
|
Gui::MenuItem* part = new Gui::MenuItem;
|
|
root->insertItem(item, part);
|
|
part->setCommand("&Part Design");
|
|
SketcherGui::addSketcherWorkbenchSketchActions( *part );
|
|
*part << geom
|
|
<< cons
|
|
<< "Separator"
|
|
<< "PartDesign_Pad"
|
|
<< "PartDesign_Pocket"
|
|
<< "PartDesign_Revolution"
|
|
<< "PartDesign_Groove"
|
|
<< "PartDesign_Fillet"
|
|
<< "PartDesign_Chamfer"
|
|
<< "PartDesign_Draft"
|
|
<< "PartDesign_Mirrored"
|
|
<< "PartDesign_LinearPattern"
|
|
<< "PartDesign_PolarPattern"
|
|
// << "PartDesign_Scaled"
|
|
<< "PartDesign_MultiTransform";
|
|
// For 0.13 a couple of python packages like numpy, matplotlib and others
|
|
// are not deployed with the installer on Windows. Thus, the WizardShaft is
|
|
// not deployed either hence the check for the existence of the command.
|
|
if (Gui::Application::Instance->commandManager().getCommandByName("PartDesign_InvoluteGear")) {
|
|
*part << "PartDesign_InvoluteGear";
|
|
}
|
|
if (Gui::Application::Instance->commandManager().getCommandByName("PartDesign_WizardShaft")) {
|
|
*part << "Separator" << "PartDesign_WizardShaft";
|
|
}
|
|
|
|
return root;
|
|
}
|
|
|
|
Gui::ToolBarItem* Workbench::setupToolBars() const
|
|
{
|
|
Gui::ToolBarItem* root = StdWorkbench::setupToolBars();
|
|
Gui::ToolBarItem* part = new Gui::ToolBarItem(root);
|
|
part->setCommand("Part Design");
|
|
SketcherGui::addSketcherWorkbenchSketchActions( *part );
|
|
*part << "Separator"
|
|
<< "PartDesign_Pad"
|
|
<< "PartDesign_Pocket"
|
|
<< "PartDesign_Revolution"
|
|
<< "PartDesign_Groove"
|
|
<< "PartDesign_Fillet"
|
|
<< "PartDesign_Chamfer"
|
|
<< "PartDesign_Draft"
|
|
<< "PartDesign_Mirrored"
|
|
<< "PartDesign_LinearPattern"
|
|
<< "PartDesign_PolarPattern"
|
|
// << "PartDesign_Scaled"
|
|
<< "PartDesign_MultiTransform";
|
|
|
|
Gui::ToolBarItem* geom = new Gui::ToolBarItem(root);
|
|
geom->setCommand("Sketcher geometries");
|
|
SketcherGui::addSketcherWorkbenchGeometries( *geom );
|
|
|
|
Gui::ToolBarItem* cons = new Gui::ToolBarItem(root);
|
|
cons->setCommand("Sketcher constraints");
|
|
SketcherGui::addSketcherWorkbenchConstraints( *cons );
|
|
|
|
Gui::ToolBarItem* consaccel = new Gui::ToolBarItem(root);
|
|
consaccel->setCommand("Sketcher tools");
|
|
SketcherGui::addSketcherWorkbenchTools( *consaccel );
|
|
|
|
return root;
|
|
}
|
|
|
|
Gui::ToolBarItem* Workbench::setupCommandBars() const
|
|
{
|
|
// Part tools
|
|
Gui::ToolBarItem* root = new Gui::ToolBarItem;
|
|
return root;
|
|
}
|
|
|