next up previous contents
Next: UIObject Up: User interface objects Previous: CommandQueue   Contents



Files: Mouse.h, Mouse.C
Derived from: \bf UIObject
Global instance (if any): mouse
Used in optional component: Part of main VMD code


The Mouse class provides all the capabilities to provide a 2D pointer for a particular DisplayDevice. Mouse will use virtual functions with DisplayDevice to determine when a mouse button has been pressed, and where it is located. Based on this, the Mouse will rotate, translate, or scale the objects in the current Scene. It can also be used to `pick' items, by clicking one of the mouse buttons while the cursor is positioned over the item. Finally, it is used to activate and choose from a pop up menu. Mouse is derived from UIObject, and is one of the main user interface methods in VMD (along with the text console, the GUI, the 3D pointers, and any external command input programs).

It is assumed the Mouse has three buttons, left, middle, and right. The right button is always used to active the pop-up menu, while the other two are used to apply transformations to the current Scene. The left and middle buttons are also used to select items. For some things, you can only click on them (press button + release) for something useful to happen. For other things, you can select them (press button), pull them (move the mouse while the button is held down), and release. The Mouse will issue commands to do the button presses, mouse motion, and button releases associated with picking objects.

The Mouse is always in one of several modes, which are changed by various means (text commands, pop-up menu options, or keyboard shortcuts). These modes are:

Note that clicking on an item with the left button while the mouse is NOT in a pick mode is equivalent to clicking-and-releasing the button with the mouse in the atom select mode. Clicking on an item with the middle button in these same situations is the same as using the left button, but instead the picking operation is done as if the mouse were in the bond selection mode.

Finally, the Mouse contains the ability to check the keyboard for special events as well as the 2D pointing device. The Mouse maintains a list of user-customizable keyboard shortcuts, which associate a specific keypress (i.e. 'A' or 'r') with a text command. When that key is pressed while the Mouse is in the graphics display window, the associated text command is executed as if the entire command had been entered at the console prompt.

There is one global instance of the Mouse class, mouse. It is created after the global DisplayDevice, and CommandQueue objects are created. Note that if a `default' DisplayDevice is created, the Mouse will not be able to check for events, determine a pointer position, etc, and so will do nothing.


Enumerations, lists or character name arrays

The MoveMode enumeration lists the possible mouse modes. These are:

Internal data structures

Nonvirtual member functions

Virtual member functions

Method of use

Once it is created and given the proper CommandQueue and DisplayDevice, Mouse only needs to have its virtual function check_event() called regularly. This is done in the main event loop of VMD.

The Command objects which have the word `user' as their first word control the customization of the pop-up menu and keyboard shortcuts.

Suggestions for future changes/additions

When a new DisplayDevice is eventually developed to use X-Windows and OpenGL, there will also need to be included routines there to post and activate the pop-up menu and for all the virtual functions in DisplayDevice which the Mouse uses. If this is done successfully then Mouse should be completely device-independent. It may be necessary (or preferred) to convert to the use of a pull-down menu in the X-Windows case.

next up previous contents
Next: UIObject Up: User interface objects Previous: CommandQueue   Contents