Debian Codegraph @

MainWindow.cpp

raw symbols SCIP
1 /***************************************************************************
2 * This file is part of Robocut. *
3 * Copyright (C) 2010 Tim Hutt <[email protected]> *
4 * Copyright (C) 2010 Markus Schulz <[email protected]> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program 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 General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
20 ***************************************************************************/
21
22 #include "MainWindow.h"cxx . . $ `<file>/MainWindow.h`/
23 #include "ui_MainWindow.h"cxx . . $ `<file>/ui_MainWindow.h`/
24
25 #include "PathPaintPage.h"cxx . . $ `<file>/PathPaintPage.h`/
26 #include "Plotter.h"cxx . . $ `<file>/Plotter.h`/
27
28 #include "ProgramOptions.h"cxx . . $ `<file>/ProgramOptions.h`/
29
30 #include "CuttingDialog.h"cxx . . $ `<file>/CuttingDialog.h`/
31 #include "PathSorter.h"cxx . . $ `<file>/PathSorter.h`/
32
33 #include <QPainter>
34 #include <QDebug>
35
36 #include <QSvgRenderer>
37
38 #include <QMessageBox>
39 #include <QFileDialog>
40 #include <QDir>
41
42 #include <QShortcut>
43 #include <cmath>
44 #include <QFile>
45
46 #include <QEvent>
47 #include <iostream>
48 #include <QWheelEvent>
49
50 using namespace std;
51
52 const double InitialZoomcxx . . $ InitialZoom. = 2.0;
53
54 MainWindowcxx . . $ MainWindow#::MainWindowcxx . . $ MainWindow#MainWindow(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget# *parent)
55 : QMainWindowcxx . . $ QMainWindow#(parent), uicxx . . $ MainWindow#ui.(new Uicxx . . $ Ui/::MainWindowcxx . . $ Ui/MainWindow#)
56 {
57 uicxx . . $ MainWindow#ui.->setupUicxx . . $ Ui_MainWindow#setupUi(f2c32f691ede4a4e).(this);
58
59 scenecxx . . $ MainWindow#scene. = new QGraphicsScenecxx . . $ QGraphicsScene#(this);
60 uicxx . . $ MainWindow#ui.->graphicsViewcxx . . $ Ui_MainWindow#graphicsView.->setScenecxx . . $ QGraphicsView#setScene(36f1b6a6c9a93129).(scenecxx . . $ MainWindow#scene.);
61
62 uicxx . . $ MainWindow#ui.->graphicsViewcxx . . $ Ui_MainWindow#graphicsView.->scalecxx . . $ QGraphicsView#scale(bc12c9ec15586e6a).(InitialZoomcxx . . $ InitialZoom., InitialZoomcxx . . $ InitialZoom.);
63
64 uicxx . . $ MainWindow#ui.->graphicsViewcxx . . $ Ui_MainWindow#graphicsView.->viewportcxx . . $ QAbstractScrollArea#viewport(27f420ad5cce8994).()->installEventFiltercxx . . $ QObject#installEventFilter(749de1b6ae65bddd).(this);
65
66 cutDialogcxx . . $ MainWindow#cutDialog. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
67
68 animationTimercxx . . $ MainWindow#animationTimer. = new QTimercxx . . $ QTimer#QTimer(749de1b6ae65bddd).(this);
69 connectcxx . . $ QObject#connect(f4332061c7e4ca89).(animationTimercxx . . $ MainWindow#animationTimer., SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(timeout()), SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(animate()));
70 cutMarkercxx . . $ MainWindow#cutMarker. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
71
72 // Alternative zoom shortcuts
73 QShortcutcxx . . $ QShortcut#* zoom_in = new QShortcutcxx . . $ QShortcut#QShortcut(8bb4a687ee90575c).(QKeySequencecxx . . $ QKeySequence#QKeySequence(6905a94d1418a018).("X"cxx . . $ QString#QString(85c52e162fed56f9).), this);
74 connectcxx . . $ QObject#connect(f4332061c7e4ca89).(zoom_in, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(activated()), SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(on_actionZoom_In_triggered()));
75 QShortcutcxx . . $ QShortcut#* zoom_out = new QShortcutcxx . . $ QShortcut#QShortcut(8bb4a687ee90575c).(QKeySequencecxx . . $ QKeySequence#QKeySequence(6905a94d1418a018).("Z"cxx . . $ QString#QString(85c52e162fed56f9).), this);
76 connectcxx . . $ QObject#connect(f4332061c7e4ca89).(zoom_out, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(activated()), SLOTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:270:10`!(on_actionZoom_Out_triggered()));
77
78 //default options if not specified on command line
79 this->showcxx . . $ QWidget#show(49f6e7a06ebc5aa8).();
80 filenamecxx . . $ MainWindow#filename. =cxx . . $ QString#`operator=`(7b76e6691bca1027). ProgramOptionscxx . . $ ProgramOptions#::Instancecxx . . $ ProgramOptions#Instance(63cd40b15f95c435).().getFileNamecxx . . $ ProgramOptions#getFileName(4365c3963150523e).();
81 if(QFilecxx . . $ QFile#::existscxx . . $ QFile#exists(e1defb592416720d).(filenamecxx . . $ MainWindow#filename.)) loadFilecxx . . $ MainWindow#loadFile(49f6e7a06ebc5aa8).();
82 if(ProgramOptionscxx . . $ ProgramOptions#::Instancecxx . . $ ProgramOptions#Instance(63cd40b15f95c435).().getStartCutcxx . . $ ProgramOptions#getStartCut(b126dc7c1de90089).() == true) on_actionCut_triggeredcxx . . $ MainWindow#on_actionCut_triggered(49f6e7a06ebc5aa8).();
83 sortFlagcxx . . $ MainWindow#sortFlag. = ProgramOptionscxx . . $ ProgramOptions#::Instancecxx . . $ ProgramOptions#Instance(63cd40b15f95c435).().getSortPathcxx . . $ ProgramOptions#getSortPath(b126dc7c1de90089).();
84 coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(88df5bef833f7f83). ProgramOptionscxx . . $ ProgramOptions#::Instancecxx . . $ ProgramOptions#Instance(63cd40b15f95c435).().getVersioncxx . . $ ProgramOptions#getVersion(4365c3963150523e).().toStdStringcxx . . $ QString#toStdString(219584694fe2b248).() <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ std/endl(345bf97a19cc83a9).;
85 }
86
87 MainWindowcxx . . $ MainWindow#::~cxx . . $ MainWindow#`~MainWindow`(49f6e7a06ebc5aa8).MainWindowcxx . . $ MainWindow#()
88 {
89 delete uicxx . . $ MainWindow#ui.;
90 }
91
92 void MainWindowcxx . . $ MainWindow#::on_actionOpen_triggeredcxx . . $ MainWindow#on_actionOpen_triggered(49f6e7a06ebc5aa8).()
93 {
94 if (lastOpenDircxx . . $ MainWindow#lastOpenDir..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).())
95 lastOpenDircxx . . $ MainWindow#lastOpenDir. =cxx . . $ QString#`operator=`(7b76e6691bca1027). QDircxx . . $ QDir#::homePathcxx . . $ QDir#homePath(4365c3963150523e).();
96
97 filenamecxx . . $ MainWindow#filename. =cxx . . $ QString#`operator=`(7b76e6691bca1027). QFileDialogcxx . . $ QFileDialog#::getOpenFileNamecxx . . $ QFileDialog#getOpenFileName(a6b29be4bec65236).(this,
98 trcxx . . $ MainWindow#tr(75d9f1c324b4579d).("Open File"), lastOpenDircxx . . $ MainWindow#lastOpenDir., trcxx . . $ MainWindow#tr(75d9f1c324b4579d).("SVG Files (*.svg)"));
99 if (filenamecxx . . $ MainWindow#filename..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).())
100 return;
101
102 lastOpenDircxx . . $ MainWindow#lastOpenDir. =cxx . . $ QString#`operator=`(7b76e6691bca1027). QFileInfocxx . . $ QFileInfo#(filenamecxx . . $ MainWindow#filename.).absoluteDircxx . . $ QFileInfo#absoluteDir(ac6552cf9b6b4ed1).().pathcxx . . $ QDir#path(6ef7b6c27b00b43d).();
103 loadFilecxx . . $ MainWindow#loadFile(49f6e7a06ebc5aa8).();
104 }
105
106 void MainWindowcxx . . $ MainWindow#::on_actionReload_triggeredcxx . . $ MainWindow#on_actionReload_triggered(49f6e7a06ebc5aa8).()
107 {
108 if(QFilecxx . . $ QFile#::existscxx . . $ QFile#exists(e1defb592416720d).(filenamecxx . . $ MainWindow#filename.))
109 loadFilecxx . . $ MainWindow#loadFile(49f6e7a06ebc5aa8).();
110 else
111 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Reload failed. File missing: " <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). filenamecxx . . $ MainWindow#filename.;
112 }
113
114 void MainWindowcxx . . $ MainWindow#::on_actionIdentify_triggeredcxx . . $ MainWindow#on_actionIdentify_triggered(49f6e7a06ebc5aa8).()
115 {
116 // CAUTION: only call this when not cutting!
117 struct cutter_idcxx . . $ cutter_id# *id = Identifycxx . . $ Identify(4c0d3da0b6c41992).();
118 coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Identify:";
119 if (id->usb_product_idcxx . . $ cutter_id#usb_product_id.)
120 {
121 coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " usb=" <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). id->usb_vendor_idcxx . . $ cutter_id#usb_vendor_id. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "/" <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). id->usb_product_idcxx . . $ cutter_id#usb_product_id.;
122 }
123 coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). id->msgcxx . . $ cutter_id#msg. <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). endlcxx . . $ std/endl(345bf97a19cc83a9).;
124 }
125
126
127 void MainWindowcxx . . $ MainWindow#::loadFilecxx . . $ MainWindow#loadFile(49f6e7a06ebc5aa8).()
128 {
129 if (filenamecxx . . $ MainWindow#filename..isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).())
130 return;
131
132 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Reading file: " <<cxx . . $ QDebug#`operator<<`(4cf17434affdd8). filenamecxx . . $ MainWindow#filename.;
133
134 QSvgRenderercxx . . $ QSvgRenderer# rendcxx . . $ QSvgRenderer#QSvgRenderer(749de1b6ae65bddd).;
135 if (!rend.loadcxx . . $ QSvgRenderer#load(e1defb592416720d).(filenamecxx . . $ MainWindow#filename.))
136 {
137 QMessageBoxcxx . . $ QMessageBox#::criticalcxx . . $ QMessageBox#critical(a9e3742e6f7b4147).(this, "Error loading file."cxx . . $ QString#QString(85c52e162fed56f9)., "Couldn't open the file for reading."cxx . . $ QString#QString(85c52e162fed56f9).);
138 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Error loading svg.";
139 return;
140 }
141
142 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "SVG default size: " <<cxx . . $ `operator<<`(592d53aaa30fc207). rend.defaultSizecxx . . $ QSvgRenderer#defaultSize(4b3b776e5ee2b367).() <<cxx . . $ QDebug#`operator<<`(eeec1a57ad6beb98). endlcxx . . $ QTextStreamFunctions/endl(e06208c9acdf85a).;
143 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "SVG view box: " <<cxx . . $ `operator<<`(e334a4ee66891918). rend.viewBoxFcxx . . $ QSvgRenderer#viewBoxF(19f9350443f914b1).() <<cxx . . $ QDebug#`operator<<`(eeec1a57ad6beb98). endlcxx . . $ QTextStreamFunctions/endl(e06208c9acdf85a).;
144
145 // Geqt size from SVG. TODO: Sanity check.
146 // Also TODO: This won't handle offset viewboxes... need to get the offset and subtract it from
147 // all the objects.
148 mediaSizecxx . . $ MainWindow#mediaSize. =cxx . . $ QSizeF#`operator=`(e7ab68f4251dade2). rend.viewBoxFcxx . . $ QSvgRenderer#viewBoxF(19f9350443f914b1).().sizecxx . . $ QRectF#size(6c9504dc925659fb).() *cxx . . $ `operator*`(4683a145cd19aee8). 25.4 /cxx . . $ `operator/`(4683a145cd19aee8). 90.0;
149
150 double ppm = 90.0/25.4; // Pixels per mm.
151
152 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Page size (mm): " <<cxx . . $ `operator<<`(4e890e0e029c6348). mediaSizecxx . . $ MainWindow#mediaSize. <<cxx . . $ QDebug#`operator<<`(eeec1a57ad6beb98). endlcxx . . $ QTextStreamFunctions/endl(e06208c9acdf85a).;
153
154 PathPaintDevicecxx . . $ PathPaintDevice# pgcxx . . $ PathPaintDevice#PathPaintDevice(98dd472ac7e5c3d4).(mediaSizecxx . . $ MainWindow#mediaSize..widthcxx . . $ QSizeF#width(21b6c25e127938e2).(), mediaSizecxx . . $ MainWindow#mediaSize..heightcxx . . $ QSizeF#height(21b6c25e127938e2).(), ppm);
155 QPaintercxx . . $ QPainter# pcxx . . $ QPainter#QPainter(dd2eedc069b0ab5f).(&pg);
156
157 rend.rendercxx . . $ QSvgRenderer#render(c81d535d1ac9d52).(&p);
158
159 PathSortercxx . . $ PathSorter# pathsortcxx . . $ PathSorter#PathSorter(dcc77b921aa1e136).(pgcxx . . $ QList#QList(b1a5d2b9a710f6d1)..pathscxx . . $ PathPaintDevice#paths(90068b3bf70c4f3b).(), mediaSizecxx . . $ MainWindow#mediaSize..heightcxx . . $ QSizeF#height(21b6c25e127938e2).());
160 pathscxx . . $ MainWindow#paths. =cxx . . $ QList#`operator=`(15ec5f0e45a4f6d6). pathsort.UnSortcxx . . $ PathSorter#UnSort(90068b3bf70c4f3b).();
161 //paths = pathsort.Sort();
162 //paths = pathsort.TspSort();
163 //paths = pathsort.GroupTSP();
164 if(!ProgramOptionscxx . . $ ProgramOptions#::Instancecxx . . $ ProgramOptions#Instance(63cd40b15f95c435).().getSortPathcxx . . $ ProgramOptions#getSortPath(b126dc7c1de90089).() == true)pathscxx . . $ MainWindow#paths. =cxx . . $ QList#`operator=`(15ec5f0e45a4f6d6). pathsort.BestSortcxx . . $ PathSorter#BestSort(90068b3bf70c4f3b).();
165 if(ProgramOptionscxx . . $ ProgramOptions#::Instancecxx . . $ ProgramOptions#Instance(63cd40b15f95c435).().getTspSortPathcxx . . $ ProgramOptions#getTspSortPath(b126dc7c1de90089).() == true)pathscxx . . $ MainWindow#paths. =cxx . . $ QList#`operator=`(15ec5f0e45a4f6d6). pathsort.BbSortcxx . . $ PathSorter#BbSort(5dd9053a288285ea).(pathscxx . . $ QList#QList(3d2301cfd89f773a).);
166 scenecxx . . $ MainWindow#scene.->clearcxx . . $ QGraphicsScene#clear(49f6e7a06ebc5aa8).();
167 scenecxx . . $ MainWindow#scene.->setBackgroundBrushcxx . . $ QGraphicsScene#setBackgroundBrush(ffc9f5d0bda78261).(QBrushcxx . . $ QBrush#QBrush(1975e3c608654284).(Qtcxx . . $ Qt/::lightGraycxx . . $ Qt/lightGray.));
168
169 // The page.
170 scenecxx . . $ MainWindow#scene.->addRectcxx . . $ QGraphicsScene#addRect(8b32f31917c83f7).(0.0, 0.0, mediaSizecxx . . $ MainWindow#mediaSize..widthcxx . . $ QSizeF#width(21b6c25e127938e2).(), mediaSizecxx . . $ MainWindow#mediaSize..heightcxx . . $ QSizeF#height(21b6c25e127938e2).(), QPencxx . . $ QPen#QPen(49f6e7a06ebc5aa8).(), QBrushcxx . . $ QBrush#QBrush(1975e3c608654284).(Qtcxx . . $ Qt/::whitecxx . . $ Qt/white.));
171
172 QPencxx . . $ QPen# pencxx . . $ QPen#QPen(49f6e7a06ebc5aa8).;
173 pen.setWidthFcxx . . $ QPen#setWidthF(ba8836b59fb42830).(0.0);
174 for (int i = 0, ii = 50, iii=0; i < pathscxx . . $ MainWindow#paths..sizecxx . . $ QList#size(455f465bc33b4cdf).(); ++i,ii+=10)
175 {
176 switch (iii)
177 {
178 case 0:
179 pen.setColorcxx . . $ QPen#setColor(129a55e114526ad3).(QColorcxx . . $ QColor#QColor(748afa4755bc9595).(ii, ii, ii));
180 break;
181 case 1:
182 pen.setColorcxx . . $ QPen#setColor(129a55e114526ad3).(QColorcxx . . $ QColor#QColor(748afa4755bc9595).(ii, 0, 0));
183 break;
184 case 2:
185 pen.setColorcxx . . $ QPen#setColor(129a55e114526ad3).(QColorcxx . . $ QColor#QColor(748afa4755bc9595).(0, ii, 0));
186 break;
187 case 3:
188 pen.setColorcxx . . $ QPen#setColor(129a55e114526ad3).(QColorcxx . . $ QColor#QColor(748afa4755bc9595).(0, 0, ii));
189 break;
190 case 4:
191 pen.setColorcxx . . $ QPen#setColor(129a55e114526ad3).(QColorcxx . . $ QColor#QColor(748afa4755bc9595).(ii, ii, 0));
192 break;
193 case 5:
194 pen.setColorcxx . . $ QPen#setColor(129a55e114526ad3).(QColorcxx . . $ QColor#QColor(748afa4755bc9595).(ii, 0, ii));
195 break;
196 case 6:
197 pen.setColorcxx . . $ QPen#setColor(129a55e114526ad3).(QColorcxx . . $ QColor#QColor(748afa4755bc9595).(0, ii, ii));
198 break;
199 }
200 QPainterPathcxx . . $ QPainterPath# pathcxx . . $ QPainterPath#QPainterPath(49f6e7a06ebc5aa8).;
201 path.addPolygoncxx . . $ QPainterPath#addPolygon(e790b6e62144e8f9).(pathscxx . . $ MainWindow#paths.[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).i]);
202 scenecxx . . $ MainWindow#scene.->addPathcxx . . $ QGraphicsScene#addPath(1bcda135230aba0c).(path, pen);
203 if(ii >= 200)
204 {
205 ii = 50;
206 iii++;
207 if(iii >=7)iii=0;
208 }
209 }
210
211 // Handle the animation. I.e. stop it.
212 // The old one was deleted when we cleared the scene.
213 cutMarkercxx . . $ MainWindow#cutMarker. = scenecxx . . $ MainWindow#scene.->addEllipsecxx . . $ QGraphicsScene#addEllipse(4150d4ec6dfc9ea).(-1.0, -1.0, 2.0, 2.0, QPencxx . . $ QPen#QPen(129a55e114526ad3).(Qtcxx . . $ QColor#QColor(cd98eb3c6d110ca7).::blackcxx . . $ Qt/black.), QBrushcxx . . $ QBrush#QBrush(1975e3c608654284).(Qtcxx . . $ Qt/::redcxx . . $ Qt/red.));
214 cutMarkercxx . . $ MainWindow#cutMarker.->hidecxx . . $ QGraphicsItem#hide(49f6e7a06ebc5aa8).();
215
216 uicxx . . $ MainWindow#ui.->actionAnimatecxx . . $ Ui_MainWindow#actionAnimate.->setCheckedcxx . . $ QAction#setChecked(b45ddcbc8423892c).(false);
217
218 // Reset the viewport.
219 on_actionReset_triggeredcxx . . $ MainWindow#on_actionReset_triggered(49f6e7a06ebc5aa8).();
220 // Redraw. Probably not necessary.
221 updatecxx . . $ QWidget#update(49f6e7a06ebc5aa8).();
222
223 if (pg.clippedcxx . . $ PathPaintDevice#clipped(50ce9a9e25b4a850).())
224 QMessageBoxcxx . . $ QMessageBox#::warningcxx . . $ QMessageBox#warning(a9e3742e6f7b4147).(this, "Paths clipped"cxx . . $ QString#QString(85c52e162fed56f9)., "<b>BIG FAT WARNING!</b><br><br>Some paths lay outside the 210&times;297&thinsp;mm A4 area. These have been squeezed back onto the page in a most ugly fashion, so cutting will almost certainly not do what you want."cxx . . $ QString#QString(85c52e162fed56f9).);
225
226 // Change window title and enable menu items.
227 setFileLoadedcxx . . $ MainWindow#setFileLoaded(7df51288a9ebd664).(filenamecxx . . $ QString#QString(3520e46b33348bf6).);
228 }
229
230 void MainWindowcxx . . $ MainWindow#::on_actionAbout_triggeredcxx . . $ MainWindow#on_actionAbout_triggered(49f6e7a06ebc5aa8).()
231 {
232 QStringcxx . . $ QString# message = "<b>"cxx . . $ QString#QString(3520e46b33348bf6). +cxx . . $ operator+(c75c3ae4eb9af1a8). ProgramOptionscxx . . $ ProgramOptions#::Instancecxx . . $ ProgramOptions#Instance(63cd40b15f95c435).().getVersioncxx . . $ ProgramOptions#getVersion(4365c3963150523e).() +cxx . . $ operator+(3d22f08efddf8107).
233 "</b><br><br>By Tim Hutt, &copy; 2010<br/>" +cxx . . $ operator+(3d22f08efddf8107).
234 "<br>Parts of the source by Markus Schulz, &copy; 2010<br/>" +cxx . . $ operator+(3d22f08efddf8107).
235 "<br/>This software allows you to read a vector image in <a href=\"http://en.wikipedia.org/wiki/Scalable_Vector_Graphics\">SVG format</a>, " +cxx . . $ operator+(3d22f08efddf8107).
236 "and send it to a <a href=\"http://www.graphteccorp.com/craftrobo/\">Graphtec Craft Robo 2</a>/3 " +cxx . . $ operator+(3d22f08efddf8107).
237 " or <a href=\"http://www.silhouette.com/cameo\">Silhouette Cameo</a> " +cxx . . $ operator+(3d22f08efddf8107).
238 " (or similar device) for cutting. It is designed to work with SVGs produced " +cxx . . $ operator+(3d22f08efddf8107).
239 "by the excellent free vector graphics editor <a href=\"http://www.inkscape.org/\">Inkscape</a>. " +cxx . . $ operator+(3d22f08efddf8107).
240 " It may work with other software but this has not been tested.<br/>" +cxx . . $ operator+(3d22f08efddf8107).
241 "<br/>See <a href=\"http://robocut.org\">the website for more information</a>.";
242 QMessageBoxcxx . . $ QMessageBox#::informationcxx . . $ QMessageBox#information(a9e3742e6f7b4147).(this, "About"cxx . . $ QString#QString(85c52e162fed56f9)., message);
243 }
244
245 void MainWindowcxx . . $ MainWindow#::on_actionExit_triggeredcxx . . $ MainWindow#on_actionExit_triggered(49f6e7a06ebc5aa8).()
246 {
247 closecxx . . $ QWidget#close(c9857a73d68e59ba).();
248 }
249
250 void MainWindowcxx . . $ MainWindow#::on_actionCut_triggeredcxx . . $ MainWindow#on_actionCut_triggered(49f6e7a06ebc5aa8).()
251 {
252 if (!cutDialogcxx . . $ MainWindow#cutDialog.)
253 cutDialogcxx . . $ MainWindow#cutDialog. = new CutDialogcxx . . $ CutDialog#(this);
254
255 if (cutDialogcxx . . $ MainWindow#cutDialog.->execcxx . . $ QDialog#exec(b126dc7c1de90089).() != QDialogcxx . . $ QDialog#::Acceptedcxx . . $ QDialog#Accepted.)
256 return;
257
258 // Create a new dialog and run the actual cutting in a different thread.
259
260 CuttingDialogcxx . . $ CuttingDialog#* cuttingDlg = new CuttingDialogcxx . . $ CuttingDialog#(this);
261
262 CutParamscxx . . $ CutParams# params;
263 params.cutscxx . . $ CutParams#cuts. =cxx . . $ QList#`operator=`(296c5e09a09ca26f). pathscxx . . $ MainWindow#paths.;
264 params.mediawidthcxx . . $ CutParams#mediawidth. = mediaSizecxx . . $ MainWindow#mediaSize..widthcxx . . $ QSizeF#width(21b6c25e127938e2).();
265 params.mediaheightcxx . . $ CutParams#mediaheight. = mediaSizecxx . . $ MainWindow#mediaSize..heightcxx . . $ QSizeF#height(21b6c25e127938e2).();
266 params.mediacxx . . $ CutParams#media. = cutDialogcxx . . $ MainWindow#cutDialog.->mediacxx . . $ CutDialog#media(455f465bc33b4cdf).();
267 params.pressurecxx . . $ CutParams#pressure. = cutDialogcxx . . $ MainWindow#cutDialog.->pressurecxx . . $ CutDialog#pressure(455f465bc33b4cdf).();
268 params.regwidthcxx . . $ CutParams#regwidth. = cutDialogcxx . . $ MainWindow#cutDialog.->regWidthcxx . . $ CutDialog#regWidth(21b6c25e127938e2).();
269 params.regheightcxx . . $ CutParams#regheight. = cutDialogcxx . . $ MainWindow#cutDialog.->regHeightcxx . . $ CutDialog#regHeight(21b6c25e127938e2).();
270 params.regmarkcxx . . $ CutParams#regmark. = cutDialogcxx . . $ MainWindow#cutDialog.->regMarkcxx . . $ CutDialog#regMark(50ce9a9e25b4a850).();
271 params.regsearchcxx . . $ CutParams#regsearch. = cutDialogcxx . . $ MainWindow#cutDialog.->regSearchcxx . . $ CutDialog#regSearch(50ce9a9e25b4a850).();
272 params.speedcxx . . $ CutParams#speed. = cutDialogcxx . . $ MainWindow#cutDialog.->speedcxx . . $ CutDialog#speed(455f465bc33b4cdf).();
273 params.trackenhancingcxx . . $ CutParams#trackenhancing. = cutDialogcxx . . $ MainWindow#cutDialog.->trackEnhancingcxx . . $ CutDialog#trackEnhancing(50ce9a9e25b4a850).();
274
275 cuttingDlg->startCutcxx . . $ CuttingDialog#startCut(f40ad2760b5d2a0).(params);
276 cuttingDlg->showcxx . . $ QWidget#show(49f6e7a06ebc5aa8).();
277 }
278
279 void MainWindowcxx . . $ MainWindow#::on_actionManual_triggeredcxx . . $ MainWindow#on_actionManual_triggered(49f6e7a06ebc5aa8).()
280 {
281 QMessageBoxcxx . . $ QMessageBox#::informationcxx . . $ QMessageBox#information(a9e3742e6f7b4147).(this, "Manual"cxx . . $ QString#QString(85c52e162fed56f9)., "An online manual is available at <br><br><a href=\"http://robocut.org/\">http://robocut.org/</a>"cxx . . $ QString#QString(85c52e162fed56f9).);
282 }
283
284 void MainWindowcxx . . $ MainWindow#::on_actionAnimate_toggledcxx . . $ MainWindow#on_actionAnimate_toggled(b45ddcbc8423892c).(bool animate)
285 {
286 if (animate)
287 {
288 animationTimercxx . . $ MainWindow#animationTimer.->startcxx . . $ QTimer#start(d4f767463ce0a6b3).(30);
289 if (cutMarkercxx . . $ MainWindow#cutMarker.)
290 {
291 cutMarkercxx . . $ MainWindow#cutMarker.->setPoscxx . . $ QGraphicsItem#setPos(bc12c9ec15586e6a).(0, 0);
292 cutMarkercxx . . $ MainWindow#cutMarker.->showcxx . . $ QGraphicsItem#show(49f6e7a06ebc5aa8).();
293 }
294
295 cutMarkerPathcxx . . $ MainWindow#cutMarkerPath. = 0;
296 cutMarkerLinecxx . . $ MainWindow#cutMarkerLine. = 0;
297 cutMarkerDistancecxx . . $ MainWindow#cutMarkerDistance. = 0.0;
298 }
299 else
300 {
301 animationTimercxx . . $ MainWindow#animationTimer.->stopcxx . . $ QTimer#stop(49f6e7a06ebc5aa8).();
302 if (cutMarkercxx . . $ MainWindow#cutMarker.)
303 cutMarkercxx . . $ MainWindow#cutMarker.->hidecxx . . $ QGraphicsItem#hide(49f6e7a06ebc5aa8).();
304 }
305 }
306
307 void MainWindowcxx . . $ MainWindow#::on_actionReset_triggeredcxx . . $ MainWindow#on_actionReset_triggered(49f6e7a06ebc5aa8).()
308 {
309 uicxx . . $ MainWindow#ui.->graphicsViewcxx . . $ Ui_MainWindow#graphicsView.->resetTransformcxx . . $ QGraphicsView#resetTransform(49f6e7a06ebc5aa8).();
310 uicxx . . $ MainWindow#ui.->graphicsViewcxx . . $ Ui_MainWindow#graphicsView.->scalecxx . . $ QGraphicsView#scale(bc12c9ec15586e6a).(InitialZoomcxx . . $ InitialZoom., InitialZoomcxx . . $ InitialZoom.);
311 }
312
313 void MainWindowcxx . . $ MainWindow#::on_actionZoom_In_triggeredcxx . . $ MainWindow#on_actionZoom_In_triggered(49f6e7a06ebc5aa8).()
314 {
315 uicxx . . $ MainWindow#ui.->graphicsViewcxx . . $ Ui_MainWindow#graphicsView.->scalecxx . . $ QGraphicsView#scale(bc12c9ec15586e6a).(1.2, 1.2);
316 }
317
318 void MainWindowcxx . . $ MainWindow#::on_actionZoom_Out_triggeredcxx . . $ MainWindow#on_actionZoom_Out_triggered(49f6e7a06ebc5aa8).()
319 {
320 uicxx . . $ MainWindow#ui.->graphicsViewcxx . . $ Ui_MainWindow#graphicsView.->scalecxx . . $ QGraphicsView#scale(bc12c9ec15586e6a).(1.0/1.2, 1.0/1.2);
321 }
322
323 void MainWindowcxx . . $ MainWindow#::animatecxx . . $ MainWindow#animate(49f6e7a06ebc5aa8).()
324 {
325 if (!cutMarkercxx . . $ MainWindow#cutMarker.)
326 return;
327
328 // Make sure the current position is sane.
329 if (cutMarkerPathcxx . . $ MainWindow#cutMarkerPath. >= pathscxx . . $ MainWindow#paths..sizecxx . . $ QList#size(455f465bc33b4cdf).() || cutMarkerLinecxx . . $ MainWindow#cutMarkerLine. >= pathscxx . . $ MainWindow#paths.[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).cutMarkerPathcxx . . $ MainWindow#cutMarkerPath.].sizecxx . . $ QVector#size(455f465bc33b4cdf).())
330 {
331 // If not, reset it.
332 cutMarkerPathcxx . . $ MainWindow#cutMarkerPath. = 0;
333 cutMarkerLinecxx . . $ MainWindow#cutMarkerLine. = 0;
334 cutMarkerDistancecxx . . $ MainWindow#cutMarkerDistance. = 0.0;
335 return;
336 }
337 // Get the ends of the segment/edge we are currently on.
338
339 QPointFcxx . . $ QPointF# a = pathscxx . . $ MainWindow#paths.[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).cutMarkerPathcxx . . $ MainWindow#cutMarkerPath.][cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).cutMarkerLinecxx . . $ MainWindow#cutMarkerLine.];
340 QPointFcxx . . $ QPointF# bcxx . . $ QPointF#QPointF(49f6e7a06ebc5aa8).;
341 if (cutMarkerLinecxx . . $ MainWindow#cutMarkerLine. == pathscxx . . $ MainWindow#paths.[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).cutMarkerPathcxx . . $ MainWindow#cutMarkerPath.].sizecxx . . $ QVector#size(455f465bc33b4cdf).()-1)
342 {
343 // We are moving between paths, and not cutting.
344 b =cxx . . $ QPointF#`operator=`(b024836c2ac1a957). pathscxx . . $ MainWindow#paths.[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).(cutMarkerPathcxx . . $ MainWindow#cutMarkerPath.+1) % pathscxx . . $ MainWindow#paths..sizecxx . . $ QList#size(455f465bc33b4cdf).()][cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).0];
345 cutMarkercxx . . $ MainWindow#cutMarker.->setOpacitycxx . . $ QGraphicsItem#setOpacity(ba8836b59fb42830).(0.2);
346 }
347 else
348 {
349 // We are cutting on a path.
350 b =cxx . . $ QPointF#`operator=`(b024836c2ac1a957). pathscxx . . $ MainWindow#paths.[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).cutMarkerPathcxx . . $ MainWindow#cutMarkerPath.][cxx . . $ QVector#`operator[]`(7a0ef1c7079e8533).cutMarkerLinecxx . . $ MainWindow#cutMarkerLine.+1];
351 cutMarkercxx . . $ MainWindow#cutMarker.->setOpacitycxx . . $ QGraphicsItem#setOpacity(ba8836b59fb42830).(1.0);
352 }
353
354 QPointFcxx . . $ QPointF# r = b-cxx . . $ operator-(e229ca25d6519380).a;
355 double h = hypot(r.xcxx . . $ QPointF#x(21b6c25e127938e2).(), r.ycxx . . $ QPointF#y(21b6c25e127938e2).());
356 if (h > 0.0)
357 r /=cxx . . $ QPointF#`operator/=`(82df65ffd9cc3fb3). h;
358
359 // The current position of the marker.
360 QPointFcxx . . $ QPointF# p = a +cxx . . $ operator+(e229ca25d6519380). r *cxx . . $ `operator*`(a55706169906eb91). cutMarkerDistancecxx . . $ MainWindow#cutMarkerDistance.;
361
362 cutMarkercxx . . $ MainWindow#cutMarker.->setPoscxx . . $ QGraphicsItem#setPos(4258778b894f8bb6).(p);
363
364 // Advance the position of the marker for the next time this function is called.
365 cutMarkerDistancecxx . . $ MainWindow#cutMarkerDistance. += 2.0;
366 if (cutMarkerDistancecxx . . $ MainWindow#cutMarkerDistance. > h)
367 {
368 cutMarkerDistancecxx . . $ MainWindow#cutMarkerDistance. = 0.0;
369 if (++cutMarkerLinecxx . . $ MainWindow#cutMarkerLine. >= pathscxx . . $ MainWindow#paths.[cxx . . $ QList#`operator[]`(7a0ef1c7079e8533).cutMarkerPathcxx . . $ MainWindow#cutMarkerPath.].sizecxx . . $ QVector#size(455f465bc33b4cdf).())
370 {
371 cutMarkerLinecxx . . $ MainWindow#cutMarkerLine. = 0;
372 if (++cutMarkerPathcxx . . $ MainWindow#cutMarkerPath. >= pathscxx . . $ MainWindow#paths..sizecxx . . $ QList#size(455f465bc33b4cdf).())
373 {
374 cutMarkerPathcxx . . $ MainWindow#cutMarkerPath. = 0;
375
376 // Also stop the animation...
377 uicxx . . $ MainWindow#ui.->actionAnimatecxx . . $ Ui_MainWindow#actionAnimate.->setCheckedcxx . . $ QAction#setChecked(b45ddcbc8423892c).(false);
378
379 }
380 }
381 }
382 }
383 void MainWindowcxx . . $ MainWindow#::setFileLoadedcxx . . $ MainWindow#setFileLoaded(7df51288a9ebd664).(QStringcxx . . $ QString# filename)
384 {
385 bool e = !filename.isEmptycxx . . $ QString#isEmpty(50ce9a9e25b4a850).();
386 if (e)
387 setWindowTitlecxx . . $ QWidget#setWindowTitle(3520e46b33348bf6).("Robocut - " +cxx . . $ operator+(c75c3ae4eb9af1a8). filename);
388 else
389 setWindowTitlecxx . . $ QWidget#setWindowTitle(3520e46b33348bf6).("Robocut"cxx . . $ QString#QString(85c52e162fed56f9).);
390
391 uicxx . . $ MainWindow#ui.->actionAnimatecxx . . $ Ui_MainWindow#actionAnimate.->setEnabledcxx . . $ QAction#setEnabled(b45ddcbc8423892c).(e);
392 uicxx . . $ MainWindow#ui.->actionResetcxx . . $ Ui_MainWindow#actionReset.->setEnabledcxx . . $ QAction#setEnabled(b45ddcbc8423892c).(e);
393 uicxx . . $ MainWindow#ui.->actionZoom_Incxx . . $ Ui_MainWindow#actionZoom_In.->setEnabledcxx . . $ QAction#setEnabled(b45ddcbc8423892c).(e);
394 uicxx . . $ MainWindow#ui.->actionZoom_Outcxx . . $ Ui_MainWindow#actionZoom_Out.->setEnabledcxx . . $ QAction#setEnabled(b45ddcbc8423892c).(e);
395 uicxx . . $ MainWindow#ui.->actionCutcxx . . $ Ui_MainWindow#actionCut.->setEnabledcxx . . $ QAction#setEnabled(b45ddcbc8423892c).(e);
396 uicxx . . $ MainWindow#ui.->actionReloadcxx . . $ Ui_MainWindow#actionReload.->setEnabledcxx . . $ QAction#setEnabled(b45ddcbc8423892c).(e);
397
398 }
399
400 bool MainWindowcxx . . $ MainWindow#::eventFiltercxx . . $ MainWindow#eventFilter(978aa4af1d030efa).(QObjectcxx . . $ QObject# *o, QEventcxx . . $ QEvent# *e)
401 {
402 if (o == uicxx . . $ MainWindow#ui.->graphicsViewcxx . . $ Ui_MainWindow#graphicsView.->viewportcxx . . $ QAbstractScrollArea#viewport(27f420ad5cce8994).())
403 {
404 if (e->typecxx . . $ QEvent#type(916a8de57f4d422b).() == QEventcxx . . $ QEvent#::Wheelcxx . . $ QEvent#Wheel.)
405 {
406 // Anchor under the mouse pointer when using the mouse wheel.
407 // This doesn't quite work as nicely as I'd like because it clamps the scrolling
408 // precisely to the scene boundary. It's a bit hard to zoom to corners. Oh well.
409 uicxx . . $ MainWindow#ui.->graphicsViewcxx . . $ Ui_MainWindow#graphicsView.->setTransformationAnchorcxx . . $ QGraphicsView#setTransformationAnchor(b1a7cc6e5f9801ca).(QGraphicsViewcxx . . $ QGraphicsView#::AnchorUnderMousecxx . . $ QGraphicsView#AnchorUnderMouse.);
410 QWheelEventcxx . . $ QWheelEvent# *w = dynamic_cast<QWheelEventcxx . . $ QWheelEvent#*>(e);
411 if (w->deltacxx . . $ QWheelEvent#delta(455f465bc33b4cdf).() <= 0)
412 on_actionZoom_Out_triggeredcxx . . $ MainWindow#on_actionZoom_Out_triggered(49f6e7a06ebc5aa8).();
413 else
414 on_actionZoom_In_triggeredcxx . . $ MainWindow#on_actionZoom_In_triggered(49f6e7a06ebc5aa8).();
415
416 // Anchor in view centre for keyboard shortcuts.
417 uicxx . . $ MainWindow#ui.->graphicsViewcxx . . $ Ui_MainWindow#graphicsView.->setTransformationAnchorcxx . . $ QGraphicsView#setTransformationAnchor(b1a7cc6e5f9801ca).(QGraphicsViewcxx . . $ QGraphicsView#::AnchorViewCentercxx . . $ QGraphicsView#AnchorViewCenter.);
418 return true;
419 }
420 }
421 return false;
422 }
423