1 /*
2 	Copyright 2006-2019 The QElectroTech Team
3 	This file is part of QElectroTech.
4 
5 	QElectroTech is free software: you can redistribute it and/or modify
6 	it under the terms of the GNU General Public License as published by
7 	the Free Software Foundation, either version 2 of the License, or
8 	(at your option) any later version.
9 
10 	QElectroTech is distributed in the hope that it will be useful,
11 	but WITHOUT ANY WARRANTY; without even the implied warranty of
12 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 	GNU General Public License for more details.
14 
15 	You should have received a copy of the GNU General Public License
16 	along with QElectroTech.  If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef ELEMENTS_MOVER_H
19 #define ELEMENTS_MOVER_H
20 
21 #include <QPointF>
22 #include "diagramcontent.h"
23 
24 class ConductorTextItem;
25 class Diagram;
26 /**
27 	This class manages the interactive movement of different items (elements,
28 	conductors, text items etc...) on a particular diagram.
29 
30 	A movement work in 3 steps:
31 	1: beginMovement    -> init a new movement
32 	2: continueMovement -> continue the curent movement
33 	3: endMovement      -> finish the curent movement
34 
35 	A movement in progress must finish befor start a new movement. We can know if
36 	element mover is ready for a new movement by calling isReady().
37 */
38 class ElementsMover {
39 	// constructors, destructor
40 	public:
41 	ElementsMover();
42 	virtual ~ElementsMover();
43 	private:
44 	ElementsMover(const ElementsMover &);
45 
46 	// methods
47 	public:
48 	bool isReady() const;
49 	int  beginMovement(Diagram *, QGraphicsItem * = nullptr);
50 	void continueMovement(const QPointF &);
51 	void endMovement();
52 
53 	// attributes
54 	private:
55 	bool movement_running_;
56 	QPointF current_movement_;
57 	Diagram *diagram_;
58 	QGraphicsItem *m_movement_driver;
59 	DiagramContent m_moved_content;
60 };
61 #endif
62