Graphite Version 3
An experimental 3D geometry processing program
Loading...
Searching...
No Matches
scene_graph.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
38#ifndef H_OGF_SCENE_GRAPH_TYPES_SCENE_GRAPH_H
39#define H_OGF_SCENE_GRAPH_TYPES_SCENE_GRAPH_H
40
43#include <OGF/gom/types/node.h>
44
49namespace OGF {
50
51 class Grob;
52 class RenderingContext;
53
54/*************************************************************************/
55
62 gom_class SCENE_GRAPH_API SceneGraph : public CompositeGrob {
63 public:
64
72 Interpreter* interpreter = nullptr,
73 bool transfer_ownership_to_scenegraph_library=false
74 );
75
79 ~SceneGraph() override;
80
81
82 gom_slots:
83
88 Grob* current();
89
94 void set_current(const GrobName& grob);
95
100 void delete_object(const GrobName& grob);
101
107
113
118
123 void move_object_up(const GrobName& grob);
124
129 void move_object_down(const GrobName& grob);
130
135 void move_object_to_top(const GrobName& grob);
136
142
143
149
155
161
167
168
175 const GrobName& grob, const std::string& new_name
176 );
177
187
188
189 /*************************************/
190
195 void clear() override;
196
201
210
217
224
229
234
247 const FileName& filename, const std::string& type="default",
248 bool change_cwd=false
249 );
250
262 const std::string& filenames, const std::string& type="default",
263 bool change_cwd=false
264 );
265
273 bool save_current_object(const NewFileName& filename);
274
284 bool save_viewer_properties(const std::string& filename);
285
296 const GrobClassName& classname="OGF::MeshGrob",
297 const std::string& name = "new_object"
298 );
299
307 Grob* create_mesh(const std::string& name = "") {
308 return create_object("OGF::MeshGrob",name);
309 }
310
321 const GrobClassName& classname, const std::string& name
322 );
323
324
332 MetaClass* grob_class, MetaClass* commands_class
333 );
334
335 gom_properties:
341 void set_current_object(const GrobName& value);
342
349
354 std::string get_values() const;
355
361 render_area_ = rdra;
362 }
363
370 return render_area_;
371 }
372
378 application_ = app;
379 }
380
387 return application_;
388 }
389
396
403
404
405 public:
409 void update() override;
410
416
420 bool is_serializable() const override;
421
426
431
436
437 gom_signals:
443 virtual void values_changed(const std::string& value);
444
450 void value_changed(Grob* value) override;
451
457 virtual void current_object_changed(const std::string& value);
458
459 public:
466 const std::string& method_name,
467 const ArgList& args, Any& ret_val
468 ) override;
469
470 protected:
482 static bool load_aln(const std::string& filename, SceneGraph* sg);
483
491 OutputGraphiteFile& out, bool all_scene
492 );
493
499
506 Grob* grob, OutputGraphiteFile& out
507 );
508
516 );
517
518 void get_grob_shader(
519 Grob* grob, std::string& classname, ArgList& properties
520 );
521
522 void set_grob_shader(
523 Grob* grob, const std::string& classname, const ArgList& properties
524 );
525
535 const std::string& obj_prop_name, ArgList& args
536 );
537
547
548 private:
549 GrobName current_object_name_;
550 Interpreter* interpreter_;
551 Object* render_area_;
552 Object* application_;
553 Object_var scene_graph_shader_manager_;
554 };
555
556/*************************************************************************/
557
558}
559#endif
A class that stores a variable of arbitrary type.
Definition any.h:62
Represents a list of name-value pairs.
Definition arg_list.h:65
A Composite Graphite Object.
Base class for all 3D Graphite objects.
Definition grob.h:68
An extension of InputGeoFile for storing a complete Graphite scenegraph in a structured binary file.
Definition geofile.h:67
Abstract base class for the GOM interpreter.
The representation of a class in the Meta repository.
Definition meta_class.h:64
Base class for all objects in the GOM system.
Definition object.h:65
An extension of InputGeoFile for storing a complete Graphite scenegraph in a structured binary file.
Definition geofile.h:129
Represents the list of objects loaded in Graphite.
Definition scene_graph.h:62
void move_object_down(const GrobName &grob)
Moves an object down in the SceneGraph.
void move_current_to_bottom()
Makes the current object the last of the list.
bool save_current_object(const NewFileName &filename)
Saves the current object to a file.
void set_application(Object *app)
Sets the application.
void move_current_up()
Swaps the current object with the previous one.
Grob * serialize_grob_read(InputGraphiteFile &in)
Reads an object from a geogram file.
void update_values()
Triggers the values_changed(), visibilities_changed(), types_changed() and value_changed() signals.
static bool load_aln(const std::string &filename, SceneGraph *sg)
Loads alignment data for pointsets.
virtual void current_object_changed(const std::string &value)
a signal that is triggered whenever the current object changes.
void set_render_area(Object *rdra)
Sets the render area.
void move_selection_to_top()
Reorganizes the object list in such a way that all selected objects appear first.
~SceneGraph() override
SceneGraph destructor.
Object * get_scene_graph_shader_manager() const
gets the scene graph shader manager.
void delete_current()
Removes the current object from this SceneGraph and deletes it.
void end_graphite_file(OutputGraphiteFile &out)
Writes the trailer of a gsg file.
void move_object_to_top(const GrobName &grob)
Makes an object the first in the list.
const GrobName & get_current_object() const
Gets the name of the current object.
Object * get_render_area() const
Gets the render area.
void delete_current_object()
Deletes the current object.
Grob * create_object(const GrobClassName &classname="OGF::MeshGrob", const std::string &name="new_object")
Creates an object.
Grob * duplicate_current()
Duplicates the current object.
void rename_object(const GrobName &grob, const std::string &new_name)
Renames an object.
std::string get_values() const
Gets the names of all the objects in this SceneGraph.
bool serialize_read(InputGraphiteFile &in) override
Reads this Grob from a GeoFile.
void load_objects(const std::string &filenames, const std::string &type="default", bool change_cwd=false)
Loads objects from a list of files, and stores them in this SceneGraph.
void delete_selected()
Removes and deletes all the selected objects in this SceneGraph.
void serialize_grob_write(Grob *grob, OutputGraphiteFile &out)
Writes an object to a geogram file.
void set_current(const GrobName &grob)
Sets the current object.
Grob * duplicate_object(const GrobName &grob)
Duplicates an object object.
Object * get_application() const
Gets the application.
Grob * create_mesh(const std::string &name="")
Creates a mesh.
Grob * find_or_create_object(const GrobClassName &classname, const std::string &name)
Creates a new object or retreives an existing one.
void move_object_to_bottom(const GrobName &grob)
Makes an object the last in the list.
void begin_graphite_file(OutputGraphiteFile &out, bool all_scene)
Writes the preamble of a gsg file to a stream.
void update() override
Triggers the value_changed() signal.
void delete_all()
Deletes and removes all the objects in this SceneGraph.
void move_current_to_top()
Makes the current object the first of the list.
void set_scene_graph_shader_manager(Object *sgshdmgr)
sets the scene graph shader manager.
void move_selection_up()
Reorganizes the object list in such a way that all selected objects move one position up.
void copy_property_to_arglist(const std::string &obj_prop_name, ArgList &args)
Copies an objet property to an arglist.
SceneGraph(Interpreter *interpreter=nullptr, bool transfer_ownership_to_scenegraph_library=false)
SceneGraph constructor.
void copy_arglist_to_properties(const ArgList &args)
Copies all the object properties previously recorded by copy_property_to_arglist() from an ArgList to...
void move_selection_down()
Reorganizes the object list in such a way that all selected objects move one position down.
bool save_viewer_properties(const std::string &filename)
Saves viewer properties to a file.
void register_grob_commands(MetaClass *grob_class, MetaClass *commands_class)
Associates a Commands class to a Grob class.
void move_current_down()
Swaps the current object with the next one.
Interpreter * interpreter() override
Gets a pointer to the main Interpreter.
void delete_object(const GrobName &grob)
Removes an object from this SceneGraph and deletes it.
bool serialize_write(OutputGraphiteFile &out) override
Writes this Grob into a stream.
Grob * load_object(const FileName &filename, const std::string &type="default", bool change_cwd=false)
Loads an object from a file, and stores it in this SceneGraph.
bool is_serializable() const override
Tests whether this Grob can be serialized in GeoFile.
void move_selection_to_bottom()
Reorganizes the object list in such a way that all selected objects appear last.
bool invoke_method(const std::string &method_name, const ArgList &args, Any &ret_val) override
Invokes a method by method name and argument list, and gets the return value.
void clear() override
Clears this SceneGraph.
void value_changed(Grob *value) override
a signal that is triggered whenever this SceneGraph changes.
void move_object_up(const GrobName &grob)
Moves an object up in the SceneGraph.
A class for Grob composed of several parts.
Global Graphite namespace.
Definition common.h:76
The base class for all composite objects in the GOM system.
Definitions common to all include files in the scene_graph library.