|
|
|
|
#include <QPainter>
|
|
|
|
|
|
|
|
|
|
//#include "ZxBaseUtil.h"
|
|
|
|
|
|
|
|
|
|
#include "nmObjPoint.h"
|
|
|
|
|
#include "nmObjPointTool.h"
|
|
|
|
|
|
|
|
|
|
nmObjPointTool::nmObjPointTool() : nmObjToolBase()
|
|
|
|
|
{
|
|
|
|
|
setText(tr("nObjPointTool"));
|
|
|
|
|
m_oNot = NOT_Point;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmObjPointTool::onLeftDown(const QPointF& pt)
|
|
|
|
|
{
|
|
|
|
|
if (NULL == m_pObj) { //绘图对象尚未创建
|
|
|
|
|
m_ptStart = pt;
|
|
|
|
|
m_bTracking = true;
|
|
|
|
|
return true;
|
|
|
|
|
} else { //业已绑定绘图对象
|
|
|
|
|
if (nmObjToolBase::onLeftDown(pt)) {
|
|
|
|
|
m_ptStart = pt;
|
|
|
|
|
m_bTracking = true;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmObjPointTool::onMouseMove(const QPointF& pt)
|
|
|
|
|
{
|
|
|
|
|
if (NULL == m_pObj) { //绘图对象尚未创建
|
|
|
|
|
m_ptMove = pt;
|
|
|
|
|
|
|
|
|
|
if (m_bTracking) {
|
|
|
|
|
m_rtTracker = getView()->adjustRectFitViewAspect(getTrackRect());
|
|
|
|
|
updateLastMoveArea(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
} else { //业已绑定绘图对象
|
|
|
|
|
return nmObjToolBase::onMouseMove(pt);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmObjPointTool::onLeftUp(const QPointF& pt)
|
|
|
|
|
{
|
|
|
|
|
if (NULL == m_pObj) {
|
|
|
|
|
getView()->setSnapshotMode(false);
|
|
|
|
|
|
|
|
|
|
if (m_bTracking) {
|
|
|
|
|
m_bTracking = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVector<QPointF> vec;
|
|
|
|
|
vec << pt;
|
|
|
|
|
emit sigPtsFinished(vec);
|
|
|
|
|
return true;
|
|
|
|
|
} else { //业已绑定绘图对象
|
|
|
|
|
return nmObjToolBase::onLeftUp(pt);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmObjPointTool::onLeftDoubleClick(const QPointF& pt)
|
|
|
|
|
{
|
|
|
|
|
return nmObjToolBase::onLeftDoubleClick(pt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool nmObjPointTool::onMouseWheel(const QPointF& pt, int delta)
|
|
|
|
|
{
|
|
|
|
|
return nmObjToolBase::onMouseWheel(pt, delta);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nmObjPointTool::onPaint(QPainter* painter, const ZxPaintParam& param)
|
|
|
|
|
{
|
|
|
|
|
nmObjPoint* pObj = dynamic_cast<nmObjPoint*>(m_pObj);
|
|
|
|
|
|
|
|
|
|
if (pObj == NULL) {
|
|
|
|
|
painter->save();
|
|
|
|
|
QPointF pt1 = getCurrentPos();
|
|
|
|
|
double r = 1.5f;
|
|
|
|
|
int nStyle = 3;
|
|
|
|
|
bool bFilling = true;
|
|
|
|
|
QColor clr = QColor(0, 255, 0);
|
|
|
|
|
ZxDrawHelper::drawPoint(painter, pt1, nStyle,
|
|
|
|
|
r, bFilling, clr);
|
|
|
|
|
Qt::CursorShape o = Qt::CrossCursor;
|
|
|
|
|
changeCursor(o);
|
|
|
|
|
painter->restore();
|
|
|
|
|
} else {
|
|
|
|
|
if (m_bTracking) {
|
|
|
|
|
if (m_oHitOption == OHO_Point) {
|
|
|
|
|
painter->save();
|
|
|
|
|
QPointF pt1 = getCurrentPos();
|
|
|
|
|
double r = pObj->getDotRadius();
|
|
|
|
|
int nStyle = pObj->getDotStyle();
|
|
|
|
|
bool bFilling = pObj->getDotFilling();
|
|
|
|
|
QColor clr = pObj->getDotColor();
|
|
|
|
|
ZxDrawHelper::drawPoint(painter, pt1, nStyle,
|
|
|
|
|
r, !bFilling, clr);
|
|
|
|
|
Qt::CursorShape o = getCursorBy((int)m_oHitOption, pObj->m_nHitIndex);
|
|
|
|
|
changeCursor(o);
|
|
|
|
|
painter->restore();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Qt::CursorShape nmObjPointTool::getCursorBy(const int& nOption, \
|
|
|
|
|
const int& nSubIndex)
|
|
|
|
|
{
|
|
|
|
|
if (nOption < 0) {
|
|
|
|
|
return Qt::ArrowCursor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ObjHitOption oHitOption = (ObjHitOption)nOption;
|
|
|
|
|
|
|
|
|
|
if (oHitOption == OHO_Point) {
|
|
|
|
|
return (Qt::SizeAllCursor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Qt::ArrowCursor;
|
|
|
|
|
}
|