FreeCAD
74 строки · 3.5 Кб
1# ***************************************************************************
2# * Copyright (c) 2019 Yorik van Havre <yorik@uncreated.net> *
3# * *
4# * This program is free software; you can redistribute it and/or modify *
5# * it under the terms of the GNU Lesser General Public License (LGPL) *
6# * as published by the Free Software Foundation; either version 2 of *
7# * the License, or (at your option) any later version. *
8# * for detail see the LICENCE text file. *
9# * *
10# * This program is distributed in the hope that it will be useful, *
11# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13# * GNU Library General Public License for more details. *
14# * *
15# * You should have received a copy of the GNU Library General Public *
16# * License along with this program; if not, write to the Free Software *
17# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
18# * USA *
19# * *
20# ***************************************************************************
21"""Provides GUI tools to create WorkingPlaneProxy objects."""
22## @package gui_planeproxy
23# \ingroup draftguitools
24# \brief Provides GUI tools to create WorkingPlaneProxy objects.
25
26## \addtogroup draftguitools
27# @{
28from PySide.QtCore import QT_TRANSLATE_NOOP
29
30import FreeCAD as App
31import FreeCADGui as Gui
32import Draft_rc
33
34# The module is used to prevent complaints from code checkers (flake8)
35True if Draft_rc.__name__ else False
36
37__title__ = "FreeCAD Draft Workbench GUI Tools - Working plane-related tools"
38__author__ = ("Yorik van Havre, Werner Mayer, Martin Burbaum, Ken Cline, "
39"Dmitry Chigrin")
40__url__ = "https://www.freecad.org"
41
42
43class Draft_WorkingPlaneProxy:
44"""The Draft_WorkingPlaneProxy command definition."""
45
46def GetResources(self):
47"""Set icon, menu and tooltip."""
48
49d = {'Pixmap': 'Draft_PlaneProxy',
50'MenuText': QT_TRANSLATE_NOOP("Draft_WorkingPlaneProxy","Create working plane proxy"),
51'ToolTip': QT_TRANSLATE_NOOP("Draft_WorkingPlaneProxy","Creates a proxy object from the current working plane.\nOnce the object is created double click it in the tree view to restore the camera position and objects' visibilities.\nThen you can use it to save a different camera position and objects' states any time you need.")}
52return d
53
54def IsActive(self):
55"""Return True when this command should be available."""
56if Gui.ActiveDocument:
57return True
58else:
59return False
60
61def Activated(self):
62"""Execute when the command is called."""
63App.ActiveDocument.openTransaction("Create WP proxy")
64Gui.addModule("Draft")
65Gui.addModule("WorkingPlane")
66Gui.doCommand("pl = WorkingPlane.get_working_plane().get_placement()")
67Gui.doCommand("Draft.make_workingplaneproxy(pl)")
68App.ActiveDocument.commitTransaction()
69App.ActiveDocument.recompute()
70
71
72Gui.addCommand('Draft_WorkingPlaneProxy', Draft_WorkingPlaneProxy())
73
74## @}
75