FreeCAD

Форк
0
/
ViewProviderPyImp.cpp 
704 строки · 21.7 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2007 Werner Mayer <wmayer[at]users.sourceforge.net>     *
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
#ifndef _PreComp_
25
# include <Inventor/SbRotation.h>
26
# include <Inventor/SoFullPath.h>
27
# include <Inventor/details/SoDetail.h>
28
# include <Inventor/nodes/SoSeparator.h>
29
# include <Inventor/nodes/SoSwitch.h>
30
# include <QByteArray>
31
# include <QDataStream>
32
#endif
33

34
#include <Base/BoundBoxPy.h>
35
#include <Base/PyWrapParseTupleAndKeywords.h>
36

37
#include "PythonWrapper.h"
38
#include "SoFCDB.h"
39

40
// inclusion of the generated files (generated out of ViewProviderPy.xml)
41
#include <Gui/ViewProviderPy.h>
42
#include <Gui/ViewProviderPy.cpp>
43
#include <Gui/View3DPy.h>
44
#include <Gui/View3DInventor.h>
45
#include <Base/Interpreter.h>
46
#include <Base/Matrix.h>
47
#include <Base/MatrixPy.h>
48
#include <Base/Placement.h>
49
#include <Base/PlacementPy.h>
50
#include <App/Document.h>
51
#include <App/DocumentObject.h>
52
#include <App/DocumentObjectPy.h>
53

54

55
using namespace Gui;
56

57
// returns a string which represent the object e.g. when printed in python
58
std::string ViewProviderPy::representation() const
59
{
60
    return "<View provider object>";
61
}
62

63
PyObject*  ViewProviderPy::addProperty(PyObject *args)
64
{
65
    char *sType,*sName=nullptr,*sGroup=nullptr,*sDoc=nullptr;
66
    short attr=0;
67
    std::string sDocStr;
68
    PyObject *ro = Py_False, *hd = Py_False;
69
    if (!PyArg_ParseTuple(args, "s|ssethO!O!", &sType,&sName,&sGroup,"utf-8",&sDoc,&attr,
70
        &PyBool_Type, &ro, &PyBool_Type, &hd))
71
        return nullptr;
72

73
    if (sDoc) {
74
        sDocStr = sDoc;
75
        PyMem_Free(sDoc);
76
    }
77

78
    App::Property* prop=nullptr;
79
    try {
80
        prop = getViewProviderPtr()->addDynamicProperty(sType,sName,sGroup,sDocStr.c_str(),attr,
81
            Base::asBoolean(ro), Base::asBoolean(hd));
82
    }
83
    catch (const Base::Exception& e) {
84
        throw Py::RuntimeError(e.what());
85
    }
86
    if (!prop) {
87
        std::stringstream str;
88
        str << "No property found of type '" << sType << "'" << std::ends;
89
        throw Py::TypeError(str.str());
90
    }
91

92
    return Py::new_reference_to(this);
93
}
94

95
PyObject*  ViewProviderPy::removeProperty(PyObject *args)
96
{
97
    char *sName;
98
    if (!PyArg_ParseTuple(args, "s", &sName))
99
        return nullptr;
100

101
    try {
102
        bool ok = getViewProviderPtr()->removeDynamicProperty(sName);
103
        return Py_BuildValue("O", (ok ? Py_True : Py_False));
104
    }
105
    catch (const Base::Exception& e) {
106
        throw Py::RuntimeError(e.what());
107
    }
108
}
109

110
PyObject*  ViewProviderPy::supportedProperties(PyObject *args)
111
{
112
    if (!PyArg_ParseTuple(args, ""))
113
        return nullptr;
114

115
    std::vector<Base::Type> ary;
116
    Base::Type::getAllDerivedFrom(App::Property::getClassTypeId(), ary);
117
    Py::List res;
118
    for (auto & it : ary) {
119
        auto data = static_cast<Base::BaseClass*>(it.createInstance());
120
        if (data) {
121
            delete data;
122
            res.append(Py::String(it.getName()));
123
        }
124
    }
125
    return Py::new_reference_to(res);
126
}
127

128
PyObject*  ViewProviderPy::show(PyObject *args)
129
{
130
    if (!PyArg_ParseTuple(args, ""))
131
        return nullptr;
132

133
    PY_TRY {
134
        getViewProviderPtr()->show();
135
        Py_Return;
136
    }
137
    PY_CATCH;
138
}
139

