2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-11-04 21:38:54 +01:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file vapplication.h
|
2014-04-30 07:38:52 +02:00
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
** @date November 15, 2013
|
2013-11-04 21:38:54 +01:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** @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 Valentina project
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
2013-11-04 21:38:54 +01:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-11-04 21:38:54 +01:00
|
|
|
** 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/>.
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
*************************************************************************/
|
2013-11-04 21:38:54 +01:00
|
|
|
|
2013-09-23 14:08:06 +02:00
|
|
|
#ifndef VAPPLICATION_H
|
|
|
|
#define VAPPLICATION_H
|
|
|
|
|
|
|
|
#include <QApplication>
|
2014-03-19 19:27:11 +01:00
|
|
|
#include "../options.h"
|
2014-05-13 10:08:37 +02:00
|
|
|
#include "vtranslation.h"
|
2014-07-10 11:36:46 +02:00
|
|
|
#include <QSettings>
|
2014-03-19 19:27:11 +01:00
|
|
|
|
2014-07-10 11:36:46 +02:00
|
|
|
class VApplication;// used in define
|
2014-06-08 20:10:57 +02:00
|
|
|
class QUndoStack;
|
|
|
|
class VMainGraphicsView;
|
2014-07-15 15:51:15 +02:00
|
|
|
class VMainGraphicsScene;
|
2014-03-19 19:27:11 +01:00
|
|
|
|
|
|
|
#if defined(qApp)
|
|
|
|
#undef qApp
|
|
|
|
#endif
|
|
|
|
#define qApp (static_cast<VApplication*>(QCoreApplication::instance()))
|
2013-09-23 14:08:06 +02:00
|
|
|
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
2014-01-27 13:27:26 +01:00
|
|
|
* @brief The VApplication class reimplamentation QApplication class.
|
2013-11-19 21:56:49 +01:00
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
class VApplication : public QApplication
|
|
|
|
{
|
2013-09-23 14:08:06 +02:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-03-19 19:27:11 +01:00
|
|
|
VApplication(int &argc, char ** argv);
|
2013-10-27 09:10:39 +01:00
|
|
|
virtual ~VApplication() {}
|
2014-07-04 16:52:11 +02:00
|
|
|
static void NewValentina(const QString &fileName);
|
2014-07-15 15:51:15 +02:00
|
|
|
static void CheckFactor(qreal &oldFactor, const qreal &Newfactor);
|
2014-06-13 19:02:41 +02:00
|
|
|
virtual bool notify(QObject * receiver, QEvent * event);
|
|
|
|
Unit patternUnit() const;
|
|
|
|
void setPatternUnit(const Unit &patternUnit);
|
|
|
|
MeasurementsType patternType() const;
|
|
|
|
void setPatternType(const MeasurementsType &patternType);
|
2014-07-23 12:04:23 +02:00
|
|
|
|
|
|
|
double toPixel(double val, const Unit &unit) const;
|
|
|
|
double toPixel(double val) const;
|
|
|
|
double fromPixel(double pix, const Unit &unit) const;
|
2014-06-13 19:02:41 +02:00
|
|
|
double fromPixel(double pix) const;
|
2014-07-23 12:04:23 +02:00
|
|
|
|
2014-06-13 19:02:41 +02:00
|
|
|
static const qreal PrintDPI;
|
|
|
|
QString translationsPath() const;
|
|
|
|
QString pathToTables() const;
|
|
|
|
qreal widthMainLine() const;
|
|
|
|
qreal widthHairLine() const;
|
|
|
|
QString VarToUser(const QString &var) const;
|
|
|
|
QString VarFromUser(const QString &var) const;
|
|
|
|
QString GuiText(const QString &measurement) const;
|
|
|
|
QString Description(const QString &measurement) const;
|
|
|
|
QString PostfixOperator(const QString &name) const;
|
|
|
|
QString FormulaFromUser(const QString &formula);
|
|
|
|
QString FormulaToUser(const QString &formula);
|
|
|
|
QUndoStack *getUndoStack() const;
|
|
|
|
VMainGraphicsView *getSceneView() const;
|
|
|
|
void setSceneView(VMainGraphicsView *value);
|
|
|
|
QTimer *getAutoSaveTimer() const;
|
|
|
|
void setAutoSaveTimer(QTimer *value);
|
2014-07-08 12:59:50 +02:00
|
|
|
QWidget *getMainWindow() const;
|
|
|
|
void setMainWindow(QWidget *value);
|
2014-07-08 13:26:13 +02:00
|
|
|
bool getOpeningPattern() const;
|
|
|
|
void setOpeningPattern();
|
2014-07-10 11:36:46 +02:00
|
|
|
void OpenSettings();
|
|
|
|
QSettings *getSettings();
|
2014-07-15 15:51:15 +02:00
|
|
|
VMainGraphicsScene *getCurrentScene() const;
|
|
|
|
void setCurrentScene(VMainGraphicsScene *value);
|
2014-03-19 19:27:11 +01:00
|
|
|
private:
|
2014-06-04 13:30:45 +02:00
|
|
|
Q_DISABLE_COPY(VApplication)
|
2014-06-13 19:02:41 +02:00
|
|
|
Unit _patternUnit;
|
|
|
|
MeasurementsType _patternType;
|
|
|
|
qreal _widthMainLine;
|
|
|
|
qreal _widthHairLine;
|
2014-05-13 10:08:37 +02:00
|
|
|
QMap<QString, VTranslation> measurements;
|
2014-05-16 12:00:33 +02:00
|
|
|
QMap<QString, VTranslation> guiTexts;
|
|
|
|
QMap<QString, VTranslation> descriptions;
|
2014-05-13 10:08:37 +02:00
|
|
|
QMap<QString, VTranslation> variables;
|
|
|
|
QMap<QString, VTranslation> functions;
|
2014-05-23 09:14:21 +02:00
|
|
|
QMap<QString, VTranslation> postfixOperators;
|
2014-06-13 19:02:41 +02:00
|
|
|
QUndoStack *undoStack;
|
|
|
|
VMainGraphicsView *sceneView;
|
2014-07-15 15:51:15 +02:00
|
|
|
VMainGraphicsScene *currentScene;
|
2014-06-13 19:02:41 +02:00
|
|
|
QTimer *autoSaveTimer;
|
2014-07-08 12:59:50 +02:00
|
|
|
/**
|
|
|
|
* @brief mainWindow pointer to main window. Usefull if need create modal dialog. Without pointer to main window
|
|
|
|
* modality doesn't work.
|
|
|
|
*/
|
|
|
|
QWidget *mainWindow;
|
2014-07-08 13:26:13 +02:00
|
|
|
/**
|
|
|
|
* @brief openingPattern true when we opening pattern. If something will be wrong in formula this help understand if
|
|
|
|
* we can allow user use Undo option.
|
|
|
|
*/
|
|
|
|
bool openingPattern;
|
2014-07-10 11:36:46 +02:00
|
|
|
/**
|
|
|
|
* @brief settings pointer to settings. Help hide constructor creation settings. Make make code more readable.
|
|
|
|
*/
|
|
|
|
QSettings *settings;
|
2014-06-13 19:02:41 +02:00
|
|
|
void InitLineWidth();
|
|
|
|
void InitMeasurements();
|
|
|
|
void InitVariables();
|
|
|
|
void InitFunctions();
|
|
|
|
void InitPostfixOperators();
|
|
|
|
bool MeasurementsFromUser(QString &newFormula, int position, const QString &token, int &bias) const;
|
|
|
|
bool VariablesFromUser(QString &newFormula, int position, const QString &token, int &bias) const;
|
|
|
|
bool PostfixOperatorsFromUser(QString &newFormula, int position, const QString &token,
|
|
|
|
int &bias) const;
|
|
|
|
bool FunctionsFromUser(QString &newFormula, int position, const QString &token, int &bias) const;
|
|
|
|
bool VariablesToUser(QString &newFormula, int position, const QString &token, int &bias) const;
|
|
|
|
void CorrectionsPositions(int position, int bias, QMap<int, QString> &tokens,
|
|
|
|
QMap<int, QString> &numbers);
|
|
|
|
void BiasTokens(int position, int bias, QMap<int, QString> &tokens) const;
|
2013-09-23 14:08:06 +02:00
|
|
|
};
|
|
|
|
|
2014-06-08 12:59:39 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-12 09:22:29 +02:00
|
|
|
inline Unit VApplication::patternUnit() const
|
2014-03-19 19:27:11 +01:00
|
|
|
{
|
|
|
|
return _patternUnit;
|
|
|
|
}
|
|
|
|
|
2014-06-08 12:59:39 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-12 09:22:29 +02:00
|
|
|
inline MeasurementsType VApplication::patternType() const
|
2014-03-19 19:27:11 +01:00
|
|
|
{
|
|
|
|
return _patternType;
|
|
|
|
}
|
|
|
|
|
2014-06-08 12:59:39 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-06-12 09:22:29 +02:00
|
|
|
inline void VApplication::setPatternType(const MeasurementsType &patternType)
|
2014-03-19 19:27:11 +01:00
|
|
|
{
|
|
|
|
_patternType = patternType;
|
|
|
|
}
|
|
|
|
|
2014-06-08 12:59:39 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-26 05:39:07 +01:00
|
|
|
inline qreal VApplication::widthMainLine() const
|
|
|
|
{
|
|
|
|
return _widthMainLine;
|
|
|
|
}
|
|
|
|
|
2014-06-08 12:59:39 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2014-03-26 05:39:07 +01:00
|
|
|
inline qreal VApplication::widthHairLine() const
|
|
|
|
{
|
|
|
|
return _widthHairLine;
|
|
|
|
}
|
2014-03-19 19:27:11 +01:00
|
|
|
|
2014-06-08 12:59:39 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline QUndoStack *VApplication::getUndoStack() const
|
|
|
|
{
|
|
|
|
return undoStack;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline VMainGraphicsView *VApplication::getSceneView() const
|
|
|
|
{
|
|
|
|
return sceneView;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline void VApplication::setSceneView(VMainGraphicsView *value)
|
|
|
|
{
|
|
|
|
sceneView = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline QTimer *VApplication::getAutoSaveTimer() const
|
|
|
|
{
|
|
|
|
return autoSaveTimer;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline void VApplication::setAutoSaveTimer(QTimer *value)
|
|
|
|
{
|
|
|
|
autoSaveTimer = value;
|
|
|
|
}
|
|
|
|
|
2013-09-23 14:08:06 +02:00
|
|
|
#endif // VAPPLICATION_H
|