FreeCAD

Форк
0
/
FeatureView.cpp 
116 строк · 4.5 Кб
1
/***************************************************************************
2
 *   Copyright (c) Jürgen Riegel          (juergen.riegel@web.de) 2002     *
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
#ifndef _PreComp_
25
#include <Standard_Failure.hxx>
26
#include <sstream>
27
#endif
28

29
#include <Base/Exception.h>
30

31
#include "FeatureView.h"
32

33

34
using namespace Drawing;
35

36
//===========================================================================
37
// FeatureView
38
//===========================================================================
39

40
PROPERTY_SOURCE(Drawing::FeatureView, App::DocumentObject)
41

42

43
FeatureView::FeatureView(void)
44
{
45
    static const char* group = "Drawing view";
46
    ADD_PROPERTY_TYPE(X,
47
                      (0),
48
                      group,
49
                      App::Prop_None,
50
                      "X position of the view on the drawing in modelling units (mm)");
51
    ADD_PROPERTY_TYPE(Y,
52
                      (0),
53
                      group,
54
                      App::Prop_None,
55
                      "Y position of the view on the drawing in modelling units (mm)");
56
    ADD_PROPERTY_TYPE(Scale, (1.0), group, App::Prop_None, "Scale factor of the view");
57
    ADD_PROPERTY_TYPE(Rotation,
58
                      (0),
59
                      group,
60
                      App::Prop_None,
61
                      "Rotation of the view in degrees counterclockwise");
62
    // The 'Visible' property is handled by the view provider exclusively. It has the 'Output' flag
63
    // set to avoid to call the execute() method. The view provider touches the page object,
64
    // instead.
65
    App::PropertyType propType =
66
        static_cast<App::PropertyType>(App::Prop_Hidden | App::Prop_Output);
67
    ADD_PROPERTY_TYPE(Visible,
68
                      (true),
69
                      group,
70
                      propType,
71
                      "Control whether view is visible in page object");
72

73
    App::PropertyType type = (App::PropertyType)(App::Prop_Hidden);
74
    ADD_PROPERTY_TYPE(ViewResult, (nullptr), group, type, "Resulting SVG fragment of that view");
75
}
76

77
FeatureView::~FeatureView()
78
{}
79

80
App::DocumentObjectExecReturn* FeatureView::recompute(void)
81
{
82
    try {
83
        return App::DocumentObject::recompute();
84
    }
85
    catch (Standard_Failure& e) {
86
        App::DocumentObjectExecReturn* ret =
87
            new App::DocumentObjectExecReturn(e.GetMessageString());
88
        if (ret->Why.empty()) {
89
            ret->Why = "Unknown OCC exception";
90
        }
91
        return ret;
92
    }
93
}
94

95
App::DocumentObjectExecReturn* FeatureView::execute(void)
96
{
97
    return App::DocumentObject::StdReturn;
98
}
99

100

101
// Python Drawing feature ---------------------------------------------------------
102

103
namespace App
104
{
105
/// @cond DOXERR
106
PROPERTY_SOURCE_TEMPLATE(Drawing::FeatureViewPython, Drawing::FeatureView)
107
template<>
108
const char* Drawing::FeatureViewPython::getViewProviderName(void) const
109
{
110
    return "DrawingGui::ViewProviderDrawingViewPython";
111
}
112
/// @endcond
113

114
// explicit template instantiation
115
template class DrawingExport FeaturePythonT<Drawing::FeatureView>;
116
}  // namespace App
117

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

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

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

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