1
/*******************************************************************
3
Part of the Fritzing project - http://fritzing.org
4
Copyright (c) 2007-2010 Fachhochschule Potsdam - http://fh-potsdam.de
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.
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.
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/>.
19
********************************************************************
22
$Author: cohen@irascible.com $:
23
$Date: 2010-06-04 19:50:59 +0200 (Fri, 04 Jun 2010) $
25
********************************************************************/
27
#ifndef FSVGRENDERER_H
28
#define FSVGRENDERER_H
31
#include <QSvgRenderer>
32
#include <QXmlStreamReader>
33
#include <QDomDocument>
35
#include <QStringList>
37
#include "viewlayer.h"
39
struct ConnectorInfo {
44
QMatrix terminalMatrix;
48
typedef QHash<ViewLayer::ViewLayerID, class FSvgRenderer *> RendererHash;
50
class FSvgRenderer : public QSvgRenderer
53
FSvgRenderer(QObject * parent = 0);
56
bool loadSvg(const QString & filename, const QStringList & connectorIDs, const QStringList & terminalIDs, const QString & setColor, const QString & colorElementID, bool findNonConnectors);
57
bool loadSvg(const QString & filename);
58
bool loadSvg( const QByteArray & contents, const QString & filename, const QStringList & connectorNames, const QStringList & terminalNames, const QString & setColor, const QString & colorElementID, bool findNonConnectors); // for SvgSplitter loads
59
bool loadSvg( const QByteArray & contents, const QString & filename); // for SvgSplitter loads
60
bool fastLoad(const QByteArray & contents);
61
const QString & filename();
62
QSizeF defaultSizeF();
63
bool setUpConnector(struct SvgIdLayer * svgIdLayer, bool ignoreTerminalPoint);
64
QList<SvgIdLayer *> setUpNonConnectors();
67
static void set(const QString & moduleID, ViewLayer::ViewLayerID, FSvgRenderer *);
68
static FSvgRenderer * getByModuleID(const QString & moduleID, ViewLayer::ViewLayerID);
69
static FSvgRenderer * getByFilename(const QString & filename, ViewLayer::ViewLayerID);
70
static QPixmap * getPixmap(const QString & moduleID, ViewLayer::ViewLayerID viewLayerID, QSize size);
71
static void calcPrinterScale();
72
static qreal printerScale();
73
static void cleanup();
74
static QSizeF parseForWidthAndHeight(QXmlStreamReader &);
75
static void removeFromHash(const QString &moduleId, const QString filename);
78
void determineDefaultSize(QXmlStreamReader &);
79
bool loadAux (const QByteArray & contents, const QString & filename, const QStringList & connectorNames, const QStringList & terminalNames, const QString & setColor, const QString & colorElementID, bool findNonConnectors);
80
void initConnectorInfo(QDomDocument &, const QStringList & connectorIDs, const QStringList & terminalIDs);
81
ConnectorInfo * initConnectorInfo(QDomElement & connectorElement);
82
bool initConnectorInfoAux(QList<QDomElement> & connectorElements, ConnectorInfo * connectorInfo);
83
void initNonConnectorInfo(QDomDocument & domDocument);
84
void initNonConnectorInfoAux(QDomElement & element);
85
void initTerminalInfoAux(QDomElement & element, const QStringList & connectorIDs, const QStringList & terminalIDs);
86
void initConnectorInfoAux(QDomElement & element, const QStringList & connectorIDs);
87
QPointF calcTerminalPoint(const QString & terminalId, const QRectF & connectorRect, bool ignoreTerminalPoint, const QRectF & viewBox, QMatrix & terminalMatrix, bool useF);
88
ConnectorInfo * getConnectorInfo(const QString & connectorID);
89
void clearConnectorInfoHash(QHash<QString, ConnectorInfo *> & hash);
93
QSizeF m_defaultSizeF;
94
QHash<QString, ConnectorInfo *> m_connectorInfoHash;
95
QHash<QString, ConnectorInfo *> m_nonConnectorInfoHash;
98
static qreal m_printerScale;
99
static QHash<QString, RendererHash * > m_filenameRendererHash;
100
static QHash<QString, RendererHash * > m_moduleIDRendererHash;
101
static QSet<RendererHash *> m_deleted;
104
static QString NonConnectorName;
1
/*******************************************************************
3
Part of the Fritzing project - http://fritzing.org
4
Copyright (c) 2007-2011 Fachhochschule Potsdam - http://fh-potsdam.de
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.
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.
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/>.
19
********************************************************************
22
$Author: cohen@irascible.com $:
23
$Date: 2011-07-30 21:17:22 +0200 (Sat, 30 Jul 2011) $
25
********************************************************************/
27
#ifndef FSVGRENDERER_H
28
#define FSVGRENDERER_H
31
#include <QSvgRenderer>
32
#include <QXmlStreamReader>
33
#include <QDomDocument>
35
#include <QStringList>
37
#include "viewlayer.h"
39
struct ConnectorInfo {
45
QMatrix terminalMatrix;
49
double legStrokeWidth;
52
typedef QHash<ViewLayer::ViewLayerID, class FSvgRenderer *> RendererHash;
54
class FSvgRenderer : public QSvgRenderer
57
FSvgRenderer(QObject * parent = 0);
60
QByteArray loadSvg(const QString & filename, const QStringList & connectorIDs, const QStringList & terminalIDs, const QStringList & legIDs, const QString & setColor, const QString & colorElementID, bool findNonConnectors);
61
QByteArray loadSvg(const QString & filename);
62
QByteArray loadSvg( const QByteArray & contents, const QString & filename, const QStringList & connectorIDs, const QStringList & terminalIDs, const QStringList & legIDs, const QString & setColor, const QString & colorElementID, bool findNonConnectors); // for SvgSplitter loads
63
QByteArray loadSvg( const QByteArray & contents, const QString & filename); // for SvgSplitter loads
64
bool fastLoad(const QByteArray & contents);
65
const QString & filename();
66
QSizeF defaultSizeF();
67
bool setUpConnector(struct SvgIdLayer * svgIdLayer, bool ignoreTerminalPoint);
68
QList<SvgIdLayer *> setUpNonConnectors();
71
static void set(const QString & moduleID, ViewLayer::ViewLayerID, FSvgRenderer *);
72
static FSvgRenderer * getByModuleID(const QString & moduleID, ViewLayer::ViewLayerID);
73
static FSvgRenderer * getByFilename(const QString & filename, ViewLayer::ViewLayerID);
74
static QPixmap * getPixmap(const QString & moduleID, ViewLayer::ViewLayerID viewLayerID, QSize size);
75
static void calcPrinterScale();
76
static double printerScale();
77
static void cleanup();
78
static QSizeF parseForWidthAndHeight(QXmlStreamReader &);
79
static void removeFromHash(const QString &moduleId, const QString filename);
82
void determineDefaultSize(QXmlStreamReader &);
83
QByteArray loadAux (const QByteArray & contents, const QString & filename, const QStringList & connectorIDs, const QStringList & terminalIDs, const QStringList & legIDs, const QString & setColor, const QString & colorElementID, bool findNonConnectors);
84
bool initConnectorInfo(QDomDocument &, const QStringList & connectorIDs, const QStringList & terminalIDs, const QStringList & legIDs);
85
ConnectorInfo * initConnectorInfo(QDomElement & connectorElement);
86
bool initConnectorInfoAux(QList<QDomElement> & connectorElements, ConnectorInfo * connectorInfo);
87
void initNonConnectorInfo(QDomDocument & domDocument);
88
void initNonConnectorInfoAux(QDomElement & element);
89
void initTerminalInfoAux(QDomElement & element, const QStringList & connectorIDs, const QStringList & terminalIDs);
90
void initLegInfoAux(QDomElement & element, const QStringList & connectorIDs, const QStringList & legIDs, bool & gotOne);
91
void initConnectorInfoAux(QDomElement & element, const QStringList & connectorIDs);
92
QPointF calcTerminalPoint(const QString & terminalId, const QRectF & connectorRect, bool ignoreTerminalPoint, const QRectF & viewBox, QMatrix & terminalMatrix);
93
bool initLegInfoAux(QDomElement & element, ConnectorInfo * connectorInfo);
94
void calcLeg(SvgIdLayer *, const QRectF & viewBox, ConnectorInfo * connectorInfo);
95
ConnectorInfo * getConnectorInfo(const QString & connectorID);
96
void clearConnectorInfoHash(QHash<QString, ConnectorInfo *> & hash);
100
QSizeF m_defaultSizeF;
101
QHash<QString, ConnectorInfo *> m_connectorInfoHash;
102
QHash<QString, ConnectorInfo *> m_nonConnectorInfoHash;
105
static double m_printerScale;
106
static QHash<QString, RendererHash * > m_filenameRendererHash;
107
static QHash<QString, RendererHash * > m_moduleIDRendererHash;
108
static QSet<RendererHash *> m_deleted;
111
static QString NonConnectorName;