1 /***********************************************************************/ 2 /* Open Visualization Data Explorer */ 3 /* (C) Copyright IBM Corp. 1989,1999 */ 4 /* ALL RIGHTS RESERVED */ 5 /* This code licensed under the */ 6 /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */ 7 /***********************************************************************/ 8 9 #include <dxconfig.h> 10 #include "../base/defines.h" 11 12 13 #ifndef _SequencerNode_h 14 #define _SequencerNode_h 15 16 17 #include "ShadowedOutputNode.h" 18 19 typedef long SequencerDirection; 20 21 // 22 // Class name definition: 23 // 24 #define ClassSequencerNode "SequencerNode" 25 26 // 27 // Referenced Classes 28 // 29 class SequencerWindow; 30 // 31 // SequencerNode class definition: 32 // 33 class SequencerNode : public ShadowedOutputNode 34 { 35 friend class SequencerWindow; 36 friend class DXExecCtl; 37 38 private: 39 // 40 // Private member data: 41 // 42 int xpos, ypos, width, height; 43 44 // 45 // Handler for 'frame %d %d' messages. 46 // 47 static void ProcessFrameInterrupt(void *clientData, int id, void *p); 48 49 SequencerWindow* seq_window; 50 boolean step; /* step mode? */ 51 boolean loop; /* loop mode? */ 52 boolean palindrome; /* palindrome mode? */ 53 54 boolean current_defined;/* current frame defined? */ 55 boolean stop_requested; /* execution stop requested? */ 56 int startValue; // Start frame 57 int stopValue; // Stop frame 58 59 //short minimum; /* minimum frame */ 60 //short maximum; /* maximum frame */ 61 //short start; /* start frame */ 62 //short stop; /* stop frame */ 63 //short increment; /* frame increment */ 64 65 short current; /* current frame */ 66 short next; /* current frame */ 67 short previous; /* previous frame */ 68 69 boolean ignoreFirstFrameMsg; 70 boolean transmitted; /* frame values transmitted? */ 71 // 72 // Indicates if this node has ever been executed 73 // (even across different executions of the User Interface). This is 74 // used to tell the Sequencer module in the executive when to ignore 75 // the frame input (it ignores it if it has never been executed before). 76 // 77 boolean wasExecuted; // Has this instance ever been run 78 79 // 80 // Nov, 1996 - added startup flag to print/parse operation so that you 81 // could start in image mode without having the vcr appear. To preserve 82 // old behavior, record whether or not you actuall parsed a startup value 83 // and treat those sequencers for which there was not value parsed as if 84 // the vcr is a startup window. 85 // 86 boolean startup; 87 void setStartup(boolean on = TRUE) { this->startup = on; } 88 89 // 90 // Disable the Frame control. 91 // 92 void disableFrameControl(); 93 // 94 // Enable the Frame control if the node is not data driven. 95 // 96 void enableFrameControl(); 97 // 98 // Set the buttons that indicate the direction of play. 99 // 100 void setPlayDirection(SequencerDirection dir); 101 void setForwardPlay(); 102 void setBackwardPlay(); 103 void setStepMode(boolean step = TRUE); 104 void setLoopMode(boolean loop = TRUE); 105 void setPalindromeMode(boolean pal = TRUE); 106 107 // 108 // Print/parse comments that are common to both .nets and .cfgs. 109 // 110 boolean printCommonComments(FILE *f, const char *indent = NULL); 111 boolean parseCommonComments(const char* comment, 112 const char *file, 113 int lineno); 114 115 116 protected: 117 // 118 // Protected member data: 119 // 120 virtual char *netNodeString(const char *prefix); 121 virtual char *valuesString(const char *prefix); 122 virtual boolean cfgPrintNode(FILE *f, PrintType dest); 123 124 virtual boolean netPrintAuxComment(FILE *f); 125 virtual boolean netParseAuxComment(const char* comment, 126 const char *file, int lineno); 127 128 // 129 // The messages we parse can contain one or more of the following... 130 // 131 // 'min=%g' 'max=%g' 'start=%d' 'end=%d' 'delta=%g' 132 // 133 // If any input or output values are to be changed, don't send them 134 // because the module backing up the sequencer will have just executed 135 // and if the UI is in 'execute on change' mode then there will be an 136 // extra execution. 137 // 138 // Returns the number of attributes parsed. 139 // 140 virtual int handleNodeMsgInfo(const char *line); 141 142 // 143 // Update the Sequencer state that is based on the state of this 144 // node. Among other times, this is called after receiving a message 145 // from the executive. 146 // 147 virtual void reflectStateChange(boolean unmanage); 148 149 // 150 // Initialize the attributes with the give string values. 151 // 152 boolean initMinimumValue(int val); 153 boolean setMinimumValue(int val); 154 155 boolean initMaximumValue(int val); 156 boolean setMaximumValue(int val); 157 158 boolean initDeltaValue(int val); 159 boolean setDeltaValue(int val); 160 161 boolean initStartValue(int val); 162 boolean setStartValue(int val); 163 164 boolean initStopValue(int val); 165 boolean setStopValue(int val); 166 167 #if 0 168 boolean isAttributeVisuallyWriteable(int input_index); 169 170 boolean setStartValue(const char *val); 171 boolean setStopValue(const char *val); 172 boolean setDeltaValue(const char *val); 173 boolean setMaximumValue(const char *val); 174 boolean setMinimumValue(const char *val); 175 #endif 176 177 // 178 // The Sequencer always expects the 'frame %d %d' message and when 179 // data-driven expects 'Sequencer_%d: ...' messages. We install the 180 // handler for the 'frame' message here and then call the super class 181 // to install the 'Sequencer_%d:' handler. 182 // hasModuleMessagingProtocol()183 virtual boolean hasModuleMessagingProtocol() { return TRUE; } 184 virtual void updateModuleMessageProtocol(DXPacketIF *pif); 185 186 // 187 // If the min or max input has changed, update the attribute parameter 188 // (integer list of min and max) and then call the super class method 189 // if the input is not the attribute parameter. 190 // 191 virtual void ioParameterStatusChanged(boolean input, int index, 192 NodeParameterStatusChange status); 193 194 195 // 196 // Make sure the value of the parameter that holds a list of ui attributes 197 // (i.e. min/max/incr) is up to date in the executive. 198 // Always send it since the input attribute is cache:0. 199 // 200 void updateAttributes(); 201 202 public: 203 // 204 // Constructor: 205 // 206 SequencerNode(NodeDefinition *nd, Network *net, int instnc); 207 208 // 209 // Destructor: 210 // 211 ~SequencerNode(); 212 213 enum { 214 ForwardDirection = 1, 215 BackwardDirection = 2, 216 Directionless = 3 217 }; 218 219 virtual boolean initialize(); 220 void openDefaultWindow(Widget); 221 boolean isStartup(); 222 223 // 224 // Let the caller of openDefaultWindow() know what kind of window she's getting. 225 // This is intended for use in EditorWindow so that we can sanity check the number 226 // of cdbs were going to open before kicking off the operation and so that we 227 // don't question the user before opening large numbers of interactors. 228 // A name describing the type of window can be written into window_name in order 229 // to enable nicer warning messages. 230 // 231 virtual boolean defaultWindowIsCDB(char* window_name = NULL) 232 { if (window_name) strcpy (window_name, "Sequencer"); return FALSE; } 233 234 virtual boolean cfgParseComment(const char* comment, 235 const char *file, 236 int lineno); 237 238 boolean isMinimumVisuallyWriteable(); 239 boolean isMaximumVisuallyWriteable(); 240 #ifdef HAS_START_STOP 241 boolean isStartVisuallyWriteable(); 242 boolean isStopVisuallyWriteable(); 243 #endif 244 boolean isDeltaVisuallyWriteable(); 245 246 int getMinimumValue(); 247 int getMaximumValue(); 248 int getDeltaValue(); 249 int getStartValue(); 250 int getStopValue(); 251 252 isStepMode()253 boolean isStepMode() { return this->step; } isLoopMode()254 boolean isLoopMode() { return this->loop; } isPalindromeMode()255 boolean isPalindromeMode() { return this->palindrome; } 256 257 // 258 // Get a string representing the assignment to the global vcr variables, 259 // @startframe, @frame, @nextframe, @endframe and @deltaframe. 260 // The returned string must be deleted by the caller. 261 // 262 char *getFrameControlString(); 263 264 Widget getVCRWidget(); 265 266 // 267 // Determine if this node is a node of the given class 268 // 269 virtual boolean isA(Symbol classname); 270 271 virtual boolean canSwitchNetwork(Network *from, Network *to); 272 getDXWindow()273 virtual DXWindow *getDXWindow() 274 {return (DXWindow *)this->seq_window;}; 275 276 // 277 // Return TRUE if this node has state that will be saved in a .cfg file. 278 // 279 virtual boolean hasCfgState(); 280 281 // 282 // Most nodes' id parameter is number 1 but a few aren't. This number is 283 // important because whenever you merge 2 nets, you update instance numbers. 284 // When you do that, you must also change the id parameter and for that you 285 // need its number. 286 // 287 virtual int getMessageIdParamNumber(); 288 getJavaNodeName()289 virtual const char* getJavaNodeName() { return "SequencerNode"; } 290 virtual boolean printInputAsJava(int input); 291 virtual const char *getJavaInputValueString(int index); 292 293 294 295 296 // 297 // Returns a pointer to the class name. 298 // getClassName()299 const char* getClassName() 300 { 301 return ClassSequencerNode; 302 } 303 }; 304 305 306 #endif // _SequencerNode_h 307