00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __OP3D_InputSelectorBase_h__
00022 #define __OP3D_InputSelectorBase_h__
00023
00024 #include "OP3D_API.h"
00025
00026 #include <BM/BM_InputSelector.h>
00027 #include <DM/DM_Defines.h>
00028 #include <GU/GU_SelectType.h>
00029 #include <UI/UI_Value.h>
00030 #include <UT/UT_String.h>
00031
00032 class SIM_Data;
00033 class SIM_Object;
00034 class GU_Detail;
00035 class OP_Node;
00036 class PI_SelectorTemplate;
00037 class UI_Menu;
00038 class UI_Feel;
00039 class UI_Event;
00040 class SI_RubberBox;
00041 class SI_Lasso;
00042 class SI_Brush;
00043 class DM_Viewport;
00044 class DM_Workbench;
00045 class GUI_DetailLook;
00046 class OP3D_View;
00047
00048 enum OP3D_SelectionAction
00049 {
00050 OP3D_SELECT_ALL,
00051 OP3D_INVERT_SELECTION,
00052 OP3D_SELECT_NONE
00053 };
00054
00055 class OP3D_PickId
00056 {
00057 public:
00058 OP3D_PickId();
00059 OP3D_PickId(int lookindex, int detailindex);
00060 ~OP3D_PickId();
00061
00062 bool operator==(const OP3D_PickId &cmp) const;
00063 bool operator!=(const OP3D_PickId &cmp) const;
00064 static int compare(const OP3D_PickId *id1, const OP3D_PickId *id2);
00065
00066 int myLookIndex;
00067 int myDetailIndex;
00068 };
00069
00070 typedef UT_RefArray<OP3D_PickId> OP3D_PickIdArray;
00071
00072 class OP3D_API OP3D_InputSelectorBase : public BM_InputSelector
00073 {
00074 public:
00075 OP3D_InputSelectorBase(OP3D_View &viewer,
00076 PI_SelectorTemplate &templ);
00077 virtual ~OP3D_InputSelectorBase();
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 virtual void setViewer(BM_View *viewer);
00088
00089
00090
00091
00092
00093 virtual void startSelecting(bool copy_cooked_selection = true);
00094 virtual void stopSelecting();
00095
00096
00097
00098
00099 UI_Value &finishedValue() { return *myFinishedValue; }
00100 const UI_Value &finishedValue() const { return *myFinishedValue; }
00101
00102 UI_Feel *getCustomToolbox() const;
00103
00104 void setPreferredSelectMode(DM_SelectMode selmode)
00105 { myPreferredSelectMode = selmode; }
00106 DM_SelectMode getPreferredSelectMode() const
00107 { return myPreferredSelectMode; }
00108
00109
00110
00111 bool allowDragging() const { return myAllowDragging; }
00112 void allowDragging(bool on) { myAllowDragging = on; }
00113
00114
00115
00116 bool allowFinishing() const
00117 { return myAllowFinishingFlag; }
00118 void allowFinishing(bool onoff)
00119 { myAllowFinishingFlag = onoff;}
00120
00121
00122
00123 bool allowFinishWithExistingSelection() const;
00124 void allowFinishWithExistingSelection(bool onoff);
00125
00126
00127
00128 bool allowQuickSelect() const { return myAllowQuickSelect; }
00129 void allowQuickSelect(bool on){ myAllowQuickSelect = on; }
00130
00131
00132
00133
00134
00135
00136
00137 bool justDisplayedOp() const
00138 { return myJustDisplayedOpFlag; }
00139 void justDisplayedOp(bool onoff)
00140 { myJustDisplayedOpFlag = onoff; }
00141
00142
00143
00144 virtual int handleKeyEvent(UI_Event *event,
00145 DM_Viewport &viewport) = 0;
00146
00147
00148
00149 virtual bool handleTransitoryKey(const UI_Event &event);
00150
00151
00152 virtual UI_Menu *getSelectorMenu() const = 0;
00153 virtual UI_Menu *getSelectorHotkeyMenu() const
00154 { return 0; }
00155
00156 virtual const char *cursor() const;
00157
00158 void handleSelectionStyleChange(UI_Event *event);
00159
00160
00161
00162 static bool getPickingMenuOn() { return thePickingMenuOn; }
00163 static void setPickingMenuOn(bool val) { thePickingMenuOn = val; }
00164 static bool getAllowUseExistingSelection()
00165 { return theAllowUseExistingSelection; }
00166 static void setAllowUseExistingSelection(bool val)
00167 { theAllowUseExistingSelection = val; }
00168
00169
00170
00171
00172 static GU_Detail *getGeometryFromPath(const char *path);
00173 static OP_Node *getNodeFromPath(const char *path);
00174 static const SIM_Object *getSimObjectFromPath(const char *path);
00175 static const SIM_Data *getSimModifierFromPath(const char *path);
00176
00177 protected:
00178 OP3D_View &viewer() { return (OP3D_View &)baseViewer(); }
00179 const OP3D_View &viewer() const { return (OP3D_View &)baseViewer(); }
00180
00181 DM_Workbench &workbench() { return *myWorkbench; }
00182 const DM_Workbench &workbench() const { return *myWorkbench; }
00183
00184 void setFinishedValuePtr(UI_Value *new_value)
00185 { myFinishedValue = new_value; }
00186 UI_Value * getFinishedValuePtr() const
00187 { return myFinishedValue; }
00188
00189 void setSelectionStylePtr(UI_Value *new_value)
00190 { mySelectionStyle = new_value; }
00191 UI_Value * getSelectionStylePtr() const
00192 { return mySelectionStyle; }
00193 DM_SelectionStyle selectionStyle() const
00194 {
00195 if (mySelectionStyle)
00196 return (DM_SelectionStyle)
00197 (int)*mySelectionStyle;
00198 else
00199 return DM_STYLE_UNKNOWN;
00200 }
00201
00202 void setSelectionRulePtr(UI_Value *new_value)
00203 { mySelectionRule = new_value; }
00204 UI_Value * getSelectionRulePtr() const
00205 { return mySelectionRule; }
00206 GU_SelectionRule selectionRule() const
00207 {
00208 if (mySelectionRule)
00209 return (GU_SelectionRule)
00210 (int)*mySelectionRule;
00211 else
00212 return GU_ReplaceSelect;
00213 }
00214 void selectionRule(GU_SelectionRule srule)
00215 {
00216 if (mySelectionRule)
00217 *mySelectionRule = (int)srule;
00218 }
00219
00220 SI_Brush * getPickBrushPtr() const
00221 { return myPickBrush; }
00222
00223
00224
00225 virtual bool needObjectPick() const;
00226
00227
00228
00229 bool selectModeMatchesTemplateType();
00230
00231
00232
00233 bool pickChosenOp(unsigned *pick_buffer, int num_picked);
00234
00235
00236
00237
00238 void userFilterPicks(uint *pickbuf, int &npicked,
00239 UI_Event *event);
00240
00241
00242
00243
00244 virtual OP_Node *switchToChosenOp(OP_Node *parent);
00245
00246
00247 virtual void saveForUndo();
00248
00249
00250
00251
00252 virtual bool getPickName(const OP3D_PickId &pickid,
00253 UT_String &name,
00254 bool descriptivename) const = 0;
00255
00256
00257
00258 void enablePicker(UI_Event *event);
00259
00260 virtual void handleBoxPickEvent(UI_Event *event) = 0;
00261 virtual void handleLassoPickEvent(UI_Event *event) = 0;
00262 virtual void handleBrushPickEvent(UI_Event *event) = 0;
00263
00264
00265 static float getTime();
00266
00267 private:
00268 DM_Workbench *myWorkbench;
00269
00270 UI_Value *myFinishedValue;
00271 UI_Value *mySelectionStyle;
00272 UI_Value *mySelectionRule;
00273
00274 SI_RubberBox *myPickBox;
00275 SI_Lasso *myPickLasso;
00276 SI_Brush *myPickBrush;
00277
00278 DM_SelectMode myPreferredSelectMode;
00279 bool myAllowDragging;
00280 bool myAllowFinishingFlag;
00281 bool myAllowFinishWithExistingSelection;
00282 bool myAllowQuickSelect;
00283 bool myJustDisplayedOpFlag;
00284
00285 static bool thePickingMenuOn;
00286 static bool theAllowUseExistingSelection;
00287 };
00288
00289 #endif