140
PyObject*  ViewProviderPy::hide(PyObject *args)
141
{
142
    if (!PyArg_ParseTuple(args, ""))
143
        return nullptr;
144

145
    PY_TRY {
146
        getViewProviderPtr()->hide();
147
        Py_Return;
148
    }
149
    PY_CATCH;
150
}
151

152
PyObject*  ViewProviderPy::isVisible(PyObject *args)
153
{
154
    if (!PyArg_ParseTuple(args, ""))
155
        return nullptr;
156

157
    PY_TRY {
158
        return Py::new_reference_to(Py::Boolean(getViewProviderPtr()->isShow()));
159
    }
160
    PY_CATCH;
161
}
162

163
PyObject*  ViewProviderPy::canDragObject(PyObject *args)
164
{
165
    PyObject *obj = Py_None;
166
    if (!PyArg_ParseTuple(args, "|O", &obj))
167
        return nullptr;
168

169
    PY_TRY {
170
        Base::PyTypeCheck(&obj, &App::DocumentObjectPy::Type);
171
        bool ret;
172
        if (!obj)
173
            ret = getViewProviderPtr()->canDragObjects();
174
        else
175
            ret = getViewProviderPtr()->canDragObject(
176
                    static_cast<App::DocumentObjectPy*>(obj)->getDocumentObjectPtr());
177

178
        return Py::new_reference_to(Py::Boolean(ret));
179
    }
180
    PY_CATCH;
181
}
182

183
PyObject*  ViewProviderPy::canDropObject(PyObject *args, PyObject *kw)
184
{
185
    PyObject *obj = Py_None;
186
    PyObject *owner = Py_None;
187
    PyObject *pyElements = Py_None;
188
    const char *subname = nullptr;
189
    static const std::array<const char *, 5> kwlist{"obj", "owner", "subname", "elem", nullptr};
190
    if (!Base::Wrapped_ParseTupleAndKeywords(args, kw, "|OOsO", kwlist,
191
                                            &obj, &owner, &subname, &pyElements)) {
192
        return nullptr;
193
    }
194

195
    PY_TRY {
196
        Base::PyTypeCheck(&obj, &App::DocumentObjectPy::Type, "expecting 'obj' to be of type App.DocumentObject or None");
197
        Base::PyTypeCheck(&owner, &App::DocumentObjectPy::Type, "expecting 'owner' to be of type App.DocumentObject or None");
198
        Base::PyTypeCheck(&pyElements, PySequence_Check, "expecting 'elem' to be sequence or None");
199

200
        bool ret;
201
        App::DocumentObject* pcObject;
202
        App::DocumentObject* pcOwner = nullptr;
203
        App::PropertyStringList elements;
204
        if (!obj && (owner || pyElements || subname)) {
205
            PyErr_SetString(PyExc_ValueError, "'obj' must be specified if 'owner', 'subname' or 'elem' is given");
206
            return nullptr;
207
        }
208
        if(!obj) {
209
            ret = getViewProviderPtr()->canDropObjects();
210
            return Py::new_reference_to(Py::Boolean(ret));
211
        }
212
        pcObject = static_cast<App::DocumentObjectPy*>(obj)->getDocumentObjectPtr();
213
        if (owner)
214
            pcOwner = static_cast<App::DocumentObjectPy*>(owner)->getDocumentObjectPtr();
215
        if (pyElements) {
216
            try {
217
                elements.setPyObject(pyElements);
218
            }
219
            catch(...) {
220
                PyErr_SetString(PyExc_TypeError, "'elem' must be a sequence of strings");
221
                return nullptr;
222
            }
223
        }
224
        ret = getViewProviderPtr()->canDropObjectEx(pcObject,pcOwner,subname,elements.getValues());
225
        return Py::new_reference_to(Py::Boolean(ret));
226
    }
227
    PY_CATCH;
228
}
229

230
PyObject*  ViewProviderPy::canDragAndDropObject(PyObject *args)
231
{
232
    PyObject *obj;
233
    if (!PyArg_ParseTuple(args, "O!", &App::DocumentObjectPy::Type,&obj))
234
        return nullptr;
235

236
    PY_TRY {
237
        bool ret = getViewProviderPtr()->canDragAndDropObject(
238
                    static_cast<App::DocumentObjectPy*>(obj)->getDocumentObjectPtr());
239
        return Py::new_reference_to(Py::Boolean(ret));
240
    }
241
    PY_CATCH;
242
}
243

