[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31141] branches/soc-2010-merwin: SpaceNav turntable and fit in 3D view.

Mike Erwin significant.bit at gmail.com
Sat Aug 7 12:57:15 CEST 2010


Revision: 31141
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31141
Author:   merwin
Date:     2010-08-07 12:57:15 +0200 (Sat, 07 Aug 2010)

Log Message:
-----------
SpaceNav turntable and fit in 3D view. Tablet data rides with cursor/button events (incomplete! Mac-only for now). Grease pencil works better with pen.

Modified Paths:
--------------
    branches/soc-2010-merwin/intern/ghost/GHOST_Types.h
    branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventButton.h
    branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventCursor.h
    branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventManager.cpp
    branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventNDOF.h
    branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManager.cpp
    branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManager.h
    branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManagerCocoa.mm
    branches/soc-2010-merwin/intern/ghost/intern/GHOST_SystemCocoa.h
    branches/soc-2010-merwin/intern/ghost/intern/GHOST_SystemCocoa.mm
    branches/soc-2010-merwin/intern/ghost/intern/GHOST_WindowCocoa.h
    branches/soc-2010-merwin/intern/ghost/intern/GHOST_WindowCocoa.mm
    branches/soc-2010-merwin/source/blender/blenlib/intern/math_rotation.c
    branches/soc-2010-merwin/source/blender/editors/gpencil/gpencil_paint.c
    branches/soc-2010-merwin/source/blender/editors/space_view3d/view3d_edit.c
    branches/soc-2010-merwin/source/blender/editors/space_view3d/view3d_intern.h
    branches/soc-2010-merwin/source/blender/editors/space_view3d/view3d_ops.c
    branches/soc-2010-merwin/source/blender/makesdna/DNA_view3d_types.h
    branches/soc-2010-merwin/source/blender/windowmanager/WM_types.h
    branches/soc-2010-merwin/source/blender/windowmanager/intern/wm_event_system.c
    branches/soc-2010-merwin/source/blender/windowmanager/intern/wm_window.c
    branches/soc-2010-merwin/source/blender/windowmanager/wm.h
    branches/soc-2010-merwin/source/blender/windowmanager/wm_event_types.h

Modified: branches/soc-2010-merwin/intern/ghost/GHOST_Types.h
===================================================================
--- branches/soc-2010-merwin/intern/ghost/GHOST_Types.h	2010-08-07 10:52:24 UTC (rev 31140)
+++ branches/soc-2010-merwin/intern/ghost/GHOST_Types.h	2010-08-07 10:57:15 UTC (rev 31141)
@@ -29,27 +29,22 @@
 #ifndef _GHOST_TYPES_H_
 #define _GHOST_TYPES_H_
 
-typedef	char				GHOST_TInt8;
-typedef	unsigned char		GHOST_TUns8;
-typedef short				GHOST_TInt16;
-typedef unsigned short		GHOST_TUns16;
-typedef	int					GHOST_TInt32;
-typedef	unsigned int		GHOST_TUns32;
+typedef char           GHOST_TInt8;
+typedef unsigned char  GHOST_TUns8;
+typedef short          GHOST_TInt16;
+typedef unsigned short GHOST_TUns16;
+typedef int            GHOST_TInt32;
+typedef unsigned int   GHOST_TUns32;
 
-#ifdef WIN32
-#define WM_BLND_NDOF_AXIS	WM_USER + 1
-#define WM_BLND_NDOF_BTN 	WM_USER + 2
-#endif
-
 #if defined(WIN32) && !defined(FREE_WINDOWS)
-typedef __int64				GHOST_TInt64;
-typedef unsigned __int64	GHOST_TUns64;
+  typedef __int64          GHOST_TInt64;
+  typedef unsigned __int64 GHOST_TUns64;
 #else
-typedef long long			GHOST_TInt64;
-typedef unsigned long long	GHOST_TUns64;
+  typedef long long          GHOST_TInt64;
+  typedef unsigned long long GHOST_TUns64;
 #endif
 
