FreeCAD

Форк
0
/
gui_downgrade.py 
93 строки · 4.3 Кб
1
# ***************************************************************************
2
# *   (c) 2009, 2010 Yorik van Havre <yorik@uncreated.net>                  *
3
# *   (c) 2009, 2010 Ken Cline <cline@frii.com>                             *
4
# *   (c) 2020 Eliud Cabrera Castillo <e.cabrera-castillo@tum.de>           *
5
# *                                                                         *
6
# *   This file is part of the FreeCAD CAx development system.              *
7
# *                                                                         *
8
# *   This program is free software; you can redistribute it and/or modify  *
9
# *   it under the terms of the GNU Lesser General Public License (LGPL)    *
10
# *   as published by the Free Software Foundation; either version 2 of     *
11
# *   the License, or (at your option) any later version.                   *
12
# *   for detail see the LICENCE text file.                                 *
13
# *                                                                         *
14
# *   FreeCAD is distributed in the hope that it will be useful,            *
15
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
16
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
17
# *   GNU Library General Public License for more details.                  *
18
# *                                                                         *
19
# *   You should have received a copy of the GNU Library General Public     *
20
# *   License along with FreeCAD; if not, write to the Free Software        *
21
# *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
22
# *   USA                                                                   *
23
# *                                                                         *
24
# ***************************************************************************
25
"""Provides GUI tools to downgrade objects.
26

27
Downgrades 2D objects to simpler objects until it reaches
28
simple Edge primitives. For example, a Draft Line to wire, and then
29
to a series of edges.
30
"""
31
## @package gui_downgrade
32
# \ingroup draftguitools
33
# \brief Provides GUI tools to downgrade objects.
34

35
## \addtogroup draftguitools
36
# @{
37
from PySide.QtCore import QT_TRANSLATE_NOOP
38

39
import FreeCADGui as Gui
40
import Draft_rc
41
import draftguitools.gui_base_original as gui_base_original
42
import draftguitools.gui_tool_utils as gui_tool_utils
43
from draftutils.messages import _msg
44
from draftutils.translate import translate
45

46
# The module is used to prevent complaints from code checkers (flake8)
47
True if Draft_rc.__name__ else False
48

49

50
class Downgrade(gui_base_original.Modifier):
51
    """Gui Command for the Downgrade tool."""
52

53
    def GetResources(self):
54
        """Set icon, menu and tooltip."""
55

56
        return {'Pixmap': 'Draft_Downgrade',
57
                'Accel': "D, N",
58
                'MenuText': QT_TRANSLATE_NOOP("Draft_Downgrade", "Downgrade"),
59
                'ToolTip': QT_TRANSLATE_NOOP("Draft_Downgrade", "Downgrades the selected objects into simpler shapes.\nThe result of the operation depends on the types of objects, which may be able to be downgraded several times in a row.\nFor example, it explodes the selected polylines into simpler faces, wires, and then edges. It can also subtract faces.")}
60

61
    def Activated(self):
62
        """Execute when the command is called."""
63
        super().Activated(name="Downgrade")
64
        if not self.ui:
65
            return
66
        if not Gui.Selection.getSelection():
67
            self.ui.selectUi(on_close_call=self.finish)
68
            _msg(translate("draft", "Select an object to upgrade"))
69
            self.call = self.view.addEventCallback("SoEvent", gui_tool_utils.selectObject)
70
        else:
71
            self.proceed()
72

73
    def proceed(self):
74
        """Proceed with execution of the command after selection."""
75
        if self.call is not None:
76
            self.end_callbacks(self.call)
77
        if Gui.Selection.getSelection():
78
            Gui.addModule("Draft")
79
            _cmd = 'Draft.downgrade'
80
            _cmd += '('
81
            _cmd += 'FreeCADGui.Selection.getSelection(), '
82
            _cmd += 'delete=True'
83
            _cmd += ')'
84
            _cmd_list = ['_objs_ = ' + _cmd,
85
                         'FreeCAD.ActiveDocument.recompute()']
86
            self.commit(translate("draft", "Downgrade"),
87
                        _cmd_list)
88
        self.finish()
89

90

91
Gui.addCommand('Draft_Downgrade', Downgrade())
92

93
## @}
94

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

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

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

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