mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-23 10:30:53 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5762b3943b |
29
CREDIT
29
CREDIT
@@ -1,29 +1,6 @@
|
||||
[en]
|
||||
Thanks to Trolltech for their Qt library ( http://trolltech.com/ ), licensed
|
||||
under GNU/GPL.
|
||||
Thanks to Everaldo Coelho for the Crystal SVG icons theme (
|
||||
http://www.everaldo.com/crystal/ ) licensed under LGPL, and to the KDE
|
||||
project ( http://www.kde.org/ ).
|
||||
Thanks to Loic for his mathematics-related explanations.
|
||||
Thanks to Nicolas for the Mac OS X experimentations.
|
||||
Thanks to Remi Collet for the Fedora packaging.
|
||||
Thanks to Piotr SQLek Skólski for the Debian packaging.
|
||||
Thanks to `trem' for the Mandriva packaging.
|
||||
Thanks to TuxFamily ( http://tuxfamily.org ) for hosting the project.
|
||||
Thanks to `Nishiki' for his elements and his support.
|
||||
Thanks to qtcentre.org for their SingleApplication class.
|
||||
|
||||
[fr]
|
||||
Merci à Trolltech pour la bibliothèque Qt ( http://trolltech.com/ ), sous
|
||||
Merci à Trolltech pour la bibliothèque Qt ( http://trolltech.com/ ), sous
|
||||
licence GNU/GPL.
|
||||
Merci à Everaldo Coelho pour le thème d'icônes Crystal SVG (
|
||||
Merci à Everaldo Coelho pour le thème d'icônes Crystal SVG (
|
||||
http://www.everaldo.com/crystal/ ) sous licence LGPL, ainsi qu'au projet KDE (
|
||||
http://www.kde.org/ ).
|
||||
Merci à Loic pour ses explications d'ordre mathématique.
|
||||
Merci à Nicolas pour les expérimentations Mac OS X.
|
||||
Merci à Remi Collet pour les paquets Fedora.
|
||||
Merci à Piotr SQLek Skólski pour les paquets Debian.
|
||||
Merci à `trem' pour les paquets Mandriva.
|
||||
Merci à TuxFamily ( http://tuxfamily.org ) pour l'hébergement du projet.
|
||||
Merci à `Nishiki' pour ses éléments et son soutien.
|
||||
Merci à qtcentre.org pour leur classe SingleApplication.
|
||||
Merci à Loic pour ses explications d'ordre mathématique.
|
||||
|
||||
24
Doxyfile
24
Doxyfile
@@ -1,14 +1,14 @@
|
||||
# Doxyfile 1.5.5
|
||||
# Doxyfile 1.5.1-KDevelop
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = QElectroTech
|
||||
PROJECT_NUMBER = 0.1
|
||||
OUTPUT_DIRECTORY =
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = French
|
||||
USE_WINDOWS_ENCODING = NO
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF = "The $name class" \
|
||||
@@ -29,7 +29,6 @@ STRIP_FROM_PATH = /home/data/chaos/projets/qet/qelectrotech/
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
@@ -38,14 +37,9 @@ TAB_SIZE = 4
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
CPP_CLI_SUPPORT = NO
|
||||
SIP_SUPPORT = NO
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SUBGROUPING = YES
|
||||
TYPEDEF_HIDES_STRUCT = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
@@ -54,7 +48,6 @@ EXTRACT_PRIVATE = NO
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
@@ -66,7 +59,6 @@ SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_GROUP_NAMES = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = NO
|
||||
GENERATE_TESTLIST = NO
|
||||
@@ -90,8 +82,7 @@ WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT =
|
||||
INPUT_ENCODING = UTF-8
|
||||
INPUT = /home/data/chaos/projets/qet/qelectrotech
|
||||
FILE_PATTERNS = *.h \
|
||||
*.cpp
|
||||
RECURSIVE = YES
|
||||
@@ -101,7 +92,6 @@ EXCLUDE = moc_* \
|
||||
debug
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_SYMBOLS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS = *
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
@@ -137,10 +127,6 @@ HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
DOCSET_BUNDLE_ID = org.doxygen.Project
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
@@ -224,7 +210,6 @@ PERL_PATH = /usr/bin/perl
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
MSCGEN_PATH =
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = YES
|
||||
CLASS_GRAPH = YES
|
||||
@@ -241,7 +226,8 @@ DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
MAX_DOT_GRAPH_DEPTH = 1000
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
|
||||
21
INSTALL
21
INSTALL
@@ -1,21 +0,0 @@
|
||||
[en]
|
||||
Requirements :
|
||||
libQt4 (see packages libqt4*)
|
||||
cupsys-bsd for printing
|
||||
|
||||
Howto compile :
|
||||
$ qmake (qmake-qt4 for Debian-based systems)
|
||||
$ make
|
||||
# umask 0022
|
||||
# make install
|
||||
|
||||
[fr]
|
||||
Pré-requis :
|
||||
libQt4 (paquets libqt4*)
|
||||
cupsys-bsd pour l'impression
|
||||
|
||||
Comment compiler :
|
||||
$ qmake (qmake-qt4 pour les systèmes basés sur Debian)
|
||||
$ make
|
||||
# umask 0022
|
||||
# make install
|
||||
9
README
9
README
@@ -1,9 +0,0 @@
|
||||
[en]
|
||||
QElectroTech is a Qt4 application to design electric diagrams. It uses XML
|
||||
files for elements and diagrams, and includes both a diagram editor and an
|
||||
element editor.
|
||||
|
||||
[fr]
|
||||
QElectroTech est une application Qt4 pour réaliser des schémas électriques.
|
||||
QET utilise le format XML pour ses éléments et ses schémas et inclut un
|
||||
éditeur de schémas ainsi qu'un éditeur d'élément.
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -15,7 +15,6 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <QtGui>
|
||||
#include "aboutqet.h"
|
||||
#include "qet.h"
|
||||
|
||||
@@ -83,7 +82,7 @@ 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") +
|
||||
tr("\251 2006-2007 Les d\351veloppeurs de QElectroTech") +
|
||||
"<br><br>"
|
||||
"<a href=\"http://qelectrotech.tuxfamily.org/\">"
|
||||
"http://qelectrotech.tuxfamily.org/</a>"
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
#ifndef ABOUTQET_H
|
||||
#define ABOUTQET_H
|
||||
#include <QDialog>
|
||||
#include <QtGui>
|
||||
/**
|
||||
Cette classe represente la boite de dialogue
|
||||
« A propos de QElectroTech »
|
||||
231
borderinset.cpp
Normal file
231
borderinset.cpp
Normal file
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "borderinset.h"
|
||||
#include "qetapp.h"
|
||||
|
||||
/**
|
||||
Constructeur simple : construit une bordure de 15 colonnes de 50x500 avec
|
||||
un cartouche de 400x50.
|
||||
@param parent QObject parent de ce BorderInset
|
||||
*/
|
||||
BorderInset::BorderInset(QObject *parent) : QObject(parent) {
|
||||
nb_columns = qMax(3, QETApp::settings().value("diagrameditor/defaultcols", 15).toInt());
|
||||
min_nb_columns = 3;
|
||||
columns_width = QETApp::settings().value("diagrameditor/defaultcolsize", 50.0).toDouble();
|
||||
columns_height = QETApp::settings().value("diagrameditor/defaultheight", 500.0).toDouble();
|
||||
min_columns_height = 80.0;
|
||||
inset_width = nb_columns * columns_width;
|
||||
inset_height = 50.0;
|
||||
columns_header_height = 20.0;
|
||||
display_inset = true;
|
||||
display_columns = true;
|
||||
display_border = true;
|
||||
updateRectangles();
|
||||
|
||||
bi_author = QETApp::settings().value("diagrameditor/defaultauthor").toString();
|
||||
bi_title = QETApp::settings().value("diagrameditor/defaulttitle").toString();
|
||||
bi_folio = QETApp::settings().value("diagrameditor/defaultfolio").toString();
|
||||
bi_filename = QETApp::settings().value("diagrameditor/defaultfilename").toString();
|
||||
QString settings_date = QETApp::settings().value("diagrameditor/defaultdate").toString();
|
||||
if (settings_date == "now") bi_date = QDate::currentDate();
|
||||
else if (settings_date.isEmpty() || settings_date == "null") bi_date = QDate();
|
||||
else bi_date = QDate::fromString(settings_date, "yyyyMMdd");
|
||||
}
|
||||
|
||||
/**
|
||||
Destructeur - ne fait rien
|
||||
*/
|
||||
BorderInset::~BorderInset() {
|
||||
}
|
||||
|
||||
/**
|
||||
Methode recalculant les rectangles composant le cadre et le cartouche en
|
||||
fonction des attributs de taille
|
||||
*/
|
||||
void BorderInset::updateRectangles() {
|
||||
// rectangle delimitant le schema
|
||||
QRectF previous_border = border;
|
||||
border = QRectF(0, 0, nb_columns * columns_width, columns_height);
|
||||
if (border != previous_border) emit(borderChanged(previous_border, border));
|
||||
|
||||
// rectangles relatifs au cartouche
|
||||
inset = QRectF(border.bottomLeft().x(), border.bottomLeft().y(), inset_width, inset_height);
|
||||
inset_author = QRectF(inset.topLeft(), QSizeF(2.0 * inset_width / 9.0, 0.5 * inset_height));
|
||||
inset_date = QRectF(inset_author.bottomLeft(), inset_author.size());
|
||||
inset_title = QRectF(inset_author.topRight(), QSizeF(5.0 * inset_width / 9.0, inset_height));
|
||||
inset_file = QRectF(inset_title.topRight(), inset_author.size());
|
||||
inset_folio = QRectF(inset_file.bottomLeft(), inset_author.size());
|
||||
}
|
||||
|
||||
/**
|
||||
Dessine le cadre et le cartouche
|
||||
@param qp QPainter a utiliser pour dessiner le cadre et le cartouche
|
||||
@param x Abscisse du cadre
|
||||
@param y Ordonnee du cadre
|
||||
*/
|
||||
void BorderInset::draw(QPainter *qp, qreal x, qreal y) {
|
||||
// translate tous les rectangles
|
||||
border .translate(x, y);
|
||||
inset .translate(x, y);
|
||||
inset_author.translate(x, y);
|
||||
inset_date .translate(x, y);
|
||||
inset_title .translate(x, y);
|
||||
inset_file .translate(x, y);
|
||||
inset_folio .translate(x, y);
|
||||
|
||||
// prepare le QPainter
|
||||
qp -> save();
|
||||
qp -> setPen(Qt::black);
|
||||
qp -> setBrush(Qt::NoBrush);
|
||||
|
||||
// dessine le cadre
|
||||
if (display_border) qp -> drawRect(border);
|
||||
|
||||
// dessine la numerotation des colonnes
|
||||
if (display_columns) {
|
||||
qp -> setBrush(Qt::white);
|
||||
for (int i = 1 ; i <= nb_columns ; ++ i) {
|
||||
QRectF numbered_rectangle = QRectF(
|
||||
border.topLeft().x() + ((i - 1) * columns_width),
|
||||
border.topLeft().y(),
|
||||
columns_width,
|
||||
columns_header_height
|
||||
);
|
||||
qp -> drawRect(numbered_rectangle);
|
||||
qp -> drawText(numbered_rectangle, Qt::AlignVCenter | Qt::AlignCenter, QString("%1").arg(i));
|
||||
}
|
||||
}
|
||||
|
||||
// dessine le cartouche
|
||||
if (display_inset) {
|
||||
qp -> setBrush(Qt::white);
|
||||
qp -> drawRect(inset);
|
||||
|
||||
qp -> drawRect(inset_author);
|
||||
qp -> drawText(inset_author, Qt::AlignVCenter | Qt::AlignLeft, tr(" Auteur : ") + bi_author);
|
||||
|
||||
qp -> drawRect(inset_date);
|
||||
qp -> drawText(inset_date, Qt::AlignVCenter | Qt::AlignLeft, tr(" Date : ") + bi_date.toString("dd/MM/yyyy"));
|
||||
|
||||
qp -> drawRect(inset_title);
|
||||
qp -> drawText(inset_title, Qt::AlignVCenter | Qt::AlignCenter, tr("Titre du document : ") + bi_title);
|
||||
|
||||
qp -> drawRect(inset_file);
|
||||
qp -> drawText(inset_file, Qt::AlignVCenter | Qt::AlignLeft, tr(" Fichier : ") + bi_filename);
|
||||
|
||||
qp -> drawRect(inset_folio);
|
||||
qp -> drawText(inset_folio, Qt::AlignVCenter | Qt::AlignLeft, tr(" Folio : ") + bi_folio);
|
||||
}
|
||||
|
||||
qp -> restore();
|
||||
|
||||
// annule la translation des rectangles
|
||||
border .translate(-x, -y);
|
||||
inset .translate(-x, -y);
|
||||
inset_author.translate(-x, -y);
|
||||
inset_date .translate(-x, -y);
|
||||
inset_title .translate(-x, -y);
|
||||
inset_file .translate(-x, -y);
|
||||
inset_folio .translate(-x, -y);
|
||||
}
|
||||
|
||||
/**
|
||||
Ajoute une colonne.
|
||||
*/
|
||||
void BorderInset::addColumn() {
|
||||
++ nb_columns;
|
||||
setInsetWidth(nb_columns * columns_width);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Enleve une colonne. Il doit rester au moins 3 colonnes.
|
||||
*/
|
||||
void BorderInset::removeColumn() {
|
||||
if (nb_columns == min_nb_columns) return;
|
||||
-- nb_columns;
|
||||
setInsetWidth(nb_columns * columns_width);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Permet de changer le nombre de colonnes.
|
||||
Si ce nombre de colonnes est inferieur au minimum requis, cette fonction ne
|
||||
fait rien
|
||||
@param nb_c nouveau nombre de colonnes
|
||||
@see minNbColumns()
|
||||
*/
|
||||
void BorderInset::setNbColumns(int nb_c) {
|
||||
if (nb_c < min_nb_columns) return;
|
||||
nb_columns = nb_c;
|
||||
setInsetWidth(nb_columns * columns_width);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Change la largeur des colonnes ; celle-ci doit rester comprise entre 10 et
|
||||
200px.
|
||||
*/
|
||||
void BorderInset::setColumnsWidth(const qreal &new_cw) {
|
||||
columns_width = qBound(10.0, new_cw, 200.0);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Change la hauteur des en-tetes contenant les numeros de colonnes. Celle-ci
|
||||
doit rester comprise entre 5 et 50 px.
|
||||
*/
|
||||
void BorderInset::setColumnsHeaderHeight(const qreal &new_chh) {
|
||||
columns_header_height = qBound(5.0, new_chh, 50.0);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Change la hauteur des colonnes (et donc du cadre). Cette hauteur doit
|
||||
rester superieure a la hauteur des en-tetes de colonnes + 20px.
|
||||
*/
|
||||
void BorderInset::setColumnsHeight(const qreal &new_ch) {
|
||||
columns_height = qMax(columns_header_height + min_columns_height, new_ch);
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Change la largeur du cartouche. Cette largeur doit rester comprise entre
|
||||
100px et la largeur du cartouche
|
||||
*/
|
||||
void BorderInset::setInsetWidth(const qreal &new_iw) {
|
||||
inset_width = qMax(100.0, qMin(nb_columns * columns_width, new_iw));
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Change la hauteur du cartouche. Cette largeur doit rester comprise entre
|
||||
20px et la hauteur du cartouche.
|
||||
*/
|
||||
void BorderInset::setInsetHeight(const qreal &new_ih) {
|
||||
inset_height = qMax(20.0, qMin(columns_height, new_ih));
|
||||
updateRectangles();
|
||||
}
|
||||
|
||||
/**
|
||||
Ajuste la largeur du cartouche de facon a ce que celui-ci soit aussi large
|
||||
que le schema
|
||||
*/
|
||||
void BorderInset::adjustInsetToColumns() {
|
||||
setInsetWidth(nbColumn() * columnsWidth());
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -18,11 +18,10 @@
|
||||
#ifndef BORDERINSET_H
|
||||
#define BORDERINSET_H
|
||||
#include "insetproperties.h"
|
||||
#include "borderproperties.h"
|
||||
#include <QObject>
|
||||
#include <QRectF>
|
||||
#include <QPainter>
|
||||
#include <QDate>
|
||||
class QPainter;
|
||||
/**
|
||||
Cette classe represente l'ensemble bordure + cartouche qui encadre le
|
||||
schema electrique.
|
||||
@@ -40,51 +39,29 @@ class BorderInset : public QObject {
|
||||
|
||||
// methodes
|
||||
public:
|
||||
static int minNbColumns();
|
||||
static qreal minColumnsWidth();
|
||||
static int minNbRows();
|
||||
static qreal minRowsHeight();
|
||||
|
||||
void draw(QPainter *, qreal = 0.0, qreal = 0.0);
|
||||
|
||||
// methodes d'acces en lecture aux dimensions
|
||||
// colonnes
|
||||
/// @return le nombre de colonnes du schema
|
||||
int nbColumns() const { return(nb_columns); }
|
||||
/// @return la largeur des colonnes en pixels
|
||||
qreal columnsWidth() const { return(columns_width); }
|
||||
/// @return la taille de l'ensemble des colonnes, en-tete des lignes non inclus
|
||||
qreal columnsTotalWidth() const { return(nb_columns * columns_width); }
|
||||
int nbColumn() const { return(nb_columns); }
|
||||
/// @return la taille des colonnes en pixels
|
||||
qreal columnsWidth() const { return(columns_width); }
|
||||
/// @return la hauteur, en pixels, des en-tetes des colonnes
|
||||
qreal columnsHeaderHeight() const { return(columns_header_height); }
|
||||
|
||||
// lignes
|
||||
/// @return le nombre de lignes du schema
|
||||
int nbRows() const { return(nb_rows); }
|
||||
/// @return la hauteur des lignes en pixels
|
||||
qreal rowsHeight() const { return(rows_height); }
|
||||
/// @return la taille de l'ensemble des lignes, en-tete des colonnes non inclus
|
||||
qreal rowsTotalHeight() const { return(nb_rows * rows_height); }
|
||||
/// @return la largeur, en pixels, des en-tetes des lignes
|
||||
qreal rowsHeaderWidth() const { return(rows_header_width); }
|
||||
|
||||
// cadre sans le cartouche = schema
|
||||
/// @return la largeur du schema, c'est-a-dire du cadre sans le cartouche
|
||||
qreal diagramWidth() const { return(columnsTotalWidth() + rowsHeaderWidth()); }
|
||||
/// @return la hauteurdu schema, c'est-a-dire du cadre sans le cartouche
|
||||
qreal diagramHeight() const { return(rowsTotalHeight() + columnsHeaderHeight()); }
|
||||
|
||||
// cartouche
|
||||
qreal columnsHeaderHeight() const { return(columns_header_height); }
|
||||
/// @return la hauteur des colonnes, en-tetes inclus
|
||||
qreal columnsHeight() const { return(columns_height); }
|
||||
/// @return la largeur de la bordure
|
||||
qreal borderWidth() const { return(nb_columns * columns_width); }
|
||||
/// @return la hauteur de la bordure
|
||||
qreal borderHeight() const { return(columns_height + inset_height); }
|
||||
/// @return la largeur du cartouche
|
||||
qreal insetWidth() const { return(inset_width); }
|
||||
qreal insetWidth() const { return(inset_width); }
|
||||
/// @return la hauteur du cartouche
|
||||
qreal insetHeight() const { return(inset_height); }
|
||||
|
||||
// cadre avec le cartouche
|
||||
/// @return la hauteur de la bordure
|
||||
qreal borderWidth() const { return(diagramWidth()); }
|
||||
/// @return la hauteur de la bordure
|
||||
qreal borderHeight() const { return(diagramHeight() + insetHeight()); }
|
||||
qreal insetHeight() const { return(inset_height); }
|
||||
/// @return la hauteur minimale acceptee des colonnes
|
||||
qreal minColumnsHeight() const { return(min_columns_height); }
|
||||
/// @return le nombre minimum accepte de colonnes
|
||||
int minNbColumns() const { return(min_nb_columns); }
|
||||
|
||||
// methodes d'acces en lecture aux informations du cartouche
|
||||
/// @return le champ "Auteur" du cartouche
|
||||
@@ -103,23 +80,16 @@ class BorderInset : public QObject {
|
||||
bool insetIsDisplayed() const { return(display_inset); }
|
||||
/// @return true si les entetes des colonnes sont affiches, false sinon
|
||||
bool columnsAreDisplayed() const { return(display_columns); }
|
||||
/// @return true si les entetes des lignes sont affiches, false sinon
|
||||
bool rowsAreDisplayed() const { return(display_rows); }
|
||||
/// @return true si la bordure est affichee, false sinon
|
||||
bool borderIsDisplayed() const { return(display_border); }
|
||||
|
||||
// methodes d'acces en ecriture aux dimensions
|
||||
void addColumn ();
|
||||
void addRow ();
|
||||
void removeColumn ();
|
||||
void removeRow ();
|
||||
void setNbColumns (int);
|
||||
void setNbRows (int);
|
||||
void setColumnsWidth (const qreal &);
|
||||
void setRowsHeight (const qreal &);
|
||||
void setColumnsHeaderHeight(const qreal &);
|
||||
void setRowsHeaderWidth (const qreal &);
|
||||
void setDiagramHeight (const qreal &);
|
||||
void setColumnsHeight (const qreal &);
|
||||
void setInsetWidth (const qreal &);
|
||||
void setInsetHeight (const qreal &);
|
||||
void adjustInsetToColumns ();
|
||||
@@ -136,20 +106,36 @@ class BorderInset : public QObject {
|
||||
/// @param filename le nouveau contenu du champ "Fichier"
|
||||
void setFileName (const QString &filename) { bi_filename = filename; }
|
||||
|
||||
InsetProperties exportInset();
|
||||
void importInset(const InsetProperties &);
|
||||
BorderProperties exportBorder();
|
||||
void importBorder(const BorderProperties &);
|
||||
/// @return les proprietes du cartouches
|
||||
InsetProperties exportInset() {
|
||||
InsetProperties ip;
|
||||
ip.author = bi_author;
|
||||
ip.date = bi_date;
|
||||
ip.title = bi_title;
|
||||
ip.folio = bi_folio;
|
||||
ip.filename = bi_filename;
|
||||
return(ip);
|
||||
}
|
||||
|
||||
/// @param ip les nouvelles proprietes du cartouche
|
||||
void importInset(const InsetProperties &ip) {
|
||||
bi_author = ip.author;
|
||||
bi_date = ip.date;
|
||||
bi_title = ip.title;
|
||||
bi_folio = ip.folio;
|
||||
bi_filename = ip.filename;
|
||||
}
|
||||
|
||||
// methodes d'acces en ecriture aux options
|
||||
void displayInset(bool);
|
||||
void displayColumns(bool);
|
||||
void displayRows(bool);
|
||||
void displayBorder(bool);
|
||||
/// @param di true pour afficher le cartouche, false sinon
|
||||
void displayInset (bool di) { display_inset = di; }
|
||||
/// @param dc true pour afficher les entetes des colonnes, false sinon
|
||||
void displayColumns (bool dc) { display_columns = dc; }
|
||||
/// @param db true pour afficher la bordure du schema, false sinon
|
||||
void displayBorder (bool db) { display_border = db; }
|
||||
|
||||
private:
|
||||
void updateRectangles();
|
||||
QString incrementLetters(const QString &);
|
||||
|
||||
// signaux
|
||||
signals:
|
||||
@@ -159,10 +145,6 @@ class BorderInset : public QObject {
|
||||
@param new_border Nouvelle bordure
|
||||
*/
|
||||
void borderChanged(QRectF old_border, QRectF new_border);
|
||||
/**
|
||||
Signal emise lorsque des options d'affichage change
|
||||
*/
|
||||
void displayChanged();
|
||||
|
||||
// attributs
|
||||
private:
|
||||
@@ -173,23 +155,18 @@ class BorderInset : public QObject {
|
||||
QString bi_folio;
|
||||
QString bi_filename;
|
||||
|
||||
// dimensions du cadre (lignes et colonnes)
|
||||
// colonnes : nombres et dimensions
|
||||
// dimensions du cadre et du cartouche
|
||||
int nb_columns;
|
||||
int min_nb_columns;
|
||||
qreal columns_width;
|
||||
qreal columns_header_height;
|
||||
|
||||
// lignes : nombres et dimensions
|
||||
int nb_rows;
|
||||
qreal rows_height;
|
||||
qreal rows_header_width;
|
||||
|
||||
// dimensions du cartouche
|
||||
qreal columns_height;
|
||||
qreal min_columns_height;
|
||||
qreal inset_width;
|
||||
qreal inset_height;
|
||||
|
||||
// rectangles utilises pour le dessin
|
||||
QRectF diagram;
|
||||
QRectF border;
|
||||
QRectF inset;
|
||||
QRectF inset_author;
|
||||
QRectF inset_date;
|
||||
@@ -200,7 +177,6 @@ class BorderInset : public QObject {
|
||||
// booleens pour les options de dessin
|
||||
bool display_inset;
|
||||
bool display_columns;
|
||||
bool display_rows;
|
||||
bool display_border;
|
||||
};
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -16,11 +16,9 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <QtDebug>
|
||||
#include <limits>
|
||||
#include "conductor.h"
|
||||
#include "conductorsegment.h"
|
||||
#include "conductorsegmentprofile.h"
|
||||
#include "diagramtextitem.h"
|
||||
#include "element.h"
|
||||
#include "diagram.h"
|
||||
#include "diagramcommands.h"
|
||||
@@ -38,14 +36,11 @@ QBrush Conductor::square_brush = QBrush(Qt::darkGreen);
|
||||
@param scene QGraphicsScene a laquelle appartient le conducteur
|
||||
*/
|
||||
Conductor::Conductor(Terminal *p1, Terminal* p2, Element *parent, QGraphicsScene *scene) :
|
||||
QObject(),
|
||||
QGraphicsPathItem(parent, scene),
|
||||
terminal1(p1),
|
||||
terminal2(p2),
|
||||
destroyed(false),
|
||||
segments(NULL),
|
||||
moving_point(false),
|
||||
moving_segment(false),
|
||||
previous_z_value(zValue()),
|
||||
modified_path(false),
|
||||
has_to_save_profile(false)
|
||||
@@ -88,12 +83,6 @@ Conductor::Conductor(Terminal *p1, Terminal* p2, Element *parent, QGraphicsScene
|
||||
text_item -> previous_text = properties_.text;
|
||||
calculateTextItemPosition();
|
||||
text_item -> setParentItem(this);
|
||||
connect(
|
||||
text_item,
|
||||
SIGNAL(diagramTextChanged(DiagramTextItem *, const QString &, const QString &)),
|
||||
this,
|
||||
SLOT(displayedTextChanged())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -931,7 +920,7 @@ QDomElement Conductor::toXml(QDomDocument &d, QHash<Terminal *, int> &table_adr_
|
||||
foreach(ConductorSegment *segment, segmentsList()) {
|
||||
current_segment = d.createElement("segment");
|
||||
current_segment.setAttribute("orientation", segment -> isHorizontal() ? "horizontal" : "vertical");
|
||||
current_segment.setAttribute("length", QString("%1").arg(segment -> length()));
|
||||
current_segment.setAttribute("length", segment -> length());
|
||||
e.appendChild(current_segment);
|
||||
}
|
||||
}
|
||||
@@ -1091,25 +1080,6 @@ void Conductor::readProperties() {
|
||||
text_item -> setVisible(properties_.type == ConductorProperties::Multi);
|
||||
}
|
||||
|
||||
/**
|
||||
Met a jour les proprietes du conducteur apres modification du champ de texte affiche
|
||||
*/
|
||||
void Conductor::displayedTextChanged() {
|
||||
// verifie que le texte a reellement change
|
||||
if (text_item -> toPlainText() == properties_.text) return;
|
||||
|
||||
// initialise l'objet UndoCommand correspondant
|
||||
if (Diagram *my_diagram = diagram()) {
|
||||
ConductorProperties new_properties(properties_);
|
||||
new_properties.text = text_item -> toPlainText();
|
||||
|
||||
ChangeConductorPropertiesCommand *ccpc = new ChangeConductorPropertiesCommand(this);
|
||||
ccpc -> setOldSettings(properties_);
|
||||
ccpc -> setNewSettings(new_properties);
|
||||
my_diagram -> undoStack().push(ccpc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@return les conducteurs avec lesquels ce conducteur partage des bornes
|
||||
communes
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -21,17 +21,15 @@
|
||||
#include "terminal.h"
|
||||
#include "conductorprofile.h"
|
||||
#include "conductorproperties.h"
|
||||
#include "diagramtextitem.h"
|
||||
class ConductorSegment;
|
||||
class DiagramTextItem;
|
||||
class Element;
|
||||
typedef QPair<QPointF, Qt::Corner> ConductorBend;
|
||||
typedef QHash<Qt::Corner, ConductorProfile> ConductorProfilesGroup;
|
||||
/**
|
||||
Cette classe represente un conducteur. Un conducteur relie deux bornes d'element.
|
||||
*/
|
||||
class Conductor : public QObject, public QGraphicsPathItem {
|
||||
|
||||
Q_OBJECT
|
||||
class Conductor : public QGraphicsPathItem {
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
@@ -83,9 +81,6 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
||||
ConductorProfilesGroup profiles() const;
|
||||
void readProperties();
|
||||
|
||||
public slots:
|
||||
void displayedTextChanged();
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -16,7 +16,6 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "conductorpropertieswidget.h"
|
||||
#include <QtGui>
|
||||
#include "conductor.h"
|
||||
|
||||
/**
|
||||
@@ -47,7 +46,6 @@ void ConductorPropertiesWidget::buildInterface() {
|
||||
setMinimumSize(380, 280);
|
||||
|
||||
QVBoxLayout *main_layout = new QVBoxLayout(this);
|
||||
main_layout -> setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QGroupBox *groupbox = new QGroupBox(tr("Type de conducteur"));
|
||||
main_layout -> addWidget(groupbox);
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -17,9 +17,8 @@
|
||||
*/
|
||||
#ifndef CONDUCTOR_PROPERTIES_WIDGET_H
|
||||
#define CONDUCTOR_PROPERTIES_WIDGET_H
|
||||
#include "conductorproperties.h"
|
||||
#include <QWidget>
|
||||
|
||||
#include "conductor.h"
|
||||
#include <QtGui>
|
||||
/**
|
||||
Ce widget permet a l utilisateur d'editer les proprietes d'un conducteur.
|
||||
Par proprietes, on entend non pas le trajet effectue par le conducteur mais
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -16,12 +16,7 @@
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "configpages.h"
|
||||
#include "borderpropertieswidget.h"
|
||||
#include "conductorpropertieswidget.h"
|
||||
#include "insetpropertieswidget.h"
|
||||
#include "qetapp.h"
|
||||
#include "qetdiagrameditor.h"
|
||||
#include "borderinset.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@@ -32,17 +27,10 @@ NewDiagramPage::NewDiagramPage(QWidget *parent) : ConfigPage(parent) {
|
||||
// acces a la configuration de QElectroTech
|
||||
QSettings &settings = QETApp::settings();
|
||||
|
||||
// dimensions par defaut d'un schema
|
||||
bpw = new BorderPropertiesWidget(QETDiagramEditor::defaultBorderProperties());
|
||||
|
||||
// proprietes par defaut d'un cartouche
|
||||
ipw = new InsetPropertiesWidget(QETDiagramEditor::defaultInsetProperties(), true);
|
||||
|
||||
// proprietes par defaut des conducteurs
|
||||
ConductorProperties cp;
|
||||
cp.fromSettings(settings, "diagrameditor/defaultconductor");
|
||||
cpw = new ConductorPropertiesWidget(cp);
|
||||
cpw -> setContentsMargins(0, 0, 0, 0);
|
||||
// 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();
|
||||
|
||||
@@ -56,9 +44,45 @@ NewDiagramPage::NewDiagramPage(QWidget *parent) : ConfigPage(parent) {
|
||||
QHBoxLayout *hlayout1 = new QHBoxLayout();
|
||||
QVBoxLayout *vlayout2 = new QVBoxLayout();
|
||||
|
||||
vlayout2 -> addWidget(bpw);
|
||||
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);
|
||||
vlayout2 -> setSpacing(5);
|
||||
hlayout1 -> addLayout(vlayout2);
|
||||
hlayout1 -> addWidget(cpw);
|
||||
vlayout1 -> addLayout(hlayout1);
|
||||
@@ -78,13 +102,9 @@ void NewDiagramPage::applyConf() {
|
||||
QSettings &settings = QETApp::settings();
|
||||
|
||||
// dimensions des nouveaux schemas
|
||||
BorderProperties border = bpw -> borderProperties();
|
||||
settings.setValue("diagrameditor/defaultcols", border.columns_count);
|
||||
settings.setValue("diagrameditor/defaultcolsize", border.columns_width);
|
||||
settings.setValue("diagrameditor/defaultdisplaycols", border.display_columns);
|
||||
settings.setValue("diagrameditor/defaultrows", border.rows_count);
|
||||
settings.setValue("diagrameditor/defaultrowsize", border.rows_height);
|
||||
settings.setValue("diagrameditor/defaultdisplayrows", border.display_rows);
|
||||
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();
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -18,9 +18,8 @@
|
||||
#ifndef CONFIG_PAGES_H
|
||||
#define CONFIG_PAGES_H
|
||||
#include <QtGui>
|
||||
class BorderPropertiesWidget;
|
||||
class ConductorPropertiesWidget;
|
||||
class InsetPropertiesWidget;
|
||||
#include "conductorpropertieswidget.h"
|
||||
#include "insetpropertieswidget.h"
|
||||
|
||||
/**
|
||||
Cette classe abstraite contient les methodes que toutes les pages de
|
||||
@@ -64,7 +63,9 @@ class NewDiagramPage : public ConfigPage {
|
||||
|
||||
// attributs
|
||||
public:
|
||||
BorderPropertiesWidget *bpw; ///< Widget d'edition des dimensions du schema
|
||||
QSpinBox *columns_count; ///< Widget d'edition du nombre par defaut de colonnes
|
||||
QSpinBox *columns_width; ///< Widget d'edition de la largeur par defaut des colonnes
|
||||
QSpinBox *columns_height; ///< Widget d'edition de la hauteur par defaut des colonnes
|
||||
InsetPropertiesWidget *ipw; ///< Widget d'edition des proprietes par defaut du cartouche
|
||||
ConductorPropertiesWidget *cpw; ///< Widget d'edition des proprietes par defaut des conducteurs
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -86,7 +86,7 @@ CustomElement::CustomElement(QString &nom_fichier, QGraphicsItem *qgi, Diagram *
|
||||
QObject::tr("Avertissement : l'\351l\351ment ") + nom_fichier
|
||||
+ QObject::tr(" a \351t\351 enregistr\351 avec une version"
|
||||
" ult\351rieure de QElectroTech.")
|
||||
) << std::endl;
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ CustomElement::CustomElement(QString &nom_fichier, QGraphicsItem *qgi, Diagram *
|
||||
QPen t;
|
||||
t.setColor(Qt::black);
|
||||
t.setWidthF(1.0);
|
||||
t.setJoinStyle(Qt::BevelJoin);
|
||||
t.setJoinStyle(Qt::MiterJoin);
|
||||
qp.setPen(t);
|
||||
|
||||
// extrait les noms de la definition XML
|
||||
@@ -418,8 +418,8 @@ bool CustomElement::parseInput(QDomElement &e) {
|
||||
) return(false);
|
||||
|
||||
ElementTextItem *eti = new ElementTextItem(e.attribute("text"), this);
|
||||
eti -> setFont(QFont(QETApp::diagramTextsFont(), size));
|
||||
eti -> setPos(pos_x, pos_y);
|
||||
eti -> setOriginalPos(QPointF(pos_x, pos_y));
|
||||
if (e.attribute("rotate") == "true") eti -> setFollowParentRotations(true);
|
||||
return(true);
|
||||
}
|
||||
@@ -513,7 +513,7 @@ void CustomElement::setPainterStyle(QDomElement &e, QPainter &qp) {
|
||||
QBrush brush = qp.brush();
|
||||
|
||||
// attributs par defaut
|
||||
pen.setJoinStyle(Qt::BevelJoin);
|
||||
pen.setJoinStyle(Qt::MiterJoin);
|
||||
pen.setCapStyle(Qt::SquareCap);
|
||||
pen.setColor(Qt::black);
|
||||
pen.setStyle(Qt::SolidLine);
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -37,10 +37,9 @@ Diagram::Diagram(QObject *parent) :
|
||||
draw_grid(true),
|
||||
use_border(true),
|
||||
moved_elements_fetched(false),
|
||||
qgi_manager(this),
|
||||
draw_terminals(true)
|
||||
{
|
||||
undo_stack = new QUndoStack();
|
||||
qgi_manager = new QGIManager(this);
|
||||
setBackgroundBrush(Qt::white);
|
||||
conductor_setter = new QGraphicsLineItem(0, 0);
|
||||
conductor_setter -> setZValue(1000000);
|
||||
@@ -60,23 +59,8 @@ Diagram::Diagram(QObject *parent) :
|
||||
Destructeur
|
||||
*/
|
||||
Diagram::~Diagram() {
|
||||
// suppression de la liste des annulations - l'undo stack fait appel au qgimanager pour supprimer certains elements
|
||||
delete undo_stack;
|
||||
// suppression du QGIManager - tous les elements qu'il connait sont supprimes
|
||||
delete qgi_manager;
|
||||
|
||||
// recense les items supprimables
|
||||
QList<QGraphicsItem *> deletable_items;
|
||||
foreach(QGraphicsItem *qgi, items()) {
|
||||
if (qgi -> parentItem()) continue;
|
||||
if (qgraphicsitem_cast<Conductor *>(qgi)) continue;
|
||||
deletable_items << qgi;
|
||||
}
|
||||
|
||||
// suppression des items supprimables
|
||||
foreach(QGraphicsItem *qgi_d, deletable_items) {
|
||||
delete qgi_d;
|
||||
}
|
||||
if (conductor_setter -> scene()) removeItem(conductor_setter);
|
||||
delete conductor_setter;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,14 +231,9 @@ QDomDocument Diagram::toXml(bool diagram) {
|
||||
if (!border_and_inset.title().isNull()) racine.setAttribute("title", border_and_inset.title());
|
||||
if (!border_and_inset.fileName().isNull()) racine.setAttribute("filename", border_and_inset.fileName());
|
||||
if (!border_and_inset.folio().isNull()) racine.setAttribute("folio", border_and_inset.folio());
|
||||
racine.setAttribute("cols", border_and_inset.nbColumns());
|
||||
racine.setAttribute("colsize", QString("%1").arg(border_and_inset.columnsWidth()));
|
||||
racine.setAttribute("rows", border_and_inset.nbRows());
|
||||
racine.setAttribute("rowsize", QString("%1").arg(border_and_inset.rowsHeight()));
|
||||
// attribut datant de la version 0.1 - laisse pour retrocompatibilite
|
||||
racine.setAttribute("height", QString("%1").arg(border_and_inset.diagramHeight()));
|
||||
racine.setAttribute("displaycols", border_and_inset.columnsAreDisplayed() ? "true" : "false");
|
||||
racine.setAttribute("displayrows", border_and_inset.rowsAreDisplayed() ? "true" : "false");
|
||||
racine.setAttribute("cols", border_and_inset.nbColumn());
|
||||
racine.setAttribute("colsize", border_and_inset.columnsWidth());
|
||||
racine.setAttribute("height", border_and_inset.columnsHeight());
|
||||
|
||||
// type de conducteur par defaut
|
||||
QDomElement default_conductor = document.createElement("defaultconductor");
|
||||
@@ -358,24 +337,9 @@ bool Diagram::fromXml(QDomDocument &document, QPointF position, bool consider_in
|
||||
double col_size = root.attribute("colsize").toDouble(&ok);
|
||||
if (ok) border_and_inset.setColumnsWidth(col_size);
|
||||
|
||||
// retrocompatibilite : les schemas enregistres avec la 0.1 ont un attribut "height"
|
||||
if (root.hasAttribute("rows") && root.hasAttribute("rowsize")) {
|
||||
// nombre de lignes
|
||||
int nb_rows = root.attribute("rows").toInt(&ok);
|
||||
if (ok) border_and_inset.setNbRows(nb_rows);
|
||||
|
||||
// taille des lignes
|
||||
double row_size = root.attribute("rowsize").toDouble(&ok);
|
||||
if (ok) border_and_inset.setRowsHeight(row_size);
|
||||
} else {
|
||||
// hauteur du schema
|
||||
double height = root.attribute("height").toDouble(&ok);
|
||||
if (ok) border_and_inset.setDiagramHeight(height);
|
||||
}
|
||||
|
||||
// affichage des lignes et colonnes
|
||||
border_and_inset.displayColumns(root.attribute("displaycols") != "false");
|
||||
border_and_inset.displayRows(root.attribute("displayrows") != "false");
|
||||
// hauteur du schema
|
||||
double height = root.attribute("height").toDouble(&ok);
|
||||
if (ok) border_and_inset.setColumnsHeight(height);
|
||||
|
||||
border_and_inset.adjustInsetToColumns();
|
||||
|
||||
@@ -497,17 +461,6 @@ bool Diagram::fromXml(QDomDocument &document, QPointF position, bool consider_in
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
Gere le fait qu'un texte du schema ait ete modifie
|
||||
@param text_item Texte modifie
|
||||
@param old_text Ancien texte
|
||||
@param new_text Nouveau texte
|
||||
*/
|
||||
void Diagram::diagramTextChanged(DiagramTextItem *text_item, const QString &old_text, const QString &new_text) {
|
||||
if (!text_item) return;
|
||||
undo_stack -> push(new ChangeDiagramTextCommand(text_item, old_text, new_text));
|
||||
}
|
||||
|
||||
/**
|
||||
Verifie si la selection est passe d'un etat ou elle est vide a un etat ou
|
||||
elle ne l'est pas, et inversement. Si c'est le cas, le signal
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -75,8 +75,8 @@ class Diagram : public QGraphicsScene {
|
||||
QSet<Conductor *> conductors_to_move;
|
||||
QHash<Conductor *, Terminal *> conductors_to_update;
|
||||
QSet<DiagramTextItem *> texts_to_move;
|
||||
QGIManager *qgi_manager;
|
||||
QUndoStack *undo_stack;
|
||||
QGIManager qgi_manager;
|
||||
QUndoStack undo_stack;
|
||||
bool draw_terminals;
|
||||
|
||||
// methodes
|
||||
@@ -126,9 +126,6 @@ class Diagram : public QGraphicsScene {
|
||||
QUndoStack &undoStack();
|
||||
QGIManager &qgiManager();
|
||||
|
||||
public slots:
|
||||
void diagramTextChanged(DiagramTextItem *, const QString &, const QString &);
|
||||
|
||||
private slots:
|
||||
void slot_checkSelectionEmptinessChange();
|
||||
|
||||
@@ -253,12 +250,12 @@ inline const QSet<DiagramTextItem *> &Diagram::textsToMove() {
|
||||
|
||||
/// @return la pile d'annulations de ce schema
|
||||
inline QUndoStack &Diagram::undoStack() {
|
||||
return(*undo_stack);
|
||||
return(undo_stack);
|
||||
}
|
||||
|
||||
/// @return le egstionnaire de QGraphicsItem de ce schema
|
||||
inline QGIManager &Diagram::qgiManager() {
|
||||
return(*qgi_manager);
|
||||
return(qgi_manager);
|
||||
}
|
||||
|
||||
/// @return true si les bornes sont affichees, false sinon
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -81,23 +81,11 @@ AddTextCommand::~AddTextCommand() {
|
||||
|
||||
/// Annule l'ajout
|
||||
void AddTextCommand::undo() {
|
||||
QObject::disconnect(
|
||||
textitem,
|
||||
SIGNAL(diagramTextChanged(DiagramTextItem *, const QString &, const QString &)),
|
||||
diagram,
|
||||
SLOT(diagramTextChanged(DiagramTextItem *, const QString &, const QString &))
|
||||
);
|
||||
diagram -> removeItem(textitem);
|
||||
}
|
||||
|
||||
/// Refait l'ajour
|
||||
void AddTextCommand::redo() {
|
||||
QObject::connect(
|
||||
textitem,
|
||||
SIGNAL(diagramTextChanged(DiagramTextItem *, const QString &, const QString &)),
|
||||
diagram,
|
||||
SLOT(diagramTextChanged(DiagramTextItem *, const QString &, const QString &))
|
||||
);
|
||||
diagram -> addItem(textitem);
|
||||
textitem -> setPos(position);
|
||||
}
|
||||
@@ -536,11 +524,13 @@ void ChangeInsetCommand::redo() {
|
||||
@param dia Schema modifie
|
||||
@param parent QUndoCommand parent
|
||||
*/
|
||||
ChangeBorderCommand::ChangeBorderCommand(Diagram *dia, const BorderProperties &old_bp, const BorderProperties &new_bp, QUndoCommand *parent) :
|
||||
ChangeBorderCommand::ChangeBorderCommand(Diagram *dia, QUndoCommand *parent) :
|
||||
QUndoCommand(QObject::tr("modifier les dimensions du sch\351ma"), parent),
|
||||
diagram(dia),
|
||||
old_properties(old_bp),
|
||||
new_properties(new_bp)
|
||||
columnsCountDifference(0),
|
||||
columnsHeightDifference(0.0),
|
||||
columnsWidthDifference(0.0),
|
||||
headersHeightDifference(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -548,14 +538,39 @@ ChangeBorderCommand::ChangeBorderCommand(Diagram *dia, const BorderProperties &o
|
||||
ChangeBorderCommand::~ChangeBorderCommand() {
|
||||
}
|
||||
|
||||
/**
|
||||
Applique les changements au schema
|
||||
@param coeff comme les changements s'expriment sous forme de nombres dont
|
||||
il suffit d'inverser le signe pour les annuler, ces valeurs sont ici
|
||||
multipliees par le coefficient passe en parametre avant d'etre appliquees.
|
||||
Pour resumer : 1 pour refaire, -1 pour annuler.
|
||||
*/
|
||||
void ChangeBorderCommand::applyChanges(int coeff) {
|
||||
// reference vers l'objet border_and_inset du schema
|
||||
BorderInset &border = diagram -> border_and_inset;
|
||||
if (columnsCountDifference) {
|
||||
border.setNbColumns(border.nbColumn() + (columnsCountDifference * coeff));
|
||||
}
|
||||
if (columnsHeightDifference) {
|
||||
border.setColumnsHeight(border.columnsHeight() + (columnsHeightDifference * coeff));
|
||||
}
|
||||
if (columnsWidthDifference) {
|
||||
border.setColumnsWidth(border.columnsWidth() + (columnsWidthDifference * coeff));
|
||||
}
|
||||
if (headersHeightDifference) {
|
||||
border.setColumnsHeaderHeight(border.columnsHeaderHeight() + (headersHeightDifference * coeff));
|
||||
}
|
||||
border.adjustInsetToColumns();
|
||||
}
|
||||
|
||||
/// Annule les changements apportes au schema
|
||||
void ChangeBorderCommand::undo() {
|
||||
diagram -> border_and_inset.importBorder(old_properties);
|
||||
applyChanges(-1);
|
||||
}
|
||||
|
||||
/// Refait les changements apportes au schema
|
||||
void ChangeBorderCommand::redo() {
|
||||
diagram -> border_and_inset.importBorder(new_properties);
|
||||
applyChanges(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -22,9 +22,7 @@
|
||||
#include "diagramcontent.h"
|
||||
#include "diagramtextitem.h"
|
||||
#include "conductor.h"
|
||||
#include "borderproperties.h"
|
||||
#include "conductorproperties.h"
|
||||
#include "insetproperties.h"
|
||||
#include <QtGui>
|
||||
/**
|
||||
Cette classe represente l'action d'ajouter un element au schema
|
||||
@@ -327,12 +325,16 @@ class ChangeInsetCommand : public QUndoCommand {
|
||||
};
|
||||
|
||||
/**
|
||||
Cette classe represente l'action de modifier les dimensions d'un schema
|
||||
Cette classe represente l'action de modifier :
|
||||
-le nombre de colonnes d'un schema
|
||||
-la hauteur des colonnes
|
||||
-la largeur des colonnes
|
||||
-la hauteur des en-tetes des colonnes
|
||||
*/
|
||||
class ChangeBorderCommand : public QUndoCommand {
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
ChangeBorderCommand(Diagram *, const BorderProperties &, const BorderProperties &, QUndoCommand * = 0);
|
||||
ChangeBorderCommand(Diagram *, QUndoCommand * = 0);
|
||||
virtual ~ChangeBorderCommand();
|
||||
private:
|
||||
ChangeBorderCommand(const ChangeBorderCommand &);
|
||||
@@ -341,16 +343,22 @@ class ChangeBorderCommand : public QUndoCommand {
|
||||
public:
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
private:
|
||||
virtual void applyChanges(int = 1);
|
||||
|
||||
// attributs
|
||||
private:
|
||||
/// schema modifie
|
||||
Diagram *diagram;
|
||||
public:
|
||||
/// anciennes dimensions du schema
|
||||
BorderProperties old_properties;
|
||||
/// nouvelles dimensions du schema
|
||||
BorderProperties new_properties;
|
||||
/// nombre de colonnes ajoutees / enlevees
|
||||
int columnsCountDifference;
|
||||
/// delta pour la hauteur des colonnes
|
||||
qreal columnsHeightDifference;
|
||||
/// delta pour la largeur des colonnes
|
||||
qreal columnsWidthDifference;
|
||||
/// delta pour la hauteur des entetes des colonnes
|
||||
qreal headersHeightDifference;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -119,15 +119,12 @@ QString DiagramContent::sentence(int filter) const {
|
||||
@param d Object QDebug a utiliser pour l'affichage des informations de debug
|
||||
@param c Contenu de schema a debugger
|
||||
*/
|
||||
QDebug &operator<<(QDebug d, DiagramContent &) {
|
||||
QDebug &operator<<(QDebug d, DiagramContent &c) {
|
||||
d << "DiagramContent {" << "\n";
|
||||
/*
|
||||
FIXME Le double-heritage QObject / QGraphicsItem a casse cet operateur
|
||||
d << " elements :" << c.elements << "\n";
|
||||
d << " conductorsToUpdate :" << c.conductorsToUpdate.keys() << "\n";
|
||||
d << " conductorsToMove :" << c.conductorsToMove << "\n";
|
||||
d << " otherConductors :" << c.otherConductors << "\n";
|
||||
*/
|
||||
d << "}";
|
||||
return(d.space());
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
#include "diagramtextitem.h"
|
||||
#include "diagramcommands.h"
|
||||
#include "qetapp.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@@ -28,7 +27,6 @@ DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, QGraphicsScene *scene) :
|
||||
QGraphicsTextItem(parent, scene)
|
||||
{
|
||||
setDefaultTextColor(Qt::black);
|
||||
setFont(QFont(QETApp::diagramTextsFont(), 9));
|
||||
setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
|
||||
connect(this, SIGNAL(lostFocus()), this, SLOT(setNonFocusable()));
|
||||
}
|
||||
@@ -44,7 +42,6 @@ DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, QGr
|
||||
previous_text(text)
|
||||
{
|
||||
setDefaultTextColor(Qt::black);
|
||||
setFont(QFont(QETApp::diagramTextsFont(), 9));
|
||||
setFlags(QGraphicsItem::ItemIsSelectable|QGraphicsItem::ItemIsMovable);
|
||||
connect(this, SIGNAL(lostFocus()), this, SLOT(setNonFocusable()));
|
||||
}
|
||||
@@ -63,10 +60,12 @@ Diagram *DiagramTextItem::diagram() const {
|
||||
*/
|
||||
void DiagramTextItem::focusOutEvent(QFocusEvent *e) {
|
||||
QGraphicsTextItem::focusOutEvent(e);
|
||||
// signale la modification du texte si besoin
|
||||
// si le texte a ete modifie
|
||||
if (toPlainText() != previous_text) {
|
||||
emit(diagramTextChanged(this, previous_text, toPlainText()));
|
||||
previous_text = toPlainText();
|
||||
if (Diagram *dia = diagram()) {
|
||||
dia -> undoStack().push(new ChangeDiagramTextCommand(this, previous_text, toPlainText()));
|
||||
previous_text = toPlainText();
|
||||
}
|
||||
}
|
||||
|
||||
// deselectionne le texte
|
||||
@@ -99,8 +98,8 @@ void DiagramTextItem::fromXml(const QDomElement &e) {
|
||||
*/
|
||||
QDomElement DiagramTextItem::toXml(QDomDocument &document) const {
|
||||
QDomElement result = document.createElement("input");
|
||||
result.setAttribute("x", QString("%1").arg(pos().x()));
|
||||
result.setAttribute("y", QString("%1").arg(pos().y()));
|
||||
result.setAttribute("x", pos().x());
|
||||
result.setAttribute("y", pos().y());
|
||||
result.setAttribute("text", toPlainText());
|
||||
return(result);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -59,8 +59,6 @@ class DiagramTextItem : public QGraphicsTextItem {
|
||||
signals:
|
||||
/// signal emis lorsque le champ de texte perd le focus
|
||||
void lostFocus();
|
||||
/// signal emis lorsque le champ de texte a ete modifie
|
||||
void diagramTextChanged(DiagramTextItem *, const QString &, const QString &);
|
||||
|
||||
// slots
|
||||
public slots:
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -19,19 +19,16 @@
|
||||
#include "diagram.h"
|
||||
#include "customelement.h"
|
||||
#include "exportdialog.h"
|
||||
#include "diagramprintdialog.h"
|
||||
#include "conductor.h"
|
||||
#include "diagramcommands.h"
|
||||
#include "conductorpropertieswidget.h"
|
||||
#include "insetpropertieswidget.h"
|
||||
#include "borderpropertieswidget.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@param parent Le QWidget parent de cette vue de schema
|
||||
@param parent Le QWidegt parent de cette vue de schema
|
||||
*/
|
||||
DiagramView::DiagramView(QWidget *parent) : QGraphicsView(parent), is_adding_text(false) {
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
setInteractive(true);
|
||||
setCacheMode(QGraphicsView::CacheBackground);
|
||||
setOptimizationFlags(QGraphicsView::DontSavePainterState|QGraphicsView::DontAdjustForAntialiasing);
|
||||
@@ -58,7 +55,6 @@ DiagramView::DiagramView(QWidget *parent) : QGraphicsView(parent), is_adding_tex
|
||||
|
||||
connect(scene, SIGNAL(selectionEmptinessChanged()), this, SIGNAL(selectionChanged()));
|
||||
connect(&(scene -> border_and_inset), SIGNAL(borderChanged(QRectF, QRectF)), this, SLOT(adjustSceneRect()));
|
||||
connect(&(scene -> border_and_inset), SIGNAL(displayChanged()), this, SLOT(adjustSceneRect()));
|
||||
connect(&(scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(updateWindowTitle()));
|
||||
}
|
||||
|
||||
@@ -69,7 +65,7 @@ DiagramView::~DiagramView() {
|
||||
}
|
||||
|
||||
/**
|
||||
Appelle la methode select sur tous les elements de la liste d'elements
|
||||
appelle la methode select sur tous les elements de la liste d'elements
|
||||
*/
|
||||
void DiagramView::selectAll() {
|
||||
if (scene -> items().isEmpty()) return;
|
||||
@@ -119,7 +115,7 @@ void DiagramView::rotateSelection() {
|
||||
}
|
||||
|
||||
/**
|
||||
Accepte ou refuse le drag'n drop en fonction du type de donnees entrant
|
||||
accepte ou refuse le drag'n drop en fonction du type de donnees entrant
|
||||
@param e le QDragEnterEvent correspondant au drag'n drop tente
|
||||
*/
|
||||
void DiagramView::dragEnterEvent(QDragEnterEvent *e) {
|
||||
@@ -128,14 +124,14 @@ void DiagramView::dragEnterEvent(QDragEnterEvent *e) {
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les dragleaveevent
|
||||
gere les dragleaveevent
|
||||
@param e le QDragEnterEvent correspondant au drag'n drop sortant
|
||||
*/
|
||||
void DiagramView::dragLeaveEvent(QDragLeaveEvent *) {
|
||||
}
|
||||
|
||||
/**
|
||||
Accepte ou refuse le drag'n drop en fonction du type de donnees entrant
|
||||
accepte ou refuse le drag'n drop en fonction du type de donnees entrant
|
||||
@param e le QDragMoveEvent correspondant au drag'n drop tente
|
||||
*/
|
||||
void DiagramView::dragMoveEvent(QDragMoveEvent *e) {
|
||||
@@ -144,7 +140,7 @@ void DiagramView::dragMoveEvent(QDragMoveEvent *e) {
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les depots (drop) acceptes sur le Diagram
|
||||
gere les depots (drop) acceptes sur le Diagram
|
||||
@param e le QDropEvent correspondant au drag'n drop effectue
|
||||
*/
|
||||
void DiagramView::dropEvent(QDropEvent *e) {
|
||||
@@ -212,7 +208,7 @@ void DiagramView::zoomReset() {
|
||||
}
|
||||
|
||||
/**
|
||||
Copie les elements selectionnes du schema dans le presse-papier puis les supprime
|
||||
copie les elements selectionnes du schema dans le presse-papier puis les supprime
|
||||
*/
|
||||
void DiagramView::cut() {
|
||||
copy();
|
||||
@@ -222,7 +218,7 @@ void DiagramView::cut() {
|
||||
}
|
||||
|
||||
/**
|
||||
Copie les elements selectionnes du schema dans le presse-papier
|
||||
copie les elements selectionnes du schema dans le presse-papier
|
||||
*/
|
||||
void DiagramView::copy() {
|
||||
QClipboard *presse_papier = QApplication::clipboard();
|
||||
@@ -262,17 +258,20 @@ void DiagramView::pasteHere() {
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les clics et plus particulierement :
|
||||
* le clic du milieu (= coller pour X11)
|
||||
* le clic pour ajouter un champ de texte independant
|
||||
gere les clics et plus particulierement le clic du milieu (= coller pour X11)
|
||||
*/
|
||||
void DiagramView::mousePressEvent(QMouseEvent *e) {
|
||||
if (e -> buttons() == Qt::MidButton) {
|
||||
paste(mapToScene(e -> pos()), QClipboard::Selection);
|
||||
} else {
|
||||
if (is_adding_text && e -> buttons() == Qt::LeftButton) {
|
||||
addDiagramTextAtPos(mapToScene(e -> pos()));
|
||||
DiagramTextItem *dti = new DiagramTextItem();
|
||||
dti -> setPlainText("_");
|
||||
dti -> previous_text = "_";
|
||||
scene -> undoStack().push(new AddTextCommand(scene, dti, e -> pos()));
|
||||
adjustSceneRect();
|
||||
is_adding_text = false;
|
||||
emit(textAdded(false));
|
||||
}
|
||||
QGraphicsView::mousePressEvent(e);
|
||||
}
|
||||
@@ -340,7 +339,7 @@ bool DiagramView::open(QString n_fichier, int *erreur) {
|
||||
qreal diagram_version = root.attribute("version").toDouble(&conv_ok);
|
||||
if (conv_ok && QET::version.toDouble() < diagram_version) {
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
0,
|
||||
tr("Avertissement"),
|
||||
tr("Ce document semble avoir \351t\351 enregistr\351 avec une "
|
||||
"version ult\351rieure de QElectroTech. Il est possible que "
|
||||
@@ -425,8 +424,10 @@ void DiagramView::closeEvent(QCloseEvent *event) {
|
||||
default: retour = true; // l'utilisateur dit non ou ferme le dialogue: c'est reussi
|
||||
}
|
||||
}
|
||||
if (retour) event -> accept();
|
||||
else event -> ignore();
|
||||
if (retour) {
|
||||
event -> accept();
|
||||
delete this;
|
||||
} else event -> ignore();
|
||||
|
||||
}
|
||||
|
||||
@@ -521,7 +522,7 @@ bool DiagramView::saveDiagramToFile(QString &n_fichier) {
|
||||
Exporte le schema.
|
||||
*/
|
||||
void DiagramView::dialogExport() {
|
||||
ExportDialog ed(scene, diagramEditor());
|
||||
ExportDialog ed(scene, this);
|
||||
ed.exec();
|
||||
}
|
||||
|
||||
@@ -529,41 +530,84 @@ void DiagramView::dialogExport() {
|
||||
Imprime le schema.
|
||||
*/
|
||||
void DiagramView::dialogPrint() {
|
||||
// initialise l'acces a l'imprimante
|
||||
QPrinter qprin;
|
||||
#ifndef Q_OS_WIN32
|
||||
qprin.setOutputFormat(QPrinter::PdfFormat);
|
||||
#endif
|
||||
qprin.setOrientation(QPrinter::Landscape);
|
||||
qprin.setPageSize(QPrinter::A4);
|
||||
QPrintDialog qpd(&qprin, this);
|
||||
|
||||
// determine un nom possible pour le document et le pdf
|
||||
QString doc_name;
|
||||
QString pdf_file_name;
|
||||
if (!file_name.isEmpty()) {
|
||||
doc_name = QFileInfo(file_name).fileName();
|
||||
pdf_file_name = file_name;
|
||||
pdf_file_name.replace(QRegExp("\\.qet$", Qt::CaseInsensitive), "");
|
||||
} else {
|
||||
doc_name = tr("schema");
|
||||
pdf_file_name = QDir::toNativeSeparators(QDir::homePath() + "/" + tr("schema"));
|
||||
if (qpd.exec() == QDialog::Accepted) {
|
||||
QPainter qp(&qprin);
|
||||
// impression physique (!= fichier PDF)
|
||||
if (qprin.outputFileName().isEmpty()) {
|
||||
// lorsqu'on imprime en paysage sur imprimante reelle, il faut pivoter soi-meme le rendu
|
||||
if (qprin.orientation() == QPrinter::Landscape) {
|
||||
qp.rotate(90.0);
|
||||
qp.translate(0.0, -qprin.pageRect().height());
|
||||
}
|
||||
}
|
||||
scene -> setDisplayGrid(false);
|
||||
scene -> setDrawTerminals(false);
|
||||
scene -> render(&qp, QRectF(), scene -> border(), Qt::KeepAspectRatio);
|
||||
scene -> setDrawTerminals(true);
|
||||
scene -> setDisplayGrid(true);
|
||||
}
|
||||
pdf_file_name += ".pdf";
|
||||
|
||||
DiagramPrintDialog print_dialog(scene, this);
|
||||
print_dialog.setDocName(doc_name);
|
||||
print_dialog.setPDFName(pdf_file_name);
|
||||
print_dialog.exec();
|
||||
}
|
||||
|
||||
/**
|
||||
Edite les informations du schema.
|
||||
*/
|
||||
void DiagramView::dialogEditInfos() {
|
||||
// recupere le cartouche et les dimensions du schema
|
||||
InsetProperties inset = scene -> border_and_inset.exportInset();
|
||||
BorderProperties border = scene -> border_and_inset.exportBorder();
|
||||
// recupere le cartouche du schema
|
||||
InsetProperties inset = scene -> border_and_inset.exportInset();
|
||||
|
||||
// recupere les dimensions du schema
|
||||
int columns_count_value = scene -> border_and_inset.nbColumn();
|
||||
int columns_width_value = qRound(scene -> border_and_inset.columnsWidth());
|
||||
int columns_height_value = qRound(scene -> border_and_inset.columnsHeight());
|
||||
|
||||
// construit le dialogue
|
||||
QDialog popup(diagramEditor());
|
||||
QDialog popup;
|
||||
popup.setMinimumWidth(400);
|
||||
popup.setWindowTitle(tr("Propri\351t\351s du sch\351ma"));
|
||||
|
||||
BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, &popup);
|
||||
InsetPropertiesWidget *inset_infos = new InsetPropertiesWidget(inset, false, &popup);
|
||||
QGroupBox *diagram_size_box = new QGroupBox(tr("Dimensions du sch\351ma"), &popup);
|
||||
QGridLayout diagram_size_box_layout(diagram_size_box);
|
||||
|
||||
QLabel *ds1 = new QLabel(tr("Colonnes :"));
|
||||
|
||||
QSpinBox *columns_count = new QSpinBox(diagram_size_box);
|
||||
columns_count -> setMinimum(scene -> border_and_inset.minNbColumns());
|
||||
columns_count -> setValue(columns_count_value);
|
||||
|
||||
QSpinBox *columns_width = new QSpinBox(diagram_size_box);
|
||||
columns_width -> setMinimum(1);
|
||||
columns_width -> setSingleStep(10);
|
||||
columns_width -> setValue(columns_width_value);
|
||||
columns_width -> setPrefix(tr("\327"));
|
||||
columns_width -> setSuffix(tr("px"));
|
||||
|
||||
QLabel *ds2 = new QLabel(tr("Hauteur :"));
|
||||
|
||||
QSpinBox *columns_height = new QSpinBox(diagram_size_box);
|
||||
columns_height -> setRange(qRound(scene -> border_and_inset.minColumnsHeight()), 10000);
|
||||
columns_height -> setSingleStep(80);
|
||||
columns_height -> setValue(columns_height_value);
|
||||
|
||||
diagram_size_box_layout.addWidget(ds1, 0, 0);
|
||||
diagram_size_box_layout.addWidget(columns_count, 0, 1);
|
||||
diagram_size_box_layout.addWidget(columns_width, 0, 2);
|
||||
diagram_size_box_layout.addWidget(ds2, 1, 0);
|
||||
diagram_size_box_layout.addWidget(columns_height, 1, 1);
|
||||
diagram_size_box_layout.setColumnStretch(0, 1);
|
||||
diagram_size_box_layout.setColumnStretch(1, 1);
|
||||
diagram_size_box_layout.setColumnStretch(2, 1);
|
||||
diagram_size_box_layout.setColumnStretch(3, 500);
|
||||
|
||||
InsetPropertiesWidget *inset_infos = new InsetPropertiesWidget(inset, false, &popup);
|
||||
|
||||
// boutons
|
||||
QDialogButtonBox boutons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
@@ -572,22 +616,30 @@ void DiagramView::dialogEditInfos() {
|
||||
|
||||
// ajout dans une disposition verticale
|
||||
QVBoxLayout layout_v(&popup);
|
||||
layout_v.addWidget(border_infos);
|
||||
layout_v.addWidget(diagram_size_box);
|
||||
layout_v.addWidget(inset_infos);
|
||||
layout_v.addStretch();
|
||||
layout_v.addWidget(&boutons);
|
||||
// si le dialogue est accepte
|
||||
if (popup.exec() == QDialog::Accepted) {
|
||||
InsetProperties new_inset = inset_infos -> insetProperties();
|
||||
BorderProperties new_border = border_infos -> borderProperties();
|
||||
InsetProperties new_inset = inset_infos -> insetProperties();
|
||||
|
||||
// s'il y a des modifications au cartouche
|
||||
if (new_inset != inset) {
|
||||
scene -> undoStack().push(new ChangeInsetCommand(scene, inset, new_inset));
|
||||
}
|
||||
|
||||
// s'il y a des modifications aux dimensions du schema
|
||||
if (new_border != border) {
|
||||
scene -> undoStack().push(new ChangeBorderCommand(scene, border, new_border));
|
||||
if (
|
||||
columns_count_value != columns_count -> value() ||\
|
||||
columns_width_value != columns_width -> value() ||\
|
||||
columns_height_value != columns_height -> value()
|
||||
) {
|
||||
ChangeBorderCommand *cbc = new ChangeBorderCommand(scene);
|
||||
cbc -> columnsCountDifference = columns_count -> value() - columns_count_value;
|
||||
cbc -> columnsWidthDifference = columns_width -> value() - columns_width_value;
|
||||
cbc -> columnsHeightDifference = columns_height -> value() - columns_height_value;
|
||||
scene -> undoStack().push(cbc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -603,40 +655,36 @@ bool DiagramView::hasSelectedItems() {
|
||||
Ajoute une colonne au schema.
|
||||
*/
|
||||
void DiagramView::addColumn() {
|
||||
BorderProperties old_bp = scene -> border_and_inset.exportBorder();
|
||||
BorderProperties new_bp = scene -> border_and_inset.exportBorder();
|
||||
new_bp.columns_count += 1;
|
||||
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
||||
ChangeBorderCommand *cbc = new ChangeBorderCommand(scene);
|
||||
cbc -> columnsCountDifference = 1;
|
||||
scene -> undoStack().push(cbc);
|
||||
}
|
||||
|
||||
/**
|
||||
Enleve une colonne au schema.
|
||||
*/
|
||||
void DiagramView::removeColumn() {
|
||||
BorderProperties old_bp = scene -> border_and_inset.exportBorder();
|
||||
BorderProperties new_bp = scene -> border_and_inset.exportBorder();
|
||||
new_bp.columns_count -= 1;
|
||||
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
||||
ChangeBorderCommand *cbc = new ChangeBorderCommand(scene);
|
||||
cbc -> columnsCountDifference = -1;
|
||||
scene -> undoStack().push(cbc);
|
||||
}
|
||||
|
||||
/**
|
||||
Agrandit le schema en hauteur
|
||||
*/
|
||||
void DiagramView::addRow() {
|
||||
BorderProperties old_bp = scene -> border_and_inset.exportBorder();
|
||||
BorderProperties new_bp = scene -> border_and_inset.exportBorder();
|
||||
new_bp.rows_count += 1;
|
||||
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
||||
void DiagramView::expand() {
|
||||
ChangeBorderCommand *cbc = new ChangeBorderCommand(scene);
|
||||
cbc -> columnsHeightDifference = 80.0;
|
||||
scene -> undoStack().push(cbc);
|
||||
}
|
||||
|
||||
/**
|
||||
Retrecit le schema en hauteur
|
||||
*/
|
||||
void DiagramView::removeRow() {
|
||||
BorderProperties old_bp = scene -> border_and_inset.exportBorder();
|
||||
BorderProperties new_bp = scene -> border_and_inset.exportBorder();
|
||||
new_bp.rows_count -= 1;
|
||||
scene -> undoStack().push(new ChangeBorderCommand(scene, old_bp, new_bp));
|
||||
void DiagramView::shrink() {
|
||||
ChangeBorderCommand *cbc = new ChangeBorderCommand(scene);
|
||||
cbc -> columnsHeightDifference = -80.0;
|
||||
scene -> undoStack().push(cbc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -725,7 +773,7 @@ void DiagramView::editConductor(Conductor *edited_conductor) {
|
||||
ConductorPropertiesWidget *cpw = new ConductorPropertiesWidget(old_properties);
|
||||
|
||||
// l'insere dans un dialogue
|
||||
QDialog conductor_dialog(diagramEditor());
|
||||
QDialog conductor_dialog;
|
||||
conductor_dialog.setWindowTitle(tr("\311diter les propri\351t\351s d'un conducteur"));
|
||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&conductor_dialog);
|
||||
dialog_layout -> addWidget(cpw);
|
||||
@@ -784,7 +832,7 @@ void DiagramView::editDefaultConductorProperties() {
|
||||
ConductorPropertiesWidget *cpw = new ConductorPropertiesWidget(scene -> defaultConductorProperties);
|
||||
|
||||
// l'insere dans un dialogue
|
||||
QDialog conductor_dialog(diagramEditor());
|
||||
QDialog conductor_dialog;
|
||||
conductor_dialog.setWindowTitle(tr("\311diter les propri\351t\351s par d\351faut des conducteurs"));
|
||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&conductor_dialog);
|
||||
dialog_layout -> addWidget(cpw);
|
||||
@@ -821,28 +869,6 @@ void DiagramView::addText() {
|
||||
is_adding_text = true;
|
||||
}
|
||||
|
||||
/**
|
||||
Cree un nouveau champ de texte et le place a la position pos
|
||||
en gerant l'annulation ; enfin, le signal textAdded est emis.
|
||||
@param pos Position du champ de texte ajoute
|
||||
@return le champ de texte ajoute
|
||||
*/
|
||||
DiagramTextItem *DiagramView::addDiagramTextAtPos(const QPointF &pos) {
|
||||
// cree un nouveau champ de texte
|
||||
DiagramTextItem *dti = new DiagramTextItem();
|
||||
dti -> setPlainText("_");
|
||||
dti -> previous_text = "_";
|
||||
|
||||
// le place a la position pos en gerant l'annulation
|
||||
scene -> undoStack().push(new AddTextCommand(scene, dti, pos));
|
||||
adjustSceneRect();
|
||||
|
||||
// emet le signal textAdded
|
||||
emit(textAdded(false));
|
||||
|
||||
return(dti);
|
||||
}
|
||||
|
||||
/**
|
||||
Gere le menu contextuel
|
||||
@param e Evenement decrivant la demande de menu contextuel
|
||||
@@ -863,8 +889,8 @@ void DiagramView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
context_menu -> addAction(qde -> infos_diagram);
|
||||
context_menu -> addAction(qde -> add_column);
|
||||
context_menu -> addAction(qde -> remove_column);
|
||||
context_menu -> addAction(qde -> add_row);
|
||||
context_menu -> addAction(qde -> remove_row);
|
||||
context_menu -> addAction(qde -> expand_diagram);
|
||||
context_menu -> addAction(qde -> shrink_diagram);
|
||||
} else {
|
||||
context_menu -> addAction(qde -> cut);
|
||||
context_menu -> addAction(qde -> copy);
|
||||
@@ -902,7 +928,7 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
// recupere le rectangle corespondant au cartouche
|
||||
QRectF inset_rect(
|
||||
Diagram::margin,
|
||||
Diagram::margin + bi.diagramHeight(),
|
||||
Diagram::margin + bi.columnsHeight(),
|
||||
bi.insetWidth(),
|
||||
bi.insetHeight()
|
||||
);
|
||||
@@ -915,14 +941,6 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
bi.columnsHeaderHeight()
|
||||
);
|
||||
|
||||
// recupere le rectangle correspondant aux en-tetes des lignes
|
||||
QRectF rows_rect(
|
||||
Diagram::margin,
|
||||
Diagram::margin,
|
||||
bi.rowsHeaderWidth(),
|
||||
bi.diagramHeight()
|
||||
);
|
||||
|
||||
// coordonnees du clic par rapport au schema
|
||||
QPointF click_pos = viewportTransform().inverted().map(e -> pos());
|
||||
|
||||
@@ -933,7 +951,7 @@ void DiagramView::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
} else {
|
||||
QGraphicsView::mouseDoubleClickEvent(e);
|
||||
}
|
||||
} else if (inset_rect.contains(click_pos) || columns_rect.contains(click_pos) || rows_rect.contains(click_pos)) {
|
||||
} else if (inset_rect.contains(click_pos) || columns_rect.contains(click_pos)) {
|
||||
// edite les proprietes du schema
|
||||
dialogEditInfos();
|
||||
} else {
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -19,7 +19,6 @@
|
||||
#define DIAGRAMVIEW_H
|
||||
#include <QtGui>
|
||||
class Diagram;
|
||||
class DiagramTextItem;
|
||||
class QETDiagramEditor;
|
||||
class Conductor;
|
||||
/**
|
||||
@@ -59,14 +58,13 @@ class DiagramView : public QGraphicsView {
|
||||
void dialogPrint();
|
||||
void addColumn();
|
||||
void removeColumn();
|
||||
void addRow();
|
||||
void removeRow();
|
||||
void expand();
|
||||
void shrink();
|
||||
/// @return Le schema visualise par ce DiagramView
|
||||
Diagram *diagram() { return(scene); }
|
||||
QETDiagramEditor *diagramEditor() const;
|
||||
bool hasSelectedItems();
|
||||
void addText();
|
||||
DiagramTextItem *addDiagramTextAtPos(const QPointF &);
|
||||
|
||||
protected:
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *);
|
||||
@@ -283,7 +283,7 @@ void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
||||
}
|
||||
}
|
||||
} else if (e -> button() & Qt::RightButton) {
|
||||
if (behavior == Polygon && current_polygon != NULL) {
|
||||
if (behavior == Polygon) {
|
||||
behavior = Normal;
|
||||
undo_stack.push(new AddPartCommand(tr("polygone"), this, current_polygon));
|
||||
current_polygon = NULL;
|
||||
@@ -536,8 +536,9 @@ void ElementScene::slot_delete() {
|
||||
*/
|
||||
void ElementScene::slot_editSizeHotSpot() {
|
||||
// cree un dialogue
|
||||
QDialog dialog_sh(element_editor);
|
||||
QDialog dialog_sh;
|
||||
dialog_sh.setModal(true);
|
||||
dialog_sh.setMinimumSize(400, 230);
|
||||
dialog_sh.setWindowTitle(tr("\311diter la taille et le point de saisie"));
|
||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_sh);
|
||||
|
||||
@@ -575,7 +576,7 @@ void ElementScene::slot_editSizeHotSpot() {
|
||||
void ElementScene::slot_editOrientations() {
|
||||
|
||||
// cree un dialogue
|
||||
QDialog dialog_ori(element_editor);
|
||||
QDialog dialog_ori;
|
||||
dialog_ori.setModal(true);
|
||||
dialog_ori.setMinimumSize(400, 260);
|
||||
dialog_ori.setWindowTitle(tr("\311diter les orientations"));
|
||||
@@ -621,7 +622,7 @@ void ElementScene::slot_editOrientations() {
|
||||
void ElementScene::slot_editNames() {
|
||||
|
||||
// cree un dialogue
|
||||
QDialog dialog(element_editor);
|
||||
QDialog dialog;
|
||||
dialog.setModal(true);
|
||||
dialog.setMinimumSize(400, 330);
|
||||
dialog.setWindowTitle(tr("\311diter les noms"));
|
||||
@@ -27,8 +27,10 @@ ElementView::ElementView(ElementScene *scene, QWidget *parent) :
|
||||
{
|
||||
setInteractive(true);
|
||||
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
//setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
||||
setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
||||
zoomReset();
|
||||
//setSceneRect(QRectF(0.0, 0.0, 50.0, 200.0));
|
||||
scale(4.0, 4.0);
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
@@ -62,67 +64,3 @@ bool ElementView::event(QEvent *e) {
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -39,15 +39,6 @@ class ElementView : public QGraphicsView {
|
||||
void setScene(ElementScene *);
|
||||
protected:
|
||||
bool event(QEvent *);
|
||||
void wheelEvent(QWheelEvent *);
|
||||
|
||||
// slots
|
||||
public slots:
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void zoomFit();
|
||||
void zoomReset();
|
||||
void adjustSceneRect();
|
||||
|
||||
//attributs
|
||||
private:
|
||||
@@ -80,12 +80,12 @@ void PartArc::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget
|
||||
const QDomElement PartArc::toXml(QDomDocument &xml_document) const {
|
||||
QDomElement xml_element = xml_document.createElement("arc");
|
||||
QPointF top_left(sceneTopLeft());
|
||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||
xml_element.setAttribute("width", QString("%1").arg(rect().width()));
|
||||
xml_element.setAttribute("height", QString("%1").arg(rect().height()));
|
||||
xml_element.setAttribute("start", QString("%1").arg(start_angle));
|
||||
xml_element.setAttribute("angle", QString("%1").arg(_angle));
|
||||
xml_element.setAttribute("x", top_left.x());
|
||||
xml_element.setAttribute("y", top_left.y());
|
||||
xml_element.setAttribute("width", rect().width());
|
||||
xml_element.setAttribute("height", rect().height());
|
||||
xml_element.setAttribute("start", start_angle);
|
||||
xml_element.setAttribute("angle", _angle);
|
||||
stylesToXml(xml_element);
|
||||
return(xml_element);
|
||||
}
|
||||
@@ -251,13 +251,3 @@ int PartArc::startAngle() const {
|
||||
bool PartArc::isUseless() const {
|
||||
return(rect().isNull() || !angle());
|
||||
}
|
||||
|
||||
/**
|
||||
@return le rectangle delimitant cette partie.
|
||||
*/
|
||||
QRectF PartArc::boundingRect() const {
|
||||
qreal adjust = 1.5;
|
||||
QRectF r(QGraphicsEllipseItem::boundingRect().normalized());
|
||||
r.adjust(-adjust, -adjust, adjust, adjust);
|
||||
return(r);
|
||||
}
|
||||
@@ -52,7 +52,6 @@ class PartArc : public QGraphicsEllipseItem, public CustomElementGraphicPart {
|
||||
virtual const QDomElement toXml(QDomDocument &) const;
|
||||
virtual void fromXml(const QDomElement &);
|
||||
virtual QPointF sceneTopLeft() const;
|
||||
virtual QRectF boundingRect() const;
|
||||
virtual void setAngle(int);
|
||||
virtual void setStartAngle(int);
|
||||
virtual int angle() const;
|
||||
@@ -68,9 +68,9 @@ void PartCircle::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWid
|
||||
const QDomElement PartCircle::toXml(QDomDocument &xml_document) const {
|
||||
QDomElement xml_element = xml_document.createElement("circle");
|
||||
QPointF top_left(sceneTopLeft());
|
||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||
xml_element.setAttribute("diameter", QString("%1").arg(rect().width()));
|
||||
xml_element.setAttribute("x", top_left.x());
|
||||
xml_element.setAttribute("y", top_left.y());
|
||||
xml_element.setAttribute("diameter", rect().width());
|
||||
stylesToXml(xml_element);
|
||||
return(xml_element);
|
||||
}
|
||||
@@ -68,10 +68,10 @@ void PartEllipse::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWi
|
||||
const QDomElement PartEllipse::toXml(QDomDocument &xml_document) const {
|
||||
QDomElement xml_element = xml_document.createElement("ellipse");
|
||||
QPointF top_left(sceneTopLeft());
|
||||
xml_element.setAttribute("x", QString("%1").arg(top_left.x()));
|
||||
xml_element.setAttribute("y", QString("%1").arg(top_left.y()));
|
||||
xml_element.setAttribute("width", QString("%1").arg(rect().width()));
|
||||
xml_element.setAttribute("height", QString("%1").arg(rect().height()));
|
||||
xml_element.setAttribute("x", top_left.x());
|
||||
xml_element.setAttribute("y", top_left.y());
|
||||
xml_element.setAttribute("width", rect().width());
|
||||
xml_element.setAttribute("height", rect().height());
|
||||
stylesToXml(xml_element);
|
||||
return(xml_element);
|
||||
}
|
||||
@@ -187,13 +187,3 @@ QPointF PartEllipse::sceneTopLeft() const {
|
||||
bool PartEllipse::isUseless() const {
|
||||
return(rect().isNull());
|
||||
}
|
||||
|
||||
/**
|
||||
@return le rectangle delimitant cette partie.
|
||||
*/
|
||||
QRectF PartEllipse::boundingRect() const {
|
||||
qreal adjust = 1.5;
|
||||
QRectF r(QGraphicsEllipseItem::boundingRect().normalized());
|
||||
r.adjust(-adjust, -adjust, adjust, adjust);
|
||||
return(r);
|
||||
}
|
||||
@@ -50,7 +50,6 @@ class PartEllipse : public QGraphicsEllipseItem, public CustomElementGraphicPart
|
||||
virtual const QDomElement toXml(QDomDocument &) const;
|
||||
virtual void fromXml(const QDomElement &);
|
||||
virtual QPointF sceneTopLeft() const;
|
||||
virtual QRectF boundingRect() const;
|
||||
virtual void setProperty(const QString &, const QVariant &);
|
||||
virtual QVariant property(const QString &);
|
||||
virtual bool isUseless() const;
|
||||
@@ -66,10 +66,10 @@ const QDomElement PartLine::toXml(QDomDocument &xml_document) const {
|
||||
QPointF p2(sceneP2());
|
||||
|
||||
QDomElement xml_element = xml_document.createElement("line");
|
||||
xml_element.setAttribute("x1", QString("%1").arg(p1.x()));
|
||||
xml_element.setAttribute("y1", QString("%1").arg(p1.y()));
|
||||
xml_element.setAttribute("x2", QString("%1").arg(p2.x()));
|
||||
xml_element.setAttribute("y2", QString("%1").arg(p2.y()));
|
||||
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);
|
||||
}
|
||||
@@ -251,3 +251,4 @@ QRectF PartLine::boundingRect() const {
|
||||
bool PartLine::isUseless() const {
|
||||
return(sceneP1() == sceneP2());
|
||||
}
|
||||
|
||||
@@ -163,13 +163,3 @@ bool PartPolygon::isUseless() const {
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@return le rectangle delimitant cette partie.
|
||||
*/
|
||||
QRectF PartPolygon::boundingRect() const {
|
||||
qreal adjust = 1.5;
|
||||
QRectF r(QGraphicsPolygonItem::boundingRect());
|
||||
r.adjust(-adjust, -adjust, adjust, adjust);
|
||||
return(r);
|
||||
}
|
||||
@@ -61,7 +61,6 @@ class PartPolygon : public QGraphicsPolygonItem, public CustomElementGraphicPart
|
||||
virtual QString name() const { return(QObject::tr("polygone")); }
|
||||
void fromXml(const QDomElement &);
|
||||
const QDomElement toXml(QDomDocument &) const;
|
||||
virtual QRectF boundingRect() const;
|
||||
void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
|
||||
void setClosed(bool c);
|
||||
bool isClosed() const;
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
#include "parttext.h"
|
||||
#include "texteditor.h"
|
||||
#include "editorcommands.h"
|
||||
#include "elementscene.h"
|
||||
#include "qetapp.h"
|
||||
|
||||
@@ -127,18 +126,6 @@ QPointF PartText::margin() const {
|
||||
*/
|
||||
void PartText::focusOutEvent(QFocusEvent *e) {
|
||||
QGraphicsTextItem::focusOutEvent(e);
|
||||
if (previous_text != toPlainText()) {
|
||||
undoStack().push(
|
||||
new ChangePartCommand(
|
||||
TextEditor::tr("texte") + " " + name(),
|
||||
this,
|
||||
"text",
|
||||
previous_text,
|
||||
toPlainText()
|
||||
)
|
||||
);
|
||||
previous_text = toPlainText();
|
||||
}
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
}
|
||||
|
||||
@@ -149,7 +136,6 @@ void PartText::focusOutEvent(QFocusEvent *e) {
|
||||
void PartText::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) {
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
|
||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||
previous_text = toPlainText();
|
||||
QGraphicsTextItem::mouseDoubleClickEvent(e);
|
||||
setFocus(Qt::MouseFocusReason);
|
||||
}
|
||||
@@ -63,6 +63,5 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
||||
|
||||
private:
|
||||
QPointF margin() const;
|
||||
QString previous_text;
|
||||
};
|
||||
#endif
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
#include "parttextfield.h"
|
||||
#include "textfieldeditor.h"
|
||||
#include "editorcommands.h"
|
||||
#include "qetapp.h"
|
||||
|
||||
/**
|
||||
@@ -145,18 +144,6 @@ QPointF PartTextField::margin() const {
|
||||
*/
|
||||
void PartTextField::focusOutEvent(QFocusEvent *e) {
|
||||
QGraphicsTextItem::focusOutEvent(e);
|
||||
if (previous_text != toPlainText()) {
|
||||
undoStack().push(
|
||||
new ChangePartCommand(
|
||||
TextFieldEditor::tr("texte") + " " + name(),
|
||||
this,
|
||||
"text",
|
||||
previous_text,
|
||||
toPlainText()
|
||||
)
|
||||
);
|
||||
previous_text = toPlainText();
|
||||
}
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
}
|
||||
|
||||
@@ -167,7 +154,6 @@ void PartTextField::focusOutEvent(QFocusEvent *e) {
|
||||
void PartTextField::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *e) {
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemIsFocusable);
|
||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||
previous_text = toPlainText();
|
||||
QGraphicsTextItem::mouseDoubleClickEvent(e);
|
||||
setFocus(Qt::MouseFocusReason);
|
||||
}
|
||||
@@ -69,6 +69,5 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart {
|
||||
|
||||
private:
|
||||
QPointF margin() const;
|
||||
QString previous_text;
|
||||
};
|
||||
#endif
|
||||
@@ -97,7 +97,7 @@ void PolygonEditor::updatePolygonClosedState() {
|
||||
*/
|
||||
void PolygonEditor::updateForm() {
|
||||
activeConnections(false);
|
||||
while(points_list.takeTopLevelItem(0)) {}
|
||||
while(points_list.takeTopLevelItem(0));
|
||||
foreach(QPointF point, part -> polygon()) {
|
||||
point = part -> mapToScene(point);
|
||||
QStringList qsl;
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "customelementpart.h"
|
||||
#include "newelementwizard.h"
|
||||
#include "elementitemeditor.h"
|
||||
#include "recentfiles.h"
|
||||
|
||||
/**
|
||||
Constructeur
|
||||
@@ -70,10 +69,6 @@ void QETElementEditor::setupActions() {
|
||||
deselectall = new QAction( tr("D\351s\351lectionner tout"), this);
|
||||
inv_select = new QAction( tr("Inverser la s\351lection"), this);
|
||||
edit_delete = new QAction(QIcon(":/ico/delete.png"), tr("&Supprimer"), this);
|
||||
zoom_in = new QAction(QIcon(":/ico/viewmag+.png"), tr("Zoom avant"), this);
|
||||
zoom_out = new QAction(QIcon(":/ico/viewmag-.png"), tr("Zoom arri\350re"), this);
|
||||
zoom_fit = new QAction(QIcon(":/ico/viewmagfit.png"), tr("Zoom adapt\351"), this);
|
||||
zoom_reset = new QAction(QIcon(":/ico/viewmag.png"), tr("Pas de zoom"), this);
|
||||
edit_size_hs = new QAction(QIcon(":/ico/hotspot.png"), tr("\311diter la taille et le point de saisie"), this);
|
||||
edit_names = new QAction(QIcon(":/ico/names.png"), tr("\311diter les noms"), this);
|
||||
edit_ori = new QAction(QIcon(":/ico/orientations.png"), tr("\311diter les orientations"), this);
|
||||
@@ -101,18 +96,12 @@ void QETElementEditor::setupActions() {
|
||||
new_element -> setShortcut(QKeySequence::New);
|
||||
open -> setShortcut(QKeySequence::Open);
|
||||
save -> setShortcut(QKeySequence::Save);
|
||||
reload -> setShortcut(Qt::Key_F5);
|
||||
reload -> setShortcut(QKeySequence::Refresh);
|
||||
quit -> setShortcut(QKeySequence(tr("Ctrl+Q")));
|
||||
selectall -> setShortcut(QKeySequence::SelectAll);
|
||||
deselectall -> setShortcut(QKeySequence(tr("Ctrl+Shift+A")));
|
||||
inv_select -> setShortcut(QKeySequence(tr("Ctrl+I")));
|
||||
edit_delete -> setShortcut(QKeySequence(tr("Suppr")));
|
||||
|
||||
zoom_in -> setShortcut(QKeySequence::ZoomIn);
|
||||
zoom_out -> setShortcut(QKeySequence::ZoomOut);
|
||||
zoom_fit -> setShortcut(QKeySequence(tr("Ctrl+9")));
|
||||
zoom_reset -> setShortcut(QKeySequence(tr("Ctrl+0")));
|
||||
|
||||
edit_names -> setShortcut(QKeySequence(tr("Ctrl+E")));
|
||||
edit_size_hs -> setShortcut(QKeySequence(tr("Ctrl+R")));
|
||||
edit_ori -> setShortcut(QKeySequence(tr("Ctrl+T")));
|
||||
@@ -131,10 +120,6 @@ void QETElementEditor::setupActions() {
|
||||
connect(selectall, SIGNAL(triggered()), ce_scene, SLOT(slot_selectAll()));
|
||||
connect(deselectall, SIGNAL(triggered()), ce_scene, SLOT(slot_deselectAll()));
|
||||
connect(inv_select, SIGNAL(triggered()), ce_scene, SLOT(slot_invertSelection()));
|
||||
connect(zoom_in, SIGNAL(triggered()), ce_view, SLOT(zoomIn()));
|
||||
connect(zoom_out, SIGNAL(triggered()), ce_view, SLOT(zoomOut()));
|
||||
connect(zoom_fit, SIGNAL(triggered()), ce_view, SLOT(zoomFit()));
|
||||
connect(zoom_reset, SIGNAL(triggered()), ce_view, SLOT(zoomReset()));
|
||||
connect(edit_delete, SIGNAL(triggered()), ce_scene, SLOT(slot_delete()));
|
||||
connect(edit_size_hs, SIGNAL(triggered()), ce_scene, SLOT(slot_editSizeHotSpot()));
|
||||
connect(edit_names, SIGNAL(triggered()), ce_scene, SLOT(slot_editNames()));
|
||||
@@ -199,48 +184,12 @@ void QETElementEditor::setupActions() {
|
||||
parts_toolbar -> addAction(xml_preview);
|
||||
*/
|
||||
|
||||
main_toolbar = new QToolBar(tr("Outils"), this);
|
||||
main_toolbar -> setObjectName("main_toolbar");
|
||||
view_toolbar = new QToolBar(tr("Affichage"), this);
|
||||
view_toolbar -> setObjectName("display");
|
||||
element_toolbar = new QToolBar(tr("\311l\351ment"), this);
|
||||
element_toolbar -> setObjectName("element_toolbar");
|
||||
depth_toolbar = new QToolBar(tr("Profondeur"), this);
|
||||
depth_toolbar -> setObjectName("depth_toolbar");
|
||||
|
||||
main_toolbar -> addAction(new_element);
|
||||
main_toolbar -> addAction(open);
|
||||
main_toolbar -> addAction(save);
|
||||
main_toolbar -> addAction(save_as);
|
||||
main_toolbar -> addAction(reload);
|
||||
main_toolbar -> addSeparator();
|
||||
main_toolbar -> addAction(undo);
|
||||
main_toolbar -> addAction(redo);
|
||||
main_toolbar -> addSeparator();
|
||||
main_toolbar -> addAction(edit_delete);
|
||||
view_toolbar -> addAction(zoom_in);
|
||||
view_toolbar -> addAction(zoom_out);
|
||||
view_toolbar -> addAction(zoom_fit);
|
||||
view_toolbar -> addAction(zoom_reset);
|
||||
element_toolbar -> addAction(edit_size_hs);
|
||||
element_toolbar -> addAction(edit_names);
|
||||
element_toolbar -> addAction(edit_ori);
|
||||
depth_toolbar -> addAction(edit_forward);
|
||||
depth_toolbar -> addAction(edit_raise);
|
||||
depth_toolbar -> addAction(edit_lower);
|
||||
depth_toolbar -> addAction(edit_backward);
|
||||
|
||||
addToolBar(Qt::TopToolBarArea, main_toolbar);
|
||||
addToolBar(Qt::TopToolBarArea, view_toolbar);
|
||||
addToolBar(Qt::TopToolBarArea, element_toolbar);
|
||||
addToolBar(Qt::TopToolBarArea, depth_toolbar);
|
||||
addToolBar(Qt::LeftToolBarArea, parts_toolbar);
|
||||
|
||||
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateInformations()));
|
||||
connect(ce_scene, SIGNAL(selectionChanged()), this, SLOT(slot_updateMenus()));
|
||||
connect(&(ce_scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(slot_updateMenus()));
|
||||
connect(&(ce_scene -> undoStack()), SIGNAL(cleanChanged(bool)), this, SLOT(slot_updateTitle()));
|
||||
connect(&(ce_scene -> undoStack()), SIGNAL(indexChanged(int)), this, SLOT(slot_updatePartsList()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -261,8 +210,6 @@ void QETElementEditor::setupMenus() {
|
||||
|
||||
file_menu -> addAction(new_element);
|
||||
file_menu -> addAction(open);
|
||||
file_menu -> addMenu(QETApp::elementsRecentFiles() -> menu());
|
||||
connect(QETApp::elementsRecentFiles(), SIGNAL(fileOpeningRequested(const QString &)), this, SLOT(openRecentFile(const QString &)));
|
||||
file_menu -> addAction(save);
|
||||
file_menu -> addAction(save_as);
|
||||
file_menu -> addSeparator();
|
||||
@@ -523,8 +470,6 @@ void QETElementEditor::fromFile(const QString &filepath) {
|
||||
|
||||
// memorise le fichier
|
||||
setFileName(filepath);
|
||||
QETApp::elementsRecentFiles() -> fileWasOpened(filepath);
|
||||
slot_updateMenus();
|
||||
}
|
||||
|
||||
|
||||
@@ -582,12 +527,12 @@ bool QETElementEditor::isReadOnly() const {
|
||||
Lance l'assistant de creation d'un nouvel element.
|
||||
*/
|
||||
void QETElementEditor::slot_new() {
|
||||
NewElementWizard new_element_wizard(this);
|
||||
NewElementWizard new_element_wizard;
|
||||
new_element_wizard.exec();
|
||||
}
|
||||
|
||||
/**
|
||||
Demande un fichier a l'utilisateur et ouvre ce fichier
|
||||
Ouvre un fichier
|
||||
*/
|
||||
void QETElementEditor::slot_open() {
|
||||
// demande un nom de fichier a ouvrir a l'utilisateur
|
||||
@@ -597,30 +542,9 @@ void QETElementEditor::slot_open() {
|
||||
_filename.isEmpty() ? QETApp::customElementsDir() : QDir(_filename).absolutePath(),
|
||||
tr("\311l\351ments QElectroTech (*.elmt);;Fichiers XML (*.xml);;Tous les fichiers (*)")
|
||||
);
|
||||
openElement(user_filename);
|
||||
}
|
||||
|
||||
/**
|
||||
Slot utilise pour ouvrir un fichier recent.
|
||||
Transfere filepath au slot openElement seulement si cet editeur est actif
|
||||
@param filepath Fichier a ouvrir
|
||||
@see openElement
|
||||
*/
|
||||
void QETElementEditor::openRecentFile(const QString &filepath) {
|
||||
if (qApp -> activeWindow() != this) return;
|
||||
openElement(filepath);
|
||||
}
|
||||
|
||||
/**
|
||||
Ouvre un fichier element dans un nouvel editeur
|
||||
Cette methode ne controle pas si le fichier est deja ouvert
|
||||
@param filepath Fichier a ouvrir
|
||||
@see fromFile
|
||||
*/
|
||||
void QETElementEditor::openElement(const QString &filepath) {
|
||||
if (filepath.isEmpty()) return;
|
||||
if (user_filename.isEmpty()) return;
|
||||
QETElementEditor *cee = new QETElementEditor();
|
||||
cee -> fromFile(filepath);
|
||||
cee -> fromFile(user_filename);
|
||||
cee -> show();
|
||||
}
|
||||
|
||||
@@ -684,7 +608,6 @@ bool QETElementEditor::slot_saveAs() {
|
||||
// si l'enregistrement reussit, le nom du fichier est conserve
|
||||
if (result_save) {
|
||||
setFileName(fn);
|
||||
QETApp::elementsRecentFiles() -> fileWasOpened(fn);
|
||||
ce_scene -> undoStack().setClean();
|
||||
}
|
||||
// retourne un booleen representatif de la reussite de l'enregistrement
|
||||
@@ -59,11 +59,10 @@ class QETElementEditor : public QMainWindow {
|
||||
/// actions du menu edition
|
||||
QAction *selectall, *deselectall, *inv_select;
|
||||
QAction *undo, *redo;
|
||||
QAction *zoom_in, *zoom_out, *zoom_fit, *zoom_reset;
|
||||
QAction *edit_delete, *edit_size_hs, *edit_names, *edit_ori;
|
||||
QAction *edit_raise, *edit_lower, *edit_backward, *edit_forward;
|
||||
/// barres d'outils
|
||||
QToolBar *parts_toolbar, *main_toolbar, *view_toolbar, *depth_toolbar, *element_toolbar;
|
||||
/// barre d'outils
|
||||
QToolBar *parts_toolbar;
|
||||
/// actions de la barre d'outils
|
||||
QActionGroup *parts;
|
||||
QAction *move, *add_line, *add_circle, *add_ellipse, *add_polygon, *add_text;
|
||||
@@ -106,8 +105,6 @@ class QETElementEditor : public QMainWindow {
|
||||
public slots:
|
||||
void slot_new();
|
||||
void slot_open();
|
||||
void openRecentFile(const QString &);
|
||||
void openElement(const QString &);
|
||||
void slot_reload();
|
||||
bool slot_save();
|
||||
bool slot_saveAs();
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -27,7 +27,6 @@
|
||||
Constructeur pour un element sans scene ni parent
|
||||
*/
|
||||
Element::Element(QGraphicsItem *parent, Diagram *scene) :
|
||||
QObject(),
|
||||
QGraphicsItem(parent, scene),
|
||||
internal_connections(false)
|
||||
{
|
||||
@@ -50,7 +49,7 @@ void Element::paint(QPainter *painter, const QStyleOptionGraphicsItem *options,
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
// corrige un bug de rendu ne se produisant que lors du rendu sur QGraphicsScene sous X11 au zoom par defaut
|
||||
static bool must_correct_rendering_bug = QETApp::settings().value("correct-rendering", false).toBool();
|
||||
static bool must_correct_rendering_bug = !QString(qVersion()).startsWith("4.4");
|
||||
if (must_correct_rendering_bug) {
|
||||
Diagram *dia = diagram();
|
||||
if (dia && options -> levelOfDetail == 1.0 && widget) {
|
||||
@@ -156,7 +155,7 @@ bool Element::setOrientation(QET::Orientation o) {
|
||||
rotate(rotation_value);
|
||||
ori.setCurrent(o);
|
||||
update();
|
||||
foreach(QGraphicsItem *qgi, childItems()) {
|
||||
foreach(QGraphicsItem *qgi, children()) {
|
||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) p -> updateConductor();
|
||||
else if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(qgi)) {
|
||||
// applique une rotation contraire si besoin
|
||||
@@ -259,21 +258,11 @@ void Element::setPos(qreal x, qreal y) {
|
||||
setPos(QPointF(x, y));
|
||||
}
|
||||
|
||||
/**
|
||||
Gere l'enfoncement d'un bouton de la souris
|
||||
*/
|
||||
void Element::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
||||
if (!isSelected() && e -> modifiers() & Qt::ControlModifier) {
|
||||
setSelected(true);
|
||||
}
|
||||
QGraphicsItem::mousePressEvent(e);
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les mouvements de souris lies a l'element
|
||||
*/
|
||||
void Element::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
||||
if (isSelected() && e -> buttons() & Qt::LeftButton) {
|
||||
if (e -> buttons() & Qt::LeftButton) {
|
||||
QPointF oldPos = pos();
|
||||
setPos(mapToParent(e -> pos()) - matrix().map(e -> buttonDownPos(Qt::LeftButton)));
|
||||
if (Diagram *diagram_ptr = diagram()) {
|
||||
@@ -355,7 +344,7 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr) {
|
||||
|
||||
QHash<int, Terminal *> priv_id_adr;
|
||||
int terminals_non_trouvees = 0;
|
||||
foreach(QGraphicsItem *qgi, childItems()) {
|
||||
foreach(QGraphicsItem *qgi, children()) {
|
||||
if (Terminal *p = qgraphicsitem_cast<Terminal *>(qgi)) {
|
||||
bool terminal_trouvee = false;
|
||||
foreach(QDomElement qde, liste_terminals) {
|
||||
@@ -387,7 +376,7 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr) {
|
||||
|
||||
// importe les valeurs des champs de texte
|
||||
QList<QDomElement> inputs = QET::findInDomElement(e, "inputs", "input");
|
||||
foreach(QGraphicsItem *qgi, childItems()) {
|
||||
foreach(QGraphicsItem *qgi, children()) {
|
||||
if (ElementTextItem *eti = qgraphicsitem_cast<ElementTextItem *>(qgi)) {
|
||||
foreach(QDomElement input, inputs) eti -> fromXml(input);
|
||||
}
|
||||
@@ -421,8 +410,8 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
||||
element.setAttribute("type", type_elmt);
|
||||
|
||||
// position, selection et orientation
|
||||
element.setAttribute("x", QString("%1").arg(pos().x()));
|
||||
element.setAttribute("y", QString("%1").arg(pos().y()));
|
||||
element.setAttribute("x", pos().x());
|
||||
element.setAttribute("y", pos().y());
|
||||
element.setAttribute("orientation", QString("%1").arg(ori.current()));
|
||||
|
||||
/* recupere le premier id a utiliser pour les bornes de cet element */
|
||||
@@ -439,7 +428,7 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
||||
// enregistrement des bornes de l'appareil
|
||||
QDomElement terminals = document.createElement("terminals");
|
||||
// pour chaque enfant de l'element
|
||||
foreach(QGraphicsItem *child, childItems()) {
|
||||
foreach(QGraphicsItem *child, children()) {
|
||||
// si cet enfant est une borne
|
||||
if (Terminal *t = qgraphicsitem_cast<Terminal *>(child)) {
|
||||
// alors on enregistre la borne
|
||||
@@ -454,7 +443,7 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
||||
// enregistrement des champ de texte de l'appareil
|
||||
QDomElement inputs = document.createElement("inputs");
|
||||
// pour chaque enfant de l'element
|
||||
foreach(QGraphicsItem *child, childItems()) {
|
||||
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
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -24,9 +24,7 @@ class Diagram;
|
||||
/**
|
||||
Cette classe abstraite represente un element electrique.
|
||||
*/
|
||||
class Element : public QObject, public QGraphicsItem {
|
||||
|
||||
Q_OBJECT
|
||||
class Element : public QGraphicsItem {
|
||||
|
||||
// constructeurs, destructeur
|
||||
public:
|
||||
@@ -116,7 +114,6 @@ class Element : public QObject, public QGraphicsItem {
|
||||
|
||||
protected:
|
||||
void drawAxes(QPainter *, const QStyleOptionGraphicsItem *);
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *);
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2006-2008 Xavier Guerrin
|
||||
Copyright 2006-2007 Xavier Guerrin
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
@@ -1,15 +0,0 @@
|
||||
<definition width="50" version="0.1" hotspot_x="25" hotspot_y="30" height="40" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Input</name>
|
||||
<name lang="fr" >Entrée</name>
|
||||
</names>
|
||||
<description>
|
||||
<input x="-18" y="-10" size="9" rotate="true" text="_" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="5" x1="10" y2="-5" x2="10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="-5" x1="-10" y2="5" x2="-10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="24" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-24" y2="0" x2="-10" />
|
||||
<terminal x="24" y="0" orientation="e" />
|
||||
<terminal x="-24" y="0" orientation="w" />
|
||||
</description>
|
||||
</definition>
|
||||
@@ -1,16 +0,0 @@
|
||||
<definition width="50" version="0.1" hotspot_x="25" hotspot_y="30" height="40" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Input (down front)</name>
|
||||
<name lang="fr" >Entrée (front descendant)</name>
|
||||
</names>
|
||||
<description>
|
||||
<text x="-4.25" y="5.25" size="9" text="N" />
|
||||
<input x="-18" y="-10" size="9" rotate="true" text="_" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="5" x1="10" y2="-5" x2="10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="-5" x1="-10" y2="5" x2="-10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="24" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-24" y2="0" x2="-10" />
|
||||
<terminal x="24" y="0" orientation="e" />
|
||||
<terminal x="-24" y="0" orientation="w" />
|
||||
</description>
|
||||
</definition>
|
||||
@@ -1,16 +0,0 @@
|
||||
<definition width="50" version="0.1" hotspot_x="25" hotspot_y="30" height="40" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Input (up front)</name>
|
||||
<name lang="fr" >Entrée (front montant)</name>
|
||||
</names>
|
||||
<description>
|
||||
<text x="-3.5" y="5.25" size="9" text="P" />
|
||||
<input x="-18" y="-10" size="9" rotate="true" text="_" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="5" x1="10" y2="-5" x2="10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="-5" x1="-10" y2="5" x2="-10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="24" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-24" y2="0" x2="-10" />
|
||||
<terminal x="24" y="0" orientation="e" />
|
||||
<terminal x="-24" y="0" orientation="w" />
|
||||
</description>
|
||||
</definition>
|
||||
@@ -1,16 +0,0 @@
|
||||
<definition width="50" version="0.1" hotspot_x="25" hotspot_y="30" height="40" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Input (negative logic)</name>
|
||||
<name lang="fr" >Entrée (NF)</name>
|
||||
</names>
|
||||
<description>
|
||||
<line antialias="true" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="5" x1="-7" y2="-5" x2="7" />
|
||||
<input x="-18" y="-10" size="9" rotate="true" text="_" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="5" x1="10" y2="-5" x2="10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="-5" x1="-10" y2="5" x2="-10" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="24" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-24" y2="0" x2="-10" />
|
||||
<terminal x="24" y="0" orientation="e" />
|
||||
<terminal x="-24" y="0" orientation="w" />
|
||||
</description>
|
||||
</definition>
|
||||
@@ -1,6 +0,0 @@
|
||||
<qet-directory>
|
||||
<names>
|
||||
<name lang="en" >Inputs</name>
|
||||
<name lang="fr" >Entrées</name>
|
||||
</names>
|
||||
</qet-directory>
|
||||
@@ -1,6 +0,0 @@
|
||||
<qet-directory>
|
||||
<names>
|
||||
<name lang="en" >Outputs</name>
|
||||
<name lang="fr" >Sorties</name>
|
||||
</names>
|
||||
</qet-directory>
|
||||
@@ -1,14 +0,0 @@
|
||||
<definition width="50" version="0.1" hotspot_x="25" hotspot_y="30" height="40" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Output</name>
|
||||
<name lang="fr" >Sortie</name>
|
||||
</names>
|
||||
<description>
|
||||
<arc width="4" x="6" y="-5" antialias="true" height="10" style="line-style:normal;line-weight:normal;filling:none;color:black" start="80" angle="-160" />
|
||||
<input x="-18" y="-10" size="9" rotate="true" text="_" />
|
||||
<arc width="4" x="-10" y="-5" antialias="true" height="10" style="line-style:normal;line-weight:normal;filling:none;color:black" start="-100" angle="-160" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="24" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-24" y2="0" x2="-10" />
|
||||
<terminal x="-24" y="0" orientation="w" />
|
||||
</description>
|
||||
</definition>
|
||||
@@ -1,15 +0,0 @@
|
||||
<definition width="50" version="0.1" hotspot_x="25" hotspot_y="30" height="40" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Output (reset)</name>
|
||||
<name lang="fr" >Sortie (reset)</name>
|
||||
</names>
|
||||
<description>
|
||||
<text x="-4.25" y="5.25" size="9" text="R" />
|
||||
<arc width="4" x="6" y="-5" antialias="true" height="10" style="line-style:normal;line-weight:normal;filling:none;color:black" start="80" angle="-160" />
|
||||
<input x="-18" y="-10" size="9" rotate="true" text="_" />
|
||||
<arc width="4" x="-10" y="-5" antialias="true" height="10" style="line-style:normal;line-weight:normal;filling:none;color:black" start="-100" angle="-160" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="24" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-24" y2="0" x2="-10" />
|
||||
<terminal x="-24" y="0" orientation="w" />
|
||||
</description>
|
||||
</definition>
|
||||
@@ -1,15 +0,0 @@
|
||||
<definition width="50" version="0.1" hotspot_x="25" hotspot_y="30" height="40" type="element" orientation="dnnn" >
|
||||
<names>
|
||||
<name lang="en" >Output (set)</name>
|
||||
<name lang="fr" >Sortie (set)</name>
|
||||
</names>
|
||||
<description>
|
||||
<arc width="4" x="6" y="-5" antialias="true" height="10" style="line-style:normal;line-weight:normal;filling:none;color:black" start="80" angle="-160" />
|
||||
<input x="-18" y="-10" size="9" rotate="true" text="_" />
|
||||
<arc width="4" x="-10" y="-5" antialias="true" height="10" style="line-style:normal;line-weight:normal;filling:none;color:black" start="-100" angle="-160" />
|
||||
<text x="-4.25" y="5.25" size="9" text="S" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="10" y2="0" x2="24" />
|
||||
<line antialias="false" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-24" y2="0" x2="-10" />
|
||||
<terminal x="-24" y="0" orientation="w" />
|
||||
</description>
|
||||
</definition>
|
||||
@@ -1,6 +0,0 @@
|
||||
<qet-directory>
|
||||
<names>
|
||||
<name lang="fr">Ladder</name>
|
||||
<name lang="en">Ladder</name>
|
||||
</names>
|
||||
</qet-directory>
|
||||
@@ -1,6 +0,0 @@
|
||||
<qet-directory>
|
||||
<names>
|
||||
<name lang="fr">Automatisme</name>
|
||||
<name lang="en">Automatism</name>
|
||||
</names>
|
||||
</qet-directory>
|
||||
@@ -1,6 +0,0 @@
|
||||
<qet-directory>
|
||||
<names>
|
||||
<name lang="en" >Transducers</name>
|
||||
<name lang="fr" >Capteurs</name>
|
||||
</names>
|
||||
</qet-directory>
|
||||
@@ -1,6 +0,0 @@
|
||||
<qet-directory>
|
||||
<names>
|
||||
<name lang="en" >Sensors</name>
|
||||
<name lang="fr" >Sondes</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