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:
blacksun
2013-08-05 13:20:57 +00:00
parent 797d5200ba
commit 302b519dfb
11 changed files with 11 additions and 786 deletions

View File

@@ -376,72 +376,6 @@ void ChangePolygonPointsCommand::redo() {
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
@param element_scene Element edite

View File

@@ -224,39 +224,6 @@ class ChangePolygonPointsCommand : public ElementEditionCommand {
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.
*/

View File

@@ -27,7 +27,6 @@
#include "parttext.h"
#include "parttextfield.h"
#include "partarc.h"
#include "hotspoteditor.h"
#include "editorcommands.h"
#include "elementcontent.h"
#include "nameslist.h"
@@ -39,9 +38,6 @@
*/
ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
QGraphicsScene(parent),
_width(3),
_height(7),
_hotspot(15, 35),
internal_connections(false),
qgi_manager(this),
element_editor(editor),
@@ -325,55 +321,6 @@ void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *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.
@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 -> setBrush(Qt::NoBrush);
p -> drawLine(QLineF(0.0, -_hotspot.y(), 0.0, height() - _hotspot.y()));
p -> drawLine(QLineF(-_hotspot.x(), 0.0, width() - _hotspot.x(), 0.0));
p -> drawLine(-20, 0, 20, 0);
p -> drawLine(0, -20, 0, 20);
p -> restore();
}
@@ -555,7 +502,7 @@ void ElementScene::fromXml(
superieur gauche les coordonnees opposees du hotspot.
*/
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());
}
/**
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
*/
@@ -1092,25 +993,7 @@ bool ElementScene::applyInformations(const QDomDocument &xml_document, QString *
}
return(false);
}
// dimensions et hotspot : ces attributs doivent etre presents et valides
int w, h, hot_x, hot_y;
if (
!QET::attributeIsAnInteger(root, QString("width"), &w) ||\
!QET::attributeIsAnInteger(root, QString("height"), &h) ||\
!QET::attributeIsAnInteger(root, QString("hotspot_x"), &hot_x) ||\
!QET::attributeIsAnInteger(root, QString("hotspot_y"), &hot_y)
) {
if (error_message) {
*error_message = tr("Les dimensions ou le point de saisie ne sont pas valides.", "error message");
}
return(false);
}
//
setWidth(w);
setHeight(h);
setHotspot(QPoint(hot_x, hot_y));
// orientations
internal_connections = (root.attribute("ic") == "true");

View File

@@ -63,12 +63,6 @@ class ElementScene : public QGraphicsScene {
// attributes
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
NamesList _names;
/// Set of orientations
@@ -116,12 +110,6 @@ class ElementScene : public QGraphicsScene {
// methods
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 &);
NamesList names() const;
OrientationSet orientations();
@@ -158,7 +146,6 @@ class ElementScene : public QGraphicsScene {
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *);
virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *);
virtual void drawBackground(QPainter *, const QRectF &);
virtual void drawForeground(QPainter *, const QRectF &);
virtual void endCurrentBehavior(const QGraphicsSceneMouseEvent *);
@@ -191,7 +178,6 @@ class ElementScene : public QGraphicsScene {
void slot_deselectAll();
void slot_invertSelection();
void slot_delete();
void slot_editSizeHotSpot();
void slot_editNames();
void slot_editOrientations();
void slot_editAuthorInformations();
@@ -220,51 +206,6 @@ class ElementScene : public QGraphicsScene {
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

View File

@@ -408,13 +408,7 @@ void ElementView::drawBackground(QPainter *p, const QRectF &r) {
p -> setPen(Qt::NoPen);
p -> setBrush(Qt::white);
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
qreal zoom_factor = matrix().m11();

View File

@@ -144,7 +144,6 @@ void QETElementEditor::setupActions() {
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_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_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);
@@ -205,7 +204,6 @@ void QETElementEditor::setupActions() {
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")));
edit_author -> setShortcut(tr("Ctrl+Y"));
@@ -236,7 +234,6 @@ void QETElementEditor::setupActions() {
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()));
connect(edit_ori, SIGNAL(triggered()), ce_scene, SLOT(slot_editOrientations()));
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_terminal, SIGNAL(triggered()), ce_scene, SLOT(slot_addTerminal()));
connect(add_textfield, SIGNAL(triggered()), ce_scene, SLOT(slot_addTextField()));
connect(move, SIGNAL(triggered()), this, SLOT(slot_setRubberBandToView()));
connect(add_line, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
connect(add_rectangle, SIGNAL(triggered()), this, SLOT(slot_setNoDragToView()));
@@ -321,7 +317,6 @@ void QETElementEditor::setupActions() {
main_toolbar -> addAction(edit_delete);
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);
@@ -398,7 +393,6 @@ void QETElementEditor::setupMenus() {
edit_menu -> addAction(edit_delete);
edit_menu -> addSeparator();
edit_menu -> addAction(edit_names);
edit_menu -> addAction(edit_size_hs);
edit_menu -> addAction(edit_ori);
edit_menu -> addAction(edit_author);
edit_menu -> addSeparator();
@@ -627,23 +621,7 @@ bool QETElementEditor::checkElement() {
// liste les avertissements applicables
typedef QPair<QString, QString> QETWarning;
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
if (!ce_scene -> containsTerminals()) {
warnings << qMakePair(

View File

@@ -92,10 +92,6 @@ class QETElementEditor : public QETMainWindow {
// methods
public:
void setSize(const QSize &);
QSize size() const;
void setHotspot(const QPoint &);
QPoint hotspot() const;
void setNames(const NamesList &);
void setOrientations(const OrientationSet &orientation_set);
OrientationSet orientations() const;
@@ -156,40 +152,6 @@ class QETElementEditor : public QETMainWindow {
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
*/