lltoolface.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 // File includes
00035 #include "lltoolface.h" 
00036 
00037 // Library includes
00038 #include "v3math.h"
00039 
00040 // Viewer includes
00041 #include "llagent.h"
00042 //#include "llbuildview.h"
00043 #include "llviewercontrol.h"
00044 #include "llselectmgr.h"
00045 #include "lltoolview.h"
00046 #include "llviewerobject.h"
00047 #include "llviewerwindow.h"
00048 #include "llfloatertools.h"
00049 
00050 //
00051 // Member functions
00052 //
00053 
00054 LLToolFace::LLToolFace()
00055 :       LLTool("Texture")
00056 { }
00057 
00058 
00059 LLToolFace::~LLToolFace()
00060 { }
00061 
00062 
00063 BOOL LLToolFace::handleDoubleClick(S32 x, S32 y, MASK mask)
00064 {
00065         if (!LLSelectMgr::getInstance()->getSelection()->isEmpty())
00066         {
00067                 // You should already have an object selected from the mousedown.
00068                 // If so, show its properties
00069                 //gBuildView->showFacePanel();
00070                 gFloaterTools->showPanel( LLFloaterTools::PANEL_FACE );
00071                 //gBuildView->showMore(LLBuildView::PANEL_FACE);
00072                 return TRUE;
00073         }
00074         else
00075         {
00076                 // Nothing selected means the first mouse click was probably
00077                 // bad, so try again.
00078                 return FALSE;
00079         }
00080 }
00081 
00082 
00083 BOOL LLToolFace::handleMouseDown(S32 x, S32 y, MASK mask)
00084 {
00085         gPickFaces = TRUE;
00086         gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback);
00087         return TRUE;
00088 }
00089 
00090 void LLToolFace::pickCallback(S32 x, S32 y, MASK mask)
00091 {
00092         LLViewerObject* hit_obj = gViewerWindow->lastObjectHit();
00093         if (hit_obj)
00094         {
00095                 S32 hit_face = gLastHitObjectFace;
00096                 
00097                 if (hit_obj->isAvatar())
00098                 {
00099                         // ...clicked on an avatar, so don't do anything
00100                         return;
00101                 }
00102 
00103                 // ...clicked on a world object, try to pick the appropriate face
00104 
00105                 if (mask & MASK_SHIFT)
00106                 {
00107                         // If object not selected, need to inform sim
00108                         if ( !hit_obj->isSelected() )
00109                         {
00110                                 // object wasn't selected so add the object and face
00111                                 LLSelectMgr::getInstance()->selectObjectOnly(hit_obj, hit_face);
00112                         }
00113                         else if (!LLSelectMgr::getInstance()->getSelection()->contains(hit_obj, hit_face) )
00114                         {
00115                                 // object is selected, but not this face, so add it.
00116                                 LLSelectMgr::getInstance()->addAsIndividual(hit_obj, hit_face);
00117                         }
00118                         else
00119                         {
00120                                 // object is selected, as is this face, so remove the face.
00121                                 LLSelectMgr::getInstance()->remove(hit_obj, hit_face);
00122 
00123                                 // BUG: If you remove the last face, the simulator won't know about it.
00124                         }
00125                 }
00126                 else
00127                 {
00128                         // clicked without modifiers, select only
00129                         // this face
00130                         LLSelectMgr::getInstance()->deselectAll();
00131                         LLSelectMgr::getInstance()->selectObjectOnly(hit_obj, hit_face);
00132                 }
00133         }
00134         else
00135         {
00136                 if (!(mask == MASK_SHIFT))
00137                 {
00138                         LLSelectMgr::getInstance()->deselectAll();
00139                 }
00140         }
00141 }
00142 
00143 
00144 void LLToolFace::handleSelect()
00145 {
00146         // From now on, draw faces
00147         LLSelectMgr::getInstance()->setTEMode(TRUE);
00148 }
00149 
00150 
00151 void LLToolFace::handleDeselect()
00152 {
00153         // Stop drawing faces
00154         LLSelectMgr::getInstance()->setTEMode(FALSE);
00155 }
00156 
00157 
00158 void LLToolFace::render()
00159 {
00160         // for now, do nothing
00161 }

Generated on Fri May 16 08:34:07 2008 for SecondLife by  doxygen 1.5.5