2013-11-15 13:41:26 +01:00
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
** @file dialogtool.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-09-18 21:16:19 +02: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.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2013-11-15 13:41:26 +01:00
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
2013-09-18 21:16:19 +02:00
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +02: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.
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
** 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-09-18 21:16:19 +02:00
|
|
|
|
2013-07-28 00:18:06 +02:00
|
|
|
#ifndef DIALOGTOOL_H
|
|
|
|
#define DIALOGTOOL_H
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <qcompilerdetection.h>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QColor>
|
|
|
|
#include <QComboBox>
|
2013-07-28 00:18:06 +02:00
|
|
|
#include <QDialog>
|
2014-03-06 14:28:46 +01:00
|
|
|
#include <QDialogButtonBox>
|
2014-07-13 14:49:00 +02:00
|
|
|
#include <QLineEdit>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QList>
|
2014-07-13 14:49:00 +02:00
|
|
|
#include <QListWidget>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QLocale>
|
|
|
|
#include <QMap>
|
|
|
|
#include <QMetaObject>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QPointer>
|
2014-06-17 11:50:11 +02:00
|
|
|
#include <QPushButton>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QString>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
2016-10-04 16:51:37 +02:00
|
|
|
#include "../vtools/visualization/visualization.h" // Issue on Windows
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../ifc/xml/vabstractpattern.h"
|
2016-08-09 15:55:46 +02:00
|
|
|
#include "../ifc/ifcdef.h"
|
2016-08-08 13:44:49 +02:00
|
|
|
#include "../vgeometry/vgeometrydef.h"
|
|
|
|
#include "../vmisc/def.h"
|
|
|
|
#include "../vmisc/logging.h"
|
|
|
|
#include "../vmisc/vabstractapplication.h"
|
|
|
|
#include "../vmisc/vcommonsettings.h"
|
|
|
|
#include "../vwidgets/vmaingraphicsscene.h"
|
|
|
|
|
|
|
|
template <class T> class QSharedPointer;
|
2014-11-24 15:51:27 +01:00
|
|
|
|
|
|
|
Q_DECLARE_LOGGING_CATEGORY(vDialog)
|
2013-07-28 00:18:06 +02:00
|
|
|
|
2014-06-08 20:10:57 +02:00
|
|
|
class QDoubleSpinBox;
|
|
|
|
class QLabel;
|
2014-06-10 13:53:40 +02:00
|
|
|
class QPlainTextEdit;
|
|
|
|
class VAbstractTool;
|
2014-06-08 20:10:57 +02:00
|
|
|
|
2015-06-20 20:32:35 +02:00
|
|
|
enum class FillComboBox : char { Whole, NoChildren};
|
2013-12-18 12:13:32 +01:00
|
|
|
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief The DialogTool class parent for all dialog of tools.
|
|
|
|
*/
|
2013-11-04 21:35:15 +01:00
|
|
|
class DialogTool : public QDialog
|
|
|
|
{
|
2013-07-28 00:18:06 +02:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-07-29 14:19:11 +02:00
|
|
|
DialogTool(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual ~DialogTool() Q_DECL_OVERRIDE;
|
2014-07-29 14:19:11 +02:00
|
|
|
|
2014-07-23 10:56:32 +02:00
|
|
|
VAbstractTool* GetAssociatedTool();
|
|
|
|
void SetAssociatedTool(VAbstractTool* tool);
|
2014-07-29 14:19:11 +02:00
|
|
|
|
2014-07-23 10:56:32 +02:00
|
|
|
virtual void ShowDialog(bool click);
|
2016-06-23 19:20:21 +02:00
|
|
|
virtual void Build(const Tool &type);
|
2016-11-23 17:41:01 +01:00
|
|
|
virtual void SetPiecesList(const QVector<quint32> &list);
|
2014-07-29 14:19:11 +02:00
|
|
|
|
|
|
|
quint32 GetToolId() const;
|
|
|
|
void SetToolId(const quint32 &value);
|
2015-02-02 17:35:40 +01:00
|
|
|
|
|
|
|
QString getPointName() const;
|
2013-07-28 00:18:06 +02:00
|
|
|
signals:
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief DialogClosed signal dialog closed
|
|
|
|
* @param result keep result
|
|
|
|
*/
|
2013-07-28 00:18:06 +02:00
|
|
|
void DialogClosed(int result);
|
2014-05-25 21:54:17 +02:00
|
|
|
/**
|
|
|
|
* @brief DialogApplied emit signal dialog apply changes
|
|
|
|
*/
|
2014-08-13 12:20:30 +02:00
|
|
|
void DialogApplied();
|
2013-11-19 21:56:49 +01:00
|
|
|
/**
|
|
|
|
* @brief ToolTip emit tooltipe for tool
|
|
|
|
* @param toolTip text tooltipe
|
|
|
|
*/
|
2013-10-07 13:11:56 +02:00
|
|
|
void ToolTip(const QString &toolTip);
|
2013-07-28 00:18:06 +02:00
|
|
|
public slots:
|
2014-07-15 16:42:41 +02:00
|
|
|
virtual void ChosenObject(quint32 id, const SceneObject &type);
|
2016-04-05 19:14:12 +02:00
|
|
|
virtual void SelectedObject(bool selected, quint32 object, quint32 tool);
|
2013-07-28 00:18:06 +02:00
|
|
|
void NamePointChanged();
|
|
|
|
virtual void DialogAccepted();
|
2014-05-25 21:54:17 +02:00
|
|
|
/**
|
|
|
|
* @brief DialogApply save data and emit signal DialogApplied.
|
|
|
|
*/
|
2014-08-13 12:20:30 +02:00
|
|
|
virtual void DialogApply();
|
2013-07-28 00:18:06 +02:00
|
|
|
virtual void DialogRejected();
|
|
|
|
void FormulaChanged();
|
2014-06-09 18:37:11 +02:00
|
|
|
/**
|
|
|
|
* @brief FormulaChangedPlainText check formula (plain text editor editor)
|
|
|
|
*/
|
|
|
|
void FormulaChangedPlainText();
|
2013-07-28 00:18:06 +02:00
|
|
|
void ArrowUp();
|
|
|
|
void ArrowDown();
|
|
|
|
void ArrowLeft();
|
|
|
|
void ArrowRight();
|
|
|
|
void ArrowLeftUp();
|
|
|
|
void ArrowLeftDown();
|
|
|
|
void ArrowRightUp();
|
|
|
|
void ArrowRightDown();
|
2014-08-11 16:41:17 +02:00
|
|
|
virtual void EvalFormula();
|
2015-04-30 13:08:54 +02:00
|
|
|
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void PointNameChanged() {}
|
2013-07-28 00:18:06 +02:00
|
|
|
protected:
|
2013-09-26 20:50:52 +02:00
|
|
|
Q_DISABLE_COPY(DialogTool)
|
2014-06-02 16:28:02 +02:00
|
|
|
|
|
|
|
/** @brief data container with data */
|
2015-04-15 14:44:57 +02:00
|
|
|
// cppcheck-suppress duplInheritedMember
|
2013-07-28 00:18:06 +02:00
|
|
|
const VContainer *data;
|
2014-06-02 16:28:02 +02:00
|
|
|
|
|
|
|
/** @brief isInitialized true if window is initialized */
|
2013-07-28 00:18:06 +02:00
|
|
|
bool isInitialized;
|
2014-06-02 16:28:02 +02:00
|
|
|
|
|
|
|
/** @brief flagName true if name is correct */
|
2013-07-28 00:18:06 +02:00
|
|
|
bool flagName;
|
2014-06-02 16:28:02 +02:00
|
|
|
|
|
|
|
/** @brief flagFormula true if formula correct */
|
2013-07-28 00:18:06 +02:00
|
|
|
bool flagFormula;
|
2014-06-02 16:28:02 +02:00
|
|
|
|
2014-07-14 12:21:46 +02:00
|
|
|
/** @brief flagError use this flag if for you do not enought @see flagName and @see flagFormula.
|
|
|
|
*
|
|
|
|
* In many cases you will need more flags fore checking if all data are valid.
|
|
|
|
* By default this flag is true.
|
|
|
|
*/
|
|
|
|
bool flagError;
|
|
|
|
|
2014-06-02 16:28:02 +02:00
|
|
|
/** @brief timerFormula timer for check formula */
|
2013-07-28 00:18:06 +02:00
|
|
|
QTimer *timerFormula;
|
2014-06-02 16:28:02 +02:00
|
|
|
|
|
|
|
/** @brief bOk button ok */
|
2013-07-28 00:18:06 +02:00
|
|
|
QPushButton *bOk;
|
2014-06-02 16:28:02 +02:00
|
|
|
|
2014-06-10 11:05:21 +02:00
|
|
|
/** @brief bApply button apply */
|
2014-05-26 13:48:42 +02:00
|
|
|
QPushButton *bApply;
|
2014-06-10 11:05:21 +02:00
|
|
|
|
2014-06-02 16:28:02 +02:00
|
|
|
/** @brief spinBoxAngle spinbox for angle */
|
2013-09-12 16:18:31 +02:00
|
|
|
QDoubleSpinBox *spinBoxAngle;
|
2014-06-02 16:28:02 +02:00
|
|
|
|
2014-06-19 11:29:56 +02:00
|
|
|
/** @brief plainTextEditFormula formula */
|
2014-05-25 11:46:54 +02:00
|
|
|
QPlainTextEdit *plainTextEditFormula;
|
2014-06-02 16:28:02 +02:00
|
|
|
|
|
|
|
/** @brief labelResultCalculation label with result of calculation */
|
2013-07-28 00:18:06 +02:00
|
|
|
QLabel *labelResultCalculation;
|
2014-06-02 16:28:02 +02:00
|
|
|
|
|
|
|
/** @brief labelEditNamePoint label used when need show wrong name of point */
|
2013-10-06 18:22:21 +02:00
|
|
|
QLabel *labelEditNamePoint;
|
2014-06-02 16:28:02 +02:00
|
|
|
|
|
|
|
/** @brief labelEditFormula label used when need show wrong formula */
|
2013-10-06 18:22:21 +02:00
|
|
|
QLabel *labelEditFormula;
|
2014-06-02 16:28:02 +02:00
|
|
|
|
2014-07-14 18:28:41 +02:00
|
|
|
const QColor okColor;
|
|
|
|
const QColor errorColor;
|
2014-07-29 14:19:11 +02:00
|
|
|
/**
|
|
|
|
* @brief associatedTool vdrawtool associated with opened dialog.
|
|
|
|
*/
|
|
|
|
VAbstractTool *associatedTool;
|
|
|
|
quint32 toolId;
|
2014-06-02 16:28:02 +02:00
|
|
|
|
2014-08-12 19:21:50 +02:00
|
|
|
/** @brief prepare show if we prepare. Show dialog after finish working with visual part of tool*/
|
|
|
|
bool prepare;
|
|
|
|
|
2014-09-06 10:14:59 +02:00
|
|
|
/** @brief pointName name of point */
|
|
|
|
QString pointName;
|
|
|
|
|
2015-02-03 09:32:32 +01:00
|
|
|
/** @brief number number of handled objects */
|
|
|
|
qint32 number;
|
|
|
|
|
2016-07-07 13:56:55 +02:00
|
|
|
QPointer<Visualization> vis;
|
2015-05-21 21:24:31 +02:00
|
|
|
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void closeEvent ( QCloseEvent * event ) Q_DECL_OVERRIDE;
|
|
|
|
virtual void showEvent( QShowEvent *event ) Q_DECL_OVERRIDE;
|
2015-02-02 12:06:58 +01:00
|
|
|
|
2015-06-24 16:30:07 +02:00
|
|
|
void FillComboBoxPoints(QComboBox *box, FillComboBox rule = FillComboBox::Whole,
|
|
|
|
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const;
|
|
|
|
void FillComboBoxArcs(QComboBox *box, FillComboBox rule = FillComboBox::Whole,
|
|
|
|
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID)const;
|
2016-04-01 16:32:36 +02:00
|
|
|
void FillComboBoxSplines(QComboBox *box)const;
|
|
|
|
void FillComboBoxSplinesPath(QComboBox *box)const;
|
2014-10-23 10:38:57 +02:00
|
|
|
void FillComboBoxCurves(QComboBox *box)const;
|
2015-01-29 16:47:02 +01:00
|
|
|
void FillComboBoxTypeLine(QComboBox *box, const QMap<QString, QIcon> &stylesPics) const;
|
2015-02-02 11:28:09 +01:00
|
|
|
void FillComboBoxLineColors(QComboBox *box)const;
|
2015-05-30 12:02:20 +02:00
|
|
|
void FillComboBoxCrossCirclesPoints(QComboBox *box) const;
|
2016-01-24 17:15:08 +01:00
|
|
|
void FillComboBoxVCrossCurvesPoint(QComboBox *box) const;
|
|
|
|
void FillComboBoxHCrossCurvesPoint(QComboBox *box) const;
|
2015-02-02 12:06:58 +01:00
|
|
|
|
2013-07-31 13:34:39 +02:00
|
|
|
virtual void CheckState();
|
2016-10-17 13:53:46 +02:00
|
|
|
QString GetComboBoxCurrentData(const QComboBox *box, const QString &def)const;
|
2015-02-02 12:55:42 +01:00
|
|
|
void ChangeCurrentData(QComboBox *box, const QVariant &value) const;
|
2016-03-05 13:30:18 +01:00
|
|
|
void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer, const QString &postfix = QString());
|
|
|
|
void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer,
|
|
|
|
const QString &postfix = QString());
|
2014-11-21 15:57:47 +01:00
|
|
|
qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix,
|
2017-01-21 14:24:40 +01:00
|
|
|
bool checkZero = true, bool checkLessThanZero = false);
|
2015-06-20 20:32:35 +02:00
|
|
|
|
|
|
|
void setCurrentPointId(QComboBox *box, const quint32 &value,
|
2015-06-24 16:30:07 +02:00
|
|
|
FillComboBox rule = FillComboBox::NoChildren,
|
|
|
|
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const;
|
2016-04-01 16:32:36 +02:00
|
|
|
void setCurrentSplineId(QComboBox *box, const quint32 &value) const;
|
2015-02-03 09:17:59 +01:00
|
|
|
void setCurrentArcId(QComboBox *box, const quint32 &value,
|
2015-06-24 16:30:07 +02:00
|
|
|
FillComboBox rule = FillComboBox::NoChildren,
|
|
|
|
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const;
|
2016-04-01 16:32:36 +02:00
|
|
|
void setCurrentSplinePathId(QComboBox *box, const quint32 &value) const;
|
2015-02-03 09:17:59 +01:00
|
|
|
void setCurrentCurveId(QComboBox *box, const quint32 &value) const;
|
2015-05-30 12:02:20 +02:00
|
|
|
|
2016-01-24 17:15:08 +01:00
|
|
|
quint32 getCurrentObjectId(QComboBox *box) const;
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
T getCurrentCrossPoint(QComboBox *box) const;
|
2015-05-30 12:02:20 +02:00
|
|
|
|
2014-08-17 20:49:29 +02:00
|
|
|
bool SetObject(const quint32 &id, QComboBox *box, const QString &toolTip);
|
2014-06-19 11:29:56 +02:00
|
|
|
void DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight);
|
2015-07-03 16:03:19 +02:00
|
|
|
|
2014-03-04 19:14:11 +01:00
|
|
|
template <typename T>
|
2015-07-03 16:03:19 +02:00
|
|
|
void InitArrow(T *ui);
|
2014-03-06 14:28:46 +01:00
|
|
|
|
2015-07-03 16:03:19 +02:00
|
|
|
template <typename T>
|
|
|
|
void InitOkCancelApply(T *ui);
|
2015-02-10 20:27:11 +01:00
|
|
|
|
2014-06-19 13:43:02 +02:00
|
|
|
template <typename T>
|
2015-07-03 16:03:19 +02:00
|
|
|
void InitOkCancel(T *ui);
|
|
|
|
|
2015-05-21 21:24:31 +02:00
|
|
|
template <typename T>
|
2015-07-03 16:03:19 +02:00
|
|
|
void InitFormulaUI(T *ui);
|
2015-05-21 21:24:31 +02:00
|
|
|
|
|
|
|
template <typename T>
|
2015-07-03 16:03:19 +02:00
|
|
|
void AddVisualization();
|
2015-05-21 21:24:31 +02:00
|
|
|
|
2014-07-14 12:21:46 +02:00
|
|
|
void ChangeColor(QWidget *widget, const QColor &color);
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void ShowVisualization() {}
|
2014-08-13 12:20:30 +02:00
|
|
|
/**
|
|
|
|
* @brief SaveData Put dialog data in local variables
|
|
|
|
*/
|
2015-07-03 15:36:54 +02:00
|
|
|
virtual void SaveData() {}
|
2017-02-27 13:28:22 +01:00
|
|
|
void MoveCursorToEnd(QPlainTextEdit *plainTextEdit) const;
|
2016-05-03 18:50:37 +02:00
|
|
|
virtual bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
|
2016-02-16 13:00:56 +01:00
|
|
|
quint32 DNumber(const QString &baseName) const;
|
2016-11-22 12:04:34 +01:00
|
|
|
|
2017-03-22 14:29:50 +01:00
|
|
|
static int FindNotExcludedNodeDown(QListWidget *listWidget, int candidate);
|
|
|
|
static int FindNotExcludedNodeUp(QListWidget *listWidget, int candidate);
|
2016-11-22 12:04:34 +01:00
|
|
|
static bool FirstPointEqualLast(QListWidget *listWidget);
|
|
|
|
static bool DoublePoints(QListWidget *listWidget);
|
2017-03-23 18:36:50 +01:00
|
|
|
static bool EachPointLabelIsUnique(QListWidget *listWidget);
|
2016-11-22 12:04:34 +01:00
|
|
|
static QString DialogWarningIcon();
|
2017-03-22 11:05:53 +01:00
|
|
|
static QFont NodeFont(bool nodeExcluded);
|
2016-11-22 12:04:34 +01:00
|
|
|
|
|
|
|
QString GetNodeName(const VPieceNode &node) const;
|
|
|
|
void NewNodeItem(QListWidget *listWidget, const VPieceNode &node);
|
2016-11-28 12:58:17 +01:00
|
|
|
|
|
|
|
void InitNodeAngles(QComboBox *box);
|
2014-01-05 21:56:18 +01:00
|
|
|
private:
|
2015-06-20 20:32:35 +02:00
|
|
|
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
|
|
|
|
|
2016-03-22 16:14:53 +01:00
|
|
|
template <typename T>
|
|
|
|
void PrepareList(QMap<QString, quint32> &list, quint32 id) const;
|
|
|
|
|
|
|
|
bool IsSpline(const QSharedPointer<VGObject> &obj) const;
|
|
|
|
bool IsSplinePath(const QSharedPointer<VGObject> &obj) const;
|
|
|
|
|
2015-06-20 20:32:35 +02:00
|
|
|
template <typename GObject>
|
2015-06-24 16:30:07 +02:00
|
|
|
void FillCombo(QComboBox *box, GOType gType, FillComboBox rule = FillComboBox::Whole,
|
|
|
|
const quint32 &ch1 = NULL_ID, const quint32 &ch2 = NULL_ID) const;
|
2016-03-22 16:14:53 +01:00
|
|
|
|
|
|
|
|
2013-07-28 00:18:06 +02:00
|
|
|
};
|
|
|
|
|
2014-06-10 13:53:40 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
inline VAbstractTool *DialogTool::GetAssociatedTool()
|
|
|
|
{
|
|
|
|
return this->associatedTool;
|
|
|
|
}
|
|
|
|
|
2015-07-03 16:03:19 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T>
|
|
|
|
inline void DialogTool::InitArrow(T *ui)
|
|
|
|
{
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(ui != nullptr)
|
2015-07-03 16:03:19 +02:00
|
|
|
spinBoxAngle = ui->doubleSpinBoxAngle;
|
|
|
|
connect(ui->toolButtonArrowDown, &QPushButton::clicked, this, &DialogTool::ArrowDown);
|
|
|
|
connect(ui->toolButtonArrowUp, &QPushButton::clicked, this, &DialogTool::ArrowUp);
|
|
|
|
connect(ui->toolButtonArrowLeft, &QPushButton::clicked, this, &DialogTool::ArrowLeft);
|
|
|
|
connect(ui->toolButtonArrowRight, &QPushButton::clicked, this, &DialogTool::ArrowRight);
|
|
|
|
connect(ui->toolButtonArrowLeftUp, &QPushButton::clicked, this, &DialogTool::ArrowLeftUp);
|
|
|
|
connect(ui->toolButtonArrowLeftDown, &QPushButton::clicked, this, &DialogTool::ArrowLeftDown);
|
|
|
|
connect(ui->toolButtonArrowRightUp, &QPushButton::clicked, this, &DialogTool::ArrowRightUp);
|
|
|
|
connect(ui->toolButtonArrowRightDown, &QPushButton::clicked, this, &DialogTool::ArrowRightDown);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T>
|
|
|
|
/**
|
|
|
|
* @brief InitOkCancelApply initialise OK / Cancel and Apply buttons
|
|
|
|
* @param ui Dialog container
|
|
|
|
*/
|
|
|
|
inline void DialogTool::InitOkCancelApply(T *ui)
|
|
|
|
{
|
|
|
|
InitOkCancel(ui);
|
|
|
|
bApply = ui->buttonBox->button(QDialogButtonBox::Apply);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(bApply != nullptr)
|
2015-07-03 16:03:19 +02:00
|
|
|
connect(bApply, &QPushButton::clicked, this, &DialogTool::DialogApply);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T>
|
|
|
|
/**
|
|
|
|
* @brief InitOkCancel initialise OK and Cancel buttons
|
|
|
|
* @param ui Dialog container
|
|
|
|
*/
|
|
|
|
inline void DialogTool::InitOkCancel(T *ui)
|
|
|
|
{
|
|
|
|
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(bOk != nullptr)
|
2015-07-03 16:03:19 +02:00
|
|
|
connect(bOk, &QPushButton::clicked, this, &DialogTool::DialogAccepted);
|
|
|
|
|
|
|
|
QPushButton *bCancel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(bCancel != nullptr)
|
2015-07-03 16:03:19 +02:00
|
|
|
connect(bCancel, &QPushButton::clicked, this, &DialogTool::DialogRejected);
|
|
|
|
|
2017-01-03 09:46:28 +01:00
|
|
|
qApp->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
|
2015-07-03 16:03:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T>
|
|
|
|
/**
|
|
|
|
* @brief InitFormulaUI initialise ui object for formula fild
|
|
|
|
* @param ui Dialog container
|
|
|
|
*/
|
|
|
|
inline void DialogTool::InitFormulaUI(T *ui)
|
|
|
|
{
|
|
|
|
labelResultCalculation = ui->labelResultCalculation;
|
|
|
|
plainTextEditFormula = ui->plainTextEditFormula;
|
|
|
|
labelEditFormula = ui->labelEditFormula;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T>
|
|
|
|
inline void DialogTool::AddVisualization()
|
|
|
|
{
|
|
|
|
if (prepare == false)
|
|
|
|
{
|
|
|
|
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(scene != nullptr)
|
2015-07-03 16:03:19 +02:00
|
|
|
|
|
|
|
T *toolVis = qobject_cast<T *>(vis);
|
2016-12-20 19:57:20 +01:00
|
|
|
SCASSERT(toolVis != nullptr)
|
2015-07-03 16:03:19 +02:00
|
|
|
|
2015-07-03 21:22:52 +02:00
|
|
|
if (not scene->items().contains(toolVis))
|
|
|
|
{
|
|
|
|
connect(scene, &VMainGraphicsScene::NewFactor, toolVis, &Visualization::SetFactor);
|
|
|
|
scene->addItem(toolVis);
|
|
|
|
}
|
|
|
|
|
2016-02-12 19:10:01 +01:00
|
|
|
toolVis->SetMode(Mode::Show);
|
2015-07-03 16:03:19 +02:00
|
|
|
toolVis->RefreshGeometry();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-24 17:15:08 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
template <typename T>
|
|
|
|
inline T DialogTool::getCurrentCrossPoint(QComboBox *box) const
|
|
|
|
{
|
|
|
|
int value;
|
|
|
|
bool ok = false;
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0)
|
|
|
|
value = box->itemData(box->currentIndex()).toInt(&ok);
|
|
|
|
#else
|
|
|
|
value = box->currentData().toInt(&ok);
|
|
|
|
#endif
|
|
|
|
if (not ok)
|
|
|
|
{
|
|
|
|
return static_cast<T>(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(value)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
return static_cast<T>(value);
|
|
|
|
default:
|
|
|
|
return static_cast<T>(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-28 00:18:06 +02:00
|
|
|
#endif // DIALOGTOOL_H
|