mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 08:10:52 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5762b3943b |
29
CREDIT
29
CREDIT
@@ -1,29 +1,6 @@
|
||||
[en]
|
||||
Thanks to Trolltech for their Qt library ( http://trolltech.com/ ), licensed
|
||||
under GNU/GPL.
|
||||
Thanks to Everaldo Coelho for the Crystal SVG icons theme (
|
||||
http://www.everaldo.com/crystal/ ) licensed under LGPL, and to the KDE
|
||||
project ( http://www.kde.org/ ).
|
||||
Thanks to Loic for his mathematics-related explanations.
|
||||
Thanks to Nicolas for the Mac OS X experimentations.
|
||||
Thanks to Remi Collet for the Fedora packaging.
|
||||
Thanks to Piotr SQLek Skólski for the Debian packaging.
|
||||
Thanks to `trem' for the Mandriva packaging.
|
||||
Thanks to TuxFamily ( http://tuxfamily.org ) for hosting the project.
|
||||
Thanks to `Nishiki' for his elements and his support.
|
||||
Thanks to qtcentre.org for their SingleApplication class.
|
||||
|
||||
[fr]
|
||||
Merci à Trolltech pour la bibliothèque Qt ( http://trolltech.com/ ), sous
|
||||
Merci à Trolltech pour la bibliothèque Qt ( http://trolltech.com/ ), sous
|
||||
licence GNU/GPL.
|
||||
Merci à Everaldo Coelho pour le thème d'icônes Crystal SVG (
|
||||
Merci à Everaldo Coelho pour le thème d'icônes Crystal SVG (
|
||||
http://www.everaldo.com/crystal/ ) sous licence LGPL, ainsi qu'au projet KDE (
|
||||
http://www.kde.org/ ).
|
||||
Merci à Loic pour ses explications d'ordre mathématique.
|
||||
Merci à Nicolas pour les expérimentations Mac OS X.
|
||||
Merci à Remi Collet pour les paquets Fedora.
|
||||
Merci à Piotr SQLek Skólski pour les paquets Debian.
|
||||
Merci à `trem' pour les paquets Mandriva.
|
||||
Merci à TuxFamily ( http://tuxfamily.org ) pour l'hébergement du projet.
|
||||
Merci à `Nishiki' pour ses éléments et son soutien.
|
||||
Merci à qtcentre.org pour leur classe SingleApplication.
|
||||
Merci à Loic pour ses explications d'ordre mathématique.
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
[fr]
|
||||
La collection d'éléments fournie avec QElectroTech est fournie telle quelle et
|
||||
sans la moindre garantie qu'elle convienne à votre utilisation ou qu'elle
|
||||
fonctionne.
|
||||
L'utilisation, la modification et l'intégration des éléments dans des schémas
|
||||
électriques est autorisée sans conditions, quelque soit la licence finale des
|
||||
schémas.
|
||||
Si vous redistribuez tout ou partie de la collection QElectroTech, avec ou sans
|
||||
modification, en dehors d'un schéma électrique, vous devrez respecter les
|
||||
conditions de la licence CC-BY :
|
||||
Cette création est mise à disposition selon le Contrat Paternité 2.0 France
|
||||
disponible en ligne http://creativecommons.org/licenses/by/2.0/fr/ ou par
|
||||
courrier postal à Creative Commons, 171 Second Street, Suite 300, San Francisco,
|
||||
California 94105, USA.
|
||||
|
||||
[en]
|
||||
The elements collection provided along with QElectroTech is provided as is and
|
||||
without any warranty of fitness for your purpose or working.
|
||||
The usage, the modification and the integration of the elements into electric
|
||||
diagrams is allowed without any condition, whatever the final license of the
|
||||
diagrams is.
|
||||
If you redistribute all or a part of the QElectroTech collection, with or
|
||||
without any modification, out of an electric diagram, you must respect the
|
||||
conditions of the CC-BY license:
|
||||
This work is licensed under the Creative Commons Attribution 2.0 France License.
|
||||
To view a copy of this license, visit
|
||||
http://creativecommons.org/licenses/by/2.0/fr/ or send a letter to Creative
|
||||
Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
|
||||
|
||||
[es]
|
||||
La colección de elementos QElectrotech es distruibida tal cual y sin ninguna
|
||||
garantía a la conveniencia de su uso y sin garantía de que funciona.
|
||||
Se permite sin condicione alguna, cualquiera que sea la licencia final, usar,
|
||||
editar, e incluir estos elementos en esquemas eléctricos.
|
||||
Si usted redistribuye una parte de la colección o toda la collección de
|
||||
QElectrotech, con o sin ediciones, fuera de un esquema eléctrico, tiene que
|
||||
respetar las condiciones de la licencia CC-BY:
|
||||
Esta obra está bajo una licencia Reconocimiento 2.0 Francia de Creative Commons.
|
||||
Para ver una copia de esta licencia, visite
|
||||
http://creativecommons.org/licenses/by/2.0/fr/ o envie una carta a Creative
|
||||
Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA.
|
||||
21
INSTALL
21
INSTALL
@@ -1,21 +0,0 @@
|
||||
[en]
|
||||
Requirements :
|
||||
libQt4 (see packages libqt4*)
|
||||
cupsys-bsd for printing
|
||||
|
||||
Howto compile :
|
||||
$ qmake (qmake-qt4 for Debian-based systems)
|
||||
$ make
|
||||
# umask 0022
|
||||
# make install
|
||||
|
||||
[fr]
|
||||
Pré-requis :
|
||||
libQt4 (paquets libqt4*)
|
||||
cupsys-bsd pour l'impression
|
||||
|
||||
Comment compiler :
|
||||
$ qmake (qmake-qt4 pour les systèmes basés sur Debian)
|
||||
$ make
|
||||
# umask 0022
|
||||
# make install
|
||||
9
README
9
README
@@ -1,9 +0,0 @@
|
||||
[en]
|
||||
QElectroTech is a Qt4 application to design electric diagrams. It uses XML
|
||||
files for elements and diagrams, and includes both a diagram editor and an
|
||||
element editor.
|
||||
|
||||
[fr]
|
||||
QElectroTech est une application Qt4 pour réaliser des schémas électriques.
|
||||
QET utilise le format XML pour ses éléments et ses schémas et inclut un
|
||||
éditeur de schémas ainsi qu'un éditeur d'élément.
|
||||
138
aboutqet.cpp
Normal file
138
aboutqet.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
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/>.
|
||||
*/
|
||||
#include "aboutqet.h"
|
||||
#include "qet.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param parent Le QWidget parent de la boite de dialogue
|
||||
*/
|
||||
AboutQET::AboutQET(QWidget *parent) : QDialog(parent) {
|
||||
// Titre, taille, comportement...
|
||||
setWindowTitle(tr("\300 propos de QElectrotech"));
|
||||
setMinimumWidth(680);
|
||||
setMinimumHeight(350);
|
||||
setModal(true);
|
||||
|
||||
// Trois onglets
|
||||
QTabWidget *onglets = new QTabWidget(this);
|
||||
onglets -> addTab(ongletAPropos(), tr("\300 &propos"));
|
||||
onglets -> addTab(ongletAuteurs(), tr("A&uteurs"));
|
||||
onglets -> addTab(ongletLicence(), tr("&Accord de licence"));
|
||||
|
||||
// Un bouton pour fermer la boite de dialogue
|
||||
QDialogButtonBox *boutons = new QDialogButtonBox(QDialogButtonBox::Close);
|
||||
connect(boutons, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(boutons, SIGNAL(rejected()), this, SLOT(accept()));
|
||||
|
||||
// Le tout dans une disposition verticale
|
||||
QVBoxLayout *disposition = new QVBoxLayout();
|
||||
disposition -> addWidget(titre());
|
||||
disposition -> addWidget(onglets);
|
||||
disposition -> addWidget(boutons);
|
||||
setLayout(disposition);
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
*/
|
||||
AboutQET::~AboutQET() {
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le titre QElectroTech avec son icone
|
||||
*/
|
||||
QWidget *AboutQET::titre() const {
|
||||
QWidget *icone_et_titre = new QWidget();
|
||||
// icone
|
||||
QLabel *icone = new QLabel();
|
||||
icone -> setPixmap(QIcon(":/ico/qelectrotech.png").pixmap(48, 48));
|
||||
// label "QElectroTech"
|
||||
QLabel *titre = new QLabel("<span style=\"font-weight:0;font-size:16pt;\">QElectroTech v" + QET::version + "</span>");
|
||||
titre -> setTextFormat(Qt::RichText);
|
||||
// le tout dans une grille
|
||||
QGridLayout *dispo_horiz = new QGridLayout();
|
||||
dispo_horiz -> addWidget(icone, 0, 0);
|
||||
dispo_horiz -> addWidget(titre, 0, 1);
|
||||
dispo_horiz -> setColumnStretch(0, 1);
|
||||
dispo_horiz -> setColumnStretch(1, 100);
|
||||
icone_et_titre -> setLayout(dispo_horiz);
|
||||
return(icone_et_titre);
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le widget contenu par l'onglet « A propos »
|
||||
*/
|
||||
QWidget *AboutQET::ongletAPropos() const {
|
||||
QLabel *apropos = new QLabel(
|
||||
tr("QElectroTech, une application de r\351alisation de sch\351mas \351lectriques.") +
|
||||
"<br><br>" +
|
||||
tr("\251 2006-2007 Les d\351veloppeurs de QElectroTech") +
|
||||
"<br><br>"
|
||||
"<a href=\"http://qelectrotech.tuxfamily.org/\">"
|
||||
"http://qelectrotech.tuxfamily.org/</a>"
|
||||
);
|
||||
apropos -> setAlignment(Qt::AlignCenter);
|
||||
apropos -> setOpenExternalLinks(true);
|
||||
apropos -> setTextFormat(Qt::RichText);
|
||||
return(apropos);
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le widget contenu par l'onglet « Auteurs »
|
||||
*/
|
||||
QWidget *AboutQET::ongletAuteurs() const {
|
||||
QLabel *auteurs = new QLabel(
|
||||
"<span style=\"text-decoration: underline;\">" +
|
||||
tr("Id\351e originale") +
|
||||
"</span> : Beno\356t Ansieau "
|
||||
"<<a href=\"mailto:benoit.ansieau@gmail.com\">"
|
||||
"benoit.ansieau@gmail.com</a>>"
|
||||
"<br><br>"
|
||||
"<span style=\"text-decoration: underline;\">" +
|
||||
tr("Programmation") +
|
||||
"</span> : Xavier Guerrin "
|
||||
"<<a href=\"mailto:xavier.guerrin@gmail.com\">"
|
||||
"xavier.guerrin@gmail.com</a>>"
|
||||
);
|
||||
auteurs -> setAlignment(Qt::AlignCenter);
|
||||
auteurs -> setOpenExternalLinks(true);
|
||||
auteurs -> setTextFormat(Qt::RichText);
|
||||
return(auteurs);
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le widget contenu par l'onglet « Accord de Licence »
|
||||
*/
|
||||
QWidget *AboutQET::ongletLicence() const {
|
||||
QWidget *licence = new QWidget();
|
||||
// label
|
||||
QLabel *titre_licence = new QLabel(tr("Ce programme est sous licence GNU/GPL."));
|
||||
|
||||
// texte de la GNU/GPL dans une zone de texte scrollable non editable
|
||||
QTextEdit *texte_licence = new QTextEdit();
|
||||
texte_licence -> setPlainText(QET::license());
|
||||
texte_licence -> setReadOnly(true);
|
||||
|
||||
// le tout dans une disposition verticale
|
||||
QVBoxLayout *dispo_licence = new QVBoxLayout();
|
||||
dispo_licence -> addWidget(titre_licence);
|
||||
dispo_licence -> addWidget(texte_licence);
|
||||
licence -> setLayout(dispo_licence);
|
||||
return(licence);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -17,11 +17,10 @@
|
||||
*/
|
||||
#ifndef ABOUTQET_H
|
||||
#define ABOUTQET_H
|
||||
#include <QDialog>
|
||||
class QLabel;
|
||||
#include <QtGui>
|
||||
/**
|
||||
Cette classe represente la boite de dialogue
|
||||
"A propos de QElectroTech".
|
||||
« A propos de QElectroTech »
|
||||
*/
|
||||
class AboutQET : public QDialog {
|
||||
Q_OBJECT
|
||||
@@ -36,10 +35,9 @@ class AboutQET : public QDialog {
|
||||
|
||||
// methodes
|
||||
private:
|
||||
QWidget *title() const;
|
||||
QWidget *aboutTab() const;
|
||||
QWidget *authorsTab() const;
|
||||
QWidget *licenseTab() const;
|
||||
void addAuthor(QLabel *, const QString &, const QString &, const QString &) const;
|
||||
QWidget *titre() const;
|
||||
QWidget *ongletAPropos() const;
|
||||
QWidget *ongletAuteurs() const;
|
||||
QWidget *ongletLicence() const;
|
||||
};
|
||||
#endif
|
||||
231
borderinset.cpp
Normal file
231
borderinset.cpp
Normal file
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
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/>.
|
||||
*/
|
||||
#include "borderinset.h"
|
||||
#include "qetapp.h"
|
||||
|
||||
/**
|
||||
Constructeur simple : construit une bordure de 15 colonnes de 50x500 avec
|
||||
un cartouche de 400x50.
|
||||
@param parent QObject parent de ce BorderInset
|
||||
*/
|
||||
BorderInset::BorderInset(QObject *parent) : QObject(parent) {
|
||||
nb_columns = qMax(3, QETApp::settings().value("diagrameditor/defaultcols", 15).toInt());
|
||||
min_nb_columns = 3;
|
||||
columns_width = QETApp::settings().value("diagrameditor/defaultcolsize", 50.0).toDouble();
|
||||
columns_height = QETApp::settings().value("diagrameditor/defaultheight", 500.0).toDouble();
|
||||
min_columns_height = 80.0;
|
||||
inset_width = nb_columns * columns_width;
|
||||
inset_height = 50.0;
|
||||
columns_header_height = 20.0;
|
||||
display_inset = true;
|
||||
display_columns = true;
|
||||
display_border = true;
|
||||
updateRectangles();
|
||||
|
||||
bi_author = QETApp::settings().value("diagrameditor/defaultauthor").toString();
|
||||
bi_title = QETApp::settings().value("diagrameditor/defaulttitle").toString();
|
||||
bi_folio = QETApp::settings().value("diagrameditor/defaultfolio").toString();
|
||||
bi_filename = QETApp::settings().value("diagrameditor/defaultfilename").toString();
|
||||
QString settings_date = QETApp::settings().value("diagrameditor/defaultdate").toString();
|
||||
if (settings_date == "now") bi_date = QDate::currentDate();
|
||||
else if (settings_date.isEmpty() || settings_date == "null") bi_date = QDate();
|
||||
else bi_date = QDate::fromString(settings_date, "yyyyMMdd");
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur - ne fait rien
|
||||
*/
|
||||
BorderInset::~BorderInset() {
|
||||
}
|
||||
|
||||
/**
|
||||
Methode recalculant les rectangles composant le cadre et le cartouche en
|
||||
fonction des attributs de taille
|
||||
*/
|
||||
void BorderInset::updateRectangles() {
|
||||
// rectangle delimitant le schema
|
||||
QRectF previous_border = border;
|
||||
border = QRectF(0, 0, nb_columns * columns_width, columns_height);
|
||||
if (border != previous_border) emit(borderChanged(previous_border, border));
|
||||
|
||||
// rectangles relatifs au cartouche
|
||||
inset = QRectF(border.bottomLeft().x(), border.bottomLeft().y(), inset_width, inset_height);
|
||||
inset_author = QRectF(inset.topLeft(), QSizeF(2.0 * inset_width / 9.0, 0.5 * inset_height));
|
||||
inset_date = QRectF(inset_author.bottomLeft(), inset_author.size());
|
||||
inset_title = QRectF(inset_author.topRight(), QSizeF(5.0 * inset_width / 9.0, inset_height));
|
||||
inset_file = QRectF(inset_title.topRight(), inset_author.size());
|
||||
inset_folio = QRectF(inset_file.bottomLeft(), inset_author.size());
|
||||
}
|
||||
|
||||
/**
|
||||
Dessine le cadre et le cartouche
|
||||
@param qp QPainter a utiliser pour dessiner le cadre et le cartouche
|
||||
@param x Abscisse du cadre
|
||||
@param y Ordonnee du cadre
|
||||
*/
|
||||
void BorderInset::draw(QPainter *qp, qreal x, qreal y) {
|
||||
// translate tous les rectangles
|
||||
border .translate(x, y);
|
||||
inset .translate(x, y);
|
||||
inset_author.translate(x, y);
|
||||
inset_date .translate(x, y);
|
||||
inset_title .translate(x, y);
|
||||
inset_file .translate(x, y);
|
||||
inset_folio .translate(x, y);
|
||||
|
||||
// prepare le QPainter
|
||||
qp -> save();
|
||||
qp -> setPen(Qt::black);
|
||||
qp -> setBrush(Qt::NoBrush);
|
||||
|
||||
// dessine le cadre
|
||||
if (display_border) qp -> drawRect(border);
|
||||
|
||||
// dessine la numerotation des colonnes
|
||||
if (display_columns) {
|
||||
qp -> setBrush(Qt::white);
|
||||
for (int i = 1 ; i <= nb_columns ; ++ i) {
|
||||
QRectF numbered_rectangle = QRectF(
|
||||
border.topLeft().x() + ((i - 1) * columns_width),
|
||||
border.topLeft().y(),
|
||||
columns_width,
|
||||
columns_header_height
|
||||
);
|
||||
qp -> drawRect(numbered_rectangle);
|
||||
qp -> drawText(numbered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, QString("%1").arg(i));
|
||||
}
|
||||
}
|
||||
|
||||
// dessine le cartouche
|
||||
if (display_inset) {
|
||||
qp -> setBrush(Qt::white);
|
||||
qp -> drawRect(inset);
|
||||
|
||||
qp -> drawRect(inset_author);
|
||||
qp -> drawText(inset_author, Qt::AlignVCenter | Qt::AlignLeft, tr(" Auteur : ") + bi_author);
|
||||
|
||||
qp -> drawRect(inset_date);
|
||||
qp -> drawText(inset_date, Qt::AlignVCenter | Qt::AlignLeft, tr(" Date : ") + bi_date.toString("dd/MM/yyyy"));
|
||||
|
||||
qp -> drawRect(inset_title);
|
||||
qp -> drawText(inset_title, Qt::AlignVCenter | Qt::AlignCenter, tr("Titre du document : ") + bi_title);
|
||||
|
||||
qp -> drawRect(inset_file);
|
||||
qp -> drawText(inset_file, Qt::AlignVCenter | Qt::AlignLeft, tr(" Fichier : ") + bi_filename);
|
||||
|
||||
qp -> drawRect(inset_folio);
|
||||
qp -> drawText(inset_folio, Qt::AlignVCenter | Qt::AlignLeft, tr(" Folio : ") + bi_folio);
|
||||
}
|
||||
|
||||
qp -> restore();
|
||||
|
||||
// annule la translation des rectangles
|
||||
border .translate(-x, -y);
|
||||
inset .translate(-x, -y);
|
||||
inset_author.translate(-x, -y);
|
||||
inset_date .translate(-x, -y);
|
||||
inset_title .translate(-x, -y);
|
||||
inset_file .translate(-x, -y);
|
||||
inset_folio .translate(-x, -y);
|
||||
}
|
||||
|
||||
/**
|
||||
Ajoute une colonne.
|
||||
*/
|
||||
void BorderInset::addColumn() {
|
||||
++ nb_columns;
|
||||
setInsetWidth(nb_columns * columns_width);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Enleve une colonne. Il doit rester au moins 3 colonnes.
|
||||
*/
|
||||
void BorderInset::removeColumn() {
|
||||
if (nb_columns == min_nb_columns) return;
|
||||
-- nb_columns;
|
||||
setInsetWidth(nb_columns * columns_width);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Permet de changer le nombre de colonnes.
|
||||
Si ce nombre de colonnes est inferieur au minimum requis, cette fonction ne
|
||||
fait rien
|
||||
@param nb_c nouveau nombre de colonnes
|
||||
@see minNbColumns()
|
||||
*/
|
||||
void BorderInset::setNbColumns(int nb_c) {
|
||||
if (nb_c < min_nb_columns) return;
|
||||
nb_columns = nb_c;
|
||||
setInsetWidth(nb_columns * columns_width);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Change la largeur des colonnes ; celle-ci doit rester comprise entre 10 et
|
||||
200px.
|
||||
*/
|
||||
void BorderInset::setColumnsWidth(const qreal &new_cw) {
|
||||
columns_width = qBound(10.0, new_cw, 200.0);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Change la hauteur des en-tetes contenant les numeros de colonnes. Celle-ci
|
||||
doit rester comprise entre 5 et 50 px.
|
||||
*/
|
||||
void BorderInset::setColumnsHeaderHeight(const qreal &new_chh) {
|
||||
columns_header_height = qBound(5.0, new_chh, 50.0);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Change la hauteur des colonnes (et donc du cadre). Cette hauteur doit
|
||||
rester superieure a la hauteur des en-tetes de colonnes + 20px.
|
||||
*/
|
||||
void BorderInset::setColumnsHeight(const qreal &new_ch) {
|
||||
columns_height = qMax(columns_header_height + min_columns_height, new_ch);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Change la largeur du cartouche. Cette largeur doit rester comprise entre
|
||||
100px et la largeur du cartouche
|
||||
*/
|
||||
void BorderInset::setInsetWidth(const qreal &new_iw) {
|
||||
inset_width = qMax(100.0, qMin(nb_columns * columns_width, new_iw));
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Change la hauteur du cartouche. Cette largeur doit rester comprise entre
|
||||
20px et la hauteur du cartouche.
|
||||
*/
|
||||
void BorderInset::setInsetHeight(const qreal &new_ih) {
|
||||
inset_height = qMax(20.0, qMin(columns_height, new_ih));
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Ajuste la largeur du cartouche de facon a ce que celui-ci soit aussi large
|
||||
que le schema
|
||||
*/
|
||||
void BorderInset::adjustInsetToColumns() {
|
||||
setInsetWidth(nbColumn() * columnsWidth());
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -18,11 +18,10 @@
|
||||
#ifndef BORDERINSET_H
|
||||
#define BORDERINSET_H
|
||||
#include "insetproperties.h"
|
||||
#include "borderproperties.h"
|
||||
#include <QObject>
|
||||
#include <QRectF>
|
||||
#include <QPainter>
|
||||
#include <QDate>
|
||||
class QPainter;
|
||||
/**
|
||||
Cette classe represente l'ensemble bordure + cartouche qui encadre le
|
||||
schema electrique.
|
||||
@@ -40,51 +39,29 @@ class BorderInset : public QObject {
|
||||
|
||||
// methodes
|
||||
public:
|
||||
static int minNbColumns();
|
||||
static qreal minColumnsWidth();
|
||||
static int minNbRows();
|
||||
static qreal minRowsHeight();
|
||||
|
||||
void draw(QPainter *, qreal = 0.0, qreal = 0.0);
|
||||
|
||||
// methodes d'acces en lecture aux dimensions
|
||||
// colonnes
|
||||
/// @return le nombre de colonnes du schema
|
||||
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); }
|
||||
int nbColumn() const { return(nb_columns); }
|
||||
/// @return la taille des colonnes en pixels
|
||||
qreal columnsWidth() const { return(columns_width); }
|
||||
/// @return la hauteur, en pixels, des en-tetes des colonnes
|
||||
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
|
||||
qreal columnsHeaderHeight() const { return(columns_header_height); }
|
||||
/// @return la hauteur des colonnes, en-tetes inclus
|
||||
qreal columnsHeight() const { return(columns_height); }
|
||||
/// @return la largeur de la bordure
|
||||
qreal borderWidth() const { return(nb_columns * columns_width); }
|
||||
/// @return la hauteur de la bordure
|
||||
qreal borderHeight() const { return(columns_height + inset_height); }
|
||||
/// @return la largeur du cartouche
|
||||
qreal insetWidth() const { return(inset_width); }
|
||||
qreal insetWidth() const { return(inset_width); }
|
||||
/// @return la hauteur du cartouche
|
||||
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()); }
|
||||
qreal insetHeight() const { return(inset_height); }
|
||||
/// @return la hauteur minimale acceptee des colonnes
|
||||
qreal minColumnsHeight() const { return(min_columns_height); }
|
||||
/// @return le nombre minimum accepte de colonnes
|
||||
int minNbColumns() const { return(min_nb_columns); }
|
||||
|
||||
// methodes d'acces en lecture aux informations du cartouche
|
||||
/// @return le champ "Auteur" du cartouche
|
||||
@@ -103,23 +80,16 @@ class BorderInset : public QObject {
|
||||
bool insetIsDisplayed() const { return(display_inset); }
|
||||
/// @return true si les entetes des colonnes sont affiches, false sinon
|
||||
bool columnsAreDisplayed() const { return(display_columns); }
|
||||
/// @return true si les entetes des lignes sont affiches, false sinon
|
||||
bool rowsAreDisplayed() const { return(display_rows); }
|
||||
/// @return true si la bordure est affichee, false sinon
|
||||
bool borderIsDisplayed() const { return(display_border); }
|
||||
|
||||
// methodes d'acces en ecriture aux dimensions
|
||||
void addColumn ();
|
||||
void addRow ();
|
||||
void removeColumn ();
|
||||
void removeRow ();
|
||||
void setNbColumns (int);
|
||||
void setNbRows (int);
|
||||
void setColumnsWidth (const qreal &);
|
||||
void setRowsHeight (const qreal &);
|
||||
void setColumnsHeaderHeight(const qreal &);
|
||||
void setRowsHeaderWidth (const qreal &);
|
||||
void setDiagramHeight (const qreal &);
|
||||
void setColumnsHeight (const qreal &);
|
||||
void setInsetWidth (const qreal &);
|
||||
void setInsetHeight (const qreal &);
|
||||
void adjustInsetToColumns ();
|
||||
@@ -130,32 +100,42 @@ class BorderInset : public QObject {
|
||||
/// @param date le nouveau contenu du champ "Date"
|
||||
void setDate (const QDate &date) { bi_date = date; }
|
||||
/// @param title le nouveau contenu du champ "Titre"
|
||||
void setTitle (const QString &title) {
|
||||
if (bi_title != title) {
|
||||
bi_title = title;
|
||||
emit(diagramTitleChanged(title));
|
||||
}
|
||||
}
|
||||
void setTitle (const QString &title) { bi_title = title; }
|
||||
/// @param folio le nouveau contenu du champ "Folio"
|
||||
void setFolio (const QString &folio) { bi_folio = folio; }
|
||||
void setFolioData(int, int);
|
||||
/// @param filename le nouveau contenu du champ "Fichier"
|
||||
void setFileName (const QString &filename) { bi_filename = filename; }
|
||||
|
||||
InsetProperties exportInset();
|
||||
void importInset(const InsetProperties &);
|
||||
BorderProperties exportBorder();
|
||||
void importBorder(const BorderProperties &);
|
||||
/// @return les proprietes du cartouches
|
||||
InsetProperties exportInset() {
|
||||
InsetProperties ip;
|
||||
ip.author = bi_author;
|
||||
ip.date = bi_date;
|
||||
ip.title = bi_title;
|
||||
ip.folio = bi_folio;
|
||||
ip.filename = bi_filename;
|
||||
return(ip);
|
||||
}
|
||||
|
||||
/// @param ip les nouvelles proprietes du cartouche
|
||||
void importInset(const InsetProperties &ip) {
|
||||
bi_author = ip.author;
|
||||
bi_date = ip.date;
|
||||
bi_title = ip.title;
|
||||
bi_folio = ip.folio;
|
||||
bi_filename = ip.filename;
|
||||
}
|
||||
|
||||
// methodes d'acces en ecriture aux options
|
||||
void displayInset(bool);
|
||||
void displayColumns(bool);
|
||||
void displayRows(bool);
|
||||
void displayBorder(bool);
|
||||
/// @param di true pour afficher le cartouche, false sinon
|
||||
void displayInset (bool di) { display_inset = di; }
|
||||
/// @param dc true pour afficher les entetes des colonnes, false sinon
|
||||
void displayColumns (bool dc) { display_columns = dc; }
|
||||
/// @param db true pour afficher la bordure du schema, false sinon
|
||||
void displayBorder (bool db) { display_border = db; }
|
||||
|
||||
private:
|
||||
void updateRectangles();
|
||||
QString incrementLetters(const QString &);
|
||||
|
||||
// signaux
|
||||
signals:
|
||||
@@ -165,21 +145,6 @@ class BorderInset : public QObject {
|
||||
@param new_border Nouvelle bordure
|
||||
*/
|
||||
void borderChanged(QRectF old_border, QRectF new_border);
|
||||
/**
|
||||
Signal emise lorsque des options d'affichage change
|
||||
*/
|
||||
void displayChanged();
|
||||
|
||||
/**
|
||||
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();
|
||||
|
||||
// attributs
|
||||
private:
|
||||
@@ -188,28 +153,20 @@ class BorderInset : public QObject {
|
||||
QDate bi_date;
|
||||
QString bi_title;
|
||||
QString bi_folio;
|
||||
QString bi_final_folio;
|
||||
int folio_index_;
|
||||
int folio_total_;
|
||||
QString bi_filename;
|
||||
|
||||
// dimensions du cadre (lignes et colonnes)
|
||||
// colonnes : nombres et dimensions
|
||||
// dimensions du cadre et du cartouche
|
||||
int nb_columns;
|
||||
int min_nb_columns;
|
||||
qreal columns_width;
|
||||
qreal columns_header_height;
|
||||
|
||||
// lignes : nombres et dimensions
|
||||
int nb_rows;
|
||||
qreal rows_height;
|
||||
qreal rows_header_width;
|
||||
|
||||
// dimensions du cartouche
|
||||
qreal columns_height;
|
||||
qreal min_columns_height;
|
||||
qreal inset_width;
|
||||
qreal inset_height;
|
||||
|
||||
// rectangles utilises pour le dessin
|
||||
QRectF diagram;
|
||||
QRectF border;
|
||||
QRectF inset;
|
||||
QRectF inset_author;
|
||||
QRectF inset_date;
|
||||
@@ -220,7 +177,6 @@ class BorderInset : public QObject {
|
||||
// booleens pour les options de dessin
|
||||
bool display_inset;
|
||||
bool display_columns;
|
||||
bool display_rows;
|
||||
bool display_border;
|
||||
};
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -16,11 +16,9 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <QtDebug>
|
||||
#include <limits>
|
||||
#include "conductor.h"
|
||||
#include "conductorsegment.h"
|
||||
#include "conductorsegmentprofile.h"
|
||||
#include "diagramtextitem.h"
|
||||
#include "element.h"
|
||||
#include "diagram.h"
|
||||
#include "diagramcommands.h"
|
||||
@@ -38,14 +36,11 @@ QBrush Conductor::square_brush = QBrush(Qt::darkGreen);
|
||||
@param scene QGraphicsScene a laquelle appartient le conducteur
|
||||
*/
|
||||
Conductor::Conductor(Terminal *p1, Terminal* p2, Element *parent, QGraphicsScene *scene) :
|
||||
QObject(),
|
||||
QGraphicsPathItem(parent, scene),
|
||||
terminal1(p1),
|
||||
terminal2(p2),
|
||||
destroyed(false),
|
||||
segments(NULL),
|
||||
moving_point(false),
|
||||
moving_segment(false),
|
||||
previous_z_value(zValue()),
|
||||
modified_path(false),
|
||||
has_to_save_profile(false)
|
||||
@@ -88,12 +83,6 @@ Conductor::Conductor(Terminal *p1, Terminal* p2, Element *parent, QGraphicsScene
|
||||
text_item -> previous_text = properties_.text;
|
||||
calculateTextItemPosition();
|
||||
text_item -> setParentItem(this);
|
||||
connect(
|
||||
text_item,
|
||||
SIGNAL(diagramTextChanged(DiagramTextItem *, const QString &, const QString &)),
|
||||
this,
|
||||
SLOT(displayedTextChanged())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -361,40 +350,40 @@ void Conductor::priv_calculeConductor(const QPointF &p1, QET::Orientation o1, co
|
||||
if (depart.y() < arrivee.y()) {
|
||||
// trajet descendant
|
||||
if ((ori_depart == QET::North && (ori_arrivee == QET::South || ori_arrivee == QET::West)) || (ori_depart == QET::East && ori_arrivee == QET::West)) {
|
||||
// cas "3"
|
||||
// cas « 3 »
|
||||
int ligne_inter_x = qRound(depart.x() + arrivee.x()) / 2;
|
||||
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
|
||||
points << QPointF(ligne_inter_x, depart.y());
|
||||
points << QPointF(ligne_inter_x, arrivee.y());
|
||||
} else if ((ori_depart == QET::South && (ori_arrivee == QET::North || ori_arrivee == QET::East)) || (ori_depart == QET::West && ori_arrivee == QET::East)) {
|
||||
// cas "4"
|
||||
// cas « 4 »
|
||||
int ligne_inter_y = qRound(depart.y() + arrivee.y()) / 2;
|
||||
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
|
||||
points << QPointF(depart.x(), ligne_inter_y);
|
||||
points << QPointF(arrivee.x(), ligne_inter_y);
|
||||
} else if ((ori_depart == QET::North || ori_depart == QET::East) && (ori_arrivee == QET::North || ori_arrivee == QET::East)) {
|
||||
points << QPointF(arrivee.x(), depart.y()); // cas "2"
|
||||
points << QPointF(arrivee.x(), depart.y()); // cas « 2 »
|
||||
} else {
|
||||
points << QPointF(depart.x(), arrivee.y()); // cas "1"
|
||||
points << QPointF(depart.x(), arrivee.y()); // cas « 1 »
|
||||
}
|
||||
} else {
|
||||
// trajet montant
|
||||
if ((ori_depart == QET::West && (ori_arrivee == QET::East || ori_arrivee == QET::South)) || (ori_depart == QET::North && ori_arrivee == QET::South)) {
|
||||
// cas "3"
|
||||
// cas « 3 »
|
||||
int ligne_inter_y = qRound(depart.y() + arrivee.y()) / 2;
|
||||
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
|
||||
points << QPointF(depart.x(), ligne_inter_y);
|
||||
points << QPointF(arrivee.x(), ligne_inter_y);
|
||||
} else if ((ori_depart == QET::East && (ori_arrivee == QET::West || ori_arrivee == QET::North)) || (ori_depart == QET::South && ori_arrivee == QET::North)) {
|
||||
// cas "4"
|
||||
// cas « 4 »
|
||||
int ligne_inter_x = qRound(depart.x() + arrivee.x()) / 2;
|
||||
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
|
||||
points << QPointF(ligne_inter_x, depart.y());
|
||||
points << QPointF(ligne_inter_x, arrivee.y());
|
||||
} else if ((ori_depart == QET::West || ori_depart == QET::North) && (ori_arrivee == QET::West || ori_arrivee == QET::North)) {
|
||||
points << QPointF(depart.x(), arrivee.y()); // cas "2"
|
||||
points << QPointF(depart.x(), arrivee.y()); // cas « 2 »
|
||||
} else {
|
||||
points << QPointF(arrivee.x(), depart.y()); // cas "1"
|
||||
points << QPointF(arrivee.x(), depart.y()); // cas « 1 »
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,13 +450,6 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
|
||||
qp -> setPen(tmp);
|
||||
}
|
||||
|
||||
// utilisation d'un trait "cosmetique" en-dessous d'un certain zoom
|
||||
if (options && options -> levelOfDetail < 1.0) {
|
||||
QPen tmp = qp -> pen();
|
||||
tmp.setCosmetic(true);
|
||||
qp -> setPen(tmp);
|
||||
}
|
||||
|
||||
// dessin du conducteur
|
||||
qp -> drawPath(path());
|
||||
if (properties_.type == ConductorProperties::Single) {
|
||||
@@ -595,9 +577,6 @@ void Conductor::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
||||
}
|
||||
}
|
||||
QGraphicsPathItem::mousePressEvent(e);
|
||||
if (e -> modifiers() & Qt::ControlModifier) {
|
||||
setSelected(!isSelected());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -664,9 +643,7 @@ void Conductor::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
||||
has_to_save_profile = false;
|
||||
}
|
||||
setZValue(previous_z_value);
|
||||
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
||||
QGraphicsPathItem::mouseReleaseEvent(e);
|
||||
}
|
||||
QGraphicsPathItem::mouseReleaseEvent(e);
|
||||
calculateTextItemPosition();
|
||||
}
|
||||
|
||||
@@ -943,13 +920,13 @@ QDomElement Conductor::toXml(QDomDocument &d, QHash<Terminal *, int> &table_adr_
|
||||
foreach(ConductorSegment *segment, segmentsList()) {
|
||||
current_segment = d.createElement("segment");
|
||||
current_segment.setAttribute("orientation", segment -> isHorizontal() ? "horizontal" : "vertical");
|
||||
current_segment.setAttribute("length", QString("%1").arg(segment -> length()));
|
||||
current_segment.setAttribute("length", segment -> length());
|
||||
e.appendChild(current_segment);
|
||||
}
|
||||
}
|
||||
|
||||
// exporte la "configuration" du conducteur
|
||||
properties_.toXml(e);
|
||||
properties_.toXml(d, e);
|
||||
return(e);
|
||||
}
|
||||
|
||||
@@ -1103,25 +1080,6 @@ void Conductor::readProperties() {
|
||||
text_item -> setVisible(properties_.type == ConductorProperties::Multi);
|
||||
}
|
||||
|
||||
/**
|
||||
Met a jour les proprietes du conducteur apres modification du champ de texte affiche
|
||||
*/
|
||||
void Conductor::displayedTextChanged() {
|
||||
// verifie que le texte a reellement change
|
||||
if (text_item -> toPlainText() == properties_.text) return;
|
||||
|
||||
// initialise l'objet UndoCommand correspondant
|
||||
if (Diagram *my_diagram = diagram()) {
|
||||
ConductorProperties new_properties(properties_);
|
||||
new_properties.text = text_item -> toPlainText();
|
||||
|
||||
ChangeConductorPropertiesCommand *ccpc = new ChangeConductorPropertiesCommand(this);
|
||||
ccpc -> setOldSettings(properties_);
|
||||
ccpc -> setNewSettings(new_properties);
|
||||
my_diagram -> undoStack().push(ccpc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@return les conducteurs avec lesquels ce conducteur partage des bornes
|
||||
communes
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -21,17 +21,15 @@
|
||||
#include "terminal.h"
|
||||
#include "conductorprofile.h"
|
||||
#include "conductorproperties.h"
|
||||
#include "diagramtextitem.h"
|
||||
class ConductorSegment;
|
||||
class DiagramTextItem;
|
||||
class Element;
|
||||
typedef QPair<QPointF, Qt::Corner> ConductorBend;
|
||||
typedef QHash<Qt::Corner, ConductorProfile> ConductorProfilesGroup;
|
||||
/**
|
||||
Cette classe represente un conducteur. Un conducteur relie deux bornes d'element.
|
||||
*/
|
||||
class Conductor : public QObject, public QGraphicsPathItem {
|
||||
|
||||
Q_OBJECT
|
||||
class Conductor : public QGraphicsPathItem {
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
@@ -83,9 +81,6 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
||||
ConductorProfilesGroup profiles() const;
|
||||
void readProperties();
|
||||
|
||||
public slots:
|
||||
void displayedTextChanged();
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -159,18 +159,19 @@ void SingleLineProperties::drawNeutral(QPainter *painter, QET::ConductorSegmentT
|
||||
}
|
||||
|
||||
/**
|
||||
Exporte les parametres du conducteur unifilaire sous formes d'attributs XML
|
||||
exporte les parametres du conducteur unifilaire sous formes d'attributs XML
|
||||
ajoutes a l'element e.
|
||||
@param d Document XML ; utilise pour ajouter (potentiellement) des elements XML
|
||||
@param e Element XML auquel seront ajoutes des attributs
|
||||
*/
|
||||
void SingleLineProperties::toXml(QDomElement &e) const {
|
||||
void SingleLineProperties::toXml(QDomDocument &, QDomElement &e) const {
|
||||
e.setAttribute("ground", hasGround ? "true" : "false");
|
||||
e.setAttribute("neutral", hasNeutral ? "true" : "false");
|
||||
e.setAttribute("phase", phases);
|
||||
}
|
||||
|
||||
/**
|
||||
Importe les parametres du conducteur unifilaire a partir des attributs XML
|
||||
importe les parametres du conducteur unifilaire a partir des attributs XML
|
||||
de l'element e
|
||||
@param e Element XML dont les attributs seront lus
|
||||
*/
|
||||
@@ -181,21 +182,22 @@ void SingleLineProperties::fromXml(QDomElement &e) {
|
||||
}
|
||||
|
||||
/**
|
||||
Exporte les parametres du conducteur sous formes d'attributs XML
|
||||
exporte les parametres du conducteur sous formes d'attributs XML
|
||||
ajoutes a l'element e.
|
||||
@param d Document XML ; utilise pour ajouter (potentiellement) des elements XML
|
||||
@param e Element XML auquel seront ajoutes des attributs
|
||||
*/
|
||||
void ConductorProperties::toXml(QDomElement &e) const {
|
||||
void ConductorProperties::toXml(QDomDocument &d, QDomElement &e) const {
|
||||
e.setAttribute("type", typeToString(type));
|
||||
if (type == Single) {
|
||||
singleLineProperties.toXml(e);
|
||||
singleLineProperties.toXml(d, e);
|
||||
} else if (type == Multi) {
|
||||
e.setAttribute("num", text);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Importe les parametres du conducteur unifilaire a partir des attributs XML
|
||||
importe les parametres du conducteur unifilaire a partir des attributs XML
|
||||
de l'element e
|
||||
@param e Element XML dont les attributs seront lus
|
||||
*/
|
||||
@@ -215,7 +217,7 @@ void ConductorProperties::fromXml(QDomElement &e) {
|
||||
|
||||
/**
|
||||
@param settings Parametres a ecrire
|
||||
@param prefix prefixe a ajouter devant les noms des parametres
|
||||
@param prefix prefix a ajouter devant les noms des parametres
|
||||
*/
|
||||
void ConductorProperties::toSettings(QSettings &settings, const QString &prefix) const {
|
||||
settings.setValue(prefix + "type", typeToString(type));
|
||||
@@ -225,7 +227,7 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix)
|
||||
|
||||
/**
|
||||
@param settings Parametres a lire
|
||||
@param prefix prefixe a ajouter devant les noms des parametres
|
||||
@param prefix prefix a ajouter devant les noms des parametres
|
||||
*/
|
||||
void ConductorProperties::fromSettings(QSettings &settings, const QString &prefix) {
|
||||
QString setting_type = settings.value(prefix + "type", typeToString(Multi)).toString();
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -31,7 +31,7 @@ class SingleLineProperties {
|
||||
void setPhasesCount(int);
|
||||
unsigned short int phasesCount();
|
||||
void draw(QPainter *, QET::ConductorSegmentType, const QRectF &);
|
||||
void toXml(QDomElement &) const;
|
||||
void toXml(QDomDocument &, QDomElement &) const;
|
||||
void fromXml(QDomElement &);
|
||||
void toSettings(QSettings &, const QString & = QString()) const;
|
||||
void fromSettings(QSettings &, const QString & = QString());
|
||||
@@ -87,7 +87,7 @@ class ConductorProperties {
|
||||
SingleLineProperties singleLineProperties;
|
||||
|
||||
// methodes
|
||||
void toXml(QDomElement &) const;
|
||||
void toXml(QDomDocument &, QDomElement &) const;
|
||||
void fromXml(QDomElement &);
|
||||
void toSettings(QSettings &, const QString & = QString()) const;
|
||||
void fromSettings(QSettings &, const QString & = QString());
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -16,7 +16,6 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "conductorpropertieswidget.h"
|
||||
#include <QtGui>
|
||||
#include "conductor.h"
|
||||
|
||||
/**
|
||||
@@ -47,7 +46,6 @@ void ConductorPropertiesWidget::buildInterface() {
|
||||
setMinimumSize(380, 280);
|
||||
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout -> setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QGroupBox *groupbox = new QGroupBox(tr("Type de conducteur"));
|
||||
main_layout -> addWidget(groupbox);
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -17,8 +17,8 @@
|
||||
*/
|
||||
#ifndef CONDUCTOR_PROPERTIES_WIDGET_H
|
||||
#define CONDUCTOR_PROPERTIES_WIDGET_H
|
||||
#include "conductorproperties.h"
|
||||
#include <QWidget>
|
||||
#include "conductor.h"
|
||||
#include <QtGui>
|
||||
/**
|
||||
Ce widget permet a l utilisateur d'editer les proprietes d'un conducteur.
|
||||
Par proprietes, on entend non pas le trajet effectue par le conducteur mais
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -24,12 +24,12 @@
|
||||
*/
|
||||
ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
|
||||
|
||||
setWindowTitle(tr("Configurer QElectroTech", "window title"));
|
||||
setWindowTitle(tr("Configurer QElectroTech"));
|
||||
|
||||
// liste des pages
|
||||
pages_list = new QListWidget();
|
||||
pages_list -> setViewMode(QListView::IconMode);
|
||||
pages_list -> setIconSize(QSize(110, 110));
|
||||
pages_list -> setIconSize(QSize(48, 48));
|
||||
pages_list -> setMovement(QListView::Static);
|
||||
pages_list -> setMinimumWidth(135);
|
||||
pages_list -> setMaximumWidth(135);
|
||||
@@ -37,7 +37,6 @@ ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
|
||||
|
||||
// pages
|
||||
pages_widget = new QStackedWidget();
|
||||
addPage(new GeneralConfigurationPage());
|
||||
addPage(new NewDiagramPage());
|
||||
buildPagesList();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
136
configpages.cpp
Normal file
136
configpages.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
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/>.
|
||||
*/
|
||||
#include "configpages.h"
|
||||
#include "qetapp.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param parent QWidget parent
|
||||
*/
|
||||
NewDiagramPage::NewDiagramPage(QWidget *parent) : ConfigPage(parent) {
|
||||
|
||||
// acces a la configuration de QElectroTech
|
||||
QSettings &settings = QETApp::settings();
|
||||
|
||||
// recupere les dimensions du schema
|
||||
int columns_count_value = settings.value("diagrameditor/defaultcols", 15).toInt();
|
||||
int columns_width_value = qRound(settings.value("diagrameditor/defaultcolsize", 50.0).toDouble());
|
||||
int columns_height_value = qRound(settings.value("diagrameditor/defaultheight", 500.0).toDouble());
|
||||
|
||||
QVBoxLayout *vlayout1 = new QVBoxLayout();
|
||||
|
||||
QLabel *title = new QLabel(tr("Nouveau sch\351ma"));
|
||||
vlayout1 -> addWidget(title);
|
||||
|
||||
QFrame *horiz_line = new QFrame();
|
||||
horiz_line -> setFrameShape(QFrame::HLine);
|
||||
vlayout1 -> addWidget(horiz_line);
|
||||
|
||||
QHBoxLayout *hlayout1 = new QHBoxLayout();
|
||||
QVBoxLayout *vlayout2 = new QVBoxLayout();
|
||||
|
||||
QGroupBox *diagram_size_box = new QGroupBox(tr("Dimensions du sch\351ma"));
|
||||
diagram_size_box -> setMinimumWidth(300);
|
||||
QGridLayout *diagram_size_box_layout = new QGridLayout(diagram_size_box);
|
||||
|
||||
QLabel *ds1 = new QLabel(tr("Colonnes :"));
|
||||
|
||||
columns_count = new QSpinBox(diagram_size_box);
|
||||
columns_count -> setMinimum(3); /// @todo methode statique pour recuperer ca
|
||||
columns_count -> setValue(columns_count_value);
|
||||
|
||||
columns_width = new QSpinBox(diagram_size_box);
|
||||
columns_width -> setMinimum(1);
|
||||
columns_width -> setSingleStep(10);
|
||||
columns_width -> setValue(columns_width_value);
|
||||
columns_width -> setPrefix(tr("\327"));
|
||||
columns_width -> setSuffix(tr("px"));
|
||||
|
||||
QLabel *ds2 = new QLabel(tr("Hauteur :"));
|
||||
|
||||
columns_height = new QSpinBox(diagram_size_box);
|
||||
columns_height -> setRange(80, 10000); /// @todo methode statique pour recuperer ca
|
||||
columns_height -> setSingleStep(80);
|
||||
columns_height -> setValue(columns_height_value);
|
||||
|
||||
diagram_size_box_layout -> addWidget(ds1, 0, 0);
|
||||
diagram_size_box_layout -> addWidget(columns_count, 0, 1);
|
||||
diagram_size_box_layout -> addWidget(columns_width, 0, 2);
|
||||
diagram_size_box_layout -> addWidget(ds2, 1, 0);
|
||||
diagram_size_box_layout -> addWidget(columns_height, 1, 1);
|
||||
|
||||
ipw = new InsetPropertiesWidget(QETDiagramEditor::defaultInsetProperties(), true, this);
|
||||
|
||||
// proprietes par defaut des conducteurs
|
||||
ConductorProperties cp;
|
||||
cp.fromSettings(settings, "diagrameditor/defaultconductor");
|
||||
cpw = new ConductorPropertiesWidget(cp);
|
||||
|
||||
vlayout2 -> addWidget(diagram_size_box);
|
||||
vlayout2 -> addWidget(ipw);
|
||||
hlayout1 -> addLayout(vlayout2);
|
||||
hlayout1 -> addWidget(cpw);
|
||||
vlayout1 -> addLayout(hlayout1);
|
||||
vlayout1 -> addStretch(1);
|
||||
hlayout1 -> setAlignment(cpw, Qt::AlignTop);
|
||||
setLayout(vlayout1);
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
NewDiagramPage::~NewDiagramPage() {
|
||||
}
|
||||
|
||||
/**
|
||||
Applique la configuration de cette page
|
||||
*/
|
||||
void NewDiagramPage::applyConf() {
|
||||
QSettings &settings = QETApp::settings();
|
||||
|
||||
// dimensions des nouveaux schemas
|
||||
settings.setValue("diagrameditor/defaultcols", columns_count -> value());
|
||||
settings.setValue("diagrameditor/defaultcolsize", columns_width -> value());
|
||||
settings.setValue("diagrameditor/defaultheight", columns_height -> value());
|
||||
|
||||
// proprietes du cartouche
|
||||
InsetProperties inset = ipw-> insetProperties();
|
||||
settings.setValue("diagrameditor/defaulttitle", inset.title);
|
||||
settings.setValue("diagrameditor/defaultauthor", inset.author);
|
||||
settings.setValue("diagrameditor/defaultfilename", inset.filename);
|
||||
settings.setValue("diagrameditor/defaultfolio", inset.folio);
|
||||
QString date_setting_value;
|
||||
if (inset.useDate == InsetProperties::UseDateValue) {
|
||||
if (inset.date.isNull()) date_setting_value = "null";
|
||||
else date_setting_value = inset.date.toString("yyyyMMdd");
|
||||
} else {
|
||||
date_setting_value = "now";
|
||||
}
|
||||
settings.setValue("diagrameditor/defaultdate", date_setting_value);
|
||||
|
||||
// proprietes par defaut des conducteurs
|
||||
cpw -> conductorProperties().toSettings(settings, "diagrameditor/defaultconductor");
|
||||
}
|
||||
|
||||
/// @return l'icone de cette page
|
||||
QIcon NewDiagramPage::icon() const {
|
||||
return(QIcon(":/ico/conf_new_diagram.png"));
|
||||
}
|
||||
|
||||
/// @return le titre de cette page
|
||||
QString NewDiagramPage::title() const {
|
||||
return(tr("Nouveau sch\351ma"));
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -18,9 +18,9 @@
|
||||
#ifndef CONFIG_PAGES_H
|
||||
#define CONFIG_PAGES_H
|
||||
#include <QtGui>
|
||||
class BorderPropertiesWidget;
|
||||
class ConductorPropertiesWidget;
|
||||
class InsetPropertiesWidget;
|
||||
#include "conductorpropertieswidget.h"
|
||||
#include "insetpropertieswidget.h"
|
||||
|
||||
/**
|
||||
Cette classe abstraite contient les methodes que toutes les pages de
|
||||
configuration doivent implementer.
|
||||
@@ -63,38 +63,10 @@ class NewDiagramPage : public ConfigPage {
|
||||
|
||||
// attributs
|
||||
public:
|
||||
BorderPropertiesWidget *bpw; ///< Widget d'edition des dimensions du schema
|
||||
QSpinBox *columns_count; ///< Widget d'edition du nombre par defaut de colonnes
|
||||
QSpinBox *columns_width; ///< Widget d'edition de la largeur par defaut des colonnes
|
||||
QSpinBox *columns_height; ///< Widget d'edition de la hauteur par defaut des colonnes
|
||||
InsetPropertiesWidget *ipw; ///< Widget d'edition des proprietes par defaut du cartouche
|
||||
ConductorPropertiesWidget *cpw; ///< Widget d'edition des proprietes par defaut des conducteurs
|
||||
};
|
||||
|
||||
/**
|
||||
Cette classe represente la page de configuration generale.
|
||||
*/
|
||||
class GeneralConfigurationPage : public ConfigPage {
|
||||
Q_OBJECT
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
GeneralConfigurationPage(QWidget * = 0);
|
||||
virtual ~GeneralConfigurationPage();
|
||||
private:
|
||||
GeneralConfigurationPage(const GeneralConfigurationPage &);
|
||||
|
||||
// methodes
|
||||
public:
|
||||
void applyConf();
|
||||
QString title() const;
|
||||
QIcon icon() const;
|
||||
|
||||
// attributs
|
||||
public:
|
||||
QLabel *title_label_;
|
||||
QFrame *horiz_line_;
|
||||
QGroupBox *projects_view_mode_;
|
||||
QRadioButton *windowed_mode_;
|
||||
QRadioButton *tabbed_mode_;
|
||||
QLabel *warning_view_mode_;
|
||||
QGroupBox *elements_management_;
|
||||
QCheckBox *integrate_elements_;
|
||||
};
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -19,151 +19,119 @@
|
||||
#include "elementtextitem.h"
|
||||
#include "diagram.h"
|
||||
#include "qetapp.h"
|
||||
#include "partline.h"
|
||||
#include "elementdefinition.h"
|
||||
#include <iostream>
|
||||
|
||||
/**
|
||||
Constructeur de la classe CustomElement. Permet d'instancier un element
|
||||
utilisable comme un element fixe a la difference que l'element perso est
|
||||
construit a partir d'une description au format XML. Celle-ci est recuperee
|
||||
a l'emplacement indique.
|
||||
@param location Emplacement de la definition d'element a utiliser
|
||||
Constructeur de la classe ElementPerso. Permet d'instancier un element
|
||||
utilisable comme un element fixe a la difference que l'element perso lit
|
||||
sa description (noms, dessin, comportement) dans un fichier XML a fournir
|
||||
en parametre.
|
||||
@param nom_fichier Le chemin du fichier XML decrivant l'element
|
||||
@param qgi Le QGraphicsItem parent de cet element
|
||||
@param s Le Schema affichant cet element
|
||||
@param state Un pointeur facultatif vers un entier. La valeur de cet entier
|
||||
@param etat Un pointeur facultatif vers un entier. La valeur de cet entier
|
||||
sera changee de maniere a refleter le deroulement de l'instanciation :
|
||||
- 0 : L'instanciation a reussi
|
||||
- 1 : l'emplacement n'a pas permis d'acceder a une definition d'element
|
||||
- 2 : la definition n'etait pas lisible
|
||||
- 3 : la definition n'etait pas valide / exploitable / utilisable
|
||||
- 4 : Le document XML n'est pas un element "definition"
|
||||
- 1 : Le fichier n'existe pas
|
||||
- 2 : Le fichier n'a pu etre ouvert
|
||||
- 3 : Le fichier n'est pas un document XML
|
||||
- 4 : Le document XML n'a pas une "definition" comme racine
|
||||
- 5 : Les attributs de la definition ne sont pas presents et / ou valides
|
||||
- 6 : La definition est vide
|
||||
- 7 : L'analyse d'un element XML decrivant une partie du dessin de l'element a echoue
|
||||
- 8 : Aucune partie du dessin n'a pu etre chargee
|
||||
*/
|
||||
CustomElement::CustomElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
|
||||
FixedElement(qgi, s),
|
||||
elmt_state(-1),
|
||||
location_(location),
|
||||
forbid_antialiasing(false)
|
||||
{
|
||||
// recupere la definition de l'element
|
||||
ElementsCollectionItem *element_item = QETApp::collectionItem(location);
|
||||
ElementDefinition *element_definition;
|
||||
if (
|
||||
!element_item ||\
|
||||
!element_item -> isElement() ||\
|
||||
!(element_definition = qobject_cast<ElementDefinition *>(element_item))
|
||||
) {
|
||||
if (state) *state = 1;
|
||||
elmt_state = 1;
|
||||
CustomElement::CustomElement(QString &nom_fichier, QGraphicsItem *qgi, Diagram *s, int *etat) : FixedElement(qgi, s) {
|
||||
nomfichier = nom_fichier;
|
||||
// pessimisme inside : par defaut, ca foire
|
||||
elmt_etat = -1;
|
||||
|
||||
// le fichier doit exister
|
||||
QFileInfo infos_file(nomfichier);
|
||||
if (!infos_file.exists() || !infos_file.isFile()) {
|
||||
if (etat != NULL) *etat = 1;
|
||||
elmt_etat = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!element_definition -> isReadable()) {
|
||||
if (state) *state = 2;
|
||||
elmt_state = 2;
|
||||
// le fichier doit etre lisible
|
||||
QFile fichier(nomfichier);
|
||||
if (!fichier.open(QIODevice::ReadOnly)) {
|
||||
if (etat != NULL) *etat = 2;
|
||||
elmt_etat = 2;
|
||||
return;
|
||||
}
|
||||
|
||||
if (element_definition -> isNull()) {
|
||||
if (state) *state = 3;
|
||||
elmt_state = 3;
|
||||
// le fichier doit etre un document XML
|
||||
QDomDocument document_xml;
|
||||
if (!document_xml.setContent(&fichier)) {
|
||||
if (etat != NULL) *etat = 3;
|
||||
elmt_etat = 3;
|
||||
return;
|
||||
}
|
||||
|
||||
buildFromXml(element_definition -> xml(), &elmt_state);
|
||||
if (state) *state = elmt_state;
|
||||
if (elmt_state) return;
|
||||
|
||||
if (state) *state = 0;
|
||||
elmt_state = 0;
|
||||
}
|
||||
|
||||
CustomElement::CustomElement(const QDomElement &xml_def_elmt, QGraphicsItem *qgi, Diagram *s, int *state) : FixedElement(qgi, s) {
|
||||
int elmt_state = -1;
|
||||
buildFromXml(xml_def_elmt, &elmt_state);
|
||||
if (state) *state = elmt_state;
|
||||
}
|
||||
|
||||
/**
|
||||
Construit l'element personnalise a partir d'un element XML representant sa
|
||||
definition.
|
||||
@param xml_def_elmt
|
||||
@param state Un pointeur facultatif vers un entier. La valeur de cet entier
|
||||
sera changee de maniere a refleter le deroulement de l'instanciation :
|
||||
- 0 : La construction s'est bien passee
|
||||
- 4 : Le document XML n'est pas un element "definition"
|
||||
- 5 : Les attributs de la definition ne sont pas presents et / ou valides
|
||||
- 6 : La definition est vide
|
||||
- 7 : L'analyse d'un element XML decrivant une partie du dessin de l'element a echoue
|
||||
- 8 : Aucune partie du dessin n'a pu etre chargee
|
||||
@return true si le chargement a reussi, false sinon
|
||||
*/
|
||||
bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) {
|
||||
|
||||
if (xml_def_elmt.tagName() != "definition" || xml_def_elmt.attribute("type") != "element") {
|
||||
if (state) *state = 4;
|
||||
return(false);
|
||||
// la racine est supposee etre une definition d'element
|
||||
QDomElement racine = document_xml.documentElement();
|
||||
if (racine.tagName() != "definition" || racine.attribute("type") != "element") {
|
||||
if (etat != NULL) *etat = 4;
|
||||
elmt_etat = 4;
|
||||
return;
|
||||
}
|
||||
|
||||
// verifie basiquement que la version actuelle est capable de lire ce fichier
|
||||
if (xml_def_elmt.hasAttribute("version")) {
|
||||
if (racine.hasAttribute("version")) {
|
||||
bool conv_ok;
|
||||
qreal element_version = xml_def_elmt.attribute("version").toDouble(&conv_ok);
|
||||
qreal element_version = racine.attribute("version").toDouble(&conv_ok);
|
||||
if (conv_ok && QET::version.toDouble() < element_version) {
|
||||
std::cerr << qPrintable(
|
||||
QObject::tr("Avertissement : l'\351l\351ment "
|
||||
" a \351t\351 enregistr\351 avec une version"
|
||||
QObject::tr("Avertissement : l'\351l\351ment ") + nom_fichier
|
||||
+ QObject::tr(" a \351t\351 enregistr\351 avec une version"
|
||||
" ult\351rieure de QElectroTech.")
|
||||
) << std::endl;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ces attributs doivent etre presents et valides
|
||||
int w, h, hot_x, hot_y;
|
||||
if (
|
||||
!QET::attributeIsAnInteger(xml_def_elmt, QString("width"), &w) ||\
|
||||
!QET::attributeIsAnInteger(xml_def_elmt, QString("height"), &h) ||\
|
||||
!QET::attributeIsAnInteger(xml_def_elmt, QString("hotspot_x"), &hot_x) ||\
|
||||
!QET::attributeIsAnInteger(xml_def_elmt, QString("hotspot_y"), &hot_y) ||\
|
||||
!validOrientationAttribute(xml_def_elmt)
|
||||
!QET::attributeIsAnInteger(racine, QString("width"), &w) ||\
|
||||
!QET::attributeIsAnInteger(racine, QString("height"), &h) ||\
|
||||
!QET::attributeIsAnInteger(racine, QString("hotspot_x"), &hot_x) ||\
|
||||
!QET::attributeIsAnInteger(racine, QString("hotspot_y"), &hot_y) ||\
|
||||
!validOrientationAttribute(racine)
|
||||
) {
|
||||
if (state) *state = 5;
|
||||
return(false);
|
||||
if (etat != NULL) *etat = 5;
|
||||
elmt_etat = 5;
|
||||
return;
|
||||
}
|
||||
|
||||
// on peut d'ores et deja specifier la taille et le hotspot
|
||||
setSize(w, h);
|
||||
setHotspot(QPoint(hot_x, hot_y));
|
||||
setInternalConnections(xml_def_elmt.attribute("ic") == "true");
|
||||
setInternalConnections(racine.attribute("ic") == "true");
|
||||
|
||||
// la definition est supposee avoir des enfants
|
||||
if (xml_def_elmt.firstChild().isNull()) {
|
||||
if (state) *state = 6;
|
||||
return(false);
|
||||
if (racine.firstChild().isNull()) {
|
||||
if (etat != NULL) *etat = 6;
|
||||
elmt_etat = 6;
|
||||
return;
|
||||
}
|
||||
|
||||
// initialisation du QPainter (pour dessiner l'element)
|
||||
QPainter qp;
|
||||
qp.begin(&drawing);
|
||||
|
||||
QPainter low_zoom_qp;
|
||||
low_zoom_qp.begin(&low_zoom_drawing);
|
||||
QPen tmp;
|
||||
tmp.setWidthF(1.0); // ligne vaudou pour prise en compte du setCosmetic - ne pas enlever
|
||||
tmp.setCosmetic(true);
|
||||
low_zoom_qp.setPen(tmp);
|
||||
qp.begin(&dessin);
|
||||
QPen t;
|
||||
t.setColor(Qt::black);
|
||||
t.setWidthF(1.0);
|
||||
t.setJoinStyle(Qt::MiterJoin);
|
||||
qp.setPen(t);
|
||||
|
||||
// extrait les noms de la definition XML
|
||||
names.fromXml(xml_def_elmt);
|
||||
setToolTip(name());
|
||||
names.fromXml(racine);
|
||||
setToolTip(nom());
|
||||
|
||||
// parcours des enfants de la definition : parties du dessin
|
||||
int parsed_elements_count = 0;
|
||||
for (QDomNode node = xml_def_elmt.firstChild() ; !node.isNull() ; node = node.nextSibling()) {
|
||||
int nb_elements_parses = 0;
|
||||
for (QDomNode node = racine.firstChild() ; !node.isNull() ; node = node.nextSibling()) {
|
||||
QDomElement elmts = node.toElement();
|
||||
if (elmts.isNull()) continue;
|
||||
if (elmts.tagName() == "description") {
|
||||
@@ -172,17 +140,11 @@ bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) {
|
||||
for (QDomNode n = node.firstChild() ; !n.isNull() ; n = n.nextSibling()) {
|
||||
QDomElement qde = n.toElement();
|
||||
if (qde.isNull()) continue;
|
||||
if (parseElement(qde, qp)) {
|
||||
++ parsed_elements_count;
|
||||
QString current_tag = qde.tagName();
|
||||
if (current_tag != "terminal" && current_tag != "input") {
|
||||
forbid_antialiasing = true;
|
||||
parseElement(qde, low_zoom_qp);
|
||||
forbid_antialiasing = false;
|
||||
}
|
||||
} else {
|
||||
if (state) *state = 7;
|
||||
return(false);
|
||||
if (parseElement(qde, qp)) ++ nb_elements_parses;
|
||||
else {
|
||||
if (etat != NULL) *etat = 7;
|
||||
elmt_etat = 7;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -190,16 +152,19 @@ bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) {
|
||||
|
||||
// fin du dessin
|
||||
qp.end();
|
||||
low_zoom_qp.end();
|
||||
|
||||
// il doit y avoir au moins un element charge
|
||||
if (!parsed_elements_count) {
|
||||
if (state) *state = 8;
|
||||
return(false);
|
||||
} else {
|
||||
if (state) *state = 0;
|
||||
return(true);
|
||||
if (!nb_elements_parses) {
|
||||
if (etat != NULL) *etat = 8;
|
||||
elmt_etat = 8;
|
||||
return;
|
||||
}
|
||||
|
||||
// fermeture du fichier
|
||||
fichier.close();
|
||||
|
||||
if (etat != NULL) *etat = 0;
|
||||
elmt_etat = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,15 +185,10 @@ QList<Conductor *> CustomElement::conductors() const {
|
||||
return(conductors);
|
||||
}
|
||||
|
||||
/// @return la liste des textes de cet element
|
||||
QList<ElementTextItem *> CustomElement::texts() const {
|
||||
return(list_texts_);
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le nombre de bornes que l'element possede
|
||||
*/
|
||||
int CustomElement::terminalsCount() const {
|
||||
int CustomElement::nbTerminals() const {
|
||||
return(list_terminals.size());
|
||||
}
|
||||
|
||||
@@ -237,12 +197,8 @@ int CustomElement::terminalsCount() const {
|
||||
@param qp Le QPainter a utiliser pour dessiner l'element
|
||||
@param options Les options graphiques
|
||||
*/
|
||||
void CustomElement::paint(QPainter *qp, const QStyleOptionGraphicsItem *options) {
|
||||
if (options && options -> levelOfDetail < 1.0) {
|
||||
low_zoom_drawing.play(qp);
|
||||
} else {
|
||||
drawing.play(qp);
|
||||
}
|
||||
void CustomElement::paint(QPainter *qp, const QStyleOptionGraphicsItem *) {
|
||||
dessin.play(qp);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,7 +217,6 @@ void CustomElement::paint(QPainter *qp, const QStyleOptionGraphicsItem *options)
|
||||
bool CustomElement::parseElement(QDomElement &e, QPainter &qp) {
|
||||
if (e.tagName() == "terminal") return(parseTerminal(e));
|
||||
else if (e.tagName() == "line") return(parseLine(e, qp));
|
||||
else if (e.tagName() == "rect") return(parseRect(e, qp));
|
||||
else if (e.tagName() == "ellipse") return(parseEllipse(e, qp));
|
||||
else if (e.tagName() == "circle") return(parseCircle(e, qp));
|
||||
else if (e.tagName() == "arc") return(parseArc(e, qp));
|
||||
@@ -289,124 +244,9 @@ bool CustomElement::parseLine(QDomElement &e, QPainter &qp) {
|
||||
if (!QET::attributeIsAReal(e, QString("y1"), &y1)) return(false);
|
||||
if (!QET::attributeIsAReal(e, QString("x2"), &x2)) return(false);
|
||||
if (!QET::attributeIsAReal(e, QString("y2"), &y2)) return(false);
|
||||
|
||||
QET::EndType first_end = QET::endTypeFromString(e.attribute("end1"));
|
||||
QET::EndType second_end = QET::endTypeFromString(e.attribute("end2"));
|
||||
qreal length1, length2;
|
||||
if (!QET::attributeIsAReal(e, QString("length1"), &length1)) length1 = 1.5;
|
||||
if (!QET::attributeIsAReal(e, QString("length2"), &length2)) length2 = 1.5;
|
||||
|
||||
qp.save();
|
||||
setPainterStyle(e, qp);
|
||||
QPen t = qp.pen();
|
||||
t.setJoinStyle(Qt::MiterJoin);
|
||||
qp.setPen(t);
|
||||
|
||||
QLineF line(x1, y1, x2, y2);
|
||||
QPointF point1(line.p1());
|
||||
QPointF point2(line.p2());
|
||||
|
||||
qreal line_length(line.length());
|
||||
qreal pen_width = qp.pen().widthF();
|
||||
|
||||
// determine s'il faut dessiner les extremites
|
||||
bool draw_1st_end, draw_2nd_end;
|
||||
qreal reduced_line_length = line_length - (length1 * PartLine::requiredLengthForEndType(first_end));
|
||||
draw_1st_end = first_end && reduced_line_length >= 0;
|
||||
if (draw_1st_end) {
|
||||
reduced_line_length -= (length2 * PartLine::requiredLengthForEndType(second_end));
|
||||
} else {
|
||||
reduced_line_length = line_length - (length2 * PartLine::requiredLengthForEndType(second_end));
|
||||
}
|
||||
draw_2nd_end = second_end && reduced_line_length >= 0;
|
||||
|
||||
// dessine la premiere extremite
|
||||
QPointF start_point, stop_point;
|
||||
if (draw_1st_end) {
|
||||
QList<QPointF> four_points1(PartLine::fourEndPoints(point1, point2, length1));
|
||||
if (first_end == QET::Circle) {
|
||||
qp.drawEllipse(QRectF(four_points1[0] - QPointF(length1, length1), QSizeF(length1 * 2.0, length1 * 2.0)));
|
||||
start_point = four_points1[1];
|
||||
} else if (first_end == QET::Diamond) {
|
||||
qp.drawPolygon(QPolygonF() << four_points1[1] << four_points1[2] << point1 << four_points1[3]);
|
||||
start_point = four_points1[1];
|
||||
} else if (first_end == QET::Simple) {
|
||||
qp.drawPolyline(QPolygonF() << four_points1[3] << point1 << four_points1[2]);
|
||||
start_point = point1;
|
||||
|
||||
} else if (first_end == QET::Triangle) {
|
||||
qp.drawPolygon(QPolygonF() << four_points1[0] << four_points1[2] << point1 << four_points1[3]);
|
||||
start_point = four_points1[0];
|
||||
}
|
||||
|
||||
// ajuste le depart selon l'epaisseur du trait
|
||||
if (pen_width && (first_end == QET::Simple || first_end == QET::Circle)) {
|
||||
start_point = QLineF(start_point, point2).pointAt(pen_width / 2.0 / line_length);
|
||||
}
|
||||
} else {
|
||||
start_point = point1;
|
||||
}
|
||||
|
||||
// dessine la seconde extremite
|
||||
if (draw_2nd_end) {
|
||||
QList<QPointF> four_points2(PartLine::fourEndPoints(point2, point1, length2));
|
||||
if (second_end == QET::Circle) {
|
||||
qp.drawEllipse(QRectF(four_points2[0] - QPointF(length2, length2), QSizeF(length2 * 2.0, length2 * 2.0)));
|
||||
stop_point = four_points2[1];
|
||||
} else if (second_end == QET::Diamond) {
|
||||
qp.drawPolygon(QPolygonF() << four_points2[2] << point2 << four_points2[3] << four_points2[1]);
|
||||
stop_point = four_points2[1];
|
||||
} else if (second_end == QET::Simple) {
|
||||
qp.drawPolyline(QPolygonF() << four_points2[3] << point2 << four_points2[2]);
|
||||
stop_point = point2;
|
||||
} else if (second_end == QET::Triangle) {
|
||||
qp.drawPolygon(QPolygonF() << four_points2[0] << four_points2[2] << point2 << four_points2[3] << four_points2[0]);
|
||||
stop_point = four_points2[0];
|
||||
}
|
||||
|
||||
// ajuste l'arrivee selon l'epaisseur du trait
|
||||
if (pen_width && (second_end == QET::Simple || second_end == QET::Circle)) {
|
||||
stop_point = QLineF(point1, stop_point).pointAt((line_length - (pen_width / 2.0)) / line_length);
|
||||
}
|
||||
} else {
|
||||
stop_point = point2;
|
||||
}
|
||||
|
||||
qp.drawLine(start_point, stop_point);
|
||||
|
||||
qp.restore();
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
Analyse un element XML suppose representer un rectangle. Si l'analyse
|
||||
reussit, le rectangle est ajoute au dessin.
|
||||
Le rectangle est defini par les attributs suivants :
|
||||
- x : abscisse du coin superieur gauche du rectangle
|
||||
- y : ordonnee du coin superieur gauche du rectangle
|
||||
- width : largeur du rectangle
|
||||
- height : hauteur du rectangle
|
||||
|
||||
@param e L'element XML a analyser
|
||||
@param qp Le QPainter a utiliser pour dessiner l'element perso
|
||||
@return true si l'analyse reussit, false sinon
|
||||
*/
|
||||
bool CustomElement::parseRect(QDomElement &e, QPainter &qp) {
|
||||
// verifie la presence des attributs obligatoires
|
||||
double rect_x, rect_y, rect_w, rect_h;
|
||||
if (!QET::attributeIsAReal(e, QString("x"), &rect_x)) return(false);
|
||||
if (!QET::attributeIsAReal(e, QString("y"), &rect_y)) return(false);
|
||||
if (!QET::attributeIsAReal(e, QString("width"), &rect_w)) return(false);
|
||||
if (!QET::attributeIsAReal(e, QString("height"), &rect_h)) return(false);
|
||||
qp.save();
|
||||
setPainterStyle(e, qp);
|
||||
|
||||
// force le type de jointures pour les rectangles
|
||||
QPen p = qp.pen();
|
||||
p.setJoinStyle(Qt::MiterJoin);
|
||||
qp.setPen(p);
|
||||
|
||||
qp.drawRect(QRectF(rect_x, rect_y, rect_w, rect_h));
|
||||
qp.drawLine(QLineF(x1, y1, x2, y2));
|
||||
qp.restore();
|
||||
return(true);
|
||||
}
|
||||
@@ -422,6 +262,7 @@ bool CustomElement::parseRect(QDomElement &e, QPainter &qp) {
|
||||
@param e L'element XML a analyser
|
||||
@param qp Le QPainter a utiliser pour dessiner l'element perso
|
||||
@return true si l'analyse reussit, false sinon
|
||||
@todo utiliser des attributs plus coherents : x et y = centre, rayon = vrai rayon
|
||||
*/
|
||||
bool CustomElement::parseCircle(QDomElement &e, QPainter &qp) {
|
||||
// verifie la presence des attributs obligatoires
|
||||
@@ -448,6 +289,7 @@ bool CustomElement::parseCircle(QDomElement &e, QPainter &qp) {
|
||||
@param e L'element XML a analyser
|
||||
@param qp Le QPainter a utiliser pour dessiner l'element perso
|
||||
@return true si l'analyse reussit, false sinon
|
||||
@todo utiliser des attributs plus coherents : x et y = centre
|
||||
*/
|
||||
bool CustomElement::parseEllipse(QDomElement &e, QPainter &qp) {
|
||||
// verifie la presence des attributs obligatoires
|
||||
@@ -563,26 +405,23 @@ bool CustomElement::parseText(QDomElement &e, QPainter &qp) {
|
||||
- une taille
|
||||
- le fait de subir les rotations de l'element ou non
|
||||
@param e L'element XML a analyser
|
||||
@return Un pointeur vers l'objet ElementTextItem ainsi cree si l'analyse reussit, 0 sinon
|
||||
@param s Le schema sur lequel l'element perso sera affiche
|
||||
@return true si l'analyse reussit, false sinon
|
||||
*/
|
||||
ElementTextItem *CustomElement::parseInput(QDomElement &e) {
|
||||
bool CustomElement::parseInput(QDomElement &e) {
|
||||
qreal pos_x, pos_y;
|
||||
int size;
|
||||
if (
|
||||
!QET::attributeIsAReal(e, "x", &pos_x) ||\
|
||||
!QET::attributeIsAReal(e, "y", &pos_y) ||\
|
||||
!QET::attributeIsAnInteger(e, "size", &size)
|
||||
) return(0);
|
||||
) return(false);
|
||||
|
||||
ElementTextItem *eti = new ElementTextItem(e.attribute("text"), this);
|
||||
eti -> setFont(QFont(QETApp::diagramTextsFont(), size));
|
||||
eti -> setPos(pos_x, pos_y);
|
||||
eti -> setOriginalPos(QPointF(pos_x, pos_y));
|
||||
if (e.attribute("rotate") == "true") eti -> setFollowParentRotations(true);
|
||||
|
||||
list_texts_ << eti;
|
||||
|
||||
return(eti);
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -593,23 +432,23 @@ ElementTextItem *CustomElement::parseInput(QDomElement &e) {
|
||||
- orientation : orientation de la borne = Nord (n), Sud (s), Est (e) ou Ouest (w)
|
||||
|
||||
@param e L'element XML a analyser
|
||||
@return Un pointeur vers l'objet Terminal ainsi cree, 0 sinon
|
||||
@param s Le schema sur lequel l'element perso sera affiche
|
||||
@return true si l'analyse reussit, false sinon
|
||||
*/
|
||||
Terminal *CustomElement::parseTerminal(QDomElement &e) {
|
||||
bool CustomElement::parseTerminal(QDomElement &e) {
|
||||
// verifie la presence et la validite des attributs obligatoires
|
||||
double terminalx, terminaly;
|
||||
QET::Orientation terminalo;
|
||||
if (!QET::attributeIsAReal(e, QString("x"), &terminalx)) return(0);
|
||||
if (!QET::attributeIsAReal(e, QString("y"), &terminaly)) return(0);
|
||||
if (!e.hasAttribute("orientation")) return(0);
|
||||
if (!QET::attributeIsAReal(e, QString("x"), &terminalx)) return(false);
|
||||
if (!QET::attributeIsAReal(e, QString("y"), &terminaly)) return(false);
|
||||
if (!e.hasAttribute("orientation")) return(false);
|
||||
if (e.attribute("orientation") == "n") terminalo = QET::North;
|
||||
else if (e.attribute("orientation") == "s") terminalo = QET::South;
|
||||
else if (e.attribute("orientation") == "e") terminalo = QET::East;
|
||||
else if (e.attribute("orientation") == "w") terminalo = QET::West;
|
||||
else return(0);
|
||||
Terminal *new_terminal = new Terminal(terminalx, terminaly, terminalo, this, qobject_cast<Diagram *>(scene()));
|
||||
list_terminals << new_terminal;
|
||||
return(new_terminal);
|
||||
else return(false);
|
||||
list_terminals << new Terminal(terminalx, terminaly, terminalo, this, qobject_cast<Diagram *>(scene()));
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -618,7 +457,6 @@ Terminal *CustomElement::parseTerminal(QDomElement &e) {
|
||||
@param aa Booleen a true pour activer l'antialiasing, a false pour le desactiver
|
||||
*/
|
||||
void CustomElement::setQPainterAntiAliasing(QPainter &qp, bool aa) {
|
||||
if (forbid_antialiasing) aa = false;
|
||||
qp.setRenderHint(QPainter::Antialiasing, aa);
|
||||
qp.setRenderHint(QPainter::TextAntialiasing, aa);
|
||||
qp.setRenderHint(QPainter::SmoothPixmapTransform, aa);
|
||||
@@ -643,7 +481,7 @@ void CustomElement::setQPainterAntiAliasing(QPainter &qp, bool aa) {
|
||||
@param e Element XML
|
||||
@return true si l'attribut "orientation" est valide, false sinon
|
||||
*/
|
||||
bool CustomElement::validOrientationAttribute(const QDomElement &e) {
|
||||
bool CustomElement::validOrientationAttribute(QDomElement &e) {
|
||||
return(ori.fromString(e.attribute("orientation")));
|
||||
}
|
||||
|
||||
@@ -675,7 +513,7 @@ void CustomElement::setPainterStyle(QDomElement &e, QPainter &qp) {
|
||||
QBrush brush = qp.brush();
|
||||
|
||||
// attributs par defaut
|
||||
pen.setJoinStyle(Qt::BevelJoin);
|
||||
pen.setJoinStyle(Qt::MiterJoin);
|
||||
pen.setCapStyle(Qt::SquareCap);
|
||||
pen.setColor(Qt::black);
|
||||
pen.setStyle(Qt::SolidLine);
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -15,14 +15,13 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef CUSTOM_ELEMENT_H
|
||||
#define CUSTOM_ELEMENT_H
|
||||
#ifndef ELEMENTPERSO_H
|
||||
#define ELEMENTPERSO_H
|
||||
#include "fixedelement.h"
|
||||
#include <QtGui>
|
||||
#include "nameslist.h"
|
||||
#include "elementslocation.h"
|
||||
class ElementTextItem;
|
||||
class Terminal;
|
||||
class CustomElementPart;
|
||||
|
||||
/**
|
||||
Cette classe represente un element electrique. Elle est utilisable
|
||||
comme un element fixe. La difference est que l'element perso lit
|
||||
@@ -30,73 +29,65 @@ class Terminal;
|
||||
en parametre.
|
||||
*/
|
||||
class CustomElement : public FixedElement {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
CustomElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
||||
CustomElement(const QDomElement &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
||||
CustomElement(QString &, QGraphicsItem * = 0, Diagram * = 0, int * = NULL);
|
||||
virtual ~CustomElement();
|
||||
|
||||
friend class CustomElementPart;
|
||||
|
||||
private:
|
||||
CustomElement(const CustomElement &);
|
||||
|
||||
// attributs
|
||||
protected:
|
||||
int elmt_state; // contient le code d'erreur si l'instanciation a echoue ou 0 si l'instanciation s'est bien passe
|
||||
private:
|
||||
int elmt_etat; // contient le code d'erreur si l'instanciation a echoue ou 0 si l'instanciation s'est bien passe
|
||||
NamesList names;
|
||||
ElementsLocation location_;
|
||||
QPicture drawing;
|
||||
QPicture low_zoom_drawing;
|
||||
QString nomfichier;
|
||||
QPicture dessin;
|
||||
QList<Terminal *> list_terminals;
|
||||
QList<ElementTextItem *> list_texts_;
|
||||
bool forbid_antialiasing;
|
||||
|
||||
// methodes
|
||||
public:
|
||||
virtual QList<Terminal *> terminals() const;
|
||||
virtual QList<Conductor *> conductors() const;
|
||||
virtual QList<ElementTextItem *> texts() const;
|
||||
virtual int terminalsCount() const;
|
||||
virtual int nbTerminals() const;
|
||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
QString typeId() const;
|
||||
ElementsLocation location() const;
|
||||
QString fichier() const;
|
||||
bool isNull() const;
|
||||
int state() const;
|
||||
QString name() const;
|
||||
int etat() const;
|
||||
QString nom() const;
|
||||
|
||||
protected:
|
||||
virtual bool buildFromXml(const QDomElement &, int * = 0);
|
||||
virtual bool parseElement(QDomElement &, QPainter &);
|
||||
virtual bool parseLine(QDomElement &, QPainter &);
|
||||
virtual bool parseRect(QDomElement &, QPainter &);
|
||||
virtual bool parseEllipse(QDomElement &, QPainter &);
|
||||
virtual bool parseCircle(QDomElement &, QPainter &);
|
||||
virtual bool parseArc(QDomElement &, QPainter &);
|
||||
virtual bool parsePolygon(QDomElement &, QPainter &);
|
||||
virtual bool parseText(QDomElement &, QPainter &);
|
||||
virtual ElementTextItem *parseInput(QDomElement &);
|
||||
virtual Terminal *parseTerminal(QDomElement &);
|
||||
virtual void setQPainterAntiAliasing(QPainter &, bool);
|
||||
virtual bool validOrientationAttribute(const QDomElement &);
|
||||
virtual void setPainterStyle(QDomElement &, QPainter &);
|
||||
private:
|
||||
bool parseElement(QDomElement &, QPainter &);
|
||||
bool parseLine(QDomElement &, QPainter &);
|
||||
bool parseEllipse(QDomElement &, QPainter &);
|
||||
bool parseCircle(QDomElement &, QPainter &);
|
||||
bool parseArc(QDomElement &, QPainter &);
|
||||
bool parsePolygon(QDomElement &, QPainter &);
|
||||
bool parseText(QDomElement &, QPainter &);
|
||||
bool parseInput(QDomElement &);
|
||||
bool parseTerminal(QDomElement &);
|
||||
void setQPainterAntiAliasing(QPainter &, bool);
|
||||
bool validOrientationAttribute(QDomElement &);
|
||||
void setPainterStyle(QDomElement &, QPainter &);
|
||||
};
|
||||
|
||||
/**
|
||||
@return L'ID du type de l'element ; pour un CustomElement, cela revient au
|
||||
nom du fichier
|
||||
@see location()
|
||||
@see fichier()
|
||||
*/
|
||||
inline QString CustomElement::typeId() const {
|
||||
return(location_.path());
|
||||
return(nomfichier);
|
||||
}
|
||||
|
||||
/**
|
||||
@return L'adresse du fichier contenant la description XML de cet element
|
||||
*/
|
||||
inline ElementsLocation CustomElement::location() const {
|
||||
return(location_);
|
||||
inline QString CustomElement::fichier() const {
|
||||
return(nomfichier);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +95,7 @@ inline ElementsLocation CustomElement::location() const {
|
||||
description XML a echoue
|
||||
*/
|
||||
inline bool CustomElement::isNull() const {
|
||||
return(elmt_state);
|
||||
return(elmt_etat != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,15 +110,15 @@ inline bool CustomElement::isNull() const {
|
||||
- 7 : L'analyse d'un element XML decrivant une partie du dessin de l'element a echoue
|
||||
- 8 : Aucune partie du dessin n'a pu etre chargee
|
||||
*/
|
||||
inline int CustomElement::state() const {
|
||||
return(elmt_state);
|
||||
inline int CustomElement::etat() const {
|
||||
return(elmt_etat);
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le nom de l'element
|
||||
*/
|
||||
inline QString CustomElement::name() const {
|
||||
return(names.name(location_.baseName()));
|
||||
inline QString CustomElement::nom() const {
|
||||
return(names.name(QFileInfo(nomfichier).baseName()));
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -20,9 +20,7 @@
|
||||
#include "conductor.h"
|
||||
#include "customelement.h"
|
||||
#include "diagram.h"
|
||||
#include "elementtextitem.h"
|
||||
#include "exportdialog.h"
|
||||
#include "ghostelement.h"
|
||||
#include "diagramcommands.h"
|
||||
#include "diagramcontent.h"
|
||||
|
||||
@@ -39,12 +37,9 @@ Diagram::Diagram(QObject *parent) :
|
||||
draw_grid(true),
|
||||
use_border(true),
|
||||
moved_elements_fetched(false),
|
||||
draw_terminals(true),
|
||||
project_(0),
|
||||
read_only_(false)
|
||||
qgi_manager(this),
|
||||
draw_terminals(true)
|
||||
{
|
||||
undo_stack = new QUndoStack();
|
||||
qgi_manager = new QGIManager(this);
|
||||
setBackgroundBrush(Qt::white);
|
||||
conductor_setter = new QGraphicsLineItem(0, 0);
|
||||
conductor_setter -> setZValue(1000000);
|
||||
@@ -55,30 +50,17 @@ Diagram::Diagram(QObject *parent) :
|
||||
conductor_setter -> setPen(t);
|
||||
conductor_setter -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0)));
|
||||
connect(this, SIGNAL(selectionChanged()), this, SLOT(slot_checkSelectionEmptinessChange()));
|
||||
|
||||
// lit les caracteristiques des conducteurs par defaut dans la configuration
|
||||
defaultConductorProperties.fromSettings(QETApp::settings(), "diagrameditor/defaultconductor");
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur
|
||||
*/
|
||||
Diagram::~Diagram() {
|
||||
// suppression de la liste des annulations - l'undo stack fait appel au qgimanager pour supprimer certains elements
|
||||
delete undo_stack;
|
||||
// suppression du QGIManager - tous les elements qu'il connait sont supprimes
|
||||
delete qgi_manager;
|
||||
|
||||
// recense les items supprimables
|
||||
QList<QGraphicsItem *> deletable_items;
|
||||
foreach(QGraphicsItem *qgi, items()) {
|
||||
if (qgi -> parentItem()) continue;
|
||||
if (qgraphicsitem_cast<Conductor *>(qgi)) continue;
|
||||
deletable_items << qgi;
|
||||
}
|
||||
|
||||
// suppression des items supprimables
|
||||
foreach(QGraphicsItem *qgi_d, deletable_items) {
|
||||
delete qgi_d;
|
||||
}
|
||||
// qDebug() << "Suppression du schema" << ((void*)this);
|
||||
if (conductor_setter -> scene()) removeItem(conductor_setter);
|
||||
delete conductor_setter;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,17 +109,15 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
||||
@param e QKeyEvent decrivant l'evenement clavier
|
||||
*/
|
||||
void Diagram::keyPressEvent(QKeyEvent *e) {
|
||||
if (!isReadOnly()) {
|
||||
QPointF movement;
|
||||
switch(e -> key()) {
|
||||
case Qt::Key_Left: movement = QPointF(-xGrid, 0.0); break;
|
||||
case Qt::Key_Right: movement = QPointF(+xGrid, 0.0); break;
|
||||
case Qt::Key_Up: movement = QPointF(0.0, -yGrid); break;
|
||||
case Qt::Key_Down: movement = QPointF(0.0, +yGrid); break;
|
||||
}
|
||||
if (!movement.isNull() && !focusItem()) {
|
||||
moveElements(movement);
|
||||
}
|
||||
QPointF movement;
|
||||
switch(e -> key()) {
|
||||
case Qt::Key_Left: movement = QPointF(-xGrid, 0.0); break;
|
||||
case Qt::Key_Right: movement = QPointF(+xGrid, 0.0); break;
|
||||
case Qt::Key_Up: movement = QPointF(0.0, -yGrid); break;
|
||||
case Qt::Key_Down: movement = QPointF(0.0, +yGrid); break;
|
||||
}
|
||||
if (!movement.isNull() && !focusItem()) {
|
||||
moveElements(movement);
|
||||
}
|
||||
QGraphicsScene::keyPressEvent(e);
|
||||
}
|
||||
@@ -147,18 +127,16 @@ void Diagram::keyPressEvent(QKeyEvent *e) {
|
||||
@param e QKeyEvent decrivant l'evenement clavier
|
||||
*/
|
||||
void Diagram::keyReleaseEvent(QKeyEvent *e) {
|
||||
if (!isReadOnly()) {
|
||||
// detecte le relachement d'une touche de direction ( = deplacement d'elements)
|
||||
if (
|
||||
(e -> key() == Qt::Key_Left || e -> key() == Qt::Key_Right ||\
|
||||
e -> key() == Qt::Key_Up || e -> key() == Qt::Key_Down) &&\
|
||||
!current_movement.isNull() && !e -> isAutoRepeat()
|
||||
) {
|
||||
// cree un objet d'annulation pour le mouvement qui vient de se finir
|
||||
undoStack().push(new MoveElementsCommand(this, selectedContent(), current_movement));
|
||||
invalidateMovedElements();
|
||||
current_movement = QPointF();
|
||||
}
|
||||
// detecte le relachement d'une touche de direction ( = deplacement d'elements)
|
||||
if (
|
||||
(e -> key() == Qt::Key_Left || e -> key() == Qt::Key_Right ||\
|
||||
e -> key() == Qt::Key_Up || e -> key() == Qt::Key_Down) &&\
|
||||
!current_movement.isNull() && !e -> isAutoRepeat()
|
||||
) {
|
||||
// cree un objet d'annulation pour le mouvement qui vient de se finir
|
||||
undoStack().push(new MoveElementsCommand(this, selectedContent(), current_movement));
|
||||
invalidateMovedElements();
|
||||
current_movement = QPointF();
|
||||
}
|
||||
QGraphicsScene::keyReleaseEvent(e);
|
||||
}
|
||||
@@ -233,14 +211,6 @@ QSize Diagram::imageSize() const {
|
||||
return(QSizeF(image_width, image_height).toSize());
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si le schema est considere comme vide, false sinon.
|
||||
Un schema vide ne contient ni element, ni conducteur, ni champ de texte
|
||||
*/
|
||||
bool Diagram::isEmpty() const {
|
||||
return(!items().count());
|
||||
}
|
||||
|
||||
/**
|
||||
Exporte tout ou partie du schema
|
||||
@param diagram Booleen (a vrai par defaut) indiquant si le XML genere doit
|
||||
@@ -261,18 +231,13 @@ QDomDocument Diagram::toXml(bool diagram) {
|
||||
if (!border_and_inset.title().isNull()) racine.setAttribute("title", border_and_inset.title());
|
||||
if (!border_and_inset.fileName().isNull()) racine.setAttribute("filename", border_and_inset.fileName());
|
||||
if (!border_and_inset.folio().isNull()) racine.setAttribute("folio", border_and_inset.folio());
|
||||
racine.setAttribute("cols", border_and_inset.nbColumns());
|
||||
racine.setAttribute("colsize", QString("%1").arg(border_and_inset.columnsWidth()));
|
||||
racine.setAttribute("rows", border_and_inset.nbRows());
|
||||
racine.setAttribute("rowsize", QString("%1").arg(border_and_inset.rowsHeight()));
|
||||
// attribut datant de la version 0.1 - laisse pour retrocompatibilite
|
||||
racine.setAttribute("height", QString("%1").arg(border_and_inset.diagramHeight()));
|
||||
racine.setAttribute("displaycols", border_and_inset.columnsAreDisplayed() ? "true" : "false");
|
||||
racine.setAttribute("displayrows", border_and_inset.rowsAreDisplayed() ? "true" : "false");
|
||||
racine.setAttribute("cols", border_and_inset.nbColumn());
|
||||
racine.setAttribute("colsize", border_and_inset.columnsWidth());
|
||||
racine.setAttribute("height", border_and_inset.columnsHeight());
|
||||
|
||||
// type de conducteur par defaut
|
||||
QDomElement default_conductor = document.createElement("defaultconductor");
|
||||
defaultConductorProperties.toXml(default_conductor);
|
||||
defaultConductorProperties.toXml(document, default_conductor);
|
||||
racine.appendChild(default_conductor);
|
||||
}
|
||||
document.appendChild(racine);
|
||||
@@ -285,7 +250,7 @@ QDomDocument Diagram::toXml(bool diagram) {
|
||||
QList<Conductor *> list_conductors;
|
||||
QList<DiagramTextItem *> list_texts;
|
||||
|
||||
// Determine les elements a "XMLiser"
|
||||
// Determine les elements a « XMLiser »
|
||||
foreach(QGraphicsItem *qgi, items()) {
|
||||
if (Element *elmt = qgraphicsitem_cast<Element *>(qgi)) {
|
||||
if (diagram) list_elements << elmt;
|
||||
@@ -338,38 +303,20 @@ QDomDocument Diagram::toXml(bool diagram) {
|
||||
}
|
||||
|
||||
/**
|
||||
Importe le schema decrit dans un document XML. Si une position est
|
||||
Importe le diagram decrit dans un document XML. Si une position est
|
||||
precisee, les elements importes sont positionnes de maniere a ce que le
|
||||
coin superieur gauche du plus petit rectangle pouvant les entourant tous
|
||||
(le bounding rect) soit a cette position.
|
||||
@param document Le document XML a analyser
|
||||
@param position La position du schema importe
|
||||
@param position La position du diagram importe
|
||||
@param consider_informations Si vrai, les informations complementaires
|
||||
(auteur, titre, ...) seront prises en compte
|
||||
@param content_ptr si ce pointeur vers un DiagramContent n'est pas NULL, il
|
||||
@param content_ptr si ce pointeur vers un DiagramContentn'est pas NULL, il
|
||||
sera rempli avec le contenu ajoute au schema par le fromXml
|
||||
@return true si l'import a reussi, false sinon
|
||||
*/
|
||||
bool Diagram::fromXml(QDomDocument &document, QPointF position, bool consider_informations, DiagramContent *content_ptr) {
|
||||
QDomElement root = document.documentElement();
|
||||
return(fromXml(root, position, consider_informations, content_ptr));
|
||||
}
|
||||
|
||||
/**
|
||||
Importe le schema decrit dans un element XML. Si une position est
|
||||
precisee, les elements importes sont positionnes de maniere a ce que le
|
||||
coin superieur gauche du plus petit rectangle pouvant les entourant tous
|
||||
(le bounding rect) soit a cette position.
|
||||
@param document Le document XML a analyser
|
||||
@param position La position du schema importe
|
||||
@param consider_informations Si vrai, les informations complementaires
|
||||
(auteur, titre, ...) seront prises en compte
|
||||
@param content_ptr si ce pointeur vers un DiagramContent n'est pas NULL, il
|
||||
sera rempli avec le contenu ajoute au schema par le fromXml
|
||||
@return true si l'import a reussi, false sinon
|
||||
*/
|
||||
bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_informations, DiagramContent *content_ptr) {
|
||||
QDomElement root = document;
|
||||
// le premier element doit etre un schema
|
||||
if (root.tagName() != "diagram") return(false);
|
||||
|
||||
@@ -390,24 +337,9 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
||||
double col_size = root.attribute("colsize").toDouble(&ok);
|
||||
if (ok) border_and_inset.setColumnsWidth(col_size);
|
||||
|
||||
// retrocompatibilite : les schemas enregistres avec la 0.1 ont un attribut "height"
|
||||
if (root.hasAttribute("rows") && root.hasAttribute("rowsize")) {
|
||||
// nombre de lignes
|
||||
int nb_rows = root.attribute("rows").toInt(&ok);
|
||||
if (ok) border_and_inset.setNbRows(nb_rows);
|
||||
|
||||
// taille des lignes
|
||||
double row_size = root.attribute("rowsize").toDouble(&ok);
|
||||
if (ok) border_and_inset.setRowsHeight(row_size);
|
||||
} else {
|
||||
// hauteur du schema
|
||||
double height = root.attribute("height").toDouble(&ok);
|
||||
if (ok) border_and_inset.setDiagramHeight(height);
|
||||
}
|
||||
|
||||
// affichage des lignes et colonnes
|
||||
border_and_inset.displayColumns(root.attribute("displaycols") != "false");
|
||||
border_and_inset.displayRows(root.attribute("displayrows") != "false");
|
||||
// hauteur du schema
|
||||
double height = root.attribute("height").toDouble(&ok);
|
||||
if (ok) border_and_inset.setColumnsHeight(height);
|
||||
|
||||
border_and_inset.adjustInsetToColumns();
|
||||
|
||||
@@ -422,10 +354,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
||||
}
|
||||
|
||||
// si la racine n'a pas d'enfant : le chargement est fini (schema vide)
|
||||
if (root.firstChild().isNull()) {
|
||||
write(document);
|
||||
return(true);
|
||||
}
|
||||
if (root.firstChild().isNull()) return(true);
|
||||
|
||||
// chargement de tous les elements du fichier XML
|
||||
QList<Element *> added_elements;
|
||||
@@ -435,23 +364,19 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
||||
|
||||
// cree un element dont le type correspond a l'id type
|
||||
QString type_id = e.attribute("type");
|
||||
ElementsLocation element_location = ElementsLocation(type_id);
|
||||
if (type_id.startsWith("embed://")) element_location.setProject(project_);
|
||||
|
||||
CustomElement *nvel_elmt = new CustomElement(element_location);
|
||||
QString chemin_fichier = QETApp::realPath(type_id);
|
||||
CustomElement *nvel_elmt = new CustomElement(chemin_fichier);
|
||||
if (nvel_elmt -> isNull()) {
|
||||
QString debug_message = QString("Le chargement de la description de l'element %1 a echoue avec le code d'erreur %2").arg(element_location.path()).arg(nvel_elmt -> state());
|
||||
qDebug() << debug_message;
|
||||
QString debug_message = QString("Le chargement de la description de l'element %1 a echoue avec le code d'erreur %2").arg(chemin_fichier).arg(nvel_elmt -> etat());
|
||||
delete nvel_elmt;
|
||||
|
||||
qDebug() << "Utilisation d'un GhostElement en lieu et place de cet element.";
|
||||
nvel_elmt = new GhostElement(element_location);
|
||||
qDebug(debug_message.toLatin1().data());
|
||||
continue;
|
||||
}
|
||||
|
||||
// charge les caracteristiques de l'element
|
||||
if (nvel_elmt -> fromXml(e, table_adr_id)) {
|
||||
// ajout de l'element au schema et a la liste des elements ajoutes
|
||||
addElement(nvel_elmt);
|
||||
addItem(nvel_elmt);
|
||||
added_elements << nvel_elmt;
|
||||
} else {
|
||||
delete nvel_elmt;
|
||||
@@ -464,7 +389,6 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
||||
foreach (QDomElement f, QET::findInDomElement(root, "inputs", "input")) {
|
||||
DiagramTextItem *dti = new DiagramTextItem(0, this);
|
||||
dti -> fromXml(f);
|
||||
addDiagramTextItem(dti);
|
||||
added_texts << dti;
|
||||
}
|
||||
|
||||
@@ -524,7 +448,7 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
||||
added_conductors << c;
|
||||
}
|
||||
}
|
||||
} else qDebug() << "Le chargement du conducteur" << id_p1 << id_p2 << "a echoue";
|
||||
} else qDebug() << "Le chargement du conductor" << id_p1 << id_p2 << "a echoue";
|
||||
}
|
||||
|
||||
// remplissage des listes facultatives
|
||||
@@ -534,178 +458,9 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
||||
content_ptr -> textFields = added_texts;
|
||||
}
|
||||
|
||||
write(document);
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
Enregistre le schema XML dans son document XML interne et emet le signal
|
||||
written().
|
||||
*/
|
||||
void Diagram::write() {
|
||||
qDebug() << qPrintable(QString("Diagram::write() : saving changes from diagram \"%1\" [%2]").arg(title()).arg(QET::pointerString(this)));
|
||||
write(toXml().documentElement());
|
||||
undoStack().setClean();
|
||||
}
|
||||
|
||||
/**
|
||||
Enregistre un element XML dans son document XML interne et emet le signal
|
||||
written().
|
||||
@param element xml a enregistrer
|
||||
*/
|
||||
void Diagram::write(const QDomElement &element) {
|
||||
xml_document.clear();
|
||||
xml_document.appendChild(xml_document.importNode(element, true));
|
||||
emit(written());
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si la fonction write a deja ete appele (pour etre plus exact :
|
||||
si le document XML utilise en interne n'est pas vide), false sinon
|
||||
*/
|
||||
bool Diagram::wasWritten() const {
|
||||
return(!xml_document.isNull());
|
||||
}
|
||||
|
||||
/**
|
||||
@return le schema en XML tel qu'il doit etre enregistre dans le fichier projet
|
||||
@param xml_doc document XML a utiliser pour creer l'element
|
||||
*/
|
||||
QDomElement Diagram::writeXml(QDomDocument &xml_doc) const {
|
||||
// si le schema n'a pas ete enregistre explicitement, on n'ecrit rien
|
||||
if (!wasWritten()) return(QDomElement());
|
||||
|
||||
QDomElement diagram_elmt = xml_document.documentElement();
|
||||
QDomNode new_node = xml_doc.importNode(diagram_elmt, true);
|
||||
return(new_node.toElement());
|
||||
}
|
||||
|
||||
/**
|
||||
Ajoute un element sur le schema
|
||||
@param element Element a ajouter
|
||||
*/
|
||||
void Diagram::addElement(Element *element) {
|
||||
if (!element || isReadOnly()) return;
|
||||
|
||||
// ajoute l'element au schema
|
||||
if (element -> scene() != this) {
|
||||
addItem(element);
|
||||
}
|
||||
|
||||
// surveille les modifications de ses champs de texte
|
||||
foreach(ElementTextItem *eti, element -> texts()) {
|
||||
connect(
|
||||
eti,
|
||||
SIGNAL(diagramTextChanged(DiagramTextItem *, const QString &, const QString &)),
|
||||
this,
|
||||
SLOT(diagramTextChanged(DiagramTextItem *, const QString &, const QString &))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Ajoute un conducteur sur le schema
|
||||
@param conductor Conducteur a ajouter
|
||||
*/
|
||||
void Diagram::addConductor(Conductor *conductor) {
|
||||
if (!conductor || isReadOnly()) return;
|
||||
|
||||
// ajoute le conducteur au schema
|
||||
if (conductor -> scene() != this) {
|
||||
addItem(conductor);
|
||||
conductor -> terminal1 -> addConductor(conductor);
|
||||
conductor -> terminal2 -> addConductor(conductor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Aoute un champ de texte independant sur le schema
|
||||
@param dti Champ de texte a ajouter
|
||||
*/
|
||||
void Diagram::addDiagramTextItem(DiagramTextItem *dti) {
|
||||
if (!dti || isReadOnly()) return;
|
||||
|
||||
// ajoute le champ de texte au schema
|
||||
if (dti -> scene() != this) {
|
||||
addItem(dti);
|
||||
}
|
||||
|
||||
// surveille les modifications apportees au champ de texte
|
||||
connect(
|
||||
dti,
|
||||
SIGNAL(diagramTextChanged(DiagramTextItem *, const QString &, const QString &)),
|
||||
this,
|
||||
SLOT(diagramTextChanged(DiagramTextItem *, const QString &, const QString &))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Enleve un element du schema
|
||||
@param element Element a enlever
|
||||
*/
|
||||
void Diagram::removeElement(Element *element) {
|
||||
if (!element || isReadOnly()) return;
|
||||
|
||||
// enleve l'element au schema
|
||||
removeItem(element);
|
||||
|
||||
// arrete la surveillance des modifications de ses champs de texte
|
||||
foreach(ElementTextItem *eti, element -> texts()) {
|
||||
disconnect(
|
||||
eti,
|
||||
SIGNAL(diagramTextChanged(DiagramTextItem *, const QString &, const QString &)),
|
||||
this,
|
||||
SLOT(diagramTextChanged(DiagramTextItem *, const QString &, const QString &))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Enleve un conducteur du schema
|
||||
@param conductor Conducteur a enlever
|
||||
*/
|
||||
void Diagram::removeConductor(Conductor *conductor) {
|
||||
if (!conductor || isReadOnly()) return;
|
||||
|
||||
// detache le conducteur sans le detruire
|
||||
conductor -> terminal1 -> removeConductor(conductor);
|
||||
conductor -> terminal2 -> removeConductor(conductor);
|
||||
|
||||
// enleve le conducteur du schema
|
||||
removeItem(conductor);
|
||||
}
|
||||
|
||||
/**
|
||||
Enleve un champ de texte independant du schema
|
||||
@param dti Champ de texte a enlever
|
||||
*/
|
||||
void Diagram::removeDiagramTextItem(DiagramTextItem *dti) {
|
||||
if (!dti || isReadOnly()) return;
|
||||
|
||||
// enleve le champ de texte au schema
|
||||
removeItem(dti);
|
||||
|
||||
// arrete la surveillance des modifications apportees au champ de texte
|
||||
disconnect(
|
||||
dti,
|
||||
SIGNAL(diagramTextChanged(DiagramTextItem *, const QString &, const QString &)),
|
||||
this,
|
||||
SLOT(diagramTextChanged(DiagramTextItem *, const QString &, const QString &))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Gere le fait qu'un texte du schema ait ete modifie
|
||||
@param text_item Texte modifie
|
||||
@param old_text Ancien texte
|
||||
@param new_text Nouveau texte
|
||||
*/
|
||||
void Diagram::diagramTextChanged(DiagramTextItem *text_item, const QString &old_text, const QString &new_text) {
|
||||
if (!text_item) return;
|
||||
undo_stack -> push(new ChangeDiagramTextCommand(text_item, old_text, new_text));
|
||||
}
|
||||
|
||||
/**
|
||||
Verifie si la selection est passe d'un etat ou elle est vide a un etat ou
|
||||
elle ne l'est pas, et inversement. Si c'est le cas, le signal
|
||||
@@ -734,26 +489,6 @@ QRectF Diagram::border() const {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@return le titre du cartouche
|
||||
*/
|
||||
QString Diagram::title() const {
|
||||
return(border_and_inset.title());
|
||||
}
|
||||
|
||||
/**
|
||||
@return la liste des elements de ce schema
|
||||
*/
|
||||
QList<CustomElement *> Diagram::customElements() const {
|
||||
QList<CustomElement *> elements_list;
|
||||
foreach(QGraphicsItem *qgi, items()) {
|
||||
if (CustomElement *elmt = qgraphicsitem_cast<CustomElement *>(qgi)) {
|
||||
elements_list << elmt;
|
||||
}
|
||||
}
|
||||
return(elements_list);
|
||||
}
|
||||
|
||||
/// oublie la liste des elements et conducteurs en mouvement
|
||||
void Diagram::invalidateMovedElements() {
|
||||
if (!moved_elements_fetched) return;
|
||||
@@ -835,20 +570,6 @@ void Diagram::moveElements(const QPointF &diff, QGraphicsItem *dontmove) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Permet de savoir si un element est utilise sur un schema
|
||||
@param location Emplacement d'un element
|
||||
@return true si l'element location est utilise sur ce schema, false sinon
|
||||
*/
|
||||
bool Diagram::usesElement(const ElementsLocation &location) {
|
||||
foreach(CustomElement *element, customElements()) {
|
||||
if (element -> location() == location) {
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
/**
|
||||
Definit s'il faut afficher ou non les bornes
|
||||
@param dt true pour afficher les bornes, false sinon
|
||||
@@ -881,39 +602,6 @@ bool Diagram::clipboardMayContainDiagram() {
|
||||
return(may_be_diagram);
|
||||
}
|
||||
|
||||
/**
|
||||
@return le projet auquel ce schema appartient ou 0 s'il s'agit d'un schema
|
||||
independant.
|
||||
*/
|
||||
QETProject *Diagram::project() const {
|
||||
return(project_);
|
||||
}
|
||||
|
||||
/**
|
||||
@param project le nouveau projet auquel ce schema appartient ou 0 s'il
|
||||
s'agit d'un schema independant. Indiquer 0 pour rendre ce schema independant.
|
||||
*/
|
||||
void Diagram::setProject(QETProject *project) {
|
||||
project_ = project;
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si le schema est en lecture seule
|
||||
*/
|
||||
bool Diagram::isReadOnly() const {
|
||||
return(read_only_);
|
||||
}
|
||||
|
||||
/**
|
||||
@param read_only true pour passer le schema en lecture seule, false sinon
|
||||
*/
|
||||
void Diagram::setReadOnly(bool read_only) {
|
||||
if (read_only_ != read_only) {
|
||||
read_only_ = read_only;
|
||||
emit(readOnlyChanged(read_only_));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le contenu du schema. Les conducteurs sont tous places dans
|
||||
conductorsToMove.
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -19,17 +19,15 @@
|
||||
#define SCHEMA_H
|
||||
#include <QtGui>
|
||||
#include <QtXml>
|
||||
#include "qetdiagrameditor.h"
|
||||
#include "borderinset.h"
|
||||
#include "qgimanager.h"
|
||||
#include "conductorproperties.h"
|
||||
class Element;
|
||||
class CustomElement;
|
||||
class Terminal;
|
||||
class Conductor;
|
||||
class DiagramTextItem;
|
||||
class DiagramContent;
|
||||
class QETProject;
|
||||
class ElementsLocation;
|
||||
/**
|
||||
Cette classe represente un schema electrique.
|
||||
Elle gere les differents elements et conducteurs qui le composent
|
||||
@@ -77,12 +75,9 @@ class Diagram : public QGraphicsScene {
|
||||
QSet<Conductor *> conductors_to_move;
|
||||
QHash<Conductor *, Terminal *> conductors_to_update;
|
||||
QSet<DiagramTextItem *> texts_to_move;
|
||||
QGIManager *qgi_manager;
|
||||
QUndoStack *undo_stack;
|
||||
QGIManager qgi_manager;
|
||||
QUndoStack undo_stack;
|
||||
bool draw_terminals;
|
||||
QDomDocument xml_document;
|
||||
QETProject *project_;
|
||||
bool read_only_;
|
||||
|
||||
// methodes
|
||||
protected:
|
||||
@@ -93,14 +88,6 @@ class Diagram : public QGraphicsScene {
|
||||
public:
|
||||
static bool clipboardMayContainDiagram();
|
||||
|
||||
// fonctions relatives au projet parent
|
||||
QETProject *project() const;
|
||||
void setProject(QETProject *);
|
||||
|
||||
// fonctions relatives a la lecture seule
|
||||
bool isReadOnly() const;
|
||||
void setReadOnly(bool);
|
||||
|
||||
// fonctions relatives a la pose de conducteurs
|
||||
void setConductor(bool);
|
||||
void setConductorStart (QPointF);
|
||||
@@ -109,20 +96,6 @@ class Diagram : public QGraphicsScene {
|
||||
// fonctions relatives a l'import / export XML
|
||||
QDomDocument toXml(bool = true);
|
||||
bool fromXml(QDomDocument &, QPointF = QPointF(), bool = true, DiagramContent * = NULL);
|
||||
bool fromXml(QDomElement &, QPointF = QPointF(), bool = true, DiagramContent * = NULL);
|
||||
void write();
|
||||
void write(const QDomElement &);
|
||||
bool wasWritten() const;
|
||||
QDomElement writeXml(QDomDocument &) const;
|
||||
|
||||
// fonctions relative a l'ajout et a l'enlevement d'elements graphiques sur le schema
|
||||
void addElement(Element *);
|
||||
void addConductor(Conductor *);
|
||||
void addDiagramTextItem(DiagramTextItem *);
|
||||
|
||||
void removeElement(Element *);
|
||||
void removeConductor(Conductor *);
|
||||
void removeDiagramTextItem(DiagramTextItem *);
|
||||
|
||||
// fonctions relatives aux options graphiques
|
||||
void setDisplayGrid(bool);
|
||||
@@ -136,13 +109,9 @@ class Diagram : public QGraphicsScene {
|
||||
void setDrawTerminals(bool);
|
||||
|
||||
QRectF border() const;
|
||||
QString title() const;
|
||||
bool toPaintDevice(QPaintDevice &, int = -1, int = -1, Qt::AspectRatioMode = Qt::KeepAspectRatio);
|
||||
QSize imageSize() const;
|
||||
|
||||
bool isEmpty() const;
|
||||
|
||||
QList<CustomElement *> customElements() const;
|
||||
void invalidateMovedElements();
|
||||
void fetchMovedElements();
|
||||
const QSet<Element *> &elementsToMove();
|
||||
@@ -153,14 +122,10 @@ class Diagram : public QGraphicsScene {
|
||||
DiagramContent content() const;
|
||||
DiagramContent selectedContent();
|
||||
void moveElements(const QPointF &, QGraphicsItem * = NULL);
|
||||
bool usesElement(const ElementsLocation &);
|
||||
|
||||
QUndoStack &undoStack();
|
||||
QGIManager &qgiManager();
|
||||
|
||||
public slots:
|
||||
void diagramTextChanged(DiagramTextItem *, const QString &, const QString &);
|
||||
|
||||
private slots:
|
||||
void slot_checkSelectionEmptinessChange();
|
||||
|
||||
@@ -171,12 +136,10 @@ class Diagram : public QGraphicsScene {
|
||||
vice-versa.
|
||||
*/
|
||||
void selectionEmptinessChanged();
|
||||
void written();
|
||||
void readOnlyChanged(bool);
|
||||
};
|
||||
|
||||
/**
|
||||
Permet d'ajouter ou enlever le "poseur de conducteur", c'est-a-dire la
|
||||
Permet d'ajouter ou enlever le « poseur de conducteur », c'est-a-dire la
|
||||
droite en pointilles qui apparait lorsqu'on pose un conducteur entre deux
|
||||
bornes.
|
||||
@param pf true pour ajouter le poseur de conducteur, false pour l'enlever
|
||||
@@ -287,12 +250,12 @@ inline const QSet<DiagramTextItem *> &Diagram::textsToMove() {
|
||||
|
||||
/// @return la pile d'annulations de ce schema
|
||||
inline QUndoStack &Diagram::undoStack() {
|
||||
return(*undo_stack);
|
||||
return(undo_stack);
|
||||
}
|
||||
|
||||
/// @return le egstionnaire de QGraphicsItem de ce schema
|
||||
inline QGIManager &Diagram::qgiManager() {
|
||||
return(*qgi_manager);
|
||||
return(qgi_manager);
|
||||
}
|
||||
|
||||
/// @return true si les bornes sont affichees, false sinon
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -33,7 +33,7 @@ AddElementCommand::AddElementCommand(
|
||||
const QPointF &p,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QString(QObject::tr("ajouter 1 %1", "undo caption - %1 is an element name")).arg(elmt -> name()), parent),
|
||||
QUndoCommand(QObject::tr("ajouter 1 ") + elmt -> nom(), parent),
|
||||
element(elmt),
|
||||
diagram(d),
|
||||
position(p)
|
||||
@@ -48,12 +48,12 @@ AddElementCommand::~AddElementCommand() {
|
||||
|
||||
/// Annule l'ajout
|
||||
void AddElementCommand::undo() {
|
||||
diagram -> removeElement(element);
|
||||
diagram -> removeItem(element);
|
||||
}
|
||||
|
||||
/// Refait l'ajout
|
||||
void AddElementCommand::redo() {
|
||||
diagram -> addElement(element);
|
||||
diagram -> addItem(element);
|
||||
element -> setPos(position);
|
||||
element -> setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ void AddElementCommand::redo() {
|
||||
@param parent QUndoCommand parent
|
||||
*/
|
||||
AddTextCommand::AddTextCommand(Diagram *dia, DiagramTextItem *text, const QPointF &pos, QUndoCommand *parent) :
|
||||
QUndoCommand(QObject::tr("Ajouter un champ de texte", "undo caption"), parent),
|
||||
QUndoCommand(QObject::tr("Ajouter un champ de texte"), parent),
|
||||
textitem(text),
|
||||
diagram(dia),
|
||||
position(pos)
|
||||
@@ -81,12 +81,12 @@ AddTextCommand::~AddTextCommand() {
|
||||
|
||||
/// Annule l'ajout
|
||||
void AddTextCommand::undo() {
|
||||
diagram -> removeDiagramTextItem(textitem);
|
||||
diagram -> removeItem(textitem);
|
||||
}
|
||||
|
||||
/// Refait l'ajour
|
||||
void AddTextCommand::redo() {
|
||||
diagram -> addDiagramTextItem(textitem);
|
||||
diagram -> addItem(textitem);
|
||||
textitem -> setPos(position);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ AddConductorCommand::AddConductorCommand(
|
||||
Conductor *c,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QObject::tr("ajouter un conducteur", "undo caption"), parent),
|
||||
QUndoCommand(QObject::tr("ajouter un conducteur"), parent),
|
||||
conductor(c),
|
||||
diagram(d)
|
||||
{
|
||||
@@ -115,12 +115,15 @@ AddConductorCommand::~AddConductorCommand() {
|
||||
|
||||
/// Annule l'ajout
|
||||
void AddConductorCommand::undo() {
|
||||
diagram -> removeConductor(conductor);
|
||||
// detache le conducteur sans le detruire
|
||||
conductor -> terminal1 -> removeConductor(conductor);
|
||||
conductor -> terminal2 -> removeConductor(conductor);
|
||||
diagram -> removeItem(conductor);
|
||||
}
|
||||
|
||||
/// Refait l'ajout
|
||||
void AddConductorCommand::redo() {
|
||||
diagram -> addConductor(conductor);
|
||||
diagram -> addItem(conductor);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,14 +141,7 @@ DeleteElementsCommand::DeleteElementsCommand(
|
||||
removed_content(content),
|
||||
diagram(dia)
|
||||
{
|
||||
setText(
|
||||
QString(
|
||||
QObject::tr(
|
||||
"supprimer %1",
|
||||
"undo caption - %1 is a sentence listing the removed content"
|
||||
)
|
||||
).arg(removed_content.sentence(DiagramContent::All))
|
||||
);
|
||||
setText(QObject::tr("supprimer ") + removed_content.sentence(DiagramContent::All));
|
||||
diagram -> qgiManager().manage(removed_content.items(DiagramContent::All));
|
||||
}
|
||||
|
||||
@@ -158,17 +154,19 @@ DeleteElementsCommand::~DeleteElementsCommand() {
|
||||
void DeleteElementsCommand::undo() {
|
||||
// remet les elements
|
||||
foreach(Element *e, removed_content.elements) {
|
||||
diagram -> addElement(e);
|
||||
diagram -> addItem(e);
|
||||
}
|
||||
|
||||
// remet les conducteurs
|
||||
foreach(Conductor *c, removed_content.conductors(DiagramContent::AnyConductor)) {
|
||||
diagram -> addConductor(c);
|
||||
diagram -> addItem(c);
|
||||
c -> terminal1 -> addConductor(c);
|
||||
c -> terminal2 -> addConductor(c);
|
||||
}
|
||||
|
||||
// remet les textes
|
||||
foreach(DiagramTextItem *t, removed_content.textFields) {
|
||||
diagram -> addDiagramTextItem(t);
|
||||
diagram -> addItem(t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,17 +174,19 @@ void DeleteElementsCommand::undo() {
|
||||
void DeleteElementsCommand::redo() {
|
||||
// enleve les conducteurs
|
||||
foreach(Conductor *c, removed_content.conductors(DiagramContent::AnyConductor)) {
|
||||
diagram -> removeConductor(c);
|
||||
c -> terminal1 -> removeConductor(c);
|
||||
c -> terminal2 -> removeConductor(c);
|
||||
diagram -> removeItem(c);
|
||||
}
|
||||
|
||||
// enleve les elements
|
||||
foreach(Element *e, removed_content.elements) {
|
||||
diagram -> removeElement(e);
|
||||
diagram -> removeItem(e);
|
||||
}
|
||||
|
||||
// enleve les textes
|
||||
foreach(DiagramTextItem *t, removed_content.textFields) {
|
||||
diagram -> removeDiagramTextItem(t);
|
||||
diagram -> removeItem(t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,14 +208,7 @@ PasteDiagramCommand::PasteDiagramCommand(
|
||||
first_redo(true)
|
||||
{
|
||||
|
||||
setText(
|
||||
QString(
|
||||
QObject::tr(
|
||||
"coller %1",
|
||||
"undo caption - %1 is a sentence listing the content to paste"
|
||||
).arg(content.sentence(filter))
|
||||
)
|
||||
);
|
||||
setText(QObject::tr("coller ") + content.sentence(filter));
|
||||
diagram -> qgiManager().manage(content.items(filter));
|
||||
}
|
||||
|
||||
@@ -227,13 +220,17 @@ PasteDiagramCommand::~PasteDiagramCommand() {
|
||||
/// annule le coller
|
||||
void PasteDiagramCommand::undo() {
|
||||
// enleve les conducteurs
|
||||
foreach(Conductor *c, content.conductorsToMove) diagram -> removeConductor(c);
|
||||
foreach(Conductor *c, content.conductorsToMove) {
|
||||
c -> terminal1 -> removeConductor(c);
|
||||
c -> terminal2 -> removeConductor(c);
|
||||
diagram -> removeItem(c);
|
||||
}
|
||||
|
||||
// enleve les elements
|
||||
foreach(Element *e, content.elements) diagram -> removeElement(e);
|
||||
foreach(Element *e, content.elements) diagram -> removeItem(e);
|
||||
|
||||
// enleve les textes
|
||||
foreach(DiagramTextItem *t, content.textFields) diagram -> removeDiagramTextItem(t);
|
||||
foreach(DiagramTextItem *t, content.textFields) diagram -> removeItem(t);
|
||||
}
|
||||
|
||||
/// refait le coller
|
||||
@@ -241,13 +238,17 @@ void PasteDiagramCommand::redo() {
|
||||
if (first_redo) first_redo = false;
|
||||
else {
|
||||
// pose les elements
|
||||
foreach(Element *e, content.elements) diagram -> addElement(e);
|
||||
foreach(Element *e, content.elements) diagram -> addItem(e);
|
||||
|
||||
// pose les conducteurs
|
||||
foreach(Conductor *c, content.conductorsToMove) diagram -> addConductor(c);
|
||||
foreach(Conductor *c, content.conductorsToMove) {
|
||||
diagram -> addItem(c);
|
||||
c -> terminal1 -> addConductor(c);
|
||||
c -> terminal2 -> addConductor(c);
|
||||
}
|
||||
|
||||
// pose les textes
|
||||
foreach(DiagramTextItem *t, content.textFields) diagram -> addDiagramTextItem(t);
|
||||
foreach(DiagramTextItem *t, content.textFields) diagram -> addItem(t);
|
||||
}
|
||||
foreach(Element *e, content.elements) e -> setSelected(true);
|
||||
foreach(Conductor *c, content.conductorsToMove) c -> setSelected(true);
|
||||
@@ -267,14 +268,7 @@ CutDiagramCommand::CutDiagramCommand(
|
||||
) :
|
||||
DeleteElementsCommand(dia, content, parent)
|
||||
{
|
||||
setText(
|
||||
QString(
|
||||
QObject::tr(
|
||||
"couper %1",
|
||||
"undo caption - %1 is a sentence listing the content to cut"
|
||||
).arg(content.sentence(DiagramContent::All))
|
||||
)
|
||||
);
|
||||
setText(QObject::tr("couper ") + content.sentence(DiagramContent::All));
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
@@ -300,21 +294,7 @@ MoveElementsCommand::MoveElementsCommand(
|
||||
movement(m),
|
||||
first_redo(true)
|
||||
{
|
||||
QString moved_content_sentence = content_to_move.sentence(
|
||||
DiagramContent::Elements |
|
||||
DiagramContent::TextFields |
|
||||
DiagramContent::ConductorsToUpdate |
|
||||
DiagramContent::ConductorsToMove
|
||||
);
|
||||
|
||||
setText(
|
||||
QString(
|
||||
QObject::tr(
|
||||
"d\351placer %1",
|
||||
"undo caption - %1 is a sentence listing the moved content"
|
||||
).arg(moved_content_sentence)
|
||||
)
|
||||
);
|
||||
setText(QObject::tr("d\351placer ") + content_to_move.sentence(DiagramContent::Elements|DiagramContent::TextFields|DiagramContent::ConductorsToUpdate|DiagramContent::ConductorsToMove));
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
@@ -375,7 +355,7 @@ ChangeDiagramTextCommand::ChangeDiagramTextCommand(
|
||||
const QString &after,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QObject::tr("modifier le texte", "undo caption"), parent),
|
||||
QUndoCommand(QObject::tr("modifier le texte"), parent),
|
||||
text_item(dti),
|
||||
text_before(before),
|
||||
text_after(after),
|
||||
@@ -408,17 +388,9 @@ void ChangeDiagramTextCommand::redo() {
|
||||
@param parent QUndoCommand parent
|
||||
*/
|
||||
RotateElementsCommand::RotateElementsCommand(const QHash<Element *, QET::Orientation> &elements, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
QUndoCommand(QObject::tr("pivoter ") + QET::ElementsAndConductorsSentence(elements.count(), 0), parent),
|
||||
elements_to_rotate(elements)
|
||||
{
|
||||
setText(
|
||||
QString(
|
||||
QObject::tr(
|
||||
"pivoter %1",
|
||||
"undo caption - %1 is a sentence listing the rotated content"
|
||||
)
|
||||
).arg(QET::ElementsAndConductorsSentence(elements.count(), 0))
|
||||
);
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
@@ -455,7 +427,7 @@ ChangeConductorCommand::ChangeConductorCommand(
|
||||
Qt::Corner path_t,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QObject::tr("modifier un conducteur", "undo caption"), parent),
|
||||
QUndoCommand(QObject::tr("modifier un conducteur"), parent),
|
||||
conductor(c),
|
||||
old_profile(old_p),
|
||||
new_profile(new_p),
|
||||
@@ -488,15 +460,9 @@ ResetConductorCommand::ResetConductorCommand(
|
||||
const QHash<Conductor *, ConductorProfilesGroup> &cp,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(parent),
|
||||
QUndoCommand(QObject::tr("R\351initialiser ") + QET::ElementsAndConductorsSentence(0, cp.count()), parent),
|
||||
conductors_profiles(cp)
|
||||
{
|
||||
setText(
|
||||
QObject::tr(
|
||||
"R\351initialiser %1",
|
||||
"undo caption - %1 is a sentence listing the reset content"
|
||||
).arg(QET::ElementsAndConductorsSentence(0, cp.count()))
|
||||
);
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
@@ -530,7 +496,7 @@ ChangeInsetCommand::ChangeInsetCommand(
|
||||
const InsetProperties &new_ip,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QObject::tr("modifier le cartouche", "undo caption"), parent),
|
||||
QUndoCommand(QObject::tr("modifier le cartouche"), parent),
|
||||
diagram(d),
|
||||
old_inset(old_ip),
|
||||
new_inset(new_ip)
|
||||
@@ -558,11 +524,13 @@ void ChangeInsetCommand::redo() {
|
||||
@param dia Schema modifie
|
||||
@param parent QUndoCommand parent
|
||||
*/
|
||||
ChangeBorderCommand::ChangeBorderCommand(Diagram *dia, const BorderProperties &old_bp, const BorderProperties &new_bp, QUndoCommand *parent) :
|
||||
QUndoCommand(QObject::tr("modifier les dimensions du sch\351ma", "undo caption"), parent),
|
||||
ChangeBorderCommand::ChangeBorderCommand(Diagram *dia, QUndoCommand *parent) :
|
||||
QUndoCommand(QObject::tr("modifier les dimensions du sch\351ma"), parent),
|
||||
diagram(dia),
|
||||
old_properties(old_bp),
|
||||
new_properties(new_bp)
|
||||
columnsCountDifference(0),
|
||||
columnsHeightDifference(0.0),
|
||||
columnsWidthDifference(0.0),
|
||||
headersHeightDifference(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -570,14 +538,39 @@ ChangeBorderCommand::ChangeBorderCommand(Diagram *dia, const BorderProperties &o
|
||||
ChangeBorderCommand::~ChangeBorderCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
Applique les changements au schema
|
||||
@param coeff comme les changements s'expriment sous forme de nombres dont
|
||||
il suffit d'inverser le signe pour les annuler, ces valeurs sont ici
|
||||
multipliees par le coefficient passe en parametre avant d'etre appliquees.
|
||||
Pour resumer : 1 pour refaire, -1 pour annuler.
|
||||
*/
|
||||
void ChangeBorderCommand::applyChanges(int coeff) {
|
||||
// reference vers l'objet border_and_inset du schema
|
||||
BorderInset &border = diagram -> border_and_inset;
|
||||
if (columnsCountDifference) {
|
||||
border.setNbColumns(border.nbColumn() + (columnsCountDifference * coeff));
|
||||
}
|
||||
if (columnsHeightDifference) {
|
||||
border.setColumnsHeight(border.columnsHeight() + (columnsHeightDifference * coeff));
|
||||
}
|
||||
if (columnsWidthDifference) {
|
||||
border.setColumnsWidth(border.columnsWidth() + (columnsWidthDifference * coeff));
|
||||
}
|
||||
if (headersHeightDifference) {
|
||||
border.setColumnsHeaderHeight(border.columnsHeaderHeight() + (headersHeightDifference * coeff));
|
||||
}
|
||||
border.adjustInsetToColumns();
|
||||
}
|
||||
|
||||
/// Annule les changements apportes au schema
|
||||
void ChangeBorderCommand::undo() {
|
||||
diagram -> border_and_inset.importBorder(old_properties);
|
||||
applyChanges(-1);
|
||||
}
|
||||
|
||||
/// Refait les changements apportes au schema
|
||||
void ChangeBorderCommand::redo() {
|
||||
diagram -> border_and_inset.importBorder(new_properties);
|
||||
applyChanges(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -586,7 +579,7 @@ void ChangeBorderCommand::redo() {
|
||||
@param parent QUndoCommand parent
|
||||
*/
|
||||
ChangeConductorPropertiesCommand::ChangeConductorPropertiesCommand(Conductor *c, QUndoCommand *parent) :
|
||||
QUndoCommand(QObject::tr("modifier les propri\351t\351s d'un conducteur", "undo caption"), parent),
|
||||
QUndoCommand(QObject::tr("modifier les propri\351t\351s d'un conducteur"), parent),
|
||||
conductor(c),
|
||||
old_settings_set(false),
|
||||
new_settings_set(false)
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -22,9 +22,7 @@
|
||||
#include "diagramcontent.h"
|
||||
#include "diagramtextitem.h"
|
||||
#include "conductor.h"
|
||||
#include "borderproperties.h"
|
||||
#include "conductorproperties.h"
|
||||
#include "insetproperties.h"
|
||||
#include <QtGui>
|
||||
/**
|
||||
Cette classe represente l'action d'ajouter un element au schema
|
||||
@@ -327,12 +325,16 @@ class ChangeInsetCommand : public QUndoCommand {
|
||||
};
|
||||
|
||||
/**
|
||||
Cette classe represente l'action de modifier les dimensions d'un schema
|
||||
Cette classe represente l'action de modifier :
|
||||
-le nombre de colonnes d'un schema
|
||||
-la hauteur des colonnes
|
||||
-la largeur des colonnes
|
||||
-la hauteur des en-tetes des colonnes
|
||||
*/
|
||||
class ChangeBorderCommand : public QUndoCommand {
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
ChangeBorderCommand(Diagram *, const BorderProperties &, const BorderProperties &, QUndoCommand * = 0);
|
||||
ChangeBorderCommand(Diagram *, QUndoCommand * = 0);
|
||||
virtual ~ChangeBorderCommand();
|
||||
private:
|
||||
ChangeBorderCommand(const ChangeBorderCommand &);
|
||||
@@ -341,16 +343,22 @@ class ChangeBorderCommand : public QUndoCommand {
|
||||
public:
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
private:
|
||||
virtual void applyChanges(int = 1);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
/// schema modifie
|
||||
Diagram *diagram;
|
||||
public:
|
||||
/// anciennes dimensions du schema
|
||||
BorderProperties old_properties;
|
||||
/// nouvelles dimensions du schema
|
||||
BorderProperties new_properties;
|
||||
/// nombre de colonnes ajoutees / enlevees
|
||||
int columnsCountDifference;
|
||||
/// delta pour la hauteur des colonnes
|
||||
qreal columnsHeightDifference;
|
||||
/// delta pour la largeur des colonnes
|
||||
qreal columnsWidthDifference;
|
||||
/// delta pour la hauteur des entetes des colonnes
|
||||
qreal headersHeightDifference;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -119,15 +119,12 @@ QString DiagramContent::sentence(int filter) const {
|
||||
@param d Object QDebug a utiliser pour l'affichage des informations de debug
|
||||
@param c Contenu de schema a debugger
|
||||
*/
|
||||
QDebug &operator<<(QDebug d, DiagramContent &) {
|
||||
QDebug &operator<<(QDebug d, DiagramContent &c) {
|
||||
d << "DiagramContent {" << "\n";
|
||||
/*
|
||||
FIXME Le double-heritage QObject / QGraphicsItem a casse cet operateur
|
||||
d << " elements :" << c.elements << "\n";
|
||||
d << " conductorsToUpdate :" << c.conductorsToUpdate.keys() << "\n";
|
||||
d << " conductorsToMove :" << c.conductorsToMove << "\n";
|
||||
d << " otherConductors :" << c.otherConductors << "\n";
|
||||
*/
|
||||
d << "}";
|
||||
return(d.space());
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
#include "diagramtextitem.h"
|
||||
#include "diagramcommands.h"
|
||||
#include "qetapp.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@@ -28,7 +27,6 @@ DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, QGraphicsScene *scene) :
|
||||
QGraphicsTextItem(parent, scene)
|
||||
{
|
||||
setDefaultTextColor(Qt::black);
|
||||
setFont(QFont(QETApp::diagramTextsFont(), QETApp::diagramTextsSize()));
|
||||
setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
|
||||
connect(this, SIGNAL(lostFocus()), this, SLOT(setNonFocusable()));
|
||||
}
|
||||
@@ -44,7 +42,6 @@ DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, QGr
|
||||
previous_text(text)
|
||||
{
|
||||
setDefaultTextColor(Qt::black);
|
||||
setFont(QFont(QETApp::diagramTextsFont(), QETApp::diagramTextsSize()));
|
||||
setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
|
||||
connect(this, SIGNAL(lostFocus()), this, SLOT(setNonFocusable()));
|
||||
}
|
||||
@@ -63,10 +60,12 @@ Diagram *DiagramTextItem::diagram() const {
|
||||
*/
|
||||
void DiagramTextItem::focusOutEvent(QFocusEvent *e) {
|
||||
QGraphicsTextItem::focusOutEvent(e);
|
||||
// signale la modification du texte si besoin
|
||||
// si le texte a ete modifie
|
||||
if (toPlainText() != previous_text) {
|
||||
emit(diagramTextChanged(this, previous_text, toPlainText()));
|
||||
previous_text = toPlainText();
|
||||
if (Diagram *dia = diagram()) {
|
||||
dia -> undoStack().push(new ChangeDiagramTextCommand(this, previous_text, toPlainText()));
|
||||
previous_text = toPlainText();
|
||||
}
|
||||
}
|
||||
|
||||
// deselectionne le texte
|
||||
@@ -99,8 +98,8 @@ void DiagramTextItem::fromXml(const QDomElement &e) {
|
||||
*/
|
||||
QDomElement DiagramTextItem::toXml(QDomDocument &document) const {
|
||||
QDomElement result = document.createElement("input");
|
||||
result.setAttribute("x", QString("%1").arg(pos().x()));
|
||||
result.setAttribute("y", QString("%1").arg(pos().y()));
|
||||
result.setAttribute("x", pos().x());
|
||||
result.setAttribute("y", pos().y());
|
||||
result.setAttribute("text", toPlainText());
|
||||
return(result);
|
||||
}
|
||||
@@ -131,16 +130,6 @@ void DiagramTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Gere le clic sur le champ de texte
|
||||
*/
|
||||
void DiagramTextItem::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
||||
if (e -> modifiers() & Qt::ControlModifier) {
|
||||
setSelected(!isSelected());
|
||||
}
|
||||
QGraphicsTextItem::mousePressEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les mouvements de souris lies au champ de texte
|
||||
*/
|
||||
@@ -175,9 +164,7 @@ void DiagramTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
||||
}
|
||||
diagram_ptr -> invalidateMovedElements();
|
||||
}
|
||||
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
||||
QGraphicsTextItem::mouseReleaseEvent(e);
|
||||
}
|
||||
QGraphicsTextItem::mouseReleaseEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -52,7 +52,6 @@ class DiagramTextItem : public QGraphicsTextItem {
|
||||
protected:
|
||||
virtual void focusOutEvent(QFocusEvent *);
|
||||
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *);
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
||||
|
||||
@@ -60,9 +59,7 @@ class DiagramTextItem : public QGraphicsTextItem {
|
||||
signals:
|
||||
/// signal emis lorsque le champ de texte perd le focus
|
||||
void lostFocus();
|
||||
/// signal emis lorsque le champ de texte a ete modifie
|
||||
void diagramTextChanged(DiagramTextItem *, const QString &, const QString &);
|
||||
|
||||
|
||||
// slots
|
||||
public slots:
|
||||
void setNonFocusable();
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -18,53 +18,44 @@
|
||||
#include "diagramview.h"
|
||||
#include "diagram.h"
|
||||
#include "customelement.h"
|
||||
#include "exportdialog.h"
|
||||
#include "conductor.h"
|
||||
#include "diagramcommands.h"
|
||||
#include "conductorpropertieswidget.h"
|
||||
#include "insetpropertieswidget.h"
|
||||
#include "qetapp.h"
|
||||
#include "qetproject.h"
|
||||
#include "borderpropertieswidget.h"
|
||||
#include "integrationmoveelementshandler.h"
|
||||
#include "qetdiagrameditor.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param parent Le QWidget parent de cette vue de schema
|
||||
@param parent Le QWidegt parent de cette vue de schema
|
||||
*/
|
||||
DiagramView::DiagramView(Diagram *diagram, QWidget *parent) : QGraphicsView(parent), is_adding_text(false) {
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
DiagramView::DiagramView(QWidget *parent) : QGraphicsView(parent), is_adding_text(false) {
|
||||
setInteractive(true);
|
||||
setCacheMode(QGraphicsView::CacheBackground);
|
||||
setOptimizationFlags(QGraphicsView::DontSavePainterState|QGraphicsView::DontAdjustForAntialiasing);
|
||||
|
||||
// active l'antialiasing
|
||||
setRenderHint(QPainter::Antialiasing, true);
|
||||
setRenderHint(QPainter::TextAntialiasing, true);
|
||||
setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||
|
||||
scene = diagram ? diagram : new Diagram(this);
|
||||
setScene(scene);
|
||||
setScene(scene = new Diagram(this));
|
||||
scene -> undoStack().setClean();
|
||||
setDragMode(RubberBandDrag);
|
||||
setAcceptDrops(true);
|
||||
setWindowIcon(QIcon(":/ico/qet-16.png"));
|
||||
setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||
setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
||||
setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
setSelectionMode();
|
||||
adjustSceneRect();
|
||||
updateWindowTitle();
|
||||
|
||||
context_menu = new QMenu(this);
|
||||
paste_here = new QAction(QIcon(":/ico/paste.png"), tr("Coller ici", "context menu action"), this);
|
||||
paste_here = new QAction(QIcon(":/ico/paste.png"), tr("Coller ici"), this);
|
||||
connect(paste_here, SIGNAL(triggered()), this, SLOT(pasteHere()));
|
||||
|
||||
connect(scene, SIGNAL(selectionEmptinessChanged()), this, SIGNAL(selectionChanged()));
|
||||
connect(scene, SIGNAL(readOnlyChanged(bool)), this, SLOT(applyReadOnly()));
|
||||
connect(&(scene -> border_and_inset), SIGNAL(borderChanged(QRectF, QRectF)), this, SLOT(adjustSceneRect()));
|
||||
connect(&(scene -> border_and_inset), SIGNAL(displayChanged()), this, SLOT(adjustSceneRect()));
|
||||
connect(&(scene -> border_and_inset), SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(updateWindowTitle()));
|
||||
connect(&(scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(updateWindowTitle()));
|
||||
|
||||
connect(this, SIGNAL(aboutToAddElement()), this, SLOT(addDroppedElement()), Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +65,7 @@ DiagramView::~DiagramView() {
|
||||
}
|
||||
|
||||
/**
|
||||
Appelle la methode select sur tous les elements de la liste d'elements
|
||||
appelle la methode select sur tous les elements de la liste d'elements
|
||||
*/
|
||||
void DiagramView::selectAll() {
|
||||
if (scene -> items().isEmpty()) return;
|
||||
@@ -103,7 +94,6 @@ void DiagramView::selectInvert() {
|
||||
Supprime les composants selectionnes
|
||||
*/
|
||||
void DiagramView::deleteSelection() {
|
||||
if (scene -> isReadOnly()) return;
|
||||
DiagramContent removed_content = scene -> selectedContent();
|
||||
scene -> clearSelection();
|
||||
scene -> undoStack().push(new DeleteElementsCommand(scene, removed_content));
|
||||
@@ -114,7 +104,6 @@ void DiagramView::deleteSelection() {
|
||||
Pivote les composants selectionnes
|
||||
*/
|
||||
void DiagramView::rotateSelection() {
|
||||
if (scene -> isReadOnly()) return;
|
||||
QHash<Element *, QET::Orientation> elements_to_rotate;
|
||||
foreach (QGraphicsItem *item, scene -> selectedItems()) {
|
||||
if (Element *e = qgraphicsitem_cast<Element *>(item)) {
|
||||
@@ -126,26 +115,23 @@ void DiagramView::rotateSelection() {
|
||||
}
|
||||
|
||||
/**
|
||||
Accepte ou refuse le drag'n drop en fonction du type de donnees entrant
|
||||
accepte ou refuse le drag'n drop en fonction du type de donnees entrant
|
||||
@param e le QDragEnterEvent correspondant au drag'n drop tente
|
||||
*/
|
||||
void DiagramView::dragEnterEvent(QDragEnterEvent *e) {
|
||||
if (e -> mimeData() -> hasFormat("application/x-qet-element-uri")) {
|
||||
e -> acceptProposedAction();
|
||||
} else {
|
||||
e -> ignore();
|
||||
}
|
||||
if (e -> mimeData() -> hasFormat("text/plain")) e -> acceptProposedAction();
|
||||
else e-> ignore();
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les dragleaveevent
|
||||
gere les dragleaveevent
|
||||
@param e le QDragEnterEvent correspondant au drag'n drop sortant
|
||||
*/
|
||||
void DiagramView::dragLeaveEvent(QDragLeaveEvent *) {
|
||||
}
|
||||
|
||||
/**
|
||||
Accepte ou refuse le drag'n drop en fonction du type de donnees entrant
|
||||
accepte ou refuse le drag'n drop en fonction du type de donnees entrant
|
||||
@param e le QDragMoveEvent correspondant au drag'n drop tente
|
||||
*/
|
||||
void DiagramView::dragMoveEvent(QDragMoveEvent *e) {
|
||||
@@ -154,23 +140,18 @@ void DiagramView::dragMoveEvent(QDragMoveEvent *e) {
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les depots (drop) acceptes sur le schema. Cette methode emet le signal
|
||||
aboutToAddElement si l'element depose est accessible.
|
||||
gere les depots (drop) acceptes sur le Diagram
|
||||
@param e le QDropEvent correspondant au drag'n drop effectue
|
||||
*/
|
||||
void DiagramView::dropEvent(QDropEvent *e) {
|
||||
// recupere l'emplacement de l'element depuis le drag'n drop
|
||||
QString elmt_path = e -> mimeData() -> text();
|
||||
ElementsLocation location(ElementsLocation::locationFromString(elmt_path));
|
||||
|
||||
// verifie qu'il existe un element correspondant a cet emplacement
|
||||
ElementsCollectionItem *dropped_item = QETApp::collectionItem(location);
|
||||
if (!dropped_item) return;
|
||||
|
||||
next_location_ = location;
|
||||
next_position_ = e-> pos();
|
||||
|
||||
emit(aboutToAddElement());
|
||||
QString fichier = e -> mimeData() -> text();
|
||||
int etat;
|
||||
Element *el = new CustomElement(fichier, 0, 0, &etat);
|
||||
if (etat) delete el;
|
||||
else {
|
||||
diagram() -> undoStack().push(new AddElementCommand(diagram(), el, mapToScene(e -> pos())));
|
||||
adjustSceneRect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +159,6 @@ void DiagramView::dropEvent(QDropEvent *e) {
|
||||
*/
|
||||
void DiagramView::setVisualisationMode() {
|
||||
setDragMode(ScrollHandDrag);
|
||||
applyReadOnly();
|
||||
setInteractive(false);
|
||||
emit(modeChanged());
|
||||
}
|
||||
@@ -189,7 +169,6 @@ void DiagramView::setVisualisationMode() {
|
||||
void DiagramView::setSelectionMode() {
|
||||
setDragMode(RubberBandDrag);
|
||||
setInteractive(true);
|
||||
applyReadOnly();
|
||||
emit(modeChanged());
|
||||
}
|
||||
|
||||
@@ -229,7 +208,7 @@ void DiagramView::zoomReset() {
|
||||
}
|
||||
|
||||
/**
|
||||
Copie les elements selectionnes du schema dans le presse-papier puis les supprime
|
||||
copie les elements selectionnes du schema dans le presse-papier puis les supprime
|
||||
*/
|
||||
void DiagramView::cut() {
|
||||
copy();
|
||||
@@ -239,7 +218,7 @@ void DiagramView::cut() {
|
||||
}
|
||||
|
||||
/**
|
||||
Copie les elements selectionnes du schema dans le presse-papier
|
||||
copie les elements selectionnes du schema dans le presse-papier
|
||||
*/
|
||||
void DiagramView::copy() {
|
||||
QClipboard *presse_papier = QApplication::clipboard();
|
||||
@@ -255,8 +234,6 @@ void DiagramView::copy() {
|
||||
@param clipboard_mode Type de presse-papier a prendre en compte
|
||||
*/
|
||||
void DiagramView::paste(const QPointF &pos, QClipboard::Mode clipboard_mode) {
|
||||
if (scene -> isReadOnly()) return;
|
||||
|
||||
QString texte_presse_papier = QApplication::clipboard() -> text(clipboard_mode);
|
||||
if ((texte_presse_papier).isEmpty()) return;
|
||||
|
||||
@@ -281,22 +258,220 @@ void DiagramView::pasteHere() {
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les clics et plus particulierement :
|
||||
* le clic du milieu (= coller pour X11)
|
||||
* le clic pour ajouter un champ de texte independant
|
||||
gere les clics et plus particulierement le clic du milieu (= coller pour X11)
|
||||
*/
|
||||
void DiagramView::mousePressEvent(QMouseEvent *e) {
|
||||
if (e -> buttons() == Qt::MidButton) {
|
||||
paste(mapToScene(e -> pos()), QClipboard::Selection);
|
||||
} else {
|
||||
if (!scene -> isReadOnly() && is_adding_text && e -> buttons() == Qt::LeftButton) {
|
||||
addDiagramTextAtPos(mapToScene(e -> pos()));
|
||||
if (is_adding_text && e -> buttons() == Qt::LeftButton) {
|
||||
DiagramTextItem *dti = new DiagramTextItem();
|
||||
dti -> setPlainText("_");
|
||||
dti -> previous_text = "_";
|
||||
scene -> undoStack().push(new AddTextCommand(scene, dti, e -> pos()));
|
||||
adjustSceneRect();
|
||||
is_adding_text = false;
|
||||
emit(textAdded(false));
|
||||
}
|
||||
QGraphicsView::mousePressEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Ouvre un fichier *.qet dans cette DiagramView
|
||||
@param n_fichier Nom du fichier a ouvrir
|
||||
@param erreur Si le pointeur est specifie, cet entier est mis a 0 en cas de reussite de l'ouverture, 1 si le fichier n'existe pas, 2 si le fichier n'est pas lisible, 3 si le fichier n'est pas un element XML, 4 si l'ouverture du fichier a echoue pour une autre raison (c'est pas ca qui manque ^^)
|
||||
@return true si l'ouverture a reussi, false sinon
|
||||
*/
|
||||
bool DiagramView::open(QString n_fichier, int *erreur) {
|
||||
// verifie l'existence du fichier
|
||||
if (!QFileInfo(n_fichier).exists()) {
|
||||
if (erreur != NULL) *erreur = 1;
|
||||
return(false);
|
||||
}
|
||||
|
||||
// ouvre le fichier
|
||||
QFile fichier(n_fichier);
|
||||
if (!fichier.open(QIODevice::ReadOnly)) {
|
||||
if (erreur != NULL) *erreur = 2;
|
||||
return(false);
|
||||
}
|
||||
|
||||
// lit son contenu dans un QDomDocument
|
||||
QDomDocument document;
|
||||
if (!document.setContent(&fichier)) {
|
||||
if (erreur != NULL) *erreur = 3;
|
||||
fichier.close();
|
||||
return(false);
|
||||
}
|
||||
fichier.close();
|
||||
|
||||
/**
|
||||
La notion de projet (ensemble de documents [schemas, nomenclatures,
|
||||
...] et d'elements) n'est pas encore geree.
|
||||
Toutefois, pour gerer au mieux la transition de la 0.1 a la 0.2,
|
||||
les schemas enregistres (element XML "diagram") sont integres dans un
|
||||
pseudo projet (element XML "project").
|
||||
S'il y a plusieurs schemas dans un projet, tous les schemas seront
|
||||
ouverts comme etant des fichiers separes
|
||||
*/
|
||||
// repere les schemas dans le fichier
|
||||
QDomElement root = document.documentElement();
|
||||
// cas 1 : l'element racine est un "diagram" : un seul schema, pas de probleme
|
||||
if (root.tagName() == "diagram") {
|
||||
// construit le schema a partir du QDomDocument
|
||||
QDomDocument &doc = document;
|
||||
if (scene -> fromXml(doc)) {
|
||||
if (erreur != NULL) *erreur = 0;
|
||||
file_name = n_fichier;
|
||||
scene -> undoStack().setClean();
|
||||
updateWindowTitle();
|
||||
return(true);
|
||||
} else {
|
||||
if (erreur != NULL) *erreur = 4;
|
||||
return(false);
|
||||
}
|
||||
// cas 2 : l'element racine est un "project"
|
||||
} else if (root.tagName() == "project") {
|
||||
// verifie basiquement que la version actuelle est capable de lire ce fichier
|
||||
if (root.hasAttribute("version")) {
|
||||
bool conv_ok;
|
||||
qreal diagram_version = root.attribute("version").toDouble(&conv_ok);
|
||||
if (conv_ok && QET::version.toDouble() < diagram_version) {
|
||||
QMessageBox::warning(
|
||||
0,
|
||||
tr("Avertissement"),
|
||||
tr("Ce document semble avoir \351t\351 enregistr\351 avec une "
|
||||
"version ult\351rieure de QElectroTech. Il est possible que "
|
||||
"l'ouverture de tout ou partie de ce document \351choue.")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// compte le nombre de schemas dans le projet
|
||||
QList<QDomElement> diagrams;
|
||||
|
||||
QDomNodeList diagram_nodes = root.elementsByTagName("diagram");
|
||||
for (uint i = 0 ; i < diagram_nodes.length() ; ++ i) {
|
||||
if (diagram_nodes.at(i).isElement()) {
|
||||
diagrams << diagram_nodes.at(i).toElement();
|
||||
}
|
||||
}
|
||||
|
||||
// il n'y aucun schema la-dedans
|
||||
if (!diagrams.count()) {
|
||||
if (erreur != NULL) *erreur = 4;
|
||||
return(false);
|
||||
} else {
|
||||
|
||||
bool keep_doc_name = diagrams.count() == 1;
|
||||
bool current_dv_loaded = false;
|
||||
for (int i = 0 ; i < diagrams.count() ; ++ i) {
|
||||
// cree un QDomDocument representant le schema
|
||||
QDomDocument diagram_doc;
|
||||
diagram_doc.appendChild(diagram_doc.importNode(diagrams[i], true));
|
||||
|
||||
// charge le premier schema valide et cree de nouveau DiagramView pour les suivants
|
||||
if (!current_dv_loaded) {
|
||||
if (scene -> fromXml(diagram_doc)) {
|
||||
if (keep_doc_name) file_name = n_fichier;
|
||||
scene -> undoStack().setClean();
|
||||
updateWindowTitle();
|
||||
current_dv_loaded = true;
|
||||
}
|
||||
} else {
|
||||
DiagramView *new_dv = new DiagramView(parentWidget());
|
||||
if (new_dv -> scene -> fromXml(diagram_doc)) {
|
||||
if (keep_doc_name) new_dv -> file_name = n_fichier;
|
||||
new_dv -> scene -> undoStack().setClean();
|
||||
new_dv -> updateWindowTitle();
|
||||
diagramEditor() -> addDiagramView(new_dv);
|
||||
} else {
|
||||
delete(new_dv);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (erreur != NULL) *erreur = 4;
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Gere la fermeture du schema.
|
||||
@param event Le QCloseEvent decrivant l'evenement
|
||||
*/
|
||||
void DiagramView::closeEvent(QCloseEvent *event) {
|
||||
bool retour;
|
||||
// si le schema est modifie
|
||||
if (!isWindowModified()) {
|
||||
retour = true;
|
||||
} else {
|
||||
// demande d'abord a l'utilisateur s'il veut enregistrer le schema en cours
|
||||
QMessageBox::StandardButton reponse = QMessageBox::question(
|
||||
this,
|
||||
tr("Enregistrer le sch\351ma en cours ?"),
|
||||
tr("Voulez-vous enregistrer le sch\351ma ") + windowTitle() + tr(" ?"),
|
||||
QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel,
|
||||
QMessageBox::Cancel
|
||||
);
|
||||
switch(reponse) {
|
||||
case QMessageBox::Cancel: retour = false; break; // l'utilisateur annule : echec de la fermeture
|
||||
case QMessageBox::Yes: retour = save(); break; // l'utilisateur dit oui : la reussite depend de l'enregistrement
|
||||
default: retour = true; // l'utilisateur dit non ou ferme le dialogue: c'est reussi
|
||||
}
|
||||
}
|
||||
if (retour) {
|
||||
event -> accept();
|
||||
delete this;
|
||||
} else event -> ignore();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Methode enregistrant le schema dans le dernier nom de fichier connu.
|
||||
Si aucun nom de fichier n'est connu, cette methode appelle la methode saveAs
|
||||
@return true si l'enregistrement a reussi, false sinon
|
||||
*/
|
||||
bool DiagramView::save() {
|
||||
if (file_name.isEmpty()) return(saveAs());
|
||||
else return(saveDiagramToFile(file_name));
|
||||
}
|
||||
|
||||
/**
|
||||
Cette methode demande un nom de fichier a l'utilisateur pour enregistrer le schema
|
||||
Si aucun nom n'est entre, elle renvoie faux.
|
||||
Si le nom ne se termine pas par l'extension .qet, celle-ci est ajoutee.
|
||||
Si l'enregistrement reussit, le nom du fichier est conserve et la fonction renvoie true.
|
||||
Sinon, faux est renvoye.
|
||||
@return true si l'enregistrement a reussi, false sinon
|
||||
*/
|
||||
bool DiagramView::saveAs() {
|
||||
// demande un nom de fichier a l'utilisateur pour enregistrer le schema
|
||||
QString n_fichier = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
tr("Enregistrer sous"),
|
||||
(file_name.isEmpty() ? QDir::homePath() : QDir(file_name)).absolutePath(),
|
||||
tr("Sch\351ma QElectroTech (*.qet)")
|
||||
);
|
||||
// si aucun nom n'est entre, renvoie faux.
|
||||
if (n_fichier.isEmpty()) return(false);
|
||||
// si le nom ne se termine pas par l'extension .qet, celle-ci est ajoutee
|
||||
if (!n_fichier.endsWith(".qet", Qt::CaseInsensitive)) n_fichier += ".qet";
|
||||
// tente d'enregistrer le fichier
|
||||
bool resultat_enregistrement = saveDiagramToFile(n_fichier);
|
||||
// si l'enregistrement reussit, le nom du fichier est conserve
|
||||
if (resultat_enregistrement) {
|
||||
file_name = n_fichier;
|
||||
updateWindowTitle();
|
||||
}
|
||||
// retourne un booleen representatif de la reussite de l'enregistrement
|
||||
return(resultat_enregistrement);
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les actions liees a la rollette de la souris
|
||||
@param e QWheelEvent decrivant l'evenement rollette
|
||||
@@ -315,39 +490,124 @@ void DiagramView::wheelEvent(QWheelEvent *e) {
|
||||
}
|
||||
|
||||
/**
|
||||
@return le titre de cette vue ; cela correspond au titre du schema
|
||||
visualise precede de la mention "Schema". Si le titre du schema est vide,
|
||||
la mention "Schema sans titre" est utilisee
|
||||
@see Diagram::title()
|
||||
Methode privee gerant l'enregistrement du fichier XML. S'il n'est pas possible
|
||||
d'ecrire dans le fichier, cette fonction affiche un message d'erreur et renvoie false.
|
||||
Autrement, elle renvoie true.
|
||||
@param n_fichier Nom du fichier dans lequel l'arbre XML doit etre ecrit
|
||||
@return true si l'enregistrement a reussi, false sinon
|
||||
*/
|
||||
QString DiagramView::title() const {
|
||||
QString view_title;
|
||||
QString diagram_title(scene -> title());
|
||||
if (diagram_title.isEmpty()) {
|
||||
view_title = tr("Sch\351ma sans titre");
|
||||
} else {
|
||||
view_title = QString(tr("Sch\351ma %1", "%1 is a diagram title")).arg(diagram_title);
|
||||
bool DiagramView::saveDiagramToFile(QString &n_fichier) {
|
||||
QFile fichier(n_fichier);
|
||||
if (!fichier.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
QMessageBox::warning(this, tr("Erreur"), tr("Impossible d'ecrire dans ce fichier"));
|
||||
return(false);
|
||||
}
|
||||
QTextStream out(&fichier);
|
||||
out.setCodec("UTF-8");
|
||||
|
||||
// l'export XML du schema est encapsule dans un pseudo-projet
|
||||
QDomDocument final_document;
|
||||
QDomElement project_root = final_document.createElement("project");
|
||||
project_root.setAttribute("version", QET::version);
|
||||
project_root.appendChild(final_document.importNode(scene -> toXml().documentElement(), true));
|
||||
final_document.appendChild(project_root);
|
||||
|
||||
out << final_document.toString(4);
|
||||
fichier.close();
|
||||
scene -> undoStack().setClean();
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
Exporte le schema.
|
||||
*/
|
||||
void DiagramView::dialogExport() {
|
||||
ExportDialog ed(scene, this);
|
||||
ed.exec();
|
||||
}
|
||||
|
||||
/**
|
||||
Imprime le schema.
|
||||
*/
|
||||
void DiagramView::dialogPrint() {
|
||||
// initialise l'acces a l'imprimante
|
||||
QPrinter qprin;
|
||||
#ifndef Q_OS_WIN32
|
||||
qprin.setOutputFormat(QPrinter::PdfFormat);
|
||||
#endif
|
||||
qprin.setOrientation(QPrinter::Landscape);
|
||||
qprin.setPageSize(QPrinter::A4);
|
||||
QPrintDialog qpd(&qprin, this);
|
||||
|
||||
if (qpd.exec() == QDialog::Accepted) {
|
||||
QPainter qp(&qprin);
|
||||
// impression physique (!= fichier PDF)
|
||||
if (qprin.outputFileName().isEmpty()) {
|
||||
// lorsqu'on imprime en paysage sur imprimante reelle, il faut pivoter soi-meme le rendu
|
||||
if (qprin.orientation() == QPrinter::Landscape) {
|
||||
qp.rotate(90.0);
|
||||
qp.translate(0.0, -qprin.pageRect().height());
|
||||
}
|
||||
}
|
||||
scene -> setDisplayGrid(false);
|
||||
scene -> setDrawTerminals(false);
|
||||
scene -> render(&qp, QRectF(), scene -> border(), Qt::KeepAspectRatio);
|
||||
scene -> setDrawTerminals(true);
|
||||
scene -> setDisplayGrid(true);
|
||||
}
|
||||
return(view_title);
|
||||
}
|
||||
|
||||
/**
|
||||
Edite les informations du schema.
|
||||
*/
|
||||
void DiagramView::editDiagramProperties() {
|
||||
if (scene -> isReadOnly()) return;
|
||||
void DiagramView::dialogEditInfos() {
|
||||
// recupere le cartouche du schema
|
||||
InsetProperties inset = scene -> border_and_inset.exportInset();
|
||||
|
||||
// recupere le cartouche et les dimensions du schema
|
||||
InsetProperties inset = scene -> border_and_inset.exportInset();
|
||||
BorderProperties border = scene -> border_and_inset.exportBorder();
|
||||
// recupere les dimensions du schema
|
||||
int columns_count_value = scene -> border_and_inset.nbColumn();
|
||||
int columns_width_value = qRound(scene -> border_and_inset.columnsWidth());
|
||||
int columns_height_value = qRound(scene -> border_and_inset.columnsHeight());
|
||||
|
||||
// construit le dialogue
|
||||
QDialog popup(diagramEditor());
|
||||
QDialog popup;
|
||||
popup.setMinimumWidth(400);
|
||||
popup.setWindowTitle(tr("Propri\351t\351s du sch\351ma", "window title"));
|
||||
popup.setWindowTitle(tr("Propri\351t\351s du sch\351ma"));
|
||||
|
||||
BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, &popup);
|
||||
InsetPropertiesWidget *inset_infos = new InsetPropertiesWidget(inset, false, &popup);
|
||||
QGroupBox *diagram_size_box = new QGroupBox(tr("Dimensions du sch\351ma"), &popup);
|
||||
QGridLayout diagram_size_box_layout(diagram_size_box);
|
||||
|
||||
QLabel *ds1 = new QLabel(tr("Colonnes :"));
|
||||
|
||||
QSpinBox *columns_count = new QSpinBox(diagram_size_box);
|
||||
columns_count -> setMinimum(scene -> border_and_inset.minNbColumns());
|
||||
columns_count -> setValue(columns_count_value);
|
||||
|
||||
QSpinBox *columns_width = new QSpinBox(diagram_size_box);
|
||||
columns_width -> setMinimum(1);
|
||||
columns_width -> setSingleStep(10);
|
||||
columns_width -> setValue(columns_width_value);
|
||||
columns_width -> setPrefix(tr("\327"));
|
||||
columns_width -> setSuffix(tr("px"));
|
||||
|
||||
QLabel *ds2 = new QLabel(tr("Hauteur :"));
|
||||
|
||||
QSpinBox *columns_height = new QSpinBox(diagram_size_box);
|
||||
columns_height -> setRange(qRound(scene -> border_and_inset.minColumnsHeight()), 10000);
|
||||
columns_height -> setSingleStep(80);
|
||||
columns_height -> setValue(columns_height_value);
|
||||
|
||||
diagram_size_box_layout.addWidget(ds1, 0, 0);
|
||||
diagram_size_box_layout.addWidget(columns_count, 0, 1);
|
||||
diagram_size_box_layout.addWidget(columns_width, 0, 2);
|
||||
diagram_size_box_layout.addWidget(ds2, 1, 0);
|
||||
diagram_size_box_layout.addWidget(columns_height, 1, 1);
|
||||
diagram_size_box_layout.setColumnStretch(0, 1);
|
||||
diagram_size_box_layout.setColumnStretch(1, 1);
|
||||
diagram_size_box_layout.setColumnStretch(2, 1);
|
||||
diagram_size_box_layout.setColumnStretch(3, 500);
|
||||
|
||||
InsetPropertiesWidget *inset_infos = new InsetPropertiesWidget(inset, false, &popup);
|
||||
|
||||
// boutons
|
||||
QDialogButtonBox boutons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
@@ -356,22 +616,30 @@ void DiagramView::editDiagramProperties() {
|
||||
|
||||
// ajout dans une disposition verticale
|
||||
QVBoxLayout layout_v(&popup);
|
||||
layout_v.addWidget(border_infos);
|
||||
layout_v.addWidget(diagram_size_box);
|
||||
layout_v.addWidget(inset_infos);
|
||||
layout_v.addStretch();
|
||||
layout_v.addWidget(&boutons);
|
||||
// si le dialogue est accepte
|
||||
if (popup.exec() == QDialog::Accepted) {
|
||||
InsetProperties new_inset = inset_infos -> insetProperties();
|
||||
BorderProperties new_border = border_infos -> borderProperties();
|
||||
InsetProperties new_inset = inset_infos -> insetProperties();
|
||||
|
||||
// s'il y a des modifications au cartouche
|
||||
if (new_inset != inset) {
|
||||
scene -> undoStack().push(new ChangeInsetCommand(scene, inset, new_inset));
|
||||
}
|
||||
|
||||
// s'il y a des modifications aux dimensions du schema
|
||||
if (new_border != border) {
|
||||
scene -> undoStack().push(new ChangeBorderCommand(scene, border, new_border));
|
||||
if (
|
||||
columns_count_value != columns_count -> value() ||\
|
||||
columns_width_value != columns_width -> value() ||\
|
||||
columns_height_value != columns_height -> value()
|
||||
) {
|
||||
ChangeBorderCommand *cbc = new ChangeBorderCommand(scene);
|
||||
cbc -> columnsCountDifference = columns_count -> value() - columns_count_value;
|
||||
cbc -> columnsWidthDifference = columns_width -> value() - columns_width_value;
|
||||
cbc -> columnsHeightDifference = columns_height -> value() - columns_height_value;
|
||||
scene -> undoStack().push(cbc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -387,44 +655,36 @@ bool DiagramView::hasSelectedItems() {
|
||||
Ajoute une colonne au schema.
|
||||
*/
|
||||
void DiagramView::addColumn() {
|
||||
if (scene -> isReadOnly()) return;
|
||||
BorderProperties old_bp = scene -> border_and_inset.exportBorder();
|
||||
BorderProperties new_bp = scene -> border_and_inset.exportBorder();
|
||||
new_bp.columns_count += 1;
|
||||
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
||||
ChangeBorderCommand *cbc = new ChangeBorderCommand(scene);
|
||||
cbc -> columnsCountDifference = 1;
|
||||
scene -> undoStack().push(cbc);
|
||||
}
|
||||
|
||||
/**
|
||||
Enleve une colonne au schema.
|
||||
*/
|
||||
void DiagramView::removeColumn() {
|
||||
if (scene -> isReadOnly()) return;
|
||||
BorderProperties old_bp = scene -> border_and_inset.exportBorder();
|
||||
BorderProperties new_bp = scene -> border_and_inset.exportBorder();
|
||||
new_bp.columns_count -= 1;
|
||||
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
||||
ChangeBorderCommand *cbc = new ChangeBorderCommand(scene);
|
||||
cbc -> columnsCountDifference = -1;
|
||||
scene -> undoStack().push(cbc);
|
||||
}
|
||||
|
||||
/**
|
||||
Agrandit le schema en hauteur
|
||||
*/
|
||||
void DiagramView::addRow() {
|
||||
if (scene -> isReadOnly()) return;
|
||||
BorderProperties old_bp = scene -> border_and_inset.exportBorder();
|
||||
BorderProperties new_bp = scene -> border_and_inset.exportBorder();
|
||||
new_bp.rows_count += 1;
|
||||
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
||||
void DiagramView::expand() {
|
||||
ChangeBorderCommand *cbc = new ChangeBorderCommand(scene);
|
||||
cbc -> columnsHeightDifference = 80.0;
|
||||
scene -> undoStack().push(cbc);
|
||||
}
|
||||
|
||||
/**
|
||||
Retrecit le schema en hauteur
|
||||
*/
|
||||
void DiagramView::removeRow() {
|
||||
if (scene -> isReadOnly()) return;
|
||||
BorderProperties old_bp = scene -> border_and_inset.exportBorder();
|
||||
BorderProperties new_bp = scene -> border_and_inset.exportBorder();
|
||||
new_bp.rows_count -= 1;
|
||||
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
||||
void DiagramView::shrink() {
|
||||
ChangeBorderCommand *cbc = new ChangeBorderCommand(scene);
|
||||
cbc -> columnsHeightDifference = -80.0;
|
||||
scene -> undoStack().push(cbc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -453,19 +713,12 @@ void DiagramView::adjustSceneRect() {
|
||||
Met a jour le titre du widget
|
||||
*/
|
||||
void DiagramView::updateWindowTitle() {
|
||||
QString view_title(title());
|
||||
|
||||
// verifie si le document a ete modifie
|
||||
bool modified_diagram = !(scene -> undoStack().isClean());
|
||||
|
||||
// specifie le titre du widget
|
||||
setWindowTitle(view_title + " [*]");
|
||||
setWindowModified(modified_diagram);
|
||||
|
||||
// emet le signal titleChanged en ajoutant manuellement [*] si le schema a ete modifie
|
||||
QString emitted_title = view_title;
|
||||
if (modified_diagram) emitted_title += " [*]";
|
||||
emit(titleChanged(this, emitted_title));
|
||||
QString window_title;
|
||||
if (file_name.isNull()) window_title += tr("nouveau sch\351ma");
|
||||
else window_title += file_name;
|
||||
window_title += "[*]";
|
||||
setWindowTitle(window_title);
|
||||
setWindowModified(!(scene -> undoStack().isClean()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -494,63 +747,6 @@ QRectF DiagramView::viewedSceneRect() const {
|
||||
return(QRectF(scene_left_top, scene_right_bottom));
|
||||
}
|
||||
|
||||
/**
|
||||
Cette methode permet de determiner s'il faut ou non integrer au projet un
|
||||
element dont on connait l'emplacement.
|
||||
L'element droppe est integre a la collection du projet :
|
||||
* s'il appartient a un autre projet, quelque soit la specification de
|
||||
l'utilisateur a ce propos ;
|
||||
* s'il appartient a la collection commune ou a la collection
|
||||
personnelle ET que l'utilisateur a autorise l'integration automatique
|
||||
des elements dans les projets.
|
||||
@param location Emplacement de l'element
|
||||
@return true si l'element doit etre integre, false sinon
|
||||
|
||||
*/
|
||||
bool DiagramView::mustIntegrateElement(const ElementsLocation &location) const {
|
||||
// l'utilisateur a-t-il autorise l'integration automatique des elements dans les projets ?
|
||||
bool auto_integration_enabled = QETApp::settings().value("diagrameditor/integrate-elements", true).toBool();
|
||||
|
||||
// l'element appartient-il a un projet et si oui, est-ce un autre projet ?
|
||||
bool elmt_from_project = location.project();
|
||||
bool elmt_from_another_project = elmt_from_project && location.project() != scene -> project();
|
||||
|
||||
// faut-il integrer l'element ?
|
||||
bool must_integrate_element = (elmt_from_another_project || (auto_integration_enabled && !elmt_from_project));
|
||||
|
||||
return(must_integrate_element);
|
||||
}
|
||||
|
||||
/**
|
||||
@param location Emplacement de l'element a ajouter sur le schema
|
||||
@param pos Position (dans les coordonnees de la vue) a laquelle l'element sera ajoute
|
||||
*/
|
||||
bool DiagramView::addElementAtPos(const ElementsLocation &location, const QPoint &pos) {
|
||||
// construit une instance de l'element correspondant a l'emplacement
|
||||
int etat;
|
||||
Element *el = new CustomElement(location, 0, 0, &etat);
|
||||
if (etat) {
|
||||
delete el;
|
||||
return(false);
|
||||
}
|
||||
|
||||
// pose de l'element sur le schema
|
||||
diagram() -> undoStack().push(new AddElementCommand(diagram(), el, mapToScene(pos)));
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
Fait en sorte que le schema ne soit editable que s'il n'est pas en lecture
|
||||
seule
|
||||
*/
|
||||
void DiagramView::applyReadOnly() {
|
||||
if (!scene) return;
|
||||
|
||||
bool is_writable = !scene -> isReadOnly();
|
||||
setInteractive(is_writable);
|
||||
setAcceptDrops(is_writable);
|
||||
}
|
||||
|
||||
/**
|
||||
Affiche un dialogue permettant d'editer le conducteur selectionne.
|
||||
Ne fait rien s'il y a 0 ou plusieurs conducteurs selectionnes.
|
||||
@@ -570,7 +766,6 @@ void DiagramView::editConductor() {
|
||||
@param edited_conductor Conducteur a editer
|
||||
*/
|
||||
void DiagramView::editConductor(Conductor *edited_conductor) {
|
||||
if (scene -> isReadOnly()) return;
|
||||
if (!edited_conductor) return;
|
||||
|
||||
// initialise l'editeur de proprietes pour le conducteur
|
||||
@@ -578,8 +773,8 @@ void DiagramView::editConductor(Conductor *edited_conductor) {
|
||||
ConductorPropertiesWidget *cpw = new ConductorPropertiesWidget(old_properties);
|
||||
|
||||
// l'insere dans un dialogue
|
||||
QDialog conductor_dialog(diagramEditor());
|
||||
conductor_dialog.setWindowTitle(tr("\311diter les propri\351t\351s d'un conducteur", "window title"));
|
||||
QDialog conductor_dialog;
|
||||
conductor_dialog.setWindowTitle(tr("\311diter les propri\351t\351s d'un conducteur"));
|
||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&conductor_dialog);
|
||||
dialog_layout -> addWidget(cpw);
|
||||
dialog_layout -> addStretch();
|
||||
@@ -607,7 +802,6 @@ void DiagramView::editConductor(Conductor *edited_conductor) {
|
||||
Reinitialise le profil des conducteurs selectionnes
|
||||
*/
|
||||
void DiagramView::resetConductors() {
|
||||
if (scene -> isReadOnly()) return;
|
||||
// recupere les conducteurs selectionnes
|
||||
QSet<Conductor *> selected_conductors = scene -> selectedConductors();
|
||||
|
||||
@@ -634,13 +828,12 @@ void DiagramView::resetConductors() {
|
||||
futurs nouveaux conducteurs
|
||||
*/
|
||||
void DiagramView::editDefaultConductorProperties() {
|
||||
if (scene -> isReadOnly()) return;
|
||||
// initialise l'editeur de proprietes pour le conducteur
|
||||
ConductorPropertiesWidget *cpw = new ConductorPropertiesWidget(scene -> defaultConductorProperties);
|
||||
|
||||
// l'insere dans un dialogue
|
||||
QDialog conductor_dialog(diagramEditor());
|
||||
conductor_dialog.setWindowTitle(tr("\311diter les propri\351t\351s par d\351faut des conducteurs", "window title"));
|
||||
QDialog conductor_dialog;
|
||||
conductor_dialog.setWindowTitle(tr("\311diter les propri\351t\351s par d\351faut des conducteurs"));
|
||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&conductor_dialog);
|
||||
dialog_layout -> addWidget(cpw);
|
||||
QDialogButtonBox *dbb = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
@@ -673,32 +866,9 @@ bool DiagramView::event(QEvent *e) {
|
||||
nouveau champ de texte.
|
||||
*/
|
||||
void DiagramView::addText() {
|
||||
if (scene -> isReadOnly()) return;
|
||||
is_adding_text = true;
|
||||
}
|
||||
|
||||
/**
|
||||
Cree un nouveau champ de texte et le place a la position pos
|
||||
en gerant l'annulation ; enfin, le signal textAdded est emis.
|
||||
@param pos Position du champ de texte ajoute
|
||||
@return le champ de texte ajoute
|
||||
*/
|
||||
DiagramTextItem *DiagramView::addDiagramTextAtPos(const QPointF &pos) {
|
||||
// cree un nouveau champ de texte
|
||||
DiagramTextItem *dti = new DiagramTextItem();
|
||||
dti -> setPlainText("_");
|
||||
dti -> previous_text = "_";
|
||||
|
||||
// le place a la position pos en gerant l'annulation
|
||||
scene -> undoStack().push(new AddTextCommand(scene, dti, pos));
|
||||
adjustSceneRect();
|
||||
|
||||
// emet le signal textAdded
|
||||
emit(textAdded(false));
|
||||
|
||||
return(dti);
|
||||
}
|
||||
|
||||
/**
|
||||
Gere le menu contextuel
|
||||
@param e Evenement decrivant la demande de menu contextuel
|
||||
@@ -719,8 +889,8 @@ void DiagramView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
context_menu -> addAction(qde -> infos_diagram);
|
||||
context_menu -> addAction(qde -> add_column);
|
||||
context_menu -> addAction(qde -> remove_column);
|
||||
context_menu -> addAction(qde -> add_row);
|
||||
context_menu -> addAction(qde -> remove_row);
|
||||
context_menu -> addAction(qde -> expand_diagram);
|
||||
context_menu -> addAction(qde -> shrink_diagram);
|
||||
} else {
|
||||
context_menu -> addAction(qde -> cut);
|
||||
context_menu -> addAction(qde -> copy);
|
||||
@@ -758,7 +928,7 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
// recupere le rectangle corespondant au cartouche
|
||||
QRectF inset_rect(
|
||||
Diagram::margin,
|
||||
Diagram::margin + bi.diagramHeight(),
|
||||
Diagram::margin + bi.columnsHeight(),
|
||||
bi.insetWidth(),
|
||||
bi.insetHeight()
|
||||
);
|
||||
@@ -771,14 +941,6 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
bi.columnsHeaderHeight()
|
||||
);
|
||||
|
||||
// recupere le rectangle correspondant aux en-tetes des lignes
|
||||
QRectF rows_rect(
|
||||
Diagram::margin,
|
||||
Diagram::margin,
|
||||
bi.rowsHeaderWidth(),
|
||||
bi.diagramHeight()
|
||||
);
|
||||
|
||||
// coordonnees du clic par rapport au schema
|
||||
QPointF click_pos = viewportTransform().inverted().map(e -> pos());
|
||||
|
||||
@@ -789,38 +951,10 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
} else {
|
||||
QGraphicsView::mouseDoubleClickEvent(e);
|
||||
}
|
||||
} else if (inset_rect.contains(click_pos) || columns_rect.contains(click_pos) || rows_rect.contains(click_pos)) {
|
||||
} else if (inset_rect.contains(click_pos) || columns_rect.contains(click_pos)) {
|
||||
// edite les proprietes du schema
|
||||
editDiagramProperties();
|
||||
dialogEditInfos();
|
||||
} else {
|
||||
QGraphicsView::mouseDoubleClickEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Cette methode ajoute l'element deisgne par l'emplacement location a la
|
||||
position pos. Si necessaire, elle demande l'integration de l'element au
|
||||
projet.
|
||||
@param location emplacement d'un element a ajouter sur le schema
|
||||
@param pos position voulue de l'element sur le schema
|
||||
@see mustIntegrateElement
|
||||
*/
|
||||
void DiagramView::addDroppedElement() {
|
||||
ElementsLocation location = next_location_;
|
||||
QPoint pos = next_position_;
|
||||
|
||||
if (!mustIntegrateElement(location)) {
|
||||
addElementAtPos(location, pos);
|
||||
} else {
|
||||
QString error_msg;
|
||||
IntegrationMoveElementsHandler *integ_handler = new IntegrationMoveElementsHandler(this);
|
||||
QString integ_path = scene -> project() -> integrateElement(location.toString(), integ_handler, error_msg);
|
||||
delete integ_handler;
|
||||
if (integ_path.isEmpty()) {
|
||||
qDebug() << error_msg;
|
||||
return;
|
||||
}
|
||||
addElementAtPos(ElementsLocation::locationFromString(integ_path), pos);
|
||||
}
|
||||
adjustSceneRect();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -18,9 +18,7 @@
|
||||
#ifndef DIAGRAMVIEW_H
|
||||
#define DIAGRAMVIEW_H
|
||||
#include <QtGui>
|
||||
#include "elementslocation.h"
|
||||
class Diagram;
|
||||
class DiagramTextItem;
|
||||
class QETDiagramEditor;
|
||||
class Conductor;
|
||||
/**
|
||||
@@ -31,36 +29,42 @@ class DiagramView : public QGraphicsView {
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
DiagramView(Diagram * = 0, QWidget * = 0);
|
||||
DiagramView(QWidget * = 0);
|
||||
virtual ~DiagramView();
|
||||
|
||||
private:
|
||||
DiagramView(const DiagramView &);
|
||||
|
||||
// attributs
|
||||
public:
|
||||
/// Nom de fichier du schema edite
|
||||
QString file_name;
|
||||
|
||||
private:
|
||||
Diagram *scene;
|
||||
QMenu *context_menu;
|
||||
QAction *paste_here;
|
||||
QPoint paste_here_pos;
|
||||
bool is_adding_text;
|
||||
ElementsLocation next_location_;
|
||||
QPoint next_position_;
|
||||
|
||||
// methodes
|
||||
public:
|
||||
QString title() const;
|
||||
void editDiagramProperties();
|
||||
bool open(QString, int * = NULL);
|
||||
void closeEvent(QCloseEvent *);
|
||||
bool save();
|
||||
bool saveAs();
|
||||
void dialogExport();
|
||||
void dialogEditInfos();
|
||||
void dialogPrint();
|
||||
void addColumn();
|
||||
void removeColumn();
|
||||
void addRow();
|
||||
void removeRow();
|
||||
void expand();
|
||||
void shrink();
|
||||
/// @return Le schema visualise par ce DiagramView
|
||||
Diagram *diagram() { return(scene); }
|
||||
QETDiagramEditor *diagramEditor() const;
|
||||
bool hasSelectedItems();
|
||||
void addText();
|
||||
DiagramTextItem *addDiagramTextAtPos(const QPointF &);
|
||||
|
||||
protected:
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *);
|
||||
@@ -69,14 +73,13 @@ class DiagramView : public QGraphicsView {
|
||||
virtual bool event(QEvent *);
|
||||
|
||||
private:
|
||||
bool saveDiagramToFile(QString &);
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void dragEnterEvent(QDragEnterEvent *);
|
||||
void dragLeaveEvent(QDragLeaveEvent *);
|
||||
void dragMoveEvent(QDragMoveEvent *);
|
||||
void dropEvent(QDropEvent *);
|
||||
QRectF viewedSceneRect() const;
|
||||
bool mustIntegrateElement(const ElementsLocation &) const;
|
||||
bool addElementAtPos(const ElementsLocation &, const QPoint &);
|
||||
|
||||
signals:
|
||||
/// Signal emis lorsque la selection change
|
||||
@@ -85,10 +88,6 @@ class DiagramView : public QGraphicsView {
|
||||
void modeChanged();
|
||||
/// Signal emis lorsqu'un texte a ete pose
|
||||
void textAdded(bool);
|
||||
/// Signal emis lorsque le titre du schema change
|
||||
void titleChanged(DiagramView *, const QString &);
|
||||
/// Signal emis avant l'integration d'un element
|
||||
void aboutToAddElement();
|
||||
|
||||
public slots:
|
||||
void selectNothing();
|
||||
@@ -114,8 +113,6 @@ class DiagramView : public QGraphicsView {
|
||||
void editDefaultConductorProperties();
|
||||
|
||||
private slots:
|
||||
void addDroppedElement();
|
||||
void adjustGridToZoom();
|
||||
void applyReadOnly();
|
||||
};
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -74,7 +74,6 @@ class CustomElementGraphicPart : public CustomElementPart {
|
||||
|
||||
/// Destructeur
|
||||
virtual ~CustomElementGraphicPart() {
|
||||
if (style_editor -> parentWidget()) return; // l'editeur de style sera supprime par son parent
|
||||
delete style_editor;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -29,7 +29,7 @@ DeletePartsCommand::DeletePartsCommand(
|
||||
const QList<QGraphicsItem *> parts,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QObject::tr("suppression", "undo caption"), parent),
|
||||
QUndoCommand(QObject::tr("suppression"), parent),
|
||||
deleted_parts(parts),
|
||||
editor_scene(scene)
|
||||
{
|
||||
@@ -59,94 +59,6 @@ void DeletePartsCommand::redo() {
|
||||
}
|
||||
}
|
||||
|
||||
/*** CutPartsCommand ***/
|
||||
/**
|
||||
Constructeur
|
||||
@param scene ElementScene concernee
|
||||
@param parts Liste des parties collees
|
||||
@param parent QUndoCommand parent
|
||||
*/
|
||||
PastePartsCommand::PastePartsCommand(
|
||||
ElementView *view,
|
||||
const ElementContent &c,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(parent),
|
||||
content_(c),
|
||||
editor_view_(view),
|
||||
editor_scene_(view -> scene()),
|
||||
uses_offset(false),
|
||||
first_redo(true)
|
||||
{
|
||||
setText(QObject::tr("coller"));
|
||||
editor_scene_ -> qgiManager().manage(content_);
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
PastePartsCommand::~PastePartsCommand() {
|
||||
editor_scene_ -> qgiManager().release(content_);
|
||||
}
|
||||
|
||||
/// annule le coller
|
||||
void PastePartsCommand::undo() {
|
||||
// enleve les parties
|
||||
foreach(QGraphicsItem *part, content_) editor_scene_ -> removeItem(part);
|
||||
if (uses_offset) {
|
||||
editor_view_ -> offset_paste_count_ = old_offset_paste_count_;
|
||||
editor_view_ -> start_top_left_corner_ = old_start_top_left_corner_;
|
||||
}
|
||||
editor_view_ -> adjustSceneRect();
|
||||
}
|
||||
|
||||
/// refait le coller
|
||||
void PastePartsCommand::redo() {
|
||||
if (first_redo) first_redo = false;
|
||||
else {
|
||||
// pose les parties
|
||||
foreach(QGraphicsItem *part, content_) editor_scene_ -> addItem(part);
|
||||
if (uses_offset) {
|
||||
editor_view_ -> offset_paste_count_ = new_offset_paste_count_;
|
||||
editor_view_ -> start_top_left_corner_ = new_start_top_left_corner_;
|
||||
}
|
||||
}
|
||||
foreach(QGraphicsItem *part, content_) part -> setSelected(true);
|
||||
editor_view_ -> adjustSceneRect();
|
||||
}
|
||||
|
||||
/**
|
||||
Indique a cet objet d'annulation que le c/c a annuler ou refaire etait un
|
||||
c/c avec decalage ; il faut plus d'informations pour annuler ce type de
|
||||
collage.
|
||||
*/
|
||||
void PastePartsCommand::setOffset(int old_offset_pc, const QPointF &old_start_tlc, int new_offset_pc, const QPointF &new_start_tlc) {
|
||||
old_offset_paste_count_ = old_offset_pc;
|
||||
old_start_top_left_corner_ = old_start_tlc;
|
||||
new_offset_paste_count_ = new_offset_pc;
|
||||
new_start_top_left_corner_ = new_start_tlc;
|
||||
uses_offset = true;
|
||||
}
|
||||
|
||||
/*** CutPartsCommand ***/
|
||||
/**
|
||||
Constructeur
|
||||
@param scene ElementScene concernee
|
||||
@param parts Liste des parties coupees
|
||||
@param parent QUndoCommand parent
|
||||
*/
|
||||
CutPartsCommand::CutPartsCommand(
|
||||
ElementScene *scene,
|
||||
const QList<QGraphicsItem *> parts,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
DeletePartsCommand(scene, parts, parent)
|
||||
{
|
||||
setText(QString(QObject::tr("couper des parties", "undo caption")));
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
CutPartsCommand::~CutPartsCommand() {
|
||||
}
|
||||
|
||||
/*** MovePartsCommand ***/
|
||||
/**
|
||||
Constructeur
|
||||
@@ -161,7 +73,7 @@ MovePartsCommand::MovePartsCommand(
|
||||
const QList<QGraphicsItem *> parts,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QObject::tr("d\351placement", "undo caption"), parent),
|
||||
QUndoCommand(QObject::tr("d\351placement"), parent),
|
||||
movement(m),
|
||||
first_redo(true)
|
||||
{
|
||||
@@ -202,7 +114,7 @@ AddPartCommand::AddPartCommand(
|
||||
QGraphicsItem *p,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QString(QObject::tr("ajout %1", "undo caption")).arg(name), parent),
|
||||
QUndoCommand(QObject::tr("ajout ") + name, parent),
|
||||
part(p),
|
||||
editor_scene(scene),
|
||||
first_redo(true)
|
||||
@@ -249,7 +161,7 @@ ChangePartCommand::ChangePartCommand(
|
||||
const QVariant &new_v,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QString(QObject::tr("modification %1", "undo caption")).arg(name), parent),
|
||||
QUndoCommand(QObject::tr("modification ") + name, parent),
|
||||
cep(part),
|
||||
property(prop),
|
||||
old_value(old_v),
|
||||
@@ -284,7 +196,7 @@ ChangePolygonPointsCommand::ChangePolygonPointsCommand(
|
||||
const QVector<QPointF> &n_points,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QObject::tr("modification points polygone", "undo caption"), parent),
|
||||
QUndoCommand(QObject::tr("modification points polygone"), parent),
|
||||
polygon(p),
|
||||
old_points(o_points),
|
||||
new_points(n_points)
|
||||
@@ -324,7 +236,7 @@ ChangeHotspotCommand::ChangeHotspotCommand(
|
||||
const QPoint &o,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QObject::tr("modification dimensions/hotspot", "undo caption"), parent),
|
||||
QUndoCommand(QObject::tr("modification dimensions/hotspot"), parent),
|
||||
element(element_scene),
|
||||
size_before(size_1),
|
||||
size_after(size_2),
|
||||
@@ -385,7 +297,7 @@ ChangeNamesCommand::ChangeNamesCommand(
|
||||
const NamesList &after,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QObject::tr("modification noms", "undo caption"), parent),
|
||||
QUndoCommand(QObject::tr("modification noms"), parent),
|
||||
names_before(before),
|
||||
names_after(after),
|
||||
element(element_scene)
|
||||
@@ -419,7 +331,7 @@ ChangeOrientationsCommand::ChangeOrientationsCommand(
|
||||
const OrientationSet &after,
|
||||
QUndoCommand *parent
|
||||
) :
|
||||
QUndoCommand(QObject::tr("modification orientations", "undo caption"), parent),
|
||||
QUndoCommand(QObject::tr("modification orientations"), parent),
|
||||
ori_before(before),
|
||||
ori_after(after),
|
||||
element(element_scene)
|
||||
@@ -463,16 +375,16 @@ ChangeZValueCommand::ChangeZValueCommand(
|
||||
|
||||
// choisit le nom en fonction du traitement
|
||||
if (option == BringForward) {
|
||||
setText(QObject::tr("amener au premier plan", "undo caption"));
|
||||
setText(QObject::tr("amener au premier plan"));
|
||||
applyBringForward(items_list);
|
||||
} else if (option == Raise) {
|
||||
setText(QObject::tr("rapprocher", "undo caption"));
|
||||
setText(QObject::tr("rapprocher"));
|
||||
applyRaise(items_list);
|
||||
} else if (option == Lower) {
|
||||
setText(QObject::tr("\351loigner", "undo caption"));
|
||||
setText(QObject::tr("\351loigner"));
|
||||
applyLower(items_list);
|
||||
} else if (option == SendBackward) {
|
||||
setText(QObject::tr("envoyer au fond", "undo caption"));
|
||||
setText(QObject::tr("envoyer au fond"));
|
||||
applySendBackward(items_list);
|
||||
}
|
||||
}
|
||||
@@ -571,7 +483,7 @@ void ChangeZValueCommand::applySendBackward(const QList<QGraphicsItem *> &items_
|
||||
@param parent QUndoCommand parent
|
||||
*/
|
||||
AllowInternalConnectionsCommand::AllowInternalConnectionsCommand(ElementScene *elmt, bool allow, QUndoCommand *parent) :
|
||||
QUndoCommand(QObject::tr("modification connexions internes", "undo caption"), parent),
|
||||
QUndoCommand(QObject::tr("modification connexions internes"), parent),
|
||||
element(elmt),
|
||||
ic(allow)
|
||||
{
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -19,9 +19,7 @@
|
||||
#define EDITOR_COMMANDS_H
|
||||
#include "customelementpart.h"
|
||||
#include "partpolygon.h"
|
||||
#include "elementview.h"
|
||||
#include "elementscene.h"
|
||||
#include "elementcontent.h"
|
||||
#include "qgimanager.h"
|
||||
#include <QtGui>
|
||||
/**
|
||||
@@ -49,52 +47,6 @@ class DeletePartsCommand : public QUndoCommand {
|
||||
ElementScene *editor_scene;
|
||||
};
|
||||
|
||||
/**
|
||||
Cette classe represente l'action de coller quelque chose dans un element
|
||||
*/
|
||||
class PastePartsCommand : public QUndoCommand {
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
PastePartsCommand(ElementView *, const ElementContent &, QUndoCommand * = 0);
|
||||
virtual ~PastePartsCommand();
|
||||
private:
|
||||
PastePartsCommand(const PastePartsCommand &);
|
||||
|
||||
// methodes
|
||||
public:
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
virtual void setOffset(int, const QPointF &, int, const QPointF &);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
/// contenu ajoute
|
||||
ElementContent content_;
|
||||
/// schema sur lequel on colle les elements et conducteurs
|
||||
ElementView *editor_view_;
|
||||
ElementScene *editor_scene_;
|
||||
/// Informations pour annuler un c/c avec decalage
|
||||
int old_offset_paste_count_;
|
||||
QPointF old_start_top_left_corner_;
|
||||
int new_offset_paste_count_;
|
||||
QPointF new_start_top_left_corner_;
|
||||
bool uses_offset;
|
||||
/// booleen pour empecher le premier appel a redo
|
||||
bool first_redo;
|
||||
};
|
||||
|
||||
/**
|
||||
Cette classe represente l'action de supprimer des parties d'un element
|
||||
*/
|
||||
class CutPartsCommand : public DeletePartsCommand {
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
CutPartsCommand(ElementScene *, const QList<QGraphicsItem *>, QUndoCommand * = 0);
|
||||
virtual ~CutPartsCommand();
|
||||
private:
|
||||
CutPartsCommand(const CutPartsCommand &);
|
||||
};
|
||||
|
||||
/**
|
||||
Cette classe represente l'action de deplacer une ou plusieurs
|
||||
parties lors de l'edition d'un element
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -22,7 +22,7 @@ class QETElementEditor;
|
||||
class ElementScene;
|
||||
class CustomElementPart;
|
||||
/**
|
||||
Cette classe est la classe de base pour les editeurs de parties dans
|
||||
Cette classe est la classe de base pour les editeurs de aprties dans
|
||||
l'editeur d'element. Elle fournit des methodes pour acceder facilement
|
||||
a l'editeur, a la pile d'annulation, a la scene d'edition ou encore pour
|
||||
ajouter facilement une annulation de type ChangePartCommand.
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "qetelementeditor.h"
|
||||
#include <cmath>
|
||||
#include "partline.h"
|
||||
#include "partrectangle.h"
|
||||
#include "partellipse.h"
|
||||
#include "partcircle.h"
|
||||
#include "partpolygon.h"
|
||||
@@ -29,7 +28,9 @@
|
||||
#include "partarc.h"
|
||||
#include "hotspoteditor.h"
|
||||
#include "editorcommands.h"
|
||||
#include "elementcontent.h"
|
||||
|
||||
const int ElementScene::xGrid = 10;
|
||||
const int ElementScene::yGrid = 10;
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@@ -46,8 +47,6 @@ ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
|
||||
element_editor(editor)
|
||||
{
|
||||
current_polygon = NULL;
|
||||
setGrid(1, 1);
|
||||
initPasteArea();
|
||||
undo_stack.setClean();
|
||||
}
|
||||
|
||||
@@ -69,13 +68,6 @@ void ElementScene::slot_addLine() {
|
||||
behavior = Line;
|
||||
}
|
||||
|
||||
/**
|
||||
Passe la scene en mode "ajout de rectangle"
|
||||
*/
|
||||
void ElementScene::slot_addRectangle() {
|
||||
behavior = Rectangle;
|
||||
}
|
||||
|
||||
/**
|
||||
Passe la scene en mode "ajout de cercle"
|
||||
*/
|
||||
@@ -112,6 +104,7 @@ void ElementScene::slot_addTerminal() {
|
||||
behavior = Terminal;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Passe la scene en mode "ajout d'arc de cercle"
|
||||
*/
|
||||
@@ -131,17 +124,7 @@ void ElementScene::slot_addTextField() {
|
||||
@param e objet decrivant l'evenement
|
||||
*/
|
||||
void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
||||
QPointF event_pos = e -> scenePos();
|
||||
if (mustSnapToGrid(e)) snapToGrid(event_pos);
|
||||
|
||||
if (behavior != Polygon && current_polygon != NULL) current_polygon = NULL;
|
||||
if (behavior == PasteArea) {
|
||||
QRectF current_rect(paste_area_ -> rect());
|
||||
current_rect.moveCenter(event_pos);
|
||||
paste_area_ -> setRect(current_rect);
|
||||
return;
|
||||
}
|
||||
|
||||
QRectF temp_rect;
|
||||
qreal radius;
|
||||
QPointF temp_point;
|
||||
@@ -149,26 +132,21 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
||||
if (e -> buttons() & Qt::LeftButton) {
|
||||
switch(behavior) {
|
||||
case Line:
|
||||
current_line -> setLine(QLineF(current_line -> line().p1(), event_pos));
|
||||
break;
|
||||
case Rectangle:
|
||||
temp_rect = current_rectangle -> rect();
|
||||
temp_rect.setBottomRight(event_pos);
|
||||
current_rectangle -> setRect(temp_rect);
|
||||
current_line -> setLine(QLineF(current_line -> line().p1(), e -> scenePos()));
|
||||
break;
|
||||
case Ellipse:
|
||||
temp_rect = current_ellipse -> rect();
|
||||
temp_rect.setBottomRight(event_pos);
|
||||
temp_rect.setBottomRight(e -> scenePos());
|
||||
current_ellipse -> setRect(temp_rect);
|
||||
break;
|
||||
case Arc:
|
||||
temp_rect = current_arc -> rect();
|
||||
temp_rect.setBottomRight(event_pos);
|
||||
temp_rect.setBottomRight(e -> scenePos());
|
||||
current_arc -> setRect(temp_rect);
|
||||
break;
|
||||
case Circle:
|
||||
temp_rect = current_circle -> rect();
|
||||
temp_point = event_pos - current_circle -> mapToScene(temp_rect.center());
|
||||
temp_point = e -> scenePos() - current_circle -> mapToScene(temp_rect.center());
|
||||
radius = sqrt(pow(temp_point.x(), 2) + pow(temp_point.y(), 2));
|
||||
temp_rect = QRectF(
|
||||
temp_rect.center() - QPointF(radius, radius),
|
||||
@@ -180,35 +158,17 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
||||
if (current_polygon == NULL) break;
|
||||
temp_polygon = current_polygon -> polygon();
|
||||
temp_polygon.pop_back();
|
||||
temp_polygon << event_pos;
|
||||
temp_polygon << e -> scenePos();
|
||||
current_polygon -> setPolygon(temp_polygon);
|
||||
break;
|
||||
case Normal:
|
||||
default:
|
||||
QList<QGraphicsItem *> selected_items = selectedItems();
|
||||
if (!selected_items.isEmpty()) {
|
||||
// mouvement de souris realise depuis le dernier press event
|
||||
QPointF mouse_movement = e -> scenePos() - moving_press_pos;
|
||||
|
||||
// application de ce mouvement a la fsi_pos enregistre dans le dernier press event
|
||||
QPointF new_fsi_pos = fsi_pos + mouse_movement;
|
||||
|
||||
// snap eventuel de la nouvelle fsi_pos
|
||||
if (mustSnapToGrid(e)) snapToGrid(new_fsi_pos);
|
||||
|
||||
// difference entre la fsi_pos finale et la fsi_pos courante = mouvement a appliquer
|
||||
|
||||
QPointF current_fsi_pos = selected_items.first() -> scenePos();
|
||||
QPointF final_movement = new_fsi_pos - current_fsi_pos;
|
||||
foreach(QGraphicsItem *qgi, selected_items) {
|
||||
qgi -> moveBy(final_movement.x(), final_movement.y());
|
||||
}
|
||||
}
|
||||
QGraphicsScene::mouseMoveEvent(e);
|
||||
}
|
||||
} else if (behavior == Polygon && current_polygon != NULL) {
|
||||
temp_polygon = current_polygon -> polygon();
|
||||
temp_polygon.pop_back();
|
||||
temp_polygon << event_pos;
|
||||
temp_polygon << e -> scenePos();
|
||||
current_polygon -> setPolygon(temp_polygon);
|
||||
} else QGraphicsScene::mouseMoveEvent(e);
|
||||
}
|
||||
@@ -218,34 +178,27 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
||||
@param e objet decrivant l'evenement
|
||||
*/
|
||||
void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
||||
QPointF event_pos = e -> scenePos();
|
||||
if (mustSnapToGrid(e)) snapToGrid(event_pos);
|
||||
|
||||
if (behavior != Polygon && current_polygon != NULL) current_polygon = NULL;
|
||||
QPolygonF temp_polygon;
|
||||
if (e -> button() & Qt::LeftButton) {
|
||||
switch(behavior) {
|
||||
case Line:
|
||||
current_line = new PartLine(element_editor, 0, this);
|
||||
current_line -> setLine(QLineF(event_pos, event_pos));
|
||||
break;
|
||||
case Rectangle:
|
||||
current_rectangle = new PartRectangle(element_editor, 0, this);
|
||||
current_rectangle -> setRect(QRectF(event_pos, QSizeF(0.0, 0.0)));
|
||||
current_line -> setLine(QLineF(e -> scenePos(), e -> scenePos()));
|
||||
break;
|
||||
case Ellipse:
|
||||
current_ellipse = new PartEllipse(element_editor, 0, this);
|
||||
current_ellipse -> setRect(QRectF(event_pos, QSizeF(0.0, 0.0)));
|
||||
current_ellipse -> setRect(QRectF(e -> scenePos(), QSizeF(0.0, 0.0)));
|
||||
current_ellipse -> setProperty("antialias", true);
|
||||
break;
|
||||
case Arc:
|
||||
current_arc = new PartArc(element_editor, 0, this);
|
||||
current_arc -> setRect(QRectF(event_pos, QSizeF(0.0, 0.0)));
|
||||
current_arc -> setRect(QRectF(e -> scenePos(), QSizeF(0.0, 0.0)));
|
||||
current_arc -> setProperty("antialias", true);
|
||||
break;
|
||||
case Circle:
|
||||
current_circle = new PartCircle(element_editor, 0, this);
|
||||
current_circle -> setRect(QRectF(event_pos, QSizeF(0.0, 0.0)));
|
||||
current_circle -> setRect(QRectF(e -> scenePos(), QSizeF(0.0, 0.0)));
|
||||
current_circle -> setProperty("antialias", true);
|
||||
break;
|
||||
case Polygon:
|
||||
@@ -254,23 +207,14 @@ void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
||||
temp_polygon = QPolygonF(0);
|
||||
} else temp_polygon = current_polygon -> polygon();
|
||||
// au debut, on insere deux points
|
||||
if (!temp_polygon.count()) temp_polygon << event_pos;
|
||||
temp_polygon << event_pos;
|
||||
if (!temp_polygon.count()) temp_polygon << e -> scenePos();
|
||||
temp_polygon << e -> scenePos();
|
||||
current_polygon -> setPolygon(temp_polygon);
|
||||
break;
|
||||
case Normal:
|
||||
default:
|
||||
QGraphicsScene::mousePressEvent(e);
|
||||
// gestion des deplacements de parties
|
||||
if (!selectedItems().isEmpty()) {
|
||||
fsi_pos = selectedItems().first() -> scenePos();
|
||||
moving_press_pos = e -> scenePos();
|
||||
moving_parts_ = true;
|
||||
} else {
|
||||
fsi_pos = QPoint();
|
||||
moving_press_pos = QPoint();
|
||||
moving_parts_ = false;
|
||||
}
|
||||
if (!selectedItems().isEmpty()) fsi_pos = selectedItems().first() -> scenePos();
|
||||
}
|
||||
} else QGraphicsScene::mousePressEvent(e);
|
||||
}
|
||||
@@ -280,97 +224,71 @@ void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
||||
@param e objet decrivant l'evenement
|
||||
*/
|
||||
void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
||||
QPointF event_pos = e -> scenePos();
|
||||
if (mustSnapToGrid(e)) snapToGrid(event_pos);
|
||||
|
||||
PartTerminal *terminal;
|
||||
PartText *text;
|
||||
PartTextField *textfield;
|
||||
if (behavior != Polygon && current_polygon != NULL) current_polygon = NULL;
|
||||
|
||||
if (behavior == PasteArea) {
|
||||
defined_paste_area_ = paste_area_ -> rect();
|
||||
removeItem(paste_area_);
|
||||
emit(pasteAreaDefined(defined_paste_area_));
|
||||
behavior = Normal;
|
||||
return;
|
||||
}
|
||||
|
||||
if (e -> button() & Qt::LeftButton) {
|
||||
switch(behavior) {
|
||||
case Line:
|
||||
if (qgiManager().manages(current_line)) break;
|
||||
undo_stack.push(new AddPartCommand(tr("ligne"), this, current_line));
|
||||
emit(partsAdded());
|
||||
endCurrentBehavior(e);
|
||||
break;
|
||||
case Rectangle:
|
||||
if (qgiManager().manages(current_rectangle)) break;
|
||||
current_rectangle -> setRect(current_rectangle -> rect().normalized());
|
||||
undo_stack.push(new AddPartCommand(tr("rectangle"), this, current_rectangle));
|
||||
emit(partsAdded());
|
||||
endCurrentBehavior(e);
|
||||
break;
|
||||
case Ellipse:
|
||||
if (qgiManager().manages(current_ellipse)) break;
|
||||
current_ellipse -> setRect(current_ellipse -> rect().normalized());
|
||||
undo_stack.push(new AddPartCommand(tr("ellipse"), this, current_ellipse));
|
||||
emit(partsAdded());
|
||||
endCurrentBehavior(e);
|
||||
break;
|
||||
case Arc:
|
||||
if (qgiManager().manages(current_arc)) break;
|
||||
current_arc-> setRect(current_arc -> rect().normalized());
|
||||
undo_stack.push(new AddPartCommand(tr("arc"), this, current_arc));
|
||||
emit(partsAdded());
|
||||
endCurrentBehavior(e);
|
||||
break;
|
||||
case Circle:
|
||||
if (qgiManager().manages(current_circle)) break;
|
||||
current_circle -> setRect(current_circle -> rect().normalized());
|
||||
undo_stack.push(new AddPartCommand(tr("cercle"), this, current_circle));
|
||||
emit(partsAdded());
|
||||
endCurrentBehavior(e);
|
||||
break;
|
||||
case Terminal:
|
||||
terminal = new PartTerminal(element_editor, 0, this);
|
||||
terminal -> setPos(event_pos);
|
||||
terminal -> setPos(e -> scenePos());
|
||||
undo_stack.push(new AddPartCommand(tr("borne"), this, terminal));
|
||||
emit(partsAdded());
|
||||
endCurrentBehavior(e);
|
||||
break;
|
||||
case Text:
|
||||
text = new PartText(element_editor, 0, this);
|
||||
text -> setPos(event_pos);
|
||||
text -> setPos(e -> scenePos());
|
||||
undo_stack.push(new AddPartCommand(tr("texte"), this, text));
|
||||
emit(partsAdded());
|
||||
endCurrentBehavior(e);
|
||||
break;
|
||||
case TextField:
|
||||
textfield = new PartTextField(element_editor, 0, this);
|
||||
textfield -> setPos(event_pos);
|
||||
textfield -> setPos(e -> scenePos());
|
||||
undo_stack.push(new AddPartCommand(tr("champ de texte"), this, textfield));
|
||||
emit(partsAdded());
|
||||
endCurrentBehavior(e);
|
||||
break;
|
||||
case Normal:
|
||||
default:
|
||||
QGraphicsScene::mouseReleaseEvent(e);
|
||||
// detecte les deplacements de parties
|
||||
if (!selectedItems().isEmpty() && moving_parts_) {
|
||||
if (!selectedItems().isEmpty()) {
|
||||
QPointF movement = selectedItems().first() -> scenePos() - fsi_pos;
|
||||
if (!movement.isNull()) {
|
||||
undo_stack.push(new MovePartsCommand(movement, this, selectedItems()));
|
||||
}
|
||||
}
|
||||
QGraphicsScene::mouseReleaseEvent(e);
|
||||
moving_parts_ = false;
|
||||
}
|
||||
} else if (e -> button() & Qt::RightButton) {
|
||||
if (behavior == Polygon && current_polygon != NULL) {
|
||||
if (behavior == Polygon) {
|
||||
behavior = Normal;
|
||||
undo_stack.push(new AddPartCommand(tr("polygone"), this, current_polygon));
|
||||
current_polygon = NULL;
|
||||
emit(partsAdded());
|
||||
endCurrentBehavior(e);
|
||||
emit(needNormalMode());
|
||||
} else QGraphicsScene::mouseReleaseEvent(e);
|
||||
} else QGraphicsScene::mouseReleaseEvent(e);
|
||||
}
|
||||
@@ -399,10 +317,6 @@ void ElementScene::drawBackground(QPainter *p, const QRectF &r) {
|
||||
p -> setBrush(Qt::NoBrush);
|
||||
p -> drawRect(drawable_area);
|
||||
|
||||
// on dessine un point de la grille sur 10
|
||||
int drawn_x_grid = x_grid * 10;
|
||||
int drawn_y_grid = y_grid * 10;
|
||||
|
||||
if (r.width() < 2500 && r.height() < 2500) {
|
||||
// dessine les points de la grille
|
||||
p -> setPen(Qt::black);
|
||||
@@ -411,12 +325,12 @@ void ElementScene::drawBackground(QPainter *p, const QRectF &r) {
|
||||
qreal limite_y = r.y() + r.height();
|
||||
|
||||
int g_x = (int)ceil(r.x());
|
||||
while (g_x % drawn_x_grid) ++ g_x;
|
||||
while (g_x % xGrid) ++ g_x;
|
||||
int g_y = (int)ceil(r.y());
|
||||
while (g_y % drawn_y_grid) ++ g_y;
|
||||
while (g_y % yGrid) ++ g_y;
|
||||
|
||||
for (int gx = g_x ; gx < limite_x ; gx += drawn_x_grid) {
|
||||
for (int gy = g_y ; gy < limite_y ; gy += drawn_y_grid) {
|
||||
for (int gx = g_x ; gx < limite_x ; gx += xGrid) {
|
||||
for (int gy = g_y ; gy < limite_y ; gy += yGrid) {
|
||||
p -> drawPoint(gx, gy);
|
||||
}
|
||||
}
|
||||
@@ -444,50 +358,11 @@ void ElementScene::drawForeground(QPainter *p, const QRectF &) {
|
||||
p -> restore();
|
||||
}
|
||||
|
||||
/**
|
||||
A partir d'un evenement souris, cette methode regarde si la touche shift est
|
||||
enfoncee ou non. Si oui, elle laisse le comportement en cours (cercle,
|
||||
texte, polygone, ...). Si non, elle repasse en mode normal / selection.
|
||||
@param e objet decrivant l'evenement souris
|
||||
*/
|
||||
void ElementScene::endCurrentBehavior(const QGraphicsSceneMouseEvent *event) {
|
||||
if (!(event -> modifiers() & Qt::ShiftModifier)) {
|
||||
// la touche Shift n'est pas enfoncee : on demande le mode normal
|
||||
behavior = Normal;
|
||||
emit(needNormalMode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@return la taille horizontale de la grille
|
||||
*/
|
||||
int ElementScene::xGrid() const {
|
||||
return(x_grid);
|
||||
}
|
||||
|
||||
/**
|
||||
@return la taille verticale de la grille
|
||||
*/
|
||||
int ElementScene::yGrid() const {
|
||||
return(y_grid);
|
||||
}
|
||||
|
||||
/**
|
||||
@param x_grid Taille horizontale de la grille
|
||||
@param y_grid Taille verticale de la grille
|
||||
*/
|
||||
void ElementScene::setGrid(int x_g, int y_g) {
|
||||
x_grid = x_g ? x_g : 1;
|
||||
y_grid = y_g ? y_g : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
Exporte l'element en XML
|
||||
@param diagram Booleen (a vrai par defaut) indiquant si le XML genere doit
|
||||
representer tout l'element ou seulement les elements selectionnes
|
||||
@return un document XML decrivant l'element
|
||||
*/
|
||||
const QDomDocument ElementScene::toXml(bool all_parts) const {
|
||||
const QDomDocument ElementScene::toXml() const {
|
||||
// document XML
|
||||
QDomDocument xml_document;
|
||||
|
||||
@@ -508,8 +383,6 @@ const QDomDocument ElementScene::toXml(bool all_parts) const {
|
||||
QDomElement description = xml_document.createElement("description");
|
||||
// description de l'element
|
||||
foreach(QGraphicsItem *qgi, zItems(true)) {
|
||||
// si l'export ne concerne que la selection, on ignore les parties non selectionnees
|
||||
if (!all_parts && !qgi -> isSelected()) continue;
|
||||
if (CustomElementPart *ce = dynamic_cast<CustomElementPart *>(qgi)) {
|
||||
if (ce -> isUseless()) continue;
|
||||
description.appendChild(ce -> toXml(xml_document));
|
||||
@@ -522,90 +395,91 @@ const QDomDocument ElementScene::toXml(bool all_parts) const {
|
||||
}
|
||||
|
||||
/**
|
||||
@param xml_document un document XML decrivant un element
|
||||
@return le boundingRect du contenu de l'element
|
||||
*/
|
||||
QRectF ElementScene::boundingRectFromXml(const QDomDocument &xml_document) {
|
||||
// charge les parties depuis le document XML
|
||||
ElementContent loaded_content = loadContent(xml_document);
|
||||
if (loaded_content.isEmpty()) return(QRectF());
|
||||
|
||||
// calcule le boundingRect
|
||||
QRectF bounding_rect = elementContentBoundingRect(loaded_content);
|
||||
|
||||
// detruit les parties chargees
|
||||
qDeleteAll(loaded_content);
|
||||
|
||||
return(bounding_rect);
|
||||
}
|
||||
|
||||
/**
|
||||
Importe l'element decrit dans un document XML. Si une position est
|
||||
precisee, les elements importes sont positionnes de maniere a ce que le
|
||||
coin superieur gauche du plus petit rectangle pouvant les entourant tous
|
||||
(le bounding rect) soit a cette position.
|
||||
Lit un element depuis un document XML
|
||||
@param xml_document un document XML decrivant l'element
|
||||
@param position La position des parties importees
|
||||
@param consider_informations Si vrai, les informations complementaires
|
||||
(dimensions, hotspot, etc.) seront prises en compte
|
||||
@param content_ptr si ce pointeur vers un ElementContent est different de 0,
|
||||
il sera rempli avec le contenu ajoute a l'element par le fromXml
|
||||
@return true si l'import a reussi, false sinon
|
||||
*/
|
||||
void ElementScene::fromXml(
|
||||
const QDomDocument &xml_document,
|
||||
const QPointF &position,
|
||||
bool consider_informations,
|
||||
ElementContent *content_ptr
|
||||
) {
|
||||
void ElementScene::fromXml(const QDomDocument &xml_document) {
|
||||
|
||||
QString error_message;
|
||||
bool state = true;
|
||||
|
||||
// prend en compte les informations de l'element
|
||||
if (consider_informations) {
|
||||
state = applyInformations(xml_document, &error_message);
|
||||
// la racine est supposee etre une definition d'element
|
||||
QDomElement root = xml_document.documentElement();
|
||||
if (root.tagName() != "definition" || root.attribute("type") != "element") {
|
||||
state = false;
|
||||
error_message = tr("Ce document XML n'est pas une definition d'\351l\351ment.");
|
||||
}
|
||||
|
||||
// dimensions et hotspot
|
||||
if (state) {
|
||||
// ces attributs doivent etre presents et valides
|
||||
int w, h, hot_x, hot_y;
|
||||
if (
|
||||
!QET::attributeIsAnInteger(root, QString("width"), &w) ||\
|
||||
!QET::attributeIsAnInteger(root, QString("height"), &h) ||\
|
||||
!QET::attributeIsAnInteger(root, QString("hotspot_x"), &hot_x) ||\
|
||||
!QET::attributeIsAnInteger(root, QString("hotspot_y"), &hot_y)
|
||||
) {
|
||||
state = false;
|
||||
error_message = tr("Les dimensions ou le point de saisie ne sont pas valides.");
|
||||
} else {
|
||||
setWidth(w);
|
||||
setHeight(h);
|
||||
setHotspot(QPoint(hot_x, hot_y));
|
||||
}
|
||||
}
|
||||
|
||||
// orientations et connexions internes
|
||||
if (state) {
|
||||
internal_connections = (root.attribute("ic") == "true");
|
||||
|
||||
if (!ori.fromString(root.attribute("orientation"))) {
|
||||
state = false;
|
||||
error_message = tr("Les orientations ne sont pas valides.");
|
||||
}
|
||||
}
|
||||
|
||||
// extrait les noms de la definition XML
|
||||
if (state) {
|
||||
_names.fromXml(root);
|
||||
}
|
||||
|
||||
// parcours des enfants de la definition : parties de l'element
|
||||
if (state) {
|
||||
ElementContent loaded_content = loadContent(xml_document, &error_message);
|
||||
if (position != QPointF()) {
|
||||
addContentAtPos(loaded_content, position, &error_message);
|
||||
} else {
|
||||
addContent(loaded_content, &error_message);
|
||||
}
|
||||
|
||||
// renvoie le contenu ajoute a l'element
|
||||
if (content_ptr) {
|
||||
*content_ptr = loaded_content;
|
||||
for (QDomNode node = root.firstChild() ; !node.isNull() ; node = node.nextSibling()) {
|
||||
QDomElement elmts = node.toElement();
|
||||
if (elmts.isNull()) continue;
|
||||
if (elmts.tagName() == "description") {
|
||||
// gestion de la description graphique de l'element
|
||||
// = parcours des differentes parties du dessin
|
||||
int z = 1;
|
||||
for (QDomNode n = node.firstChild() ; !n.isNull() ; n = n.nextSibling()) {
|
||||
QDomElement qde = n.toElement();
|
||||
if (qde.isNull()) continue;
|
||||
CustomElementPart *cep;
|
||||
if (qde.tagName() == "line") cep = new PartLine (element_editor, 0, this);
|
||||
else if (qde.tagName() == "ellipse") cep = new PartEllipse (element_editor, 0, this);
|
||||
else if (qde.tagName() == "circle") cep = new PartCircle (element_editor, 0, this);
|
||||
else if (qde.tagName() == "polygon") cep = new PartPolygon (element_editor, 0, this);
|
||||
else if (qde.tagName() == "terminal") cep = new PartTerminal (element_editor, 0, this);
|
||||
else if (qde.tagName() == "text") cep = new PartText (element_editor, 0, this);
|
||||
else if (qde.tagName() == "input") cep = new PartTextField(element_editor, 0, this);
|
||||
else if (qde.tagName() == "arc") cep = new PartArc (element_editor, 0, this);
|
||||
else continue;
|
||||
if (QGraphicsItem *qgi = dynamic_cast<QGraphicsItem *>(cep)) qgi -> setZValue(z++);
|
||||
cep -> fromXml(qde);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@return le rectangle representant les limites de l'element.
|
||||
Ce rectangle a pour dimensions la taille de l'element et pour coin
|
||||
superieur gauche les coordonnees opposees du hotspot.
|
||||
*/
|
||||
QRectF ElementScene::borderRect() const {
|
||||
return(QRectF(-_hotspot, QSizeF(width(), height())));
|
||||
}
|
||||
|
||||
/**
|
||||
@return un rectangle englobant toutes les parties ainsi que le
|
||||
"bounding rect" de l'element
|
||||
*/
|
||||
QRectF ElementScene::sceneContent() const {
|
||||
return(itemsBoundingRect().unite(borderRect()));
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si toutes les parties graphiques composant l'element sont
|
||||
integralement contenues dans le rectangle representant les limites de
|
||||
l'element.
|
||||
*/
|
||||
bool ElementScene::borderContainsEveryParts() const {
|
||||
return(borderRect().contains(itemsBoundingRect()));
|
||||
return(itemsBoundingRect().unite(QRectF(-_hotspot, QSizeF(width(), height()))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -622,64 +496,6 @@ QGIManager &ElementScene::qgiManager() {
|
||||
return(qgi_manager);
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si le presse-papier semble contenir un element
|
||||
*/
|
||||
bool ElementScene::clipboardMayContainElement() {
|
||||
QString clipboard_text = QApplication::clipboard() -> text().trimmed();
|
||||
bool may_be_element = clipboard_text.startsWith("<definition") && clipboard_text.endsWith("</definition>");
|
||||
return(may_be_element);
|
||||
}
|
||||
|
||||
/**
|
||||
@param clipboard_content chaine de caractere, provenant vraisemblablement du
|
||||
presse-papier.
|
||||
@return true si clipboard_content a ete copie depuis cet element.
|
||||
*/
|
||||
bool ElementScene::wasCopiedFromThisElement(const QString &clipboard_content) {
|
||||
return(clipboard_content == last_copied_);
|
||||
}
|
||||
|
||||
/**
|
||||
Gere le fait de couper la selection = l'exporter en XML dans le
|
||||
presse-papier puis la supprimer.
|
||||
*/
|
||||
void ElementScene::cut() {
|
||||
copy();
|
||||
QList<QGraphicsItem *> cut_content = selectedItems();
|
||||
clearSelection();
|
||||
undoStack().push(new CutPartsCommand(this, cut_content));
|
||||
}
|
||||
|
||||
/**
|
||||
Gere le fait de copier la selection = l'exporter en XML dans le
|
||||
presse-papier.
|
||||
*/
|
||||
void ElementScene::copy() {
|
||||
// accede au presse-papier
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
|
||||
// genere la description XML de la selection
|
||||
QString clipboard_content = toXml(false).toString(4);
|
||||
|
||||
// met la description XML dans le presse-papier
|
||||
if (clipboard -> supportsSelection()) {
|
||||
clipboard -> setText(clipboard_content, QClipboard::Selection);
|
||||
}
|
||||
clipboard -> setText(clipboard_content);
|
||||
|
||||
// retient le dernier contenu copie
|
||||
last_copied_ = clipboard_content;
|
||||
}
|
||||
|
||||
/**
|
||||
Gere le fait de coller le contenu du presse-papier = l'importer dans le
|
||||
presse-papier a une position donnee.
|
||||
*/
|
||||
void ElementScene::paste() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Selectionne tout
|
||||
*/
|
||||
@@ -720,9 +536,10 @@ void ElementScene::slot_delete() {
|
||||
*/
|
||||
void ElementScene::slot_editSizeHotSpot() {
|
||||
// cree un dialogue
|
||||
QDialog dialog_sh(element_editor);
|
||||
QDialog dialog_sh;
|
||||
dialog_sh.setModal(true);
|
||||
dialog_sh.setWindowTitle(tr("\311diter la taille et le point de saisie", "window title"));
|
||||
dialog_sh.setMinimumSize(400, 230);
|
||||
dialog_sh.setWindowTitle(tr("\311diter la taille et le point de saisie"));
|
||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_sh);
|
||||
|
||||
// ajoute un HotspotEditor au dialogue
|
||||
@@ -759,10 +576,10 @@ void ElementScene::slot_editSizeHotSpot() {
|
||||
void ElementScene::slot_editOrientations() {
|
||||
|
||||
// cree un dialogue
|
||||
QDialog dialog_ori(element_editor);
|
||||
QDialog dialog_ori;
|
||||
dialog_ori.setModal(true);
|
||||
dialog_ori.setMinimumSize(400, 260);
|
||||
dialog_ori.setWindowTitle(tr("\311diter les orientations", "window title"));
|
||||
dialog_ori.setWindowTitle(tr("\311diter les orientations"));
|
||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_ori);
|
||||
|
||||
// ajoute un champ explicatif au dialogue
|
||||
@@ -805,10 +622,10 @@ void ElementScene::slot_editOrientations() {
|
||||
void ElementScene::slot_editNames() {
|
||||
|
||||
// cree un dialogue
|
||||
QDialog dialog(element_editor);
|
||||
QDialog dialog;
|
||||
dialog.setModal(true);
|
||||
dialog.setMinimumSize(400, 330);
|
||||
dialog.setWindowTitle(tr("\311diter les noms", "window title"));
|
||||
dialog.setWindowTitle(tr("\311diter les noms"));
|
||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog);
|
||||
|
||||
// ajoute un champ explicatif au dialogue
|
||||
@@ -900,30 +717,6 @@ QList<QGraphicsItem *> ElementScene::zItems(bool include_terminals) const {
|
||||
return(all_items_list);
|
||||
}
|
||||
|
||||
/**
|
||||
@return les parties graphiques selectionnees
|
||||
*/
|
||||
ElementContent ElementScene::selectedContent() const {
|
||||
ElementContent content;
|
||||
foreach(QGraphicsItem *qgi, zItems(true)) {
|
||||
if (qgi -> isSelected()) content << qgi;
|
||||
}
|
||||
return(content);
|
||||
}
|
||||
|
||||
/**
|
||||
@param to_paste Rectangle englobant les parties a coller
|
||||
@return le rectangle ou il faudra coller ces parties
|
||||
*/
|
||||
void ElementScene::getPasteArea(const QRectF &to_paste) {
|
||||
// on le dessine sur la scene
|
||||
paste_area_ -> setRect(to_paste);
|
||||
addItem(paste_area_);
|
||||
|
||||
// on passe la scene en mode "recherche de zone pour copier/coller"
|
||||
behavior = PasteArea;
|
||||
}
|
||||
|
||||
/**
|
||||
Supprime les parties de l'element et les objets d'annulations.
|
||||
Les autres caracteristiques sont conservees.
|
||||
@@ -937,200 +730,3 @@ void ElementScene::reset() {
|
||||
qgiManager().release(qgi);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@param content Contenu ( = parties) d'un element
|
||||
@return le boundingRect de ces parties, exprime dans les coordonnes de la
|
||||
scene
|
||||
*/
|
||||
QRectF ElementScene::elementContentBoundingRect(const ElementContent &content) {
|
||||
QRectF bounding_rect;
|
||||
foreach(QGraphicsItem *qgi, content) {
|
||||
bounding_rect |= qgi -> sceneBoundingRect();
|
||||
}
|
||||
return(bounding_rect);
|
||||
}
|
||||
|
||||
/**
|
||||
Applique les informations (dimensions, hostpot, orientations, connexions
|
||||
internes et noms) contenu dans un document XML.
|
||||
@param xml_document Document XML a analyser
|
||||
@param error_message pointeur vers une QString ; si error_message est
|
||||
different de 0, un message d'erreur sera stocke dedans si necessaire
|
||||
@return true si la lecture et l'application des informations s'est bien
|
||||
passee, false sinon.
|
||||
*/
|
||||
bool ElementScene::applyInformations(const QDomDocument &xml_document, QString *error_message) {
|
||||
// la racine est supposee etre une definition d'element
|
||||
QDomElement root = xml_document.documentElement();
|
||||
if (root.tagName() != "definition" || root.attribute("type") != "element") {
|
||||
if (error_message) {
|
||||
*error_message = tr("Ce document XML n'est pas une d\351finition d'\351l\351ment.", "error message");
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
// dimensions et hotspot : ces attributs doivent etre presents et valides
|
||||
int w, h, hot_x, hot_y;
|
||||
if (
|
||||
!QET::attributeIsAnInteger(root, QString("width"), &w) ||\
|
||||
!QET::attributeIsAnInteger(root, QString("height"), &h) ||\
|
||||
!QET::attributeIsAnInteger(root, QString("hotspot_x"), &hot_x) ||\
|
||||
!QET::attributeIsAnInteger(root, QString("hotspot_y"), &hot_y)
|
||||
) {
|
||||
if (error_message) {
|
||||
*error_message = tr("Les dimensions ou le point de saisie ne sont pas valides.", "error message");
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
//
|
||||
setWidth(w);
|
||||
setHeight(h);
|
||||
setHotspot(QPoint(hot_x, hot_y));
|
||||
|
||||
// orientations
|
||||
internal_connections = (root.attribute("ic") == "true");
|
||||
|
||||
// connexions internes
|
||||
if (!ori.fromString(root.attribute("orientation"))) {
|
||||
if (error_message) {
|
||||
*error_message = tr("Les orientations ne sont pas valides.", "error message");
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
// extrait les noms de la definition XML
|
||||
_names.fromXml(root);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
Par le document XML xml_document et retourne le contenu ( = liste de
|
||||
parties) correspondant.
|
||||
@param xml_document Document XML a analyser
|
||||
@param error_message pointeur vers une QString ; si error_message est
|
||||
different de 0, un message d'erreur sera stocke dedans si necessaire
|
||||
*/
|
||||
ElementContent ElementScene::loadContent(const QDomDocument &xml_document, QString *error_message) {
|
||||
ElementContent loaded_parts;
|
||||
|
||||
// la racine est supposee etre une definition d'element
|
||||
QDomElement root = xml_document.documentElement();
|
||||
if (root.tagName() != "definition" || root.attribute("type") != "element") {
|
||||
if (error_message) {
|
||||
*error_message = tr("Ce document XML n'est pas une d\351finition d'\351l\351ment.", "error message");
|
||||
}
|
||||
return(loaded_parts);
|
||||
}
|
||||
|
||||
// chargement de la description graphique de l'element
|
||||
for (QDomNode node = root.firstChild() ; !node.isNull() ; node = node.nextSibling()) {
|
||||
QDomElement elmts = node.toElement();
|
||||
if (elmts.isNull()) continue;
|
||||
if (elmts.tagName() == "description") {
|
||||
|
||||
// = parcours des differentes parties du dessin
|
||||
int z = 1;
|
||||
for (QDomNode n = node.firstChild() ; !n.isNull() ; n = n.nextSibling()) {
|
||||
QDomElement qde = n.toElement();
|
||||
if (qde.isNull()) continue;
|
||||
CustomElementPart *cep;
|
||||
if (qde.tagName() == "line") cep = new PartLine (element_editor, 0, 0);
|
||||
else if (qde.tagName() == "rect") cep = new PartRectangle(element_editor, 0, 0);
|
||||
else if (qde.tagName() == "ellipse") cep = new PartEllipse (element_editor, 0, 0);
|
||||
else if (qde.tagName() == "circle") cep = new PartCircle (element_editor, 0, 0);
|
||||
else if (qde.tagName() == "polygon") cep = new PartPolygon (element_editor, 0, 0);
|
||||
else if (qde.tagName() == "terminal") cep = new PartTerminal (element_editor, 0, 0);
|
||||
else if (qde.tagName() == "text") cep = new PartText (element_editor, 0, 0);
|
||||
else if (qde.tagName() == "input") cep = new PartTextField(element_editor, 0, 0);
|
||||
else if (qde.tagName() == "arc") cep = new PartArc (element_editor, 0, 0);
|
||||
else continue;
|
||||
if (QGraphicsItem *qgi = dynamic_cast<QGraphicsItem *>(cep)) {
|
||||
qgi -> setZValue(z++);
|
||||
loaded_parts << qgi;
|
||||
}
|
||||
cep -> fromXml(qde);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(loaded_parts);
|
||||
}
|
||||
|
||||
/**
|
||||
Ajoute le contenu content a cet element
|
||||
@param content contenu ( = liste de parties) a charger
|
||||
@param error_message pointeur vers une QString ; si error_message est
|
||||
different de 0, un message d'erreur sera stocke dedans si necessaire
|
||||
@return Le contenu ajoute
|
||||
*/
|
||||
ElementContent ElementScene::addContent(const ElementContent &content, QString */*error_message*/) {
|
||||
foreach(QGraphicsItem *part, content) {
|
||||
addItem(part);
|
||||
}
|
||||
return(content);
|
||||
}
|
||||
|
||||
/**
|
||||
Ajoute le contenu content a cet element
|
||||
@param content contenu ( = liste de parties) a charger
|
||||
@param pos Position du coin superieur gauche du contenu apres avoir ete ajoute
|
||||
@param error_message pointeur vers une QString ; si error_message est
|
||||
different de 0, un message d'erreur sera stocke dedans si necessaire
|
||||
@return Le contenu ajoute
|
||||
*/
|
||||
ElementContent ElementScene::addContentAtPos(const ElementContent &content, const QPointF &pos, QString */*error_message*/) {
|
||||
// calcule le boundingRect du contenu a ajouter
|
||||
QRectF bounding_rect = elementContentBoundingRect(content);
|
||||
|
||||
// en deduit le decalage a appliquer aux parties pour les poser au point demander
|
||||
QPointF offset = pos - bounding_rect.topLeft();
|
||||
|
||||
// ajoute les parties avec le decalage adequat
|
||||
foreach(QGraphicsItem *part, content) {
|
||||
part -> setPos(part -> pos() + offset);
|
||||
addItem(part);
|
||||
}
|
||||
return(content);
|
||||
}
|
||||
|
||||
/**
|
||||
Initialise la zone de collage
|
||||
*/
|
||||
void ElementScene::initPasteArea() {
|
||||
paste_area_ = new QGraphicsRectItem();
|
||||
paste_area_ -> setZValue(1000000);
|
||||
|
||||
QPen paste_area_pen;
|
||||
paste_area_pen.setStyle(Qt::DashDotLine);
|
||||
paste_area_pen.setColor(QColor(30, 56, 86, 255));
|
||||
|
||||
QBrush paste_area_brush;
|
||||
paste_area_brush.setStyle(Qt::SolidPattern);
|
||||
paste_area_brush.setColor(QColor(90, 167, 255, 64));
|
||||
|
||||
paste_area_ -> setPen(paste_area_pen);
|
||||
paste_area_ -> setBrush(paste_area_brush);
|
||||
}
|
||||
|
||||
/**
|
||||
Arrondit les coordonnees du point passees en parametre de facon a ce que ce
|
||||
point soit aligne sur la grille.
|
||||
@param point une reference vers un QPointF. Cet objet sera modifie.
|
||||
|
||||
*/
|
||||
void ElementScene::snapToGrid(QPointF &point) {
|
||||
point.rx() = qRound(point.x() / x_grid) * x_grid;
|
||||
point.ry() = qRound(point.y() / y_grid) * y_grid;
|
||||
}
|
||||
|
||||
/**
|
||||
@param e Evenement souris
|
||||
@return true s'il faut utiliser le snap-to-grid
|
||||
Typiquement, cette methode retourne true si l'evenement souris se produit
|
||||
sans la touche Ctrl enfoncee.
|
||||
*/
|
||||
bool ElementScene::mustSnapToGrid(QGraphicsSceneMouseEvent *e) {
|
||||
return(!(e -> modifiers() & Qt::ControlModifier));
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -22,10 +22,8 @@
|
||||
#include "nameslistwidget.h"
|
||||
#include "orientationsetwidget.h"
|
||||
#include "qgimanager.h"
|
||||
#include "elementcontent.h"
|
||||
class QETElementEditor;
|
||||
class PartLine;
|
||||
class PartRectangle;
|
||||
class PartEllipse;
|
||||
class PartCircle;
|
||||
class PartPolygon;
|
||||
@@ -40,7 +38,7 @@ class ElementScene : public QGraphicsScene {
|
||||
Q_OBJECT
|
||||
|
||||
// enum
|
||||
enum Behavior { Normal, Line, Rectangle, Circle, Ellipse, Polygon, Text, Terminal, Arc, TextField, PasteArea };
|
||||
enum Behavior { Normal, Line, Circle, Ellipse, Polygon, Text, Terminal, Arc, TextField };
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
@@ -51,6 +49,10 @@ class ElementScene : public QGraphicsScene {
|
||||
ElementScene(const ElementScene &);
|
||||
|
||||
// attributs
|
||||
public:
|
||||
static const int xGrid; ///< Taille horizontale de la grille
|
||||
static const int yGrid; ///< Taille verticale de la grille
|
||||
|
||||
private:
|
||||
/// longueur de l'element en dizaines de pixels
|
||||
uint _width;
|
||||
@@ -70,31 +72,16 @@ class ElementScene : public QGraphicsScene {
|
||||
QUndoStack undo_stack;
|
||||
/// Position du premier item selectionne (utilise pour annuler les deplacements)
|
||||
QPointF fsi_pos;
|
||||
QPointF moving_press_pos;
|
||||
bool moving_parts_;
|
||||
|
||||
/// Variables relatives a la gestion du dessin des parties sur la scene
|
||||
Behavior behavior;
|
||||
PartLine *current_line;
|
||||
PartRectangle *current_rectangle;
|
||||
PartEllipse *current_ellipse;
|
||||
PartCircle *current_circle;
|
||||
PartPolygon *current_polygon;
|
||||
PartArc *current_arc;
|
||||
QETElementEditor *element_editor;
|
||||
|
||||
/// Variables relatives a la gestion de la zone de collage sur la scene
|
||||
QGraphicsRectItem *paste_area_;
|
||||
QRectF defined_paste_area_;
|
||||
|
||||
/// Variables relatives au copier-coller avec decalage
|
||||
QString last_copied_;
|
||||
|
||||
///< Taille horizontale de la grille
|
||||
int x_grid;
|
||||
///< Taille verticale de la grille
|
||||
int y_grid;
|
||||
|
||||
// methodes
|
||||
public:
|
||||
void setWidth(const uint &);
|
||||
@@ -109,26 +96,13 @@ class ElementScene : public QGraphicsScene {
|
||||
void setOrientations(const OrientationSet &);
|
||||
bool internalConnections();
|
||||
void setInternalConnections(bool);
|
||||
virtual int xGrid() const;
|
||||
virtual int yGrid() const;
|
||||
virtual void setGrid(int, int);
|
||||
virtual const QDomDocument toXml(bool = true) const;
|
||||
virtual QRectF boundingRectFromXml(const QDomDocument &);
|
||||
virtual void fromXml(const QDomDocument &, const QPointF & = QPointF(), bool = true, ElementContent * = 0);
|
||||
virtual const QDomDocument toXml() const;
|
||||
virtual void fromXml(const QDomDocument &);
|
||||
virtual void reset();
|
||||
virtual QList<QGraphicsItem *> zItems(bool = false) const;
|
||||
virtual ElementContent selectedContent() const;
|
||||
virtual void getPasteArea(const QRectF &);
|
||||
QRectF borderRect() const;
|
||||
QRectF sceneContent() const;
|
||||
bool borderContainsEveryParts() const;
|
||||
QUndoStack &undoStack();
|
||||
QGIManager &qgiManager();
|
||||
static bool clipboardMayContainElement();
|
||||
bool wasCopiedFromThisElement(const QString &);
|
||||
void cut();
|
||||
void copy();
|
||||
void paste();
|
||||
|
||||
protected:
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||
@@ -136,22 +110,10 @@ class ElementScene : public QGraphicsScene {
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
||||
virtual void drawBackground(QPainter *, const QRectF &);
|
||||
virtual void drawForeground(QPainter *, const QRectF &);
|
||||
virtual void endCurrentBehavior(const QGraphicsSceneMouseEvent *);
|
||||
|
||||
private:
|
||||
QRectF elementContentBoundingRect(const ElementContent &);
|
||||
bool applyInformations(const QDomDocument &, QString * = 0);
|
||||
ElementContent loadContent(const QDomDocument &, QString * = 0);
|
||||
ElementContent addContent(const ElementContent &, QString * = 0);
|
||||
ElementContent addContentAtPos(const ElementContent &, const QPointF &, QString * = 0);
|
||||
void initPasteArea();
|
||||
void snapToGrid(QPointF &);
|
||||
bool mustSnapToGrid(QGraphicsSceneMouseEvent *);
|
||||
|
||||
public slots:
|
||||
void slot_move();
|
||||
void slot_addLine();
|
||||
void slot_addRectangle();
|
||||
void slot_addCircle();
|
||||
void slot_addEllipse();
|
||||
void slot_addPolygon();
|
||||
@@ -183,8 +145,6 @@ class ElementScene : public QGraphicsScene {
|
||||
void partsRemoved();
|
||||
/// Signal emis lorsque la zValue d'une ou plusieurs parties change
|
||||
void partsZValueChanged();
|
||||
/// Signal emis lorsque l'utilisateur a fini de choisir une zone pour un copier/coller
|
||||
void pasteAreaDefined(const QRectF &);
|
||||
};
|
||||
|
||||
/**
|
||||
66
editor/elementview.cpp
Normal file
66
editor/elementview.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
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/>.
|
||||
*/
|
||||
#include "elementview.h"
|
||||
/**
|
||||
Constructeur
|
||||
@param scene ElementScene visualisee par cette ElementView
|
||||
@param parent QWidget parent de cette ElementView
|
||||
*/
|
||||
ElementView::ElementView(ElementScene *scene, QWidget *parent) :
|
||||
QGraphicsView(scene, parent),
|
||||
scene_(scene)
|
||||
{
|
||||
setInteractive(true);
|
||||
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
//setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||
setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
||||
//setSceneRect(QRectF(0.0, 0.0, 50.0, 200.0));
|
||||
scale(4.0, 4.0);
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
ElementView::~ElementView() {
|
||||
}
|
||||
|
||||
/// @return l'ElementScene visualisee par cette ElementView
|
||||
ElementScene *ElementView::scene() const {
|
||||
return(scene_);
|
||||
}
|
||||
|
||||
/**
|
||||
Definit l'ElementScene visualisee par cette ElementView
|
||||
@param s l'ElementScene visualisee par cette ElementView
|
||||
*/
|
||||
void ElementView::setScene(ElementScene *s) {
|
||||
QGraphicsView::setScene(s);
|
||||
scene_ = s;
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les evenements envoyes a la vue.
|
||||
Methode reimplentee pour gerer le conflit de raccourcis avec Suppr
|
||||
(supprimer une partie ou supprimer le caractere suivant)
|
||||
@param e evenement a gerer
|
||||
*/
|
||||
bool ElementView::event(QEvent *e) {
|
||||
if (e -> type() == QEvent::ShortcutOverride && scene_ -> focusItem()) {
|
||||
e -> accept();
|
||||
return(true);
|
||||
}
|
||||
return(QGraphicsView::event(e));
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -25,8 +25,6 @@
|
||||
*/
|
||||
class ElementView : public QGraphicsView {
|
||||
Q_OBJECT
|
||||
friend class PastePartsCommand;
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
ElementView(ElementScene *, QWidget * = 0);
|
||||
@@ -39,41 +37,11 @@ class ElementView : public QGraphicsView {
|
||||
public:
|
||||
ElementScene *scene() const;
|
||||
void setScene(ElementScene *);
|
||||
QRectF viewedSceneRect() const;
|
||||
|
||||
protected:
|
||||
bool event(QEvent *);
|
||||
void mousePressEvent(QMouseEvent *);
|
||||
void wheelEvent(QWheelEvent *);
|
||||
virtual void drawBackground(QPainter *, const QRectF &);
|
||||
|
||||
private:
|
||||
QRectF applyMovement(const QRectF &, const QET::OrientedMovement &, const QPointF &);
|
||||
|
||||
// slots
|
||||
public slots:
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void zoomFit();
|
||||
void zoomReset();
|
||||
void adjustSceneRect();
|
||||
void cut();
|
||||
void copy();
|
||||
void paste();
|
||||
void pasteInArea();
|
||||
|
||||
private slots:
|
||||
void getPasteArea(const QRectF &);
|
||||
ElementContent pasteAreaDefined(const QRectF &);
|
||||
ElementContent paste(const QPointF &);
|
||||
ElementContent paste(const QDomDocument &, const QPointF &);
|
||||
ElementContent pasteWithOffset(const QDomDocument &);
|
||||
|
||||
//attributs
|
||||
private:
|
||||
ElementScene *scene_;
|
||||
QString to_paste_in_area_;
|
||||
int offset_paste_count_;
|
||||
QPointF start_top_left_corner_;
|
||||
};
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -63,9 +63,9 @@ EllipseEditor::~EllipseEditor() {
|
||||
*/
|
||||
void EllipseEditor::updateEllipse() {
|
||||
part -> setProperty("x", x -> text().toDouble());
|
||||
part -> setProperty("y", y -> text().toDouble());
|
||||
part -> setProperty("diameter_h", h -> text().toDouble());
|
||||
part -> setProperty("diameter_v", v -> text().toDouble());
|
||||
part -> setProperty("y", x -> text().toDouble());
|
||||
part -> setProperty("diameter_h", x -> text().toDouble());
|
||||
part -> setProperty("diameter_v", x -> text().toDouble());
|
||||
}
|
||||
|
||||
/// Met a jour l'abscisse du centre de l'ellipse et cree un objet d'annulation
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
115
editor/lineeditor.cpp
Normal file
115
editor/lineeditor.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
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/>.
|
||||
*/
|
||||
#include "lineeditor.h"
|
||||
#include "partline.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param editor L'editeur d'element concerne
|
||||
@param line La ligne a editer
|
||||
@param parent le Widget parent
|
||||
*/
|
||||
LineEditor::LineEditor(QETElementEditor *editor, PartLine *line, QWidget *parent) : ElementItemEditor(editor, parent) {
|
||||
|
||||
part = line;
|
||||
|
||||
x1 = new QLineEdit();
|
||||
y1 = new QLineEdit();
|
||||
x2 = new QLineEdit();
|
||||
y2 = new QLineEdit();
|
||||
|
||||
x1 -> setValidator(new QDoubleValidator(x1));
|
||||
y1 -> setValidator(new QDoubleValidator(y1));
|
||||
x2 -> setValidator(new QDoubleValidator(x2));
|
||||
y2 -> setValidator(new QDoubleValidator(y2));
|
||||
|
||||
QGridLayout *grid = new QGridLayout(this);
|
||||
grid -> addWidget(new QLabel("x1"), 0, 0);
|
||||
grid -> addWidget(x1, 0, 1);
|
||||
grid -> addWidget(new QLabel("y1"), 0, 2);
|
||||
grid -> addWidget(y1, 0, 3);
|
||||
grid -> addWidget(new QLabel("x2"), 1, 0);
|
||||
grid -> addWidget(x2, 1, 1);
|
||||
grid -> addWidget(new QLabel("y2"), 1, 2);
|
||||
grid -> addWidget(y2, 1, 3);
|
||||
|
||||
updateForm();
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
LineEditor::~LineEditor() {
|
||||
}
|
||||
|
||||
/**
|
||||
Met a jour la ligne a partir des donnees du formulaire
|
||||
*/
|
||||
void LineEditor::updateLine() {
|
||||
part -> setLine(
|
||||
QLineF(
|
||||
part -> mapFromScene(
|
||||
x1 -> text().toDouble(),
|
||||
y1 -> text().toDouble()
|
||||
),
|
||||
part -> mapFromScene(
|
||||
x2 -> text().toDouble(),
|
||||
y2 -> text().toDouble()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/// Met a jour l'abscisse du premier point de la ligne et cree un objet d'annulation
|
||||
void LineEditor::updateLineX1() { addChangePartCommand(tr("abscisse point 1"), part, "x1", x1 -> text().toDouble()); }
|
||||
/// Met a jour l'ordonnee du premier point de la ligne et cree un objet d'annulation
|
||||
void LineEditor::updateLineY1() { addChangePartCommand(tr("ordonn\351e point 1"), part, "y1", y1 -> text().toDouble()); }
|
||||
/// Met a jour l'abscisse du second point de la ligne et cree un objet d'annulation
|
||||
void LineEditor::updateLineX2() { addChangePartCommand(tr("abscisse point 2"), part, "x2", x2 -> text().toDouble()); }
|
||||
/// Met a jour l'ordonnee du second point de la ligne et cree un objet d'annulation
|
||||
void LineEditor::updateLineY2() { addChangePartCommand(tr("ordonn\351e point 2"), part, "y2", y2 -> text().toDouble()); }
|
||||
|
||||
/**
|
||||
Met a jour le formulaire d'edition
|
||||
*/
|
||||
void LineEditor::updateForm() {
|
||||
activeConnections(false);
|
||||
QPointF p1(part -> sceneP1());
|
||||
QPointF p2(part -> sceneP2());
|
||||
x1 -> setText(QString("%1").arg(p1.x()));
|
||||
y1 -> setText(QString("%1").arg(p1.y()));
|
||||
x2 -> setText(QString("%1").arg(p2.x()));
|
||||
y2 -> setText(QString("%1").arg(p2.y()));
|
||||
activeConnections(true);
|
||||
}
|
||||
|
||||
/**
|
||||
Active ou desactive les connexionx signaux/slots entre les widgets internes.
|
||||
@param active true pour activer les connexions, false pour les desactiver
|
||||
*/
|
||||
void LineEditor::activeConnections(bool active) {
|
||||
if (active) {
|
||||
connect(x1, SIGNAL(editingFinished()), this, SLOT(updateLineX1()));
|
||||
connect(y1, SIGNAL(editingFinished()), this, SLOT(updateLineY1()));
|
||||
connect(x2, SIGNAL(editingFinished()), this, SLOT(updateLineX2()));
|
||||
connect(y2, SIGNAL(editingFinished()), this, SLOT(updateLineY2()));
|
||||
} else {
|
||||
connect(x1, SIGNAL(editingFinished()), this, SLOT(updateLineX1()));
|
||||
connect(y1, SIGNAL(editingFinished()), this, SLOT(updateLineY1()));
|
||||
connect(x2, SIGNAL(editingFinished()), this, SLOT(updateLineX2()));
|
||||
connect(y2, SIGNAL(editingFinished()), this, SLOT(updateLineY2()));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -37,8 +37,6 @@ class LineEditor : public ElementItemEditor {
|
||||
private:
|
||||
PartLine *part;
|
||||
QLineEdit *x1, *y1, *x2, *y2;
|
||||
QComboBox *end1_type, *end2_type;
|
||||
QLineEdit *end1_length, *end2_length;
|
||||
|
||||
// methodes
|
||||
public slots:
|
||||
@@ -47,10 +45,6 @@ class LineEditor : public ElementItemEditor {
|
||||
void updateLineY1();
|
||||
void updateLineX2();
|
||||
void updateLineY2();
|
||||
void updateLineEndType1();
|
||||
void updateLineEndLength1();
|
||||
void updateLineEndType2();
|
||||
void updateLineEndLength2();
|
||||
void updateForm();
|
||||
|
||||
private:
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -80,12 +80,12 @@ void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget
|
||||
const QDomElement PartArc::toXml(QDomDocument &xml_document) const {
|
||||
QDomElement xml_element = xml_document.createElement("arc");
|
||||
QPointF top_left(sceneTopLeft());
|
||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||
xml_element.setAttribute("width", QString("%1").arg(rect().width()));
|
||||
xml_element.setAttribute("height", QString("%1").arg(rect().height()));
|
||||
xml_element.setAttribute("start", QString("%1").arg(start_angle));
|
||||
xml_element.setAttribute("angle", QString("%1").arg(_angle));
|
||||
xml_element.setAttribute("x", top_left.x());
|
||||
xml_element.setAttribute("y", top_left.y());
|
||||
xml_element.setAttribute("width", rect().width());
|
||||
xml_element.setAttribute("height", rect().height());
|
||||
xml_element.setAttribute("start", start_angle);
|
||||
xml_element.setAttribute("angle", _angle);
|
||||
stylesToXml(xml_element);
|
||||
return(xml_element);
|
||||
}
|
||||
@@ -159,7 +159,6 @@ void PartArc::setProperty(const QString &property, const QVariant &value) {
|
||||
} else if (property == "angle") {
|
||||
setAngle(value.toInt());
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,13 +251,3 @@ int PartArc::startAngle() const {
|
||||
bool PartArc::isUseless() const {
|
||||
return(rect().isNull() || !angle());
|
||||
}
|
||||
|
||||
/**
|
||||
@return le rectangle delimitant cette partie.
|
||||
*/
|
||||
QRectF PartArc::boundingRect() const {
|
||||
qreal adjust = 1.5;
|
||||
QRectF r(QGraphicsEllipseItem::boundingRect().normalized());
|
||||
r.adjust(-adjust, -adjust, adjust, adjust);
|
||||
return(r);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -48,11 +48,10 @@ class PartArc : public QGraphicsEllipseItem, public CustomElementGraphicPart {
|
||||
*/
|
||||
virtual int type() const { return Type; }
|
||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
||||
virtual QString name() const { return(QObject::tr("arc", "element part name")); }
|
||||
virtual QString name() const { return(QObject::tr("arc")); }
|
||||
virtual const QDomElement toXml(QDomDocument &) const;
|
||||
virtual void fromXml(const QDomElement &);
|
||||
virtual QPointF sceneTopLeft() const;
|
||||
virtual QRectF boundingRect() const;
|
||||
virtual void setAngle(int);
|
||||
virtual void setStartAngle(int);
|
||||
virtual int angle() const;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -68,9 +68,9 @@ void PartCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWid
|
||||
const QDomElement PartCircle::toXml(QDomDocument &xml_document) const {
|
||||
QDomElement xml_element = xml_document.createElement("circle");
|
||||
QPointF top_left(sceneTopLeft());
|
||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||
xml_element.setAttribute("diameter", QString("%1").arg(rect().width()));
|
||||
xml_element.setAttribute("x", top_left.x());
|
||||
xml_element.setAttribute("y", top_left.y());
|
||||
xml_element.setAttribute("diameter", rect().width());
|
||||
stylesToXml(xml_element);
|
||||
return(xml_element);
|
||||
}
|
||||
@@ -125,7 +125,6 @@ void PartCircle::setProperty(const QString &property, const QVariant &value) {
|
||||
current_rect.setSize(QSizeF(new_diameter, new_diameter));
|
||||
setRect(current_rect);
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -46,7 +46,7 @@ class PartCircle : public QGraphicsEllipseItem, public CustomElementGraphicPart
|
||||
*/
|
||||
virtual int type() const { return Type; }
|
||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
||||
virtual QString name() const { return(QObject::tr("cercle", "element part name")); }
|
||||
virtual QString name() const { return(QObject::tr("cercle")); }
|
||||
virtual const QDomElement toXml(QDomDocument &) const;
|
||||
virtual void fromXml(const QDomElement &);
|
||||
virtual QPointF sceneTopLeft() const;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -68,10 +68,10 @@ void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWi
|
||||
const QDomElement PartEllipse::toXml(QDomDocument &xml_document) const {
|
||||
QDomElement xml_element = xml_document.createElement("ellipse");
|
||||
QPointF top_left(sceneTopLeft());
|
||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||
xml_element.setAttribute("width", QString("%1").arg(rect().width()));
|
||||
xml_element.setAttribute("height", QString("%1").arg(rect().height()));
|
||||
xml_element.setAttribute("x", top_left.x());
|
||||
xml_element.setAttribute("y", top_left.y());
|
||||
xml_element.setAttribute("width", rect().width());
|
||||
xml_element.setAttribute("height", rect().height());
|
||||
stylesToXml(xml_element);
|
||||
return(xml_element);
|
||||
}
|
||||
@@ -129,7 +129,6 @@ void PartEllipse::setProperty(const QString &property, const QVariant &value) {
|
||||
current_rect.setHeight(new_height);
|
||||
setRect(current_rect);
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,13 +187,3 @@ QPointF PartEllipse::sceneTopLeft() const {
|
||||
bool PartEllipse::isUseless() const {
|
||||
return(rect().isNull());
|
||||
}
|
||||
|
||||
/**
|
||||
@return le rectangle delimitant cette partie.
|
||||
*/
|
||||
QRectF PartEllipse::boundingRect() const {
|
||||
qreal adjust = 1.5;
|
||||
QRectF r(QGraphicsEllipseItem::boundingRect().normalized());
|
||||
r.adjust(-adjust, -adjust, adjust, adjust);
|
||||
return(r);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -46,11 +46,10 @@ class PartEllipse : public QGraphicsEllipseItem, public CustomElementGraphicPart
|
||||
*/
|
||||
virtual int type() const { return Type; }
|
||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
||||
virtual QString name() const { return(QObject::tr("ellipse", "element part name")); }
|
||||
virtual QString name() const { return(QObject::tr("ellipse")); }
|
||||
virtual const QDomElement toXml(QDomDocument &) const;
|
||||
virtual void fromXml(const QDomElement &);
|
||||
virtual QPointF sceneTopLeft() const;
|
||||
virtual QRectF boundingRect() const;
|
||||
virtual void setProperty(const QString &, const QVariant &);
|
||||
virtual QVariant property(const QString &);
|
||||
virtual bool isUseless() const;
|
||||
254
editor/partline.cpp
Normal file
254
editor/partline.cpp
Normal file
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
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/>.
|
||||
*/
|
||||
#include "partline.h"
|
||||
#include "lineeditor.h"
|
||||
#include <cmath>
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param editor L'editeur d'element concerne
|
||||
@param parent Le QGraphicsItem parent de cette ligne
|
||||
@param scene La scene sur laquelle figure cette ligne
|
||||
*/
|
||||
PartLine::PartLine(QETElementEditor *editor, QGraphicsItem *parent, QGraphicsScene *scene) : QGraphicsLineItem(parent, scene), CustomElementGraphicPart(editor) {
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
setAcceptedMouseButtons(Qt::LeftButton);
|
||||
informations = new LineEditor(elementEditor(), this);
|
||||
informations -> setElementTypeName(name());
|
||||
style_editor -> appendWidget(informations);
|
||||
style_editor -> setElementTypeName(name());
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
PartLine::~PartLine() {
|
||||
}
|
||||
|
||||
/**
|
||||
Dessine la ligne
|
||||
@param painter QPainter a utiliser pour rendre le dessin
|
||||
@param options Options pour affiner le rendu
|
||||
@param widget Widget sur lequel le rendu est effectue
|
||||
*/
|
||||
void PartLine::paint(QPainter *painter, const QStyleOptionGraphicsItem */*q*/, QWidget */*w*/) {
|
||||
applyStylesToQPainter(*painter);
|
||||
QPen t = painter -> pen();
|
||||
if (isSelected()) {
|
||||
t.setColor(Qt::red);
|
||||
painter -> setPen(t);
|
||||
}
|
||||
painter -> setBrush(Qt::NoBrush);
|
||||
painter -> drawLine(line());
|
||||
}
|
||||
|
||||
/**
|
||||
Exporte la ligne en XML
|
||||
@param xml_document Document XML a utiliser pour creer l'element XML
|
||||
@return un element XML decrivant la ligne
|
||||
*/
|
||||
const QDomElement PartLine::toXml(QDomDocument &xml_document) const {
|
||||
|
||||
QPointF p1(sceneP1());
|
||||
QPointF p2(sceneP2());
|
||||
|
||||
QDomElement xml_element = xml_document.createElement("line");
|
||||
xml_element.setAttribute("x1", p1.x());
|
||||
xml_element.setAttribute("y1", p1.y());
|
||||
xml_element.setAttribute("x2", p2.x());
|
||||
xml_element.setAttribute("y2", p2.y());
|
||||
stylesToXml(xml_element);
|
||||
return(xml_element);
|
||||
}
|
||||
|
||||
/**
|
||||
Importe les proprietes d'une ligne depuis un element XML
|
||||
@param qde Element XML a lire
|
||||
*/
|
||||
void PartLine::fromXml(const QDomElement &qde) {
|
||||
stylesFromXml(qde);
|
||||
setLine(
|
||||
QLineF(
|
||||
mapFromScene(
|
||||
qde.attribute("x1", "0").toDouble(),
|
||||
qde.attribute("y1", "0").toDouble()
|
||||
),
|
||||
mapFromScene(
|
||||
qde.attribute("x2", "0").toDouble(),
|
||||
qde.attribute("y2", "0").toDouble()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Specifie la valeur d'une propriete donnee de la ligne
|
||||
@param property propriete a modifier. Valeurs acceptees :
|
||||
* x1 : abscisse du premier point
|
||||
* y1 : ordonnee du second point
|
||||
* x2 : abscisse du premier point
|
||||
* y2 : ordonnee du second point
|
||||
@param value Valeur a attribuer a la propriete
|
||||
*/
|
||||
void PartLine::setProperty(const QString &property, const QVariant &value) {
|
||||
CustomElementGraphicPart::setProperty(property, value);
|
||||
if (!value.canConvert(QVariant::Double)) return;
|
||||
QPointF new_p1(sceneP1()), new_p2(sceneP2());
|
||||
bool setline = true;
|
||||
if (property == "x1") {
|
||||
new_p1.setX(value.toDouble());
|
||||
} else if (property == "y1") {
|
||||
new_p1.setY(value.toDouble());
|
||||
} else if (property == "x2") {
|
||||
new_p2.setX(value.toDouble());
|
||||
} else if (property == "y2") {
|
||||
new_p2.setY(value.toDouble());
|
||||
} else setline = false;
|
||||
setLine(QLineF(mapFromScene(new_p1), mapFromScene(new_p2)));
|
||||
}
|
||||
|
||||
/**
|
||||
Permet d'acceder a la valeur d'une propriete donnee de la ligne
|
||||
@param property propriete lue. Valeurs acceptees :
|
||||
* x1 : abscisse du premier point
|
||||
* y1 : ordonnee du second point
|
||||
* x2 : abscisse du premier point
|
||||
* y2 : ordonnee du second point
|
||||
@return La valeur de la propriete property
|
||||
*/
|
||||
QVariant PartLine::property(const QString &property) {
|
||||
// appelle la methode property de CustomElementGraphicpart pour les styles
|
||||
QVariant style_property = CustomElementGraphicPart::property(property);
|
||||
if (style_property != QVariant()) return(style_property);
|
||||
|
||||
if (property == "x1") {
|
||||
return(sceneP1().x());
|
||||
} else if (property == "y1") {
|
||||
return(sceneP1().y());
|
||||
} else if (property == "x2") {
|
||||
return(sceneP2().x());
|
||||
} else if (property == "y2") {
|
||||
return(sceneP2().y());
|
||||
}
|
||||
return(QVariant());
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les changements intervenant sur cette partie
|
||||
@param change Type de changement
|
||||
@param value Valeur numerique relative au changement
|
||||
*/
|
||||
QVariant PartLine::itemChange(GraphicsItemChange change, const QVariant &value) {
|
||||
if (scene()) {
|
||||
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
||||
informations -> updateForm();
|
||||
}
|
||||
}
|
||||
return(QGraphicsLineItem::itemChange(change, value));
|
||||
}
|
||||
|
||||
/**
|
||||
@return le premier point, dans les coordonnees de la scene.
|
||||
*/
|
||||
QPointF PartLine::sceneP1() const {
|
||||
return(mapToScene(line().p1()));
|
||||
}
|
||||
|
||||
/**
|
||||
@return le second point, dans les coordonnees de la scene.
|
||||
*/
|
||||
QPointF PartLine::sceneP2() const {
|
||||
return(mapToScene(line().p2()));
|
||||
}
|
||||
|
||||
/**
|
||||
@return la forme selectionnable de la ligne
|
||||
*/
|
||||
QPainterPath PartLine::shape() const {
|
||||
QList<QPointF> points = fourShapePoints();
|
||||
QPainterPath t;
|
||||
t.setFillRule(Qt::WindingFill);
|
||||
t.moveTo(points.at(0));
|
||||
t.lineTo(points.at(1));
|
||||
t.lineTo(points.at(2));
|
||||
t.lineTo(points.at(3));
|
||||
t.lineTo(points.at(0));
|
||||
return(t);
|
||||
}
|
||||
|
||||
/**
|
||||
@return une liste contenant les deux points de la droite + les 4 points entourant ces deux points
|
||||
*/
|
||||
QList<QPointF> PartLine::fourShapePoints() const {
|
||||
const qreal marge = 2.0;
|
||||
// on a donc A(xa , ya) et B(xb, yb)
|
||||
QPointF a = line().p1();
|
||||
QPointF b = line().p2();
|
||||
|
||||
QList<QPointF> result;
|
||||
|
||||
// cas particulier : la droite se ramene a un point
|
||||
if (a == b) {
|
||||
result << QPointF(a.x() - marge, a.y() - marge);
|
||||
result << QPointF(a.x() - marge, a.y() + marge);
|
||||
result << QPointF(a.x() + marge, a.y() + marge);
|
||||
result << QPointF(a.x() + marge, a.y() - marge);
|
||||
} else {
|
||||
|
||||
// on calcule le vecteur AB : (xb-xa, yb-ya)
|
||||
QPointF v_ab = b - a;
|
||||
|
||||
// et la distance AB : racine des coordonnees du vecteur au carre
|
||||
qreal ab = sqrt(pow(v_ab.x(), 2) + pow(v_ab.y(), 2));
|
||||
|
||||
// ensuite on definit le vecteur u(a, b) qui est egal au vecteur AB divise
|
||||
// par sa longueur et multiplie par la longueur de la marge que tu veux
|
||||
// laisser
|
||||
QPointF u = v_ab / ab * marge;
|
||||
|
||||
// on definit le vecteur v(-b , a) qui est perpendiculaire a AB
|
||||
QPointF v(-u.y(), u.x());
|
||||
QPointF m = -u + v; // on a le vecteur M = -u + v
|
||||
QPointF n = -u - v; // et le vecteur N=-u-v
|
||||
QPointF h = a + m; // H = A + M
|
||||
QPointF k = a + n; // K = A + N
|
||||
QPointF i = b - n; // I = B - N
|
||||
QPointF j = b - m; // J = B - M
|
||||
|
||||
result << h << i << j << k;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@return le rectangle delimitant cette partie.
|
||||
*/
|
||||
QRectF PartLine::boundingRect() const {
|
||||
qreal adjust = 1.5;
|
||||
QRectF r(QGraphicsLineItem::boundingRect());
|
||||
r.adjust(-adjust, -adjust, adjust, adjust);
|
||||
return(r);
|
||||
}
|
||||
|
||||
/**
|
||||
@return true si cette partie n'est pas pertinente et ne merite pas d'etre
|
||||
conservee / enregistree.
|
||||
Une ligne est pertinente des lors que ses deux points sont differents
|
||||
*/
|
||||
bool PartLine::isUseless() const {
|
||||
return(sceneP1() == sceneP2());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -15,41 +15,43 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef PART_RECTANGLE_H
|
||||
#define PART_RECTANGLE_H
|
||||
#ifndef PART_LINE_H
|
||||
#define PART_LINE_H
|
||||
#include <QtGui>
|
||||
#include "customelementgraphicpart.h"
|
||||
class RectangleEditor;
|
||||
class LineEditor;
|
||||
/**
|
||||
Cette classe represente un rectangle pouvant etre utilise pour composer le
|
||||
Cette classe represente une ligne pouvant etre utilisee pour composer le
|
||||
dessin d'un element dans l'editeur d'element.
|
||||
*/
|
||||
class PartRectangle : public QGraphicsRectItem, public CustomElementGraphicPart {
|
||||
class PartLine : public QGraphicsLineItem, public CustomElementGraphicPart {
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
PartRectangle(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||
virtual ~PartRectangle();
|
||||
PartLine(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||
virtual ~PartLine();
|
||||
|
||||
private:
|
||||
PartRectangle(const PartRectangle &);
|
||||
PartLine(const PartLine &);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
RectangleEditor *informations;
|
||||
LineEditor *informations;
|
||||
|
||||
// methodes
|
||||
public:
|
||||
enum { Type = UserType + 1109 };
|
||||
enum { Type = UserType + 1104 };
|
||||
/**
|
||||
permet de caster un QGraphicsItem en PartRectangle avec qgraphicsitem_cast
|
||||
permet de caster un QGraphicsItem en PartLine avec qgraphicsitem_cast
|
||||
@return le type de QGraphicsItem
|
||||
*/
|
||||
virtual int type() const { return Type; }
|
||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
||||
virtual QString name() const { return(QObject::tr("rectangle", "element part name")); }
|
||||
virtual QString name() const { return(QObject::tr("ligne")); }
|
||||
virtual const QDomElement toXml(QDomDocument &) const;
|
||||
virtual void fromXml(const QDomElement &);
|
||||
virtual QPointF sceneTopLeft() const;
|
||||
virtual QPointF sceneP1() const;
|
||||
virtual QPointF sceneP2() const;
|
||||
virtual QPainterPath shape() const;
|
||||
virtual QRectF boundingRect() const;
|
||||
virtual void setProperty(const QString &, const QVariant &);
|
||||
virtual QVariant property(const QString &);
|
||||
@@ -57,5 +59,8 @@ class PartRectangle : public QGraphicsRectItem, public CustomElementGraphicPart
|
||||
|
||||
protected:
|
||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||
|
||||
private:
|
||||
QList<QPointF> fourShapePoints() const;
|
||||
};
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -114,7 +114,6 @@ void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWi
|
||||
void PartPolygon::setProperty(const QString &property, const QVariant &value) {
|
||||
CustomElementGraphicPart::setProperty(property, value);
|
||||
if (property == "closed") closed = value.toBool();
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,13 +163,3 @@ bool PartPolygon::isUseless() const {
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@return le rectangle delimitant cette partie.
|
||||
*/
|
||||
QRectF PartPolygon::boundingRect() const {
|
||||
qreal adjust = 1.5;
|
||||
QRectF r(QGraphicsPolygonItem::boundingRect());
|
||||
r.adjust(-adjust, -adjust, adjust, adjust);
|
||||
return(r);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -58,10 +58,9 @@ class PartPolygon : public QGraphicsPolygonItem, public CustomElementGraphicPart
|
||||
@return le type de QGraphicsItem
|
||||
*/
|
||||
virtual int type() const { return Type; }
|
||||
virtual QString name() const { return(QObject::tr("polygone", "element part name")); }
|
||||
virtual QString name() const { return(QObject::tr("polygone")); }
|
||||
void fromXml(const QDomElement &);
|
||||
const QDomElement toXml(QDomDocument &) const;
|
||||
virtual QRectF boundingRect() const;
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||
void setClosed(bool c);
|
||||
bool isClosed() const;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -39,7 +39,6 @@ PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent, QGra
|
||||
|
||||
/// Destructeur
|
||||
PartTerminal::~PartTerminal() {
|
||||
if (informations -> parentWidget()) return; // le widget sera supprime par son parent
|
||||
delete informations;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -48,7 +48,7 @@ class PartTerminal : public CustomElementPart, public QGraphicsItem {
|
||||
@return le type de QGraphicsItem
|
||||
*/
|
||||
virtual int type() const { return Type; }
|
||||
virtual QString name() const { return(QObject::tr("borne", "element part name")); }
|
||||
virtual QString name() const { return(QObject::tr("borne")); }
|
||||
virtual void fromXml(const QDomElement &);
|
||||
virtual const QDomElement toXml(QDomDocument &) const;
|
||||
virtual QWidget *elementInformations();
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
#include "parttext.h"
|
||||
#include "texteditor.h"
|
||||
#include "editorcommands.h"
|
||||
#include "elementscene.h"
|
||||
#include "qetapp.h"
|
||||
|
||||
@@ -33,14 +32,14 @@ PartText::PartText(QETElementEditor *editor, QGraphicsItem *parent, ElementScene
|
||||
{
|
||||
setDefaultTextColor(Qt::black);
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
setPlainText(QObject::tr("T", "default text when adding a text in the element editor"));
|
||||
setPlainText(QObject::tr("T"));
|
||||
infos = new TextEditor(elementEditor(), this);
|
||||
infos -> setElementTypeName(name());
|
||||
}
|
||||
|
||||
|
||||
/// Destructeur
|
||||
PartText::~PartText() {
|
||||
if (infos -> parentWidget()) return; // le widget sera supprime par son parent
|
||||
delete infos;
|
||||
}
|
||||
|
||||
@@ -127,25 +126,6 @@ QPointF PartText::margin() const {
|
||||
*/
|
||||
void PartText::focusOutEvent(QFocusEvent *e) {
|
||||
QGraphicsTextItem::focusOutEvent(e);
|
||||
if (previous_text != toPlainText()) {
|
||||
undoStack().push(
|
||||
new ChangePartCommand(
|
||||
TextEditor::tr("contenu") + " " + name(),
|
||||
this,
|
||||
"text",
|
||||
previous_text,
|
||||
toPlainText()
|
||||
)
|
||||
);
|
||||
previous_text = toPlainText();
|
||||
}
|
||||
|
||||
// deselectionne le texte
|
||||
QTextCursor qtc = textCursor();
|
||||
qtc.clearSelection();
|
||||
setTextCursor(qtc);
|
||||
|
||||
setTextInteractionFlags(Qt::NoTextInteraction);
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
}
|
||||
|
||||
@@ -156,7 +136,6 @@ void PartText::focusOutEvent(QFocusEvent *e) {
|
||||
void PartText::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) {
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
|
||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||
previous_text = toPlainText();
|
||||
QGraphicsTextItem::mouseDoubleClickEvent(e);
|
||||
setFocus(Qt::MouseFocusReason);
|
||||
}
|
||||
@@ -183,7 +162,6 @@ void PartText::setProperty(const QString &property, const QVariant &value) {
|
||||
} else if (property == "text") {
|
||||
setPlainText(value.toString());
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -44,7 +44,7 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
||||
@return le type de QGraphicsItem
|
||||
*/
|
||||
virtual int type() const { return Type; }
|
||||
virtual QString name() const { return(QObject::tr("texte", "element part name")); }
|
||||
virtual QString name() const { return(QObject::tr("texte")); }
|
||||
void fromXml(const QDomElement &);
|
||||
const QDomElement toXml(QDomDocument &) const;
|
||||
QWidget *elementInformations();
|
||||
@@ -63,6 +63,5 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
||||
|
||||
private:
|
||||
QPointF margin() const;
|
||||
QString previous_text;
|
||||
};
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
#include "parttextfield.h"
|
||||
#include "textfieldeditor.h"
|
||||
#include "editorcommands.h"
|
||||
#include "qetapp.h"
|
||||
|
||||
/**
|
||||
@@ -33,14 +32,13 @@ PartTextField::PartTextField(QETElementEditor *editor, QGraphicsItem *parent, QG
|
||||
{
|
||||
setDefaultTextColor(Qt::black);
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
setPlainText(QObject::tr("_", "default text when adding a textfield in the element editor"));
|
||||
setPlainText(QObject::tr("_"));
|
||||
infos = new TextFieldEditor(elementEditor(), this);
|
||||
infos -> setElementTypeName(name());
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
PartTextField::~PartTextField() {
|
||||
if (infos -> parentWidget()) return; // le widget sera supprime par son parent
|
||||
delete infos;
|
||||
}
|
||||
|
||||
@@ -146,25 +144,6 @@ QPointF PartTextField::margin() const {
|
||||
*/
|
||||
void PartTextField::focusOutEvent(QFocusEvent *e) {
|
||||
QGraphicsTextItem::focusOutEvent(e);
|
||||
if (previous_text != toPlainText()) {
|
||||
undoStack().push(
|
||||
new ChangePartCommand(
|
||||
TextFieldEditor::tr("contenu") + " " + name(),
|
||||
this,
|
||||
"text",
|
||||
previous_text,
|
||||
toPlainText()
|
||||
)
|
||||
);
|
||||
previous_text = toPlainText();
|
||||
}
|
||||
|
||||
// deselectionne le texte
|
||||
QTextCursor qtc = textCursor();
|
||||
qtc.clearSelection();
|
||||
setTextCursor(qtc);
|
||||
|
||||
setTextInteractionFlags(Qt::NoTextInteraction);
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
}
|
||||
|
||||
@@ -175,7 +154,6 @@ void PartTextField::focusOutEvent(QFocusEvent *e) {
|
||||
void PartTextField::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) {
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
|
||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||
previous_text = toPlainText();
|
||||
QGraphicsTextItem::mouseDoubleClickEvent(e);
|
||||
setFocus(Qt::MouseFocusReason);
|
||||
}
|
||||
@@ -205,7 +183,6 @@ void PartTextField::setProperty(const QString &property, const QVariant &value)
|
||||
} else if (property == "rotate") {
|
||||
follow_parent_rotations = value.toBool();
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -48,7 +48,7 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart {
|
||||
@return le type de QGraphicsItem
|
||||
*/
|
||||
virtual int type() const { return Type; }
|
||||
virtual QString name() const { return(QObject::tr("champ de texte", "element part name")); }
|
||||
virtual QString name() const { return(QObject::tr("champ de texte")); }
|
||||
void fromXml(const QDomElement &);
|
||||
const QDomElement toXml(QDomDocument &) const;
|
||||
QWidget *elementInformations();
|
||||
@@ -69,6 +69,5 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart {
|
||||
|
||||
private:
|
||||
QPointF margin() const;
|
||||
QString previous_text;
|
||||
};
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -69,8 +69,8 @@ void PolygonEditor::updatePolygonPoints() {
|
||||
if (points.count() < 2) {
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
tr("Erreur", "message box title"),
|
||||
tr("Le polygone doit comporter au moins deux points.", "message box content")
|
||||
tr("Erreur"),
|
||||
tr("Le polygone doit comporter au moins deux points.")
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ void PolygonEditor::updatePolygonClosedState() {
|
||||
*/
|
||||
void PolygonEditor::updateForm() {
|
||||
activeConnections(false);
|
||||
while(points_list.takeTopLevelItem(0)) {}
|
||||
while(points_list.takeTopLevelItem(0));
|
||||
foreach(QPointF point, part -> polygon()) {
|
||||
point = part -> mapToScene(point);
|
||||
QStringList qsl;
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -22,9 +22,6 @@
|
||||
#include "customelementpart.h"
|
||||
#include "newelementwizard.h"
|
||||
#include "elementitemeditor.h"
|
||||
#include "elementdefinition.h"
|
||||
#include "elementdialog.h"
|
||||
#include "recentfiles.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@@ -33,8 +30,8 @@
|
||||
QETElementEditor::QETElementEditor(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
read_only(false),
|
||||
min_title(tr("QElectroTech - \311diteur d'\351l\351ment", "window title")),
|
||||
opened_from_file(false)
|
||||
min_title(tr("QElectroTech - \311diteur d'\351l\351ment")),
|
||||
_filename(QString())
|
||||
{
|
||||
setWindowTitle(min_title);
|
||||
setWindowIcon(QIcon(":/ico/qet.png"));
|
||||
@@ -49,7 +46,6 @@ QETElementEditor::QETElementEditor(QWidget *parent) :
|
||||
|
||||
// lecture des parametres
|
||||
readSettings();
|
||||
slot_updateMenus();
|
||||
|
||||
// affichage
|
||||
show();
|
||||
@@ -57,12 +53,6 @@ QETElementEditor::QETElementEditor(QWidget *parent) :
|
||||
|
||||
/// Destructeur
|
||||
QETElementEditor::~QETElementEditor() {
|
||||
/*
|
||||
retire le widget d'edition de partie affiche par le dock
|
||||
cela evite qu'il ne soit supprime avant que la partie a laquelle il est
|
||||
rattache ne le supprime une fois de trop
|
||||
*/
|
||||
clearToolsDock();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,24 +61,14 @@ QETElementEditor::~QETElementEditor() {
|
||||
void QETElementEditor::setupActions() {
|
||||
new_element = new QAction(QIcon(":/ico/new.png"), tr("&Nouveau"), this);
|
||||
open = new QAction(QIcon(":/ico/open.png"), tr("&Ouvrir"), this);
|
||||
open_file = new QAction(QIcon(":/ico/open.png"), tr("&Ouvrir depuis un fichier"), this);
|
||||
save = new QAction(QIcon(":/ico/save.png"), tr("&Enregistrer"), this);
|
||||
save_as = new QAction(QIcon(":/ico/saveas.png"), tr("Enregistrer sous"), this);
|
||||
save_as_file = new QAction(QIcon(":/ico/saveas.png"), tr("Enregistrer dans un fichier"), this);
|
||||
reload = new QAction(QIcon(":/ico/reload.png"), tr("Recharger"), this);
|
||||
quit = new QAction(QIcon(":/ico/exit.png"), tr("&Quitter"), this);
|
||||
selectall = new QAction( tr("Tout s\351lectionner"), this);
|
||||
deselectall = new QAction( tr("D\351s\351lectionner tout"), this);
|
||||
cut = new QAction(QIcon(":/ico/cut.png"), tr("Co&uper"), this);
|
||||
copy = new QAction(QIcon(":/ico/copy.png"), tr("Cop&ier"), this);
|
||||
paste = new QAction(QIcon(":/ico/paste.png"), tr("C&oller"), this);
|
||||
paste_in_area = new QAction(QIcon(":/ico/paste.png"), tr("C&oller dans la zone..."), this);
|
||||
inv_select = new QAction( tr("Inverser la s\351lection"), this);
|
||||
edit_delete = new QAction(QIcon(":/ico/delete.png"), tr("&Supprimer"), this);
|
||||
zoom_in = new QAction(QIcon(":/ico/viewmag+.png"), tr("Zoom avant"), this);
|
||||
zoom_out = new QAction(QIcon(":/ico/viewmag-.png"), tr("Zoom arri\350re"), this);
|
||||
zoom_fit = new QAction(QIcon(":/ico/viewmagfit.png"), tr("Zoom adapt\351"), this);
|
||||
zoom_reset = new QAction(QIcon(":/ico/viewmag.png"), tr("Pas de zoom"), this);
|
||||
edit_size_hs = new QAction(QIcon(":/ico/hotspot.png"), tr("\311diter la taille et le point de saisie"), this);
|
||||
edit_names = new QAction(QIcon(":/ico/names.png"), tr("\311diter les noms"), this);
|
||||
edit_ori = new QAction(QIcon(":/ico/orientations.png"), tr("\311diter les orientations"), this);
|
||||
@@ -98,7 +78,6 @@ void QETElementEditor::setupActions() {
|
||||
edit_forward = new QAction(QIcon(":/ico/bring_forward.png"),tr("Amener au premier plan"), this);
|
||||
move = new QAction(QIcon(":/ico/select.png"), tr("D\351placer un objet"), this);
|
||||
add_line = new QAction(QIcon(":/ico/line.png"), tr("Ajouter une ligne"), this);
|
||||
add_rectangle = new QAction(QIcon(":/ico/rectangle.png"), tr("Ajouter un rectangle"), this);
|
||||
add_ellipse = new QAction(QIcon(":/ico/ellipse.png"), tr("Ajouter une ellipse"), this);
|
||||
add_circle = new QAction(QIcon(":/ico/circle.png"), tr("Ajouter un cercle"), this);
|
||||
add_polygon = new QAction(QIcon(":/ico/polygon.png"), tr("Ajouter un polygone"), this);
|
||||
@@ -107,17 +86,6 @@ void QETElementEditor::setupActions() {
|
||||
add_terminal = new QAction(QIcon(":/ico/terminal.png"), tr("Ajouter une borne"), this);
|
||||
add_textfield = new QAction(QIcon(":/ico/textfield.png"), tr("Ajouter un champ de texte"), this);
|
||||
|
||||
QString add_status_tip = tr("Maintenez la touche Shift enfonc\351e pour effectuer plusieurs ajouts d'affil\351e");
|
||||
add_line -> setStatusTip(add_status_tip);
|
||||
add_rectangle -> setStatusTip(add_status_tip);
|
||||
add_ellipse -> setStatusTip(add_status_tip);
|
||||
add_circle -> setStatusTip(add_status_tip);
|
||||
add_text -> setStatusTip(add_status_tip);
|
||||
add_arc -> setStatusTip(add_status_tip);
|
||||
add_terminal -> setStatusTip(add_status_tip);
|
||||
add_textfield -> setStatusTip(add_status_tip);
|
||||
add_polygon -> setStatusTip(tr("Utilisez le bouton droit de la souris pour poser le dernier point du polygone"));
|
||||
|
||||
undo = ce_scene -> undoStack().createUndoAction(this, tr("Annuler"));
|
||||
redo = ce_scene -> undoStack().createRedoAction(this, tr("Refaire"));
|
||||
undo -> setIcon(QIcon(":/ico/undo.png"));
|
||||
@@ -127,25 +95,13 @@ void QETElementEditor::setupActions() {
|
||||
|
||||
new_element -> setShortcut(QKeySequence::New);
|
||||
open -> setShortcut(QKeySequence::Open);
|
||||
open_file -> setShortcut(tr("Ctrl+Shift+O"));
|
||||
save -> setShortcut(QKeySequence::Save);
|
||||
save_as_file -> setShortcut(tr("Ctrl+Shift+S"));
|
||||
reload -> setShortcut(Qt::Key_F5);
|
||||
reload -> setShortcut(QKeySequence::Refresh);
|
||||
quit -> setShortcut(QKeySequence(tr("Ctrl+Q")));
|
||||
selectall -> setShortcut(QKeySequence::SelectAll);
|
||||
deselectall -> setShortcut(QKeySequence(tr("Ctrl+Shift+A")));
|
||||
inv_select -> setShortcut(QKeySequence(tr("Ctrl+I")));
|
||||
cut -> setShortcut(QKeySequence::Cut);
|
||||
copy -> setShortcut(QKeySequence::Copy);
|
||||
paste -> setShortcut(QKeySequence::Paste);
|
||||
paste_in_area -> setShortcut(tr("Ctrl+Shift+V"));
|
||||
edit_delete -> setShortcut(QKeySequence(tr("Suppr")));
|
||||
|
||||
zoom_in -> setShortcut(QKeySequence::ZoomIn);
|
||||
zoom_out -> setShortcut(QKeySequence::ZoomOut);
|
||||
zoom_fit -> setShortcut(QKeySequence(tr("Ctrl+9")));
|
||||
zoom_reset -> setShortcut(QKeySequence(tr("Ctrl+0")));
|
||||
|
||||
edit_names -> setShortcut(QKeySequence(tr("Ctrl+E")));
|
||||
edit_size_hs -> setShortcut(QKeySequence(tr("Ctrl+R")));
|
||||
edit_ori -> setShortcut(QKeySequence(tr("Ctrl+T")));
|
||||
@@ -157,23 +113,13 @@ void QETElementEditor::setupActions() {
|
||||
|
||||
connect(new_element, SIGNAL(triggered()), this, SLOT(slot_new()));
|
||||
connect(open, SIGNAL(triggered()), this, SLOT(slot_open()));
|
||||
connect(open_file, SIGNAL(triggered()), this, SLOT(slot_openFile()));
|
||||
connect(save, SIGNAL(triggered()), this, SLOT(slot_save()));
|
||||
connect(save_as, SIGNAL(triggered()), this, SLOT(slot_saveAs()));
|
||||
connect(save_as_file, SIGNAL(triggered()), this, SLOT(slot_saveAsFile()));
|
||||
connect(reload, SIGNAL(triggered()), this, SLOT(slot_reload()));
|
||||
connect(quit, SIGNAL(triggered()), this, SLOT(close()));
|
||||
connect(selectall, SIGNAL(triggered()), ce_scene, SLOT(slot_selectAll()));
|
||||
connect(deselectall, SIGNAL(triggered()), ce_scene, SLOT(slot_deselectAll()));
|
||||
connect(inv_select, SIGNAL(triggered()), ce_scene, SLOT(slot_invertSelection()));
|
||||
connect(cut, SIGNAL(triggered()), ce_view, SLOT(cut()));
|
||||
connect(copy, SIGNAL(triggered()), ce_view, SLOT(copy()));
|
||||
connect(paste, SIGNAL(triggered()), ce_view, SLOT(paste()));
|
||||
connect(paste_in_area, SIGNAL(triggered()), ce_view, SLOT(pasteInArea()));
|
||||
connect(zoom_in, SIGNAL(triggered()), ce_view, SLOT(zoomIn()));
|
||||
connect(zoom_out, SIGNAL(triggered()), ce_view, SLOT(zoomOut()));
|
||||
connect(zoom_fit, SIGNAL(triggered()), ce_view, SLOT(zoomFit()));
|
||||
connect(zoom_reset, SIGNAL(triggered()), ce_view, SLOT(zoomReset()));
|
||||
connect(edit_delete, SIGNAL(triggered()), ce_scene, SLOT(slot_delete()));
|
||||
connect(edit_size_hs, SIGNAL(triggered()), ce_scene, SLOT(slot_editSizeHotSpot()));
|
||||
connect(edit_names, SIGNAL(triggered()), ce_scene, SLOT(slot_editNames()));
|
||||
@@ -184,7 +130,6 @@ void QETElementEditor::setupActions() {
|
||||
connect(edit_backward, SIGNAL(triggered()), ce_scene, SLOT(slot_sendBackward()));
|
||||
connect(move, SIGNAL(triggered()), ce_scene, SLOT(slot_move()));
|
||||
connect(add_line, SIGNAL(triggered()), ce_scene, SLOT(slot_addLine()));
|
||||
connect(add_rectangle, SIGNAL(triggered()), ce_scene, SLOT(slot_addRectangle()));
|
||||
connect(add_ellipse, SIGNAL(triggered()), ce_scene, SLOT(slot_addEllipse()));
|
||||
connect(add_circle, SIGNAL(triggered()), ce_scene, SLOT(slot_addCircle()));
|
||||
connect(add_polygon, SIGNAL(triggered()), ce_scene, SLOT(slot_addPolygon()));
|
||||
@@ -195,7 +140,6 @@ void QETElementEditor::setupActions() {
|
||||
|
||||
connect(move, SIGNAL(triggered()), this, SLOT(slot_setRubberBandToView()));
|
||||
connect(add_line, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
||||
connect(add_rectangle, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
||||
connect(add_ellipse, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
||||
connect(add_circle, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
||||
connect(add_polygon, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
||||
@@ -208,7 +152,6 @@ void QETElementEditor::setupActions() {
|
||||
|
||||
move -> setCheckable(true);
|
||||
add_line -> setCheckable(true);
|
||||
add_rectangle -> setCheckable(true);
|
||||
add_ellipse -> setCheckable(true);
|
||||
add_circle -> setCheckable(true);
|
||||
add_polygon -> setCheckable(true);
|
||||
@@ -220,17 +163,16 @@ void QETElementEditor::setupActions() {
|
||||
parts = new QActionGroup(this);
|
||||
parts -> addAction(move);
|
||||
parts -> addAction(add_line);
|
||||
parts -> addAction(add_rectangle);
|
||||
parts -> addAction(add_ellipse);
|
||||
parts -> addAction(add_circle);
|
||||
parts -> addAction(add_polygon);
|
||||
parts -> addAction(add_arc);
|
||||
parts -> addAction(add_text);
|
||||
parts -> addAction(add_arc);
|
||||
parts -> addAction(add_textfield);
|
||||
parts -> addAction(add_terminal);
|
||||
parts -> setExclusive(true);
|
||||
|
||||
parts_toolbar = new QToolBar(tr("Parties", "toolbar title"), this);
|
||||
parts_toolbar = new QToolBar(tr("Parties"), this);
|
||||
parts_toolbar -> setObjectName("parts");
|
||||
foreach (QAction *action, parts -> actions()) parts_toolbar -> addAction(action);
|
||||
move -> setChecked(true);
|
||||
@@ -242,49 +184,12 @@ void QETElementEditor::setupActions() {
|
||||
parts_toolbar -> addAction(xml_preview);
|
||||
*/
|
||||
|
||||
main_toolbar = new QToolBar(tr("Outils", "toolbar title"), this);
|
||||
main_toolbar -> setObjectName("main_toolbar");
|
||||
view_toolbar = new QToolBar(tr("Affichage", "toolbar title"), this);
|
||||
view_toolbar -> setObjectName("display");
|
||||
element_toolbar = new QToolBar(tr("\311l\351ment", "toolbar title"), this);
|
||||
element_toolbar -> setObjectName("element_toolbar");
|
||||
depth_toolbar = new QToolBar(tr("Profondeur", "toolbar title"), this);
|
||||
depth_toolbar -> setObjectName("depth_toolbar");
|
||||
|
||||
main_toolbar -> addAction(new_element);
|
||||
main_toolbar -> addAction(open);
|
||||
main_toolbar -> addAction(save);
|
||||
main_toolbar -> addAction(save_as);
|
||||
main_toolbar -> addAction(reload);
|
||||
main_toolbar -> addSeparator();
|
||||
main_toolbar -> addAction(undo);
|
||||
main_toolbar -> addAction(redo);
|
||||
main_toolbar -> addSeparator();
|
||||
main_toolbar -> addAction(edit_delete);
|
||||
view_toolbar -> addAction(zoom_in);
|
||||
view_toolbar -> addAction(zoom_out);
|
||||
view_toolbar -> addAction(zoom_fit);
|
||||
view_toolbar -> addAction(zoom_reset);
|
||||
element_toolbar -> addAction(edit_size_hs);
|
||||
element_toolbar -> addAction(edit_names);
|
||||
element_toolbar -> addAction(edit_ori);
|
||||
depth_toolbar -> addAction(edit_forward);
|
||||
depth_toolbar -> addAction(edit_raise);
|
||||
depth_toolbar -> addAction(edit_lower);
|
||||
depth_toolbar -> addAction(edit_backward);
|
||||
|
||||
addToolBar(Qt::TopToolBarArea, main_toolbar);
|
||||
addToolBar(Qt::TopToolBarArea, view_toolbar);
|
||||
addToolBar(Qt::TopToolBarArea, element_toolbar);
|
||||
addToolBar(Qt::TopToolBarArea, depth_toolbar);
|
||||
addToolBar(Qt::LeftToolBarArea, parts_toolbar);
|
||||
|
||||
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateInformations()));
|
||||
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateMenus()));
|
||||
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(slot_updateMenus()));
|
||||
connect(&(ce_scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(slot_updateMenus()));
|
||||
connect(&(ce_scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(slot_updateTitle()));
|
||||
connect(&(ce_scene -> undoStack()), SIGNAL(indexChanged(int)), this, SLOT(slot_updatePartsList()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -305,12 +210,8 @@ void QETElementEditor::setupMenus() {
|
||||
|
||||
file_menu -> addAction(new_element);
|
||||
file_menu -> addAction(open);
|
||||
file_menu -> addAction(open_file);
|
||||
file_menu -> addMenu(QETApp::elementsRecentFiles() -> menu());
|
||||
connect(QETApp::elementsRecentFiles(), SIGNAL(fileOpeningRequested(const QString &)), this, SLOT(openRecentFile(const QString &)));
|
||||
file_menu -> addAction(save);
|
||||
file_menu -> addAction(save_as);
|
||||
file_menu -> addAction(save_as_file);
|
||||
file_menu -> addSeparator();
|
||||
file_menu -> addAction(reload);
|
||||
file_menu -> addSeparator();
|
||||
@@ -323,11 +224,6 @@ void QETElementEditor::setupMenus() {
|
||||
edit_menu -> addAction(deselectall);
|
||||
edit_menu -> addAction(inv_select);
|
||||
edit_menu -> addSeparator();
|
||||
edit_menu -> addAction(cut);
|
||||
edit_menu -> addAction(copy);
|
||||
edit_menu -> addAction(paste);
|
||||
edit_menu -> addAction(paste_in_area);
|
||||
edit_menu -> addSeparator();
|
||||
edit_menu -> addAction(edit_delete);
|
||||
edit_menu -> addSeparator();
|
||||
edit_menu -> addAction(edit_names);
|
||||
@@ -360,13 +256,6 @@ void QETElementEditor::setupMenus() {
|
||||
*/
|
||||
void QETElementEditor::slot_updateMenus() {
|
||||
bool selected_items = !ce_scene -> selectedItems().isEmpty();
|
||||
bool clipboard_elmt = ElementScene::clipboardMayContainElement();
|
||||
|
||||
deselectall -> setEnabled(selected_items);
|
||||
cut -> setEnabled(selected_items);
|
||||
copy -> setEnabled(selected_items);
|
||||
paste -> setEnabled(clipboard_elmt);
|
||||
paste_in_area -> setEnabled(clipboard_elmt);
|
||||
edit_delete -> setEnabled(selected_items);
|
||||
edit_forward -> setEnabled(selected_items);
|
||||
edit_raise -> setEnabled(selected_items);
|
||||
@@ -381,10 +270,10 @@ void QETElementEditor::slot_updateMenus() {
|
||||
void QETElementEditor::slot_updateTitle() {
|
||||
QString title = min_title;
|
||||
title += " - " + ce_scene -> names().name() + " ";
|
||||
if (!filename_.isEmpty() || !location_.isNull()) {
|
||||
if (!ce_scene -> undoStack().isClean()) title += tr("[Modifi\351]", "window title tag");
|
||||
if (_filename != QString()) {
|
||||
if (!ce_scene -> undoStack().isClean()) title += tr("[Modifi\351]");
|
||||
if (isReadOnly()) title += tr(" [lecture seule]");
|
||||
}
|
||||
if (isReadOnly()) title += tr(" [lecture seule]", "window title tag");
|
||||
setWindowTitle(title);
|
||||
}
|
||||
|
||||
@@ -402,25 +291,19 @@ void QETElementEditor::setupInterface() {
|
||||
// widget par defaut dans le QDockWidget
|
||||
default_informations = new QLabel();
|
||||
|
||||
// ScrollArea pour accueillir un widget d'edition (change a la volee)
|
||||
tools_dock_scroll_area_ = new QScrollArea();
|
||||
|
||||
// Pile de widgets pour accueillir les deux widgets precedents
|
||||
tools_dock_stack_ = new QStackedWidget();
|
||||
tools_dock_stack_ -> insertWidget(0, default_informations);
|
||||
tools_dock_stack_ -> insertWidget(1, tools_dock_scroll_area_);
|
||||
|
||||
// panel sur le cote pour editer les parties
|
||||
tools_dock = new QDockWidget(tr("Informations", "dock title"), this);
|
||||
tools_dock = new QDockWidget(tr("Informations"), this);
|
||||
tools_dock -> setObjectName("informations");
|
||||
tools_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
tools_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
tools_dock -> setMinimumWidth(380);
|
||||
tools_dock -> setMinimumWidth(290);
|
||||
addDockWidget(Qt::RightDockWidgetArea, tools_dock);
|
||||
tools_dock -> setWidget(tools_dock_stack_);
|
||||
QWidget *info_widget = new QWidget();
|
||||
info_widget -> setLayout(new QVBoxLayout(info_widget));
|
||||
tools_dock -> setWidget(info_widget);
|
||||
|
||||
// panel sur le cote pour les annulations
|
||||
undo_dock = new QDockWidget(tr("Annulations", "dock title"), this);
|
||||
undo_dock = new QDockWidget(tr("Annulations"), this);
|
||||
undo_dock -> setObjectName("undo");
|
||||
undo_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
undo_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
@@ -438,7 +321,7 @@ void QETElementEditor::setupInterface() {
|
||||
connect(ce_scene, SIGNAL(partsZValueChanged()), this, SLOT(slot_createPartsList()));
|
||||
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updatePartsList()));
|
||||
connect(parts_list, SIGNAL(itemSelectionChanged()), this, SLOT(slot_updateSelectionFromPartsList()));
|
||||
parts_dock = new QDockWidget(tr("Parties", "dock title"), this);
|
||||
parts_dock = new QDockWidget(tr("Parties"), this);
|
||||
parts_dock -> setObjectName("parts_list");
|
||||
parts_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
parts_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
@@ -450,7 +333,7 @@ void QETElementEditor::setupInterface() {
|
||||
slot_createPartsList();
|
||||
|
||||
// barre d'etat
|
||||
statusBar() -> showMessage(tr("\311diteur d'\351l\351ments", "status bar message"));
|
||||
statusBar() -> showMessage(tr("\311diteur d'\351l\351ments"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -492,23 +375,31 @@ void QETElementEditor::slot_updateInformations() {
|
||||
}
|
||||
}
|
||||
|
||||
clearToolsDock();
|
||||
// recupere le layout
|
||||
QLayout *layout = tools_dock -> widget() -> layout();
|
||||
|
||||
// enleve les widgets deja presents
|
||||
QLayoutItem *qli;
|
||||
while ((qli = layout -> takeAt(0)) != 0) {
|
||||
if (QWidget *w = qli -> widget()) {
|
||||
layout -> removeWidget(w);
|
||||
w -> setParent(0);
|
||||
w -> hide();
|
||||
}
|
||||
}
|
||||
if (selected_parts.size() == 1) {
|
||||
// recupere le premier CustomElementPart et en ajoute le widget d'edition
|
||||
QWidget *edit_widget = selected_parts.first() -> elementInformations();
|
||||
tools_dock_scroll_area_ -> setWidget(edit_widget);
|
||||
tools_dock_stack_ -> setCurrentIndex(1);
|
||||
layout -> addWidget(edit_widget);
|
||||
edit_widget -> show();
|
||||
} else {
|
||||
default_informations -> setText(
|
||||
tr(
|
||||
"%n partie(s) s\351lectionn\351e(s).",
|
||||
"",
|
||||
selected_parts.size()
|
||||
)
|
||||
selected_parts.size() ?
|
||||
QString("%1").arg(selected_parts.size()) + tr(" parties s\351lectionn\351es.") :
|
||||
tr("Aucune partie s\351lectionn\351e.")
|
||||
);
|
||||
default_informations -> setAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
||||
tools_dock_stack_ -> setCurrentIndex(0);
|
||||
layout -> addWidget(default_informations);
|
||||
default_informations -> show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -524,33 +415,6 @@ void QETElementEditor::xmlPreview() {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
Verifie si l'ensemble des parties graphiques consituant l'element en cours
|
||||
d'edition est bien contenu dans le rectangle representant les limites de
|
||||
l'element. Si ce n'est pas le cas, l'utilisateur en est informe.
|
||||
@return true si la situation est ok, false sinon
|
||||
*/
|
||||
bool QETElementEditor::checkElementSize() {
|
||||
if (ce_scene -> borderContainsEveryParts()) {
|
||||
return(true);
|
||||
} else {
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
tr("Dimensions de l'\351l\351ment", "messagebox title"),
|
||||
tr(
|
||||
"Attention : certaines parties graphiques (textes, cercles, "
|
||||
"lignes...) semblent d\351border du cadre de l'\351l\351ment. Cela"
|
||||
" risque de g\351n\351rer des bugs graphiques lors de leur "
|
||||
"manipulation sur un sch\351ma. Vous pouvez corriger cela soit "
|
||||
"en d\351pla\347ant ces parties, soit en vous rendant dans "
|
||||
"\311dition > \311diter la taille et le point de saisie."
|
||||
, "messagebox content"
|
||||
)
|
||||
);
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Charge un fichier
|
||||
@param filepath Chemin du fichier a charger
|
||||
@@ -563,7 +427,7 @@ void QETElementEditor::fromFile(const QString &filepath) {
|
||||
QFileInfo infos_file(filepath);
|
||||
if (!infos_file.exists() || !infos_file.isFile()) {
|
||||
state = false;
|
||||
error_message = QString(tr("Le fichier %1 n'existe pas.", "message box content")).arg(filepath);
|
||||
error_message = tr("Le fichier ") + filepath + tr(" n'existe pas.");
|
||||
}
|
||||
|
||||
// le fichier doit etre lisible
|
||||
@@ -571,7 +435,7 @@ void QETElementEditor::fromFile(const QString &filepath) {
|
||||
if (state) {
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
state = false;
|
||||
error_message = QString(tr("Impossible d'ouvrir le fichier %1.", "message box content")).arg(filepath);
|
||||
error_message = tr("Impossible d'ouvrir le fichier ") + filepath + ".";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -580,13 +444,13 @@ void QETElementEditor::fromFile(const QString &filepath) {
|
||||
if (state) {
|
||||
if (!document_xml.setContent(&file)) {
|
||||
state = false;
|
||||
error_message = tr("Ce fichier n'est pas un document XML valide", "message box content");
|
||||
error_message = tr("Ce fichier n'est pas un document XML valide");
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
if (!state) {
|
||||
QMessageBox::critical(this, tr("Erreur", "toolbar title"), error_message);
|
||||
QMessageBox::critical(this, tr("Erreur"), error_message);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -598,18 +462,17 @@ void QETElementEditor::fromFile(const QString &filepath) {
|
||||
if (!infos_file.isWritable()) {
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
tr("\311dition en lecture seule", "message box title"),
|
||||
tr("Vous n'avez pas les privil\350ges n\351cessaires pour modifier cet \351lement. Il sera donc ouvert en lecture seule.", "message box content")
|
||||
tr("\311dition en lecture seule"),
|
||||
tr("Vous n'avez pas les privil\350ges n\351cessaires pour modifier cet \351lement. Il sera donc ouvert en lecture seule.")
|
||||
);
|
||||
setReadOnly(true);
|
||||
}
|
||||
|
||||
// memorise le fichier
|
||||
setFileName(filepath);
|
||||
QETApp::elementsRecentFiles() -> fileWasOpened(filepath);
|
||||
slot_updateMenus();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Enregistre l'element vers un fichier
|
||||
@param fn Chemin du fichier a enregistrer
|
||||
@@ -618,7 +481,7 @@ void QETElementEditor::fromFile(const QString &filepath) {
|
||||
bool QETElementEditor::toFile(const QString &fn) {
|
||||
QFile file(fn);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
QMessageBox::warning(this, tr("Erreur", "message box title"), tr("Impossible d'\351crire dans ce fichier", "message box content"));
|
||||
QMessageBox::warning(this, tr("Erreur"), tr("Impossible d'ecrire dans ce fichier"));
|
||||
return(false);
|
||||
}
|
||||
QTextStream out(&file);
|
||||
@@ -628,45 +491,6 @@ bool QETElementEditor::toFile(const QString &fn) {
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
Enregistre l'element vers un emplacement
|
||||
@param location Emplacement de l'element a enregistrer
|
||||
@return true en cas de reussite, false sinon
|
||||
*/
|
||||
bool QETElementEditor::toLocation(const ElementsLocation &location) {
|
||||
ElementsCollectionItem *item = QETApp::collectionItem(location);
|
||||
ElementDefinition *element;
|
||||
if (item) {
|
||||
// l'element existe deja
|
||||
element = qobject_cast<ElementDefinition *>(item);
|
||||
} else {
|
||||
// l'element n'existe pas encore, on demande sa creation
|
||||
element = QETApp::createElement(location);
|
||||
}
|
||||
|
||||
if (!element) {
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr("Erreur", "message box title"),
|
||||
tr("Impossible d'atteindre l'\351l\351ment", "message box content")
|
||||
);
|
||||
return(false);
|
||||
}
|
||||
|
||||
// enregistre l'element
|
||||
element -> setXml(ce_scene -> toXml().documentElement());
|
||||
if (!element -> write()) {
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr("Erreur", "message box title"),
|
||||
tr("Impossible d'enregistrer l'\351l\351ment", "message box content")
|
||||
);
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
specifie si l'editeur d'element doit etre en mode lecture seule
|
||||
@param ro true pour activer le mode lecture seule, false pour le desactiver
|
||||
@@ -680,9 +504,6 @@ void QETElementEditor::setReadOnly(bool ro) {
|
||||
ce_view -> setInteractive(!ro);
|
||||
|
||||
// active / desactive l'edition de la taille, du hotspot, des noms et des orientations
|
||||
cut -> setEnabled(!ro);
|
||||
copy -> setEnabled(!ro);
|
||||
paste -> setEnabled(!ro);
|
||||
selectall -> setEnabled(!ro);
|
||||
deselectall -> setEnabled(!ro);
|
||||
inv_select -> setEnabled(!ro);
|
||||
@@ -706,63 +527,24 @@ bool QETElementEditor::isReadOnly() const {
|
||||
Lance l'assistant de creation d'un nouvel element.
|
||||
*/
|
||||
void QETElementEditor::slot_new() {
|
||||
NewElementWizard new_element_wizard(this);
|
||||
NewElementWizard new_element_wizard;
|
||||
new_element_wizard.exec();
|
||||
}
|
||||
|
||||
/**
|
||||
Ouvre un element
|
||||
Ouvre un fichier
|
||||
*/
|
||||
void QETElementEditor::slot_open() {
|
||||
// demande le chemin virtuel de l'element a ouvrir a l'utilisateur
|
||||
ElementsLocation location = ElementDialog::getOpenElementLocation();
|
||||
if (location.isNull()) return;
|
||||
QETElementEditor *cee = new QETElementEditor();
|
||||
cee -> fromLocation(location);
|
||||
cee -> show();
|
||||
}
|
||||
|
||||
/**
|
||||
Ouvre un fichier
|
||||
Demande un fichier a l'utilisateur et ouvre ce fichier
|
||||
*/
|
||||
void QETElementEditor::slot_openFile() {
|
||||
// demande un nom de fichier a ouvrir a l'utilisateur
|
||||
QString user_filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Ouvrir un fichier", "dialog title"),
|
||||
filename_.isEmpty() ? QETApp::customElementsDir() : QDir(filename_).absolutePath(),
|
||||
tr(
|
||||
"\311l\351ments QElectroTech (*.elmt);;"
|
||||
"Fichiers XML (*.xml);;"
|
||||
"Tous les fichiers (*)",
|
||||
"filetypes allowed when opening an element file"
|
||||
)
|
||||
tr("Ouvrir un fichier"),
|
||||
_filename.isEmpty() ? QETApp::customElementsDir() : QDir(_filename).absolutePath(),
|
||||
tr("\311l\351ments QElectroTech (*.elmt);;Fichiers XML (*.xml);;Tous les fichiers (*)")
|
||||
);
|
||||
openElement(user_filename);
|
||||
}
|
||||
|
||||
/**
|
||||
Slot utilise pour ouvrir un fichier recent.
|
||||
Transfere filepath au slot openElement seulement si cet editeur est actif
|
||||
@param filepath Fichier a ouvrir
|
||||
@see openElement
|
||||
*/
|
||||
void QETElementEditor::openRecentFile(const QString &filepath) {
|
||||
if (qApp -> activeWindow() != this) return;
|
||||
openElement(filepath);
|
||||
}
|
||||
|
||||
/**
|
||||
Ouvre un fichier element dans un nouvel editeur
|
||||
Cette methode ne controle pas si le fichier est deja ouvert
|
||||
@param filepath Fichier a ouvrir
|
||||
@see fromFile
|
||||
*/
|
||||
void QETElementEditor::openElement(const QString &filepath) {
|
||||
if (filepath.isEmpty()) return;
|
||||
if (user_filename.isEmpty()) return;
|
||||
QETElementEditor *cee = new QETElementEditor();
|
||||
cee -> fromFile(filepath);
|
||||
cee -> fromFile(user_filename);
|
||||
cee -> show();
|
||||
}
|
||||
|
||||
@@ -770,13 +552,16 @@ void QETElementEditor::openElement(const QString &filepath) {
|
||||
Recharge l'element edite
|
||||
*/
|
||||
void QETElementEditor::slot_reload() {
|
||||
// impossible de recharger un element non enregistre
|
||||
if (_filename.isEmpty()) return;
|
||||
|
||||
// s'il ya des modifications, on demande a l'utilisateur s'il est certain
|
||||
// de vouloir recharger
|
||||
if (!ce_scene -> undoStack().isClean()) {
|
||||
QMessageBox::StandardButton answer = QMessageBox::question(
|
||||
this,
|
||||
tr("Recharger l'\351l\351ment", "dialog title"),
|
||||
tr("Vous avez efffectu\351 des modifications sur cet \351l\351ment. Si vous le rechargez, ces modifications seront perdues. Voulez-vous vraiment recharger l'\351l\351ment ?", "dialog content"),
|
||||
tr("Recharger l'\351l\351ment"),
|
||||
tr("Vous avez efffectu\351 des modifications sur cet \351l\351ment. Si vous le rechargez, ces modifications seront perdues. Voulez-vous vraiment recharger l'\351l\351ment ?"),
|
||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
|
||||
QMessageBox::Cancel
|
||||
);
|
||||
@@ -784,19 +569,8 @@ void QETElementEditor::slot_reload() {
|
||||
}
|
||||
|
||||
// recharge l'element
|
||||
if (opened_from_file) {
|
||||
// l'element a ete ouvert a partir d'un chemin de fichier
|
||||
ce_scene -> reset();
|
||||
fromFile(filename_);
|
||||
} else {
|
||||
// l'element a ete ouvert a partir d'un emplacement (ElementsLocation)
|
||||
// il peut s'agir aussi bien d'un fichier que d'un element XML
|
||||
if (ElementsCollectionItem *item = QETApp::collectionItem(location_)) {
|
||||
item -> reload();
|
||||
ce_scene -> reset();
|
||||
fromLocation(location_);
|
||||
}
|
||||
}
|
||||
ce_scene -> reset();
|
||||
fromFile(_filename);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -806,57 +580,24 @@ void QETElementEditor::slot_reload() {
|
||||
@see slot_saveAs()
|
||||
*/
|
||||
bool QETElementEditor::slot_save() {
|
||||
// verification avant d'enregistrer le fichier
|
||||
checkElementSize();
|
||||
|
||||
// si on ne connait pas le nom du fichier en cours, enregistrer revient a enregistrer sous
|
||||
if (opened_from_file) {
|
||||
if (filename_.isEmpty()) return(slot_saveAsFile());
|
||||
// sinon on enregistre dans le nom de fichier connu
|
||||
bool result_save = toFile(filename_);
|
||||
if (result_save) ce_scene -> undoStack().setClean();
|
||||
return(result_save);
|
||||
} else {
|
||||
if (location_.isNull()) return(slot_saveAs());
|
||||
// sinon on enregistre a l'emplacement connu
|
||||
bool result_save = toLocation(location_);
|
||||
if (result_save) ce_scene -> undoStack().setClean();
|
||||
return(result_save);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Demande une localisation a l'utilisateur et enregistre l'element
|
||||
*/
|
||||
bool QETElementEditor::slot_saveAs() {
|
||||
// demande une localisation a l'utilisateur
|
||||
ElementsLocation location = ElementDialog::getSaveElementLocation();
|
||||
if (location.isNull()) return(false);
|
||||
|
||||
// tente l'enregistrement
|
||||
bool result_save = toLocation(location);
|
||||
if (result_save) {
|
||||
setLocation(location);
|
||||
ce_scene -> undoStack().setClean();
|
||||
}
|
||||
|
||||
// retourne un booleen representatif de la reussite de l'enregistrement
|
||||
if (_filename.isEmpty()) return(slot_saveAs());
|
||||
// sinon on enregistre dans le nom de fichier connu
|
||||
bool result_save = toFile(_filename);
|
||||
if (result_save) ce_scene -> undoStack().setClean();
|
||||
return(result_save);
|
||||
}
|
||||
|
||||
/**
|
||||
Demande un nom de fichier a l'utilisateur et enregistre l'element
|
||||
*/
|
||||
bool QETElementEditor::slot_saveAsFile() {
|
||||
bool QETElementEditor::slot_saveAs() {
|
||||
// demande un nom de fichier a l'utilisateur pour enregistrer l'element
|
||||
QString fn = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
tr("Enregistrer sous", "dialog title"),
|
||||
filename_.isEmpty() ? QETApp::customElementsDir() : QDir(filename_).absolutePath(),
|
||||
tr(
|
||||
"\311l\351ments QElectroTech (*.elmt)",
|
||||
"filetypes allowed when saving an element file"
|
||||
)
|
||||
tr("Enregistrer sous"),
|
||||
_filename.isEmpty() ? QETApp::customElementsDir() : QDir(_filename).absolutePath(),
|
||||
tr("\311l\351ments QElectroTech (*.elmt)")
|
||||
);
|
||||
// si aucun nom n'est entre, renvoie faux.
|
||||
if (fn.isEmpty()) return(false);
|
||||
@@ -867,7 +608,6 @@ bool QETElementEditor::slot_saveAsFile() {
|
||||
// si l'enregistrement reussit, le nom du fichier est conserve
|
||||
if (result_save) {
|
||||
setFileName(fn);
|
||||
QETApp::elementsRecentFiles() -> fileWasOpened(fn);
|
||||
ce_scene -> undoStack().setClean();
|
||||
}
|
||||
// retourne un booleen representatif de la reussite de l'enregistrement
|
||||
@@ -885,14 +625,9 @@ bool QETElementEditor::canClose() {
|
||||
// demande d'abord a l'utilisateur s'il veut enregistrer l'element en cours
|
||||
QMessageBox::StandardButton answer = QMessageBox::question(
|
||||
this,
|
||||
tr("Enregistrer l'\351l\351ment en cours ?", "dialog title"),
|
||||
QString(
|
||||
tr(
|
||||
"Voulez-vous enregistrer l'\351l\351ment %1 ?",
|
||||
"dialog content - %1 is an element name"
|
||||
)
|
||||
).arg(ce_scene -> names().name()),
|
||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
|
||||
tr("Enregistrer l'\351l\351ment en cours ?"),
|
||||
tr("Voulez-vous enregistrer l'\351l\351ment ") + ce_scene -> names().name() + tr(" ?"),
|
||||
QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel,
|
||||
QMessageBox::Cancel
|
||||
);
|
||||
bool result;
|
||||
@@ -904,20 +639,6 @@ bool QETElementEditor::canClose() {
|
||||
return(result);
|
||||
}
|
||||
|
||||
/**
|
||||
Enleve et cache le widget affiche par le dock permettant d'editer les
|
||||
parties.
|
||||
@return le widget enleve, ou 0 s'il n'y avait pas de widget a enlever
|
||||
*/
|
||||
QWidget *QETElementEditor::clearToolsDock() {
|
||||
if (QWidget *previous_widget = tools_dock_scroll_area_ -> takeWidget()) {
|
||||
previous_widget -> setParent(0);
|
||||
previous_widget -> hide();
|
||||
return(previous_widget);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
Permet de quitter l'editeur lors de la fermeture de la fenetre principale
|
||||
@param qce Le QCloseEvent correspondant a l'evenement de fermeture
|
||||
@@ -989,7 +710,6 @@ void QETElementEditor::slot_updateSelectionFromPartsList() {
|
||||
parts_list -> blockSignals(false);
|
||||
ce_scene -> blockSignals(false);
|
||||
slot_updateInformations();
|
||||
slot_updateMenus();
|
||||
}
|
||||
|
||||
/// Lit les parametres de l'editeur d'element
|
||||
@@ -1011,70 +731,3 @@ void QETElementEditor::writeSettings() {
|
||||
settings.setValue("elementeditor/geometry", saveGeometry());
|
||||
settings.setValue("elementeditor/state", saveState());
|
||||
}
|
||||
|
||||
/**
|
||||
@return les decalages horizontaux et verticaux (sous la forme d'un point) a
|
||||
utiliser lors d'un copier/coller avec decalage.
|
||||
*/
|
||||
QPointF QETElementEditor::pasteOffset() {
|
||||
QPointF paste_offset(5.0, 0.0);
|
||||
return(paste_offset);
|
||||
}
|
||||
|
||||
/**
|
||||
@return Le type de mouvement a effectuer lors d'un copier/coller avec
|
||||
decalage.
|
||||
*/
|
||||
QET::OrientedMovement QETElementEditor::pasteMovement() {
|
||||
return(QET::ToEast);
|
||||
}
|
||||
|
||||
/**
|
||||
@param location Emplacement de l'element a editer
|
||||
*/
|
||||
void QETElementEditor::fromLocation(const ElementsLocation &location) {
|
||||
|
||||
// l'element doit exister
|
||||
ElementsCollectionItem *item = QETApp::collectionItem(location);
|
||||
ElementDefinition *element = 0;
|
||||
if (!item) {
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr("\311l\351ment inexistant.", "message box title"),
|
||||
tr("L'\351l\351ment n'existe pas.", "message box content")
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!item -> isElement() || !(element = qobject_cast<ElementDefinition *>(item)) || element -> isNull()) {
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
tr("\311l\351ment inexistant.", "message box title"),
|
||||
tr("Le chemin virtuel choisi ne correspond pas \340 un \351l\351ment.", "message box content")
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// le fichier doit etre un document XML
|
||||
QDomDocument document_xml;
|
||||
QDomNode node = document_xml.importNode(element -> xml(), true);
|
||||
document_xml.appendChild(node);
|
||||
|
||||
// chargement de l'element
|
||||
ce_scene -> fromXml(document_xml);
|
||||
slot_createPartsList();
|
||||
|
||||
// gestion de la lecture seule
|
||||
if (!element -> isWritable()) {
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
tr("\311dition en lecture seule", "message box title"),
|
||||
tr("Vous n'avez pas les privil\350ges n\351cessaires pour modifier cet \351lement. Il sera donc ouvert en lecture seule.", "message box content")
|
||||
);
|
||||
setReadOnly(true);
|
||||
}
|
||||
|
||||
// memorise le fichier
|
||||
setLocation(location);
|
||||
slot_updateMenus();
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -18,10 +18,8 @@
|
||||
#ifndef CUSTOM_ELEMENT_EDITOR_H
|
||||
#define CUSTOM_ELEMENT_EDITOR_H
|
||||
#include <QtGui>
|
||||
#include "qet.h"
|
||||
#include "elementscene.h"
|
||||
#include "orientationset.h"
|
||||
#include "elementslocation.h"
|
||||
class ElementView;
|
||||
/**
|
||||
Cette classe represente un editeur d'element. Elle permet a l'utilisateur
|
||||
@@ -50,12 +48,6 @@ class QETElementEditor : public QMainWindow {
|
||||
ElementScene *ce_scene;
|
||||
/// container pour les widgets d'edition des parties
|
||||
QDockWidget *tools_dock;
|
||||
/// Pile de widgets pour tools_dock
|
||||
QStackedWidget *tools_dock_stack_;
|
||||
/// label affiche lors de la selection de plusieurs elements
|
||||
QLabel *default_informations;
|
||||
/// ScrollArea pour le DockWidget affichant des infos sur la partie selectionnee
|
||||
QScrollArea *tools_dock_scroll_area_;
|
||||
/// container pour la liste des annulations
|
||||
QDockWidget *undo_dock;
|
||||
/// Container pour la liste des parties
|
||||
@@ -63,28 +55,24 @@ class QETElementEditor : public QMainWindow {
|
||||
/// Liste des parties
|
||||
QListWidget *parts_list;
|
||||
/// actions du menu fichier
|
||||
QAction *new_element, *open, *open_file, *save, *save_as, *save_as_file, *reload, *quit;
|
||||
QAction *new_element, *open, *save, *save_as, *reload, *quit;
|
||||
/// actions du menu edition
|
||||
QAction *selectall, *deselectall, *inv_select;
|
||||
QAction *cut, *copy, *paste, *paste_in_area;
|
||||
QAction *undo, *redo;
|
||||
QAction *zoom_in, *zoom_out, *zoom_fit, *zoom_reset;
|
||||
QAction *edit_delete, *edit_size_hs, *edit_names, *edit_ori;
|
||||
QAction *edit_raise, *edit_lower, *edit_backward, *edit_forward;
|
||||
/// barres d'outils
|
||||
QToolBar *parts_toolbar, *main_toolbar, *view_toolbar, *depth_toolbar, *element_toolbar;
|
||||
/// barre d'outils
|
||||
QToolBar *parts_toolbar;
|
||||
/// actions de la barre d'outils
|
||||
QActionGroup *parts;
|
||||
QAction *move, *add_line, *add_circle, *add_rectangle, *add_ellipse, *add_polygon, *add_text;
|
||||
QAction *move, *add_line, *add_circle, *add_ellipse, *add_polygon, *add_text;
|
||||
QAction *add_arc, *add_terminal, *add_textfield;
|
||||
/// label affiche lors de la selection de plusieurs elements
|
||||
QLabel *default_informations;
|
||||
/// titre minimal
|
||||
QString min_title;
|
||||
/// Nom de fichier de l'element edite
|
||||
QString filename_;
|
||||
/// Emplacement de l'element edite
|
||||
ElementsLocation location_;
|
||||
/// booleen indiquant si l'element en cours d'edition provient d'un fichier ou d'un emplacement
|
||||
bool opened_from_file;
|
||||
/// Nom de fichier
|
||||
QString _filename;
|
||||
|
||||
// methodes
|
||||
public:
|
||||
@@ -95,21 +83,15 @@ class QETElementEditor : public QMainWindow {
|
||||
void setNames(const NamesList &);
|
||||
void setOrientations(const OrientationSet &orientation_set);
|
||||
OrientationSet orientations() const;
|
||||
void setLocation(const ElementsLocation &);
|
||||
ElementsLocation location() const;
|
||||
void setFileName(const QString &);
|
||||
QString fileName() const;
|
||||
void setReadOnly(bool);
|
||||
bool isReadOnly() const;
|
||||
void fromFile(const QString &);
|
||||
void fromLocation(const ElementsLocation &);
|
||||
bool toFile(const QString &);
|
||||
bool toLocation(const ElementsLocation &);
|
||||
ElementScene *elementScene() const;
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
static QPointF pasteOffset();
|
||||
static QET::OrientedMovement pasteMovement();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *);
|
||||
@@ -119,18 +101,13 @@ class QETElementEditor : public QMainWindow {
|
||||
void setupMenus();
|
||||
void setupInterface();
|
||||
bool canClose();
|
||||
QWidget *clearToolsDock();
|
||||
|
||||
public slots:
|
||||
void slot_new();
|
||||
void slot_open();
|
||||
void slot_openFile();
|
||||
void openRecentFile(const QString &);
|
||||
void openElement(const QString &);
|
||||
void slot_reload();
|
||||
bool slot_save();
|
||||
bool slot_saveAs();
|
||||
bool slot_saveAsFile();
|
||||
void slot_setRubberBandToView();
|
||||
void slot_setNoDragToView();
|
||||
void slot_setNormalMode();
|
||||
@@ -141,7 +118,6 @@ class QETElementEditor : public QMainWindow {
|
||||
void slot_updatePartsList();
|
||||
void slot_updateSelectionFromPartsList();
|
||||
void xmlPreview();
|
||||
bool checkElementSize();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -199,36 +175,19 @@ inline OrientationSet QETElementEditor::orientations() const {
|
||||
return(ce_scene -> orientations());
|
||||
}
|
||||
|
||||
/**
|
||||
@param el Le nouvel emplacement de l'element edite
|
||||
*/
|
||||
inline void QETElementEditor::setLocation(const ElementsLocation &el) {
|
||||
location_ = el;
|
||||
opened_from_file = false;
|
||||
slot_updateTitle();
|
||||
}
|
||||
|
||||
/**
|
||||
@return l'emplacement de l'element edite
|
||||
*/
|
||||
inline ElementsLocation QETElementEditor::location() const {
|
||||
return(location_);
|
||||
}
|
||||
|
||||
/**
|
||||
@param fn Le nouveau nom de fichier de l'element edite
|
||||
*/
|
||||
inline void QETElementEditor::setFileName(const QString &fn) {
|
||||
filename_ = fn;
|
||||
opened_from_file = true;
|
||||
_filename = fn;
|
||||
slot_updateTitle();
|
||||
}
|
||||
|
||||
/**
|
||||
@return le nom de fichier de l'element edite
|
||||
@return le nomde fichier de l'element edite
|
||||
*/
|
||||
inline QString QETElementEditor::fileName() const {
|
||||
return(filename_);
|
||||
return(_filename);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -27,26 +27,26 @@
|
||||
StyleEditor::StyleEditor(QETElementEditor *editor, CustomElementGraphicPart *p, QWidget *parent) : ElementItemEditor(editor, parent), part(p) {
|
||||
// couleur
|
||||
color = new QButtonGroup(this);
|
||||
color -> addButton(black_color = new QRadioButton(tr("Noir", "element part color")), CustomElementGraphicPart::BlackColor);
|
||||
color -> addButton(white_color = new QRadioButton(tr("Blanc", "element part color")), CustomElementGraphicPart::WhiteColor);
|
||||
color -> addButton(black_color = new QRadioButton(tr("Noir")), CustomElementGraphicPart::BlackColor);
|
||||
color -> addButton(white_color = new QRadioButton(tr("Blanc")), CustomElementGraphicPart::WhiteColor);
|
||||
|
||||
// style
|
||||
style = new QButtonGroup(this);
|
||||
style -> addButton(normal_style = new QRadioButton(tr("Normal", "element part line style")), CustomElementGraphicPart::NormalStyle);
|
||||
style -> addButton(dashed_style = new QRadioButton(tr("Pointill\351", "element part line style")), CustomElementGraphicPart::DashedStyle);
|
||||
style -> addButton(normal_style = new QRadioButton(tr("Normal")), CustomElementGraphicPart::NormalStyle);
|
||||
style -> addButton(dashed_style = new QRadioButton(tr("Pointill\351")), CustomElementGraphicPart::DashedStyle);
|
||||
style -> button(part -> lineStyle()) -> setChecked(true);
|
||||
|
||||
// epaisseur
|
||||
weight = new QButtonGroup(this);
|
||||
weight -> addButton(none_weight = new QRadioButton(tr("Nulle", "element part weight")), CustomElementGraphicPart::NoneWeight);
|
||||
weight -> addButton(thin_weight = new QRadioButton(tr("Fine", "element part weight")), CustomElementGraphicPart::ThinWeight);
|
||||
weight -> addButton(normal_weight = new QRadioButton(tr("Normale", "element part weight")), CustomElementGraphicPart::NormalWeight);
|
||||
weight -> addButton(none_weight = new QRadioButton(tr("Nulle")), CustomElementGraphicPart::NoneWeight);
|
||||
weight -> addButton(thin_weight = new QRadioButton(tr("Fine")), CustomElementGraphicPart::ThinWeight);
|
||||
weight -> addButton(normal_weight = new QRadioButton(tr("Normale")), CustomElementGraphicPart::NormalWeight);
|
||||
|
||||
// remplissage
|
||||
filling = new QButtonGroup(this);
|
||||
filling -> addButton(no_filling = new QRadioButton(tr("Aucun", "element part filling")), CustomElementGraphicPart::NoneFilling );
|
||||
filling -> addButton(black_filling = new QRadioButton(tr("Noir", "element part filling")), CustomElementGraphicPart::BlackFilling);
|
||||
filling -> addButton(white_filling = new QRadioButton(tr("Blanc", "element part filling")), CustomElementGraphicPart::WhiteFilling);
|
||||
filling -> addButton(no_filling = new QRadioButton(tr("Aucun")), CustomElementGraphicPart::NoneFilling );
|
||||
filling -> addButton(black_filling = new QRadioButton(tr("Noir")), CustomElementGraphicPart::BlackFilling);
|
||||
filling -> addButton(white_filling = new QRadioButton(tr("Blanc")), CustomElementGraphicPart::WhiteFilling);
|
||||
|
||||
// antialiasing
|
||||
antialiasing = new QCheckBox(tr("Antialiasing"));
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -81,7 +81,7 @@ void TextEditor::updateTextX() { addChangePartCommand(tr("abscisse"), part, "
|
||||
/// Met a jour l'ordonnee de la position du texte et cree un objet d'annulation
|
||||
void TextEditor::updateTextY() { addChangePartCommand(tr("ordonn\351e"), part, "y", qle_y -> text().toDouble()); updateForm(); }
|
||||
/// Met a jour le texte et cree un objet d'annulation
|
||||
void TextEditor::updateTextT() { addChangePartCommand(tr("contenu"), part, "text", qle_text -> text()); }
|
||||
void TextEditor::updateTextT() { addChangePartCommand(tr("texte"), part, "text", qle_text -> text()); }
|
||||
/// Met a jour la taille du texte et cree un objet d'annulation
|
||||
void TextEditor::updateTextS() { addChangePartCommand(tr("taille"), part, "size", font_size -> value()); }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -86,7 +86,7 @@ void TextFieldEditor::updateTextFieldX() { addChangePartCommand(tr("abscisse"),
|
||||
/// Met a jour l'ordonnee de la position du champ de texte et cree un objet d'annulation
|
||||
void TextFieldEditor::updateTextFieldY() { addChangePartCommand(tr("ordonn\351e"), part, "y", qle_y -> text().toDouble()); updateForm(); }
|
||||
/// Met a jour le texte du champ de texte et cree un objet d'annulation
|
||||
void TextFieldEditor::updateTextFieldT() { addChangePartCommand(tr("contenu"), part, "text", qle_text -> text()); }
|
||||
void TextFieldEditor::updateTextFieldT() { addChangePartCommand(tr("texte"), part, "text", qle_text -> text()); }
|
||||
/// Met a jour la taille du champ de texte et cree un objet d'annulation
|
||||
void TextFieldEditor::updateTextFieldS() { addChangePartCommand(tr("taille"), part, "size", font_size -> value()); }
|
||||
/// Met a jour la taille du champ de texte et cree un objet d'annulation
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -27,7 +27,6 @@
|
||||
Constructeur pour un element sans scene ni parent
|
||||
*/
|
||||
Element::Element(QGraphicsItem *parent, Diagram *scene) :
|
||||
QObject(),
|
||||
QGraphicsItem(parent, scene),
|
||||
internal_connections(false)
|
||||
{
|
||||
@@ -50,7 +49,7 @@ void Element::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
// corrige un bug de rendu ne se produisant que lors du rendu sur QGraphicsScene sous X11 au zoom par defaut
|
||||
static bool must_correct_rendering_bug = QETApp::settings().value("correct-rendering", false).toBool();
|
||||
static bool must_correct_rendering_bug = !QString(qVersion()).startsWith("4.4");
|
||||
if (must_correct_rendering_bug) {
|
||||
Diagram *dia = diagram();
|
||||
if (dia && options -> levelOfDetail == 1.0 && widget) {
|
||||
@@ -138,8 +137,8 @@ void Element::deselect() {
|
||||
@return La pixmap de l'element
|
||||
*/
|
||||
QPixmap Element::pixmap() {
|
||||
if (preview.isNull()) updatePixmap(); // on genere la pixmap si ce n'est deja fait
|
||||
return(preview);
|
||||
if (apercu.isNull()) updatePixmap(); // on genere la pixmap si ce n'est deja fait
|
||||
return(apercu);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +155,7 @@ bool Element::setOrientation(QET::Orientation o) {
|
||||
rotate(rotation_value);
|
||||
ori.setCurrent(o);
|
||||
update();
|
||||
foreach(QGraphicsItem *qgi, childItems()) {
|
||||
foreach(QGraphicsItem *qgi, children()) {
|
||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) p -> updateConductor();
|
||||
else if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(qgi)) {
|
||||
// applique une rotation contraire si besoin
|
||||
@@ -220,10 +219,10 @@ void Element::drawSelection(QPainter *painter, const QStyleOptionGraphicsItem *)
|
||||
*/
|
||||
void Element::updatePixmap() {
|
||||
// Pixmap transparente faisant la taille de base de l'element
|
||||
preview = QPixmap(dimensions);
|
||||
preview.fill(QColor(255, 255, 255, 0));
|
||||
apercu = QPixmap(dimensions);
|
||||
apercu.fill(QColor(255, 255, 255, 0));
|
||||
// QPainter sur la pixmap, avec antialiasing
|
||||
QPainter p(&preview);
|
||||
QPainter p(&apercu);
|
||||
p.setRenderHint(QPainter::Antialiasing, true);
|
||||
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||
// Translation de l'origine du repere de la pixmap
|
||||
@@ -259,21 +258,11 @@ void Element::setPos(qreal x, qreal y) {
|
||||
setPos(QPointF(x, y));
|
||||
}
|
||||
|
||||
/**
|
||||
Gere l'enfoncement d'un bouton de la souris
|
||||
*/
|
||||
void Element::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
||||
if (e -> modifiers() & Qt::ControlModifier) {
|
||||
setSelected(!isSelected());
|
||||
}
|
||||
QGraphicsItem::mousePressEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les mouvements de souris lies a l'element
|
||||
*/
|
||||
void Element::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
||||
if (isSelected() && e -> buttons() & Qt::LeftButton) {
|
||||
if (e -> buttons() & Qt::LeftButton) {
|
||||
QPointF oldPos = pos();
|
||||
setPos(mapToParent(e -> pos()) - matrix().map(e -> buttonDownPos(Qt::LeftButton)));
|
||||
if (Diagram *diagram_ptr = diagram()) {
|
||||
@@ -302,9 +291,7 @@ void Element::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
||||
}
|
||||
diagram_ptr -> invalidateMovedElements();
|
||||
}
|
||||
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
||||
QGraphicsItem::mouseReleaseEvent(e);
|
||||
}
|
||||
QGraphicsItem::mouseReleaseEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,7 +344,7 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr) {
|
||||
|
||||
QHash<int, Terminal *> priv_id_adr;
|
||||
int terminals_non_trouvees = 0;
|
||||
foreach(QGraphicsItem *qgi, childItems()) {
|
||||
foreach(QGraphicsItem *qgi, children()) {
|
||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) {
|
||||
bool terminal_trouvee = false;
|
||||
foreach(QDomElement qde, liste_terminals) {
|
||||
@@ -389,7 +376,7 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr) {
|
||||
|
||||
// importe les valeurs des champs de texte
|
||||
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input");
|
||||
foreach(QGraphicsItem *qgi, childItems()) {
|
||||
foreach(QGraphicsItem *qgi, children()) {
|
||||
if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(qgi)) {
|
||||
foreach(QDomElement input, inputs) eti -> fromXml(input);
|
||||
}
|
||||
@@ -418,11 +405,13 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
||||
QDomElement element = document.createElement("element");
|
||||
|
||||
// type
|
||||
element.setAttribute("type", typeId());
|
||||
QString chemin_elmt = typeId();
|
||||
QString type_elmt = QETApp::symbolicPath(chemin_elmt);
|
||||
element.setAttribute("type", type_elmt);
|
||||
|
||||
// position, selection et orientation
|
||||
element.setAttribute("x", QString("%1").arg(pos().x()));
|
||||
element.setAttribute("y", QString("%1").arg(pos().y()));
|
||||
element.setAttribute("x", pos().x());
|
||||
element.setAttribute("y", pos().y());
|
||||
element.setAttribute("orientation", QString("%1").arg(ori.current()));
|
||||
|
||||
/* recupere le premier id a utiliser pour les bornes de cet element */
|
||||
@@ -437,21 +426,29 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
||||
}
|
||||
|
||||
// enregistrement des bornes de l'appareil
|
||||
QDomElement xml_terminals = document.createElement("terminals");
|
||||
QDomElement terminals = document.createElement("terminals");
|
||||
// pour chaque enfant de l'element
|
||||
foreach(Terminal *t, terminals()) {
|
||||
// alors on enregistre la borne
|
||||
QDomElement terminal = t -> toXml(document);
|
||||
terminal.setAttribute("id", id_terminal);
|
||||
table_adr_id.insert(t, id_terminal ++);
|
||||
xml_terminals.appendChild(terminal);
|
||||
foreach(QGraphicsItem *child, children()) {
|
||||
// si cet enfant est une borne
|
||||
if (Terminal *t = qgraphicsitem_cast<Terminal *>(child)) {
|
||||
// alors on enregistre la borne
|
||||
QDomElement terminal = t -> toXml(document);
|
||||
terminal.setAttribute("id", id_terminal);
|
||||
table_adr_id.insert(t, id_terminal ++);
|
||||
terminals.appendChild(terminal);
|
||||
}
|
||||
}
|
||||
element.appendChild(xml_terminals);
|
||||
element.appendChild(terminals);
|
||||
|
||||
// enregistrement des champ de texte de l'appareil
|
||||
QDomElement inputs = document.createElement("inputs");
|
||||
foreach(ElementTextItem *eti, texts()) {
|
||||
inputs.appendChild(eti -> toXml(document));
|
||||
// pour chaque enfant de l'element
|
||||
foreach(QGraphicsItem *child, children()) {
|
||||
// si cet enfant est un champ de texte
|
||||
if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(child)) {
|
||||
// alors on enregistre le champ de texte
|
||||
inputs.appendChild(eti -> toXml(document));
|
||||
}
|
||||
}
|
||||
element.appendChild(inputs);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -21,13 +21,10 @@
|
||||
#include "terminal.h"
|
||||
#include "orientationset.h"
|
||||
class Diagram;
|
||||
class ElementTextItem;
|
||||
/**
|
||||
Cette classe abstraite represente un element electrique.
|
||||
*/
|
||||
class Element : public QObject, public QGraphicsItem {
|
||||
|
||||
Q_OBJECT
|
||||
class Element : public QGraphicsItem {
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
@@ -54,7 +51,7 @@ class Element : public QObject, public QGraphicsItem {
|
||||
private:
|
||||
QSize dimensions;
|
||||
QPoint hotspot_coord;
|
||||
QPixmap preview;
|
||||
QPixmap apercu;
|
||||
|
||||
// methodes
|
||||
public:
|
||||
@@ -69,14 +66,12 @@ class Element : public QObject, public QGraphicsItem {
|
||||
virtual QList<Terminal *> terminals() const = 0;
|
||||
/// @return la liste des conducteurs relies a cet element
|
||||
virtual QList<Conductor *> conductors() const = 0;
|
||||
/// @return la liste des champs de textes de cet element
|
||||
virtual QList<ElementTextItem *> texts() const = 0;
|
||||
/// @return le nombre de bornes actuel de cet element
|
||||
virtual int terminalsCount() const = 0;
|
||||
virtual int nbTerminals() const = 0;
|
||||
/// @return le nombre de bornes minimum de cet element
|
||||
virtual int minTerminalsCount() const = 0;
|
||||
virtual int nbTerminalsMin() const = 0;
|
||||
/// @return le nombre de bornes maximum de cet element
|
||||
virtual int maxTerminalsCount() const = 0;
|
||||
virtual int nbTerminalsMax() const = 0;
|
||||
/**
|
||||
Dessine l'element
|
||||
*/
|
||||
@@ -84,7 +79,7 @@ class Element : public QObject, public QGraphicsItem {
|
||||
/// @return L'ID du type de l'element
|
||||
virtual QString typeId() const = 0;
|
||||
/// @return Le nom de l'element
|
||||
virtual QString name() const = 0;
|
||||
virtual QString nom() const = 0;
|
||||
Diagram *diagram() const;
|
||||
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||
@@ -119,7 +114,6 @@ class Element : public QObject, public QGraphicsItem {
|
||||
|
||||
protected:
|
||||
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -16,25 +16,16 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "elementdeleter.h"
|
||||
#include "qetapp.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param elmt_path Chemin virtuel du fichier representant l'element a supprimer
|
||||
@param elmt_path Chemin du fichier representant l'element a supprimer
|
||||
@param parent QWidget parent
|
||||
*/
|
||||
ElementDeleter::ElementDeleter(const ElementsLocation &elmt_path, QWidget *parent) :
|
||||
ElementDeleter::ElementDeleter(const QString &elmt_path, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
element(0)
|
||||
element_path(elmt_path)
|
||||
{
|
||||
// recupere l'element a supprimer
|
||||
ElementsCollectionItem *element_item = QETApp::collectionItem(elmt_path);
|
||||
if (!element_item) return;
|
||||
|
||||
// on exige un element
|
||||
if (!element_item -> isElement()) return;
|
||||
|
||||
element = element_item;
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
@@ -45,31 +36,27 @@ ElementDeleter::~ElementDeleter() {
|
||||
Supprime l'element : verifie l'existence du fichier, demande confirmation a
|
||||
l'utilisateur et avertit ce dernier si la suppression a echoue.
|
||||
*/
|
||||
bool ElementDeleter::exec() {
|
||||
void ElementDeleter::exec() {
|
||||
// verifie l'existence de l'element
|
||||
if (!element || !element -> isElement()) return(false);
|
||||
QFile elmt_file(element_path);
|
||||
if (!elmt_file.exists()) return;
|
||||
|
||||
// confirmation #1
|
||||
QMessageBox::StandardButton answer_1 = QMessageBox::question(
|
||||
this,
|
||||
tr("Supprimer l'\351l\351ment ?", "message box title"),
|
||||
tr("\312tes-vous s\373r de vouloir supprimer cet \351l\351ment ?\n", "message box content"),
|
||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel
|
||||
tr("Supprimer l'\351l\351ment ?"),
|
||||
tr("\312tes-vous s\373r de vouloir supprimer cet \351l\351ment ?\n"),
|
||||
QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel
|
||||
);
|
||||
if (answer_1 != QMessageBox::Yes) return(false);
|
||||
|
||||
/**
|
||||
@todo Regression : rafficher le chemin de l'element
|
||||
*/
|
||||
if (answer_1 != QMessageBox::Yes) return;
|
||||
|
||||
// supprime l'element
|
||||
if (!element -> remove()) {
|
||||
if (!elmt_file.remove()) {
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
tr("Suppression de l'\351l\351ment", "message box title"),
|
||||
tr("La suppression de l'\351l\351ment a \351chou\351.", "message box content")
|
||||
tr("Suppression de l'\351l\351ment"),
|
||||
tr("La suppression de l'\351l\351ment a \351chou\351.\n"
|
||||
"V\351rifiez vos droits sur le fichier ") + element_path + tr(".")
|
||||
);
|
||||
return(false);
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2009 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -18,28 +18,27 @@
|
||||
#ifndef ELEMENT_DELETER_H
|
||||
#define ELEMENT_DELETER_H
|
||||
#include "elementscategory.h"
|
||||
#include "elementslocation.h"
|
||||
#include <QtGui>
|
||||
/**
|
||||
Cette classe represente une couche d'abstraction pour supprimer
|
||||
un element de la collection d'elements.
|
||||
Elle demande notamment confirmation a l'utilisateur.
|
||||
Elle demande notamment confirmation a l'utilisateur
|
||||
*/
|
||||
class ElementDeleter : public QWidget {
|
||||
Q_OBJECT
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
ElementDeleter(const ElementsLocation &, QWidget * = 0);
|
||||
ElementDeleter(const QString &, QWidget * = 0);
|
||||
virtual ~ElementDeleter();
|
||||
private:
|
||||
ElementDeleter(const ElementsCategory &);
|
||||
|
||||
// methodes
|
||||
public slots:
|
||||
bool exec();
|
||||
void exec();
|
||||
|
||||
// attributs
|
||||
private:
|
||||
ElementsCollectionItem *element;
|
||||
QString element_path;
|
||||
};
|
||||
#endif
|
||||
@@ -1,16 +0,0 @@
|
||||
<definition width="50" version="0.1" hotspot_x="25" hotspot_y="30" height="40" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Input</name>
|
||||
<name lang="fr" >Entrée</name>
|
||||
<name lang="es" >Entrada</name>
|
||||
</names>
|
||||
<description>
|
||||
<input x="-18" y="-10" size="9" rotate="true" text="_" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="5" x1="10" y2="-5" x2="10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="-5" x1="-10" y2="5" x2="-10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="24" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-24" y2="0" x2="-10" />
|
||||
<terminal x="24" y="0" orientation="e" />
|
||||
<terminal x="-24" y="0" orientation="w" />
|
||||
</description>
|
||||
</definition>
|
||||
@@ -1,17 +0,0 @@
|
||||
<definition width="50" version="0.1" hotspot_x="25" hotspot_y="30" height="40" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Input (down front)</name>
|
||||
<name lang="fr" >Entrée (front descendant)</name>
|
||||
<name lang="es" >Entrada (front descendant)</name>
|
||||
</names>
|
||||
<description>
|
||||
<text x="-4.25" y="5.25" size="9" text="N" />
|
||||
<input x="-18" y="-10" size="9" rotate="true" text="_" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="5" x1="10" y2="-5" x2="10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="-5" x1="-10" y2="5" x2="-10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="24" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-24" y2="0" x2="-10" />
|
||||
<terminal x="24" y="0" orientation="e" />
|
||||
<terminal x="-24" y="0" orientation="w" />
|
||||
</description>
|
||||
</definition>
|
||||
@@ -1,16 +0,0 @@
|
||||
<definition width="50" version="0.1" hotspot_x="25" hotspot_y="30" height="40" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Input (up front)</name>
|
||||
<name lang="fr" >Entrée (front montant)</name>
|
||||
</names>
|
||||
<description>
|
||||
<text x="-3.5" y="5.25" size="9" text="P" />
|
||||
<input x="-18" y="-10" size="9" rotate="true" text="_" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="5" x1="10" y2="-5" x2="10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="-5" x1="-10" y2="5" x2="-10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="24" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-24" y2="0" x2="-10" />
|
||||
<terminal x="24" y="0" orientation="e" />
|
||||
<terminal x="-24" y="0" orientation="w" />
|
||||
</description>
|
||||
</definition>
|
||||
@@ -1,16 +0,0 @@
|
||||
<definition width="50" version="0.1" hotspot_x="25" hotspot_y="30" height="40" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Input (negative logic)</name>
|
||||
<name lang="fr" >Entrée (NF)</name>
|
||||
</names>
|
||||
<description>
|
||||
<line antialias="true" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="5" x1="-7" y2="-5" x2="7" />
|
||||
<input x="-18" y="-10" size="9" rotate="true" text="_" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="5" x1="10" y2="-5" x2="10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="-5" x1="-10" y2="5" x2="-10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="24" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-24" y2="0" x2="-10" />
|
||||
<terminal x="24" y="0" orientation="e" />
|
||||
<terminal x="-24" y="0" orientation="w" />
|
||||
</description>
|
||||
</definition>
|
||||
@@ -1,7 +0,0 @@
|
||||
<qet-directory>
|
||||
<names>
|
||||
<name lang="en" >Inputs</name>
|
||||
<name lang="fr" >Entrées</name>
|
||||
<name lang="es" >Entradas</name>
|
||||
</names>
|
||||
</qet-directory>
|
||||
@@ -1,7 +0,0 @@
|
||||
<qet-directory>
|
||||
<names>
|
||||
<name lang="en" >Outputs</name>
|
||||
<name lang="fr" >Sorties</name>
|
||||
<name lang="es" >Salidas</name>
|
||||
</names>
|
||||
</qet-directory>
|
||||
@@ -1,15 +0,0 @@
|
||||
<definition width="50" version="0.1" hotspot_x="25" hotspot_y="30" height="40" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Output</name>
|
||||
<name lang="fr" >Sortie</name>
|
||||
<name lang="es" >Salida</name>
|
||||
</names>
|
||||
<description>
|
||||
<arc width="4" x="6" y="-5" antialias="true" height="10" style="line-style:normal;line-weight:normal;filling:none;color:black" start="80" angle="-160" />
|
||||
<input x="-18" y="-10" size="9" rotate="true" text="_" />
|
||||
<arc width="4" x="-10" y="-5" antialias="true" height="10" style="line-style:normal;line-weight:normal;filling:none;color:black" start="-100" angle="-160" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="24" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-24" y2="0" x2="-10" />
|
||||
<terminal x="-24" y="0" orientation="w" />
|
||||
</description>
|
||||
</definition>
|
||||
@@ -1,16 +0,0 @@
|
||||
<definition width="50" version="0.1" hotspot_x="25" hotspot_y="30" height="40" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Output (reset)</name>
|
||||
<name lang="fr" >Sortie (reset)</name>
|
||||
<name lang="es" >Salida (reset)</name>
|
||||
</names>
|
||||
<description>
|
||||
<text x="-4.25" y="5.25" size="9" text="R" />
|
||||
<arc width="4" x="6" y="-5" antialias="true" height="10" style="line-style:normal;line-weight:normal;filling:none;color:black" start="80" angle="-160" />
|
||||
<input x="-18" y="-10" size="9" rotate="true" text="_" />
|
||||
<arc width="4" x="-10" y="-5" antialias="true" height="10" style="line-style:normal;line-weight:normal;filling:none;color:black" start="-100" angle="-160" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="24" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-24" y2="0" x2="-10" />
|
||||
<terminal x="-24" y="0" orientation="w" />
|
||||
</description>
|
||||
</definition>
|
||||
@@ -1,16 +0,0 @@
|
||||
<definition width="50" version="0.1" hotspot_x="25" hotspot_y="30" height="40" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Output (set)</name>
|
||||
<name lang="fr" >Sortie (set)</name>
|
||||
<name lang="es" >Salida (set)</name>
|
||||
</names>
|
||||
<description>
|
||||
<arc width="4" x="6" y="-5" antialias="true" height="10" style="line-style:normal;line-weight:normal;filling:none;color:black" start="80" angle="-160" />
|
||||
<input x="-18" y="-10" size="9" rotate="true" text="_" />
|
||||
<arc width="4" x="-10" y="-5" antialias="true" height="10" style="line-style:normal;line-weight:normal;filling:none;color:black" start="-100" angle="-160" />
|
||||
<text x="-4.25" y="5.25" size="9" text="S" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="24" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-24" y2="0" x2="-10" />
|
||||
<terminal x="-24" y="0" orientation="w" />
|
||||
</description>
|
||||
</definition>
|
||||
@@ -1,7 +0,0 @@
|
||||
<qet-directory>
|
||||
<names>
|
||||
<name lang="fr">Ladder</name>
|
||||
<name lang="en">Ladder</name>
|
||||
<name lang="es">Ladder</name>
|
||||
</names>
|
||||
</qet-directory>
|
||||
@@ -1,7 +0,0 @@
|
||||
<qet-directory>
|
||||
<names>
|
||||
<name lang="fr">Automatisme</name>
|
||||
<name lang="en">Automatism</name>
|
||||
<name lang="es">Automática</name>
|
||||
</names>
|
||||
</qet-directory>
|
||||
@@ -1,16 +0,0 @@
|
||||
<definition width="50" version="0.2" hotspot_x="25" hotspot_y="15" height="30" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Horizontal ammeter</name>
|
||||
<name lang="fr" >Ampèremètre horizontal</name>
|
||||
<name lang="es" >Amperímetro horizontal</name>
|
||||
</names>
|
||||
<description>
|
||||
<line length1="1.5" length2="1.5" antialias="false" end1="none" end2="none" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-1.75" y2="0" x2="1.75" />
|
||||
<line length1="1.5" length2="1.5" antialias="false" end1="none" end2="none" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="21" />
|
||||
<line length1="1.5" length2="1.5" antialias="false" end1="none" end2="none" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-21" y2="0" x2="-10" />
|
||||
<polygon antialias="true" style="line-style:normal;line-weight:normal;filling:none;color:black" closed="false" y1="6" x1="-5" y2="-6" x2="0" y3="6" x3="5" />
|
||||
<circle x="-10" y="-10" antialias="true" style="line-style:normal;line-weight:normal;filling:none;color:black" diameter="20" />
|
||||
<terminal x="-21" y="0" orientation="w" />
|
||||
<terminal x="21" y="0" orientation="e" />
|
||||
</description>
|
||||
</definition>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user