mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
Les pivotements d'elements sont desormais annulables
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@139 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -65,7 +65,6 @@ Conducer::Conducer(Terminal *p1, Terminal* p2, Element *parent, QGraphicsScene *
|
|||||||
mais s'en detache
|
mais s'en detache
|
||||||
*/
|
*/
|
||||||
Conducer::~Conducer() {
|
Conducer::~Conducer() {
|
||||||
// qDebug() << "~Conducer()" << (void *)this;
|
|
||||||
// se detache des bornes
|
// se detache des bornes
|
||||||
if (!isDestroyed()) destroy();
|
if (!isDestroyed()) destroy();
|
||||||
|
|
||||||
@@ -939,7 +938,7 @@ void Conducer::calculateTextItemPosition() {
|
|||||||
dans priv_modifieConducer.
|
dans priv_modifieConducer.
|
||||||
*/
|
*/
|
||||||
void Conducer::saveProfile() {
|
void Conducer::saveProfile() {
|
||||||
conducer_profile = ConducerProfile(this);
|
conducer_profile.fromConducer(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,15 +11,14 @@ ConducerProfile::ConducerProfile() {
|
|||||||
@param Conducer conducteur dont il faut extraire le profil
|
@param Conducer conducteur dont il faut extraire le profil
|
||||||
*/
|
*/
|
||||||
ConducerProfile::ConducerProfile(Conducer *conducer) {
|
ConducerProfile::ConducerProfile(Conducer *conducer) {
|
||||||
foreach(ConducerSegment *conducer_segment, conducer -> segmentsList()) {
|
fromConducer(conducer);
|
||||||
segments << new ConducerSegmentProfile(conducer_segment);
|
|
||||||
}
|
|
||||||
beginOrientation = conducer -> terminal1 -> orientation();
|
|
||||||
endOrientation = conducer -> terminal2 -> orientation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// destructeur
|
/// destructeur
|
||||||
ConducerProfile::~ConducerProfile() {
|
ConducerProfile::~ConducerProfile() {
|
||||||
|
foreach(ConducerSegmentProfile * s, segments) {
|
||||||
|
delete s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return true si le profil est nul
|
/// @return true si le profil est nul
|
||||||
@@ -77,6 +76,18 @@ QList<ConducerSegmentProfile *> ConducerProfile::verticalSegments() {
|
|||||||
return(segments_list);
|
return(segments_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConducerProfile::fromConducer(Conducer *conducer) {
|
||||||
|
// supprime les segments precedents
|
||||||
|
foreach(ConducerSegmentProfile *csp, segments) delete csp;
|
||||||
|
segments.clear();
|
||||||
|
|
||||||
|
foreach(ConducerSegment *conducer_segment, conducer -> segmentsList()) {
|
||||||
|
segments << new ConducerSegmentProfile(conducer_segment);
|
||||||
|
}
|
||||||
|
beginOrientation = conducer -> terminal1 -> orientation();
|
||||||
|
endOrientation = conducer -> terminal2 -> orientation();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet de debugger un profil de conducteur
|
Permet de debugger un profil de conducteur
|
||||||
@param d Object QDebug a utiliser pour l'affichage des informations de debug
|
@param d Object QDebug a utiliser pour l'affichage des informations de debug
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ class ConducerProfile {
|
|||||||
uint nbSegments(QET::ConducerSegmentType) const;
|
uint nbSegments(QET::ConducerSegmentType) const;
|
||||||
QList<ConducerSegmentProfile *> horizontalSegments();
|
QList<ConducerSegmentProfile *> horizontalSegments();
|
||||||
QList<ConducerSegmentProfile *> verticalSegments();
|
QList<ConducerSegmentProfile *> verticalSegments();
|
||||||
|
void fromConducer(Conducer *);
|
||||||
};
|
};
|
||||||
QDebug &operator<<(QDebug d, ConducerProfile &);
|
QDebug &operator<<(QDebug d, ConducerProfile &);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -327,3 +327,33 @@ void ChangeDiagramTextCommand::redo() {
|
|||||||
text_item -> previous_text = text_after;
|
text_item -> previous_text = text_after;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Constructeur
|
||||||
|
@param elements Elements a pivoter associes a leur orientation d'origine
|
||||||
|
@param parent QUndoCommand parent
|
||||||
|
*/
|
||||||
|
RotateElementsCommand::RotateElementsCommand(const QHash<Element *, QET::Orientation> &elements, QUndoCommand *parent) :
|
||||||
|
QUndoCommand(QObject::tr("pivoter ") + QET::ElementsAndConducersSentence(elements.count(), 0), parent),
|
||||||
|
elements_to_rotate(elements)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Destructeur
|
||||||
|
RotateElementsCommand::~RotateElementsCommand() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// defait le pivotement
|
||||||
|
void RotateElementsCommand::undo() {
|
||||||
|
foreach(Element *e, elements_to_rotate.keys()) {
|
||||||
|
e -> setOrientation(elements_to_rotate[e]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// refait le pivotement
|
||||||
|
void RotateElementsCommand::redo() {
|
||||||
|
foreach(Element *e, elements_to_rotate.keys()) {
|
||||||
|
e -> setOrientation(e -> orientation().next());
|
||||||
|
e -> update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#ifndef DIAGRAM_COMMANDS_H
|
#ifndef DIAGRAM_COMMANDS_H
|
||||||
#define DIAGRAM_COMMANDS_H
|
#define DIAGRAM_COMMANDS_H
|
||||||
|
#include "qet.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "diagramtextitem.h"
|
#include "diagramtextitem.h"
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
@@ -183,4 +184,26 @@ class ChangeDiagramTextCommand : public QUndoCommand {
|
|||||||
bool first_redo;
|
bool first_redo;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Cette classe represente l'action de pivoter plusieurs elements
|
||||||
|
*/
|
||||||
|
class RotateElementsCommand : public QUndoCommand {
|
||||||
|
// constructeurs, destructeur
|
||||||
|
public:
|
||||||
|
RotateElementsCommand(const QHash<Element *, QET::Orientation> &elements, QUndoCommand * = 0);
|
||||||
|
virtual ~RotateElementsCommand();
|
||||||
|
private:
|
||||||
|
RotateElementsCommand(const RotateElementsCommand &);
|
||||||
|
|
||||||
|
// methodes
|
||||||
|
public:
|
||||||
|
virtual void undo();
|
||||||
|
virtual void redo();
|
||||||
|
|
||||||
|
// attributs
|
||||||
|
private:
|
||||||
|
/// texte avant changement
|
||||||
|
QHash<Element *, QET::Orientation> elements_to_rotate;
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -104,12 +104,13 @@ void DiagramView::supprimer() {
|
|||||||
*/
|
*/
|
||||||
void DiagramView::pivoter() {
|
void DiagramView::pivoter() {
|
||||||
if (scene -> selectedItems().isEmpty()) return;
|
if (scene -> selectedItems().isEmpty()) return;
|
||||||
|
QHash<Element *, QET::Orientation> elements_to_rotate;
|
||||||
foreach (QGraphicsItem *item, scene -> selectedItems()) {
|
foreach (QGraphicsItem *item, scene -> selectedItems()) {
|
||||||
if (Element *elt = qgraphicsitem_cast<Element *>(item)) {
|
if (Element *e = qgraphicsitem_cast<Element *>(item)) {
|
||||||
elt -> setOrientation(elt -> orientation().next());
|
elements_to_rotate.insert(e, e -> orientation().current());
|
||||||
elt -> update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scene -> undoStack().push(new RotateElementsCommand(elements_to_rotate));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user