2006-10-27 15:47:22 +00:00
|
|
|
#ifndef SCHEMA_H
|
|
|
|
#define SCHEMA_H
|
|
|
|
#define GRILLE_X 10
|
|
|
|
#define GRILLE_Y 10
|
2007-01-28 00:53:17 +00:00
|
|
|
#define MARGIN 5.0
|
2006-10-27 15:47:22 +00:00
|
|
|
#include <QtGui>
|
|
|
|
#include <QtXml>
|
2007-01-28 00:53:17 +00:00
|
|
|
#include "qetapp.h"
|
|
|
|
#include "borderinset.h"
|
2006-10-27 15:47:22 +00:00
|
|
|
class Element;
|
2007-01-29 20:14:26 +00:00
|
|
|
class Terminal;
|
2007-01-29 00:41:12 +00:00
|
|
|
class Diagram : public QGraphicsScene {
|
2006-10-27 15:47:22 +00:00
|
|
|
Q_OBJECT
|
2007-02-01 01:07:26 +00:00
|
|
|
enum BorderOptions { EmptyBorder, Inset, Columns };
|
2006-10-27 15:47:22 +00:00
|
|
|
public:
|
2007-01-29 00:41:12 +00:00
|
|
|
Diagram(QObject * = 0);
|
2006-10-27 15:47:22 +00:00
|
|
|
void drawBackground(QPainter *, const QRectF &);
|
2007-02-01 01:07:26 +00:00
|
|
|
|
|
|
|
// fonctions relatives a la pose de conducteurs
|
2007-01-29 20:32:38 +00:00
|
|
|
inline void poseConducer(bool pf) {
|
2006-10-27 15:47:22 +00:00
|
|
|
if (pf) {
|
2007-01-29 20:32:38 +00:00
|
|
|
if (!poseur_de_conducer -> scene()) addItem(poseur_de_conducer);
|
2006-10-27 15:47:22 +00:00
|
|
|
} else {
|
2007-01-29 20:32:38 +00:00
|
|
|
if (poseur_de_conducer -> scene()) removeItem(poseur_de_conducer);
|
2006-10-27 15:47:22 +00:00
|
|
|
}
|
|
|
|
}
|
2007-01-29 20:32:38 +00:00
|
|
|
inline void setDepart (QPointF d) { poseur_de_conducer -> setLine(QLineF(d, poseur_de_conducer -> line().p2())); }
|
|
|
|
inline void setArrivee(QPointF a) { poseur_de_conducer -> setLine(QLineF(poseur_de_conducer -> line().p1(), a)); }
|
2007-02-01 01:07:26 +00:00
|
|
|
|
|
|
|
// fonctions relatives a l'import / export XML
|
2006-10-27 15:47:22 +00:00
|
|
|
QDomDocument toXml(bool = true);
|
2007-01-28 00:53:17 +00:00
|
|
|
bool fromXml(QDomDocument &, QPointF = QPointF(), bool = true);
|
2007-02-01 01:07:26 +00:00
|
|
|
|
|
|
|
// fonctions relatives aux options graphiques
|
|
|
|
inline void setAffichageGrille(bool dg) { draw_grid = dg; }
|
|
|
|
inline bool displayGrid() { return(draw_grid); }
|
|
|
|
inline void setUseBorder(bool ub) { use_border = ub; }
|
|
|
|
inline bool useBorder() { return(use_border); }
|
|
|
|
inline void setBorderOptions(BorderOptions bo) {
|
|
|
|
border_and_inset.displayBorder(!(bo & EmptyBorder));
|
|
|
|
border_and_inset.displayColumns(bo & Columns);
|
|
|
|
border_and_inset.displayInset(bo & Inset);
|
|
|
|
}
|
|
|
|
inline BorderOptions borderOptions() {
|
|
|
|
BorderOptions retour = EmptyBorder;
|
|
|
|
if (border_and_inset.insetIsDisplayed()) retour = (BorderOptions)(retour|Inset);
|
|
|
|
if (border_and_inset.columnsAreDisplayed()) retour = (BorderOptions)(retour|Columns);
|
|
|
|
return(retour);
|
|
|
|
}
|
|
|
|
|
2007-01-28 00:53:17 +00:00
|
|
|
BorderInset border_and_inset;
|
|
|
|
QRectF border() const;
|
2007-02-01 01:07:26 +00:00
|
|
|
QImage toImage(int = -1, int = -1, Qt::AspectRatioMode = Qt::KeepAspectRatio);
|
|
|
|
QSize imageSize() const;
|
2006-11-19 18:40:03 +00:00
|
|
|
|
|
|
|
private:
|
2007-01-29 20:32:38 +00:00
|
|
|
QGraphicsLineItem *poseur_de_conducer;
|
2007-02-01 01:07:26 +00:00
|
|
|
bool draw_grid;
|
|
|
|
bool use_border;
|
|
|
|
|
2006-10-27 15:47:22 +00:00
|
|
|
private slots:
|
|
|
|
void slot_checkSelectionChange();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void selectionChanged();
|
|
|
|
};
|
|
|
|
#endif
|