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