00001
00032 #ifndef LL_MANIP_H
00033 #define LL_MANIP_H
00034
00035 #include "lltool.h"
00036
00037
00038 class LLView;
00039 class LLTextBox;
00040 class LLViewerObject;
00041 class LLToolComposite;
00042 class LLVector3;
00043 class LLObjectSelection;
00044
00045 const S32 MIN_DIVISION_PIXEL_WIDTH = 9;
00046
00047 class LLManip : public LLTool
00048 {
00049 public:
00050 typedef enum e_manip_part
00051 {
00052 LL_NO_PART = 0,
00053
00054
00055 LL_X_ARROW,
00056 LL_Y_ARROW,
00057 LL_Z_ARROW,
00058
00059 LL_YZ_PLANE,
00060 LL_XZ_PLANE,
00061 LL_XY_PLANE,
00062
00063
00064 LL_CORNER_NNN,
00065 LL_CORNER_NNP,
00066 LL_CORNER_NPN,
00067 LL_CORNER_NPP,
00068 LL_CORNER_PNN,
00069 LL_CORNER_PNP,
00070 LL_CORNER_PPN,
00071 LL_CORNER_PPP,
00072
00073
00074 LL_FACE_POSZ,
00075 LL_FACE_POSX,
00076 LL_FACE_POSY,
00077 LL_FACE_NEGX,
00078 LL_FACE_NEGY,
00079 LL_FACE_NEGZ,
00080
00081
00082 LL_EDGE_NEGX_NEGY,
00083 LL_EDGE_NEGX_POSY,
00084 LL_EDGE_POSX_NEGY,
00085 LL_EDGE_POSX_POSY,
00086
00087 LL_EDGE_NEGY_NEGZ,
00088 LL_EDGE_NEGY_POSZ,
00089 LL_EDGE_POSY_NEGZ,
00090 LL_EDGE_POSY_POSZ,
00091
00092 LL_EDGE_NEGZ_NEGX,
00093 LL_EDGE_NEGZ_POSX,
00094 LL_EDGE_POSZ_NEGX,
00095 LL_EDGE_POSZ_POSX,
00096
00097
00098 LL_ROT_GENERAL,
00099 LL_ROT_X,
00100 LL_ROT_Y,
00101 LL_ROT_Z,
00102 LL_ROT_ROLL
00103 } EManipPart;
00104
00105
00106 typedef enum e_select_part_ranges
00107 {
00108 LL_ARROW_MIN = LL_X_ARROW,
00109 LL_ARROW_MAX = LL_Z_ARROW,
00110
00111 LL_CORNER_MIN = LL_CORNER_NNN,
00112 LL_CORNER_MAX = LL_CORNER_PPP,
00113
00114 LL_FACE_MIN = LL_FACE_POSZ,
00115 LL_FACE_MAX = LL_FACE_NEGZ,
00116
00117 LL_EDGE_MIN = LL_EDGE_NEGX_NEGY,
00118 LL_EDGE_MAX = LL_EDGE_POSZ_POSX
00119 } EManipPartRanges;
00120 public:
00121 static void rebuild(LLViewerObject* vobj);
00122
00123 LLManip( const LLString& name, LLToolComposite* composite );
00124
00125 virtual BOOL handleMouseDownOnPart(S32 x, S32 y, MASK mask) = 0;
00126 void renderGuidelines(BOOL draw_x = TRUE, BOOL draw_y = TRUE, BOOL draw_z = TRUE);
00127 static void renderXYZ(const LLVector3 &vec);
00128
00129 BOOL handleMouseUp(S32 x, S32 y, MASK mask);
00130 BOOL handleHover(S32 x, S32 y, MASK mask);
00131 virtual void highlightManipulators(S32 x, S32 y) = 0;
00132 virtual void handleSelect();
00133 virtual void handleDeselect();
00134 virtual BOOL canAffectSelection() = 0;
00135
00136 EManipPart getHighlightedPart() { return mHighlightedPart; }
00137
00138 LLHandle<LLObjectSelection> getSelection();
00139
00140 protected:
00141 LLVector3 getSavedPivotPoint() const;
00142 LLVector3 getPivotPoint();
00143 void getManipNormal(LLViewerObject* object, EManipPart manip, LLVector3 &normal);
00144 BOOL getManipAxis(LLViewerObject* object, EManipPart manip, LLVector3 &axis);
00145 F32 getSubdivisionLevel(const LLVector3 &reference_point, const LLVector3 &translate_axis, F32 grid_scale, S32 min_pixel_spacing = MIN_DIVISION_PIXEL_WIDTH);
00146 void renderTickValue(const LLVector3& pos, F32 value, const char* suffix, const LLColor4 &color);
00147 void renderTickText(const LLVector3& pos, const char* suffix, const LLColor4 &color);
00148 void updateGridSettings();
00149 BOOL getMousePointOnPlaneGlobal(LLVector3d& point, S32 x, S32 y, LLVector3d origin, LLVector3 normal);
00150 BOOL getMousePointOnPlaneAgent(LLVector3& point, S32 x, S32 y, LLVector3 origin, LLVector3 normal);
00151 BOOL nearestPointOnLineFromMouse( S32 x, S32 y, const LLVector3& b1, const LLVector3& b2, F32 &a_param, F32 &b_param );
00152 LLColor4 setupSnapGuideRenderPass(S32 pass);
00153 protected:
00154 LLFrameTimer mHelpTextTimer;
00155 BOOL mInSnapRegime;
00156 LLHandle<LLObjectSelection> mObjectSelection;
00157 EManipPart mHighlightedPart;
00158
00159 static F32 sHelpTextVisibleTime;
00160 static F32 sHelpTextFadeTime;
00161 static S32 sNumTimesHelpTextShown;
00162 static S32 sMaxTimesShowHelpText;
00163 static F32 sGridMaxSubdivisionLevel;
00164 static F32 sGridMinSubdivisionLevel;
00165 static LLVector2 sTickLabelSpacing;
00166 };
00167
00168
00169 #endif