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: 6984 $: 22 $Author: irascibl@gmail.com $: 23 $Date: 2013-04-22 23:44:56 +0200 (Mo, 22. Apr 2013) $ 24 25 ********************************************************************/ 26 27 #ifndef STRIPBOARD_H 28 #define STRIPBOARD_H 29 30 #include <QRectF> 31 #include <QPainterPath> 32 #include <QGraphicsPathItem> 33 34 #include "perfboard.h" 35 36 class ConnectorItem; 37 38 class Stripbit : public QGraphicsPathItem 39 { 40 public: 41 Stripbit(const QPainterPath & path, int x, int y, bool horizontal, QGraphicsItem * parent); 42 ~Stripbit(); 43 44 bool horizontal(); 45 void setRemoved(bool); 46 bool removed(); 47 void setChanged(bool); 48 bool changed(); 49 int y(); 50 int x(); 51 QString makeRemovedString(); 52 53 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); 54 void mousePressEvent(QGraphicsSceneMouseEvent *event); 55 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); 56 void mouseMoveEvent(QGraphicsSceneMouseEvent *event); 57 void hoverEnterEvent( QGraphicsSceneHoverEvent * event ); 58 void hoverLeaveEvent( QGraphicsSceneHoverEvent * event ); 59 60 protected: 61 bool m_removed; 62 bool m_inHover; 63 int m_x; 64 int m_y; 65 bool m_changed; 66 bool m_horizontal; 67 }; 68 69 struct StripConnector { 70 ConnectorItem * connectorItem; 71 Stripbit * down; 72 Stripbit * right; 73 74 StripConnector(); 75 }; 76 77 class Stripboard : public Perfboard 78 { 79 Q_OBJECT 80 81 public: 82 // after calling this constructor if you want to render the loaded svg (either from model or from file), MUST call <renderImage> 83 Stripboard(ModelPart *, ViewLayer::ViewID, const ViewGeometry & viewGeometry, long id, QMenu * itemMenu, bool doLabel); 84 ~Stripboard(); 85 86 QString retrieveSvg(ViewLayer::ViewLayerID, QHash<QString, QString> & svgHash, bool blackOnly, double dpi, double & factor); 87 bool collectExtraInfo(QWidget * parent, const QString & family, const QString & prop, const QString & value, bool swappingEnabled, QString & returnProp, QString & returnValue, QWidget * & returnWidget, bool & hide); 88 void addedToScene(bool temporary); 89 void setProp(const QString & prop, const QString & value); 90 void reinitBuses(bool triggerUndo); 91 void initCutting(Stripbit *); 92 void getConnectedColor(ConnectorItem *, QBrush &, QPen &, double & opacity, double & negativePenWidth, bool & negativeOffsetRect); 93 void restoreRowColors(Stripbit * stripbit); 94 void swapEntry(const QString & text); 95 QStringList collectValues(const QString & family, const QString & prop, QString & value); 96 97 protected: 98 void nextBus(QList<ConnectorItem *> & soFar); 99 QString getRowLabel(); 100 QString getColumnLabel(); 101 void makeInitialPath(); 102 void collectConnected(int x, int y, QList<ConnectorItem *> & connected); 103 StripConnector * getStripConnector(int x, int y); 104 void collectTo(QSet<ConnectorItem *> &); 105 void initStripLayouts(); 106 107 public: 108 static QString genFZP(const QString & moduleID); 109 static QString genModuleID(QMap<QString, QString> & currPropsMap); 110 111 protected: 112 QList<StripConnector *> m_strips; 113 QList<class BusShared *> m_buses; 114 QString m_beforeCut; 115 int m_x; 116 int m_y; 117 QString m_layout; 118 }; 119 120 #endif 121