FreeCAD

Форк
0
/
ViewProvider.cpp 
122 строки · 4.4 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2004 Juergen Riegel <juergen.riegel@web.de>             *
3
 *                                                                         *
4
 *   This file is part 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 PARTICULAR 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
#ifndef _PreComp_
26
#include <QObject>
27
#endif
28

29
#include <App/Document.h>
30
#include <Base/Console.h>
31
#include <Base/Exception.h>
32
#include <Gui/Command.h>
33

34
#include "ViewProvider.h"
35

36

37
using namespace PartGui;
38

39
PROPERTY_SOURCE(PartGui::ViewProviderPart, PartGui::ViewProviderPartExt)  // NOLINT
40

41

42
ViewProviderPart::ViewProviderPart() = default;
43

44
ViewProviderPart::~ViewProviderPart() = default;
45

46
bool ViewProviderPart::doubleClicked()
47
{
48
    try {
49
        QString text = QObject::tr("Edit %1").arg(QString::fromUtf8(getObject()->Label.getValue()));
50
        Gui::Command::openCommand(text.toUtf8());
51
        FCMD_SET_EDIT(pcObject);
52
        return true;
53
    }
54
    catch (const Base::Exception& e) {
55
        Base::Console().Error("%s\n", e.what());
56
        return false;
57
    }
58
}
59

60
void ViewProviderPart::applyColor(const Part::ShapeHistory& hist,
61
                                  const std::vector<App::Color>& colBase,
62
                                  std::vector<App::Color>& colBool)
63
{
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);
68
        }
69
    }
70
}
71

72
void ViewProviderPart::applyMaterial(const Part::ShapeHistory& hist,
73
                                     const std::vector<App::Material>& colBase,
74
                                     std::vector<App::Material>& colBool)
75
{
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);
80
        }
81
    }
82
}
83

84
void ViewProviderPart::applyTransparency(float transparency, std::vector<App::Color>& colors)
85
{
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
90
            if (j.a == 0.0) {
91
                j.a = transparency/100.0F;  // transparency comes in percent
92
            }
93
        }
94
    }
95
}
96

97
void ViewProviderPart::applyTransparency(float transparency, std::vector<App::Material>& colors)
98
{
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
105
            }
106
        }
107
    }
108
}
109

110
// ----------------------------------------------------------------------------
111

112
void ViewProviderShapeBuilder::buildNodes(const App::Property* prop, std::vector<SoNode*>& nodes) const
113
{
114
    Q_UNUSED(prop)
115
    Q_UNUSED(nodes)
116
}
117

118
void ViewProviderShapeBuilder::createShape(const App::Property* prop, SoSeparator* node) const
119
{
120
    Q_UNUSED(prop)
121
    Q_UNUSED(node)
122
}
123

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

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

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

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