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
**********************************************************************/
28
#include "rs_actionmodifyoffset.h"
30
#include "rs_dialogfactory.h"
31
#include "rs_graphicview.h"
32
//#include "rs_commands.h"
33
//#include "rs_commandevent.h"
34
#include "rs_modification.h"
37
RS_ActionModifyOffset::RS_ActionModifyOffset(RS_EntityContainer& container,
38
RS_GraphicView& graphicView)
39
:RS_PreviewActionInterface("Modify Offset",
40
container, graphicView) {
44
data.useCurrentAttributes = true;
45
data.useCurrentLayer = true;
50
RS_ActionModifyOffset::~RS_ActionModifyOffset() {}
52
QAction* RS_ActionModifyOffset::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/) {
53
QAction* action = new QAction(tr("&Offset"),NULL);
54
action->setIcon(QIcon(":/extui/arcspara.png"));//we need a new icon here
61
void RS_ActionModifyOffset::init(int status) {
62
RS_ActionInterface::init(status);
63
//finish, if nothing selected
64
if(container->countSelected()==0) finish();
68
void RS_ActionModifyOffset::trigger() {
69
RS_Modification m(*container, graphicView);
71
if (RS_DIALOGFACTORY!=NULL) {
72
RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
73
RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected(),container->totalSelectedLength());
80
void RS_ActionModifyOffset::mouseMoveEvent(QMouseEvent* e) {
81
// RS_DEBUG->print("RS_ActionModifyOffset::mouseMoveEvent begin");
82
data.coord=snapPoint(e);
85
RS_EntityContainer ec(NULL,true);
86
for(RS_Entity* en=container->firstEntity();en!=NULL;en=container->nextEntity()){
87
if(en->isSelected()) ec.addEntity(en->clone());
89
if(ec.isEmpty()) return;
90
RS_Modification m(ec, NULL, false);
94
preview->addSelectionFrom(ec);
101
void RS_ActionModifyOffset::mouseReleaseEvent(QMouseEvent* e) {
102
if (e->button()==Qt::LeftButton) {
104
} else if (e->button()==Qt::RightButton) {
111
void RS_ActionModifyOffset::updateMouseButtonHints() {
112
if (RS_DIALOGFACTORY!=NULL) {
113
switch (getStatus()) {
115
RS_DIALOGFACTORY->updateMouseWidget(tr("Specify direction of offset"), tr("Back"));
119
RS_DIALOGFACTORY->updateMouseWidget("", "");
127
void RS_ActionModifyOffset::showOptions() {
128
RS_ActionInterface::showOptions();
129
if (RS_DIALOGFACTORY!=NULL) {
130
RS_DIALOGFACTORY->requestModifyOffsetOptions(data.distance, true);
136
void RS_ActionModifyOffset::hideOptions() {
137
RS_ActionInterface::hideOptions();
139
if (RS_DIALOGFACTORY!=NULL) {
140
RS_DIALOGFACTORY->requestModifyOffsetOptions(data.distance, false);
146
void RS_ActionModifyOffset::updateMouseCursor() {
147
graphicView->setMouseCursor(RS2::CadCursor);
152
//void RS_ActionModifyOffset::updateToolBar() {
153
// if (RS_DIALOGFACTORY!=NULL) {
154
// if (isFinished()) {
155
// RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);