/************************************************************************ ** ** @file movelabel.cpp ** @author Roman Telezhynskyi ** @date 25 12, 2014 ** ** @brief ** @copyright ** This source code is part of the Valentine project, a pattern making ** program, whose allow create and modeling patterns of clothing. ** Copyright (C) 2013-2015 Valentina project ** All Rights Reserved. ** ** Valentina is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** Valentina is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with Valentina. If not, see . ** *************************************************************************/ #include "movelabel.h" #include #include #include "../xml/vpattern.h" #include "../tools/vabstracttool.h" #include "../core/vapplication.h" //--------------------------------------------------------------------------------------------------------------------- MoveLabel::MoveLabel(VPattern *doc, const double &x, const double &y, const quint32 &id, QGraphicsScene *scene, QUndoCommand *parent) : VUndoCommand(QDomElement(), doc, parent), oldMx(0.0), oldMy(0.0), newMx(x), newMy(y), scene(scene) { setText(tr("Move point label")); nodeId = id; qCDebug(vUndo)<<"Point id"<elementById(id); if (domElement.isElement()) { oldMx = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMx, "0.0")); oldMy = qApp->toPixel(doc->GetParametrDouble(domElement, VAbstractTool::AttrMy, "0.0")); qCDebug(vUndo)<<"Label old Mx"<(command); SCASSERT(moveCommand != nullptr); const quint32 id = moveCommand->getPointId(); if (id != nodeId) { return false; } qCDebug(vUndo)<<"Mergin undo."; newMx = moveCommand->getNewMx(); newMy = moveCommand->getNewMy(); qCDebug(vUndo)<<"Label new Mx"<(UndoCommand::MoveLabel); } //--------------------------------------------------------------------------------------------------------------------- void MoveLabel::Do(double mx, double my) { qCDebug(vUndo)<<"New mx"<elementById(nodeId); if (domElement.isElement()) { doc->SetAttribute(domElement, VAbstractTool::AttrMx, QString().setNum(qApp->fromPixel(mx))); doc->SetAttribute(domElement, VAbstractTool::AttrMy, QString().setNum(qApp->fromPixel(my))); emit NeedLiteParsing(Document::LitePPParse); QList list = scene->views(); VAbstractTool::NewSceneRect(scene, list[0]); } else { qCDebug(vUndo)<<"Can't find point with id ="<