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.
245 lines
6.9 KiB
C++
245 lines
6.9 KiB
C++
#pragma once
|
|
#include "SigmaDoc.h"
|
|
#include "ImageCut.h"
|
|
#include "FileTransformer.h"
|
|
#include "DrawOperator/expected.hpp"
|
|
#include "ListenerManager.h"
|
|
|
|
//namespace NDraw
|
|
//{
|
|
namespace NItem
|
|
{
|
|
class CItemBkGrid;
|
|
}
|
|
|
|
typedef void(__stdcall* Listener)(BSTR);
|
|
|
|
class CrossLine;
|
|
class CSigmaView
|
|
{
|
|
public:
|
|
CSigmaView();
|
|
CSigmaView(CXy* pXy);
|
|
void Initialize();
|
|
~CSigmaView();
|
|
public:
|
|
CRect m_client;
|
|
CSigmaDoc* m_pDoc;
|
|
CDC* m_pDC;
|
|
|
|
CDC* m_pImgDC;
|
|
|
|
COLORREF mBackColor;
|
|
double GridStepX;
|
|
double GridStepY;
|
|
|
|
protected:
|
|
HWND m_HWND;
|
|
CDC* m_pDrawDC;
|
|
int m_viewportOffsetX; //视口原点偏移值
|
|
int m_viewportOffsetY; //视口原点偏移值
|
|
int m_topPageMargin;
|
|
int m_bottomPageMargin;
|
|
int m_leftPageMargin;
|
|
int m_rightPageMargin;
|
|
bool m_bShowBKGrid;
|
|
POSITION m_moveSelect;
|
|
wchar_t m_tipMessageBuffer[1024];
|
|
CItemBkGrid* m_pItemBkGrid;
|
|
//bool m_bEnableCrossLine;
|
|
bool m_bScroll;
|
|
CPoint m_oldPtForDrawCrossLine; //用于画十字线
|
|
bool m_bFirstForDrawCrossLine; //是否是第一次画十字线
|
|
std::unique_ptr<ImageCut> m_imageCut;
|
|
std::unique_ptr<FileTransformer> m_pFileTransformer;
|
|
HANDLE m_imgageCutHandle; //批量切图线程句柄
|
|
HANDLE m_transformerHandle; //批量文件格式转换线程句柄
|
|
BOOL m_bEnableMeshPackage = FALSE;
|
|
|
|
BOOL m_bSymbolView = FALSE;
|
|
|
|
CPoint m_lastRightButtonXY;
|
|
bool m_bEnableRotate;
|
|
|
|
std::unique_ptr<CMemoryDC> m_pMemViewDC;
|
|
CDC* m_pScreenDC;
|
|
Listener m_listener = nullptr;
|
|
ListenerManager<> m_viewChangedListenerManager;
|
|
public:
|
|
virtual bool OnDrawDC(); // 在画布中绘制
|
|
virtual void OnDrawMem(); // 在内存中绘制
|
|
virtual void DrawForPrint();
|
|
virtual void OnDraw(CXyDC& dc);
|
|
virtual bool OnDrawAll(CDC* pDC);
|
|
virtual void OnDrawAllBefore(CXyDC& dc);
|
|
virtual void OnDrawAllAfter(CXyDC& dc);
|
|
virtual void OnDrawOther(CDC* pCdc);
|
|
virtual void SetMapUnit(CSize unit);
|
|
virtual void Clear();
|
|
//void UpdateCrossLine(CDC* pDC, CPoint point);
|
|
//void DrawCrossLine(CDC* pDC, CPoint point);
|
|
//void EnableCrossLine(bool bEnable);
|
|
//bool GetCrossLineEnabledStatus();
|
|
virtual void Scroll(int orientation, double offset);
|
|
void SetTop(double top);
|
|
void SetZoomMode(int zoomMode);
|
|
CRect GetClientRect() {
|
|
return m_client;
|
|
}
|
|
bool CreateMemDC(CRect rect, CDC* pDC);
|
|
CDC* GetMemDC(void) { return m_pMemViewDC.get(); }
|
|
void SetImgDc(CDC* pDC);
|
|
CDC* GetImgDC() {
|
|
return m_pImgDC;
|
|
}
|
|
void SetScreenDC(CDC* pScreenDC);
|
|
CDC* GetScreenDC() { return m_pScreenDC; }
|
|
bool DrawImg(bool symbolViewFlag);
|
|
bool CombinImg(int x, int y, int width, int height, int screenX, int screenY);
|
|
void ShowBKGrid(bool bShow);
|
|
bool HasEnableBKGrid();
|
|
CPoint GetGridPoint(CPoint& pt);
|
|
void SetDc(CDC* pDC);
|
|
CDC* GetDc();
|
|
void SetBackColor(COLORREF color);
|
|
COLORREF GetBackColor();
|
|
void OffsetViewportOrg(int offsetX, int offsetY);
|
|
virtual void SetClient(int l, int t, int r, int b);
|
|
bool OpenFile(LPCTSTR lpszFileName, BOOL bMergeFile);
|
|
bool OpenXy(CXy* pXy, BOOL bMergeFile);
|
|
bool ReloadFile();
|
|
bool CreateNew();
|
|
bool CreateNew(LPCTSTR fileName);
|
|
void InitialView();
|
|
|
|
void SetScrollBar(int& hMax, int& vMax, int& hPage, int& vPage, int& hPos, int& vPos);
|
|
void OnHScroll(UINT nSBCode, UINT nPos, int nScrollMax);
|
|
void OnVScroll(UINT nSBCode, UINT nPos, int nScrollMax);
|
|
|
|
void Extend(double locationX, double locationY, double width, double height, int mode);
|
|
void OnViewExtend();
|
|
void OnViewEnlarge();
|
|
void OnViewEnlargeByMousePoint(int mouseX, int mouseY);
|
|
void OnViewReduce();
|
|
void ReduceForScreenPoint();
|
|
void OnViewReduce(double factor);
|
|
void ViewReduceByMousePoint(int mouseX, int mouseY);
|
|
void FillScreenToCenter();
|
|
void FillScreenByStrech();
|
|
void ToCenterAndFixScale();
|
|
void SetViewPan();
|
|
|
|
//移动到point,以point为中心
|
|
void PanTo(int mouseX, int mouseY);
|
|
void SetViewWindow();
|
|
void ViewMouseDown(UINT nFlags, CPoint point);
|
|
void ViewMouseMove(UINT nFlags, CPoint point);
|
|
void ViewMouseUp(UINT nFlags, CPoint point);
|
|
|
|
void SetItem(int itemType);
|
|
NItem::CItem* GetItem(void);
|
|
void SetHWND(HWND hwnd);
|
|
HWND GetHWND();
|
|
|
|
void ActionAdd(COne* pOne, UINT nUndoID = IDS_STRING_ACTION_ADD);
|
|
void SendRedrawMsg();
|
|
|
|
void SetDrawDC(CDC* cdc);
|
|
CDC* GetDrawDC();
|
|
void GetPageMargin(int* top, int* bottom, int* left, int* right);
|
|
void SetPageMargin(int top, int bottom, int left, int right);
|
|
//鼠标移动时 高亮光标之下的图元 并获得图元的提示信息
|
|
int HighLightGraphItem(int mouseX, int mouseY, CDC* pScreenDC);
|
|
void EndHighLightGraphItem();
|
|
wchar_t* GetTipInfoString();
|
|
//void InitXyDC();
|
|
//fbw
|
|
POSITION GetSelectedOnePosition(int type);
|
|
POSITION GetPositionFind(COne* pOne);
|
|
CPositionList* GetSelection(void);
|
|
//void InitXyDC();
|
|
//fbw
|
|
COne* GetSelectedOne(int type);
|
|
static CLIPFORMAT m_clipboardDraw; // custom clipboard format
|
|
static CLIPFORMAT m_cfObjectDescriptor;
|
|
BOOL OnLButtonUpOther(CDC* pDC, UINT nFlags, CPoint point, int vk = 0);
|
|
void OnProcessZFlag();
|
|
ImageCut* GetImageCut();
|
|
void StopThreadOfImageCut();
|
|
void StartThreadOfImageCut(CutImageInfo* icInfo);
|
|
FileTransformer* GetFileTransformer();
|
|
void StopThreadOfFileTransformer();
|
|
void StartThreadOfFileTransformer(FileTransformationInfo* tfInfo);
|
|
|
|
void EnableMeshPackage(BOOL isEnable, BOOL force = false);
|
|
void SetFaultLayer(LPCTSTR layer);
|
|
CString GetFaultLayer();
|
|
void SetBorderLayer(LPCTSTR layer);
|
|
CString GetBorderLayer();
|
|
void SetFaultLayer3D(LPCTSTR layer);
|
|
CString GetFaultLayer3D();
|
|
void SetBorderLayer3D(LPCTSTR layer);
|
|
CString GetBorderLayer3D();
|
|
void SetWellLayer3D(LPCTSTR layer);
|
|
CString GetWellLayer3D();
|
|
void SetMainMeshLayer3D(LPCTSTR layer);
|
|
CString GetMainMeshLayer3D();
|
|
void SetMainMeshId3D(int64_t id);
|
|
int64_t GetMainMeshId3D();
|
|
void SetSymbolView(BOOL isSymbolView) { this->m_bSymbolView = isSymbolView; }
|
|
|
|
bool GetPointsZRange(double& zMin, double& zMax);
|
|
bool SetPointsColor(CString colorItemsData, double dWidth, double dHeight);
|
|
void SetAntiAlias(bool enable);
|
|
bool GetAntiAlias();
|
|
void SetPrinting(bool isPriting);
|
|
bool GetIsPriting();
|
|
// 是否允许进行变形等操作
|
|
void SetEnableRotate(bool enable);
|
|
|
|
CPoint GetLastRightButtonPoint() const;
|
|
virtual void SetLastRightButtonPoint(const CPoint& point);
|
|
|
|
void RegisterListener(Listener listener);
|
|
|
|
void Notify(const CString& message);
|
|
|
|
ListenerManager<>& GetViewChangedListener();
|
|
|
|
virtual void OnLButtonDown(int mouseX, int mouseY, HDC hdc, int vk); //ggff2025
|
|
virtual void OnLButtonUp(int mouseX, int mouseY, HDC hdc, int vk);
|
|
virtual int OnLButtonDoubleClick(int mouseX, int mouseY);
|
|
virtual int OnMouseMove(HDC hMemDC, int mouseX, int mouseY, int buttonStatus);
|
|
private:
|
|
void DrawElement(POSITION pos);
|
|
void DrawCurve(POSITION pos);
|
|
void FillTipInfo(POSITION pos, CPoint2D pt);
|
|
//void ResetStatusForCrossLine();
|
|
};
|
|
|
|
template <typename T>
|
|
tl::expected<T*, CString>
|
|
TryGetItemCast(CSigmaView* pView)
|
|
{
|
|
if (pView == nullptr)
|
|
{
|
|
return tl::make_unexpected("pView 为 nullptr");
|
|
}
|
|
|
|
CItem* pItem = pView->GetItem();
|
|
if (pItem == nullptr)
|
|
{
|
|
return tl::make_unexpected("pItem 为 nullptr");
|
|
}
|
|
|
|
T* pTarget = dynamic_cast<T*>(pItem);
|
|
if (pTarget == nullptr)
|
|
{
|
|
return tl::make_unexpected("pItem 转换失败");
|
|
}
|
|
|
|
return pTarget;
|
|
}
|
|
|
|
//};
|