mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
element editor: improve the autosize of element
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2406 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -439,24 +439,27 @@ void ElementScene::setGrid(int x_g, int y_g) {
|
||||
@return un document XML decrivant l'element
|
||||
*/
|
||||
const QDomDocument ElementScene::toXml(bool all_parts) const {
|
||||
// document XML
|
||||
QDomDocument xml_document;
|
||||
|
||||
//define the size of the element by the upper multiple of 10
|
||||
QRectF size= elementSceneGeometricRect();
|
||||
int upwidth = (qRound(size.width())/10)*10;
|
||||
if ((qRound(size.width())%10) >= 5) upwidth+=10;
|
||||
int upwidth = ((qRound(size.width())/10)*10)+10;
|
||||
if ((qRound(size.width())%10) > 6) upwidth+=10;
|
||||
|
||||
int upheight = (qRound(size.height())/10)*10;
|
||||
if ((qRound(size.height())%10) >= 5) upheight+=10;
|
||||
int upheight = ((qRound(size.height())/10)*10)+10;
|
||||
if ((qRound(size.height())%10) > 6) upheight+=10;
|
||||
|
||||
//the margin between the real size of the element and the rectangle that delimits
|
||||
int xmargin = qRound(upwidth - size.width());
|
||||
int ymargin = qRound(upheight - size.height());
|
||||
|
||||
// document XML
|
||||
QDomDocument xml_document;
|
||||
// racine du document XML
|
||||
QDomElement root = xml_document.createElement("definition");
|
||||
root.setAttribute("type", "element");
|
||||
root.setAttribute("width", QString("%1").arg(upwidth+10));
|
||||
root.setAttribute("height", QString("%1").arg(upheight+10));
|
||||
root.setAttribute("hotspot_x", QString("%1").arg(-(qRound(size.x())-5)));
|
||||
root.setAttribute("hotspot_y", QString("%1").arg(-(qRound(size.y())-5)));
|
||||
root.setAttribute("width", QString("%1").arg(upwidth));
|
||||
root.setAttribute("height", QString("%1").arg(upheight));
|
||||
root.setAttribute("hotspot_x", QString("%1").arg(-(qRound(size.x() - (xmargin/2)))));
|
||||
root.setAttribute("hotspot_y", QString("%1").arg(-(qRound(size.y() - (ymargin/2)))));
|
||||
root.setAttribute("orientation", ori.toString());
|
||||
root.setAttribute("version", QET::version);
|
||||
if (internal_connections) root.setAttribute("ic", "true");
|
||||
|
||||
Reference in New Issue
Block a user