SimpleGraphView.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. // SimpleGraphView.h : interface of the CSimpleGraphView class
  19. //
  20. /////////////////////////////////////////////////////////////////////////////
  21. #if !defined(AFX_SIMPLEGRAPHVIEW_H__C44E4EBD_F133_11D3_A08F_00104B791122__INCLUDED_)
  22. #define AFX_SIMPLEGRAPHVIEW_H__C44E4EBD_F133_11D3_A08F_00104B791122__INCLUDED_
  23. #if _MSC_VER > 1000
  24. #pragma once
  25. #endif // _MSC_VER > 1000
  26. #include "resource.h"
  27. #include "cardinalspline.h"
  28. #include "vector2.h"
  29. class CSimpleGraphDoc;
  30. class CSimpleGraphView : public CView
  31. {
  32. protected: // create from serialization only
  33. CSimpleGraphView();
  34. DECLARE_DYNCREATE(CSimpleGraphView)
  35. // Attributes
  36. public:
  37. CSimpleGraphDoc* GetDocument();
  38. // Operations
  39. public:
  40. // Overrides
  41. // ClassWizard generated virtual function overrides
  42. //{{AFX_VIRTUAL(CSimpleGraphView)
  43. public:
  44. virtual void OnDraw(CDC* pDC); // overridden to draw this view
  45. virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
  46. virtual void OnInitialUpdate();
  47. //}}AFX_VIRTUAL
  48. // Implementation
  49. public:
  50. virtual ~CSimpleGraphView();
  51. #ifdef _DEBUG
  52. virtual void AssertValid() const;
  53. virtual void Dump(CDumpContext& dc) const;
  54. #endif
  55. protected:
  56. // Generated message map functions
  57. protected:
  58. //{{AFX_MSG(CSimpleGraphView)
  59. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  60. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  61. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  62. afx_msg void OnDelete();
  63. afx_msg void OnUpdateDelete(CCmdUI* pCmdUI);
  64. afx_msg void OnZoomExtents();
  65. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  66. afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
  67. //}}AFX_MSG
  68. DECLARE_MESSAGE_MAP()
  69. public:
  70. //////////////////////////////////////////////////////////
  71. // Protected methods
  72. //////////////////////////////////////////////////////////
  73. void Render_Graph (CDC *dc);
  74. void Get_Visible_Points (int *left_pt, int *right_pt);
  75. typedef enum
  76. {
  77. HIT_GRAPH_AREA = 1,
  78. HIT_POINT,
  79. HIT_AXIS,
  80. HIT_UNKNOWN
  81. } HITTYPE;
  82. HITTYPE Hit_Test (const CPoint &point, int *hit_pt);
  83. void Get_Graph_Rect (CRect &rect);
  84. void Value_To_Point (const Vector2 &value, CPoint *point);
  85. void Point_To_Value (const CPoint &point, Vector2 *value);
  86. int Move_Value (int old_index, const Vector2 &new_value);
  87. void Render_Axis (CDC *dc);
  88. void Repaint_Graph (void);
  89. void Render_Points (CDC *dc);
  90. int Add_New_Point (CPoint &point);
  91. void Delete_Point (int index);
  92. int Get_Selection (void) const { return m_SelPt; }
  93. void Get_Ranges (Vector2 &range_min, Vector2 &range_max) { range_min = m_Min; range_max = m_Max; }
  94. void Set_Ranges (Vector2 &range_min, Vector2 &range_max) { m_Min = range_min; m_Max = range_max; Repaint_Graph (); }
  95. protected:
  96. //////////////////////////////////////////////////////////
  97. // Protected member data
  98. //////////////////////////////////////////////////////////
  99. Vector2 m_Min;
  100. Vector2 m_Max;
  101. int m_DraggingPt;
  102. int m_SelPt;
  103. CBrush m_Brush;
  104. CBrush m_SelBrush;
  105. HFONT m_Font;
  106. CPoint m_ZoomPt;
  107. bool m_IsZooming;
  108. };
  109. #ifndef _DEBUG // debug version in SimpleGraphView.cpp
  110. inline CSimpleGraphDoc* CSimpleGraphView::GetDocument()
  111. { return (CSimpleGraphDoc*)m_pDocument; }
  112. #endif
  113. /////////////////////////////////////////////////////////////////////////////
  114. //{{AFX_INSERT_LOCATION}}
  115. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  116. #endif // !defined(AFX_SIMPLEGRAPHVIEW_H__C44E4EBD_F133_11D3_A08F_00104B791122__INCLUDED_)