mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
Les proprietes des elements affichent desormais la position de l'element dans la grille.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@662 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
2
CREDIT
2
CREDIT
@@ -50,4 +50,4 @@ http://www.oxygen-icons.org/ ) лицензированную на услови
|
|||||||
Спасибо `trem' за пакет для Mandriva.
|
Спасибо `trem' за пакет для Mandriva.
|
||||||
Спасибо TuxFamily ( http://tuxfamily.org/ ) за хостинг для проекта.
|
Спасибо TuxFamily ( http://tuxfamily.org/ ) за хостинг для проекта.
|
||||||
Спасибо `Nishiki' за элементы и поддержку.
|
Спасибо `Nishiki' за элементы и поддержку.
|
||||||
Спасибо qtcentre.org за их класс SingleApplication.
|
Спасибо qtcentre.org за их класс SingleApplication.
|
||||||
|
|||||||
@@ -52,4 +52,4 @@ Commons, 171 Second Street, Suite 300, San Francisco, California 94105, USA.
|
|||||||
Чтобы увидеть копию этой лицензии, посетите
|
Чтобы увидеть копию этой лицензии, посетите
|
||||||
http://creativecommons.org/licenses/by/2.0/fr/ или отправте письмо в Creative
|
http://creativecommons.org/licenses/by/2.0/fr/ или отправте письмо в Creative
|
||||||
Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
|
Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
|
||||||
(данный перевод, на русский язык, является вольным и выполнен не юристом!)
|
(данный перевод, на русский язык, является вольным и выполнен не юристом!)
|
||||||
|
|||||||
2
README
2
README
@@ -11,4 +11,4 @@ QET utilise le format XML pour ses éléments et ses schémas et inclut un
|
|||||||
[ru]
|
[ru]
|
||||||
QElectroTech - приложение написанное на Qt4 и предназначенное для разработки электрических схем.
|
QElectroTech - приложение написанное на Qt4 и предназначенное для разработки электрических схем.
|
||||||
Оно использует XML-файлы для элементов и схем, и включает, как редактор схем, так и редактор
|
Оно использует XML-файлы для элементов и схем, и включает, как редактор схем, так и редактор
|
||||||
элементов.
|
элементов.
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ HEADERS += sources/aboutqet.h \
|
|||||||
sources/diagram.h \
|
sources/diagram.h \
|
||||||
sources/diagramcommands.h \
|
sources/diagramcommands.h \
|
||||||
sources/diagramcontent.h \
|
sources/diagramcontent.h \
|
||||||
|
sources/diagramposition.h \
|
||||||
sources/diagramprintdialog.h \
|
sources/diagramprintdialog.h \
|
||||||
sources/diagramschooser.h \
|
sources/diagramschooser.h \
|
||||||
sources/diagramtextitem.h \
|
sources/diagramtextitem.h \
|
||||||
@@ -173,6 +174,7 @@ SOURCES += sources/aboutqet.cpp \
|
|||||||
sources/diagram.cpp \
|
sources/diagram.cpp \
|
||||||
sources/diagramcommands.cpp \
|
sources/diagramcommands.cpp \
|
||||||
sources/diagramcontent.cpp \
|
sources/diagramcontent.cpp \
|
||||||
|
sources/diagramposition.cpp \
|
||||||
sources/diagramprintdialog.cpp \
|
sources/diagramprintdialog.cpp \
|
||||||
sources/diagramschooser.cpp \
|
sources/diagramschooser.cpp \
|
||||||
sources/diagramtextitem.cpp \
|
sources/diagramtextitem.cpp \
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include "borderinset.h"
|
#include "borderinset.h"
|
||||||
|
#include "diagramposition.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
|
||||||
@@ -426,6 +427,36 @@ void BorderInset::adjustInsetToColumns() {
|
|||||||
setInsetWidth(diagramWidth());
|
setInsetWidth(diagramWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param pos Position cartesienne (ex : 10.3, 45.2) a transformer en position
|
||||||
|
dans la grille (ex : B2)
|
||||||
|
@return la position dans la grille correspondant a pos
|
||||||
|
*/
|
||||||
|
DiagramPosition BorderInset::convertPosition(const QPointF &pos) {
|
||||||
|
// recupere le rectangle quadrille par les en-tetes
|
||||||
|
QRectF grid_rect(
|
||||||
|
rowsHeaderWidth(),
|
||||||
|
columnsHeaderHeight(),
|
||||||
|
diagramWidth(),
|
||||||
|
diagramHeight()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!grid_rect.contains(pos)) {
|
||||||
|
return(DiagramPosition("", 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF relative_pos = pos - grid_rect.topLeft();
|
||||||
|
int row_number = ceil(relative_pos.x() / columnsWidth());
|
||||||
|
int column_number = ceil(relative_pos.y() / rowsHeight());
|
||||||
|
|
||||||
|
QString letter = "A";
|
||||||
|
for (int i = 1 ; i < column_number ; ++ i) {
|
||||||
|
letter = incrementLetters(letter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(DiagramPosition(letter, row_number));
|
||||||
|
}
|
||||||
|
|
||||||
QString BorderInset::incrementLetters(const QString &string) {
|
QString BorderInset::incrementLetters(const QString &string) {
|
||||||
if (string.isEmpty()) {
|
if (string.isEmpty()) {
|
||||||
return("A");
|
return("A");
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <QRectF>
|
#include <QRectF>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
class DiagramPosition;
|
||||||
/**
|
/**
|
||||||
Cette classe represente l'ensemble bordure + cartouche qui encadre le
|
Cette classe represente l'ensemble bordure + cartouche qui encadre le
|
||||||
schema electrique.
|
schema electrique.
|
||||||
@@ -124,6 +125,8 @@ class BorderInset : public QObject {
|
|||||||
void setInsetHeight (const qreal &);
|
void setInsetHeight (const qreal &);
|
||||||
void adjustInsetToColumns ();
|
void adjustInsetToColumns ();
|
||||||
|
|
||||||
|
DiagramPosition convertPosition(const QPointF &);
|
||||||
|
|
||||||
// methodes d'acces en ecriture aux informations du cartouche
|
// methodes d'acces en ecriture aux informations du cartouche
|
||||||
/// @param author le nouveau contenu du champ "Auteur"
|
/// @param author le nouveau contenu du champ "Auteur"
|
||||||
void setAuthor (const QString &author) { bi_author = author; }
|
void setAuthor (const QString &author) { bi_author = author; }
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "ghostelement.h"
|
#include "ghostelement.h"
|
||||||
#include "diagramcommands.h"
|
#include "diagramcommands.h"
|
||||||
#include "diagramcontent.h"
|
#include "diagramcontent.h"
|
||||||
|
#include "diagramposition.h"
|
||||||
|
|
||||||
const int Diagram::xGrid = 10;
|
const int Diagram::xGrid = 10;
|
||||||
const int Diagram::yGrid = 10;
|
const int Diagram::yGrid = 10;
|
||||||
@@ -896,6 +897,24 @@ bool Diagram::usesElement(const ElementsLocation &location) {
|
|||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param pos Position cartesienne (ex : 10.3, 45.2) a transformer en position
|
||||||
|
dans la grille (ex : B2)
|
||||||
|
@return la position dans la grille correspondant a pos
|
||||||
|
*/
|
||||||
|
DiagramPosition Diagram::convertPosition(const QPointF &pos) {
|
||||||
|
// decale la position pour prendre en compte les marges en haut a gauche du schema
|
||||||
|
QPointF final_pos = pos - QPointF(margin, margin);
|
||||||
|
|
||||||
|
// delegue le calcul au BorderInset
|
||||||
|
DiagramPosition diagram_position = border_and_inset.convertPosition(final_pos);
|
||||||
|
|
||||||
|
// embarque la position cartesienne
|
||||||
|
diagram_position.setPosition(pos);
|
||||||
|
|
||||||
|
return(diagram_position);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Definit s'il faut afficher ou non les bornes
|
Definit s'il faut afficher ou non les bornes
|
||||||
@param dt true pour afficher les bornes, false sinon
|
@param dt true pour afficher les bornes, false sinon
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class Terminal;
|
|||||||
class Conductor;
|
class Conductor;
|
||||||
class DiagramTextItem;
|
class DiagramTextItem;
|
||||||
class DiagramContent;
|
class DiagramContent;
|
||||||
|
class DiagramPosition;
|
||||||
class QETProject;
|
class QETProject;
|
||||||
class ElementsLocation;
|
class ElementsLocation;
|
||||||
/**
|
/**
|
||||||
@@ -132,6 +133,7 @@ class Diagram : public QGraphicsScene {
|
|||||||
bool useBorder();
|
bool useBorder();
|
||||||
void setBorderOptions(BorderOptions);
|
void setBorderOptions(BorderOptions);
|
||||||
BorderOptions borderOptions();
|
BorderOptions borderOptions();
|
||||||
|
DiagramPosition convertPosition(const QPointF &);
|
||||||
|
|
||||||
bool drawTerminals() const;
|
bool drawTerminals() const;
|
||||||
void setDrawTerminals(bool);
|
void setDrawTerminals(bool);
|
||||||
|
|||||||
70
sources/diagramposition.cpp
Normal file
70
sources/diagramposition.cpp
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2009 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 "diagramposition.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
Constructeur
|
||||||
|
@param letter Lettre(s) composant la position
|
||||||
|
@param number Numero composant la position
|
||||||
|
Si une chaine entierement invalide ou vide, ou bien un 0 est passe en
|
||||||
|
parametre, il en resulte un objet DiagramPosition invalide, dont la methode
|
||||||
|
isOutOfBounds renverra true.
|
||||||
|
*/
|
||||||
|
DiagramPosition::DiagramPosition(const QString &letter, unsigned int number) {
|
||||||
|
// purifie les lettres
|
||||||
|
letter_ = letter.toUpper();
|
||||||
|
letter_.remove(QRegExp("[^A-Z]"));
|
||||||
|
number_ = number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructeur
|
||||||
|
*/
|
||||||
|
DiagramPosition::~DiagramPosition() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return les coordonnees stockees dans cet objet, ou un QPointF nul sinon.
|
||||||
|
*/
|
||||||
|
QPointF DiagramPosition::position() const {
|
||||||
|
return(position_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@param position Position a stocker dans cet objet
|
||||||
|
*/
|
||||||
|
void DiagramPosition::setPosition(const QPointF &position) {
|
||||||
|
position_ = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return une representation textuelle de la position
|
||||||
|
*/
|
||||||
|
QString DiagramPosition::toString() {
|
||||||
|
if (isOutOfBounds()) {
|
||||||
|
return("-");
|
||||||
|
}
|
||||||
|
return(QString("%1%2").arg(letter_).arg(number_));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@return true si l'element est en dehors des bords du schema
|
||||||
|
*/
|
||||||
|
bool DiagramPosition::isOutOfBounds() const {
|
||||||
|
return(letter_.isEmpty() || !number_);
|
||||||
|
}
|
||||||
48
sources/diagramposition.h
Normal file
48
sources/diagramposition.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2006-2009 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/>.
|
||||||
|
*/
|
||||||
|
#ifndef DIAGRAM_POSITION_H
|
||||||
|
#define DIAGRAM_POSITION_H
|
||||||
|
#include <QPointF>
|
||||||
|
#include <QString>
|
||||||
|
#include <QRegExp>
|
||||||
|
/**
|
||||||
|
Cette classe represente la position d'un element sur le schema. Il ne
|
||||||
|
s'agit pas de ses coordonnees (bien que celles-ci puissent etre embarquees
|
||||||
|
par commodite), mais du secteur du schema dans lequel il se situe, par
|
||||||
|
exemple B2 ou C4.
|
||||||
|
*/
|
||||||
|
class DiagramPosition {
|
||||||
|
// constructeurs, destructeur
|
||||||
|
public:
|
||||||
|
DiagramPosition(const QString & = "", unsigned int = 0);
|
||||||
|
virtual ~DiagramPosition();
|
||||||
|
|
||||||
|
// methodes
|
||||||
|
public:
|
||||||
|
QPointF position() const;
|
||||||
|
void setPosition(const QPointF &);
|
||||||
|
QString toString();
|
||||||
|
bool isOutOfBounds() const;
|
||||||
|
|
||||||
|
// attributs
|
||||||
|
private:
|
||||||
|
QString letter_;
|
||||||
|
unsigned int number_;
|
||||||
|
QPointF position_;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "ghostelement.h"
|
#include "ghostelement.h"
|
||||||
#include "conductor.h"
|
#include "conductor.h"
|
||||||
#include "diagramcommands.h"
|
#include "diagramcommands.h"
|
||||||
|
#include "diagramposition.h"
|
||||||
#include "conductorpropertieswidget.h"
|
#include "conductorpropertieswidget.h"
|
||||||
#include "insetpropertieswidget.h"
|
#include "insetpropertieswidget.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
@@ -613,6 +614,7 @@ void DiagramView::editElement(Element *element) {
|
|||||||
|
|
||||||
// nom, nombre de bornes, dimensions
|
// nom, nombre de bornes, dimensions
|
||||||
description_string += QString(tr("Nom\240: %1\n")).arg(element -> name());
|
description_string += QString(tr("Nom\240: %1\n")).arg(element -> name());
|
||||||
|
description_string += QString(tr("Position\240: %1\n")).arg(scene -> convertPosition(element -> scenePos()).toString());
|
||||||
description_string += QString(tr("Dimensions\240: %1\327%2\n")).arg(element -> size().width()).arg(element -> size().height());
|
description_string += QString(tr("Dimensions\240: %1\327%2\n")).arg(element -> size().width()).arg(element -> size().height());
|
||||||
description_string += QString(tr("Bornes\240: %1\n")).arg(element -> terminals().count());
|
description_string += QString(tr("Bornes\240: %1\n")).arg(element -> terminals().count());
|
||||||
description_string += QString(tr("Connexions internes\240: %1\n")).arg(element -> internalConnections() ? tr("Autoris\351es") : tr("Interdites"));
|
description_string += QString(tr("Connexions internes\240: %1\n")).arg(element -> internalConnections() ? tr("Autoris\351es") : tr("Interdites"));
|
||||||
|
|||||||
Reference in New Issue
Block a user