1
/***************************************************************************
2
* Copyright (c) J�rgen Riegel (juergen.riegel@web.de) 2002 *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
24
#include "PreCompiled.h"
32
#include <Gui/Application.h>
33
#include <Gui/Command.h>
34
#include <Gui/MainWindow.h>
35
#include "DlgPartCylinderImp.h"
36
#include "DlgPartBoxImp.h"
38
//===========================================================================
40
//===========================================================================
41
DEF_STD_CMD_A(CmdPartCylinder);
43
CmdPartCylinder::CmdPartCylinder()
44
: Command("Part_Cylinder")
47
sGroup = QT_TR_NOOP("Part");
48
sMenuText = QT_TR_NOOP("Create Cylinder...");
49
sToolTipText = QT_TR_NOOP("Create a Cylinder");
50
sWhatsThis = sToolTipText;
51
sStatusTip = sToolTipText;
52
sPixmap = "Part_Cylinder";
56
void CmdPartCylinder::activated(int iMsg)
58
PartGui::DlgPartCylinderImp dlg(Gui::getMainWindow());
59
if (dlg.exec()== QDialog::Accepted) {
60
Base::Vector3f dir = dlg.getDirection();
61
openCommand("Create Part Cylinder");
62
doCommand(Doc,"from FreeCAD import Base");
63
doCommand(Doc,"import Part");
64
doCommand(Doc,"__cf__ = App.ActiveDocument.addObject(\"Part::Cylinder\",\"Cylinder\")");
65
doCommand(Doc,"__cf__.Location = Base.Vector(%f,%f,%f)",
69
doCommand(Doc,"__cf__.Axis = Base.Vector(%f,%f,%f)",
71
doCommand(Doc,"__cf__.Radius = %f", dlg.radius->value());
72
doCommand(Doc,"__cf__.Height = %f", dlg.length->value());
73
doCommand(Doc,"del __cf__");
79
bool CmdPartCylinder::isActive(void)
81
if (getActiveGuiDocument())
87
//===========================================================================
89
//===========================================================================
90
DEF_STD_CMD_A(CmdPartBox);
92
CmdPartBox::CmdPartBox()
96
sGroup = QT_TR_NOOP("Part");
97
sMenuText = QT_TR_NOOP("Create box...");
98
sToolTipText = QT_TR_NOOP("Create a Box feature");
99
sWhatsThis = "Part_Box";
100
sStatusTip = sToolTipText;
101
sPixmap = "Part_Box";
105
void CmdPartBox::activated(int iMsg)
107
PartGui::DlgPartBoxImp dlg(Gui::getMainWindow());
108
if (dlg.exec()== QDialog::Accepted) {
109
Base::Vector3f dir = dlg.getDirection();
110
openCommand("Part Box Create");
111
doCommand(Doc,"from FreeCAD import Base");
112
doCommand(Doc,"import Part");
113
doCommand(Doc,"__fb__ = App.ActiveDocument.addObject(\"Part::Box\",\"PartBox\")");
114
doCommand(Doc,"__fb__.Location = Base.Vector(%f,%f,%f)",
118
doCommand(Doc,"__fb__.Axis = Base.Vector(%f,%f,%f)",
119
dir.x, dir.y, dir.z);
120
doCommand(Doc,"__fb__.Length = %f",dlg.uLength->value());
121
doCommand(Doc,"__fb__.Width = %f" ,dlg.vLength->value());
122
doCommand(Doc,"__fb__.Height = %f",dlg.wLength->value());
123
doCommand(Doc,"del __fb__");
129
bool CmdPartBox::isActive(void)
131
if (getActiveGuiDocument())
138
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
140
void CreateParamPartCommands(void)
142
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
143
rcCmdMgr.addCommand(new CmdPartCylinder());
144
rcCmdMgr.addCommand(new CmdPartBox());