FreeCAD

Форк
0
/
ViewProviderPython.cpp 
99 строк · 4.1 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2010 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/nodes/SoSeparator.h>
26
#endif
27

28
#include <Gui/ViewProviderBuilder.h>
29

30
#include "ViewProviderPython.h"
31

32

33
using namespace SketcherGui;
34

35
PROPERTY_SOURCE(SketcherGui::ViewProviderCustom, SketcherGui::ViewProviderSketch)
36

37
ViewProviderCustom::ViewProviderCustom()
38
{}
39

40
ViewProviderCustom::~ViewProviderCustom()
41
{}
42

43
void ViewProviderCustom::onChanged(const App::Property* prop)
44
{
45
    std::map<const App::Property*, Gui::ViewProvider*>::iterator it;
46
    for (it = propView.begin(); it != propView.end(); ++it) {
47
        App::Property* view = it->second->getPropertyByName(prop->getName());
48
        if (view) {
49
            App::Property* copy = prop->Copy();
50
            if (copy) {
51
                view->Paste(*copy);
52
                delete copy;
53
            }
54
        }
55
    }
56
    ViewProviderSketch::onChanged(prop);
57
}
58

59
void ViewProviderCustom::updateData(const App::Property* prop)
60
{
61
    if (prop->isDerivedFrom<App::PropertyComplexGeoData>()) {
62
        std::map<const App::Property*, Gui::ViewProvider*>::iterator it = propView.find(prop);
63
        if (it == propView.end()) {
64
            Gui::ViewProvider* view = Gui::ViewProviderBuilder::create(prop->getTypeId());
65
            if (view) {
66
                if (view->isDerivedFrom<Gui::ViewProviderDocumentObject>()) {
67
                    static_cast<Gui::ViewProviderDocumentObject*>(view)->attach(this->getObject());
68
                    static_cast<Gui::ViewProviderDocumentObject*>(view)->setDisplayMode(
69
                        this->getActiveDisplayMode().c_str());
70
                }
71
                propView[prop] = view;
72
                view->updateData(prop);
73
                this->getRoot()->addChild(view->getRoot());
74
            }
75
        }
76
        else {
77
            it->second->updateData(prop);
78
        }
79
    }
80
}
81

82
// -----------------------------------------------------------------------
83

84
namespace Gui
85
{
86
/// @cond DOXERR
87
PROPERTY_SOURCE_TEMPLATE(SketcherGui::ViewProviderPython, SketcherGui::ViewProviderSketch)
88
/// @endcond
89

90
// explicit template instantiation
91
template class SketcherGuiExport ViewProviderFeaturePythonT<SketcherGui::ViewProviderSketch>;
92

93
/// @cond DOXERR
94
PROPERTY_SOURCE_TEMPLATE(SketcherGui::ViewProviderCustomPython, SketcherGui::ViewProviderCustom)
95
/// @endcond
96

97
// explicit template instantiation
98
template class SketcherGuiExport ViewProviderFeaturePythonT<SketcherGui::ViewProviderCustom>;
99
}  // namespace Gui
100

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

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

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

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