FreeCAD

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

28
__title__ = "FreeCAD Draft Edit Tool"
29
__author__ = ("Yorik van Havre, Werner Mayer, Martin Burbaum, Ken Cline, "
30
              "Dmitry Chigrin, Carlo Pavan")
31
__url__ = "https://www.freecad.org"
32

33
## \addtogroup draftguitools
34
# @{
35
import FreeCAD as App
36
from draftutils.translate import translate
37

38
from draftguitools.gui_edit_base_object import GuiTools
39

40

41
class SketcherSketchObjectGuiTools(GuiTools):
42

43
    def __init__(self):
44
        pass
45

46
    def get_edit_points(self, obj):
47
        """Return the list of edipoints for the given single line sketch.
48
        (WallTrace)
49
        0 : startpoint
50
        1 : endpoint
51
        """
52
        import Part
53
        editpoints = []
54
        if (obj.ConstraintCount == 0
55
                and obj.GeometryCount == 1
56
                and type(obj.Geometry[0]) == Part.LineSegment):
57
            editpoints.append(obj.getPoint(0,1))
58
            editpoints.append(obj.getPoint(0,2))
59
            return editpoints
60
        else:
61
            _wrn = translate("draft", "Sketch is too complex to edit: "
62
                                    "it is suggested to use sketcher default editor")
63
            App.Console.PrintWarning(_wrn + "\n")
64
            return None
65

66
    def update_object_from_edit_points(self, obj, node_idx, v, alt_edit_mode=0):
67
        """Move a single line sketch vertex a certain displacement.
68

69
        (single segment sketch object, node index as Int, App.Vector)
70
        move a single line sketch (WallTrace) vertex according to a given App.Vector
71
        0 : startpoint
72
        1 : endpoint
73
        """
74
        line = obj.Geometry[0]
75
        if node_idx == 0:
76
            line.StartPoint = v
77
        elif node_idx == 1:
78
            line.EndPoint = v
79
        obj.Geometry = [line]
80
        obj.recompute()
81

82
## @}
83

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

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

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

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