FreeCAD

Форк
0
/
ViewProviderView.cpp 
221 строка · 7.2 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de>              *
3
 *                                                                         *
4
 *   This file is Drawing 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 DrawingICULAR 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

25
#include <App/DocumentObject.h>
26
#include <Mod/Drawing/App/FeatureClip.h>
27
#include <Mod/Drawing/App/FeatureView.h>
28

29
#include "ViewProviderView.h"
30

31

32
using namespace DrawingGui;
33

34
PROPERTY_SOURCE(DrawingGui::ViewProviderDrawingView, Gui::ViewProviderDocumentObject)
35

36
ViewProviderDrawingView::ViewProviderDrawingView()
37
{
38
    sPixmap = "Page";
39

40
    // Do not show in property editor
41
    DisplayMode.setStatus(App::Property::Hidden, true);
42
}
43

44
ViewProviderDrawingView::~ViewProviderDrawingView()
45
{}
46

47
void ViewProviderDrawingView::attach(App::DocumentObject* pcFeat)
48
{
49
    // call parent attach method
50
    ViewProviderDocumentObject::attach(pcFeat);
51
}
52

53
void ViewProviderDrawingView::setDisplayMode(const char* ModeName)
54
{
55
    ViewProviderDocumentObject::setDisplayMode(ModeName);
56
}
57

58
std::vector<std::string> ViewProviderDrawingView::getDisplayModes(void) const
59
{
60
    std::vector<std::string> StrList = ViewProviderDocumentObject::getDisplayModes();
61
    return StrList;
62
}
63

64
void ViewProviderDrawingView::show(void)
65
{
66
    ViewProviderDocumentObject::show();
67

68
    App::DocumentObject* obj = getObject();
69
    if (!obj || obj->isRestoring()) {
70
        return;
71
    }
72
    if (obj->isDerivedFrom<Drawing::FeatureView>()) {
73
        // The 'Visible' property is marked as 'Output'. To update the drawing on recompute
74
        // the parent page object is touched.
75
        static_cast<Drawing::FeatureView*>(obj)->Visible.setValue(true);
76
        std::vector<App::DocumentObject*> inp = obj->getInList();
77
        for (std::vector<App::DocumentObject*>::iterator it = inp.begin(); it != inp.end(); ++it) {
78
            (*it)->touch();
79
        }
80
    }
81
}
82

83
void ViewProviderDrawingView::hide(void)
84
{
85
    ViewProviderDocumentObject::hide();
86

87
    App::DocumentObject* obj = getObject();
88
    if (!obj || obj->isRestoring()) {
89
        return;
90
    }
91
    if (obj->isDerivedFrom<Drawing::FeatureView>()) {
92
        // The 'Visible' property is marked as 'Output'. To update the drawing on recompute
93
        // the parent page object is touched.
94
        static_cast<Drawing::FeatureView*>(obj)->Visible.setValue(false);
95
        std::vector<App::DocumentObject*> inp = obj->getInList();
96
        for (std::vector<App::DocumentObject*>::iterator it = inp.begin(); it != inp.end(); ++it) {
97
            (*it)->touch();
98
        }
99
    }
100
}
101

102
bool ViewProviderDrawingView::isShow(void) const
103
{
104
    return Visibility.getValue();
105
}
106

107
void ViewProviderDrawingView::startRestoring()
108
{
109
    // do nothing
110
}
111

112
void ViewProviderDrawingView::finishRestoring()
113
{
114
    // do nothing
115
}
116

117
void ViewProviderDrawingView::updateData(const App::Property*)
118
{}
119

120
// Python viewprovider -----------------------------------------------------------------------
121

122
namespace Gui
123
{
124
/// @cond DOXERR
125
PROPERTY_SOURCE_TEMPLATE(DrawingGui::ViewProviderDrawingViewPython,
126
                         DrawingGui::ViewProviderDrawingView)
127
/// @endcond
128

129
// explicit template instantiation
130
template class DrawingGuiExport ViewProviderPythonFeatureT<DrawingGui::ViewProviderDrawingView>;
131
}  // namespace Gui
132

133

134
// ----------------------------------------------------------------------------
135

136
PROPERTY_SOURCE(DrawingGui::ViewProviderDrawingClip, Gui::ViewProviderDocumentObjectGroup)
137

138
ViewProviderDrawingClip::ViewProviderDrawingClip()
139
{
140
    sPixmap = "Page";
141

142
    // Do not show in property editor
143
    DisplayMode.setStatus(App::Property::Hidden, true);
144
}
145

146
ViewProviderDrawingClip::~ViewProviderDrawingClip()
147
{}
148

149
void ViewProviderDrawingClip::attach(App::DocumentObject* pcFeat)
150
{
151
    // call parent attach method
152
    ViewProviderDocumentObject::attach(pcFeat);
153
}
154

155
void ViewProviderDrawingClip::setDisplayMode(const char* ModeName)
156
{
157
    ViewProviderDocumentObject::setDisplayMode(ModeName);
158
}
159

160
std::vector<std::string> ViewProviderDrawingClip::getDisplayModes(void) const
161
{
162
    // get the modes of the father
163
    std::vector<std::string> StrList;
164
    return StrList;
165
}
166

167
void ViewProviderDrawingClip::show(void)
168
{
169
    ViewProviderDocumentObjectGroup::show();
170

171
    App::DocumentObject* obj = getObject();
172
    if (!obj || obj->isRestoring()) {
173
        return;
174
    }
175
    if (obj->isDerivedFrom<Drawing::FeatureClip>()) {
176
        // The 'Visible' property is marked as 'Output'. To update the drawing on recompute
177
        // the parent page object is touched.
178
        static_cast<Drawing::FeatureClip*>(obj)->Visible.setValue(true);
179
        std::vector<App::DocumentObject*> inp = obj->getInList();
180
        for (std::vector<App::DocumentObject*>::iterator it = inp.begin(); it != inp.end(); ++it) {
181
            (*it)->touch();
182
        }
183
    }
184
}
185

186
void ViewProviderDrawingClip::hide(void)
187
{
188
    ViewProviderDocumentObjectGroup::hide();
189

190
    App::DocumentObject* obj = getObject();
191
    if (!obj || obj->isRestoring()) {
192
        return;
193
    }
194
    if (obj->isDerivedFrom<Drawing::FeatureClip>()) {
195
        // The 'Visible' property is marked as 'Output'. To update the drawing on recompute
196
        // the parent page object is touched.
197
        static_cast<Drawing::FeatureClip*>(obj)->Visible.setValue(false);
198
        std::vector<App::DocumentObject*> inp = obj->getInList();
199
        for (std::vector<App::DocumentObject*>::iterator it = inp.begin(); it != inp.end(); ++it) {
200
            (*it)->touch();
201
        }
202
    }
203
}
204

205
bool ViewProviderDrawingClip::isShow(void) const
206
{
207
    return Visibility.getValue();
208
}
209

210
void ViewProviderDrawingClip::startRestoring()
211
{
212
    // do nothing
213
}
214

215
void ViewProviderDrawingClip::finishRestoring()
216
{
217
    // do nothing
218
}
219

220
void ViewProviderDrawingClip::updateData(const App::Property*)
221
{}
222

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

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

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

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