-typedef void*				GHOST_TUserDataPtr;
+typedef void* GHOST_TUserDataPtr;
 
 typedef enum
 {
@@ -154,8 +149,7 @@
 	GHOST_kEventTrackpad,		/// Trackpad event
 
 	GHOST_kEventNDOFMotion,		/// N degree of freedom device motion event
-	GHOST_kEventNDOFButtonDown,/// N degree of freedom device button events
-	GHOST_kEventNDOFButtonUp,
+	GHOST_kEventNDOFButton,
 
 	GHOST_kEventKeyDown,
 	GHOST_kEventKeyUp,
@@ -276,7 +270,6 @@
 	GHOST_kKeyRightBracket = ']',
 	GHOST_kKeyBackslash    = 0x5C,
 	GHOST_kKeyAccentGrave  = '`',
-
 	
 	GHOST_kKeyLeftShift = 0x100,
 	GHOST_kKeyRightShift,
@@ -284,8 +277,8 @@
 	GHOST_kKeyRightControl,
 	GHOST_kKeyLeftAlt,
 	GHOST_kKeyRightAlt,
-    GHOST_kKeyCommand,				// APPLE only!
-    GHOST_kKeyGrLess ,		// German PC only!
+	GHOST_kKeyCommand,  // APPLE only!
+	GHOST_kKeyGrLess,   // German PC only!
 
 	GHOST_kKeyCapsLock,
 	GHOST_kKeyNumLock,
@@ -365,11 +358,17 @@
 	GHOST_TInt32 x;
 	/** The y-coordinate of the cursor position. */
 	GHOST_TInt32 y;
+
+	GHOST_TabletData tablet;
+
 } GHOST_TEventCursorData;
 
 typedef struct {
 	/** The mask of the mouse button. */
 	GHOST_TButtonMask button;
+
+	GHOST_TabletData tablet;
+
 } GHOST_TEventButtonData;
 
 typedef struct {
@@ -384,7 +383,6 @@
 	GHOST_kTrackpadEventSwipe, /* Reserved, not used for now */
 	GHOST_kTrackpadEventMagnify
 } GHOST_TTrackpadEventSubTypes;
-	
 
 typedef struct {
 	/** The event subtype */
@@ -423,40 +421,23 @@
 	GHOST_TUns8 **strings;
 } GHOST_TStringArray;
 
-
-/* original patch used floats, but the driver return ints and uns. We will calibrate in view, no sense on doing conversions twice */
-/* as all USB device controls are likely to use ints, this is also more future proof */
-//typedef struct {
-//   /** N-degree of freedom device data */
-//   float tx, ty, tz;   /** -x left, +y up, +z forward */
-//   float rx, ry, rz;
-//   float dt;
-//} GHOST_TEventNDOFData;
-
-// typedef struct {
-//    /** N-degree of freedom device data v2*/
-//    int changed;
-//    GHOST_TUns64 client;
-//    GHOST_TUns64 address;
-//    GHOST_TInt16 tx, ty, tz;   /** -x left, +y up, +z forward */
-//    GHOST_TInt16 rx, ry, rz;
-//    GHOST_TInt16 buttons;
-//    GHOST_TUns64 time;
-//    GHOST_TUns64 delta;
-// } GHOST_TEventNDOFData;
-
 typedef struct {
    /** N-degree of freedom device data v3 [GSoC 2010]*/
+   /* Each component normally ranges from -1 to +1, but can exceed that. */
+   float tx, ty, tz; /* translation: -x left, +y forward, -z up */
+   float rx, ry, rz; /* rotation:
+   	axis = (rx,ry,rz).normalized
+   	amount = (rx,ry,rz).magnitude [in revolutions, 1.0 = 360 deg] */
+   float dt; // time since previous NDOF Motion event (or zero if this is the first)
 
-   // Fairly close to raw device data.
-   // Each component normally ranges from -1 to +1, but can exceed that.
-   // rot axis = (rx,ry,rz).normalized
-   // rot amount = (rx,ry,rz).magnitude [in revolutions, 1.0 = 360 deg]
+} GHOST_TEventNDOFMotionData;
 
