1 /*******************************************************************
2 
3 Part of the Fritzing project - http://fritzing.org
4 Copyright (c) 2007-2014 Fachhochschule Potsdam - http://fh-potsdam.de
5 
6 Fritzing 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 Fritzing 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 Fritzing.  If not, see <http://www.gnu.org/licenses/>.
18 
19 ********************************************************************
20 
21 $Revision: 6912 $:
22 $Author: irascibl@gmail.com $:
23 $Date: 2013-03-09 08:18:59 +0100 (Sa, 09. Mrz 2013) $
24 
25 ********************************************************************/
26 
27 #ifndef CLIPABLEWIRE_H
28 #define CLIPABLEWIRE_H
29 
30 #include "wire.h"
31 
32 #include <QPointer>
33 
34 class ClipableWire : public Wire
35 {
36 
37 public:
38 	ClipableWire( ModelPart * modelPart, ViewLayer::ViewID,  const ViewGeometry & , long id, QMenu* itemMenu, bool initLabel);
39 
40 	void setClipEnds(bool);
41 	const QLineF & getPaintLine();
42 	bool filterMousePressConnectorEvent(ConnectorItem *, QGraphicsSceneMouseEvent *);
43 	void mousePressEvent(QGraphicsSceneMouseEvent *event);
44 	void hoverEnterConnectorItem(QGraphicsSceneHoverEvent * event, class ConnectorItem * item);
45 	void hoverLeaveConnectorItem(QGraphicsSceneHoverEvent * event, class ConnectorItem * item);
46 	void hoverMoveConnectorItem(QGraphicsSceneHoverEvent * event, class ConnectorItem * item);
47 
48 protected:
49 	bool insideInnerCircle(ConnectorItem * connectorItem, QPointF localPos);
50 	bool insideSpoke(ClipableWire * wire, QPointF scenePos);
51 	void dispatchHover(QPointF scenePos);
52 	void dispatchHoverAux(bool inInner, Wire * inWire);
53 	QPointF findIntersection(ConnectorItem * connectorItem, const QPointF & p);
54 	void calcClip(QPointF & p1, QPointF & p2, ConnectorItem * c1, ConnectorItem * c2);
55 
56 protected:
57 	bool m_clipEnds;
58 	QLineF m_cachedLine;
59 	QLineF m_cachedOriginalLine;
60 	QGraphicsSceneMouseEvent * m_justFilteredEvent;
61 	QPointer<ConnectorItem> m_trackHoverItem;
62 	QPointer<ConnectorItem> m_trackHoverLastItem;
63 	QPointer<Wire> m_trackHoverLastWireItem;
64 };
65 
66 #endif
67