Invisible "VSimpleCurve" causes exponential growth scene size, and it causes
the program crash. Because we don't need anymore this calss i just have removed it. --HG-- branch : develop
This commit is contained in:
parent
2bd5a22218
commit
36704cd02e
|
@ -146,10 +146,6 @@ void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item)
|
|||
currentItem = item->parentItem();
|
||||
ShowItemOptions(currentItem);
|
||||
break;
|
||||
case VSimpleCurve::Type:
|
||||
currentItem = item->parentItem();
|
||||
ShowItemOptions(currentItem);
|
||||
break;
|
||||
case VToolLineIntersectAxis::Type:
|
||||
ShowOptionsToolLineIntersectAxis(item);
|
||||
break;
|
||||
|
|
|
@ -185,7 +185,7 @@ QLineF VGObject::BuildLine(const QPointF &p1, const qreal &length, const qreal &
|
|||
{
|
||||
QLineF line = QLineF();
|
||||
line.setP1(p1);
|
||||
line.setAngle(angle);// First set angle than length. Length can have negative value.
|
||||
line.setAngle(angle);// First set angle then length. Length can have negative value.
|
||||
line.setLength(length);
|
||||
return line;
|
||||
}
|
||||
|
|
|
@ -103,7 +103,6 @@ enum class Vis : ToolVisHolderType
|
|||
{
|
||||
ControlPointSpline = static_cast<ToolVisHolderType>(Tool::LAST_ONE_DO_NOT_USE),
|
||||
GraphicsSimpleTextItem,
|
||||
SimpleSplinePath,
|
||||
SimplePoint,
|
||||
Line,
|
||||
Path,
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
VToolCut::VToolCut(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
|
||||
const quint32 &curveCutId, const quint32 &curve1id, const quint32 &curve2id, const QString &color,
|
||||
QGraphicsItem *parent)
|
||||
:VToolSinglePoint(doc, data, id, parent), formula(formula), firstCurve(nullptr), secondCurve(nullptr),
|
||||
:VToolSinglePoint(doc, data, id, parent), formula(formula),
|
||||
curveCutId(curveCutId), curve1id(curve1id), curve2id(curve2id), detailsMode(false)
|
||||
{
|
||||
Q_ASSERT_X(curveCutId != 0, Q_FUNC_INFO, "curveCutId == 0"); //-V654 //-V712
|
||||
|
@ -42,39 +42,12 @@ VToolCut::VToolCut(VAbstractPattern *doc, VContainer *data, const quint32 &id, c
|
|||
Q_ASSERT_X(curve2id != 0, Q_FUNC_INFO, "curve2id == 0"); //-V654 //-V712
|
||||
|
||||
lineColor = color;
|
||||
|
||||
firstCurve = new VSimpleCurve(curve1id, QColor(lineColor), SimpleCurvePoint::ForthPoint, *data->GetPatternUnit(),
|
||||
&factor);
|
||||
firstCurve->setParentItem(this);
|
||||
connect(firstCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed);
|
||||
connect(firstCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath);
|
||||
// TODO: Now we only hide simple curves, but in future need totally delete them all.
|
||||
firstCurve->setVisible(false);
|
||||
|
||||
secondCurve = new VSimpleCurve(curve2id, QColor(lineColor), SimpleCurvePoint::FirstPoint, *data->GetPatternUnit(),
|
||||
&factor);
|
||||
secondCurve->setParentItem(this);
|
||||
connect(secondCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed);
|
||||
connect(secondCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath);
|
||||
secondCurve->setVisible(false);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCut::HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction)
|
||||
{
|
||||
VSimpleCurve* simpleCurve = qobject_cast<VSimpleCurve*>(sender());
|
||||
if (simpleCurve)
|
||||
{
|
||||
RefreshCurve(simpleCurve, id, curvePosition, direction);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCut::Disable(bool disable, const QString &namePP)
|
||||
{
|
||||
VToolSinglePoint::Disable(disable, namePP);
|
||||
firstCurve->ChangedActivDraw(enabled);
|
||||
secondCurve->ChangedActivDraw(enabled);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -141,8 +114,6 @@ void VToolCut::SetFormula(const VFormula &value)
|
|||
*/
|
||||
void VToolCut::RefreshGeometry()
|
||||
{
|
||||
RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint);
|
||||
RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint);
|
||||
VToolSinglePoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#define VTOOLCUT_H
|
||||
|
||||
#include "../vtoolsinglepoint.h"
|
||||
#include "../vwidgets/vsimplecurve.h"
|
||||
#include "../../../toolcurve/vabstractspline.h"
|
||||
|
||||
class VFormula;
|
||||
|
@ -52,8 +51,6 @@ public:
|
|||
void setCurveCutId(const quint32 &value);
|
||||
|
||||
public slots:
|
||||
virtual void CurveChoosed(quint32 id)=0;
|
||||
void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction);
|
||||
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
|
||||
void DetailsMode(bool mode);
|
||||
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
|
||||
|
@ -61,20 +58,12 @@ protected:
|
|||
/** @brief formula keep formula of length */
|
||||
QString formula;
|
||||
|
||||
/** @brief firstCurve first curve after cutting. */
|
||||
VSimpleCurve *firstCurve;
|
||||
|
||||
/** @brief secondCurve second curve after cutting. */
|
||||
VSimpleCurve *secondCurve;
|
||||
|
||||
quint32 curveCutId;
|
||||
quint32 curve1id;
|
||||
quint32 curve2id;
|
||||
|
||||
bool detailsMode;
|
||||
|
||||
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
|
||||
PathDirection direction = PathDirection::Hide)=0;
|
||||
void RefreshGeometry();
|
||||
virtual void RemoveReferens() Q_DECL_OVERRIDE;
|
||||
void FullUpdateCurveFromFile(const QString &attrCurve);
|
||||
|
|
|
@ -54,9 +54,6 @@ VToolCutArc::VToolCutArc(VAbstractPattern *doc, VContainer *data, const quint32
|
|||
const Source &typeCreation, QGraphicsItem * parent)
|
||||
:VToolCut(doc, data, id, formula, arcId, arc1id, arc2id, color, parent)
|
||||
{
|
||||
RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint);
|
||||
RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint);
|
||||
|
||||
ToolCreation(typeCreation);
|
||||
}
|
||||
|
||||
|
@ -185,16 +182,6 @@ void VToolCutArc::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolCutArc>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief CurveChoosed send signal about selection from cutted arc.
|
||||
* @param id object id in container.
|
||||
*/
|
||||
void VToolCutArc::CurveChoosed(quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::Arc);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
|
@ -228,31 +215,6 @@ void VToolCutArc::SaveDialog(QDomElement &domElement)
|
|||
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RefreshCurve refresh curve on scene.
|
||||
* @param curve curve.
|
||||
* @param curveId curve id.
|
||||
*/
|
||||
void VToolCutArc::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
|
||||
PathDirection direction)
|
||||
{
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(curveId);
|
||||
QPainterPath path;
|
||||
path.addPath(arc->GetPath(direction));
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
if (curvePosition == SimpleCurvePoint::FirstPoint)
|
||||
{
|
||||
path.translate(-arc->GetP1().x(), -arc->GetP1().y());
|
||||
}
|
||||
else
|
||||
{
|
||||
path.translate(-arc->GetP2().x(), -arc->GetP2().y());
|
||||
}
|
||||
curve->SetCurrentColor(QColor(lineColor));
|
||||
curve->setPath(path);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCutArc::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
|
|
|
@ -52,13 +52,9 @@ public:
|
|||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::CutArc)};
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
public slots:
|
||||
virtual void CurveChoosed(quint32 id) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
|
||||
PathDirection direction = PathDirection::Hide) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
|
|
|
@ -53,9 +53,6 @@ VToolCutSpline::VToolCutSpline(VAbstractPattern *doc, VContainer *data, const qu
|
|||
const QString &color, const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolCut(doc, data, id, formula, splineId, spl1id, spl2id, color, parent)
|
||||
{
|
||||
RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint);
|
||||
RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint);
|
||||
|
||||
ToolCreation(typeCreation);
|
||||
}
|
||||
|
||||
|
@ -193,16 +190,6 @@ void VToolCutSpline::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolCutSpline>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief CurveChoosed send signal about selection from spline.
|
||||
* @param id object id in container.
|
||||
*/
|
||||
void VToolCutSpline::CurveChoosed(quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::Spline);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
|
@ -236,31 +223,6 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement)
|
|||
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RefreshCurve refresh curve on scene.
|
||||
* @param curve curve.
|
||||
* @param curveId curve id.
|
||||
*/
|
||||
void VToolCutSpline::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
|
||||
PathDirection direction)
|
||||
{
|
||||
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(curveId);
|
||||
QPainterPath path;
|
||||
path.addPath(spl->GetPath(direction));
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
if (curvePosition == SimpleCurvePoint::FirstPoint)
|
||||
{
|
||||
path.translate(-spl->GetP1().toQPointF().x(), -spl->GetP1().toQPointF().y());
|
||||
}
|
||||
else
|
||||
{
|
||||
path.translate(-spl->GetP4().toQPointF().x(), -spl->GetP4().toQPointF().y());
|
||||
}
|
||||
curve->SetCurrentColor(QColor(lineColor));
|
||||
curve->setPath(path);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCutSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
|
|
|
@ -55,13 +55,9 @@ public:
|
|||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::CutSpline)};
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
public slots:
|
||||
virtual void CurveChoosed(quint32 id) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
|
||||
PathDirection direction = PathDirection::Hide) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
|
|
|
@ -56,9 +56,6 @@ VToolCutSplinePath::VToolCutSplinePath(VAbstractPattern *doc, VContainer *data,
|
|||
const Source &typeCreation, QGraphicsItem *parent)
|
||||
:VToolCut(doc, data, id, formula, splinePathId, splPath1id, splPath2id, color, parent)
|
||||
{
|
||||
RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint);
|
||||
RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint);
|
||||
|
||||
ToolCreation(typeCreation);
|
||||
}
|
||||
|
||||
|
@ -237,16 +234,6 @@ void VToolCutSplinePath::ShowVisualization(bool show)
|
|||
ShowToolVisualization<VisToolCutSplinePath>(show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief CurveChoosed send signal about selection splinePath.
|
||||
* @param id object id in container.
|
||||
*/
|
||||
void VToolCutSplinePath::CurveChoosed(quint32 id)
|
||||
{
|
||||
emit ChoosedTool(id, SceneObject::SplinePath);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief contextMenuEvent handle context menu events.
|
||||
|
@ -280,33 +267,6 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement)
|
|||
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief RefreshCurve refresh curve on scene.
|
||||
* @param curve curve.
|
||||
* @param curveId curve id.
|
||||
*/
|
||||
void VToolCutSplinePath::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
|
||||
PathDirection direction)
|
||||
{
|
||||
const QSharedPointer<VSplinePath> splPath = VAbstractTool::data.GeometricObject<VSplinePath>(curveId);
|
||||
QPainterPath path;
|
||||
path.addPath(splPath->GetPath(direction));
|
||||
path.setFillRule( Qt::WindingFill );
|
||||
if (curvePosition == SimpleCurvePoint::FirstPoint)
|
||||
{
|
||||
VSpline spl = splPath->GetSpline(1);
|
||||
path.translate(-spl.GetP1().toQPointF().x(), -spl.GetP1().toQPointF().y());
|
||||
}
|
||||
else
|
||||
{
|
||||
VSpline spl = splPath->GetSpline(splPath->Count());
|
||||
path.translate(-spl.GetP4().toQPointF().x(), -spl.GetP4().toQPointF().y());
|
||||
}
|
||||
curve->SetCurrentColor(QColor(lineColor));
|
||||
curve->setPath(path);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCutSplinePath::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
|
|
|
@ -56,13 +56,9 @@ public:
|
|||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::CutSplinePath)};
|
||||
virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE;
|
||||
public slots:
|
||||
virtual void CurveChoosed(quint32 id) Q_DECL_OVERRIDE;
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void SaveDialog(QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
|
||||
PathDirection direction = PathDirection::Hide) Q_DECL_OVERRIDE;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
|
||||
virtual void SetVisualization() Q_DECL_OVERRIDE;
|
||||
|
|
|
@ -141,12 +141,20 @@ QVariant VToolBasePoint::itemChange(QGraphicsItem::GraphicsItemChange change, co
|
|||
}
|
||||
if (change == ItemPositionHasChanged && scene())
|
||||
{
|
||||
// Each time we move something we call recalculation scene rect. In some cases this can cause moving
|
||||
// objects positions. And this cause infinite redrawing. That's why we wait the finish of saving the last move.
|
||||
static bool changeFinished = true;
|
||||
if (changeFinished)
|
||||
{
|
||||
changeFinished = false;
|
||||
// value - this is new position.
|
||||
QPointF newPos = value.toPointF();
|
||||
|
||||
MoveSPoint *moveSP = new MoveSPoint(doc, newPos.x(), newPos.y(), id, this->scene());
|
||||
connect(moveSP, &MoveSPoint::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree);
|
||||
qApp->getUndoStack()->push(moveSP);
|
||||
changeFinished = true;
|
||||
}
|
||||
}
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
|
|
|
@ -70,9 +70,6 @@ void MoveDetail::undo()
|
|||
SaveCoordinates(domElement, oldX, oldY);
|
||||
|
||||
emit NeedLiteParsing(Document::LiteParse);
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -96,9 +93,6 @@ void MoveDetail::redo()
|
|||
emit NeedLiteParsing(Document::LiteParse);
|
||||
}
|
||||
redoFlag = true;
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -178,9 +178,6 @@ void MoveDoubleLabel::Do(double mx, double my)
|
|||
}
|
||||
|
||||
emit NeedLiteParsing(Document::LitePPParse);
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -121,9 +121,6 @@ void MoveLabel::Do(double mx, double my)
|
|||
doc->SetAttribute(domElement, AttrMy, QString().setNum(qApp->fromPixel(my)));
|
||||
|
||||
emit NeedLiteParsing(Document::LitePPParse);
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -99,9 +99,6 @@ void MoveSpline::Do(const VSpline &spl)
|
|||
doc->SetAttribute(domElement, AttrKCurve, QString().setNum(spl.GetKcurve()));
|
||||
|
||||
emit NeedLiteParsing(Document::LiteParse);
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -93,9 +93,6 @@ void MoveSplinePath::Do(const VSplinePath &splPath)
|
|||
VToolSplinePath::UpdatePathPoint(doc, domElement, splPath);
|
||||
|
||||
emit NeedLiteParsing(Document::LiteParse);
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -123,9 +123,6 @@ void MoveSPoint::Do(double x, double y)
|
|||
doc->SetAttribute(domElement, AttrY, QString().setNum(qApp->fromPixel(y)));
|
||||
|
||||
emit NeedLiteParsing(Document::LitePPParse);
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -71,9 +71,6 @@ void SaveDetailOptions::undo()
|
|||
}
|
||||
}
|
||||
emit NeedLiteParsing(Document::LiteParse);
|
||||
|
||||
QList<QGraphicsView*> list = scene->views();
|
||||
VMainGraphicsView::NewSceneRect(scene, list[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -108,9 +105,6 @@ void SaveDetailOptions::redo()
|
|||
}
|
||||
}
|
||||
emit NeedLiteParsing(Document::LiteParse);
|
||||
|
||||
QList<QGraphicsView*> listV = scene->views();
|
||||
VMainGraphicsView::NewSceneRect(scene, listV[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -85,6 +85,16 @@ QPointF VisLine::Ray(const QPointF &firstPoint, const qreal &angle) const
|
|||
}
|
||||
|
||||
QRectF scRect = this->scene()->sceneRect();
|
||||
|
||||
//Limit size of the scene rect. Axis that has same size as scene rect cause scene size growth.
|
||||
QLineF line1 = QLineF(scRect.topLeft(), scRect.bottomRight());
|
||||
line1.setLength(20);
|
||||
|
||||
QLineF line2 = QLineF(scRect.bottomRight(), scRect.topLeft());
|
||||
line2.setLength(20);
|
||||
|
||||
scRect = QRectF(line1.p2(), line2.p2());
|
||||
|
||||
if (QGuiApplication::keyboardModifiers() == Qt::ShiftModifier)
|
||||
{
|
||||
return VGObject::BuildRay(firstPoint, CorrectAngle(angle), scRect);
|
||||
|
|
|
@ -112,6 +112,7 @@ QGraphicsEllipseItem *Visualization::InitPoint(const QColor &color, QGraphicsIte
|
|||
point->setBrush(QBrush(Qt::NoBrush));
|
||||
point->setPen(QPen(color, qApp->toPixel(WidthMainLine(*Visualization::data->GetPatternUnit()))/factor));
|
||||
point->setRect(PointRect(ToPixel(DefPointRadius/*mm*/, Unit::Mm)));
|
||||
point->setPos(QPointF());
|
||||
point->setFlags(QGraphicsItem::ItemStacksBehindParent);
|
||||
point->setVisible(false);
|
||||
return point;
|
||||
|
|
|
@ -120,9 +120,17 @@ QVariant VControlPointSpline::itemChange(QGraphicsItem::GraphicsItemChange chang
|
|||
{
|
||||
if (change == ItemPositionChange && scene())
|
||||
{
|
||||
// Each time we move something we call recalculation scene rect. In some cases this can cause moving
|
||||
// objects positions. And this cause infinite redrawing. That's why we wait the finish of saving the last move.
|
||||
static bool changeFinished = true;
|
||||
if (changeFinished)
|
||||
{
|
||||
changeFinished = false;
|
||||
// value - new position.
|
||||
QPointF newPos = value.toPointF();
|
||||
emit ControlPointChangePosition(indexSpline, position, newPos);
|
||||
changeFinished = false;
|
||||
}
|
||||
}
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
|
|
|
@ -115,8 +115,16 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV
|
|||
{
|
||||
if (change == ItemPositionChange && scene())
|
||||
{
|
||||
// Each time we move something we call recalculation scene rect. In some cases this can cause moving
|
||||
// objects positions. And this cause infinite redrawing. That's why we wait the finish of saving the last move.
|
||||
static bool changeFinished = true;
|
||||
if (changeFinished)
|
||||
{
|
||||
changeFinished = false;
|
||||
QPointF newPos = value.toPointF() + this->parentItem()->pos();
|
||||
emit NameChangePosition(newPos);
|
||||
changeFinished = true;
|
||||
}
|
||||
}
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <QWheelEvent>
|
||||
#include <QApplication>
|
||||
#include <QScrollBar>
|
||||
#include "vsimplecurve.h"
|
||||
#include "vsimplepoint.h"
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QMouseEvent>
|
||||
|
@ -211,6 +211,7 @@ void VMainGraphicsView::ZoomOriginal()
|
|||
trans.setMatrix(1.0, trans.m12(), trans.m13(), trans.m21(), 1.0, trans.m23(), trans.m31(), trans.m32(),
|
||||
trans.m33());
|
||||
this->setTransform(trans);
|
||||
VMainGraphicsView::NewSceneRect(this->scene(), this);
|
||||
emit NewFactor(1.0);
|
||||
}
|
||||
|
||||
|
@ -225,6 +226,7 @@ void VMainGraphicsView::ZoomFitBest()
|
|||
}
|
||||
|
||||
this->fitInView(rect, Qt::KeepAspectRatio);
|
||||
VMainGraphicsView::NewSceneRect(this->scene(), this);
|
||||
emit NewFactor(this->transform().m11());
|
||||
}
|
||||
|
||||
|
@ -255,7 +257,7 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress)
|
|||
{
|
||||
if (this->scene()->items().contains(list.at(i)))
|
||||
{
|
||||
if (list.at(i)->type() <= VSimpleCurve::Type &&
|
||||
if (list.at(i)->type() <= VSimplePoint::Type &&
|
||||
list.at(i)->type() > QGraphicsItem::UserType)
|
||||
{
|
||||
emit itemClicked(list.at(i));
|
||||
|
@ -308,25 +310,20 @@ 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();
|
||||
//Calculate view rect
|
||||
//to receive the currently visible area, map the widgets bounds to the scene
|
||||
const QPointF a = view->mapToScene(0, 0 );
|
||||
const QPointF b = view->mapToScene(view->viewport()->width(), view->viewport()->height());
|
||||
const QRectF viewRect = QRectF( a, b );
|
||||
|
||||
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));
|
||||
//Calculate scene rect
|
||||
const QRectF itemsRect = sc->itemsBoundingRect();
|
||||
|
||||
rec1.translate(rec0.center().x()-rec1.center().x(), rec0.center().y()-rec1.center().y());
|
||||
const QPolygonF polygone = view->mapToScene(rec1.toRect());
|
||||
rec1 = polygone.boundingRect();
|
||||
//Unite two rects
|
||||
const QRectF newRect = itemsRect.united(viewRect);
|
||||
|
||||
if (newRect != itemsRect)
|
||||
{//Update if only need
|
||||
sc->setSceneRect(newRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
rec1 = rec0;
|
||||
}
|
||||
rec1 = rec1.united(rect.toRect());
|
||||
sc->setSceneRect(rec1);
|
||||
}
|
||||
|
|
|
@ -1,128 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vsimplecurve.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 17 12, 2013
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2013-2015 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#include "vsimplecurve.h"
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QPen>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief VSimpleSpline constructor.
|
||||
* @param id spline id.
|
||||
* @param factor scene scale factor.
|
||||
* @param currentColor current color.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VSimpleCurve::VSimpleCurve(quint32 id, const QColor ¤tColor, SimpleCurvePoint pointPosition, Unit patternUnit,
|
||||
qreal *factor, QObject *parent)
|
||||
:VAbstractSimple(id, currentColor, patternUnit, factor, parent), QGraphicsPathItem(), curvePosition(pointPosition)
|
||||
{
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::ChangedActivDraw(const bool &flag)
|
||||
{
|
||||
enabled = flag;
|
||||
setEnabled(enabled);
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
/* From question on StackOverflow
|
||||
* https://stackoverflow.com/questions/10985028/how-to-remove-border-around-qgraphicsitem-when-selected
|
||||
*
|
||||
* There's no interface to disable the drawing of the selection border for the build-in QGraphicsItems. The only way
|
||||
* I can think of is derive your own items from the build-in ones and override the paint() function:*/
|
||||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
QGraphicsPathItem::paint(painter, &myOption, widget);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief mouseReleaseEvent handle mouse release events.
|
||||
* @param event mouse release event.
|
||||
*/
|
||||
void VSimpleCurve::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
emit Choosed(id);
|
||||
}
|
||||
QGraphicsPathItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief hoverEnterEvent handle hover enter events.
|
||||
* @param event hover move event.
|
||||
*/
|
||||
void VSimpleCurve::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
SetPen(this, currentColor, WidthMainLine(patternUnit));
|
||||
emit HoverPath(id, curvePosition, PathDirection::Show);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief hoverLeaveEvent handle hover leave events.
|
||||
* @param event hover leave event.
|
||||
*/
|
||||
void VSimpleCurve::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
SetPen(this, currentColor, WidthHairLine(patternUnit));
|
||||
emit HoverPath(id, curvePosition, PathDirection::Hide);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
event->ignore();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
QColor VSimpleCurve::GetCurrentColor() const
|
||||
{
|
||||
return currentColor;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VSimpleCurve::SetCurrentColor(const QColor &value)
|
||||
{
|
||||
currentColor = value;
|
||||
SetPen(this, CorrectColor(currentColor), pen().widthF());
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file vsimplecurve.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 17 12, 2013
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentine project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2013-2015 Valentina project
|
||||
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
||||
**
|
||||
** Valentina is free software: you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation, either version 3 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** Valentina is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
||||
**
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef VSIMPLECURVE_H
|
||||
#define VSIMPLECURVE_H
|
||||
|
||||
#include <QGraphicsPathItem>
|
||||
#include "../vgeometry/vabstractcurve.h"
|
||||
#include "vabstractsimple.h"
|
||||
|
||||
enum class SimpleCurvePoint : char { FirstPoint, ForthPoint };
|
||||
|
||||
/**
|
||||
* @brief The VSimpleSpline class for simple spline. This object used when we cut spline and want show peaces.
|
||||
*/
|
||||
class VSimpleCurve : public VAbstractSimple, public QGraphicsPathItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VSimpleCurve(quint32 id, const QColor ¤tColor, SimpleCurvePoint curvePosition, Unit patternUnit,
|
||||
qreal *factor = nullptr, QObject *parent = 0);
|
||||
virtual void ChangedActivDraw(const bool &flag) Q_DECL_OVERRIDE;
|
||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option,
|
||||
QWidget * widget = 0) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::SimpleSplinePath)};
|
||||
|
||||
QColor GetCurrentColor() const;
|
||||
void SetCurrentColor(const QColor &value);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Choosed send id when clicked.
|
||||
* @param id spline id.
|
||||
*/
|
||||
void Choosed(quint32 id);
|
||||
void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction);
|
||||
protected:
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent * event) Q_DECL_OVERRIDE;
|
||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;
|
||||
private:
|
||||
Q_DISABLE_COPY(VSimpleCurve)
|
||||
|
||||
|
||||
SimpleCurvePoint curvePosition;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // VSIMPLECURVE_H
|
|
@ -4,7 +4,6 @@
|
|||
SOURCES += \
|
||||
$$PWD/vmaingraphicsscene.cpp \
|
||||
$$PWD/vmaingraphicsview.cpp \
|
||||
$$PWD/vsimplecurve.cpp \
|
||||
$$PWD/vwidgetpopup.cpp \
|
||||
$$PWD/vcontrolpointspline.cpp \
|
||||
$$PWD/vgraphicssimpletextitem.cpp \
|
||||
|
@ -17,7 +16,6 @@ HEADERS += \
|
|||
$$PWD/stable.h \
|
||||
$$PWD/vmaingraphicsscene.h \
|
||||
$$PWD/vmaingraphicsview.h \
|
||||
$$PWD/vsimplecurve.h \
|
||||
$$PWD/vwidgetpopup.h \
|
||||
$$PWD/vcontrolpointspline.h \
|
||||
$$PWD/vgraphicssimpletextitem.h \
|
||||
|
|
Loading…
Reference in New Issue
Block a user