1
/***************************************************************************
2
* Copyright (c) 2004 Juergen 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"
29
#include <App/Document.h>
30
#include <Base/Console.h>
31
#include <Base/Exception.h>
32
#include <Gui/Command.h>
34
#include "ViewProvider.h"
37
using namespace PartGui;
39
PROPERTY_SOURCE(PartGui::ViewProviderPart, PartGui::ViewProviderPartExt) // NOLINT
42
ViewProviderPart::ViewProviderPart() = default;
44
ViewProviderPart::~ViewProviderPart() = default;
46
bool ViewProviderPart::doubleClicked()
49
QString text = QObject::tr("Edit %1").arg(QString::fromUtf8(getObject()->Label.getValue()));
50
Gui::Command::openCommand(text.toUtf8());
51
FCMD_SET_EDIT(pcObject);
54
catch (const Base::Exception& e) {
55
Base::Console().Error("%s\n", e.what());
60
void ViewProviderPart::applyColor(const Part::ShapeHistory& hist,
61
const std::vector<App::Color>& colBase,
62
std::vector<App::Color>& colBool)
64
// apply color from modified faces
65
for (const auto& jt : hist.shapeMap) {
66
for (auto kt : jt.second) {
67
colBool.at(kt) = colBase.at(jt.first);
72
void ViewProviderPart::applyMaterial(const Part::ShapeHistory& hist,
73
const std::vector<App::Material>& colBase,
74
std::vector<App::Material>& colBool)
76
// apply color from modified faces
77
for (const auto& jt : hist.shapeMap) {
78
for (auto kt : jt.second) {
79
colBool.at(kt) = colBase.at(jt.first);
84
void ViewProviderPart::applyTransparency(float transparency, std::vector<App::Color>& colors)
86
if (transparency != 0.0) {
87
// transparency has been set object-wide
88
for (auto& j : colors) {
89
// transparency hasn't been set for this face
91
j.a = transparency/100.0F; // transparency comes in percent
97
void ViewProviderPart::applyTransparency(float transparency, std::vector<App::Material>& colors)
99
if (transparency != 0.0) {
100
// transparency has been set object-wide
101
for (auto& j : colors) {
102
// transparency hasn't been set for this face
103
if (j.transparency == 0.0) {
104
j.transparency = transparency / 100.0F; // transparency comes in percent
110
// ----------------------------------------------------------------------------
112
void ViewProviderShapeBuilder::buildNodes(const App::Property* prop, std::vector<SoNode*>& nodes) const
118
void ViewProviderShapeBuilder::createShape(const App::Property* prop, SoSeparator* node) const