mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Compare commits
2 Commits
0f179a5d49
...
707005879b
Author | SHA1 | Date | |
---|---|---|---|
|
707005879b | ||
|
29c362fe4c |
@ -126,30 +126,28 @@ void ElementsMover::continueMovement(const QPointF &movement)
|
|||||||
| dc::Images
|
| dc::Images
|
||||||
| dc::Shapes
|
| dc::Shapes
|
||||||
| dc::ElementTextFields
|
| dc::ElementTextFields
|
||||||
| dc::TextGroup
|
| dc::TextGroup))
|
||||||
| dc::ConductorsToMove))
|
|
||||||
{
|
{
|
||||||
if (qgi == m_movement_driver)
|
if (qgi == m_movement_driver)
|
||||||
continue;
|
continue;
|
||||||
qgi->setPos(qgi->pos() + movement);
|
qgi->setPos(qgi->pos() + movement);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move some conductors
|
QVector<Conductor *>list_conductors;
|
||||||
|
for(auto *con : m_moved_content.m_conductors_to_move){
|
||||||
|
list_conductors << con;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update conductors 'conductors_to_move'
|
||||||
|
for(auto *cond : list_conductors){
|
||||||
|
cond->updatePath();
|
||||||
|
if(cond->textItem()->wasMovedByUser() == true)
|
||||||
|
cond->textItem()->setPos(cond->textItem()->pos()+movement);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update conductors 'conductors_to_update'
|
||||||
for (auto &conductor : m_moved_content.m_conductors_to_update)
|
for (auto &conductor : m_moved_content.m_conductors_to_update)
|
||||||
{
|
{
|
||||||
#if TODO_LIST
|
|
||||||
#pragma message("@TODO fix this problem correctly, probably we must see conductor class.")
|
|
||||||
#endif
|
|
||||||
//Due to a weird behavior, we must ensure that the position of the conductor is (0,0).
|
|
||||||
//If not, in some unknown case the function QGraphicsScene::itemsBoundingRect() return a rectangle
|
|
||||||
//that take into account the pos() of the conductor, even if the bounding rect returned by the conductor is not in the pos().
|
|
||||||
//For the user this situation appears when the top right of the folio is not at the top right of the graphicsview,
|
|
||||||
//but displaced to the right and/or bottom.
|
|
||||||
|
|
||||||
//@TODO fix this problem correctly, probably we must see conductor class.
|
|
||||||
// if (c->pos() != QPointF(0,0)) { //<- they work, but the conductor text return to its original pos when the pos is set by user and not auto
|
|
||||||
// c->setPos(0,0); // because set the pos to 0,0 so text move to, and after call updatePath but because text pos is user defined
|
|
||||||
// } // we don't move it.
|
|
||||||
conductor->updatePath();
|
conductor->updatePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "../qetgraphicsitem/conductor.h"
|
#include "../qetgraphicsitem/conductor.h"
|
||||||
#include "../qetgraphicsitem/elementtextitemgroup.h"
|
#include "../qetgraphicsitem/elementtextitemgroup.h"
|
||||||
|
#include "../qetgraphicsitem/conductortextitem.h"
|
||||||
|
|
||||||
#include "../diagram.h"
|
#include "../diagram.h"
|
||||||
|
|
||||||
@ -65,6 +66,7 @@ void MoveGraphicsItemCommand::undo()
|
|||||||
m_diagram->showMe();
|
m_diagram->showMe();
|
||||||
m_anim_group.setDirection(QAnimationGroup::Forward);
|
m_anim_group.setDirection(QAnimationGroup::Forward);
|
||||||
m_anim_group.start();
|
m_anim_group.start();
|
||||||
|
updateConductors(false);
|
||||||
}
|
}
|
||||||
QUndoCommand::undo();
|
QUndoCommand::undo();
|
||||||
}
|
}
|
||||||
@ -87,6 +89,7 @@ void MoveGraphicsItemCommand::redo()
|
|||||||
{
|
{
|
||||||
m_anim_group.setDirection(QAnimationGroup::Backward);
|
m_anim_group.setDirection(QAnimationGroup::Backward);
|
||||||
m_anim_group.start();
|
m_anim_group.start();
|
||||||
|
updateConductors(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QUndoCommand::redo();
|
QUndoCommand::redo();
|
||||||
@ -137,19 +140,6 @@ void MoveGraphicsItemCommand::move(const QPointF &movement)
|
|||||||
qgi->setPos(qgi->pos() + movement);
|
qgi->setPos(qgi->pos() + movement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Move some conductors
|
|
||||||
for (const auto &conductor : qAsConst(m_content.m_conductors_to_move)) {
|
|
||||||
setupAnimation(conductor,
|
|
||||||
"pos",
|
|
||||||
conductor->pos(),
|
|
||||||
conductor->pos() + movement);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Recalculate the path of other conductors
|
|
||||||
for (const auto &conductor : qAsConst(m_content.m_conductors_to_update)) {
|
|
||||||
setupAnimation(conductor, "animPath", 1, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -167,9 +157,34 @@ void MoveGraphicsItemCommand::setupAnimation(QObject *target,
|
|||||||
const QVariant &end)
|
const QVariant &end)
|
||||||
{
|
{
|
||||||
QPropertyAnimation *animation{new QPropertyAnimation(target, property_name)};
|
QPropertyAnimation *animation{new QPropertyAnimation(target, property_name)};
|
||||||
animation->setDuration(300);
|
// duration must be set to 0, otherwise the conductors will not be updated
|
||||||
|
animation->setDuration(0);
|
||||||
animation->setStartValue(start);
|
animation->setStartValue(start);
|
||||||
animation->setEndValue(end);
|
animation->setEndValue(end);
|
||||||
animation->setEasingCurve(QEasingCurve::OutQuad);
|
animation->setEasingCurve(QEasingCurve::OutQuad);
|
||||||
m_anim_group.addAnimation(animation);
|
m_anim_group.addAnimation(animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MoveGraphicsItemCommand::connectConductors
|
||||||
|
* @param is_redo
|
||||||
|
*/
|
||||||
|
void MoveGraphicsItemCommand::updateConductors(bool is_redo)
|
||||||
|
{
|
||||||
|
//Recalculate the path of 'conductors_to_move'
|
||||||
|
for (const auto &conductor : qAsConst(m_content.m_conductors_to_move)) {
|
||||||
|
conductor->updatePath();
|
||||||
|
if(conductor->textItem()->wasMovedByUser() == true){
|
||||||
|
if(is_redo)
|
||||||
|
conductor->textItem()->setPos(conductor->textItem()->pos() + m_movement);
|
||||||
|
else
|
||||||
|
conductor->textItem()->setPos(conductor->textItem()->pos() - m_movement);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recalculate the path of 'conductors_to_update'
|
||||||
|
for (const auto &conductor : qAsConst(m_content.m_conductors_to_update)) {
|
||||||
|
conductor->updatePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -49,6 +49,7 @@ class MoveGraphicsItemCommand : public QUndoCommand
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void move(const QPointF &movement);
|
void move(const QPointF &movement);
|
||||||
|
void updateConductors(bool is_redo = false);
|
||||||
void setupAnimation(QObject *target,
|
void setupAnimation(QObject *target,
|
||||||
const QByteArray &property_name,
|
const QByteArray &property_name,
|
||||||
const QVariant &start,
|
const QVariant &start,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user