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 MeshGrob* prev_mesh_grob_; // See reset()
244 };
245
246 /**********************************************************/
247
248
252 gom_attribute(category, "paint")
253 gom_attribute(icon, "paint_rect")
254 gom_attribute(help, "paint attributes in rectangle")
255 gom_attribute(message, "btn1: paint; btn2: probe; btn3: erase")
256
257 gom_class MESH_GFX_API MeshGrobPaintRect : public MeshGrobPaintTool {
258 public:
264
268 void grab(const RayPick& p_ndc) override;
269
273 void drag(const RayPick& p_ndc) override;
274
278 void release(const RayPick& p_ndc) override;
279
280 gom_properties:
281
282 protected:
283
293 void paint_rect(
294 const RayPick& raypick,
295 index_t x0, index_t y0, index_t x1, index_t y1,
296 Image* mask = nullptr
297 );
298 vec2 p_;
299 };
300
301 /************************************************************************/
302
306 gom_attribute(category, "paint")
307 gom_attribute(icon, "paint")
308 gom_attribute(help, "paint attributes")
309 gom_attribute(message, "btn1: paint; btn2: probe; btn3: erase")
310
311 gom_class MESH_GFX_API MeshGrobPaint : public MeshGrobPaintRect {
312 public:
318
322 void grab(const RayPick& p_ndc) override;
323
327 void drag(const RayPick& p_ndc) override;
328
332 void release(const RayPick& p_ndc) override;
333
334 gom_properties:
335
336 void set_width(index_t value) {
337 width_ = value;
338 }
339
340 index_t get_width() const {
341 return width_;
342 }
343
344 void set_stroke_mode(bool value) {
345 stroke_mode_ = value;
346 }
347
348 bool get_stroke_mode() const {
349 return stroke_mode_;
350 }
351
352 protected:
359 std::function<void(vec2, vec2, vec2, vec2)> doit
360 );
361
362 protected:
363 index_t width_;
364 vec2 latest_ndc_;
365 bool stroke_mode_;
366 vector<vec2> stroke_;
367 };
368
369 /*************************************************************/
370
374 gom_attribute(category, "paint")
375 gom_attribute(icon, "paint_freeform")
376 gom_attribute(help, "paint attributes with free-form selection")
377 gom_attribute(message, "btn1: paint; btn2: probe; btn3: erase")
378
379 gom_class MESH_GFX_API MeshGrobPaintFreeform : public MeshGrobPaintRect {
380 public:
386
390 void grab(const RayPick& p_ndc) override;
391
395 void drag(const RayPick& p_ndc) override;
396
400 void release(const RayPick& p_ndc) override;
401
402 private:
403 vec2 latest_ndc_;
404 vector<vec2> selection_;
405 };
406
407 /*****************************************************************/
408
412 gom_attribute(category, "paint")
413 gom_attribute(icon, "paint_connected")
414 gom_attribute(help, "paint attributes on connected components")
415 gom_attribute(message, "btn1: paint; btn2: probe; btn3: erase")
416
417 gom_class MESH_GFX_API MeshGrobPaintConnected : public MeshGrobPaintTool {
418 public:
424
428 void grab(const RayPick& p_ndc) override;
429
430 gom_properties:
431
436 void set_fill_same_value(bool x) {
437 fill_same_value_ = x;
438 }
439
440 bool get_fill_same_value() const {
441 return fill_same_value_;
442 }
443
448 void set_tolerance(double value) {
449 tolerance_ = value;
450 }
451
452 double get_tolerance() const {
453 return tolerance_;
454 }
455
456
457 protected:
458 bool test(double reference, double value) const {
459 return !fill_same_value_ ||
460 ::fabs(reference - value) <= tolerance_;
461 }
462
463 private:
464 bool fill_same_value_;
465 double tolerance_;
466 };
467
468 /**********************************************************************/
469
473 gom_attribute(category, "paint")
474 gom_attribute(icon, "pipette")
475 gom_attribute(help, "probe attributes")
476 gom_attribute(message, "btn1: probe attributes")
477
478 gom_class MESH_GFX_API MeshGrobProbe : public MeshGrobTool {
479 public:
485
489 void grab(const RayPick& p_ndc) override;
490
494 void drag(const RayPick& p_ndc) override;
495
499 void release(const RayPick& p_ndc) override;
500
505 void set_probed_as_paint(bool x) {
506 set_probed_as_paint_ = x;
507 }
508
509
516 display_probed_on_release_ = x;
517 }
518
519 protected:
520 void probe(const RayPick& p_ndc);
521
522 private:
523 bool picked_;
524 bool grabbed_;
525 double value_;
526 vec2 latest_ndc_;
527 std::string message_;
528 bool set_probed_as_paint_;
529 bool display_probed_on_release_;
530 };
531
532 /********************************************************/
533
537 gom_attribute(category, "paint")
538 gom_attribute(icon, "ruler")
539 gom_attribute(help, "measures distances on a mesh")
540
541 gom_class MESH_GFX_API MeshGrobRuler : public MeshGrobTool {
542 public:
548
552 void grab(const RayPick& p_ndc) override;
553
557 void drag(const RayPick& p_ndc) override;
558
562 void release(const RayPick& p_ndc) override;
563
564 protected:
565 bool pick(const RayPick& p_ndc, vec3& p);
566 void show_distance(const RayPick& p_ndc);
567
568 private:
569 bool p_picked_;
570 vec3 p_;
571 vec2 latest_ndc_;
572 };
573
574 /*******************************************************/
575
576}
577
578#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.
A Grob wrapper around Geogram's Mesh class.
Definition mesh_grob.h:56
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:330
Global Graphite namespace.
Definition common.h:76
PaintOp
A painting operation.
Represents the information related with a picking event.
Definition ray_picker.h:64