FreeCAD

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

22
#include "PreCompiled.h"
23

24
#include "Model.h"
25
#include "ModelPropertyPy.h"
26

27
#include "ModelPropertyPy.cpp"
28

29
using namespace Materials;
30

31
// returns a string which represents the object e.g. when printed in python
32
std::string ModelPropertyPy::representation() const
33
{
34
    ModelPropertyPy::PointerType ptr = getModelPropertyPtr();
35
    std::stringstream str;
36
    str << "Property [Name=(";
37
    str << ptr->getName().toStdString();
38
    str << "), Type=(";
39
    str << ptr->getPropertyType().toStdString();
40
    str << "), Units=(";
41
    str << ptr->getUnits().toStdString();
42
    str << "), URL=(";
43
    str << ptr->getURL().toStdString();
44
    str << "), Description=(";
45
    str << ptr->getDescription().toStdString();
46
    str << ")]";
47

48
    return str.str();
49
}
50

51
PyObject* ModelPropertyPy::PyMake(struct _typeobject*, PyObject*, PyObject*)  // Python wrapper
52
{
53
    // never create such objects with the constructor
54
    return new ModelPropertyPy(new ModelProperty());
55
}
56

57
// constructor method
58
int ModelPropertyPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
59
{
60
    return 0;
61
}
62

63
Py::String ModelPropertyPy::getName() const
64
{
65
    return Py::String(getModelPropertyPtr()->getName().toStdString());
66
}
67

68
Py::String ModelPropertyPy::getType() const
69
{
70
    return Py::String(getModelPropertyPtr()->getPropertyType().toStdString());
71
}
72

73
Py::String ModelPropertyPy::getUnits() const
74
{
75
    return Py::String(getModelPropertyPtr()->getUnits().toStdString());
76
}
77

78
Py::String ModelPropertyPy::getURL() const
79
{
80
    return Py::String(getModelPropertyPtr()->getURL().toStdString());
81
}
82

83
Py::String ModelPropertyPy::getDescription() const
84
{
85
    return Py::String(getModelPropertyPtr()->getDescription().toStdString());
86
}
87

88
PyObject* ModelPropertyPy::getCustomAttributes(const char* /*attr*/) const
89
{
90
    return nullptr;
91
}
92

93
int ModelPropertyPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
94
{
95
    return 0;
96
}
97

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

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

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

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