FreeCAD

Форк
0
/
gui_planeproxy.py 
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
# @{
28
from PySide.QtCore import QT_TRANSLATE_NOOP
29

30
import FreeCAD as App
31
import FreeCADGui as Gui
32
import Draft_rc
33

34
# The module is used to prevent complaints from code checkers (flake8)
35
True 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

43
class Draft_WorkingPlaneProxy:
44
    """The Draft_WorkingPlaneProxy command definition."""
45

46
    def GetResources(self):
47
        """Set icon, menu and tooltip."""
48

49
        d = {'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.")}
52
        return d
53

54
    def IsActive(self):
55
        """Return True when this command should be available."""
56
        if Gui.ActiveDocument:
57
            return True
58
        else:
59
            return False
60

61
    def Activated(self):
62
        """Execute when the command is called."""
63
        App.ActiveDocument.openTransaction("Create WP proxy")
64
        Gui.addModule("Draft")
65
        Gui.addModule("WorkingPlane")
66
        Gui.doCommand("pl = WorkingPlane.get_working_plane().get_placement()")
67
        Gui.doCommand("Draft.make_workingplaneproxy(pl)")
68
        App.ActiveDocument.commitTransaction()
69
        App.ActiveDocument.recompute()
70

71

72
Gui.addCommand('Draft_WorkingPlaneProxy', Draft_WorkingPlaneProxy())
73

74
## @}
75

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.