mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Remove file and code, because unused with the new auto hotspot
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2410 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -376,72 +376,6 @@ void ChangePolygonPointsCommand::redo() {
|
|||||||
polygon -> setPolygon(new_points);
|
polygon -> setPolygon(new_points);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Constructeur
|
|
||||||
@param element_scene Element edite
|
|
||||||
@param size_1 Dimensions de l'element avant le changement
|
|
||||||
@param size_2 Dimensions de l'element apres le changement
|
|
||||||
@param hotspot_1 Point de saisie de l'element avant le changement
|
|
||||||
@param hotspot_2 Point de saisie de l'element apres le changement
|
|
||||||
@param o Eventuel decalage a appliquer aux parties de l'element edite
|
|
||||||
@param parent QUndoCommand parent
|
|
||||||
*/
|
|
||||||
ChangeHotspotCommand::ChangeHotspotCommand(
|
|
||||||
ElementScene *element_scene,
|
|
||||||
const QSize &size_1,
|
|
||||||
const QSize &size_2,
|
|
||||||
const QPoint &hotspot_1,
|
|
||||||
const QPoint &hotspot_2,
|
|
||||||
const QPoint &o,
|
|
||||||
QUndoCommand *parent
|
|
||||||
) :
|
|
||||||
ElementEditionCommand(QObject::tr("modification dimensions/hotspot", "undo caption"), element_scene, 0, parent),
|
|
||||||
size_before(size_1),
|
|
||||||
size_after(size_2),
|
|
||||||
hotspot_before(hotspot_1),
|
|
||||||
hotspot_after(hotspot_2),
|
|
||||||
offset(o)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Destructeur
|
|
||||||
ChangeHotspotCommand::~ChangeHotspotCommand() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Annule le changement
|
|
||||||
void ChangeHotspotCommand::undo() {
|
|
||||||
QRectF sc(editor_scene_ -> sceneContent());
|
|
||||||
|
|
||||||
editor_scene_ -> setWidth(size_before.width());
|
|
||||||
editor_scene_ -> setHeight(size_before.height());
|
|
||||||
editor_scene_ -> setHotspot(hotspot_before);
|
|
||||||
if (!offset.isNull()) applyOffset(-offset);
|
|
||||||
|
|
||||||
editor_scene_ -> update(editor_scene_ -> sceneContent().unite(sc));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Refait le changement
|
|
||||||
void ChangeHotspotCommand::redo() {
|
|
||||||
QRectF sc(editor_scene_ -> sceneContent());
|
|
||||||
|
|
||||||
editor_scene_ -> setWidth(size_after.width());
|
|
||||||
editor_scene_ -> setHeight(size_after.height());
|
|
||||||
editor_scene_ -> setHotspot(hotspot_after);
|
|
||||||
if (!offset.isNull()) applyOffset(offset);
|
|
||||||
|
|
||||||
editor_scene_ -> update(editor_scene_ -> sceneContent().unite(sc));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Applique une translation aux parties de l'element edite
|
|
||||||
@param o Translation a appliquer
|
|
||||||
*/
|
|
||||||
void ChangeHotspotCommand::applyOffset(const QPointF &o) {
|
|
||||||
foreach(QGraphicsItem *qgi, editor_scene_ -> items()) {
|
|
||||||
qgi -> translate(o.x(), o.y());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur
|
Constructeur
|
||||||
@param element_scene Element edite
|
@param element_scene Element edite
|
||||||
|
|||||||
@@ -224,39 +224,6 @@ class ChangePolygonPointsCommand : public ElementEditionCommand {
|
|||||||
QVector<QPointF> new_points;
|
QVector<QPointF> new_points;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
This command changes the dimensions and/or the hotspot of an electrical
|
|
||||||
element.
|
|
||||||
*/
|
|
||||||
class ChangeHotspotCommand : public ElementEditionCommand {
|
|
||||||
// constructors, destructor
|
|
||||||
public:
|
|
||||||
ChangeHotspotCommand(ElementScene *, const QSize &, const QSize &, const QPoint &, const QPoint &, const QPoint & = QPoint(), QUndoCommand * = 0);
|
|
||||||
virtual ~ChangeHotspotCommand();
|
|
||||||
private:
|
|
||||||
ChangeHotspotCommand(const ChangeHotspotCommand &);
|
|
||||||
|
|
||||||
// methods
|
|
||||||
public:
|
|
||||||
virtual void undo();
|
|
||||||
virtual void redo();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void applyOffset(const QPointF &);
|
|
||||||
|
|
||||||
// attributes
|
|
||||||
/// Former dimensions
|
|
||||||
QSize size_before;
|
|
||||||
/// new dimensions
|
|
||||||
QSize size_after;
|
|
||||||
/// Former hotspot
|
|
||||||
QPoint hotspot_before;
|
|
||||||
/// New hotspot
|
|
||||||
QPoint hotspot_after;
|
|
||||||
/// Offset to be applied to primitives
|
|
||||||
QPoint offset;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This command changes the translated names of an electrical element.
|
This command changes the translated names of an electrical element.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
#include "parttext.h"
|
#include "parttext.h"
|
||||||
#include "parttextfield.h"
|
#include "parttextfield.h"
|
||||||
#include "partarc.h"
|
#include "partarc.h"
|
||||||
#include "hotspoteditor.h"
|
|
||||||
#include "editorcommands.h"
|
#include "editorcommands.h"
|
||||||
#include "elementcontent.h"
|
#include "elementcontent.h"
|
||||||
#include "nameslist.h"
|
#include "nameslist.h"
|
||||||
@@ -39,9 +38,6 @@
|
|||||||
*/
|
*/
|
||||||
ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
|
ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
|
||||||
QGraphicsScene(parent),
|
QGraphicsScene(parent),
|
||||||
_width(3),
|
|
||||||
_height(7),
|
|
||||||
_hotspot(15, 35),
|
|
||||||
internal_connections(false),
|
internal_connections(false),
|
||||||
qgi_manager(this),
|
qgi_manager(this),
|
||||||
element_editor(editor),
|
element_editor(editor),
|
||||||
@@ -325,55 +321,6 @@ void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
} else QGraphicsScene::mouseReleaseEvent(e);
|
} else QGraphicsScene::mouseReleaseEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Dessine l'arriere-plan de l'editeur, cad la grille.
|
|
||||||
@param p Le QPainter a utiliser pour dessiner
|
|
||||||
@param r Le rectangle de la zone a dessiner
|
|
||||||
*/
|
|
||||||
void ElementScene::drawBackground(QPainter *p, const QRectF &r) {
|
|
||||||
p -> save();
|
|
||||||
|
|
||||||
// desactive tout antialiasing, sauf pour le texte
|
|
||||||
p -> setRenderHint(QPainter::Antialiasing, false);
|
|
||||||
p -> setRenderHint(QPainter::TextAntialiasing, true);
|
|
||||||
p -> setRenderHint(QPainter::SmoothPixmapTransform, false);
|
|
||||||
|
|
||||||
// dessine un fond blanc
|
|
||||||
p -> setPen(Qt::NoPen);
|
|
||||||
p -> setBrush(Qt::white);
|
|
||||||
p -> drawRect(r);
|
|
||||||
|
|
||||||
// encadre la zone dessinable de l'element
|
|
||||||
QRectF drawable_area(-_hotspot.x(), -_hotspot.y(), width(), height());
|
|
||||||
p -> setPen(Qt::black);
|
|
||||||
p -> setBrush(Qt::NoBrush);
|
|
||||||
p -> drawRect(drawable_area);
|
|
||||||
|
|
||||||
// on dessine un point de la grille sur 10
|
|
||||||
int drawn_x_grid = x_grid * 10;
|
|
||||||
int drawn_y_grid = y_grid * 10;
|
|
||||||
|
|
||||||
if (r.width() < 2500 && r.height() < 2500) {
|
|
||||||
// dessine les points de la grille
|
|
||||||
p -> setPen(Qt::black);
|
|
||||||
p -> setBrush(Qt::NoBrush);
|
|
||||||
qreal limite_x = r.x() + r.width();
|
|
||||||
qreal limite_y = r.y() + r.height();
|
|
||||||
|
|
||||||
int g_x = (int)ceil(r.x());
|
|
||||||
while (g_x % drawn_x_grid) ++ g_x;
|
|
||||||
int g_y = (int)ceil(r.y());
|
|
||||||
while (g_y % drawn_y_grid) ++ g_y;
|
|
||||||
|
|
||||||
for (int gx = g_x ; gx < limite_x ; gx += drawn_x_grid) {
|
|
||||||
for (int gy = g_y ; gy < limite_y ; gy += drawn_y_grid) {
|
|
||||||
p -> drawPoint(gx, gy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p -> restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Dessine l'arriere-plan de l'editeur, cad l'indicateur de hotspot.
|
Dessine l'arriere-plan de l'editeur, cad l'indicateur de hotspot.
|
||||||
@param p Le QPainter a utiliser pour dessiner
|
@param p Le QPainter a utiliser pour dessiner
|
||||||
@@ -390,8 +337,8 @@ void ElementScene::drawForeground(QPainter *p, const QRectF &rect) {
|
|||||||
|
|
||||||
p -> setPen(Qt::red);
|
p -> setPen(Qt::red);
|
||||||
p -> setBrush(Qt::NoBrush);
|
p -> setBrush(Qt::NoBrush);
|
||||||
p -> drawLine(QLineF(0.0, -_hotspot.y(), 0.0, height() - _hotspot.y()));
|
p -> drawLine(-20, 0, 20, 0);
|
||||||
p -> drawLine(QLineF(-_hotspot.x(), 0.0, width() - _hotspot.x(), 0.0));
|
p -> drawLine(0, -20, 0, 20);
|
||||||
p -> restore();
|
p -> restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -555,7 +502,7 @@ void ElementScene::fromXml(
|
|||||||
superieur gauche les coordonnees opposees du hotspot.
|
superieur gauche les coordonnees opposees du hotspot.
|
||||||
*/
|
*/
|
||||||
QRectF ElementScene::borderRect() const {
|
QRectF ElementScene::borderRect() const {
|
||||||
return(QRectF(-_hotspot, QSizeF(width(), height())));
|
return(QRectF(-elementSceneGeometricRect().topLeft(), QSizeF(width(), height())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -730,52 +677,6 @@ void ElementScene::slot_delete() {
|
|||||||
emit(selectionChanged());
|
emit(selectionChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Lance un dialogue pour editer les dimensions et le point de saisie
|
|
||||||
(hotspot) de l'element.
|
|
||||||
*/
|
|
||||||
void ElementScene::slot_editSizeHotSpot() {
|
|
||||||
bool is_read_only = element_editor && element_editor -> isReadOnly();
|
|
||||||
|
|
||||||
// cree un dialogue
|
|
||||||
QDialog dialog_sh(element_editor);
|
|
||||||
dialog_sh.setModal(true);
|
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
dialog_sh.setWindowFlags(Qt::Sheet);
|
|
||||||
#endif
|
|
||||||
dialog_sh.setWindowTitle(tr("\311diter la taille et le point de saisie", "window title"));
|
|
||||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_sh);
|
|
||||||
|
|
||||||
// ajoute un HotspotEditor au dialogue
|
|
||||||
HotspotEditor *hotspot_editor = new HotspotEditor();
|
|
||||||
hotspot_editor -> setElementWidth(static_cast<uint>(width() / 10));
|
|
||||||
hotspot_editor -> setElementHeight(static_cast<uint>(height() / 10));
|
|
||||||
hotspot_editor -> setHotspot(hotspot());
|
|
||||||
hotspot_editor -> setOldHotspot(hotspot());
|
|
||||||
hotspot_editor -> setPartsRect(elementContentBoundingRect(items()));
|
|
||||||
hotspot_editor -> setPartsRectEnabled(true);
|
|
||||||
hotspot_editor -> setReadOnly(is_read_only);
|
|
||||||
dialog_layout -> addWidget(hotspot_editor);
|
|
||||||
|
|
||||||
// ajoute deux boutons au dialogue
|
|
||||||
QDialogButtonBox *dialog_buttons = new QDialogButtonBox(is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
|
||||||
dialog_layout -> addWidget(dialog_buttons);
|
|
||||||
connect(dialog_buttons, SIGNAL(accepted()), &dialog_sh, SLOT(accept()));
|
|
||||||
connect(dialog_buttons, SIGNAL(rejected()), &dialog_sh, SLOT(reject()));
|
|
||||||
|
|
||||||
// lance le dialogue
|
|
||||||
if (dialog_sh.exec() == QDialog::Accepted && !is_read_only) {
|
|
||||||
QSize new_size(hotspot_editor -> elementSize());
|
|
||||||
QSize old_size(width(), height());
|
|
||||||
QPoint new_hotspot(hotspot_editor -> hotspot());
|
|
||||||
QPoint old_hotspot(_hotspot);
|
|
||||||
|
|
||||||
if (new_size != old_size || new_hotspot != old_hotspot) {
|
|
||||||
undo_stack.push(new ChangeHotspotCommand(this, old_size, new_size, old_hotspot, new_hotspot, hotspot_editor -> offsetParts()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Lance un dialogue pour editer les noms de cete element
|
Lance un dialogue pour editer les noms de cete element
|
||||||
*/
|
*/
|
||||||
@@ -1092,25 +993,7 @@ bool ElementScene::applyInformations(const QDomDocument &xml_document, QString *
|
|||||||
}
|
}
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// dimensions et hotspot : ces attributs doivent etre presents et valides
|
|
||||||
int w, h, hot_x, hot_y;
|
|
||||||
if (
|
|
||||||
!QET::attributeIsAnInteger(root, QString("width"), &w) ||\
|
|
||||||
!QET::attributeIsAnInteger(root, QString("height"), &h) ||\
|
|
||||||
!QET::attributeIsAnInteger(root, QString("hotspot_x"), &hot_x) ||\
|
|
||||||
!QET::attributeIsAnInteger(root, QString("hotspot_y"), &hot_y)
|
|
||||||
) {
|
|
||||||
if (error_message) {
|
|
||||||
*error_message = tr("Les dimensions ou le point de saisie ne sont pas valides.", "error message");
|
|
||||||
}
|
|
||||||
return(false);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
setWidth(w);
|
|
||||||
setHeight(h);
|
|
||||||
setHotspot(QPoint(hot_x, hot_y));
|
|
||||||
|
|
||||||
// orientations
|
// orientations
|
||||||
internal_connections = (root.attribute("ic") == "true");
|
internal_connections = (root.attribute("ic") == "true");
|
||||||
|
|
||||||
|
|||||||
@@ -63,12 +63,6 @@ class ElementScene : public QGraphicsScene {
|
|||||||
|
|
||||||
// attributes
|
// attributes
|
||||||
private:
|
private:
|
||||||
/// element width, in dozens of pixels
|
|
||||||
uint _width;
|
|
||||||
/// element height, in dozens of pixels
|
|
||||||
uint _height;
|
|
||||||
/// hotspot position
|
|
||||||
QPoint _hotspot;
|
|
||||||
/// List of localized names
|
/// List of localized names
|
||||||
NamesList _names;
|
NamesList _names;
|
||||||
/// Set of orientations
|
/// Set of orientations
|
||||||
@@ -116,12 +110,6 @@ class ElementScene : public QGraphicsScene {
|
|||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
void setWidth(const uint &);
|
|
||||||
uint width() const;
|
|
||||||
void setHeight(const uint &);
|
|
||||||
uint height() const;
|
|
||||||
void setHotspot(const QPoint &);
|
|
||||||
QPoint hotspot() const;
|
|
||||||
void setNames(const NamesList &);
|
void setNames(const NamesList &);
|
||||||
NamesList names() const;
|
NamesList names() const;
|
||||||
OrientationSet orientations();
|
OrientationSet orientations();
|
||||||
@@ -158,7 +146,6 @@ class ElementScene : public QGraphicsScene {
|
|||||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
|
||||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
|
||||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
|
||||||
virtual void drawBackground(QPainter *, const QRectF &);
|
|
||||||
virtual void drawForeground(QPainter *, const QRectF &);
|
virtual void drawForeground(QPainter *, const QRectF &);
|
||||||
virtual void endCurrentBehavior(const QGraphicsSceneMouseEvent *);
|
virtual void endCurrentBehavior(const QGraphicsSceneMouseEvent *);
|
||||||
|
|
||||||
@@ -191,7 +178,6 @@ class ElementScene : public QGraphicsScene {
|
|||||||
void slot_deselectAll();
|
void slot_deselectAll();
|
||||||
void slot_invertSelection();
|
void slot_invertSelection();
|
||||||
void slot_delete();
|
void slot_delete();
|
||||||
void slot_editSizeHotSpot();
|
|
||||||
void slot_editNames();
|
void slot_editNames();
|
||||||
void slot_editOrientations();
|
void slot_editOrientations();
|
||||||
void slot_editAuthorInformations();
|
void slot_editAuthorInformations();
|
||||||
@@ -220,51 +206,6 @@ class ElementScene : public QGraphicsScene {
|
|||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(ElementScene::ItemOptions)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(ElementScene::ItemOptions)
|
||||||
|
|
||||||
/**
|
|
||||||
@param wid the new width for the currently edited element
|
|
||||||
*/
|
|
||||||
inline void ElementScene::setWidth(const uint &wid) {
|
|
||||||
_width = wid;
|
|
||||||
while (_width % 10) ++ _width;
|
|
||||||
_width /= 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return the height of the currently edited element
|
|
||||||
*/
|
|
||||||
inline uint ElementScene::width() const {
|
|
||||||
return(_width * 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param hei the new height for the currently edited element
|
|
||||||
*/
|
|
||||||
inline void ElementScene::setHeight(const uint &hei) {
|
|
||||||
_height = hei;
|
|
||||||
while (_height % 10) ++ _height;
|
|
||||||
_height /= 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return the width of the currently edited element
|
|
||||||
*/
|
|
||||||
inline uint ElementScene::height() const {
|
|
||||||
return(_height * 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param hs the new hotspot for the currently edited element
|
|
||||||
*/
|
|
||||||
inline void ElementScene::setHotspot(const QPoint &hs) {
|
|
||||||
_hotspot = hs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return the hotspot of the currently edited element
|
|
||||||
*/
|
|
||||||
inline QPoint ElementScene::hotspot() const {
|
|
||||||
return(_hotspot);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param nameslist New set of naes for the currently edited element
|
@param nameslist New set of naes for the currently edited element
|
||||||
|
|||||||
@@ -408,13 +408,7 @@ void ElementView::drawBackground(QPainter *p, const QRectF &r) {
|
|||||||
p -> setPen(Qt::NoPen);
|
p -> setPen(Qt::NoPen);
|
||||||
p -> setBrush(Qt::white);
|
p -> setBrush(Qt::white);
|
||||||
p -> drawRect(r);
|
p -> drawRect(r);
|
||||||
|
|
||||||
// encadre la zone dessinable de l'element
|
|
||||||
QRectF drawable_area(-scene_ -> hotspot().x(), -scene_ -> hotspot().y(), scene_ -> width(), scene_ -> height());
|
|
||||||
p -> setPen(Qt::black);
|
|
||||||
p -> setBrush(Qt::NoBrush);
|
|
||||||
p -> drawRect(drawable_area);
|
|
||||||
|
|
||||||
// determine le zoom en cours
|
// determine le zoom en cours
|
||||||
qreal zoom_factor = matrix().m11();
|
qreal zoom_factor = matrix().m11();
|
||||||
|
|
||||||
|
|||||||
@@ -144,7 +144,6 @@ void QETElementEditor::setupActions() {
|
|||||||
zoom_out = new QAction(QET::Icons::ZoomOut, tr("Zoom arri\350re"), this);
|
zoom_out = new QAction(QET::Icons::ZoomOut, tr("Zoom arri\350re"), this);
|
||||||
zoom_fit = new QAction(QET::Icons::ZoomFitBest, tr("Zoom adapt\351"), this);
|
zoom_fit = new QAction(QET::Icons::ZoomFitBest, tr("Zoom adapt\351"), this);
|
||||||
zoom_reset = new QAction(QET::Icons::ZoomOriginal, tr("Pas de zoom"), this);
|
zoom_reset = new QAction(QET::Icons::ZoomOriginal, tr("Pas de zoom"), this);
|
||||||
edit_size_hs = new QAction(QET::Icons::HotSpot, tr("\311diter la taille et le point de saisie"), this);
|
|
||||||
edit_names = new QAction(QET::Icons::Names, tr("\311diter les noms"), this);
|
edit_names = new QAction(QET::Icons::Names, tr("\311diter les noms"), this);
|
||||||
edit_ori = new QAction(QET::Icons::Orientations, tr("\311diter les orientations"), this);
|
edit_ori = new QAction(QET::Icons::Orientations, tr("\311diter les orientations"), this);
|
||||||
edit_author = new QAction(QET::Icons::UserInformations, tr("\311diter les informations sur l'auteur"), this);
|
edit_author = new QAction(QET::Icons::UserInformations, tr("\311diter les informations sur l'auteur"), this);
|
||||||
@@ -205,7 +204,6 @@ void QETElementEditor::setupActions() {
|
|||||||
zoom_reset -> setShortcut(QKeySequence(tr("Ctrl+0")));
|
zoom_reset -> setShortcut(QKeySequence(tr("Ctrl+0")));
|
||||||
|
|
||||||
edit_names -> setShortcut(QKeySequence(tr("Ctrl+E")));
|
edit_names -> setShortcut(QKeySequence(tr("Ctrl+E")));
|
||||||
edit_size_hs -> setShortcut(QKeySequence(tr("Ctrl+R")));
|
|
||||||
edit_ori -> setShortcut(QKeySequence(tr("Ctrl+T")));
|
edit_ori -> setShortcut(QKeySequence(tr("Ctrl+T")));
|
||||||
edit_author -> setShortcut(tr("Ctrl+Y"));
|
edit_author -> setShortcut(tr("Ctrl+Y"));
|
||||||
|
|
||||||
@@ -236,7 +234,6 @@ void QETElementEditor::setupActions() {
|
|||||||
connect(zoom_fit, SIGNAL(triggered()), ce_view, SLOT(zoomFit()));
|
connect(zoom_fit, SIGNAL(triggered()), ce_view, SLOT(zoomFit()));
|
||||||
connect(zoom_reset, SIGNAL(triggered()), ce_view, SLOT(zoomReset()));
|
connect(zoom_reset, SIGNAL(triggered()), ce_view, SLOT(zoomReset()));
|
||||||
connect(edit_delete, SIGNAL(triggered()), ce_scene, SLOT(slot_delete()));
|
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()));
|
connect(edit_names, SIGNAL(triggered()), ce_scene, SLOT(slot_editNames()));
|
||||||
connect(edit_ori, SIGNAL(triggered()), ce_scene, SLOT(slot_editOrientations()));
|
connect(edit_ori, SIGNAL(triggered()), ce_scene, SLOT(slot_editOrientations()));
|
||||||
connect(edit_author, SIGNAL(triggered()), ce_scene, SLOT(slot_editAuthorInformations()));
|
connect(edit_author, SIGNAL(triggered()), ce_scene, SLOT(slot_editAuthorInformations()));
|
||||||
@@ -253,7 +250,6 @@ void QETElementEditor::setupActions() {
|
|||||||
connect(add_arc, SIGNAL(triggered()), ce_scene, SLOT(slot_addArc()));
|
connect(add_arc, SIGNAL(triggered()), ce_scene, SLOT(slot_addArc()));
|
||||||
connect(add_terminal, SIGNAL(triggered()), ce_scene, SLOT(slot_addTerminal()));
|
connect(add_terminal, SIGNAL(triggered()), ce_scene, SLOT(slot_addTerminal()));
|
||||||
connect(add_textfield, SIGNAL(triggered()), ce_scene, SLOT(slot_addTextField()));
|
connect(add_textfield, SIGNAL(triggered()), ce_scene, SLOT(slot_addTextField()));
|
||||||
|
|
||||||
connect(move, SIGNAL(triggered()), this, SLOT(slot_setRubberBandToView()));
|
connect(move, SIGNAL(triggered()), this, SLOT(slot_setRubberBandToView()));
|
||||||
connect(add_line, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
connect(add_line, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
||||||
connect(add_rectangle, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
connect(add_rectangle, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
|
||||||
@@ -321,7 +317,6 @@ void QETElementEditor::setupActions() {
|
|||||||
main_toolbar -> addAction(edit_delete);
|
main_toolbar -> addAction(edit_delete);
|
||||||
view_toolbar -> addAction(zoom_fit);
|
view_toolbar -> addAction(zoom_fit);
|
||||||
view_toolbar -> addAction(zoom_reset);
|
view_toolbar -> addAction(zoom_reset);
|
||||||
element_toolbar -> addAction(edit_size_hs);
|
|
||||||
element_toolbar -> addAction(edit_names);
|
element_toolbar -> addAction(edit_names);
|
||||||
element_toolbar -> addAction(edit_ori);
|
element_toolbar -> addAction(edit_ori);
|
||||||
depth_toolbar -> addAction(edit_forward);
|
depth_toolbar -> addAction(edit_forward);
|
||||||
@@ -398,7 +393,6 @@ void QETElementEditor::setupMenus() {
|
|||||||
edit_menu -> addAction(edit_delete);
|
edit_menu -> addAction(edit_delete);
|
||||||
edit_menu -> addSeparator();
|
edit_menu -> addSeparator();
|
||||||
edit_menu -> addAction(edit_names);
|
edit_menu -> addAction(edit_names);
|
||||||
edit_menu -> addAction(edit_size_hs);
|
|
||||||
edit_menu -> addAction(edit_ori);
|
edit_menu -> addAction(edit_ori);
|
||||||
edit_menu -> addAction(edit_author);
|
edit_menu -> addAction(edit_author);
|
||||||
edit_menu -> addSeparator();
|
edit_menu -> addSeparator();
|
||||||
@@ -627,23 +621,7 @@ bool QETElementEditor::checkElement() {
|
|||||||
// liste les avertissements applicables
|
// liste les avertissements applicables
|
||||||
typedef QPair<QString, QString> QETWarning;
|
typedef QPair<QString, QString> QETWarning;
|
||||||
QList<QETWarning> warnings;
|
QList<QETWarning> warnings;
|
||||||
|
|
||||||
/// Avertissement #1 : si les parties semblent deborder du cadre de l'element
|
|
||||||
if (!ce_scene -> borderContainsEveryParts()) {
|
|
||||||
warnings << qMakePair(
|
|
||||||
tr("Dimensions de l'\351l\351ment", "warning title"),
|
|
||||||
tr(
|
|
||||||
"Certaines parties graphiques (textes, cercles, lignes...) "
|
|
||||||
"semblent d\351border du cadre de l'\351l\351ment. Cela "
|
|
||||||
"risque de g\351n\351rer des bugs graphiques lors de leur "
|
|
||||||
"manipulation sur un sch\351ma. Vous pouvez corriger cela soit "
|
|
||||||
"en d\351pla\347ant ces parties, soit en vous rendant dans "
|
|
||||||
"\311dition > \311diter la taille et le point de saisie.",
|
|
||||||
"warning description"
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Avertissement #2 : si l'element ne comporte aucune borne
|
/// Avertissement #2 : si l'element ne comporte aucune borne
|
||||||
if (!ce_scene -> containsTerminals()) {
|
if (!ce_scene -> containsTerminals()) {
|
||||||
warnings << qMakePair(
|
warnings << qMakePair(
|
||||||
|
|||||||
@@ -92,10 +92,6 @@ class QETElementEditor : public QETMainWindow {
|
|||||||
|
|
||||||
// methods
|
// methods
|
||||||
public:
|
public:
|
||||||
void setSize(const QSize &);
|
|
||||||
QSize size() const;
|
|
||||||
void setHotspot(const QPoint &);
|
|
||||||
QPoint hotspot() const;
|
|
||||||
void setNames(const NamesList &);
|
void setNames(const NamesList &);
|
||||||
void setOrientations(const OrientationSet &orientation_set);
|
void setOrientations(const OrientationSet &orientation_set);
|
||||||
OrientationSet orientations() const;
|
OrientationSet orientations() const;
|
||||||
@@ -156,40 +152,6 @@ class QETElementEditor : public QETMainWindow {
|
|||||||
void updateCurrentPartEditor();
|
void updateCurrentPartEditor();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
@param siz The new size for the currently edited element
|
|
||||||
*/
|
|
||||||
inline void QETElementEditor::setSize(const QSize &siz) {
|
|
||||||
ce_scene -> setWidth(siz.width());
|
|
||||||
ce_scene -> setHeight(siz.height());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return the size of the currently edited element
|
|
||||||
*/
|
|
||||||
inline QSize QETElementEditor::size() const {
|
|
||||||
return(
|
|
||||||
QSize(
|
|
||||||
ce_scene -> width(),
|
|
||||||
ce_scene -> height()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param hs The new hotspot for the currently edited element
|
|
||||||
*/
|
|
||||||
inline void QETElementEditor::setHotspot(const QPoint &hs) {
|
|
||||||
ce_scene -> setHotspot(hs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return the hotspot of the currently edited element
|
|
||||||
*/
|
|
||||||
inline QPoint QETElementEditor::hotspot() const {
|
|
||||||
return(ce_scene -> hotspot());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@param nameslist the new list of names for the currently edited element
|
@param nameslist the new list of names for the currently edited element
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,329 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2006-2012 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 "hotspoteditor.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
Constructeur
|
|
||||||
@param parent QWidget parent de cet editeur de hotspot
|
|
||||||
*/
|
|
||||||
HotspotEditor::HotspotEditor(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
parts_rect_enabled(false)
|
|
||||||
{
|
|
||||||
informations_label_ = new QLabel(
|
|
||||||
tr(
|
|
||||||
"L'\351l\351ment doit \352tre assez grand pour contenir tout sa "
|
|
||||||
"repr\351sentation graphique."
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
sb_width = new QSpinBox();
|
|
||||||
sb_width -> setMinimum(1);
|
|
||||||
sb_width -> setMaximum(1000);
|
|
||||||
sb_width -> setValue(3);
|
|
||||||
sb_width -> setSuffix(tr(" \32710 px"));
|
|
||||||
sb_height = new QSpinBox();
|
|
||||||
sb_height -> setMinimum(1);
|
|
||||||
sb_height -> setMaximum(1000);
|
|
||||||
sb_height -> setValue(7);
|
|
||||||
sb_height -> setSuffix(tr(" \32710 px"));
|
|
||||||
|
|
||||||
sb_hotspot_x = new QSpinBox();
|
|
||||||
sb_hotspot_x -> setValue(15);
|
|
||||||
sb_hotspot_x -> setSuffix(tr(" px"));
|
|
||||||
sb_hotspot_x -> setSingleStep(10);
|
|
||||||
sb_hotspot_y = new QSpinBox();
|
|
||||||
sb_hotspot_y -> setValue(35);
|
|
||||||
sb_hotspot_y -> setSuffix(tr(" px"));
|
|
||||||
sb_hotspot_y -> setSingleStep(10);
|
|
||||||
|
|
||||||
diagram_scene = new Diagram();
|
|
||||||
diagram_scene -> border_and_titleblock.setColumnsWidth(50.0);
|
|
||||||
diagram_scene -> border_and_titleblock.setColumnsCount(3);
|
|
||||||
diagram_scene -> border_and_titleblock.setRowsHeight(60.0);
|
|
||||||
diagram_scene -> border_and_titleblock.setRowsCount(2);
|
|
||||||
diagram_scene -> border_and_titleblock.displayRows(false);
|
|
||||||
diagram_scene -> border_and_titleblock.displayTitleBlock(false);
|
|
||||||
|
|
||||||
diagram_view = new QGraphicsView(diagram_scene);
|
|
||||||
diagram_view -> setMinimumSize(
|
|
||||||
qRound(diagram_scene -> border_and_titleblock.diagramWidth() + (3 * Diagram::margin)),
|
|
||||||
qRound(diagram_scene -> border_and_titleblock.diagramHeight() + (3 * Diagram::margin))
|
|
||||||
);
|
|
||||||
diagram_view -> setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
|
|
||||||
diagram_view -> setResizeAnchor(QGraphicsView::AnchorUnderMouse);
|
|
||||||
diagram_view -> setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
|
||||||
|
|
||||||
hotspot_sync = new QCheckBox(tr("D\351placer l'\351l\351ment avec le hotspot"));
|
|
||||||
hotspot_sync -> setChecked(true);
|
|
||||||
// TODO setvisible to disable checkbox hotspot_sync
|
|
||||||
// one for remove bug in element editor after un move hotspot_sync, selection is not focused on primitives
|
|
||||||
// two is not specialy used
|
|
||||||
// and for future auto boudinrect hotspot
|
|
||||||
hotspot_sync -> setVisible(false);
|
|
||||||
|
|
||||||
connect(sb_width, SIGNAL(valueChanged(int)), this, SLOT(updateHotspotLimits()));
|
|
||||||
connect(sb_height, SIGNAL(valueChanged(int)), this, SLOT(updateHotspotLimits()));
|
|
||||||
connect(sb_width, SIGNAL(valueChanged(int)), this, SLOT(updateScene()));
|
|
||||||
connect(sb_height, SIGNAL(valueChanged(int)), this, SLOT(updateScene()));
|
|
||||||
connect(sb_hotspot_x, SIGNAL(valueChanged(int)), this, SLOT(updateScene()));
|
|
||||||
connect(sb_hotspot_y, SIGNAL(valueChanged(int)), this, SLOT(updateScene()));
|
|
||||||
connect(hotspot_sync, SIGNAL(stateChanged(int)), this, SLOT(updateScene()));
|
|
||||||
|
|
||||||
QGridLayout *grid_layout = new QGridLayout();
|
|
||||||
grid_layout -> addWidget(new QLabel(tr("<span style=\"text-decoration:underline;\">Dimensions</span>")), 0, 0);
|
|
||||||
grid_layout -> addWidget(new QLabel(tr("Largeur :")), 1, 0);
|
|
||||||
grid_layout -> addWidget(sb_width, 1, 1);
|
|
||||||
grid_layout -> addWidget(new QLabel(tr("Hauteur :")), 2, 0);
|
|
||||||
grid_layout -> addWidget(sb_height, 2, 1);
|
|
||||||
grid_layout -> addWidget(new QLabel(tr("<span style=\"text-decoration:underline;\">Hotspot</span>")), 3, 0);
|
|
||||||
grid_layout -> addWidget(new QLabel(tr("Abscisse :")), 4, 0);
|
|
||||||
grid_layout -> addWidget(sb_hotspot_x, 4, 1);
|
|
||||||
grid_layout -> addWidget(new QLabel(tr("Ordonn\351e :")), 5, 0);
|
|
||||||
grid_layout -> addWidget(sb_hotspot_y, 5, 1);
|
|
||||||
grid_layout -> setRowStretch(6, 500);
|
|
||||||
grid_layout -> setSpacing(3);
|
|
||||||
|
|
||||||
QHBoxLayout *hlayout = new QHBoxLayout();
|
|
||||||
hlayout -> addLayout(grid_layout, 1);
|
|
||||||
hlayout -> addWidget(diagram_view, 500);
|
|
||||||
|
|
||||||
vlayout = new QVBoxLayout(this);
|
|
||||||
vlayout -> setSpacing(0);
|
|
||||||
vlayout -> addWidget(informations_label_);
|
|
||||||
vlayout -> addLayout(hlayout, 1);
|
|
||||||
|
|
||||||
updateScene();
|
|
||||||
updateHotspotLimits();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @param w Nouvelle largeur de l'element, en dizaines de pixels
|
|
||||||
void HotspotEditor::setElementWidth(uint w) {
|
|
||||||
sb_width -> setValue(w);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @param h Nouvelle hauteur de l'element, en dizaines de pixels
|
|
||||||
void HotspotEditor::setElementHeight(uint h) {
|
|
||||||
sb_height -> setValue(h);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return la Largeur de l'element en dizaines de pixels
|
|
||||||
uint HotspotEditor::elementWidth10px() const {
|
|
||||||
return(sb_width -> value());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return la hauteur de l'element en dizaines de pixels
|
|
||||||
uint HotspotEditor::elementHeight10px() const {
|
|
||||||
return(sb_height -> value());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return la Largeur de l'element en pixels
|
|
||||||
uint HotspotEditor::elementWidth() const {
|
|
||||||
return(sb_width -> value() * 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return la hauteur de l'element en pixels
|
|
||||||
uint HotspotEditor::elementHeight() const {
|
|
||||||
return(sb_height -> value() * 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @param size La nouvelle taille de l'element, en dizaines de pixels
|
|
||||||
void HotspotEditor::setElementSize(const QSize &size) {
|
|
||||||
setElementWidth(size.width());
|
|
||||||
setElementWidth(size.height());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return la taille de l'element, en dizaines de pixels
|
|
||||||
QSize HotspotEditor::elementSize10px() const {
|
|
||||||
return(QSize(elementWidth10px(), elementHeight10px()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return la taille de l'element, en pixels
|
|
||||||
QSize HotspotEditor::elementSize() const {
|
|
||||||
return(QSize(elementWidth(), elementHeight()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @param hs Nouvelle position du hotspot
|
|
||||||
void HotspotEditor::setHotspot(const QPoint &hs) {
|
|
||||||
sb_hotspot_x -> setValue(hs.x());
|
|
||||||
sb_hotspot_y -> setValue(hs.y());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return les coordonnees du hotspot de l'element
|
|
||||||
QPoint HotspotEditor::hotspot() const {
|
|
||||||
return(QPoint(sb_hotspot_x -> value(), sb_hotspot_y -> value()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @param o_h l'ancien hotspot en cas d'edition du hotspot
|
|
||||||
void HotspotEditor::setOldHotspot(const QPoint &o_h) {
|
|
||||||
old_hotspot = o_h;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return l'ancien hotspot en cas d'edition du hotspot
|
|
||||||
QPoint HotspotEditor::oldHotspot() const {
|
|
||||||
return(old_hotspot);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Specifie le rectangle delimitant les parties de l'element
|
|
||||||
@param rect rectangle delimitant les parties de l'element
|
|
||||||
*/
|
|
||||||
void HotspotEditor::setPartsRect(const QRectF &rect) {
|
|
||||||
parts_rect = rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return le rectangle delimitant les parties de l'element
|
|
||||||
QRectF HotspotEditor::partsRect() const {
|
|
||||||
return(parts_rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param a true pour activer l'affichage du rectangle representant l'element,
|
|
||||||
false pour le desactiver
|
|
||||||
*/
|
|
||||||
void HotspotEditor::setPartsRectEnabled(bool a) {
|
|
||||||
if (a != parts_rect_enabled) {
|
|
||||||
if (a) vlayout -> addWidget(hotspot_sync);
|
|
||||||
else vlayout -> removeWidget(hotspot_sync);
|
|
||||||
}
|
|
||||||
parts_rect_enabled = a;
|
|
||||||
updateScene();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return true si l'affichage du rectangle representant l'element est active,
|
|
||||||
false sinon
|
|
||||||
*/
|
|
||||||
bool HotspotEditor::partsRectEnabled() {
|
|
||||||
return(parts_rect_enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return true s'il sera necessaire d'appliquer une translation aux parties de l'elements
|
|
||||||
bool HotspotEditor::mustTranslateParts() const {
|
|
||||||
// il sera necessaire d'appliquer une translation aux parties de l'elements
|
|
||||||
// si le hotspot a ete change et si l'element ne suit pas le hotspot
|
|
||||||
bool hotspot_change = !old_hotspot.isNull() && old_hotspot != hotspot();
|
|
||||||
return(hotspot_change && !hotspot_sync -> isChecked());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return La translation a faire subir aux parties de l'element apres l'edition du hotspot
|
|
||||||
QPoint HotspotEditor::offsetParts() const {
|
|
||||||
// si le hotspot n'a pas ete change ou si l'element doit suivre le hotspot,
|
|
||||||
// il n'est pas necessaire d'appliquer une translation aux parties de
|
|
||||||
// l'elements
|
|
||||||
if (!mustTranslateParts()) return(QPoint(0,0));
|
|
||||||
else return(old_hotspot - hotspot());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@return true si ce widget est en lecture seule, false sinon
|
|
||||||
*/
|
|
||||||
bool HotspotEditor::isReadOnly() const {
|
|
||||||
return(sb_width -> isReadOnly());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@param ro true pour passer ce widget en lecture seule, false sinon
|
|
||||||
*/
|
|
||||||
void HotspotEditor::setReadOnly(bool ro) {
|
|
||||||
sb_width -> setReadOnly(ro);
|
|
||||||
sb_height -> setReadOnly(ro);
|
|
||||||
sb_hotspot_x -> setReadOnly(ro);
|
|
||||||
sb_hotspot_y -> setReadOnly(ro);
|
|
||||||
hotspot_sync -> setDisabled(ro);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Met a jour le schema
|
|
||||||
*/
|
|
||||||
void HotspotEditor::updateScene() {
|
|
||||||
// nettoie la scene
|
|
||||||
foreach (QGraphicsItem *qgi, diagram_scene -> items()) {
|
|
||||||
diagram_scene -> removeItem(qgi);
|
|
||||||
delete qgi;
|
|
||||||
}
|
|
||||||
|
|
||||||
int elmt_width = sb_width -> value() * 10;
|
|
||||||
int elmt_height = sb_height -> value() * 10;
|
|
||||||
int hotspot_x = sb_hotspot_x -> value();
|
|
||||||
int hotspot_y = sb_hotspot_y -> value();
|
|
||||||
int margin_x = 10;
|
|
||||||
int margin_y = 30;
|
|
||||||
|
|
||||||
// dessin du cadre representant les dimensions de l'element
|
|
||||||
diagram_scene -> addRect(QRectF(margin_x, margin_y, elmt_width, elmt_height));
|
|
||||||
|
|
||||||
// dessin des deux segments representant le point de saisie de l'element
|
|
||||||
QPen hotspot_pen(Qt::red);
|
|
||||||
QGraphicsLineItem *line_hotspot_x = diagram_scene -> addLine(
|
|
||||||
QLine(
|
|
||||||
margin_x,
|
|
||||||
margin_y + hotspot_y,
|
|
||||||
margin_x + elmt_width,
|
|
||||||
margin_y + hotspot_y
|
|
||||||
),
|
|
||||||
hotspot_pen
|
|
||||||
);
|
|
||||||
QGraphicsLineItem *line_hotspot_y = diagram_scene -> addLine(
|
|
||||||
QLine(
|
|
||||||
margin_x + hotspot_x,
|
|
||||||
margin_y,
|
|
||||||
margin_x + hotspot_x,
|
|
||||||
margin_y + elmt_height
|
|
||||||
),
|
|
||||||
hotspot_pen
|
|
||||||
);
|
|
||||||
line_hotspot_x -> setZValue(10);
|
|
||||||
line_hotspot_y -> setZValue(10);
|
|
||||||
|
|
||||||
// dessin eventuel du rectangle representant l'element
|
|
||||||
if (parts_rect_enabled) {
|
|
||||||
QPen element_pen(Qt::blue);
|
|
||||||
QBrush element_brush(QColor(0, 0, 255, 100));
|
|
||||||
QRectF parts_rect_to_draw;
|
|
||||||
|
|
||||||
if (!hotspot_sync -> isChecked() && !old_hotspot.isNull()) {
|
|
||||||
// coordonnees de l'ancien hotspot sur le schema
|
|
||||||
QPointF current_old_hotspotf(margin_x + old_hotspot.x(), margin_y + old_hotspot.y());
|
|
||||||
QPoint current_old_hotspot(current_old_hotspotf.toPoint());
|
|
||||||
|
|
||||||
// laisse l'element en place par rapport au coin superieur gauche
|
|
||||||
parts_rect_to_draw = parts_rect.translated(current_old_hotspot);
|
|
||||||
} else {
|
|
||||||
// coordonnees du nouveau hotspot sur le schema
|
|
||||||
QPointF current_hotspotf(line_hotspot_y -> line().x1(), line_hotspot_x -> line().y1());
|
|
||||||
QPoint current_hotspot(current_hotspotf.toPoint());
|
|
||||||
|
|
||||||
// deplace l'element en meme temps que le hotspot
|
|
||||||
parts_rect_to_draw = parts_rect.translated(current_hotspot);
|
|
||||||
}
|
|
||||||
QGraphicsRectItem *rect_element = diagram_scene -> addRect(parts_rect_to_draw, element_pen, element_brush);
|
|
||||||
rect_element -> setZValue(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
diagram_scene -> setSceneRect(QRect(0, 0, elmt_width + (2 * margin_x) + 15, elmt_height + (2 * margin_y)));
|
|
||||||
diagram_scene -> update();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Met a jour les limites des QSpinBox
|
|
||||||
*/
|
|
||||||
void HotspotEditor::updateHotspotLimits() {
|
|
||||||
sb_hotspot_x -> setMaximum(sb_width -> value() * 10);
|
|
||||||
sb_hotspot_y -> setMaximum(sb_height -> value() * 10);
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2006-2012 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 HOTSPOT_EDITOR_H
|
|
||||||
#define HOTSPOT_EDITOR_H
|
|
||||||
#include <QtGui>
|
|
||||||
#include "diagram.h"
|
|
||||||
/**
|
|
||||||
This widget enable users to edit the dimensions and the hotspot of an
|
|
||||||
electrical element.
|
|
||||||
*/
|
|
||||||
class HotspotEditor : public QWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
// constructors, destructor
|
|
||||||
public:
|
|
||||||
HotspotEditor(QWidget * = 0);
|
|
||||||
virtual ~HotspotEditor() {};
|
|
||||||
|
|
||||||
private:
|
|
||||||
HotspotEditor(const HotspotEditor &);
|
|
||||||
|
|
||||||
// attributes
|
|
||||||
private:
|
|
||||||
QLabel *informations_label_;
|
|
||||||
QSpinBox *sb_width;
|
|
||||||
QSpinBox *sb_height;
|
|
||||||
QSpinBox *sb_hotspot_x;
|
|
||||||
QSpinBox *sb_hotspot_y;
|
|
||||||
QCheckBox *hotspot_sync;
|
|
||||||
Diagram *diagram_scene;
|
|
||||||
QGraphicsView *diagram_view;
|
|
||||||
QRectF parts_rect;
|
|
||||||
QPoint old_hotspot;
|
|
||||||
bool parts_rect_enabled;
|
|
||||||
QVBoxLayout *vlayout;
|
|
||||||
|
|
||||||
// methods
|
|
||||||
public:
|
|
||||||
void setElementWidth(uint);
|
|
||||||
void setElementHeight(uint);
|
|
||||||
uint elementWidth10px() const;
|
|
||||||
uint elementWidth() const;
|
|
||||||
uint elementHeight10px() const;
|
|
||||||
uint elementHeight() const;
|
|
||||||
void setElementSize(const QSize &);
|
|
||||||
QSize elementSize10px() const;
|
|
||||||
QSize elementSize() const;
|
|
||||||
void setHotspot(const QPoint &);
|
|
||||||
QPoint hotspot() const;
|
|
||||||
void setOldHotspot(const QPoint &);
|
|
||||||
QPoint oldHotspot() const;
|
|
||||||
void setPartsRect(const QRectF &);
|
|
||||||
QRectF partsRect() const;
|
|
||||||
void setPartsRectEnabled(bool);
|
|
||||||
bool partsRectEnabled();
|
|
||||||
bool mustTranslateParts() const;
|
|
||||||
QPoint offsetParts() const;
|
|
||||||
bool isReadOnly() const;
|
|
||||||
void setReadOnly(bool);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void updateScene();
|
|
||||||
void updateHotspotLimits();
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
@@ -21,7 +21,6 @@
|
|||||||
#include "elementscategorieslist.h"
|
#include "elementscategorieslist.h"
|
||||||
#include "nameslistwidget.h"
|
#include "nameslistwidget.h"
|
||||||
#include "orientationsetwidget.h"
|
#include "orientationsetwidget.h"
|
||||||
#include "hotspoteditor.h"
|
|
||||||
#include "element.h"
|
#include "element.h"
|
||||||
#include "qetelementeditor.h"
|
#include "qetelementeditor.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
@@ -50,7 +49,6 @@ NewElementWizard::NewElementWizard(QWidget *parent, Qt::WindowFlags f) :
|
|||||||
addPage(buildStep2());
|
addPage(buildStep2());
|
||||||
addPage(buildStep3());
|
addPage(buildStep3());
|
||||||
addPage(buildStep4());
|
addPage(buildStep4());
|
||||||
addPage(buildStep5());
|
|
||||||
setFixedSize(705, 325);
|
setFixedSize(705, 325);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +92,7 @@ bool NewElementWizard::preselectCategory(ElementsCategory *category) {
|
|||||||
QWizardPage *NewElementWizard::buildStep1() {
|
QWizardPage *NewElementWizard::buildStep1() {
|
||||||
QWizardPage *page = new QWizardPage();
|
QWizardPage *page = new QWizardPage();
|
||||||
page -> setProperty("WizardState", Category);
|
page -> setProperty("WizardState", Category);
|
||||||
page -> setTitle(tr("\311tape 1/5 : Cat\351gorie parente", "wizard page title"));
|
page -> setTitle(tr("\311tape 1/4 : Cat\351gorie parente", "wizard page title"));
|
||||||
page -> setSubTitle(tr("S\351lectionnez une cat\351gorie dans laquelle enregistrer le nouvel \351l\351ment.", "wizard page subtitle"));
|
page -> setSubTitle(tr("S\351lectionnez une cat\351gorie dans laquelle enregistrer le nouvel \351l\351ment.", "wizard page subtitle"));
|
||||||
QVBoxLayout *layout = new QVBoxLayout();
|
QVBoxLayout *layout = new QVBoxLayout();
|
||||||
|
|
||||||
@@ -111,7 +109,7 @@ QWizardPage *NewElementWizard::buildStep1() {
|
|||||||
QWizardPage *NewElementWizard::buildStep2() {
|
QWizardPage *NewElementWizard::buildStep2() {
|
||||||
QWizardPage *page = new QWizardPage();
|
QWizardPage *page = new QWizardPage();
|
||||||
page -> setProperty("WizardState", Filename);
|
page -> setProperty("WizardState", Filename);
|
||||||
page -> setTitle(tr("\311tape 2/5 : Nom du fichier", "wizard page title"));
|
page -> setTitle(tr("\311tape 2/4 : Nom du fichier", "wizard page title"));
|
||||||
page -> setSubTitle(tr("Indiquez le nom du fichier dans lequel enregistrer le nouvel \351l\351ment.", "wizard page subtitle"));
|
page -> setSubTitle(tr("Indiquez le nom du fichier dans lequel enregistrer le nouvel \351l\351ment.", "wizard page subtitle"));
|
||||||
QVBoxLayout *layout = new QVBoxLayout();
|
QVBoxLayout *layout = new QVBoxLayout();
|
||||||
|
|
||||||
@@ -134,7 +132,7 @@ QWizardPage *NewElementWizard::buildStep2() {
|
|||||||
QWizardPage *NewElementWizard::buildStep3() {
|
QWizardPage *NewElementWizard::buildStep3() {
|
||||||
QWizardPage *page = new QWizardPage();
|
QWizardPage *page = new QWizardPage();
|
||||||
page -> setProperty("WizardState", Names);
|
page -> setProperty("WizardState", Names);
|
||||||
page -> setTitle(tr("\311tape 3/5 : Noms de l'\351l\351ment", "wizard page title"));
|
page -> setTitle(tr("\311tape 3/4 : Noms de l'\351l\351ment", "wizard page title"));
|
||||||
page -> setSubTitle(tr("Indiquez le ou les noms de l'\351l\351ment.", "wizard page subtitle"));
|
page -> setSubTitle(tr("Indiquez le ou les noms de l'\351l\351ment.", "wizard page subtitle"));
|
||||||
QVBoxLayout *layout = new QVBoxLayout();
|
QVBoxLayout *layout = new QVBoxLayout();
|
||||||
|
|
||||||
@@ -149,30 +147,12 @@ QWizardPage *NewElementWizard::buildStep3() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Met en place l'etape 4 : Dimensions et Hotspot
|
Met en place l'etape 4 : orientations possibles pour le nouvel element
|
||||||
*/
|
*/
|
||||||
QWizardPage *NewElementWizard::buildStep4() {
|
QWizardPage *NewElementWizard::buildStep4() {
|
||||||
QWizardPage *page = new QWizardPage();
|
|
||||||
page -> setProperty("WizardState", Dimensions);
|
|
||||||
page -> setTitle(tr("\311tape 4/5 : Dimensions et point de saisie", "wizard page title"));
|
|
||||||
page -> setSubTitle(tr("Saisissez les dimensions du nouvel \351l\351ment ainsi que la position du hotspot (point de saisie de l'\351l\351ment \340 la souris) en consid\351rant que l'\351l\351ment est dans son orientation par d\351faut.", "wizard page subtitle"));
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout();
|
|
||||||
|
|
||||||
hotspot_editor = new HotspotEditor();
|
|
||||||
layout -> addWidget(hotspot_editor, 0);
|
|
||||||
layout -> setSpacing(0);
|
|
||||||
|
|
||||||
page -> setLayout(layout);
|
|
||||||
return(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Met en place l'etape 5 : orientations possibles pour le nouvel element
|
|
||||||
*/
|
|
||||||
QWizardPage *NewElementWizard::buildStep5() {
|
|
||||||
QWizardPage *page = new QWizardPage();
|
QWizardPage *page = new QWizardPage();
|
||||||
page -> setProperty("WizardState", Orientations);
|
page -> setProperty("WizardState", Orientations);
|
||||||
page -> setTitle(tr("\311tape 5/5 : Orientations", "wizard page title"));
|
page -> setTitle(tr("\311tape 4/4 : Orientations", "wizard page title"));
|
||||||
page -> setSubTitle(tr("Indiquez les orientations possibles pour le nouvel \351l\351ment.", "wizard page subtitle"));
|
page -> setSubTitle(tr("Indiquez les orientations possibles pour le nouvel \351l\351ment.", "wizard page subtitle"));
|
||||||
QVBoxLayout *layout = new QVBoxLayout();
|
QVBoxLayout *layout = new QVBoxLayout();
|
||||||
|
|
||||||
@@ -274,8 +254,6 @@ bool NewElementWizard::validStep2() {
|
|||||||
*/
|
*/
|
||||||
void NewElementWizard::createNewElement() {
|
void NewElementWizard::createNewElement() {
|
||||||
QETElementEditor *edit_new_element = new QETElementEditor(parentWidget());
|
QETElementEditor *edit_new_element = new QETElementEditor(parentWidget());
|
||||||
edit_new_element -> setSize(hotspot_editor -> elementSize());
|
|
||||||
edit_new_element -> setHotspot(hotspot_editor -> hotspot());
|
|
||||||
edit_new_element -> setNames(element_names -> names());
|
edit_new_element -> setNames(element_names -> names());
|
||||||
edit_new_element -> setOrientations(orientation_set -> orientationSet());
|
edit_new_element -> setOrientations(orientation_set -> orientationSet());
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ class ElementsCategoriesWidget;
|
|||||||
class ElementsCategory;
|
class ElementsCategory;
|
||||||
class NamesListWidget;
|
class NamesListWidget;
|
||||||
class OrientationSetWidget;
|
class OrientationSetWidget;
|
||||||
class HotspotEditor;
|
|
||||||
class QFileNameEdit;
|
class QFileNameEdit;
|
||||||
/**
|
/**
|
||||||
This class provides a wizard dialog enabling users to to specify the basic
|
This class provides a wizard dialog enabling users to to specify the basic
|
||||||
@@ -59,7 +58,6 @@ class NewElementWizard : public QWizard {
|
|||||||
QFileNameEdit *qle_filename;
|
QFileNameEdit *qle_filename;
|
||||||
NamesListWidget *element_names;
|
NamesListWidget *element_names;
|
||||||
OrientationSetWidget *orientation_set;
|
OrientationSetWidget *orientation_set;
|
||||||
HotspotEditor *hotspot_editor;
|
|
||||||
WizardState current_state;
|
WizardState current_state;
|
||||||
QString chosen_file;
|
QString chosen_file;
|
||||||
ElementsCategory *chosen_category;
|
ElementsCategory *chosen_category;
|
||||||
@@ -70,7 +68,6 @@ class NewElementWizard : public QWizard {
|
|||||||
QWizardPage *buildStep2();
|
QWizardPage *buildStep2();
|
||||||
QWizardPage *buildStep3();
|
QWizardPage *buildStep3();
|
||||||
QWizardPage *buildStep4();
|
QWizardPage *buildStep4();
|
||||||
QWizardPage *buildStep5();
|
|
||||||
bool validStep1();
|
bool validStep1();
|
||||||
bool validStep2();
|
bool validStep2();
|
||||||
bool validateCurrentPage();
|
bool validateCurrentPage();
|
||||||
|
|||||||
Reference in New Issue
Block a user