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()
{
sceneDraw = new VMainGraphicsScene();
sceneDraw = new VMainGraphicsScene(this);
currentScene = sceneDraw;
qApp->setCurrentScene(currentScene);
qApp->setCurrentScene(&currentScene);
connect(this, &MainWindow::EnableItemMove, sceneDraw, &VMainGraphicsScene::EnableItemMove);
connect(this, &MainWindow::ItemsSelection, sceneDraw, &VMainGraphicsScene::ItemsSelection);
@ -331,7 +331,7 @@ void MainWindow::InitScenes()
connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::MouseMove);
sceneDetails = new VMainGraphicsScene();
sceneDetails = new VMainGraphicsScene(this);
connect(this, &MainWindow::EnableItemMove, sceneDetails, &VMainGraphicsScene::EnableItemMove);
connect(this, &MainWindow::EnableNodeLabelSelection, sceneDetails, &VMainGraphicsScene::ToggleNodeLabelSelection);
@ -3830,8 +3830,6 @@ MainWindow::~MainWindow()
CleanLayout();
delete doc;
delete sceneDetails;
delete sceneDraw;
delete ui;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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