00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __MSS_JoinSelector_h__
00024 #define __MSS_JoinSelector_h__
00025
00026 #include "MSS_API.h"
00027 #include <UT/UT_RefArray.h>
00028 #include <GU/GU_Detail.h>
00029 #include <OP3D/OP3D_GenericSelector.h>
00030
00031 class GEO_Primitive;
00032 class OP_Node;
00033 class OP3D_View;
00034 class UI_Event;
00035
00036 class MSS_API MSS_JoinPrimitive
00037 {
00038 public:
00039 GEO_Primitive *prim;
00040
00041
00042
00043
00044 UT_Vector3 point_in;
00045 UT_Vector3 point_out;
00046 UT_Vector3 point_in2;
00047 UT_Vector3 point_out2;
00048 UT_Vector3 midpt_out;
00049
00050 UT_String oppath;
00051 int reverse;
00052 int prim_id;
00053 int selinst;
00054
00055
00056 MSS_JoinPrimitive &operator=(const MSS_JoinPrimitive &info)
00057 {
00058 if (&info != this)
00059 {
00060 prim = info.prim;
00061 point_in = info.point_in;
00062 point_out = info.point_out;
00063 point_in2 = info.point_in2;
00064 point_out2= info.point_out2;
00065 midpt_out = info.midpt_out;
00066 reverse = info.reverse;
00067 oppath.harden(info.oppath);
00068 prim_id = info.prim_id;
00069 selinst = info.selinst;
00070 }
00071
00072 return *this;
00073 }
00074
00075
00076
00077
00078
00079 int operator==(const MSS_JoinPrimitive &info)
00080 {
00081 return prim == info.prim;
00082 }
00083
00084 bool load(UT_IStream &is);
00085 void save(ostream &os, int binary);
00086 };
00087
00088 class MSS_API MSS_JoinSelector : public OP3D_GenericSelector
00089 {
00090 public:
00091 MSS_JoinSelector(OP3D_View &viewer, PI_SelectorTemplate &templ);
00092 virtual ~MSS_JoinSelector();
00093
00094 static BM_InputSelector *ourConstructor(BM_View &Viewer,
00095 PI_SelectorTemplate &templ);
00096
00097
00098 virtual const char *className() const;
00099
00100 virtual int hasLocates() const { return 1; }
00101 virtual void doRender(RE_Render *r, short x, short y, int ghost);
00102 virtual void generateAllSelectionStrings(UT_String &sel_string,
00103 bool destroy_selections,
00104 bool only_one_gdp);
00105
00106 protected:
00107 virtual void startSelecting(bool copy_cooked_selection);
00108
00109
00110
00111 virtual void appendToLastNode(SOP_Node *&input_node,
00112 const UT_String &creator_state_name,
00113 bool branch_off);
00114
00115
00116 virtual void setNodeParameters(OP_Node &new_node);
00117
00118 virtual void addToSelection(UI_Event *event,
00119 const char *path,
00120 int selinst,
00121 void *geo);
00122
00123 virtual int handleMouseEvent(UI_Event *event);
00124 virtual bool handleNoPick(UI_Event *event);
00125 virtual int handleKeyEvent(UI_Event *event, DM_Viewport &viewport);
00126
00127 virtual void handleNodeDeleted(OP_Node &node);
00128
00129
00130
00131 virtual void clearSelections();
00132
00133
00134 virtual void saveForUndo();
00135
00136 private:
00137 SELECTOR_SETUP()
00138
00139 void getObjectXform(const char *oppath, UT_Matrix4 &xform,
00140 bool inverse = false);
00141
00142
00143
00144 void getRenderXform(const char *oppath, UT_Matrix4 &xform);
00145
00146
00147
00148
00149
00150 void xformToObject(const char *oppath, UT_Vector3 &vec,
00151 bool is_coord = true);
00152 void xformToRender(const char *oppath, UT_Vector3 &vec,
00153 bool is_coord = true);
00154
00155
00156 void renderConnectingLines(RE_Render *r, int ghost);
00157 void renderLastClick(RE_Render *r, int ghost);
00158 void renderFaceEdges(RE_Render *r, int ghost);
00159 void renderHullEdges(RE_Render *r, int ghost);
00160
00161 SOP_Node *createReverseNode(OP_Node &parent, int rev_type,
00162 const UT_String &creator_state_name,
00163 bool branch_off);
00164
00165
00166
00167 void processHull(GEO_Primitive *prim, float u_real,
00168 float v_real, bool &use_u, float &knot_in,
00169 float &knot_out, int &reverse);
00170 void processFace(GEO_Primitive *prim, float u_real,
00171 float &knot_in, float &knot_out, int &reverse);
00172
00173
00174
00175
00176 void reprocessHull(MSS_JoinPrimitive &hullinfo,
00177 int idx = -1);
00178 void reprocessFace(MSS_JoinPrimitive &faceinfo);
00179
00180 void findFaceEndpoints(GEO_Face *face, UT_Vector3 &pos1,
00181 UT_Vector3 &pos2);
00182 void findFaceMidpoint(GEO_Face *face, UT_Vector3 &pos);
00183
00184
00185
00186
00187 void removePrimitive(int prim_idx, const char *oppath,
00188 int selinst, GEO_Primitive *prim = 0);
00189
00190 void nodeRemoved(const char *oppath);
00191
00192
00193
00194 int oppositeSide(int rev_type);
00195
00196
00197 bool findRayIntersection(UI_Event *event,
00198 const char *oppath, GEO_Primitive *prim,
00199 float &u_real, float &v_real);
00200
00201
00202
00203 void extractHullSides(GEO_Primitive *prim, bool use_u,
00204 float knot_in, float knot_out, GEO_Face *&side1,
00205 GEO_Face *&side2, int prim_idx = -1);
00206
00207 bool selectingHulls()
00208 { return (primMask() & GEOHULL) ? true : false; }
00209
00210
00211
00212 UT_Vector3 lastClickedPos();
00213
00214
00215 friend class MSS_JoinSelectorUndo;
00216
00217 UT_RefArray<MSS_JoinPrimitive> mySelectedPrims;
00218
00219 GU_Detail *myInIsoDetail;
00220 GU_Detail *myOutIsoDetail;
00221
00222 UT_Vector3 myCrtPos;
00223
00224 bool myWrapFlag;
00225 bool myForceReverseFlag;
00226 };
00227
00228 #endif