1 /**************************************************************************** 2 ** 3 ** This file is part of the LibreCAD project, a 2D CAD program 4 ** 5 ** Copyright (C) 2019 A. Stebich (librecad@mail.lordofbikes.de) 6 ** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl) 7 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved. 8 ** 9 ** 10 ** This file may be distributed and/or modified under the terms of the 11 ** GNU General Public License version 2 as published by the Free Software 12 ** Foundation and appearing in the file gpl-2.0.txt included in the 13 ** packaging of this file. 14 ** 15 ** This program is distributed in the hope that it will be useful, 16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 ** GNU General Public License for more details. 19 ** 20 ** You should have received a copy of the GNU General Public License 21 ** along with this program; if not, write to the Free Software 22 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 ** 24 ** This copyright notice MUST APPEAR in all copies of the script! 25 ** 26 **********************************************************************/ 27 28 #ifndef RS_ACTIONDRAWLINE_H 29 #define RS_ACTIONDRAWLINE_H 30 31 #include "rs_previewactioninterface.h" 32 33 /** 34 * This action class can handle user events to draw 35 * simple lines with the start- and endpoint given. 36 * 37 * @author Andrew Mustun 38 */ 39 class RS_ActionDrawLine : public RS_PreviewActionInterface 40 { 41 Q_OBJECT 42 43 public: 44 /// Action States 45 enum Status { 46 SetStartpoint, ///< Setting the startpoint 47 SetEndpoint ///< Setting the endpoint 48 }; 49 50 /// History Actions 51 enum HistoryAction { 52 HA_SetStartpoint, ///< Setting the startpoint 53 HA_SetEndpoint, ///< Setting the endpoint 54 HA_Close, ///< Close group of lines 55 HA_Next ///< Start new group of lines 56 }; 57 58 public: 59 RS_ActionDrawLine(RS_EntityContainer& container, 60 RS_GraphicView& graphicView); 61 ~RS_ActionDrawLine() override; 62 63 void reset(); 64 65 void init(int status=0) override; 66 void trigger() override; 67 68 void mouseMoveEvent(QMouseEvent* e) override; 69 void mouseReleaseEvent(QMouseEvent* e) override; 70 71 void coordinateEvent(RS_CoordinateEvent* e) override; 72 void commandEvent(RS_CommandEvent* e) override; 73 QStringList getAvailableCommands() override; 74 75 void showOptions() override; 76 void hideOptions() override; 77 78 void updateMouseButtonHints() override; 79 void updateMouseCursor() override; 80 void addHistory(RS_ActionDrawLine::HistoryAction a, const RS_Vector& p, const RS_Vector& c, const int s); 81 82 void close(); 83 void next(); 84 void undo(); 85 void redo(); 86 87 protected: 88 struct History; 89 struct Points; 90 std::unique_ptr<Points> pPoints; 91 }; 92 93 #endif 94