Optimize adjusting new scene rect.
If we know an object that cause adjustment no need to recalc bounding rect for all scene items. --HG-- branch : develop
This commit is contained in:
parent
6dfe04e2bc
commit
4af32961b0
|
@ -295,7 +295,7 @@ void MainWindow::AddPP(const QString &PPName)
|
|||
comboBoxDraws->blockSignals(false);
|
||||
|
||||
// Show best for new PP
|
||||
VMainGraphicsView::NewSceneRect(ui->view->scene(), ui->view);
|
||||
VMainGraphicsView::NewSceneRect(ui->view->scene(), ui->view, spoint);
|
||||
//ZoomFitBestCurrent();
|
||||
QApplication::postEvent(this, new FitBestCurrentEvent());
|
||||
|
||||
|
|
|
@ -184,9 +184,9 @@ inline void VAbstractSpline::ShowToolVisualization(bool show)
|
|||
ShowHandles(show);
|
||||
}
|
||||
|
||||
if (scene())
|
||||
if (QGraphicsScene *sc = scene())
|
||||
{ // Showing/hiding control points require recalculation scene size.
|
||||
VMainGraphicsView::NewSceneRect(scene(), qApp->getSceneView());
|
||||
VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp
|
|||
|
||||
if (QGraphicsScene *sc = scene())
|
||||
{
|
||||
VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView());
|
||||
VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ void VToolSpline::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
if (QGraphicsScene *sc = scene())
|
||||
{
|
||||
VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView());
|
||||
VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons
|
|||
|
||||
if (QGraphicsScene *sc = scene())
|
||||
{
|
||||
VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView());
|
||||
VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -614,7 +614,7 @@ void VToolSplinePath::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
if (QGraphicsScene *sc = scene())
|
||||
{
|
||||
VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView());
|
||||
VMainGraphicsView::NewSceneRect(sc, qApp->getSceneView(), this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -492,7 +492,7 @@ void VToolSeamAllowance::Update(const VPiece &piece)
|
|||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
||||
VAbstractTool::data.UpdatePiece(m_id, piece);
|
||||
RefreshGeometry();
|
||||
VMainGraphicsView::NewSceneRect(m_sceneDetails, qApp->getSceneView());
|
||||
VMainGraphicsView::NewSceneRect(m_sceneDetails, qApp->getSceneView(), this);
|
||||
setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -89,8 +89,6 @@ void AddPiece::undo()
|
|||
DecrementReferences(m_detail.GetCustomSARecords());
|
||||
DecrementReferences(m_detail.GetInternalPaths());
|
||||
DecrementReferences(m_detail.GetPins());
|
||||
|
||||
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -127,10 +125,14 @@ void AddPiece::redo()
|
|||
m_scene->addItem(m_tool);
|
||||
m_tool->ConnectOutsideSignals();
|
||||
m_tool->show();
|
||||
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView(), m_tool);
|
||||
m_tool.clear();
|
||||
}
|
||||
|
||||
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
|
||||
else
|
||||
{
|
||||
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView(),
|
||||
qobject_cast<VToolSeamAllowance*>(VAbstractPattern::getTool(nodeId)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -103,9 +103,8 @@ void DeletePiece::undo()
|
|||
m_scene->addItem(m_tool);
|
||||
m_tool->ConnectOutsideSignals();
|
||||
m_tool->show();
|
||||
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView(), m_tool);
|
||||
m_tool.clear();
|
||||
|
||||
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -133,8 +132,6 @@ void DeletePiece::redo()
|
|||
DecrementReferences(m_detail.GetCustomSARecords());
|
||||
DecrementReferences(m_detail.GetInternalPaths());
|
||||
DecrementReferences(m_detail.GetPins());
|
||||
|
||||
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -74,11 +74,12 @@ void MovePiece::undo()
|
|||
if (domElement.isElement())
|
||||
{
|
||||
SaveCoordinates(domElement, m_oldX, m_oldY);
|
||||
if (VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(nodeId)))
|
||||
VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(nodeId));
|
||||
if (tool)
|
||||
{
|
||||
tool->Move(m_oldX, m_oldY);
|
||||
}
|
||||
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
|
||||
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView(), tool);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -96,14 +97,12 @@ void MovePiece::redo()
|
|||
{
|
||||
SaveCoordinates(domElement, m_newX, m_newY);
|
||||
|
||||
if (redoFlag)
|
||||
VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(nodeId));
|
||||
if (redoFlag && tool)
|
||||
{
|
||||
if (VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(nodeId)))
|
||||
{
|
||||
tool->Move(m_newX, m_newY);
|
||||
}
|
||||
tool->Move(m_newX, m_newY);
|
||||
}
|
||||
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView());
|
||||
VMainGraphicsView::NewSceneRect(m_scene, qApp->getSceneView(), tool);
|
||||
redoFlag = true;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -64,7 +64,6 @@ void MoveSpline::undo()
|
|||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
Do(oldSpline);
|
||||
VMainGraphicsView::NewSceneRect(scene, qApp->getSceneView());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -73,7 +72,6 @@ void MoveSpline::redo()
|
|||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
Do(newSpline);
|
||||
VMainGraphicsView::NewSceneRect(scene, qApp->getSceneView());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -63,7 +63,6 @@ void MoveSplinePath::undo()
|
|||
qCDebug(vUndo, "Undo.");
|
||||
|
||||
Do(oldSplinePath);
|
||||
VMainGraphicsView::NewSceneRect(scene, qApp->getSceneView());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -72,7 +71,6 @@ void MoveSplinePath::redo()
|
|||
qCDebug(vUndo, "Redo.");
|
||||
|
||||
Do(newSplinePath);
|
||||
VMainGraphicsView::NewSceneRect(scene, qApp->getSceneView());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -116,12 +116,9 @@ void VGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic
|
|||
m_oldScale = 1;
|
||||
}
|
||||
|
||||
if (scene && not scene->sceneRect().contains(sceneBoundingRect()))
|
||||
if (QGraphicsView *view = scene->views().at(0))
|
||||
{
|
||||
if (QGraphicsView *view = scene->views().at(0))
|
||||
{
|
||||
VMainGraphicsView::NewSceneRect(scene, view);
|
||||
}
|
||||
VMainGraphicsView::NewSceneRect(scene, view, this);
|
||||
}
|
||||
QGraphicsSimpleTextItem::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -578,21 +578,28 @@ void VMainGraphicsView::AllowRubberBand(bool value)
|
|||
* @param sc scene.
|
||||
* @param view view.
|
||||
*/
|
||||
void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view)
|
||||
void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QGraphicsItem *item)
|
||||
{
|
||||
SCASSERT(sc != nullptr)
|
||||
SCASSERT(view != nullptr)
|
||||
|
||||
//Calculate view rect
|
||||
const QRectF viewRect = SceneVisibleArea(view);
|
||||
if (item == nullptr)
|
||||
{
|
||||
//Calculate view rect
|
||||
const QRectF viewRect = SceneVisibleArea(view);
|
||||
|
||||
//Calculate scene rect
|
||||
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(sc);
|
||||
SCASSERT(currentScene)
|
||||
const QRectF itemsRect = currentScene->VisibleItemsBoundingRect();
|
||||
//Calculate scene rect
|
||||
VMainGraphicsScene *currentScene = qobject_cast<VMainGraphicsScene *>(sc);
|
||||
SCASSERT(currentScene)
|
||||
const QRectF itemsRect = currentScene->VisibleItemsBoundingRect();
|
||||
|
||||
//Unite two rects
|
||||
sc->setSceneRect(itemsRect.united(viewRect));
|
||||
//Unite two rects
|
||||
sc->setSceneRect(itemsRect.united(viewRect));
|
||||
}
|
||||
else if (not sc->sceneRect().contains(item->sceneBoundingRect()))
|
||||
{
|
||||
sc->setSceneRect(sc->sceneRect().united(item->sceneBoundingRect()));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -118,7 +118,7 @@ public:
|
|||
void setShowToolOptions(bool value);
|
||||
void AllowRubberBand(bool value);
|
||||
|
||||
static void NewSceneRect(QGraphicsScene *sc, QGraphicsView *view);
|
||||
static void NewSceneRect(QGraphicsScene *sc, QGraphicsView *view, QGraphicsItem *item = nullptr);
|
||||
static QRectF SceneVisibleArea(QGraphicsView *view);
|
||||
|
||||
static qreal MinScale();
|
||||
|
|
Loading…
Reference in New Issue
Block a user