00001
00032
00033
00034 #include "llviewerprecompiledheaders.h"
00035
00036 #include "lltoolobjpicker.h"
00037
00038 #include "llagent.h"
00039 #include "llselectmgr.h"
00040 #include "llworld.h"
00041 #include "viewer.h"
00042 #include "llviewercontrol.h"
00043 #include "llmenugl.h"
00044 #include "lltoolmgr.h"
00045 #include "llviewerobject.h"
00046 #include "llviewerobjectlist.h"
00047 #include "llviewermenu.h"
00048 #include "llviewercamera.h"
00049 #include "llviewerwindow.h"
00050 #include "lldrawable.h"
00051
00052 LLToolObjPicker* gToolObjPicker = NULL;
00053
00054 LLToolObjPicker::LLToolObjPicker()
00055 : LLTool( "ObjPicker", NULL ),
00056 mPicked( FALSE ),
00057 mHitObjectID( LLUUID::null ),
00058 mExitCallback( NULL ),
00059 mExitCallbackData( NULL )
00060 { }
00061
00062
00063
00064 BOOL LLToolObjPicker::handleMouseDown(S32 x, S32 y, MASK mask)
00065 {
00066 LLView* viewp = gViewerWindow->getRootView();
00067 BOOL handled = viewp->handleMouseDown(x, y, mask);
00068
00069 mHitObjectID.setNull();
00070
00071 if (! handled)
00072 {
00073
00074 gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback);
00075 handled = TRUE;
00076 }
00077 else
00078 {
00079 if (hasMouseCapture())
00080 {
00081 setMouseCapture(FALSE);
00082 }
00083 else
00084 {
00085 llwarns << "PickerTool doesn't have mouse capture on mouseDown" << llendl;
00086 }
00087 }
00088
00089
00090 LLTool::handleMouseDown(x, y, mask);
00091
00092 return handled;
00093 }
00094
00095 void LLToolObjPicker::pickCallback(S32 x, S32 y, MASK mask)
00096 {
00097
00098 LLViewerObject* objectp = NULL;
00099 objectp = gObjectList.findObject( gLastHitObjectID );
00100 if (objectp)
00101 {
00102 gToolObjPicker->mHitObjectID = objectp->mID;
00103 gToolObjPicker->mPicked = TRUE;
00104 }
00105 }
00106
00107
00108 BOOL LLToolObjPicker::handleMouseUp(S32 x, S32 y, MASK mask)
00109 {
00110 LLView* viewp = gViewerWindow->getRootView();
00111 BOOL handled = viewp->handleHover(x, y, mask);
00112 if (handled)
00113 {
00114
00115 }
00116
00117 LLTool::handleMouseUp(x, y, mask);
00118 if (hasMouseCapture())
00119 {
00120 setMouseCapture(FALSE);
00121 }
00122 else
00123 {
00124 llwarns << "PickerTool doesn't have mouse capture on mouseUp" << llendl;
00125 }
00126 return handled;
00127 }
00128
00129
00130 BOOL LLToolObjPicker::handleHover(S32 x, S32 y, MASK mask)
00131 {
00132 LLView *viewp = gViewerWindow->getRootView();
00133 BOOL handled = viewp->handleHover(x, y, mask);
00134 if (!handled)
00135 {
00136
00137 ECursorType cursor = UI_CURSOR_ARROWLOCKED;
00138
00139 cursor = UI_CURSOR_TOOLPICKOBJECT3;
00140
00141 gViewerWindow->getWindow()->setCursor(cursor);
00142 }
00143 return handled;
00144 }
00145
00146
00147 void LLToolObjPicker::onMouseCaptureLost()
00148 {
00149 if (mExitCallback)
00150 {
00151 mExitCallback(mExitCallbackData);
00152
00153 mExitCallback = NULL;
00154 mExitCallbackData = NULL;
00155 }
00156
00157 mPicked = FALSE;
00158 mHitObjectID.setNull();
00159 }
00160
00161
00162 void LLToolObjPicker::setExitCallback(void (*callback)(void *), void *callback_data)
00163 {
00164 mExitCallback = callback;
00165 mExitCallbackData = callback_data;
00166 }
00167
00168
00169 void LLToolObjPicker::handleSelect()
00170 {
00171 LLTool::handleSelect();
00172 setMouseCapture(TRUE);
00173 }
00174
00175
00176 void LLToolObjPicker::handleDeselect()
00177 {
00178 if (hasMouseCapture())
00179 {
00180 LLTool::handleDeselect();
00181 setMouseCapture(FALSE);
00182 }
00183 }
00184
00185