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 PART_TERMINAL_H 19 #define PART_TERMINAL_H 20 21 #include "customelementgraphicpart.h" 22 23 24 25 /** 26 This class represents a terminal which may be used to compose the drawing of 27 an electrical element within the element editor. 28 */ 29 class PartTerminal : public CustomElementGraphicPart 30 { 31 Q_OBJECT 32 33 Q_PROPERTY(Qet::Orientation orientation READ orientation WRITE setOrientation) 34 35 36 public: 37 // constructors, destructor 38 PartTerminal(QETElementEditor *editor, QGraphicsItem *parent = nullptr); 39 ~PartTerminal() override; 40 private: 41 PartTerminal(const PartTerminal &); 42 43 signals: 44 void orientationChanged(); 45 46 // attributes 47 private: 48 Qet::Orientation m_orientation; 49 QPointF second_point; 50 51 52 // methods 53 public: 54 enum { Type = UserType + 1106 }; 55 /** 56 * Enable the use of qgraphicsitem_cast to safely cast a QGraphicsItem into a PartTerminal. 57 * @return the QGraphicsItem type 58 */ type()59 int type() const override { return Type; } name()60 QString name() const override { return(QObject::tr("borne", "element part name")); } xmlName()61 QString xmlName() const override { return(QString("terminal")); } 62 void fromXml(const QDomElement &) override; 63 const QDomElement toXml(QDomDocument &) const override; 64 void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) override; 65 66 QPainterPath shape() const override; shadowShape()67 QPainterPath shadowShape() const override {return shape();} 68 QRectF boundingRect() const override; 69 bool isUseless() const override; 70 QRectF sceneGeometricRect() const override; 71 void startUserTransformation(const QRectF &) override; 72 void handleUserTransformation(const QRectF &, const QRectF &) override; 73 orientation()74 Qet::Orientation orientation() const {return m_orientation;} 75 void setOrientation(Qet::Orientation ori); 76 77 private: 78 void updateSecondPoint(); 79 80 private: 81 QPointF saved_position_; 82 }; 83 #endif 84