IMouseConfigManager Class Reference
 
 
 
IMouseConfigManager Class Reference

#include <ICUIMouseConfigManager.h>

Inheritance diagram for IMouseConfigManager:
FPStaticInterface FPInterfaceDesc FPInterface BaseInterface InterfaceServer MaxHeapOperators

Class Description

A core interface for accessing properties of the customized mode introduced in 3ds Max 2013.

The mouse config manager allows plug-ins to get the shortcut of customized pan mode or zoom mode and value of some modes' parameters.

Public Member Functions

virtual bool  GetOperationShortcut (OperationMode eOperation, KeyOption &eKey, MouseButtonOption &eButton) const =0
  Plug-ins that have functions of setting customized pan,zoom,rotate or other customized mode will need to get concrete shortcut of different customized mode when users are switching among modes.
virtual bool  GetValueOfOperationParameter (OperationParameter parmeter, int &ivalue) const =0
  Plug-ins that have functions such as zoom or the other operation that need to get values of some operation parameters will use this function.For example,plug-ins will need to get the zoom in direction when user is in zoom mode and want to try different zoom in directions.If there is the corresponding operation parameter as input, the return value is true and the input/output parameter will be the value of operation parameter.Otherwise,if there is no corresponding operation paramter as input,the return value is false and the output parameter keep unchanged.
CoreExport void  SetMayaSelection (bool isMayaSelection)
  In selection mode, using modifier keys add additional behaviors to pure selection.
CoreExport bool  GetMayaSelection () const
  In selection mode, using modifier keys add additional behaviors to pure selection.

Member Function Documentation

virtual bool GetOperationShortcut ( OperationMode  eOperation,
KeyOption eKey,
MouseButtonOption eButton 
) const [pure virtual]

Plug-ins that have functions of setting customized pan,zoom,rotate or other customized mode will need to get concrete shortcut of different customized mode when users are switching among modes.

If the operation mode as input parameter is valid, the output parameters of function GetOperationShortcut() will be the shortcut that has been set in custom user interface or by MAXScript.

Parameters:
[in] eOperation The customized mode indicated by UI or MAXScript.
[out] eKey The key of customized mode's shortcut indicated by UI or MAXScript.
[out] eButton The mouse button of customized mode's shortcut indicated by UI or MAXScript.
        bool MyPlugin::IsCustomizedPanMode() 
        {
                using namespace MaxSDK::CUI;
                KeyOption ePanKey                               = EKey_Null;
                MouseButtonOption ePanButton    = EMouseButton_Null;
                if(GetOperationShortcut(EOperationMode_Pan,ePanKey,ePanButton) == false)
                        return false;

                int iKeyFlag = 0;
                if (ePanKey & EKey_Shift)
                {
                        iKeyFlag |= MOUSE_SHIFT;
                }
                if (ePanKey & EKey_Ctrl)
                {
                        iKeyFlag |= MOUSE_CTRL;
                }
                if (ePanKey & EKey_Alt)
                {
                        iKeyFlag |= MOUSE_ALT;
                }

                int iMouseFlag = 0;
                if (ePanButton & EMouseButton_Left)
                {
                        iMouseFlag |= MOUSE_LBUTTON;
                }
                if (ePanButton & EMouseButton_Right)
                {
                        iMouseFlag |= MOUSE_RBUTTON;
                }
                if (ePanButton & EMouseButton_Middle)
                {
                        iMouseFlag |= MOUSE_MBUTTON;
                }
                int iPanFlag            = iKeyFlag|iMouseFlag;


                int iButtonStates = 0;
                if ( GetAsyncKeyState(VK_MENU) & 0x8000 ) 
                {
                        iButtonStates |= MOUSE_ALT;
                }
                if ( GetAsyncKeyState(VK_CONTROL) & 0x8000 ) 
                {
                        iButtonStates |= MOUSE_CTRL;
                }
                if ( GetAsyncKeyState(VK_SHIFT) & 0x8000 ) 
                {
                        iButtonStates |= MOUSE_SHIFT;
                }

                if ( GetAsyncKeyState(VK_LBUTTON) & 0x8000)
                {
                        iButtonStates |= MOUSE_LBUTTON;
                }
                if ( GetAsyncKeyState(VK_RBUTTON) & 0x8000)
                {
                        iButtonStates |= MOUSE_RBUTTON;
                }
                if ( GetAsyncKeyState(VK_MBUTTON) & 0x8000)
                {
                        iButtonStates |= MOUSE_MBUTTON;
                }

                //Try the exact match firstly
                if(iButtonStates == iPanFlag)
                {
                        return true;
                }
                //if no exact match, use & instead of ==
                if((iButtonStates & iPanFlag) == iPanFlag)
                {
                        return true;
                }

                return false;
        }
