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>
29 
30 #include <ost/io/io_exception.hh>
34 #if OST_IMG_ENABLED
35 #include <ost/io/map_io_handler.hh>
36 #endif
37 
38 #include <QString>
39 #include <QList>
40 #include <QMap>
41 namespace ost { namespace gui {
42 
44 private:
45 
46  enum ErrorType { DEFAULT = 0,
47  IO_LOADING,
48  GFX_ADD,
49  GFX_MULTIPLE_ADD,
50  INFO
51  };
52 
53  FileLoader();
54  static gfx::GfxObjP TryLoadEntity(const QString& filename, io::EntityIOHandlerP handler=io::EntityIOHandlerP(), const QString& selection=QString());
55  static gfx::GfxObjP TryLoadSurface(const QString& filename, io::SurfaceIOHandlerPtr handler=io::SurfaceIOHandlerPtr());
56  static gfx::GfxObjP TryLoadAlignment(const QString& filename, io::SequenceIOHandlerPtr handler=io::SequenceIOHandlerPtr());
57 #if OST_IMG_ENABLED
58  static gfx::GfxObjP TryLoadMap(const QString& filename, io::MapIOHandlerPtr handler=io::MapIOHandlerPtr());
59 #endif
60  static void RunScript(const QString& filename);
61  static void LoadPDB(const QString& filename, const QString& selection=QString());
62  static void AddToScene(const QString& filename, gfx::GfxObjP obj);
63  static void HandleError(const Error& e, ErrorType type, const QString& filename, gfx::GfxObjP obj=gfx::GfxObjP());
64  static gfx::GfxObjP NoHandlerFound(const QString& filename);
65  virtual ~FileLoader();
66 
67  static LoaderManagerPtr loader_manager_;
68 
69 #if OST_IMG_ENABLED
70  static QList<img::ImageHandle> loaded_images_;
71 #endif
72 
73 public:
74  static void LoadObject(const QString& filename, const QString& selection=QString());
75  static void LoadFrom(const QString& id, const QString& site=QString(), const QString& selection=QString());
76  static std::vector<String> GetSiteLoaderIdents();
77  static LoaderManagerPtr GetLoaderManager();
78 };
79 
80 } }
81 
82 #endif /* OST_GUI_FILE_LOADER_HH */