#include "stdafx.h" #include "SigmaView.h" #include "SectionDoc.h" #include "ItemGrid.h" #include "MxnFormat\AxisLayout.h" using namespace NItem; static CItemEditGrid * GetItemEditGridFromView(CSigmaView * pView) { if (pView == NULL) return 0; CItem * pItem = pView->GetItem(); if (pItem == NULL) return 0; CItemEditGrid * itemGrid = dynamic_cast(pItem); if (itemGrid == NULL) return 0; return itemGrid; } extern "C" __declspec(dllexport) int RectangularCSGrid_GetStepAndRange(CSigmaView * pView, RectangularCSGridData * pData) { CItemEditGrid * pItem = GetItemEditGridFromView(pView); if (pItem == NULL) return -1; return pItem->GetStepAndRange(pData); } extern "C" __declspec(dllexport) int RectangularCSGrid_Create(CSigmaView * pView, RectangularCSGridData * pData, HDC hdcMem) { CItemEditGrid * pItem = GetItemEditGridFromView(pView); if (pItem == NULL) return -1; CDC *pDC = CDC::FromHandle(hdcMem); return pItem->Create(pData, pDC); } extern "C" __declspec(dllexport) int GridGetStepAndRange(double left, double bottom, double right, double top, RectangularCSGridData * pData) { if (pData == NULL) return -1; pData->left = left; pData->top = top; pData->right = right; pData->bottom = bottom; //自动计算步长 CAxisLayout al(left, right, 1); TIntervalStep sx = al.sd; double step = min(sx.step, al.sd.step); pData->stepX = pData->stepY = step; pData->textHeight = step / 40.0; pData->borderThickness = pData->textHeight / 2.0; return 1; }