Refactoring. Reduce modules dependency.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-07-22 17:06:30 +03:00
parent d21da1944e
commit 5c84c80039
17 changed files with 94 additions and 81 deletions

View File

@ -41,6 +41,7 @@
class VCommandLine;
using VCommandLinePtr = std::shared_ptr<VCommandLine>;
using VLayoutGeneratorPtr = std::shared_ptr<VLayoutGenerator>;
enum class PageOrientation : bool;
//@brief: class used to install export command line options and parse their values
//QCommandLineParser* object must exists until this object alive

View File

@ -33,8 +33,6 @@
#include <QMargins>
#include "vabstractlayoutdialog.h"
#include "../vlayout/vbank.h"
#include "../ifc/ifcdef.h"
namespace Ui
{
@ -42,6 +40,7 @@ namespace Ui
}
class VLayoutGenerator;
enum class Cases : char;
class DialogLayoutSettings : public VAbstractLayoutDialog
{

View File

@ -29,11 +29,11 @@
#ifndef VABSTRACTLAYOUTDIALOG_H
#define VABSTRACTLAYOUTDIALOG_H
#include "../ifc/ifcdef.h"
#include <QComboBox>
#include <QDialog>
enum class Unit : char;
class VAbstractLayoutDialog : public QDialog
{
public:

View File

@ -323,8 +323,8 @@ bool MainWindowsNoGUI::GenerateLayout(VLayoutGenerator& lGenerator)
isLayoutPortrait = lGenerator.IsPortrait();
scenes = CreateScenes(papers, shadows, details);
//Uncomment to debug, shows global contour
// gcontours = lGenerator.GetGlobalContours(); // uncomment for debugging
// InsertGlobalContours(scenes, gcontours); // uncomment for debugging
gcontours = lGenerator.GetGlobalContours(); // uncomment for debugging
InsertGlobalContours(scenes, gcontours); // uncomment for debugging
if (VApplication::IsGUIMode())
{
PrepareSceneList(PreviewQuatilty::Fast);

View File

@ -51,6 +51,7 @@
#include "../vmisc/vmath.h"
#include "dxiface.h"
#include "../vlayout/vlayoutpiece.h"
#include "../vgeometry/vgeometrydef.h"
static const qreal AAMATextHeight = 2.5;

View File

@ -768,6 +768,44 @@ QT_WARNING_POP
}
}
#endif
//---------------------------------------------------------------------------------------------------------------------
template<class T>
QVector<T> CorrectPathDistortion(QVector<T> path)
{
if (path.size() < 3)
{
return path;
}
int prev = -1;
for (qint32 i = 0; i < path.size(); ++i)
{
if (prev == -1)
{
i == 0 ? prev = path.size() - 1 : prev = i-1;
}
int next = i+1;
if (i == path.size() - 1)
{
next = 0;
}
const QPointF &iPoint = path.at(i);
const QPointF &prevPoint = path.at(prev);
const QPointF &nextPoint = path.at(next);
if (VGObject::IsPointOnLineSegment(iPoint, prevPoint, nextPoint))
{
const QPointF p = VGObject::CorrectDistortion(iPoint, prevPoint, nextPoint);
path[i].setX(p.x());
path[i].setY(p.y());
}
}
return path;
}
}
// Friend functions

View File

