FreeCAD

Форк
0
/
ViewProviderPartExtPyImp.cpp 
71 строка · 2.9 Кб
1
// SPDX-License-Identifier: LGPL-2.1-or-later
2

3
/***************************************************************************
4
 *   Copyright (c) 2024 David Carter <dcarter@david.carter.ca>             *
5
 *                                                                         *
6
 *   This file is part of FreeCAD.                                         *
7
 *                                                                         *
8
 *   FreeCAD is free software: you can redistribute it and/or modify it    *
9
 *   under the terms of the GNU Lesser General Public License as           *
10
 *   published by the Free Software Foundation, either version 2.1 of the  *
11
 *   License, or (at your option) any later version.                       *
12
 *                                                                         *
13
 *   FreeCAD is distributed in the hope that it will be useful, but        *
14
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
15
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      *
16
 *   Lesser General Public License for more details.                       *
17
 *                                                                         *
18
 *   You should have received a copy of the GNU Lesser General Public      *
19
 *   License along with FreeCAD. If not, see                               *
20
 *   <https://www.gnu.org/licenses/>.                                      *
21
 *                                                                         *
22
 **************************************************************************/
23

24
#include "PreCompiled.h"
25

26
#ifndef _PreComp_
27
#include <sstream>
28
#endif
29

30
#include <App/GeoFeature.h>
31
#include <App/PropertyStandard.h>
32

33
#include "ViewProviderPartExtPy.h"
34
#include "ViewProviderPartExtPy.cpp"
35

36

37
using namespace PartGui;
38

39
// returns a string which represents the object e.g. when printed in python
40
std::string ViewProviderPartExtPy::representation() const
41
{
42
    std::stringstream str;
43
    str << "<View provider geometry object at " << getViewProviderPartExtPtr() << ">";
44

45
    return str.str();
46
}
47

48
PyObject* ViewProviderPartExtPy::getCustomAttributes(const char* attr) const
49
{
50
    ViewProviderPartExt* vp = getViewProviderPartExtPtr();
51
    if (strcmp(attr, "DiffuseColor") == 0) {
52
        // Get the color properties
53
        App::PropertyColorList prop;
54
        prop.setValues(vp->ShapeAppearance.getDiffuseColors());
55
        return prop.getPyObject();
56
    }
57
    return nullptr;
58
}
59

60
int ViewProviderPartExtPy::setCustomAttributes(const char* attr, PyObject* obj)
61
{
62
    ViewProviderPartExt* vp = getViewProviderPartExtPtr();
63
    if (strcmp(attr, "DiffuseColor") == 0) {
64
        // Set the color properties
65
        App::PropertyColorList prop;
66
        prop.setPyObject(obj);
67
        vp->ShapeAppearance.setDiffuseColors(prop.getValues());
68
        return 1;
69
    }
70
    return 0;
71
}
72

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

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

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

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