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 DRC_H 28 #define DRC_H 29 30 #include <QList> 31 #include <QObject> 32 #include <QImage> 33 #include <QDomDocument> 34 #include <QGraphicsPixmapItem> 35 #include <QDialog> 36 #include <QDoubleSpinBox> 37 #include <QRadioButton> 38 #include <QListWidgetItem> 39 #include <QPointer> 40 41 #include "../svg/svgfilesplitter.h" 42 #include "../viewlayer.h" 43 44 struct CollidingThing { 45 QPointer<class NonConnectorItem> nonConnectorItem; 46 QList<QPointF> atPixels; 47 }; 48 49 struct Markers { 50 QString inSvgID; 51 QString inSvgAndID; 52 QString inTerminalID; 53 QString inNoID; 54 QString outID; 55 }; 56 57 class DRC : public QObject 58 { 59 Q_OBJECT 60 61 public: 62 DRC(class PCBSketchWidget *, class ItemBase * board); 63 virtual ~DRC(void); 64 65 QStringList start(bool showOkMessage, double keepoutMils); 66 67 public: 68 static void splitNetPrep(QDomDocument * masterDoc, QList<class ConnectorItem *> & equi, const Markers &, QList<QDomElement> & net, QList<QDomElement> & alsoNet, QList<QDomElement> & notNet, bool checkIntersection); 69 static void extendBorder(double keepoutImagePixels, QImage * image); 70 71 public slots: 72 void cancel(); 73 74 signals: 75 void hideProgress(); 76 void setMaximumProgress(int); 77 void setProgressValue(int); 78 void wantTopVisible(); 79 void wantBottomVisible(); 80 void wantBothVisible(); 81 void setProgressMessage(const QString &); 82 83 public: 84 static const QString NotNet; 85 static const QString AlsoNet; 86 static const QString Net; 87 static const uchar BitTable[]; 88 static const QString KeepoutSettingName; 89 static const double KeepoutDefaultMils; 90 91 protected: 92 bool makeBoard(QImage *, QRectF & sourceRes); 93 void splitNet(QDomDocument *, QList<ConnectorItem *> & , QImage * minusImage, QImage * plusImage, QRectF & sourceRes, ViewLayer::ViewLayerPlacement viewLayerPlacement, int index, double keepoutMils); 94 void updateDisplay(); 95 bool startAux(QString & message, QStringList & messages, QList<CollidingThing *> &, double keepoutMils); 96 CollidingThing * findItemsAt(QList<QPointF> &, ItemBase * board, const LayerList & viewLayerIDs, double keepout, double dpi, bool skipHoles, ConnectorItem * already); 97 void checkHoles(QStringList & messages, QList<CollidingThing *> & collidingThings, double dpi); 98 void checkCopperBoth(QStringList & messages, QList<CollidingThing *> & collidingThings, double dpi); 99 QList<ConnectorItem *> missingCopper(const QString & layerName, ViewLayer::ViewLayerID, ItemBase *, const QDomElement & svgRoot); 100 101 protected: 102 static void markSubs(QDomElement & root, const QString & mark); 103 static void splitSubs(QDomDocument *, QDomElement & root, const QString & partID, const Markers &, const QStringList & svgIDs, const QStringList & terminalIDs, const QList<ItemBase *> &, QHash<QString, QString> & both, bool checkIntersection); 104 105 protected: 106 class PCBSketchWidget * m_sketchWidget; 107 class ItemBase * m_board; 108 double m_keepout; 109 QImage * m_plusImage; 110 QImage * m_minusImage; 111 QImage * m_displayImage; 112 QGraphicsPixmapItem * m_displayItem; 113 QHash<ViewLayer::ViewLayerPlacement, QDomDocument *> m_masterDocs; 114 bool m_cancelled; 115 int m_maxProgress; 116 }; 117 118 class DRCResultsDialog : public QDialog 119 { 120 Q_OBJECT 121 122 public: 123 DRCResultsDialog(const QString & message, const QStringList & messages, const QList<CollidingThing *> &, QGraphicsPixmapItem * displayItem, QImage * displayImage, class PCBSketchWidget * sketchWidget, QWidget *parent = 0); 124 ~DRCResultsDialog(); 125 126 protected slots: 127 void pressedSlot(QListWidgetItem *); 128 void releasedSlot(QListWidgetItem *); 129 130 protected: 131 QStringList m_messages; 132 QList<CollidingThing *> m_collidingThings; 133 QPointer <class PCBSketchWidget> m_sketchWidget; 134 QGraphicsPixmapItem * m_displayItem; 135 QImage * m_displayImage; 136 }; 137 138 #endif 139