2007-12-01 10:47:15 +00:00
|
|
|
/*
|
2010-01-03 16:12:10 +00:00
|
|
|
Copyright 2006-2010 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/>.
|
|
|
|
*/
|
2007-01-28 00:53:17 +00:00
|
|
|
#ifndef BORDERINSET_H
|
2007-04-12 03:13:13 +00:00
|
|
|
#define BORDERINSET_H
|
2007-09-28 17:39:30 +00:00
|
|
|
#include "insetproperties.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;
|
2007-04-12 03:13:13 +00:00
|
|
|
/**
|
|
|
|
Cette classe represente l'ensemble bordure + cartouche qui encadre le
|
|
|
|
schema electrique.
|
|
|
|
*/
|
|
|
|
class BorderInset : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
// constructeurs, destructeur
|
|
|
|
public:
|
|
|
|
BorderInset(QObject * = 0);
|
|
|
|
virtual ~BorderInset();
|
|
|
|
|
|
|
|
private:
|
|
|
|
BorderInset(const BorderInset &);
|
|
|
|
|
|
|
|
// 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
|
2008-08-10 15:07:59 +00:00
|
|
|
qreal insetWidth() const { return(inset_width); }
|
2007-12-05 21:16:01 +00:00
|
|
|
/// @return la hauteur du cartouche
|
2008-08-10 15:07:59 +00:00
|
|
|
qreal insetHeight() const { return(inset_height); }
|
|
|
|
|
|
|
|
// cadre avec le cartouche
|
|
|
|
/// @return la hauteur de la bordure
|
|
|
|
qreal borderWidth() const { return(diagramWidth()); }
|
|
|
|
/// @return la hauteur de la bordure
|
|
|
|
qreal borderHeight() const { return(diagramHeight() + insetHeight()); }
|
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
|
2007-04-12 03:13:13 +00:00
|
|
|
bool insetIsDisplayed() const { return(display_inset); }
|
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 &);
|
2007-04-12 03:13:13 +00:00
|
|
|
void setInsetWidth (const qreal &);
|
|
|
|
void setInsetHeight (const qreal &);
|
2007-10-12 12:54:25 +00:00
|
|
|
void adjustInsetToColumns ();
|
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; }
|
2009-04-03 19:30:25 +00:00
|
|
|
void setFolioData(int, int);
|
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
|
|
|
|
2008-08-14 22:51:08 +00:00
|
|
|
InsetProperties exportInset();
|
|
|
|
void importInset(const InsetProperties &);
|
|
|
|
BorderProperties exportBorder();
|
|
|
|
void importBorder(const BorderProperties &);
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
// methodes d'acces en ecriture aux options
|
2008-08-15 12:46:22 +00:00
|
|
|
void displayInset(bool);
|
|
|
|
void displayColumns(bool);
|
|
|
|
void displayRows(bool);
|
|
|
|
void displayBorder(bool);
|
2007-04-12 03:13:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void updateRectangles();
|
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();
|
|
|
|
|
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;
|
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
|
2007-04-12 03:13:13 +00:00
|
|
|
qreal inset_width;
|
|
|
|
qreal inset_height;
|
|
|
|
|
|
|
|
// rectangles utilises pour le dessin
|
2008-08-10 15:07:59 +00:00
|
|
|
QRectF diagram;
|
2007-04-12 03:13:13 +00:00
|
|
|
QRectF inset;
|
|
|
|
QRectF inset_author;
|
|
|
|
QRectF inset_date;
|
|
|
|
QRectF inset_title;
|
|
|
|
QRectF inset_file;
|
|
|
|
QRectF inset_folio;
|
|
|
|
|
|
|
|
// booleens pour les options de dessin
|
|
|
|
bool display_inset;
|
|
|
|
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;
|
|
|
|
};
|
2007-01-28 00:53:17 +00:00
|
|
|
#endif
|