1
/***************************************************************************
2
* Copyright (c) 2004 Jürgen Riegel <juergen.riegel@web.de> *
4
* This file is part of the FreeCAD CAx development system. *
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. *
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. *
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 *
21
***************************************************************************/
23
#include "PreCompiled.h"
25
#include <Gui/Application.h>
26
#include <Mod/Part/App/PartFeatures.h>
28
#include "ViewProviderRuledSurface.h"
31
using namespace PartGui;
34
//**************************************************************************
35
// Construction/Destruction
37
PROPERTY_SOURCE(PartGui::ViewProviderRuledSurface, PartGui::ViewProviderPart)
40
ViewProviderRuledSurface::ViewProviderRuledSurface()
42
sPixmap = "Part_RuledSurface.svg";
45
ViewProviderRuledSurface::~ViewProviderRuledSurface() = default;
47
std::vector<App::DocumentObject*> ViewProviderRuledSurface::claimChildren() const
49
// in a set each element is unique
50
std::set<App::DocumentObject*> temp;
51
temp.insert(static_cast<Part::RuledSurface*>(getObject())->Curve1.getValue());
52
temp.insert(static_cast<Part::RuledSurface*>(getObject())->Curve2.getValue());
54
std::vector<App::DocumentObject*> array;
55
array.insert(array.begin(), temp.begin(), temp.end());
59
void ViewProviderRuledSurface::updateData(const App::Property* prop)
61
PartGui::ViewProviderPart::updateData(prop);
62
if (prop->is<Part::PropertyShapeHistory>()) {
63
//const std::vector<Part::ShapeHistory>& hist = static_cast<const Part::PropertyShapeHistory*>
64
// (prop)->getValues();
66
/* //The following hides the Children shapes. If the edges from which the Ruled Surface was created
67
* were selected from the subshapes of another shape, it is likely that one would not want to hide the shape
68
* hence this section is commented out
69
Part::RuledSurface* pRuledSurface = static_cast<Part::RuledSurface*>(getObject());
70
App::DocumentObject *pCurve1 = pRuledSurface->Curve1.getValue();
71
App::DocumentObject *pCurve2 = pRuledSurface->Curve2.getValue();
73
Gui::Application::Instance->hideViewProvider(pCurve1);
75
Gui::Application::Instance->hideViewProvider(pCurve2);*/
79
bool ViewProviderRuledSurface::onDelete(const std::vector<std::string> &)
81
// get the input shape
82
Part::RuledSurface* pRuledSurface = static_cast<Part::RuledSurface*>(getObject());
83
App::DocumentObject *pCurve1 = pRuledSurface->Curve1.getValue();
84
App::DocumentObject *pCurve2 = pRuledSurface->Curve2.getValue();
86
Gui::Application::Instance->showViewProvider(pCurve1);
88
Gui::Application::Instance->showViewProvider(pCurve2);
94
// **********************************************************************************
96
std::vector<std::string> ViewProviderRuledSurface::getDisplayModes() const
98
// get the modes of the father
99
std::vector<std::string> StrList;
101
// add your own modes
102
StrList.emplace_back("Flat Lines");
103
StrList.emplace_back("Shaded");
104
StrList.emplace_back("Wireframe");
105
StrList.emplace_back("Points");