| 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 | #pragma once |
| 23 | |
| 24 | #include <QThread> |
| 25 | |
| 26 | #include <QPolygonF> |
| 27 | |
| 28 | // A thread to send the cutting stuff to the plotter. |
| 29 | // To use: |
| 30 | // |
| 31 | // 1. Create. |
| 32 | // 2. Connect success() and error() to your class. Only one is called. |
| 33 | // 3. Call setParams(...) with the parameters you want. |
| 34 | // 4. Call start(). |
| 35 | // 5. Wait for success() or error(). |
| 36 | |
| 37 | struct CutParams |
| 38 | { |
| 39 | QList<QPolygonF> cuts; |
| 40 | double mediawidth = 0.0; |
| 41 | double mediaheight = 0.0; |
| 42 | int media = 300; |
| 43 | int speed = 10; |
| 44 | int pressure = 10; |
| 45 | bool trackenhancing = false; |
| 46 | bool regmark = false; |
| 47 | bool regsearch = false; |
| 48 | double regwidth = 0.0; |
| 49 | double regheight = 0.0; |
| 50 | }; |
| 51 | |
| 52 | class CuttingThread : public QThread |
| 53 | { |
| 54 | Q_OBJECT |
| 55 | public: |
| 56 | explicit CuttingThread(QObject *parent = 0); |
| 57 | |
| 58 | // Set the parameters to use for the cut. |
| 59 | void setParams(const CutParams& params); |
| 60 | |
| 61 | signals: |
| 62 | // Emitted if the cutting was (as far as we can tell) successful. |
| 63 | void success(); |
| 64 | // Emitted if the cutting failed. |
| 65 | void error(QString message); |
| 66 | public slots: |
| 67 | |
| 68 | protected: |
| 69 | // This reads the params, then tries to send the data to the cutter. |
| 70 | // When it is done, it runs exec() to send the success() or error() signal. |
| 71 | void run(); |
| 72 | |
| 73 | private: |
| 74 | CutParams params; |
| 75 | |
| 76 | }; |