mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-04 19:40:53 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user