You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWATI/Src/nmNum/nmPlot/nmGuiPlotCmdHelper.cpp

80 lines
2.6 KiB
C++

#include "ZxBaseUtil.h"
#include "zxLogInstance.h"
#include "ZxPlot.h"
#include "iGuiPlot.h"
#include "nmObjPointTool.h"
#include "nmObjLineTool.h"
#include "nmObjPolygonTool.h"
#include "nmObjPolygonOutlineTool.h"
#include "nmGuiPlot.h"
#include "nmGuiPlotCmdHelper.h"
nmGuiPlotCmdHelper::nmGuiPlotCmdHelper(iGuiPlot* p)
: iGuiPlotCmdHelper(p)
{
}
nmGuiPlotCmdHelper::~nmGuiPlotCmdHelper()
{
}
bool nmGuiPlotCmdHelper::runAction(QString sAction)
{
Q_ASSERT (NULL != m_pGuiPlot);
ZxPlot* pPlot = m_pGuiPlot->m_pPlot;
Q_ASSERT (NULL != pPlot);
// 鼠标交互,插入数值试井绘图对象 的例子:点、线、多边形
if (_isSame(sAction, "nmInsertObjPoint")) {
nmObjToolBase* pObjTool = new nmObjPointTool();
Q_ASSERT (NULL != pObjTool);
pPlot->appendTools(pObjTool);
connect(pObjTool, SIGNAL(sigPtsFinished(QVector<QPointF>&)), \
this, SLOT(slotObjPtsFinished(QVector<QPointF>&)));
return true;
} else if (_isSame(sAction, "nmInsertObjLine")) {
nmObjToolBase* pObjTool = new nmObjLineTool();
Q_ASSERT (NULL != pObjTool);
pPlot->appendTools(pObjTool);
connect(pObjTool, SIGNAL(sigPtsFinished(QVector<QPointF>&)), \
this, SLOT(slotObjPtsFinished(QVector<QPointF>&)));
return true;
} else if (_isSame(sAction, "nmInsertObjPolygon")) {
nmObjToolBase* pObjTool = new nmObjPolygonTool();
Q_ASSERT (NULL != pObjTool);
pPlot->appendTools(pObjTool);
connect(pObjTool, SIGNAL(sigPtsFinished(QVector<QPointF>&)), \
this, SLOT(slotObjPtsFinished(QVector<QPointF>&)));
return true;
} else if (_isSame(sAction, "nmInsertObjPolygonOutline")) {
nmObjToolBase* pObjTool = new nmObjPolygonOutlineTool();
Q_ASSERT (NULL != pObjTool);
pPlot->appendTools(pObjTool);
connect(pObjTool, SIGNAL(sigPtsFinished(QVector<QPointF>&)), \
this, SLOT(slotObjPtsFinished(QVector<QPointF>&)));
return true;
} else {
// 其它Action
}
return iGuiPlotCmdHelper::runAction(sAction);
}
void nmGuiPlotCmdHelper::slotObjPtsFinished(QVector<QPointF>& vec)
{
nmObjToolBase* pTool = dynamic_cast<nmObjToolBase*>(sender());
if (NULL == pTool) {
return;
}
nmGuiPlot* pWxPlot = dynamic_cast<nmGuiPlot*>(m_pGuiPlot);
if (NULL == pWxPlot) {
return;
}
ZxPlot* pPlot = pWxPlot->m_pPlot;
Q_ASSERT (NULL != pPlot);
pPlot->removeTools(pTool); //移除Tool
QString sName = tr("nmObj");
pWxPlot->appendOneObj(pTool->getNOT(), sName, vec);
}