mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-22 09:40:52 +01:00
QetShapeItem: improve code.
Other improvement related to the refactoring of QetShapeItem git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3134 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -418,9 +418,7 @@ QDomDocument Diagram::toXml(bool whole_content) {
|
||||
if (!list_shapes.isEmpty()) {
|
||||
QDomElement shapes = document.createElement("shapes");
|
||||
foreach (QetShapeItem *dii, list_shapes) {
|
||||
dii ->setWritingXml(true);
|
||||
shapes.appendChild(dii -> toXml(document));
|
||||
dii ->setWritingXml(false);
|
||||
}
|
||||
racine.appendChild(shapes);
|
||||
}
|
||||
@@ -1106,6 +1104,20 @@ DiagramPosition Diagram::convertPosition(const QPointF &pos) {
|
||||
return(diagram_position);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Diagram::snapToGrid
|
||||
* Return a nearest snap point of p
|
||||
* @param p point to find the nearest snaped point
|
||||
* @return
|
||||
*/
|
||||
QPointF Diagram::snapToGrid(const QPointF &p) {
|
||||
// arrondit l'abscisse a 10 px pres
|
||||
int p_x = qRound(p.x() / (Diagram::xGrid * 1.0)) * Diagram::xGrid;
|
||||
// arrondit l'ordonnee a 10 px pres
|
||||
int p_y = qRound(p.y() / (Diagram::yGrid * 1.0)) * Diagram::yGrid;
|
||||
return (QPointF(p_x, p_y));
|
||||
}
|
||||
|
||||
/**
|
||||
Definit s'il faut afficher ou non les bornes
|
||||
@param dt true pour afficher les bornes, false sinon
|
||||
|
||||
Reference in New Issue
Block a user