Move VFormula to library VPatternDB. New class VAbstractPattern.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-06-18 11:45:38 +03:00
parent fab30e999f
commit a312e763c0
23 changed files with 186 additions and 82 deletions

View File

@ -3,14 +3,12 @@
HEADERS += \
$$PWD/vapplication.h \
$$PWD/vformula.h \
$$PWD/vformulaproperty.h \
$$PWD/vformulapropertyeditor.h \
$$PWD/vtooloptionspropertybrowser.h
SOURCES += \
$$PWD/vapplication.cpp \
$$PWD/vformula.cpp \
$$PWD/vformulaproperty.cpp \
$$PWD/vformulapropertyeditor.cpp \
$$PWD/vtooloptionspropertybrowser.cpp

View File

@ -156,9 +156,9 @@ const QString VApplication::GistFileName = QStringLiteral("gist.json");
* @param argv command line.
*/
VApplication::VApplication(int &argc, char **argv)
: QApplication(argc, argv), _patternUnit(Unit::Cm), _patternType(MeasurementsType::Individual),
: VAbstractApplication(argc, argv), _patternUnit(Unit::Cm),
trVars(nullptr), undoStack(nullptr), sceneView(nullptr), currentScene(nullptr), autoSaveTimer(nullptr),
mainWindow(nullptr), openingPattern(false), settings(nullptr), doc(nullptr), log(nullptr),
mainWindow(nullptr), openingPattern(false), doc(nullptr), log(nullptr),
#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
out(nullptr), logLock(nullptr)
#else
@ -572,29 +572,6 @@ void VApplication::setOpeningPattern()
openingPattern = !openingPattern;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VApplication::OpenSettings get acsses to application settings.
*
* Because we can create object in constructor we open file separately.
*/
void VApplication::OpenSettings()
{
settings = new VSettings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
QApplication::applicationName(), this);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief VApplication::getSettings hide settings constructor.
* @return pointer to class for acssesing to settings in ini file.
*/
VSettings *VApplication::getSettings()
{
SCASSERT(settings != nullptr);
return settings;
}
//---------------------------------------------------------------------------------------------------------------------
QGraphicsScene *VApplication::getCurrentScene() const
{

View File

@ -29,13 +29,13 @@
#ifndef VAPPLICATION_H
#define VAPPLICATION_H
#include <QApplication>
#include "../libs/vmisc/vabstractapplication.h"
#include "../options.h"
#include "../libs/vwidgets/vmaingraphicsview.h"
#include "../libs/vpatterndb/vtranslatevars.h"
#include "vsettings.h"
class VApplication;// used in define
class VApplication;// use in define
class QUndoStack;
class VMainGraphicsView;
class VPattern;
@ -47,12 +47,12 @@ class QLockFile;
#if defined(qApp)
#undef qApp
#endif
#define qApp (static_cast<VApplication*>(QCoreApplication::instance()))
#define qApp (static_cast<VApplication*>(VAbstractApplication::instance()))
/**
* @brief The VApplication class reimplamentation QApplication class.
*/
class VApplication : public QApplication
class VApplication : public VAbstractApplication
{
Q_OBJECT
public:
@ -64,8 +64,6 @@ public:
Unit patternUnit() const;
const Unit *patternUnitP() const;
void setPatternUnit(const Unit &patternUnit);
MeasurementsType patternType() const;
void setPatternType(const MeasurementsType &patternType);
void InitOptions();
@ -78,14 +76,6 @@ public:
QString translationsPath() const;
template <typename T>
QString LocaleToString(const T &value)
{
QLocale loc;
qApp->getSettings()->GetOsSeparator() ? loc = QLocale::system() : loc = QLocale(QLocale::C);
return loc.toString(value);
}
QUndoStack *getUndoStack() const;
VMainGraphicsView *getSceneView() const;
void setSceneView(VMainGraphicsView *value);
@ -96,9 +86,6 @@ public:
bool getOpeningPattern() const;
void setOpeningPattern();
void OpenSettings();
VSettings *getSettings();
QGraphicsScene *getCurrentScene() const;
void setCurrentScene(QGraphicsScene *value);
@ -110,7 +97,7 @@ public:
void StartLogging();
QTextStream *LogFile();
const VTranslateVars *TrVars();
virtual const VTranslateVars *TrVars();
void InitTrVars();
@ -127,7 +114,6 @@ private slots:
private:
Q_DISABLE_COPY(VApplication)
Unit _patternUnit;
MeasurementsType _patternType;
VTranslateVars *trVars;
QUndoStack *undoStack;
VMainGraphicsView *sceneView;
@ -143,10 +129,6 @@ private:
* we can allow user use Undo option.
*/
bool openingPattern;
/**
* @brief settings pointer to settings. Help hide constructor creation settings. Make make code more readable.
*/
VSettings *settings;
VPattern *doc;
QFile *log;
@ -185,18 +167,6 @@ inline const Unit *VApplication::patternUnitP() const
return &_patternUnit;
}
//---------------------------------------------------------------------------------------------------------------------
inline MeasurementsType VApplication::patternType() const
{
return _patternType;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VApplication::setPatternType(const MeasurementsType &patternType)
{
_patternType = patternType;
}
//---------------------------------------------------------------------------------------------------------------------
inline QUndoStack *VApplication::getUndoStack() const
{

View File

@ -32,7 +32,7 @@
#include "../../libs/vpropertyexplorer/vproperty_p.h"
#include "vformulapropertyeditor.h"
#include "../../libs/vpropertyexplorer/vproperties.h"
#include "../core/vformula.h"
#include "../../libs/vpatterndb/vformula.h"
enum class ChildType : char {Invalid = 0, Value = 1, Formula = 2};

View File

@ -35,7 +35,7 @@
#include <QLabel>
#include <QSpacerItem>
#include "../core/vformula.h"
#include "../../libs/vpatterndb/vformula.h"
class VFormulaPropertyEditor : public QWidget
{

View File

@ -34,7 +34,7 @@
#include "../../libs/vwidgets/vcontrolpointspline.h"
#include "../../libs/vpropertyexplorer/vproperties.h"
#include "vformulaproperty.h"
#include "../core/vformula.h"
#include "../../libs/vpatterndb/vformula.h"
#include <QDockWidget>
#include <QHBoxLayout>

View File

@ -30,7 +30,7 @@
#include "../../libs/vpatterndb/calculator.h"
#include "../../dialogs/tools/dialogarc.h"
#include "../../libs/vgeometry/varc.h"
#include "../../core/vformula.h"
#include "../../libs/vpatterndb/vformula.h"
#include "../../visualization/vistoolarc.h"
#include <QKeyEvent>

View File

@ -30,7 +30,7 @@
#include "../../libs/vpatterndb/calculator.h"
#include "../../dialogs/tools/dialogarcwithlength.h"
#include "../../libs/vgeometry/varc.h"
#include "../../core/vformula.h"
#include "../../libs/vpatterndb/vformula.h"
#include "../../visualization/vistoolarcwithlength.h"
#include <QKeyEvent>

View File

@ -28,7 +28,7 @@
#include "vtoolcut.h"
#include "../../libs/vgeometry/vpointf.h"
#include "../../core/vformula.h"
#include "../../libs/vpatterndb/vformula.h"
//---------------------------------------------------------------------------------------------------------------------
VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula,

View File

@ -30,7 +30,7 @@
#define VTOOLLINEPOINT_H
#include "vtoolpoint.h"
#include "../../core/vformula.h"
#include "../../../libs/vpatterndb/vformula.h"
/**
* @brief The VToolLinePoint class parent for all tools what create point with line.

View File

@ -31,7 +31,7 @@
#include "../../libs/vgeometry/vpointf.h"
#include "../../libs/vgeometry/varc.h"
#include "../../visualization/vistoolpointfromcircleandtangent.h"
#include "../../core/vformula.h"
#include "../../libs/vpatterndb/vformula.h"
const QString VToolPointFromCircleAndTangent::ToolType = QStringLiteral("pointFromCircleAndTangent");

View File

@ -30,7 +30,7 @@
#include "../../libs/vpatterndb/calculator.h"
#include "../../dialogs/tools/dialogpointofcontact.h"
#include "../../libs/vgeometry/vpointf.h"
#include "../../core/vformula.h"
#include "../../libs/vpatterndb/vformula.h"
#include "../../visualization/vistoolpointofcontact.h"
#include <QtCore/qmath.h>

View File

@ -31,7 +31,7 @@
#include "../../libs/vgeometry/vpointf.h"
#include "../../libs/vgeometry/varc.h"
#include "../../visualization/vistoolpointofintersectioncircles.h"
#include "../../core/vformula.h"
#include "../../libs/vpatterndb/vformula.h"
const QString VToolPointOfIntersectionCircles::ToolType = QStringLiteral("pointOfIntersectionCircles");

View File

@ -37,7 +37,6 @@
#endif /*Q_OS_WIN32*/
enum class Unit : char { Mm, Cm, Inch, Px };
enum class MeasurementsType : char { Standard, Individual };
static const quint32 null_id = 0;

View File

@ -34,6 +34,7 @@
#include <QCoreApplication>
#include "ifcdef.h"
#include "../vmisc/def.h"
#include "../vmisc/logging.h"
Q_DECLARE_LOGGING_CATEGORY(vXML)

View File

@ -35,6 +35,7 @@
enum class NodeDetail : char { Contour, Modeling };
enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Unknown };
enum class MeasurementsType : char { Standard, Individual };
enum class Tool : unsigned char
{

View File

@ -0,0 +1,61 @@
/************************************************************************
**
** @file vabstractapplication.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 18 6, 2015
**
** @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) 2015 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 "vabstractapplication.h"
//---------------------------------------------------------------------------------------------------------------------
VAbstractApplication::VAbstractApplication(int &argc, char **argv)
:QApplication(argc, argv), _patternType(MeasurementsType::Individual), settings(nullptr)
{}
//---------------------------------------------------------------------------------------------------------------------
VAbstractApplication::~VAbstractApplication()
{}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief OpenSettings get acsses to application settings.
*
* Because we can create object in constructor we open file separately.
*/
void VAbstractApplication::OpenSettings()
{
settings = new VSettings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
QApplication::applicationName(), this);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getSettings hide settings constructor.
* @return pointer to class for acssesing to settings in ini file.
*/
VSettings *VAbstractApplication::getSettings()
{
SCASSERT(settings != nullptr);
return settings;
}

View File

@ -0,0 +1,92 @@
/************************************************************************
**
** @file vabstractapplication.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 18 6, 2015
**
** @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) 2015 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 VABSTRACTAPPLICATION_H
#define VABSTRACTAPPLICATION_H
#include <QApplication>
#include "def.h"
#include "vsettings.h"
class VAbstractApplication;// use in define
class VTranslateVars;
#if defined(qApp)
#undef qApp
#endif
#define qApp (static_cast<VAbstractApplication*>(QCoreApplication::instance()))
class VAbstractApplication : public QApplication
{
public:
VAbstractApplication(int &argc, char ** argv);
virtual ~VAbstractApplication();
virtual const VTranslateVars *TrVars()=0;
MeasurementsType patternType() const;
void setPatternType(const MeasurementsType &patternType);
void OpenSettings();
VSettings *getSettings();
template <typename T>
QString LocaleToString(const T &value);
private:
Q_DISABLE_COPY(VAbstractApplication)
MeasurementsType _patternType;
/**
* @brief settings pointer to settings. Help hide constructor creation settings. Make make code more readable.
*/
VSettings *settings;
};
//---------------------------------------------------------------------------------------------------------------------
inline MeasurementsType VAbstractApplication::patternType() const
{
return _patternType;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VAbstractApplication::setPatternType(const MeasurementsType &patternType)
{
_patternType = patternType;
}
//---------------------------------------------------------------------------------------------------------------------
template <typename T>
QString VAbstractApplication::LocaleToString(const T &value)
{
QLocale loc;
qApp->getSettings()->GetOsSeparator() ? loc = QLocale::system() : loc = QLocale(QLocale::C);
return loc.toString(value);
}
#endif // VABSTRACTAPPLICATION_H

View File

@ -7,7 +7,8 @@ SOURCES += \
$$PWD/undoevent.cpp \
$$PWD/backport/qcommandlineoption.cpp \
$$PWD/backport/qcommandlineparser.cpp \
$$PWD/vsettings.cpp
$$PWD/vsettings.cpp \
$$PWD/vabstractapplication.cpp
HEADERS += \
$$PWD/stable.h \
@ -17,4 +18,5 @@ HEADERS += \
$$PWD/undoevent.h \
$$PWD/backport/qcommandlineoption.h \
$$PWD/backport/qcommandlineparser.h \
$$PWD/vsettings.h
$$PWD/vsettings.h \
$$PWD/vabstractapplication.h

View File

@ -30,7 +30,7 @@
#define CALCULATOR_H
#include "../qmuparser/qmuparser.h"
#include "../ifc/ifcdef.h"
#include "../vmisc/def.h"
class VContainer;

View File

@ -27,10 +27,11 @@
*************************************************************************/
#include "vformula.h"
#include "../libs/vpatterndb/calculator.h"
#include "../libs/vpatterndb/vcontainer.h"
#include "../core/vapplication.h"
#include "../libs/vmisc/vsettings.h"
#include "calculator.h"
#include "vcontainer.h"
#include "../vmisc/vabstractapplication.h"
#include "../vmisc/vsettings.h"
#include "vtranslatevars.h"
#include <QDebug>
//VFormula

View File

@ -21,7 +21,8 @@ SOURCES += \
$$PWD/variables/vmeasurement.cpp \
$$PWD/variables/vsplineangle.cpp \
$$PWD/variables/vsplinelength.cpp \
$$PWD/variables/vvariable.cpp
$$PWD/variables/vvariable.cpp \
$$PWD/vformula.cpp
HEADERS += \
$$PWD/vcontainer.h \
@ -54,4 +55,5 @@ HEADERS += \
$$PWD/variables/vsplineangle.h \
$$PWD/variables/vsplinelength.h \
$$PWD/variables/vvariable.h \
$$PWD/variables/vvariable_p.h
$$PWD/variables/vvariable_p.h \
$$PWD/vformula.h