68 lines
1.6 KiB
C++
68 lines
1.6 KiB
C++
/**
|
||
*\file baseSelector.h
|
||
*
|
||
*\brief selector是用来实现图元具体操作的行为类,例如创建、编辑、旋转、移动等
|
||
*
|
||
*\author dsc
|
||
*/
|
||
|
||
#ifndef BASESELECTOR_H
|
||
#define BASESELECTOR_H
|
||
|
||
#include <QObject>
|
||
#include "designerScene.h"
|
||
|
||
enum SelectorType
|
||
{
|
||
ST_base = 0, //基本
|
||
ST_cerating, //创建
|
||
ST_editing, //顶点编辑
|
||
ST_scaling, //缩放
|
||
ST_rotating, //旋转
|
||
};
|
||
|
||
enum OperationMode
|
||
{
|
||
OM_none = 0,
|
||
OM_move, //移动
|
||
OM_create, //创建
|
||
OM_edit, //顶点编辑
|
||
OM_scale, //缩放
|
||
OM_rotate, //旋转
|
||
};
|
||
|
||
class BaseSelector : public QObject
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
explicit BaseSelector(QObject *parent = 0);
|
||
virtual ~BaseSelector();
|
||
|
||
public:
|
||
virtual void mousePressEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
|
||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
|
||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*, DesignerScene*);
|
||
|
||
SelectorType getSelectorType() { return m_type; }
|
||
//void setOperationMode(OperationMode m) { m_opMode = m; }
|
||
OperationMode getOperationMode() { return ms_opMode; }
|
||
|
||
void setCursor(DesignerScene*, const QCursor&);
|
||
|
||
signals:
|
||
void setWorkingSelector(SelectorType);
|
||
|
||
protected:
|
||
//静态变量,用于不同类型对象间的成员共享
|
||
static OperationMode ms_opMode;
|
||
static QPointF ms_ptMouseDown;
|
||
static QPointF ms_ptMouseLast;
|
||
static int ms_nDragHandle; //当前抓取的控制点
|
||
|
||
SelectorType m_type;
|
||
bool m_bHoverOnHandel; //鼠标是否悬停在handel
|
||
};
|
||
|
||
#endif
|