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.

109 lines
3.5 KiB
C

1 month ago
#pragma once
#include "ItemCurve.h"
#include "ItemArc.h"
#include "ItemSelectElement.h"
1 month ago
#include <vector>
1 month ago
namespace NItem
{
class CItemCurveArc :
public CItemCurve
{
public:
CItemCurveArc(CSigmaDoc * ppDoc);
virtual ~CItemCurveArc(void);
protected:
CItemArc* m_pArc;
public:
void OnLButtonDown(CDC *pDC, UINT nFlags, CPoint point, int vk) override;
int OnMouseMove(CDC* pDC, UINT nFlags, CPoint point) override;//, BYTE*& destBuffer, int& destLen);
void OnLButtonUp(CDC* pDC, UINT nFlags, CPoint point, int vk) override;
virtual void SetCurveState(int state, CDC * pDC);
int loop;
BOOL IsArcState(void);
};
class CItemCurveSpline :
public CItemCurveArc
{
public:
CItemCurveSpline(CSigmaDoc * ppDoc);
virtual ~CItemCurveSpline(void);
public:
void OnDraw(CXyDC* pDC) override;
void OnLButtonDown(CDC *pDC, UINT nFlags, CPoint point, int vk) override;
int OnMouseMove(CDC* pDC, UINT nFlags, CPoint point) override;
void OnLButtonUp(CDC *pDc, UINT nFlags, CPoint point, int vk) override;
virtual void SetCurveState(int state, CDC * pDC);
virtual void AppendPoint(void);
void clearSplineData();
BOOL OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) override;
void EraseAuxiliarySpline(CDC * pScreenDC);
void DrawAssistant(CDC * pDC, int mouseX, int mouseY) override;
1 month ago
void AutoClose(void) override;
POSITION NextCurve(void) override;
void Undo(void) override;
void Redo(void) override;
BOOL IsCanUndo(void) override;
BOOL IsCanRedo(void) override;
void OnCancel(void) override;
1 month ago
BOOL IsSplineState(void);
void RemoveTail(void);
BOOL IsOnlyPointListTail(void);
protected:
1 month ago
void BuildSplineCurve(const CPointList& controlPoints, CPointList& outSampledPoints);
void DrawSplineCurve(CXyDC* pDC, const CPointList& controlPoints);
void DrawControlPointHandles(CXyDC* pDC, const CPointList& controlPoints);
void ErasePreview(CDC* pScreenDC);
void DrawPreview(CDC* pScreenDC);
CPointList m_controlPoints; // single source of truth: spline control points
std::vector<CPoint> m_cachedScreenPoints; // cached screen coordinates for XOR erase
1 month ago
private:
1 month ago
void DrawControlPointHandles(CDC* pDC);
// Diff and incremental drawing helpers
size_t FindCommonPrefixLength(const std::vector<CPoint>& oldPoints,
const std::vector<CPoint>& newPoints);
void DrawPolylineXOR(CDC* pDC, const std::vector<CPoint>& points, size_t startIdx);
void IncrementalUpdatePreview(CDC* pScreenDC, const std::vector<CPoint>& newScreenPoints);
1 month ago
int m_nSplineNodes;
int m_mSmoothStepFactor;
};
class CItemCurveMerge :
public CItemCurveSpline
{
public:
CItemCurveMerge(CSigmaDoc * ppDoc);
virtual ~CItemCurveMerge(void);
void OnLButtonDown(CDC *pDC, UINT nFlags, CPoint point, int vk) override;
int OnMouseMove(CDC *pDC, UINT nFlags, CPoint point) override;// , BYTE*& destBuffer, int& destLen);
void OnLButtonUp(CDC *pDC, UINT nFlags, CPoint point, int vk) override;
void DrawAssistant(CDC * pDC, int mouseX, int mouseY) override;
virtual BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
void EndCurve();
void AddCurve();
void AutoClose(void);
void ChangeMergeState();
virtual void OnCancel(void) override;
virtual void SetCurveState(int state, CDC * pDC) override;
protected:
void EreaseOldLine();
void DrawLine(dfPoint pt1, dfPoint pt2);
void MergeElement(POSITION pos, CPoint2D& dp);
CItemSelectElement * m_pItemSelect;
CPointList m_ptDisposableList;
public:
BOOL IsMergeState(void);
};
};