FreeCAD

Форк
0
/
ViewProviderViewClip.cpp 
146 строк · 5.0 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de>              *
3
 *   Copyright (c) 2012 Luke Parry <l.parry@warwick.ac.uk>                 *
4
 *                                                                         *
5
 *   This file is part of the FreeCAD CAx development system.              *
6
 *                                                                         *
7
 *   This library is free software; you can redistribute it and/or         *
8
 *   modify it under the terms of the GNU Library General Public           *
9
 *   License as published by the Free Software Foundation; either          *
10
 *   version 2 of the License, or (at your option) any later version.      *
11
 *                                                                         *
12
 *   This library  is distributed in the hope that it will be useful,      *
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
15
 *   GNU Library General Public License for more details.                  *
16
 *                                                                         *
17
 *   You should have received a copy of the GNU Library General Public     *
18
 *   License along with this library; see the file COPYING.LIB. If not,    *
19
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
20
 *   Suite 330, Boston, MA  02111-1307, USA                                *
21
 *                                                                         *
22
 ***************************************************************************/
23

24

25
#include "PreCompiled.h"
26

27
#ifndef _PreComp_
28
# ifdef FC_OS_WIN32
29
#  include <windows.h>
30
# endif
31
#endif
32

33
#include <App/DocumentObject.h>
34
#include <Mod/TechDraw/App/DrawPage.h>
35
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
36

37
#include "ViewProviderViewClip.h"
38

39
using namespace TechDrawGui;
40

41
PROPERTY_SOURCE(TechDrawGui::ViewProviderViewClip, TechDrawGui::ViewProviderDrawingView)
42

43
ViewProviderViewClip::ViewProviderViewClip()
44
{
45
    sPixmap = "actions/TechDraw_ClipGroup";
46

47
    // Do not show in property editor   why? wf  WF: because DisplayMode applies only to coin and we
48
    // don't use coin.
49
    DisplayMode.setStatus(App::Property::Hidden, true);
50
}
51

52
ViewProviderViewClip::~ViewProviderViewClip()
53
{
54
}
55

56
std::vector<App::DocumentObject*> ViewProviderViewClip::claimChildren() const
57
{
58
    // Collect any child views
59
    // for Clip, valid children are any View in Views
60
    const std::vector<App::DocumentObject *> &views = getObject()->Views.getValues();
61
    return views;
62
}
63

64
void ViewProviderViewClip::show()
65
{
66
    //TODO: not sure that clip members need to be touched when hiding clip group
67
    App::DocumentObject* obj = getObject();
68
    if (!obj || obj->isRestoring())
69
        return;
70
    if (obj->isDerivedFrom<TechDraw::DrawViewClip>()) {
71
        std::vector<App::DocumentObject*> inp = obj->getInList();
72
        for (std::vector<App::DocumentObject*>::iterator it = inp.begin(); it != inp.end(); ++it)
73
            (*it)->touch();
74
    }
75
    ViewProviderDrawingView::show();
76

77
}
78

79
void ViewProviderViewClip::hide()
80
{
81
    //TODO: not sure that clip members need to be touched when hiding clip group
82
    App::DocumentObject* obj = getObject();
83
    if (!obj || obj->isRestoring())
84
        return;
85
    if (obj->isDerivedFrom<TechDraw::DrawViewClip>()) {
86
        std::vector<App::DocumentObject*> inp = obj->getInList();
87
        for (std::vector<App::DocumentObject*>::iterator it = inp.begin(); it != inp.end(); ++it)
88
            (*it)->touch();
89
    }
90
    ViewProviderDrawingView::hide();
91
}
92

93
bool ViewProviderViewClip::canDelete(App::DocumentObject *obj) const
94
{
95
    // deletions of Clip objects don't destroy anything
96
    // thus we can pass this action
97
    Q_UNUSED(obj)
98
    return true;
99
}
100

101
TechDraw::DrawViewClip* ViewProviderViewClip::getViewObject() const
102
{
103
    return dynamic_cast<TechDraw::DrawViewClip*>(pcObject);
104
}
105

106
TechDraw::DrawViewClip* ViewProviderViewClip::getObject() const
107
{
108
    return getViewObject();
109
}
110

111

112
void ViewProviderViewClip::dragObject(App::DocumentObject* docObj)
113
{
114
    if (!docObj->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
115
        return;
116
    }
117

118
    auto dv = static_cast<TechDraw::DrawView*>(docObj);
119

120
    getObject()->removeView(dv);
121
}
122

123
void ViewProviderViewClip::dropObject(App::DocumentObject* docObj)
124
{
125
    if (docObj->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
126
        //DPGI can not be dropped onto the Page as it belongs to DPG, not Page
127
        return;
128
    }
129
    if (!docObj->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
130
        return;
131
    }
132

133
    auto dv = static_cast<TechDraw::DrawView*>(docObj);
134
    TechDraw::DrawPage* pageClip = getObject()->findParentPage();
135
    TechDraw::DrawPage* pageView = dv->findParentPage();
136
    if (!pageClip || !pageView) {
137
        return;
138
    }
139

140
    if (pageClip != pageView) {
141
        pageView->removeView(dv);
142
        pageClip->addView(dv);
143
    }
144

145
    getObject()->addView(dv);
146
}

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

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

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

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