00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __MSS_SingleOpState_H__
00022 #define __MSS_SingleOpState_H__
00023
00024 #include "MSS_API.h"
00025 #include <UT/UT_PtrArray.h>
00026 #include <UT/UT_String.h>
00027 #include <GU/GU_Selection.h>
00028 #include <UI/UI_Value.h>
00029 #include <UI/UI_Event.h>
00030 #include <BM/BM_ResourceManager.h>
00031 #include "MSS_SingleOpBaseState.h"
00032
00033 class UT_String;
00034 class PRM_Template;
00035 class DM_Workbench;
00036 class OP3D_View;
00037 class JEDI_View;
00038 class OP3D_InputSelector;
00039 class DM_Viewport;
00040
00041 class mss_InputSelectorUndoWorker;
00042 class mss_UndoClearHandles;
00043
00044 class MSS_API MSS_SingleOpState : public MSS_SingleOpBaseState
00045 {
00046 friend class mss_UndoClearHandles;
00047 friend class mss_UndoCreateHandles;
00048 friend class mss_InputSelectorUndoWorker;
00049
00050 public:
00051
00052 MSS_SingleOpState(JEDI_View &view, PI_StateTemplate &templ,
00053 BM_SceneManager *scene, const char *cursor);
00054 virtual ~MSS_SingleOpState(void);
00055
00056
00057
00058 static BM_State *ourConstructor(BM_View &view, PI_StateTemplate &templ,
00059 BM_SceneManager *scene);
00060 static PRM_Template *ourTemplateList;
00061
00062
00063 virtual const char *className() const;
00064
00065
00066 virtual int enter(BM_SimpleState::BM_EntryType how);
00067 virtual void exit();
00068 virtual void restart(void);
00069 virtual int generate(BM_SimpleState::BM_EntryType how,
00070 bool insertmode = true);
00071
00072 virtual int hasLocates(void) const;
00073
00074
00075
00076 virtual int handleNodeDeleted(OP_Node &node);
00077
00078
00079
00080
00081 virtual bool ignoreDisplayFlagChange() const;
00082
00083 void undoReselecting();
00084
00085
00086 virtual UI_Menu *getSelectorMenu();
00087
00088
00089 virtual UI_Menu *getExtraStateMenu();
00090
00091 protected:
00092
00093
00094 virtual void doGenerate(void);
00095
00096
00097 virtual void doRender(RE_Render *r, short, short, int ghost);
00098
00099
00100 virtual int handleMouseEvent(UI_Event *event);
00101 virtual bool handleDoubleClickEvent(UI_Event *event);
00102 virtual int handleKeyTypeEvent(UI_Event *event, BM_Viewport &);
00103 virtual bool handleTransitoryKey(const UI_Event &event);
00104
00105
00106
00107 virtual bool isSelecting(void) const;
00108
00109
00110
00111
00112
00113
00114
00115
00116 virtual void resume(BM_SimpleState *state = 0);
00117
00118
00119 virtual bool generateAllNodes();
00120
00121
00122
00123 virtual void doneSelecting(void);
00124
00125
00126
00127 virtual int nodeIdToReselectWithin() const { return 0; }
00128
00129
00130 OP3D_InputSelector *selector(int idx)
00131 {
00132 UT_ASSERT(idx >= 0);
00133 UT_ASSERT(idx < mySelectors.entries());
00134 return mySelectors(idx).mySelector;
00135 }
00136 int getNumSelectors() const
00137 {
00138 return mySelectors.entries();
00139 }
00140
00141 virtual bool isSelectorActive() const
00142 { return (myCurrentSelector != 0); }
00143
00144 virtual int getToolboxCount() const;
00145 virtual UI_Feel *getToolbox(int idx) const;
00146
00147 virtual void handleSelectorDone(UI_Event *);
00148
00149
00150
00151 virtual bool canStartSelectors() const { return true; }
00152
00153 virtual const PI_BindingSelectorInfo *findNextParmWithSelector(int idx) const;
00154
00155 virtual void addAnyReselectionUndos();
00156
00157 virtual void updateCurrentSelector(OP3D_InputSelector * ,
00158 const PI_BindingSelectorInfo * )
00159 { }
00160
00161 virtual bool getSelectionBoundingBox( DM_Viewport &vport,
00162 UT_BoundingBox &bbox );
00163
00164 virtual bool getAllowQuickSelect() const { return false; }
00165
00166 virtual const char *getTemplateName() const
00167 { return (const char *)getTemplate().name(); }
00168
00169 bool getFirstSelectionFlag() const
00170 { return myFirstSelectionFlag; }
00171 void setFirstSelectionFlag(bool first)
00172 { myFirstSelectionFlag = first; }
00173
00174 virtual void handleSelectionTypeChange(UI_Event *event);
00175
00176 private:
00177
00178 void appendNodeToDisplay(OP_Node &newnode);
00179
00180 bool usesSelectors();
00181
00182 void deleteSelectors();
00183 void setCurrentSelector(const PI_BindingSelectorInfo *
00184 selector_info);
00185 void clearReselectLists();
00186
00187
00188 void storeSelectionsOfInputNodes();
00189
00190 void restoreCurrentSelectorSelections();
00191
00192 void restoreSelection(const char *selection_string,
00193 int selector_index);
00194
00195 GU_SelectionType getSelectionTypeForCurNode();
00196
00197 void startNonSecureSelector(UI_Event *event);
00198 void undoStartNonSecureSelector();
00199
00200 void finishSelector();
00201
00202 bool isRapidFire() const;
00203
00204 void createHotkeySelector();
00205 void destroyHotkeySelectorIfNeeded();
00206
00207 void handleFinishUndoEvent(UI_Event *event = 0);
00208
00209
00210
00211 class MSS_API MSS_SelectorBind
00212 {
00213 public:
00214 MSS_SelectorBind()
00215 : mySelector(0), mySelectorInfo(0)
00216 { }
00217 ~MSS_SelectorBind()
00218 {
00219
00220
00221 if( mySelector && PIresourceManagerExists() )
00222 BMgetResourceManager()->deleteSelector(
00223 (BM_InputSelector *)mySelector);
00224 }
00225 OP3D_InputSelector *mySelector;
00226 const PI_BindingSelectorInfo *mySelectorInfo;
00227 };
00228
00229 UT_RefArray<MSS_SelectorBind> mySelectors;
00230 OP3D_InputSelector *myCurrentSelector;
00231 const PI_BindingSelectorInfo *myCurrentSelectorInfo;
00232
00233
00234
00235 OP3D_InputSelector *myHotkeySelector;
00236 UI_Menu * myHotkeySelectorMenu;
00237
00238
00239
00240
00241 int mySelectorIndex;
00242
00243 UT_PtrArray<UT_StringArray *> myReselectPathLists;
00244 UT_StringArray myReselectSelectionStrings;
00245 UT_RefArray<GU_SelectionType> myReselectSelectionTypes;
00246
00247 UI_Value mySelFinishedValue;
00248
00249 float mySelectorActiveCoords[2];
00250 UI_Event myRapidFireActiveEvent;
00251 UI_Value myRapidFireActiveEventValue;
00252
00253 mss_InputSelectorUndoWorker * mySelectorUndoWorker;
00254
00255 int mySelectableFlag;
00256 unsigned myMouseTakenFlag:1;
00257 bool myFirstSelectionFlag;
00258 bool myInNonSecureUndo;
00259 bool myInNonSecureSelector;
00260
00261 int myDoubleClickUndoLevel;
00262 };
00263
00264 #endif