OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
file_loader.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_GUI_FILE_LOADER_HH
20 #define OST_GUI_FILE_LOADER_HH
21 #include <vector>
22 
23 
24 #include <ost/gfx/gfx_object.hh>
25 
26 #include <ost/gui/module_config.hh>
27 
28 #include <ost/io/io_exception.hh>
32 #if OST_IMG_ENABLED
33 #include <ost/io/map_io_handler.hh>
34 #endif
35 
36 #include <QString>
37 #include <QList>
38 #include <QMap>
39 namespace ost { namespace gui {
40 
42 private:
43 
44  enum ErrorType { DEFAULT = 0,
45  IO_LOADING,
46  GFX_ADD,
47  GFX_MULTIPLE_ADD,
48  INFO
49  };
50 
51  FileLoader();
52  static gfx::GfxObjP TryLoadEntity(const QString& filename, io::EntityIOHandlerP handler=io::EntityIOHandlerP(), const QString& selection=QString());
53  static gfx::GfxObjP TryLoadSurface(const QString& filename, io::SurfaceIOHandlerPtr handler=io::SurfaceIOHandlerPtr());
54  static gfx::GfxObjP TryLoadAlignment(const QString& filename, io::SequenceIOHandlerPtr handler=io::SequenceIOHandlerPtr());
55 #if OST_IMG_ENABLED
56  static gfx::GfxObjP TryLoadMap(const QString& filename, io::MapIOHandlerPtr handler=io::MapIOHandlerPtr());
57 #endif
58  static void RunScript(const QString& filename);
59  static void LoadPDB(const QString& filename, const QString& selection=QString());
60  static void AddToScene(const QString& filename, gfx::GfxObjP obj);
61  static void HandleError(const Error& e, ErrorType type, const QString& filename, gfx::GfxObjP obj=gfx::GfxObjP());
62  static gfx::GfxObjP NoHandlerFound(const QString& filename);
63  virtual ~FileLoader();
64 
65 
66 #if OST_IMG_ENABLED
67  static QList<img::ImageHandle> loaded_images_;
68 #endif
69 
70 public:
71  static void LoadObject(const QString& filename, const QString& selection=QString());
72  static std::vector<String> GetSiteLoaderIdents();
73 };
74 
75 } }
76 
77 #endif /* OST_GUI_FILE_LOADER_HH */