mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d5a4fdf4f |
56
CREDIT
56
CREDIT
@@ -1,55 +1,23 @@
|
|||||||
[en]
|
[en]
|
||||||
Thanks to Qt Software for their Qt library ( http://www.qtsoftware.com/ ), licensed under GNU/GPL.
|
Thanks to Trolltech for their Qt library ( http://trolltech.com/ ), licensed
|
||||||
Thanks to Everaldo Coelho for the Crystal SVG icons theme ( http://www.everaldo.com/crystal/ ) licensed under LGPL.
|
under GNU/GPL.
|
||||||
Thanks to Nuno Pinheiro for the Oxygen icons theme ( http://www.oxygen-icons.org/ ) licensed under LGPL but also for the QElectroTech-dedicated icons.
|
Thanks to Everaldo Coelho for the Crystal SVG icons theme (
|
||||||
Thanks to the KDE project ( http://www.kde.org/ ).
|
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 Loic for his mathematics-related explanations.
|
||||||
Thanks to Nicolas for the Mac OS X experimentations.
|
Thanks to Nicolas for the Mac OS X experimentations.
|
||||||
Thanks to Remi Collet for the Fedora packaging.
|
Thanks to Remi Collet for the Fedora packaging.
|
||||||
Thanks to Laurent Trinques for the Debian packaging.
|
Thanks to TuxFamily ( http://tuxfamily.org ) for hosting the project.
|
||||||
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 `Nishiki' for his elements and his support.
|
||||||
Thanks to qtcentre.org for their SingleApplication class.
|
|
||||||
|
|
||||||
[fr]
|
[fr]
|
||||||
Merci à Qt Software pour la bibliothèque Qt ( http://www.qtsoftware.com/ ), sous licence GNU/GPL.
|
Merci à Trolltech pour la bibliothèque Qt ( http://trolltech.com/ ), sous
|
||||||
Merci à Everaldo Coelho pour le thème d'icônes Crystal SVG ( http://www.everaldo.com/crystal/ ) sous licence LGPL.
|
licence GNU/GPL.
|
||||||
Merci à Nuno Pinheiro pour le thème d'icônes Oxygen ( http://www.oxygen-icons.org/ ) sous licence LGPL mais aussi pour les icônes dédiées à QElectroTech
|
Merci à Everaldo Coelho pour le thème d'icônes Crystal SVG (
|
||||||
Merci au projet KDE ( http://www.kde.org/ ).
|
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 à Loic pour ses explications d'ordre mathématique.
|
||||||
Merci à Nicolas pour les expérimentations Mac OS X.
|
Merci à Nicolas pour les expérimentations Mac OS X.
|
||||||
Merci à Remi Collet pour les paquets Fedora.
|
Merci à Remi Collet pour les paquets Fedora.
|
||||||
Merci à Laurent Trinques pour les paquets Debian.
|
Merci à TuxFamily ( http://tuxfamily.org ) pour l'hébergement du projet.
|
||||||
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 à `Nishiki' pour ses éléments et son soutien.
|
||||||
Merci à qtcentre.org pour leur classe SingleApplication.
|
|
||||||
|
|
||||||
[ru]
|
|
||||||
Спасибо Qt Software за их библиотеку Qt ( http://www.qtsoftware.com/ ), лицензированную на условиях GNU/GPL.
|
|
||||||
Спасибо Everaldo Coelho за тему значков Crystal SVG ( http://www.everaldo.com/crystal/ ) лицензированную на условиях LGPL.
|
|
||||||
Спасибо Nuno Pinheiro за тему значков Oxygen ( http://www.oxygen-icons.org/ ) лицензированную на условиях LGPL, а также за значки связанные с QElectroTech.
|
|
||||||
Спасибо проекту KDE ( http://www.kde.org/ ).
|
|
||||||
Спасибо Loic за объяснения связанные с математикой.
|
|
||||||
Спасибо Nicolas за эксперименты с Mac OS X.
|
|
||||||
Спасибо Remi Collet за пакет для Fedora.
|
|
||||||
Спасибо Laurent Trinques за пакет для Debian.
|
|
||||||
Спасибо `trem' за пакет для Mandriva.
|
|
||||||
Спасибо TuxFamily ( http://tuxfamily.org/ ) за хостинг для проекта.
|
|
||||||
Спасибо `Nishiki' за элементы и поддержку.
|
|
||||||
Спасибо qtcentre.org за их класс SingleApplication.
|
|
||||||
|
|
||||||
[pt]
|
|
||||||
Agradecimentos à QT Software pela sua biblioteca Qt ( http://www.qtsoftware.com/ ), licenciada de acordo com a GNU/GPL.
|
|
||||||
Agradecimentos a Everaldo Coelho pelo tema de ícones Crystal SVG ( http://www.everaldo.com/crystal/ ), licenciado de acordo com a LGPL.
|
|
||||||
Agradecimentos a Nuno Pinheiro pelo tema de ícones Oxygen e em especial pelos ícones dedicados ao programa QElectroTech ( http://www.oxygen-icons.org/ ), lincenciado de acordo com a LGPL.
|
|
||||||
Agradecimentos ao projecto KDE ( http://www.kde.org/ ).
|
|
||||||
Agradecimentos a Loic pelas suas explicações relacionadas com problemas matemáticos.
|
|
||||||
Agradecimentos a Nicolas pelo trabalho desenvolvido com Mac OS X.
|
|
||||||
Agradecimentos a Remi Collet pela criação dos pacotes para Fedora.
|
|
||||||
Agradecimentos a Laurent Trinques pela criação dos pacotes para Debian.
|
|
||||||
Agradecimentos a "trem" pela criação dos pacotes para Mandriva.
|
|
||||||
Agradecimentos a TuxFamily ( http://tuxfamily.org/ ) por albergarem este projecto.
|
|
||||||
Agradecimentos a "Nishiki" pela criação de elementos e o seu suporte.
|
|
||||||
Agradecimentos a qtcentre.org pela classe SingleApplication.
|
|
||||||
|
|||||||
86
ChangeLog
86
ChangeLog
@@ -1,86 +0,0 @@
|
|||||||
====== Changelog 0.11 -> 0.2 ======
|
|
||||||
À partir de la version 0.2, QElectroTech est disponible en français, anglais, mais aussi :
|
|
||||||
* en espagnol, grâce aux traductions de Youssef ;
|
|
||||||
* en russe, grâce aux traductions de Yuriy ;
|
|
||||||
* en portugais, grâce aux traductions de José.
|
|
||||||
L'application utilise désormais le thème d'icônes Oxygen, réalisé par Nuno Pinheiro pour le projet KDE.
|
|
||||||
|
|
||||||
===== Notion de fichier projet =====
|
|
||||||
Un fichier .qet peut désormais contenir zéro, un ou plusieurs schémas électriques. Les éléments composant ces schémas sont embarqués dans le fichier projet au moment où ils sont posés sur un schéma. Le panel d'éléments affiche donc désormais :
|
|
||||||
* les projets ouverts, avec, sous chaque projet :
|
|
||||||
* les schémas de ce projet,
|
|
||||||
* la collection embarquée du projet (catégories et éléments utilisés dans les schémas)
|
|
||||||
* la collection commune fournie par QET,
|
|
||||||
* et la collection personnelle de l'utilisateur.
|
|
||||||
|
|
||||||
===== Éditeur de schémas =====
|
|
||||||
* Il est désormais possible de déplacer et copier les catégories et éléments par simple glisser-déposer (drag'n drop) dans le panel d'éléments.
|
|
||||||
* La collection embarquée est manipulable au même titre que la collection utilisateur. Les éléments inutilisés dans le projet apparaissent sur fond rouge et un dialogue permet de les purger rapidement.
|
|
||||||
* Chaque projet embarque également (au niveau de ses propriétés) les paramétrages par défaut pour les nouveaux schémas, cartouches et conducteurs.
|
|
||||||
* Il est possible de changer l'ordre des schémas dans le projet en déplaçant les onglets qui les représente. Dans le champ "Folio" des cartouches, on peut se référer à la position du schéma courant ou au nombre total de schémas dans le projet en écrivant respectivement %id et %total.
|
|
||||||
* Lors du chargement d'un fichier .qet, si des éléments ne sont pas trouvés, ils sont remplacés par un élément "fantôme", ce qui évite de perdre certaines informations lors de l'enregistrement du fichier.
|
|
||||||
* Le rendu avec un zoom réduit a été amélioré.
|
|
||||||
* Enfin, le logiciel gère l'ouverture en lecture seule d'un fichier projet.
|
|
||||||
|
|
||||||
==== Impression et export ====
|
|
||||||
|
|
||||||
À partir de la version 0.2, QElectroTech :
|
|
||||||
* propose d'utiliser une imprimante réelle ou bien de générer un document PDF ou PostScript, et ce sous Windows comme sous X11.
|
|
||||||
* génère un aperçu avant l'impression d'un projet. Cet aperçu permet de choisir les options d'impression mais également les schémas à imprimer ou non.
|
|
||||||
|
|
||||||
À noter toutefois une limitation pour les impressions PDF/PS sous Windows : le dialogue de mise en page, permettant de spécifier le format du papier ainsi que ses marges, n'est pas disponible.
|
|
||||||
|
|
||||||
Le dialogue "Exporter" (pour générer un fichier image d'un schéma) a également été refait dans l'optique d'un export simultané de tous les schémas du projet.
|
|
||||||
|
|
||||||
===== Éditeur d'éléments =====
|
|
||||||
|
|
||||||
* Lorsque l'on dessine une ligne dans l'éditeur d'éléments, il est possible de choisir un embout différent pour chaque extrémité, comme par exemple une flèche, un cercle, un carré ou, tout simplement, un bout de ligne normal.
|
|
||||||
* La forme "Rectangle" a été ajoutée.
|
|
||||||
* On peut enregistrer un élément en désignant un fichier (= comportement en 0.11) ou bien en choisissant un élément cible dans une liste reprenant l'arborescence du panel d'éléments.
|
|
||||||
* Si l'on maintient la touche Shift lorsque l'on ajoute une partie (droite, cercle, texte, ...), l'outil en cours est conservé après le dessin. Sinon l'éditeur repasse sur l'outil de sélection.
|
|
||||||
* La grille a été améliorée : sa densité varie en fonction du zoom ; les points correspondant à ceux de la grille de l'éditeur de schémas sont mis en valeur.
|
|
||||||
* L'accrochage à la grille (aka "snap to grid", également connu sous le nom de grille magnétique ou encore grille aimantée) a été ajouté. Le dessin s'y accroche désormais avec une précision de 1px. On peut travailler en coordonnées libres en maintenant la touche Ctrl enfoncée durant le dessin.
|
|
||||||
* Le copier-coller a été implémenté : il est possible de coller :
|
|
||||||
* avec le bouton du milieu de la souris
|
|
||||||
* en choisissant une "zone de collage" sur l'élément (Ctrl+Shift+V)
|
|
||||||
* directement (Ctrl+V) : les parties collées sont placées à côté des parties copiées ; si on recolle les parties, elles sont collées encore un cran à côté, et ce de manière incrémentale.
|
|
||||||
* Des contrôles sont désormais effectués à l'enregistrement : présence de bornes, respect du cadre, etc.
|
|
||||||
* Uniformisation des menus par rapport à l'éditeur de schémas
|
|
||||||
|
|
||||||
====== Changelog 0.1 -> 0.11 ======
|
|
||||||
|
|
||||||
===== Fonctionnalités et interface =====
|
|
||||||
|
|
||||||
* L'application est désormais capable d'ouvrir un fichier élément passe en paramètre
|
|
||||||
* L'application se lance désormais une seule fois par utilisateur
|
|
||||||
* Lors de l'ouverture d'un fichier en dehors de l'application alors que QET est déjà démarré celui-ci essaye de s'afficher ou d'attirer l'attention de l'utilisateur.
|
|
||||||
* L'application vérifie que ce fichier n'est pas déjà ouvert dans tous les éditeurs de schémas / éléments.
|
|
||||||
* Ajout de fichiers permettant d'automatiser les associations de fichiers sous Windows (.bat et .reg) et X11 (.desktop et .xml)
|
|
||||||
* Ajout de menus "Récemment ouverts" pour accéder aux fichiers récents dans les éditeurs de schémas et éléments.
|
|
||||||
* Ajout d'un splash screen
|
|
||||||
* La hauteur du schéma est désormais gérée via un système de lignes, dont le nombre et la hauteur sont ajustables.
|
|
||||||
* Il est également possible d'afficher ou non les en-têtes des lignes et/ou des colonnes.
|
|
||||||
* Ajout d'une option --lang-dir
|
|
||||||
* Ajout d'une description dans le dialogue des options d'impression
|
|
||||||
* Ajout de pages de manuel Unix (`man') en anglais et en français
|
|
||||||
|
|
||||||
===== Corrections de bugs =====
|
|
||||||
|
|
||||||
* Bug #12 : QET provoquait une erreur de segmentation dès son démarrage dans un environnement sans systray
|
|
||||||
* Bug #14 : il manquait un / dans le chemin proposé lors de l'impression vers un PDF
|
|
||||||
* Bug #15 : Mauvais positionnement des champs de texte sur le schéma
|
|
||||||
* Bug #16 : Mauvaise gestion des modifications du texte d'un conducteur
|
|
||||||
* La classe DiagramView écrivait sur la sortie d'erreur sans fin de ligne
|
|
||||||
* L'option --config-dir était mal prise en compte
|
|
||||||
* Après fermeture d'un schema, le menu Fenêtres n'était pas correctement mis à jour
|
|
||||||
* Les textes des éléments, des conducteurs, du cartouche ainsi que les textes indépendants utilisent désormais tous la même police.
|
|
||||||
* Remise à niveau de l'impression suite au passage à Qt 4.4
|
|
||||||
|
|
||||||
===== Code et détails techniques =====
|
|
||||||
|
|
||||||
* Corrections pour que QET compile avec gcc-4.3
|
|
||||||
* Les classes Conductor et Element héritent désormais de QObject (dépendance sur Qt 4.4)
|
|
||||||
* Affinage du constructeur de la classe QETApp
|
|
||||||
* Moins d'avertissements à la compilation (testé avec gcc 4.3)
|
|
||||||
* Moins d'inclusions non pertinentes
|
|
||||||
* Nettoyage du trunk : déplacement des sources dans un sous-répertoire
|
|
||||||
@@ -1,64 +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é 3.0
|
|
||||||
disponible en ligne http://creativecommons.org/licenses/by/3.0/ 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 3.0 License.
|
|
||||||
To view a copy of this license, visit
|
|
||||||
http://creativecommons.org/licenses/by/3.0/ 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 3.0 de Creative Commons.
|
|
||||||
Para ver una copia de esta licencia, visite
|
|
||||||
http://creativecommons.org/licenses/by/3.0/ o envie una carta a Creative
|
|
||||||
Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA.
|
|
||||||
|
|
||||||
[ru]
|
|
||||||
Коллекция элементов, поставляемая вместе с QElectroTech, поставляется "как есть" и
|
|
||||||
без каких-либо гарантий пригодности для той или иной цели или работы.
|
|
||||||
Использование, изменение и интеграция элементов в электрическую
|
|
||||||
схему разрешается без каких-либо условий, безотносительно конечной лицензии на
|
|
||||||
схему.
|
|
||||||
Если Вы распространяете всю или часть коллекции QElectroTech, с или без изменений,
|
|
||||||
отдельно от электрической схемы, Вы должны соблюдать условия лицензии CC-BY:
|
|
||||||
Эта работа лицензирована на условиях Creative Commons Attribution 3.0 License.
|
|
||||||
Чтобы увидеть копию этой лицензии, посетите
|
|
||||||
http://creativecommons.org/licenses/by/3.0/ или отправте письмо в Creative
|
|
||||||
Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
|
|
||||||
(данный перевод, на русский язык, является вольным и выполнен не юристом!)
|
|
||||||
|
|
||||||
[pt]
|
|
||||||
A colecção de elementos fornecida com o programa QElectroTech é fornecida como é e sem nenhuma garantia da aptidão para o seu uso e sem garantia de que funciona.
|
|
||||||
É permitido, sem condição alguma, qualquer que seja a licença final, usar, editar e incluir estes elementos em esquemas eléctricos.
|
|
||||||
Se você redistribuir uma parte ou toda a colecção de elementos do programa QElectroTech, tendo editado ou não os elementos, sem ser num esquema eléctrico, tem de respeitar as condições da licença CC-BY:
|
|
||||||
Este trabalho está licenciado de acordo com os termos da licença Creative Commons Attribution 3.0 License.
|
|
||||||
Para ver uma cópia da licença visite http://creativecommons.org/licenses/by/3.0/ ou envie uma carta para o endereço Creative
|
|
||||||
Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
|
|
||||||
|
|
||||||
24
INSTALL
24
INSTALL
@@ -6,7 +6,6 @@ cupsys-bsd for printing
|
|||||||
Howto compile :
|
Howto compile :
|
||||||
$ qmake (qmake-qt4 for Debian-based systems)
|
$ qmake (qmake-qt4 for Debian-based systems)
|
||||||
$ make
|
$ make
|
||||||
# umask 0022
|
|
||||||
# make install
|
# make install
|
||||||
|
|
||||||
[fr]
|
[fr]
|
||||||
@@ -17,27 +16,4 @@ cupsys-bsd pour l'impression
|
|||||||
Comment compiler :
|
Comment compiler :
|
||||||
$ qmake (qmake-qt4 pour les systèmes basés sur Debian)
|
$ qmake (qmake-qt4 pour les systèmes basés sur Debian)
|
||||||
$ make
|
$ make
|
||||||
# umask 0022
|
|
||||||
# make install
|
|
||||||
|
|
||||||
[ru]
|
|
||||||
Зависимости:
|
|
||||||
libQt4 (пакет libqt4*)
|
|
||||||
cupsys-bsd для печати
|
|
||||||
|
|
||||||
Как компилировать?:
|
|
||||||
$ qmake (qmake-qt4 для систем основанных на Debian)
|
|
||||||
$ make
|
|
||||||
# umask 0022
|
|
||||||
# make install
|
|
||||||
|
|
||||||
[pt]
|
|
||||||
Dependências:
|
|
||||||
libqt4 (ver pacotes libqt4*)
|
|
||||||
cupsys-bsd para impressão
|
|
||||||
|
|
||||||
Como compilar:
|
|
||||||
$ qmake (qmake-qt4 para sistemas baseados em Debian)
|
|
||||||
$ make
|
|
||||||
# umask 0022
|
|
||||||
# make install
|
# make install
|
||||||
|
|||||||
16
README
16
README
@@ -1,15 +1,9 @@
|
|||||||
[en]
|
[en]
|
||||||
QElectroTech is a Qt4 application to design electric diagrams.
|
QElectroTech is a Qt4 application to design electric diagrams. It uses XML
|
||||||
It uses XML files for elements and diagrams, and includes both a diagram editor and an element editor.
|
files for elements and diagrams, and includes both a diagram editor and an
|
||||||
|
element editor.
|
||||||
|
|
||||||
[fr]
|
[fr]
|
||||||
QElectroTech est une application Qt4 pour réaliser des schémas électriques.
|
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.
|
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.
|
||||||
[ru]
|
|
||||||
QElectroTech - приложение написанное на Qt4 и предназначенное для разработки электрических схем.
|
|
||||||
Оно использует XML-файлы для элементов и схем, и включает, как редактор схем, так и редактор элементов.
|
|
||||||
|
|
||||||
[pt]
|
|
||||||
QElectroTech é uma aplicação baseada em Qt4 para desenhar esquemas eléctricos.
|
|
||||||
QET utiliza ficheiros XML para os elementos e para os esquemas e inclui um editor de esquemas e um editor de elementos.
|
|
||||||
|
|||||||
138
aboutqet.cpp
Normal file
138
aboutqet.cpp
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2008 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 <20> A propos <20>
|
||||||
|
*/
|
||||||
|
QWidget *AboutQET::ongletAPropos() const {
|
||||||
|
QLabel *apropos = new QLabel(
|
||||||
|
tr("QElectroTech, une application de r\351alisation de sch\351mas \351lectriques.") +
|
||||||
|
"<br><br>" +
|
||||||
|
tr("\251 2006-2008 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 <20> Auteurs <20>
|
||||||
|
*/
|
||||||
|
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 <20> Accord de Licence <20>
|
||||||
|
*/
|
||||||
|
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-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -17,11 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef ABOUTQET_H
|
#ifndef ABOUTQET_H
|
||||||
#define ABOUTQET_H
|
#define ABOUTQET_H
|
||||||
#include <QDialog>
|
#include <QtGui>
|
||||||
class QLabel;
|
|
||||||
/**
|
/**
|
||||||
Cette classe represente la boite de dialogue
|
Cette classe represente la boite de dialogue
|
||||||
"A propos de QElectroTech".
|
« A propos de QElectroTech »
|
||||||
*/
|
*/
|
||||||
class AboutQET : public QDialog {
|
class AboutQET : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -36,12 +35,9 @@ class AboutQET : public QDialog {
|
|||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
private:
|
private:
|
||||||
QWidget *title() const;
|
QWidget *titre() const;
|
||||||
QWidget *aboutTab() const;
|
QWidget *ongletAPropos() const;
|
||||||
QWidget *authorsTab() const;
|
QWidget *ongletAuteurs() const;
|
||||||
QWidget *translatorsTab() const;
|
QWidget *ongletLicence() const;
|
||||||
QWidget *contributorsTab() const;
|
|
||||||
QWidget *licenseTab() const;
|
|
||||||
void addAuthor(QLabel *, const QString &, const QString &, const QString &) const;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
231
borderinset.cpp
Normal file
231
borderinset.cpp
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2008 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-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -18,12 +18,10 @@
|
|||||||
#ifndef BORDERINSET_H
|
#ifndef BORDERINSET_H
|
||||||
#define BORDERINSET_H
|
#define BORDERINSET_H
|
||||||
#include "insetproperties.h"
|
#include "insetproperties.h"
|
||||||
#include "borderproperties.h"
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
|
#include <QPainter>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
class QPainter;
|
|
||||||
class DiagramPosition;
|
|
||||||
/**
|
/**
|
||||||
Cette classe represente l'ensemble bordure + cartouche qui encadre le
|
Cette classe represente l'ensemble bordure + cartouche qui encadre le
|
||||||
schema electrique.
|
schema electrique.
|
||||||
@@ -41,51 +39,29 @@ class BorderInset : public QObject {
|
|||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
static int minNbColumns();
|
|
||||||
static qreal minColumnsWidth();
|
|
||||||
static int minNbRows();
|
|
||||||
static qreal minRowsHeight();
|
|
||||||
|
|
||||||
void draw(QPainter *, qreal = 0.0, qreal = 0.0);
|
void draw(QPainter *, qreal = 0.0, qreal = 0.0);
|
||||||
|
|
||||||
// methodes d'acces en lecture aux dimensions
|
// methodes d'acces en lecture aux dimensions
|
||||||
// colonnes
|
|
||||||
/// @return le nombre de colonnes du schema
|
/// @return le nombre de colonnes du schema
|
||||||
int nbColumns() const { return(nb_columns); }
|
int nbColumn() const { return(nb_columns); }
|
||||||
/// @return la largeur des colonnes en pixels
|
/// @return la taille des colonnes en pixels
|
||||||
qreal columnsWidth() const { return(columns_width); }
|
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); }
|
|
||||||
/// @return la hauteur, en pixels, des en-tetes des colonnes
|
/// @return la hauteur, en pixels, des en-tetes des colonnes
|
||||||
qreal columnsHeaderHeight() const { return(columns_header_height); }
|
qreal columnsHeaderHeight() const { return(columns_header_height); }
|
||||||
|
/// @return la hauteur des colonnes, en-tetes inclus
|
||||||
// lignes
|
qreal columnsHeight() const { return(columns_height); }
|
||||||
/// @return le nombre de lignes du schema
|
/// @return la largeur de la bordure
|
||||||
int nbRows() const { return(nb_rows); }
|
qreal borderWidth() const { return(nb_columns * columns_width); }
|
||||||
/// @return la hauteur des lignes en pixels
|
/// @return la hauteur de la bordure
|
||||||
qreal rowsHeight() const { return(rows_height); }
|
qreal borderHeight() const { return(columns_height + inset_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
|
|
||||||
/// @return la largeur du cartouche
|
/// @return la largeur du cartouche
|
||||||
qreal insetWidth() const { return(inset_width); }
|
qreal insetWidth() const { return(inset_width); }
|
||||||
/// @return la hauteur du cartouche
|
/// @return la hauteur du cartouche
|
||||||
qreal insetHeight() const { return(inset_height); }
|
qreal insetHeight() const { return(inset_height); }
|
||||||
|
/// @return la hauteur minimale acceptee des colonnes
|
||||||
// cadre avec le cartouche
|
qreal minColumnsHeight() const { return(min_columns_height); }
|
||||||
/// @return la hauteur de la bordure
|
/// @return le nombre minimum accepte de colonnes
|
||||||
qreal borderWidth() const { return(diagramWidth()); }
|
int minNbColumns() const { return(min_nb_columns); }
|
||||||
/// @return la hauteur de la bordure
|
|
||||||
qreal borderHeight() const { return(diagramHeight() + insetHeight()); }
|
|
||||||
|
|
||||||
// methodes d'acces en lecture aux informations du cartouche
|
// methodes d'acces en lecture aux informations du cartouche
|
||||||
/// @return le champ "Auteur" du cartouche
|
/// @return le champ "Auteur" du cartouche
|
||||||
@@ -104,61 +80,62 @@ class BorderInset : public QObject {
|
|||||||
bool insetIsDisplayed() const { return(display_inset); }
|
bool insetIsDisplayed() const { return(display_inset); }
|
||||||
/// @return true si les entetes des colonnes sont affiches, false sinon
|
/// @return true si les entetes des colonnes sont affiches, false sinon
|
||||||
bool columnsAreDisplayed() const { return(display_columns); }
|
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
|
/// @return true si la bordure est affichee, false sinon
|
||||||
bool borderIsDisplayed() const { return(display_border); }
|
bool borderIsDisplayed() const { return(display_border); }
|
||||||
|
|
||||||
// methodes d'acces en ecriture aux dimensions
|
// methodes d'acces en ecriture aux dimensions
|
||||||
void addColumn ();
|
void addColumn ();
|
||||||
void addRow ();
|
|
||||||
void removeColumn ();
|
void removeColumn ();
|
||||||
void removeRow ();
|
|
||||||
void setNbColumns (int);
|
void setNbColumns (int);
|
||||||
void setNbRows (int);
|
|
||||||
void setColumnsWidth (const qreal &);
|
void setColumnsWidth (const qreal &);
|
||||||
void setRowsHeight (const qreal &);
|
|
||||||
void setColumnsHeaderHeight(const qreal &);
|
void setColumnsHeaderHeight(const qreal &);
|
||||||
void setRowsHeaderWidth (const qreal &);
|
void setColumnsHeight (const qreal &);
|
||||||
void setDiagramHeight (const qreal &);
|
|
||||||
void setInsetWidth (const qreal &);
|
void setInsetWidth (const qreal &);
|
||||||
void setInsetHeight (const qreal &);
|
void setInsetHeight (const qreal &);
|
||||||
void adjustInsetToColumns ();
|
void adjustInsetToColumns ();
|
||||||
|
|
||||||
DiagramPosition convertPosition(const QPointF &);
|
|
||||||
|
|
||||||
// methodes d'acces en ecriture aux informations du cartouche
|
// methodes d'acces en ecriture aux informations du cartouche
|
||||||
/// @param author le nouveau contenu du champ "Auteur"
|
/// @param author le nouveau contenu du champ "Auteur"
|
||||||
void setAuthor (const QString &author) { bi_author = author; }
|
void setAuthor (const QString &author) { bi_author = author; }
|
||||||
/// @param date le nouveau contenu du champ "Date"
|
/// @param date le nouveau contenu du champ "Date"
|
||||||
void setDate (const QDate &date) { bi_date = date; }
|
void setDate (const QDate &date) { bi_date = date; }
|
||||||
/// @param title le nouveau contenu du champ "Titre"
|
/// @param title le nouveau contenu du champ "Titre"
|
||||||
void setTitle (const QString &title) {
|
void setTitle (const QString &title) { bi_title = title; }
|
||||||
if (bi_title != title) {
|
|
||||||
bi_title = title;
|
|
||||||
emit(diagramTitleChanged(title));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// @param folio le nouveau contenu du champ "Folio"
|
/// @param folio le nouveau contenu du champ "Folio"
|
||||||
void setFolio (const QString &folio) { bi_folio = folio; }
|
void setFolio (const QString &folio) { bi_folio = folio; }
|
||||||
void setFolioData(int, int);
|
|
||||||
/// @param filename le nouveau contenu du champ "Fichier"
|
/// @param filename le nouveau contenu du champ "Fichier"
|
||||||
void setFileName (const QString &filename) { bi_filename = filename; }
|
void setFileName (const QString &filename) { bi_filename = filename; }
|
||||||
|
|
||||||
InsetProperties exportInset();
|
/// @return les proprietes du cartouches
|
||||||
void importInset(const InsetProperties &);
|
InsetProperties exportInset() {
|
||||||
BorderProperties exportBorder();
|
InsetProperties ip;
|
||||||
void importBorder(const BorderProperties &);
|
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
|
// methodes d'acces en ecriture aux options
|
||||||
void displayInset(bool);
|
/// @param di true pour afficher le cartouche, false sinon
|
||||||
void displayColumns(bool);
|
void displayInset (bool di) { display_inset = di; }
|
||||||
void displayRows(bool);
|
/// @param dc true pour afficher les entetes des colonnes, false sinon
|
||||||
void displayBorder(bool);
|
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:
|
private:
|
||||||
void updateRectangles();
|
void updateRectangles();
|
||||||
QString incrementLetters(const QString &);
|
|
||||||
|
|
||||||
// signaux
|
// signaux
|
||||||
signals:
|
signals:
|
||||||
@@ -168,21 +145,6 @@ class BorderInset : public QObject {
|
|||||||
@param new_border Nouvelle bordure
|
@param new_border Nouvelle bordure
|
||||||
*/
|
*/
|
||||||
void borderChanged(QRectF old_border, QRectF new_border);
|
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
|
// attributs
|
||||||
private:
|
private:
|
||||||
@@ -191,28 +153,20 @@ class BorderInset : public QObject {
|
|||||||
QDate bi_date;
|
QDate bi_date;
|
||||||
QString bi_title;
|
QString bi_title;
|
||||||
QString bi_folio;
|
QString bi_folio;
|
||||||
QString bi_final_folio;
|
|
||||||
int folio_index_;
|
|
||||||
int folio_total_;
|
|
||||||
QString bi_filename;
|
QString bi_filename;
|
||||||
|
|
||||||
// dimensions du cadre (lignes et colonnes)
|
// dimensions du cadre et du cartouche
|
||||||
// colonnes : nombres et dimensions
|
|
||||||
int nb_columns;
|
int nb_columns;
|
||||||
|
int min_nb_columns;
|
||||||
qreal columns_width;
|
qreal columns_width;
|
||||||
qreal columns_header_height;
|
qreal columns_header_height;
|
||||||
|
qreal columns_height;
|
||||||
// lignes : nombres et dimensions
|
qreal min_columns_height;
|
||||||
int nb_rows;
|
|
||||||
qreal rows_height;
|
|
||||||
qreal rows_header_width;
|
|
||||||
|
|
||||||
// dimensions du cartouche
|
|
||||||
qreal inset_width;
|
qreal inset_width;
|
||||||
qreal inset_height;
|
qreal inset_height;
|
||||||
|
|
||||||
// rectangles utilises pour le dessin
|
// rectangles utilises pour le dessin
|
||||||
QRectF diagram;
|
QRectF border;
|
||||||
QRectF inset;
|
QRectF inset;
|
||||||
QRectF inset_author;
|
QRectF inset_author;
|
||||||
QRectF inset_date;
|
QRectF inset_date;
|
||||||
@@ -223,7 +177,6 @@ class BorderInset : public QObject {
|
|||||||
// booleens pour les options de dessin
|
// booleens pour les options de dessin
|
||||||
bool display_inset;
|
bool display_inset;
|
||||||
bool display_columns;
|
bool display_columns;
|
||||||
bool display_rows;
|
|
||||||
bool display_border;
|
bool display_border;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
#include "conductor.h"
|
#include "conductor.h"
|
||||||
#include "conductorsegment.h"
|
#include "conductorsegment.h"
|
||||||
#include "conductorsegmentprofile.h"
|
#include "conductorsegmentprofile.h"
|
||||||
#include "diagramtextitem.h"
|
|
||||||
#include "element.h"
|
#include "element.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "diagramcommands.h"
|
#include "diagramcommands.h"
|
||||||
@@ -37,7 +36,6 @@ QBrush Conductor::square_brush = QBrush(Qt::darkGreen);
|
|||||||
@param scene QGraphicsScene a laquelle appartient le conducteur
|
@param scene QGraphicsScene a laquelle appartient le conducteur
|
||||||
*/
|
*/
|
||||||
Conductor::Conductor(Terminal *p1, Terminal* p2, Element *parent, QGraphicsScene *scene) :
|
Conductor::Conductor(Terminal *p1, Terminal* p2, Element *parent, QGraphicsScene *scene) :
|
||||||
QObject(),
|
|
||||||
QGraphicsPathItem(parent, scene),
|
QGraphicsPathItem(parent, scene),
|
||||||
terminal1(p1),
|
terminal1(p1),
|
||||||
terminal2(p2),
|
terminal2(p2),
|
||||||
@@ -87,12 +85,6 @@ Conductor::Conductor(Terminal *p1, Terminal* p2, Element *parent, QGraphicsScene
|
|||||||
text_item -> previous_text = properties_.text;
|
text_item -> previous_text = properties_.text;
|
||||||
calculateTextItemPosition();
|
calculateTextItemPosition();
|
||||||
text_item -> setParentItem(this);
|
text_item -> setParentItem(this);
|
||||||
connect(
|
|
||||||
text_item,
|
|
||||||
SIGNAL(diagramTextChanged(DiagramTextItem *, const QString &, const QString &)),
|
|
||||||
this,
|
|
||||||
SLOT(displayedTextChanged())
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -360,40 +352,40 @@ void Conductor::priv_calculeConductor(const QPointF &p1, QET::Orientation o1, co
|
|||||||
if (depart.y() < arrivee.y()) {
|
if (depart.y() < arrivee.y()) {
|
||||||
// trajet descendant
|
// trajet descendant
|
||||||
if ((ori_depart == QET::North && (ori_arrivee == QET::South || ori_arrivee == QET::West)) || (ori_depart == QET::East && ori_arrivee == QET::West)) {
|
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;
|
int ligne_inter_x = qRound(depart.x() + arrivee.x()) / 2;
|
||||||
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
|
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
|
||||||
points << QPointF(ligne_inter_x, depart.y());
|
points << QPointF(ligne_inter_x, depart.y());
|
||||||
points << QPointF(ligne_inter_x, arrivee.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)) {
|
} 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;
|
int ligne_inter_y = qRound(depart.y() + arrivee.y()) / 2;
|
||||||
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
|
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
|
||||||
points << QPointF(depart.x(), ligne_inter_y);
|
points << QPointF(depart.x(), ligne_inter_y);
|
||||||
points << QPointF(arrivee.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)) {
|
} 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 {
|
} else {
|
||||||
points << QPointF(depart.x(), arrivee.y()); // cas "1"
|
points << QPointF(depart.x(), arrivee.y()); // cas « 1 »
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// trajet montant
|
// trajet montant
|
||||||
if ((ori_depart == QET::West && (ori_arrivee == QET::East || ori_arrivee == QET::South)) || (ori_depart == QET::North && ori_arrivee == QET::South)) {
|
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;
|
int ligne_inter_y = qRound(depart.y() + arrivee.y()) / 2;
|
||||||
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
|
while (ligne_inter_y % Diagram::yGrid) -- ligne_inter_y;
|
||||||
points << QPointF(depart.x(), ligne_inter_y);
|
points << QPointF(depart.x(), ligne_inter_y);
|
||||||
points << QPointF(arrivee.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)) {
|
} 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;
|
int ligne_inter_x = qRound(depart.x() + arrivee.x()) / 2;
|
||||||
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
|
while (ligne_inter_x % Diagram::xGrid) -- ligne_inter_x;
|
||||||
points << QPointF(ligne_inter_x, depart.y());
|
points << QPointF(ligne_inter_x, depart.y());
|
||||||
points << QPointF(ligne_inter_x, arrivee.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)) {
|
} 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 {
|
} else {
|
||||||
points << QPointF(arrivee.x(), depart.y()); // cas "1"
|
points << QPointF(arrivee.x(), depart.y()); // cas « 1 »
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,13 +452,6 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
|
|||||||
qp -> setPen(tmp);
|
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
|
// dessin du conducteur
|
||||||
qp -> drawPath(path());
|
qp -> drawPath(path());
|
||||||
if (properties_.type == ConductorProperties::Single) {
|
if (properties_.type == ConductorProperties::Single) {
|
||||||
@@ -479,8 +464,8 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
|
|||||||
if (isSelected()) qp -> setBrush(Qt::NoBrush);
|
if (isSelected()) qp -> setBrush(Qt::NoBrush);
|
||||||
}
|
}
|
||||||
|
|
||||||
// decalage ideal pour le rendu centre d'un carre / cercle de 2.0 px de cote / diametre
|
// decalage ideal pour le rendu centre d'un carre / cercle de 5.0 px de cote / diametre
|
||||||
qreal pretty_offset = (options -> levelOfDetail == 1 ? 1.0 : 1.0);
|
qreal pretty_offset = (options -> levelOfDetail == 1 ? 2.0 : 2.5);
|
||||||
|
|
||||||
// dessin des points d'accroche du conducteur si celui-ci est selectionne
|
// dessin des points d'accroche du conducteur si celui-ci est selectionne
|
||||||
if (isSelected()) {
|
if (isSelected()) {
|
||||||
@@ -495,8 +480,8 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
|
|||||||
QRectF(
|
QRectF(
|
||||||
((previous_point.x() + point.x()) / 2.0 ) - pretty_offset,
|
((previous_point.x() + point.x()) / 2.0 ) - pretty_offset,
|
||||||
((previous_point.y() + point.y()) / 2.0 ) - pretty_offset,
|
((previous_point.y() + point.y()) / 2.0 ) - pretty_offset,
|
||||||
2.0,
|
5.0,
|
||||||
2.0
|
5.0
|
||||||
),
|
),
|
||||||
square_brush
|
square_brush
|
||||||
);
|
);
|
||||||
@@ -513,7 +498,7 @@ void Conductor::paint(QPainter *qp, const QStyleOptionGraphicsItem *options, QWi
|
|||||||
qp -> setBrush(junction_brush);
|
qp -> setBrush(junction_brush);
|
||||||
qp -> setRenderHint(QPainter::Antialiasing, true);
|
qp -> setRenderHint(QPainter::Antialiasing, true);
|
||||||
foreach(QPointF point, junctions_list) {
|
foreach(QPointF point, junctions_list) {
|
||||||
qp -> drawEllipse(QRectF(point.x() - pretty_offset, point.y() - pretty_offset, 2.0, 2.0));
|
qp -> drawEllipse(QRectF(point.x() - pretty_offset, point.y() - pretty_offset, 5.0, 5.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qp -> restore();
|
qp -> restore();
|
||||||
@@ -594,9 +579,6 @@ void Conductor::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QGraphicsPathItem::mousePressEvent(e);
|
QGraphicsPathItem::mousePressEvent(e);
|
||||||
if (e -> modifiers() & Qt::ControlModifier) {
|
|
||||||
setSelected(!isSelected());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -663,9 +645,7 @@ void Conductor::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
has_to_save_profile = false;
|
has_to_save_profile = false;
|
||||||
}
|
}
|
||||||
setZValue(previous_z_value);
|
setZValue(previous_z_value);
|
||||||
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
QGraphicsPathItem::mouseReleaseEvent(e);
|
||||||
QGraphicsPathItem::mouseReleaseEvent(e);
|
|
||||||
}
|
|
||||||
calculateTextItemPosition();
|
calculateTextItemPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -893,15 +873,13 @@ bool Conductor::fromXml(QDomElement &e) {
|
|||||||
QPointF t2 = terminal2 -> amarrageConductor();
|
QPointF t2 = terminal2 -> amarrageConductor();
|
||||||
qreal expected_width = t2.x() - t1.x();
|
qreal expected_width = t2.x() - t1.x();
|
||||||
qreal expected_height = t2.y() - t1.y();
|
qreal expected_height = t2.y() - t1.y();
|
||||||
|
qreal precision = std::numeric_limits<qreal>::epsilon();
|
||||||
// on considere que le trajet est incoherent a partir d'une unite de difference avec l'espacement entre les bornes
|
|
||||||
if (
|
if (
|
||||||
qAbs(expected_width - width) > 1.0 ||
|
expected_width > width + precision ||\
|
||||||
qAbs(expected_height - height) > 1.0
|
expected_width < width - precision ||\
|
||||||
) {
|
expected_height > height + precision ||\
|
||||||
qDebug() << "Conductor::fromXml : les segments du conducteur ne semblent pas coherents - utilisation d'un trajet automatique";
|
expected_height < height - precision
|
||||||
return(false);
|
) return(false);
|
||||||
}
|
|
||||||
|
|
||||||
/* on recree les segments a partir des donnes XML */
|
/* on recree les segments a partir des donnes XML */
|
||||||
// cree la liste de points
|
// cree la liste de points
|
||||||
@@ -944,13 +922,13 @@ QDomElement Conductor::toXml(QDomDocument &d, QHash<Terminal *, int> &table_adr_
|
|||||||
foreach(ConductorSegment *segment, segmentsList()) {
|
foreach(ConductorSegment *segment, segmentsList()) {
|
||||||
current_segment = d.createElement("segment");
|
current_segment = d.createElement("segment");
|
||||||
current_segment.setAttribute("orientation", segment -> isHorizontal() ? "horizontal" : "vertical");
|
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);
|
e.appendChild(current_segment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// exporte la "configuration" du conducteur
|
// exporte la "configuration" du conducteur
|
||||||
properties_.toXml(e);
|
properties_.toXml(d, e);
|
||||||
return(e);
|
return(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1104,25 +1082,6 @@ void Conductor::readProperties() {
|
|||||||
text_item -> setVisible(properties_.type == ConductorProperties::Multi);
|
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
|
@return les conducteurs avec lesquels ce conducteur partage des bornes
|
||||||
communes
|
communes
|
||||||
@@ -1135,33 +1094,6 @@ QSet<Conductor *> Conductor::relatedConductors() const {
|
|||||||
return(other_conductors);
|
return(other_conductors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
@param a reel
|
|
||||||
@param b reel
|
|
||||||
@param c reel
|
|
||||||
@return true si a est entre b et c ou est egal a l'un des deux
|
|
||||||
*/
|
|
||||||
bool isBetween(qreal a, qreal b, qreal c) {
|
|
||||||
if (b <= c) {
|
|
||||||
return(a >= b && a <= c);
|
|
||||||
} else {
|
|
||||||
return(a <= b && a >= c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param a point
|
|
||||||
@param b point
|
|
||||||
@param c point
|
|
||||||
@return true si le point a est contenu dans le rectangle delimite par les points b et c
|
|
||||||
*/
|
|
||||||
bool isContained(const QPointF &a, const QPointF &b, const QPointF &c) {
|
|
||||||
return(
|
|
||||||
isBetween(a.x(), b.x(), c.x()) &&
|
|
||||||
isBetween(a.y(), b.y(), c.y())
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return la liste des positions des jonctions avec d'autres conducteurs
|
@return la liste des positions des jonctions avec d'autres conducteurs
|
||||||
*/
|
*/
|
||||||
@@ -1203,8 +1135,9 @@ QList<QPointF> Conductor::junctions() const {
|
|||||||
// parcoure les segments a la recherche d'un point commun
|
// parcoure les segments a la recherche d'un point commun
|
||||||
for (int j = 0 ; j < c_segments.count() ; ++ j) {
|
for (int j = 0 ; j < c_segments.count() ; ++ j) {
|
||||||
ConductorSegment *segment = c_segments[j];
|
ConductorSegment *segment = c_segments[j];
|
||||||
|
QRectF rect(segment -> firstPoint(), segment -> secondPoint());
|
||||||
// un point commun a ete trouve sur ce segment
|
// un point commun a ete trouve sur ce segment
|
||||||
if (isContained(conductor_point, segment -> firstPoint(), segment -> secondPoint())) {
|
if (rect.contains(conductor_point)) {
|
||||||
is_junction = true;
|
is_junction = true;
|
||||||
// ce point commun ne doit pas etre une bifurcation identique a celle-ci
|
// ce point commun ne doit pas etre une bifurcation identique a celle-ci
|
||||||
QList<ConductorBend> other_conductor_bends = c -> bends();
|
QList<ConductorBend> other_conductor_bends = c -> bends();
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -21,17 +21,15 @@
|
|||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "conductorprofile.h"
|
#include "conductorprofile.h"
|
||||||
#include "conductorproperties.h"
|
#include "conductorproperties.h"
|
||||||
|
#include "diagramtextitem.h"
|
||||||
class ConductorSegment;
|
class ConductorSegment;
|
||||||
class DiagramTextItem;
|
|
||||||
class Element;
|
class Element;
|
||||||
typedef QPair<QPointF, Qt::Corner> ConductorBend;
|
typedef QPair<QPointF, Qt::Corner> ConductorBend;
|
||||||
typedef QHash<Qt::Corner, ConductorProfile> ConductorProfilesGroup;
|
typedef QHash<Qt::Corner, ConductorProfile> ConductorProfilesGroup;
|
||||||
/**
|
/**
|
||||||
Cette classe represente un conducteur. Un conducteur relie deux bornes d'element.
|
Cette classe represente un conducteur. Un conducteur relie deux bornes d'element.
|
||||||
*/
|
*/
|
||||||
class Conductor : public QObject, public QGraphicsPathItem {
|
class Conductor : public QGraphicsPathItem {
|
||||||
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
@@ -83,9 +81,6 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
|||||||
ConductorProfilesGroup profiles() const;
|
ConductorProfilesGroup profiles() const;
|
||||||
void readProperties();
|
void readProperties();
|
||||||
|
|
||||||
public slots:
|
|
||||||
void displayedTextChanged();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
|
||||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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.
|
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
|
@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("ground", hasGround ? "true" : "false");
|
||||||
e.setAttribute("neutral", hasNeutral ? "true" : "false");
|
e.setAttribute("neutral", hasNeutral ? "true" : "false");
|
||||||
e.setAttribute("phase", phases);
|
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
|
de l'element e
|
||||||
@param e Element XML dont les attributs seront lus
|
@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.
|
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
|
@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));
|
e.setAttribute("type", typeToString(type));
|
||||||
if (type == Single) {
|
if (type == Single) {
|
||||||
singleLineProperties.toXml(e);
|
singleLineProperties.toXml(d, e);
|
||||||
} else if (type == Multi) {
|
} else if (type == Multi) {
|
||||||
e.setAttribute("num", text);
|
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
|
de l'element e
|
||||||
@param e Element XML dont les attributs seront lus
|
@param e Element XML dont les attributs seront lus
|
||||||
*/
|
*/
|
||||||
@@ -215,7 +217,7 @@ void ConductorProperties::fromXml(QDomElement &e) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@param settings Parametres a ecrire
|
@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 {
|
void ConductorProperties::toSettings(QSettings &settings, const QString &prefix) const {
|
||||||
settings.setValue(prefix + "type", typeToString(type));
|
settings.setValue(prefix + "type", typeToString(type));
|
||||||
@@ -225,7 +227,7 @@ void ConductorProperties::toSettings(QSettings &settings, const QString &prefix)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@param settings Parametres a lire
|
@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) {
|
void ConductorProperties::fromSettings(QSettings &settings, const QString &prefix) {
|
||||||
QString setting_type = settings.value(prefix + "type", typeToString(Multi)).toString();
|
QString setting_type = settings.value(prefix + "type", typeToString(Multi)).toString();
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -31,7 +31,7 @@ class SingleLineProperties {
|
|||||||
void setPhasesCount(int);
|
void setPhasesCount(int);
|
||||||
unsigned short int phasesCount();
|
unsigned short int phasesCount();
|
||||||
void draw(QPainter *, QET::ConductorSegmentType, const QRectF &);
|
void draw(QPainter *, QET::ConductorSegmentType, const QRectF &);
|
||||||
void toXml(QDomElement &) const;
|
void toXml(QDomDocument &, QDomElement &) const;
|
||||||
void fromXml(QDomElement &);
|
void fromXml(QDomElement &);
|
||||||
void toSettings(QSettings &, const QString & = QString()) const;
|
void toSettings(QSettings &, const QString & = QString()) const;
|
||||||
void fromSettings(QSettings &, const QString & = QString());
|
void fromSettings(QSettings &, const QString & = QString());
|
||||||
@@ -87,7 +87,7 @@ class ConductorProperties {
|
|||||||
SingleLineProperties singleLineProperties;
|
SingleLineProperties singleLineProperties;
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
void toXml(QDomElement &) const;
|
void toXml(QDomDocument &, QDomElement &) const;
|
||||||
void fromXml(QDomElement &);
|
void fromXml(QDomElement &);
|
||||||
void toSettings(QSettings &, const QString & = QString()) const;
|
void toSettings(QSettings &, const QString & = QString()) const;
|
||||||
void fromSettings(QSettings &, const QString & = QString());
|
void fromSettings(QSettings &, const QString & = QString());
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -16,9 +16,7 @@
|
|||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "conductorpropertieswidget.h"
|
#include "conductorpropertieswidget.h"
|
||||||
#include <QtGui>
|
|
||||||
#include "conductor.h"
|
#include "conductor.h"
|
||||||
#include "qeticons.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@@ -48,7 +46,6 @@ void ConductorPropertiesWidget::buildInterface() {
|
|||||||
setMinimumSize(380, 280);
|
setMinimumSize(380, 280);
|
||||||
|
|
||||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||||
main_layout -> setContentsMargins(0, 0, 0, 0);
|
|
||||||
|
|
||||||
QGroupBox *groupbox = new QGroupBox(tr("Type de conducteur"));
|
QGroupBox *groupbox = new QGroupBox(tr("Type de conducteur"));
|
||||||
main_layout -> addWidget(groupbox);
|
main_layout -> addWidget(groupbox);
|
||||||
@@ -69,7 +66,7 @@ void ConductorPropertiesWidget::buildInterface() {
|
|||||||
|
|
||||||
QHBoxLayout *singleline_layout3 = new QHBoxLayout();
|
QHBoxLayout *singleline_layout3 = new QHBoxLayout();
|
||||||
phase_checkbox = new QCheckBox(tr("phase"));
|
phase_checkbox = new QCheckBox(tr("phase"));
|
||||||
phase_checkbox -> setIcon(QET::Icons::Phase);
|
phase_checkbox -> setIcon(QIcon(":/ico/phase.png"));
|
||||||
phase_slider = new QSlider(Qt::Horizontal);
|
phase_slider = new QSlider(Qt::Horizontal);
|
||||||
phase_slider -> setRange(1, 3);
|
phase_slider -> setRange(1, 3);
|
||||||
phase_spinbox = new QSpinBox();
|
phase_spinbox = new QSpinBox();
|
||||||
@@ -80,9 +77,9 @@ void ConductorPropertiesWidget::buildInterface() {
|
|||||||
|
|
||||||
QVBoxLayout *singleline_layout2 = new QVBoxLayout();
|
QVBoxLayout *singleline_layout2 = new QVBoxLayout();
|
||||||
ground_checkbox = new QCheckBox(tr("terre"));
|
ground_checkbox = new QCheckBox(tr("terre"));
|
||||||
ground_checkbox -> setIcon(QET::Icons::Ground);
|
ground_checkbox -> setIcon(QIcon(":/ico/ground.png"));
|
||||||
neutral_checkbox = new QCheckBox(tr("neutre"));
|
neutral_checkbox = new QCheckBox(tr("neutre"));
|
||||||
neutral_checkbox -> setIcon(QET::Icons::Neutral);
|
neutral_checkbox -> setIcon(QIcon(":/ico/neutral.png"));
|
||||||
singleline_layout2 -> addWidget(ground_checkbox);
|
singleline_layout2 -> addWidget(ground_checkbox);
|
||||||
singleline_layout2 -> addWidget(neutral_checkbox);
|
singleline_layout2 -> addWidget(neutral_checkbox);
|
||||||
singleline_layout2 -> addLayout(singleline_layout3);
|
singleline_layout2 -> addLayout(singleline_layout3);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef CONDUCTOR_PROPERTIES_WIDGET_H
|
#ifndef CONDUCTOR_PROPERTIES_WIDGET_H
|
||||||
#define CONDUCTOR_PROPERTIES_WIDGET_H
|
#define CONDUCTOR_PROPERTIES_WIDGET_H
|
||||||
#include "conductorproperties.h"
|
#include "conductor.h"
|
||||||
#include <QWidget>
|
#include <QtGui>
|
||||||
/**
|
/**
|
||||||
Ce widget permet a l utilisateur d'editer les proprietes d'un conducteur.
|
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
|
Par proprietes, on entend non pas le trajet effectue par le conducteur mais
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -24,12 +24,12 @@
|
|||||||
*/
|
*/
|
||||||
ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
|
ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
|
||||||
|
|
||||||
setWindowTitle(tr("Configurer QElectroTech", "window title"));
|
setWindowTitle(tr("Configurer QElectroTech"));
|
||||||
|
|
||||||
// liste des pages
|
// liste des pages
|
||||||
pages_list = new QListWidget();
|
pages_list = new QListWidget();
|
||||||
pages_list -> setViewMode(QListView::IconMode);
|
pages_list -> setViewMode(QListView::IconMode);
|
||||||
pages_list -> setIconSize(QSize(110, 110));
|
pages_list -> setIconSize(QSize(48, 48));
|
||||||
pages_list -> setMovement(QListView::Static);
|
pages_list -> setMovement(QListView::Static);
|
||||||
pages_list -> setMinimumWidth(135);
|
pages_list -> setMinimumWidth(135);
|
||||||
pages_list -> setMaximumWidth(135);
|
pages_list -> setMaximumWidth(135);
|
||||||
@@ -37,7 +37,6 @@ ConfigDialog::ConfigDialog(QWidget *parent) : QDialog(parent) {
|
|||||||
|
|
||||||
// pages
|
// pages
|
||||||
pages_widget = new QStackedWidget();
|
pages_widget = new QStackedWidget();
|
||||||
addPage(new GeneralConfigurationPage());
|
|
||||||
addPage(new NewDiagramPage());
|
addPage(new NewDiagramPage());
|
||||||
buildPagesList();
|
buildPagesList();
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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-2008 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-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -18,9 +18,9 @@
|
|||||||
#ifndef CONFIG_PAGES_H
|
#ifndef CONFIG_PAGES_H
|
||||||
#define CONFIG_PAGES_H
|
#define CONFIG_PAGES_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
class BorderPropertiesWidget;
|
#include "conductorpropertieswidget.h"
|
||||||
class ConductorPropertiesWidget;
|
#include "insetpropertieswidget.h"
|
||||||
class InsetPropertiesWidget;
|
|
||||||
/**
|
/**
|
||||||
Cette classe abstraite contient les methodes que toutes les pages de
|
Cette classe abstraite contient les methodes que toutes les pages de
|
||||||
configuration doivent implementer.
|
configuration doivent implementer.
|
||||||
@@ -63,40 +63,10 @@ class NewDiagramPage : public ConfigPage {
|
|||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
public:
|
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
|
InsetPropertiesWidget *ipw; ///< Widget d'edition des proprietes par defaut du cartouche
|
||||||
ConductorPropertiesWidget *cpw; ///< Widget d'edition des proprietes par defaut des conducteurs
|
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 *appearance_;
|
|
||||||
QCheckBox *use_system_colors_;
|
|
||||||
QGroupBox *projects_view_mode_;
|
|
||||||
QRadioButton *windowed_mode_;
|
|
||||||
QRadioButton *tabbed_mode_;
|
|
||||||
QLabel *warning_view_mode_;
|
|
||||||
QGroupBox *elements_management_;
|
|
||||||
QCheckBox *integrate_elements_;
|
|
||||||
};
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -19,151 +19,119 @@
|
|||||||
#include "elementtextitem.h"
|
#include "elementtextitem.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
#include "partline.h"
|
|
||||||
#include "elementdefinition.h"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur de la classe CustomElement. Permet d'instancier un element
|
Constructeur de la classe ElementPerso. Permet d'instancier un element
|
||||||
utilisable comme un element fixe a la difference que l'element perso est
|
utilisable comme un element fixe a la difference que l'element perso lit
|
||||||
construit a partir d'une description au format XML. Celle-ci est recuperee
|
sa description (noms, dessin, comportement) dans un fichier XML a fournir
|
||||||
a l'emplacement indique.
|
en parametre.
|
||||||
@param location Emplacement de la definition d'element a utiliser
|
@param nom_fichier Le chemin du fichier XML decrivant l'element
|
||||||
@param qgi Le QGraphicsItem parent de cet element
|
@param qgi Le QGraphicsItem parent de cet element
|
||||||
@param s Le Schema affichant 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 :
|
sera changee de maniere a refleter le deroulement de l'instanciation :
|
||||||
- 0 : L'instanciation a reussi
|
- 0 : L'instanciation a reussi
|
||||||
- 1 : l'emplacement n'a pas permis d'acceder a une definition d'element
|
- 1 : Le fichier n'existe pas
|
||||||
- 2 : la definition n'etait pas lisible
|
- 2 : Le fichier n'a pu etre ouvert
|
||||||
- 3 : la definition n'etait pas valide / exploitable / utilisable
|
- 3 : Le fichier n'est pas un document XML
|
||||||
- 4 : Le document XML n'est pas un element "definition"
|
- 4 : Le document XML n'a pas une "definition" comme racine
|
||||||
- 5 : Les attributs de la definition ne sont pas presents et / ou valides
|
- 5 : Les attributs de la definition ne sont pas presents et / ou valides
|
||||||
- 6 : La definition est vide
|
- 6 : La definition est vide
|
||||||
- 7 : L'analyse d'un element XML decrivant une partie du dessin de l'element a echoue
|
- 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
|
- 8 : Aucune partie du dessin n'a pu etre chargee
|
||||||
*/
|
*/
|
||||||
CustomElement::CustomElement(const ElementsLocation &location, QGraphicsItem *qgi, Diagram *s, int *state) :
|
CustomElement::CustomElement(QString &nom_fichier, QGraphicsItem *qgi, Diagram *s, int *etat) : FixedElement(qgi, s) {
|
||||||
FixedElement(qgi, s),
|
nomfichier = nom_fichier;
|
||||||
elmt_state(-1),
|
// pessimisme inside : par defaut, ca foire
|
||||||
location_(location),
|
elmt_etat = -1;
|
||||||
forbid_antialiasing(false)
|
|
||||||
{
|
// le fichier doit exister
|
||||||
// recupere la definition de l'element
|
QFileInfo infos_file(nomfichier);
|
||||||
ElementsCollectionItem *element_item = QETApp::collectionItem(location);
|
if (!infos_file.exists() || !infos_file.isFile()) {
|
||||||
ElementDefinition *element_definition;
|
if (etat != NULL) *etat = 1;
|
||||||
if (
|
elmt_etat = 1;
|
||||||
!element_item ||\
|
|
||||||
!element_item -> isElement() ||\
|
|
||||||
!(element_definition = qobject_cast<ElementDefinition *>(element_item))
|
|
||||||
) {
|
|
||||||
if (state) *state = 1;
|
|
||||||
elmt_state = 1;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!element_definition -> isReadable()) {
|
// le fichier doit etre lisible
|
||||||
if (state) *state = 2;
|
QFile fichier(nomfichier);
|
||||||
elmt_state = 2;
|
if (!fichier.open(QIODevice::ReadOnly)) {
|
||||||
|
if (etat != NULL) *etat = 2;
|
||||||
|
elmt_etat = 2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element_definition -> isNull()) {
|
// le fichier doit etre un document XML
|
||||||
if (state) *state = 3;
|
QDomDocument document_xml;
|
||||||
elmt_state = 3;
|
if (!document_xml.setContent(&fichier)) {
|
||||||
|
if (etat != NULL) *etat = 3;
|
||||||
|
elmt_etat = 3;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildFromXml(element_definition -> xml(), &elmt_state);
|
// la racine est supposee etre une definition d'element
|
||||||
if (state) *state = elmt_state;
|
QDomElement racine = document_xml.documentElement();
|
||||||
if (elmt_state) return;
|
if (racine.tagName() != "definition" || racine.attribute("type") != "element") {
|
||||||
|
if (etat != NULL) *etat = 4;
|
||||||
if (state) *state = 0;
|
elmt_etat = 4;
|
||||||
elmt_state = 0;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// verifie basiquement que la version actuelle est capable de lire ce fichier
|
// 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;
|
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) {
|
if (conv_ok && QET::version.toDouble() < element_version) {
|
||||||
std::cerr << qPrintable(
|
std::cerr << qPrintable(
|
||||||
QObject::tr("Avertissement : l'\351l\351ment "
|
QObject::tr("Avertissement : l'\351l\351ment ") + nom_fichier
|
||||||
" a \351t\351 enregistr\351 avec une version"
|
+ QObject::tr(" a \351t\351 enregistr\351 avec une version"
|
||||||
" ult\351rieure de QElectroTech.")
|
" ult\351rieure de QElectroTech.")
|
||||||
) << std::endl;
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ces attributs doivent etre presents et valides
|
// ces attributs doivent etre presents et valides
|
||||||
int w, h, hot_x, hot_y;
|
int w, h, hot_x, hot_y;
|
||||||
if (
|
if (
|
||||||
!QET::attributeIsAnInteger(xml_def_elmt, QString("width"), &w) ||\
|
!QET::attributeIsAnInteger(racine, QString("width"), &w) ||\
|
||||||
!QET::attributeIsAnInteger(xml_def_elmt, QString("height"), &h) ||\
|
!QET::attributeIsAnInteger(racine, QString("height"), &h) ||\
|
||||||
!QET::attributeIsAnInteger(xml_def_elmt, QString("hotspot_x"), &hot_x) ||\
|
!QET::attributeIsAnInteger(racine, QString("hotspot_x"), &hot_x) ||\
|
||||||
!QET::attributeIsAnInteger(xml_def_elmt, QString("hotspot_y"), &hot_y) ||\
|
!QET::attributeIsAnInteger(racine, QString("hotspot_y"), &hot_y) ||\
|
||||||
!validOrientationAttribute(xml_def_elmt)
|
!validOrientationAttribute(racine)
|
||||||
) {
|
) {
|
||||||
if (state) *state = 5;
|
if (etat != NULL) *etat = 5;
|
||||||
return(false);
|
elmt_etat = 5;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// on peut d'ores et deja specifier la taille et le hotspot
|
// on peut d'ores et deja specifier la taille et le hotspot
|
||||||
setSize(w, h);
|
setSize(w, h);
|
||||||
setHotspot(QPoint(hot_x, hot_y));
|
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
|
// la definition est supposee avoir des enfants
|
||||||
if (xml_def_elmt.firstChild().isNull()) {
|
if (racine.firstChild().isNull()) {
|
||||||
if (state) *state = 6;
|
if (etat != NULL) *etat = 6;
|
||||||
return(false);
|
elmt_etat = 6;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialisation du QPainter (pour dessiner l'element)
|
// initialisation du QPainter (pour dessiner l'element)
|
||||||
QPainter qp;
|
QPainter qp;
|
||||||
qp.begin(&drawing);
|
qp.begin(&dessin);
|
||||||
|
QPen t;
|
||||||
QPainter low_zoom_qp;
|
t.setColor(Qt::black);
|
||||||
low_zoom_qp.begin(&low_zoom_drawing);
|
t.setWidthF(1.0);
|
||||||
QPen tmp;
|
t.setJoinStyle(Qt::BevelJoin);
|
||||||
tmp.setWidthF(1.0); // ligne vaudou pour prise en compte du setCosmetic - ne pas enlever
|
qp.setPen(t);
|
||||||
tmp.setCosmetic(true);
|
|
||||||
low_zoom_qp.setPen(tmp);
|
|
||||||
|
|
||||||
// extrait les noms de la definition XML
|
// extrait les noms de la definition XML
|
||||||
names.fromXml(xml_def_elmt);
|
names.fromXml(racine);
|
||||||
setToolTip(name());
|
setToolTip(nom());
|
||||||
|
|
||||||
// parcours des enfants de la definition : parties du dessin
|
// parcours des enfants de la definition : parties du dessin
|
||||||
int parsed_elements_count = 0;
|
int nb_elements_parses = 0;
|
||||||
for (QDomNode node = xml_def_elmt.firstChild() ; !node.isNull() ; node = node.nextSibling()) {
|
for (QDomNode node = racine.firstChild() ; !node.isNull() ; node = node.nextSibling()) {
|
||||||
QDomElement elmts = node.toElement();
|
QDomElement elmts = node.toElement();
|
||||||
if (elmts.isNull()) continue;
|
if (elmts.isNull()) continue;
|
||||||
if (elmts.tagName() == "description") {
|
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()) {
|
for (QDomNode n = node.firstChild() ; !n.isNull() ; n = n.nextSibling()) {
|
||||||
QDomElement qde = n.toElement();
|
QDomElement qde = n.toElement();
|
||||||
if (qde.isNull()) continue;
|
if (qde.isNull()) continue;
|
||||||
if (parseElement(qde, qp)) {
|
if (parseElement(qde, qp)) ++ nb_elements_parses;
|
||||||
++ parsed_elements_count;
|
else {
|
||||||
QString current_tag = qde.tagName();
|
if (etat != NULL) *etat = 7;
|
||||||
if (current_tag != "terminal" && current_tag != "input") {
|
elmt_etat = 7;
|
||||||
forbid_antialiasing = true;
|
return;
|
||||||
parseElement(qde, low_zoom_qp);
|
|
||||||
forbid_antialiasing = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (state) *state = 7;
|
|
||||||
return(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -190,16 +152,19 @@ bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) {
|
|||||||
|
|
||||||
// fin du dessin
|
// fin du dessin
|
||||||
qp.end();
|
qp.end();
|
||||||
low_zoom_qp.end();
|
|
||||||
|
|
||||||
// il doit y avoir au moins un element charge
|
// il doit y avoir au moins un element charge
|
||||||
if (!parsed_elements_count) {
|
if (!nb_elements_parses) {
|
||||||
if (state) *state = 8;
|
if (etat != NULL) *etat = 8;
|
||||||
return(false);
|
elmt_etat = 8;
|
||||||
} else {
|
return;
|
||||||
if (state) *state = 0;
|
|
||||||
return(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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(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
|
@return Le nombre de bornes que l'element possede
|
||||||
*/
|
*/
|
||||||
int CustomElement::terminalsCount() const {
|
int CustomElement::nbTerminals() const {
|
||||||
return(list_terminals.size());
|
return(list_terminals.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,12 +197,8 @@ int CustomElement::terminalsCount() const {
|
|||||||
@param qp Le QPainter a utiliser pour dessiner l'element
|
@param qp Le QPainter a utiliser pour dessiner l'element
|
||||||
@param options Les options graphiques
|
@param options Les options graphiques
|
||||||
*/
|
*/
|
||||||
void CustomElement::paint(QPainter *qp, const QStyleOptionGraphicsItem *options) {
|
void CustomElement::paint(QPainter *qp, const QStyleOptionGraphicsItem *) {
|
||||||
if (options && options -> levelOfDetail < 1.0) {
|
dessin.play(qp);
|
||||||
low_zoom_drawing.play(qp);
|
|
||||||
} else {
|
|
||||||
drawing.play(qp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -261,7 +217,6 @@ void CustomElement::paint(QPainter *qp, const QStyleOptionGraphicsItem *options)
|
|||||||
bool CustomElement::parseElement(QDomElement &e, QPainter &qp) {
|
bool CustomElement::parseElement(QDomElement &e, QPainter &qp) {
|
||||||
if (e.tagName() == "terminal") return(parseTerminal(e));
|
if (e.tagName() == "terminal") return(parseTerminal(e));
|
||||||
else if (e.tagName() == "line") return(parseLine(e, qp));
|
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() == "ellipse") return(parseEllipse(e, qp));
|
||||||
else if (e.tagName() == "circle") return(parseCircle(e, qp));
|
else if (e.tagName() == "circle") return(parseCircle(e, qp));
|
||||||
else if (e.tagName() == "arc") return(parseArc(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("y1"), &y1)) return(false);
|
||||||
if (!QET::attributeIsAReal(e, QString("x2"), &x2)) return(false);
|
if (!QET::attributeIsAReal(e, QString("x2"), &x2)) return(false);
|
||||||
if (!QET::attributeIsAReal(e, QString("y2"), &y2)) 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();
|
qp.save();
|
||||||
setPainterStyle(e, qp);
|
setPainterStyle(e, qp);
|
||||||
QPen t = qp.pen();
|
qp.drawLine(QLineF(x1, y1, x2, y2));
|
||||||
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.restore();
|
qp.restore();
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
@@ -422,6 +262,7 @@ bool CustomElement::parseRect(QDomElement &e, QPainter &qp) {
|
|||||||
@param e L'element XML a analyser
|
@param e L'element XML a analyser
|
||||||
@param qp Le QPainter a utiliser pour dessiner l'element perso
|
@param qp Le QPainter a utiliser pour dessiner l'element perso
|
||||||
@return true si l'analyse reussit, false sinon
|
@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) {
|
bool CustomElement::parseCircle(QDomElement &e, QPainter &qp) {
|
||||||
// verifie la presence des attributs obligatoires
|
// 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 e L'element XML a analyser
|
||||||
@param qp Le QPainter a utiliser pour dessiner l'element perso
|
@param qp Le QPainter a utiliser pour dessiner l'element perso
|
||||||
@return true si l'analyse reussit, false sinon
|
@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) {
|
bool CustomElement::parseEllipse(QDomElement &e, QPainter &qp) {
|
||||||
// verifie la presence des attributs obligatoires
|
// verifie la presence des attributs obligatoires
|
||||||
@@ -548,7 +390,7 @@ bool CustomElement::parseText(QDomElement &e, QPainter &qp) {
|
|||||||
|
|
||||||
qp.save();
|
qp.save();
|
||||||
setPainterStyle(e, qp);
|
setPainterStyle(e, qp);
|
||||||
qp.setFont(QETApp::diagramTextsFont(size));
|
qp.setFont(QFont(QString(QETApp::diagramTextsFont()), size));
|
||||||
qp.drawText(QPointF(pos_x, pos_y), e.attribute("text"));
|
qp.drawText(QPointF(pos_x, pos_y), e.attribute("text"));
|
||||||
qp.restore();
|
qp.restore();
|
||||||
return(true);
|
return(true);
|
||||||
@@ -563,26 +405,24 @@ bool CustomElement::parseText(QDomElement &e, QPainter &qp) {
|
|||||||
- une taille
|
- une taille
|
||||||
- le fait de subir les rotations de l'element ou non
|
- le fait de subir les rotations de l'element ou non
|
||||||
@param e L'element XML a analyser
|
@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;
|
qreal pos_x, pos_y;
|
||||||
int size;
|
int size;
|
||||||
if (
|
if (
|
||||||
!QET::attributeIsAReal(e, "x", &pos_x) ||\
|
!QET::attributeIsAReal(e, "x", &pos_x) ||\
|
||||||
!QET::attributeIsAReal(e, "y", &pos_y) ||\
|
!QET::attributeIsAReal(e, "y", &pos_y) ||\
|
||||||
!QET::attributeIsAnInteger(e, "size", &size)
|
!QET::attributeIsAnInteger(e, "size", &size)
|
||||||
) return(0);
|
) return(false);
|
||||||
|
|
||||||
ElementTextItem *eti = new ElementTextItem(e.attribute("text"), this);
|
ElementTextItem *eti = new ElementTextItem(e.attribute("text"), this);
|
||||||
eti -> setFont(QETApp::diagramTextsFont(size));
|
eti -> setFont(QFont(QETApp::diagramTextsFont(), size));
|
||||||
eti -> setPos(pos_x, pos_y);
|
eti -> setPos(pos_x, pos_y);
|
||||||
eti -> setOriginalPos(QPointF(pos_x, pos_y));
|
eti -> setOriginalPos(QPointF(pos_x, pos_y));
|
||||||
if (e.attribute("rotate") == "true") eti -> setFollowParentRotations(true);
|
if (e.attribute("rotate") == "true") eti -> setFollowParentRotations(true);
|
||||||
|
return(true);
|
||||||
list_texts_ << eti;
|
|
||||||
|
|
||||||
return(eti);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -593,23 +433,23 @@ ElementTextItem *CustomElement::parseInput(QDomElement &e) {
|
|||||||
- orientation : orientation de la borne = Nord (n), Sud (s), Est (e) ou Ouest (w)
|
- orientation : orientation de la borne = Nord (n), Sud (s), Est (e) ou Ouest (w)
|
||||||
|
|
||||||
@param e L'element XML a analyser
|
@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
|
// verifie la presence et la validite des attributs obligatoires
|
||||||
double terminalx, terminaly;
|
double terminalx, terminaly;
|
||||||
QET::Orientation terminalo;
|
QET::Orientation terminalo;
|
||||||
if (!QET::attributeIsAReal(e, QString("x"), &terminalx)) return(0);
|
if (!QET::attributeIsAReal(e, QString("x"), &terminalx)) return(false);
|
||||||
if (!QET::attributeIsAReal(e, QString("y"), &terminaly)) return(0);
|
if (!QET::attributeIsAReal(e, QString("y"), &terminaly)) return(false);
|
||||||
if (!e.hasAttribute("orientation")) return(0);
|
if (!e.hasAttribute("orientation")) return(false);
|
||||||
if (e.attribute("orientation") == "n") terminalo = QET::North;
|
if (e.attribute("orientation") == "n") terminalo = QET::North;
|
||||||
else if (e.attribute("orientation") == "s") terminalo = QET::South;
|
else if (e.attribute("orientation") == "s") terminalo = QET::South;
|
||||||
else if (e.attribute("orientation") == "e") terminalo = QET::East;
|
else if (e.attribute("orientation") == "e") terminalo = QET::East;
|
||||||
else if (e.attribute("orientation") == "w") terminalo = QET::West;
|
else if (e.attribute("orientation") == "w") terminalo = QET::West;
|
||||||
else return(0);
|
else return(false);
|
||||||
Terminal *new_terminal = new Terminal(terminalx, terminaly, terminalo, this, qobject_cast<Diagram *>(scene()));
|
list_terminals << new Terminal(terminalx, terminaly, terminalo, this, qobject_cast<Diagram *>(scene()));
|
||||||
list_terminals << new_terminal;
|
return(true);
|
||||||
return(new_terminal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -618,7 +458,6 @@ Terminal *CustomElement::parseTerminal(QDomElement &e) {
|
|||||||
@param aa Booleen a true pour activer l'antialiasing, a false pour le desactiver
|
@param aa Booleen a true pour activer l'antialiasing, a false pour le desactiver
|
||||||
*/
|
*/
|
||||||
void CustomElement::setQPainterAntiAliasing(QPainter &qp, bool aa) {
|
void CustomElement::setQPainterAntiAliasing(QPainter &qp, bool aa) {
|
||||||
if (forbid_antialiasing) aa = false;
|
|
||||||
qp.setRenderHint(QPainter::Antialiasing, aa);
|
qp.setRenderHint(QPainter::Antialiasing, aa);
|
||||||
qp.setRenderHint(QPainter::TextAntialiasing, aa);
|
qp.setRenderHint(QPainter::TextAntialiasing, aa);
|
||||||
qp.setRenderHint(QPainter::SmoothPixmapTransform, aa);
|
qp.setRenderHint(QPainter::SmoothPixmapTransform, aa);
|
||||||
@@ -643,7 +482,7 @@ void CustomElement::setQPainterAntiAliasing(QPainter &qp, bool aa) {
|
|||||||
@param e Element XML
|
@param e Element XML
|
||||||
@return true si l'attribut "orientation" est valide, false sinon
|
@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")));
|
return(ori.fromString(e.attribute("orientation")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef CUSTOM_ELEMENT_H
|
#ifndef ELEMENTPERSO_H
|
||||||
#define CUSTOM_ELEMENT_H
|
#define ELEMENTPERSO_H
|
||||||
#include "fixedelement.h"
|
#include "fixedelement.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "nameslist.h"
|
#include "nameslist.h"
|
||||||
#include "elementslocation.h"
|
class CustomElementPart;
|
||||||
class ElementTextItem;
|
|
||||||
class Terminal;
|
|
||||||
/**
|
/**
|
||||||
Cette classe represente un element electrique. Elle est utilisable
|
Cette classe represente un element electrique. Elle est utilisable
|
||||||
comme un element fixe. La difference est que l'element perso lit
|
comme un element fixe. La difference est que l'element perso lit
|
||||||
@@ -30,73 +29,65 @@ class Terminal;
|
|||||||
en parametre.
|
en parametre.
|
||||||
*/
|
*/
|
||||||
class CustomElement : public FixedElement {
|
class CustomElement : public FixedElement {
|
||||||
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
CustomElement(const ElementsLocation &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
CustomElement(QString &, QGraphicsItem * = 0, Diagram * = 0, int * = NULL);
|
||||||
CustomElement(const QDomElement &, QGraphicsItem * = 0, Diagram * = 0, int * = 0);
|
|
||||||
virtual ~CustomElement();
|
virtual ~CustomElement();
|
||||||
|
|
||||||
|
friend class CustomElementPart;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CustomElement(const CustomElement &);
|
CustomElement(const CustomElement &);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
protected:
|
private:
|
||||||
int elmt_state; // contient le code d'erreur si l'instanciation a echoue ou 0 si l'instanciation s'est bien passe
|
int elmt_etat; // contient le code d'erreur si l'instanciation a echoue ou 0 si l'instanciation s'est bien passe
|
||||||
NamesList names;
|
NamesList names;
|
||||||
ElementsLocation location_;
|
QString nomfichier;
|
||||||
QPicture drawing;
|
QPicture dessin;
|
||||||
QPicture low_zoom_drawing;
|
|
||||||
QList<Terminal *> list_terminals;
|
QList<Terminal *> list_terminals;
|
||||||
QList<ElementTextItem *> list_texts_;
|
|
||||||
bool forbid_antialiasing;
|
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
virtual QList<Terminal *> terminals() const;
|
virtual QList<Terminal *> terminals() const;
|
||||||
virtual QList<Conductor *> conductors() const;
|
virtual QList<Conductor *> conductors() const;
|
||||||
virtual QList<ElementTextItem *> texts() const;
|
virtual int nbTerminals() const;
|
||||||
virtual int terminalsCount() const;
|
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *);
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *);
|
||||||
QString typeId() const;
|
QString typeId() const;
|
||||||
ElementsLocation location() const;
|
QString fichier() const;
|
||||||
bool isNull() const;
|
bool isNull() const;
|
||||||
int state() const;
|
int etat() const;
|
||||||
QString name() const;
|
QString nom() const;
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
virtual bool buildFromXml(const QDomElement &, int * = 0);
|
bool parseElement(QDomElement &, QPainter &);
|
||||||
virtual bool parseElement(QDomElement &, QPainter &);
|
bool parseLine(QDomElement &, QPainter &);
|
||||||
virtual bool parseLine(QDomElement &, QPainter &);
|
bool parseEllipse(QDomElement &, QPainter &);
|
||||||
virtual bool parseRect(QDomElement &, QPainter &);
|
bool parseCircle(QDomElement &, QPainter &);
|
||||||
virtual bool parseEllipse(QDomElement &, QPainter &);
|
bool parseArc(QDomElement &, QPainter &);
|
||||||
virtual bool parseCircle(QDomElement &, QPainter &);
|
bool parsePolygon(QDomElement &, QPainter &);
|
||||||
virtual bool parseArc(QDomElement &, QPainter &);
|
bool parseText(QDomElement &, QPainter &);
|
||||||
virtual bool parsePolygon(QDomElement &, QPainter &);
|
bool parseInput(QDomElement &);
|
||||||
virtual bool parseText(QDomElement &, QPainter &);
|
bool parseTerminal(QDomElement &);
|
||||||
virtual ElementTextItem *parseInput(QDomElement &);
|
void setQPainterAntiAliasing(QPainter &, bool);
|
||||||
virtual Terminal *parseTerminal(QDomElement &);
|
bool validOrientationAttribute(QDomElement &);
|
||||||
virtual void setQPainterAntiAliasing(QPainter &, bool);
|
void setPainterStyle(QDomElement &, QPainter &);
|
||||||
virtual bool validOrientationAttribute(const QDomElement &);
|
|
||||||
virtual void setPainterStyle(QDomElement &, QPainter &);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return L'ID du type de l'element ; pour un CustomElement, cela revient au
|
@return L'ID du type de l'element ; pour un CustomElement, cela revient au
|
||||||
nom du fichier
|
nom du fichier
|
||||||
@see location()
|
@see fichier()
|
||||||
*/
|
*/
|
||||||
inline QString CustomElement::typeId() const {
|
inline QString CustomElement::typeId() const {
|
||||||
return(location_.path());
|
return(nomfichier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return L'adresse du fichier contenant la description XML de cet element
|
@return L'adresse du fichier contenant la description XML de cet element
|
||||||
*/
|
*/
|
||||||
inline ElementsLocation CustomElement::location() const {
|
inline QString CustomElement::fichier() const {
|
||||||
return(location_);
|
return(nomfichier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -104,7 +95,7 @@ inline ElementsLocation CustomElement::location() const {
|
|||||||
description XML a echoue
|
description XML a echoue
|
||||||
*/
|
*/
|
||||||
inline bool CustomElement::isNull() const {
|
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
|
- 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
|
- 8 : Aucune partie du dessin n'a pu etre chargee
|
||||||
*/
|
*/
|
||||||
inline int CustomElement::state() const {
|
inline int CustomElement::etat() const {
|
||||||
return(elmt_state);
|
return(elmt_etat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return Le nom de l'element
|
@return Le nom de l'element
|
||||||
*/
|
*/
|
||||||
inline QString CustomElement::name() const {
|
inline QString CustomElement::nom() const {
|
||||||
return(names.name(location_.baseName()));
|
return(names.name(QFileInfo(nomfichier).baseName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -20,12 +20,9 @@
|
|||||||
#include "conductor.h"
|
#include "conductor.h"
|
||||||
#include "customelement.h"
|
#include "customelement.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "elementtextitem.h"
|
|
||||||
#include "exportdialog.h"
|
#include "exportdialog.h"
|
||||||
#include "ghostelement.h"
|
|
||||||
#include "diagramcommands.h"
|
#include "diagramcommands.h"
|
||||||
#include "diagramcontent.h"
|
#include "diagramcontent.h"
|
||||||
#include "diagramposition.h"
|
|
||||||
|
|
||||||
const int Diagram::xGrid = 10;
|
const int Diagram::xGrid = 10;
|
||||||
const int Diagram::yGrid = 10;
|
const int Diagram::yGrid = 10;
|
||||||
@@ -40,12 +37,9 @@ Diagram::Diagram(QObject *parent) :
|
|||||||
draw_grid(true),
|
draw_grid(true),
|
||||||
use_border(true),
|
use_border(true),
|
||||||
moved_elements_fetched(false),
|
moved_elements_fetched(false),
|
||||||
draw_terminals(true),
|
qgi_manager(this),
|
||||||
project_(0),
|
draw_terminals(true)
|
||||||
read_only_(false)
|
|
||||||
{
|
{
|
||||||
undo_stack = new QUndoStack();
|
|
||||||
qgi_manager = new QGIManager(this);
|
|
||||||
setBackgroundBrush(Qt::white);
|
setBackgroundBrush(Qt::white);
|
||||||
conductor_setter = new QGraphicsLineItem(0, 0);
|
conductor_setter = new QGraphicsLineItem(0, 0);
|
||||||
conductor_setter -> setZValue(1000000);
|
conductor_setter -> setZValue(1000000);
|
||||||
@@ -55,29 +49,18 @@ Diagram::Diagram(QObject *parent) :
|
|||||||
t.setStyle(Qt::DashLine);
|
t.setStyle(Qt::DashLine);
|
||||||
conductor_setter -> setPen(t);
|
conductor_setter -> setPen(t);
|
||||||
conductor_setter -> setLine(QLineF(QPointF(0.0, 0.0), QPointF(0.0, 0.0)));
|
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
|
Destructeur
|
||||||
*/
|
*/
|
||||||
Diagram::~Diagram() {
|
Diagram::~Diagram() {
|
||||||
// suppression de la liste des annulations - l'undo stack fait appel au qgimanager pour supprimer certains elements
|
if (conductor_setter -> scene()) removeItem(conductor_setter);
|
||||||
delete undo_stack;
|
delete conductor_setter;
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,17 +109,15 @@ void Diagram::drawBackground(QPainter *p, const QRectF &r) {
|
|||||||
@param e QKeyEvent decrivant l'evenement clavier
|
@param e QKeyEvent decrivant l'evenement clavier
|
||||||
*/
|
*/
|
||||||
void Diagram::keyPressEvent(QKeyEvent *e) {
|
void Diagram::keyPressEvent(QKeyEvent *e) {
|
||||||
if (!isReadOnly()) {
|
QPointF movement;
|
||||||
QPointF movement;
|
switch(e -> key()) {
|
||||||
switch(e -> key()) {
|
case Qt::Key_Left: movement = QPointF(-xGrid, 0.0); break;
|
||||||
case Qt::Key_Left: movement = QPointF(-xGrid, 0.0); break;
|
case Qt::Key_Right: 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_Up: movement = QPointF(0.0, -yGrid); break;
|
case Qt::Key_Down: movement = QPointF(0.0, +yGrid); break;
|
||||||
case Qt::Key_Down: movement = QPointF(0.0, +yGrid); break;
|
}
|
||||||
}
|
if (!movement.isNull() && !focusItem()) {
|
||||||
if (!movement.isNull() && !focusItem()) {
|
moveElements(movement);
|
||||||
moveElements(movement);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QGraphicsScene::keyPressEvent(e);
|
QGraphicsScene::keyPressEvent(e);
|
||||||
}
|
}
|
||||||
@@ -146,18 +127,16 @@ void Diagram::keyPressEvent(QKeyEvent *e) {
|
|||||||
@param e QKeyEvent decrivant l'evenement clavier
|
@param e QKeyEvent decrivant l'evenement clavier
|
||||||
*/
|
*/
|
||||||
void Diagram::keyReleaseEvent(QKeyEvent *e) {
|
void Diagram::keyReleaseEvent(QKeyEvent *e) {
|
||||||
if (!isReadOnly()) {
|
// detecte le relachement d'une touche de direction ( = deplacement d'elements)
|
||||||
// detecte le relachement d'une touche de direction ( = deplacement d'elements)
|
if (
|
||||||
if (
|
(e -> key() == Qt::Key_Left || e -> key() == Qt::Key_Right ||\
|
||||||
(e -> key() == Qt::Key_Left || e -> key() == Qt::Key_Right ||\
|
e -> key() == Qt::Key_Up || e -> key() == Qt::Key_Down) &&\
|
||||||
e -> key() == Qt::Key_Up || e -> key() == Qt::Key_Down) &&\
|
!current_movement.isNull() && !e -> isAutoRepeat()
|
||||||
!current_movement.isNull() && !e -> isAutoRepeat()
|
) {
|
||||||
) {
|
// cree un objet d'annulation pour le mouvement qui vient de se finir
|
||||||
// cree un objet d'annulation pour le mouvement qui vient de se finir
|
undoStack().push(new MoveElementsCommand(this, selectedContent(), current_movement));
|
||||||
undoStack().push(new MoveElementsCommand(this, selectedContent(), current_movement));
|
invalidateMovedElements();
|
||||||
invalidateMovedElements();
|
current_movement = QPointF();
|
||||||
current_movement = QPointF();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
QGraphicsScene::keyReleaseEvent(e);
|
QGraphicsScene::keyReleaseEvent(e);
|
||||||
}
|
}
|
||||||
@@ -232,14 +211,6 @@ QSize Diagram::imageSize() const {
|
|||||||
return(QSizeF(image_width, image_height).toSize());
|
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
|
Exporte tout ou partie du schema
|
||||||
@param diagram Booleen (a vrai par defaut) indiquant si le XML genere doit
|
@param diagram Booleen (a vrai par defaut) indiquant si le XML genere doit
|
||||||
@@ -260,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.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.fileName().isNull()) racine.setAttribute("filename", border_and_inset.fileName());
|
||||||
if (!border_and_inset.folio().isNull()) racine.setAttribute("folio", border_and_inset.folio());
|
if (!border_and_inset.folio().isNull()) racine.setAttribute("folio", border_and_inset.folio());
|
||||||
racine.setAttribute("cols", border_and_inset.nbColumns());
|
racine.setAttribute("cols", border_and_inset.nbColumn());
|
||||||
racine.setAttribute("colsize", QString("%1").arg(border_and_inset.columnsWidth()));
|
racine.setAttribute("colsize", border_and_inset.columnsWidth());
|
||||||
racine.setAttribute("rows", border_and_inset.nbRows());
|
racine.setAttribute("height", border_and_inset.columnsHeight());
|
||||||
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");
|
|
||||||
|
|
||||||
// type de conducteur par defaut
|
// type de conducteur par defaut
|
||||||
QDomElement default_conductor = document.createElement("defaultconductor");
|
QDomElement default_conductor = document.createElement("defaultconductor");
|
||||||
defaultConductorProperties.toXml(default_conductor);
|
defaultConductorProperties.toXml(document, default_conductor);
|
||||||
racine.appendChild(default_conductor);
|
racine.appendChild(default_conductor);
|
||||||
}
|
}
|
||||||
document.appendChild(racine);
|
document.appendChild(racine);
|
||||||
@@ -284,7 +250,7 @@ QDomDocument Diagram::toXml(bool diagram) {
|
|||||||
QList<Conductor *> list_conductors;
|
QList<Conductor *> list_conductors;
|
||||||
QList<DiagramTextItem *> list_texts;
|
QList<DiagramTextItem *> list_texts;
|
||||||
|
|
||||||
// Determine les elements a "XMLiser"
|
// Determine les elements a « XMLiser »
|
||||||
foreach(QGraphicsItem *qgi, items()) {
|
foreach(QGraphicsItem *qgi, items()) {
|
||||||
if (Element *elmt = qgraphicsitem_cast<Element *>(qgi)) {
|
if (Element *elmt = qgraphicsitem_cast<Element *>(qgi)) {
|
||||||
if (diagram) list_elements << elmt;
|
if (diagram) list_elements << elmt;
|
||||||
@@ -337,66 +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
|
precisee, les elements importes sont positionnes de maniere a ce que le
|
||||||
coin superieur gauche du plus petit rectangle pouvant les entourant tous
|
coin superieur gauche du plus petit rectangle pouvant les entourant tous
|
||||||
(le bounding rect) soit a cette position.
|
(le bounding rect) soit a cette position.
|
||||||
@param document Le document XML a analyser
|
@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
|
@param consider_informations Si vrai, les informations complementaires
|
||||||
(auteur, titre, ...) seront prises en compte
|
(auteur, titre, ...) seront prises en compte
|
||||||
@param content_ptr si ce pointeur vers un DiagramContent est different de 0,
|
@param content_ptr si ce pointeur vers un DiagramContentn'est pas NULL, il
|
||||||
il sera rempli avec le contenu ajoute au schema par le fromXml
|
sera rempli avec le contenu ajoute au schema par le fromXml
|
||||||
@return true si l'import a reussi, false sinon
|
@return true si l'import a reussi, false sinon
|
||||||
*/
|
*/
|
||||||
bool Diagram::fromXml(QDomDocument &document, QPointF position, bool consider_informations, DiagramContent *content_ptr) {
|
bool Diagram::fromXml(QDomDocument &document, QPointF position, bool consider_informations, DiagramContent *content_ptr) {
|
||||||
QDomElement root = document.documentElement();
|
QDomElement root = document.documentElement();
|
||||||
return(fromXml(root, position, consider_informations, content_ptr));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Importe le schema decrit dans un element XML. Cette methode delegue son travail a Diagram::fromXml
|
|
||||||
Si l'import reussit, cette methode initialise egalement le document XML
|
|
||||||
interne permettant de bien gerer l'enregistrement de ce schema dans le
|
|
||||||
projet auquel il appartient.
|
|
||||||
@see Diagram::fromXml
|
|
||||||
@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 est different de 0,
|
|
||||||
il sera rempli avec le contenu ajoute au schema par le fromXml
|
|
||||||
@return true si l'import a reussi, false sinon
|
|
||||||
|
|
||||||
*/
|
|
||||||
bool Diagram::initFromXml(QDomElement &document, QPointF position, bool consider_informations, DiagramContent *content_ptr) {
|
|
||||||
// import le contenu et les proprietes du schema depuis l'element XML fourni en parametre
|
|
||||||
bool from_xml = fromXml(document, position, consider_informations, content_ptr);
|
|
||||||
|
|
||||||
// initialise le document XML interne a partir de l'element XML fourni en parametre
|
|
||||||
if (from_xml) {
|
|
||||||
xml_document.clear();
|
|
||||||
xml_document.appendChild(xml_document.importNode(document, true));
|
|
||||||
// a ce stade, le document XML interne contient le code XML qui a ete importe, et non pas une version re-exporte par la methode toXml()
|
|
||||||
}
|
|
||||||
return(from_xml);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
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 est different de 0,
|
|
||||||
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
|
// le premier element doit etre un schema
|
||||||
if (root.tagName() != "diagram") return(false);
|
if (root.tagName() != "diagram") return(false);
|
||||||
|
|
||||||
@@ -417,24 +337,9 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
double col_size = root.attribute("colsize").toDouble(&ok);
|
double col_size = root.attribute("colsize").toDouble(&ok);
|
||||||
if (ok) border_and_inset.setColumnsWidth(col_size);
|
if (ok) border_and_inset.setColumnsWidth(col_size);
|
||||||
|
|
||||||
// retrocompatibilite : les schemas enregistres avec la 0.1 ont un attribut "height"
|
// hauteur du schema
|
||||||
if (root.hasAttribute("rows") && root.hasAttribute("rowsize")) {
|
double height = root.attribute("height").toDouble(&ok);
|
||||||
// nombre de lignes
|
if (ok) border_and_inset.setColumnsHeight(height);
|
||||||
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");
|
|
||||||
|
|
||||||
border_and_inset.adjustInsetToColumns();
|
border_and_inset.adjustInsetToColumns();
|
||||||
|
|
||||||
@@ -449,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)
|
// si la racine n'a pas d'enfant : le chargement est fini (schema vide)
|
||||||
if (root.firstChild().isNull()) {
|
if (root.firstChild().isNull()) return(true);
|
||||||
write(document);
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// chargement de tous les elements du fichier XML
|
// chargement de tous les elements du fichier XML
|
||||||
QList<Element *> added_elements;
|
QList<Element *> added_elements;
|
||||||
@@ -462,27 +364,23 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
|
|
||||||
// cree un element dont le type correspond a l'id type
|
// cree un element dont le type correspond a l'id type
|
||||||
QString type_id = e.attribute("type");
|
QString type_id = e.attribute("type");
|
||||||
ElementsLocation element_location = ElementsLocation(type_id);
|
QString chemin_fichier = QETApp::realPath(type_id);
|
||||||
if (type_id.startsWith("embed://")) element_location.setProject(project_);
|
CustomElement *nvel_elmt = new CustomElement(chemin_fichier);
|
||||||
|
|
||||||
CustomElement *nvel_elmt = new CustomElement(element_location);
|
|
||||||
if (nvel_elmt -> isNull()) {
|
if (nvel_elmt -> isNull()) {
|
||||||
QString debug_message = QString("Diagram::fromXml() : 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());
|
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());
|
||||||
qDebug() << qPrintable(debug_message);
|
|
||||||
delete nvel_elmt;
|
delete nvel_elmt;
|
||||||
|
qDebug(debug_message.toLatin1().data());
|
||||||
qDebug() << "Diagram::fromXml() : Utilisation d'un GhostElement en lieu et place de cet element.";
|
continue;
|
||||||
nvel_elmt = new GhostElement(element_location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// charge les caracteristiques de l'element
|
// charge les caracteristiques de l'element
|
||||||
if (nvel_elmt -> fromXml(e, table_adr_id)) {
|
if (nvel_elmt -> fromXml(e, table_adr_id)) {
|
||||||
// ajout de l'element au schema et a la liste des elements ajoutes
|
// ajout de l'element au schema et a la liste des elements ajoutes
|
||||||
addElement(nvel_elmt);
|
addItem(nvel_elmt);
|
||||||
added_elements << nvel_elmt;
|
added_elements << nvel_elmt;
|
||||||
} else {
|
} else {
|
||||||
delete nvel_elmt;
|
delete nvel_elmt;
|
||||||
qDebug() << "Diagram::fromXml() : Le chargement des parametres d'un element a echoue";
|
qDebug("Le chargement des parametres d'un element a echoue");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,7 +389,6 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
foreach (QDomElement f, QET::findInDomElement(root, "inputs", "input")) {
|
foreach (QDomElement f, QET::findInDomElement(root, "inputs", "input")) {
|
||||||
DiagramTextItem *dti = new DiagramTextItem(0, this);
|
DiagramTextItem *dti = new DiagramTextItem(0, this);
|
||||||
dti -> fromXml(f);
|
dti -> fromXml(f);
|
||||||
addDiagramTextItem(dti);
|
|
||||||
added_texts << dti;
|
added_texts << dti;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,11 +448,11 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
added_conductors << c;
|
added_conductors << c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else qDebug() << "Diagram::fromXml() : 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
|
// remplissage des listes facultatives
|
||||||
if (content_ptr) {
|
if (content_ptr != NULL) {
|
||||||
content_ptr -> elements = added_elements;
|
content_ptr -> elements = added_elements;
|
||||||
content_ptr -> conductorsToMove = added_conductors;
|
content_ptr -> conductorsToMove = added_conductors;
|
||||||
content_ptr -> textFields = added_texts;
|
content_ptr -> textFields = added_texts;
|
||||||
@@ -565,203 +462,17 @@ bool Diagram::fromXml(QDomElement &document, QPointF position, bool consider_inf
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Enregistre le schema XML dans son document XML interne et emet le signal
|
Verifie si la selection est passe d'un etat ou elle est vide a un etat ou
|
||||||
written().
|
elle ne l'est pas, et inversement. Si c'est le cas, le signal
|
||||||
|
EmptinessChanged() est emis.
|
||||||
*/
|
*/
|
||||||
void Diagram::write() {
|
void Diagram::slot_checkSelectionEmptinessChange() {
|
||||||
qDebug() << qPrintable(QString("Diagram::write() : saving changes from diagram \"%1\" [%2]").arg(title()).arg(QET::pointerString(this)));
|
static bool selection_was_empty = true;
|
||||||
write(toXml().documentElement());
|
bool selection_is_empty = selectedItems().isEmpty();
|
||||||
undoStack().setClean();
|
if (selection_was_empty != selection_is_empty) {
|
||||||
}
|
emit(selectionEmptinessChanged());
|
||||||
|
selection_was_empty = selection_is_empty;
|
||||||
/**
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Selectionne tous les objets du schema
|
|
||||||
*/
|
|
||||||
void Diagram::selectAll() {
|
|
||||||
if (items().isEmpty()) return;
|
|
||||||
|
|
||||||
blockSignals(true);
|
|
||||||
foreach(QGraphicsItem *qgi, items()) qgi -> setSelected(true);
|
|
||||||
blockSignals(false);
|
|
||||||
emit(selectionChanged());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Deslectionne tous les objets selectionnes
|
|
||||||
*/
|
|
||||||
void Diagram::deselectAll() {
|
|
||||||
if (items().isEmpty()) return;
|
|
||||||
|
|
||||||
clearSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Inverse l'etat de selection de tous les objets du schema
|
|
||||||
*/
|
|
||||||
void Diagram::invertSelection() {
|
|
||||||
if (items().isEmpty()) return;
|
|
||||||
|
|
||||||
blockSignals(true);
|
|
||||||
foreach (QGraphicsItem *item, items()) item -> setSelected(!item -> isSelected());
|
|
||||||
blockSignals(false);
|
|
||||||
emit(selectionChanged());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -778,29 +489,7 @@ QRectF Diagram::border() const {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// oublie la liste des elements et conducteurs en mouvement
|
||||||
@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() {
|
void Diagram::invalidateMovedElements() {
|
||||||
if (!moved_elements_fetched) return;
|
if (!moved_elements_fetched) return;
|
||||||
moved_elements_fetched = false;
|
moved_elements_fetched = false;
|
||||||
@@ -810,9 +499,7 @@ void Diagram::invalidateMovedElements() {
|
|||||||
texts_to_move.clear();
|
texts_to_move.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// reconstruit la liste des elements et conducteurs en mouvement
|
||||||
Reconstruit la liste des elements et conducteurs en mouvement
|
|
||||||
*/
|
|
||||||
void Diagram::fetchMovedElements() {
|
void Diagram::fetchMovedElements() {
|
||||||
// recupere les elements deplaces
|
// recupere les elements deplaces
|
||||||
foreach (QGraphicsItem *item, selectedItems()) {
|
foreach (QGraphicsItem *item, selectedItems()) {
|
||||||
@@ -861,7 +548,7 @@ void Diagram::moveElements(const QPointF &diff, QGraphicsItem *dontmove) {
|
|||||||
|
|
||||||
// deplace les elements selectionnes
|
// deplace les elements selectionnes
|
||||||
foreach(Element *element, elementsToMove()) {
|
foreach(Element *element, elementsToMove()) {
|
||||||
if (dontmove && element == dontmove) continue;
|
if (dontmove != NULL && element == dontmove) continue;
|
||||||
element -> setPos(element -> pos() + diff);
|
element -> setPos(element -> pos() + diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -878,43 +565,11 @@ void Diagram::moveElements(const QPointF &diff, QGraphicsItem *dontmove) {
|
|||||||
|
|
||||||
// deplace les champs de texte
|
// deplace les champs de texte
|
||||||
foreach(DiagramTextItem *dti, textsToMove()) {
|
foreach(DiagramTextItem *dti, textsToMove()) {
|
||||||
if (dontmove && dti == dontmove) continue;
|
if (dontmove != NULL && dti == dontmove) continue;
|
||||||
dti -> setPos(dti -> pos() + diff);
|
dti -> setPos(dti -> pos() + diff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param pos Position cartesienne (ex : 10.3, 45.2) a transformer en position
|
|
||||||
dans la grille (ex : B2)
|
|
||||||
@return la position dans la grille correspondant a pos
|
|
||||||
*/
|
|
||||||
DiagramPosition Diagram::convertPosition(const QPointF &pos) {
|
|
||||||
// decale la position pour prendre en compte les marges en haut a gauche du schema
|
|
||||||
QPointF final_pos = pos - QPointF(margin, margin);
|
|
||||||
|
|
||||||
// delegue le calcul au BorderInset
|
|
||||||
DiagramPosition diagram_position = border_and_inset.convertPosition(final_pos);
|
|
||||||
|
|
||||||
// embarque la position cartesienne
|
|
||||||
diagram_position.setPosition(pos);
|
|
||||||
|
|
||||||
return(diagram_position);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Definit s'il faut afficher ou non les bornes
|
Definit s'il faut afficher ou non les bornes
|
||||||
@param dt true pour afficher les bornes, false sinon
|
@param dt true pour afficher les bornes, false sinon
|
||||||
@@ -947,39 +602,6 @@ bool Diagram::clipboardMayContainDiagram() {
|
|||||||
return(may_be_diagram);
|
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
|
@return Le contenu du schema. Les conducteurs sont tous places dans
|
||||||
conductorsToMove.
|
conductorsToMove.
|
||||||
@@ -1024,20 +646,3 @@ DiagramContent Diagram::selectedContent() {
|
|||||||
invalidateMovedElements();
|
invalidateMovedElements();
|
||||||
return(dc);
|
return(dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
@return true s'il est possible de tourner les elements selectionnes.
|
|
||||||
Concretement, cette methode retourne true s'il y a des elements selectionnes
|
|
||||||
et qu'au moins l'un d'entre eux peut etre pivote.
|
|
||||||
*/
|
|
||||||
bool Diagram::canRotateSelection() const {
|
|
||||||
foreach(QGraphicsItem * qgi, selectedItems()) {
|
|
||||||
if (Element *e = qgraphicsitem_cast<Element *>(qgi)) {
|
|
||||||
// l'element est-il pivotable ?
|
|
||||||
if (e -> orientation().current() != e -> orientation().next()) {
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(false);
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -19,18 +19,15 @@
|
|||||||
#define SCHEMA_H
|
#define SCHEMA_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QtXml>
|
#include <QtXml>
|
||||||
|
#include "qetdiagrameditor.h"
|
||||||
#include "borderinset.h"
|
#include "borderinset.h"
|
||||||
#include "qgimanager.h"
|
#include "qgimanager.h"
|
||||||
#include "conductorproperties.h"
|
#include "conductorproperties.h"
|
||||||
class Element;
|
class Element;
|
||||||
class CustomElement;
|
|
||||||
class Terminal;
|
class Terminal;
|
||||||
class Conductor;
|
class Conductor;
|
||||||
class DiagramTextItem;
|
class DiagramTextItem;
|
||||||
class DiagramContent;
|
class DiagramContent;
|
||||||
class DiagramPosition;
|
|
||||||
class QETProject;
|
|
||||||
class ElementsLocation;
|
|
||||||
/**
|
/**
|
||||||
Cette classe represente un schema electrique.
|
Cette classe represente un schema electrique.
|
||||||
Elle gere les differents elements et conducteurs qui le composent
|
Elle gere les differents elements et conducteurs qui le composent
|
||||||
@@ -78,12 +75,9 @@ class Diagram : public QGraphicsScene {
|
|||||||
QSet<Conductor *> conductors_to_move;
|
QSet<Conductor *> conductors_to_move;
|
||||||
QHash<Conductor *, Terminal *> conductors_to_update;
|
QHash<Conductor *, Terminal *> conductors_to_update;
|
||||||
QSet<DiagramTextItem *> texts_to_move;
|
QSet<DiagramTextItem *> texts_to_move;
|
||||||
QGIManager *qgi_manager;
|
QGIManager qgi_manager;
|
||||||
QUndoStack *undo_stack;
|
QUndoStack undo_stack;
|
||||||
bool draw_terminals;
|
bool draw_terminals;
|
||||||
QDomDocument xml_document;
|
|
||||||
QETProject *project_;
|
|
||||||
bool read_only_;
|
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
protected:
|
protected:
|
||||||
@@ -94,14 +88,6 @@ class Diagram : public QGraphicsScene {
|
|||||||
public:
|
public:
|
||||||
static bool clipboardMayContainDiagram();
|
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
|
// fonctions relatives a la pose de conducteurs
|
||||||
void setConductor(bool);
|
void setConductor(bool);
|
||||||
void setConductorStart (QPointF);
|
void setConductorStart (QPointF);
|
||||||
@@ -109,22 +95,7 @@ class Diagram : public QGraphicsScene {
|
|||||||
|
|
||||||
// fonctions relatives a l'import / export XML
|
// fonctions relatives a l'import / export XML
|
||||||
QDomDocument toXml(bool = true);
|
QDomDocument toXml(bool = true);
|
||||||
bool initFromXml(QDomElement &, QPointF = QPointF(), bool = true, DiagramContent * = 0);
|
bool fromXml(QDomDocument &, QPointF = QPointF(), bool = true, DiagramContent * = NULL);
|
||||||
bool fromXml(QDomDocument &, QPointF = QPointF(), bool = true, DiagramContent * = 0);
|
|
||||||
bool fromXml(QDomElement &, QPointF = QPointF(), bool = true, DiagramContent * = 0);
|
|
||||||
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
|
// fonctions relatives aux options graphiques
|
||||||
void setDisplayGrid(bool);
|
void setDisplayGrid(bool);
|
||||||
@@ -133,19 +104,14 @@ class Diagram : public QGraphicsScene {
|
|||||||
bool useBorder();
|
bool useBorder();
|
||||||
void setBorderOptions(BorderOptions);
|
void setBorderOptions(BorderOptions);
|
||||||
BorderOptions borderOptions();
|
BorderOptions borderOptions();
|
||||||
DiagramPosition convertPosition(const QPointF &);
|
|
||||||
|
|
||||||
bool drawTerminals() const;
|
bool drawTerminals() const;
|
||||||
void setDrawTerminals(bool);
|
void setDrawTerminals(bool);
|
||||||
|
|
||||||
QRectF border() const;
|
QRectF border() const;
|
||||||
QString title() const;
|
|
||||||
bool toPaintDevice(QPaintDevice &, int = -1, int = -1, Qt::AspectRatioMode = Qt::KeepAspectRatio);
|
bool toPaintDevice(QPaintDevice &, int = -1, int = -1, Qt::AspectRatioMode = Qt::KeepAspectRatio);
|
||||||
QSize imageSize() const;
|
QSize imageSize() const;
|
||||||
|
|
||||||
bool isEmpty() const;
|
|
||||||
|
|
||||||
QList<CustomElement *> customElements() const;
|
|
||||||
void invalidateMovedElements();
|
void invalidateMovedElements();
|
||||||
void fetchMovedElements();
|
void fetchMovedElements();
|
||||||
const QSet<Element *> &elementsToMove();
|
const QSet<Element *> &elementsToMove();
|
||||||
@@ -155,28 +121,25 @@ class Diagram : public QGraphicsScene {
|
|||||||
QSet<Conductor *> selectedConductors() const;
|
QSet<Conductor *> selectedConductors() const;
|
||||||
DiagramContent content() const;
|
DiagramContent content() const;
|
||||||
DiagramContent selectedContent();
|
DiagramContent selectedContent();
|
||||||
bool canRotateSelection() const;
|
void moveElements(const QPointF &, QGraphicsItem * = NULL);
|
||||||
void moveElements(const QPointF &, QGraphicsItem * = 0);
|
|
||||||
bool usesElement(const ElementsLocation &);
|
|
||||||
|
|
||||||
QUndoStack &undoStack();
|
QUndoStack &undoStack();
|
||||||
QGIManager &qgiManager();
|
QGIManager &qgiManager();
|
||||||
|
|
||||||
public slots:
|
private slots:
|
||||||
void diagramTextChanged(DiagramTextItem *, const QString &, const QString &);
|
void slot_checkSelectionEmptinessChange();
|
||||||
|
|
||||||
// fonctions relative a la selection sur le schema
|
|
||||||
void selectAll();
|
|
||||||
void deselectAll();
|
|
||||||
void invertSelection();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void written();
|
/**
|
||||||
void readOnlyChanged(bool);
|
Ce signal est emis lorsque la selection passe de l'etat rempli (par un
|
||||||
|
nombre quelconque d'elements et conducteurs) a l'etat vide et
|
||||||
|
vice-versa.
|
||||||
|
*/
|
||||||
|
void selectionEmptinessChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
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
|
droite en pointilles qui apparait lorsqu'on pose un conducteur entre deux
|
||||||
bornes.
|
bornes.
|
||||||
@param pf true pour ajouter le poseur de conducteur, false pour l'enlever
|
@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
|
/// @return la pile d'annulations de ce schema
|
||||||
inline QUndoStack &Diagram::undoStack() {
|
inline QUndoStack &Diagram::undoStack() {
|
||||||
return(*undo_stack);
|
return(undo_stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return le egstionnaire de QGraphicsItem de ce schema
|
/// @return le egstionnaire de QGraphicsItem de ce schema
|
||||||
inline QGIManager &Diagram::qgiManager() {
|
inline QGIManager &Diagram::qgiManager() {
|
||||||
return(*qgi_manager);
|
return(qgi_manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return true si les bornes sont affichees, false sinon
|
/// @return true si les bornes sont affichees, false sinon
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -33,7 +33,7 @@ AddElementCommand::AddElementCommand(
|
|||||||
const QPointF &p,
|
const QPointF &p,
|
||||||
QUndoCommand *parent
|
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),
|
element(elmt),
|
||||||
diagram(d),
|
diagram(d),
|
||||||
position(p)
|
position(p)
|
||||||
@@ -48,12 +48,12 @@ AddElementCommand::~AddElementCommand() {
|
|||||||
|
|
||||||
/// Annule l'ajout
|
/// Annule l'ajout
|
||||||
void AddElementCommand::undo() {
|
void AddElementCommand::undo() {
|
||||||
diagram -> removeElement(element);
|
diagram -> removeItem(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refait l'ajout
|
/// Refait l'ajout
|
||||||
void AddElementCommand::redo() {
|
void AddElementCommand::redo() {
|
||||||
diagram -> addElement(element);
|
diagram -> addItem(element);
|
||||||
element -> setPos(position);
|
element -> setPos(position);
|
||||||
element -> setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
element -> setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,7 @@ void AddElementCommand::redo() {
|
|||||||
@param parent QUndoCommand parent
|
@param parent QUndoCommand parent
|
||||||
*/
|
*/
|
||||||
AddTextCommand::AddTextCommand(Diagram *dia, DiagramTextItem *text, const QPointF &pos, 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),
|
textitem(text),
|
||||||
diagram(dia),
|
diagram(dia),
|
||||||
position(pos)
|
position(pos)
|
||||||
@@ -81,12 +81,12 @@ AddTextCommand::~AddTextCommand() {
|
|||||||
|
|
||||||
/// Annule l'ajout
|
/// Annule l'ajout
|
||||||
void AddTextCommand::undo() {
|
void AddTextCommand::undo() {
|
||||||
diagram -> removeDiagramTextItem(textitem);
|
diagram -> removeItem(textitem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refait l'ajour
|
/// Refait l'ajour
|
||||||
void AddTextCommand::redo() {
|
void AddTextCommand::redo() {
|
||||||
diagram -> addDiagramTextItem(textitem);
|
diagram -> addItem(textitem);
|
||||||
textitem -> setPos(position);
|
textitem -> setPos(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ AddConductorCommand::AddConductorCommand(
|
|||||||
Conductor *c,
|
Conductor *c,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("ajouter un conducteur", "undo caption"), parent),
|
QUndoCommand(QObject::tr("ajouter un conducteur"), parent),
|
||||||
conductor(c),
|
conductor(c),
|
||||||
diagram(d)
|
diagram(d)
|
||||||
{
|
{
|
||||||
@@ -115,12 +115,15 @@ AddConductorCommand::~AddConductorCommand() {
|
|||||||
|
|
||||||
/// Annule l'ajout
|
/// Annule l'ajout
|
||||||
void AddConductorCommand::undo() {
|
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
|
/// Refait l'ajout
|
||||||
void AddConductorCommand::redo() {
|
void AddConductorCommand::redo() {
|
||||||
diagram -> addConductor(conductor);
|
diagram -> addItem(conductor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,14 +141,7 @@ DeleteElementsCommand::DeleteElementsCommand(
|
|||||||
removed_content(content),
|
removed_content(content),
|
||||||
diagram(dia)
|
diagram(dia)
|
||||||
{
|
{
|
||||||
setText(
|
setText(QObject::tr("supprimer ") + removed_content.sentence(DiagramContent::All));
|
||||||
QString(
|
|
||||||
QObject::tr(
|
|
||||||
"supprimer %1",
|
|
||||||
"undo caption - %1 is a sentence listing the removed content"
|
|
||||||
)
|
|
||||||
).arg(removed_content.sentence(DiagramContent::All))
|
|
||||||
);
|
|
||||||
diagram -> qgiManager().manage(removed_content.items(DiagramContent::All));
|
diagram -> qgiManager().manage(removed_content.items(DiagramContent::All));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,17 +154,19 @@ DeleteElementsCommand::~DeleteElementsCommand() {
|
|||||||
void DeleteElementsCommand::undo() {
|
void DeleteElementsCommand::undo() {
|
||||||
// remet les elements
|
// remet les elements
|
||||||
foreach(Element *e, removed_content.elements) {
|
foreach(Element *e, removed_content.elements) {
|
||||||
diagram -> addElement(e);
|
diagram -> addItem(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remet les conducteurs
|
// remet les conducteurs
|
||||||
foreach(Conductor *c, removed_content.conductors(DiagramContent::AnyConductor)) {
|
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
|
// remet les textes
|
||||||
foreach(DiagramTextItem *t, removed_content.textFields) {
|
foreach(DiagramTextItem *t, removed_content.textFields) {
|
||||||
diagram -> addDiagramTextItem(t);
|
diagram -> addItem(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,17 +174,19 @@ void DeleteElementsCommand::undo() {
|
|||||||
void DeleteElementsCommand::redo() {
|
void DeleteElementsCommand::redo() {
|
||||||
// enleve les conducteurs
|
// enleve les conducteurs
|
||||||
foreach(Conductor *c, removed_content.conductors(DiagramContent::AnyConductor)) {
|
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
|
// enleve les elements
|
||||||
foreach(Element *e, removed_content.elements) {
|
foreach(Element *e, removed_content.elements) {
|
||||||
diagram -> removeElement(e);
|
diagram -> removeItem(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// enleve les textes
|
// enleve les textes
|
||||||
foreach(DiagramTextItem *t, removed_content.textFields) {
|
foreach(DiagramTextItem *t, removed_content.textFields) {
|
||||||
diagram -> removeDiagramTextItem(t);
|
diagram -> removeItem(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,14 +208,7 @@ PasteDiagramCommand::PasteDiagramCommand(
|
|||||||
first_redo(true)
|
first_redo(true)
|
||||||
{
|
{
|
||||||
|
|
||||||
setText(
|
setText(QObject::tr("coller ") + content.sentence(filter));
|
||||||
QString(
|
|
||||||
QObject::tr(
|
|
||||||
"coller %1",
|
|
||||||
"undo caption - %1 is a sentence listing the content to paste"
|
|
||||||
).arg(content.sentence(filter))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
diagram -> qgiManager().manage(content.items(filter));
|
diagram -> qgiManager().manage(content.items(filter));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,13 +220,17 @@ PasteDiagramCommand::~PasteDiagramCommand() {
|
|||||||
/// annule le coller
|
/// annule le coller
|
||||||
void PasteDiagramCommand::undo() {
|
void PasteDiagramCommand::undo() {
|
||||||
// enleve les conducteurs
|
// 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
|
// enleve les elements
|
||||||
foreach(Element *e, content.elements) diagram -> removeElement(e);
|
foreach(Element *e, content.elements) diagram -> removeItem(e);
|
||||||
|
|
||||||
// enleve les textes
|
// enleve les textes
|
||||||
foreach(DiagramTextItem *t, content.textFields) diagram -> removeDiagramTextItem(t);
|
foreach(DiagramTextItem *t, content.textFields) diagram -> removeItem(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// refait le coller
|
/// refait le coller
|
||||||
@@ -241,13 +238,17 @@ void PasteDiagramCommand::redo() {
|
|||||||
if (first_redo) first_redo = false;
|
if (first_redo) first_redo = false;
|
||||||
else {
|
else {
|
||||||
// pose les elements
|
// pose les elements
|
||||||
foreach(Element *e, content.elements) diagram -> addElement(e);
|
foreach(Element *e, content.elements) diagram -> addItem(e);
|
||||||
|
|
||||||
// pose les conducteurs
|
// 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
|
// 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(Element *e, content.elements) e -> setSelected(true);
|
||||||
foreach(Conductor *c, content.conductorsToMove) c -> setSelected(true);
|
foreach(Conductor *c, content.conductorsToMove) c -> setSelected(true);
|
||||||
@@ -267,14 +268,7 @@ CutDiagramCommand::CutDiagramCommand(
|
|||||||
) :
|
) :
|
||||||
DeleteElementsCommand(dia, content, parent)
|
DeleteElementsCommand(dia, content, parent)
|
||||||
{
|
{
|
||||||
setText(
|
setText(QObject::tr("couper ") + content.sentence(DiagramContent::All));
|
||||||
QString(
|
|
||||||
QObject::tr(
|
|
||||||
"couper %1",
|
|
||||||
"undo caption - %1 is a sentence listing the content to cut"
|
|
||||||
).arg(content.sentence(DiagramContent::All))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
@@ -300,21 +294,7 @@ MoveElementsCommand::MoveElementsCommand(
|
|||||||
movement(m),
|
movement(m),
|
||||||
first_redo(true)
|
first_redo(true)
|
||||||
{
|
{
|
||||||
QString moved_content_sentence = content_to_move.sentence(
|
setText(QObject::tr("d\351placer ") + content_to_move.sentence(DiagramContent::Elements|DiagramContent::TextFields|DiagramContent::ConductorsToUpdate|DiagramContent::ConductorsToMove));
|
||||||
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)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
@@ -375,7 +355,7 @@ ChangeDiagramTextCommand::ChangeDiagramTextCommand(
|
|||||||
const QString &after,
|
const QString &after,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("modifier le texte", "undo caption"), parent),
|
QUndoCommand(QObject::tr("modifier le texte"), parent),
|
||||||
text_item(dti),
|
text_item(dti),
|
||||||
text_before(before),
|
text_before(before),
|
||||||
text_after(after),
|
text_after(after),
|
||||||
@@ -408,17 +388,9 @@ void ChangeDiagramTextCommand::redo() {
|
|||||||
@param parent QUndoCommand parent
|
@param parent QUndoCommand parent
|
||||||
*/
|
*/
|
||||||
RotateElementsCommand::RotateElementsCommand(const QHash<Element *, QET::Orientation> &elements, 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)
|
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
|
/// Destructeur
|
||||||
@@ -455,7 +427,7 @@ ChangeConductorCommand::ChangeConductorCommand(
|
|||||||
Qt::Corner path_t,
|
Qt::Corner path_t,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("modifier un conducteur", "undo caption"), parent),
|
QUndoCommand(QObject::tr("modifier un conducteur"), parent),
|
||||||
conductor(c),
|
conductor(c),
|
||||||
old_profile(old_p),
|
old_profile(old_p),
|
||||||
new_profile(new_p),
|
new_profile(new_p),
|
||||||
@@ -488,15 +460,9 @@ ResetConductorCommand::ResetConductorCommand(
|
|||||||
const QHash<Conductor *, ConductorProfilesGroup> &cp,
|
const QHash<Conductor *, ConductorProfilesGroup> &cp,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(parent),
|
QUndoCommand(QObject::tr("R\351initialiser ") + QET::ElementsAndConductorsSentence(0, cp.count()), parent),
|
||||||
conductors_profiles(cp)
|
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
|
/// Destructeur
|
||||||
@@ -530,7 +496,7 @@ ChangeInsetCommand::ChangeInsetCommand(
|
|||||||
const InsetProperties &new_ip,
|
const InsetProperties &new_ip,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("modifier le cartouche", "undo caption"), parent),
|
QUndoCommand(QObject::tr("modifier le cartouche"), parent),
|
||||||
diagram(d),
|
diagram(d),
|
||||||
old_inset(old_ip),
|
old_inset(old_ip),
|
||||||
new_inset(new_ip)
|
new_inset(new_ip)
|
||||||
@@ -558,11 +524,13 @@ void ChangeInsetCommand::redo() {
|
|||||||
@param dia Schema modifie
|
@param dia Schema modifie
|
||||||
@param parent QUndoCommand parent
|
@param parent QUndoCommand parent
|
||||||
*/
|
*/
|
||||||
ChangeBorderCommand::ChangeBorderCommand(Diagram *dia, const BorderProperties &old_bp, const BorderProperties &new_bp, QUndoCommand *parent) :
|
ChangeBorderCommand::ChangeBorderCommand(Diagram *dia, QUndoCommand *parent) :
|
||||||
QUndoCommand(QObject::tr("modifier les dimensions du sch\351ma", "undo caption"), parent),
|
QUndoCommand(QObject::tr("modifier les dimensions du sch\351ma"), parent),
|
||||||
diagram(dia),
|
diagram(dia),
|
||||||
old_properties(old_bp),
|
columnsCountDifference(0),
|
||||||
new_properties(new_bp)
|
columnsHeightDifference(0.0),
|
||||||
|
columnsWidthDifference(0.0),
|
||||||
|
headersHeightDifference(0.0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,14 +538,39 @@ ChangeBorderCommand::ChangeBorderCommand(Diagram *dia, const BorderProperties &o
|
|||||||
ChangeBorderCommand::~ChangeBorderCommand() {
|
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
|
/// Annule les changements apportes au schema
|
||||||
void ChangeBorderCommand::undo() {
|
void ChangeBorderCommand::undo() {
|
||||||
diagram -> border_and_inset.importBorder(old_properties);
|
applyChanges(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refait les changements apportes au schema
|
/// Refait les changements apportes au schema
|
||||||
void ChangeBorderCommand::redo() {
|
void ChangeBorderCommand::redo() {
|
||||||
diagram -> border_and_inset.importBorder(new_properties);
|
applyChanges(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -586,7 +579,7 @@ void ChangeBorderCommand::redo() {
|
|||||||
@param parent QUndoCommand parent
|
@param parent QUndoCommand parent
|
||||||
*/
|
*/
|
||||||
ChangeConductorPropertiesCommand::ChangeConductorPropertiesCommand(Conductor *c, 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),
|
conductor(c),
|
||||||
old_settings_set(false),
|
old_settings_set(false),
|
||||||
new_settings_set(false)
|
new_settings_set(false)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -22,9 +22,7 @@
|
|||||||
#include "diagramcontent.h"
|
#include "diagramcontent.h"
|
||||||
#include "diagramtextitem.h"
|
#include "diagramtextitem.h"
|
||||||
#include "conductor.h"
|
#include "conductor.h"
|
||||||
#include "borderproperties.h"
|
|
||||||
#include "conductorproperties.h"
|
#include "conductorproperties.h"
|
||||||
#include "insetproperties.h"
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
/**
|
/**
|
||||||
Cette classe represente l'action d'ajouter un element au schema
|
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 {
|
class ChangeBorderCommand : public QUndoCommand {
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
ChangeBorderCommand(Diagram *, const BorderProperties &, const BorderProperties &, QUndoCommand * = 0);
|
ChangeBorderCommand(Diagram *, QUndoCommand * = 0);
|
||||||
virtual ~ChangeBorderCommand();
|
virtual ~ChangeBorderCommand();
|
||||||
private:
|
private:
|
||||||
ChangeBorderCommand(const ChangeBorderCommand &);
|
ChangeBorderCommand(const ChangeBorderCommand &);
|
||||||
@@ -341,16 +343,22 @@ class ChangeBorderCommand : public QUndoCommand {
|
|||||||
public:
|
public:
|
||||||
virtual void undo();
|
virtual void undo();
|
||||||
virtual void redo();
|
virtual void redo();
|
||||||
|
private:
|
||||||
|
virtual void applyChanges(int = 1);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
/// schema modifie
|
/// schema modifie
|
||||||
Diagram *diagram;
|
Diagram *diagram;
|
||||||
public:
|
public:
|
||||||
/// anciennes dimensions du schema
|
/// nombre de colonnes ajoutees / enlevees
|
||||||
BorderProperties old_properties;
|
int columnsCountDifference;
|
||||||
/// nouvelles dimensions du schema
|
/// delta pour la hauteur des colonnes
|
||||||
BorderProperties new_properties;
|
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-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -54,11 +54,6 @@ QList<Conductor *> DiagramContent::conductors(int filter) const {
|
|||||||
if (filter & ConductorsToMove) result += conductorsToMove;
|
if (filter & ConductorsToMove) result += conductorsToMove;
|
||||||
if (filter & ConductorsToUpdate) result += conductorsToUpdate.keys();
|
if (filter & ConductorsToUpdate) result += conductorsToUpdate.keys();
|
||||||
if (filter & OtherConductors) result += otherConductors;
|
if (filter & OtherConductors) result += otherConductors;
|
||||||
if (filter & SelectedOnly) {
|
|
||||||
foreach(Conductor *conductor, result) {
|
|
||||||
if (!conductor -> isSelected()) result.removeOne(conductor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,11 +77,6 @@ QList<QGraphicsItem *> DiagramContent::items(int filter) const {
|
|||||||
foreach(QGraphicsItem *qgi, conductors(filter)) items_list << qgi;
|
foreach(QGraphicsItem *qgi, conductors(filter)) items_list << qgi;
|
||||||
if (filter & Elements) foreach(QGraphicsItem *qgi, elements) items_list << qgi;
|
if (filter & Elements) foreach(QGraphicsItem *qgi, elements) items_list << qgi;
|
||||||
if (filter & TextFields) foreach(QGraphicsItem *qgi, textFields) items_list << qgi;
|
if (filter & TextFields) foreach(QGraphicsItem *qgi, textFields) items_list << qgi;
|
||||||
if (filter & SelectedOnly) {
|
|
||||||
foreach(QGraphicsItem *qgi, items_list) {
|
|
||||||
if (!qgi -> isSelected()) items_list.removeOne(qgi);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(items_list);
|
return(items_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,19 +86,11 @@ QList<QGraphicsItem *> DiagramContent::items(int filter) const {
|
|||||||
*/
|
*/
|
||||||
int DiagramContent::count(int filter) const {
|
int DiagramContent::count(int filter) const {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (filter & SelectedOnly) {
|
if (filter & Elements) count += elements.count();
|
||||||
if (filter & Elements) foreach(Element *element, elements) { if (element -> isSelected()) ++ count; }
|
if (filter & TextFields) count += textFields.count();
|
||||||
if (filter & TextFields) foreach(DiagramTextItem *dti, textFields) { if (dti -> isSelected()) ++ count; }
|
if (filter & ConductorsToMove) count += conductorsToMove.count();
|
||||||
if (filter & ConductorsToMove) foreach(Conductor *conductor, conductorsToMove) { if (conductor -> isSelected()) ++ count; }
|
if (filter & ConductorsToUpdate) count += conductorsToUpdate.count();
|
||||||
if (filter & ConductorsToUpdate) foreach(Conductor *conductor, conductorsToUpdate.keys()) { if (conductor -> isSelected()) ++ count; }
|
if (filter & OtherConductors) count += otherConductors.count();
|
||||||
if (filter & OtherConductors) foreach(Conductor *conductor, otherConductors) { if (conductor -> isSelected()) ++ count; }
|
|
||||||
} else {
|
|
||||||
if (filter & Elements) count += elements.count();
|
|
||||||
if (filter & TextFields) count += textFields.count();
|
|
||||||
if (filter & ConductorsToMove) count += conductorsToMove.count();
|
|
||||||
if (filter & ConductorsToUpdate) count += conductorsToUpdate.count();
|
|
||||||
if (filter & OtherConductors) count += otherConductors.count();
|
|
||||||
}
|
|
||||||
return(count);
|
return(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,15 +119,12 @@ QString DiagramContent::sentence(int filter) const {
|
|||||||
@param d Object QDebug a utiliser pour l'affichage des informations de debug
|
@param d Object QDebug a utiliser pour l'affichage des informations de debug
|
||||||
@param c Contenu de schema a debugger
|
@param c Contenu de schema a debugger
|
||||||
*/
|
*/
|
||||||
QDebug &operator<<(QDebug d, DiagramContent &) {
|
QDebug &operator<<(QDebug d, DiagramContent &c) {
|
||||||
d << "DiagramContent {" << "\n";
|
d << "DiagramContent {" << "\n";
|
||||||
/*
|
|
||||||
FIXME Le double-heritage QObject / QGraphicsItem a casse cet operateur
|
|
||||||
d << " elements :" << c.elements << "\n";
|
d << " elements :" << c.elements << "\n";
|
||||||
d << " conductorsToUpdate :" << c.conductorsToUpdate.keys() << "\n";
|
d << " conductorsToUpdate :" << c.conductorsToUpdate.keys() << "\n";
|
||||||
d << " conductorsToMove :" << c.conductorsToMove << "\n";
|
d << " conductorsToMove :" << c.conductorsToMove << "\n";
|
||||||
d << " otherConductors :" << c.otherConductors << "\n";
|
d << " otherConductors :" << c.otherConductors << "\n";
|
||||||
*/
|
|
||||||
d << "}";
|
d << "}";
|
||||||
return(d.space());
|
return(d.space());
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -46,8 +46,7 @@ class DiagramContent {
|
|||||||
ConductorsToUpdate = 8,
|
ConductorsToUpdate = 8,
|
||||||
OtherConductors = 16,
|
OtherConductors = 16,
|
||||||
AnyConductor = 28,
|
AnyConductor = 28,
|
||||||
All = 31,
|
All = 31
|
||||||
SelectedOnly = 32
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Elements de texte du schema
|
/// Elements de texte du schema
|
||||||
302
diagramprintdialog.cpp
Normal file
302
diagramprintdialog.cpp
Normal file
@@ -0,0 +1,302 @@
|
|||||||
|
/*
|
||||||
|
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 "diagramprintdialog.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Constructeur
|
||||||
|
@param dia Schema a imprimer
|
||||||
|
@param printer Imprimante a utiliser
|
||||||
|
@param parent Widget parent du dialogue
|
||||||
|
*/
|
||||||
|
DiagramPrintDialog::DiagramPrintDialog(Diagram *dia, QWidget *parent) :
|
||||||
|
QWidget(parent),
|
||||||
|
diagram(dia),
|
||||||
|
dialog(0)
|
||||||
|
{
|
||||||
|
// initialise l'imprimante
|
||||||
|
printer = new QPrinter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructeur
|
||||||
|
*/
|
||||||
|
DiagramPrintDialog::~DiagramPrintDialog() {
|
||||||
|
delete dialog;
|
||||||
|
delete printer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Definit le nom du PDF si l'utilisateur choisit une sortie vers un PDF
|
||||||
|
*/
|
||||||
|
void DiagramPrintDialog::setPDFName(const QString &name) {
|
||||||
|
pdf_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return le nom du PDF
|
||||||
|
*/
|
||||||
|
QString DiagramPrintDialog::PDFName() const {
|
||||||
|
return(pdf_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Execute le dialogue d'impression
|
||||||
|
*/
|
||||||
|
void DiagramPrintDialog::exec() {
|
||||||
|
|
||||||
|
// affichage du dialogue d'impression standard
|
||||||
|
QPrintDialog print_dialog(printer);
|
||||||
|
print_dialog.setEnabledOptions(QAbstractPrintDialog::PrintToFile);
|
||||||
|
#ifndef Q_OS_WIN32
|
||||||
|
if (!pdf_name.isEmpty()) printer -> setOutputFileName(pdf_name);
|
||||||
|
#endif
|
||||||
|
if (print_dialog.exec() == QDialog::Rejected) return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Apres l'execution de ce premier dialogue, on connait le format papier a
|
||||||
|
utiliser, son orientation et on est sur que tout cela est supporte par
|
||||||
|
l'imprimante.
|
||||||
|
On peut donc en deduire le nombre de pages a imprimer
|
||||||
|
*/
|
||||||
|
|
||||||
|
// affichage d'un second dialogue, non standard, pour connaitre les pages a imprimer
|
||||||
|
buildDialog();
|
||||||
|
if (dialog -> exec() == QDialog::Rejected) return;
|
||||||
|
|
||||||
|
// effectue l'impression en elle-meme
|
||||||
|
print();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param fullPage true pour utiliser toute la feuille dans le calcul
|
||||||
|
@return Le nombre de pages necessaires pour imprimer le schema
|
||||||
|
avec l'orientation et le format papier utilise dans l'imprimante en cours.
|
||||||
|
*/
|
||||||
|
int DiagramPrintDialog::pagesCount(bool fullpage) const {
|
||||||
|
return(horizontalPagesCount(fullpage) * verticalPagesCount(fullpage));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param fullPage true pour utiliser toute la feuille dans le calcul
|
||||||
|
@return La largeur du "poster" en nombre de pages pour imprimer le schema
|
||||||
|
avec l'orientation et le format papier utilise dans l'imprimante en cours.
|
||||||
|
*/
|
||||||
|
int DiagramPrintDialog::horizontalPagesCount(bool fullpage) const {
|
||||||
|
// note : pageRect et Paper Rect tiennent compte de l'orientation du papier
|
||||||
|
QRect printable_area = fullpage ? printer -> paperRect() : printer -> pageRect();
|
||||||
|
QRect diagram_rect = diagram -> border().toRect();
|
||||||
|
|
||||||
|
int h_pages_count = int(ceil(qreal(diagram_rect.width()) / qreal(printable_area.width())));
|
||||||
|
return(h_pages_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param fullPage true pour utiliser toute la feuille dans le calcul
|
||||||
|
@return La largeur du "poster" en nombre de pages pour imprimer le schema
|
||||||
|
avec l'orientation et le format papier utilise dans l'imprimante en cours.
|
||||||
|
*/
|
||||||
|
int DiagramPrintDialog::verticalPagesCount(bool fullpage) const {
|
||||||
|
// note : pageRect et Paper Rect tiennent compte de l'orientation du papier
|
||||||
|
QRect printable_area = fullpage ? printer -> paperRect() : printer -> pageRect();
|
||||||
|
QRect diagram_rect = diagram -> border().toRect();
|
||||||
|
|
||||||
|
int v_pages_count = int(ceil(qreal(diagram_rect.height()) / qreal(printable_area.height())));
|
||||||
|
return(v_pages_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Construit un dialogue non standard pour demander les pages a imprimer a l'utilisateur
|
||||||
|
*/
|
||||||
|
void DiagramPrintDialog::buildDialog() {
|
||||||
|
dialog = new QDialog();
|
||||||
|
dialog -> setWindowTitle(tr("Options d'impression"));
|
||||||
|
options_label = new QLabel();
|
||||||
|
use_full_page = new QCheckBox(tr("Utiliser toute la feuille"));
|
||||||
|
fit_diagram_to_page = new QCheckBox(tr("Adapter le sch\351ma \340 la page"));
|
||||||
|
range_from_label = new QLabel(tr("Plage de "));
|
||||||
|
start_page = new QSpinBox();
|
||||||
|
to_label = new QLabel(tr(" \340 "));
|
||||||
|
end_page = new QSpinBox();
|
||||||
|
buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
|
QHBoxLayout *pages_layout = new QHBoxLayout();
|
||||||
|
pages_layout -> addWidget(range_from_label);
|
||||||
|
pages_layout -> addWidget(start_page);
|
||||||
|
pages_layout -> addWidget(to_label);
|
||||||
|
pages_layout -> addWidget(end_page);
|
||||||
|
|
||||||
|
QVBoxLayout *dialog_layout = new QVBoxLayout(dialog);
|
||||||
|
dialog_layout -> addWidget(options_label);
|
||||||
|
dialog_layout -> addWidget(use_full_page);
|
||||||
|
dialog_layout -> addWidget(fit_diagram_to_page);
|
||||||
|
dialog_layout -> addLayout(pages_layout);
|
||||||
|
dialog_layout -> addStretch();
|
||||||
|
dialog_layout -> addWidget(buttons);
|
||||||
|
|
||||||
|
connect(use_full_page, SIGNAL(stateChanged(int)), this, SLOT(updateDialog()));
|
||||||
|
connect(fit_diagram_to_page, SIGNAL(stateChanged(int)), this, SLOT(updateDialog()));
|
||||||
|
connect(start_page, SIGNAL(valueChanged(int)), this, SLOT(checkStartPage()));
|
||||||
|
connect(end_page, SIGNAL(valueChanged(int)), this, SLOT(checkEndPage()));
|
||||||
|
connect(buttons, SIGNAL(accepted()), dialog, SLOT(accept()));
|
||||||
|
connect(buttons, SIGNAL(rejected()), dialog, SLOT(reject()));
|
||||||
|
|
||||||
|
updateDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Assure la coherence du dialogue
|
||||||
|
*/
|
||||||
|
void DiagramPrintDialog::updateDialog() {
|
||||||
|
int pages_count;
|
||||||
|
// si on adapte le schema a la page, alors il n'y a qu'une page a imprimer
|
||||||
|
if (fit_diagram_to_page -> isChecked()) {
|
||||||
|
pages_count = 1;
|
||||||
|
} else {
|
||||||
|
pages_count = pagesCount(use_full_page -> isChecked());
|
||||||
|
}
|
||||||
|
options_label -> setText(tr("Nombre total de pages : ") + QString("%1").arg(pages_count));
|
||||||
|
setPagesRangeVisible(pages_count > 1);
|
||||||
|
start_page -> setRange(1, pages_count);
|
||||||
|
end_page -> setRange(1, pages_count);
|
||||||
|
end_page -> setValue(pages_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
S'assure que la premiere page ne soit pas superieure a la derniere page
|
||||||
|
*/
|
||||||
|
void DiagramPrintDialog::checkStartPage() {
|
||||||
|
if (start_page -> value() > end_page -> value()) {
|
||||||
|
start_page -> blockSignals(true);
|
||||||
|
start_page -> setValue(end_page -> value());
|
||||||
|
start_page -> blockSignals(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
S'assure que la derniere page ne soit pas inferieure a la premiere page
|
||||||
|
*/
|
||||||
|
void DiagramPrintDialog::checkEndPage() {
|
||||||
|
if (end_page -> value() < start_page -> value()) {
|
||||||
|
end_page -> blockSignals(true);
|
||||||
|
end_page -> setValue(start_page -> value());
|
||||||
|
end_page -> blockSignals(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param visible true pour afficher les pages, false sinon
|
||||||
|
*/
|
||||||
|
void DiagramPrintDialog::setPagesRangeVisible(bool visible) {
|
||||||
|
range_from_label -> setVisible(visible);
|
||||||
|
start_page -> setVisible(visible);
|
||||||
|
to_label -> setVisible(visible);
|
||||||
|
end_page -> setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Effectue l'impression elle-meme
|
||||||
|
*/
|
||||||
|
void DiagramPrintDialog::print() {
|
||||||
|
// recupere les informations collectees dans le second dialogue
|
||||||
|
bool full_page = use_full_page -> isChecked();
|
||||||
|
bool fit_page = fit_diagram_to_page -> isChecked();
|
||||||
|
int first_page = start_page -> value();
|
||||||
|
int last_page = end_page -> value();
|
||||||
|
|
||||||
|
// parametre l'imprimante
|
||||||
|
printer -> setFullPage(full_page);
|
||||||
|
|
||||||
|
// QPainter utiliser pour effectuer le rendu
|
||||||
|
QPainter qp(printer);
|
||||||
|
|
||||||
|
// impression physique (!= fichier PDF)
|
||||||
|
if (printer -> outputFileName().isEmpty()) {
|
||||||
|
// lorsqu'on imprime en paysage sur imprimante reelle, il faut pivoter soi-meme le rendu
|
||||||
|
if (printer -> orientation() == QPrinter::Landscape) {
|
||||||
|
qp.rotate(90.0);
|
||||||
|
qp.translate(0.0, -printer -> pageRect().height());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diagram -> setDisplayGrid(false);
|
||||||
|
diagram -> setDrawTerminals(false);
|
||||||
|
|
||||||
|
if (fit_page) {
|
||||||
|
// impression adaptee sur une seule page
|
||||||
|
diagram -> render(&qp, QRectF(), diagram -> border(), Qt::KeepAspectRatio);
|
||||||
|
} else {
|
||||||
|
// impression sur une ou plusieurs pages
|
||||||
|
QRect diagram_rect = diagram -> border().toRect();
|
||||||
|
QRect printed_area = full_page ? printer -> paperRect() : printer -> pageRect();
|
||||||
|
int used_width = printed_area.width();
|
||||||
|
int used_height = printed_area.height();
|
||||||
|
int h_pages_count = horizontalPagesCount(full_page);
|
||||||
|
int v_pages_count = verticalPagesCount(full_page);
|
||||||
|
|
||||||
|
QVector< QVector< QRect > > pages_grid;
|
||||||
|
// le schema est imprime sur une matrice de feuilles
|
||||||
|
// parcourt les lignes de la matrice
|
||||||
|
int y_offset = 0;
|
||||||
|
for (int i = 0 ; i < v_pages_count ; ++ i) {
|
||||||
|
pages_grid << QVector< QRect >();
|
||||||
|
|
||||||
|
// parcourt les feuilles de la ligne
|
||||||
|
int x_offset = 0;
|
||||||
|
for (int j = 0 ; j < h_pages_count ; ++ j) {
|
||||||
|
pages_grid.last() << QRect(
|
||||||
|
QPoint(x_offset, y_offset),
|
||||||
|
QSize(
|
||||||
|
qMin(used_width, diagram_rect.width() - x_offset),
|
||||||
|
qMin(used_height, diagram_rect.height() - y_offset)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
x_offset += used_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
y_offset += used_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ne retient que les pages a imprimer
|
||||||
|
QVector<QRect> pages_to_print;
|
||||||
|
for (int i = 0 ; i < v_pages_count ; ++ i) {
|
||||||
|
for (int j = 0 ; j < h_pages_count ; ++ j) {
|
||||||
|
int page_number = (i * h_pages_count) + j + 1;
|
||||||
|
if (page_number >= first_page && page_number <= last_page) {
|
||||||
|
pages_to_print << pages_grid.at(i).at(j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// parcourt les pages pour impression
|
||||||
|
for (int i = 0 ; i < pages_to_print.count() ; ++ i) {
|
||||||
|
QRect current_rect(pages_to_print.at(i));
|
||||||
|
diagram -> render(
|
||||||
|
&qp,
|
||||||
|
QRect(QPoint(0,0), current_rect.size()),
|
||||||
|
current_rect.translated(diagram_rect.topLeft()),
|
||||||
|
Qt::KeepAspectRatio
|
||||||
|
);
|
||||||
|
if (i != pages_to_print.count() - 1) {
|
||||||
|
printer -> newPage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diagram -> setDrawTerminals(true);
|
||||||
|
diagram -> setDisplayGrid(true);
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -14,11 +14,11 @@
|
|||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#ifndef DIAGRAM_PRINT_DIALOG_H
|
#ifndef DIAGRAM_PRINT_DIALOG_H
|
||||||
#define DIAGRAM_PRINT_DIALOG_H
|
#define DIAGRAM_PRINT_DIALOG_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "qetproject.h"
|
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
/**
|
/**
|
||||||
Cette classe represente le dialogue de configuration de l'impression d'un
|
Cette classe represente le dialogue de configuration de l'impression d'un
|
||||||
@@ -29,55 +29,43 @@ class DiagramPrintDialog : public QWidget {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// Constructeurs, destructeur
|
// Constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
DiagramPrintDialog(QETProject *, QWidget * = 0);
|
DiagramPrintDialog(Diagram *, QWidget * = 0);
|
||||||
virtual ~DiagramPrintDialog();
|
virtual ~DiagramPrintDialog();
|
||||||
private:
|
private:
|
||||||
DiagramPrintDialog(const DiagramPrintDialog &);
|
DiagramPrintDialog(const DiagramPrintDialog &);
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
void setFileName(const QString &);
|
void setPDFName(const QString &);
|
||||||
QString fileName() const;
|
QString PDFName() const;
|
||||||
void setDocName(const QString &);
|
int pagesCount(bool = false) const;
|
||||||
QString docName() const;
|
int horizontalPagesCount(bool = false) const;
|
||||||
int pagesCount(Diagram *, bool = false) const;
|
int verticalPagesCount(bool = false) const;
|
||||||
int horizontalPagesCount(Diagram *, bool = false) const;
|
|
||||||
int verticalPagesCount(Diagram *, bool = false) const;
|
|
||||||
void exec();
|
void exec();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void buildPrintTypeDialog();
|
|
||||||
void buildDialog();
|
void buildDialog();
|
||||||
|
void print();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void print(const QList<Diagram *> &, bool, QPrinter *);
|
void updateDialog();
|
||||||
void printDiagram(Diagram *, bool, QPainter *, QPrinter * = 0);
|
void checkStartPage();
|
||||||
void updatePrintTypeDialog();
|
void checkEndPage();
|
||||||
void acceptPrintTypeDialog();
|
void setPagesRangeVisible(bool);
|
||||||
void browseFilePrintTypeDialog();
|
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
QETProject *project_;
|
Diagram *diagram;
|
||||||
QPrinter *printer_;
|
QPrinter *printer;
|
||||||
QString doc_name_;
|
QString pdf_name;
|
||||||
QString file_name_;
|
QDialog *dialog;
|
||||||
|
QLabel *options_label;
|
||||||
/// Attributs relatifs au 1er dialogue
|
QLabel *range_from_label;
|
||||||
QDialog *dialog_;
|
QLabel *to_label;
|
||||||
QLabel *printtype_label_;
|
QCheckBox *use_full_page;
|
||||||
QGridLayout *glayout0_;
|
QCheckBox *fit_diagram_to_page;
|
||||||
QVBoxLayout *vlayout0_;
|
QSpinBox *start_page;
|
||||||
QHBoxLayout *hlayout0_;
|
QSpinBox *end_page;
|
||||||
QLabel *printer_icon_;
|
QDialogButtonBox *buttons;
|
||||||
QLabel *pdf_icon_;
|
|
||||||
QLabel *ps_icon_;
|
|
||||||
QButtonGroup *printtype_choice_;
|
|
||||||
QRadioButton *printer_choice_;
|
|
||||||
QRadioButton *pdf_choice_;
|
|
||||||
QRadioButton *ps_choice_;
|
|
||||||
QLineEdit *filepath_field_;
|
|
||||||
QPushButton *browse_button_;
|
|
||||||
QDialogButtonBox *buttons_;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "diagramtextitem.h"
|
#include "diagramtextitem.h"
|
||||||
#include "diagramcommands.h"
|
#include "diagramcommands.h"
|
||||||
#include "qetapp.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@@ -28,7 +27,6 @@ DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, QGraphicsScene *scene) :
|
|||||||
QGraphicsTextItem(parent, scene)
|
QGraphicsTextItem(parent, scene)
|
||||||
{
|
{
|
||||||
setDefaultTextColor(Qt::black);
|
setDefaultTextColor(Qt::black);
|
||||||
setFont(QETApp::diagramTextsFont());
|
|
||||||
setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
|
setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
|
||||||
connect(this, SIGNAL(lostFocus()), this, SLOT(setNonFocusable()));
|
connect(this, SIGNAL(lostFocus()), this, SLOT(setNonFocusable()));
|
||||||
}
|
}
|
||||||
@@ -44,7 +42,6 @@ DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, QGr
|
|||||||
previous_text(text)
|
previous_text(text)
|
||||||
{
|
{
|
||||||
setDefaultTextColor(Qt::black);
|
setDefaultTextColor(Qt::black);
|
||||||
setFont(QETApp::diagramTextsFont());
|
|
||||||
setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
|
setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
|
||||||
connect(this, SIGNAL(lostFocus()), this, SLOT(setNonFocusable()));
|
connect(this, SIGNAL(lostFocus()), this, SLOT(setNonFocusable()));
|
||||||
}
|
}
|
||||||
@@ -63,10 +60,12 @@ Diagram *DiagramTextItem::diagram() const {
|
|||||||
*/
|
*/
|
||||||
void DiagramTextItem::focusOutEvent(QFocusEvent *e) {
|
void DiagramTextItem::focusOutEvent(QFocusEvent *e) {
|
||||||
QGraphicsTextItem::focusOutEvent(e);
|
QGraphicsTextItem::focusOutEvent(e);
|
||||||
// signale la modification du texte si besoin
|
// si le texte a ete modifie
|
||||||
if (toPlainText() != previous_text) {
|
if (toPlainText() != previous_text) {
|
||||||
emit(diagramTextChanged(this, previous_text, toPlainText()));
|
if (Diagram *dia = diagram()) {
|
||||||
previous_text = toPlainText();
|
dia -> undoStack().push(new ChangeDiagramTextCommand(this, previous_text, toPlainText()));
|
||||||
|
previous_text = toPlainText();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// deselectionne le texte
|
// deselectionne le texte
|
||||||
@@ -99,8 +98,8 @@ void DiagramTextItem::fromXml(const QDomElement &e) {
|
|||||||
*/
|
*/
|
||||||
QDomElement DiagramTextItem::toXml(QDomDocument &document) const {
|
QDomElement DiagramTextItem::toXml(QDomDocument &document) const {
|
||||||
QDomElement result = document.createElement("input");
|
QDomElement result = document.createElement("input");
|
||||||
result.setAttribute("x", QString("%1").arg(pos().x()));
|
result.setAttribute("x", pos().x());
|
||||||
result.setAttribute("y", QString("%1").arg(pos().y()));
|
result.setAttribute("y", pos().y());
|
||||||
result.setAttribute("text", toPlainText());
|
result.setAttribute("text", toPlainText());
|
||||||
return(result);
|
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
|
Gere les mouvements de souris lies au champ de texte
|
||||||
*/
|
*/
|
||||||
@@ -175,9 +164,7 @@ void DiagramTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
}
|
}
|
||||||
diagram_ptr -> invalidateMovedElements();
|
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-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -52,7 +52,6 @@ class DiagramTextItem : public QGraphicsTextItem {
|
|||||||
protected:
|
protected:
|
||||||
virtual void focusOutEvent(QFocusEvent *);
|
virtual void focusOutEvent(QFocusEvent *);
|
||||||
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *);
|
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *);
|
||||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
|
|
||||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
||||||
|
|
||||||
@@ -60,9 +59,7 @@ class DiagramTextItem : public QGraphicsTextItem {
|
|||||||
signals:
|
signals:
|
||||||
/// signal emis lorsque le champ de texte perd le focus
|
/// signal emis lorsque le champ de texte perd le focus
|
||||||
void lostFocus();
|
void lostFocus();
|
||||||
/// signal emis lorsque le champ de texte a ete modifie
|
|
||||||
void diagramTextChanged(DiagramTextItem *, const QString &, const QString &);
|
|
||||||
|
|
||||||
// slots
|
// slots
|
||||||
public slots:
|
public slots:
|
||||||
void setNonFocusable();
|
void setNonFocusable();
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -18,12 +18,9 @@
|
|||||||
#ifndef DIAGRAMVIEW_H
|
#ifndef DIAGRAMVIEW_H
|
||||||
#define DIAGRAMVIEW_H
|
#define DIAGRAMVIEW_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "elementslocation.h"
|
|
||||||
class Conductor;
|
|
||||||
class Diagram;
|
class Diagram;
|
||||||
class DiagramTextItem;
|
|
||||||
class Element;
|
|
||||||
class QETDiagramEditor;
|
class QETDiagramEditor;
|
||||||
|
class Conductor;
|
||||||
/**
|
/**
|
||||||
Classe representant graphiquement un schema electrique
|
Classe representant graphiquement un schema electrique
|
||||||
*/
|
*/
|
||||||
@@ -32,37 +29,42 @@ class DiagramView : public QGraphicsView {
|
|||||||
|
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
DiagramView(Diagram * = 0, QWidget * = 0);
|
DiagramView(QWidget * = 0);
|
||||||
virtual ~DiagramView();
|
virtual ~DiagramView();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DiagramView(const DiagramView &);
|
DiagramView(const DiagramView &);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
|
public:
|
||||||
|
/// Nom de fichier du schema edite
|
||||||
|
QString file_name;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Diagram *scene;
|
Diagram *scene;
|
||||||
QMenu *context_menu;
|
QMenu *context_menu;
|
||||||
QAction *paste_here;
|
QAction *paste_here;
|
||||||
QAction *find_element_;
|
|
||||||
QPoint paste_here_pos;
|
QPoint paste_here_pos;
|
||||||
bool is_adding_text;
|
bool is_adding_text;
|
||||||
ElementsLocation next_location_;
|
|
||||||
QPoint next_position_;
|
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
QString title() const;
|
bool open(QString, int * = NULL);
|
||||||
void editDiagramProperties();
|
void closeEvent(QCloseEvent *);
|
||||||
|
bool save();
|
||||||
|
bool saveAs();
|
||||||
|
void dialogExport();
|
||||||
|
void dialogEditInfos();
|
||||||
|
void dialogPrint();
|
||||||
void addColumn();
|
void addColumn();
|
||||||
void removeColumn();
|
void removeColumn();
|
||||||
void addRow();
|
void expand();
|
||||||
void removeRow();
|
void shrink();
|
||||||
/// @return Le schema visualise par ce DiagramView
|
/// @return Le schema visualise par ce DiagramView
|
||||||
Diagram *diagram() { return(scene); }
|
Diagram *diagram() { return(scene); }
|
||||||
QETDiagramEditor *diagramEditor() const;
|
QETDiagramEditor *diagramEditor() const;
|
||||||
bool hasSelectedItems();
|
bool hasSelectedItems();
|
||||||
void addText();
|
void addText();
|
||||||
DiagramTextItem *addDiagramTextAtPos(const QPointF &);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mouseDoubleClickEvent(QMouseEvent *);
|
virtual void mouseDoubleClickEvent(QMouseEvent *);
|
||||||
@@ -71,14 +73,13 @@ class DiagramView : public QGraphicsView {
|
|||||||
virtual bool event(QEvent *);
|
virtual bool event(QEvent *);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool saveDiagramToFile(QString &);
|
||||||
void mousePressEvent(QMouseEvent *);
|
void mousePressEvent(QMouseEvent *);
|
||||||
void dragEnterEvent(QDragEnterEvent *);
|
void dragEnterEvent(QDragEnterEvent *);
|
||||||
void dragLeaveEvent(QDragLeaveEvent *);
|
void dragLeaveEvent(QDragLeaveEvent *);
|
||||||
void dragMoveEvent(QDragMoveEvent *);
|
void dragMoveEvent(QDragMoveEvent *);
|
||||||
void dropEvent(QDropEvent *);
|
void dropEvent(QDropEvent *);
|
||||||
QRectF viewedSceneRect() const;
|
QRectF viewedSceneRect() const;
|
||||||
bool mustIntegrateElement(const ElementsLocation &) const;
|
|
||||||
bool addElementAtPos(const ElementsLocation &, const QPoint &);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/// Signal emis lorsque la selection change
|
/// Signal emis lorsque la selection change
|
||||||
@@ -87,12 +88,6 @@ class DiagramView : public QGraphicsView {
|
|||||||
void modeChanged();
|
void modeChanged();
|
||||||
/// Signal emis lorsqu'un texte a ete pose
|
/// Signal emis lorsqu'un texte a ete pose
|
||||||
void textAdded(bool);
|
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();
|
|
||||||
/// Signal emis lorsque l'utilisateur souhaite retrouver un element du schema dans les collections
|
|
||||||
void findElementRequired(const ElementsLocation &);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void selectNothing();
|
void selectNothing();
|
||||||
@@ -112,16 +107,12 @@ class DiagramView : public QGraphicsView {
|
|||||||
void pasteHere();
|
void pasteHere();
|
||||||
void adjustSceneRect();
|
void adjustSceneRect();
|
||||||
void updateWindowTitle();
|
void updateWindowTitle();
|
||||||
void editSelectionProperties();
|
|
||||||
void editElement(Element *);
|
|
||||||
void editConductor();
|
void editConductor();
|
||||||
void editConductor(Conductor *);
|
void editConductor(Conductor *);
|
||||||
void resetConductors();
|
void resetConductors();
|
||||||
void editDefaultConductorProperties();
|
void editDefaultConductorProperties();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void addDroppedElement();
|
|
||||||
void adjustGridToZoom();
|
void adjustGridToZoom();
|
||||||
void applyReadOnly();
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -74,7 +74,6 @@ class CustomElementGraphicPart : public CustomElementPart {
|
|||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
virtual ~CustomElementGraphicPart() {
|
virtual ~CustomElementGraphicPart() {
|
||||||
if (style_editor -> parentWidget()) return; // l'editeur de style sera supprime par son parent
|
|
||||||
delete style_editor;
|
delete style_editor;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -29,7 +29,7 @@ DeletePartsCommand::DeletePartsCommand(
|
|||||||
const QList<QGraphicsItem *> parts,
|
const QList<QGraphicsItem *> parts,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("suppression", "undo caption"), parent),
|
QUndoCommand(QObject::tr("suppression"), parent),
|
||||||
deleted_parts(parts),
|
deleted_parts(parts),
|
||||||
editor_scene(scene)
|
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_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
editor_scene_ -> slot_select(content_);
|
|
||||||
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 ***/
|
/*** MovePartsCommand ***/
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@@ -161,7 +73,7 @@ MovePartsCommand::MovePartsCommand(
|
|||||||
const QList<QGraphicsItem *> parts,
|
const QList<QGraphicsItem *> parts,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("d\351placement", "undo caption"), parent),
|
QUndoCommand(QObject::tr("d\351placement"), parent),
|
||||||
movement(m),
|
movement(m),
|
||||||
first_redo(true)
|
first_redo(true)
|
||||||
{
|
{
|
||||||
@@ -202,7 +114,7 @@ AddPartCommand::AddPartCommand(
|
|||||||
QGraphicsItem *p,
|
QGraphicsItem *p,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QString(QObject::tr("ajout %1", "undo caption")).arg(name), parent),
|
QUndoCommand(QObject::tr("ajout ") + name, parent),
|
||||||
part(p),
|
part(p),
|
||||||
editor_scene(scene),
|
editor_scene(scene),
|
||||||
first_redo(true)
|
first_redo(true)
|
||||||
@@ -249,7 +161,7 @@ ChangePartCommand::ChangePartCommand(
|
|||||||
const QVariant &new_v,
|
const QVariant &new_v,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QString(QObject::tr("modification %1", "undo caption")).arg(name), parent),
|
QUndoCommand(QObject::tr("modification ") + name, parent),
|
||||||
cep(part),
|
cep(part),
|
||||||
property(prop),
|
property(prop),
|
||||||
old_value(old_v),
|
old_value(old_v),
|
||||||
@@ -284,7 +196,7 @@ ChangePolygonPointsCommand::ChangePolygonPointsCommand(
|
|||||||
const QVector<QPointF> &n_points,
|
const QVector<QPointF> &n_points,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("modification points polygone", "undo caption"), parent),
|
QUndoCommand(QObject::tr("modification points polygone"), parent),
|
||||||
polygon(p),
|
polygon(p),
|
||||||
old_points(o_points),
|
old_points(o_points),
|
||||||
new_points(n_points)
|
new_points(n_points)
|
||||||
@@ -324,7 +236,7 @@ ChangeHotspotCommand::ChangeHotspotCommand(
|
|||||||
const QPoint &o,
|
const QPoint &o,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("modification dimensions/hotspot", "undo caption"), parent),
|
QUndoCommand(QObject::tr("modification dimensions/hotspot"), parent),
|
||||||
element(element_scene),
|
element(element_scene),
|
||||||
size_before(size_1),
|
size_before(size_1),
|
||||||
size_after(size_2),
|
size_after(size_2),
|
||||||
@@ -385,7 +297,7 @@ ChangeNamesCommand::ChangeNamesCommand(
|
|||||||
const NamesList &after,
|
const NamesList &after,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("modification noms", "undo caption"), parent),
|
QUndoCommand(QObject::tr("modification noms"), parent),
|
||||||
names_before(before),
|
names_before(before),
|
||||||
names_after(after),
|
names_after(after),
|
||||||
element(element_scene)
|
element(element_scene)
|
||||||
@@ -419,7 +331,7 @@ ChangeOrientationsCommand::ChangeOrientationsCommand(
|
|||||||
const OrientationSet &after,
|
const OrientationSet &after,
|
||||||
QUndoCommand *parent
|
QUndoCommand *parent
|
||||||
) :
|
) :
|
||||||
QUndoCommand(QObject::tr("modification orientations", "undo caption"), parent),
|
QUndoCommand(QObject::tr("modification orientations"), parent),
|
||||||
ori_before(before),
|
ori_before(before),
|
||||||
ori_after(after),
|
ori_after(after),
|
||||||
element(element_scene)
|
element(element_scene)
|
||||||
@@ -463,16 +375,16 @@ ChangeZValueCommand::ChangeZValueCommand(
|
|||||||
|
|
||||||
// choisit le nom en fonction du traitement
|
// choisit le nom en fonction du traitement
|
||||||
if (option == BringForward) {
|
if (option == BringForward) {
|
||||||
setText(QObject::tr("amener au premier plan", "undo caption"));
|
setText(QObject::tr("amener au premier plan"));
|
||||||
applyBringForward(items_list);
|
applyBringForward(items_list);
|
||||||
} else if (option == Raise) {
|
} else if (option == Raise) {
|
||||||
setText(QObject::tr("rapprocher", "undo caption"));
|
setText(QObject::tr("rapprocher"));
|
||||||
applyRaise(items_list);
|
applyRaise(items_list);
|
||||||
} else if (option == Lower) {
|
} else if (option == Lower) {
|
||||||
setText(QObject::tr("\351loigner", "undo caption"));
|
setText(QObject::tr("\351loigner"));
|
||||||
applyLower(items_list);
|
applyLower(items_list);
|
||||||
} else if (option == SendBackward) {
|
} else if (option == SendBackward) {
|
||||||
setText(QObject::tr("envoyer au fond", "undo caption"));
|
setText(QObject::tr("envoyer au fond"));
|
||||||
applySendBackward(items_list);
|
applySendBackward(items_list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -571,7 +483,7 @@ void ChangeZValueCommand::applySendBackward(const QList<QGraphicsItem *> &items_
|
|||||||
@param parent QUndoCommand parent
|
@param parent QUndoCommand parent
|
||||||
*/
|
*/
|
||||||
AllowInternalConnectionsCommand::AllowInternalConnectionsCommand(ElementScene *elmt, bool allow, 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),
|
element(elmt),
|
||||||
ic(allow)
|
ic(allow)
|
||||||
{
|
{
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -19,9 +19,7 @@
|
|||||||
#define EDITOR_COMMANDS_H
|
#define EDITOR_COMMANDS_H
|
||||||
#include "customelementpart.h"
|
#include "customelementpart.h"
|
||||||
#include "partpolygon.h"
|
#include "partpolygon.h"
|
||||||
#include "elementview.h"
|
|
||||||
#include "elementscene.h"
|
#include "elementscene.h"
|
||||||
#include "elementcontent.h"
|
|
||||||
#include "qgimanager.h"
|
#include "qgimanager.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
/**
|
/**
|
||||||
@@ -49,52 +47,6 @@ class DeletePartsCommand : public QUndoCommand {
|
|||||||
ElementScene *editor_scene;
|
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
|
Cette classe represente l'action de deplacer une ou plusieurs
|
||||||
parties lors de l'edition d'un element
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -22,7 +22,7 @@ class QETElementEditor;
|
|||||||
class ElementScene;
|
class ElementScene;
|
||||||
class CustomElementPart;
|
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
|
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
|
a l'editeur, a la pile d'annulation, a la scene d'edition ou encore pour
|
||||||
ajouter facilement une annulation de type ChangePartCommand.
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
#include "qetelementeditor.h"
|
#include "qetelementeditor.h"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include "partline.h"
|
#include "partline.h"
|
||||||
#include "partrectangle.h"
|
|
||||||
#include "partellipse.h"
|
#include "partellipse.h"
|
||||||
#include "partcircle.h"
|
#include "partcircle.h"
|
||||||
#include "partpolygon.h"
|
#include "partpolygon.h"
|
||||||
@@ -29,7 +28,9 @@
|
|||||||
#include "partarc.h"
|
#include "partarc.h"
|
||||||
#include "hotspoteditor.h"
|
#include "hotspoteditor.h"
|
||||||
#include "editorcommands.h"
|
#include "editorcommands.h"
|
||||||
#include "elementcontent.h"
|
|
||||||
|
const int ElementScene::xGrid = 10;
|
||||||
|
const int ElementScene::yGrid = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@@ -46,8 +47,6 @@ ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
|
|||||||
element_editor(editor)
|
element_editor(editor)
|
||||||
{
|
{
|
||||||
current_polygon = NULL;
|
current_polygon = NULL;
|
||||||
setGrid(1, 1);
|
|
||||||
initPasteArea();
|
|
||||||
undo_stack.setClean();
|
undo_stack.setClean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,13 +68,6 @@ void ElementScene::slot_addLine() {
|
|||||||
behavior = Line;
|
behavior = Line;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Passe la scene en mode "ajout de rectangle"
|
|
||||||
*/
|
|
||||||
void ElementScene::slot_addRectangle() {
|
|
||||||
behavior = Rectangle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Passe la scene en mode "ajout de cercle"
|
Passe la scene en mode "ajout de cercle"
|
||||||
*/
|
*/
|
||||||
@@ -112,6 +104,7 @@ void ElementScene::slot_addTerminal() {
|
|||||||
behavior = Terminal;
|
behavior = Terminal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Passe la scene en mode "ajout d'arc de cercle"
|
Passe la scene en mode "ajout d'arc de cercle"
|
||||||
*/
|
*/
|
||||||
@@ -131,17 +124,7 @@ void ElementScene::slot_addTextField() {
|
|||||||
@param e objet decrivant l'evenement
|
@param e objet decrivant l'evenement
|
||||||
*/
|
*/
|
||||||
void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
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 != 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;
|
QRectF temp_rect;
|
||||||
qreal radius;
|
qreal radius;
|
||||||
QPointF temp_point;
|
QPointF temp_point;
|
||||||
@@ -149,26 +132,21 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
if (e -> buttons() & Qt::LeftButton) {
|
if (e -> buttons() & Qt::LeftButton) {
|
||||||
switch(behavior) {
|
switch(behavior) {
|
||||||
case Line:
|
case Line:
|
||||||
current_line -> setLine(QLineF(current_line -> line().p1(), event_pos));
|
current_line -> setLine(QLineF(current_line -> line().p1(), e -> scenePos()));
|
||||||
break;
|
|
||||||
case Rectangle:
|
|
||||||
temp_rect = current_rectangle -> rect();
|
|
||||||
temp_rect.setBottomRight(event_pos);
|
|
||||||
current_rectangle -> setRect(temp_rect);
|
|
||||||
break;
|
break;
|
||||||
case Ellipse:
|
case Ellipse:
|
||||||
temp_rect = current_ellipse -> rect();
|
temp_rect = current_ellipse -> rect();
|
||||||
temp_rect.setBottomRight(event_pos);
|
temp_rect.setBottomRight(e -> scenePos());
|
||||||
current_ellipse -> setRect(temp_rect);
|
current_ellipse -> setRect(temp_rect);
|
||||||
break;
|
break;
|
||||||
case Arc:
|
case Arc:
|
||||||
temp_rect = current_arc -> rect();
|
temp_rect = current_arc -> rect();
|
||||||
temp_rect.setBottomRight(event_pos);
|
temp_rect.setBottomRight(e -> scenePos());
|
||||||
current_arc -> setRect(temp_rect);
|
current_arc -> setRect(temp_rect);
|
||||||
break;
|
break;
|
||||||
case Circle:
|
case Circle:
|
||||||
temp_rect = current_circle -> rect();
|
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));
|
radius = sqrt(pow(temp_point.x(), 2) + pow(temp_point.y(), 2));
|
||||||
temp_rect = QRectF(
|
temp_rect = QRectF(
|
||||||
temp_rect.center() - QPointF(radius, radius),
|
temp_rect.center() - QPointF(radius, radius),
|
||||||
@@ -180,35 +158,17 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
if (current_polygon == NULL) break;
|
if (current_polygon == NULL) break;
|
||||||
temp_polygon = current_polygon -> polygon();
|
temp_polygon = current_polygon -> polygon();
|
||||||
temp_polygon.pop_back();
|
temp_polygon.pop_back();
|
||||||
temp_polygon << event_pos;
|
temp_polygon << e -> scenePos();
|
||||||
current_polygon -> setPolygon(temp_polygon);
|
current_polygon -> setPolygon(temp_polygon);
|
||||||
break;
|
break;
|
||||||
case Normal:
|
case Normal:
|
||||||
default:
|
default:
|
||||||
QList<QGraphicsItem *> selected_items = selectedItems();
|
QGraphicsScene::mouseMoveEvent(e);
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (behavior == Polygon && current_polygon != NULL) {
|
} else if (behavior == Polygon && current_polygon != NULL) {
|
||||||
temp_polygon = current_polygon -> polygon();
|
temp_polygon = current_polygon -> polygon();
|
||||||
temp_polygon.pop_back();
|
temp_polygon.pop_back();
|
||||||
temp_polygon << event_pos;
|
temp_polygon << e -> scenePos();
|
||||||
current_polygon -> setPolygon(temp_polygon);
|
current_polygon -> setPolygon(temp_polygon);
|
||||||
} else QGraphicsScene::mouseMoveEvent(e);
|
} else QGraphicsScene::mouseMoveEvent(e);
|
||||||
}
|
}
|
||||||
@@ -218,34 +178,27 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
@param e objet decrivant l'evenement
|
@param e objet decrivant l'evenement
|
||||||
*/
|
*/
|
||||||
void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
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;
|
if (behavior != Polygon && current_polygon != NULL) current_polygon = NULL;
|
||||||
QPolygonF temp_polygon;
|
QPolygonF temp_polygon;
|
||||||
if (e -> button() & Qt::LeftButton) {
|
if (e -> button() & Qt::LeftButton) {
|
||||||
switch(behavior) {
|
switch(behavior) {
|
||||||
case Line:
|
case Line:
|
||||||
current_line = new PartLine(element_editor, 0, this);
|
current_line = new PartLine(element_editor, 0, this);
|
||||||
current_line -> setLine(QLineF(event_pos, event_pos));
|
current_line -> setLine(QLineF(e -> scenePos(), e -> scenePos()));
|
||||||
break;
|
|
||||||
case Rectangle:
|
|
||||||
current_rectangle = new PartRectangle(element_editor, 0, this);
|
|
||||||
current_rectangle -> setRect(QRectF(event_pos, QSizeF(0.0, 0.0)));
|
|
||||||
break;
|
break;
|
||||||
case Ellipse:
|
case Ellipse:
|
||||||
current_ellipse = new PartEllipse(element_editor, 0, this);
|
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);
|
current_ellipse -> setProperty("antialias", true);
|
||||||
break;
|
break;
|
||||||
case Arc:
|
case Arc:
|
||||||
current_arc = new PartArc(element_editor, 0, this);
|
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);
|
current_arc -> setProperty("antialias", true);
|
||||||
break;
|
break;
|
||||||
case Circle:
|
case Circle:
|
||||||
current_circle = new PartCircle(element_editor, 0, this);
|
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);
|
current_circle -> setProperty("antialias", true);
|
||||||
break;
|
break;
|
||||||
case Polygon:
|
case Polygon:
|
||||||
@@ -254,23 +207,14 @@ void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
temp_polygon = QPolygonF(0);
|
temp_polygon = QPolygonF(0);
|
||||||
} else temp_polygon = current_polygon -> polygon();
|
} else temp_polygon = current_polygon -> polygon();
|
||||||
// au debut, on insere deux points
|
// au debut, on insere deux points
|
||||||
if (!temp_polygon.count()) temp_polygon << event_pos;
|
if (!temp_polygon.count()) temp_polygon << e -> scenePos();
|
||||||
temp_polygon << event_pos;
|
temp_polygon << e -> scenePos();
|
||||||
current_polygon -> setPolygon(temp_polygon);
|
current_polygon -> setPolygon(temp_polygon);
|
||||||
break;
|
break;
|
||||||
case Normal:
|
case Normal:
|
||||||
default:
|
default:
|
||||||
QGraphicsScene::mousePressEvent(e);
|
QGraphicsScene::mousePressEvent(e);
|
||||||
// gestion des deplacements de parties
|
if (!selectedItems().isEmpty()) fsi_pos = selectedItems().first() -> scenePos();
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else QGraphicsScene::mousePressEvent(e);
|
} else QGraphicsScene::mousePressEvent(e);
|
||||||
}
|
}
|
||||||
@@ -280,97 +224,71 @@ void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
@param e objet decrivant l'evenement
|
@param e objet decrivant l'evenement
|
||||||
*/
|
*/
|
||||||
void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
||||||
QPointF event_pos = e -> scenePos();
|
|
||||||
if (mustSnapToGrid(e)) snapToGrid(event_pos);
|
|
||||||
|
|
||||||
PartTerminal *terminal;
|
PartTerminal *terminal;
|
||||||
PartText *text;
|
PartText *text;
|
||||||
PartTextField *textfield;
|
PartTextField *textfield;
|
||||||
if (behavior != Polygon && current_polygon != NULL) current_polygon = NULL;
|
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) {
|
if (e -> button() & Qt::LeftButton) {
|
||||||
switch(behavior) {
|
switch(behavior) {
|
||||||
case Line:
|
case Line:
|
||||||
if (qgiManager().manages(current_line)) break;
|
if (qgiManager().manages(current_line)) break;
|
||||||
undo_stack.push(new AddPartCommand(tr("ligne"), this, current_line));
|
undo_stack.push(new AddPartCommand(tr("ligne"), this, current_line));
|
||||||
emit(partsAdded());
|
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;
|
break;
|
||||||
case Ellipse:
|
case Ellipse:
|
||||||
if (qgiManager().manages(current_ellipse)) break;
|
if (qgiManager().manages(current_ellipse)) break;
|
||||||
current_ellipse -> setRect(current_ellipse -> rect().normalized());
|
current_ellipse -> setRect(current_ellipse -> rect().normalized());
|
||||||
undo_stack.push(new AddPartCommand(tr("ellipse"), this, current_ellipse));
|
undo_stack.push(new AddPartCommand(tr("ellipse"), this, current_ellipse));
|
||||||
emit(partsAdded());
|
emit(partsAdded());
|
||||||
endCurrentBehavior(e);
|
|
||||||
break;
|
break;
|
||||||
case Arc:
|
case Arc:
|
||||||
if (qgiManager().manages(current_arc)) break;
|
if (qgiManager().manages(current_arc)) break;
|
||||||
current_arc-> setRect(current_arc -> rect().normalized());
|
current_arc-> setRect(current_arc -> rect().normalized());
|
||||||
undo_stack.push(new AddPartCommand(tr("arc"), this, current_arc));
|
undo_stack.push(new AddPartCommand(tr("arc"), this, current_arc));
|
||||||
emit(partsAdded());
|
emit(partsAdded());
|
||||||
endCurrentBehavior(e);
|
|
||||||
break;
|
break;
|
||||||
case Circle:
|
case Circle:
|
||||||
if (qgiManager().manages(current_circle)) break;
|
if (qgiManager().manages(current_circle)) break;
|
||||||
current_circle -> setRect(current_circle -> rect().normalized());
|
current_circle -> setRect(current_circle -> rect().normalized());
|
||||||
undo_stack.push(new AddPartCommand(tr("cercle"), this, current_circle));
|
undo_stack.push(new AddPartCommand(tr("cercle"), this, current_circle));
|
||||||
emit(partsAdded());
|
emit(partsAdded());
|
||||||
endCurrentBehavior(e);
|
|
||||||
break;
|
break;
|
||||||
case Terminal:
|
case Terminal:
|
||||||
terminal = new PartTerminal(element_editor, 0, this);
|
terminal = new PartTerminal(element_editor, 0, this);
|
||||||
terminal -> setPos(event_pos);
|
terminal -> setPos(e -> scenePos());
|
||||||
undo_stack.push(new AddPartCommand(tr("borne"), this, terminal));
|
undo_stack.push(new AddPartCommand(tr("borne"), this, terminal));
|
||||||
emit(partsAdded());
|
emit(partsAdded());
|
||||||
endCurrentBehavior(e);
|
|
||||||
break;
|
break;
|
||||||
case Text:
|
case Text:
|
||||||
text = new PartText(element_editor, 0, this);
|
text = new PartText(element_editor, 0, this);
|
||||||
text -> setPos(event_pos);
|
text -> setPos(e -> scenePos());
|
||||||
undo_stack.push(new AddPartCommand(tr("texte"), this, text));
|
undo_stack.push(new AddPartCommand(tr("texte"), this, text));
|
||||||
emit(partsAdded());
|
emit(partsAdded());
|
||||||
endCurrentBehavior(e);
|
|
||||||
break;
|
break;
|
||||||
case TextField:
|
case TextField:
|
||||||
textfield = new PartTextField(element_editor, 0, this);
|
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));
|
undo_stack.push(new AddPartCommand(tr("champ de texte"), this, textfield));
|
||||||
emit(partsAdded());
|
emit(partsAdded());
|
||||||
endCurrentBehavior(e);
|
|
||||||
break;
|
break;
|
||||||
case Normal:
|
case Normal:
|
||||||
default:
|
default:
|
||||||
|
QGraphicsScene::mouseReleaseEvent(e);
|
||||||
// detecte les deplacements de parties
|
// detecte les deplacements de parties
|
||||||
if (!selectedItems().isEmpty() && moving_parts_) {
|
if (!selectedItems().isEmpty()) {
|
||||||
QPointF movement = selectedItems().first() -> scenePos() - fsi_pos;
|
QPointF movement = selectedItems().first() -> scenePos() - fsi_pos;
|
||||||
if (!movement.isNull()) {
|
if (!movement.isNull()) {
|
||||||
undo_stack.push(new MovePartsCommand(movement, this, selectedItems()));
|
undo_stack.push(new MovePartsCommand(movement, this, selectedItems()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QGraphicsScene::mouseReleaseEvent(e);
|
|
||||||
moving_parts_ = false;
|
|
||||||
}
|
}
|
||||||
} else if (e -> button() & Qt::RightButton) {
|
} else if (e -> button() & Qt::RightButton) {
|
||||||
if (behavior == Polygon && current_polygon != NULL) {
|
if (behavior == Polygon && current_polygon != NULL) {
|
||||||
|
behavior = Normal;
|
||||||
undo_stack.push(new AddPartCommand(tr("polygone"), this, current_polygon));
|
undo_stack.push(new AddPartCommand(tr("polygone"), this, current_polygon));
|
||||||
current_polygon = NULL;
|
current_polygon = NULL;
|
||||||
emit(partsAdded());
|
emit(partsAdded());
|
||||||
endCurrentBehavior(e);
|
emit(needNormalMode());
|
||||||
} else QGraphicsScene::mouseReleaseEvent(e);
|
} else QGraphicsScene::mouseReleaseEvent(e);
|
||||||
} 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 -> setBrush(Qt::NoBrush);
|
||||||
p -> drawRect(drawable_area);
|
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) {
|
if (r.width() < 2500 && r.height() < 2500) {
|
||||||
// dessine les points de la grille
|
// dessine les points de la grille
|
||||||
p -> setPen(Qt::black);
|
p -> setPen(Qt::black);
|
||||||
@@ -411,12 +325,12 @@ void ElementScene::drawBackground(QPainter *p, const QRectF &r) {
|
|||||||
qreal limite_y = r.y() + r.height();
|
qreal limite_y = r.y() + r.height();
|
||||||
|
|
||||||
int g_x = (int)ceil(r.x());
|
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());
|
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 gx = g_x ; gx < limite_x ; gx += xGrid) {
|
||||||
for (int gy = g_y ; gy < limite_y ; gy += drawn_y_grid) {
|
for (int gy = g_y ; gy < limite_y ; gy += yGrid) {
|
||||||
p -> drawPoint(gx, gy);
|
p -> drawPoint(gx, gy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -444,50 +358,11 @@ void ElementScene::drawForeground(QPainter *p, const QRectF &) {
|
|||||||
p -> restore();
|
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
|
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
|
@return un document XML decrivant l'element
|
||||||
*/
|
*/
|
||||||
const QDomDocument ElementScene::toXml(bool all_parts) const {
|
const QDomDocument ElementScene::toXml() const {
|
||||||
// document XML
|
// document XML
|
||||||
QDomDocument xml_document;
|
QDomDocument xml_document;
|
||||||
|
|
||||||
@@ -508,8 +383,6 @@ const QDomDocument ElementScene::toXml(bool all_parts) const {
|
|||||||
QDomElement description = xml_document.createElement("description");
|
QDomElement description = xml_document.createElement("description");
|
||||||
// description de l'element
|
// description de l'element
|
||||||
foreach(QGraphicsItem *qgi, zItems(true)) {
|
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 (CustomElementPart *ce = dynamic_cast<CustomElementPart *>(qgi)) {
|
||||||
if (ce -> isUseless()) continue;
|
if (ce -> isUseless()) continue;
|
||||||
description.appendChild(ce -> toXml(xml_document));
|
description.appendChild(ce -> toXml(xml_document));
|
||||||
@@ -522,104 +395,91 @@ const QDomDocument ElementScene::toXml(bool all_parts) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param xml_document un document XML decrivant un element
|
Lit un element depuis un document XML
|
||||||
@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.
|
|
||||||
@param xml_document un document XML decrivant l'element
|
@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(
|
void ElementScene::fromXml(const QDomDocument &xml_document) {
|
||||||
const QDomDocument &xml_document,
|
|
||||||
const QPointF &position,
|
|
||||||
bool consider_informations,
|
|
||||||
ElementContent *content_ptr
|
|
||||||
) {
|
|
||||||
QString error_message;
|
QString error_message;
|
||||||
bool state = true;
|
bool state = true;
|
||||||
|
|
||||||
// prend en compte les informations de l'element
|
// la racine est supposee etre une definition d'element
|
||||||
if (consider_informations) {
|
QDomElement root = xml_document.documentElement();
|
||||||
state = applyInformations(xml_document, &error_message);
|
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
|
// parcours des enfants de la definition : parties de l'element
|
||||||
if (state) {
|
if (state) {
|
||||||
ElementContent loaded_content = loadContent(xml_document, &error_message);
|
for (QDomNode node = root.firstChild() ; !node.isNull() ; node = node.nextSibling()) {
|
||||||
if (position != QPointF()) {
|
QDomElement elmts = node.toElement();
|
||||||
addContentAtPos(loaded_content, position, &error_message);
|
if (elmts.isNull()) continue;
|
||||||
} else {
|
if (elmts.tagName() == "description") {
|
||||||
addContent(loaded_content, &error_message);
|
// gestion de la description graphique de l'element
|
||||||
}
|
// = parcours des differentes parties du dessin
|
||||||
|
int z = 1;
|
||||||
// renvoie le contenu ajoute a l'element
|
for (QDomNode n = node.firstChild() ; !n.isNull() ; n = n.nextSibling()) {
|
||||||
if (content_ptr) {
|
QDomElement qde = n.toElement();
|
||||||
*content_ptr = loaded_content;
|
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
|
@return un rectangle englobant toutes les parties ainsi que le
|
||||||
"bounding rect" de l'element
|
"bounding rect" de l'element
|
||||||
*/
|
*/
|
||||||
QRectF ElementScene::sceneContent() const {
|
QRectF ElementScene::sceneContent() const {
|
||||||
qreal adjustment = 5.0;
|
return(itemsBoundingRect().unite(QRectF(-_hotspot, QSizeF(width(), height()))));
|
||||||
return(itemsBoundingRect().unite(borderRect()).adjusted(-adjustment, -adjustment, adjustment, adjustment));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@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 true si l'element comporte au moins une borne, false s'il n'en a
|
|
||||||
aucune.
|
|
||||||
*/
|
|
||||||
bool ElementScene::containsTerminals() const {
|
|
||||||
foreach(QGraphicsItem *qgi,items()) {
|
|
||||||
if (qgraphicsitem_cast<PartTerminal *>(qgi)) {
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -636,80 +496,11 @@ QGIManager &ElementScene::qgiManager() {
|
|||||||
return(qgi_manager);
|
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 une liste de parties
|
|
||||||
@param content liste des parties a selectionner
|
|
||||||
*/
|
|
||||||
void ElementScene::slot_select(const ElementContent &content) {
|
|
||||||
blockSignals(true);
|
|
||||||
foreach(QGraphicsItem *qgi, content) qgi -> setSelected(true);
|
|
||||||
blockSignals(false);
|
|
||||||
emit(selectionChanged());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Selectionne tout
|
Selectionne tout
|
||||||
*/
|
*/
|
||||||
void ElementScene::slot_selectAll() {
|
void ElementScene::slot_selectAll() {
|
||||||
slot_select(items());
|
foreach(QGraphicsItem *qgi, items()) qgi -> setSelected(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -723,10 +514,7 @@ void ElementScene::slot_deselectAll() {
|
|||||||
Inverse la selection
|
Inverse la selection
|
||||||
*/
|
*/
|
||||||
void ElementScene::slot_invertSelection() {
|
void ElementScene::slot_invertSelection() {
|
||||||
blockSignals(true);
|
|
||||||
foreach(QGraphicsItem *qgi, items()) qgi -> setSelected(!qgi -> isSelected());
|
foreach(QGraphicsItem *qgi, items()) qgi -> setSelected(!qgi -> isSelected());
|
||||||
blockSignals(false);
|
|
||||||
emit(selectionChanged());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -748,9 +536,10 @@ void ElementScene::slot_delete() {
|
|||||||
*/
|
*/
|
||||||
void ElementScene::slot_editSizeHotSpot() {
|
void ElementScene::slot_editSizeHotSpot() {
|
||||||
// cree un dialogue
|
// cree un dialogue
|
||||||
QDialog dialog_sh(element_editor);
|
QDialog dialog_sh;
|
||||||
dialog_sh.setModal(true);
|
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);
|
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_sh);
|
||||||
|
|
||||||
// ajoute un HotspotEditor au dialogue
|
// ajoute un HotspotEditor au dialogue
|
||||||
@@ -787,10 +576,10 @@ void ElementScene::slot_editSizeHotSpot() {
|
|||||||
void ElementScene::slot_editOrientations() {
|
void ElementScene::slot_editOrientations() {
|
||||||
|
|
||||||
// cree un dialogue
|
// cree un dialogue
|
||||||
QDialog dialog_ori(element_editor);
|
QDialog dialog_ori;
|
||||||
dialog_ori.setModal(true);
|
dialog_ori.setModal(true);
|
||||||
dialog_ori.setMinimumSize(400, 260);
|
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);
|
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_ori);
|
||||||
|
|
||||||
// ajoute un champ explicatif au dialogue
|
// ajoute un champ explicatif au dialogue
|
||||||
@@ -833,10 +622,10 @@ void ElementScene::slot_editOrientations() {
|
|||||||
void ElementScene::slot_editNames() {
|
void ElementScene::slot_editNames() {
|
||||||
|
|
||||||
// cree un dialogue
|
// cree un dialogue
|
||||||
QDialog dialog(element_editor);
|
QDialog dialog;
|
||||||
dialog.setModal(true);
|
dialog.setModal(true);
|
||||||
dialog.setMinimumSize(400, 330);
|
dialog.setMinimumSize(400, 330);
|
||||||
dialog.setWindowTitle(tr("\311diter les noms", "window title"));
|
dialog.setWindowTitle(tr("\311diter les noms"));
|
||||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog);
|
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog);
|
||||||
|
|
||||||
// ajoute un champ explicatif au dialogue
|
// ajoute un champ explicatif au dialogue
|
||||||
@@ -928,30 +717,6 @@ QList<QGraphicsItem *> ElementScene::zItems(bool include_terminals) const {
|
|||||||
return(all_items_list);
|
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.
|
Supprime les parties de l'element et les objets d'annulations.
|
||||||
Les autres caracteristiques sont conservees.
|
Les autres caracteristiques sont conservees.
|
||||||
@@ -965,200 +730,3 @@ void ElementScene::reset() {
|
|||||||
qgiManager().release(qgi);
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -22,10 +22,8 @@
|
|||||||
#include "nameslistwidget.h"
|
#include "nameslistwidget.h"
|
||||||
#include "orientationsetwidget.h"
|
#include "orientationsetwidget.h"
|
||||||
#include "qgimanager.h"
|
#include "qgimanager.h"
|
||||||
#include "elementcontent.h"
|
|
||||||
class QETElementEditor;
|
class QETElementEditor;
|
||||||
class PartLine;
|
class PartLine;
|
||||||
class PartRectangle;
|
|
||||||
class PartEllipse;
|
class PartEllipse;
|
||||||
class PartCircle;
|
class PartCircle;
|
||||||
class PartPolygon;
|
class PartPolygon;
|
||||||
@@ -40,7 +38,7 @@ class ElementScene : public QGraphicsScene {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
// enum
|
// 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
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
@@ -51,6 +49,10 @@ class ElementScene : public QGraphicsScene {
|
|||||||
ElementScene(const ElementScene &);
|
ElementScene(const ElementScene &);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
|
public:
|
||||||
|
static const int xGrid; ///< Taille horizontale de la grille
|
||||||
|
static const int yGrid; ///< Taille verticale de la grille
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// longueur de l'element en dizaines de pixels
|
/// longueur de l'element en dizaines de pixels
|
||||||
uint _width;
|
uint _width;
|
||||||
@@ -70,31 +72,16 @@ class ElementScene : public QGraphicsScene {
|
|||||||
QUndoStack undo_stack;
|
QUndoStack undo_stack;
|
||||||
/// Position du premier item selectionne (utilise pour annuler les deplacements)
|
/// Position du premier item selectionne (utilise pour annuler les deplacements)
|
||||||
QPointF fsi_pos;
|
QPointF fsi_pos;
|
||||||
QPointF moving_press_pos;
|
|
||||||
bool moving_parts_;
|
|
||||||
|
|
||||||
/// Variables relatives a la gestion du dessin des parties sur la scene
|
/// Variables relatives a la gestion du dessin des parties sur la scene
|
||||||
Behavior behavior;
|
Behavior behavior;
|
||||||
PartLine *current_line;
|
PartLine *current_line;
|
||||||
PartRectangle *current_rectangle;
|
|
||||||
PartEllipse *current_ellipse;
|
PartEllipse *current_ellipse;
|
||||||
PartCircle *current_circle;
|
PartCircle *current_circle;
|
||||||
PartPolygon *current_polygon;
|
PartPolygon *current_polygon;
|
||||||
PartArc *current_arc;
|
PartArc *current_arc;
|
||||||
QETElementEditor *element_editor;
|
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
|
// methodes
|
||||||
public:
|
public:
|
||||||
void setWidth(const uint &);
|
void setWidth(const uint &);
|
||||||
@@ -109,27 +96,13 @@ class ElementScene : public QGraphicsScene {
|
|||||||
void setOrientations(const OrientationSet &);
|
void setOrientations(const OrientationSet &);
|
||||||
bool internalConnections();
|
bool internalConnections();
|
||||||
void setInternalConnections(bool);
|
void setInternalConnections(bool);
|
||||||
virtual int xGrid() const;
|
virtual const QDomDocument toXml() const;
|
||||||
virtual int yGrid() const;
|
virtual void fromXml(const QDomDocument &);
|
||||||
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 void reset();
|
virtual void reset();
|
||||||
virtual QList<QGraphicsItem *> zItems(bool = false) const;
|
virtual QList<QGraphicsItem *> zItems(bool = false) const;
|
||||||
virtual ElementContent selectedContent() const;
|
|
||||||
virtual void getPasteArea(const QRectF &);
|
|
||||||
QRectF borderRect() const;
|
|
||||||
QRectF sceneContent() const;
|
QRectF sceneContent() const;
|
||||||
bool borderContainsEveryParts() const;
|
|
||||||
bool containsTerminals() const;
|
|
||||||
QUndoStack &undoStack();
|
QUndoStack &undoStack();
|
||||||
QGIManager &qgiManager();
|
QGIManager &qgiManager();
|
||||||
static bool clipboardMayContainElement();
|
|
||||||
bool wasCopiedFromThisElement(const QString &);
|
|
||||||
void cut();
|
|
||||||
void copy();
|
|
||||||
void paste();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||||
@@ -137,22 +110,10 @@ class ElementScene : public QGraphicsScene {
|
|||||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
||||||
virtual void drawBackground(QPainter *, const QRectF &);
|
virtual void drawBackground(QPainter *, const QRectF &);
|
||||||
virtual void drawForeground(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:
|
public slots:
|
||||||
void slot_move();
|
void slot_move();
|
||||||
void slot_addLine();
|
void slot_addLine();
|
||||||
void slot_addRectangle();
|
|
||||||
void slot_addCircle();
|
void slot_addCircle();
|
||||||
void slot_addEllipse();
|
void slot_addEllipse();
|
||||||
void slot_addPolygon();
|
void slot_addPolygon();
|
||||||
@@ -160,7 +121,6 @@ class ElementScene : public QGraphicsScene {
|
|||||||
void slot_addArc();
|
void slot_addArc();
|
||||||
void slot_addTerminal();
|
void slot_addTerminal();
|
||||||
void slot_addTextField();
|
void slot_addTextField();
|
||||||
void slot_select(const ElementContent &);
|
|
||||||
void slot_selectAll();
|
void slot_selectAll();
|
||||||
void slot_deselectAll();
|
void slot_deselectAll();
|
||||||
void slot_invertSelection();
|
void slot_invertSelection();
|
||||||
@@ -185,8 +145,6 @@ class ElementScene : public QGraphicsScene {
|
|||||||
void partsRemoved();
|
void partsRemoved();
|
||||||
/// Signal emis lorsque la zValue d'une ou plusieurs parties change
|
/// Signal emis lorsque la zValue d'une ou plusieurs parties change
|
||||||
void partsZValueChanged();
|
void partsZValueChanged();
|
||||||
/// Signal emis lorsque l'utilisateur a fini de choisir une zone pour un copier/coller
|
|
||||||
void pasteAreaDefined(const QRectF &);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
128
editor/elementview.cpp
Normal file
128
editor/elementview.cpp
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
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);
|
||||||
|
setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
||||||
|
zoomReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Agrandit le schema (+33% = inverse des -25 % de zoomMoins())
|
||||||
|
*/
|
||||||
|
void ElementView::zoomIn() {
|
||||||
|
scale(4.0/3.0, 4.0/3.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Retrecit le schema (-25% = inverse des +33 % de zoomPlus())
|
||||||
|
*/
|
||||||
|
void ElementView::zoomOut() {
|
||||||
|
scale(0.75, 0.75);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Agrandit ou rectrecit le schema de facon a ce que tous les elements du
|
||||||
|
schema soient visibles a l'ecran. S'il n'y a aucun element sur le schema,
|
||||||
|
le zoom est reinitialise
|
||||||
|
*/
|
||||||
|
void ElementView::zoomFit() {
|
||||||
|
adjustSceneRect();
|
||||||
|
fitInView(sceneRect(), Qt::KeepAspectRatio);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reinitialise le zoom
|
||||||
|
*/
|
||||||
|
void ElementView::zoomReset() {
|
||||||
|
resetMatrix();
|
||||||
|
scale(4.0, 4.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Ajuste le sceneRect (zone du schema visualisee par l'ElementView) afin que
|
||||||
|
celui inclut a la fois les parties dans et en dehors du cadre et le cadre
|
||||||
|
lui-meme.
|
||||||
|
*/
|
||||||
|
void ElementView::adjustSceneRect() {
|
||||||
|
QRectF old_scene_rect = scene_ -> sceneRect();
|
||||||
|
QRectF new_scene_rect = scene_ -> sceneContent();
|
||||||
|
setSceneRect(new_scene_rect);
|
||||||
|
|
||||||
|
// met a jour la scene
|
||||||
|
scene_ -> update(old_scene_rect.united(new_scene_rect));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gere les actions liees a la rollette de la souris
|
||||||
|
@param e QWheelEvent decrivant l'evenement rollette
|
||||||
|
*/
|
||||||
|
void ElementView::wheelEvent(QWheelEvent *e) {
|
||||||
|
// si la touche Ctrl est enfoncee, on zoome / dezoome
|
||||||
|
if (e -> modifiers() & Qt::ControlModifier) {
|
||||||
|
if (e -> delta() > 0) {
|
||||||
|
zoomIn();
|
||||||
|
} else {
|
||||||
|
zoomOut();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
QAbstractScrollArea::wheelEvent(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -25,8 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
class ElementView : public QGraphicsView {
|
class ElementView : public QGraphicsView {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
friend class PastePartsCommand;
|
|
||||||
|
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
ElementView(ElementScene *, QWidget * = 0);
|
ElementView(ElementScene *, QWidget * = 0);
|
||||||
@@ -39,16 +37,9 @@ class ElementView : public QGraphicsView {
|
|||||||
public:
|
public:
|
||||||
ElementScene *scene() const;
|
ElementScene *scene() const;
|
||||||
void setScene(ElementScene *);
|
void setScene(ElementScene *);
|
||||||
QRectF viewedSceneRect() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent *);
|
bool event(QEvent *);
|
||||||
void mousePressEvent(QMouseEvent *);
|
|
||||||
void wheelEvent(QWheelEvent *);
|
void wheelEvent(QWheelEvent *);
|
||||||
virtual void drawBackground(QPainter *, const QRectF &);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QRectF applyMovement(const QRectF &, const QET::OrientedMovement &, const QPointF &);
|
|
||||||
|
|
||||||
// slots
|
// slots
|
||||||
public slots:
|
public slots:
|
||||||
@@ -57,23 +48,9 @@ class ElementView : public QGraphicsView {
|
|||||||
void zoomFit();
|
void zoomFit();
|
||||||
void zoomReset();
|
void zoomReset();
|
||||||
void adjustSceneRect();
|
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
|
//attributs
|
||||||
private:
|
private:
|
||||||
ElementScene *scene_;
|
ElementScene *scene_;
|
||||||
QString to_paste_in_area_;
|
|
||||||
int offset_paste_count_;
|
|
||||||
QPointF start_top_left_corner_;
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -63,9 +63,9 @@ EllipseEditor::~EllipseEditor() {
|
|||||||
*/
|
*/
|
||||||
void EllipseEditor::updateEllipse() {
|
void EllipseEditor::updateEllipse() {
|
||||||
part -> setProperty("x", x -> text().toDouble());
|
part -> setProperty("x", x -> text().toDouble());
|
||||||
part -> setProperty("y", y -> text().toDouble());
|
part -> setProperty("y", x -> text().toDouble());
|
||||||
part -> setProperty("diameter_h", h -> text().toDouble());
|
part -> setProperty("diameter_h", x -> text().toDouble());
|
||||||
part -> setProperty("diameter_v", v -> 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
|
/// 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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -37,8 +37,6 @@ class LineEditor : public ElementItemEditor {
|
|||||||
private:
|
private:
|
||||||
PartLine *part;
|
PartLine *part;
|
||||||
QLineEdit *x1, *y1, *x2, *y2;
|
QLineEdit *x1, *y1, *x2, *y2;
|
||||||
QComboBox *end1_type, *end2_type;
|
|
||||||
QLineEdit *end1_length, *end2_length;
|
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public slots:
|
public slots:
|
||||||
@@ -47,10 +45,6 @@ class LineEditor : public ElementItemEditor {
|
|||||||
void updateLineY1();
|
void updateLineY1();
|
||||||
void updateLineX2();
|
void updateLineX2();
|
||||||
void updateLineY2();
|
void updateLineY2();
|
||||||
void updateLineEndType1();
|
|
||||||
void updateLineEndLength1();
|
|
||||||
void updateLineEndType2();
|
|
||||||
void updateLineEndLength2();
|
|
||||||
void updateForm();
|
void updateForm();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -48,14 +48,11 @@ PartArc::~PartArc() {
|
|||||||
@param options Options pour affiner le rendu
|
@param options Options pour affiner le rendu
|
||||||
@param widget Widget sur lequel le rendu est effectue
|
@param widget Widget sur lequel le rendu est effectue
|
||||||
*/
|
*/
|
||||||
void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *) {
|
void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
||||||
applyStylesToQPainter(*painter);
|
applyStylesToQPainter(*painter);
|
||||||
// enleve systematiquement la couleur de fond
|
// enleve systematiquement la couleur de fond
|
||||||
painter -> setBrush(Qt::NoBrush);
|
painter -> setBrush(Qt::NoBrush);
|
||||||
QPen t = painter -> pen();
|
QPen t = painter -> pen();
|
||||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
|
||||||
painter -> setPen(t);
|
|
||||||
|
|
||||||
if (isSelected()) {
|
if (isSelected()) {
|
||||||
// dessine l'ellipse en noir
|
// dessine l'ellipse en noir
|
||||||
painter -> drawEllipse(rect());
|
painter -> drawEllipse(rect());
|
||||||
@@ -64,7 +61,6 @@ void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
|||||||
t.setColor(Qt::red);
|
t.setColor(Qt::red);
|
||||||
painter -> setPen(t);
|
painter -> setPen(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
painter -> drawArc(rect(), start_angle * 16, _angle * 16);
|
painter -> drawArc(rect(), start_angle * 16, _angle * 16);
|
||||||
if (isSelected()) {
|
if (isSelected()) {
|
||||||
// dessine la croix au centre de l'ellipse
|
// dessine la croix au centre de l'ellipse
|
||||||
@@ -84,12 +80,12 @@ void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
|||||||
const QDomElement PartArc::toXml(QDomDocument &xml_document) const {
|
const QDomElement PartArc::toXml(QDomDocument &xml_document) const {
|
||||||
QDomElement xml_element = xml_document.createElement("arc");
|
QDomElement xml_element = xml_document.createElement("arc");
|
||||||
QPointF top_left(sceneTopLeft());
|
QPointF top_left(sceneTopLeft());
|
||||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
xml_element.setAttribute("x", top_left.x());
|
||||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
xml_element.setAttribute("y", top_left.y());
|
||||||
xml_element.setAttribute("width", QString("%1").arg(rect().width()));
|
xml_element.setAttribute("width", rect().width());
|
||||||
xml_element.setAttribute("height", QString("%1").arg(rect().height()));
|
xml_element.setAttribute("height", rect().height());
|
||||||
xml_element.setAttribute("start", QString("%1").arg(start_angle));
|
xml_element.setAttribute("start", start_angle);
|
||||||
xml_element.setAttribute("angle", QString("%1").arg(_angle));
|
xml_element.setAttribute("angle", _angle);
|
||||||
stylesToXml(xml_element);
|
stylesToXml(xml_element);
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
@@ -163,7 +159,6 @@ void PartArc::setProperty(const QString &property, const QVariant &value) {
|
|||||||
} else if (property == "angle") {
|
} else if (property == "angle") {
|
||||||
setAngle(value.toInt());
|
setAngle(value.toInt());
|
||||||
}
|
}
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -48,7 +48,7 @@ class PartArc : public QGraphicsEllipseItem, public CustomElementGraphicPart {
|
|||||||
*/
|
*/
|
||||||
virtual int type() const { return Type; }
|
virtual int type() const { return Type; }
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
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 const QDomElement toXml(QDomDocument &) const;
|
||||||
virtual void fromXml(const QDomElement &);
|
virtual void fromXml(const QDomElement &);
|
||||||
virtual QPointF sceneTopLeft() const;
|
virtual QPointF sceneTopLeft() const;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -43,14 +43,13 @@ PartCircle::~PartCircle() {
|
|||||||
@param options Options pour affiner le rendu
|
@param options Options pour affiner le rendu
|
||||||
@param widget Widget sur lequel le rendu est effectue
|
@param widget Widget sur lequel le rendu est effectue
|
||||||
*/
|
*/
|
||||||
void PartCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *) {
|
void PartCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
||||||
applyStylesToQPainter(*painter);
|
applyStylesToQPainter(*painter);
|
||||||
QPen t = painter -> pen();
|
QPen t = painter -> pen();
|
||||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
|
||||||
if (isSelected()) {
|
if (isSelected()) {
|
||||||
t.setColor(Qt::red);
|
t.setColor(Qt::red);
|
||||||
|
painter -> setPen(t);
|
||||||
}
|
}
|
||||||
painter -> setPen(t);
|
|
||||||
painter -> drawEllipse(rect());
|
painter -> drawEllipse(rect());
|
||||||
if (isSelected()) {
|
if (isSelected()) {
|
||||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
@@ -69,9 +68,9 @@ void PartCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *option
|
|||||||
const QDomElement PartCircle::toXml(QDomDocument &xml_document) const {
|
const QDomElement PartCircle::toXml(QDomDocument &xml_document) const {
|
||||||
QDomElement xml_element = xml_document.createElement("circle");
|
QDomElement xml_element = xml_document.createElement("circle");
|
||||||
QPointF top_left(sceneTopLeft());
|
QPointF top_left(sceneTopLeft());
|
||||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
xml_element.setAttribute("x", top_left.x());
|
||||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
xml_element.setAttribute("y", top_left.y());
|
||||||
xml_element.setAttribute("diameter", QString("%1").arg(rect().width()));
|
xml_element.setAttribute("diameter", rect().width());
|
||||||
stylesToXml(xml_element);
|
stylesToXml(xml_element);
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
@@ -126,7 +125,6 @@ void PartCircle::setProperty(const QString &property, const QVariant &value) {
|
|||||||
current_rect.setSize(QSizeF(new_diameter, new_diameter));
|
current_rect.setSize(QSizeF(new_diameter, new_diameter));
|
||||||
setRect(current_rect);
|
setRect(current_rect);
|
||||||
}
|
}
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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 int type() const { return Type; }
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
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 const QDomElement toXml(QDomDocument &) const;
|
||||||
virtual void fromXml(const QDomElement &);
|
virtual void fromXml(const QDomElement &);
|
||||||
virtual QPointF sceneTopLeft() const;
|
virtual QPointF sceneTopLeft() const;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -43,14 +43,13 @@ PartEllipse::~PartEllipse() {
|
|||||||
@param options Options pour affiner le rendu
|
@param options Options pour affiner le rendu
|
||||||
@param widget Widget sur lequel le rendu est effectue
|
@param widget Widget sur lequel le rendu est effectue
|
||||||
*/
|
*/
|
||||||
void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *) {
|
void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
||||||
applyStylesToQPainter(*painter);
|
applyStylesToQPainter(*painter);
|
||||||
QPen t = painter -> pen();
|
QPen t = painter -> pen();
|
||||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
|
||||||
if (isSelected()) {
|
if (isSelected()) {
|
||||||
t.setColor(Qt::red);
|
t.setColor(Qt::red);
|
||||||
|
painter -> setPen(t);
|
||||||
}
|
}
|
||||||
painter -> setPen(t);
|
|
||||||
painter -> drawEllipse(rect());
|
painter -> drawEllipse(rect());
|
||||||
if (isSelected()) {
|
if (isSelected()) {
|
||||||
painter -> setRenderHint(QPainter::Antialiasing, false);
|
painter -> setRenderHint(QPainter::Antialiasing, false);
|
||||||
@@ -69,10 +68,10 @@ void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
|||||||
const QDomElement PartEllipse::toXml(QDomDocument &xml_document) const {
|
const QDomElement PartEllipse::toXml(QDomDocument &xml_document) const {
|
||||||
QDomElement xml_element = xml_document.createElement("ellipse");
|
QDomElement xml_element = xml_document.createElement("ellipse");
|
||||||
QPointF top_left(sceneTopLeft());
|
QPointF top_left(sceneTopLeft());
|
||||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
xml_element.setAttribute("x", top_left.x());
|
||||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
xml_element.setAttribute("y", top_left.y());
|
||||||
xml_element.setAttribute("width", QString("%1").arg(rect().width()));
|
xml_element.setAttribute("width", rect().width());
|
||||||
xml_element.setAttribute("height", QString("%1").arg(rect().height()));
|
xml_element.setAttribute("height", rect().height());
|
||||||
stylesToXml(xml_element);
|
stylesToXml(xml_element);
|
||||||
return(xml_element);
|
return(xml_element);
|
||||||
}
|
}
|
||||||
@@ -130,7 +129,6 @@ void PartEllipse::setProperty(const QString &property, const QVariant &value) {
|
|||||||
current_rect.setHeight(new_height);
|
current_rect.setHeight(new_height);
|
||||||
setRect(current_rect);
|
setRect(current_rect);
|
||||||
}
|
}
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -46,7 +46,7 @@ class PartEllipse : public QGraphicsEllipseItem, public CustomElementGraphicPart
|
|||||||
*/
|
*/
|
||||||
virtual int type() const { return Type; }
|
virtual int type() const { return Type; }
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
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 const QDomElement toXml(QDomDocument &) const;
|
||||||
virtual void fromXml(const QDomElement &);
|
virtual void fromXml(const QDomElement &);
|
||||||
virtual QPointF sceneTopLeft() const;
|
virtual QPointF sceneTopLeft() const;
|
||||||
253
editor/partline.cpp
Normal file
253
editor/partline.cpp
Normal file
@@ -0,0 +1,253 @@
|
|||||||
|
/*
|
||||||
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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
|
You should have received a copy of the GNU General Public License
|
||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef PART_RECTANGLE_H
|
#ifndef PART_LINE_H
|
||||||
#define PART_RECTANGLE_H
|
#define PART_LINE_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "customelementgraphicpart.h"
|
#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.
|
dessin d'un element dans l'editeur d'element.
|
||||||
*/
|
*/
|
||||||
class PartRectangle : public QGraphicsRectItem, public CustomElementGraphicPart {
|
class PartLine : public QGraphicsLineItem, public CustomElementGraphicPart {
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
PartRectangle(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
PartLine(QETElementEditor *, QGraphicsItem * = 0, QGraphicsScene * = 0);
|
||||||
virtual ~PartRectangle();
|
virtual ~PartLine();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PartRectangle(const PartRectangle &);
|
PartLine(const PartLine &);
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
RectangleEditor *informations;
|
LineEditor *informations;
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
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
|
@return le type de QGraphicsItem
|
||||||
*/
|
*/
|
||||||
virtual int type() const { return Type; }
|
virtual int type() const { return Type; }
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0);
|
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 const QDomElement toXml(QDomDocument &) const;
|
||||||
virtual void fromXml(const QDomElement &);
|
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 QRectF boundingRect() const;
|
||||||
virtual void setProperty(const QString &, const QVariant &);
|
virtual void setProperty(const QString &, const QVariant &);
|
||||||
virtual QVariant property(const QString &);
|
virtual QVariant property(const QString &);
|
||||||
@@ -57,5 +59,8 @@ class PartRectangle : public QGraphicsRectItem, public CustomElementGraphicPart
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QList<QPointF> fourShapePoints() const;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -94,12 +94,13 @@ const QDomElement PartPolygon::toXml(QDomDocument &xml_document) const {
|
|||||||
@param options Options pour affiner le rendu
|
@param options Options pour affiner le rendu
|
||||||
@param widget Widget sur lequel le rendu est effectue
|
@param widget Widget sur lequel le rendu est effectue
|
||||||
*/
|
*/
|
||||||
void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *) {
|
void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) {
|
||||||
applyStylesToQPainter(*painter);
|
applyStylesToQPainter(*painter);
|
||||||
QPen t = painter -> pen();
|
QPen t = painter -> pen();
|
||||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
if (isSelected()) {
|
||||||
if (isSelected()) t.setColor(Qt::red);
|
t.setColor(Qt::red);
|
||||||
painter -> setPen(t);
|
painter -> setPen(t);
|
||||||
|
}
|
||||||
if (closed) painter -> drawPolygon(polygon());
|
if (closed) painter -> drawPolygon(polygon());
|
||||||
else painter -> drawPolyline(polygon());
|
else painter -> drawPolyline(polygon());
|
||||||
}
|
}
|
||||||
@@ -113,7 +114,6 @@ void PartPolygon::paint(QPainter *painter, const QStyleOptionGraphicsItem *optio
|
|||||||
void PartPolygon::setProperty(const QString &property, const QVariant &value) {
|
void PartPolygon::setProperty(const QString &property, const QVariant &value) {
|
||||||
CustomElementGraphicPart::setProperty(property, value);
|
CustomElementGraphicPart::setProperty(property, value);
|
||||||
if (property == "closed") closed = value.toBool();
|
if (property == "closed") closed = value.toBool();
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -58,7 +58,7 @@ class PartPolygon : public QGraphicsPolygonItem, public CustomElementGraphicPart
|
|||||||
@return le type de QGraphicsItem
|
@return le type de QGraphicsItem
|
||||||
*/
|
*/
|
||||||
virtual int type() const { return Type; }
|
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 &);
|
void fromXml(const QDomElement &);
|
||||||
const QDomElement toXml(QDomDocument &) const;
|
const QDomElement toXml(QDomDocument &) const;
|
||||||
virtual QRectF boundingRect() const;
|
virtual QRectF boundingRect() const;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -39,7 +39,6 @@ PartTerminal::PartTerminal(QETElementEditor *editor, QGraphicsItem *parent, QGra
|
|||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
PartTerminal::~PartTerminal() {
|
PartTerminal::~PartTerminal() {
|
||||||
if (informations -> parentWidget()) return; // le widget sera supprime par son parent
|
|
||||||
delete informations;
|
delete informations;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -90,7 +89,7 @@ QWidget *PartTerminal::elementInformations() {
|
|||||||
@param options Options pour affiner le rendu
|
@param options Options pour affiner le rendu
|
||||||
@param widget Widget sur lequel le rendu est effectue
|
@param widget Widget sur lequel le rendu est effectue
|
||||||
*/
|
*/
|
||||||
void PartTerminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, QWidget *) {
|
void PartTerminal::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) {
|
||||||
p -> save();
|
p -> save();
|
||||||
|
|
||||||
// annulation des renderhints
|
// annulation des renderhints
|
||||||
@@ -100,7 +99,6 @@ void PartTerminal::paint(QPainter *p, const QStyleOptionGraphicsItem *options, Q
|
|||||||
|
|
||||||
QPen t;
|
QPen t;
|
||||||
t.setWidthF(1.0);
|
t.setWidthF(1.0);
|
||||||
t.setCosmetic(options && options -> levelOfDetail < 1.0);
|
|
||||||
|
|
||||||
// dessin de la borne en rouge
|
// dessin de la borne en rouge
|
||||||
t.setColor(isSelected() ? Terminal::couleur_neutre : Qt::red);
|
t.setColor(isSelected() ? Terminal::couleur_neutre : Qt::red);
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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
|
@return le type de QGraphicsItem
|
||||||
*/
|
*/
|
||||||
virtual int type() const { return Type; }
|
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 void fromXml(const QDomElement &);
|
||||||
virtual const QDomElement toXml(QDomDocument &) const;
|
virtual const QDomElement toXml(QDomDocument &) const;
|
||||||
virtual QWidget *elementInformations();
|
virtual QWidget *elementInformations();
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -32,16 +32,15 @@ PartText::PartText(QETElementEditor *editor, QGraphicsItem *parent, ElementScene
|
|||||||
CustomElementPart(editor)
|
CustomElementPart(editor)
|
||||||
{
|
{
|
||||||
setDefaultTextColor(Qt::black);
|
setDefaultTextColor(Qt::black);
|
||||||
setFont(QETApp::diagramTextsFont());
|
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
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 = new TextEditor(elementEditor(), this);
|
||||||
infos -> setElementTypeName(name());
|
infos -> setElementTypeName(name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
PartText::~PartText() {
|
PartText::~PartText() {
|
||||||
if (infos -> parentWidget()) return; // le widget sera supprime par son parent
|
|
||||||
delete infos;
|
delete infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +53,7 @@ void PartText::fromXml(const QDomElement &xml_element) {
|
|||||||
int font_size = xml_element.attribute("size").toInt(&ok);
|
int font_size = xml_element.attribute("size").toInt(&ok);
|
||||||
if (!ok || font_size < 1) font_size = 20;
|
if (!ok || font_size < 1) font_size = 20;
|
||||||
|
|
||||||
setFont(QETApp::diagramTextsFont(font_size));
|
setFont(QFont(QString(QETApp::diagramTextsFont()), font_size));
|
||||||
setPlainText(xml_element.attribute("text"));
|
setPlainText(xml_element.attribute("text"));
|
||||||
setPos(
|
setPos(
|
||||||
xml_element.attribute("x").toDouble(),
|
xml_element.attribute("x").toDouble(),
|
||||||
@@ -131,7 +130,7 @@ void PartText::focusOutEvent(QFocusEvent *e) {
|
|||||||
if (previous_text != toPlainText()) {
|
if (previous_text != toPlainText()) {
|
||||||
undoStack().push(
|
undoStack().push(
|
||||||
new ChangePartCommand(
|
new ChangePartCommand(
|
||||||
TextEditor::tr("contenu") + " " + name(),
|
TextEditor::tr("texte") + " " + name(),
|
||||||
this,
|
this,
|
||||||
"text",
|
"text",
|
||||||
previous_text,
|
previous_text,
|
||||||
@@ -140,13 +139,6 @@ void PartText::focusOutEvent(QFocusEvent *e) {
|
|||||||
);
|
);
|
||||||
previous_text = toPlainText();
|
previous_text = toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
// deselectionne le texte
|
|
||||||
QTextCursor qtc = textCursor();
|
|
||||||
qtc.clearSelection();
|
|
||||||
setTextCursor(qtc);
|
|
||||||
|
|
||||||
setTextInteractionFlags(Qt::NoTextInteraction);
|
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,11 +172,10 @@ void PartText::setProperty(const QString &property, const QVariant &value) {
|
|||||||
setPos(pos().x(), value.toDouble());
|
setPos(pos().x(), value.toDouble());
|
||||||
} else if (property == "size") {
|
} else if (property == "size") {
|
||||||
if (!value.canConvert(QVariant::Int)) return;
|
if (!value.canConvert(QVariant::Int)) return;
|
||||||
setFont(QETApp::diagramTextsFont(value.toInt()));
|
setFont(QFont(font().family(), value.toInt()));
|
||||||
} else if (property == "text") {
|
} else if (property == "text") {
|
||||||
setPlainText(value.toString());
|
setPlainText(value.toString());
|
||||||
}
|
}
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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
|
@return le type de QGraphicsItem
|
||||||
*/
|
*/
|
||||||
virtual int type() const { return Type; }
|
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 &);
|
void fromXml(const QDomElement &);
|
||||||
const QDomElement toXml(QDomDocument &) const;
|
const QDomElement toXml(QDomDocument &) const;
|
||||||
QWidget *elementInformations();
|
QWidget *elementInformations();
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -32,16 +32,14 @@ PartTextField::PartTextField(QETElementEditor *editor, QGraphicsItem *parent, QG
|
|||||||
follow_parent_rotations(true)
|
follow_parent_rotations(true)
|
||||||
{
|
{
|
||||||
setDefaultTextColor(Qt::black);
|
setDefaultTextColor(Qt::black);
|
||||||
setFont(QETApp::diagramTextsFont());
|
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
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 = new TextFieldEditor(elementEditor(), this);
|
||||||
infos -> setElementTypeName(name());
|
infos -> setElementTypeName(name());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
PartTextField::~PartTextField() {
|
PartTextField::~PartTextField() {
|
||||||
if (infos -> parentWidget()) return; // le widget sera supprime par son parent
|
|
||||||
delete infos;
|
delete infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +52,7 @@ void PartTextField::fromXml(const QDomElement &xml_element) {
|
|||||||
int font_size = xml_element.attribute("size").toInt(&ok);
|
int font_size = xml_element.attribute("size").toInt(&ok);
|
||||||
if (!ok || font_size < 1) font_size = 20;
|
if (!ok || font_size < 1) font_size = 20;
|
||||||
|
|
||||||
setFont(QETApp::diagramTextsFont(font_size));
|
setFont(QFont(QString(QETApp::diagramTextsFont()), font_size));
|
||||||
setPlainText(xml_element.attribute("text"));
|
setPlainText(xml_element.attribute("text"));
|
||||||
setPos(
|
setPos(
|
||||||
xml_element.attribute("x").toDouble(),
|
xml_element.attribute("x").toDouble(),
|
||||||
@@ -150,7 +148,7 @@ void PartTextField::focusOutEvent(QFocusEvent *e) {
|
|||||||
if (previous_text != toPlainText()) {
|
if (previous_text != toPlainText()) {
|
||||||
undoStack().push(
|
undoStack().push(
|
||||||
new ChangePartCommand(
|
new ChangePartCommand(
|
||||||
TextFieldEditor::tr("contenu") + " " + name(),
|
TextFieldEditor::tr("texte") + " " + name(),
|
||||||
this,
|
this,
|
||||||
"text",
|
"text",
|
||||||
previous_text,
|
previous_text,
|
||||||
@@ -159,13 +157,6 @@ void PartTextField::focusOutEvent(QFocusEvent *e) {
|
|||||||
);
|
);
|
||||||
previous_text = toPlainText();
|
previous_text = toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
// deselectionne le texte
|
|
||||||
QTextCursor qtc = textCursor();
|
|
||||||
qtc.clearSelection();
|
|
||||||
setTextCursor(qtc);
|
|
||||||
|
|
||||||
setTextInteractionFlags(Qt::NoTextInteraction);
|
|
||||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,13 +191,12 @@ void PartTextField::setProperty(const QString &property, const QVariant &value)
|
|||||||
setPos(pos().x(), value.toDouble());
|
setPos(pos().x(), value.toDouble());
|
||||||
} else if (property == "size") {
|
} else if (property == "size") {
|
||||||
if (!value.canConvert(QVariant::Int)) return;
|
if (!value.canConvert(QVariant::Int)) return;
|
||||||
setFont(QETApp::diagramTextsFont(value.toInt()));
|
setFont(QFont(font().family(), value.toInt()));
|
||||||
} else if (property == "text") {
|
} else if (property == "text") {
|
||||||
setPlainText(value.toString());
|
setPlainText(value.toString());
|
||||||
} else if (property == "rotate") {
|
} else if (property == "rotate") {
|
||||||
follow_parent_rotations = value.toBool();
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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
|
@return le type de QGraphicsItem
|
||||||
*/
|
*/
|
||||||
virtual int type() const { return Type; }
|
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 &);
|
void fromXml(const QDomElement &);
|
||||||
const QDomElement toXml(QDomDocument &) const;
|
const QDomElement toXml(QDomDocument &) const;
|
||||||
QWidget *elementInformations();
|
QWidget *elementInformations();
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -69,8 +69,8 @@ void PolygonEditor::updatePolygonPoints() {
|
|||||||
if (points.count() < 2) {
|
if (points.count() < 2) {
|
||||||
QMessageBox::warning(
|
QMessageBox::warning(
|
||||||
this,
|
this,
|
||||||
tr("Erreur", "message box title"),
|
tr("Erreur"),
|
||||||
tr("Le polygone doit comporter au moins deux points.", "message box content")
|
tr("Le polygone doit comporter au moins deux points.")
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ void PolygonEditor::updatePolygonClosedState() {
|
|||||||
*/
|
*/
|
||||||
void PolygonEditor::updateForm() {
|
void PolygonEditor::updateForm() {
|
||||||
activeConnections(false);
|
activeConnections(false);
|
||||||
while(points_list.takeTopLevelItem(0)) {}
|
while(points_list.takeTopLevelItem(0));
|
||||||
foreach(QPointF point, part -> polygon()) {
|
foreach(QPointF point, part -> polygon()) {
|
||||||
point = part -> mapToScene(point);
|
point = part -> mapToScene(point);
|
||||||
QStringList qsl;
|
QStringList qsl;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -18,10 +18,8 @@
|
|||||||
#ifndef CUSTOM_ELEMENT_EDITOR_H
|
#ifndef CUSTOM_ELEMENT_EDITOR_H
|
||||||
#define CUSTOM_ELEMENT_EDITOR_H
|
#define CUSTOM_ELEMENT_EDITOR_H
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include "qet.h"
|
|
||||||
#include "elementscene.h"
|
#include "elementscene.h"
|
||||||
#include "orientationset.h"
|
#include "orientationset.h"
|
||||||
#include "elementslocation.h"
|
|
||||||
class ElementView;
|
class ElementView;
|
||||||
/**
|
/**
|
||||||
Cette classe represente un editeur d'element. Elle permet a l'utilisateur
|
Cette classe represente un editeur d'element. Elle permet a l'utilisateur
|
||||||
@@ -43,19 +41,13 @@ class QETElementEditor : public QMainWindow {
|
|||||||
/// booleen indiquant si l'editeur est en mode "lecture seule" ou non
|
/// booleen indiquant si l'editeur est en mode "lecture seule" ou non
|
||||||
bool read_only;
|
bool read_only;
|
||||||
/// menus
|
/// menus
|
||||||
QMenu *file_menu, *edit_menu, *display_menu, *tools_menu, *config_menu, *help_menu;
|
QMenu *file_menu, *edit_menu, *display_menu, *tools_menu, *help_menu;
|
||||||
/// vue sur la scene d'edition
|
/// vue sur la scene d'edition
|
||||||
ElementView *ce_view;
|
ElementView *ce_view;
|
||||||
/// scene d'edition
|
/// scene d'edition
|
||||||
ElementScene *ce_scene;
|
ElementScene *ce_scene;
|
||||||
/// container pour les widgets d'edition des parties
|
/// container pour les widgets d'edition des parties
|
||||||
QDockWidget *tools_dock;
|
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
|
/// container pour la liste des annulations
|
||||||
QDockWidget *undo_dock;
|
QDockWidget *undo_dock;
|
||||||
/// Container pour la liste des parties
|
/// Container pour la liste des parties
|
||||||
@@ -63,35 +55,25 @@ class QETElementEditor : public QMainWindow {
|
|||||||
/// Liste des parties
|
/// Liste des parties
|
||||||
QListWidget *parts_list;
|
QListWidget *parts_list;
|
||||||
/// actions du menu fichier
|
/// 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
|
/// actions du menu edition
|
||||||
QAction *selectall, *deselectall, *inv_select;
|
QAction *selectall, *deselectall, *inv_select;
|
||||||
QAction *cut, *copy, *paste, *paste_in_area;
|
|
||||||
QAction *undo, *redo;
|
QAction *undo, *redo;
|
||||||
|
QAction *zoom_in, *zoom_out, *zoom_fit, *zoom_reset;
|
||||||
QAction *edit_delete, *edit_size_hs, *edit_names, *edit_ori;
|
QAction *edit_delete, *edit_size_hs, *edit_names, *edit_ori;
|
||||||
QAction *edit_raise, *edit_lower, *edit_backward, *edit_forward;
|
QAction *edit_raise, *edit_lower, *edit_backward, *edit_forward;
|
||||||
/// actions du menu affichage
|
|
||||||
QAction *zoom_in, *zoom_out, *zoom_fit, *zoom_reset;
|
|
||||||
/// actions du menu configurer
|
|
||||||
QAction *fullscreen; ///< Passe en mode plein ecran ou en sort
|
|
||||||
QAction *configure; ///< Lance le dialogue de configuration de QElectroTech
|
|
||||||
/// actions du menu aide
|
|
||||||
QAction *about_qet; ///< Lance le dialogue "A propos de QElectroTech"
|
|
||||||
QAction *about_qt; ///< Lance le dialogue "A propos de Qt"
|
|
||||||
/// barres d'outils
|
/// barres d'outils
|
||||||
QToolBar *parts_toolbar, *main_toolbar, *view_toolbar, *depth_toolbar, *element_toolbar;
|
QToolBar *parts_toolbar, *main_toolbar, *view_toolbar, *depth_toolbar, *element_toolbar;
|
||||||
/// actions de la barre d'outils
|
/// actions de la barre d'outils
|
||||||
QActionGroup *parts;
|
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;
|
QAction *add_arc, *add_terminal, *add_textfield;
|
||||||
|
/// label affiche lors de la selection de plusieurs elements
|
||||||
|
QLabel *default_informations;
|
||||||
/// titre minimal
|
/// titre minimal
|
||||||
QString min_title;
|
QString min_title;
|
||||||
/// Nom de fichier de l'element edite
|
/// Nom de fichier
|
||||||
QString filename_;
|
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;
|
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
@@ -102,56 +84,41 @@ class QETElementEditor : public QMainWindow {
|
|||||||
void setNames(const NamesList &);
|
void setNames(const NamesList &);
|
||||||
void setOrientations(const OrientationSet &orientation_set);
|
void setOrientations(const OrientationSet &orientation_set);
|
||||||
OrientationSet orientations() const;
|
OrientationSet orientations() const;
|
||||||
void setLocation(const ElementsLocation &);
|
|
||||||
ElementsLocation location() const;
|
|
||||||
void setFileName(const QString &);
|
void setFileName(const QString &);
|
||||||
QString fileName() const;
|
QString fileName() const;
|
||||||
void setReadOnly(bool);
|
void setReadOnly(bool);
|
||||||
bool isReadOnly() const;
|
bool isReadOnly() const;
|
||||||
void fromFile(const QString &);
|
void fromFile(const QString &);
|
||||||
void fromLocation(const ElementsLocation &);
|
|
||||||
bool toFile(const QString &);
|
bool toFile(const QString &);
|
||||||
bool toLocation(const ElementsLocation &);
|
|
||||||
ElementScene *elementScene() const;
|
ElementScene *elementScene() const;
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
static QPointF pasteOffset();
|
|
||||||
static QET::OrientedMovement pasteMovement();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *);
|
void closeEvent(QCloseEvent *);
|
||||||
virtual bool event(QEvent *);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupActions();
|
void setupActions();
|
||||||
void setupMenus();
|
void setupMenus();
|
||||||
void setupInterface();
|
void setupInterface();
|
||||||
bool canClose();
|
bool canClose();
|
||||||
QWidget *clearToolsDock();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void slot_new();
|
void slot_new();
|
||||||
void slot_open();
|
void slot_open();
|
||||||
void slot_openFile();
|
|
||||||
void openRecentFile(const QString &);
|
|
||||||
void openElement(const QString &);
|
|
||||||
void slot_reload();
|
void slot_reload();
|
||||||
bool slot_save();
|
bool slot_save();
|
||||||
bool slot_saveAs();
|
bool slot_saveAs();
|
||||||
bool slot_saveAsFile();
|
|
||||||
void slot_setRubberBandToView();
|
void slot_setRubberBandToView();
|
||||||
void slot_setNoDragToView();
|
void slot_setNoDragToView();
|
||||||
void slot_setNormalMode();
|
void slot_setNormalMode();
|
||||||
void slot_updateInformations();
|
void slot_updateInformations();
|
||||||
void slot_updateMenus();
|
void slot_updateMenus();
|
||||||
void slot_updateFullScreenAction();
|
|
||||||
void slot_updateTitle();
|
void slot_updateTitle();
|
||||||
void slot_createPartsList();
|
void slot_createPartsList();
|
||||||
void slot_updatePartsList();
|
void slot_updatePartsList();
|
||||||
void slot_updateSelectionFromPartsList();
|
void slot_updateSelectionFromPartsList();
|
||||||
void toggleFullScreen();
|
|
||||||
void xmlPreview();
|
void xmlPreview();
|
||||||
bool checkElement();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -209,36 +176,19 @@ inline OrientationSet QETElementEditor::orientations() const {
|
|||||||
return(ce_scene -> orientations());
|
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
|
@param fn Le nouveau nom de fichier de l'element edite
|
||||||
*/
|
*/
|
||||||
inline void QETElementEditor::setFileName(const QString &fn) {
|
inline void QETElementEditor::setFileName(const QString &fn) {
|
||||||
filename_ = fn;
|
_filename = fn;
|
||||||
opened_from_file = true;
|
|
||||||
slot_updateTitle();
|
slot_updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return le nom de fichier de l'element edite
|
@return le nomde fichier de l'element edite
|
||||||
*/
|
*/
|
||||||
inline QString QETElementEditor::fileName() const {
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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) {
|
StyleEditor::StyleEditor(QETElementEditor *editor, CustomElementGraphicPart *p, QWidget *parent) : ElementItemEditor(editor, parent), part(p) {
|
||||||
// couleur
|
// couleur
|
||||||
color = new QButtonGroup(this);
|
color = new QButtonGroup(this);
|
||||||
color -> addButton(black_color = new QRadioButton(tr("Noir", "element part color")), CustomElementGraphicPart::BlackColor);
|
color -> addButton(black_color = new QRadioButton(tr("Noir")), CustomElementGraphicPart::BlackColor);
|
||||||
color -> addButton(white_color = new QRadioButton(tr("Blanc", "element part color")), CustomElementGraphicPart::WhiteColor);
|
color -> addButton(white_color = new QRadioButton(tr("Blanc")), CustomElementGraphicPart::WhiteColor);
|
||||||
|
|
||||||
// style
|
// style
|
||||||
style = new QButtonGroup(this);
|
style = new QButtonGroup(this);
|
||||||
style -> addButton(normal_style = new QRadioButton(tr("Normal", "element part line style")), CustomElementGraphicPart::NormalStyle);
|
style -> addButton(normal_style = new QRadioButton(tr("Normal")), CustomElementGraphicPart::NormalStyle);
|
||||||
style -> addButton(dashed_style = new QRadioButton(tr("Pointill\351", "element part line style")), CustomElementGraphicPart::DashedStyle);
|
style -> addButton(dashed_style = new QRadioButton(tr("Pointill\351")), CustomElementGraphicPart::DashedStyle);
|
||||||
style -> button(part -> lineStyle()) -> setChecked(true);
|
style -> button(part -> lineStyle()) -> setChecked(true);
|
||||||
|
|
||||||
// epaisseur
|
// epaisseur
|
||||||
weight = new QButtonGroup(this);
|
weight = new QButtonGroup(this);
|
||||||
weight -> addButton(none_weight = new QRadioButton(tr("Nulle", "element part weight")), CustomElementGraphicPart::NoneWeight);
|
weight -> addButton(none_weight = new QRadioButton(tr("Nulle")), CustomElementGraphicPart::NoneWeight);
|
||||||
weight -> addButton(thin_weight = new QRadioButton(tr("Fine", "element part weight")), CustomElementGraphicPart::ThinWeight);
|
weight -> addButton(thin_weight = new QRadioButton(tr("Fine")), CustomElementGraphicPart::ThinWeight);
|
||||||
weight -> addButton(normal_weight = new QRadioButton(tr("Normale", "element part weight")), CustomElementGraphicPart::NormalWeight);
|
weight -> addButton(normal_weight = new QRadioButton(tr("Normale")), CustomElementGraphicPart::NormalWeight);
|
||||||
|
|
||||||
// remplissage
|
// remplissage
|
||||||
filling = new QButtonGroup(this);
|
filling = new QButtonGroup(this);
|
||||||
filling -> addButton(no_filling = new QRadioButton(tr("Aucun", "element part filling")), CustomElementGraphicPart::NoneFilling );
|
filling -> addButton(no_filling = new QRadioButton(tr("Aucun")), CustomElementGraphicPart::NoneFilling );
|
||||||
filling -> addButton(black_filling = new QRadioButton(tr("Noir", "element part filling")), CustomElementGraphicPart::BlackFilling);
|
filling -> addButton(black_filling = new QRadioButton(tr("Noir")), CustomElementGraphicPart::BlackFilling);
|
||||||
filling -> addButton(white_filling = new QRadioButton(tr("Blanc", "element part filling")), CustomElementGraphicPart::WhiteFilling);
|
filling -> addButton(white_filling = new QRadioButton(tr("Blanc")), CustomElementGraphicPart::WhiteFilling);
|
||||||
|
|
||||||
// antialiasing
|
// antialiasing
|
||||||
antialiasing = new QCheckBox(tr("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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "terminaleditor.h"
|
#include "terminaleditor.h"
|
||||||
#include "partterminal.h"
|
#include "partterminal.h"
|
||||||
#include "qeticons.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@@ -35,10 +34,10 @@ TerminalEditor::TerminalEditor(QETElementEditor *editor, PartTerminal *term, QWi
|
|||||||
qle_y -> setValidator(new QDoubleValidator(qle_y));
|
qle_y -> setValidator(new QDoubleValidator(qle_y));
|
||||||
|
|
||||||
orientation = new QComboBox();
|
orientation = new QComboBox();
|
||||||
orientation -> addItem(QET::Icons::North, tr("Nord"), QET::North);
|
orientation -> addItem(QIcon(":/ico/north.png"), tr("Nord"), QET::North);
|
||||||
orientation -> addItem(QET::Icons::East, tr("Est"), QET::East);
|
orientation -> addItem(QIcon(":/ico/east.png"), tr("Est"), QET::East);
|
||||||
orientation -> addItem(QET::Icons::South, tr("Sud"), QET::South);
|
orientation -> addItem(QIcon(":/ico/south.png"), tr("Sud"), QET::South);
|
||||||
orientation -> addItem(QET::Icons::West, tr("Ouest"), QET::West);
|
orientation -> addItem(QIcon(":/ico/west.png"), tr("Ouest"), QET::West);
|
||||||
|
|
||||||
QVBoxLayout *main_layout = new QVBoxLayout();
|
QVBoxLayout *main_layout = new QVBoxLayout();
|
||||||
main_layout -> addWidget(new QLabel(tr("Position : ")));
|
main_layout -> addWidget(new QLabel(tr("Position : ")));
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2007 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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
|
/// 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(); }
|
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
|
/// 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
|
/// Met a jour la taille du texte et cree un objet d'annulation
|
||||||
void TextEditor::updateTextS() { addChangePartCommand(tr("taille"), part, "size", font_size -> value()); }
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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
|
/// 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(); }
|
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
|
/// 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
|
/// 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()); }
|
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
|
/// 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.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -27,7 +27,6 @@
|
|||||||
Constructeur pour un element sans scene ni parent
|
Constructeur pour un element sans scene ni parent
|
||||||
*/
|
*/
|
||||||
Element::Element(QGraphicsItem *parent, Diagram *scene) :
|
Element::Element(QGraphicsItem *parent, Diagram *scene) :
|
||||||
QObject(),
|
|
||||||
QGraphicsItem(parent, scene),
|
QGraphicsItem(parent, scene),
|
||||||
internal_connections(false)
|
internal_connections(false)
|
||||||
{
|
{
|
||||||
@@ -48,9 +47,9 @@ Element::~Element() {
|
|||||||
*/
|
*/
|
||||||
void Element::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget) {
|
void Element::paint(QPainter *painter, const QStyleOptionGraphicsItem *options, QWidget *widget) {
|
||||||
|
|
||||||
#ifndef Q_WS_WIN
|
#ifdef Q_WS_X11
|
||||||
// corrige un bug de rendu ne se produisant que lors du rendu sur QGraphicsScene sous X11 au zoom par defaut
|
// 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 = QETApp::settings().value("correct-rendering", true).toBool();
|
||||||
if (must_correct_rendering_bug) {
|
if (must_correct_rendering_bug) {
|
||||||
Diagram *dia = diagram();
|
Diagram *dia = diagram();
|
||||||
if (dia && options -> levelOfDetail == 1.0 && widget) {
|
if (dia && options -> levelOfDetail == 1.0 && widget) {
|
||||||
@@ -95,13 +94,6 @@ QSize Element::setSize(int wid, int hei) {
|
|||||||
return(dimensions = QSize(wid, hei));
|
return(dimensions = QSize(wid, hei));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
@return la taille de l'element sur le schema
|
|
||||||
*/
|
|
||||||
QSize Element::size() const {
|
|
||||||
return(dimensions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Definit le hotspot de l'element par rapport au coin superieur gauche de son rectangle delimitant.
|
Definit le hotspot de l'element par rapport au coin superieur gauche de son rectangle delimitant.
|
||||||
Necessite que la taille ait deja ete definie
|
Necessite que la taille ait deja ete definie
|
||||||
@@ -145,8 +137,8 @@ void Element::deselect() {
|
|||||||
@return La pixmap de l'element
|
@return La pixmap de l'element
|
||||||
*/
|
*/
|
||||||
QPixmap Element::pixmap() {
|
QPixmap Element::pixmap() {
|
||||||
if (preview.isNull()) updatePixmap(); // on genere la pixmap si ce n'est deja fait
|
if (apercu.isNull()) updatePixmap(); // on genere la pixmap si ce n'est deja fait
|
||||||
return(preview);
|
return(apercu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -163,7 +155,7 @@ bool Element::setOrientation(QET::Orientation o) {
|
|||||||
rotate(rotation_value);
|
rotate(rotation_value);
|
||||||
ori.setCurrent(o);
|
ori.setCurrent(o);
|
||||||
update();
|
update();
|
||||||
foreach(QGraphicsItem *qgi, childItems()) {
|
foreach(QGraphicsItem *qgi, children()) {
|
||||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) p -> updateConductor();
|
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) p -> updateConductor();
|
||||||
else if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(qgi)) {
|
else if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(qgi)) {
|
||||||
// applique une rotation contraire si besoin
|
// applique une rotation contraire si besoin
|
||||||
@@ -227,10 +219,10 @@ void Element::drawSelection(QPainter *painter, const QStyleOptionGraphicsItem *)
|
|||||||
*/
|
*/
|
||||||
void Element::updatePixmap() {
|
void Element::updatePixmap() {
|
||||||
// Pixmap transparente faisant la taille de base de l'element
|
// Pixmap transparente faisant la taille de base de l'element
|
||||||
preview = QPixmap(dimensions);
|
apercu = QPixmap(dimensions);
|
||||||
preview.fill(QColor(255, 255, 255, 0));
|
apercu.fill(QColor(255, 255, 255, 0));
|
||||||
// QPainter sur la pixmap, avec antialiasing
|
// QPainter sur la pixmap, avec antialiasing
|
||||||
QPainter p(&preview);
|
QPainter p(&apercu);
|
||||||
p.setRenderHint(QPainter::Antialiasing, true);
|
p.setRenderHint(QPainter::Antialiasing, true);
|
||||||
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
p.setRenderHint(QPainter::SmoothPixmapTransform, true);
|
||||||
// Translation de l'origine du repere de la pixmap
|
// Translation de l'origine du repere de la pixmap
|
||||||
@@ -270,8 +262,8 @@ void Element::setPos(qreal x, qreal y) {
|
|||||||
Gere l'enfoncement d'un bouton de la souris
|
Gere l'enfoncement d'un bouton de la souris
|
||||||
*/
|
*/
|
||||||
void Element::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
void Element::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
||||||
if (e -> modifiers() & Qt::ControlModifier) {
|
if (!isSelected() && e -> modifiers() & Qt::ControlModifier) {
|
||||||
setSelected(!isSelected());
|
setSelected(true);
|
||||||
}
|
}
|
||||||
QGraphicsItem::mousePressEvent(e);
|
QGraphicsItem::mousePressEvent(e);
|
||||||
}
|
}
|
||||||
@@ -309,9 +301,7 @@ void Element::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
}
|
}
|
||||||
diagram_ptr -> invalidateMovedElements();
|
diagram_ptr -> invalidateMovedElements();
|
||||||
}
|
}
|
||||||
if (!(e -> modifiers() & Qt::ControlModifier)) {
|
QGraphicsItem::mouseReleaseEvent(e);
|
||||||
QGraphicsItem::mouseReleaseEvent(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -364,7 +354,7 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr) {
|
|||||||
|
|
||||||
QHash<int, Terminal *> priv_id_adr;
|
QHash<int, Terminal *> priv_id_adr;
|
||||||
int terminals_non_trouvees = 0;
|
int terminals_non_trouvees = 0;
|
||||||
foreach(QGraphicsItem *qgi, childItems()) {
|
foreach(QGraphicsItem *qgi, children()) {
|
||||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) {
|
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) {
|
||||||
bool terminal_trouvee = false;
|
bool terminal_trouvee = false;
|
||||||
foreach(QDomElement qde, liste_terminals) {
|
foreach(QDomElement qde, liste_terminals) {
|
||||||
@@ -396,7 +386,7 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr) {
|
|||||||
|
|
||||||
// importe les valeurs des champs de texte
|
// importe les valeurs des champs de texte
|
||||||
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input");
|
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input");
|
||||||
foreach(QGraphicsItem *qgi, childItems()) {
|
foreach(QGraphicsItem *qgi, children()) {
|
||||||
if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(qgi)) {
|
if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(qgi)) {
|
||||||
foreach(QDomElement input, inputs) eti -> fromXml(input);
|
foreach(QDomElement input, inputs) eti -> fromXml(input);
|
||||||
}
|
}
|
||||||
@@ -425,11 +415,13 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
|||||||
QDomElement element = document.createElement("element");
|
QDomElement element = document.createElement("element");
|
||||||
|
|
||||||
// type
|
// 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
|
// position, selection et orientation
|
||||||
element.setAttribute("x", QString("%1").arg(pos().x()));
|
element.setAttribute("x", pos().x());
|
||||||
element.setAttribute("y", QString("%1").arg(pos().y()));
|
element.setAttribute("y", pos().y());
|
||||||
element.setAttribute("orientation", QString("%1").arg(ori.current()));
|
element.setAttribute("orientation", QString("%1").arg(ori.current()));
|
||||||
|
|
||||||
/* recupere le premier id a utiliser pour les bornes de cet element */
|
/* recupere le premier id a utiliser pour les bornes de cet element */
|
||||||
@@ -444,21 +436,29 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
|||||||
}
|
}
|
||||||
|
|
||||||
// enregistrement des bornes de l'appareil
|
// enregistrement des bornes de l'appareil
|
||||||
QDomElement xml_terminals = document.createElement("terminals");
|
QDomElement terminals = document.createElement("terminals");
|
||||||
// pour chaque enfant de l'element
|
// pour chaque enfant de l'element
|
||||||
foreach(Terminal *t, terminals()) {
|
foreach(QGraphicsItem *child, children()) {
|
||||||
// alors on enregistre la borne
|
// si cet enfant est une borne
|
||||||
QDomElement terminal = t -> toXml(document);
|
if (Terminal *t = qgraphicsitem_cast<Terminal *>(child)) {
|
||||||
terminal.setAttribute("id", id_terminal);
|
// alors on enregistre la borne
|
||||||
table_adr_id.insert(t, id_terminal ++);
|
QDomElement terminal = t -> toXml(document);
|
||||||
xml_terminals.appendChild(terminal);
|
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
|
// enregistrement des champ de texte de l'appareil
|
||||||
QDomElement inputs = document.createElement("inputs");
|
QDomElement inputs = document.createElement("inputs");
|
||||||
foreach(ElementTextItem *eti, texts()) {
|
// pour chaque enfant de l'element
|
||||||
inputs.appendChild(eti -> toXml(document));
|
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);
|
element.appendChild(inputs);
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -21,13 +21,10 @@
|
|||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "orientationset.h"
|
#include "orientationset.h"
|
||||||
class Diagram;
|
class Diagram;
|
||||||
class ElementTextItem;
|
|
||||||
/**
|
/**
|
||||||
Cette classe abstraite represente un element electrique.
|
Cette classe abstraite represente un element electrique.
|
||||||
*/
|
*/
|
||||||
class Element : public QObject, public QGraphicsItem {
|
class Element : public QGraphicsItem {
|
||||||
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
@@ -54,7 +51,7 @@ class Element : public QObject, public QGraphicsItem {
|
|||||||
private:
|
private:
|
||||||
QSize dimensions;
|
QSize dimensions;
|
||||||
QPoint hotspot_coord;
|
QPoint hotspot_coord;
|
||||||
QPixmap preview;
|
QPixmap apercu;
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public:
|
public:
|
||||||
@@ -69,14 +66,12 @@ class Element : public QObject, public QGraphicsItem {
|
|||||||
virtual QList<Terminal *> terminals() const = 0;
|
virtual QList<Terminal *> terminals() const = 0;
|
||||||
/// @return la liste des conducteurs relies a cet element
|
/// @return la liste des conducteurs relies a cet element
|
||||||
virtual QList<Conductor *> conductors() const = 0;
|
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
|
/// @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
|
/// @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
|
/// @return le nombre de bornes maximum de cet element
|
||||||
virtual int maxTerminalsCount() const = 0;
|
virtual int nbTerminalsMax() const = 0;
|
||||||
/**
|
/**
|
||||||
Dessine l'element
|
Dessine l'element
|
||||||
*/
|
*/
|
||||||
@@ -84,13 +79,12 @@ class Element : public QObject, public QGraphicsItem {
|
|||||||
/// @return L'ID du type de l'element
|
/// @return L'ID du type de l'element
|
||||||
virtual QString typeId() const = 0;
|
virtual QString typeId() const = 0;
|
||||||
/// @return Le nom de l'element
|
/// @return Le nom de l'element
|
||||||
virtual QString name() const = 0;
|
virtual QString nom() const = 0;
|
||||||
Diagram *diagram() const;
|
Diagram *diagram() const;
|
||||||
|
|
||||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
QSize setSize(int, int);
|
QSize setSize(int, int);
|
||||||
QSize size() const;
|
|
||||||
QPixmap pixmap();
|
QPixmap pixmap();
|
||||||
|
|
||||||
// methodes relatives au point de saisie
|
// methodes relatives au point de saisie
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2006-2009 Xavier Guerrin
|
Copyright 2006-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
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/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "elementdeleter.h"
|
#include "elementdeleter.h"
|
||||||
#include "qetapp.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
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
|
@param parent QWidget parent
|
||||||
*/
|
*/
|
||||||
ElementDeleter::ElementDeleter(const ElementsLocation &elmt_path, QWidget *parent) :
|
ElementDeleter::ElementDeleter(const QString &elmt_path, QWidget *parent) :
|
||||||
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
|
/// Destructeur
|
||||||
@@ -45,31 +36,27 @@ ElementDeleter::~ElementDeleter() {
|
|||||||
Supprime l'element : verifie l'existence du fichier, demande confirmation a
|
Supprime l'element : verifie l'existence du fichier, demande confirmation a
|
||||||
l'utilisateur et avertit ce dernier si la suppression a echoue.
|
l'utilisateur et avertit ce dernier si la suppression a echoue.
|
||||||
*/
|
*/
|
||||||
bool ElementDeleter::exec() {
|
void ElementDeleter::exec() {
|
||||||
// verifie l'existence de l'element
|
// verifie l'existence de l'element
|
||||||
if (!element || !element -> isElement()) return(false);
|
QFile elmt_file(element_path);
|
||||||
|
if (!elmt_file.exists()) return;
|
||||||
|
|
||||||
// confirmation #1
|
// confirmation #1
|
||||||
QMessageBox::StandardButton answer_1 = QMessageBox::question(
|
QMessageBox::StandardButton answer_1 = QMessageBox::question(
|
||||||
this,
|
this,
|
||||||
tr("Supprimer l'\351l\351ment ?", "message box title"),
|
tr("Supprimer l'\351l\351ment ?"),
|
||||||
tr("\312tes-vous s\373r de vouloir supprimer cet \351l\351ment ?\n", "message box content"),
|
tr("\312tes-vous s\373r de vouloir supprimer cet \351l\351ment ?\n"),
|
||||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel
|
QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel
|
||||||
);
|
);
|
||||||
if (answer_1 != QMessageBox::Yes) return(false);
|
if (answer_1 != QMessageBox::Yes) return;
|
||||||
|
|
||||||
/**
|
|
||||||
@todo Regression : rafficher le chemin de l'element
|
|
||||||
*/
|
|
||||||
|
|
||||||
// supprime l'element
|
// supprime l'element
|
||||||
if (!element -> remove()) {
|
if (!elmt_file.remove()) {
|
||||||
QMessageBox::warning(
|
QMessageBox::warning(
|
||||||
this,
|
this,
|
||||||
tr("Suppression de l'\351l\351ment", "message box title"),
|
tr("Suppression de l'\351l\351ment"),
|
||||||
tr("La suppression de l'\351l\351ment a \351chou\351.", "message box content")
|
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-2008 Xavier Guerrin
|
||||||
This file is part of QElectroTech.
|
This file is part of QElectroTech.
|
||||||
|
|
||||||
QElectroTech is free software: you can redistribute it and/or modify
|
QElectroTech is free software: you can redistribute it and/or modify
|
||||||
@@ -18,28 +18,27 @@
|
|||||||
#ifndef ELEMENT_DELETER_H
|
#ifndef ELEMENT_DELETER_H
|
||||||
#define ELEMENT_DELETER_H
|
#define ELEMENT_DELETER_H
|
||||||
#include "elementscategory.h"
|
#include "elementscategory.h"
|
||||||
#include "elementslocation.h"
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
/**
|
/**
|
||||||
Cette classe represente une couche d'abstraction pour supprimer
|
Cette classe represente une couche d'abstraction pour supprimer
|
||||||
un element de la collection d'elements.
|
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 {
|
class ElementDeleter : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
// constructeurs, destructeur
|
// constructeurs, destructeur
|
||||||
public:
|
public:
|
||||||
ElementDeleter(const ElementsLocation &, QWidget * = 0);
|
ElementDeleter(const QString &, QWidget * = 0);
|
||||||
virtual ~ElementDeleter();
|
virtual ~ElementDeleter();
|
||||||
private:
|
private:
|
||||||
ElementDeleter(const ElementsCategory &);
|
ElementDeleter(const ElementsCategory &);
|
||||||
|
|
||||||
// methodes
|
// methodes
|
||||||
public slots:
|
public slots:
|
||||||
bool exec();
|
void exec();
|
||||||
|
|
||||||
// attributs
|
// attributs
|
||||||
private:
|
private:
|
||||||
ElementsCollectionItem *element;
|
QString element_path;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
<definition width="80" version="0.2" hotspot_x="30" hotspot_y="50" height="110" type="element" ic="true" orientation="dyyy" >
|
|
||||||
<names>
|
|
||||||
<name lang="ru" >Вход</name>
|
|
||||||
<name lang="en" >Input</name>
|
|
||||||
<name lang="fr" >Entrée</name>
|
|
||||||
<name lang="es" >Entrada</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="40" y2="0" x2="20" />
|
|
||||||
<input x="25" y="-10" size="8" rotate="true" text="_" />
|
|
||||||
<input x="-25" y="50" size="9" rotate="true" text="_" />
|
|
||||||
<text x="-2" y="5" size="12" text="I" />
|
|
||||||
<rect width="40" x="-20" y="-35" antialias="false" height="70" style="line-style:normal;line-weight:normal;filling:none;color:black" />
|
|
||||||
<terminal x="40" y="0" orientation="e" />
|
|
||||||
</description>
|
|
||||||
</definition>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<definition width="100" version="0.2" hotspot_x="50" hotspot_y="50" height="110" type="element" ic="true" orientation="dyyy" >
|
|
||||||
<names>
|
|
||||||
<name lang="ru" >И</name>
|
|
||||||
<name lang="en" >AND</name>
|
|
||||||
<name lang="fr" >ET</name>
|
|
||||||
<name lang="es" >Y</name>
|
|
||||||
</names>
|
|
||||||
<description>
|
|
||||||
<input x="-46" y="10" size="8" rotate="true" text="_" />
|
|
||||||
<input x="-46" y="-30" size="8" rotate="true" text="_" />
|
|
||||||
<input x="25" y="-10" size="8" rotate="true" text="_" />
|
|
||||||
<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="-20" x1="-40" y2="-20" 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="20" x1="-40" y2="20" 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="40" y2="0" x2="21" />
|
|
||||||
<input x="-25" y="50" size="9" rotate="true" text="_" />
|
|
||||||
<text x="-6" y="5" size="12" text="&" />
|
|
||||||
<rect width="40" x="-20" y="-35" antialias="false" height="70" style="line-style:normal;line-weight:normal;filling:none;color:black" />
|
|
||||||
<terminal x="40" y="0" orientation="e" />
|
|
||||||
<terminal x="-40" y="-20" orientation="w" />
|
|
||||||
<terminal x="-40" y="20" orientation="w" />
|
|
||||||
</description>
|
|
||||||
</definition>
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
<definition width="100" version="0.2" hotspot_x="50" hotspot_y="50" height="110" type="element" ic="true" orientation="dyyy" >
|
|
||||||
<names>
|
|
||||||
<name lang="ru" >И, трёхвходовый</name>
|
|
||||||
<name lang="en" >AND 3 inputs</name>
|
|
||||||
<name lang="fr" >ET 3 entrées</name>
|
|
||||||
<name lang="es" >Y 3 entradas</name>
|
|
||||||
</names>
|
|
||||||
<description>
|
|
||||||
<input x="-46" y="-10" size="8" rotate="true" text="_" />
|
|
||||||
<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="-40" y2="0" x2="-20" />
|
|
||||||
<input x="-46" y="10" size="8" rotate="true" text="_" />
|
|
||||||
<input x="-46" y="-30" size="8" rotate="true" text="_" />
|
|
||||||
<input x="25" y="-10" size="8" rotate="true" text="_" />
|
|
||||||
<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="-20" x1="-40" y2="-20" 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="20" x1="-40" y2="20" 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="40" y2="0" x2="21" />
|
|
||||||
<input x="-25" y="50" size="9" rotate="true" text="_" />
|
|
||||||
<text x="-6" y="5" size="12" text="&" />
|
|
||||||
<rect width="40" x="-20" y="-35" antialias="false" height="70" style="line-style:normal;line-weight:normal;filling:none;color:black" />
|
|
||||||
<terminal x="40" y="0" orientation="e" />
|
|
||||||
<terminal x="-40" y="-20" orientation="w" />
|
|
||||||
<terminal x="-40" y="20" orientation="w" />
|
|
||||||
<terminal x="-40" y="0" orientation="w" />
|
|
||||||
</description>
|
|
||||||
</definition>
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<definition width="100" version="0.2" hotspot_x="50" hotspot_y="50" height="110" type="element" ic="true" orientation="dyyy" >
|
|
||||||
<names>
|
|
||||||
<name lang="ru" >И-НЕ</name>
|
|
||||||
<name lang="en" >NAND</name>
|
|
||||||
<name lang="fr" >NON-ET (NAND)</name>
|
|
||||||
<name lang="es" >NO-Y (NAND)</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="40" y2="0" x2="26" />
|
|
||||||
<circle x="20.5" y="-2.5" antialias="true" style="line-style:normal;line-weight:normal;filling:none;color:black" diameter="5" />
|
|
||||||
<input x="-46" y="10" size="8" rotate="true" text="_" />
|
|
||||||
<input x="-46" y="-30" size="8" rotate="true" text="_" />
|
|
||||||
<input x="25" y="-10" size="8" rotate="true" text="_" />
|
|
||||||
<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="-20" x1="-40" y2="-20" 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="20" x1="-40" y2="20" x2="-21" />
|
|
||||||
<input x="-25" y="50" size="9" rotate="true" text="_" />
|
|
||||||
<text x="-6" y="5" size="12" text="&" />
|
|
||||||
<rect width="40" x="-20" y="-35" antialias="false" height="70" style="line-style:normal;line-weight:normal;filling:none;color:black" />
|
|
||||||
<terminal x="40" y="0" orientation="e" />
|
|
||||||
<terminal x="-40" y="-20" orientation="w" />
|
|
||||||
<terminal x="-40" y="20" orientation="w" />
|
|
||||||
</description>
|
|
||||||
</definition>
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<definition width="100" version="0.2" hotspot_x="50" hotspot_y="50" height="110" type="element" ic="true" orientation="dyyy" >
|
|
||||||
<names>
|
|
||||||
<name lang="ru" >НЕ</name>
|
|
||||||
<name lang="en" >NOT</name>
|
|
||||||
<name lang="fr" >NON</name>
|
|
||||||
<name lang="es" >NO</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="40" y2="0" x2="26" />
|
|
||||||
<circle x="20.5" y="-2.5" antialias="true" style="line-style:normal;line-weight:normal;filling:none;color:black" diameter="5" />
|
|
||||||
<input x="-46" y="-10" size="8" rotate="true" text="_" />
|
|
||||||
<input x="25" y="-10" size="8" rotate="true" text="_" />
|
|
||||||
<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="-39" y2="0" x2="-20" />
|
|
||||||
<input x="-25" y="50" size="9" rotate="true" text="_" />
|
|
||||||
<text x="-5" y="5" size="12" text="1" />
|
|
||||||
<rect width="40" x="-20" y="-35" antialias="false" height="70" style="line-style:normal;line-weight:normal;filling:none;color:black" />
|
|
||||||
<terminal x="-40" y="0" orientation="w" />
|
|
||||||
<terminal x="40" y="0" orientation="e" />
|
|
||||||
</description>
|
|
||||||
</definition>
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
<definition width="100" version="0.2" hotspot_x="50" hotspot_y="50" height="110" type="element" ic="true" orientation="dyyy" >
|
|
||||||
<names>
|
|
||||||
<name lang="ru" >ИЛИ-НЕ</name>
|
|
||||||
<name lang="en" >NOR</name>
|
|
||||||
<name lang="fr" >NON-OU (NOR)</name>
|
|
||||||
<name lang="es" >NO-O (NOR)</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="40" y2="0" x2="26" />
|
|
||||||
<circle x="20.5" y="-2.5" antialias="true" style="line-style:normal;line-weight:normal;filling:none;color:black" diameter="5" />
|
|
||||||
<input x="-46" y="10" size="8" rotate="true" text="_" />
|
|
||||||
<input x="-46" y="-30" size="8" rotate="true" text="_" />
|
|
||||||
<input x="25" y="-10" size="8" rotate="true" text="_" />
|
|
||||||
<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="-20" x1="-40" y2="-20" 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="20" x1="-40" y2="20" x2="-21" />
|
|
||||||
<input x="-25" y="50" size="9" rotate="true" text="_" />
|
|
||||||
<text x="-11.5" y="5" size="12" text="≥1" />
|
|
||||||
<rect width="40" x="-20" y="-35" antialias="false" height="70" style="line-style:normal;line-weight:normal;filling:none;color:black" />
|
|
||||||
<terminal x="40" y="0" orientation="e" />
|
|
||||||
<terminal x="-40" y="-20" orientation="w" />
|
|
||||||
<terminal x="-40" y="20" orientation="w" />
|
|
||||||
</description>
|
|
||||||
</definition>
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<definition width="100" version="0.2" hotspot_x="50" hotspot_y="50" height="110" type="element" ic="true" orientation="dyyy" >
|
|
||||||
<names>
|
|
||||||
<name lang="ru" >ИЛИ</name>
|
|
||||||
<name lang="en" >OR</name>
|
|
||||||
<name lang="fr" >OU</name>
|
|
||||||
<name lang="es" >O</name>
|
|
||||||
</names>
|
|
||||||
<description>
|
|
||||||
<input x="-46" y="10" size="8" rotate="true" text="_" />
|
|
||||||
<input x="-46" y="-30" size="8" rotate="true" text="_" />
|
|
||||||
<input x="25" y="-10" size="8" rotate="true" text="_" />
|
|
||||||
<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="-20" x1="-40" y2="-20" 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="20" x1="-40" y2="20" 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="40" y2="0" x2="21" />
|
|
||||||
<input x="-25" y="50" size="9" rotate="true" text="_" />
|
|
||||||
<text x="-11.5" y="5" size="12" text="≥1" />
|
|
||||||
<rect width="40" x="-20" y="-35" antialias="false" height="70" style="line-style:normal;line-weight:normal;filling:none;color:black" />
|
|
||||||
<terminal x="40" y="0" orientation="e" />
|
|
||||||
<terminal x="-40" y="-20" orientation="w" />
|
|
||||||
<terminal x="-40" y="20" orientation="w" />
|
|
||||||
</description>
|
|
||||||
</definition>
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
<definition width="100" version="0.2" hotspot_x="50" hotspot_y="50" height="110" type="element" ic="true" orientation="dyyy" >
|
|
||||||
<names>
|
|
||||||
<name lang="ru" >ИЛИ, трёхвходовый</name>
|
|
||||||
<name lang="en" >OR 3 inputs</name>
|
|
||||||
<name lang="fr" >OU 3 entrées</name>
|
|
||||||
<name lang="es" >O 3 entradas</name>
|
|
||||||
</names>
|
|
||||||
<description>
|
|
||||||
<input x="-46" y="-10" size="8" rotate="true" text="_" />
|
|
||||||
<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="-40" y2="0" x2="-20" />
|
|
||||||
<input x="-46" y="10" size="8" rotate="true" text="_" />
|
|
||||||
<input x="-46" y="-30" size="8" rotate="true" text="_" />
|
|
||||||
<input x="25" y="-10" size="8" rotate="true" text="_" />
|
|
||||||
<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="-20" x1="-40" y2="-20" 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="20" x1="-40" y2="20" 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="40" y2="0" x2="21" />
|
|
||||||
<input x="-25" y="50" size="9" rotate="true" text="_" />
|
|
||||||
<text x="-11.5" y="5" size="12" text="≥1" />
|
|
||||||
<rect width="40" x="-20" y="-35" antialias="false" height="70" style="line-style:normal;line-weight:normal;filling:none;color:black" />
|
|
||||||
<terminal x="40" y="0" orientation="e" />
|
|
||||||
<terminal x="-40" y="-20" orientation="w" />
|
|
||||||
<terminal x="-40" y="20" orientation="w" />
|
|
||||||
<terminal x="-40" y="0" orientation="w" />
|
|
||||||
</description>
|
|
||||||
</definition>
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
<qet-directory>
|
|
||||||
<names>
|
|
||||||
<name lang="ru" >Логические устройства</name>
|
|
||||||
<name lang="en" >Logic gates</name>
|
|
||||||
<name lang="fr" >Fonctions logiques</name>
|
|
||||||
<name lang="es" >Puertas lógicas</name>
|
|
||||||
</names>
|
|
||||||
</qet-directory>
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user