mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +01:00
Minor : add QGIUtility namespace
This commit is contained in:
@@ -253,13 +253,13 @@ void CrossRefItem::autoPos()
|
|||||||
{
|
{
|
||||||
//We calcul the position according to the snapTo of the xrefproperties
|
//We calcul the position according to the snapTo of the xrefproperties
|
||||||
if (m_properties.snapTo() == XRefProperties::Bottom)
|
if (m_properties.snapTo() == XRefProperties::Bottom)
|
||||||
centerToBottomDiagram(this,
|
QGIUtility::centerToBottomDiagram(this,
|
||||||
m_element,
|
m_element,
|
||||||
m_properties.offset() <= 40
|
m_properties.offset() <= 40
|
||||||
? 5
|
? 5
|
||||||
: m_properties.offset());
|
: m_properties.offset());
|
||||||
else
|
else
|
||||||
centerToParentBottom(this);
|
QGIUtility::centerToParentBottom(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -861,7 +861,7 @@ void ElementTextItemGroup::autoPos()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
qreal r = rotation();
|
qreal r = rotation();
|
||||||
centerToBottomDiagram(this, m_parent_element, offset);
|
QGIUtility::centerToBottomDiagram(this, m_parent_element, offset);
|
||||||
//centerToBottomDiagram change the rotation of this group if needed,
|
//centerToBottomDiagram change the rotation of this group if needed,
|
||||||
//but setRotation is not a virtual function of QGraphicsItem, and the function centerToBottomDiagram
|
//but setRotation is not a virtual function of QGraphicsItem, and the function centerToBottomDiagram
|
||||||
//work with a QGraphicsItem. So we emit the signal if rotation changed
|
//work with a QGraphicsItem. So we emit the signal if rotation changed
|
||||||
|
|||||||
@@ -23,6 +23,9 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
|
|
||||||
|
namespace QGIUtility
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief centerToParentBottom
|
@brief centerToParentBottom
|
||||||
Center the item at the bottom of is parent.
|
Center the item at the bottom of is parent.
|
||||||
@@ -51,10 +54,10 @@ bool centerToParentBottom(QGraphicsItem *item) {
|
|||||||
@param offset
|
@param offset
|
||||||
@return true if element is centered else false (element_to_follow have not diagram)
|
@return true if element is centered else false (element_to_follow have not diagram)
|
||||||
*/
|
*/
|
||||||
#include "elementtextitemgroup.h"
|
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, qreal offset)
|
||||||
#include "crossrefitem.h"
|
{
|
||||||
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, qreal offset) {
|
if (! element_to_follow -> diagram())
|
||||||
if (! element_to_follow -> diagram()) {
|
{
|
||||||
qDebug() << "qgraphicsitemutility centerAtBottomDiagram : Element_to_follow have not diagram";
|
qDebug() << "qgraphicsitemutility centerAtBottomDiagram : Element_to_follow have not diagram";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -81,8 +84,11 @@ bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_f
|
|||||||
rot += parent->rotation();
|
rot += parent->rotation();
|
||||||
parent = parent->parentItem();
|
parent = parent->parentItem();
|
||||||
}
|
}
|
||||||
if(rot != 0)
|
if(rot != 0) {
|
||||||
item_to_center->setRotation(item_to_center->rotation() - rot);
|
item_to_center->setRotation(item_to_center->rotation() - rot);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,16 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef QGRAPHICSITEMUTILITY_H
|
#ifndef QGRAPHICSITEMUTILITY_H
|
||||||
#define QGRAPHICSITEMUTILITY_H
|
#define QGRAPHICSITEMUTILITY_H
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
class QGraphicsItem;
|
class QGraphicsItem;
|
||||||
class Element;
|
class Element;
|
||||||
|
|
||||||
bool centerToParentBottom (QGraphicsItem *item);
|
namespace QGIUtility
|
||||||
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, qreal offset = 0 );
|
{
|
||||||
|
bool centerToParentBottom (QGraphicsItem *item);
|
||||||
|
bool centerToBottomDiagram (QGraphicsItem *item_to_center, Element *element_to_follow, qreal offset = 0 );
|
||||||
|
}
|
||||||
|
|
||||||
#endif // QGRAPHICSITEMUTILITY_H
|
#endif // QGRAPHICSITEMUTILITY_H
|
||||||
|
|||||||
Reference in New Issue
Block a user