1
/***************************************************************************
2
* Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de> *
3
* Copyright (c) 2012 Luke Parry <l.parry@warwick.ac.uk> *
5
* This file is part of the FreeCAD CAx development system. *
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. *
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. *
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 *
22
***************************************************************************/
25
#include "PreCompiled.h"
33
#include <App/DocumentObject.h>
34
#include <Mod/TechDraw/App/DrawPage.h>
35
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
37
#include "ViewProviderViewClip.h"
39
using namespace TechDrawGui;
41
PROPERTY_SOURCE(TechDrawGui::ViewProviderViewClip, TechDrawGui::ViewProviderDrawingView)
43
ViewProviderViewClip::ViewProviderViewClip()
45
sPixmap = "actions/TechDraw_ClipGroup";
47
// Do not show in property editor why? wf WF: because DisplayMode applies only to coin and we
49
DisplayMode.setStatus(App::Property::Hidden, true);
52
ViewProviderViewClip::~ViewProviderViewClip()
56
std::vector<App::DocumentObject*> ViewProviderViewClip::claimChildren() const
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();
64
void ViewProviderViewClip::show()
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())
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)
75
ViewProviderDrawingView::show();
79
void ViewProviderViewClip::hide()
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())
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)
90
ViewProviderDrawingView::hide();
93
bool ViewProviderViewClip::canDelete(App::DocumentObject *obj) const
95
// deletions of Clip objects don't destroy anything
96
// thus we can pass this action
101
TechDraw::DrawViewClip* ViewProviderViewClip::getViewObject() const
103
return dynamic_cast<TechDraw::DrawViewClip*>(pcObject);
106
TechDraw::DrawViewClip* ViewProviderViewClip::getObject() const
108
return getViewObject();
112
void ViewProviderViewClip::dragObject(App::DocumentObject* docObj)
114
if (!docObj->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
118
auto dv = static_cast<TechDraw::DrawView*>(docObj);
120
getObject()->removeView(dv);
123
void ViewProviderViewClip::dropObject(App::DocumentObject* docObj)
125
if (docObj->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
126
//DPGI can not be dropped onto the Page as it belongs to DPG, not Page
129
if (!docObj->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
133
auto dv = static_cast<TechDraw::DrawView*>(docObj);
134
TechDraw::DrawPage* pageClip = getObject()->findParentPage();
135
TechDraw::DrawPage* pageView = dv->findParentPage();
136
if (!pageClip || !pageView) {
140
if (pageClip != pageView) {
141
pageView->removeView(dv);
142
pageClip->addView(dv);
145
getObject()->addView(dv);