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.
nmWTAI-Platform/Src/nmNum/nmPlot/nmPlotDataAnalyzeController...

71 lines
1.8 KiB
C++

#include "nmPlotDataAnalyzeController.h"
#include "ZxPlot.h"
#include "nmDataAnalyzeManager.h"
#include "nmDataPlotContext.h"
#include "nmGuiPlot.h"
namespace {
// 将数据层保存的绘图指针还原为绘图层接口指针
nmGuiPlot* toPlot(void* pPlot)
{
return static_cast<nmGuiPlot*>(pPlot);
}
// nmPlot模块加载时注册绘图上下文提供者
struct nmPlotDataAnalyzeControllerRegistrar {
nmPlotDataAnalyzeControllerRegistrar()
{
nmDataPlotContext::setProvider(nmPlotDataAnalyzeController::instance());
}
};
nmPlotDataAnalyzeControllerRegistrar s_registrar;
}
// 获取绘图层上下文控制器单例
nmPlotDataAnalyzeController* nmPlotDataAnalyzeController::instance()
{
static nmPlotDataAnalyzeController s_controller;
return &s_controller;
}
// 按井数据移除对应井图元
bool nmPlotDataAnalyzeController::removeWellPlotByData(void* pPlot, nmDataWellBase* pWellData)
{
nmGuiPlot* pNmGuiPlot = toPlot(pPlot);
if(pNmGuiPlot == nullptr) {
return false;
}
pNmGuiPlot->removeWellPlotByData(pWellData);
return true;
}
// 根据数据管理器刷新井图元
bool nmPlotDataAnalyzeController::updateWellPlots(void* pPlot, nmDataAnalyzeManager* pDataManager)
{
nmGuiPlot* pNmGuiPlot = toPlot(pPlot);
if(pNmGuiPlot == nullptr || pDataManager == nullptr) {
return false;
}
pNmGuiPlot->removeAllWellPlot();
pNmGuiPlot->initWellObjsFromData(pDataManager);
return true;
}
// 将数值坐标转换为绘图坐标
bool nmPlotDataAnalyzeController::getPosForValue(void* pPlot, QVector<QPointF>& vecValues, QVector<QPointF>& vecPos)
{
nmGuiPlot* pNmGuiPlot = toPlot(pPlot);
if(pNmGuiPlot == nullptr || pNmGuiPlot->m_pPlot == nullptr) {
return false;
}
vecPos = pNmGuiPlot->m_pPlot->getPosForValue(vecValues);
return true;
}