MQCommandPlugin class

(new in Rev2.41)

MQCommandPlugin class inherits a MQStationPlugin class, and it provides functions to implement a command plug-in.

You can make a command plug-in with a simple implementation and without taking care of complex message procedures between a plug-in and a main part of Metasequoia by inheriting this MQCommandPlugin class and implementing required virtual functions.

In MQCommandPlugin class, each plug-in member functions and messages are declared as virtual functions. It is necessary to implement the virtual function in the inherited class.

 

Class
MQCommandPlugin Constructor
Declared in the super class
GetPlugInID Get a plug-in ID
GetPlugInName Get a plug-in name
EnumString Get a string displayed on a button
Initialize Initialize an application
Exit Exit an application
Activate A message for activating or deactivation a window
IsActivated A message for checking an activated state of a window
OnMinimize A message for minimizing a window
OnReceiveUserMessage A message for receive a plug-in own message
OnDraw A message for drawing
OnNewDocument A message for initializing a document
OnEndDocument A message for exiting a document
OnSaveDocument A message for saving a document
OnUndo A message for an undo
OnRedo A message for an redo
OnUpdateUndo A message for updating an undo state
OnObjectModified A message for editing objects
OnObjectSelected A message for selecting objects
OnUpdateObjectList A message for changing a current object
OnMaterialModified A message for modifying parameters of materials
OnUpdateMaterialList A message for changing a current material
OnUpdateScene A message for updating a scene
Plug-in
GetPlugInType Get a plug-in type
Message procedure
OnLeftButtonDown When a left button is pressed
OnLeftButtonMove When a mouse is moved with pressing a left button
OnLeftButtonUp When a left button is released
OnMiddleButtonDown When a middle button is pressed
OnMiddleButtonMove When a mouse is moved with pressing a middle button
OnMiddleButtonUp When a middle button is released
OnRightButtonDown When a right button is pressed
OnRightButtonMove When a mouse is moved with pressing a right button
OnRightButtonUp When a right button is released
OnMouseMove When a mouse is moved
OnMouseWheel When a mouse wheel is rotated
OnKeyDown When a key is pressed
OnKeyUp When a key is released
Supplemental functions for the super class
OpenSetting Open a setting file
CloseSetting Close a setting file
SendUserMessage Send a plug-in own message to the other plug-ins
WindowClose Close a window
BeginCallback Begin the callback procedure
ExecuteCallback Implementation for the callback
CreateDrawingObject Add a drawing object in OnDraw()
CreateDrawingMaterial Add a material for a drawing object in OnDraw()
DeleteDrawingObject Delete a drawing object
DeleteDrawingMaterial Delete a material for drawing objects
GetCurrentUndoState Get a current undo state
GetSceneOption Get display options of the scene
Supplemental functions
UpdateUndo Update an undo buffer
RedrawScene Reserve updating a scene
RedrawAllScene Reserve updating all scenes
GetEditOption Get edit options
GetSnappedPos Get a snapped position
HitTest Detect a target
GetResourceCursor Get a default mouse cursor
SetMouseCursor Set a mouse cursor
SetStatusString Set a display string on a status bar

struct MOUSE_BUTTON_STATE {
    POINT MousePos;	// The position of a mouse cursor
    int Wheel;		// The amount of rotations of a mouse wheel (Multiple or divisor of WHEEL_DELTA)
    BOOL LButton;	// Whether the left button is pressed
    BOOL MButton;	// Whether the middle button is pressed
    BOOL RButton;	// Whether the right button is pressed
    BOOL Shift;		// Whether the Shift key is pressed
    BOOL Ctrl;		// Whether the Ctrl key is pressed
    BOOL Alt;		// Whether the Alt key is pressed
};

This is a structure for storing status of mouse buttons and a keyboard.


MQCommandPlugin::MQCommandPlugin();

This is a constructor.


virtual int MQCommandPlugin::GetPlugInType();

Return value
A plug-in type
[MQPLUGIN_TYPE_COMMAND] Command

It implements a virtual function declared in MQBasePlugin::GetPlugInType(). It is not necessary to implement this function in an inherited class.


virtual BOOL MQCommandPlugin::OnLeftButtonDown(MQDocument doc, MQScene scene, MOUSE_BUTTON_STATE& state);

doc
A document
scene
A scene
state
States of mouse buttons
Return value
Whether the message has been done with
[TRUE] The message has been done with
[FALSE] The message has not been done with

This method is called when a left button is pressed.

It must return TRUE if a plug-in own operation has been done with, and return FALSE if when you want to do with a default operation.


