00001 /*************************************************************************** 00002 *cr 00003 *cr (C) Copyright 1995-2019 The Board of Trustees of the 00004 *cr University of Illinois 00005 *cr All Rights Reserved 00006 *cr 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * RCS INFORMATION: 00011 * 00012 * $RCSfile: Mouse.h,v $ 00013 * $Author: johns $ $Locker: $ $State: Exp $ 00014 * $Revision: 1.69 $ $Date: 2019/01/17 21:21:00 $ 00015 * 00016 *************************************************************************** 00017 * DESCRIPTION: 00018 * 00019 * The Mouse UI object, which maintains the current state of the 00020 * mouse, including what it is currently used for, and how much it has moved 00021 * from one measurement to the next. This also deals with any pop-up or 00022 * pull-down menus available by using the mouse, as well as picking objects. 00023 * 00024 * A three-button mouse is assumed here, with the following usage: 00025 * 1) Buttons 1 and 2 : manipulation and picking. 00026 * 2) Button 3 (right): pop-up menu 00027 * 00028 * This is the general base class definition; specific versions for each 00029 * windowing/graphics system may be supplied. This class can function as 00030 * it is, however, and will just be a 'zero' mouse - the buttons will never 00031 * be pressed, and the cursor will always be at 0,0. 00032 * 00033 ***************************************************************************/ 00034 #ifndef MOUSE_OBJ_H 00035 #define MOUSE_OBJ_H 00036 00037 #include "UIObject.h" 00038 #include "Command.h" 00039 #include "NameList.h" 00040 00042 class Mouse : public UIObject { 00043 public: 00045 enum MoveMode {ROTATION, TRANSLATION, SCALING, LIGHT, USERPOINT, 00046 // All "picking" modes need to be listed after PICK, 00047 // and non-picking modes need to be listed before 00048 // This is because later code does a check on 00049 // (enum value) >= PICK to determine if we are in 00050 // a "picking" mode 00051 PICK, QUERY, CENTER, \ 00052 LABELATOM, LABELBOND, LABELANGLE, LABELDIHEDRAL, \ 00053 MOVEATOM, MOVERES, MOVEFRAG, MOVEMOL, MOVEREP,\ 00054 FORCEATOM, FORCERES, FORCEFRAG, \ 00055 ADDBOND}; 00056 00057 enum MouseButton { B_NONE = 0, B_LEFT = 1, B_MIDDLE, B_RIGHT }; 00058 00060 static const char *get_mode_str(MoveMode mode); 00061 00062 private: 00063 MoveMode moveMode; 00064 MouseButton pickInProgress; 00065 // If zero, no picking operation is currently in progress. 00066 // If something is currently being selected with the mouse 00067 // and the button is still down, this flag indicates which button is 00068 // used. In fact, pickInProgress = pick-button + 1. 00069 int moveObj; 00070 int currX, currY; 00071 int oldX, oldY; 00072 MouseButton buttonDown; 00073 00075 float transInc, rotInc, scaleInc; 00076 00078 float xRotVel, yRotVel, zRotVel, scaling, RotVelScale; 00079 00081 int rocking_enabled; 00082 00084 int mouse_moved(void); 00085 00087 int mouse_userpoint(void); 00088 00090 void handle_winevent(long, long); 00091 00092 public: 00093 Mouse(VMDApp *); 00094 virtual ~Mouse(void); 00095 00097 virtual void reset(void); 00098 00100 int move_mode(MoveMode, int = 0); 00101 00103 void stop_rotation(void); 00104 00106 virtual int check_event(void); 00107 00109 void set_rocking(int on); 00110 }; 00111 00112 00116 class CmdMouseMode : public Command { 00117 public: 00119 CmdMouseMode(int mm, int ms) 00120 : Command(MOUSE_MODE), mouseMode(mm), mouseSetting(ms) {} 00121 00123 int mouseMode, mouseSetting; 00124 }; 00125 00126 #endif 00127