244
PyObject*  ViewProviderPy::dropObject(PyObject *args, PyObject *kw)
245
{
246
    PyObject *obj;
247
    PyObject *owner = Py_None;
248
    PyObject *pyElements = Py_None;
249
    const char *subname = nullptr;
250
    static const std::array<const char *, 5> kwlist{"obj", "owner", "subname", "elem", nullptr};
251
    if (!Base::Wrapped_ParseTupleAndKeywords(args, kw, "O!|OsO", kwlist,
252
                                             &App::DocumentObjectPy::Type, &obj, &owner, &subname, &pyElements)) {
253
        return nullptr;
254
    }
255

256
    PY_TRY {
257
        Base::PyTypeCheck(&owner, &App::DocumentObjectPy::Type, "expecting 'owner' to be of type App.DocumentObject or None");
258
        Base::PyTypeCheck(&pyElements, PySequence_Check, "expecting 'elem' to be sequence or None");
259

260
        auto pcObject = static_cast<App::DocumentObjectPy*>(obj)->getDocumentObjectPtr();
261
        App::DocumentObject *pcOwner = nullptr;
262
        App::PropertyStringList elements;
263
        if (owner)
264
            pcOwner = static_cast<App::DocumentObjectPy*>(owner)->getDocumentObjectPtr();
265
        if (pyElements) {
266
            try {
267
                elements.setPyObject(pyElements);
268
            }
269
            catch(...) {
270
                PyErr_SetString(PyExc_TypeError, "'elem' must be a sequence of strings");
271
                return nullptr;
272
            }
273
        }
274
        auto ret = getViewProviderPtr()->dropObjectEx(pcObject,pcOwner, subname,elements.getValues());
275
        return Py::new_reference_to(Py::String(ret));
276
    }
277
    PY_CATCH;
278
}
279

280
PyObject*  ViewProviderPy::dragObject(PyObject *args)
281
{
282
    PyObject *obj;
283
    if (!PyArg_ParseTuple(args, "O!", &App::DocumentObjectPy::Type,&obj))
284
        return nullptr;
285

286
    PY_TRY {
287
        getViewProviderPtr()->dragObject(
288
                static_cast<App::DocumentObjectPy*>(obj)->getDocumentObjectPtr());
289
        Py_Return;
290
    }
291
    PY_CATCH;
292
}
293

294
PyObject* ViewProviderPy::replaceObject(PyObject *args)
295
{
296
    PyObject *oldObj;
297
    PyObject *newObj;
298
    if (!PyArg_ParseTuple(args, "O!O!",
299
                &App::DocumentObjectPy::Type,&oldObj,
300
                &App::DocumentObjectPy::Type,&newObj))
301
        return nullptr;
302

303
    PY_TRY {
304
        int ret = getViewProviderPtr()->replaceObject(
305
                static_cast<App::DocumentObjectPy*>(oldObj)->getDocumentObjectPtr(),
306
                static_cast<App::DocumentObjectPy*>(newObj)->getDocumentObjectPtr());
307
        return Py::new_reference_to(Py::Int(ret));
308
    }
309
    PY_CATCH;
310
}
311

312
PyObject* ViewProviderPy::addDisplayMode(PyObject * args)
313
{
314
    char* mode;
315
    PyObject* obj;
316
    if (!PyArg_ParseTuple(args, "Os", &obj, &mode))
317
        return nullptr;
318

319
    void* ptr = nullptr;
320
    try {
321
        Base::Interpreter().convertSWIGPointerObj("pivy.coin","_p_SoNode", obj, &ptr, 0);
322
    }
323
    catch (const Base::Exception& e) {
324
        PyErr_SetString(PyExc_RuntimeError, e.what());
325
        return nullptr;
326
    }
327

328
    PY_TRY {
329
        auto node = static_cast<SoNode*>(ptr);
330
        getViewProviderPtr()->addDisplayMaskMode(node,mode);
331
        Py_Return;
332
    }
333
    PY_CATCH;
334
}
335

336
PyObject*  ViewProviderPy::listDisplayModes(PyObject *args)
337
{
338
    if (!PyArg_ParseTuple(args, ""))
339
        return nullptr;
340

341
    PY_TRY {
342
        std::vector<std::string> modes = getViewProviderPtr()->getDisplayModes();
343
        PyObject* pyList = PyList_New(modes.size());
344
        int i=0;
345

346
        for (const auto & mode : modes) {
347
            PyObject* str = PyUnicode_FromString(mode.c_str());
348
            PyList_SetItem(pyList, i++, str);
349
        }
350

351
        return pyList;
352
    }
353
    PY_CATCH;
354
}
355

