#include "nmPlotDataAnalyzeController.h" #include "ZxPlot.h" #include "nmDataAnalyzeManager.h" #include "nmDataPlotContext.h" #include "nmGuiPlot.h" namespace { // 将数据层保存的绘图指针还原为绘图层接口指针 nmGuiPlot* toPlot(void* pPlot) { return static_cast(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& vecValues, QVector& vecPos) { nmGuiPlot* pNmGuiPlot = toPlot(pPlot); if(pNmGuiPlot == nullptr || pNmGuiPlot->m_pPlot == nullptr) { return false; } vecPos = pNmGuiPlot->m_pPlot->getPosForValue(vecValues); return true; }