0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / IVtkDraw / IVtkDraw_Interactor.hxx
CommitLineData
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>
25e59720 21#include <Standard_Transient.hxx>
52f99d93 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
a9660929 33// prevent disabling some MSVC warning messages by VTK headers
34#ifdef _MSC_VER
35#pragma warning(push)
36#endif
52f99d93 37#include <vtkRenderWindowInteractor.h>
38#include <vtkSmartPointer.h>
a9660929 39#ifdef _MSC_VER
40#pragma warning(pop)
41#endif
42
52f99d93 43#include <IVtkTools_ShapePicker.hxx>
44#include <IVtkDraw_HighlightAndSelectionPipeline.hxx>
45#include <Aspect_Window.hxx>
46
47class vtkWin32RenderWindowInteractor;
48typedef vtkSmartPointer<IVtkTools_ShapePicker> PSelector;
49
50class IVtkDraw_Interactor : public vtkRenderWindowInteractor
51{
52public:
53 static IVtkDraw_Interactor *New();
68858c7d 54
55 vtkTypeMacro (IVtkDraw_Interactor, vtkRenderWindowInteractor)
52f99d93 56
57 virtual void Initialize();
58 virtual void Enable();
59 virtual void Start() { }
60
1e756cb9 61 const PSelector& Selector() const { return mySelector; }
52f99d93 62 void SetShapePicker (const PSelector& theSelector);
63 void SetPipelines (const Handle(ShapePipelineMap)& thePipelines);
64 void SetOCCWindow (const Handle(Aspect_Window)& theWindow);
65 const Handle(Aspect_Window)& GetOCCWindow() const;
66
67 //! Process highlighting
68 void MoveTo (Standard_Integer theX, Standard_Integer theY);
69
70 //! Process selection
71 void OnSelection();
72
73 Standard_Boolean IsEnabled() const;
74
75#ifndef _WIN32
76 Display* GetDisplayId() const;
77 Standard_Integer ViewerMainLoop (Standard_Integer theArgNum, const char** theArgs);
78#endif
79
80protected:
81 IVtkDraw_Interactor();
52f99d93 82 ~IVtkDraw_Interactor();
83
52f99d93 84#ifdef _WIN32
85 friend LRESULT CALLBACK WndProc (HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam);
86 friend LRESULT CALLBACK ViewerWindowProc (HWND hwnd,
87 UINT Msg,
88 WPARAM wParam,
89 LPARAM lParam,
90 IVtkDraw_Interactor *theInteractor);
91
92 void OnMouseMove (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y);
93 void OnRButtonDown (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y, Standard_Integer repeat=0);
94 void OnRButtonUp (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y);
95 void OnMButtonDown (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y, Standard_Integer repeat=0);
96 void OnMButtonUp (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y);
97 void OnLButtonDown (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y, Standard_Integer repeat=0);
98 void OnLButtonUp (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y);
99 void OnSize (HWND wnd, UINT nType, Standard_Integer X, Standard_Integer Y);
100 void OnTimer (HWND wnd, UINT nIDEvent);
101 void OnMouseWheelForward (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y);
102 void OnMouseWheelBackward (HWND wnd, UINT nFlags, Standard_Integer X, Standard_Integer Y);
103#else
104 static void ProcessEvents (ClientData theData, int);
105 void GetMousePosition (Standard_Integer *theX, Standard_Integer *theY);
106#endif
107
c7854818 108private:
109 // copying is prohibited
110 IVtkDraw_Interactor (const IVtkDraw_Interactor&);
111 void operator = (const IVtkDraw_Interactor&);
52f99d93 112
113private:
114
115#ifdef _WIN32
116 HWND myWindowId;
117 Standard_Integer myMouseInWindow;
118#else
119 Window myWindowId;
120 Display *myDisplayId;
121 Standard_Boolean myIsLeftButtonPressed;
122#endif
123
124 PSelector mySelector;
125 Handle(ShapePipelineMap) myPipelines;
126 Handle(Aspect_Window) myWindow;
127
128};
129
130#endif