Fix pointer to current scene. Show piece path visualization if the tool dialog

was opened.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-11-29 19:39:40 +02:00
parent 0c9a0347e9
commit e2579c231c
7 changed files with 27 additions and 13 deletions

View file

@ -309,9 +309,9 @@ QPointF MainWindow::StartPositionNewPP() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::InitScenes() void MainWindow::InitScenes()
{ {
sceneDraw = new VMainGraphicsScene(); sceneDraw = new VMainGraphicsScene(this);
currentScene = sceneDraw; currentScene = sceneDraw;
qApp->setCurrentScene(currentScene); qApp->setCurrentScene(&currentScene);
connect(this, &MainWindow::EnableItemMove, sceneDraw, &VMainGraphicsScene::EnableItemMove); connect(this, &MainWindow::EnableItemMove, sceneDraw, &VMainGraphicsScene::EnableItemMove);
connect(this, &MainWindow::ItemsSelection, sceneDraw, &VMainGraphicsScene::ItemsSelection); connect(this, &MainWindow::ItemsSelection, sceneDraw, &VMainGraphicsScene::ItemsSelection);
@ -331,7 +331,7 @@ void MainWindow::InitScenes()
connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::MouseMove); connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::MouseMove);
sceneDetails = new VMainGraphicsScene(); sceneDetails = new VMainGraphicsScene(this);
connect(this, &MainWindow::EnableItemMove, sceneDetails, &VMainGraphicsScene::EnableItemMove); connect(this, &MainWindow::EnableItemMove, sceneDetails, &VMainGraphicsScene::EnableItemMove);
connect(this, &MainWindow::EnableNodeLabelSelection, sceneDetails, &VMainGraphicsScene::ToggleNodeLabelSelection); connect(this, &MainWindow::EnableNodeLabelSelection, sceneDetails, &VMainGraphicsScene::ToggleNodeLabelSelection);
@ -3830,8 +3830,6 @@ MainWindow::~MainWindow()
CleanLayout(); CleanLayout();
delete doc; delete doc;
delete sceneDetails;
delete sceneDraw;
delete ui; delete ui;
} }

View file

@ -290,12 +290,12 @@ VCommonSettings *VAbstractApplication::Settings()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QGraphicsScene *VAbstractApplication::getCurrentScene() const QGraphicsScene *VAbstractApplication::getCurrentScene() const
{ {
SCASSERT(currentScene != nullptr); SCASSERT(*currentScene != nullptr);
return currentScene; return *currentScene;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractApplication::setCurrentScene(QGraphicsScene *value) void VAbstractApplication::setCurrentScene(QGraphicsScene **value)
{ {
currentScene = value; currentScene = value;
} }

View file

@ -88,7 +88,7 @@ public:
QString LocaleToString(const T &value); QString LocaleToString(const T &value);
QGraphicsScene *getCurrentScene() const; QGraphicsScene *getCurrentScene() const;
void setCurrentScene(QGraphicsScene *value); void setCurrentScene(QGraphicsScene **value);
VMainGraphicsView *getSceneView() const; VMainGraphicsView *getSceneView() const;
void setSceneView(VMainGraphicsView *value); void setSceneView(VMainGraphicsView *value);
@ -137,7 +137,7 @@ private:
MeasurementsType _patternType; MeasurementsType _patternType;
QGraphicsScene *currentScene; QGraphicsScene **currentScene;
VMainGraphicsView *sceneView; VMainGraphicsView *sceneView;
VAbstractPattern *doc; VAbstractPattern *doc;

View file

@ -199,6 +199,12 @@ void DialogPiecePath::CheckState()
bOk->setEnabled(flagName && flagError); bOk->setEnabled(flagName && flagError);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::ShowVisualization()
{
AddVisualization<VisToolPiecePath>();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::ShowContextMenu(const QPoint &pos) void DialogPiecePath::ShowContextMenu(const QPoint &pos)
{ {
@ -459,6 +465,10 @@ void DialogPiecePath::SetPiecePath(const VPiecePath &path)
SetType(path.GetType()); SetType(path.GetType());
ui->lineEditName->setText(path.GetName()); ui->lineEditName->setText(path.GetName());
VisToolPiecePath *visPath = qobject_cast<VisToolPiecePath *>(vis);
SCASSERT(visPath != nullptr);
visPath->SetPath(path);
ValidObjects(PathIsValid()); ValidObjects(PathIsValid());
ListChanged(); ListChanged();

View file

@ -63,6 +63,7 @@ protected:
/** @brief SaveData Put dialog data in local variables */ /** @brief SaveData Put dialog data in local variables */
virtual void SaveData() Q_DECL_OVERRIDE; virtual void SaveData() Q_DECL_OVERRIDE;
virtual void CheckState() Q_DECL_OVERRIDE; virtual void CheckState() Q_DECL_OVERRIDE;
virtual void ShowVisualization() Q_DECL_OVERRIDE;
private slots: private slots:
void ShowContextMenu(const QPoint &pos); void ShowContextMenu(const QPoint &pos);

View file

@ -51,8 +51,13 @@ class QRectF;
/** /**
* @brief VMainGraphicsScene default constructor. * @brief VMainGraphicsScene default constructor.
*/ */
VMainGraphicsScene::VMainGraphicsScene() VMainGraphicsScene::VMainGraphicsScene(QObject *parent)
:QGraphicsScene(), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform()), scenePos(QPointF()), : QGraphicsScene(parent),
horScrollBar(0),
verScrollBar(0),
scaleFactor(1),
_transform(QTransform()),
scenePos(QPointF()),
origins() origins()
{} {}

View file

@ -54,7 +54,7 @@ class VMainGraphicsScene : public QGraphicsScene
{ {
Q_OBJECT Q_OBJECT
public: public:
VMainGraphicsScene(); explicit VMainGraphicsScene(QObject *parent = nullptr);
explicit VMainGraphicsScene(const QRectF & sceneRect, QObject * parent = nullptr); explicit VMainGraphicsScene(const QRectF & sceneRect, QObject * parent = nullptr);
qint32 getHorScrollBar() const; qint32 getHorScrollBar() const;
void setHorScrollBar(const qint32 &value); void setHorScrollBar(const qint32 &value);