# HG changeset patch # User jwe # Date 1201939013 0 # Node ID 1867156fc552ec18a21e649af1266f49b09154f7 # Parent 6873fe003323ccef71606d01ce16807931f09488 [project @ 2008-02-02 07:56:53 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-02-02 Shai Ayal + + * graphics.h.in (graphics_backend::find_backend): New function. + (class figure): Add __backend__ property and set method. + 2008-02-02 John W. Eaton * help.cc (do_type): Don't print dyamically loaded function files. diff --git a/src/graphics.h.in b/src/graphics.h.in --- a/src/graphics.h.in +++ b/src/graphics.h.in @@ -1193,11 +1193,23 @@ static void unregister_backend (const std::string& name) { available_backends.erase (name); } + static graphics_backend find_backend (const std::string& name) + { + const_available_backends_iterator p = available_backends.find (name); + + if (p != available_backends.end ()) + return p->second; + else + return default_backend (); + } + private: base_graphics_backend *rep; -private: static std::map available_backends; + + typedef std::map::iterator available_backends_iterator; + typedef std::map::const_iterator const_available_backends_iterator; }; // --------------------------------------------------------------------- @@ -2022,7 +2034,36 @@ return backend; } - void set_backend (const graphics_backend& b) { backend = b; } + void set_backend (const graphics_backend& b) + { + close (false); + backend = b; + __backend__ = b.get_name (); + mark_modified (); + } + + void set___backend__ (const octave_value& val) + { + if (! error_state) + { + if (val.is_string ()) + { + std::string nm = val.string_value (); + graphics_backend b = graphics_backend::find_backend (nm); + if (b.get_name () != nm) + { + error ("figure::__backend__ : illegal backend"); + } + else + { + set_backend (b); + mark_modified (); + } + } + else + error ("__backend__ must be a string"); + } + } // See the genprops.awk script for an explanation of the // properties declarations. @@ -2078,6 +2119,7 @@ string_property xvisual , "" radio_property xvisualmode , "{auto}|manual" callback_property buttondownfcn , Matrix () + string_property __backend__ s , "gnuplot" END_PROPERTIES protected: