FreeCAD

Форк
0
/
ViewProviderPlaneParametric.cpp 
114 строк · 4.1 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de>              *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
6
 *   This library is free software; you can redistribute it and/or         *
7
 *   modify it under the terms of the GNU Library General Public           *
8
 *   License as published by the Free Software Foundation; either          *
9
 *   version 2 of the License, or (at your option) any later version.      *
10
 *                                                                         *
11
 *   This library  is distributed in the hope that it will be useful,      *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU Library General Public License for more details.                  *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU Library General Public     *
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24

25
#include "ViewProviderPlaneParametric.h"
26
#include <Mod/Part/App/FeatureFace.h>
27
#include <Mod/Part/App/Part2DObject.h>
28

29

30
using namespace PartGui;
31

32
//**************************************************************************
33
// Construction/Destruction
34

35
PROPERTY_SOURCE(PartGui::ViewProviderPlaneParametric, PartGui::ViewProviderPrimitive)
36

37

38
ViewProviderPlaneParametric::ViewProviderPlaneParametric()
39
{
40
    sPixmap = "Part_Plane_Parametric";
41
}
42

43
ViewProviderPlaneParametric::~ViewProviderPlaneParametric() = default;
44

45
std::vector<std::string> ViewProviderPlaneParametric::getDisplayModes() const
46
{
47
    // get the modes of the father
48
    std::vector<std::string> StrList;
49

50
    // add your own modes
51
    StrList.emplace_back("Flat Lines");
52
    StrList.emplace_back("Shaded");
53
    StrList.emplace_back("Wireframe");
54
    StrList.emplace_back("Points");
55

56
    return StrList;
57
}
58

59
// ----------------------------------------------------------------------------
60

61
PROPERTY_SOURCE(PartGui::ViewProviderFace, PartGui::ViewProviderPlaneParametric)
62

63

64
ViewProviderFace::ViewProviderFace() = default;
65

66
ViewProviderFace::~ViewProviderFace() = default;
67

68
std::vector<App::DocumentObject*> ViewProviderFace::claimChildren() const
69
{
70
    return static_cast<Part::Face*>(getObject())->Sources.getValues();
71
}
72

73
bool ViewProviderFace::canDragObjects() const
74
{
75
    return true;
76
}
77

78
bool ViewProviderFace::canDragObject(App::DocumentObject* obj) const
79
{
80
    (void)obj;
81
    // return Part::Feature::hasShapeOwner(obj);
82
    return true;
83
}
84

85
void ViewProviderFace::dragObject(App::DocumentObject* obj)
86
{
87
    Part::Face* face = static_cast<Part::Face*>(getObject());
88
    std::vector<App::DocumentObject*> sources = face->Sources.getValues();
89
    for (std::vector<App::DocumentObject*>::iterator it = sources.begin(); it != sources.end(); ++it) {
90
        if (*it == obj) {
91
            sources.erase(it);
92
            face->Sources.setValues(sources);
93
            break;
94
        }
95
    }
96
}
97

98
bool ViewProviderFace::canDropObjects() const
99
{
100
    return true;
101
}
102

103
bool ViewProviderFace::canDropObject(App::DocumentObject* obj) const
104
{
105
    return canDragObject(obj);
106
}
107

108
void ViewProviderFace::dropObject(App::DocumentObject* obj)
109
{
110
    Part::Face* face = static_cast<Part::Face*>(getObject());
111
    std::vector<App::DocumentObject*> sources = face->Sources.getValues();
112
    sources.push_back(obj);
113
    face->Sources.setValues(sources);
114
}
115

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

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

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

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