2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2012-01-01 22:51:51 +00:00
|
|
|
Copyright 2006-2012 Xavier Guerrin
|
2007-12-01 10:47:15 +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 BORDERTITLEBLOCK_H
|
|
|
|
#define BORDERTITLEBLOCK_H
|
2011-01-09 15:16:51 +00:00
|
|
|
#include "diagramcontext.h"
|
2010-12-20 02:45:36 +00:00
|
|
|
#include "titleblockproperties.h"
|
2008-08-14 22:51:08 +00:00
|
|
|
#include "borderproperties.h"
|
2007-04-12 03:13:13 +00:00
|
|
|
#include <QObject>
|
|
|
|
#include <QRectF>
|
|
|
|
#include <QDate>
|
2008-07-30 12:44:57 +00:00
|
|
|
class QPainter;
|
2009-05-20 21:29:17 +00:00
|
|
|
class DiagramPosition;
|
2010-12-20 02:45:36 +00:00
|
|
|
class TitleBlockTemplate;
|
|
|
|
class TitleBlockTemplateRenderer;
|
2007-04-12 03:13:13 +00:00
|
|
|
/**
|
|
|
|
Cette classe represente l'ensemble bordure + cartouche qui encadre le
|
|
|
|
schema electrique.
|
|
|
|
*/
|
2010-12-20 02:45:36 +00:00
|
|
|
class BorderTitleBlock : public QObject {
|
2007-04-12 03:13:13 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
2010-12-20 02:45:36 +00:00
|
|
|
BorderTitleBlock(QObject * = 0);
|
|
|
|
virtual ~BorderTitleBlock();
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
private:
|
2010-12-20 02:45:36 +00:00
|
|
|
BorderTitleBlock(const BorderTitleBlock &);
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
// methodes
|
|
|
|
public:
|
2008-08-10 15:07:59 +00:00
|
|
|
static int minNbColumns();
|
|
|
|
static qreal minColumnsWidth();
|
|
|
|
static int minNbRows();
|
|
|
|
static qreal minRowsHeight();
|
|
|
|
|
2007-04-12 03:13:13 +00:00
|
|
|
void draw(QPainter *, qreal = 0.0, qreal = 0.0);
|
|
|
|
|
|
|
|
// methodes d'acces en lecture aux dimensions
|
2008-08-10 15:07:59 +00:00
|
|
|
// colonnes
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @return le nombre de colonnes du schema
|
2008-08-10 15:07:59 +00:00
|
|
|
int nbColumns() const { return(nb_columns); }
|
|
|
|
/// @return la largeur des colonnes en pixels
|
|
|
|
qreal columnsWidth() const { return(columns_width); }
|
|
|
|
/// @return la taille de l'ensemble des colonnes, en-tete des lignes non inclus
|
|
|
|
qreal columnsTotalWidth() const { return(nb_columns * columns_width); }
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @return la hauteur, en pixels, des en-tetes des colonnes
|
2008-08-10 15:07:59 +00:00
|
|
|
qreal columnsHeaderHeight() const { return(columns_header_height); }
|
|
|
|
|
|
|
|
// lignes
|
|
|
|
/// @return le nombre de lignes du schema
|
|
|
|
int nbRows() const { return(nb_rows); }
|
|
|
|
/// @return la hauteur des lignes en pixels
|
|
|
|
qreal rowsHeight() const { return(rows_height); }
|
|
|
|
/// @return la taille de l'ensemble des lignes, en-tete des colonnes non inclus
|
|
|
|
qreal rowsTotalHeight() const { return(nb_rows * rows_height); }
|
|
|
|
/// @return la largeur, en pixels, des en-tetes des lignes
|
|
|
|
qreal rowsHeaderWidth() const { return(rows_header_width); }
|
|
|
|
|
|
|
|
// cadre sans le cartouche = schema
|
|
|
|
/// @return la largeur du schema, c'est-a-dire du cadre sans le cartouche
|
|
|
|
qreal diagramWidth() const { return(columnsTotalWidth() + rowsHeaderWidth()); }
|
|
|
|
/// @return la hauteurdu schema, c'est-a-dire du cadre sans le cartouche
|
|
|
|
qreal diagramHeight() const { return(rowsTotalHeight() + columnsHeaderHeight()); }
|
|
|
|
|
|
|
|
// cartouche
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @return la largeur du cartouche
|
2010-12-20 02:45:36 +00:00
|
|
|
qreal titleBlockWidth() const { return(titleblock_width); }
|
|
|
|
qreal titleBlockHeight() const;
|
2008-08-10 15:07:59 +00:00
|
|
|
|
|
|
|
// cadre avec le cartouche
|
|
|
|
/// @return la hauteur de la bordure
|
|
|
|
qreal borderWidth() const { return(diagramWidth()); }
|
|
|
|
/// @return la hauteur de la bordure
|
2010-12-20 02:45:36 +00:00
|
|
|
qreal borderHeight() const { return(diagramHeight() + titleBlockHeight()); }
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
// methodes d'acces en lecture aux informations du cartouche
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @return le champ "Auteur" du cartouche
|
2007-04-12 03:13:13 +00:00
|
|
|
QString author() const { return(bi_author); }
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @return le champ "Date" du cartouche
|
2007-04-12 03:13:13 +00:00
|
|
|
QDate date() const { return(bi_date); }
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @return le champ "Titre" du cartouche
|
2007-04-12 03:13:13 +00:00
|
|
|
QString title() const { return(bi_title); }
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @return le champ "Folio" du cartouche
|
2007-04-12 03:13:13 +00:00
|
|
|
QString folio() const { return(bi_folio); }
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @return le champ "Fichier" du cartouche
|
2007-04-12 03:13:13 +00:00
|
|
|
QString fileName() const { return(bi_filename); }
|
|
|
|
|
|
|
|
// methodes d'acces en lecture aux options
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @return true si le cartouche est affiche, false sinon
|
2010-12-20 02:45:36 +00:00
|
|
|
bool titleBlockIsDisplayed() const { return(display_titleblock); }
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @return true si les entetes des colonnes sont affiches, false sinon
|
2007-04-12 03:13:13 +00:00
|
|
|
bool columnsAreDisplayed() const { return(display_columns); }
|
2008-08-10 15:07:59 +00:00
|
|
|
/// @return true si les entetes des lignes sont affiches, false sinon
|
|
|
|
bool rowsAreDisplayed() const { return(display_rows); }
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @return true si la bordure est affichee, false sinon
|
2007-04-12 03:13:13 +00:00
|
|
|
bool borderIsDisplayed() const { return(display_border); }
|
|
|
|
|
|
|
|
// methodes d'acces en ecriture aux dimensions
|
|
|
|
void addColumn ();
|
2008-08-10 15:07:59 +00:00
|
|
|
void addRow ();
|
2007-04-12 03:13:13 +00:00
|
|
|
void removeColumn ();
|
2008-08-10 15:07:59 +00:00
|
|
|
void removeRow ();
|
2007-04-12 03:13:13 +00:00
|
|
|
void setNbColumns (int);
|
2008-08-10 15:07:59 +00:00
|
|
|
void setNbRows (int);
|
2007-04-12 03:13:13 +00:00
|
|
|
void setColumnsWidth (const qreal &);
|
2008-08-10 15:07:59 +00:00
|
|
|
void setRowsHeight (const qreal &);
|
2007-04-12 03:13:13 +00:00
|
|
|
void setColumnsHeaderHeight(const qreal &);
|
2008-08-10 15:07:59 +00:00
|
|
|
void setRowsHeaderWidth (const qreal &);
|
|
|
|
void setDiagramHeight (const qreal &);
|
2010-12-20 02:45:36 +00:00
|
|
|
void setTitleBlockWidth (const qreal &);
|
|
|
|
void adjustTitleBlockToColumns ();
|
2007-04-12 03:13:13 +00:00
|
|
|
|
2009-05-20 21:29:17 +00:00
|
|
|
DiagramPosition convertPosition(const QPointF &);
|
|
|
|
|
2007-04-12 03:13:13 +00:00
|
|
|
// methodes d'acces en ecriture aux informations du cartouche
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @param author le nouveau contenu du champ "Auteur"
|
2007-04-12 03:13:13 +00:00
|
|
|
void setAuthor (const QString &author) { bi_author = author; }
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @param date le nouveau contenu du champ "Date"
|
2007-04-12 03:13:13 +00:00
|
|
|
void setDate (const QDate &date) { bi_date = date; }
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @param title le nouveau contenu du champ "Titre"
|
2009-04-03 19:30:25 +00:00
|
|
|
void setTitle (const QString &title) {
|
|
|
|
if (bi_title != title) {
|
|
|
|
bi_title = title;
|
|
|
|
emit(diagramTitleChanged(title));
|
|
|
|
}
|
|
|
|
}
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @param folio le nouveau contenu du champ "Folio"
|
2007-04-12 03:13:13 +00:00
|
|
|
void setFolio (const QString &folio) { bi_folio = folio; }
|
2012-07-01 21:54:07 +00:00
|
|
|
void setFolioData(int, int, const DiagramContext & = DiagramContext());
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @param filename le nouveau contenu du champ "Fichier"
|
2007-04-12 03:13:13 +00:00
|
|
|
void setFileName (const QString &filename) { bi_filename = filename; }
|
2007-12-05 21:16:01 +00:00
|
|
|
|
2011-01-09 00:01:38 +00:00
|
|
|
void titleBlockToXml(QDomElement &);
|
|
|
|
void titleBlockFromXml(const QDomElement &);
|
|
|
|
void borderToXml(QDomElement &);
|
|
|
|
void borderFromXml(const QDomElement &);
|
|
|
|
|
2010-12-20 02:45:36 +00:00
|
|
|
TitleBlockProperties exportTitleBlock();
|
|
|
|
void importTitleBlock(const TitleBlockProperties &);
|
2008-08-14 22:51:08 +00:00
|
|
|
BorderProperties exportBorder();
|
|
|
|
void importBorder(const BorderProperties &);
|
2007-04-12 03:13:13 +00:00
|
|
|
|
2010-12-20 02:45:36 +00:00
|
|
|
const TitleBlockTemplate *titleBlockTemplate();
|
|
|
|
void setTitleBlockTemplate(const TitleBlockTemplate *);
|
2010-12-24 23:35:40 +00:00
|
|
|
QString titleBlockTemplateName() const;
|
2010-12-19 18:12:56 +00:00
|
|
|
|
2010-12-24 21:00:11 +00:00
|
|
|
public slots:
|
|
|
|
void titleBlockTemplateChanged(const QString &);
|
|
|
|
void titleBlockTemplateRemoved(const QString &, const TitleBlockTemplate * = 0);
|
|
|
|
|
2007-04-12 03:13:13 +00:00
|
|
|
// methodes d'acces en ecriture aux options
|
2010-12-20 02:45:36 +00:00
|
|
|
void displayTitleBlock(bool);
|
2008-08-15 12:46:22 +00:00
|
|
|
void displayColumns(bool);
|
|
|
|
void displayRows(bool);
|
|
|
|
void displayBorder(bool);
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void updateRectangles();
|
2012-07-01 21:54:07 +00:00
|
|
|
void updateDiagramContextForTitleBlock(const DiagramContext & = DiagramContext());
|
2008-08-10 15:07:59 +00:00
|
|
|
QString incrementLetters(const QString &);
|
2007-04-12 03:13:13 +00:00
|
|
|
|
2007-09-28 21:02:53 +00:00
|
|
|
// signaux
|
|
|
|
signals:
|
|
|
|
/**
|
|
|
|
Signal emis lorsque la bordure change
|
|
|
|
@param old_border Ancienne bordure
|
|
|
|
@param new_border Nouvelle bordure
|
|
|
|
*/
|
|
|
|
void borderChanged(QRectF old_border, QRectF new_border);
|
2008-08-15 12:46:22 +00:00
|
|
|
/**
|
|
|
|
Signal emise lorsque des options d'affichage change
|
|
|
|
*/
|
|
|
|
void displayChanged();
|
2007-09-28 21:02:53 +00:00
|
|
|
|
2009-04-03 19:30:25 +00:00
|
|
|
/**
|
|
|
|
Signal emis lorsque le titre du schema change
|
|
|
|
*/
|
|
|
|
void diagramTitleChanged(const QString &);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Signal emis lorsque le cartouche requiert une mise a jour des donnees
|
|
|
|
utilisees pour generer le folio.
|
|
|
|
*/
|
|
|
|
void needFolioData();
|
|
|
|
|
2010-12-24 23:35:40 +00:00
|
|
|
/**
|
|
|
|
Signal emitted when this object needs to set a specific title block
|
|
|
|
template. This object cannot handle the job since it does not know of
|
|
|
|
its parent project.
|
|
|
|
*/
|
|
|
|
void needTitleBlockTemplate(const QString &);
|
|
|
|
|
2007-04-12 03:13:13 +00:00
|
|
|
// attributs
|
|
|
|
private:
|
|
|
|
// informations du cartouche
|
|
|
|
QString bi_author;
|
|
|
|
QDate bi_date;
|
|
|
|
QString bi_title;
|
2007-09-28 17:39:30 +00:00
|
|
|
QString bi_folio;
|
2009-04-03 19:30:25 +00:00
|
|
|
QString bi_final_folio;
|
|
|
|
int folio_index_;
|
|
|
|
int folio_total_;
|
2007-09-28 17:39:30 +00:00
|
|
|
QString bi_filename;
|
2011-01-09 15:16:51 +00:00
|
|
|
DiagramContext additional_fields_;
|
2007-04-12 03:13:13 +00:00
|
|
|
|
2008-08-10 15:07:59 +00:00
|
|
|
// dimensions du cadre (lignes et colonnes)
|
|
|
|
// colonnes : nombres et dimensions
|
2007-04-12 03:13:13 +00:00
|
|
|
int nb_columns;
|
|
|
|
qreal columns_width;
|
|
|
|
qreal columns_header_height;
|
2008-08-10 15:07:59 +00:00
|
|
|
|
|
|
|
// lignes : nombres et dimensions
|
|
|
|
int nb_rows;
|
|
|
|
qreal rows_height;
|
|
|
|
qreal rows_header_width;
|
|
|
|
|
|
|
|
// dimensions du cartouche
|
2010-12-20 02:45:36 +00:00
|
|
|
qreal titleblock_width;
|
|
|
|
qreal titleblock_height;
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
// rectangles utilises pour le dessin
|
2008-08-10 15:07:59 +00:00
|
|
|
QRectF diagram;
|
2010-12-20 02:45:36 +00:00
|
|
|
QRectF titleblock;
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
// booleens pour les options de dessin
|
2010-12-20 02:45:36 +00:00
|
|
|
bool display_titleblock;
|
2007-04-12 03:13:13 +00:00
|
|
|
bool display_columns;
|
2008-08-10 15:07:59 +00:00
|
|
|
bool display_rows;
|
2007-04-12 03:13:13 +00:00
|
|
|
bool display_border;
|
2010-12-20 02:45:36 +00:00
|
|
|
TitleBlockTemplateRenderer *titleblock_template_renderer;
|
2007-04-12 03:13:13 +00:00
|
|
|
};
|
2007-01-28 00:53:17 +00:00
|
|
|
#endif
|