00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include <UT/UT_DSOVersion.h>
00030 #include <GU/GU_Detail.h>
00031 #include <GU/GU_PrimPoly.h>
00032 #include <PRM/PRM_Include.h>
00033 #include <PRM/PRM_ChoiceList.h>
00034 #include <OP/OP_Operator.h>
00035 #include <OP/OP_OperatorTable.h>
00036
00037 #include <SOP/SOP_Guide.h>
00038 #include <BM/BM_ResourceManager.h>
00039 #include <SOP/SOP_Node.h>
00040 #include <SOP/SOP_BrushBase.h>
00041 #include <MSS/MSS_BrushBaseState.h>
00042 #include <MSS/MSS_KeyBindings.h>
00043 #include "MSS_BrushHairLen.h"
00044
00045 #define PRM_MENU_CHOICES (PRM_ChoiceListType)(PRM_CHOICELIST_EXCLUSIVE |\
00046 PRM_CHOICELIST_REPLACE)
00047
00048
00049 PI_StateTemplate *sopBrushHairLenState();
00050
00051 using namespace HDK_Sample;
00052
00053
00054 void
00055 newModelState(BM_ResourceManager *m)
00056 {
00057 m->registerState(sopBrushHairLenState());
00058 }
00059
00060 enum MSS_PaintOp {
00061 MSS_PAINT,
00062 MSS_EYEDROP,
00063 MSS_SMOOTH,
00064 MSS_CALLBACK,
00065 MSS_ERASE
00066 };
00067
00068 static PRM_Name mssOpMenuNames[] = {
00069 PRM_Name("paint", "Paint"),
00070 PRM_Name("eyedrop", "Eye Dropper"),
00071 PRM_Name("smooth", "Smooth"),
00072 PRM_Name("callback", "Callback"),
00073 PRM_Name("erase", "Erase Changes"),
00074 PRM_Name(0)
00075 };
00076
00077 #define PRM_MENU_CHOICES (PRM_ChoiceListType)(PRM_CHOICELIST_EXCLUSIVE |\
00078 PRM_CHOICELIST_REPLACE)
00079
00080 PRM_ChoiceList MSS_BrushHairLen::theLMBMenu(PRM_MENU_CHOICES, mssOpMenuNames);
00081 PRM_ChoiceList MSS_BrushHairLen::theMMBMenu(PRM_MENU_CHOICES, mssOpMenuNames);
00082
00083 PRM_Template
00084 MSS_BrushHairLen::ourTemplateList[] =
00085 {
00086 PRM_Template(PRM_ORD, 1, &PRMlmbName, PRMzeroDefaults, &theLMBMenu),
00087 PRM_Template(PRM_ORD, 1, &PRMmmbName, PRMzeroDefaults, &theMMBMenu),
00088 PRM_Template(),
00089 };
00090
00091 BM_State *
00092 MSS_BrushHairLen::ourConstructor(BM_View &view, PI_StateTemplate &templ,
00093 BM_SceneManager *scene)
00094 {
00095 return new MSS_BrushHairLen((JEDI_View &)view, templ, scene);
00096 }
00097
00098 MSS_BrushHairLen::MSS_BrushHairLen(JEDI_View &view, PI_StateTemplate &templ,
00099 BM_SceneManager *scene, char *cursor)
00100 : MSS_BrushBaseState(view, templ, scene, cursor)
00101 {
00102
00103 }
00104
00105 MSS_BrushHairLen::~MSS_BrushHairLen()
00106 {
00107
00108 }
00109
00110 const char *
00111 MSS_BrushHairLen::className() const
00112 {
00113 return "MSS_BrushHairLen";
00114 }
00115
00116 void
00117 MSS_BrushHairLen::getUIFileName(UT_String &uifilename) const
00118 {
00119 uifilename = "MSS_BrushHairLen.ui";
00120 }
00121
00122 int
00123 MSS_BrushHairLen::handleKeyTypeEvent(UI_Event *event, BM_Viewport &viewport)
00124 {
00125 int key = (int)*event->value;
00126
00127 if (!KEYCMP(MSS_KEY_BRUSH_P_MAIN))
00128 {
00129 getPrimaryVal() = int(MSS_PAINT);
00130 getPrimaryVal().changed(0);
00131 return 1;
00132 }
00133 if (!KEYCMP(MSS_KEY_BRUSH_S_MAIN))
00134 {
00135 getSecondaryVal() = int(MSS_PAINT);
00136 getSecondaryVal().changed(0);
00137 return 1;
00138 }
00139
00140 if (!KEYCMP(MSS_KEY_PAINT_P_EYEDROP))
00141 {
00142 getPrimaryVal() = int(MSS_EYEDROP);
00143 getPrimaryVal().changed(0);
00144 return 1;
00145 }
00146 if (!KEYCMP(MSS_KEY_PAINT_S_EYEDROP))
00147 {
00148 getSecondaryVal() = int(MSS_EYEDROP);
00149 getSecondaryVal().changed(0);
00150 return 1;
00151 }
00152
00153 if (!KEYCMP(MSS_KEY_BRUSH_P_SMOOTH))
00154 {
00155 getPrimaryVal() = int(MSS_SMOOTH);
00156 getPrimaryVal().changed(0);
00157 return 1;
00158 }
00159 if (!KEYCMP(MSS_KEY_BRUSH_S_SMOOTH))
00160 {
00161 getSecondaryVal() = int(MSS_SMOOTH);
00162 getSecondaryVal().changed(0);
00163 return 1;
00164 }
00165
00166 if (!KEYCMP("h.pane.gview.state.sop.brush.p_callback"))
00167 {
00168 getPrimaryVal() = int(MSS_CALLBACK);
00169 getPrimaryVal().changed(0);
00170 return 1;
00171 }
00172 if (!KEYCMP("h.pane.gview.state.sop.brush.s_callback"))
00173 {
00174 getSecondaryVal() = int(MSS_CALLBACK);
00175 getSecondaryVal().changed(0);
00176 return 1;
00177 }
00178
00179 if (!KEYCMP(MSS_KEY_BRUSH_P_ERASE))
00180 {
00181 getPrimaryVal() = int(MSS_ERASE);
00182 getPrimaryVal().changed(0);
00183 return 1;
00184 }
00185 if (!KEYCMP(MSS_KEY_BRUSH_S_ERASE))
00186 {
00187 getSecondaryVal() = int(MSS_ERASE);
00188 getSecondaryVal().changed(0);
00189 return 1;
00190 }
00191
00192 return MSS_BrushBaseState::handleKeyTypeEvent(event, viewport);
00193 }
00194
00195 SOP_BrushOp
00196 MSS_BrushHairLen::menuToBrushOp(const UI_Value &v) const
00197 {
00198 switch ((MSS_PaintOp)(int)v)
00199 {
00200 case MSS_PAINT: return SOP_BRUSHOP_PAINT;
00201 case MSS_EYEDROP: return SOP_BRUSHOP_EYEDROP;
00202 case MSS_SMOOTH: return SOP_BRUSHOP_SMOOTHATTRIB;
00203 case MSS_CALLBACK: return SOP_BRUSHOP_CALLBACK;
00204 case MSS_ERASE:
00205 default: return SOP_BRUSHOP_ERASE;
00206 }
00207 }
00208
00209
00210 PI_StateTemplate *
00211 sopBrushHairLenState()
00212 {
00213 return new PI_StateTemplate("proto_brushhairlen",
00214 "Brush Hair Len",
00215 "SOP_proto_brushhairlen",
00216 (void *)MSS_BrushHairLen::ourConstructor,
00217 MSS_BrushHairLen::ourTemplateList, PI_VIEWER_SCENE,
00218 PI_NETMASK_SOP,
00219 0);
00220 }