Graphite  Version 3
An experimental 3D geometry processing program
ray_picker.h
Go to the documentation of this file.
1 /*
2  * OGF/Graphite: Geometry and Graphics Programming Library + Utilities
3  * Copyright (C) 2000 Bruno Levy
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  * If you modify this software, you should include a notice giving the
20  * name of the person performing the modification, the date of modification,
21  * and the reason for such modification.
22  *
23  * Contact: Bruno Levy
24  *
25  * levy@loria.fr
26  *
27  * ISA Project
28  * LORIA, INRIA Lorraine,
29  * Campus Scientifique, BP 239
30  * 54506 VANDOEUVRE LES NANCY CEDEX
31  * FRANCE
32  *
33  * Note that the GNU General Public License does not permit incorporating
34  * the Software into proprietary programs.
35  */
36 
37 
38 #ifndef H_OGF_SCENE_GRAPH_GFX_TRANSFORMS_RAY_PICKER_H
39 #define H_OGF_SCENE_GRAPH_GFX_TRANSFORMS_RAY_PICKER_H
40 
41 #include <OGF/scene_graph_gfx/common/common.h>
42 #include <OGF/gom/types/node.h>
44 
50 namespace OGF {
51 
52  class RenderingContext;
53 
54  /**************************************************************************/
55 
64  struct RayPick {
65  public:
66 
73  RayPick(const vec2& p_ndc_in, int btn_in) :
74  p_ndc(p_ndc_in),
75  button(btn_in) {
76  }
77 
82  RayPick() {
83  }
84 
90 
94  int button;
95  };
96 
104  SCENE_GRAPH_GFX_API std::ostream& operator<<(
105  std::ostream& out, const RayPick& ev
106  );
107 
115  SCENE_GRAPH_GFX_API std::istream& operator>>(std::istream& in, RayPick& ev);
116 
117 
126  gom_class SCENE_GRAPH_GFX_API RayPicker : public Object {
127  public:
132 
136  ~RayPicker() override;
137 
138  gom_slots:
139 
147  void grab(
148  RenderingContext* rendering_context,
149  const vec2& point_ndc, int button
150  );
151 
160  void drag(
161  RenderingContext* rendering_context,
162  const vec2& point_ndc, int button
163  );
164 
172  void release(
173  RenderingContext* rendering_context,
174  const vec2& point_ndc, int button
175  );
176 
177  gom_signals:
184  void ray_grab(
185  RenderingContext* rendering_context, const RayPick& value
186  );
187 
194  void ray_drag(
195  RenderingContext* rendering_context, const RayPick& value
196  );
197 
205  RenderingContext* rendering_context, const RayPick& value
206  );
207 
208  protected:
222  RenderingContext* context, const vec2& p_ndc, int button
223  );
224  };
225 
226  /*************************************************************************/
227 
228 }
229 #endif
Base class for all objects in the GOM system.
Definition: object.h:65
Converts a 2D picking in a rendering window into a ray picking event.
Definition: ray_picker.h:126
RayPicker()
RayPicker constructor.
void release(RenderingContext *rendering_context, const vec2 &point_ndc, int button)
Callback called when a mouse button is released.
void ray_drag(RenderingContext *rendering_context, const RayPick &value)
The signal triggered when the mouse is dragged.
void drag(RenderingContext *rendering_context, const vec2 &point_ndc, int button)
Callback called when the mouse is dragged with a button pressed.
RayPick point_to_ray_pick(RenderingContext *context, const vec2 &p_ndc, int button)
Converts a mouse pointer location into a RayPick event.
void ray_release(RenderingContext *rendering_context, const RayPick &value)
The signal triggered when a mouse button is released.
~RayPicker() override
RayPicker destructor.
Helper class for OpenGL context management.
Global Graphite namespace.
Definition: common.h:76
std::ostream & operator<<(std::ostream &out, const ArgList &args)
Prints an ArgList into a stream.
Definition: arg_list.h:527
std::istream & operator>>(std::istream &in, PointStyle &ps)
Reads a PointStyle from a stream.
The base class for all composite objects in the GOM system.
Simple geometric objects and manipulations.
Represents the information related with a picking event.
Definition: ray_picker.h:64
vec2 p_ndc
picked point, in normalized device coordinates (X and Y both in [-1.0, 1.0]).
Definition: ray_picker.h:89
RayPick()
RayPick constructor.
Definition: ray_picker.h:82
int button
Clicked button.
Definition: ray_picker.h:94
RayPick(const vec2 &p_ndc_in, int btn_in)
RayPick constructor.
Definition: ray_picker.h:73