return true if the customized mode is pan mode.
virtual bool GetValueOfOperationParameter ( OperationParameter  parmeter,
int &  ivalue 
) const [pure virtual]

Plug-ins that have functions such as zoom or the other operation that need to get values of some operation parameters will use this function.For example,plug-ins will need to get the zoom in direction when user is in zoom mode and want to try different zoom in directions.If there is the corresponding operation parameter as input, the return value is true and the input/output parameter will be the value of operation parameter.Otherwise,if there is no corresponding operation paramter as input,the return value is false and the output parameter keep unchanged.

Parameters:
[in] parmeter The parameter of some customized modes indicated by UI or MAXScript.
[out] ivalue The value of parameter of some customized modes.
        #define ZOOM_FACT       0.01f
        void MyPlugin::Zoom() 
        {
                IPoint2 delta = OrigialPoint-CurrentPoint;
                int iDirection = 0;
                MaxSDK::CUI::GetValueOfOperationParameter(MaxSDK::CUI::EOperationParameter_ZoomInDirection,iDirection);
                float fVerticalCoefficience             = 1.0;
                float fHorizontalCoefficience   = 1.0;

                if(iDirection & MaxSDK::CUI::EZoomInDirection_North)
                {
                        fVerticalCoefficience = delta.y < 0 ? (1.0f/(1.0f-ZOOM_FACT*delta.y)) : (1.0f+ZOOM_FACT*delta.y);
                }
                else if(iDirection & MaxSDK::CUI::EZoomInDirection_South)
                {
                        fVerticalCoefficience = delta.y < 0 ? (1.0f-ZOOM_FACT*delta.y) : (1.0f/(1.0f+ZOOM_FACT*delta.y));
                }

                if(iDirection & MaxSDK::CUI::EZoomInDirection_East)
                {
                        fHorizontalCoefficience = delta.x < 0 ? (1.0f-ZOOM_FACT*delta.x) : (1.0/(1.0f+ZOOM_FACT*delta.x));
                }
                else if(iDirection & MaxSDK::CUI::EZoomInDirection_West)
                {
                        fHorizontalCoefficience = delta.x > 0 ? (1.0f+ZOOM_FACT*delta.x) : (1.0/(1.0f-ZOOM_FACT*delta.x));;
                }
                float fZoomCoefficience = fVerticalCoefficience * fHorizontalCoefficience;
                ..................

        }
CoreExport void SetMayaSelection ( bool  isMayaSelection )

In selection mode, using modifier keys add additional behaviors to pure selection.

For instance, Ctrl + click is used for add selection, Alt for substract selection. While in Maya mode, Shift is used for add/substract selection, Ctrl for substract selection. This function set the Maya selection mode.

Parameters:
[in] isMayaSelection true if using Maya selection mode.
CoreExport bool GetMayaSelection ( ) const

In selection mode, using modifier keys add additional behaviors to pure selection.

For instance, Ctrl + click is used for add selection, Alt for substract selection. While in Maya mode, Shift is used for add/substract selection, Ctrl for substract selection. This function get whether Max is in Maya selection mode.

Returns:
true if Max is in Maya selection mode, otherwise false.