00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __MSS_PolySplitState_H__
00022 #define __MSS_PolySplitState_H__
00023
00024 #include "MSS_API.h"
00025 #include <UT/UT_Vector3.h>
00026 #include <UT/UT_Vector3Array.h>
00027 #include <UI/UI_Value.h>
00028 #include "MSS_SingleOpBaseState.h"
00029 #include <GEO/GEO_PrimPoly.h>
00030 #include <GQ/GQ_Detail.h>
00031 class BM_View;
00032 class GU_Detail;
00033 class SOP_PolySplit;
00034 class JEDI_View;
00035 class DM_RayIntersect;
00036 class mss_UndoLoop;
00037
00038 class MSS_API MSS_SplitPoint
00039 {
00040 public:
00041 MSS_SplitPoint() {
00042 primitive = 0;
00043 type = 0;
00044 index = 0;
00045 percentage = 0.5f;
00046 position.assign(0, 0, 0);
00047 }
00048 int primitive;
00049 char type;
00050 int index;
00051 float percentage;
00052 UT_Vector3 position;
00053 };
00054
00055 class MSS_API MSS_PSStateFlags
00056 {
00057 public:
00058 MSS_PSStateFlags() {
00059 extendfromstart = 0;
00060 mousemoving = 0;
00061 updatestring = 0;
00062 updaterefarray = 1;
00063 validpick = 0;
00064
00065 mousebusy = 0;
00066
00067 }
00068 unsigned extendfromstart :1,
00069 mousemoving :1,
00070 updatestring :1,
00071 updaterefarray :1,
00072 validpick :1,
00073
00074 mousebusy :1;
00075 };
00076
00077 class MSS_API MSS_PolySplitState : public MSS_SingleOpBaseState
00078 {
00079 friend class mss_UndoLoop;
00080 public:
00081
00082 MSS_PolySplitState(JEDI_View &view, PI_StateTemplate &templ,
00083 BM_SceneManager *scene, bool edgeloop);
00084 virtual ~MSS_PolySplitState(void);
00085
00086
00087
00088 static BM_State *ourConstructor(BM_View &view,
00089 PI_StateTemplate &templ,
00090 BM_SceneManager *scene);
00091 static BM_State *ourEdgeLoopConstructor(BM_View &view,
00092 PI_StateTemplate &templ,
00093 BM_SceneManager *scene);
00094
00095 static PRM_Template ourTemplateList[];
00096
00097
00098 virtual const char *className() const;
00099
00100 virtual void initializeUI(PRM_Template *templates=0);
00101
00102 virtual int matchesNode(OP_Node &node) const;
00103
00104
00105 virtual int handleMouseEvent(UI_Event *event);
00106
00107 virtual void handleOpNodeChange(OP_Node &);
00108
00109 void handleOpEvent(OP_Node *node, OP_EventType type,
00110 void *data);
00111 static void opEvent(OP_Node *caller, void *callee,
00112 OP_EventType type, void *data);
00113
00114 int handlePickEvent(UI_Event *event);
00115
00116 int handleRapidFireEvent(UI_Event *event);
00117
00118 virtual int handleNodeDeleted(OP_Node &node);
00119
00120 virtual int getToolboxCount() const;
00121
00122 protected:
00123
00124
00125 virtual int enter(BM_SimpleState::BM_EntryType how);
00126 virtual void exit (void);
00127
00128
00129 virtual void interrupt(BM_SimpleState * = 0);
00130 virtual void resume (BM_SimpleState * = 0);
00131
00132
00133 virtual void restart(void);
00134
00135
00136 virtual int handleParameterEvent(UI_Event *event);
00137
00138 virtual int handleKeyTypeEvent(UI_Event *event,
00139 BM_Viewport &);
00140
00141
00142 virtual void setBuild(int yesNo);
00143
00144
00145 virtual void doGenerate();
00146
00147
00148 virtual void doRender(RE_Render *r, short x, short y, int ghost);
00149
00150 private:
00151 SOP_PolySplit *getPolySplitSOP(void) const;
00152
00153 int useLocate() { return (int)myFeedbackVal; }
00154 int snapToMidpoint() { return (int)myMidpointSnapVal; }
00155 int snapToPerp() { return (int)myPerpSnapVal; }
00156 int constBias() { return (int)myConstBiasVal; }
00157
00158
00159
00160 bool setParentSOP(UI_Event *event);
00161
00162 GU_Detail *getInputGdp();
00163 void updateFromSOP();
00164
00165
00166 void renderCurrentEdge(RE_Render *r, int ghost);
00167 void renderPosFeedback(RE_Render *r, int ghost);
00168 void renderSplitPath(RE_Render *r, int ghost);
00169 void renderLoop(RE_Render *r, int ghost);
00170
00171 void showFeedback(int yesNo);
00172 void setMidpointSnap(int yesNo);
00173 void setConstantBias(int yesNo);
00174 void setPerpSnap(int yesNo);
00175
00176 void handleFeedbackChange(UI_Event *event);
00177 void handleConstantBiasChange(UI_Event *event);
00178 void handleMidpointSnapChange(UI_Event *event);
00179 void handlePerpSnapChange(UI_Event *event);
00180
00181
00182
00183 void pickGeoData(UI_Event *event, MSS_SplitPoint &data);
00184
00185
00186
00187 int calculateEdgePos(UI_Event *event, UT_Vector3 &pos,
00188 UT_Vector3 &end1, UT_Vector3 &end2);
00189
00190 void calculatePosition(UI_Event *event,
00191 MSS_SplitPoint &data);
00192
00193 void addPoint(MSS_SplitPoint data);
00194 void delPoint();
00195
00196 void endSplitPath();
00197 void prepareExtend(UT_Vector3 &point);
00198
00199
00200 void deleteAllPoints();
00201
00202
00203 void updateEndpoints();
00204
00205 void formatPointString(char *point, MSS_SplitPoint data);
00206 static void extendString(UT_String &str, UT_String ext,
00207 int from_end);
00208 void removeString(UT_String &str, int from_end);
00209
00210
00211
00212
00213 void applyStateSettings();
00214
00215 void undoStateSettings();
00216
00217
00218 void buildRayIntersect();
00219
00220 void handleQuitState(UI_Event *event);
00221
00222 private:
00223
00224
00225
00226 UT_Vector3Array myPointList;
00227
00228
00229 UT_String myPointsString;
00230
00231
00232 MSS_SplitPoint myNextPoint;
00233
00234
00235
00236 UT_Vector3 myFirstPoint;
00237 UT_Vector3 myLastPoint;
00238 float myLastBias;
00239
00240 MSS_PSStateFlags myFlags;
00241
00242 UI_Value mySelFinishedValue;
00243
00244
00245
00246 short myLastMouseDown;
00247 bool myPickStarted;
00248
00249 BM_State::BM_GenerateMode myLastGenMode;
00250
00251 UI_Value myFeedbackVal;
00252 UI_Value myConstBiasVal;
00253 UI_Value myMidpointSnapVal;
00254 UI_Value myPerpSnapVal;
00255
00256 DM_RayIntersect *myRayIntersect;
00257 GQ_Detail *myGqd;
00258
00259 bool myWeCausedRewire;
00260
00261 bool myEdgeLoopState;
00262 bool myLoopGenerate;
00263 bool myUpdateRayIntersect;
00264 float myBias;
00265
00266
00267
00268
00269 int myPickedNode;
00270 };
00271
00272 #endif
00273