2010-12-19 18:08:08 +00:00
|
|
|
/*
|
2011-03-02 00:16:40 +00:00
|
|
|
Copyright 2006-2011 Xavier Guerrin
|
2010-12-19 18:08:08 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2010-12-20 02:45:36 +00:00
|
|
|
#ifndef TITLEBLOCK_TEMPLATE_H
|
|
|
|
#define TITLEBLOCK_TEMPLATE_H
|
2010-12-19 18:08:08 +00:00
|
|
|
#include <QtXml>
|
|
|
|
#include <QtSvg>
|
|
|
|
#include "diagramcontext.h"
|
2010-12-20 02:45:36 +00:00
|
|
|
#include "titleblockcell.h"
|
2010-12-19 18:08:08 +00:00
|
|
|
#include "qet.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
This struct is a simple container associating a length with its type.
|
2010-12-20 02:45:36 +00:00
|
|
|
@see TitleBlockColumnLength
|
2010-12-19 18:08:08 +00:00
|
|
|
*/
|
2010-12-20 02:45:36 +00:00
|
|
|
struct TitleBlockColDimension {
|
|
|
|
TitleBlockColDimension(int v, QET::TitleBlockColumnLength t = QET::Absolute) {
|
2010-12-19 18:08:08 +00:00
|
|
|
value = v;
|
|
|
|
type = t;
|
|
|
|
}
|
2010-12-20 02:45:36 +00:00
|
|
|
QET::TitleBlockColumnLength type;
|
2010-12-19 18:08:08 +00:00
|
|
|
int value;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2010-12-20 02:45:36 +00:00
|
|
|
This class represents an titleblock templ)ate for an electric diagram.
|
2010-12-19 18:08:08 +00:00
|
|
|
It can read from an XML document the layout of the table that graphically
|
2010-12-20 02:45:36 +00:00
|
|
|
represents the titleblock, and can produce a graphical rendering of it from a
|
2010-12-19 18:08:08 +00:00
|
|
|
diagram context (object embedding the informations of the diagram we want to
|
2010-12-20 02:45:36 +00:00
|
|
|
represent the titleblock.
|
2010-12-19 18:08:08 +00:00
|
|
|
*/
|
2010-12-20 02:45:36 +00:00
|
|
|
class TitleBlockTemplate : public QObject {
|
2010-12-19 18:08:08 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2010-12-20 02:45:36 +00:00
|
|
|
TitleBlockTemplate(QObject * = 0);
|
|
|
|
virtual ~TitleBlockTemplate();
|
2010-12-19 18:08:08 +00:00
|
|
|
private:
|
2010-12-20 02:45:36 +00:00
|
|
|
TitleBlockTemplate(const TitleBlockTemplate &);
|
2010-12-19 18:08:08 +00:00
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
|
|
|
bool loadFromXmlFile(const QString &);
|
|
|
|
bool loadFromXmlElement(const QDomElement &);
|
2010-12-24 23:35:40 +00:00
|
|
|
QString name() const;
|
2010-12-19 18:08:08 +00:00
|
|
|
QList<int> columnsWidth(int) const;
|
|
|
|
int height() const;
|
|
|
|
|
|
|
|
void render(QPainter &, const DiagramContext &, int) const;
|
|
|
|
QString toString() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool loadLogos(const QDomElement &, bool = false);
|
|
|
|
bool loadLogo(const QDomElement &);
|
|
|
|
bool loadGrid(const QDomElement &);
|
|
|
|
bool loadCells(const QDomElement &);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void parseRows(const QString &);
|
|
|
|
void parseColumns(const QString &);
|
2010-12-20 02:45:36 +00:00
|
|
|
bool checkCell(const QDomElement &, TitleBlockCell ** = 0);
|
2010-12-19 18:08:08 +00:00
|
|
|
void flushCells();
|
|
|
|
void initCells();
|
|
|
|
int lengthRange(int, int, const QList<int> &) const;
|
2010-12-20 02:45:36 +00:00
|
|
|
QString finalTextForCell(const TitleBlockCell &, const DiagramContext &) const;
|
2011-02-08 06:53:47 +00:00
|
|
|
void renderTextCell(QPainter &, const QString &, const TitleBlockCell &, const QRectF &) const;
|
2010-12-19 18:08:08 +00:00
|
|
|
|
|
|
|
// attributs
|
|
|
|
private:
|
|
|
|
QDomDocument xml_description_;
|
2010-12-24 23:35:40 +00:00
|
|
|
QString name_;
|
2010-12-19 18:08:08 +00:00
|
|
|
QHash<QString, QSvgRenderer *> vector_logos_;
|
|
|
|
QHash<QString, QPixmap *> bitmap_logos_;
|
|
|
|
QList<int> rows_heights_;
|
2010-12-20 02:45:36 +00:00
|
|
|
QList<TitleBlockColDimension> columns_width_;
|
|
|
|
QVector< QVector<TitleBlockCell> > cells_;
|
2010-12-19 18:08:08 +00:00
|
|
|
};
|
|
|
|
#endif
|