@ -44,6 +44,8 @@ class VAbstractPieceData;
class QPainterPath;
class VGrainlineData;
class VContainer;
enum class LayoutGravity : qint8;
enum class CuttingTime : unsigned char;
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Weffc++")
@ -223,9 +225,6 @@ public:
static QLineF ParallelLine(const VSAPoint &p1, const VSAPoint &p2, qreal width);
static bool IsAllowanceValid(const QVector<QPointF> &base, const QVector<QPointF> &allowance);
template <class T>
static QVector<T> CorrectPathDistortion(QVector<T> path);
template <class T>
static QVector<T> CorrectEquidistantPoints(const QVector<T> &points, bool removeFirstAndLast = true);
@ -254,44 +253,6 @@ private:
Q_DECLARE_TYPEINFO(VAbstractPiece, Q_MOVABLE_TYPE);
//---------------------------------------------------------------------------------------------------------------------
template<class T>
QVector<T> VAbstractPiece::CorrectPathDistortion(QVector<T> path)
{
if (path.size() < 3)
{
return path;
}
int prev = -1;
for (qint32 i = 0; i < path.size(); ++i)
{
if (prev == -1)
{
i == 0 ? prev = path.size() - 1 : prev = i-1;
}
int next = i+1;
if (i == path.size() - 1)
{
next = 0;
}
const QPointF &iPoint = path.at(i);
const QPointF &prevPoint = path.at(prev);
const QPointF &nextPoint = path.at(next);
if (VGObject::IsPointOnLineSegment(iPoint, prevPoint, nextPoint))
{
const QPointF p = VGObject::CorrectDistortion(iPoint, prevPoint, nextPoint);
path[i].setX(p.x());
path[i].setY(p.y());
}
}
return path;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief CorrectEquidistantPoints clear equivalent points and remove point on line from equdistant.

View File

@ -34,6 +34,8 @@
#include "../vmisc/vabstractapplication.h"
#include "vlayoutpiece.h"
#include "vlayoutdef.h"
#include "../ifc/exception/vexception.h"
#include "../vpatterndb/floatItemData/floatitemdef.h"
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes")

View File

@ -34,6 +34,7 @@
#include <QRectF>
#include <QVector>
#include <QtGlobal>
#include <QLoggingCategory>
#include "../vmisc/typedef.h"
@ -45,6 +46,8 @@
#undef small
#endif
Q_DECLARE_LOGGING_CATEGORY(lBank)
class VLayoutPiece;
enum class Cases : char { CaseThreeGroup = 0, CaseTwoGroup, CaseDesc, UnknownCase};

View File

@ -39,6 +39,8 @@
#include "vcontour_p.h"
#include "vlayoutpiece.h"
#include "../vmisc/vmath.h"
#include "../vgeometry/vgeometrydef.h"
#include "../vgeometry/vgobject.h"
namespace
{

View File

@ -49,6 +49,7 @@
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
#include "../vmisc/vmath.h"
#include "../vmisc/vabstractapplication.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/calculator.h"
#include "../vpatterndb/vpassmark.h"
#include "../vpatterndb/vpiecenode.h"

View File

@ -40,19 +40,21 @@
#include <QTypeInfo>
#include <QVector>
#include <QtGlobal>
#include <QCoreApplication>
#include "../ifc/xml/vabstractpattern.h"
#include "../vpatterndb/floatItemData/vpatternlabeldata.h"
#include "../vpatterndb/floatItemData/vpiecelabeldata.h"
#include "../vpatterndb/vcontainer.h"
#include "vabstractpiece.h"
#include "../vgeometry/vgeometrydef.h"
#include "../vmisc/typedef.h"
class VLayoutPieceData;
class VLayoutPiecePath;
class QGraphicsItem;
class QGraphicsPathItem;
class VTextManager;
class VPiece;
class VPieceLabelData;
class VAbstractPattern;
class VPatternLabelData;
enum class ArrowType : char;
class VLayoutPiece :public VAbstractPiece
{

View File

@ -49,6 +49,8 @@
#include "../vmisc/def.h"
#include "../vmisc/vmath.h"
#include "../ifc/exception/vexception.h"
#include "../vpatterndb/floatItemData/floatitemdef.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
#include "../vmisc/backport/qscopeguard.h"

View File

@ -38,8 +38,6 @@
#include <QStringList>
#include <QtGlobal>
#include "../vlayout/vbank.h"
class VCommonSettings : public QSettings
{
Q_OBJECT

View File

@ -43,6 +43,7 @@
#include "../vmisc/def.h"
#include "../vmisc/vmath.h"
#include "../vlayout/vbank.h"
Q_DECLARE_METATYPE(QMarginsF)
@ -123,6 +124,30 @@ VSettings::VSettings(Format format, Scope scope, const QString &organization, co
qRegisterMetaTypeStreamOperators<QMarginsF>("QMarginsF");
}
//---------------------------------------------------------------------------------------------------------------------
template <class T>
inline T VSettings::ValueOrDef(const QString &setting, const T &defValue) const
{
const QVariant val = value(setting, QVariant::fromValue(defValue));
return val.canConvert<T>() ? val.value<T>() : defValue;
}
//---------------------------------------------------------------------------------------------------------------------
template <>
inline Cases VSettings::ValueOrDef<Cases>(const QString &setting, const Cases &defValue) const
{
const QVariant val = value(setting, QVariant::fromValue(static_cast<int>(defValue)));
const int g = val.canConvert<int>() ? val.value<int>() : static_cast<int>(defValue);
if (g < static_cast<int>(Cases::CaseThreeGroup) || g >= static_cast<int>(Cases::UnknownCase))
{
return defValue;
}
else
{
return static_cast<Cases>(g);
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetLabelLanguage() const
{
@ -138,7 +163,7 @@ void VSettings::SetLabelLanguage(const QString &value)
//---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetDefPathLayout()
{
return QDir::homePath() + QLatin1String("/valentina/") + tr("layouts");
return QDir::homePath() + QStringLiteral("/valentina/") + tr("layouts");
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -36,11 +36,12 @@
#include <QtGlobal>
#include <QMargins>
#include "../vmisc/def.h"
#include "../vlayout/vbank.h"
#include "vcommonsettings.h"
template <class T> class QSharedPointer;
enum class Cases : char;
enum class Unit : char;
enum class PageOrientation : bool;
class VSettings : public VCommonSettings
{
@ -187,28 +188,4 @@ private:
T ValueOrDef(const QString &setting, const T &defValue) const;
};
//---------------------------------------------------------------------------------------------------------------------
template <class T>
inline T VSettings::ValueOrDef(const QString &setting, const T &defValue) const
{
const QVariant val = value(setting, QVariant::fromValue(defValue));
return val.canConvert<T>() ? val.value<T>() : defValue;
}
//---------------------------------------------------------------------------------------------------------------------
template <>
inline Cases VSettings::ValueOrDef<Cases>(const QString &setting, const Cases &defValue) const
{
const QVariant val = value(setting, QVariant::fromValue(static_cast<int>(defValue)));
const int g = val.canConvert<int>() ? val.value<int>() : static_cast<int>(defValue);
if (g < static_cast<int>(Cases::CaseThreeGroup) || g >= static_cast<int>(Cases::UnknownCase))
{
return defValue;
}
else
{
return static_cast<Cases>(g);
}
}
#endif // VSETTINGS_H

View File

@ -54,6 +54,7 @@
#include "../vwidgets/vnobrushscalepathitem.h"
#include "../vwidgets/vabstractmainwindow.h"
#include "../qmuparser/qmutokenparser.h"
#include "../vlayout/vlayoutdef.h"
#include <QFuture>
#include <QtConcurrent/QtConcurrentRun>