FreeCAD

Форк
0
/
gui_upgrade.py 
93 строки · 4.4 Кб
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 upgrade objects.
26

27
Upgrades simple 2D objects to more complex objects until it reaches
28
Draft scripted objects. For example, an edge to a wire, and to a Draft Line.
29
"""
30
## @package gui_upgrade
31
# \ingroup draftguitools
32
# \brief Provides GUI tools to upgrade objects.
33

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

38
import FreeCADGui as Gui
39
import Draft_rc
40
import draftguitools.gui_base_original as gui_base_original
41
import draftguitools.gui_tool_utils as gui_tool_utils
42

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 Upgrade(gui_base_original.Modifier):
51
    """Gui Command for the Upgrade tool."""
52

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

56
        return {'Pixmap': 'Draft_Upgrade',
57
                'Accel': "U, P",
58
                'MenuText': QT_TRANSLATE_NOOP("Draft_Upgrade", "Upgrade"),
59
                'ToolTip': QT_TRANSLATE_NOOP("Draft_Upgrade", "Upgrades the selected objects into more complex shapes.\nThe result of the operation depends on the types of objects, which may be able to be upgraded several times in a row.\nFor example, it can join the selected objects into one, convert simple edges into parametric polylines,\nconvert closed edges into filled faces and parametric polygons, and merge faces into a single face.")}
60

61
    def Activated(self):
62
        """Execute when the command is called."""
63
        super().Activated(name="Upgrade")
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.upgrade'
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", "Upgrade"),
87
                        _cmd_list)
88
        self.finish()
89

90

91
Gui.addCommand('Draft_Upgrade', Upgrade())
92

93
## @}
94

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

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

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

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