00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __MSS_EditState_H__
00021 #define __MSS_EditState_H__
00022
00023 #include "MSS_API.h"
00024 #include "MSS_SingleOpState.h"
00025 #include "MSS_EditSelector.h"
00026
00027 #include <SOP/SOP_BrushBase.h>
00028 #include <UT/UT_String.h>
00029 #include <UT/UT_Vector2.h>
00030 #include <GU/GU_Detail.h>
00031 #include <GU/GU_RayIntersect.h>
00032 #include <BM/BM_MoveTool.h>
00033 #include "MSS_PaintSelector.h"
00034
00035 class UT_Matrix4;
00036 class UI_Menu;
00037 class OP_Context;
00038 class PRM_Template;
00039 class DM_Workbench;
00040 class JEDI_View;
00041 class SOP_Edit;
00042 class SOP_Node;
00043
00044
00045 class MSS_API MSS_EditState : public MSS_SingleOpState, public BM_MoveTool
00046 {
00047 public:
00048
00049 MSS_EditState(JEDI_View &view, PI_StateTemplate &templ,
00050 BM_SceneManager *scene,
00051 const char *cursor);
00052 virtual ~MSS_EditState();
00053
00054
00055
00056 static BM_State *ourConstructor(BM_View &view, PI_StateTemplate &templ,
00057 BM_SceneManager *scene);
00058 static PRM_Template ourTemplateList[];
00059 static PRM_Template ourToolTemplateList[];
00060
00061
00062 virtual const char *className() const;
00063
00064
00065 virtual void restart();
00066
00067 virtual void stopGenerating();
00068
00069
00070 void flattenSelection();
00071
00072 virtual void handleOpNodeChange(OP_Node &node);
00073
00074
00075
00076 virtual int matchesNode(OP_Node &node) const;
00077
00078 virtual UI_Menu *getStateMenu(int ortho = 0);
00079
00080 virtual void setMoveToolType(Type move_type);
00081 virtual Type getMoveToolType() const;
00082
00083 virtual const char *getOperationBarIconName() const;
00084 virtual const char *getOperationBarLabel() const;
00085
00086 protected:
00087
00088 virtual int handleKeyTypeEvent(UI_Event *event,
00089 BM_Viewport &);
00090
00091
00092 virtual bool generateAllNodes();
00093
00094
00095 virtual void setNode(OP_Node *node);
00096
00097
00098
00099 virtual int nodeIdToReselectWithin() const;
00100
00101 SOP_Edit *getEditSOP() const
00102 { return (SOP_Edit *)BM_SingleOpState::getNode(); }
00103
00104
00105 virtual SOP_BrushOp menuToBrushOp(const UI_Value &menuvalue) const;
00106
00107 virtual int enter(BM_SimpleState::BM_EntryType how);
00108 virtual void exit (void);
00109 virtual void interrupt(BM_SimpleState * = 0);
00110 virtual void resume (BM_SimpleState * = 0);
00111
00112
00113
00114 virtual void doneSelecting(void);
00115
00116
00117 virtual int handleMouseEvent(UI_Event *event);
00118 virtual int handleParameterEvent(UI_Event *event);
00119
00120
00121 virtual void doRender(RE_Render *r, short x, short y, int ghost);
00122
00123 UI_Value &getPrimaryVal () { return myPrimaryButtonVal; }
00124 UI_Value &getSecondaryVal() { return mySecondaryButtonVal; }
00125
00126 virtual void updatePrompt();
00127
00128 virtual bool getSelectionBoundingBox( DM_Viewport &vport,
00129 UT_BoundingBox &bbox );
00130
00131 virtual bool getAllowQuickSelect() const
00132 {
00133 return (myHandlingKeyEvent
00134 || !myDoingRestartFlag);
00135 }
00136
00137 virtual const char *getTemplateName() const;
00138
00139 virtual void handleSelectionTypeChange(UI_Event *event);
00140
00141 virtual void updateCurrentSelector(
00142 OP3D_InputSelector *cur_sel,
00143 const PI_BindingSelectorInfo *selector_info);
00144
00145 virtual bool allowDeleteEmptyEditSops() const;
00146
00147 virtual bool allowOpMaxExportToDialog() const;
00148
00149 private:
00150
00151
00152 void flattenPoints(
00153 SOP_Edit &node,
00154 const GB_PointGroup &grp);
00155 void flattenBreakpoints(
00156 SOP_Edit &node,
00157 const GB_BreakpointGroup &grp);
00158
00159 void handleBrushShapeChange (UI_Event *event);
00160 void handleBrushOrientChange(UI_Event *event);
00161 void handleAccumStencilChange(UI_Event *event);
00162 void handlePrimaryTieChange(UI_Event *event);
00163 void handleSecondaryTieChange(UI_Event *event);
00164
00165
00166
00167 void usePrimaryButton (void);
00168 void useSecondaryButton(void);
00169
00170 int sendRay(UI_Event *event, bool isuv,
00171 float t, UT_Vector3 &rayorig,
00172 UT_Vector3 &hitpos,
00173 UT_Vector3 &dir, GU_RayInfo &hinfo,
00174 GEO_Point *&hitpt,
00175 float &scalehistory,
00176 int checkgeo);
00177
00178
00179 void orientCursor(float t, const UT_Vector3 &hitpos,
00180 const UT_Vector3 &nml,
00181 float scalehistory,
00182 bool isuv,
00183 const GEO_Primitive *prim,
00184 float u, float v);
00185
00186
00187
00188 void reorientCursor();
00189
00190 void updateFixedType();
00191
00192 enum mssInputMode
00193 {
00194 mssEditMode,
00195 mssSculptMode
00196 };
00197 bool changeMode(mssInputMode new_mode);
00198 void modeChanged();
00199
00200 void deleteEmptyEditSopIfNeeded();
00201 void updateDetailLookSelection(OP_Context &context,
00202 SOP_Node &sop);
00203
00204 private:
00205 SOP_Edit *mySavedEditNode;
00206 GU_RayIntersect myRayIntersect;
00207 GU_Detail myBrushCursor;
00208 UT_Matrix4 myBrushCursorXform;
00209 bool myRenderBrushCursor;
00210 bool myBrushCursorIsUV;
00211 bool myOneHit;
00212 bool myLocatedFlag;
00213 UT_Vector2 myOldCoord;
00214
00215
00216 bool myResizingCursor;
00217 short myLastCursorX, myLastCursorY;
00218
00219
00220
00221
00222 bool myOldOrientValid;
00223 float myOldOrientT;
00224 UT_Vector3 myOldOrientHitPos;
00225 UT_Vector3 myOldOrientHitNml;
00226 float myOldOrientScaleHistory;
00227 bool myOldOrientIsUV;
00228 const GEO_Primitive *myOldOrientHitPrim;
00229 float myOldOrientHitU;
00230 float myOldOrientHitV;
00231
00232 UI_Value myPrimaryButtonVal;
00233 UI_Value mySecondaryButtonVal;
00234 UI_Value myBrushShapeVal;
00235 UI_Value myBrushOrientVal;
00236 UI_Value myAccumStencilVal;
00237
00238 UT_IntArray myOldEditSops;
00239
00240 bool myFirstEntry:1,
00241 myHandlingKeyEvent:1,
00242 myDoingRestartFlag:1;
00243
00244 BM_MoveTool::Type myMoveType;
00245 UT_String myToolMenuName;
00246
00247 mssInputMode myInputMode;
00248 static mssInputMode theLastInputMode;
00249 };
00250
00251 #endif