lltoolpipette.cpp

Go to the documentation of this file.
00001 
00036 #include "llviewerprecompiledheaders.h"
00037 
00038 // File includes
00039 #include "lltoolpipette.h" 
00040 
00041 // Library includes
00042 
00043 // Viewer includes
00044 #include "llviewerobjectlist.h"
00045 #include "llviewerwindow.h"
00046 #include "llselectmgr.h"
00047 #include "lltoolmgr.h"
00048 
00049 // Globals
00050 LLToolPipette *gToolPipette = NULL;
00051 
00052 //
00053 // Member functions
00054 //
00055 
00056 LLToolPipette::LLToolPipette()
00057 :       LLTool("Pipette"),
00058 mSuccess(TRUE)
00059 { 
00060         mSelectCallback = NULL;
00061         mUserData = NULL;
00062 }
00063 
00064 
00065 LLToolPipette::~LLToolPipette()
00066 { }
00067 
00068 
00069 BOOL LLToolPipette::handleMouseDown(S32 x, S32 y, MASK mask)
00070 {
00071         mSuccess = TRUE;
00072         mTooltipMsg.clear();
00073         gPickFaces = TRUE;
00074         setMouseCapture(TRUE);
00075         gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback);
00076         return TRUE;
00077 }
00078 
00079 BOOL LLToolPipette::handleMouseUp(S32 x, S32 y, MASK mask)
00080 {
00081         mSuccess = TRUE;
00082         gSelectMgr->unhighlightAll();
00083         // *NOTE: This assumes the pipette tool is a transient tool.
00084         gToolMgr->clearTransientTool();
00085         setMouseCapture(FALSE);
00086         return TRUE;
00087 }
00088 
00089 BOOL LLToolPipette::handleHover(S32 x, S32 y, MASK mask)
00090 {
00091         gViewerWindow->setCursor(mSuccess ? UI_CURSOR_PIPETTE : UI_CURSOR_NO);
00092         if (hasMouseCapture()) // mouse button is down
00093         {
00094                 gPickFaces = TRUE;
00095                 gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback);
00096                 return TRUE;
00097         }
00098         return FALSE;
00099 }
00100 
00101 BOOL LLToolPipette::handleToolTip(S32 x, S32 y, LLString& msg, LLRect *sticky_rect_screen)
00102 {
00103         if (mTooltipMsg.empty())
00104         {
00105                 return FALSE;
00106         }
00107         // keep tooltip message up when mouse in this part of screen
00108         sticky_rect_screen->setCenterAndSize(x, y, 20, 20);
00109         msg = mTooltipMsg;
00110         return TRUE;
00111 }
00112 
00113 void LLToolPipette::pickCallback(S32 x, S32 y, MASK mask)
00114 {
00115         LLViewerObject* hit_obj = gViewerWindow->lastObjectHit();
00116         gSelectMgr->unhighlightAll();
00117 
00118         // if we clicked on a face of a valid prim, save off texture entry data
00119         if (hit_obj && 
00120                 hit_obj->getPCode() == LL_PCODE_VOLUME &&
00121                 gLastHitObjectFace != -1)
00122         {
00123                 //TODO: this should highlight the selected face only
00124                 gSelectMgr->highlightObjectOnly(hit_obj);
00125                 gToolPipette->mTextureEntry = *hit_obj->getTE(gLastHitObjectFace);
00126                 if (gToolPipette->mSelectCallback)
00127                 {
00128                         gToolPipette->mSelectCallback(gToolPipette->mTextureEntry, gToolPipette->mUserData);
00129                 }
00130         }
00131 }
00132 
00133 void LLToolPipette::setSelectCallback(select_callback callback, void* user_data)
00134 {
00135         mSelectCallback = callback;
00136         mUserData = user_data;
00137 }
00138 
00139 void LLToolPipette::setResult(BOOL success, const LLString& msg)
00140 {
00141         mTooltipMsg = msg;
00142         mSuccess = success;
00143 }

Generated on Thu Jul 1 06:09:22 2010 for Second Life Viewer by  doxygen 1.4.7