FreeCAD

Форк
0
/
ViewProviderLine.cpp 
82 строки · 3.2 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2012 Jürgen Riegel <juergen.riegel@web.de>              *
3
 *   Copyright (c) 2015 Alexander Golubev (Fat-Zer) <fatzer2@gmail.com>    *
4
 *                                                                         *
5
 *   This file is part of the FreeCAD CAx development system.              *
6
 *                                                                         *
7
 *   This library is free software; you can redistribute it and/or         *
8
 *   modify it under the terms of the GNU Library General Public           *
9
 *   License as published by the Free Software Foundation; either          *
10
 *   version 2 of the License, or (at your option) any later version.      *
11
 *                                                                         *
12
 *   This library  is distributed in the hope that it will be useful,      *
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
15
 *   GNU Library General Public License for more details.                  *
16
 *                                                                         *
17
 *   You should have received a copy of the GNU Library General Public     *
18
 *   License along with this library; see the file COPYING.LIB. If not,    *
19
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
20
 *   Suite 330, Boston, MA  02111-1307, USA                                *
21
 *                                                                         *
22
 ***************************************************************************/
23

24
#include "PreCompiled.h"
25

26
#ifndef _PreComp_
27
# include <Inventor/nodes/SoAsciiText.h>
28
# include <Inventor/nodes/SoCoordinate3.h>
29
# include <Inventor/nodes/SoIndexedLineSet.h>
30
# include <Inventor/nodes/SoPickStyle.h>
31
# include <Inventor/nodes/SoSeparator.h>
32
# include <Inventor/nodes/SoTranslation.h>
33
#endif
34

35
#include "ViewProviderLine.h"
36
#include "ViewProviderOrigin.h"
37

38

39
using namespace Gui;
40

41
PROPERTY_SOURCE(Gui::ViewProviderLine, Gui::ViewProviderOriginFeature)
42

43

44
ViewProviderLine::ViewProviderLine()
45
{
46
    sPixmap = "Std_Axis";
47
}
48

49
ViewProviderLine::~ViewProviderLine() = default;
50

51
void ViewProviderLine::attach ( App::DocumentObject *obj ) {
52
    ViewProviderOriginFeature::attach ( obj );
53

54
    static const float size = ViewProviderOrigin::defaultSize ();
55

56
    static const SbVec3f verts[2] = { SbVec3f(size, 0, 0),   SbVec3f ( -size, 0, 0 ) };
57

58
    // indexes used to create the edges
59
    static const int32_t lines[4] = { 0, 1, -1 };
60

61
    SoSeparator *sep = getOriginFeatureRoot ();
62

63
    auto pCoords = new SoCoordinate3 ();
64
    pCoords->point.setNum (2);
65
    pCoords->point.setValues ( 0, 2, verts );
66
    sep->addChild ( pCoords );
67

68
    auto pLines  = new SoIndexedLineSet ();
69
    pLines->coordIndex.setNum(3);
70
    pLines->coordIndex.setValues(0, 3, lines);
71
    sep->addChild ( pLines );
72

73
    auto textTranslation = new SoTranslation ();
74
    textTranslation->translation.setValue ( SbVec3f ( -size * 49. / 50., size / 30., 0 ) );
75
    sep->addChild ( textTranslation );
76

77
    auto ps = new SoPickStyle();
78
    ps->style.setValue(SoPickStyle::BOUNDING_BOX);
79
    sep->addChild(ps);
80

81
    sep->addChild ( getLabel () );
82
}
83

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

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

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

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