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
90namespace OGF {
91
101
102 gom_class MESH_GFX_API MeshGrobPaintTool : public MeshGrobTool {
103 public:
105
109 void reset() override;
110
111 gom_properties:
115 void set_value(double value);
116
117 double get_value() const {
118 return value_;
119 }
120
124 void set_value2(double value);
125
126 double get_value2() const {
127 return value2_;
128 }
129
134 void set_accumulate(bool value);
135
136 bool get_accumulate() const {
137 return accumulate_;
138 }
139
144 void set_autorange(bool value);
145
146 bool get_autorange() const {
147 return autorange_;
148 }
149
155 void set_pick_vertices_only(bool value);
156
157 bool get_pick_vertices_only() const {
158 return pick_vertices_only_;
159 }
160
166 void set_xray_mode(bool value);
167
168 bool get_xray_mode() const {
169 return xray_mode_;
170 }
171
172 public:
176 void grab(const RayPick& p_ndc) override;
177
181 void drag(const RayPick& p_ndc) override;
182
186 void release(const RayPick& p_ndc) override;
187
188 public:
189 void set_value_for_this_tool(double value) {
190 value_ = value;
191 }
192
193 void set_value2_for_this_tool(double value) {
194 value2_ = value;
195 }
196
197 void set_accumulate_for_this_tool(bool value) {
198 accumulate_ = value;
199 }
200
201 void set_autorange_for_this_tool(bool value) {
202 autorange_ = value;
203 }
204
205 void set_pick_vertices_for_this_tool(bool value) {
206 pick_vertices_only_ = value;
207 }
208
209 void set_xray_mode_for_this_tool(bool value) {
210 xray_mode_ = value;
211 }
212
219 static void get_paint_tools(
220 ToolsManager* manager, vector<MeshGrobPaintTool*>& paint_tools
221 );
222
223 protected:
224
225 bool get_painting_parameters(
226 const RayPick& raypick,
227 PaintOp& op,
228 MeshElementsFlags& where,
229 std::string& attribute_name,
230 index_t& component
231 );
232
233 void paint(const RayPick& p_ndc);
234
235 protected:
236 double value_;
237 double value2_;
238 bool accumulate_;
239 bool autorange_;
240 bool pick_vertices_only_;
241 bool xray_mode_;
242 index_t picked_element_;
243 Tool_var probe_tool_; // For middle button
244 MeshGrob* prev_mesh_grob_; // See reset()
245 };
246
247 /**********************************************************/
248
249
253 gom_attribute(category, "paint")
254 gom_attribute(icon, "paint_rect")
255 gom_attribute(help, "paint attributes in rectangle")
256 gom_attribute(message, "btn1: paint; btn2: probe; btn3: erase")
257
258 gom_class MESH_GFX_API MeshGrobPaintRect : public MeshGrobPaintTool {
259 public:
265
269 void grab(const RayPick& p_ndc) override;
270
274 void drag(const RayPick& p_ndc) override;
275
279 void release(const RayPick& p_ndc) override;
280
281 gom_properties:
282
283 protected:
284
294 void paint_rect(
295 const RayPick& raypick,
296 index_t x0, index_t y0, index_t x1, index_t y1,
297 Image* mask = nullptr
298 );
299 vec2 p_;
300 };
301
302 /************************************************************************/
303
307 gom_attribute(category, "paint")
308 gom_attribute(icon, "paint")
309 gom_attribute(help, "paint attributes")
310 gom_attribute(message, "btn1: paint; btn2: probe; btn3: erase")
311
312 gom_class MESH_GFX_API MeshGrobPaint : public MeshGrobPaintRect {
313 public:
319
323 void grab(const RayPick& p_ndc) override;
324
328 void drag(const RayPick& p_ndc) override;
329
333 void release(const RayPick& p_ndc) override;
334
335 gom_properties:
336
337 void set_width(index_t value) {
338 width_ = value;
339 }
340
341 index_t get_width() const {
342 return width_;
343 }
344
345 void set_stroke_mode(bool value) {
346 stroke_mode_ = value;
347 }
348
349 bool get_stroke_mode() const {
350 return stroke_mode_;
351 }
352
353 protected:
360 std::function<void(vec2, vec2, vec2, vec2)> doit
361 );
362
363 protected:
364 index_t width_;
365 vec2 latest_ndc_;
366 bool stroke_mode_;
367 vector<vec2> stroke_;
368 };
369
370 /*************************************************************/
371
375 gom_attribute(category, "paint")
376 gom_attribute(icon, "paint_freeform")
377 gom_attribute(help, "paint attributes with free-form selection")
378 gom_attribute(message, "btn1: paint; btn2: probe; btn3: erase")
379
380 gom_class MESH_GFX_API MeshGrobPaintFreeform : public MeshGrobPaintRect {
381 public:
387
391 void grab(const RayPick& p_ndc) override;
392
396 void drag(const RayPick& p_ndc) override;
397
401 void release(const RayPick& p_ndc) override;
402
403 private:
404 vec2 latest_ndc_;
405 vector<vec2> selection_;
406 };
407
408 /*****************************************************************/
409
413 gom_attribute(category, "paint")
414 gom_attribute(icon, "paint_connected")
415 gom_attribute(help, "paint attributes on connected components")
416 gom_attribute(message, "btn1: paint; btn2: probe; btn3: erase")
417
418 gom_class MESH_GFX_API MeshGrobPaintConnected : public MeshGrobPaintTool {
419 public:
425
429 void grab(const RayPick& p_ndc) override;
430
431 gom_properties:
432
437 void set_fill_same_value(bool x) {
438 fill_same_value_ = x;
439 }
440
441 bool get_fill_same_value() const {
442 return fill_same_value_;
443 }
444
449 void set_tolerance(double value) {
450 tolerance_ = value;
451 }
452
453 double get_tolerance() const {
454 return tolerance_;
455 }
456
457
458 protected:
459 bool test(double reference, double value) const {
460 return !fill_same_value_ ||
461 ::fabs(reference - value) <= tolerance_;
462 }
463
464 private:
465 bool fill_same_value_;
466 double tolerance_;
467 };
468
469 /**********************************************************************/
470
474 gom_attribute(category, "paint")
475 gom_attribute(icon, "pipette")
476 gom_attribute(help, "probe attributes")
477 gom_attribute(message, "btn1: probe attributes")
478
479 gom_class MESH_GFX_API MeshGrobProbe : public MeshGrobTool {
480 public:
486
490 void grab(const RayPick& p_ndc) override;
491
495 void drag(const RayPick& p_ndc) override;
496
500 void release(const RayPick& p_ndc) override;
501
506 void set_probed_as_paint(bool x) {
507 set_probed_as_paint_ = x;
508 }
509
510
517 display_probed_on_release_ = x;
518 }
519
520 protected:
521 void probe(const RayPick& p_ndc);
522
523 private:
524 bool picked_;
525 bool grabbed_;
526 double value_;
527 vec2 latest_ndc_;
528 std::string message_;
529 bool set_probed_as_paint_;
530 bool display_probed_on_release_;
531 };
532
533 /********************************************************/
534
538 gom_attribute(category, "paint")
539 gom_attribute(icon, "ruler")
540 gom_attribute(help, "measures distances on a mesh")
541
542 gom_class MESH_GFX_API MeshGrobRuler : public MeshGrobTool {
543 public:
549
553 void grab(const RayPick& p_ndc) override;
554
558 void drag(const RayPick& p_ndc) override;
559
563 void release(const RayPick& p_ndc) override;
564
565 protected:
566 bool pick(const RayPick& p_ndc, vec3& p);
567 void show_distance(const RayPick& p_ndc);
568
569 private:
570 bool p_picked_;
571 vec3 p_;
572 vec2 latest_ndc_;
573 };
574
575 /*******************************************************/
576
577}
578
579#endif
An image.
Definition image.h:59
Vector with aligned memory allocation.
Definition memory.h:702
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