Save and restore transformation for each scene.
--HG-- branch : develop
This commit is contained in:
parent
e5247cf323
commit
4b2db9a95d
|
@ -87,6 +87,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
view = new VMainGraphicsView();
|
view = new VMainGraphicsView();
|
||||||
ui->LayoutView->addWidget(view);
|
ui->LayoutView->addWidget(view);
|
||||||
view->setScene(currentScene);
|
view->setScene(currentScene);
|
||||||
|
|
||||||
|
sceneDraw->setTransform(view->transform());
|
||||||
|
sceneDetails->setTransform(view->transform());
|
||||||
|
|
||||||
connect(view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor);
|
connect(view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor);
|
||||||
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
policy.setHorizontalStretch(12);
|
policy.setHorizontalStretch(12);
|
||||||
|
@ -880,24 +884,38 @@ void MainWindow::keyPressEvent ( QKeyEvent * event )
|
||||||
QMainWindow::keyPressEvent ( event );
|
QMainWindow::keyPressEvent ( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::SaveCurrentScene()
|
||||||
|
{
|
||||||
|
/*Save transform*/
|
||||||
|
currentScene->setTransform(view->transform());
|
||||||
|
/*Save scroll bars value for previous scene.*/
|
||||||
|
QScrollBar *horScrollBar = view->horizontalScrollBar();
|
||||||
|
currentScene->setHorScrollBar(horScrollBar->value());
|
||||||
|
QScrollBar *verScrollBar = view->verticalScrollBar();
|
||||||
|
currentScene->setVerScrollBar(verScrollBar->value());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::RestoreCurrentScene()
|
||||||
|
{
|
||||||
|
/*Set transform for current scene*/
|
||||||
|
view->setTransform(currentScene->transform());
|
||||||
|
/*Set value for current scene scroll bar.*/
|
||||||
|
QScrollBar *horScrollBar = view->horizontalScrollBar();
|
||||||
|
horScrollBar->setValue(currentScene->getHorScrollBar());
|
||||||
|
QScrollBar *verScrollBar = view->verticalScrollBar();
|
||||||
|
verScrollBar->setValue(currentScene->getVerScrollBar());
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::ActionDraw(bool checked)
|
void MainWindow::ActionDraw(bool checked)
|
||||||
{
|
{
|
||||||
if (checked)
|
if (checked)
|
||||||
{
|
{
|
||||||
ui->actionDetails->setChecked(false);
|
ui->actionDetails->setChecked(false);
|
||||||
/*Save scroll bars value for previous scene.*/
|
SaveCurrentScene();
|
||||||
QScrollBar *horScrollBar = view->horizontalScrollBar();
|
|
||||||
currentScene->setHorScrollBar(horScrollBar->value());
|
|
||||||
QScrollBar *verScrollBar = view->verticalScrollBar();
|
|
||||||
currentScene->setVerScrollBar(verScrollBar->value());
|
|
||||||
|
|
||||||
currentScene = sceneDraw;
|
currentScene = sceneDraw;
|
||||||
view->setScene(currentScene);
|
view->setScene(currentScene);
|
||||||
/*Set value for current scene scroll bar.*/
|
RestoreCurrentScene();
|
||||||
horScrollBar = view->horizontalScrollBar();
|
|
||||||
horScrollBar->setValue(currentScene->getHorScrollBar());
|
|
||||||
verScrollBar = view->verticalScrollBar();
|
|
||||||
verScrollBar->setValue(currentScene->getVerScrollBar());
|
|
||||||
|
|
||||||
mode = Draw::Calculation;
|
mode = Draw::Calculation;
|
||||||
comboBoxDraws->setEnabled(true);
|
comboBoxDraws->setEnabled(true);
|
||||||
|
@ -918,19 +936,11 @@ void MainWindow::ActionDetails(bool checked)
|
||||||
if (checked)
|
if (checked)
|
||||||
{
|
{
|
||||||
ui->actionDraw->setChecked(false);
|
ui->actionDraw->setChecked(false);
|
||||||
/*Save scroll bars value for previous scene.*/
|
SaveCurrentScene();
|
||||||
QScrollBar *horScrollBar = view->horizontalScrollBar();
|
|
||||||
currentScene->setHorScrollBar(horScrollBar->value());
|
|
||||||
QScrollBar *verScrollBar = view->verticalScrollBar();
|
|
||||||
currentScene->setVerScrollBar(verScrollBar->value());
|
|
||||||
|
|
||||||
currentScene = sceneDetails;
|
currentScene = sceneDetails;
|
||||||
view->setScene(sceneDetails);
|
view->setScene(sceneDetails);
|
||||||
/*Set value for current scene scroll bar.*/
|
RestoreCurrentScene();
|
||||||
horScrollBar = view->horizontalScrollBar();
|
|
||||||
horScrollBar->setValue(currentScene->getHorScrollBar());
|
|
||||||
verScrollBar = view->verticalScrollBar();
|
|
||||||
verScrollBar->setValue(currentScene->getVerScrollBar());
|
|
||||||
|
|
||||||
currentDrawIndex = comboBoxDraws->currentIndex();//save current pattern peace
|
currentDrawIndex = comboBoxDraws->currentIndex();//save current pattern peace
|
||||||
comboBoxDraws->setCurrentIndex(comboBoxDraws->count()-1);
|
comboBoxDraws->setCurrentIndex(comboBoxDraws->count()-1);
|
||||||
|
|
|
@ -537,6 +537,8 @@ private:
|
||||||
* @param enable
|
* @param enable
|
||||||
*/
|
*/
|
||||||
void SetEnableTool(bool enable);
|
void SetEnableTool(bool enable);
|
||||||
|
void SaveCurrentScene();
|
||||||
|
void RestoreCurrentScene();
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -31,10 +31,10 @@
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
|
||||||
VMainGraphicsScene::VMainGraphicsScene()
|
VMainGraphicsScene::VMainGraphicsScene()
|
||||||
:QGraphicsScene(), horScrollBar(0), verScrollBar(0), scaleFactor(1){}
|
:QGraphicsScene(), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform()){}
|
||||||
|
|
||||||
VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * parent)
|
VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * parent)
|
||||||
:QGraphicsScene ( sceneRect, parent ), horScrollBar(0), verScrollBar(0), scaleFactor(1){}
|
:QGraphicsScene ( sceneRect, parent ), horScrollBar(0), verScrollBar(0), scaleFactor(1), _transform(QTransform()){}
|
||||||
|
|
||||||
void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
|
void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
|
||||||
{
|
{
|
||||||
|
@ -48,6 +48,16 @@ void VMainGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
QGraphicsScene::mousePressEvent(event);
|
QGraphicsScene::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTransform VMainGraphicsScene::transform() const
|
||||||
|
{
|
||||||
|
return _transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VMainGraphicsScene::setTransform(const QTransform &transform)
|
||||||
|
{
|
||||||
|
_transform = transform;
|
||||||
|
}
|
||||||
|
|
||||||
void VMainGraphicsScene::ChoosedItem(qint64 id, const Scene::Scenes &type)
|
void VMainGraphicsScene::ChoosedItem(qint64 id, const Scene::Scenes &type)
|
||||||
{
|
{
|
||||||
emit ChoosedObject(id, type);
|
emit ChoosedObject(id, type);
|
||||||
|
|
|
@ -69,6 +69,8 @@ public:
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
inline void setVerScrollBar(const qint32 &value) {verScrollBar = value;}
|
inline void setVerScrollBar(const qint32 &value) {verScrollBar = value;}
|
||||||
|
QTransform transform() const;
|
||||||
|
void setTransform(const QTransform &transform);
|
||||||
public slots:
|
public slots:
|
||||||
/**
|
/**
|
||||||
* @brief ChoosedItem
|
* @brief ChoosedItem
|
||||||
|
@ -127,6 +129,7 @@ private:
|
||||||
* @brief scaleFactor
|
* @brief scaleFactor
|
||||||
*/
|
*/
|
||||||
qreal scaleFactor;
|
qreal scaleFactor;
|
||||||
|
QTransform _transform;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VMAINGRAPHICSSCENE_H
|
#endif // VMAINGRAPHICSSCENE_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user