Diagram editor : add 4 tools for edit the depth (Z value) of items.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5394 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2018-06-17 18:21:56 +00:00
parent 74ac93e171
commit 52eb4b5f71
11 changed files with 209 additions and 79 deletions

View File

@@ -38,6 +38,7 @@
#include "dynamicelementtextitem.h"
#include "elementtextitemgroup.h"
#include "undocommand/addelementtextcommand.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h"
const int Diagram::xGrid = 10;
const int Diagram::yGrid = 10;
@@ -1268,6 +1269,62 @@ void Diagram::loadFolioSeqHash(QHash<QString, QStringList> *hash, QString title,
}
}
/**
* @brief Diagram::changeZValue
* Change the Z value of the current selected item, according to @option
*/
void Diagram::changeZValue(QET::DepthOption option)
{
DiagramContent dc(this);
QUndoCommand *undo = new QUndoCommand(tr("Modifier la profondeur"));
QList<QGraphicsItem *> l = dc.items(DiagramContent::SelectedOnly | \
DiagramContent::Elements | \
DiagramContent::Shapes | \
DiagramContent::Images);
QList<QGraphicsObject *> list;
for(QGraphicsItem *item : l)
list << item->toGraphicsObject();
qreal maxz=0,
minz=0;
for(QGraphicsItem *item : this->items())
{
qreal z = item->zValue();
if(z >= Terminal::Z-2)
continue;
maxz = std::max(maxz,z);
minz = std::min(minz,z);
}
if(option == QET::Raise)
{
for(QGraphicsObject *qgo : list)
if(qgo->zValue() < (Terminal::Z-2)) //Ensure item is always below terminal
new QPropertyUndoCommand(qgo, "z", qgo->zValue(), qgo->zValue()+1, undo);
}
else if(option == QET::Lower)
{
for(QGraphicsObject *qgo : list)
if(qgo->zValue() < (Terminal::Z-2)) //Ensure item is always below terminal
new QPropertyUndoCommand(qgo, "z", qgo->zValue(), qgo->zValue()-1, undo);
}
else if (option == QET::BringForward)
{
for(QGraphicsObject *qgo : list)
new QPropertyUndoCommand(qgo, "z", qgo->zValue(), maxz+1, undo);
}
else if(option == QET::SendBackward)
{
for(QGraphicsObject *qgo : list)
new QPropertyUndoCommand(qgo, "z", qgo->zValue(), minz-1, undo);
}
if(undo->childCount())
this->undoStack().push(undo);
else
delete undo;
}
/**
* @brief Diagram::loadElmtFolioSeq
* This class loads all folio sequential variables related