1 // Created on: 2012-05-28
3 // Copyright (c) 2011-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #define _WIN32_WINNT 0x0400 // for trackmouseevent support requires Win95 with IE 3.0 or greater.
19 #include <vtkWin32RenderWindowInteractor.h>
20 #include <vtkWin32OpenGLRenderWindow.h>
23 #include <IVtkTools_ShapePicker.hxx>
24 #include <IVtkTools_SubPolyDataFilter.hxx>
25 #include <IVtkTools_DisplayModeFilter.hxx>
26 #include <IVtkTools_ShapeObject.hxx>
27 #include <IVtkTools_ShapeDataSource.hxx>
28 #include <IVtkDraw_Interactor.hxx>
30 #include <Message.hxx>
31 #include <Message_Messenger.hxx>
34 #include <vtkActorCollection.h>
35 #include <vtkCommand.h>
36 #include <vtkObjectFactory.h>
37 #include <vtkSmartPointer.h>
41 #include <X11/Shell.h>
44 #include <vtkXRenderWindowInteractor.h>
45 #include <vtkXOpenGLRenderWindow.h>
46 #include <X11/Xutil.h>
50 //===========================================================
51 // Function : ClearHighlightAndSelection
53 //===========================================================
54 static void ClearHighlightAndSelection (const Handle(ShapePipelineMap)& theMap,
55 const Standard_Boolean doHighlighting,
56 const Standard_Boolean doSelection)
58 if (!doHighlighting && !doSelection)
63 for (ShapePipelineMap::Iterator anIt (*theMap); anIt.More(); anIt.Next())
65 const Handle(IVtkDraw_HighlightAndSelectionPipeline)& aPL = anIt.Value();
69 aPL->ClearHighlightFilters();
74 aPL->ClearSelectionFilters();
79 vtkStandardNewMacro(IVtkDraw_Interactor);
81 //===========================================================
82 // Function : Constructor
84 //===========================================================
85 IVtkDraw_Interactor::IVtkDraw_Interactor()
91 myIsLeftButtonPressed (Standard_False)
95 //===========================================================
96 // Function : Destructor
98 //===========================================================
99 IVtkDraw_Interactor::~IVtkDraw_Interactor()
103 //===========================================================
104 // Function : SetShapePicker
106 //===========================================================
107 void IVtkDraw_Interactor::SetShapePicker (const PSelector& theSelector)
109 mySelector = theSelector;
112 //===========================================================
113 // Function : SetPipelines
115 //===========================================================
116 void IVtkDraw_Interactor::SetPipelines (const Handle(ShapePipelineMap)& thePipelines)
118 myPipelines = thePipelines;
121 //===========================================================
122 // Function : SetOCCWindow
124 //===========================================================
125 void IVtkDraw_Interactor::SetOCCWindow (const Handle(Aspect_Window)& theWindow)
127 myWindow = theWindow;
130 //===========================================================
131 // Function : GetOCCWindow
133 //===========================================================
134 const Handle(Aspect_Window)& IVtkDraw_Interactor::GetOCCWindow() const
139 //===========================================================
140 // Function : IsEnabled
142 //===========================================================
143 Standard_Boolean IVtkDraw_Interactor::IsEnabled() const
148 //===========================================================
149 // Function : Initialize
151 //===========================================================
152 void IVtkDraw_Interactor::Initialize()
154 // Make sure we have a RenderWindow and camera
155 if (!this->RenderWindow)
157 vtkErrorMacro(<<"No renderer defined!");
161 if (this->Initialized)
166 this->Initialized = 1;
168 // Get the info we need from the RenderingWindow
169 Standard_Integer *aSize;
171 vtkWin32OpenGLRenderWindow *aRenWin;
172 aRenWin = (vtkWin32OpenGLRenderWindow *)(this->RenderWindow);
174 aSize = aRenWin->GetSize();
175 aRenWin->GetPosition();
176 this->myWindowId = aRenWin->GetWindowId();
178 vtkXOpenGLRenderWindow *aRenWin;
179 aRenWin = static_cast<vtkXOpenGLRenderWindow *>(this->RenderWindow);
180 this->myDisplayId = aRenWin->GetDisplayId();
181 this->myWindowId = aRenWin->GetWindowId();
182 aSize = aRenWin->GetSize();
187 this->Size[0] = aSize[0];
188 this->Size[1] = aSize[1];
191 //===========================================================
194 //===========================================================
195 void IVtkDraw_Interactor::Enable()
202 // Add event handlers
204 SetWindowLongPtr(this->myWindowId, GWLP_USERDATA, (LONG_PTR)this);
205 SetWindowLongPtr(this->myWindowId, GWLP_WNDPROC, (LONG_PTR)WndProc);
207 #if TCL_MAJOR_VERSION < 8
208 Tk_CreateFileHandler((void*)ConnectionNumber(this->myDisplayId),
209 TK_READABLE, ProcessEvents, (ClientData) this);
211 Tk_CreateFileHandler(ConnectionNumber(this->myDisplayId),
212 TK_READABLE, ProcessEvents, (ClientData) this);
220 //===========================================================
223 //===========================================================
224 void IVtkDraw_Interactor::MoveTo (Standard_Integer theX, Standard_Integer theY)
226 // Processing highlighting
227 mySelector->Pick (theX, theY, 0.0);
228 vtkActorCollection* anActorCollection = mySelector->GetPickedActors();
230 if (anActorCollection)
232 // Highlight picked subshapes
233 ClearHighlightAndSelection (myPipelines, Standard_True, Standard_False);
234 anActorCollection->InitTraversal();
235 while (vtkActor* anActor = anActorCollection->GetNextActor())
237 IVtkTools_ShapeDataSource* aDataSource = IVtkTools_ShapeObject::GetShapeSource (anActor);
243 IVtkOCC_Shape::Handle anOccShape = aDataSource->GetShape();
244 if (anOccShape.IsNull())
249 IVtk_IdType aShapeID = anOccShape->GetId();
250 Handle(Message_Messenger) anOutput = Message::DefaultMessenger();
251 if (!myPipelines->IsBound(aShapeID))
253 anOutput << "Warning: there is no VTK pipeline registered for highlighted shape" << endl;
257 const Handle(IVtkDraw_HighlightAndSelectionPipeline)& aPL = myPipelines->Find (aShapeID);
259 // Add a subpolydata filter to the highlight pipeline for the shape data source.
260 IVtkTools_SubPolyDataFilter* aFilter = aPL->GetHighlightFilter();
262 // Set the selected sub-shapes ids to subpolydata filter.
263 IVtk_ShapeIdList aSubShapeIds = mySelector->GetPickedSubShapesIds(aShapeID);
265 // Get ids of cells for picked subshapes.
266 IVtk_ShapeIdList aSubIds;
267 IVtk_ShapeIdList::Iterator aMetaIds (aSubShapeIds);
268 for (; aMetaIds.More(); aMetaIds.Next())
270 IVtk_ShapeIdList aSubSubIds = anOccShape->GetSubIds (aMetaIds.Value());
271 aSubIds.Append (aSubSubIds);
274 aFilter->SetDoFiltering (!aSubIds.IsEmpty());
275 aFilter->SetData (aSubIds);
276 if (!aFilter->GetInput())
278 aFilter->SetInputConnection (aDataSource->GetOutputPort());
286 //===========================================================
287 // Function : OnSelection
289 //===========================================================
290 void IVtkDraw_Interactor::OnSelection()
292 // Processing selection
293 vtkActorCollection* anActorCollection = mySelector->GetPickedActors();
295 if (anActorCollection)
297 // Highlight picked subshapes.
298 ClearHighlightAndSelection (myPipelines, Standard_False, Standard_True);
299 anActorCollection->InitTraversal();
300 while (vtkActor* anActor = anActorCollection->GetNextActor())
302 IVtkTools_ShapeDataSource* aDataSource = IVtkTools_ShapeObject::GetShapeSource (anActor);
308 IVtkOCC_Shape::Handle anOccShape = aDataSource->GetShape();
309 if (anOccShape.IsNull())
314 IVtk_IdType aShapeID = anOccShape->GetId();
315 Handle(Message_Messenger) anOutput = Message::DefaultMessenger();
316 if (!myPipelines->IsBound (aShapeID))
318 anOutput << "Warning: there is no VTK pipeline registered for picked shape" << endl;
322 const Handle(IVtkDraw_HighlightAndSelectionPipeline)& aPL = myPipelines->Find (aShapeID);
324 // Add a subpolydata filter to the selection pipeline for the shape data source.
325 IVtkTools_SubPolyDataFilter* aFilter = aPL->GetSelectionFilter();
327 // Set the selected sub-shapes ids to subpolydata filter.
328 IVtk_ShapeIdList aSubShapeIds = mySelector->GetPickedSubShapesIds(aShapeID);
330 // Get ids of cells for picked subshapes.
331 IVtk_ShapeIdList aSubIds;
332 IVtk_ShapeIdList::Iterator aMetaIds (aSubShapeIds);
333 for (; aMetaIds.More(); aMetaIds.Next())
335 IVtk_ShapeIdList aSubSubIds = anOccShape->GetSubIds (aMetaIds.Value());
336 aSubIds.Append (aSubSubIds);
339 aFilter->SetDoFiltering (!aSubIds.IsEmpty());
340 aFilter->SetData (aSubIds);
341 if (!aFilter->GetInput())
343 aFilter->SetInputConnection (aDataSource->GetOutputPort());
353 //===========================================================
354 // Function : OnMouseMove
356 //===========================================================
357 void IVtkDraw_Interactor::OnMouseMove (HWND theHWnd, UINT theNFlags,
358 Standard_Integer theX,
359 Standard_Integer theY)
366 this->SetEventInformationFlipY (theX,
368 theNFlags & MK_CONTROL,
369 theNFlags & MK_SHIFT);
370 this->SetAltKey(GetKeyState(VK_MENU) & (~1));
371 if (!this->myMouseInWindow &&
372 (theX >= 0 && theX < this->Size[0] && theY >= 0 && theY < this->Size[1]))
374 this->InvokeEvent (vtkCommand::EnterEvent, NULL);
375 this->myMouseInWindow = 1;
376 // request WM_MOUSELEAVE generation
377 TRACKMOUSEEVENT aTme;
378 aTme.cbSize = sizeof (TRACKMOUSEEVENT);
379 aTme.dwFlags = TME_LEAVE;
380 aTme.hwndTrack = theHWnd;
381 TrackMouseEvent (&aTme);
384 if (!(theNFlags & MK_LBUTTON))
385 this->MoveTo (theX, this->Size[1] - theY - 1);
387 this->InvokeEvent (vtkCommand::MouseMoveEvent, NULL);
390 //===========================================================
391 // Function : OnMouseWheelForward
393 //===========================================================
394 void IVtkDraw_Interactor::OnMouseWheelForward (HWND, UINT theNFlags,
395 Standard_Integer theX,
396 Standard_Integer theY)
403 this->SetEventInformationFlipY (theX,
405 theNFlags & MK_CONTROL,
406 theNFlags & MK_SHIFT);
408 this->SetAltKey (GetKeyState(VK_MENU) & (~1));
409 this->InvokeEvent (vtkCommand::MouseWheelForwardEvent, NULL);
412 //===========================================================
413 // Function : OnMouseWheelBackward
415 //===========================================================
416 void IVtkDraw_Interactor::OnMouseWheelBackward (HWND, UINT theNFlags,
417 Standard_Integer theX,
418 Standard_Integer theY)
425 this->SetEventInformationFlipY (theX,
427 theNFlags & MK_CONTROL,
428 theNFlags & MK_SHIFT);
430 this->SetAltKey (GetKeyState(VK_MENU) & (~1));
431 this->InvokeEvent (vtkCommand::MouseWheelBackwardEvent, NULL);
434 //===========================================================
435 // Function : OnLButtonDown
437 //===========================================================
438 void IVtkDraw_Interactor::OnLButtonDown (HWND theHWnd, UINT theNFlags,
439 Standard_Integer theX,
440 Standard_Integer theY,
441 Standard_Integer theRepeat)
448 SetCapture (theHWnd);
449 this->SetEventInformationFlipY (theX,
451 theNFlags & MK_CONTROL,
452 theNFlags & MK_SHIFT,
454 this->SetAltKey (GetKeyState(VK_MENU) & (~1));
458 this->InvokeEvent (vtkCommand::LeftButtonPressEvent, NULL);
461 //===========================================================
462 // Function : OnLButtonUp
464 //===========================================================
465 void IVtkDraw_Interactor::OnLButtonUp (HWND, UINT theNFlags,
466 Standard_Integer theX,
467 Standard_Integer theY)
474 this->SetEventInformationFlipY (theX,
476 theNFlags & MK_CONTROL,
477 theNFlags & MK_SHIFT);
479 this->SetAltKey (GetKeyState(VK_MENU) & (~1));
480 this->InvokeEvent (vtkCommand::LeftButtonReleaseEvent, NULL);
484 //===========================================================
485 // Function : OnMButtonDown
487 //===========================================================
488 void IVtkDraw_Interactor::OnMButtonDown (HWND theHWnd, UINT theNFlags,
489 Standard_Integer theX,
490 Standard_Integer theY,
491 Standard_Integer theRepeat)
499 SetCapture (theHWnd);
500 this->SetEventInformationFlipY (theX,
502 theNFlags & MK_CONTROL,
503 theNFlags & MK_SHIFT,
505 this->SetAltKey (GetKeyState(VK_MENU) & (~1));
506 this->InvokeEvent (vtkCommand::MiddleButtonPressEvent, NULL);
509 //===========================================================
510 // Function : OnMButtonUp
512 //===========================================================
513 void IVtkDraw_Interactor::OnMButtonUp (HWND, UINT theNFlags,
514 Standard_Integer theX,
515 Standard_Integer theY)
521 this->SetEventInformationFlipY (theX,
523 theNFlags & MK_CONTROL,
524 theNFlags & MK_SHIFT);
526 this->SetAltKey (GetKeyState(VK_MENU) & (~1));
527 this->InvokeEvent (vtkCommand::MiddleButtonReleaseEvent, NULL);
531 //===========================================================
532 // Function : OnRButtonDown
534 //===========================================================
535 void IVtkDraw_Interactor::OnRButtonDown (HWND theHWnd, UINT theNFlags,
536 Standard_Integer theX,
537 Standard_Integer theY,
538 Standard_Integer theRepeat)
547 this->SetEventInformationFlipY (theX,
549 theNFlags & MK_CONTROL,
550 theNFlags & MK_SHIFT,
553 this->SetAltKey (GetKeyState(VK_MENU) & (~1));
554 this->InvokeEvent (vtkCommand::RightButtonPressEvent, NULL);
557 //===========================================================
558 // Function : OnRButtonUp
560 //===========================================================
561 void IVtkDraw_Interactor::OnRButtonUp (HWND, UINT theNFlags,
562 Standard_Integer theX,
563 Standard_Integer theY)
569 this->SetEventInformationFlipY (theX,
571 theNFlags & MK_CONTROL,
572 theNFlags & MK_SHIFT);
574 this->SetAltKey (GetKeyState(VK_MENU) & (~1));
575 this->InvokeEvent (vtkCommand::RightButtonReleaseEvent, NULL);
579 //===========================================================
582 //===========================================================
583 void IVtkDraw_Interactor::OnSize (HWND, UINT,
584 Standard_Integer theX,
585 Standard_Integer theY)
587 this->UpdateSize (theX, theY);
590 this->InvokeEvent (vtkCommand::ConfigureEvent, NULL);
594 //===========================================================
595 // Function : OnTimer
597 //===========================================================
598 void IVtkDraw_Interactor::OnTimer (HWND, UINT theTimerId)
605 Standard_Integer aTid = static_cast<Standard_Integer>(theTimerId);
606 this->InvokeEvent (vtkCommand::TimerEvent, (void*)&aTid);
608 // Here we deal with one-shot versus repeating timers
609 if (this->IsOneShotTimer(aTid))
611 KillTimer (this->myWindowId, aTid); //'cause windows timers are always repeating
615 //===========================================================
616 // Function : WndProc
618 //===========================================================
619 LRESULT CALLBACK WndProc (HWND theHWnd,UINT theUMsg,
624 IVtkDraw_Interactor *anInteractor = 0;
626 anInteractor = (IVtkDraw_Interactor *)GetWindowLongPtr (theHWnd, GWLP_USERDATA);
628 if (anInteractor && anInteractor->GetReferenceCount() > 0)
630 anInteractor->Register (anInteractor);
631 aRes = ViewerWindowProc (theHWnd, theUMsg, theWParam, theLParam, anInteractor);
632 anInteractor->UnRegister (anInteractor);
638 //===========================================================
639 // Function : ViewerWindowProc
641 //===========================================================
642 LRESULT CALLBACK ViewerWindowProc (HWND theHWnd,
646 IVtkDraw_Interactor *theInteractor)
651 theInteractor->GetOCCWindow ()->Unmap ();
654 theInteractor->Render();
657 theInteractor->OnSize (theHWnd, theWParam, LOWORD(theLParam), HIWORD(theLParam));
659 case WM_LBUTTONDBLCLK:
660 theInteractor->OnLButtonDown (theHWnd, theWParam, MAKEPOINTS(theLParam).x, MAKEPOINTS(theLParam).y, 1);
663 theInteractor->OnLButtonDown (theHWnd, theWParam, MAKEPOINTS(theLParam).x, MAKEPOINTS(theLParam).y, 0);
666 theInteractor->OnLButtonUp (theHWnd, theWParam, MAKEPOINTS(theLParam).x, MAKEPOINTS(theLParam).y);
668 case WM_MBUTTONDBLCLK:
669 theInteractor->OnMButtonDown (theHWnd, theWParam, MAKEPOINTS(theLParam).x, MAKEPOINTS(theLParam).y, 1);
672 theInteractor->OnMButtonDown (theHWnd, theWParam, MAKEPOINTS(theLParam).x, MAKEPOINTS(theLParam).y, 0);
675 theInteractor->OnMButtonUp (theHWnd, theWParam, MAKEPOINTS(theLParam).x, MAKEPOINTS(theLParam).y);
677 case WM_RBUTTONDBLCLK:
678 theInteractor->OnRButtonDown (theHWnd, theWParam, MAKEPOINTS(theLParam).x, MAKEPOINTS(theLParam).y, 1);
681 theInteractor->OnRButtonDown (theHWnd, theWParam, MAKEPOINTS(theLParam).x, MAKEPOINTS(theLParam).y, 0);
684 theInteractor->OnRButtonUp (theHWnd, theWParam, MAKEPOINTS(theLParam).x, MAKEPOINTS(theLParam).y);
688 theInteractor->InvokeEvent (vtkCommand::LeaveEvent, NULL);
689 theInteractor->myMouseInWindow = 0;
693 theInteractor->OnMouseMove (theHWnd, theWParam, MAKEPOINTS(theLParam).x, MAKEPOINTS(theLParam).y);
698 pt.x = MAKEPOINTS(theLParam).x;
699 pt.y = MAKEPOINTS(theLParam).y;
700 ::ScreenToClient(theHWnd, &pt);
701 if( GET_WHEEL_DELTA_WPARAM(theWParam) > 0)
703 theInteractor->OnMouseWheelForward (theHWnd, theWParam, pt.x, pt.y);
707 theInteractor->OnMouseWheelBackward (theHWnd, theWParam, pt.x, pt.y);
712 theInteractor->OnTimer (theHWnd, theWParam);
715 return DefWindowProc(theHWnd, theMsg, theWParam, theLParam);
720 //===========================================================
721 // Function : GetDisplayId
723 //===========================================================
724 Display* IVtkDraw_Interactor::GetDisplayId() const
729 //===========================================================
730 // Function : GetMousePosition
732 //===========================================================
733 void IVtkDraw_Interactor::GetMousePosition (Standard_Integer *theX,
734 Standard_Integer *theY)
736 Window aRoot, aChild;
737 Standard_Integer aRoot_x, aRoot_y;
740 XQueryPointer (this->myDisplayId, this->myWindowId,
741 &aRoot, &aChild, &aRoot_x, &aRoot_y, theX, theY, &aKeys);
745 //===========================================================
746 // Function : ViewerMainLoop
748 //===========================================================
749 Standard_Integer IVtkDraw_Interactor::ViewerMainLoop (Standard_Integer theArgNum, const char** /*theArgs*/)
751 Standard_Integer aXp, aYp;
752 Standard_Boolean aPick = theArgNum > 0;
754 static XEvent anEvent;
755 XNextEvent (myDisplayId, &anEvent);
757 switch (anEvent.type)
766 while (XCheckTypedWindowEvent (this->myDisplayId,
771 // just getting the expose configure event
775 this->SetEventSize (anEvent.xexpose.width, anEvent.xexpose.height);
778 aXp = anEvent.xexpose.x;
779 aYp = this->Size[1] - anEvent.xexpose.y - 1;
780 this->SetEventPosition (aXp, aYp);
782 // only render if we are currently accepting events
785 this->InvokeEvent(vtkCommand::ExposeEvent,NULL);
793 // only render if we are currently accepting events
794 if (this->Enabled && this->GetRenderWindow()->GetNeverRendered())
801 case ConfigureNotify:
804 while (XCheckTypedWindowEvent(this->myDisplayId,
809 // just getting the last configure event
812 Standard_Integer aWidth = anEvent.xconfigure.width;
813 Standard_Integer aHeight = anEvent.xconfigure.height;
814 if (aWidth != this->Size[0] || aHeight != this->Size[1])
816 Standard_Boolean toResizeSmaller = aWidth <= this->Size[0] && aHeight <= this->Size[1];
817 this->UpdateSize (aWidth, aHeight);
818 aXp = anEvent.xbutton.x;
819 aYp = anEvent.xbutton.y;
821 SetEventPosition (aXp, this->Size[1] - aYp - 1);
823 // only render if we are currently accepting events
826 this->InvokeEvent(vtkCommand::ConfigureEvent,NULL);
829 // Don't call Render when the window is resized to be larger:
831 // - if the window is resized to be larger, an Expose event will
832 // be trigged by the X server which will trigger a call to
834 // - if the window is resized to be smaller, no Expose event will
835 // be trigged by the X server, as no new area become visible.
836 // only in this case, we need to explicitly call Render()
837 // in ConfigureNotify.
852 Standard_Integer aCtrl = anEvent.xbutton.state & ControlMask ? 1 : 0;
853 Standard_Integer aShift = anEvent.xbutton.state & ShiftMask ? 1 : 0;
854 Standard_Integer anAlt = anEvent.xbutton.state & Mod1Mask ? 1 : 0;
855 aXp = anEvent.xbutton.x;
856 aYp = anEvent.xbutton.y;
858 // check for double click
859 static Standard_Integer aMousePressTime = 0;
860 Standard_Integer aRepeat = 0;
861 // 400 ms threshold by default is probably good to start
862 Standard_Integer anEventTime = static_cast<int>(anEvent.xbutton.time);
863 if ((anEventTime - aMousePressTime) < 400)
865 aMousePressTime -= 2000; // no double click next time
870 aMousePressTime = anEventTime;
873 this->SetEventInformationFlipY (aXp, aYp, aCtrl, aShift, 0, aRepeat);
874 this->SetAltKey (anAlt);
876 switch (anEvent.xbutton.button)
879 this->OnSelection ();
880 this->myIsLeftButtonPressed = 1;
881 this->InvokeEvent (vtkCommand::LeftButtonPressEvent,NULL);
884 this->InvokeEvent (vtkCommand::MiddleButtonPressEvent,NULL);
887 this->InvokeEvent (vtkCommand::RightButtonPressEvent,NULL);
890 this->InvokeEvent (vtkCommand::MouseWheelForwardEvent,NULL);
893 this->InvokeEvent (vtkCommand::MouseWheelBackwardEvent,NULL);
906 Standard_Integer aCtrl = anEvent.xbutton.state & ControlMask ? 1 : 0;
907 Standard_Integer aShift = anEvent.xbutton.state & ShiftMask ? 1 : 0;
908 Standard_Integer anAlt = anEvent.xbutton.state & Mod1Mask ? 1 : 0;
909 aXp = anEvent.xbutton.x;
910 aYp = anEvent.xbutton.y;
912 this->SetEventInformationFlipY (aXp, aYp, aCtrl, aShift);
913 this->SetAltKey (anAlt);
914 switch (anEvent.xbutton.button)
917 this->InvokeEvent (vtkCommand::LeftButtonReleaseEvent,NULL);
918 this->myIsLeftButtonPressed = False;
921 this->InvokeEvent (vtkCommand::MiddleButtonReleaseEvent,NULL);
924 this->InvokeEvent (vtkCommand::RightButtonReleaseEvent,NULL);
935 XEnterWindowEvent *anEnterEvent = reinterpret_cast<XEnterWindowEvent *>(&anEvent);
936 this->SetEventInformationFlipY (anEnterEvent->x,
938 (anEnterEvent->state & ControlMask) != 0,
939 (anEnterEvent->state & ShiftMask) != 0);
941 this->SetAltKey (anEvent.xbutton.state & Mod1Mask ? 1 : 0);
942 this->InvokeEvent (vtkCommand::EnterEvent, NULL);
952 XLeaveWindowEvent *aLeaveEvent = reinterpret_cast<XLeaveWindowEvent *>(&anEvent);
953 this->SetEventInformationFlipY (aLeaveEvent->x,
955 (aLeaveEvent->state & ControlMask) != 0,
956 (aLeaveEvent->state & ShiftMask) != 0);
958 this->SetAltKey (anEvent.xbutton.state & Mod1Mask ? 1 : 0);
959 this->InvokeEvent(vtkCommand::LeaveEvent, NULL);
972 Standard_Integer aCtrl = anEvent.xbutton.state & ControlMask ? 1 : 0;
973 Standard_Integer aShift = anEvent.xbutton.state & ShiftMask ? 1 : 0;
974 Standard_Integer anAlt = anEvent.xbutton.state & Mod1Mask ? 1 : 0;
976 // Note that even though the (x,y) location of the pointer is event structure,
977 // we must call XQueryPointer for the hints (motion event compression) to
979 this->GetMousePosition (&aXp, &aYp);
980 this->SetEventInformationFlipY (aXp, aYp, aCtrl, aShift);
981 this->SetAltKey (anAlt);
982 if (!myIsLeftButtonPressed)
983 MoveTo (aXp, this->Size[1]- aYp - 1);
984 this->InvokeEvent (vtkCommand::MouseMoveEvent, NULL);
992 //===========================================================
993 // Function : ProcessEvents
995 //===========================================================
996 void IVtkDraw_Interactor::ProcessEvents (ClientData theData, int)
998 IVtkDraw_Interactor *anInteractor = (IVtkDraw_Interactor *)theData;
1000 while (XPending(anInteractor->GetDisplayId()))
1002 anInteractor->ViewerMainLoop (0, NULL);