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)
|
||||
{
|
||||
if (VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(nodeId)))
|
||||
VToolSeamAllowance *tool = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(nodeId));
|
||||
if (redoFlag && tool)
|
||||
{
|
||||
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))
|
||||
{
|
||||
VMainGraphicsView::NewSceneRect(scene, view);
|
||||
}
|
||||
VMainGraphicsView::NewSceneRect(scene, view, this);
|
||||
}
|
||||
QGraphicsSimpleTextItem::paint(painter, option, widget);
|
||||
}
|
||||
|
|
|
@ -578,11 +578,13 @@ 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)
|
||||
|
||||
if (item == nullptr)
|
||||
{
|
||||
//Calculate view rect
|
||||
const QRectF viewRect = SceneVisibleArea(view);
|
||||
|
||||
|
@ -594,6 +596,11 @@ void VMainGraphicsView::NewSceneRect(QGraphicsScene *sc, QGraphicsView *view)
|
|||
//Unite two rects
|
||||
sc->setSceneRect(itemsRect.united(viewRect));
|
||||
}
|
||||
else if (not sc->sceneRect().contains(item->sceneBoundingRect()))
|
||||
{
|
||||
sc->setSceneRect(sc->sceneRect().united(item->sceneBoundingRect()));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QRectF VMainGraphicsView::SceneVisibleArea(QGraphicsView *view)
|
||||
|
|
|
@ -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