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: 6715 $: 22 $Author: irascibl@gmail.com $: 23 $Date: 2012-12-17 11:27:32 +0100 (Mo, 17. Dez 2012) $ 24 25 ********************************************************************/ 26 27 #ifndef INFOGRAPHICSVIEW_H 28 #define INFOGRAPHICSVIEW_H 29 30 #include <QGraphicsView> 31 #include <QMenu> 32 #include <QHash> 33 #include <QList> 34 35 #include "../items/itembase.h" 36 #include "zoomablegraphicsview.h" 37 38 class InfoGraphicsView : public ZoomableGraphicsView 39 { 40 Q_OBJECT 41 42 public: 43 InfoGraphicsView(QWidget* parent = 0); 44 45 virtual void viewItemInfo(ItemBase *); 46 virtual void hoverEnterItem(QGraphicsSceneHoverEvent * event, ItemBase *); 47 virtual void hoverLeaveItem(QGraphicsSceneHoverEvent * event, ItemBase *); 48 void updateRotation(ItemBase *); 49 50 virtual bool swappingEnabled(ItemBase *) = 0; 51 52 virtual void hoverEnterConnectorItem(QGraphicsSceneHoverEvent * event, ConnectorItem *); 53 virtual void hoverLeaveConnectorItem(QGraphicsSceneHoverEvent * event, ConnectorItem *); 54 55 void setInfoView(class HtmlInfoView *); 56 class HtmlInfoView * infoView(); 57 58 virtual void mousePressConnectorEvent(ConnectorItem *, QGraphicsSceneMouseEvent *); 59 60 61 virtual void hidePartLabel(ItemBase * item); 62 virtual void partLabelMoved(ItemBase *, QPointF oldPos, QPointF oldOffset, QPointF newPos, QPointF newOffset); 63 virtual void rotateFlipPartLabel(ItemBase *, double degrees, Qt::Orientations flipDirection); 64 virtual void noteSizeChanged(ItemBase * itemBase, const QSizeF & oldSize, const QSizeF & newSize); 65 66 virtual bool spaceBarIsPressed(); 67 virtual void initWire(class Wire *, int penWidth); 68 setIgnoreSelectionChangeEvents(bool)69 virtual void setIgnoreSelectionChangeEvents(bool) {} 70 virtual void getBendpointWidths(class Wire *, double w, double & w1, double & w2, bool & negativeOffsetRect); 71 virtual void getLabelFont(QFont &, QColor &, ItemBase *); 72 virtual double getLabelFontSizeTiny(); 73 virtual double getLabelFontSizeSmall(); 74 virtual double getLabelFontSizeMedium(); 75 virtual double getLabelFontSizeLarge(); 76 virtual bool hasBigDots(); 77 78 virtual LayerHash & viewLayers(); 79 virtual void loadLogoImage(ItemBase *, const QString & oldSvg, const QSizeF oldAspectRatio, const QString & oldFilename, const QString & newFilename, bool addName); 80 81 virtual void setNoteFocus(QGraphicsItem *, bool inFocus); 82 83 int boardLayers(); 84 virtual void setBoardLayers(int, bool redraw); 85 virtual class VirtualWire * makeOneRatsnestWire(ConnectorItem * source, ConnectorItem * dest, bool routed, QColor, bool force); 86 virtual void getRatsnestColor(QColor &); 87 88 virtual void changeBus(ItemBase *, bool connect, const QString & oldBus, const QString & newBus, QList<ConnectorItem *> &, const QString & message, const QString & oldLayout, const QString & newLayout); 89 virtual const QString & filenameIf(); 90 virtual QString generateCopperFillUnit(ItemBase * itemBase, QPointF whereToStart); 91 virtual void prepLegBendpointMove(ConnectorItem * from, int index, QPointF oldPos, QPointF newPos, ConnectorItem * to, bool changeConnections); 92 virtual void prepLegCurveChange(ConnectorItem * from, int index, const class Bezier * oldB, const class Bezier * newB, bool triggerFirstTime); 93 virtual void prepLegBendpointChange(ConnectorItem * from, int oldCount, int newCount, int index, QPointF pos, const class Bezier *, const class Bezier *, const class Bezier *, bool triggerFirstTime); 94 virtual void prepLegSelection(ItemBase *); 95 virtual double getWireStrokeWidth(Wire *, double wireWidth); 96 virtual bool curvyWiresIndicated(Qt::KeyboardModifiers); 97 virtual void triggerRotate(ItemBase *, double degrees); 98 virtual void changePinLabels(ItemBase *, bool singleRow); 99 virtual void renamePins(ItemBase *, const QStringList & oldLabels, const QStringList & newLabels, bool singleRow); 100 virtual ViewGeometry::WireFlag getTraceFlag(); 101 virtual void setAnyInRotation(); 102 103 virtual void partLabelChanged(ItemBase *, const QString &oldText, const QString & newText); 104 virtual void noteChanged(ItemBase *, const QString &oldText, const QString & newText, QSizeF oldSize, QSizeF newSize); 105 virtual void setResistance(QString resistance, QString pinSpacing); 106 virtual void setProp(ItemBase *, const QString & propName, const QString & translatedPropName, const QString & oldValue, const QString & newValue, bool redraw); 107 virtual void setHoleSize(ItemBase *, const QString & propName, const QString & translatedPropName, const QString & oldValue, const QString & newValue, QRectF & oldRect, QRectF & newRect, bool redraw); 108 virtual void changeWireWidthMils(const QString newWidth); 109 virtual void changeWireColor(const QString newColor); 110 virtual void swap(const QString & family, const QString & prop, QMap<QString, QString> & propsMap, ItemBase *); 111 virtual void resolveTemporary(bool, ItemBase *); 112 virtual void newWire(Wire *); 113 114 void setActiveWire(Wire *); 115 void setActiveConnectorItem(ConnectorItem *); 116 void setSMDOrientation(Qt::Orientations); 117 Qt::Orientations smdOrientation(); 118 virtual void moveItem(ItemBase *, double x, double y); 119 virtual void rotateX(double degrees, bool rubberBandLegEnabled, ItemBase * originatingItem); 120 121 public slots: 122 virtual void setVoltage(double, bool doEmit); 123 virtual void resizeBoard(double w, double h, bool doEmit); 124 virtual void setInstanceTitle(long id, const QString & oldTitle, const QString & newTitle, bool isUndoable, bool doEmit); 125 126 signals: 127 void setVoltageSignal(double, bool doEmit); 128 void swapSignal(const QString & family, const QString & prop, QMap<QString, QString> & propsMap, ItemBase *); 129 void changePinLabelsSignal(ItemBase *, bool singleRow); 130 void setActiveWireSignal(Wire *); 131 void setActiveConnectorItemSignal(ConnectorItem *); 132 void newWireSignal(Wire *); 133 134 public: 135 static InfoGraphicsView * getInfoGraphicsView(QGraphicsItem *); 136 137 protected: 138 QGraphicsItem *selectedAux(); 139 class HtmlInfoView *m_infoView; 140 int m_boardLayers; 141 bool m_hoverEnterMode; 142 bool m_hoverEnterConnectorMode; 143 Qt::Orientations m_smdOrientation; 144 }; 145 146 #endif 147