| 1 | // Owner Drawn Gauge helper class |
| 2 | // |
| 3 | // Moved to SimGear by Thomas Geymayer - October 2012 |
| 4 | // |
| 5 | // This program is free software; you can redistribute it and/or |
| 6 | // modify it under the terms of the GNU General Public License as |
| 7 | // published by the Free Software Foundation; either version 2 of the |
| 8 | // License, or (at your option) any later version. |
| 9 | // |
| 10 | // This program is distributed in the hope that it will be useful, but |
| 11 | // WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | // 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | // |
| 19 | // |
| 20 | |
| 21 | #ifndef _OD_GAUGE_HXX |
| 22 | #define _OD_GAUGE_HXX |
| 23 | |
| 24 | #include <simgear/canvas/ODGauge.hxx> |
| 25 | #include <simgear/canvas/CanvasPlacement.hxx> |
| 26 | |
| 27 | class SGPropertyNode; |
| 28 | |
| 29 | /** |
| 30 | * Owner Drawn Gauge helper class |
| 31 | */ |
| 32 | class FGODGauge: |
| 33 | public simgear::canvas::ODGauge |
| 34 | { |
| 35 | public: |
| 36 | FGODGauge(); |
| 37 | virtual ~FGODGauge(); |
| 38 | |
| 39 | /** |
| 40 | * Replace an opengl texture name inside a given branch of the scene graph. |
| 41 | * This is to replace a static texture by a dynamic one |
| 42 | * |
| 43 | * @param branch Scene graph branch to use for search |
| 44 | * @param name texture filename |
| 45 | * @param new_texture dynamic texture to replace the old one |
| 46 | * @return A list of groups which override the given texture |
| 47 | */ |
| 48 | static |
| 49 | simgear::canvas::Placements set_texture( osg::Node* branch, |
| 50 | const char * name, |
| 51 | osg::Texture2D* new_texture ); |
| 52 | |
| 53 | /** |
| 54 | * Replace an opengl texture name inside the aircraft scene graph. |
| 55 | * This is to replace a static texture by a dynamic one |
| 56 | * |
| 57 | * @param branch Scene graph branch to search for matching |
| 58 | * @param name texture filename |
| 59 | * @param new_texture dynamic texture to replace the old one |
| 60 | * @return A list of groups which override the given texture |
| 61 | */ |
| 62 | static |
| 63 | simgear::canvas::Placements |
| 64 | set_aircraft_texture( const char * name, |
| 65 | osg::Texture2D* new_texture ); |
| 66 | |
| 67 | /** |
| 68 | * Replace an opengl texture name inside a given branch of the scene graph. |
| 69 | * This is to replace a static texture by a dynamic one. The replacement |
| 70 | * is base on certain filtering criteria which have to be stored in string |
| 71 | * value childs of the placement node. Recognized nodes are: |
| 72 | * - texture Match the name of the texture |
| 73 | * - node Match the name of the object |
| 74 | * - parent Match any of the object parents names (all the tree upwards) |
| 75 | * |
| 76 | * @param placement the node containing the replacement criteria |
| 77 | * @param new_texture dynamic texture to replace the old one |
| 78 | * @param an optional cull callback which will be installed on any matching |
| 79 | * object |
| 80 | * @return A list of groups which override the given texture |
| 81 | */ |
| 82 | static |
| 83 | simgear::canvas::Placements |
| 84 | set_texture( osg::Node* branch, |
| 85 | SGPropertyNode* placement, |
| 86 | osg::Texture2D* new_texture, |
| 87 | osg::NodeCallback* cull_callback = 0, |
| 88 | const simgear::canvas::CanvasWeakPtr& canvas = |
| 89 | simgear::canvas::CanvasWeakPtr() ); |
| 90 | |
| 91 | /** |
| 92 | * Replace an opengl texture name inside the aircraft scene graph. |
| 93 | * |
| 94 | * @param placement the node containing the replacement criteria |
| 95 | * @param new_texture dynamic texture to replace the old one |
| 96 | * @param an optional cull callback which will be installed on any matching |
| 97 | * object |
| 98 | * @return A list of groups which override the given texture |
| 99 | */ |
| 100 | static |
| 101 | simgear::canvas::Placements |
| 102 | set_aircraft_texture( SGPropertyNode* placement, |
| 103 | osg::Texture2D* new_texture, |
| 104 | osg::NodeCallback* cull_callback = 0, |
| 105 | const simgear::canvas::CanvasWeakPtr& canvas = |
| 106 | simgear::canvas::CanvasWeakPtr() ); |
| 107 | |
| 108 | }; |
| 109 | |
| 110 | #endif // _OD_GAUGE_HXX |