1
/***************************************************************************
2
* Copyright (c) 2013 Werner Mayer <wmayer[at]users.sourceforge.net> *
4
* This file is part of the FreeCAD CAx development system. *
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. *
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. *
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 *
21
***************************************************************************/
23
#include "PreCompiled.h"
26
#include "ui_Selection.h"
29
using namespace MeshGui;
31
/* TRANSLATOR MeshGui::Selection */
33
Selection::Selection(QWidget* parent)
35
, ui(new Ui_Selection())
39
ui->addSelection->installEventFilter(this);
40
ui->clearSelection->installEventFilter(this);
42
meshSel.setCheckOnlyVisibleTriangles(ui->visibleTriangles->isChecked());
43
meshSel.setCheckOnlyPointToUserTriangles(ui->screenTriangles->isChecked());
44
meshSel.setEnabledViewerSelection(false);
48
* Destroys the object and frees any allocated resources
50
Selection::~Selection()
52
// no need to delete child widgets, Qt does it all for us
54
meshSel.clearSelection();
55
meshSel.setEnabledViewerSelection(true);
58
void Selection::setupConnections()
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);
72
void Selection::setObjects(const std::vector<Gui::SelectionObject>& o)
74
meshSel.setObjects(o);
77
std::vector<App::DocumentObject*> Selection::getObjects() const
79
return meshSel.getObjects();
82
bool Selection::eventFilter(QObject* o, QEvent* e)
84
if (e->type() == QEvent::HoverEnter) {
85
if (o == ui->addSelection) {
86
ui->label->setText(tr("Use a brush tool to select the area"));
88
else if (o == ui->clearSelection) {
89
ui->label->setText(tr("Clears completely the selected area"));
92
else if (e->type() == QEvent::HoverLeave) {
93
if (o == ui->addSelection) {
96
else if (o == ui->clearSelection) {
104
void Selection::onAddSelectionClicked()
106
meshSel.startSelection();
109
void Selection::onClearSelectionClicked()
111
meshSel.clearSelection();
114
void Selection::onVisibleTrianglesToggled(bool on)
116
meshSel.setCheckOnlyVisibleTriangles(on);
119
void Selection::onScreenTrianglesToggled(bool on)
121
meshSel.setCheckOnlyPointToUserTriangles(on);
124
#include "moc_Selection.cpp"