FreeCAD

Форк
0
/
gui_dimension_ops.py 
85 строк · 4.0 Кб
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 modify dimension objects.
26

27
For example, a tool to flip the direction of the text in the dimension
28
as the normal is sometimes not correctly calculated automatically.
29
"""
30
## @package gui_dimension_ops
31
# \ingroup draftguitools
32
# \brief Provides GUI tools to modify dimension objects.
33

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

38
import FreeCADGui as Gui
39
import draftutils.utils as utils
40
import draftguitools.gui_base as gui_base
41

42
from draftutils.translate import translate
43

44

45
class FlipDimension(gui_base.GuiCommandNeedsSelection):
46
    """The Draft FlipDimension command definition.
47

48
    Flip the normal direction of the selected dimensions.
49

50
    It inherits `GuiCommandNeedsSelection` to set up the document
51
    and other behavior. See this class for more information.
52
    """
53

54
    def __init__(self):
55
        super(Draft_FlipDimension, self).__init__(name=translate("draft","Flip dimension"))
56

57
    def GetResources(self):
58
        """Set icon, menu and tooltip."""
59

60
        return {'Pixmap': 'Draft_FlipDimension',
61
                'MenuText': QT_TRANSLATE_NOOP("Draft_FlipDimension",
62
                                              "Flip dimension"),
63
                'ToolTip': QT_TRANSLATE_NOOP("Draft_FlipDimension",
64
                                             "Flip the normal direction of the selected dimensions (linear, radial, angular).\nIf other objects are selected they are ignored.")}
65

66
    def Activated(self):
67
        """Execute when the command is called."""
68
        super(Draft_FlipDimension, self).Activated()
69

70
        for o in Gui.Selection.getSelection():
71
            if utils.get_type(o) in ("Dimension",
72
                                     "LinearDimension", "AngularDimension"):
73
                self.doc.openTransaction("Flip dimension")
74
                _cmd = "App.activeDocument()." + o.Name + ".Normal"
75
                _cmd += " = "
76
                _cmd += "App.activeDocument()." + o.Name + ".Normal.negative()"
77
                Gui.doCommand(_cmd)
78
                self.doc.commitTransaction()
79
                self.doc.recompute()
80

81

82
Draft_FlipDimension = FlipDimension
83
Gui.addCommand('Draft_FlipDimension', FlipDimension())
84

85
## @}
86

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

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

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

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