Refactoring VToolArc.

--HG--
branch : develop
This commit is contained in:
dismine 2014-06-25 12:56:19 +03:00
parent 29b36745fe
commit 9aaf90bf5b
9 changed files with 4 additions and 152 deletions

View File

@ -28,7 +28,6 @@
#include "configdialog.h"
#include <QListWidget>
#include <QtWidgets>
#include <QPushButton>
#include <QHBoxLayout>
#include <QVBoxLayout>

View File

@ -29,7 +29,6 @@
#include "mainwindow.h"
#include "widgets/vapplication.h"
#include <QTextCodec>
#include <QtCore>
#include <QMessageBox>
#include <QThread>
#include "tablewindow.h"

View File

@ -42,7 +42,6 @@
#include "widgets/undoevent.h"
#include <QInputDialog>
#include <QtCore>
#include <QDebug>
#include <QMessageBox>
#include <QShowEvent>

View File

@ -44,9 +44,8 @@ const QString VToolArc::ToolType = QStringLiteral("simple");
* @param typeCreation way we create this tool.
* @param parent parent object
*/
VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
QGraphicsItem *parent)
:VDrawTool(doc, data, id), QGraphicsPathItem(parent)
VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem *parent)
:VAbstractSpline(doc, data, id, parent)
{
const VArc *arc = data->GeometricObject<const VArc *>(id);
QPainterPath path;
@ -174,59 +173,6 @@ void VToolArc::FullUpdateFromFile()
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ChangedActivDraw disable or enable context menu after change active pattern peace.
* @param newName new name active pattern peace.
*/
void VToolArc::ChangedActivDraw(const QString &newName)
{
bool selectable = false;
if (nameActivDraw == newName)
{
selectable = true;
currentColor = Qt::black;
}
else
{
selectable = false;
currentColor = Qt::gray;
}
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, selectable);
this->setAcceptHoverEvents (selectable);
VDrawTool::ChangedActivDraw(newName);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief ShowTool highlight tool.
* @param id object id in container
* @param color highlight color.
* @param enable enable or disable highlight.
*/
void VToolArc::ShowTool(quint32 id, Qt::GlobalColor color, bool enable)
{
ShowItem(this, id, color, enable);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SetFactor set current scale factor of scene.
* @param factor scene scale factor.
*/
void VToolArc::SetFactor(qreal factor)
{
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
//---------------------------------------------------------------------------------------------------------------------
void VToolArc::Disable(bool disable)
{
DisableItem(this, disable);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.
@ -287,30 +233,6 @@ void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
QGraphicsItem::mouseReleaseEvent(event);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverMoveEvent handle hover move events.
* @param event hover move event.
*/
//cppcheck-suppress unusedFunction
void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor));
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief hoverLeaveEvent handle hover leave events.
* @param event hover leave event.
*/
//cppcheck-suppress unusedFunction
void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief RemoveReferens decrement value of reference.
@ -321,49 +243,6 @@ void VToolArc::RemoveReferens()
doc->DecrementReferens(arc->GetCenter().id());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief itemChange handle tool change.
* @param change change.
* @param value value.
* @return value.
*/
QVariant VToolArc::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{
if (change == QGraphicsItem::ItemSelectedChange)
{
if (value == true)
{
// do stuff if selected
this->setFocus();
}
else
{
// do stuff if not selected
}
}
return QGraphicsItem::itemChange(change, value);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief keyReleaseEvent handle key release events.
* @param event key release event.
*/
void VToolArc::keyReleaseEvent(QKeyEvent *event)
{
switch (event->key())
{
case Qt::Key_Delete:
DeleteTool(this);
break;
default:
break;
}
QGraphicsItem::keyReleaseEvent ( event );
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief SaveDialog save options into file after change in dialog.

View File

@ -29,14 +29,12 @@
#ifndef VTOOLARC_H
#define VTOOLARC_H
#include "vdrawtool.h"
#include <QGraphicsPathItem>
#include "../../widgets/vcontrolpointspline.h"
#include "vabstractspline.h"
/**
* @brief The VToolArc class tool for creation arc.
*/
class VToolArc :public VDrawTool, public QGraphicsPathItem
class VToolArc :public VAbstractSpline
{
Q_OBJECT
public:
@ -50,20 +48,12 @@ public:
static const QString ToolType;
public slots:
virtual void FullUpdateFromFile();
virtual void ChangedActivDraw(const QString &newName);
virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable);
virtual void SetFactor(qreal factor);
void Disable(bool disable);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
virtual void RefreshDataInFile();
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
virtual void RemoveReferens();
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void keyReleaseEvent(QKeyEvent * event);
virtual void SaveDialog(QDomElement &domElement);
private:
void RefreshGeometry();

View File

@ -205,12 +205,6 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp
qApp->getUndoStack()->push(moveSpl);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSpline::Disable(bool disable)
{
DisableItem(this, disable);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief contextMenuEvent handle context menu events.

View File

@ -51,7 +51,6 @@ public:
public slots:
void ControlPointChangePosition (const qint32 &indexSpline, const SplinePointPosition &position,
const QPointF &pos);
void Disable(bool disable);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile ();

View File

@ -187,12 +187,6 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons
qApp->getUndoStack()->push(moveSplPath);
}
//---------------------------------------------------------------------------------------------------------------------
void VToolSplinePath::Disable(bool disable)
{
DisableItem(this, disable);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief UpdateControlPoints update position points control points in file.

View File

@ -65,7 +65,6 @@ public slots:
void ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
const QPointF &pos);
void Disable(bool disable);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();