llcameraview.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 #include "llcameraview.h"
00035 #include "llvieweruictrlfactory.h"
00036 
00037 // Library includes
00038 #include "llfontgl.h"
00039 
00040 // Viewer includes
00041 #include "llagent.h"
00042 #include "lljoystickbutton.h"
00043 #include "llviewercontrol.h"
00044 #include "llviewerwindow.h"
00045 #include "viewer.h"
00046 
00047 // Constants
00048 const char *CAMERA_TITLE = "";
00049 const F32 CAMERA_BUTTON_DELAY = 0.0f;
00050 
00051 // Globals
00052 LLFloaterCamera* gFloaterCamera = NULL;
00053 
00054 
00055 //
00056 // Member functions
00057 //
00058 
00059 LLFloaterCamera::LLFloaterCamera(const std::string& name)
00060 :       LLFloater(name, "FloaterCameraRect", CAMERA_TITLE, FALSE, 100, 100, DRAG_ON_TOP,
00061                           MINIMIZE_NO)
00062 {
00063         setIsChrome(TRUE);
00064         
00065         S32 top = mRect.getHeight();
00066         S32 bottom = 0;
00067         S32 left = 16;
00068 
00069         const S32 ROTATE_WIDTH = 64;
00070         mRotate = new LLJoystickCameraRotate("cam rotate stick", 
00071                 LLRect( left, top, left + ROTATE_WIDTH, bottom ),
00072                 "cam_rotate_out.tga",
00073                 "cam_rotate_in.tga" );
00074         mRotate->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
00075         mRotate->setHeldDownDelay(CAMERA_BUTTON_DELAY);
00076         mRotate->setToolTip( "Rotate Camera Around Focus" );
00077         mRotate->setSoundFlags(MOUSE_DOWN | MOUSE_UP);
00078         addChild(mRotate);
00079 
00080         left += ROTATE_WIDTH;
00081 
00082         const S32 ZOOM_WIDTH = 16;
00083         mZoom = new LLJoystickCameraZoom( 
00084                 "zoom",
00085                 LLRect( left, top, left + ZOOM_WIDTH, bottom ),
00086                 "cam_zoom_out.tga",
00087                 "cam_zoom_plus_in.tga",
00088                 "cam_zoom_minus_in.tga");
00089         mZoom->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
00090         mZoom->setHeldDownDelay(CAMERA_BUTTON_DELAY);
00091         mZoom->setToolTip( "Zoom Camera Towards Focus" );
00092         mZoom->setSoundFlags(MOUSE_DOWN | MOUSE_UP);
00093         addChild(mZoom);
00094 
00095         left += ZOOM_WIDTH;
00096         
00097         const S32 TRACK_WIDTH = 64;
00098         mTrack = new LLJoystickCameraTrack("cam track stick", 
00099                 LLRect( left, top, left + TRACK_WIDTH, bottom ),
00100                 "cam_tracking_out.tga",
00101                 "cam_tracking_in.tga");
00102         mTrack->setFollows(FOLLOWS_TOP | FOLLOWS_LEFT);
00103         mTrack->setHeldDownDelay(CAMERA_BUTTON_DELAY);
00104         mTrack->setToolTip( "Move Camera Up and Down, Left and Right" );
00105         mTrack->setSoundFlags(MOUSE_DOWN | MOUSE_UP);
00106         addChild(mTrack);
00107 }
00108 
00109 
00110 LLFloaterCamera::~LLFloaterCamera()
00111 {
00112         // children all deleted by LLView destructor
00113         gFloaterCamera = NULL;
00114 }
00115 
00116 // virtual
00117 void LLFloaterCamera::onClose(bool app_quitting)
00118 {
00119         LLFloater::onClose(app_quitting);
00120         
00121         if (!app_quitting)
00122         {
00123                 gSavedSettings.setBOOL("ShowCameraControls", FALSE);
00124         }
00125 }
00126 
00127 //
00128 // Static member functions
00129 //
00130 
00131 // static
00132 void LLFloaterCamera::show(void*)
00133 {
00134         if(!gFloaterCamera)
00135         {
00136                 gFloaterCamera = new LLFloaterCamera("camera floater");
00137         }
00138         gFloaterCamera->open(); /* Flawfinder: ignore */
00139         gSavedSettings.setBOOL("ShowCameraControls", TRUE);
00140 }
00141 
00142 // static
00143 void LLFloaterCamera::toggle(void*)
00144 {
00145         if (gFloaterCamera)
00146         {
00147                 gFloaterCamera->close();
00148         }
00149         else
00150         {
00151                 show(NULL);
00152         }
00153 }
00154 
00155 // static
00156 BOOL LLFloaterCamera::visible(void*)
00157 {
00158         if (gFloaterCamera)
00159         {
00160                 return gFloaterCamera->getVisible();
00161         }
00162         else
00163         {
00164                 return FALSE;
00165         }
00166 }
00167 
00168 LLFloaterJoystick       *LLFloaterJoystick::sInstance = NULL;
00169 
00170 
00171 LLFloaterJoystick::LLFloaterJoystick( )
00172 : LLFloater("Joystick floater")
00173 {
00174         sInstance = this;
00175 }
00176 
00177 LLFloaterJoystick::~LLFloaterJoystick()
00178 {
00179         sInstance = NULL;
00180 }
00181 
00182 void LLFloaterJoystick::draw()
00183 {
00184         for (U32 i = 0; i < 6; i++)
00185         {
00186                 F32 value = gViewerWindow->getWindow()->getJoystickAxis(i);
00187                 mAxis[i]->addValue(value*gFrameIntervalSeconds);
00188                 
00189                 if (mAxisBar[i]->mMinBar > value)
00190                 {
00191                         mAxisBar[i]->mMinBar = value;
00192                 }
00193                 if (mAxisBar[i]->mMaxBar < value)
00194                 {
00195                         mAxisBar[i]->mMaxBar = value;
00196                 }
00197         }
00198 
00199         LLFloater::draw();
00200 }
00201 
00202 // static
00203 void LLFloaterJoystick::show(void*)
00204 {
00205         if (sInstance)
00206         {
00207                 sInstance->open();      /*Flawfinder: ignore*/
00208         }
00209         else
00210         {
00211                 LLFloaterJoystick* floater = new LLFloaterJoystick();
00212 
00213                 gUICtrlFactory->buildFloater(floater, "floater_joystick.xml");
00214                 F32 range = gSavedSettings.getBOOL("FlycamAbsolute") ? 1024.f : 2.f;
00215                 LLUIString axis = floater->childGetText("Axis");
00216                 LLUIString joystick = floater->childGetText("JoystickMonitor");
00217 
00218                 LLView* child = floater->getChildByName("ZoomLabel");
00219                 LLRect rect;
00220 
00221                 if (child)
00222                 {
00223                         LLRect r = child->getRect();
00224                         LLRect f = floater->getRect();
00225                         rect = LLRect(150, r.mTop, r.mRight, 0);
00226                 }
00227 
00228                 floater->mAxisStats = new LLStatView("axis values", joystick, "", rect);
00229                 floater->mAxisStats->setDisplayChildren(TRUE);
00230 
00231                 for (U32 i = 0; i < 6; i++)
00232                 {
00233                         axis.setArg("[NUM]", llformat("%d", i));
00234                         floater->mAxis[i] = new LLStat(4);
00235                         floater->mAxisBar[i] = floater->mAxisStats->addStat(axis, floater->mAxis[i]);
00236                         floater->mAxisBar[i]->mMinBar = -range;
00237                         floater->mAxisBar[i]->mMaxBar = range;
00238                         floater->mAxisBar[i]->mLabelSpacing = range * 0.5f;
00239                         floater->mAxisBar[i]->mTickSpacing = range * 0.25f;                     
00240                 }
00241 
00242                 
00243 
00244                 floater->addChild(floater->mAxisStats);
00245                 floater->open();        /*Flawfinder: ignore*/
00246         }
00247 }
00248 
00249 //static 
00250 LLFloaterJoystick* LLFloaterJoystick::getInstance()
00251 {
00252         return sInstance;
00253 }
00254 
00255 // static
00256 BOOL LLFloaterJoystick::visible(void*)
00257 {
00258         return (sInstance != NULL);
00259 }

Generated on Thu Jul 1 06:08:21 2010 for Second Life Viewer by  doxygen 1.4.7