Refactoring.
--HG-- branch : develop
This commit is contained in:
parent
a33ab27909
commit
b72f5511b4
|
@ -41,7 +41,7 @@ class QString;
|
||||||
#define DefPointRadius 2.0//mm
|
#define DefPointRadius 2.0//mm
|
||||||
#define NULL_ID 0//use this value for initialization variables that keeps id values. 0 mean uknown id value.
|
#define NULL_ID 0//use this value for initialization variables that keeps id values. 0 mean uknown id value.
|
||||||
|
|
||||||
enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail };
|
enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Unknown };
|
||||||
enum class Tool : char
|
enum class Tool : char
|
||||||
{
|
{
|
||||||
ArrowTool,
|
ArrowTool,
|
||||||
|
|
|
@ -33,7 +33,8 @@ const QString VAbstractSpline::TagName = QStringLiteral("spline");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VAbstractSpline::VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent)
|
VAbstractSpline::VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent)
|
||||||
:VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector<VControlPointSpline *>())
|
:VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector<VControlPointSpline *>()),
|
||||||
|
sceneType(SceneObject::Unknown)
|
||||||
{
|
{
|
||||||
ignoreFullUpdate = true;
|
ignoreFullUpdate = true;
|
||||||
}
|
}
|
||||||
|
@ -183,6 +184,20 @@ void VAbstractSpline::keyReleaseEvent(QKeyEvent *event)
|
||||||
QGraphicsItem::keyReleaseEvent ( event );
|
QGraphicsItem::keyReleaseEvent ( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* @brief mouseReleaseEvent handle mouse release events.
|
||||||
|
* @param event mouse release event.
|
||||||
|
*/
|
||||||
|
void VAbstractSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (event->button() == Qt::LeftButton)
|
||||||
|
{
|
||||||
|
emit ChoosedTool(id, sceneType);
|
||||||
|
}
|
||||||
|
QGraphicsItem::mouseReleaseEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QPainterPath VAbstractSpline::ToolPath(PathDirection direction) const
|
QPainterPath VAbstractSpline::ToolPath(PathDirection direction) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,6 +63,7 @@ protected:
|
||||||
* @brief controlPoints list pointers of control points.
|
* @brief controlPoints list pointers of control points.
|
||||||
*/
|
*/
|
||||||
QVector<VControlPointSpline *> controlPoints;
|
QVector<VControlPointSpline *> controlPoints;
|
||||||
|
SceneObject sceneType;
|
||||||
/**
|
/**
|
||||||
* @brief RefreshGeometry refresh item on scene.
|
* @brief RefreshGeometry refresh item on scene.
|
||||||
*/
|
*/
|
||||||
|
@ -74,6 +75,7 @@ protected:
|
||||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
|
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
|
||||||
virtual void keyReleaseEvent(QKeyEvent * event);
|
virtual void keyReleaseEvent(QKeyEvent * event);
|
||||||
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
QPainterPath ToolPath(PathDirection direction = PathDirection::Hide) const;
|
QPainterPath ToolPath(PathDirection direction = PathDirection::Hide) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,8 @@ const QString VToolArc::ToolType = QStringLiteral("simple");
|
||||||
VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem *parent)
|
VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem *parent)
|
||||||
:VAbstractSpline(doc, data, id, parent)
|
:VAbstractSpline(doc, data, id, parent)
|
||||||
{
|
{
|
||||||
|
sceneType = SceneObject::Arc;
|
||||||
|
|
||||||
this->setPath(ToolPath());
|
this->setPath(ToolPath());
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
|
@ -217,20 +219,6 @@ void VToolArc::RefreshDataInFile()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief mouseReleaseEvent handle mouse release events.
|
|
||||||
* @param event mouse release event.
|
|
||||||
*/
|
|
||||||
void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|
||||||
{
|
|
||||||
if (event->button() == Qt::LeftButton)
|
|
||||||
{
|
|
||||||
emit ChoosedTool(id, SceneObject::Arc);
|
|
||||||
}
|
|
||||||
QGraphicsItem::mouseReleaseEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief RemoveReferens decrement value of reference.
|
* @brief RemoveReferens decrement value of reference.
|
||||||
|
|
|
@ -52,7 +52,6 @@ protected:
|
||||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
virtual void AddToFile();
|
virtual void AddToFile();
|
||||||
virtual void RefreshDataInFile();
|
virtual void RefreshDataInFile();
|
||||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
|
||||||
virtual void RemoveReferens();
|
virtual void RemoveReferens();
|
||||||
virtual void SaveDialog(QDomElement &domElement);
|
virtual void SaveDialog(QDomElement &domElement);
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -46,6 +46,8 @@ VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Sour
|
||||||
QGraphicsItem *parent)
|
QGraphicsItem *parent)
|
||||||
:VAbstractSpline(doc, data, id, parent)
|
:VAbstractSpline(doc, data, id, parent)
|
||||||
{
|
{
|
||||||
|
sceneType = SceneObject::Spline;
|
||||||
|
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
this->setFlag(QGraphicsItem::ItemIsFocusable, true);
|
||||||
|
@ -255,20 +257,6 @@ void VToolSpline::RefreshDataInFile()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief mouseReleaseEvent handle mouse release events.
|
|
||||||
* @param event context menu event.
|
|
||||||
*/
|
|
||||||
void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|
||||||
{
|
|
||||||
if (event->button() == Qt::LeftButton)
|
|
||||||
{
|
|
||||||
emit ChoosedTool(id, SceneObject::Spline);
|
|
||||||
}
|
|
||||||
QGraphicsItem::mouseReleaseEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief RemoveReferens decrement value of reference.
|
* @brief RemoveReferens decrement value of reference.
|
||||||
|
|
|
@ -55,7 +55,6 @@ protected:
|
||||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
virtual void AddToFile ();
|
virtual void AddToFile ();
|
||||||
virtual void RefreshDataInFile();
|
virtual void RefreshDataInFile();
|
||||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
|
||||||
virtual void RemoveReferens();
|
virtual void RemoveReferens();
|
||||||
virtual void SaveDialog(QDomElement &domElement);
|
virtual void SaveDialog(QDomElement &domElement);
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -45,6 +45,8 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co
|
||||||
QGraphicsItem *parent)
|
QGraphicsItem *parent)
|
||||||
:VAbstractSpline(doc, data, id, parent)
|
:VAbstractSpline(doc, data, id, parent)
|
||||||
{
|
{
|
||||||
|
sceneType = SceneObject::SplinePath;
|
||||||
|
|
||||||
this->setPath(ToolPath());
|
this->setPath(ToolPath());
|
||||||
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor));
|
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor));
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
|
@ -321,20 +323,6 @@ void VToolSplinePath::AddPathPoint(QDomElement &domElement, const VSplinePoint &
|
||||||
domElement.appendChild(pathPoint);
|
domElement.appendChild(pathPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief mouseReleaseEvent handle mouse release events.
|
|
||||||
* @param event mouse release event.
|
|
||||||
*/
|
|
||||||
void VToolSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|
||||||
{
|
|
||||||
if (event->button() == Qt::LeftButton)
|
|
||||||
{
|
|
||||||
emit ChoosedTool(id, SceneObject::SplinePath);
|
|
||||||
}
|
|
||||||
QGraphicsItem::mouseReleaseEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief RemoveReferens decrement value of reference.
|
* @brief RemoveReferens decrement value of reference.
|
||||||
|
|
|
@ -69,7 +69,6 @@ protected:
|
||||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
virtual void AddToFile();
|
virtual void AddToFile();
|
||||||
virtual void RefreshDataInFile();
|
virtual void RefreshDataInFile();
|
||||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
|
||||||
virtual void RemoveReferens();
|
virtual void RemoveReferens();
|
||||||
virtual void SaveDialog(QDomElement &domElement);
|
virtual void SaveDialog(QDomElement &domElement);
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user