52f99d93 |
1 | // Created on: 2012-05-28 |
2 | // |
3 | // Copyright (c) 2012-2014 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef _IVtkDraw_Interactor_HeaderFile |
17 | #define _IVtkDraw_Interactor_HeaderFile |
18 | |
19 | #include <Standard.hxx> |
20 | #include <Standard_Macro.hxx> |
21 | #include <MMgt_TShared.hxx> |
22 | |
23 | #ifdef _WIN32 |
24 | #include <windows.h> |
25 | #else |
26 | #include <X11/X.h> |
27 | #include <X11/Xlib.h> |
28 | #include <X11/Shell.h> |
29 | #include <X11/Xutil.h> |
30 | #include <tk.h> |
31 | #endif |
32 | |
33 | #include <vtkRenderWindowInteractor.h> |
34 | #include <vtkSmartPointer.h> |
35 | #include <IVtkTools_ShapePicker.hxx> |
36 | #include <IVtkDraw_HighlightAndSelectionPipeline.hxx> |
37 | #include <Aspect_Window.hxx> |
38 | |
39 | class vtkWin32RenderWindowInteractor; |
40 | typedef vtkSmartPointer<IVtkTools_ShapePicker> PSelector; |
41 | |
42 | class IVtkDraw_Interactor : public vtkRenderWindowInteractor |
43 | { |
44 | public: |
45 | static IVtkDraw_Interactor *New(); |
46 | vtkTypeMacro (IVtkDraw_Interactor, vtkRenderWindowInteractor); |
47 | |
48 | virtual void Initialize(); |
49 | virtual void Enable(); |
50 | virtual void Start() { } |
51 | |
52 | void SetShapePicker (const PSelector& theSelector); |
53 | void SetPipelines (const Handle(ShapePipelineMap)& thePipelines); |
54 | void SetOCCWindow (const Handle(Aspect_Window)& theWindow); |
55 | const Handle(Aspect_Window)& GetOCCWindow() const; |
56 | |
57 | //! Process highlighting |
58 | void MoveTo (Standard_Integer theX, Standard_Integer theY); |
59 | |
60 | //! Process selection |
61 | void OnSelection(); |
62 | |
63 | Standard_Boolean IsEnabled() const; |
64 | |
65 | #ifndef _WIN32 |
66 | Display* GetDisplayId() const; |
67 | Standard_Integer ViewerMainLoop (Standard_Integer theArgNum, const char** theArgs); |
68 | #endif |
69 | |
70 | protected: |
71 | IVtkDraw_Interactor(); |
72 | IVtkDraw_Interactor (const IVtkDraw_Interactor& ); |
73 | ~IVtkDraw_Interactor(); |
74 | |
75 | |
76 | #ifdef _WIN32 |
77 | friend LRESULT CALLBACK WndProc (HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam); |
78 | friend LRESULT CALLBACK ViewerWindowProc (HWND hwnd, |
79 | UINT Msg, |
80 | WPARAM wParam, |
81 | LPARAM lParam, |
82 | IVtkDraw_Interactor *theInteractor); |
83 | |
84 | void OnMouseMove (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y); |
85 | void OnRButtonDown (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y, Standard_Integer repeat=0); |
86 | void OnRButtonUp (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y); |
87 | void OnMButtonDown (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y, Standard_Integer repeat=0); |
88 | void OnMButtonUp (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y); |
89 | void OnLButtonDown (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y, Standard_Integer repeat=0); |
90 | void OnLButtonUp (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y); |
91 | void OnSize (HWND wnd, UINT nType, Standard_Integer X, Standard_Integer Y); |
92 | void OnTimer (HWND wnd, UINT nIDEvent); |
93 | void OnMouseWheelForward (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y); |
94 | void OnMouseWheelBackward (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y); |
95 | #else |
96 | static void ProcessEvents (ClientData theData, int); |
97 | void GetMousePosition (Standard_Integer *theX, Standard_Integer *theY); |
98 | #endif |
99 | |
100 | |
101 | private: |
102 | |
103 | #ifdef _WIN32 |
104 | HWND myWindowId; |
105 | Standard_Integer myMouseInWindow; |
106 | #else |
107 | Window myWindowId; |
108 | Display *myDisplayId; |
109 | Standard_Boolean myIsLeftButtonPressed; |
110 | #endif |
111 | |
112 | PSelector mySelector; |
113 | Handle(ShapePipelineMap) myPipelines; |
114 | Handle(Aspect_Window) myWindow; |
115 | |
116 | }; |
117 | |
118 | #endif |