Graphite  Version 3
An experimental 3D geometry processing program
tool.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 #ifndef H_OGF_SCENE_GRAPH_TOOLS_TOOL_H
38 #define H_OGF_SCENE_GRAPH_TOOLS_TOOL_H
39 
40 #include <OGF/scene_graph_gfx/common/common.h>
43 #include <OGF/gom/types/node.h>
45 
51 namespace OGF {
52 
53  class ToolsManager;
54  class Grob;
55  class SceneGraph;
56 
60  gom_attribute(abstract, "true")
61  gom_class SCENE_GRAPH_GFX_API Tool : public Node {
62  public:
63 
68  Tool(ToolsManager* mgr) : tools_manager_(mgr) {
69  }
70 
78  void status(const std::string& value) ;
79 
85 
86  gom_slots:
91  virtual void grab(const RayPick& value) ;
92 
97  virtual void drag(const RayPick& value) ;
98 
103  virtual void release(const RayPick& value) ;
104 
111  virtual void reset() ;
112 
118  virtual void configure() ;
119 
120  public:
121 
127  return tools_manager_ ;
128  }
129 
136  const mat4& focus() const ;
137 
143 
148  Grob* object() const ;
149 
159 
160 
168  vec2 ndc_to_dc(vec2 p) const;
169 
170  protected:
176  void set_tooltip(const std::string& text);
177 
182 
183  protected:
184  ToolsManager* tools_manager_ ;
185  } ;
186 
191 
192  //___________________________________________________________________
193 
198  gom_attribute(abstract, "true")
199  gom_class SCENE_GRAPH_GFX_API MultiTool : public Tool {
200  public:
206 
212  void grab(const RayPick& value) override;
213 
219  void drag(const RayPick& value) override;
220 
226  void release(const RayPick& value) override;
227 
232  void reset() override;
233 
234  protected:
241  void set_tool(int button, Tool* tool) ;
242 
249  Tool* get_tool(int button) const ;
250 
251  protected:
252  Tool_var tools_[MOUSE_BUTTONS_NB];
253  } ;
254 
255  //_________________________________________________________________
256 
257 }
258 
259 #endif
Base class for all 3D Graphite objects.
Definition: grob.h:68
A Tool that can associate a different tool to each button of the mouse.
Definition: tool.h:199
void set_tool(int button, Tool *tool)
Associates a tool to one of the buttons.
Tool * get_tool(int button) const
Gets a Tool by button id.
void reset() override
Resets this Tool.
void grab(const RayPick &value) override
MultiTool(ToolsManager *mgr)
MultiTool constructor.
void release(const RayPick &value) override
The event handler for mouse release events.
void drag(const RayPick &value) override
The event handler for mouse drag events.
A composite object in the GOM system.
Definition: node.h:58
Helper class for OpenGL context management.
Represents the list of objects loaded in Graphite.
Definition: scene_graph.h:62
Base class for the tools.
Definition: tool.h:61
vec2 ndc_to_dc(vec2 p) const
Converts normalized device coordinates to device coordinates.
virtual void release(const RayPick &value)
The event handler for mouse release events.
RenderingContext * rendering_context() const
Gets the RenderingContext.
void reset_tooltip()
Removes a tooltip previously created by set_tooltip()
Tool(ToolsManager *mgr)
Tool constructor.
Definition: tool.h:68
void status(const std::string &value)
Outputs a message in the status bar.
virtual void reset()
Resets this Tool.
ToolsManager * tools_manager() const
Gets the ToolsManager.
Definition: tool.h:126
SceneGraph * scene_graph()
Gets the SceneGraph.
void set_tooltip(const std::string &text)
Sets the tooltip to be displayed under the mouse.
virtual void configure()
Configures this Tool.
virtual void drag(const RayPick &value)
The event handler for mouse drag events.
vec2 project_point(vec3 p) const
Computes screen-coordinates of a 3D point.
Grob * object() const
Gets the current object.
const mat4 & focus() const
Gets the current focus matrix.
Manages the Tool objects associated with a given Grob class.
Definition: tools_manager.h:62
Global Graphite namespace.
Definition: common.h:76
SmartPointer< Tool > Tool_var
An automatic reference-counted pointer to a Tool.
Definition: tool.h:190
The base class for all composite objects in the GOM system.
Transformation of user input between the screen and the 3D space.
Simple geometric objects and manipulations.
Events.
Represents the information related with a picking event.
Definition: ray_picker.h:64