Graphite  Version 3
An experimental 3D geometry processing program
mesh_grob_component_tools.h
Go to the documentation of this file.
1 
2 /*
3  * OGF/Graphite: Geometry and Graphics Programming Library + Utilities
4  * Copyright (C) 2000-2009 INRIA - Project ALICE
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  * If you modify this software, you should include a notice giving the
21  * name of the person performing the modification, the date of modification,
22  * and the reason for such modification.
23  *
24  * Contact: Bruno Levy - levy@loria.fr
25  *
26  * Project ALICE
27  * LORIA, INRIA Lorraine,
28  * Campus Scientifique, BP 239
29  * 54506 VANDOEUVRE LES NANCY CEDEX
30  * FRANCE
31  *
32  * Note that the GNU General Public License does not permit incorporating
33  * the Software into proprietary programs.
34  *
35  * As an exception to the GPL, Graphite can be linked
36  * with the following (non-GPL) libraries: Qt, SuperLU, WildMagic and CGAL
37  */
38 
39 #ifndef H_OGF_MESH_GFX_TOOLS_MESH_GROB_COMPONENT_TOOLS_H
40 #define H_OGF_MESH_GFX_TOOLS_MESH_GROB_COMPONENT_TOOLS_H
41 
42 #include <OGF/mesh_gfx/common/common.h>
44 
50 namespace OGF {
51 
52  /****************************************************************/
53 
58  gom_attribute(category, "components")
59  gom_attribute(icon, "move_component")
60  gom_attribute(help, "move component / resize component / rotate component")
61  gom_attribute(
62  message,
63  "btn1: move; btn2: resize; btn3: rotate"
64  )
65  gom_class MESH_GFX_API MeshGrobTransformComponent :
66  public MeshGrobTransformTool {
67  public:
73  ToolsManager* parent
74  ) : MeshGrobTransformTool(parent) {
75  }
76 
77  protected:
82  MeshGrobTransformSubset* tool, const RayPick& rp
83  ) override;
84 
88  void transform_subset(const mat4& M) override;
89 
93  void clear_subset() override;
94 
95  vector<bool> v_is_picked_;
96  };
97 
98  /****************************************************************/
99 
103  class MESH_GFX_API MeshGrobRemoveComponent :
104  public MeshGrobTool {
105  public:
113  ToolsManager* parent, bool invert_selection = false
114  ) : MeshGrobTool(parent),
115  invert_selection_(invert_selection) {
116  }
117 
121  void grab(const RayPick& p_ndc) override;
122  protected:
123  bool invert_selection_;
124  };
125 
126  /****************************************************************/
127 
133  gom_attribute(category, "components")
134  gom_attribute(icon, "remove_component")
135  gom_attribute(help, "remove component / keep component")
136  gom_attribute(
137  message,
138  "btn1: remove component; btn3: keep component"
139  )
140  gom_class MESH_GFX_API MeshGrobKeepOrRemoveComponent : public MultiTool {
141  public:
147  ToolsManager* parent
148  ) : MultiTool(parent) {
149  set_tool(
150  MOUSE_BUTTON_LEFT, new MeshGrobRemoveComponent(parent,false)
151  );
152  set_tool(
153  MOUSE_BUTTON_RIGHT, new MeshGrobRemoveComponent(parent,true)
154  );
155  }
156 
161  };
162 
163  /****************************************************************/
164 
168  gom_attribute(category, "components")
169  gom_attribute(icon, "copy_component")
170  gom_attribute(help, "copy component / delete component")
171  gom_attribute(
172  message,
173  "btn1: copy component; btn3: remove component"
174  )
175  gom_class MESH_GFX_API MeshGrobCopyComponent : public MeshGrobTransformTool {
176  public:
182  ToolsManager* parent
183  ) : MeshGrobTransformTool(parent) {
184  set_tool(
185  MOUSE_BUTTON_MIDDLE, nullptr
186  );
187  set_tool(
188  MOUSE_BUTTON_RIGHT, new MeshGrobRemoveComponent(parent,false)
189  );
190  }
191 
192  protected:
197  MeshGrobTransformSubset* tool, const RayPick& rp
198  ) override;
199 
203  void transform_subset(const mat4& M) override;
204 
205  private:
206  index_t first_new_vertex_;
207  };
208 
209 
210  /****************************************************************/
211 
215  gom_attribute(category, "components")
216  gom_attribute(icon, "flip_component")
217  gom_attribute(help, "flip component")
218  gom_attribute(message, "btn1: flip")
219  gom_class MESH_GFX_API MeshGrobFlipComponent : public MeshGrobTool {
220  public:
226  MeshGrobTool(parent) {
227  }
228 
232  void grab(const RayPick& p_ndc) override;
233  };
234 
235 }
236 
237 #endif
Specialization of vector for elements of type bool.
Definition: memory.h:795
A tool that copies and drags a connected component of a mesh.
MeshGrobCopyComponent(ToolsManager *parent)
MeshGrobCopyComponent constructor.
void pick_subset(MeshGrobTransformSubset *tool, const RayPick &rp) override
Gets the subset by picking.
void transform_subset(const mat4 &M) override
Applies a 3D transform to the subset.
A tool that flips the normals of a connected component.
void grab(const RayPick &p_ndc) override
MeshGrobFlipComponent(ToolsManager *parent)
MeshGrobFlipComponent constructor.
A tool that removes a connected component of a mesh or its complement depending on the pushed mouse b...
~MeshGrobKeepOrRemoveComponent() override
MeshGrobKeepOrRemoveComponent destructor.
MeshGrobKeepOrRemoveComponent(ToolsManager *parent)
MeshGrobRemoveOrKeepComponent constructor.
A tool that removes a connected component of a mesh.
MeshGrobRemoveComponent(ToolsManager *parent, bool invert_selection=false)
MeshGrobRemoveComponent constructor.
void grab(const RayPick &p_ndc) override
Base class for tools that operate on MeshGrob.
A tool that translates/scales/rotates a mesh connected component depending on the pushed mouse button...
MeshGrobTransformComponent(ToolsManager *parent)
MeshGrobTransformComponent constructor.
void pick_subset(MeshGrobTransformSubset *tool, const RayPick &rp) override
Gets the subset by picking.
void transform_subset(const mat4 &M) override
Applies a 3D transform to the subset.
void clear_subset() override
Clears the state variables that store the subset.
Base class of tools that apply 3d transform to a subset of a MeshGrob and that are attached to a Mult...
A MultiTool that applies a mouse-controlled transform to a subset.
A Tool that can associate a different tool to each button of the mouse.
Definition: tool.h:199
Manages the Tool objects associated with a given Grob class.
Definition: tools_manager.h:62
Base classes for tools that operate on MeshGrob.
void copy(void *to, const void *from, size_t size)
Copies a memory block.
Definition: memory.h:129
geo_index_t index_t
The type for storing and manipulating indices.
Definition: numeric.h:329
Global Graphite namespace.
Definition: common.h:76
Represents the information related with a picking event.
Definition: ray_picker.h:64