FreeCAD

Форк
0
/
Selection.cpp 
124 строки · 4.1 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2013 Werner Mayer <wmayer[at]users.sourceforge.net>     *
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
#include "Selection.h"
26
#include "ui_Selection.h"
27

28

29
using namespace MeshGui;
30

31
/* TRANSLATOR MeshGui::Selection */
32

33
Selection::Selection(QWidget* parent)
34
    : QWidget(parent)
35
    , ui(new Ui_Selection())
36
{
37
    ui->setupUi(this);
38
    setupConnections();
39
    ui->addSelection->installEventFilter(this);
40
    ui->clearSelection->installEventFilter(this);
41

42
    meshSel.setCheckOnlyVisibleTriangles(ui->visibleTriangles->isChecked());
43
    meshSel.setCheckOnlyPointToUserTriangles(ui->screenTriangles->isChecked());
44
    meshSel.setEnabledViewerSelection(false);
45
}
46

47
/*
48
 *  Destroys the object and frees any allocated resources
49
 */
50
Selection::~Selection()
51
{
52
    // no need to delete child widgets, Qt does it all for us
53
    delete ui;
54
    meshSel.clearSelection();
55
    meshSel.setEnabledViewerSelection(true);
56
}
57

58
void Selection::setupConnections()
59
{
60
    // clang-format off
61
    connect(ui->addSelection, &QPushButton::clicked,
62
            this, &Selection::onAddSelectionClicked);
63
    connect(ui->clearSelection, &QPushButton::clicked,
64
            this, &Selection::onClearSelectionClicked);
65
    connect(ui->visibleTriangles, &QPushButton::clicked,
66
            this, &Selection::onVisibleTrianglesToggled);
67
    connect(ui->screenTriangles, &QPushButton::clicked,
68
            this, &Selection::onScreenTrianglesToggled);
69
    // clang-format on
70
}
71

72
void Selection::setObjects(const std::vector<Gui::SelectionObject>& o)
73
{
74
    meshSel.setObjects(o);
75
}
76

77
std::vector<App::DocumentObject*> Selection::getObjects() const
78
{
79
    return meshSel.getObjects();
80
}
81

82
bool Selection::eventFilter(QObject* o, QEvent* e)
83
{
84
    if (e->type() == QEvent::HoverEnter) {
85
        if (o == ui->addSelection) {
86
            ui->label->setText(tr("Use a brush tool to select the area"));
87
        }
88
        else if (o == ui->clearSelection) {
89
            ui->label->setText(tr("Clears completely the selected area"));
90
        }
91
    }
92
    else if (e->type() == QEvent::HoverLeave) {
93
        if (o == ui->addSelection) {
94
            ui->label->clear();
95
        }
96
        else if (o == ui->clearSelection) {
97
            ui->label->clear();
98
        }
99
    }
100

101
    return false;
102
}
103

104
void Selection::onAddSelectionClicked()
105
{
106
    meshSel.startSelection();
107
}
108

109
void Selection::onClearSelectionClicked()
110
{
111
    meshSel.clearSelection();
112
}
113

114
void Selection::onVisibleTrianglesToggled(bool on)
115
{
116
    meshSel.setCheckOnlyVisibleTriangles(on);
117
}
118

119
void Selection::onScreenTrianglesToggled(bool on)
120
{
121
    meshSel.setCheckOnlyPointToUserTriangles(on);
122
}
123

124
#include "moc_Selection.cpp"
125

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

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

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

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