Refactoring VToolArc.
--HG-- branch : develop
This commit is contained in:
parent
29b36745fe
commit
9aaf90bf5b
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
#include "configdialog.h"
|
#include "configdialog.h"
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QtWidgets>
|
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "widgets/vapplication.h"
|
#include "widgets/vapplication.h"
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QtCore>
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include "tablewindow.h"
|
#include "tablewindow.h"
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
#include "widgets/undoevent.h"
|
#include "widgets/undoevent.h"
|
||||||
|
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QtCore>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QShowEvent>
|
#include <QShowEvent>
|
||||||
|
|
|
@ -44,9 +44,8 @@ const QString VToolArc::ToolType = QStringLiteral("simple");
|
||||||
* @param typeCreation way we create this tool.
|
* @param typeCreation way we create this tool.
|
||||||
* @param parent parent object
|
* @param parent parent object
|
||||||
*/
|
*/
|
||||||
VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation,
|
VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem *parent)
|
||||||
QGraphicsItem *parent)
|
:VAbstractSpline(doc, data, id, parent)
|
||||||
:VDrawTool(doc, data, id), QGraphicsPathItem(parent)
|
|
||||||
{
|
{
|
||||||
const VArc *arc = data->GeometricObject<const VArc *>(id);
|
const VArc *arc = data->GeometricObject<const VArc *>(id);
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
|
@ -174,59 +173,6 @@ void VToolArc::FullUpdateFromFile()
|
||||||
RefreshGeometry();
|
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.
|
* @brief contextMenuEvent handle context menu events.
|
||||||
|
@ -287,30 +233,6 @@ void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
QGraphicsItem::mouseReleaseEvent(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.
|
* @brief RemoveReferens decrement value of reference.
|
||||||
|
@ -321,49 +243,6 @@ void VToolArc::RemoveReferens()
|
||||||
doc->DecrementReferens(arc->GetCenter().id());
|
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.
|
* @brief SaveDialog save options into file after change in dialog.
|
||||||
|
|
|
@ -29,14 +29,12 @@
|
||||||
#ifndef VTOOLARC_H
|
#ifndef VTOOLARC_H
|
||||||
#define VTOOLARC_H
|
#define VTOOLARC_H
|
||||||
|
|
||||||
#include "vdrawtool.h"
|
#include "vabstractspline.h"
|
||||||
#include <QGraphicsPathItem>
|
|
||||||
#include "../../widgets/vcontrolpointspline.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The VToolArc class tool for creation arc.
|
* @brief The VToolArc class tool for creation arc.
|
||||||
*/
|
*/
|
||||||
class VToolArc :public VDrawTool, public QGraphicsPathItem
|
class VToolArc :public VAbstractSpline
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -50,20 +48,12 @@ public:
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void FullUpdateFromFile();
|
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:
|
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 mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
|
||||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
|
||||||
virtual void RemoveReferens();
|
virtual void RemoveReferens();
|
||||||
virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
|
|
||||||
virtual void keyReleaseEvent(QKeyEvent * event);
|
|
||||||
virtual void SaveDialog(QDomElement &domElement);
|
virtual void SaveDialog(QDomElement &domElement);
|
||||||
private:
|
private:
|
||||||
void RefreshGeometry();
|
void RefreshGeometry();
|
||||||
|
|
|
@ -205,12 +205,6 @@ void VToolSpline::ControlPointChangePosition(const qint32 &indexSpline, const Sp
|
||||||
qApp->getUndoStack()->push(moveSpl);
|
qApp->getUndoStack()->push(moveSpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VToolSpline::Disable(bool disable)
|
|
||||||
{
|
|
||||||
DisableItem(this, disable);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief contextMenuEvent handle context menu events.
|
* @brief contextMenuEvent handle context menu events.
|
||||||
|
|
|
@ -51,7 +51,6 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void ControlPointChangePosition (const qint32 &indexSpline, const SplinePointPosition &position,
|
void ControlPointChangePosition (const qint32 &indexSpline, const SplinePointPosition &position,
|
||||||
const QPointF &pos);
|
const QPointF &pos);
|
||||||
void Disable(bool disable);
|
|
||||||
protected:
|
protected:
|
||||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
virtual void AddToFile ();
|
virtual void AddToFile ();
|
||||||
|
|
|
@ -187,12 +187,6 @@ void VToolSplinePath::ControlPointChangePosition(const qint32 &indexSpline, cons
|
||||||
qApp->getUndoStack()->push(moveSplPath);
|
qApp->getUndoStack()->push(moveSplPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
void VToolSplinePath::Disable(bool disable)
|
|
||||||
{
|
|
||||||
DisableItem(this, disable);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief UpdateControlPoints update position points control points in file.
|
* @brief UpdateControlPoints update position points control points in file.
|
||||||
|
|
|
@ -65,7 +65,6 @@ public slots:
|
||||||
|
|
||||||
void ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
|
void ControlPointChangePosition(const qint32 &indexSpline, const SplinePointPosition &position,
|
||||||
const QPointF &pos);
|
const QPointF &pos);
|
||||||
void Disable(bool disable);
|
|
||||||
protected:
|
protected:
|
||||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||||
virtual void AddToFile();
|
virtual void AddToFile();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user