7d8f474c3c896d8425ad616db95a519773c7ca72
[occt.git] / samples / mfc / standard / 04_Viewer3d / src / Viewer3dView.h
1 // Viewer3dView.h : interface of the CViewer3dView class
2 //
3 /////////////////////////////////////////////////////////////////////////////
4
5 #if !defined(AFX_VIEWERVIEW_H__4EF39FBC_4EBB_11D1_8D67_0800369C8A03__INCLUDED_)
6 #define AFX_VIEWERVIEW_H__4EF39FBC_4EBB_11D1_8D67_0800369C8A03__INCLUDED_
7
8 #include <Viewer3dDoc.h>
9
10 #include <V3d_DirectionalLight.hxx>
11 #include <V3d_PositionalLight.hxx>
12 #include <V3d_AmbientLight.hxx>
13 #include <V3d_SpotLight.hxx>
14 #include <Graphic3d_GraphicDriver.hxx>
15
16 #include <Graphic3d_ClipPlane.hxx>
17
18 #if _MSC_VER >= 1000
19 #pragma once
20 #endif // _MSC_VER >= 1000
21 enum View3D_CurrentAction { 
22   CurAction3d_Nothing,
23   CurAction3d_DynamicZooming,
24   CurAction3d_WindowZooming,
25   CurAction3d_DynamicPanning,
26   CurAction3d_GlobalPanning,
27   CurAction3d_DynamicRotation,
28   CurAction3d_BeginSpotLight,
29   CurAction3d_TargetSpotLight,
30   CurAction3d_EndSpotLight,
31   CurAction3d_BeginPositionalLight,
32   CurAction3d_BeginDirectionalLight,
33   CurAction3d_EndDirectionalLight
34 };
35
36 class CViewer3dView : public CView
37 {
38 protected: // create from serialization only
39         CViewer3dView();
40         DECLARE_DYNCREATE(CViewer3dView)
41
42 public:
43   CViewer3dDoc* GetDocument();
44   void Redraw() {   myView->Redraw(); };
45   void InitButtons();
46   void Reset();
47   void GetViewAt (Standard_Real& theX, Standard_Real& theY, Standard_Real& theZ) const;
48   void SetViewAt (const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ);
49   void GetViewEye (Standard_Real& X, Standard_Real& Y, Standard_Real& Z);
50   void SetViewEye (const Standard_Real X,const Standard_Real Y,const Standard_Real Z);
51   Standard_Real GetViewScale();
52   void SetViewScale (const Standard_Real Coef);
53   void FitAll() {   myView->FitAll();  myView->ZFitAll();  };
54
55
56 // Overrides
57         // ClassWizard generated virtual function overrides
58         //{{AFX_VIRTUAL(CViewer3dView)
59         public:
60         virtual void OnDraw(CDC* pDC);  // overridden to draw this view
61         virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
62         virtual void OnInitialUpdate();
63         //}}AFX_VIRTUAL
64
65 // Implementation
66 public:
67         virtual ~CViewer3dView();
68 #ifdef _DEBUG
69         virtual void AssertValid() const;
70         virtual void Dump(CDumpContext& dc) const;
71 #endif
72
73   int scaleX;
74   int scaleY;
75   int scaleZ;
76
77 protected:
78
79 // Generated message map functions
80 protected:
81         //{{AFX_MSG(CViewer3dView)
82         afx_msg void OnBUTTONAxo();
83         afx_msg void OnBUTTONBack();
84         afx_msg void OnBUTTONBottom();
85         afx_msg void OnBUTTONFront();
86         afx_msg void OnBUTTONHlrOff();
87         afx_msg void OnBUTTONHlrOn();
88         afx_msg void OnBUTTONLeft();
89         afx_msg void OnBUTTONPan();
90         afx_msg void OnBUTTONPanGlo();
91         afx_msg void OnBUTTONReset();
92         afx_msg void OnBUTTONRight();
93         afx_msg void OnBUTTONRot();
94         afx_msg void OnBUTTONTop();
95         afx_msg void OnBUTTONZoomAll();
96         afx_msg void OnSize(UINT nType, int cx, int cy);
97         afx_msg void OnBUTTONZoomProg();
98         afx_msg void OnBUTTONZoomWin();
99         afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
100   afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
101         afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
102         afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
103         afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
104         afx_msg void OnMouseMove(UINT nFlags, CPoint point);
105         afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
106         afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
107     afx_msg void OnUpdateBUTTONHlrOff(CCmdUI* pCmdUI);
108         afx_msg void OnUpdateBUTTONHlrOn(CCmdUI* pCmdUI);
109         afx_msg void OnUpdateBUTTONPanGlo(CCmdUI* pCmdUI);
110         afx_msg void OnUpdateBUTTONPan(CCmdUI* pCmdUI);
111         afx_msg void OnUpdateBUTTONZoomProg(CCmdUI* pCmdUI);
112         afx_msg void OnUpdateBUTTONZoomWin(CCmdUI* pCmdUI);
113         afx_msg void OnUpdateBUTTONRot(CCmdUI* pCmdUI);
114         afx_msg void OnModifyChangeBackground();
115         afx_msg void OnDirectionalLight();
116         afx_msg void OnSpotLight();
117         afx_msg void OnPositionalLight();
118         afx_msg void OnAmbientLight();
119         afx_msg void OnScale();
120         afx_msg void OnShadingmodel();
121         afx_msg void OnAntialiasingonoff();
122         afx_msg void OnClearLights();
123         afx_msg void OnModelclipping();
124         afx_msg void OnOptionsTrihedronStaticTrihedron();
125         //}}AFX_MSG
126         DECLARE_MESSAGE_MAP()
127 private:
128         enum VisMode { VIS_WIREFRAME, VIS_SHADE, VIS_HLR };
129         VisMode                        myVisMode;
130         
131   Handle(V3d_View)                myView;
132   Handle(Graphic3d_GraphicDriver) myGraphicDriver;
133   View3D_CurrentAction           myCurrentMode;
134   Standard_Integer               myXmin;
135   Standard_Integer               myYmin;
136   Standard_Integer               myXmax;
137   Standard_Integer               myYmax;
138
139   Standard_Integer               NbActiveLights;
140   Standard_Boolean               myHlrModeIsOn;
141   Standard_Real                  myCurZoom;
142   Handle(V3d_AmbientLight)       myCurrent_AmbientLight;
143   Handle(V3d_SpotLight)          myCurrent_SpotLight;
144   Handle(V3d_PositionalLight)    myCurrent_PositionalLight;
145   Handle(V3d_DirectionalLight)   myCurrent_DirectionalLight;
146   Handle(Graphic3d_ClipPlane)    myClippingPlane;
147   Handle(AIS_Shape)              myShape;
148
149 private:
150         enum LineStyle { Solid, Dot, ShortDash, LongDash, Default };
151         CPen*  m_Pen;
152     virtual void DrawRectangle (const Standard_Integer  MinX  ,
153                                                 const Standard_Integer  MinY  ,
154                                 const Standard_Integer  MaxX  ,
155                                                 const Standard_Integer  MaxY  ,
156                                                     const Standard_Boolean  Draw  ,
157                                 const LineStyle aLineStyle = Default  );
158         UINT myAxisKey;
159         UINT myScaleDirection;
160         void RedrawVisMode();
161
162 };
163
164 #ifndef _DEBUG  // debug version in Viewer3dView.cpp
165 inline CViewer3dDoc* CViewer3dView::GetDocument()
166    { return (CViewer3dDoc*)m_pDocument; }
167 #endif
168
169 /////////////////////////////////////////////////////////////////////////////
170
171 //{{AFX_INSERT_LOCATION}}
172 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
173
174 #endif // !defined(AFX_VIEWERVIEW_H__4EF39FBC_4EBB_11D1_8D67_0800369C8A03__INCLUDED_)