00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef VRS_SG_AREASELECTOR_H
00023 #define VRS_SG_AREASELECTOR_H
00024
00025 #include <vrs/bounds.h>
00026 #include <vrs/callback.h>
00027 #include <vrs/color.h>
00028 #include <vrs/sg/interactiontechnique.h>
00029 #include <vrs/rayrequesttechnique.h>
00030
00031 namespace VRS {
00032
00033 class SceneThing;
00034 class Filter;
00035
00036
00041 class VRS_CORE_API AreaSelector :
00042 public InteractionTechnique
00043 {
00044 public:
00045 VRS_TYPEINFO(AreaSelector, InteractionTechnique);
00046
00048 AreaSelector(double minY, double maxY, const Color& color = Color(1.0, 0.0, 0.0, 0.3),SO<Filter> rayRequestFilter = 0,RayRequestTechnique::RQMode = RayRequestTechnique::All);
00049
00050 static const MouseButtonFunctionID SelectionButton;
00051
00054 void setHeights(double minY, double maxY);
00055 double getMinHeight() const;
00056 double getMaxHeight() const;
00057
00059 virtual void onDragStart(
00060 int x, int y,
00061 SO<ButtonEvent>,
00062 MouseButtonFunctionID id
00063 );
00064 virtual void onDragMotion(
00065 int x, int y,
00066 SO<MotionEvent>,
00067 MouseButtonFunctionID id,
00068 int startX, int startY
00069 );
00070 virtual void onDragEnd(
00071 int x, int y,
00072 SO<ButtonEvent>,
00073 MouseButtonFunctionID id,
00074 int startX, int startY
00075 );
00076
00078 virtual void onEventPassive(SO<Event> e, bool modeActive);
00079
00083 SO<SceneThing> getSelectionScene() const;
00084
00087 void registerDragStartCallback(SO<Callback2<SO<ButtonEvent>, Vector> > callback);
00088 void registerDragMotionCallback(SO<Callback2<SO<MotionEvent>, Bounds> > callback);
00089 void registerDragEndCallback(SO<Callback2<SO<ButtonEvent>, Bounds> > callback);
00090
00091 void unregisterDragStartCallback(SO<Callback2<SO<ButtonEvent>, Vector> > callback);
00092 void unregisterDragMotionCallback(SO<Callback2<SO<MotionEvent>, Bounds> > callback);
00093 void unregisterDragEndCallback(SO<Callback2<SO<ButtonEvent>, Bounds> > callback);
00094
00098 bool keepSelectionSceneEnabled() const;
00099 void setKeepSelectionSceneEnabled(bool yesNo = false);
00100
00102 void setCurrentSelection(const VRS::Bounds& bounds);
00103
00104 SO<Filter> getRayRequestFilter() const { return m_rayRequestFilter; }
00105 void setRayRequestFilter(SO<Filter> val) { m_rayRequestFilter = val; }
00106
00107 protected:
00108
00109
00111 SO<SceneThing> createSelectionScene(const Bounds& bounds);
00112
00115 void finishSelection(SO<ButtonEvent> be);
00116
00117 bool m_dragging;
00118 SO<Filter> m_rayRequestFilter;
00119
00120 RayRequestTechnique::RQMode m_rayRequestMode;
00121
00122 SO<SceneThing> m_selectionScene;
00123 double m_minY;
00124 double m_maxY;
00125 Color m_color;
00126 Bounds m_selectionBounds;
00127 SO<Canvas> m_canvas;
00128 Vector m_dragStart;
00129 bool m_keepSelectionSceneEnabled;
00130
00131 SO<Array<SO<Callback2<SO<ButtonEvent>, Vector> > > > m_startCallbacks;
00132 SO<Array<SO<Callback2<SO<MotionEvent>, Bounds> > > > m_motionCallbacks;
00133 SO<Array<SO<Callback2<SO<ButtonEvent>, Bounds> > > > m_endCallbacks;
00134 };
00135
00136 }
00137
00138 #endif // VRS_SG_AREASELECTOR_H