00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SO_INTERACTIVE_COMPLEXITY_H
00024 #define SO_INTERACTIVE_COMPLEXITY_H
00025
00026 #include <Inventor/nodes/SoNode.h>
00027 #include <Inventor/fields/SoMFString.h>
00028 #include <Inventor/fields/SoSFEnum.h>
00029 #include <Inventor/fields/SoSFBool.h>
00030 #include <Inventor/fields/SoSFFloat.h>
00031
00032 #include <Inventor/STL/map>
00033 #include <Inventor/sensors/SoAlarmSensor.h>
00034
00035 #ifdef _WIN32
00036 #pragma warning( push )
00037 #pragma warning(disable:4251) // disable warning 4251 "needs to have dll-interface to be used by clients of class..." caused by ScalarBoundsMap
00038 #endif
00039
00152 class SoInteractiveComplexity : public SoNode
00153 {
00154 SO_NODE_HEADER(SoInteractiveComplexity);
00155
00156 public:
00157 SoInteractiveComplexity();
00158
00160 enum InteractiveMode {
00162 AUTO,
00164 FORCE_INTERACTION,
00166 FORCE_STILL,
00168 DISABLED
00169 };
00170
00220 SoMFString fieldSettings;
00221
00225 SoSFFloat refinementDelay;
00226
00233 SoSFEnum interactiveMode;
00234
00235 private:
00236 virtual void doAction(SoAction *action);
00237 virtual void GLRender(SoGLRenderAction *action);
00238
00239 private:
00243 virtual void notify(SoNotList *list);
00244
00245 static void initClass();
00246 static void exitClass();
00247
00249 double getScalarFieldValue(SoState* state, const SoSField* field);
00250 SbBool getBooleanFieldValue(SoState* state, const SoSFBool* field);
00251 int getEnumFieldValue(SoState* state, const SoSFEnum* field);
00252
00254 bool isBounded(const SoField* field) const;
00255
00256 private:
00257 struct ScalarBounds
00258 {
00259 double startBound;
00260 double endBound;
00261 double increment;
00262
00263 double currentVal;
00264 bool immediate;
00265 };
00266 typedef std::map<SbString, ScalarBounds> ScalarBoundsMap;
00267
00268 virtual ~SoInteractiveComplexity();
00269
00271 static SbBool isScalarField(const SoField* field);
00272
00274 void updateFieldList();
00275 void addParameters(const SbString& paramString);
00276
00278 void handleScalarParam(const SbString& paramString, const std::vector<SbString>& token);
00279 void handleBoolParam(const SbString& paramString, const std::vector<SbString>& token);
00280 void handleEnumParam(const SbString& paramString, const std::vector<SbString>& token,
00281 const SoField* field);
00282
00284 bool checkParamNumber(size_t numParam, size_t expected, const SbString& fieldName) const;
00285
00287 void getClassAndFieldName(const SoField* field, SbString& className, SbString& fieldName) const;
00288
00290 double getScalarFieldValue(SoState* state, const SoSField* field,
00291 const SbString& classAndFieldName, bool updateValue = false);
00292
00294 void updateAllFieldsValue(SoState* state);
00295
00298 static void sensorCB(void *data, SoSensor *sensor);
00299
00301 ScalarBoundsMap m_scalarBounds;
00302
00304 SoAlarmSensor m_redrawSensor;
00305 };
00306
00307 #if defined(_WIN32)
00308 #pragma warning( pop )
00309 #endif
00310
00311 #endif //SO_INTERACTIVE_COMPLEXITY_H
00312