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 14 #ifndef _ScalarNode_h 15 #define _ScalarNode_h 16 17 18 #include "InteractorNode.h" 19 #include "StepperInteractor.h" 20 #include "List.h" 21 22 class Network; 23 24 // 25 // Class name definition: 26 // 27 #define ClassScalarNode "ScalarNode" 28 29 // 30 // ScalarNode class definition: 31 // 32 class ScalarNode : public InteractorNode 33 { 34 35 private: 36 // 37 // Private member data: 38 // 39 boolean vectorType; 40 boolean needsRangeCheck; 41 int rangeCheckDeferrals; 42 43 // 44 // Adjusts the dimensionality of all attribute components for 45 // this->doDimensionalityChange(). 46 // 47 boolean adjustAttributeDimensions(int old_dim, int new_dim); 48 49 protected: 50 // 51 // Protected member data: 52 // 53 54 // 55 // If we're parsing input #4 (which is now REFRESH and was at one point REMAP) 56 // and the net version is older than 3.1.0 (which is compiled in by DXVersion.h), 57 // then set the defaulting status = TRUE. Reason: the older ui was setting 58 // the defaulting status of this unused param to FALSE. Now that we want to use 59 // the param again, old nets believe the param is set. 60 // 61 virtual boolean parseIOComment(boolean input, const char* comment, 62 const char* filename, int lineno, boolean valueOnly = FALSE); 63 64 // 65 // Make sure the number of inputs is the number expected. 66 // 67 boolean verifyInputCount(); 68 69 // 70 // Adjusts the dimensionality of all outputs for 71 // this->doDimensionalityChange(). 72 // 73 virtual boolean adjustOutputDimensions(int old_dim, int new_dim); 74 75 // 76 // Global flag for all interactor instances indicating whether or not to 77 // do continuous updates to the exec. 78 // 79 boolean isContinuousUpdate; 80 81 82 boolean cfgParseComponentComment(const char *comment, 83 const char *filename, int lineno); 84 boolean cfgParseInstanceComment(const char *comment, 85 const char *filename, int lineno); 86 87 // 88 // Print the '// interactor...' comment to the .cfg file. 89 // We override the parent's method so that we can print num_components 90 // correctly. 91 // 92 virtual boolean cfgPrintInteractorComment(FILE *f); 93 // 94 // Print auxiliary info for this interactor, which includes all global 95 // information about each component. 96 // 97 virtual boolean cfgPrintInteractorAuxInfo(FILE *f); 98 // 99 // Print auxiliary info for the interactor instance, which includes 100 // all local information about each component. 101 // 102 virtual boolean cfgPrintInstanceAuxInfo(FILE *f, InteractorInstance *ii); 103 104 // 105 // Get a ScalarInstance instead of an InteractorInstance. 106 // 107 virtual InteractorInstance *newInteractorInstance(); 108 109 // 110 // Parse comments the 'local increment' comment. 111 // 112 boolean cfgParseLocalIncrementComment(const char *comment, 113 const char *filename, int lineno); 114 115 // 116 // Parse comments the 'local increment' comment. 117 // 118 boolean cfgParseLocalContinuousComment(const char *comment, 119 const char *filename, int lineno); 120 121 // The messages we deal with can contain one or more of the following... 122 // 123 // 'min=%g' 'max=%g' 'delta=%g' 'value=%g' 'decimals=%d' 124 // 125 // or one or more of the following... 126 // 127 // 'min=[%g %g %g]' 'max=[%g %g %g]' 'delta=[%g %g %g]' 'value=[%g %g %g]' 128 // 'decimals=[%g %g %g]' 129 // 130 // Returns the number of attributes parsed. 131 virtual int handleInteractorMsgInfo(const char *line); 132 // 133 // Handles... 134 // 'min=%g' 'max=%g' 'delta=%g' 'value=%g' 'decimals=%d' 135 // 136 int handleScalarMsgInfo(const char *line); 137 // 138 // Handles... 139 // 'dim=%d' 140 // 'min=[%g %g %g]' 'max=[%g %g %g]' 'delta=[%g %g %g]' 'value=[%g %g %g]' 141 // 'decimals=[%g %g %g]' 142 // 143 int handleVectorMsgInfo(const char *line); 144 145 // 146 // Set the interactor's default attributes (attributes that can 147 // be shared by derived classes). 148 // 149 virtual boolean setDefaultAttributes(); 150 151 // 152 // Get and set the USUALLY global component values. In some cases 153 // (i.e. ScalarListNode), the component values are saved with the 154 // InteractorInstance. So we make these protected and only allow 155 // the ScalarInstance class to access them. 156 // 157 boolean setComponentValue(int component, double value); 158 double getComponentValue(int component); 159 friend class ScalarInstance; 160 161 // 162 // Do what ever is necessary when the given component of the output 163 // value is out of range as indicated by the limits. Typically, this just 164 // means resetting the current output value that is associated with the 165 // node. ScalarListNodes however, have the current (non-output) value 166 // associated with the interactor instance. Therefore, ScalarListNodes, 167 // re-implement this to reset the component values of all their instances. 168 // If 'component' is less than 0, then min/max are ignored and all 169 // components are checked with the current min/max values. 170 // 171 virtual void doRangeCheckComponentValue(int component, 172 double min, double max); 173 174 // 175 // Call doRangeCheckComponentValue() if range checking is not deferred. 176 // 177 void rangeCheckComponentValue(int component, double min, double max); 178 179 // 180 // Provide methods to delay doRangeCheckComponentValue(). 181 // isRangeCheckingDeferred()182 boolean isRangeCheckingDeferred() 183 { return this->rangeCheckDeferrals != 0;} deferRangeChecking()184 void deferRangeChecking() {this->rangeCheckDeferrals++;} undeferRangeChecking()185 void undeferRangeChecking() 186 { ASSERT(this->rangeCheckDeferrals > 0); 187 if ((--this->rangeCheckDeferrals == 0) && 188 this->needsRangeCheck) 189 this->rangeCheckComponentValue(-1, 0.0, 0.0); 190 } 191 192 193 // 194 // Initialize the attributes with the give string values. 195 // 196 boolean initMinimumAttribute(const char *val); 197 boolean setMinimumAttribute(const char *val); 198 boolean initMaximumAttribute(const char *val); 199 boolean setMaximumAttribute(const char *val); 200 boolean initDeltaAttribute(const char *val); 201 boolean setDeltaAttribute(const char *val); 202 boolean initDecimalsAttribute(const char *val); 203 boolean setDecimalsAttribute(const char *val); 204 205 // 206 // Change the dimensionality of a Vector interactor. 207 // 208 virtual boolean doDimensionalityChange(int new_dim); 209 210 211 public: 212 // 213 // Constructor: 214 // 215 ScalarNode(NodeDefinition *nd, Network *net, int instnc, 216 boolean isVector = FALSE, int dimensions = 1); 217 218 // 219 // Destructor: 220 // ~ScalarNode()221 ~ScalarNode(){} 222 223 // 224 // Set the attributes for the given component of the given instance 225 // of an interactor. 226 // 227 boolean setAllComponentRanges(double *min, double *max); 228 boolean setComponentMinimum(int component, double min); 229 boolean setComponentMaximum(int component, double max); 230 boolean setComponentDelta(int component, double delta); 231 boolean setComponentDecimals(int component, int decimals); setContinuous(boolean val)232 void setContinuous(boolean val) { isContinuousUpdate = val; } setContinuous()233 void setContinuous() { isContinuousUpdate = TRUE; } clrContinuous()234 void clrContinuous() { isContinuousUpdate = FALSE; } 235 236 // 237 // Get the global attributes for the given component of an interactor. 238 // 239 double getComponentMinimum(int component); 240 double getComponentMaximum(int component); 241 double getComponentDelta(int component); 242 int getComponentDecimals(int component); 243 boolean isIntegerTypeComponent(); isContinuous()244 boolean isContinuous() { return isContinuousUpdate; } 245 isVectorType()246 boolean isVectorType() { return this->vectorType; } 247 248 // 249 // Called once for each instance 250 // 251 virtual boolean initialize(); 252 253 // 254 // Indicates whether this node has outputs that can be remapped by the 255 // server. 256 // hasRemappableOutput()257 virtual boolean hasRemappableOutput() { return TRUE; } 258 259 // 260 // Call the super class method, but then catch the output comment 261 // to determine the number of components. 262 // We need to do this when we have a 2d vector and no .cfg file to 263 // tell us so. We then get numComponent==3, but all the parameter 264 // values are 2d, which results in an ASSERTion failure. 265 // 266 virtual boolean netParseComment(const char* comment, 267 const char *file, int lineno); 268 269 // 270 // Parse comments found in the .cfg that the InteractorNode knows how to 271 // parse plus ones that it does not. 272 // 273 virtual boolean cfgParseComment(const char *comment, 274 const char *filename, int lineno); 275 276 // 277 // Does this node implement doDimensionalityChange(); 278 // 279 virtual boolean hasDynamicDimensionality(boolean ignoreDataDriven = FALSE); 280 281 // 282 // Determine if this node is a node of the given class 283 // 284 virtual boolean isA(Symbol classname); 285 286 boolean isMinimumVisuallyWriteable(); 287 boolean isMaximumVisuallyWriteable(); 288 boolean isDecimalsVisuallyWriteable(); 289 boolean isDeltaVisuallyWriteable(); 290 291 virtual boolean printJavaValue(FILE*); getJavaNodeName()292 virtual const char* getJavaNodeName() { return "ScalarNode"; } 293 294 295 // 296 // Returns a pointer to the class name. 297 // getClassName()298 const char* getClassName() 299 { 300 return ClassScalarNode; 301 } 302 }; 303 304 305 #endif // _ScalarNode_h 306