Visualization for VToolLine.
--HG-- branch : develop
This commit is contained in:
parent
6c6ee3c883
commit
b08019104e
|
@ -31,6 +31,9 @@
|
||||||
|
|
||||||
#include "../../geometry/vpointf.h"
|
#include "../../geometry/vpointf.h"
|
||||||
#include "../../container/vcontainer.h"
|
#include "../../container/vcontainer.h"
|
||||||
|
#include "../../visualization/vgraphicslineitem.h"
|
||||||
|
#include "../../widgets/vapplication.h"
|
||||||
|
#include "../../widgets/vmaingraphicsscene.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +42,8 @@
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogLine::DialogLine(const VContainer *data, QWidget *parent)
|
DialogLine::DialogLine(const VContainer *data, QWidget *parent)
|
||||||
:DialogTool(data, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0), typeLine(QString())
|
:DialogTool(data, parent), ui(new Ui::DialogLine), number(0), firstPoint(0), secondPoint(0), typeLine(QString()),
|
||||||
|
line(nullptr)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
InitOkCancel(ui);
|
InitOkCancel(ui);
|
||||||
|
@ -59,6 +63,7 @@ DialogLine::DialogLine(const VContainer *data, QWidget *parent)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogLine::~DialogLine()
|
DialogLine::~DialogLine()
|
||||||
{
|
{
|
||||||
|
delete line;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,6 +132,16 @@ void DialogLine::PointNameChanged()
|
||||||
CheckState();
|
CheckState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogLine::ShowVisualization()
|
||||||
|
{
|
||||||
|
VMainGraphicsScene *scene = qApp->getCurrentScene();
|
||||||
|
line = new VGraphicsLineItem(data, getCurrentObjectId(ui->comboBoxFirstPoint),
|
||||||
|
getCurrentObjectId(ui->comboBoxSecondPoint));
|
||||||
|
connect(scene, &VMainGraphicsScene::NewFactor, line, &VGraphicsLineItem::SetFactor);
|
||||||
|
scene->addItem(line);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
||||||
|
@ -143,6 +158,13 @@ void DialogLine::ChoosedObject(quint32 id, const SceneObject &type)
|
||||||
qint32 index = ui->comboBoxFirstPoint->findText(point->name());
|
qint32 index = ui->comboBoxFirstPoint->findText(point->name());
|
||||||
if ( index != -1 )
|
if ( index != -1 )
|
||||||
{ // -1 for not found
|
{ // -1 for not found
|
||||||
|
|
||||||
|
VMainGraphicsScene *scene = qApp->getCurrentScene();
|
||||||
|
line = new VGraphicsLineItem(data, id, scene->getScenePos());
|
||||||
|
scene->addItem(line);
|
||||||
|
connect(scene, &VMainGraphicsScene::NewFactor, line, &VGraphicsLineItem::SetFactor);
|
||||||
|
connect(scene, &VMainGraphicsScene::mouseMove, line, &VGraphicsLineItem::MousePos);
|
||||||
|
|
||||||
ui->comboBoxFirstPoint->setCurrentIndex(index);
|
ui->comboBoxFirstPoint->setCurrentIndex(index);
|
||||||
number++;
|
number++;
|
||||||
emit ToolTip(tr("Select second point"));
|
emit ToolTip(tr("Select second point"));
|
||||||
|
@ -155,13 +177,12 @@ void DialogLine::ChoosedObject(quint32 id, const SceneObject &type)
|
||||||
if ( index != -1 )
|
if ( index != -1 )
|
||||||
{ // -1 for not found
|
{ // -1 for not found
|
||||||
ui->comboBoxSecondPoint->setCurrentIndex(index);
|
ui->comboBoxSecondPoint->setCurrentIndex(index);
|
||||||
number = 0;
|
if (flagError)
|
||||||
emit ToolTip("");
|
{
|
||||||
}
|
number = 0;
|
||||||
if (isInitialized == false)
|
emit ToolTip("");
|
||||||
{
|
DialogAccepted();
|
||||||
this->setModal(true);
|
}
|
||||||
this->show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ namespace Ui
|
||||||
class DialogLine;
|
class DialogLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class VGraphicsLineItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The DialogLine class dialog for ToolLine. Help create line and edit option.
|
* @brief The DialogLine class dialog for ToolLine. Help create line and edit option.
|
||||||
*/
|
*/
|
||||||
|
@ -62,6 +64,8 @@ public slots:
|
||||||
*/
|
*/
|
||||||
virtual void DialogApply(){}
|
virtual void DialogApply(){}
|
||||||
virtual void PointNameChanged();
|
virtual void PointNameChanged();
|
||||||
|
protected:
|
||||||
|
virtual void ShowVisualization();
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogLine)
|
Q_DISABLE_COPY(DialogLine)
|
||||||
|
|
||||||
|
@ -79,6 +83,7 @@ private:
|
||||||
|
|
||||||
/** @brief typeLine type of line */
|
/** @brief typeLine type of line */
|
||||||
QString typeLine;
|
QString typeLine;
|
||||||
|
VGraphicsLineItem *line;
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -102,6 +102,7 @@ void DialogTool::showEvent(QShowEvent *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isInitialized = true;//first show windows are held
|
isInitialized = true;//first show windows are held
|
||||||
|
ShowVisualization();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -304,6 +304,7 @@ protected:
|
||||||
VAbstractTool* associatedTool;
|
VAbstractTool* associatedTool;
|
||||||
void ChangeColor(QWidget *widget, const QColor &color);
|
void ChangeColor(QWidget *widget, const QColor &color);
|
||||||
void setPointId(QComboBox *box, quint32 &pointId, const quint32 &value, const quint32 &id);
|
void setPointId(QComboBox *box, quint32 &pointId, const quint32 &value, const quint32 &id);
|
||||||
|
virtual void ShowVisualization(){}
|
||||||
private:
|
private:
|
||||||
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
|
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
|
||||||
};
|
};
|
||||||
|
|
|
@ -73,6 +73,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
|
|
||||||
sceneDraw = new VMainGraphicsScene();
|
sceneDraw = new VMainGraphicsScene();
|
||||||
currentScene = sceneDraw;
|
currentScene = sceneDraw;
|
||||||
|
qApp->setCurrentScene(currentScene);
|
||||||
connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
|
connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
|
||||||
sceneDetails = new VMainGraphicsScene();
|
sceneDetails = new VMainGraphicsScene();
|
||||||
connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
|
connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
|
||||||
|
|
|
@ -164,10 +164,7 @@ void VDrawTool::DialogLinkDestroy()
|
||||||
*/
|
*/
|
||||||
void VDrawTool::SetFactor(qreal factor)
|
void VDrawTool::SetFactor(qreal factor)
|
||||||
{
|
{
|
||||||
if (factor <= 2 && factor >= 0.5)
|
VApplication::CheckFactor(this->factor, factor);
|
||||||
{
|
|
||||||
this->factor = factor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -48,6 +48,9 @@ public:
|
||||||
VDrawTool(VPattern *doc, VContainer *data, quint32 id);
|
VDrawTool(VPattern *doc, VContainer *data, quint32 id);
|
||||||
virtual ~VDrawTool();
|
virtual ~VDrawTool();
|
||||||
|
|
||||||
|
/** @brief factor scene scale factor. */
|
||||||
|
static qreal factor;
|
||||||
|
|
||||||
/** @brief setDialog set dialog when user want change tool option. */
|
/** @brief setDialog set dialog when user want change tool option. */
|
||||||
virtual void setDialog() {}
|
virtual void setDialog() {}
|
||||||
virtual void DialogLinkDestroy();
|
virtual void DialogLinkDestroy();
|
||||||
|
@ -70,9 +73,6 @@ protected:
|
||||||
/** @brief nameActivDraw name of tool's pattern peace. */
|
/** @brief nameActivDraw name of tool's pattern peace. */
|
||||||
QString nameActivDraw;
|
QString nameActivDraw;
|
||||||
|
|
||||||
/** @brief factor scene scale factor. */
|
|
||||||
static qreal factor;
|
|
||||||
|
|
||||||
/** @brief dialog dialog options.*/
|
/** @brief dialog dialog options.*/
|
||||||
DialogTool *dialog;
|
DialogTool *dialog;
|
||||||
|
|
||||||
|
|
91
src/app/visualization/vgraphicslineitem.cpp
Normal file
91
src/app/visualization/vgraphicslineitem.cpp
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vgraphicslineitem.cpp
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 15 7, 2014
|
||||||
|
**
|
||||||
|
** @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) 2014 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 "vgraphicslineitem.h"
|
||||||
|
#include "../container/vcontainer.h"
|
||||||
|
#include "../geometry/vpointf.h"
|
||||||
|
#include "../widgets/vapplication.h"
|
||||||
|
#include "../tools/drawTools/vdrawtool.h"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VGraphicsLineItem::VGraphicsLineItem(const VContainer *data, const quint32 &pointId, const QPointF &scenePos,
|
||||||
|
QGraphicsItem *parent)
|
||||||
|
:QObject(), QGraphicsLineItem(parent), data(data), point1Id(pointId), point2Id(0), factor(VDrawTool::factor),
|
||||||
|
scenePos(scenePos), color(Qt::black)
|
||||||
|
{
|
||||||
|
RefreshGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VGraphicsLineItem::VGraphicsLineItem(const VContainer *data, const quint32 &p1Id, const quint32 &p2Id,
|
||||||
|
QGraphicsItem *parent)
|
||||||
|
:QObject(), QGraphicsLineItem(parent), data(data), point1Id(p1Id), point2Id(p2Id), factor(VDrawTool::factor),
|
||||||
|
scenePos(QPointF()), color(Qt::red)
|
||||||
|
{
|
||||||
|
RefreshGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VGraphicsLineItem::~VGraphicsLineItem()
|
||||||
|
{}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VGraphicsLineItem::SetFactor(qreal factor)
|
||||||
|
{
|
||||||
|
VApplication::CheckFactor(this->factor, factor);
|
||||||
|
RefreshGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VGraphicsLineItem::MousePos(const QPointF &scenePos)
|
||||||
|
{
|
||||||
|
this->scenePos = scenePos;
|
||||||
|
RefreshGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VGraphicsLineItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
QGraphicsLineItem::mouseMoveEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VGraphicsLineItem::RefreshGeometry()
|
||||||
|
{
|
||||||
|
const VPointF *first = data->GeometricObject<const VPointF *>(point1Id);
|
||||||
|
if (point2Id == 0)
|
||||||
|
{
|
||||||
|
this->setLine(QLineF(first->toQPointF(), scenePos));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const VPointF *second = data->GeometricObject<const VPointF *>(point2Id);
|
||||||
|
this->setLine(QLineF(first->toQPointF(), second->toQPointF()));
|
||||||
|
}
|
||||||
|
this->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor, Qt::SolidLine));
|
||||||
|
}
|
59
src/app/visualization/vgraphicslineitem.h
Normal file
59
src/app/visualization/vgraphicslineitem.h
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/************************************************************************
|
||||||
|
**
|
||||||
|
** @file vgraphicslineitem.h
|
||||||
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||||
|
** @date 15 7, 2014
|
||||||
|
**
|
||||||
|
** @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) 2014 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 VGRAPHICSLINEITEM_H
|
||||||
|
#define VGRAPHICSLINEITEM_H
|
||||||
|
|
||||||
|
#include <QGraphicsLineItem>
|
||||||
|
class VContainer;
|
||||||
|
|
||||||
|
class VGraphicsLineItem : public QObject, public QGraphicsLineItem
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VGraphicsLineItem(const VContainer *data, const quint32 &pointId, const QPointF &scenePos,
|
||||||
|
QGraphicsItem * parent = 0);
|
||||||
|
VGraphicsLineItem(const VContainer *data, const quint32 &p1Id, const quint32 &p2Id, QGraphicsItem * parent = 0);
|
||||||
|
virtual ~VGraphicsLineItem();
|
||||||
|
public slots:
|
||||||
|
void SetFactor(qreal factor);
|
||||||
|
void MousePos(const QPointF &scenePos);
|
||||||
|
protected:
|
||||||
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY(VGraphicsLineItem)
|
||||||
|
const VContainer *data;
|
||||||
|
const quint32 point1Id;
|
||||||
|
const quint32 point2Id;
|
||||||
|
qreal factor;
|
||||||
|
QPointF scenePos;
|
||||||
|
const QColor color;
|
||||||
|
void RefreshGeometry();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VGRAPHICSLINEITEM_H
|
|
@ -2,10 +2,12 @@ HEADERS += \
|
||||||
visualization/vgraphicssimpletextitem.h \
|
visualization/vgraphicssimpletextitem.h \
|
||||||
visualization/vcontrolpointspline.h \
|
visualization/vcontrolpointspline.h \
|
||||||
visualization/vsimplesplinepath.h \
|
visualization/vsimplesplinepath.h \
|
||||||
visualization/vsimplecurve.h
|
visualization/vsimplecurve.h \
|
||||||
|
visualization/vgraphicslineitem.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
visualization/vgraphicssimpletextitem.cpp \
|
visualization/vgraphicssimpletextitem.cpp \
|
||||||
visualization/vcontrolpointspline.cpp \
|
visualization/vcontrolpointspline.cpp \
|
||||||
visualization/vsimplesplinepath.cpp \
|
visualization/vsimplesplinepath.cpp \
|
||||||
visualization/vsimplecurve.cpp
|
visualization/vsimplecurve.cpp \
|
||||||
|
visualization/vgraphicslineitem.cpp
|
||||||
|
|
|
@ -57,8 +57,8 @@ VApplication::VApplication(int &argc, char **argv)
|
||||||
_widthMainLine(DefWidth), _widthHairLine(DefWidth/3.0), measurements(QMap<QString, VTranslation>()),
|
_widthMainLine(DefWidth), _widthHairLine(DefWidth/3.0), measurements(QMap<QString, VTranslation>()),
|
||||||
guiTexts(QMap<QString, VTranslation>()), descriptions(QMap<QString, VTranslation>()),
|
guiTexts(QMap<QString, VTranslation>()), descriptions(QMap<QString, VTranslation>()),
|
||||||
variables(QMap<QString, VTranslation>()), functions(QMap<QString, VTranslation>()),
|
variables(QMap<QString, VTranslation>()), functions(QMap<QString, VTranslation>()),
|
||||||
postfixOperators(QMap<QString, VTranslation>()), undoStack(nullptr), sceneView(nullptr), autoSaveTimer(nullptr),
|
postfixOperators(QMap<QString, VTranslation>()), undoStack(nullptr), sceneView(nullptr), currentScene(nullptr),
|
||||||
mainWindow(nullptr), openingPattern(false), settings(nullptr)
|
autoSaveTimer(nullptr), mainWindow(nullptr), openingPattern(false), settings(nullptr)
|
||||||
{
|
{
|
||||||
undoStack = new QUndoStack(this);
|
undoStack = new QUndoStack(this);
|
||||||
|
|
||||||
|
@ -83,6 +83,15 @@ void VApplication::NewValentina(const QString &fileName)
|
||||||
delete v;
|
delete v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VApplication::CheckFactor(qreal &oldFactor, const qreal &Newfactor)
|
||||||
|
{
|
||||||
|
if (Newfactor <= 2 && Newfactor >= 0.5)
|
||||||
|
{
|
||||||
|
oldFactor = Newfactor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief notify Reimplemented from QApplication::notify().
|
* @brief notify Reimplemented from QApplication::notify().
|
||||||
|
@ -1995,3 +2004,16 @@ QSettings *VApplication::getSettings()
|
||||||
SCASSERT(settings != nullptr);
|
SCASSERT(settings != nullptr);
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
VMainGraphicsScene *VApplication::getCurrentScene() const
|
||||||
|
{
|
||||||
|
SCASSERT(currentScene != nullptr);
|
||||||
|
return currentScene;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VApplication::setCurrentScene(VMainGraphicsScene *value)
|
||||||
|
{
|
||||||
|
currentScene = value;
|
||||||
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
class VApplication;// used in define
|
class VApplication;// used in define
|
||||||
class QUndoStack;
|
class QUndoStack;
|
||||||
class VMainGraphicsView;
|
class VMainGraphicsView;
|
||||||
|
class VMainGraphicsScene;
|
||||||
|
|
||||||
#if defined(qApp)
|
#if defined(qApp)
|
||||||
#undef qApp
|
#undef qApp
|
||||||
|
@ -53,6 +54,7 @@ public:
|
||||||
VApplication(int &argc, char ** argv);
|
VApplication(int &argc, char ** argv);
|
||||||
virtual ~VApplication() {}
|
virtual ~VApplication() {}
|
||||||
static void NewValentina(const QString &fileName);
|
static void NewValentina(const QString &fileName);
|
||||||
|
static void CheckFactor(qreal &oldFactor, const qreal &Newfactor);
|
||||||
virtual bool notify(QObject * receiver, QEvent * event);
|
virtual bool notify(QObject * receiver, QEvent * event);
|
||||||
Unit patternUnit() const;
|
Unit patternUnit() const;
|
||||||
void setPatternUnit(const Unit &patternUnit);
|
void setPatternUnit(const Unit &patternUnit);
|
||||||
|
@ -83,6 +85,8 @@ public:
|
||||||
void setOpeningPattern();
|
void setOpeningPattern();
|
||||||
void OpenSettings();
|
void OpenSettings();
|
||||||
QSettings *getSettings();
|
QSettings *getSettings();
|
||||||
|
VMainGraphicsScene *getCurrentScene() const;
|
||||||
|
void setCurrentScene(VMainGraphicsScene *value);
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(VApplication)
|
Q_DISABLE_COPY(VApplication)
|
||||||
Unit _patternUnit;
|
Unit _patternUnit;
|
||||||
|
@ -97,6 +101,7 @@ private:
|
||||||
QMap<QString, VTranslation> postfixOperators;
|
QMap<QString, VTranslation> postfixOperators;
|
||||||
QUndoStack *undoStack;
|
QUndoStack *undoStack;
|
||||||
VMainGraphicsView *sceneView;
|
VMainGraphicsView *sceneView;
|
||||||
|
VMainGraphicsScene *currentScene;
|
||||||
QTimer *autoSaveTimer;
|
QTimer *autoSaveTimer;
|
||||||
/**
|
/**
|
||||||
* @brief mainWindow pointer to main window. Usefull if need create modal dialog. Without pointer to main window
|
* @brief mainWindow pointer to main window. Usefull if need create modal dialog. Without pointer to main window
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
* @brief VMainGraphicsScene default constructor.
|
* @brief VMainGraphicsScene default constructor.
|
||||||
*/
|
*/
|
||||||
VMainGraphicsScene::VMainGraphicsScene()
|
VMainGraphicsScene::VMainGraphicsScene()
|
||||||
:QGraphicsScene(), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform())
|
:QGraphicsScene(), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform()), scenePos(QPointF())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -46,7 +46,8 @@ VMainGraphicsScene::VMainGraphicsScene()
|
||||||
* @param parent parent object.
|
* @param parent parent object.
|
||||||
*/
|
*/
|
||||||
VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * parent)
|
VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * parent)
|
||||||
:QGraphicsScene ( sceneRect, parent ), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform())
|
:QGraphicsScene ( sceneRect, parent ), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform()),
|
||||||
|
scenePos(QPointF())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -56,6 +57,7 @@ VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * paren
|
||||||
*/
|
*/
|
||||||
void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
|
void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
|
||||||
{
|
{
|
||||||
|
scenePos = event->scenePos();
|
||||||
emit mouseMove(event->scenePos());
|
emit mouseMove(event->scenePos());
|
||||||
QGraphicsScene::mouseMoveEvent(event);
|
QGraphicsScene::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -71,6 +73,12 @@ void VMainGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
QGraphicsScene::mousePressEvent(event);
|
QGraphicsScene::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QPointF VMainGraphicsScene::getScenePos() const
|
||||||
|
{
|
||||||
|
return scenePos;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief transform return view transformation.
|
* @brief transform return view transformation.
|
||||||
|
|
|
@ -48,6 +48,7 @@ public:
|
||||||
QTransform transform() const;
|
QTransform transform() const;
|
||||||
void setTransform(const QTransform &transform);
|
void setTransform(const QTransform &transform);
|
||||||
void SetDisable(bool enabled);
|
void SetDisable(bool enabled);
|
||||||
|
QPointF getScenePos() const;
|
||||||
public slots:
|
public slots:
|
||||||
void ChoosedItem(quint32 id, const SceneObject &type);
|
void ChoosedItem(quint32 id, const SceneObject &type);
|
||||||
void SetFactor(qreal factor);
|
void SetFactor(qreal factor);
|
||||||
|
@ -59,7 +60,7 @@ signals:
|
||||||
* @brief mouseMove send new mouse position.
|
* @brief mouseMove send new mouse position.
|
||||||
* @param scenePos new mouse position.
|
* @param scenePos new mouse position.
|
||||||
*/
|
*/
|
||||||
void mouseMove(QPointF scenePos);
|
void mouseMove(const QPointF &scenePos);
|
||||||
/**
|
/**
|
||||||
* @brief mousePress send new mouse press position.
|
* @brief mousePress send new mouse press position.
|
||||||
* @param scenePos new mouse press position.
|
* @param scenePos new mouse press position.
|
||||||
|
@ -89,6 +90,7 @@ private:
|
||||||
|
|
||||||
/** @brief _transform view transform value. */
|
/** @brief _transform view transform value. */
|
||||||
QTransform _transform;
|
QTransform _transform;
|
||||||
|
QPointF scenePos;
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user