Graphite  Version 3
An experimental 3D geometry processing program
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 
49 namespace OGF {
50 
51  class Grob;
52  class RenderingContext;
53 
54 /*************************************************************************/
55 
62  gom_class SCENE_GRAPH_API SceneGraph : public CompositeGrob {
63  public:
64 
71  SceneGraph(Interpreter* interpreter = nullptr);
72 
76  ~SceneGraph() override;
77 
81  void update() override;
82 
87  void update_values();
88 
92  bool is_serializable() const override;
93 
97  bool serialize_read(InputGraphiteFile& in) override;
98 
102  bool serialize_write(OutputGraphiteFile& out) override;
103 
104  gom_slots:
105 
115  bool save_viewer_properties(const std::string& value);
116 
121 
130 
137 
144 
149  void clear() override;
150 
165  const FileName& value, const std::string& type="default",
166  bool invoked_from_gui=false
167  );
168 
181  const std::string& value, const std::string& type="default",
182  bool invoked_from_gui=false
183  );
184 
189  bool save_current_object(const NewFileName& value);
190 
201  const GrobClassName& classname, const std::string& name = ""
202  );
203 
204 
212  Grob* create_mesh(const std::string& name = "") {
213  return create_object("OGF::MeshGrob",name);
214  }
215 
226  const GrobClassName& classname, const std::string& name
227  );
228 
234 
241  void set_visibility(index_t index, bool value);
242 
243 
251  MetaClass* grob_class, MetaClass* commands_class
252  );
253 
254  gom_properties:
259  void set_current_object(const std::string& value);
260 
265  const std::string& get_current_object() const;
266 
271  std::string get_values() const;
272 
278  void set_visibilities(const std::string& value);
279 
285  std::string get_visibilities() const;
286 
291  std::string get_types() const;
292 
293 
298  void set_render_area(Object* rdra) {
299  render_area_ = rdra;
300  }
301 
308  return render_area_;
309  }
310 
315  void set_application(Object* app) {
316  application_ = app;
317  }
318 
325  return application_;
326  }
327 
334 
341 
342  gom_signals:
348  virtual void values_changed(const std::string& value);
349 
356  virtual void visibilities_changed(const std::string& value);
357 
363  virtual void types_changed(const std::string& value);
364 
370  void value_changed(Grob* value) override;
371 
377  virtual void current_object_changed(const std::string& value);
378 
384  void grob_created(const std::string& name);
385 
391  void grob_deleted(const std::string& name);
392 
397  void grob_renamed();
398 
399  public:
406  void set_current_object(const std::string& value, bool record_history);
407 
408 
413 
414  protected:
426  static bool load_aln(const std::string& filename, SceneGraph* sg);
427 
435  OutputGraphiteFile& out, bool all_scene
436  );
437 
443 
450  Grob* grob, OutputGraphiteFile& out
451  );
452 
460  );
461 
462  void get_grob_shader(
463  Grob* grob, std::string& classname, ArgList& properties
464  );
465 
466  void set_grob_shader(
467  Grob* grob, const std::string& classname, const ArgList& properties
468  );
469 
479  const std::string& obj_prop_name, ArgList& args
480  );
481 
491 
492  private:
493  std::string current_object_;
494  Interpreter* interpreter_;
495  Object* render_area_;
496  Object* application_;
497  Object_var scene_graph_shader_manager_;
498  };
499 
500 /*************************************************************************/
501 
502 }
503 #endif
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.
Definition: interpreter.h:222
The representation of a class in the Meta repository.
Definition: meta_class.h:64
A template class for strings that need to have a specific type in the GOM system.
Definition: properties.h:218
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
Grob * find_or_create_object(const GrobClassName &classname, const std::string &name)
Creates a new object or retreives an existing one.
SceneGraph(Interpreter *interpreter=nullptr)
SceneGraph constructor.
void set_application(Object *app)
Sets the application.
Definition: scene_graph.h:315
virtual void visibilities_changed(const std::string &value)
a signal that is triggered whenever object visibility flags change.
void move_current_up()
Swaps the current object with the previous one.
void update_values()
Triggers the values_changed(), visibilities_changed(), types_changed() and value_changed() signals.
void load_objects(const std::string &value, const std::string &type="default", bool invoked_from_gui=false)
Loads objects from a list of files, and stores them in this SceneGraph.
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.
Definition: scene_graph.h:298
virtual void types_changed(const std::string &value)
a signal that is triggered whenever the list of objects changes.
Grob * serialize_grob_read(InputGraphiteFile &in)
Reads an object from a geogram file.
Object * get_application() const
Gets the application.
Definition: scene_graph.h:324
~SceneGraph() override
SceneGraph destructor.
void grob_renamed()
a signal that is triggered whenever an object is renamed in this SceneGraph
void end_graphite_file(OutputGraphiteFile &out)
Writes the trailer of a gsg file.
Object * get_scene_graph_shader_manager() const
gets the scene graph shader manager.
void delete_current_object()
Deletes the current object.
std::string get_values() const
Gets the names of all the objects in this SceneGraph.
Object * get_render_area() const
Gets the render area.
Definition: scene_graph.h:307
bool serialize_read(InputGraphiteFile &in) override
Reads this Grob from a GeoFile.
void serialize_grob_write(Grob *grob, OutputGraphiteFile &out)
Writes an object to a geogram file.
void set_visibilities(const std::string &value)
Sets the visibility flags for all the objects.
bool save_current_object(const NewFileName &value)
Saves the current object to a file.
void grob_created(const std::string &name)
a signal that is triggered whenever an object is created in this SceneGraph
Interpreter * interpreter() override
Gets a pointer to the main Interpreter.
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 grob_deleted(const std::string &name)
a signal that is triggered whenever an object is deleted in this SceneGraph
void set_current_object(const std::string &value, bool record_history)
Sets the current object.
void set_scene_graph_shader_manager(Object *sgshdmgr)
sets the scene graph shader manager.
void copy_property_to_arglist(const std::string &obj_prop_name, ArgList &args)
Copies an objet property to an arglist.
Grob * load_object(const FileName &value, const std::string &type="default", bool invoked_from_gui=false)
Loads an object from a file, and stores it in this SceneGraph.
void set_visibility(index_t index, bool value)
Sets the visibility flag of one of the objects.
void copy_arglist_to_properties(const ArgList &args)
Copies all the object properties previously recorded by copy_property_to_arglist() from an ArgList to...
Grob * current()
Gets the current object.
Grob * create_object(const GrobClassName &classname, const std::string &name="")
Creates an object.
Grob * create_mesh(const std::string &name="")
Creates a mesh.
Definition: scene_graph.h:212
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.
bool serialize_write(OutputGraphiteFile &out) override
Writes this Grob into a stream.
const std::string & get_current_object() const
Gets the name of the current object.
bool is_serializable() const override
Tests whether this Grob can be serialized in GeoFile.
std::string get_types() const
Gets the object types for all the objects.
std::string get_visibilities() const
Gets the visibility flags for all the objects.
Grob * duplicate_current()
Duplicates the current object.
void clear() override
Clears this SceneGraph.
void value_changed(Grob *value) override
a signal that is triggered whenever this SceneGraph changes.
A class for Grob composed of several parts.
geo_index_t index_t
The type for storing and manipulating indices.
Definition: numeric.h:329
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.