!XT (Code) Update copyright headers in Code/Sandbox.
[CRYENGINE.git] / Code / Sandbox / EditorQt / Util / Ruler.h
blobcc214897f04d1e3db42222f1a76406ae5db2eccc
1 // Copyright 2001-2018 Crytek GmbH / Crytek Group. All rights reserved.
3 #ifndef __RULER_H__
4 #define __RULER_H__
6 #include "RulerPoint.h"
7 #include "RulerPathAgent.h"
9 #include <EditorFramework/Preferences.h>
10 #include <CrySerialization/yasli/decorators/Range.h>
12 // Preferences
13 struct SRulerPreferences : public SPreferencePage
15 SRulerPreferences()
16 : SPreferencePage("Ruler", "Viewport/Gizmo")
17 , rulerSphereScale(0.5f)
18 , rulerSphereTrans(0.5f)
22 virtual bool Serialize(yasli::Archive& ar) override
24 ar.openBlock("Ruler", "Ruler");
25 ar(yasli::Range(rulerSphereScale, 0.01f, 100.f), "rulerSphereScale", "Ruler Sphere Scale");
26 ar(yasli::Range(rulerSphereTrans, 0.01f, 100.f), "rulerSphereTrans", "Ruler Sphere Transparency");
27 ar.closeBlock();
29 return true;
32 // Scale size and transparency for debug spheres when using Ruler tool
33 float rulerSphereScale;
34 float rulerSphereTrans;
37 //! The Ruler utility helps to determine distances between user-specified points.
38 class CRuler
40 public:
41 CRuler();
42 ~CRuler();
44 //! Returns if ruler has queued paths in the path agent
45 bool HasQueuedPaths() const;
47 //! Activate the ruler
48 void SetActive(bool bActive);
49 bool IsActive() const { return m_bActive; }
51 //! Update
52 void Update();
54 //! Mouse callback handling from viewport
55 bool MouseCallback(CViewport* pView, EMouseEvent event, CPoint& point, int flags);
57 private:
58 //! Mouse callback helpers
59 void OnMouseMove(CViewport* pView, CPoint& point, int flags);
60 void OnLButtonUp(CViewport* pView, CPoint& point, int flags);
61 void OnMButtonUp(CViewport* pView, CPoint& point, int flags);
62 void OnRButtonUp(CViewport* pView, CPoint& point, int flags);
64 //! Returns world point based on mouse point
65 void UpdateRulerPoint(CViewport* pView, const CPoint& point, CRulerPoint& rulerPoint, bool bRequestPath);
67 //! Request a path using the path agent
68 void RequestPath();
70 bool IsObjectSelectMode() const;
72 private:
73 bool m_bActive;
74 CryGUID m_MouseOverObject;
76 // Base point
77 CRulerPoint m_startPoint;
78 CRulerPoint m_endPoint;
80 // Path agent(s)
81 CRulerPathAgent* m_pPathAgents;
82 int m_numPathAgents;
84 float m_sphereScale;
85 float m_sphereTrans;
88 #endif //__RULER_H__