QElectroTech  0.70
diagrameventaddelement.h
Go to the documentation of this file.
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 DIAGRAMEVENTADDELEMENT_H
19 #define DIAGRAMEVENTADDELEMENT_H
20 
21 #include "diagrameventinterface.h"
22 #include "elementslocation.h"
23 
24 class Element;
25 
32 {
33  Q_OBJECT
34 
35  public:
36  DiagramEventAddElement(ElementsLocation &location, Diagram *diagram, QPointF pos = QPointF(0,0));
37  ~DiagramEventAddElement() override;
38 
39  void mouseMoveEvent (QGraphicsSceneMouseEvent *event) override;
40  void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
41  void mouseReleaseEvent (QGraphicsSceneMouseEvent *event) override;
42  void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event) override;
43  void keyPressEvent (QKeyEvent *event) override;
44  void init() override;
45 
46  private:
47  bool buildElement();
48  void addElement();
49 
50  private:
54 };
55 
56 #endif // DIAGRAMEVENTADDELEMENT_H
DiagramEventAddElement(ElementsLocation &location, Diagram *diagram, QPointF pos=QPointF(0, 0))
DiagramEventAddElement::DiagramEventAddElement Defaut constructor.
bool buildElement()
DiagramEventAddElement::buildElement Build the element, if the element is build successfully, we return true, otherwise false.
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddElement::mouseDoubleClickEvent If mouse left double clic, finish this event (isRunning...
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddElement::mouseReleaseEvent Right button finish this event (isRunning = false) and emit...
void keyPressEvent(QKeyEvent *event) override
DiagramEventAddElement::keyPressEvent Press space key rotate the element to 90° (return true) else ca...
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddElement::mouseMoveEvent Move the element to new pos of mouse the event is always accep...
~DiagramEventAddElement() override
DiagramEventAddElement::~DiagramEventAddElement Destructor Enable context menu for each view of diagr...
void init() override
DiagramEventAddElement::init Init this event.
The DiagramEventAddElement class This diagram event add a new element, for each left click button at ...
The DiagramEventInterface class isRunning() return true if action is running (do something). By default return false.
void mousePressEvent(QGraphicsSceneMouseEvent *event) override
DiagramEventAddElement::mousePressEvent Do nothing, but return true for not transit the event to othe...
void addElement()
DiagramEventAddElement::addElement Add an element at the current pos en current rotation, if project autoconductor option is enable, and the element can be wired, we do it.