Graphite Version 3
An experimental 3D geometry processing program
Loading...
Searching...
No Matches
mesh_grob_paint_tools.h
Go to the documentation of this file.
1/*
2 * OGF/Graphite: Geometry and Graphics Programming Library + Utilities
3 * Copyright (C) 2000-2009 INRIA - Project ALICE
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 - levy@loria.fr
24 *
25 * Project ALICE
26 * LORIA, INRIA Lorraine,
27 * Campus Scientifique, BP 239
28 * 54506 VANDOEUVRE LES NANCY CEDEX
29 * FRANCE
30 *
31 * Note that the GNU General Public License does not permit incorporating
32 * the Software into proprietary programs.
33 *
34 * As an exception to the GPL, Graphite can be linked
35 * with the following (non-GPL) libraries: Qt, SuperLU, WildMagic and CGAL
36 */
37
38#ifndef H_OGF_MESH_GFX_TOOLS_MESH_GROB_PAINT_TOOLS_H
39#define H_OGF_MESH_GFX_TOOLS_MESH_GROB_PAINT_TOOLS_H
40
41#include <OGF/mesh_gfx/common/common.h>
43
89namespace OGF {
90
100
101 gom_class MESH_GFX_API MeshGrobPaintTool : public MeshGrobTool {
102 public:
104
108 void reset() override;
109
110 gom_properties:
114 void set_value(double value);
115
116 double get_value() const {
117 return value_;
118 }
119
123 void set_value2(double value);
124
125 double get_value2() const {
126 return value2_;
127 }
128
133 void set_accumulate(bool value);
134
135 bool get_accumulate() const {
136 return accumulate_;
137 }
138
143 void set_autorange(bool value);
144
145 bool get_autorange() const {
146 return autorange_;
147 }
148
154 void set_pick_vertices_only(bool value);
155
156 bool get_pick_vertices_only() const {
157 return pick_vertices_only_;
158 }
159
165 void set_xray_mode(bool value);
166
167 bool get_xray_mode() const {
168 return xray_mode_;
169 }
170
171 public:
175 void grab(const RayPick& p_ndc) override;
176
180 void drag(const RayPick& p_ndc) override;
181
185 void release(const RayPick& p_ndc) override;
186
187 public:
188 void set_value_for_this_tool(double value) {
189 value_ = value;
190 }
191
192 void set_value2_for_this_tool(double value) {
193 value2_ = value;
194 }
195
196 void set_accumulate_for_this_tool(bool value) {
197 accumulate_ = value;
198 }
199
200 void set_autorange_for_this_tool(bool value) {
201 autorange_ = value;
202 }
203
204 void set_pick_vertices_for_this_tool(bool value) {
205 pick_vertices_only_ = value;
206 }
207
208 void set_xray_mode_for_this_tool(bool value) {
209 xray_mode_ = value;
210 }
211
218 static void get_paint_tools(
219 ToolsManager* manager, vector<MeshGrobPaintTool*>& paint_tools
220 );
221
222 protected:
223
224 bool get_painting_parameters(
225 const RayPick& raypick,
226 PaintOp& op,
227 MeshElementsFlags& where,
228 std::string& attribute_name,
229 index_t& component
230 );
231
232 void paint(const RayPick& p_ndc);
233
234 protected:
235 double value_;
236 double value2_;
237 bool accumulate_;
238 bool autorange_;
239 bool pick_vertices_only_;
240 bool xray_mode_;
241 index_t picked_element_;
242 Tool_var probe_tool_; // For middle button
243 };
244
245 /**********************************************************/
246
247
251 gom_attribute(category, "paint")
252 gom_attribute(icon, "paint_rect")
253 gom_attribute(help, "paint attributes in rectangle")
254 gom_attribute(message, "btn1: paint; btn2: probe; btn3: erase")
255
256 gom_class MESH_GFX_API MeshGrobPaintRect : public MeshGrobPaintTool {
257 public:
263
267 void grab(const RayPick& p_ndc) override;
268
272 void drag(const RayPick& p_ndc) override;
273
277 void release(const RayPick& p_ndc) override;
278
279 gom_properties:
280
281 protected:
282
292 void paint_rect(
293 const RayPick& raypick,
294 index_t x0, index_t y0, index_t x1, index_t y1,
295 Image* mask = nullptr
296 );
297 vec2 p_;
298 };
299
300 /************************************************************************/
301
305 gom_attribute(category, "paint")
306 gom_attribute(icon, "paint")
307 gom_attribute(help, "paint attributes")
308 gom_attribute(message, "btn1: paint; btn2: probe; btn3: erase")
309
310 gom_class MESH_GFX_API MeshGrobPaint : public MeshGrobPaintRect {
311 public:
317
321 void grab(const RayPick& p_ndc) override;
322
326 void drag(const RayPick& p_ndc) override;
327
331 void release(const RayPick& p_ndc) override;
332
333 gom_properties:
334
335 void set_width(index_t value) {
336 width_ = value;
337 }
338
339 index_t get_width() const {
340 return width_;
341 }
342
343 void set_stroke_mode(bool value) {
344 stroke_mode_ = value;
345 }
346
347 bool get_stroke_mode() const {
348 return stroke_mode_;
349 }
350
351 protected:
358 std::function<void(vec2, vec2, vec2, vec2)> doit
359 );
360
361 protected:
362 index_t width_;
363 vec2 latest_ndc_;
364 bool stroke_mode_;
365 vector<vec2> stroke_;
366 };
367
368 /*************************************************************/
369
373 gom_attribute(category, "paint")
374 gom_attribute(icon, "paint_freeform")
375 gom_attribute(help, "paint attributes with free-form selection")
376 gom_attribute(message, "btn1: paint; btn2: probe; btn3: erase")
377
378 gom_class MESH_GFX_API MeshGrobPaintFreeform : public MeshGrobPaintRect {
379 public:
385
389 void grab(const RayPick& p_ndc) override;
390
394 void drag(const RayPick& p_ndc) override;
395
399 void release(const RayPick& p_ndc) override;
400
401 private:
402 vec2 latest_ndc_;
403 vector<vec2> selection_;
404 };
405
406 /*****************************************************************/
407
411 gom_attribute(category, "paint")
412 gom_attribute(icon, "paint_connected")
413 gom_attribute(help, "paint attributes on connected components")
414 gom_attribute(message, "btn1: paint; btn2: probe; btn3: erase")
415
416 gom_class MESH_GFX_API MeshGrobPaintConnected : public MeshGrobPaintTool {
417 public:
423
427 void grab(const RayPick& p_ndc) override;
428
429 gom_properties:
430
435 void set_fill_same_value(bool x) {
436 fill_same_value_ = x;
437 }
438
439 bool get_fill_same_value() const {
440 return fill_same_value_;
441 }
442
447 void set_tolerance(double value) {
448 tolerance_ = value;
449 }
450
451 double get_tolerance() const {
452 return tolerance_;
453 }
454
455
456 protected:
457 bool test(double reference, double value) const {
458 return !fill_same_value_ ||
459 ::fabs(reference - value) <= tolerance_;
460 }
461
462 private:
463 bool fill_same_value_;
464 double tolerance_;
465 };
466
467 /**********************************************************************/
468
472 gom_attribute(category, "paint")
473 gom_attribute(icon, "pipette")
474 gom_attribute(help, "probe attributes")
475 gom_attribute(message, "btn1: probe attributes")
476
477 gom_class MESH_GFX_API MeshGrobProbe : public MeshGrobTool {
478 public:
484
488 void grab(const RayPick& p_ndc) override;
489
493 void drag(const RayPick& p_ndc) override;
494
498 void release(const RayPick& p_ndc) override;
499
504 void set_probed_as_paint(bool x) {
505 set_probed_as_paint_ = x;
506 }
507
508
515 display_probed_on_release_ = x;
516 }
517
518 protected:
519 void probe(const RayPick& p_ndc);
520
521 private:
522 bool picked_;
523 bool grabbed_;
524 double value_;
525 vec2 latest_ndc_;
526 std::string message_;
527 bool set_probed_as_paint_;
528 bool display_probed_on_release_;
529 };
530
531 /********************************************************/
532
536 gom_attribute(category, "paint")
537 gom_attribute(icon, "ruler")
538 gom_attribute(help, "measures distances on a mesh")
539
540 gom_class MESH_GFX_API MeshGrobRuler : public MeshGrobTool {
541 public:
547
551 void grab(const RayPick& p_ndc) override;
552
556 void drag(const RayPick& p_ndc) override;
557
561 void release(const RayPick& p_ndc) override;
562
563 protected:
564 bool pick(const RayPick& p_ndc, vec3& p);
565 void show_distance(const RayPick& p_ndc);
566
567 private:
568 bool p_picked_;
569 vec3 p_;
570 vec2 latest_ndc_;
571 };
572
573 /*******************************************************/
574
575}
576
577#endif
An image.
Definition image.h:59
Vector with aligned memory allocation.
Definition memory.h:710
Paint attributes in connected components.
MeshGrobPaintConnected(ToolsManager *parent)
MeshGrobPaintConnected constructor.
void set_tolerance(double value)
Tolerance used if fill_same_value os set.
void grab(const RayPick &p_ndc) override
Paint attributes using free-form selection.
void grab(const RayPick &p_ndc) override
void release(const RayPick &p_ndc) override
The event handler for mouse release events.
void drag(const RayPick &p_ndc) override
The event handler for mouse drag events.
MeshGrobPaintFreeform(ToolsManager *parent)
MeshGrobPaintFreeform constructor.
A rect selection tool that paints attribute values in a mesh.
void grab(const RayPick &p_ndc) override
MeshGrobPaintRect(ToolsManager *parent)
MeshGrobPaint constructor.
void release(const RayPick &p_ndc) override
The event handler for mouse release events.
void drag(const RayPick &p_ndc) override
The event handler for mouse drag events.
void reset() override
Resets this Tool.
void drag(const RayPick &p_ndc) override
The event handler for mouse drag events.
static void get_paint_tools(ToolsManager *manager, vector< MeshGrobPaintTool * > &paint_tools)
Gets all paint tools from the ToolsManager.
void grab(const RayPick &p_ndc) override
void set_xray_mode(bool value)
If set, pick everything that falls within the rect, else pick only visible elements.
void set_value2(double value)
The value to be painted (right button)
void release(const RayPick &p_ndc) override
The event handler for mouse release events.
void set_accumulate(bool value)
If set, value is added to previous value when painting.
void set_pick_vertices_only(bool value)
If set, vertex attributes can be only painted by directly picking vertices, else one can pick facets ...
void set_autorange(bool value)
If set, colormap range is continuously updated when painting.
A tool that paints attribute values in a mesh.
void release(const RayPick &p_ndc) override
The event handler for mouse release events.
void drag(const RayPick &p_ndc) override
The event handler for mouse drag events.
void grab(const RayPick &p_ndc) override
void for_each_stroke_quad(std::function< void(vec2, vec2, vec2, vec2)> doit)
Calls a user function for each quad of the stroke.
MeshGrobPaint(ToolsManager *parent)
MeshGrobPaint constructor.
A tool that probes attribute values in a mesh.
void grab(const RayPick &p_ndc) override
void set_probed_as_paint(bool x)
Sets the interaction mode between probe tool and paint tool.
MeshGrobProbe(ToolsManager *parent)
MeshGrobPaint constructor.
void release(const RayPick &p_ndc) override
The event handler for mouse release events.
void set_display_probed_on_release(bool x)
Sets the behavior when mouse button is release.
void drag(const RayPick &p_ndc) override
The event handler for mouse drag events.
A tool that measures distances.
void drag(const RayPick &p_ndc) override
The event handler for mouse drag events.
void release(const RayPick &p_ndc) override
The event handler for mouse release events.
void grab(const RayPick &p_ndc) override
MeshGrobRuler(ToolsManager *parent)
MeshGrobPaint constructor.
Base class for tools that operate on MeshGrob.
Manages the Tool objects associated with a given Grob class.
Base classes for tools that operate on MeshGrob.
geo_index_t index_t
The type for storing and manipulating indices.
Definition numeric.h:329
Global Graphite namespace.
Definition common.h:76
PaintOp
A painting operation.
Represents the information related with a picking event.
Definition ray_picker.h:64