-   float tx, ty, tz;   /** -x left, +y forward, -z up */
-   float rx, ry, rz;
-} GHOST_TEventNDOFData;
+typedef enum { GHOST_kPress, GHOST_kRelease } GHOST_TButtonAction; // good for mouse or other buttons too, hmmm?
 
+typedef struct {
+	GHOST_TButtonAction action;
+	short button;
+} GHOST_TEventNDOFButtonData;
 
 typedef struct {
 	/** The key code. */
@@ -478,13 +459,13 @@
 
 
 #ifdef _WIN32
-typedef long GHOST_TEmbedderWindowID;
+  typedef long GHOST_TEmbedderWindowID;
 #endif // _WIN32
 
 #ifndef _WIN32
-// I can't use "Window" from "<X11/Xlib.h>" because it conflits with Window defined in winlay.h
-typedef int GHOST_TEmbedderWindowID;
-#endif // _WIN32
+  // I can't use "Window" from "<X11/Xlib.h>" because it conflits with Window defined in winlay.h
+  typedef int GHOST_TEmbedderWindowID;
+#endif
 
 /**
  * A timer task callback routine.
@@ -492,12 +473,11 @@
  * @param time The current time.
  */
 #ifdef __cplusplus
-class GHOST_ITimerTask;
-typedef void (*GHOST_TimerProcPtr)(GHOST_ITimerTask* task, GHOST_TUns64 time);
+  class GHOST_ITimerTask;
+  typedef void (*GHOST_TimerProcPtr)(GHOST_ITimerTask* task, GHOST_TUns64 time);
 #else
-struct GHOST_TimerTaskHandle__;
-typedef void (*GHOST_TimerProcPtr)(struct GHOST_TimerTaskHandle__* task, GHOST_TUns64 time);
+  struct GHOST_TimerTaskHandle__;
+  typedef void (*GHOST_TimerProcPtr)(struct GHOST_TimerTaskHandle__* task, GHOST_TUns64 time);
 #endif
 
 #endif // _GHOST_TYPES_H_
-

Modified: branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventButton.h
===================================================================
--- branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventButton.h	2010-08-07 10:52:24 UTC (rev 31140)
+++ branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventButton.h	2010-08-07 10:57:15 UTC (rev 31141)
@@ -55,6 +55,7 @@
 		: GHOST_Event(time, type, window)
 	{
 		m_buttonEventData.button = button;
+		m_buttonEventData.tablet.Active = GHOST_kTabletModeNone;
 		m_data = &m_buttonEventData;
 	}
 
@@ -64,4 +65,3 @@
 };
 
 #endif // _GHOST_EVENT_BUTTON_H_
-

Modified: branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventCursor.h
===================================================================
--- branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventCursor.h	2010-08-07 10:52:24 UTC (rev 31140)
+++ branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventCursor.h	2010-08-07 10:57:15 UTC (rev 31141)
@@ -55,6 +55,7 @@
 	{
 		m_cursorEventData.x = x;
 		m_cursorEventData.y = y;
+		m_cursorEventData.tablet.Active = GHOST_kTabletModeNone;
 		m_data = &m_cursorEventData;
 	}
 

