Merged in ValentinaZhuravska/valentina/feature (pull request #132)

Resolved issue #461. Improve feature: Add a keyboard shortcut for getting pure 45, 90, 135, 180, 225, 270, 315 and 0 degree angles for all tools.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2016-07-26 16:19:57 +03:00
commit 75c57628ce
21 changed files with 191 additions and 44 deletions

View File

@ -680,6 +680,7 @@ void MainWindow::ClosedDialogWithApply(int result)
{
VDrawTool *vtool= static_cast<VDrawTool *>(dialogTool->GetAssociatedTool());
vtool->DialogLinkDestroy();
connect(vtool, &VDrawTool::ToolTip, this, &MainWindow::ShowToolTip);
}
ArrowTool();
// If insert not to the end of file call lite parse

View File

@ -57,7 +57,7 @@
//---------------------------------------------------------------------------------------------------------------------
MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
: QMainWindow(parent), listDetails(QVector<VLayoutDetail>()), currentScene(nullptr), tempSceneLayout(nullptr),
: VAbstractMainWindow(parent), listDetails(QVector<VLayoutDetail>()), currentScene(nullptr), tempSceneLayout(nullptr),
pattern(new VContainer(qApp->TrVars(), qApp->patternUnitP())), doc(nullptr), papers(QList<QGraphicsItem *>()),
shadows(QList<QGraphicsItem *>()), scenes(QList<QGraphicsScene *>()), details(QList<QList<QGraphicsItem *> >()),
undoAction(nullptr), redoAction(nullptr), actionDockWidgetToolOptions(nullptr), actionDockWidgetGroups(nullptr),

View File

@ -37,13 +37,14 @@
#include "xml/vpattern.h"
#include "dialogs/dialogsavelayout.h"
#include "../vlayout/vlayoutgenerator.h"
#include "../vwidgets/vabstractmainwindow.h"
class QGraphicsScene;
class QPrinter;
class PosterData;
class MainWindowsNoGUI : public QMainWindow
class MainWindowsNoGUI : public VAbstractMainWindow
{
Q_OBJECT
public:

View File

@ -27,6 +27,7 @@
*************************************************************************/
#include "vpattern.h"
#include "../vwidgets/vabstractmainwindow.h"
#include "../vtools/tools/vdatatool.h"
#include "../vtools/tools/vtooldetail.h"
#include "../vtools/tools/vtooluniondetails.h"
@ -1914,8 +1915,16 @@ void VPattern::ParseToolSpline(VMainGraphicsScene *scene, QDomElement &domElemen
const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
const quint32 duplicate = GetParametrUInt(domElement, AttrDuplicate, "0");
VToolSpline::Create(id, point1, point4, a1, a2, l1, l2, duplicate, color, scene, this, data, parse,
Source::FromFile);
VToolSpline *spl = VToolSpline::Create(id, point1, point4, a1, a2, l1, l2, duplicate, color, scene, this,
data, parse, Source::FromFile);
if (spl != nullptr)
{
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
SCASSERT(window != nullptr);
connect(spl, &VToolSpline::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
}
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (a1 != angle1 || a2 != angle2 || l1 != length1 || l2 != length2)
{
@ -2095,7 +2104,16 @@ void VPattern::ParseToolSplinePath(VMainGraphicsScene *scene, const QDomElement
l1 = length1;
l2 = length2;
VToolSplinePath::Create(id, points, a1, a2, l1, l2, color, scene, this, data, parse, Source::FromFile);
VToolSplinePath *spl = VToolSplinePath::Create(id, points, a1, a2, l1, l2, color, scene, this, data, parse,
Source::FromFile);
if (spl != nullptr)
{
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
SCASSERT(window != nullptr);
connect(spl, &VToolSplinePath::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
}
//Rewrite attribute formula. Need for situation when we have wrong formula.
int count = 0;
for (qint32 i = 0; i < num; ++i)

View File

@ -29,6 +29,7 @@
#include "dialogcubicbezierpath.h"
#include "ui_dialogcubicbezierpath.h"
#include "../../visualization/path/vistoolcubicbezierpath.h"
#include "../vwidgets/vabstractmainwindow.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
# include "../vmisc/vmath.h"
@ -128,7 +129,9 @@ void DialogCubicBezierPath::ChosenObject(quint32 id, const SceneObject &type)
if (path.CountPoints() == 1)
{
visPath->VisualMode(NULL_ID);
connect(visPath, &VisToolCubicBezierPath::ToolTip, [this](const QString &toolTip){emit ToolTip(toolTip);});
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
SCASSERT(window != nullptr);
connect(visPath, &VisToolCubicBezierPath::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
}
else
{

View File

@ -36,6 +36,7 @@
#include "../../../vwidgets/vmaingraphicsscene.h"
#include "../../tools/vabstracttool.h"
#include "../support/dialogeditwrongformula.h"
#include "../vwidgets/vabstractmainwindow.h"
#include <QTimer>
@ -217,8 +218,10 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
{
number++;
line->VisualMode(id);
connect(line, &VisToolCurveIntersectAxis::ToolTip,
[this](const QString &toolTip){emit ToolTip(toolTip);});
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
SCASSERT(window != nullptr);
connect(line, &VisToolCurveIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
}
}
break;

View File

@ -36,6 +36,7 @@
#include "../../../vwidgets/vmaingraphicsscene.h"
#include "../../tools/vabstracttool.h"
#include "../support/dialogeditwrongformula.h"
#include "../vwidgets/vabstractmainwindow.h"
#include <QTimer>
//---------------------------------------------------------------------------------------------------------------------
@ -167,7 +168,9 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type)
if (SetObject(id, ui->comboBoxBasePoint, ""))
{
vis->VisualMode(id);
connect(vis.data(), &Visualization::ToolTip, [this](const QString &toolTip){emit ToolTip(toolTip);});
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
SCASSERT(window != nullptr);
connect(vis, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
prepare = true;
}
}

View File

@ -36,6 +36,7 @@
#include "../../../vwidgets/vmaingraphicsscene.h"
#include "../../tools/vabstracttool.h"
#include "../support/dialogeditwrongformula.h"
#include "../vwidgets/vabstractmainwindow.h"
#include <QTimer>
@ -242,8 +243,9 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
{
number++;
line->VisualMode(id);
connect(line, &VisToolLineIntersectAxis::ToolTip,
[this](const QString &toolTip){emit ToolTip(toolTip);});
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
SCASSERT(window != nullptr);
connect(line, &VisToolLineIntersectAxis::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
}
break;
case (1):

View File

@ -38,6 +38,7 @@
#include "../../visualization/line/vistoolrotation.h"
#include "../support/dialogeditwrongformula.h"
#include "../qmuparser/qmudef.h"
#include "../vwidgets/vabstractmainwindow.h"
//---------------------------------------------------------------------------------------------------------------------
DialogRotation::DialogRotation(const VContainer *data, const quint32 &toolId, QWidget *parent)
@ -215,8 +216,9 @@ void DialogRotation::ChosenObject(quint32 id, const SceneObject &type)
{
VisToolRotation *operation = qobject_cast<VisToolRotation *>(vis);
SCASSERT(operation != nullptr);
connect(operation, &Visualization::ToolTip, [this](const QString &toolTip){emit ToolTip(toolTip);});
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
SCASSERT(window != nullptr);
connect(operation, &Visualization::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
operation->SetOriginPointId(id);
operation->RefreshGeometry();

View File

@ -33,6 +33,7 @@
#include "../../visualization/path/vistoolsplinepath.h"
#include "../support/dialogeditwrongformula.h"
#include "../qmuparser/qmuparsererror.h"
#include "../vwidgets/vabstractmainwindow.h"
#include <QTimer>
@ -181,7 +182,10 @@ void DialogSplinePath::ChosenObject(quint32 id, const SceneObject &type)
if (path.CountPoints() == 1)
{
visPath->VisualMode(NULL_ID);
connect(visPath, &VisToolSplinePath::ToolTip, [this](const QString &toolTip){emit ToolTip(toolTip);});
VAbstractMainWindow *window = qobject_cast<VAbstractMainWindow *>(qApp->getMainWindow());
SCASSERT(window != nullptr);
connect(visPath, &VisToolSplinePath::ToolTip, window, &VAbstractMainWindow::ShowToolTip);
connect(visPath, &VisToolSplinePath::PathChanged, this, &DialogSplinePath::PathUpdated);
}
else

View File

@ -261,6 +261,10 @@ VSpline VAbstractSpline::CorrectedSpline(const VSpline &spline, const SplinePoin
if (position == SplinePointPosition::FirstPoint)
{
QLineF line(spline.GetP1(), pos);
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
{
line.setAngle(VisLine::CorrectAngle(line.angle()));
}
qreal newAngle1 = line.angle();
QString newAngle1F = QString().setNum(newAngle1);
@ -287,6 +291,10 @@ VSpline VAbstractSpline::CorrectedSpline(const VSpline &spline, const SplinePoin
else
{
QLineF line(spline.GetP4(), pos);
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
{
line.setAngle(VisLine::CorrectAngle(line.angle()));
}
qreal newAngle2 = line.angle();
QString newAngle2F = QString().setNum(newAngle2);

View File

@ -30,6 +30,7 @@
#define VABSTRACTSPLINE_H
#include "../vdrawtool.h"
#include "visualization/line/visline.h"
#include <QGraphicsPathItem>

View File

@ -95,6 +95,8 @@ signals:
* @brief FullUpdateTree emit if need reparse pattern file.
*/
void LiteUpdateTree(const Document &parse);
void ToolTip(const QString &toolTip);
protected:
/** @brief doc dom document container */
VAbstractPattern *doc;
@ -166,6 +168,7 @@ inline void VAbstractTool::AddVisualization()
scene->addItem(visual);
vis = visual;
connect(vis, &Visualization::ToolTip, [=] (const QString &toolTip) {emit ToolTip(toolTip);});
}
#endif // VABSTRACTTOOL_H

View File

@ -43,7 +43,7 @@ VisLine::~VisLine()
{}
//---------------------------------------------------------------------------------------------------------------------
qreal VisLine::CorrectAngle(const qreal &angle) const
qreal VisLine::CorrectAngle(const qreal &angle)
{
qreal ang = angle;
if (angle > 360)

View File

@ -44,8 +44,8 @@ public:
virtual int type() const Q_DECL_OVERRIDE {return Type;}
enum { Type = UserType + static_cast<int>(Vis::Line)};
static qreal CorrectAngle(const qreal &angle);
protected:
qreal CorrectAngle(const qreal &angle) const;
QPointF Ray(const QPointF &firstPoint, const qreal &angle) const;
QPointF Ray(const QPointF &firstPoint) const;
QLineF Axis(const QPointF &p, const qreal &angle) const;

View File

@ -275,6 +275,11 @@ void VisToolCubicBezierPath::RefreshToolTip()
{
Visualization::toolTip = tr("<b>Curved path</b>: select more points for complete segment");
}
if (mode == Mode::Show)
{
Visualization::toolTip = "";
}
emit ToolTip(Visualization::toolTip);
}
}

View File

@ -66,7 +66,9 @@ VisToolSpline::VisToolSpline(const VContainer *data, QGraphicsItem *parent)
//---------------------------------------------------------------------------------------------------------------------
VisToolSpline::~VisToolSpline()
{}
{
emit ToolTip("");
}
//---------------------------------------------------------------------------------------------------------------------
void VisToolSpline::RefreshGeometry()
@ -150,6 +152,8 @@ void VisToolSpline::RefreshGeometry()
{
VSpline spline(*first, *second, angle1, angle2, kAsm1, kAsm2, kCurve);
DrawPath(this, spline.GetPath(PathDirection::Show), mainColor, Qt::SolidLine, Qt::RoundCap);
Visualization::toolTip = tr("Use <b>Shift</b> for sticking angle!");
emit ToolTip(Visualization::toolTip);
}
}
}

View File

@ -48,6 +48,7 @@ VisToolSplinePath::~VisToolSplinePath()
{
qDeleteAll(ctrlPoints);
qDeleteAll(points);
emit ToolTip("");
}
//---------------------------------------------------------------------------------------------------------------------
@ -99,6 +100,11 @@ void VisToolSplinePath::RefreshGeometry()
Visualization::toolTip = tr("<b>Curved path</b>: select three or more points, "
"<b>Enter</b> - finish creation");
}
if (mode == Mode::Show)
{
Visualization::toolTip = tr("Use <b>Shift</b> for sticking angle!");
emit ToolTip(Visualization::toolTip);
}
}
}

View File

@ -0,0 +1,36 @@
/************************************************************************
**
** @file
** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
** @date 19 7, 2016
**
** @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) 2016 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vabstractmainwindow.h"
VAbstractMainWindow::VAbstractMainWindow(QWidget *parent) : QMainWindow(parent)
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractMainWindow::~VAbstractMainWindow()
{}

View File

@ -0,0 +1,45 @@
/************************************************************************
**
** @file
** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
** @date 19 7, 2016
**
** @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) 2016 Valentina project
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VABSTRACTMAINWINDOW_H
#define VABSTRACTMAINWINDOW_H
#include <QMainWindow>
class VAbstractMainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit VAbstractMainWindow(QWidget *parent = nullptr);
virtual ~VAbstractMainWindow() Q_DECL_OVERRIDE;
public slots:
virtual void ShowToolTip(const QString &toolTip)=0;
};
#endif // VABSTRACTMAINWINDOW_H

View File

@ -10,7 +10,8 @@ SOURCES += \
$$PWD/vsimplepoint.cpp \
$$PWD/vabstractsimple.cpp \
$$PWD/vnobrushscalepathitem.cpp \
$$PWD/vsimplecurve.cpp
$$PWD/vsimplecurve.cpp \
$$PWD/vabstractmainwindow.cpp
win32-msvc*:SOURCES += $$PWD/stable.cpp
@ -24,4 +25,5 @@ HEADERS += \
$$PWD/vsimplepoint.h \
$$PWD/vabstractsimple.h \
$$PWD/vnobrushscalepathitem.h \
$$PWD/vsimplecurve.h
$$PWD/vsimplecurve.h \
$$PWD/vabstractmainwindow.h