mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
start work to define if conductor text item was moved by user or not
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2229 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -1113,6 +1113,7 @@ ConductorSegment *Conductor::middleSegment() {
|
||||
void Conductor::calculateTextItemPosition() {
|
||||
if (!text_item) return;
|
||||
|
||||
//position
|
||||
if (text_item -> wasMovedByUser()) {
|
||||
// le champ de texte a ete deplace par l'utilisateur :
|
||||
// on verifie qu'il est encore a proximite du conducteur
|
||||
@@ -1124,10 +1125,13 @@ void Conductor::calculateTextItemPosition() {
|
||||
} else {
|
||||
// positionnement automatique basique
|
||||
text_item -> setPos(middleSegment() -> middle());
|
||||
//rotation
|
||||
if (!text_item -> wasRotateByUser()) {
|
||||
middleSegment() -> isVertical()? text_item -> setRotationAngle(properties_.verti_rotate_text):
|
||||
text_item -> setRotationAngle(properties_.horiz_rotate_text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Sauvegarde le profil courant du conducteur pour l'utiliser ulterieurement
|
||||
|
||||
@@ -28,6 +28,7 @@ ConductorTextItem::ConductorTextItem(Conductor *parent_conductor, Diagram *paren
|
||||
DiagramTextItem(parent_conductor, parent_diagram),
|
||||
parent_conductor_(parent_conductor),
|
||||
moved_by_user_(false),
|
||||
rotate_by_user_(false),
|
||||
first_move_(true)
|
||||
{
|
||||
// par defaut, les DiagramTextItem sont Selectable et Movable
|
||||
@@ -44,6 +45,7 @@ ConductorTextItem::ConductorTextItem(const QString &text, Conductor *parent_cond
|
||||
DiagramTextItem(text, parent_conductor, parent_diagram),
|
||||
parent_conductor_(parent_conductor),
|
||||
moved_by_user_(false),
|
||||
rotate_by_user_(false),
|
||||
first_move_(true)
|
||||
{
|
||||
// par defaut, les DiagramTextItem sont Selectable et Movable
|
||||
@@ -107,6 +109,14 @@ bool ConductorTextItem::wasMovedByUser() const {
|
||||
return(moved_by_user_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ConductorTextItem::wasRotateByUser
|
||||
* @return true if text was explicit moved by user else false
|
||||
*/
|
||||
bool ConductorTextItem::wasRotateByUser() const {
|
||||
return(rotate_by_user_);
|
||||
}
|
||||
|
||||
/**
|
||||
@param moved_by_user true pour que la position du texte soit consideree
|
||||
comme ayant ete definie par l'utilisateur (et donc soit sauvegardee), false
|
||||
@@ -122,6 +132,21 @@ void ConductorTextItem::forceMovedByUser(bool moved_by_user) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ConductorTextItem::forceRotateByUser
|
||||
* @param rotate_by_user true pour que la rotation du texte soit consideree
|
||||
comme ayant ete definie par l'utilisateur (et donc soit sauvegardee), false
|
||||
pour remettre le texte a sont angle originelle
|
||||
*/
|
||||
void ConductorTextItem::forceRotateByUser(bool rotate_by_user) {
|
||||
if (rotate_by_user == rotate_by_user_) return;
|
||||
|
||||
rotate_by_user_ = rotate_by_user;
|
||||
if (!rotate_by_user && parent_conductor_) {
|
||||
parent_conductor_ -> adjustTextItemPosition();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Gere les clics de souris lies au champ de texte
|
||||
@param e Objet decrivant l'evenement souris
|
||||
|
||||
@@ -48,7 +48,9 @@ class ConductorTextItem : public DiagramTextItem {
|
||||
public:
|
||||
virtual int type() const { return Type; }
|
||||
virtual bool wasMovedByUser() const;
|
||||
virtual bool wasRotateByUser() const;
|
||||
virtual void forceMovedByUser(bool);
|
||||
virtual void forceRotateByUser(bool);
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
|
||||
@@ -59,6 +61,7 @@ class ConductorTextItem : public DiagramTextItem {
|
||||
private:
|
||||
Conductor *parent_conductor_;
|
||||
bool moved_by_user_;
|
||||
bool rotate_by_user_;
|
||||
QPointF before_mov_pos_;
|
||||
bool first_move_;
|
||||
QPointF mouse_to_origin_movement_;
|
||||
|
||||
@@ -601,9 +601,20 @@ void RotateElementsCommand::undo() {
|
||||
rotateElement(e, elements_to_rotate[e]);
|
||||
}
|
||||
foreach(DiagramTextItem *dti, texts_to_rotate) {
|
||||
//ConductorTextItem have got a default rotation propertie
|
||||
//so we apply specific undo method for him
|
||||
if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(dti)) {
|
||||
cti -> forceRotateByUser(previous_rotate_by_user_);
|
||||
//previous_rotate_by_user is false mean the rotation is propertie rotation
|
||||
if (previous_rotate_by_user_ == false) {cti -> parentConductor() ->adjustTextItemPosition();}
|
||||
else {cti -> rotateBy(-applied_rotation_angle_);}
|
||||
}
|
||||
//this isn't a ConductorTextItem
|
||||
else {
|
||||
dti -> rotateBy(-applied_rotation_angle_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// refait le pivotement
|
||||
void RotateElementsCommand::redo() {
|
||||
@@ -611,6 +622,10 @@ void RotateElementsCommand::redo() {
|
||||
rotateElement(e, e -> orientation().next());
|
||||
}
|
||||
foreach(DiagramTextItem *dti, texts_to_rotate) {
|
||||
if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(dti)) {
|
||||
previous_rotate_by_user_ = cti -> wasRotateByUser();
|
||||
cti -> forceRotateByUser(true);
|
||||
}
|
||||
dti -> rotateBy(applied_rotation_angle_);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user