Modified: branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventManager.cpp
===================================================================
--- branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventManager.cpp	2010-08-07 10:52:24 UTC (rev 31140)
+++ branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventManager.cpp	2010-08-07 10:57:15 UTC (rev 31141)
@@ -110,7 +110,7 @@
 bool GHOST_EventManager::dispatchEvent(GHOST_IEvent* event)
 {
 	// [mce] this variant switches the "handled" flag to work as described in the header
-	//       it also stops after the first consumer has handled the event
+	//       it also stops after the first consumer has handled the event (no it doesn't)
 	bool handled = false;
 	if (event) {
 		TConsumerVector::iterator iter;
@@ -322,7 +322,7 @@
 
 void GHOST_EventManager::disposeEvents()
 {
-	while (m_events.size() > 0) {
+	while (!m_events.empty()) {
 		GHOST_ASSERT(m_events[0], "invalid event");
 		delete m_events[0];
 		m_events.pop_front();

Modified: branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventNDOF.h
===================================================================
--- branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventNDOF.h	2010-08-07 10:52:24 UTC (rev 31140)
+++ branches/soc-2010-merwin/intern/ghost/intern/GHOST_EventNDOF.h	2010-08-07 10:57:15 UTC (rev 31141)
@@ -28,33 +28,31 @@
 
 
 class GHOST_EventNDOFMotion : public GHOST_Event
-{
-protected:
-	GHOST_TEventNDOFData m_axisData;
+	{
+	protected:
+		GHOST_TEventNDOFMotionData m_axisData;
+	
+	public:
+		GHOST_EventNDOFMotion(GHOST_TUns64 time, GHOST_IWindow* window)
+			: GHOST_Event(time, GHOST_kEventNDOFMotion, window)
+			{
+			m_data = &m_axisData;
+			}
+	};
 
-public:
-	GHOST_EventNDOFMotion(GHOST_TUns64 time)
-		: GHOST_Event(time, GHOST_kEventNDOFMotion, NULL)
-//		, m_data(&m_axisData)
-		{
-		m_data = &m_axisData;
-		}
-};
 
 class GHOST_EventNDOFButton : public GHOST_Event
-{
-protected:
-	GHOST_TUns16 m_buttonNumber;
+	{
+	protected:
+		GHOST_TEventNDOFButtonData m_buttonData;
+	
+	public:
+		GHOST_EventNDOFButton(GHOST_TUns64 time, GHOST_IWindow* window)
+			: GHOST_Event(time, GHOST_kEventNDOFButton, window)
+			{
+			m_data = &m_buttonData;
+			}
+	};
 
-public:
-	GHOST_EventNDOFButton(GHOST_TUns64 time, GHOST_TUns16 buttonNumber, GHOST_TEventType upOrDown)
-		: GHOST_Event(time, upOrDown, NULL)
-		, m_buttonNumber(buttonNumber)
-//		, m_data(&m_buttonNumber)
-		{
-		m_data = &m_buttonNumber;
-		}
-};
 
-
 #endif // _GHOST_EVENT_NDOF_H_

Modified: branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManager.cpp
===================================================================
--- branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManager.cpp	2010-08-07 10:52:24 UTC (rev 31140)
+++ branches/soc-2010-merwin/intern/ghost/intern/GHOST_NDOFManager.cpp	2010-08-07 10:57:15 UTC (rev 31141)
@@ -22,12 +22,15 @@
 
 #include "GHOST_NDOFManager.h"
 #include "GHOST_EventNDOF.h"
+#include "GHOST_WindowManager.h"
 #include <string.h> // for memory functions
 #include <stdio.h> // for debug tracing
 
 GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System& sys)
 	: m_system(sys)
 	, m_buttons(0)
+	, m_motionTime(1000) // one full second (operators should filter out such large time deltas)
+	, m_prevMotionTime(0)
 	, m_atRest(true)
 	{
 	// to avoid the rare situation where one triple is updated and
@@ -52,13 +55,28 @@
 
 void GHOST_NDOFManager::updateButtons(unsigned short buttons, GHOST_TUns64 time)
 	{
+	GHOST_System* system = (GHOST_System*) GHOST_System::getSystem();
+	GHOST_IWindow* window = system->getWindowManager()->getActiveWindow();
+
 	unsigned short diff = m_buttons ^ buttons;
+
 	for (int i = 0; i < 16; ++i)
 		{

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list