]> git.mxchange.org Git - simgear.git/blob - simgear/scene/util/SGReaderWriterOptions.hxx
Fix VS2010 lack of fminf
[simgear.git] / simgear / scene / util / SGReaderWriterOptions.hxx
1 // Copyright (C) 2007 Tim Moore timoore@redhat.com
2 // Copyright (C) 2008 Till Busch buti@bux.at
3 // Copyright (C) 2011 Mathias Froehlich
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 #ifndef SGREADERWRITEROPTIONS_HXX
21 #define SGREADERWRITEROPTIONS_HXX 1
22
23 #include <osgDB/Options>
24 #include <simgear/scene/model/modellib.hxx>
25 #include <simgear/scene/material/matlib.hxx>
26
27 #include <simgear/props/props.hxx>
28
29 class SGPropertyNode;
30
31
32 namespace simgear
33 {
34
35 class SGReaderWriterOptions : public osgDB::Options {
36 public:
37     SGReaderWriterOptions() :
38         _materialLib(0),
39         _load_panel(0),
40         _model_data(0),
41         _instantiateEffects(false)
42     { }
43     SGReaderWriterOptions(const std::string& str) :
44         osgDB::Options(str),
45         _materialLib(0),
46         _load_panel(0),
47         _model_data(0),
48         _instantiateEffects(false)
49     { }
50     SGReaderWriterOptions(const osgDB::Options& options,
51                           const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY) :
52         osgDB::Options(options, copyop),
53         _materialLib(0),
54         _load_panel(0),
55         _model_data(0),
56         _instantiateEffects(false)
57     { }
58     SGReaderWriterOptions(const SGReaderWriterOptions& options,
59                           const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY) :
60         osgDB::Options(options, copyop),
61         _propertyNode(options._propertyNode),
62         _materialLib(options._materialLib),
63         _load_panel(options._load_panel),
64         _model_data(options._model_data),
65         _instantiateEffects(options._instantiateEffects)
66     { }
67
68     META_Object(simgear, SGReaderWriterOptions);
69
70     const SGSharedPtr<SGPropertyNode>& getPropertyNode() const
71     { return _propertyNode; }
72     void setPropertyNode(const SGSharedPtr<SGPropertyNode>& propertyNode)
73     { _propertyNode = propertyNode; }
74
75     SGMaterialLibPtr getMaterialLib() const
76     { return _materialLib; }
77     void setMaterialLib(SGMaterialLib* materialLib)
78     { _materialLib = materialLib; }
79
80     typedef osg::Node *(*panel_func)(SGPropertyNode *);
81
82     panel_func getLoadPanel() const
83     { return _load_panel; }
84     void setLoadPanel(panel_func pf)
85     { _load_panel=pf; }
86
87     SGModelData *getModelData() const
88     { return _model_data.get(); }
89     void setModelData(SGModelData *modelData)
90     { _model_data=modelData; }
91
92     bool getInstantiateEffects() const
93     { return _instantiateEffects; }
94     void setInstantiateEffects(bool instantiateEffects)
95     { _instantiateEffects = instantiateEffects; }
96
97     static SGReaderWriterOptions* copyOrCreate(const osgDB::Options* options);
98     static SGReaderWriterOptions* fromPath(const std::string& path);
99
100 protected:
101     virtual ~SGReaderWriterOptions();
102
103 private:
104     SGSharedPtr<SGPropertyNode> _propertyNode;
105     SGSharedPtr<SGMaterialLib> _materialLib;
106     osg::Node *(*_load_panel)(SGPropertyNode *);
107     osg::ref_ptr<SGModelData> _model_data;
108     bool _instantiateEffects;
109 };
110
111 }
112
113 #endif