0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / samples / mfc / standard / Common / OCC_BaseView.h
1 // OCC_BaseView.h: interface for the OCC_BaseView class.
2 //
3 //////////////////////////////////////////////////////////////////////
4
5 #if !defined(AFX_OCC_BASEVIEW_H__2E048CCA_38F9_11D7_8611_0060B0EE281E__INCLUDED_)
6 #define AFX_OCC_BASEVIEW_H__2E048CCA_38F9_11D7_8611_0060B0EE281E__INCLUDED_
7
8 #if _MSC_VER > 1000
9 #pragma once
10 #endif // _MSC_VER > 1000
11
12 #include <stdafx.h>
13
14 #include "OCC_BaseDoc.h"
15 #include "AIS_ViewController.hxx"
16
17 enum CurAction3d
18 {
19   CurAction3d_Nothing,
20   CurAction3d_DynamicZooming,
21   CurAction3d_WindowZooming,
22   CurAction3d_DynamicPanning,
23   CurAction3d_GlobalPanning,
24   CurAction3d_DynamicRotation
25 };
26
27 class Standard_EXPORT OCC_BaseView  : public CView, public AIS_ViewController
28 {
29   
30 public:
31   
32         OCC_BaseView();
33         virtual ~OCC_BaseView();
34
35   //! Return the view.
36   const Handle(V3d_View)& GetView() const { return myView; }
37
38   void FitAll() {   if ( !myView.IsNull() ) myView->FitAll();  myView->ZFitAll(); };
39   void Redraw() {   if ( !myView.IsNull() ) myView->Redraw(); };
40
41   void SetZoom ( const Standard_Real& Coef  ) {   myView->SetZoom ( Coef  );  };
42
43   //! Return the document.
44   OCC_BaseDoc* GetDocument();
45
46   //! Request view redrawing.
47   void update3dView();
48
49   //! Flush events and redraw view.
50   void redraw3dView();
51
52 protected:
53
54   //! Handle view redraw.
55   virtual void handleViewRedraw (const Handle(AIS_InteractiveContext)& theCtx,
56                                  const Handle(V3d_View)& theView) Standard_OVERRIDE;
57
58   //! Callback called by handleMoveTo() on Selection in 3D Viewer.
59   virtual void OnSelectionChanged (const Handle(AIS_InteractiveContext)& theCtx,
60                                    const Handle(V3d_View)& theView) Standard_OVERRIDE;
61
62   //! Return interactive context.
63   virtual const Handle(AIS_InteractiveContext)& GetAISContext() const;
64
65 protected:
66
67   //! Setup mouse gestures.
68   void defineMouseGestures();
69
70   //! Get current action.
71   CurAction3d getCurrentAction() const { return myCurrentMode; }
72
73   //! Set current action.
74   void setCurrentAction (CurAction3d theAction)
75   {
76     myCurrentMode = theAction;
77     defineMouseGestures();
78   }
79
80 public:
81
82   virtual BOOL PreCreateWindow (CREATESTRUCT& cs) Standard_OVERRIDE;
83   virtual void PostNcDestroy() Standard_OVERRIDE;
84
85 protected:
86
87   Handle(V3d_View)    myView;
88   AIS_MouseGestureMap myDefaultGestures;
89   Graphic3d_Vec2i     myClickPos;
90   Standard_Real       myCurZoom;
91   unsigned int        myUpdateRequests; //!< counter for unhandled update requests
92
93 private:
94
95   CurAction3d         myCurrentMode;
96
97 // message map functions
98 protected:
99   DECLARE_MESSAGE_MAP()
100 public:
101   virtual void OnInitialUpdate() Standard_OVERRIDE;
102   virtual void OnDraw (CDC* /*pDC*/) Standard_OVERRIDE;
103   afx_msg void OnSize (UINT nType, int cx, int cy);
104   afx_msg BOOL OnMouseWheel (UINT theFlags, short theDelta, CPoint thePoint);
105   afx_msg void OnMouseMove (UINT theFlags, CPoint thePoint);
106   afx_msg void OnMouseLeave();
107   afx_msg void OnLButtonDown (UINT theFlags, CPoint thePoint);
108   afx_msg void OnLButtonUp (UINT theFlags, CPoint thePoint);
109   afx_msg void OnMButtonDown (UINT theFlags, CPoint thePoint);
110   afx_msg void OnMButtonUp (UINT theFlags, CPoint thePoint);
111   afx_msg void OnRButtonDown (UINT theFlags, CPoint thePoint);
112   afx_msg void OnRButtonUp (UINT theFlags, CPoint thePoint);
113 };
114
115 #endif // !defined(AFX_OCC_BASEVIEW_H__2E048CCA_38F9_11D7_8611_0060B0EE281E__INCLUDED_)