FreeCAD

Форк
0
/
QGICMark.cpp 
105 строк · 3.2 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2016 Wandererfan <WandererFan@gmail.com>                *
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 <cassert>
26

27
# include <QPainter>
28
# include <QPainterPath>
29
# include <QStyleOptionGraphicsItem>
30
#endif
31

32
#include <App/Material.h>
33
#include <Base/Parameter.h>
34
#include <Mod/TechDraw/App/Preferences.h>
35

36
#include "QGICMark.h"
37
#include "PreferencesGui.h"
38

39
using namespace TechDraw;
40
using namespace TechDrawGui;
41

42
QGICMark::QGICMark(int index) : QGIVertex(index)
43
{
44
    m_size = 3.0;
45
    m_width = 0.75;
46
    draw();
47
}
48
void QGICMark::draw()
49
{
50
    QPainterPath cmPath;
51
    cmPath.moveTo(0.0, m_size);
52
    cmPath.lineTo(0.0, -m_size);
53
    cmPath.moveTo(m_size, 0.0);
54
    cmPath.lineTo(-m_size, 0.0);
55
    setPath(cmPath);
56
}
57

58
void QGICMark::setSize(float s)
59
{
60
    m_size = s;
61
    draw();
62
}
63

64
void QGICMark::setThick(float t)
65
{
66
    m_width = t;
67
    draw();
68
}
69

70
QColor QGICMark::getCMarkColor()
71
{
72
    return PreferencesGui::centerQColor();
73
}
74

75
void QGICMark::setPrettyNormal() {
76
    m_colCurrent = getCMarkColor();
77
    update();
78
}
79

80
void QGICMark::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
81
{
82
    QStyleOptionGraphicsItem myOption(*option);
83
    myOption.state &= ~QStyle::State_Selected;
84

85
    QGIVertex::paint (painter, &myOption, widget);
86
}
87

88
QRectF QGICMark::boundingRect() const
89
{
90
    return shape().controlPointRect();
91
}
92

93
QPainterPath QGICMark::shape() const
94
{
95
    QPainterPath outline;
96
    QPainterPathStroker stroker;
97
    stroker.setWidth(getMarkFuzz());
98
    outline = stroker.createStroke(path());
99
    return outline;
100
}
101

102
 double QGICMark::getMarkFuzz() const
103
{
104
    return Preferences::getPreferenceGroup("General")->GetFloat("MarkFuzz", 5.0);
105
}
106

107

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

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

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

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