FreeCAD

Форк
0
/
PointsFeature.cpp 
116 строк · 3.9 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2011 Jürgen 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 <vector>
27
#endif
28

29
#include "PointsFeature.h"
30

31

32
using namespace Points;
33

34
//===========================================================================
35
// Feature
36
//===========================================================================
37

38
PROPERTY_SOURCE(Points::Feature, App::GeoFeature)
39

40
Feature::Feature()
41
{
42
    ADD_PROPERTY(Points, (PointKernel()));
43
}
44

45
short Feature::mustExecute() const
46
{
47
    return 0;
48
}
49

50
App::DocumentObjectExecReturn* Feature::execute()
51
{
52
    this->Points.touch();
53
    return App::DocumentObject::StdReturn;
54
}
55

56
void Feature::Restore(Base::XMLReader& reader)
57
{
58
    GeoFeature::Restore(reader);
59
}
60

61
void Feature::RestoreDocFile(Base::Reader& reader)
62
{
63
    // This gets only invoked if a points file has been added from Restore()
64
    Points.RestoreDocFile(reader);
65
}
66

67
void Feature::onChanged(const App::Property* prop)
68
{
69
    // if the placement has changed apply the change to the point data as well
70
    if (prop == &this->Placement) {
71
        this->Points.setTransform(this->Placement.getValue().toMatrix());
72
    }
73
    // if the point data has changed check and adjust the transformation as well
74
    else if (prop == &this->Points) {
75
        try {
76
            Base::Placement p;
77
            p.fromMatrix(this->Points.getTransform());
78
            if (p != this->Placement.getValue()) {
79
                this->Placement.setValue(p);
80
            }
81
        }
82
        catch (const Base::ValueError&) {
83
        }
84
    }
85

86
    GeoFeature::onChanged(prop);
87
}
88

89
// ---------------------------------------------------------
90

91
namespace App
92
{
93
/// @cond DOXERR
94
PROPERTY_SOURCE_TEMPLATE(Points::FeatureCustom, Points::Feature)
95
/// @endcond
96

97
// explicit template instantiation
98
template class PointsExport FeatureCustomT<Points::Feature>;
99
}  // namespace App
100

101
// ---------------------------------------------------------
102

103
namespace App
104
{
105
/// @cond DOXERR
106
PROPERTY_SOURCE_TEMPLATE(Points::FeaturePython, Points::Feature)
107
template<>
108
const char* Points::FeaturePython::getViewProviderName() const
109
{
110
    return "PointsGui::ViewProviderPython";
111
}
112
/// @endcond
113

114
// explicit template instantiation
115
template class PointsExport FeaturePythonT<Points::Feature>;
116
}  // namespace App
117

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

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

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

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