virtual BOOL MQCommandPlugin::OnLeftButtonMove(MQDocument doc, MQScene scene, MOUSE_BUTTON_STATE& state);

doc
A document
scene
A scene
state
States of mouse buttons
Return value
Whether the message has been done with
[TRUE] The message has been done with
[FALSE] The message has not been done with

This method is called when a mouse is moved with pressing a left button.

It must return TRUE if a plug-in own operation has been done with, and return FALSE if when you want to do with a default operation.


virtual BOOL MQCommandPlugin::OnLeftButtonUp(MQDocument doc, MQScene scene, MOUSE_BUTTON_STATE& state);

doc
A document
scene
A scene
state
States of mouse buttons
Return value
Whether the message has been done with
[TRUE] The message has been done with
[FALSE] The message has not been done with

This method is called when a left button is released.

It must return TRUE if a plug-in own operation has been done with, and return FALSE if when you want to do with a default operation.


virtual BOOL MQCommandPlugin::OnMiddleButtonDown(MQDocument doc, MQScene scene, MOUSE_BUTTON_STATE& state);

doc
A document
scene
A scene
state
States of mouse buttons
Return value
Whether the message has been done with
[TRUE] The message has been done with
[FALSE] The message has not been done with

This method is called when a middle button is pressed.

It must return TRUE if a plug-in own operation has been done with, and return FALSE if when you want to do with a default operation.


virtual BOOL MQCommandPlugin::OnMiddleButtonMove(MQDocument doc, MQScene scene, MOUSE_BUTTON_STATE& state);

doc
A document
scene
A scene
state
States of mouse buttons
Return value
Whether the message has been done with
[TRUE] The message has been done with
[FALSE] The message has not been done with

This method is called when a mouse is moved with pressing a middle button.

It must return TRUE if a plug-in own operation has been done with, and return FALSE if when you want to do with a default operation.


virtual BOOL MQCommandPlugin::OnMiddleButtonUp(MQDocument doc, MQScene scene, MOUSE_BUTTON_STATE& state);

doc
A document
scene
A scene
state
States of mouse buttons
Return value
Whether the message has been done with
[TRUE] The message has been done with
[FALSE] The message has not been done with

This method is called when a middle button is released.

It must return TRUE if a plug-in own operation has been done with, and return FALSE if when you want to do with a default operation.


virtual BOOL MQCommandPlugin::OnRightButtonDown(MQDocument doc, MQScene scene, MOUSE_BUTTON_STATE& state);

doc
A document
scene
A scene
state
States of mouse buttons
Return value
Whether the message has been done with
[TRUE] The message has been done with
[FALSE] The message has not been done with

This method is called when a right button is pressed.

It must return TRUE if a plug-in own operation has been done with, and return FALSE if when you want to do with a default operation.


virtual BOOL MQCommandPlugin::OnRightButtonMove(MQDocument doc, MQScene scene, MOUSE_BUTTON_STATE& state);

doc
A document
scene
A scene
state
States of mouse buttons
Return value
Whether the message has been done with
[TRUE] The message has been done with
[FALSE] The message has not been done with

This method is called when a mouse is moved with pressing a right button.

It must return TRUE if a plug-in own operation has been done with, and return FALSE if when you want to do with a default operation.


virtual BOOL MQCommandPlugin::OnRightButtonUp(MQDocument doc, MQScene scene, MOUSE_BUTTON_STATE& state);

doc
A document
scene
A scene
state
States of mouse buttons
Return value
Whether the message has been done with
[TRUE] The message has been done with
[FALSE] The message has not been done with

This method is called when a right button is released.

It must return TRUE if a plug-in own operation has been done with, and return FALSE if when you want to do with a default operation.


virtual BOOL MQCommandPlugin::OnMouseMove(MQDocument doc, MQScene scene, MOUSE_BUTTON_STATE& state);

doc
A document
scene
A scene
state
States of mouse buttons
Return value
Whether the message has been done with
[TRUE] The message has been done with
[FALSE] The message has not been done with

This method is called when a mouse has been moved.

It must return TRUE if a plug-in own operation has been done with, and return FALSE if when you want to do with a default operation.


virtual BOOL MQCommandPlugin::OnMouseWheel(MQDocument doc, MQScene scene, MOUSE_BUTTON_STATE& state);

doc
A document
scene
A scene
state
States of mouse buttons
Return value
Whether the message has been done with
[TRUE] The message has been done with
[FALSE] The message has not been done with

This method is called when a mouse wheel has been rotated.

The amount of a rotation of a wheel is stored in state.Wheel by the multiple or divisor of WHEEL_DELTA.