356
PyObject*  ViewProviderPy::toString(PyObject *args)
357
{
358
    if (!PyArg_ParseTuple(args, ""))
359
        return nullptr;
360

361
    PY_TRY {
362
        std::string buffer = getViewProviderPtr()->toString();
363
        return Py::new_reference_to(Py::String(buffer));
364
    }
365
    PY_CATCH;
366
}
367

368
PyObject*  ViewProviderPy::setTransformation(PyObject *args)
369
{
370
    PyObject* p;
371
    Base::Matrix4D mat;
372
    if (PyArg_ParseTuple(args, "O!",&(Base::MatrixPy::Type),&p)) {
373
        mat = *static_cast<Base::MatrixPy*>(p)->getMatrixPtr();
374
        getViewProviderPtr()->setTransformation(mat);
375
        Py_Return;
376
    }
377
    PyErr_Clear();
378

379
    if (PyArg_ParseTuple(args, "O!",&(Base::PlacementPy::Type),&p)) {
380
        auto plc = static_cast<Base::PlacementPy*>(p);
381
        getViewProviderPtr()->setTransformation(plc->getPlacementPtr()->toMatrix());
382
        Py_Return;
383
    }
384

385
    PyErr_SetString(PyExc_TypeError, "The transformation must be a Base.Matrix or a Base.Placement");
386
    return nullptr;
387
}
388

389
PyObject* ViewProviderPy::claimChildren(PyObject* args)
390
{
391
    if (!PyArg_ParseTuple(args, ""))
392
        return nullptr;
393

394
    std::vector<App::DocumentObject*> children = this->getViewProviderPtr()->claimChildren();
395
    Py::List ret;
396
    for(auto* child : children){
397
        if (child)
398
            ret.append(Py::asObject(child->getPyObject()));
399
        else
400
            ret.append(Py::None());
401
    }
402
    return Py::new_reference_to(ret);
403
}
404

405
PyObject* ViewProviderPy::claimChildrenRecursive(PyObject* args)
406
{
407
    if (!PyArg_ParseTuple(args, ""))
408
        return nullptr;
409

410
    std::vector<App::DocumentObject*> children = this->getViewProviderPtr()->claimChildrenRecursive();
411
    Py::List ret;
412
    for(auto* child : children){
413
        if (child)
414
            ret.append(Py::asObject(child->getPyObject()));
415
        else
416
            ret.append(Py::None());
417
    }
418
    return Py::new_reference_to(ret);
419
}
420

421
PyObject* ViewProviderPy::partialRender(PyObject* args)
422
{
423
    PyObject *value = Py_None;
424
    PyObject *clear = Py_False;
425
    if (!PyArg_ParseTuple(args, "|OO!",&value,&PyBool_Type,&clear))
426
        return nullptr;
427

428
    std::vector<std::string> values;
429
    if (value != Py_None) {
430
        std::vector<Py::Object> pylist;
431
        if (PyList_Check(value) || PyTuple_Check(value)) {
432
            Py::Sequence seq(value);
433
            for (const auto& it : seq) {
434
                pylist.emplace_back(it);
435
            }
436
        }
437
        else {
438
            pylist.emplace_back(value);
439
        }
440

441
        values.reserve(pylist.size());
442
        for (const auto& it : pylist) {
443
            if (it.isString()) {
444
                values.push_back(Py::String(it));
445
            }
446
            else {
447
                std::string error = std::string("type must be str");
448
                error += " not, ";
449
                error += it.ptr()->ob_type->tp_name;
450
                throw Py::TypeError(error);
451
            }
452
        }
453
    }
454

455
    Py::Int ret(getViewProviderPtr()->partialRender(values, Base::asBoolean(clear)));
456
    return Py::new_reference_to(ret);
457
}
458

459
PyObject* ViewProviderPy::getElementColors(PyObject* args)
460
{
461
    const char *element = nullptr;
462
    if (!PyArg_ParseTuple(args, "|s", &element))
463
        return nullptr;
464

465
    Py::Dict dict;
466
    for(auto &v : getViewProviderPtr()->getElementColors(element)) {
467
        auto &c = v.second;
468
        dict.setItem(Py::String(v.first),
469
                Py::TupleN(Py::Float(c.r),Py::Float(c.g),Py::Float(c.b),Py::Float(c.a)));
470
    }
471
    return Py::new_reference_to(dict);
472
}
473

