1 // Copyright (C) 2007 Tim Moore timoore@redhat.com
2 // Copyright (C) 2008 Till Busch buti@bux.at
3 // Copyright (C) 2011 Mathias Froehlich
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.
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.
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.
20 #ifndef SGREADERWRITEROPTIONS_HXX
21 #define SGREADERWRITEROPTIONS_HXX 1
23 #include <osgDB/Options>
24 #include <osgDB/Registry>
25 #include <simgear/scene/model/modellib.hxx>
26 #include <simgear/props/props.hxx>
34 class SGReaderWriterOptions : public osgDB::Options {
36 SGReaderWriterOptions() :
40 _instantiateEffects(false)
42 SGReaderWriterOptions(const std::string& str) :
47 _instantiateEffects(false)
49 SGReaderWriterOptions(const osgDB::Options& options,
50 const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY) :
51 osgDB::Options(options, copyop),
55 _instantiateEffects(false)
57 SGReaderWriterOptions(const SGReaderWriterOptions& options,
58 const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY) :
59 osgDB::Options(options, copyop),
60 _propertyNode(options._propertyNode),
61 _materialLib(options._materialLib),
62 _load_panel(options._load_panel),
63 _model_data(options._model_data),
64 _instantiateEffects(options._instantiateEffects)
67 META_Object(simgear, SGReaderWriterOptions);
69 const SGSharedPtr<SGPropertyNode>& getPropertyNode() const
70 { return _propertyNode; }
71 void setPropertyNode(const SGSharedPtr<SGPropertyNode>& propertyNode)
72 { _propertyNode = propertyNode; }
74 SGMaterialLib* getMaterialLib() const
75 { return _materialLib; }
76 void setMaterialLib(SGMaterialLib* materialLib)
77 { _materialLib = materialLib; }
79 typedef osg::Node *(*panel_func)(SGPropertyNode *);
81 panel_func getLoadPanel() const
82 { return _load_panel; }
83 void setLoadPanel(panel_func pf)
86 SGModelData *getModelData() const
87 { return _model_data.get(); }
88 void setModelData(SGModelData *modelData)
89 { _model_data=modelData; }
91 bool getInstantiateEffects() const
92 { return _instantiateEffects; }
93 void setInstantiateEffects(bool instantiateEffects)
94 { _instantiateEffects = instantiateEffects; }
96 static SGReaderWriterOptions* copyOrCreate(const osgDB::Options* options)
99 options = osgDB::Registry::instance()->getOptions();
101 return new SGReaderWriterOptions;
102 if (!dynamic_cast<const SGReaderWriterOptions*>(options))
103 return new SGReaderWriterOptions(*options);
104 return new SGReaderWriterOptions(*static_cast<const SGReaderWriterOptions*>(options));
108 virtual ~SGReaderWriterOptions() {}
111 SGSharedPtr<SGPropertyNode> _propertyNode;
112 SGMaterialLib* _materialLib;
113 osg::Node *(*_load_panel)(SGPropertyNode *);
114 osg::ref_ptr<SGModelData> _model_data;
115 bool _instantiateEffects;