It must return TRUE if a plug-in own operation has been done with, and return FALSE if when you want to do with a default operation.


virtual BOOL MQCommandPlugin::OnKeyDown(MQDocument doc, MQScene scene, int key, MOUSE_BUTTON_STATE& state);

doc
A document
scene
A scene
key
A virtual key code
state
States of mouse buttons
Return value
Whether the message has been done with
[TRUE] The message has been done with
[FALSE] The message has not been done with

This method is called when a key is pressed.

The virtual key code of 'key' is the same as the contents acquired by WM_KEYDOWN.

It must return TRUE if a plug-in own operation has been done with, and return FALSE if when you want to do with a default operation.


virtual BOOL MQCommandPlugin::OnKeyUp(MQDocument doc, MQScene scene, int key, MOUSE_BUTTON_STATE& state);

doc
A document
scene
A scene
key
A virtual key code
state
States of mouse buttons
Return value
Whether the message has been done with
[TRUE] The message has been done with
[FALSE] The message has not been done with

This method is called when a key is released.

The virtual key code of 'key' is the same as the contents acquired by WM_KEYUP.

It must return TRUE if a plug-in own operation has been done with, and return FALSE if when you want to do with a default operation.


void MQCommandPlugin::UpdateUndo();

It updates an undo buffer.

Actually, this function only reserves an updating of an undo buffer. It is done with after exiting an event procedure in a plugin and returning a procedure to the main part of Metasequoia.

 

Attention: In Ver2.4.3 or older version, it does not make any change by calling UpdateUndo() in ExecuteCallback().


void MQCommandPlugin::RedrawScene(MQScene scene);

scene
A scene

It updates the specified scene.

Actually, this function only reserves to redraw. It is done with after exiting an event procedure in a plugin and returning a procedure to the main part of Metasequoia.

 

Attention: In Ver2.4.3 or older version, it does not make any change by calling UpdateUndo() in ExecuteCallback().


void MQCommandPlugin::RedrawAllScene();

It updates for all scenes.

Actually, this function only reserves to redraw. It is done with after exiting an event procedure in a plugin and returning a procedure to the main part of Metasequoia.

 

Attention: In Ver2.4.3 or older version, it does not make any change by calling UpdateUndo() in ExecuteCallback().


void MQCommandPlugin::GetEditOption(EDITOPTION& option);

option
Edit options

It gets edit options. The edit options are stored in 'option'.

struct EDIT_OPTION {
    BOOL EditVertex;                // Enable vertex editing
    BOOL EditLine;                  // Enable line editing
    BOOL EditFace;                  // Enable face editing
    BOOL SelectRect;                // Selection with rectangle
    BOOL SelectRope;                // Selection with rope
    BOOL SnapX;                     // Edit along X axis
    BOOL SnapY;                     // Edit along Y axis
    BOOL SnapZ;                     // Edit along Z axis
    COORDINATE_TYPE CoordinateType; // A type of a coordinate
    SNAP_GRID_TYPE SnapGrid;        // Snap to a grid
    BOOL Symmetry;                  // Symmetry editing
    float SymmetryDistance;         // Distance for symmetry editing
    BOOL CurrentObjectOnly;         // Edit current object only
};
CoordinateType
A type of a coordinate
[COORDINATE_SCREEN] Screen coordinate
[COORDINATE_WORLD] World coordinate
[COORDINATE_LOCAL] Local coordinate
SnapGrid
Snap in each axis (Use & operator for checking because multiple values are set)
[SNAP_GRID_X] Snap in the X axis
[SNAP_GRID_Y] Snap in the Y axis
[SNAP_GRID_Z] Snap in the Z axis

MQPoint MQCommandPlugin::GetSnappedPos(MQScene scene, const MQPoint& p, SNAP_GRID_TYPE type);

scene
A scene
p
A position before snapping
type
The direction for snapping (One or multiple values can be selected)
[SNAP_GRID_X] Snap in the X axis
[SNAP_GRID_Y] Snap in the Y axis
[SNAP_GRID_Z] Snap in the Z axis
Return value
A position after snapping

It gets a snapped position.

The direction for snapping is not influenced by edit options. It snaps only in the direction specified by 'type'.

 

Attention: In Ver2.4.3 or older version, it does not make any change by calling UpdateUndo() in ExecuteCallback().


BOOL MQCommandPlugin::HitTest(MQScene scene, POINT p, HIT_TEST_PARAM& param);

scene
A scene
p
A screen coordinate
param
Parameters
Return value
[TRUE] A vertex, a line or a face has been detected
[FALSE] Nothing is detected