474
PyObject* ViewProviderPy::setElementColors(PyObject* args)
475
{
476
    PyObject *pyObj;
477
    if (!PyArg_ParseTuple(args, "O", &pyObj))
478
        return nullptr;
479

480
    if(!PyDict_Check(pyObj))
481
        throw Py::TypeError("Expect a dict");
482

483
    std::map<std::string,App::Color> colors;
484
    Py::Dict dict(pyObj);
485
    for(auto it=dict.begin();it!=dict.end();++it) {
486
        const auto &value = *it;
487
        if(!value.first.isString() || !value.second.isSequence())
488
            throw Py::TypeError("Expect the dictionary to contain items of type elementName:(r,g,b,a)");
489

490
        App::PropertyColor prop;
491
        prop.setPyObject(value.second.ptr());
492
        colors[value.first.as_string()] = prop.getValue();
493
    }
494
    getViewProviderPtr()->setElementColors(colors);
495
    Py_Return;
496
}
497

498
PyObject* ViewProviderPy::getElementPicked(PyObject* args)
499
{
500
    PyObject *obj;
501
    if (!PyArg_ParseTuple(args, "O",&obj))
502
        return nullptr;
503

504
    void *ptr = nullptr;
505
    Base::Interpreter().convertSWIGPointerObj("pivy.coin", "_p_SoPickedPoint", obj, &ptr, 0);
506
    auto pp = static_cast<SoPickedPoint*>(ptr);
507
    if(!pp)
508
        throw Base::TypeError("type must be coin.SoPickedPoint");
509

510
    std::string name;
511
    if(!getViewProviderPtr()->getElementPicked(pp,name))
512
        Py_Return;
513

514
    return Py::new_reference_to(Py::String(name));
515
}
516

517
PyObject* ViewProviderPy::getDetailPath(PyObject* args)
518
{
519
    const char *sub;
520
    PyObject *path;
521
    PyObject *append = Py_True;
522
    if (!PyArg_ParseTuple(args, "sO|O!",&sub,&path,&PyBool_Type,&append))
523
        return nullptr;
524

525
    void *ptr = nullptr;
526
    Base::Interpreter().convertSWIGPointerObj("pivy.coin", "_p_SoPath", path, &ptr, 0);
527
    auto pPath = static_cast<SoPath*>(ptr);
528
    if(!pPath)
529
        throw Base::TypeError("'path' must be a coin.SoPath");
530
    SoDetail *det = nullptr;
531
    if(!getViewProviderPtr()->getDetailPath(sub,static_cast<SoFullPath*>(pPath),append,det)) {
532
        delete det;
533
        Py_Return;
534
    }
535
    if(!det)
536
        Py_Return;
537
    return Base::Interpreter().createSWIGPointerObj("pivy.coin", "_p_SoDetail", static_cast<void*>(det), 0);
538
}
539

540
PyObject *ViewProviderPy::signalChangeIcon(PyObject *args)
541
{
542
    if (!PyArg_ParseTuple(args, ""))
543
        return nullptr;
544

545
    getViewProviderPtr()->signalChangeIcon();
546
    Py_Return;
547
}
548

549
PyObject *ViewProviderPy::getBoundingBox(PyObject *args) {
550
    PyObject *transform=Py_True;
551
    PyObject *pyView = nullptr;
552
    const char *subname = nullptr;
553
    if (!PyArg_ParseTuple(args, "|sO!O!", &subname,&PyBool_Type,&transform,View3DInventorPy::type_object(),&pyView))
554
        return nullptr;
555

556
    PY_TRY {
557
        View3DInventor *view = nullptr;
558
        if(pyView)
559
            view = static_cast<View3DInventorPy*>(pyView)->getView3DIventorPtr();
560
        auto bbox = getViewProviderPtr()->getBoundingBox(subname, Base::asBoolean(transform), view);
561
        return new Base::BoundBoxPy(new Base::BoundBox3d(bbox));
562
    }
563
    PY_CATCH;
564
}
565

566
PyObject *ViewProviderPy::doubleClicked(PyObject *args) {
567
    if(!PyArg_ParseTuple(args, ""))
568
        return nullptr;
569

570
    PY_TRY {
571
        return Py::new_reference_to(Py::Boolean(getViewProviderPtr()->doubleClicked()));
572
    }
573
    PY_CATCH;
574
}
575

