#include "stdafx.h" #include "SigmaView.h" #include "ItemSelect.h" #pragma pack(1) struct ViewFactor { double offsetX; double offsetY; double zoomFactor; }; #pragma pack() extern "C" __declspec(dllexport) void SetScrollBar(CSigmaView* pView, int& hMax, int& vMax, int& hPage, int& vPage, int& hPos, int& vPos) { pView->SetScrollBar(hMax, vMax, hPage, vPage, hPos, vPos); } extern "C" __declspec(dllexport) void HScroll(CSigmaView* pView, int nSBCode, int nPos, int nScrollMax) { pView->OnHScroll(nSBCode, nPos, nScrollMax); } extern "C" __declspec(dllexport) void Scroll(CSigmaView* pView, int orientation, double offset) { pView->Scroll(orientation, offset); } extern "C" __declspec(dllexport) void ViewEnlarge(CSigmaView* pView) { pView->OnViewEnlarge(); } extern "C" __declspec(dllexport) void ViewEnlargeByMousePoint(CSigmaView * pView, int mouseX, int mouseY) { pView->OnViewEnlargeByMousePoint(mouseX, mouseY); } extern "C" __declspec(dllexport) void ViewReduceByMousePoint(CSigmaView * pView, int mouseX, int mouseY) { pView->ViewReduceByMousePoint(mouseX, mouseY); } extern "C" __declspec(dllexport) void ViewReduce(CSigmaView* pView) { pView->OnViewReduce(); } extern "C" __declspec(dllexport) void ViewReduceWithFactor(CSigmaView* pView, double factor) { pView->OnViewReduce(factor); } extern "C" __declspec(dllexport) void ViewReduceForScreenPoint(CSigmaView* pView) { pView->ReduceForScreenPoint(); } extern "C" __declspec(dllexport) void OffsetViewportOrigion(CSigmaView* pView, int x, int y) { pView->OffsetViewportOrg(x, y); } extern "C" __declspec(dllexport) void ViewExtend(CSigmaView* pView) { pView->OnViewExtend(); } extern "C" __declspec(dllexport) void Extend(CSigmaView* pView, double locationX,double locationY, double width, double height, int mode) { pView->Extend(locationX, locationY, width, height, mode); } //kind 视图操作的类型 0--无效值 1--平移 2--窗口放大 extern "C" __declspec(dllexport) void SetViewOperationKind(CSigmaView* pView, int kind) { if (kind == 1) { pView->SetViewPan(); } else if (kind == 2) { pView->SetViewWindow(); } } extern "C" __declspec(dllexport) void ViewPanTo(CSigmaView* pView, int mouseX, int mouseY) { pView->PanTo(mouseX, mouseY); } extern "C" __declspec(dllexport) void SetViewWindow(CSigmaView* pView) { pView->SetViewWindow(); } extern "C" __declspec(dllexport) int GetViewFactors(CSigmaView * pView, ViewFactor * factorsOut) { if (pView == 0) return -1; if (pView->m_pDoc == 0) return -1; CItemView * item = pView->m_pDoc->GetItemView(); if (item == 0) return -1; item->GetViewFactors(factorsOut->offsetX, factorsOut->offsetY, factorsOut->zoomFactor); return 1; } extern "C" __declspec(dllexport) int SetViewScreenFactors(CSigmaView * pView, double offsetX, double offsetY, double zoomFactor) { if (pView == 0 || pView->m_pDoc == 0) return -1; CItemView * item = pView->m_pDoc->GetItemView(); if (item == 0) return -1; item->SetViewScreenFactors(offsetX, offsetY, zoomFactor); return 1; } extern "C" __declspec(dllexport) int SetViewFactors(CSigmaView * pView, double offsetXIn, double offsetYIn, double zoomFactorIn) { if (pView == 0) return -1; if (pView->m_pDoc == 0) return -1; CItemView * item = pView->m_pDoc->GetItemView(); if (item == 0) return -1; item->SetViewFactors(offsetXIn, offsetYIn, zoomFactorIn); return 1; } extern "C" __declspec(dllexport) int GetDrawingWithAndHeightInScreen(CSigmaView * pView, int * widthOut, int * heightOut) { *widthOut = 0; *heightOut = 0; if (pView == 0) return -1; if (pView->m_pDoc == 0) return -1; pView->m_pDoc->GetDrawingWithAndHeightInScreen(*widthOut, *heightOut); return 1; } extern "C" __declspec(dllexport) int FillScreenByStrech(CSigmaView * pView) { if (pView == 0) return -1; pView->FillScreenByStrech(); return 1; } extern "C" __declspec(dllexport) int FillScreenToCenter(CSigmaView * pView) { if (pView == 0) return -1; pView->FillScreenToCenter(); return 1; } extern "C" __declspec(dllexport) int ToCenterAndFixScale(CSigmaView * pView) { if (pView == 0) return -1; pView->ToCenterAndFixScale(); return 1; } extern "C" __declspec(dllexport) void SetZoomMode(CSigmaView* pView,int zoomMode) { pView->SetZoomMode(zoomMode); } /** * 获取当前图件显示区域 * * \param left 指定矩形左上角的 x 坐标 * \param top 指定矩形左上角的 y 坐标 * \param right 指定矩形右下角的 x 坐标 * \param bottom 指定矩形右下角的 y 坐标 */ extern "C" __declspec(dllexport) void GetRealViewRect(CSigmaView *pView, double &left, double &top, double &right, double &bottom) { CXyDC& xyDC = pView->m_pDoc->GetDC(); CRect8 realRect = xyDC.GetReal(xyDC.GetViewRect()); realRect.NormalizeRect(); left = realRect.left; top = realRect.top; right = realRect.right; bottom = realRect.bottom; } extern "C" __declspec(dllexport) void GetViewStatus(CSigmaView * pView, double &left, double & top, double& scaleX, double& scaleY) { CXyDC& xyDC = pView->m_pDoc->GetDC(); CRect8 realRect = xyDC.GetReal(xyDC.GetViewRect()); realRect.NormalizeRect(); left = realRect.left; top = realRect.top; xyDC.GetScale(scaleX, scaleY); } extern "C" __declspec(dllexport) void SetViewStatus(CSigmaView * pView, double left, double top, double scaleX, double scaleY) { CXyDC& xyDC = pView->m_pDoc->GetDC(); xyDC.SetScale(scaleX, scaleY); CRect8 realRect = xyDC.GetReal(xyDC.GetViewRect()); xyDC.OffsetRect(left - realRect.left, top - realRect.top); CSigmaDoc* pDoc = pView->m_pDoc; CItemSelect* pItemSelect = pDoc->GetSelectItem(); if (pItemSelect!=nullptr) { pItemSelect->ReloadTrackerPath(); } } /** * 设置当前图件显示区域 * * \param pView * \param left 指定矩形左上角的 x 坐标 * \param top 指定矩形左上角的 y 坐标 * \param right 指定矩形右下角的 x 坐标 * \param bottom 指定矩形右下角的 y 坐标 */ extern "C" __declspec(dllexport) void SetRealViewRect(CSigmaView *pView, double left, double top, double right, double bottom) { CXyDC& xyDC = pView->m_pDoc->GetDC(); CRect8 realRect{ left, top, right, bottom }; realRect.NormalizeRect(); pView->m_pDoc->GetDC().Extend(realRect, 0); } /** * 获取当前缩放比 * * \param pView * \param scaleX 水平缩放比 * \param scaleY 垂直缩放比 */ extern "C" __declspec(dllexport) void GetScaleSize(CSigmaView* pView, double& scaleX, double& scaleY) { pView->m_pDoc->GetDC().GetScale(scaleX, scaleY); } /** * 设置显示 z 值时只留几位小数 * \param pView * \param precision */ extern "C" __declspec(dllexport) void SetViewPrecision(CSigmaView* pView, int precision) { AfxGetPublicFunction()->SetDisplayPrecision(precision); } /** * 设置当前缩放比 * * \param pView * \param scaleX 水平缩放比 * \param scaleY 垂直缩放比 */ extern "C" __declspec(dllexport) void SetScaleSize(CSigmaView* pView, double scaleX, double scaleY) { pView->m_pDoc->GetDC().SetScale(scaleX, scaleY); }