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_DIALOG_SLIDER_
00024 #define _SO_DIALOG_SLIDER_
00025
00026 #include <DialogViz/dialog/SoDialogComponent.h>
00027 #include <Inventor/fields/SoMFColor.h>
00028
00029 class SoDialogCustomSlider;
00030 class SbLineProjector;
00031 class SoEventCallback;
00032 class SoKeyboardEvent;
00033
00053 class SoDialogSlider : public SoDialogComponent
00054 {
00055 SO_DG_HEADER(SoDialogSlider);
00056
00057 public:
00058
00062 SoSFBool valueVisible;
00063
00067 SoSFString format;
00068
00074 SoSFBool continuousTrigger;
00075
00080 SoSFBool toggleVisible;
00081
00086 SoSFBool fixedLimits;
00087
00093 SoMFColor colors;
00094
00099 SoSFBool shadedColors;
00100
00104 SoDialogSlider();
00105
00106
00107
00108 private:
00109 virtual void buildWidget(SoWidget parent, SbVec2i32 &rSize, SbVec2i32 &pos, SbBool isActive2d);
00110 virtual void destroyWidget();
00111 virtual void eventNotify(unsigned int event, uintptr_t param);
00112 virtual SoWidget getLabelWidget();
00113 static void initClass();
00114 static void exitClass();
00115 virtual void setValueFromEdit(SbBool ) {};
00116 virtual void setValueFromSlider(float ) {};
00117 virtual void changeSliderValue() {};
00118 virtual void updateFromSensor(SoSensor* sensor);
00119 float getValue();
00120 static void finishCallback(void *slider, float newValue);
00121 static void valueChangeCallback(void* slider, float newValue);
00122 virtual void setValue() {};
00123 SbBool getActive2d() { return m_isActive2d; };
00124
00125
00126 void changeValueFromSlider(float newValue);
00127 void changeValueAfterFinish(float newValue);
00128 void changeSliderFromEdit();
00129 void changeSliderFromSlider(float num);
00130
00131
00132 void updateEditWidget();
00133 void updateSliderWidget();
00134 void updateLabelWidget();
00135 void updateToggleWidget();
00136
00137 private:
00138
00139 SoWidget m_sliderWidget;
00140 SoWidget m_toggleWidget;
00141 SoWidget m_editWidget;
00142 int m_sliderWidth;
00143 int m_editWidth;
00144 float m_sliderValue;
00145 SoDialogCustomSlider* m_dialogCustomSlider;
00146 bool m_ownDialogCustomSlider;
00147
00148 virtual ~SoDialogSlider();
00149
00150 virtual void changeEditValue() {};
00151 SbString getValueFromEdit();
00152 virtual int computeEditZoneWidth() {return 0;};
00153
00154 void updateWidget();
00155
00156 private:
00157
00158 FIELD_SENSOR(valueVisible);
00159 FIELD_SENSOR(continuousTrigger);
00160 FIELD_SENSOR(toggleVisible);
00161 FIELD_SENSOR(fixedLimits);
00162 FIELD_SENSOR(colors);
00163 FIELD_SENSOR(shadedColors);
00164 FIELD_SENSOR(format);
00165
00166
00167 virtual SbVec2i32 getComponentInitSize();
00168 virtual void getDefaultSize(SbVec2i32 &size, SbVec2i32 &min, SbVec2i32 &max);
00169
00170
00171 void createEditWidget();
00172 void createLabelWidget();
00173 void createSliderWidget();
00174 void createToggleWidget();
00175
00176
00177
00178
00179 virtual void changeValueVisible();
00180 virtual void changeToggleVisible();
00181 virtual void changeContinuousTrigger();
00182 virtual void changeFormat();
00183
00184
00185 virtual void changeEdgeStyle();
00186 virtual void changeLabelVisibility();
00187
00188
00189 virtual void changeEnable();
00190 virtual void changeWidgetEnable(SbBool state);
00191 virtual void changeLabel();
00192 virtual void changeLabelAlignment();
00193
00195
00196 private:
00197 static char* DialogSlider;
00198 static void change3DSkin();
00199 static SbBool isSkinLoaded();
00200 static void setSkinLoaded(SbBool loaded);
00201
00202 SbBool ip_isEditing;
00203
00204 void change3DSliderValue();
00205 void change3DCursor();
00206
00207 static void processKeyEvents(void *inDragger, SoEventCallback *cb);
00208
00209 private:
00210
00211 SO_DG_CATALOG_ENTRY_HEADER( labelSep );
00212 SO_DG_CATALOG_ENTRY_HEADER( labelSwitch );
00213 SO_DG_CATALOG_ENTRY_HEADER( labelProp );
00214 SO_DG_CATALOG_ENTRY_HEADER( checkSep );
00215 SO_DG_CATALOG_ENTRY_HEADER( checkSwtch );
00216 SO_DG_CATALOG_ENTRY_HEADER( checkStateOff );
00217 SO_DG_CATALOG_ENTRY_HEADER( checkStateOn );
00218 SO_DG_CATALOG_ENTRY_HEADER( sliderSep );
00219 SO_DG_CATALOG_ENTRY_HEADER( frameSep );
00220 SO_DG_CATALOG_ENTRY_HEADER( frame );
00221 SO_DG_CATALOG_ENTRY_HEADER( cursorSep );
00222 SO_DG_CATALOG_ENTRY_HEADER( cursor );
00223 SO_DG_CATALOG_ENTRY_HEADER( edtSwtch );
00224 SO_DG_CATALOG_ENTRY_HEADER( edtFrmSep );
00225 SO_DG_CATALOG_ENTRY_HEADER( edtFrmSwtch );
00226 SO_DG_CATALOG_ENTRY_HEADER( valueFrame );
00227 SO_DG_CATALOG_ENTRY_HEADER( editValueFrame);
00228 SO_DG_CATALOG_ENTRY_HEADER( editTextSep );
00229 SO_DG_CATALOG_ENTRY_HEADER( editTextProp );
00230
00231 SoScale *sliderFrameScale, *sliderEditFrameScale;
00232 SoText3 *sliderLabel, *sliderEditText;
00233 SoTransform *sliderFrameTransform, *sliderEditFrameTransform;
00234 SoTranslation *sliderLabelTranslation, *sliderToggleTranslation;
00235 SoTranslation *sliderFrameTranslation, *sliderEditFrameTranslation;
00236 SoTranslation *sliderEditTextTranslation, *sliderCursorTranslation, *sliderCursorPosTranslation;
00237
00238 SbString get3DValueFromEdit();
00239 virtual void change3DEditValue();
00240 virtual void change3DEnable();
00241
00242 private:
00243 SbBox3f m_editTextCachedBBox;
00244 static SbBool m_isSkinLoaded;
00245
00246 SbLineProjector* m_lineProj;
00247 SbVec3f m_initialPos;
00248 int m_slider3DWidth;
00249
00250 void create3DDialogSlider();
00251 void update3DSlider();
00252 void update3DLabel();
00253
00254 virtual void set3DInactive();
00255 virtual void change3DLabelVisibility();
00256 virtual void change3DLabel();
00257 virtual void change3DLabelAlignment();
00258 void change3DContinuousTrigger();
00259 void change3DValueVisible();
00260 void change3DToggleVisible();
00261
00262 static void startCB3D( void *, SoDragger *inDragger );
00263 static void motionCB3D( void *, SoDragger *inDragger );
00264 static void finishCB3D( void *, SoDragger *inDragger );
00265 void draggerStartCallback3D();
00266 void draggerMotionCallback3D();
00267 void draggerFinishCallback3D();
00268
00269 virtual void computeNewSliderEditValue(SoKeyboardEvent* ) {};
00270
00271 private:
00272 virtual void finish3DEditing() {};
00274
00275 };
00276
00277 #endif // _SO_DIALOG_SLIDER_
00278
00279
00280