576
PyObject *ViewProviderPy::getCustomAttributes(const char* attr) const
577
{
578
    // search for dynamic property
579
    App::Property* prop = getViewProviderPtr()->getDynamicPropertyByName(attr);
580
    if (prop)
581
        return prop->getPyObject();
582
    else
583
        return nullptr;
584
}
585

586
int ViewProviderPy::setCustomAttributes(const char* attr, PyObject* value)
587
{
588
    // search for dynamic property
589
    try {
590
        App::Property* prop = getViewProviderPtr()->getDynamicPropertyByName(attr);
591
        if (prop) {
592
            prop->setPyObject(value);
593
            return 1;
594
        }
595
        return 0;
596
    }
597
    catch (Base::Exception &exc) {
598
        PyErr_Format(PyExc_AttributeError, "Attribute (Name: %s) error: '%s' ", attr, exc.what());
599
        return -1;
600
    }
601
    catch (...) {
602
        PyErr_Format(PyExc_AttributeError, "Unknown error in attribute %s", attr);
603
        return -1;
604
    }
605
}
606

607
Py::Object ViewProviderPy::getAnnotation() const
608
{
609
    try {
610
        auto node = getViewProviderPtr()->getAnnotation();
611
        PyObject* Ptr = Base::Interpreter().createSWIGPointerObj("pivy.coin", "_p_SoSeparator", node, 1);
612
        node->ref();
613
        return Py::Object(Ptr, true);
614
    }
615
    catch (const Base::Exception& e) {
616
        throw Py::RuntimeError(e.what());
617
    }
618
}
619

620
void  ViewProviderPy::setAnnotation(Py::Object)
621
{
622

623
}
624

625
Py::Object ViewProviderPy::getRootNode() const
626
{
627
    try {
628
        SoSeparator* node = getViewProviderPtr()->getRoot();
629
        PyObject* Ptr = Base::Interpreter().createSWIGPointerObj("pivy.coin","_p_SoSeparator", node, 1);
630
        node->ref();
631
        return Py::Object(Ptr, true);
632
    }
633
    catch (const Base::Exception& e) {
634
        throw Py::RuntimeError(e.what());
635
    }
636
}
637

638
void  ViewProviderPy::setRootNode(Py::Object)
639
{
640

641
}
642

643
Py::Object ViewProviderPy::getSwitchNode() const
644
{
645
    try {
646
        SoSwitch* node = getViewProviderPtr()->getModeSwitch();
647
        PyObject* Ptr = Base::Interpreter().createSWIGPointerObj("pivy.coin","_p_SoSwitch", node, 1);
648
        node->ref();
649
        return Py::Object(Ptr, true);
650
    }
651
    catch (const Base::Exception& e) {
652
        throw Py::RuntimeError(e.what());
653
    }
654
}
655

656
void  ViewProviderPy::setSwitchNode(Py::Object)
657
{
658

659
}
660

661
Py::String ViewProviderPy::getIV() const
662
{
663
    std::string buf = Gui::SoFCDB::writeNodesToString(getViewProviderPtr()->getRoot());
664
    return {buf};
665
}
666

667
Py::Object ViewProviderPy::getIcon() const
668
{
669
    PythonWrapper wrap;
670
    wrap.loadGuiModule();
671
    wrap.loadWidgetsModule();
672
    QIcon icon = getViewProviderPtr()->getIcon();
673
    return wrap.fromQIcon(new QIcon(icon));
674
}
675

676
Py::Int ViewProviderPy::getDefaultMode() const
677
{
678
    return Py::Int((long)getViewProviderPtr()->getDefaultMode());
679
}
680

681
void ViewProviderPy::setDefaultMode(Py::Int arg)
682
{
683
    return getViewProviderPtr()->setDefaultMode(arg);
684
}
685

686
Py::Boolean ViewProviderPy::getCanRemoveChildrenFromRoot() const
687
{
688
    return {getViewProviderPtr()->canRemoveChildrenFromRoot()};
689
}
690

691
Py::Boolean ViewProviderPy::getLinkVisibility() const
692
{
693
    return {getViewProviderPtr()->isLinkVisible()};
694
}
695

696
void ViewProviderPy::setLinkVisibility(Py::Boolean arg)
697
{
698
    getViewProviderPtr()->setLinkVisible(arg);
699
}
700

701
Py::String ViewProviderPy::getDropPrefix() const
702
{
703
    return {getViewProviderPtr()->getDropPrefix()};
704
}
705

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

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

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

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