(new in Rev2.49)

It detects a face, a line or a vertex on or near the specified position in the scene.

When you call this function with input the target to TestVetex, TestLine and TestFace in param and this function returns TRUE, it stores a type of the target into HitType, a position of the target into HitPos, and indices into ObjectIndex, VertexIndex, LineIndex and FaceIndex.

struct HIT_TEST_PARAM {
    // input
    BOOL TestVertex;        // Detect vertices
    BOOL TestLine;          // Detect lines
    BOOL TestFace;          // Detect faces

    // output
    HIT_TYPE HitType;       // A type of the detected target
    MQPoint HitPos;         // A position of the detected target
    int ObjectIndex;        // A index of the detected object
    int VertexIndex;        // A index of the vertex (Only when a vertex is detected)
    int LineIndex;          // A index of the line (Only when a line is detected)
    int FaceIndex;          // A index of the face (Only when a face is detected)
};
TestVertex
Whether to detect vertices
[TRUE] Enable to detect vertices
[FALSE] Disable to detected vertices
TestLine
Whether to detect lines
[TRUE] Enable to detect lines
[FALSE] Disable to detect lines
TestFace
Whether to detect faces
[TRUE] Enable to detect faces
[FALSE] Disable to detect faces
HitType
A kind of the detected target
[HIT_TEST_VERTEX] A vertex has been detected
[HIT_TEST_LINE] A line has been detected
[HIT_TEST_FACE] A face has been detected
[HIT_TEST_NONE] Nothing has been detected
HitPos
A position of the detected target (in a world coordinate)
ObjectIndex
An index of the detected object
VertexIndex
An index of the detected vertex (Only when a vertex has been detected)
LineIndex
An index of the detected line (Only when a line has been detected)
FaceIndex
An index of the detected face (Only when a line or a face has been detected)


Example for calling a function (in OnLeftButtonDown, OnMouseMove and so on)
    // Get edit options.
    EDIT_OPTION option;
    GetEditOption(option);

    // Detect the target on the mouse cursor, and select it.
    HIT_TEST_PARAM param;
    param.TestVertex = option.EditVertex;
    param.TestLine = option.EditLine;
    param.TestFace = option.EditFace;
    if(HitTest(scene, state.MousePos, param)){
        if(param.HitType == HIT_TYPE_VERTEX){
            doc->AddSelectVertex(param.ObjectIndex, param.VertexIndex);
        }else if(param.HitType == HIT_TYPE_FACE){
            doc->AddSelectFace(param.ObjectIndex, param.FaceIndex);
        }else if(param.HitType == HIT_TYPE_LINE){
            doc->AddSelectLine(param.ObjectIndex, param.FaceIndex, param.LineIndex);
        }
    }


HCURSOR MQCommandPlugin::GetResourceCursor(MQCURSOR_TYPE cursor_type);

cursor_type
A type of a mouse cursor
[MQCURSOR_SIZEALL] 4 directional arrows
[MQCURSOR_HANDPOINT] Hand point
[MQCURSOR_HELP] Question
[MQCURSOR_NO] Prohibit
[MQCURSOR_WAIT] Sandglass
[MQCURSOR_UPARROW] Up arrow
[MQCURSOR_SIZEWE] The both-directions arrow which points out right and left
[MQCURSOR_SIZENWSE] The both-directions arrow which points out left up and right bottom
[MQCURSOR_SIZENS] The both-directions arrow which points out up and bottom
[MQCURSOR_SIZENESW] The both-directions arrow which points out right up and left bottom
[MQCURSOR_CROSS] Cross
[MQCURSOR_NONE] Invisible
[MQCURSOR_DEFAULT] Default
[MQCURSOR_RECT] Rectangle
[MQCURSOR_ROPE] Rope
[MQCURSOR_MOVE] Move
[MQCURSOR_SCALE] Scale
[MQCURSOR_ROTATE] Rotate
Return value
A cursor handle

(new in Rev2.46)

It gets the specified type of the mouse cursor.

The returned cursor is available for SetMouseCursor().


void MQCommandPlugin::SetMouseCursor(HCURSOR cursor);

cursor
A mouse cursor

(new in Rev2.46)

It changes a mouse cursor.

Please specify a cursor that is obtained by GetResourceCursor() or is a resource cursor obtained by LoadCursor() of Win32-API with the DLL instance. The operation is not ensured when a predefined cursor obtained by LoadCursor() with the NULL instance is specified.


void MQCommandPlugin::SetStatusString(const char *str);

str
A display string (ANSI character code)

(new in Rev2.49)

It sets a display string on a status bar.