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.
kev/Drawer/Module/GeoSigmaDraw/CurveEditorDefault.h

111 lines
3.8 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include "CurveEditorBase.h"
#include "HandleDrawer.h"
#include "SegmentSnappingEngine.h"
#include <memory>
#include <optional>
/*
* ?????????????
*
* ?????
* 1. ?????????????????
* 2. ??????????????????
* 3. ??????????
*/
class CurveEditorDefault : public CurveEditorBase
{
public:
CurveEditorDefault(CSigmaDoc* pDoc)
: CurveEditorBase(pDoc)
, m_bLButtonDownWhenMouseMove(false)
, m_handleDrawer(std::make_unique<HandleDrawer>(pDoc))
, m_nHandleDrawMode(TRACKER_CIRCLE)
, m_nModeX(-1)
, m_nModeY(-1)
, m_nDragSegmentIndex(-1) {}
virtual ~CurveEditorDefault(void) {}
// Mouse event handlers
void OnDraw(CXyDC* pDC) override;
void OnLButtonDblClk(UINT nFlags, CPoint point) 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;
BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) override;
BOOL OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) override;
BOOL OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) override;
int GetSubMenu() override;
void SetPos(POSITION pos) override;
void Clear(void) override;
void Draw(CDC* pDC) override;
void DrawAssistant(CDC* pDC, int mouseX, int mouseY) override;
int GetNumberOfNode() override;
void EreaseHandles(CDC* pDC) override;
void EndEdit(void) override;
void CancelAll(void) override;
BOOL IsCanCancelAll(void) override;
// Control point operations
int HitTestHandle(CPoint point) override;
void DeleteHandle(int nIndex) override;
int AddHandle(CPoint point) override;
BOOL IsCanAddHandle(CPoint point, double* pl0 = nullptr) override;
CCurveEx* GetControlCurve(void) override;
void GetXY(CCurveEx* pValue, int nIndex, dfPoint& point) override;
void AttachProcess(CPointList& oldPoints, CPointList& newPoints) override;
void DrawMoveLine(void) override;
void GetMarkCurve(void) override;
CPoint2D GetCDown() const override;
CPoint2D GetCLast() const override;
protected:
void OnDrawDragPreview();
void OnCalculateDragEffect(CPointList* pList);
void OnModeInitialize();
void OnDragMove(int nIndex, CPoint2D pt);
int GetOffsetMode(void);
int AddHandle(double l0);
int AddHandle(CCurveEx* pValue, dfPoint add);
//
CPoint2D c_down, c_last; // ??????????
bool m_bLButtonDownWhenMouseMove; // ????
std::unique_ptr<COne> m_pBakOne; // ????????????
std::unique_ptr<HandleDrawer> m_handleDrawer; // ??????
CPoint m_nLButtonDownPoint; // ???????????
CPointList NewPointList; // ??????????
CPointList PointList; // ?????
DWORD m_nHandleDrawMode; // ???????
int m_nModeX, m_nModeY; // ????
// <20>߶<EFBFBD><DFB6>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>س<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>
int m_nDragSegmentIndex; // <20><>ǰ<EFBFBD>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>߶<EFBFBD><DFB6><EFBFBD><EFBFBD><EFBFBD> (-1<><31>ʾδ<CABE>϶<EFBFBD>)
Geometry::SnapResult m_lastSnapResult; // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
private:
void DrawHandle(CXyDC* pDC, CCurveEx* pCurve);
void DrawHandlesByCDC(CDC* pDC, CCurveEx* pCurve);
void DrawSelectHandle(int nHandle);
CRect GetRangeWidthIndex(int nIndex);
CRect GetFirstNodeHandleRectFocus(CPoint point);
void SetDrawMode(int nModeX, int nModeY);
int HitTestHandle(CCurveEx* pValue, CPoint point);
bool IsDragging(int nFlags) const;
int HandleMouseDrag(CXyDC* pDC, CPoint point);
int HandleMouseHover(CDC* dc, CPoint point);
// <20>߶<EFBFBD><DFB6>϶<EFBFBD><CFB6><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int HitTestSegment(CPoint point);
void DrawMoveSegment(CDC* pDC);
NBase::CPoint2D CalculateSnappedMousePos(NBase::CPoint2D rawMouse, int segmentIndex);
NBase::CPoint2D CalculateNormalOffset(dfPoint p1, dfPoint p2, double dx, double dy);
double DistancePointToLine(double px, double py, double x1, double y1, double x2, double y2);
CRect8 GetLineSegmentAABB(const dfPoint& point1, const dfPoint& point2, double width) const;
};