1
/****************************************************************************
3
** This file is part of the LibreCAD project, a 2D CAD program
5
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
6
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
9
** This file may be distributed and/or modified under the terms of the
10
** GNU General Public License version 2 as published by the Free Software
11
** Foundation and appearing in the file gpl-2.0.txt included in the
12
** packaging of this file.
14
** This program is distributed in the hope that it will be useful,
15
** but WITHOUT ANY WARRANTY; without even the implied warranty of
16
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
** GNU General Public License for more details.
19
** You should have received a copy of the GNU General Public License
20
** along with this program; if not, write to the Free Software
21
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
** This copyright notice MUST APPEAR in all copies of the script!
25
**********************************************************************/
26
#include "qg_cadtoolbarselect.h"
28
#include "qg_cadtoolbar.h"
29
#include "rs_actionselect.h"
32
* Constructs a QG_CadToolBarSelect as a child of 'parent', with the
33
* name 'name' and widget flags set to 'f'.
35
QG_CadToolBarSelect::QG_CadToolBarSelect(QWidget* parent, Qt::WindowFlags fl)
39
parentTB=static_cast<QG_CadToolBar*>(parent);
45
* Destroys the object and frees any allocated resources
47
QG_CadToolBarSelect::~QG_CadToolBarSelect()
49
// no need to delete child widgets, Qt does it all for us
53
* Sets the strings of the subwidgets using the current
56
void QG_CadToolBarSelect::languageChange()
61
void QG_CadToolBarSelect::init() {
68
void QG_CadToolBarSelect::mousePressEvent(QMouseEvent* e) {
69
if (e->button()==Qt::RightButton && cadToolBar!=NULL) {
75
void QG_CadToolBarSelect::contextMenuEvent(QContextMenuEvent *e) {
79
void QG_CadToolBarSelect::setCadToolBar(QG_CadToolBar* tb) {
82
actionHandler = tb->getActionHandler();
83
//actionHandler->setCadToolBarSelect(this);
86
RS_DEBUG->print(RS_Debug::D_ERROR,
87
"QG_CadToolBarSelect::setCadToolBar(): No valid toolbar set.");
91
void QG_CadToolBarSelect::selectSingle() {
92
if (actionHandler!=NULL) {
93
if(actionHandler->getCurrentAction()->rtti() != RS2::ActionSelect){
94
actionHandler->slotSelectSingle();
99
void QG_CadToolBarSelect::selectContour() {
100
if (actionHandler!=NULL) {
101
actionHandler->slotSelectContour();
105
void QG_CadToolBarSelect::deselectAll() {
106
if (actionHandler!=NULL) {
107
actionHandler->slotDeselectAll();
111
void QG_CadToolBarSelect::selectAll() {
112
if (actionHandler!=NULL) {
113
actionHandler->slotSelectAll();
117
void QG_CadToolBarSelect::selectWindow() {
118
if (actionHandler!=NULL) {
119
actionHandler->slotSelectWindow();
123
void QG_CadToolBarSelect::deselectWindow() {
124
if (actionHandler!=NULL) {
125
actionHandler->slotDeselectWindow();
129
void QG_CadToolBarSelect::selectIntersected() {
130
if (actionHandler!=NULL) {
131
actionHandler->slotSelectIntersected();
135
void QG_CadToolBarSelect::deselectIntersected() {
136
if (actionHandler!=NULL) {
137
actionHandler->slotDeselectIntersected();
141
void QG_CadToolBarSelect::selectInvert() {
142
if (actionHandler!=NULL) {
143
actionHandler->slotSelectInvert();
147
void QG_CadToolBarSelect::selectLayer() {
148
if (actionHandler!=NULL) {
149
actionHandler->slotSelectLayer();
153
void QG_CadToolBarSelect::setSelectAction(RS_ActionInterface* selectAction) {
154
this->selectAction = selectAction;
157
void QG_CadToolBarSelect::setNextAction(int nextAction) {
158
this->nextAction = nextAction;
159
if (nextAction==-1) {
166
void QG_CadToolBarSelect::runNextAction() {
167
if (selectAction!=NULL) {
168
if(selectAction->rtti() == RS2::ActionSelect){
169
//refuse to run next action if no entity is selected, to avoid segfault by action upon empty selection
171
if( static_cast<RS_ActionSelect*>(selectAction)->countSelected()==0) return;
173
selectAction->finish();
176
if (nextAction!=-1) {
177
actionHandler->killSelectActions();
178
actionHandler->setCurrentAction((RS2::ActionType)nextAction);
182
void QG_CadToolBarSelect::back() {
183
if(parentTB != NULL){
184
parentTB->showPreviousToolBar();
188
void QG_CadToolBarSelect::on_bBack_clicked()
190
if(parentTB != NULL){
191
parentTB->showPreviousToolBar();