SDC C-Project CF Review 프로그램
LYW
2021-07-01 4acd943c6f0beecd3ee573f77d8d6c7524fd5045
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#pragma once
 
#include <list>
#include "CHImageData.h"
#include "CHRectTracker.h"
 
namespace CHImageControls
{
    enum DrawType            { DrawOrigin=0, DrawScale, DrawFit };
    enum ObjectType            { ObjectLine=1, ObjectRectangle=2, ObjectCircle=4, ObjectText=8, ObjectTextRect=16 };
}
 
class AFX_EXT_CLASS CCHDrawObject
{
public:
    CCHDrawObject() { Reset(); }
 
    CCHDrawObject(int left, int top, int right, int bottom)
    {
        Reset();
        nLeft            = left;
        nTop            = top;
        nRight            = right;
        nBottom            = bottom;
    }
 
    void Reset()
    {
        nLeft            = 0;
        nTop            = 0;
        nRight            = 0;
        nBottom            = 0;
        nObjectType        = 1;    
        nForeColor        = RGB(255,0,0);
        nBackColor        = NULL_BRUSH;
        nSize            = 1;
        nTextWidth        = 8;
        nTextHeight        = 16;
        strTextString    = _T("");
    }
 
    int GetWidth()        { return (nRight-nLeft)+1; }
    int GetHeight()        { return (nBottom-nTop)+1; }
    int GetCenterX()    { return nLeft + (GetWidth()/2); }
    int GetCenterY()    { return nLeft + (GetHeight()/2); }
 
    int            nObjectType;
    int            nLeft;
    int            nTop;
    int            nRight;
    int            nBottom;
    DWORD        nForeColor;
    DWORD        nBackColor;
    int            nSize;
 
    int            nTextWidth;
    int            nTextHeight;
    CString        strTextString;
 
};
typedef std::list<CCHDrawObject>                ListDrawObject;
typedef std::list<CCHDrawObject>::iterator        ListDrawObjectIt;
 
class AFX_EXT_CLASS CCHImageView : public CWnd, public CCHImageData
{
    DECLARE_DYNAMIC(CCHImageView)
public:
    CCHImageView();
    CCHImageView(CWnd *pParentWnd);
    virtual ~CCHImageView();
 
    void    Reset();
    
    // getter
    double    GetWidthScale(void)            { return m_dWidthScale; }
    double    GetHeightScale(void)        { return m_dHeightScale; }
    int        GetScaleWidth(void);
    int        GetScaleHeight(void);
    int        GetHScrollPos(void);
    int        GetVScrollPos(void);
 
    // setter
    void    SetDrawObject(BOOL bDraw);
    void    SetDrawType(int nDrawType);
    void    SetViewName(const CString strViewName);
    void    SetParentWnd(CWnd* pParentWnd);
    void    SetDrawScale(double dScale);    
 
    BOOL    LoadImage(const CString& strFilename);
 
    void    AddDrawObject(const CCHDrawObject& drawObject);
    void    DeleteAllDrawObject(void);
    void    DeleteAllDrawObject(int nType);
    void    DeleteTailDrawObject(void);
    void    DeleteDrawObject(const CRect& rtRect);
 
    CCHDrawObject * GetDrawObject(UINT nIndex);
    
protected:
    DECLARE_MESSAGE_MAP()
 
protected:
    void    DrawObject(CDC *pDC, CCHDrawObject *pObject);
    void    DrawObjectList(CDC *pDC);
    void    DrawText(CDC *pDC, int nLeft, int nTop, int nRight, int nBottom, double dScaleX, double dScaleY, CCHDrawObject *pObject);
    int        PointInDrawObject(CPoint point, CRect& rtResult);
    void    UpdateImageView(CDC *pDC);
 
    CWnd        *m_pParentWnd;
    CString        m_strViewName;
 
    // pre draw info
    CRect        m_rtClientRect;
    int            m_nScaleWidth;
    int            m_nScaleHeight;
 
    // Scroll Pos
    int            m_nVScroll;
    int            m_nHScroll;
 
    // Max Scroll Pos
    int            m_nMaxVScroll;
    int            m_nMaxHScroll;
 
 
    // image draw
    double            m_dWidthScale; 
    double            m_dHeightScale;
    int                m_nDrawType;
    BOOL            m_bDrawObject;
    
    ListDrawObject    m_ListDrawObject;
 
public:
    afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
    afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
    afx_msg void OnPaint();
    afx_msg void OnDestroy();
 
    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
    afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
 
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
 
    afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
    afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
 
    afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//    afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
};