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.

1900 lines
41 KiB
C++

1 month ago
#include "stdafx.h"
#include "SigmaView.h"
#include "Item.h"
#include "SigmaDoc.h"
#include "ItemSelect.h"
#include "ItemBkGrid.h"
#include "PublicParam.h"
#include "DCHelp.h"
#include "ItemMesh.h"
#include "ActionListItem.h"
#include "ActionReplaceColorItem.h"
1 month ago
#include "json.hpp"
#include "Util.h"
1 month ago
static BOOL IsROP2(int type);
wchar_t* AsciiToUnicodeChar(const char* str);
// private clipboard format (list of DFDraw objects) //fbw
CLIPFORMAT CSigmaView::m_clipboardDraw = (CLIPFORMAT)::RegisterClipboardFormat(_T("SSDrawerClipboard"));
CLIPFORMAT CSigmaView::m_cfObjectDescriptor = NULL;
static DWORD CutImageThreadProc(LPVOID lpParam);
static DWORD FileTransformerThreadProc(LPVOID lpParam);
void Test() {
CFileDialog* fDlg = new CFileDialog(
TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"Ƥ<EFBFBD><EFBFBD>(.ski)|*.ski||", NULL);
if (fDlg->DoModal() == IDOK)
{
}
delete fDlg;
}
class CrossLine
{
public:
CrossLine(CPoint& pt, CRect& rt);
void SetPoint(CPoint& pt);
void SetRect(CRect& rt);
void Draw(CDC* pDC);
protected:
CPoint m_pt;
CRect m_rt;
};
CrossLine::CrossLine(CPoint& pt, CRect& rt)
:m_pt(pt),
m_rt(rt)
{
}
void CrossLine::SetPoint(CPoint& pt)
{
m_pt = pt;
}
void CrossLine::SetRect(CRect& rt)
{
m_rt = rt;
}
void CrossLine::Draw(CDC* pDC)
{
pDC->MoveTo(m_pt.x, m_rt.top);
pDC->LineTo(m_pt.x, m_rt.bottom);
pDC->MoveTo(m_rt.left, m_pt.y);
pDC->LineTo(m_rt.right, m_pt.y);
}
CSigmaView::CSigmaView()
: m_pDoc(nullptr)
, m_HWND(NULL)
, m_pDrawDC(NULL)
, m_viewportOffsetX(0)
, m_viewportOffsetY(0)
, m_topPageMargin(0)
, m_bottomPageMargin(0)
, m_leftPageMargin(0)
, m_rightPageMargin(0)
, m_bShowBKGrid(false)
, m_moveSelect(0)
, m_imgageCutHandle(INVALID_HANDLE_VALUE)
, m_transformerHandle(INVALID_HANDLE_VALUE)
, m_bEnableMeshPackage(FALSE)
, mBackColor(RGB(255, 255, 255))
, m_bSymbolView(FALSE)
, m_bEnableRotate(FALSE)
{
Initialize();
//ResetStatusForCrossLine();
1 month ago
m_viewChangedConnection = viewChanged.ConnectScoped([this]
{
CSigmaView::ReloadTrackPath();
});
m_transformChangedConnection = transformChanged.ConnectScoped([this](
UINT nMatrixID,
const Gdiplus::Matrix& matrix,
const CPositionList& positions)
{
OnTransformChanged(nMatrixID, matrix, positions);
});
1 month ago
}
CSigmaView::CSigmaView(CXy* pXy)
:CSigmaView()
{
m_pDoc->m_pXy = pXy;
}
void CSigmaView::Initialize()
{
m_viewportOffsetX = 0;
m_viewportOffsetY = 0;
m_topPageMargin = 0;
m_bottomPageMargin = 0;
m_leftPageMargin = 0;
m_rightPageMargin = 0;
m_rightPageMargin = false;
m_moveSelect = 0;
PARAM().refAll();
m_pMemViewDC = std::make_unique<CMemoryDC>();
m_pDoc = new CSigmaDoc();
m_pDoc->SetView(this);
m_pItemBkGrid = new NItem::CItemBkGrid(m_pDoc);
memset(m_tipMessageBuffer, 0, sizeof(m_tipMessageBuffer));
}
void CSigmaView::EnableMeshPackage(BOOL isEnable, BOOL force)
{
m_bEnableMeshPackage = isEnable;
if (m_pDoc != nullptr)
{
m_pDoc->EnableMeshPackage(isEnable, force);
}
}
void CSigmaView::SetFaultLayer(LPCTSTR layer)
{
if (m_pDoc != nullptr)
{
m_pDoc->SetFaultLayer(layer);
}
}
CString CSigmaView::GetFaultLayer()
{
return m_pDoc->GetFaultLayer();
}
void CSigmaView::SetBorderLayer(LPCTSTR layer)
{
if (m_pDoc != nullptr)
{
m_pDoc->SetBorderLayer(layer);
}
}
CString CSigmaView::GetBorderLayer()
{
return m_pDoc->GetBorderLayer();
}
void CSigmaView::SetFaultLayer3D(LPCTSTR layer)
{
if (m_pDoc != nullptr)
{
m_pDoc->SetFaultLayer3D(layer);
}
}
CString CSigmaView::GetFaultLayer3D()
{
return m_pDoc->GetFaultLayer3D();
}
void CSigmaView::SetBorderLayer3D(LPCTSTR layer)
{
if (m_pDoc != nullptr)
{
m_pDoc->SetBorderLayer3D(layer);
}
}
CString CSigmaView::GetBorderLayer3D()
{
return m_pDoc->GetBorderLayer3D();
}
void CSigmaView::SetWellLayer3D(LPCTSTR layer)
{
if (m_pDoc != nullptr)
{
m_pDoc->SetWellLayer3D(layer);
}
}
CString CSigmaView::GetWellLayer3D()
{
return m_pDoc->GetWellLayer3D();
}
void CSigmaView::SetMainMeshLayer3D(LPCTSTR layer)
{
if (m_pDoc != nullptr)
{
m_pDoc->SetMainMeshLayer3D(layer);
}
}
CString CSigmaView::GetMainMeshLayer3D()
{
return m_pDoc->GetMainMeshLayer3D();
}
void CSigmaView::SetMainMeshId3D(int64_t id)
{
if (m_pDoc != nullptr)
{
m_pDoc->SetMainMeshId3D(id);
}
}
int64_t CSigmaView::GetMainMeshId3D()
{
return m_pDoc->GetMainMeshId3D();
}
CSigmaView::~CSigmaView()
{
Clear();
}
void CSigmaView::Clear()
{
if (m_pDoc != nullptr)
{
delete m_pDoc;
m_pDoc = nullptr;
}
if (m_pDC != nullptr)
{
delete m_pDC;
m_pDC = nullptr;
}
if (m_pDrawDC != nullptr)
{
delete m_pDrawDC;
m_pDrawDC = nullptr;
}
if (m_pItemBkGrid != nullptr)
{
delete m_pItemBkGrid;
}
m_pMemViewDC.reset();
PARAM().unrefAll();
}
//void CSigmaView::UpdateCrossLine(CDC* pDC, CPoint point)
//{
// DrawCrossLine(pDC, m_oldPtForDrawCrossLine);
// //m_oldPtForDrawCrossLine = point;
// DrawCrossLine(pDC, point);
//}
//void CSigmaView::DrawCrossLine(CDC* pDC, CPoint point)
//{
// m_oldPtForDrawCrossLine = point;
// CRect rt = this->GetClientRect();
// int nOldRop = pDC->SetROP2(R2_NOTXORPEN);
// if (!m_oldCrossLine)
// {
// m_oldCrossLine = new CrossLine(point, rt);
// }
// else
// {
// m_oldCrossLine->Draw(pDC); //<2F><><EFBFBD><EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD>Ƶ<EFBFBD>
// m_oldCrossLine->SetPoint(point);
// m_oldCrossLine->SetRect(rt);
// }
//
// pDC->MoveTo(point.x, rt.top);
// pDC->LineTo(point.x, rt.bottom);
// pDC->MoveTo(rt.left, point.y);
// pDC->LineTo(rt.right, point.y);
//
// pDC->SetROP2(nOldRop);
//}
//void CSigmaView::EnableCrossLine(bool bEnable)
//{
// ResetStatusForCrossLine();
// m_bEnableCrossLine = bEnable;
// delete m_oldCrossLine;
// m_oldCrossLine = nullptr;
//}
//
//bool CSigmaView::GetCrossLineEnabledStatus()
//{
// return m_bEnableCrossLine;
//}
void CSigmaView::OnDrawMem()
{
if (!m_pDoc) return;
TRACE(_T("CSigmaView::OnDraw(CDC*)\n"));
if (m_pDoc->m_bRedraw)
{
//ʹ<><CAB9><EFBFBD>ڴ<EFBFBD>DC<44><43>ʾ<EFBFBD><CABE>ʽ
if (CreateMemDC(m_client, m_pDC))
OnDrawAll(m_pMemViewDC.get());
m_pDoc->m_xyDC.Create(m_pDC);
}
}
void CSigmaView::DrawForPrint()
{
if (!m_pDoc)
return;
//m_pDoc->m_xyDC.Create(m_pDC);
int dip = m_pDC->GetDeviceCaps(LOGPIXELSX);
int top = 0;
int left = 0;
if (m_topPageMargin != 0 || m_leftPageMargin != 0)
{
//ҳ<>߾<EFBFBD><DFBE>ĵ<EFBFBD>λΪ<CEBB><CEAA><EFBFBD><EFBFBD> ת<><D7AA>Ϊ<EFBFBD><CEAA>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>
//25.4/dip == 1/n ==>n=dip/25.4
double n = dip / 25.4;
top = (int)(m_topPageMargin * n);
left = (int)(m_leftPageMargin * n);
m_pDC->SetViewportOrg(left, top);
}
if (m_bottomPageMargin != 0 || m_rightPageMargin != 0)
{
double n = dip / 25.4;
int bottom = (int)(m_bottomPageMargin * n);
int right = (int)(m_rightPageMargin * n);
m_pDC->IntersectClipRect(0, 0, m_client.Width() - right - left, m_client.Height() - bottom - top);
}
else
{
//CRect rtView = m_pDoc->m_xyDC.GetViewRect();
//rtView.SetRect(0, 0, rtView.Width() * 9, rtView.Height() * 4);
//m_pDoc->m_xyDC.SetViewRect(rtView);
//->IntersectClipRect(0, 0, m_client.Width(), m_client.Height());
}
OnDrawAll(m_pDC);
}
bool CSigmaView::OnDrawDC()
{
if (!m_pDoc)
return false;
if (!(m_pDC && m_pDC->GetSafeHdc()))
return false;
m_pDC->BitBlt(m_client.left, m_client.top, m_client.Width(), m_client.Height(), m_pMemViewDC.get(), 0, 0, SRCCOPY);
return true;
}
void CSigmaView::OnDraw(CXyDC& dc)
{
TRACE(_T("CSigmaView::OnDraw(CXyDC&)\n"));
//ASSERT_VALID(m_pDoc);
m_pDoc->OnDraw(dc);
}
bool CSigmaView::OnDrawAll(CDC* pDC)
{
if (m_pDoc == NULL) return false;
CXyDC* pXyDC = &(m_pDoc->m_xyDC);
if (!pXyDC->Create(pDC)) return false;
pXyDC->SetViewRect(m_client);
// <20><>ʾԪ<CABE><D4AA>
OnDrawAllBefore(*pXyDC);
//CRect8 rect(1e100, -1e100, -1e100, 1e100);
//m_pDoc->m_pXy->GetRange(rect);
//m_pDoc->m_pXy->m_range = rect;
//pXyDC->Extend(rect, m_client, EXTEND_MODE_CENTER);
this->OnDraw(*pXyDC);
OnDrawAllAfter(*pXyDC);
return TRUE;
}
void CSigmaView::Scroll(int orientation, double offset)
{
CXyDC* pDC = &(m_pDoc->m_xyDC);
if (orientation == 0) {
pDC->OffsetRect(offset, 0);
}
else {
pDC->OffsetRect(0, -offset);
}
m_bScroll = true;
1 month ago
viewChanged.Emit();
1 month ago
//CWnd* pWnd = CWnd::FromHandle(GetHWND());
//if (pWnd)
//{
// SCROLLINFO bar;
// pWnd->SetScrollRange(SB_HORZ, 0, 1000);
// BOOL b = pWnd->GetScrollInfo(SB_HORZ, &bar, SIF_ALL);
// bar.nPage = 980;
// pWnd->SetScrollInfo(SB_HORZ, &bar, 0);
//}
}
void CSigmaView::SetTop(double top)
{
CXyDC* pDC = &(m_pDoc->m_xyDC);
pDC->top = top;
1 month ago
viewChanged.Emit();
1 month ago
}
void CSigmaView::OnDrawAllBefore(CXyDC& dc)
{
if (m_bSymbolView)
{
CRect8 rect(-0.5, 0.5, 0.5, -0.5);
COLORREF color = RGB(255, 255, 255);
CXyDC* pDC = &(m_pDoc->m_xyDC);
pDC->FillSolidRect(rect, color);
}
}
void CSigmaView::OnDrawAllAfter(CXyDC& dc)
{
/*
m_pDoc->DrawItem(dc, -1, -1);
if (m_pDoc->GetItem())
{
GetItem()->OnDraw(&dc);
}
*/
if (m_bShowBKGrid == true && m_pItemBkGrid != nullptr)
{
m_pItemBkGrid->DrawGrid(this->GridStepX, this->GridStepY, 1);
}
//CItemSelect * pItemSelect = m_pDoc->GetSelectItem();
//if (pItemSelect)
//{
// pItemSelect->OnDraw(&dc);
//}
//pItemSelect->GetTracker()->Draw(m_pScreenDC);
}
void CSigmaView::SetMapUnit(CSize unit)
{
}
bool CSigmaView::CreateMemDC(CRect rect, CDC* pDC)
{
m_pDoc->EnableRedraw(false);
if (m_pMemViewDC == NULL)
{
m_pMemViewDC = std::make_unique<CMemoryDC>();
m_pMemViewDC->Create(CSize(rect.Width(), rect.Height()), 0, pDC);
}
else if (m_pMemViewDC->GetSize() != rect.Size())
{
m_pMemViewDC->Empty();
m_pMemViewDC->Create(CSize(rect.Width(), rect.Height()));
}
m_pMemViewDC->Erase(m_pDoc->GetPaperColor());
//m_pMemViewDC->Erase(RGB(0,0,156));
if (m_pDoc->m_pXy == NULL) return false;
//return OnDrawAll(m_pMemViewDC);
m_pDoc->GetItemView()->SetMemDC(m_pMemViewDC.get());
//CItemView itemView = m_pDoc->GetItemView();
//itemView.SetMemDC(m_pMemViewDC);
return true;
}
void CSigmaView::SetScreenDC(CDC* pScreenDC)
{
m_pScreenDC = pScreenDC;
}
void CSigmaView::SetImgDc(CDC* pDC)
{
m_pImgDC = pDC;
m_pDoc->m_xyDC.Create(m_pImgDC);
}
void CSigmaView::SetAntiAlias(bool enable)
{
m_pDoc->m_xyDC.SetAntiAlias(enable);
}
bool CSigmaView::GetAntiAlias()
{
return m_pDoc->m_xyDC.GetAntiAlias();
}
void CSigmaView::SetPrinting(bool isPriting) {
m_pDoc->m_xyDC.SetPrinting(isPriting);
}
bool CSigmaView::GetIsPriting() {
return m_pDoc->m_xyDC.GetIsPrinting();
}
void CSigmaView::SetEnableRotate(bool enable)
{
this->m_bEnableRotate = enable;
}
CPoint CSigmaView::GetLastRightButtonPoint() const
{
return m_lastRightButtonXY;
}
void CSigmaView::SetLastRightButtonPoint(const CPoint& point)
{
m_lastRightButtonXY = point;
}
void CSigmaView::RegisterListener(Listener listener)
{
m_listener = listener;
}
void CSigmaView::Notify(const CString& message)
{
if (m_listener != nullptr)
{
BSTR bstr = message.AllocSysString();
m_listener(bstr);
}
}
bool CSigmaView::DrawImg(bool symbolViewFlag)
{
// COLORREF clrBck = RGB(255, 0, 0);
// DCHelp::ClearDC(m_pImgDC, clrBck); // this->mBackColor);
DCHelp::ClearDC(m_pImgDC, this->mBackColor);
m_pImgDC->OffsetViewportOrg(m_viewportOffsetX, m_viewportOffsetY);
m_pImgDC->IntersectClipRect(0, 0, m_client.Width(), m_client.Height());
CXyDC* pXyDC = &(m_pDoc->m_xyDC);
//if (!pXyDC->Create(m_pImgDC)) return false;
pXyDC->SetViewRect(m_client);
// <20><>ʾԪ<CABE><D4AA>
OnDrawAllBefore(*pXyDC);
m_pDoc->OnDraw(*pXyDC);
OnDrawAllAfter(*pXyDC);
OnDrawOther(m_pImgDC);
//m_pDoc->EnableRedraw(false);
return true;
}
bool CSigmaView::CombinImg(int x, int y, int width, int height, int worldX, int worldY)
{
HWND hwnd = GetDesktopWindow();
CDC* pDCDesk = CDC::FromHandle(GetDC(hwnd));
m_pImgDC->BitBlt(x, y, width, height, pDCDesk, worldX, worldY, SRCCOPY);
return TRUE;
}
void CSigmaView::ShowBKGrid(bool bShow)
{
m_bShowBKGrid = bShow;
}
bool CSigmaView::HasEnableBKGrid()
{
return m_bShowBKGrid;
}
CPoint CSigmaView::GetGridPoint(CPoint& pt)
{
CPoint ptGrid = pt;
m_pItemBkGrid->GetGridPoint(ptGrid);
return ptGrid;
}
void CSigmaView::OnDrawOther(CDC* pDC)
{
CItem* pItem = m_pDoc->GetItem();
if (pItem == nullptr) {
return;
}
if (pItem->GetType() == ITEM_SELECT)
{
((CItemSelect *)pItem)->SetEnableRotate(m_bEnableRotate);
}
CXyDC* pXyDC = &(m_pDoc->m_xyDC);
pItem->OnDraw(pXyDC, pDC);
}
void CSigmaView::SetBackColor(COLORREF color)
{
this->mBackColor = color;
this->m_pDoc->SetBackColor(color);
}
COLORREF CSigmaView::GetBackColor()
{
return this->mBackColor;
}
void CSigmaView::SetDc(CDC* pDC)
{
/*if(m_pDC != NULL)
m_pDC->DeleteDC();*/
//m_pDC->Detach();
m_pDC = pDC;
m_pDoc->m_xyDC.Create(m_pDC);
//m_pDrawDC = pDC; //added by sjc
}
CDC* CSigmaView::GetDc() {
return m_pDC;
}
void CSigmaView::OffsetViewportOrg(int offsetX, int offsetY)
{
m_viewportOffsetX = offsetX;
m_viewportOffsetY = offsetY;
1 month ago
viewChanged.Emit();
1 month ago
}
void CSigmaView::SetClient(int l, int t, int r, int b)
{
m_client.left = l;
m_client.top = t;
m_client.right = r;
m_client.bottom = b;
m_pDoc->GetItemView()->setClientRect(m_client);
m_pDoc->GetDC().SetViewRect(m_client);
1 month ago
viewChanged.Emit();
1 month ago
}
bool CSigmaView::OpenFile(LPCTSTR lpszFileName, BOOL bMergeFile)
{
if (m_pDoc == NULL) return false;
m_pDoc->EnableMeshPackage(this->m_bEnableMeshPackage);
if (m_pDoc->OpenFile(lpszFileName, bMergeFile) != TRUE) {
return false;
}
//m_pDoc->GetItemView().
//InitialView();
//OnDraw();
AfxGetPublicFunction()->EnableJudgeRange(TRUE);
return true;
}
bool CSigmaView::OpenXy(CXy* pXy, BOOL bMergeFile)
{
if (m_pDoc == NULL) return false;
m_pDoc->EnableMeshPackage(this->m_bEnableMeshPackage);
m_pDoc->m_pXy = pXy;
return true;
}
bool CSigmaView::ReloadFile()
{
CString strFile = m_pDoc->m_FileName;
Clear();
Initialize();
if (m_pDoc == NULL) return false;
if (m_pDoc->OpenFile(strFile, false) != TRUE) {
return false;
}
return true;
}
bool CSigmaView::CreateNew(LPCTSTR fileName) {
if (m_pDoc == NULL) return false;
if (m_pDoc->CreateNew(fileName) != TRUE) {
return false;
}
//InitialView();
return true;
}
bool CSigmaView::CreateNew() {
InitialView();
return true;
}
void CSigmaView::InitialView()
{
//CDrawDoc* pDoc = GetDocument();
//m_pDoc->m_xyDC.Create(m_pDC);
//Ϊ<>˱<EFBFBD><CBB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
//m_pItemBkGrid = new CItemBkGrid(pDoc);
//InitTracker();
//m_pItemToolTip = new CItemToolTipHttp(pDoc); // <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ϣ
//m_pItemToolTip->InitToolTip();
m_pDoc->GetItemView()->SetDoc(m_pDoc); // <20><><EFBFBD><EFBFBD>
//pDoc->SetPathName(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
if (m_pDoc->m_pXy == NULL)
{
return;
}
//<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
m_pDoc->m_xyDC.SetScale(m_pDoc->m_pXy->m_scaleSize.cx, m_pDoc->m_pXy->m_scaleSize.cy);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾλ<CABE><CEBB>
//CRect rt; GetClientRect(hWhd, rt);
CRect rt = m_client;
if (m_pDoc->m_pXy && m_pDoc->m_pXy->GetCount() > 0)
{
if (m_pDoc->m_pXy->m_display.IsEmpty())
{
m_pDoc->m_xyDC.Extend(m_pDoc->m_pXy->m_range, rt, EXTEND_MODE_DEFAULT);
}
else
{
//Ϊ<>˼<EFBFBD><CBBC><EFBFBD><EFBFBD>ϰ汾
if (AfxGetPublicFunction()->IsEqual(m_pDoc->m_pXy->m_scaleSize.cx, 1.0) &&
AfxGetPublicFunction()->IsEqual(m_pDoc->m_pXy->m_scaleSize.cy, 1.0))
m_pDoc->m_xyDC.Extend(m_pDoc->m_pXy->m_range, rt, EXTEND_MODE_DEFAULT);
else
{
//<2F>°汾ʱ
//<2F>ƶ<EFBFBD><C6B6><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB1A3>ʱһ<CAB1><D2BB>
double dx = m_pDoc->m_pXy->m_display.left - m_pDoc->m_xyDC.left;
double dy = m_pDoc->m_pXy->m_display.top - m_pDoc->m_xyDC.top;
m_pDoc->m_xyDC.OffsetRect(dx, dy);
}
}
}
else
{
CRect8 r8(rt.left, rt.bottom, rt.right, rt.top);
m_pDoc->m_xyDC.Extend(r8, rt, EXTEND_MODE_DEFAULT);
}
////CGM<47>ļ<EFBFBD><C4BC>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//if (m_pDoc->m_cgmDefaultInfo.mode != -1)
//{
// GetDC().SetScale(pDoc->m_cgmDefaultInfo.scaling, pDoc->m_cgmDefaultInfo.scaling);
//}
//SetScrollBarRange();
//Timer(false);
}
///////<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>////////////////////////
void CSigmaView::OnVScroll(UINT nSBCode, UINT nPos, int nScrollMax)
{
double dScrollOneLine = 0.9;
double dScrollOnePage = 0.2;
//CClientDC dc(this); pDoc->SetDC(&dc);
//CXyDC *pDC = &GetDC();
CXyDC* pDC = &(m_pDoc->m_xyDC);
CRect crt = this->m_client;
CRect8 rcScreenReal = pDC->GetReal(crt);
rcScreenReal.NormalizeRect();
long ol = AfxGetPublicFunction()->FloatToLong(crt.Height() * dScrollOneLine); //һ<>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
long op = AfxGetPublicFunction()->FloatToLong(crt.Height() * dScrollOnePage); //һҳ<D2BB><D2B3><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
if (ol < 1)ol = 1; if (op < 1)op = 1;
double OneLine = pDC->GetRealHeight(ol); //һ<>е<EFBFBD>ʵ<EFBFBD>ʵ<EFBFBD>λ<EFBFBD><CEBB>
double OnePage = pDC->GetRealHeight(op); //һҳ<D2BB><D2B3>ʵ<EFBFBD>ʵ<EFBFBD>λ<EFBFBD><CEBB>
int offset = 0;
BOOL bFlash = FALSE;
switch (nSBCode)
{
case SB_ENDSCROLL: // End scroll.
break;
case SB_BOTTOM: //Scroll to bottom.
pDC->OffsetRect(0, m_pDoc->m_pXy->m_range.bottom - rcScreenReal.bottom);
offset = -ol;
break;
case SB_TOP:
pDC->OffsetRect(0, m_pDoc->m_pXy->m_range.top - rcScreenReal.top);
offset = ol;
break;
case SB_LINEDOWN: //Scroll one line down.
pDC->OffsetRect(0, OneLine);
offset = -ol;
break;
case SB_LINEUP: //Scroll one line up.
pDC->OffsetRect(0, -OneLine);
offset = ol;
break;
case SB_PAGEDOWN: //Scroll one page down.
pDC->OffsetRect(0, OnePage);
offset = -op;
break;
case SB_PAGEUP: //Scroll one page up.
pDC->OffsetRect(0, -OnePage);
offset = op;
break;
case SB_THUMBPOSITION: //Scroll to the absolute position. The current position is provided in nPos.
case SB_THUMBTRACK: //Drag scroll box to specified position. The current position is provided in nPos.
if (m_pDoc->m_pXy->GetCount() > 0)
{
double nMax = nScrollMax;
CRect8 rect = m_pDoc->m_pXy->m_range;
double bak = rcScreenReal.top;
double dy = rcScreenReal.top - rcScreenReal.bottom;
pDC->top = rect.top - (rect.top - rect.bottom - dy) * (nPos / nMax);
pDC->bottom = pDC->top - dy;
if (bak != pDC->top)
bFlash = TRUE;
}
break;
}
if (offset != 0)
{
bFlash = TRUE;
}
1 month ago
viewChanged.Emit();
1 month ago
//if (bFlash)
//{
// pDoc->Invalidate();
//}
}
void CSigmaView::OnHScroll(UINT nSBCode, UINT nPos, int nScrollMax)
{
double dScrollOneLine = 0.2;
double dScrollOnePage = 0.9;
CXyDC* pDC = &(m_pDoc->m_xyDC);
CRect crt = this->m_client;
//CDrawDoc* pDoc = GetDocument();
//CClientDC dc(this); pDoc->SetDC(&dc);
//CXyDC *pDC = &GetDC();
//CRect crt; this->GetClientRect(&crt);
CRect8 rcScreenReal = pDC->GetReal(crt);
rcScreenReal.NormalizeRect();
long ol = AfxGetPublicFunction()->FloatToLong(crt.Width() * dScrollOneLine); //һ<>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
long op = AfxGetPublicFunction()->FloatToLong(crt.Width() * dScrollOnePage); //һҳ<D2BB><D2B3><EFBFBD><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
if (ol < 1)ol = 1; if (op < 1)op = 1;
double OneLine = pDC->GetRealWidth(ol); //һ<>е<EFBFBD>ʵ<EFBFBD>ʵ<EFBFBD>λ<EFBFBD><CEBB>
double OnePage = pDC->GetRealWidth(op); //һҳ<D2BB><D2B3>ʵ<EFBFBD>ʵ<EFBFBD>λ<EFBFBD><CEBB>
int offset = 0;
BOOL bFlash = FALSE;
switch (nSBCode)
{
case SB_ENDSCROLL: // End scroll.
break;
case SB_LEFT: //Scroll to left.
pDC->OffsetRect(m_pDoc->m_pXy->m_range.left - rcScreenReal.left, 0);
offset -= ol;
break;
case SB_RIGHT:
pDC->OffsetRect(m_pDoc->m_pXy->m_range.right - rcScreenReal.right, 0);
offset = ol;
break;
case SB_LINERIGHT: //Scroll one line down.
pDC->OffsetRect(OneLine, 0);
offset = -ol;
break;
case SB_LINELEFT: //Scroll one line up.
pDC->OffsetRect(-OneLine, 0);
offset = ol;
break;
case SB_PAGERIGHT: //Scroll one page down.
pDC->OffsetRect(OnePage, 0);
offset = -op;
break;
case SB_PAGELEFT: //Scroll one page up.
pDC->OffsetRect(-OnePage, 0);
offset = op;
break;
case SB_THUMBPOSITION: //Scroll to the absolute position. The current position is provided in nPos.
case SB_THUMBTRACK: //Drag scroll box to specified position. The current position is provided in nPos.
if (m_pDoc->m_pXy->GetCount() > 0)
{
double nMax = nScrollMax; //GetScrollLimit()<29>ķ<EFBFBD><C4B7><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>nMax - nPage + 1
CRect8 rect = m_pDoc->m_pXy->m_range;
double bak = rcScreenReal.left;
double dx = rcScreenReal.right - rcScreenReal.left; //һҳ<D2BB><D2B3>ʵ<EFBFBD>ʿ<EFBFBD><CABF><EFBFBD>
pDC->left = rect.left + (rect.right - rect.left - dx) * (nPos / nMax);
pDC->right = pDC->left + dx;
if (bak != pDC->left)
bFlash = TRUE;
}
break;
}
if (offset != 0)
{
bFlash = TRUE;
}
1 month ago
viewChanged.Emit();
1 month ago
//if (bFlash)
//{
// pDoc->Invalidate();
//}
//CView::OnHScroll(nSBCode, nPos, pScrollBar);
}
void CSigmaView::SetScrollBar(int& hMax, int& vMax, int& hPage, int& vPage, int& hPos, int& vPos)
{
//if (&(m_pDoc->m_xyDC) == NULL ||
// m_pDoc->m_pXy->GetCount() == 0)
//{
// SetScrollRange(SB_HORZ, 0, 1000);
// SCROLLINFO bar;
// GetScrollInfo(SB_HORZ, &bar, SIF_ALL);
// bar.nPage = 980;
// SetScrollInfo(SB_HORZ, &bar, 0);
// SetScrollRange(SB_VERT, 0, 1000);
// GetScrollInfo(SB_VERT, &bar, SIF_ALL);
// bar.nPage = 980;
// SetScrollInfo(SB_VERT, &bar, 0);
// return;
//}
CXyDC* pDC = &(m_pDoc->m_xyDC);
if (m_pDoc->m_pXy == NULL)
{
return;
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>Χ
CRect8 rect = m_pDoc->m_pXy->m_range;
double dx = rect.right - rect.left;
double dy = rect.top - rect.bottom;
int hts = pDC->GetScreenWidth(dx);
int vts = pDC->GetScreenHeight(fabs(dy));
vts = abs(vts);
//if (hts > 8000) hts = 8000;
//if (vts > 8000) vts = 8000;
if (hts < 100) hts = 100;
if (vts < 100) vts = 100;
hMax = hts;
vMax = vts;
//SetScrollRange(SB_HORZ, 0, hts);
//SetScrollRange(SB_VERT, 0, vts);
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>Χ
CRect rcScreen = m_client;
CRect8 rcScreenReal = pDC->GetReal(rcScreen);
rcScreenReal.NormalizeRect();
//SCROLLINFO bar;
//GetScrollInfo(SB_HORZ, &bar, SIF_ALL);
//bar.nPage = AfxGetPublicFunction()->FloatToLong((rcScreenReal.right - rcScreenReal.left) / dx * hts);
UINT nPageH = AfxGetPublicFunction()->FloatToLong((rcScreenReal.right - rcScreenReal.left) / dx * hts);
if (nPageH > (UINT)(hts - 5))
nPageH = hts - 5;
//SetScrollInfo(SB_HORZ, &bar, 0);
//GetScrollInfo(SB_VERT, &bar, SIF_ALL);
//bar.nPage = AfxGetPublicFunction()->FloatToLong((rcScreenReal.top - rcScreenReal.bottom) / dy * vts);
UINT nPageV = AfxGetPublicFunction()->FloatToLong((rcScreenReal.top - rcScreenReal.bottom) / dy * vts);
if (nPageV > (UINT)(vts - 5))
nPageV = vts - 5;
//SetScrollInfo(SB_VERT, &bar, 0);
hPage = nPageH;
vPage = nPageV;
//<2F><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>
double xm = rcScreenReal.left - rect.left;
double ym = rect.top - rcScreenReal.top;
xm = xm / dx * hts;
ym = ym / dy * vts;
if (xm < 0) xm = 0; if (xm > hts) xm = hts;
if (ym < 0) ym = 0; if (ym > vts) ym = vts;
hPos = AfxGetPublicFunction()->FloatToLong(xm);
vPos = AfxGetPublicFunction()->FloatToLong(ym);
//SetScrollPos(SB_HORZ, AfxGetPublicFunction()->FloatToLong(xm));
//SetScrollPos(SB_VERT, AfxGetPublicFunction()->FloatToLong(ym));
}
/**
* <EFBFBD>Ŵ<EFBFBD>
**/
void CSigmaView::OnViewEnlarge()
{
m_pDoc->GetItemView()->Enlarge();
1 month ago
viewChanged.Emit();
1 month ago
}
void CSigmaView::SetZoomMode(int zoomMode)
{
m_pDoc->GetItemView()->zoomMode = zoomMode;
}
void CSigmaView::OnViewEnlargeByMousePoint(int mouseX, int mouseY)
{
CPoint2D ptReal = m_pDoc->GetDC().GetReal((long)mouseX, (long)mouseY);
m_pDoc->GetItemView()->Reduce(ptReal, 1.5);
1 month ago
viewChanged.Emit();
1 month ago
}
void CSigmaView::OnViewReduce()
{
m_pDoc->GetItemView()->Reduce();
1 month ago
viewChanged.Emit();
1 month ago
}
void CSigmaView::ReduceForScreenPoint()
{
m_pDoc->GetItemView()->ReduceForScreenPoint();
}
void CSigmaView::OnViewReduce(double factor)
{
m_pDoc->GetItemView()->Reduce(factor);
1 month ago
viewChanged.Emit();
1 month ago
}
void CSigmaView::ViewReduceByMousePoint(int mouseX, int mouseY)
{
CPoint2D ptReal = m_pDoc->GetDC().GetReal((long)mouseX, (long)mouseY);
m_pDoc->GetItemView()->Reduce(ptReal, 1 / 1.5);
}
void CSigmaView::FillScreenToCenter()
{
CRect8 rect(1e100, -1e100, -1e100, 1e100);
if (m_pDoc->GetDraw()->GetCount() > 0)
m_pDoc->GetDrawRange(rect);
else
rect = m_client;
//һ<><D2BB>Ҫ<EFBFBD>Ƚ<EFBFBD><C8BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊx,y<><79><EFBFBD><EFBFBD><EFBFBD>ȱ<EFBFBD><C8B1><EFBFBD>
//<2F><>Ϊȫͼ<C8AB><CDBC><EFBFBD><EFBFBD>֮ǰ <20>п<EFBFBD><D0BF>ܵ<EFBFBD><DCB5><EFBFBD>ȫͼ<C8AB><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ὣx,y<><79><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ò<EFBFBD>ͬ
//<2F><><EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD>ȫͼ<C8AB><CDBC><EFBFBD><EFBFBD>ʱ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC> <20><><EFBFBD><EFBFBD>ȫͼ<C8AB><CDBC><EFBFBD>е<EFBFBD>ͼ<EFBFBD><CDBC>Ҳ<EFBFBD><D2B2>x,y<><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ
m_pDoc->GetDC().SetScale(1.0, 1.0);
m_pDoc->GetDC().Extend(rect, m_client, EXTEND_MODE_CENTER);
1 month ago
viewChanged.Emit();
1 month ago
}
void CSigmaView::FillScreenByStrech()
{
CRect8 rect(1e100, -1e100, -1e100, 1e100);
if (m_pDoc->GetDraw()->GetCount() > 0)
m_pDoc->GetDrawRange(rect);
else
rect = m_client;
double xx, yy;
m_pDoc->GetDC().GetScale(xx, yy);
m_pDoc->GetDC().Extend(rect, m_client, EXTEND_MODE_STRECH);
m_pDoc->GetDC().GetScale(xx, yy);
1 month ago
viewChanged.Emit();
1 month ago
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ
void CSigmaView::ToCenterAndFixScale()
{
if (m_pDoc->GetDraw()->GetCount() == 0)
return;
//<2F><><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>Ĵ<EFBFBD>С
CRect8 rect(1e100, -1e100, -1e100, 1e100);
m_pDoc->GetDrawRange(rect);
CRect rt = m_client;
//CRect mg = GetMarginRect();
//CPoint porg = pDC->GetViewportOrg();
//rt.OffsetRect(-mg.left, -mg.top);
CRect8 rs = m_pDoc->GetDC().GetReal(rt);
CPoint2D pt = rect.CenterPoint();
CPoint2D ps = rs.CenterPoint();
m_pDoc->GetDC().OffsetRect(pt.x0 - ps.x0, pt.y0 - ps.y0);
1 month ago
viewChanged.Emit();
1 month ago
}
void CSigmaView::OnViewExtend()
{
m_pDoc->GetItemView()->Extend(EXTEND_MODE_DEFAULT);
//m_pDoc->InvalidateAttachView(); //<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>а󶨸<D0B0><F3B6A8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ
}
void CSigmaView::Extend(double locationX, double locationY, double width, double height, int mode)
{
CRect m_window = m_client;
if (m_window.Width() < 100)m_window.SetRect(0, 0, 320, 240);
//CRect8 rect(locationX, locationY, width, height);
CRect8 rect(locationX, locationY + height, locationY + width, locationY);
//m_pDoc->GetDrawRange(rect);
m_pDoc->m_xyDC.Extend(rect, m_window, mode);
1 month ago
viewChanged.Emit();
1 month ago
}
void CSigmaView::SetViewPan()
{
//m_pDoc->GetItemView().SetMemDC(m_pMemViewDC);
if (m_pDoc->GetItemView()->GetType() == ID_VIEW_PAN)
{
//m_pDoc->GetItemView().SetType(0);
//pDoc->SetDefaultCursor();
}
else
{
m_pDoc->GetItemView()->SetType(ID_VIEW_PAN);
//pDoc->GetCursor().BakupCursor();
//pDoc->SetDefaultCursor();
}
}
void CSigmaView::PanTo(int mouseX, int mouseY)
{
//<2F><><EFBFBD><EFBFBD>û<EFBFBD>н<EFBFBD><D0BD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ƽ<EFBFBD>Ƴ<EFBFBD><C6B3><EFBFBD>
CPoint2D point(mouseX, mouseY);
CPoint2D ptW = m_pDoc->m_xyDC.GetReal(point);
m_pDoc->GetItemView()->PanTo(ptW);
1 month ago
viewChanged.Emit();
1 month ago
}
void CSigmaView::SetViewWindow()
{
//m_pDoc->GetItemView().SetMemDC(m_pMemViewDC);
if (m_pDoc->GetItemView()->GetType() == ID_VIEW_WINDOW)
{
//m_pDoc->GetItemView().SetType(0);
//pDoc->SetDefaultCursor();
}
else
{
m_pDoc->GetItemView()->SetType(ID_VIEW_WINDOW);
}
}
void CSigmaView::ViewMouseDown(UINT nFlags, CPoint point)
{
m_pDoc->GetItemView()->OnLButtonDown(nullptr, nFlags, point, 0);
}
int nTmpX = 0, nTmpY = 0;
void CSigmaView::ViewMouseMove(UINT nFlags, CPoint point)
{
//m_pDoc->m_xyDC.Create(m_pDC);
//nTmpX += 2;
//nTmpY += 2;
//m_pDC->BitBlt(m_client.left+ nTmpX, m_client.top+ nTmpY, m_client.Width(), m_client.Height(), m_pMemViewDC, 0, 0, SRCCOPY);
//CXyDC* pDC = &m_pDoc->GetDC();
//pDC->Create(m_pDC);
//Dra
//DrawCrossLine();
m_pDoc->GetItemView()->OnMouseMove(nullptr, nFlags, point);
}
void CSigmaView::ViewMouseUp(UINT nFlags, CPoint point)
{
m_pDoc->GetItemView()->OnLButtonUp(nullptr, nFlags, point, 0);
}
void CSigmaView::SetItem(int itemType)
{
if (itemType <= 0)
{
//***<2A><>Ҫ<EFBFBD>Ķ<EFBFBD> <20><><EFBFBD>ò<EFBFBD><C3B2>Ϸ<EFBFBD><CFB7><EFBFBD>itemTypeֱ<65><D6B1>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Item
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>ԭ<EFBFBD><D4AD>:<3A><><EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ItemΪDefaultItem <20><><EFBFBD><EFBFBD>C++<2B><>û<EFBFBD>ж<EFBFBD>Ӧ<EFBFBD><D3A6>Item<65><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD>ֱ<EFA3AC>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD>ˡ<EFBFBD>
//<2F><><EFBFBD><EFBFBD>C++<2B><>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD>Ѳ<EFBFBD><D1B2>õ<EFBFBD>Item<65><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ESC<53><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD><DCBB><EFBFBD><EFBFBD>ٻ<EFBFBD>ʹ<EFBFBD><CAB9>ǰ<EFBFBD><C7B0>Item<65><6D>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD><EFBFBD>ϲ<CFB2><E3B4AB><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Item<65><6D><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Щ<EFBFBD><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_pDoc->DeleteItem();
return;
}
if (m_pDoc->GetItemType() != itemType)
{
m_pDoc->DeleteItem();
m_pDoc->SetItem(m_pDoc->FindItem(itemType));
}
//else
// m_pDoc->EnableDefaultTool();
}
CItem* CSigmaView::GetItem()
{
return m_pDoc->GetItem();
}
void CSigmaView::SetHWND(HWND hwnd)
{
m_HWND = hwnd;
CWnd* pWnd = CWnd::FromHandle(m_HWND);
// m_pDoc->GetTracker().SetParent(pWnd);
}
HWND CSigmaView::GetHWND()
{
return m_HWND;
}
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><C2B6><EFBFBD>,<2C><><EFBFBD><EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD>Undo,Redo<64><6F><EFBFBD><EFBFBD>
void CSigmaView::ActionAdd(COne* pOne, UINT nUndoID)
{
//CDFDrawProDoc* pDoc = GetDocument();
CSigmaDoc* pDoc = m_pDoc;
//pDoc->SetActionItem(new CActionAddItem(pDoc, nUndoID, pOne));
}
void CSigmaView::SendRedrawMsg()
{
if (m_HWND == NULL)
return;
m_pDoc->m_bRedraw = true;
//::PostMessageA(m_HWND, WM_PAINT, 0, 0);
::InvalidateRect(m_HWND, NULL, TRUE);
}
void CSigmaView::SetDrawDC(CDC* cdc)
{
m_pDrawDC = cdc;
}
CDC* CSigmaView::GetDrawDC()
{
return m_pDrawDC;
}
void CSigmaView::GetPageMargin(int* top, int* bottom, int* left, int* right)
{
*top = m_topPageMargin;
*bottom = m_bottomPageMargin;
*left = m_leftPageMargin;
*right = m_rightPageMargin;
}
void CSigmaView::SetPageMargin(int top, int bottom, int left, int right)
{
m_topPageMargin = top;
m_bottomPageMargin = bottom;
m_leftPageMargin = left;
m_rightPageMargin = right;
1 month ago
viewChanged.Emit();
1 month ago
}
int CSigmaView::HighLightGraphItem(int mouseX, int mouseY, CDC* pScreenDC)
{
int nResult = -1;
//CDrawDoc* pDoc = GetDocument();
CPoint2D pt;
pt.x0 = mouseX;
pt.y0 = mouseY;
pt = m_pDoc->GetDC().GetReal(pt);
POSITION p = m_pDoc->GetSelectedItem(pt);
BOOL br = FALSE;
if (p != m_moveSelect)
{
m_pDoc->GetDC().Create(pScreenDC);
int old = m_pDoc->GetDC().GetDC()->SetROP2(R2_COPYPEN);
//int bkModeOld = m_pDoc->GetDC().GetDC()->SetBkMode(TRANSPARENT);
//if (m_moveSelect != NULL && IsROP2(m_pDoc->GetDraw()->GetElementType(m_moveSelect)))
// DrawElement(m_moveSelect);
m_moveSelect = p;
if (m_moveSelect != NULL && IsROP2(m_pDoc->GetDraw()->GetElementType(m_moveSelect)))
{
DrawElement(m_moveSelect);
nResult = 1;
}
else
{
nResult = 2;
}
//m_pDoc->GetDC().GetDC()->SetBkMode(bkModeOld);
m_pDoc->GetDC().GetDC()->SetROP2(old);
//m_pDoc->GetDC().GetDC()->MoveTo(0, 0);
//m_pDoc->GetDC().GetDC()->LineTo(800, 600);
}
if (m_moveSelect)
{
FillTipInfo(m_moveSelect, pt);
}
else
memset(m_tipMessageBuffer, 0, sizeof(m_tipMessageBuffer));
return nResult;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE>Ϣ
//if (!br) SetTooltipText(MoveSelect, dp);
//pDoc->MoveSelect = MoveSelect;
//pDoc->MoveSelect = MoveSelect;
}
void CSigmaView::EndHighLightGraphItem()
{
m_moveSelect = 0;
memset(m_tipMessageBuffer, 0, sizeof(m_tipMessageBuffer));
}
wchar_t* CSigmaView::GetTipInfoString()
{
return m_tipMessageBuffer;
}
//void CSigmaView::InitXyDC()
//{
// CXyDC & dc = m_pDoc->GetDC();
// dc.Create(m_pDrawDC);
//}
COne* CSigmaView::GetSelectedOne(int type)
{
//CSigmaDoc* pDoc = GetDocument();
POSITION pos = GetSelectedOnePosition(type);
if (pos == NULL) return NULL;
return m_pDoc->GetDraw()->GetAt(pos);
}
//CSigmaDoc* CSigmaView::GetDocument() const // <20>ǵ<EFBFBD><C7B5>԰汾<D4B0><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//{
// CDocument * m_pDocument = (CDocument *)m_pDoc;
// ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSigmaDoc)));
// return (CSigmaDoc*)m_pDocument;
//}
POSITION CSigmaView::GetSelectedOnePosition(int type)
{
//CDFDrawProDoc* pDoc = GetDocument();
if (m_pDoc->GetItemType() != ITEM_SELECT) return NULL;
if (GetSelection()->GetCount() != 1) return NULL;
CList<POSITION, POSITION>* plist = GetSelection();
POSITION pos = plist->GetHead();
if (pos == NULL)return NULL;
COne* pOne = (COne*)m_pDoc->GetDraw()->GetAt(pos);
//ASSERT(pOne->GetType()==type);
if (pOne->GetType() != type) return NULL;
return pos;
}
CPositionList* CSigmaView::GetSelection(void)
{
//CDFDrawProDoc* pDoc = GetDocument();
if (m_pDoc->GetItem() == NULL) return NULL;
if (m_pDoc->GetItem()->GetType() != ITEM_SELECT) return NULL;
return &(((CItemSelect*)m_pDoc->GetItem())->m_selection);
}
POSITION CSigmaView::GetPositionFind(COne* pOne)
{
return m_pDoc->GetDraw()->Find(pOne);
}
void CSigmaView::DrawElement(POSITION pos)
{
if (pos == NULL)
return;
CXy* pDraw = m_pDoc->GetDraw();
switch (pDraw->GetElementType(pos))
{
case DOUBLEFOX_MXN:
case DOUBLEFOX_OTHERDRAW:
case DOUBLEFOX_SECTION:
break;
case DOUBLEFOX_CURVE:
DrawCurve(pos);
break;
default:
pDraw->Draw(m_pDoc->GetDC(), pos);
break;
}
}
void CSigmaView::DrawCurve(POSITION pos)
{
CXy* pDraw = m_pDoc->GetDraw();
if (pDraw == NULL)
return;
COne* pOne = (COne*)(pDraw->GetAt(pos));
CCurveEx* pCurve = (CCurveEx*)(pOne->value);
if (pOne->GetHowToViewCurve() == NULL && pCurve->m_type == PLINE_NODRAW)
{
pCurve->m_type = 0;
pDraw->Draw(m_pDoc->GetDC(), pos);
pCurve->m_type = PLINE_NODRAW;
}
else
{
pOne->Draw(m_pDoc->GetDC());
}
}
void CSigmaView::FillTipInfo(POSITION pos, CPoint2D pt)
{
memset(m_tipMessageBuffer, 0, sizeof(m_tipMessageBuffer));
CString tipInfoStr = m_pDoc->GetElementString(pos, &pt);
if (tipInfoStr.IsEmpty())
return;
wchar_t* tipStr = AsciiToUnicodeChar(tipInfoStr.GetBuffer());
if (tipStr == 0)
return;
size_t size = wcslen(tipStr);
if (size == 0)
return;
if (size >= 1024)
size = 1023;
memcpy_s(m_tipMessageBuffer, sizeof(m_tipMessageBuffer) - 2, tipStr, size * 2);
delete tipStr;
}
1 month ago
void CSigmaView::OnTransformChanged(UINT nMatrixID, const Gdiplus::Matrix& matrix, const CPositionList& positions)
{
if (nMatrixID == IDS_STRING_ACTION_MOVE)
{
std::string data;
data.reserve(128);
POSITION pos = positions.GetHeadPosition();
while (pos != nullptr)
{
POSITION pt = positions.GetNext(pos);
if (!data.empty())
{
data += ",";
}
data += std::to_string((int64_t)pt);
}
nlohmann::json eventObject
{
{"event", "move" },
{"data", data },
};
std::string event = eventObject.dump();
CString strEvent = CA2T(event.c_str());
Notify(strEvent);
}
}
void CSigmaView::ReloadTrackPath()
{
if (m_pDoc->GetSelectItem())
{
m_pDoc->GetSelectItem()->ReloadTrackerPath();
}
}
1 month ago
//void CSigmaView::ResetStatusForCrossLine()
//{
// m_bScroll = false;
// m_bEnableCrossLine = false;
// m_oldPtForDrawCrossLine.x = m_oldPtForDrawCrossLine.y = -1;
// m_bFirstForDrawCrossLine = true;
//}
BOOL CSigmaView::OnLButtonUpOther(CDC* pDC, UINT nFlags, CPoint point, int vk)
{
//CDFDrawProDoc* pDoc = GetDocument();
if (m_pDoc->GetItem())
{
m_pDoc->GetItem()->OnLButtonUp(pDC, nFlags, point, vk); //<2F><><EFBFBD>ߡ<EFBFBD><DFA1><EFBFBD><EFBFBD>ι<EFBFBD><CEB9>ߵ<EFBFBD>
return true;
}
else if (m_pDoc->GetOtherItem())
{
m_pDoc->GetOtherItem()->OnLButtonUp(pDC, nFlags, point, vk);
return true;
}
else
return false;
//CDrawView::OnLButtonUpOther(nFlags, point); //<2F><><EFBFBD><EFBFBD><EAB3A3>״̬
//CDrawDoc* pDoc = GetDocument();
//CXyDC* pDC = &pDoc->GetDC(); pDC->Create(m_pDrawDC);
////<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
//if (IsViewState())
//{
// int typeBak = pDoc->GetItemView().GetType();
// if (::IsKeyDown(GetPanKey())) pDoc->GetItemView().SetType(ID_VIEW_PAN);
// pDoc->GetItemView().OnLButtonUp(nFlags, point);
// if (::IsKeyDown(GetPanKey())) pDoc->GetItemView().SetType(typeBak);
//}
//else
// OnLButtonUpOther(nFlags, point);
//CView::OnLButtonUp(nFlags, point);
}
void CSigmaView::OnProcessZFlag()
{
CSigmaDoc* pDoc = m_pDoc;
CPtrList* pl = pDoc->GetDraw()->GetValueList();
CString oldName, newName;
COne* pOne;
//Ϊ<><CEAA><EFBFBD><EFBFBD><EFBFBD>ε<EFBFBD>Redo/Undo
CActionListItem* pAction = new CActionListItem(pDoc, ID_PROCESS_Z_FLAGS);
POSITION pos, pt;
pos = pl->GetHeadPosition();
while (pos)
{
pt = pos;
pOne = (COne*)pl->GetNext(pos);
if (!pOne->IsCanEdit() || !pOne->IsView()) continue;
switch (pOne->GetType())
{
case DOUBLEFOX_CURVE:
oldName = ((CCurveEx*)pOne->GetValue())->GetName();
if (oldName.IsEmpty()) break;
if (!AfxGetPublicFunction()->IsDigit(oldName)) break;
newName = oldName;
if (newName[0] == '-') newName = newName.Mid(1);
else newName = _T("-") + newName;
//for redo/undo
//pAction->AddChangeNameItem(pt, oldName, newName);
pAction->AddChangeNameItem(pt, oldName, newName);
((CCurveEx*)pOne->GetValue())->SetName(newName);
break;
case DOUBLEFOX_MESH:
//for redo/undo
pAction->AddBackupItem(pOne);
((CMesh*)pOne->GetValue())->ScaleProperty(-1.0, -1.0);
break;
}
}
if (pAction->GetCount() > 0)
pDoc->SetActionItem(pAction);
else
delete pAction;
pDoc->Invalidate();
//pDoc->SetModifiedFlag();
pDoc->Modified();
}
ImageCut* CSigmaView::GetImageCut()
{
if (m_imageCut == nullptr)
{
m_imageCut = std::make_unique<ImageCut>();
}
return m_imageCut.get();
}
void CSigmaView::StopThreadOfImageCut()
{
TerminateThread(m_imgageCutHandle, 0);
m_imgageCutHandle = INVALID_HANDLE_VALUE;
}
void CSigmaView::StartThreadOfImageCut(CutImageInfo* icInfo)
{
if (icInfo == NULL)
return;
icInfo = icInfo->Copy();
ImageCut* imageCut = GetImageCut();
imageCut->SetCutImageInfo(icInfo);
//imageCut->Execute();
CloseHandle(m_imgageCutHandle);
m_imgageCutHandle = CreateThread(NULL, 0, CutImageThreadProc, imageCut, 0, 0);
}
FileTransformer* CSigmaView::GetFileTransformer()
{
if (m_pFileTransformer == nullptr)
{
m_pFileTransformer = std::make_unique<FileTransformer>(m_pDoc);
}
return m_pFileTransformer.get();
}
void CSigmaView::StartThreadOfFileTransformer(FileTransformationInfo* tfInfo)
{
if (tfInfo == NULL)
return;
tfInfo = tfInfo->Copy();
FileTransformer* transformer = GetFileTransformer();
transformer->SetFileTransInfo(tfInfo);
//imageCut->Execute();
CloseHandle(m_transformerHandle);
m_transformerHandle = CreateThread(NULL, 0, FileTransformerThreadProc, transformer, 0, 0);
}
void CSigmaView::StopThreadOfFileTransformer()
{
TerminateThread(m_transformerHandle, 0);
CloseHandle(m_transformerHandle);
m_transformerHandle = INVALID_HANDLE_VALUE;
}
bool CSigmaView::GetPointsZRange(double& zMin, double& zMax)
{
bool bFound = false;
CPtrList* pl = m_pDoc->GetDraw()->GetValueList();
CString oldName, newName;
COne* pOne;
zMin = 1E301;
zMax = -1E301;
POSITION pos;
pos = pl->GetHeadPosition();
while (pos)
{
pOne = (COne*)pl->GetNext(pos);
if (!pOne->IsCanEdit() || !pOne->IsView()) continue;
switch (pOne->GetType())
{
case DOUBLEFOX_XYZ:
case DOUBLEFOX_POINT:
{
CPointNameEx* pPoint = (CPointNameEx*)pOne->GetValue();
if (pPoint->z0 > zMax)
{
zMax = pPoint->z0;
bFound = true;
}
if (pPoint->z0 < zMin)
{
zMin = pPoint->z0;
}
}
break;
}
}
return bFound;
}
bool CSigmaView::SetPointsColor(CString colorItemsData, double dWidth, double dHeight)
{
CColorBase color;
CColorItem item;
CPoint2D pt;
int nCount = color.GetColor().size();
color.GetColor().remove(0, nCount);
nCount = color.GetAlpha().size();
color.GetAlpha().remove(0, nCount);
int iStart = 0;
CString strZ, strR, strG, strB, strT, strContinue;
BYTE r, g, b, t;
while (1)
{
CString subItem = colorItemsData.Tokenize(_T("\r\n"), iStart);
if (subItem.IsEmpty())
break;
AfxExtractSubString(strZ, subItem, 0, _T(','));
AfxExtractSubString(strR, subItem, 1, _T(','));
AfxExtractSubString(strG, subItem, 2, _T(','));
AfxExtractSubString(strB, subItem, 3, _T(','));
AfxExtractSubString(strT, subItem, 4, _T(','));
AfxExtractSubString(strContinue, subItem, 5, _T(','));
item.z = atof(strZ);
r = (BYTE)atol(strR);
g = (BYTE)atol(strG);
b = (BYTE)atol(strB);
t = (BYTE)atol(strT);
item.m_bContinue = TRUE;
item.SetColor(r, g, b, t);
color.GetColor().add(item);
}
CSize sizeMark(dWidth, dHeight);
CSize sizeWord(0, 0);
CSigmaDoc* pDoc = m_pDoc;
CPtrList* pl = pDoc->GetDraw()->GetValueList();
CString oldName, newName;
COne* pOne;
POSITION pos;
pos = pl->GetHeadPosition();
while (pos)
{
pOne = (COne*)pl->GetNext(pos);
if (!pOne->IsCanEdit() || !pOne->IsView()) continue;
switch (pOne->GetType())
{
case DOUBLEFOX_XYZ:
case DOUBLEFOX_POINT:
{
CPointNameEx* pPoint = (CPointNameEx*)pOne->GetValue();
if (pOne->HowToViewPoint == nullptr)
{
pOne->HowToViewPoint = new CHowToViewPoint;
}
pOne->HowToViewPoint->frColor = color.GetColor(pPoint->z0);
pOne->HowToViewPoint->m_mark = sizeMark;
pOne->HowToViewPoint->m_word = sizeWord;
pOne->HowToViewPoint->SetNullSymbolMode(INSERT_DRAW_CIRCLE);
}
break;
}
}
return true;
}
1 month ago
int CSigmaView::IsProjectionState()
{
if (m_pDoc->GetDraw()->GetProjection().IsEmpty())
{
return -1;
}
return 1;
}
1 month ago
void CSigmaView::OnLButtonDown(int mouseX, int mouseY, HDC hdc, int vk) //ggff2025
{
CItem * pItem = GetItem();
if (pItem == NULL)
return;
pItem->m_client = m_client;
CPoint pt;
pt.x = mouseX;
pt.y = mouseY;
if (HasEnableBKGrid())
pt = GetGridPoint(pt);
if (hdc != nullptr)
{
CDC *pDC = CDC::FromHandle(hdc);
pItem->SetScreenDC(pDC);
pItem->SetBackGroundDC(m_pImgDC);
pItem->OnLButtonDown(pDC, 0, pt, vk);
}
else {
pItem->OnLButtonDown(nullptr, 0, pt, vk);
}
}
void CSigmaView::OnLButtonUp(int mouseX, int mouseY, HDC hdc, int vk)
{
CItem * pItem = GetItem();
if (pItem == NULL)
return;
CPoint pt;
pt.x = mouseX;
pt.y = mouseY;
if (HasEnableBKGrid())
pt = GetGridPoint(pt);
if (hdc != NULL)
{
CDC *pDC = CDC::FromHandle(hdc);
//pView->SetScreenDC(pDC);
pItem->SetScreenDC(pDC);
pItem->SetBackGroundDC(m_pImgDC);
pItem->OnLButtonUp(pDC, 0, pt, vk);
}
else {
pItem->OnLButtonUp(nullptr, 0, pt, vk);
}
}
int CSigmaView::OnLButtonDoubleClick(int mouseX, int mouseY)
{
if (m_pDoc == 0)
return -1;
CPoint point(mouseX, mouseY);
if (HasEnableBKGrid())
point = GetGridPoint(point);
CSigmaDoc* pDoc = m_pDoc;
if (pDoc->GetItem())
{
pDoc->GetItem()->OnLButtonDblClk(0, point);
return 0;
}
else
{
CPoint2D pt = pDoc->GetDC().GetReal(point);
POSITION p = pDoc->GetSelectedItem(pt);
if (!p)
return 1;
int type = pDoc->GetDraw()->GetElementType(p);
if (type == DOUBLEFOX_CURVE)
{
pDoc->ClearSelectionSet();
pDoc->AddToSelectionSet(p);
return 2;
}
return -1;
}
}
int CSigmaView::OnMouseMove(HDC hMemDC, int mouseX, int mouseY, int buttonStatus)
{
CDC *pDC = CDC::FromHandle(hMemDC);
SetScreenDC(pDC);
CPoint pt;
pt.x = mouseX;
pt.y = mouseY;
if (HasEnableBKGrid())
pt = GetGridPoint(pt);
//pView->DrawCrossLine(pDC, pt);
CItem * pItem = GetItem();
if (pItem) {
pItem->SetScreenDC(pDC);
return pItem->OnMouseMove(pDC, buttonStatus, pt);
}
//CDC::FromHandle(hMemDC)->DeleteDC();
return 1;
}
static BOOL IsROP2(int type)
{
if (type != DOUBLEFOX_SECTION &&
type != DOUBLEFOX_WMF &&
type != DOUBLEFOX_MESH &&
type != DOUBLEFOX_IMAGE &&
type != DOUBLEFOX_MXN)
return TRUE;
return FALSE;
}
static DWORD CutImageThreadProc(LPVOID lpParam)
{
ImageCut* imageCut = (ImageCut*)lpParam;
//imageCut->SetCutImageInfo(ciInfo);
//imageCut->StopCutImage(false);
return imageCut->Execute();
}
static DWORD FileTransformerThreadProc(LPVOID lpParam)
{
FileTransformer* transformer = (FileTransformer*)lpParam;
//imageCut->SetCutImageInfo(ciInfo);
//imageCut->StopCutImage(false);
return transformer->Execute();
}