llfloaterimagepreview.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /**
  2. * @file llfloaterimagepreview.h
  3. * @brief LLFloaterImagePreview class definition
  4. *
  5. * $LicenseInfo:firstyear=2004&license=viewergpl$
  6. *
  7. * Copyright (c) 2004-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLFLOATERIMAGEPREVIEW_H
  33. #define LL_LLFLOATERIMAGEPREVIEW_H
  34. #include "hbfloateruploadasset.h"
  35. #include "lldynamictexture.h"
  36. #include "llquaternion.h"
  37. class LLCheckBoxCtrl;
  38. class LLComboBox;
  39. class LLJoint;
  40. class LLViewerJointMesh;
  41. class LLVOAvatar;
  42. class LLVertexBuffer;
  43. class LLVolume;
  44. class LLImagePreviewSculpted final : public LLViewerDynamicTexture
  45. {
  46. protected:
  47. ~LLImagePreviewSculpted() override = default;
  48. public:
  49. LLImagePreviewSculpted(S32 width, S32 height);
  50. S8 getType() const override;
  51. void setPreviewTarget(LLImageRaw* imagep, F32 distance);
  52. LL_INLINE void setTexture(U32 name) { mTextureName = name; }
  53. LL_INLINE bool needsRender() override { return mNeedsUpdate; }
  54. bool render() override;
  55. void refresh();
  56. void rotate(F32 yaw_radians, F32 pitch_radians);
  57. void zoom(F32 zoom_amt);
  58. void pan(F32 right, F32 up);
  59. protected:
  60. LLPointer<LLVolume> mVolume;
  61. LLPointer<LLVertexBuffer> mVertexBuffer;
  62. LLVector3 mCameraOffset;
  63. U32 mTextureName;
  64. F32 mCameraDistance;
  65. F32 mCameraYaw;
  66. F32 mCameraPitch;
  67. F32 mCameraZoom;
  68. bool mNeedsUpdate;
  69. };
  70. class LLImagePreviewAvatar final : public LLViewerDynamicTexture
  71. {
  72. protected:
  73. LOG_CLASS(LLImagePreviewAvatar);
  74. ~LLImagePreviewAvatar() override;
  75. public:
  76. LLImagePreviewAvatar(S32 width, S32 height);
  77. S8 getType() const override;
  78. void setPreviewTarget(U32 joint_key, const std::string& mesh_name,
  79. F32 distance, bool male);
  80. LL_INLINE void setTexture(U32 name) { mTextureName = name; }
  81. void clearPreviewTexture(const std::string& mesh_name);
  82. LL_INLINE bool needsRender() override { return mNeedsUpdate; }
  83. bool render() override;
  84. void refresh();
  85. void rotate(F32 yaw_radians, F32 pitch_radians);
  86. void zoom(F32 zoom_amt);
  87. void pan(F32 right, F32 up);
  88. protected:
  89. LLJoint* mTargetJoint;
  90. LLViewerJointMesh* mTargetMesh;
  91. LLPointer<LLVOAvatar> mDummyAvatar;
  92. LLVector3 mCameraOffset;
  93. F32 mCameraDistance;
  94. F32 mCameraYaw;
  95. F32 mCameraPitch;
  96. F32 mCameraZoom;
  97. U32 mTextureName;
  98. bool mNeedsUpdate;
  99. };
  100. class LLFloaterImagePreview final : public HBFloaterUploadAsset
  101. {
  102. public:
  103. // For uploading an inventory texture asset.
  104. LLFloaterImagePreview(const std::string& filename);
  105. // For uploading inventory thumbnail pictures (which are not inventory
  106. // assets and do not cost any money to upload). 'thumbnail_inv_id' must be
  107. // UUID for the inventory object to set the thumbnail for. HB
  108. LLFloaterImagePreview(const std::string& filename,
  109. const LLUUID& thumbnail_inv_id );
  110. ~LLFloaterImagePreview() override;
  111. protected:
  112. // LLFloater overrides
  113. bool postBuild() override;
  114. void draw() override;
  115. // HBFloaterUploadAsset override
  116. void uploadAsset() override;
  117. S32 getExpectedUploadCost() const override;
  118. bool handleMouseDown(S32 x, S32 y, MASK mask) override;
  119. bool handleMouseUp(S32 x, S32 y, MASK mask) override;
  120. bool handleHover(S32 x, S32 y, MASK mask) override;
  121. bool handleScrollWheel(S32 x, S32 y, S32 clicks) override;
  122. bool loadImage(const std::string& filename);
  123. static void onPreviewTypeCommit(LLUICtrl*, void*);
  124. private:
  125. void init();
  126. void clearAllPreviewTextures();
  127. private:
  128. LLComboBox* mClothingCombo;
  129. LLCheckBoxCtrl* mTempAssetCheck;
  130. LLPointer<LLImageRaw> mRawImagep;
  131. LLPointer<LLImagePreviewAvatar> mAvatarPreview;
  132. LLPointer<LLImagePreviewSculpted> mSculptedPreview;
  133. LLPointer<LLViewerTexture> mImagep;
  134. LLUUID mThumbnailInventoryId;
  135. LLRect mPreviewRect;
  136. LLRectf mPreviewImageRect;
  137. S32 mLastMouseX;
  138. S32 mLastMouseY;
  139. };
  140. #endif // LL_LLFLOATERIMAGEPREVIEW_H