Refactoring. Preparetion for creation VWidgets static library.
--HG-- branch : feature
This commit is contained in:
parent
da1ec57ce6
commit
70441f48ed
|
@ -2035,8 +2035,8 @@ void MainWindow::New()
|
|||
}
|
||||
|
||||
//Set scene size to size scene view
|
||||
VAbstractTool::NewSceneRect(sceneDraw, ui->view);
|
||||
VAbstractTool::NewSceneRect(sceneDetails, ui->view);
|
||||
VMainGraphicsView::NewSceneRect(sceneDraw, ui->view);
|
||||
VMainGraphicsView::NewSceneRect(sceneDetails, ui->view);
|
||||
ToolBarOption();
|
||||
|
||||
AddPP(patternPieceName, path);
|
||||
|
@ -2782,8 +2782,8 @@ void MainWindow::LoadPattern(const QString &fileName)
|
|||
#endif //QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
|
||||
|
||||
// On this stage scene empty. Fit scene size to view size
|
||||
VAbstractTool::NewSceneRect(sceneDraw, ui->view);
|
||||
VAbstractTool::NewSceneRect(sceneDetails, ui->view);
|
||||
VMainGraphicsView::NewSceneRect(sceneDraw, ui->view);
|
||||
VMainGraphicsView::NewSceneRect(sceneDetails, ui->view);
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
qt_ntfs_permission_lookup++; // turn checking on
|
||||
|
@ -3102,8 +3102,8 @@ void MainWindow::ZoomFirstShow()
|
|||
ActionDraw(true);
|
||||
ui->view->ZoomFitBest();
|
||||
|
||||
VAbstractTool::NewSceneRect(sceneDraw, ui->view);
|
||||
VAbstractTool::NewSceneRect(sceneDetails, ui->view);
|
||||
VMainGraphicsView::NewSceneRect(sceneDraw, ui->view);
|
||||
VMainGraphicsView::NewSceneRect(sceneDetails, ui->view);
|
||||
|
||||
ActionDetails(true);
|
||||
ui->view->ZoomFitBest();
|
||||
|
|
|
@ -55,9 +55,6 @@ extern const QString degreeSymbol;
|
|||
extern const QString cursorArrowOpenHand;
|
||||
extern const QString cursorArrowCloseHand;
|
||||
|
||||
enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Unknown };
|
||||
|
||||
|
||||
enum class Source : char { FromGui, FromFile, FromTool };
|
||||
enum class Contour : char { OpenContour, CloseContour };
|
||||
|
||||
|
|
|
@ -124,43 +124,6 @@ VAbstractTool::VAbstractTool(VPattern *doc, VContainer *data, quint32 id, QObjec
|
|||
VAbstractTool::~VAbstractTool()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view.
|
||||
* @param sc scene.
|
||||
* @param view view.
|
||||
*/
|
||||
void VAbstractTool::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view)
|
||||
{
|
||||
SCASSERT(sc != nullptr);
|
||||
SCASSERT(view != nullptr);
|
||||
|
||||
QRectF rect = sc->itemsBoundingRect();
|
||||
|
||||
QRect rec0 = view->rect();
|
||||
rec0 = QRect(0, 0, rec0.width()-2, rec0.height()-2);
|
||||
|
||||
QTransform t = view->transform();
|
||||
|
||||
QRectF rec1;
|
||||
if (t.m11() < 1)
|
||||
{
|
||||
qreal width = rec0.width()/t.m11();
|
||||
qreal height = rec0.height()/t.m22();
|
||||
rec1 = QRect(0, 0, static_cast<qint32>(width), static_cast<qint32>(height));
|
||||
|
||||
rec1.translate(rec0.center().x()-rec1.center().x(), rec0.center().y()-rec1.center().y());
|
||||
QPolygonF polygone = view->mapToScene(rec1.toRect());
|
||||
rec1 = polygone.boundingRect();
|
||||
}
|
||||
else
|
||||
{
|
||||
rec1 = rec0;
|
||||
}
|
||||
rec1 = rec1.united(rect.toRect());
|
||||
sc->setSceneRect(rec1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief DeleteTool full delete object form scene and file.
|
||||
|
|
|
@ -53,7 +53,6 @@ class VAbstractTool: public VDataTool
|
|||
public:
|
||||
VAbstractTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent = nullptr);
|
||||
virtual ~VAbstractTool();
|
||||
static void NewSceneRect(QGraphicsScene *sc, QGraphicsView *view);
|
||||
quint32 getId() const;
|
||||
static const QString AttrType;
|
||||
static const QString AttrMx;
|
||||
|
|
|
@ -81,7 +81,7 @@ void AddToCalc::undo()
|
|||
doc->setCursor(0);
|
||||
}
|
||||
emit NeedFullParsing();
|
||||
VAbstractTool::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ void AddToCalc::redo()
|
|||
return;
|
||||
}
|
||||
RedoFullParsing();
|
||||
VAbstractTool::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -72,7 +72,7 @@ void MoveDetail::undo()
|
|||
emit NeedLiteParsing(Document::LiteParse);
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VAbstractTool::NewSceneRect(scene, list[0]);
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ void MoveDetail::redo()
|
|||
redoFlag = true;
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VAbstractTool::NewSceneRect(scene, list[0]);
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -123,7 +123,7 @@ void MoveLabel::Do(double mx, double my)
|
|||
emit NeedLiteParsing(Document::LitePPParse);
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VAbstractTool::NewSceneRect(scene, list[0]);
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -100,7 +100,7 @@ void MoveSpline::Do(const VSpline &spl)
|
|||
emit NeedLiteParsing(Document::LiteParse);
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VAbstractTool::NewSceneRect(scene, list[0]);
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -95,7 +95,7 @@ void MoveSplinePath::Do(const VSplinePath &splPath)
|
|||
emit NeedLiteParsing(Document::LiteParse);
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VAbstractTool::NewSceneRect(scene, list[0]);
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -125,7 +125,7 @@ void MoveSPoint::Do(double x, double y)
|
|||
emit NeedLiteParsing(Document::LitePPParse);
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VAbstractTool::NewSceneRect(scene, list[0]);
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -71,7 +71,7 @@ void SaveDetailOptions::undo()
|
|||
emit NeedLiteParsing(Document::LiteParse);
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VAbstractTool::NewSceneRect(scene, list[0]);
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ void SaveDetailOptions::redo()
|
|||
emit NeedLiteParsing(Document::LiteParse);
|
||||
|
||||
QList<QGraphicsView*> listV = scene->views();
|
||||
VAbstractTool::NewSceneRect(scene, listV[0]);
|
||||
VMainGraphicsView::NewSceneRect(scene, listV[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "doubledelegate.h"
|
||||
#include <QDoubleSpinBox>
|
||||
#include "../options.h"
|
||||
#include "../../utils/def.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "textdelegate.h"
|
||||
#include <QLineEdit>
|
||||
#include "../options.h"
|
||||
#include "../libs/vpatterndb/vcontainer.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#define VMAINGRAPHICSSCENE_H
|
||||
|
||||
#include <QGraphicsScene>
|
||||
#include "../options.h"
|
||||
#include "../../utils/def.h"
|
||||
|
||||
/**
|
||||
* @brief The VMainGraphicsScene class main scene.
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include <QWheelEvent>
|
||||
#include <QApplication>
|
||||
#include <QScrollBar>
|
||||
#include "../tools/vabstracttool.h"
|
||||
#include "../visualization/vsimplecurve.h"
|
||||
|
||||
#include <QGraphicsItem>
|
||||
|
@ -193,7 +192,7 @@ VMainGraphicsView::VMainGraphicsView(QWidget *parent)
|
|||
void VMainGraphicsView::ZoomIn()
|
||||
{
|
||||
scale(1.1, 1.1);
|
||||
VAbstractTool::NewSceneRect(this->scene(), this);
|
||||
VMainGraphicsView::NewSceneRect(this->scene(), this);
|
||||
emit NewFactor(1.1);
|
||||
}
|
||||
|
||||
|
@ -201,7 +200,7 @@ void VMainGraphicsView::ZoomIn()
|
|||
void VMainGraphicsView::ZoomOut()
|
||||
{
|
||||
scale(1.0/1.1, 1.0/1.1);
|
||||
VAbstractTool::NewSceneRect(this->scene(), this);
|
||||
VMainGraphicsView::NewSceneRect(this->scene(), this);
|
||||
emit NewFactor(1.0/1.1);
|
||||
}
|
||||
|
||||
|
@ -254,7 +253,7 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress)
|
|||
}
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
{
|
||||
if (qApp->getCurrentScene()->items().contains(list.at(i)))
|
||||
if (this->scene()->items().contains(list.at(i)))
|
||||
{
|
||||
if (list.at(i)->type() <= VSimpleCurve::Type &&
|
||||
list.at(i)->type() > QGraphicsItem::UserType)
|
||||
|
@ -297,3 +296,37 @@ void VMainGraphicsView::setShowToolOptions(bool value)
|
|||
{
|
||||
showToolOptions = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view.
|
||||
* @param sc scene.
|
||||
* @param view view.
|
||||
*/
|
||||
void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view)
|
||||
{
|
||||
SCASSERT(sc != nullptr);
|
||||
SCASSERT(view != nullptr);
|
||||
|
||||
const QRectF rect = sc->itemsBoundingRect();
|
||||
const QRect rec0 = QRect(0, 0, view->rect().width()-2, view->rect().height()-2);
|
||||
const QTransform t = view->transform();
|
||||
|
||||
QRectF rec1;
|
||||
if (t.m11() < 1)
|
||||
{
|
||||
const qreal width = rec0.width()/t.m11();
|
||||
const qreal height = rec0.height()/t.m22();
|
||||
rec1 = QRect(0, 0, static_cast<qint32>(width), static_cast<qint32>(height));
|
||||
|
||||
rec1.translate(rec0.center().x()-rec1.center().x(), rec0.center().y()-rec1.center().y());
|
||||
const QPolygonF polygone = view->mapToScene(rec1.toRect());
|
||||
rec1 = polygone.boundingRect();
|
||||
}
|
||||
else
|
||||
{
|
||||
rec1 = rec0;
|
||||
}
|
||||
rec1 = rec1.united(rect.toRect());
|
||||
sc->setSceneRect(rec1);
|
||||
}
|
||||
|
|
|
@ -104,6 +104,8 @@ public:
|
|||
explicit VMainGraphicsView(QWidget *parent = nullptr);
|
||||
void setShowToolOptions(bool value);
|
||||
|
||||
static void NewSceneRect(QGraphicsScene *sc, QGraphicsView *view);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief NewFactor send new scale factor.
|
||||
|
|
|
@ -842,8 +842,8 @@ void VPattern::LiteParseTree(const Document &parse)
|
|||
setCurrentData();
|
||||
emit FullUpdateFromFile();
|
||||
// Recalculate scene rect
|
||||
VAbstractTool::NewSceneRect(sceneDraw, qApp->getSceneView());
|
||||
VAbstractTool::NewSceneRect(sceneDetail, qApp->getSceneView());
|
||||
VMainGraphicsView::NewSceneRect(sceneDraw, qApp->getSceneView());
|
||||
VMainGraphicsView::NewSceneRect(sceneDetail, qApp->getSceneView());
|
||||
qCDebug(vXML, "Scene size updated.");
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <QStringList>
|
||||
|
||||
enum class NodeDetail : char { Contour, Modeling };
|
||||
enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Unknown };
|
||||
|
||||
enum class Tool : unsigned char
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user