1
/***************************************************************************
2
* Copyright (c) 2018 Werner Mayer <wmayer[at]users.sourceforge.net> *
4
* This file is part of the FreeCAD CAx development system. *
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. *
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. *
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 *
21
***************************************************************************/
23
#include "PreCompiled.h"
28
#include "ViewProvider.h"
29
// inclusion of the generated files (generated out of ViewProviderMeshPy.xml)
30
#include "ViewProviderMeshPy.h"
31
#include "ViewProviderMeshPy.cpp"
34
using namespace MeshGui;
36
// returns a string which represents the object e.g. when printed in python
37
std::string ViewProviderMeshPy::representation() const
39
std::stringstream str;
40
str << "<View provider object at " << getViewProviderDocumentObjectPtr() << ">";
45
PyObject* ViewProviderMeshPy::setSelection(PyObject* args)
48
if (!PyArg_ParseTuple(args, "O", &obj)) {
52
Py::Sequence list(obj);
53
std::vector<Mesh::FacetIndex> selection;
54
selection.reserve(list.size());
55
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
57
Mesh::FacetIndex value = static_cast<Mesh::FacetIndex>(index);
58
selection.push_back(value);
61
ViewProviderMesh* vp = getViewProviderMeshPtr();
62
vp->setSelection(selection);
66
PyObject* ViewProviderMeshPy::addSelection(PyObject* args)
69
if (!PyArg_ParseTuple(args, "O", &obj)) {
73
Py::Sequence list(obj);
74
std::vector<Mesh::FacetIndex> selection;
75
selection.reserve(list.size());
76
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
78
Mesh::FacetIndex value = static_cast<Mesh::FacetIndex>(index);
79
selection.push_back(value);
82
ViewProviderMesh* vp = getViewProviderMeshPtr();
83
vp->addSelection(selection);
87
PyObject* ViewProviderMeshPy::removeSelection(PyObject* args)
90
if (!PyArg_ParseTuple(args, "O", &obj)) {
94
Py::Sequence list(obj);
95
std::vector<Mesh::FacetIndex> selection;
96
selection.reserve(list.size());
97
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
99
Mesh::FacetIndex value = static_cast<Mesh::FacetIndex>(index);
100
selection.push_back(value);
103
ViewProviderMesh* vp = getViewProviderMeshPtr();
104
vp->removeSelection(selection);
108
PyObject* ViewProviderMeshPy::invertSelection(PyObject* args)
110
if (!PyArg_ParseTuple(args, "")) {
114
ViewProviderMesh* vp = getViewProviderMeshPtr();
115
vp->invertSelection();
119
PyObject* ViewProviderMeshPy::clearSelection(PyObject* args)
121
if (!PyArg_ParseTuple(args, "")) {
125
ViewProviderMesh* vp = getViewProviderMeshPtr();
126
vp->clearSelection();
130
PyObject* ViewProviderMeshPy::highlightSegments(PyObject* args)
133
if (!PyArg_ParseTuple(args, "O", &list)) {
137
App::PropertyColorList colors;
138
colors.setPyObject(list);
140
ViewProviderMesh* vp = getViewProviderMeshPtr();
141
vp->highlightSegments(colors.getValues());
145
PyObject* ViewProviderMeshPy::getCustomAttributes(const char* /*attr*/) const
150
int ViewProviderMeshPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)