Skip to content
Snippets Groups Projects
Commit e3d46659 authored by stefan's avatar stefan
Browse files

FileLoader, support for alignments

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2298 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 9fcb2f6d
Branches
Tags
No related merge requests found
...@@ -38,6 +38,9 @@ ...@@ -38,6 +38,9 @@
#include <ost/conop/conop.hh> #include <ost/conop/conop.hh>
#include <ost/seq/sequence_list.hh>
#include <ost/seq/alignment_handle.hh>
#include <ost/gfx/entity.hh> #include <ost/gfx/entity.hh>
#include <ost/gfx/surface.hh> #include <ost/gfx/surface.hh>
#include <ost/gfx/scene.hh> #include <ost/gfx/scene.hh>
...@@ -47,6 +50,7 @@ ...@@ -47,6 +50,7 @@
#include <ost/gui/python_shell/python_interpreter.hh> #include <ost/gui/python_shell/python_interpreter.hh>
#include <ost/gui/main_area.hh> #include <ost/gui/main_area.hh>
#include <ost/gui/file_type_dialog.hh> #include <ost/gui/file_type_dialog.hh>
#include <ost/gui/sequence/sequence_viewer.hh>
#if OST_IMG_ENABLED #if OST_IMG_ENABLED
#include <ost/io/img/load_map.hh> #include <ost/io/img/load_map.hh>
...@@ -88,6 +92,13 @@ void FileLoader::LoadObject(const QString& filename, const QString& selection) ...@@ -88,6 +92,13 @@ void FileLoader::LoadObject(const QString& filename, const QString& selection)
} }
} }
#endif #endif
if (!obj) {
try{
obj=FileLoader::TryLoadAlignment(filename);
} catch (io::IOFileAlreadyLoadedException&) {
return;
}
}
if (!obj) { if (!obj) {
obj=FileLoader::TryLoadSurface(filename); obj=FileLoader::TryLoadSurface(filename);
} }
...@@ -296,6 +307,29 @@ gfx::GfxObjP FileLoader::TryLoadSurface(const QString& filename, io::SurfaceIOHa ...@@ -296,6 +307,29 @@ gfx::GfxObjP FileLoader::TryLoadSurface(const QString& filename, io::SurfaceIOHa
return gfx::GfxObjP(); return gfx::GfxObjP();
} }
gfx::GfxObjP FileLoader::TryLoadAlignment(const QString& filename, io::SequenceIOHandlerPtr handler)
{
if(!handler){
try{
handler = io::IOManager::Instance().FindAlignmentImportHandler(filename.toStdString(),"auto");
}
catch(io::IOUnknownFormatException e){
handler = io::SequenceIOHandlerPtr();
}
}
if(handler){
seq::SequenceList seq_list = seq::CreateSequenceList();
handler->Import(seq_list,filename.toStdString());
seq::AlignmentHandle alignment = seq::AlignmentFromSequenceList(seq_list);
gui::MainArea* main_area = gui::GostyApp::Instance()->GetPerspective()->GetMainArea();
SequenceViewerV2* viewer = new SequenceViewerV2(main_area);
viewer->AddAlignment(alignment);
main_area->AddWidget(filename,viewer);
throw io::IOFileAlreadyLoadedException("Loaded in DataViewer");
}
return gfx::GfxObjP();
}
void FileLoader::RunScript(const QString& filename) void FileLoader::RunScript(const QString& filename)
{ {
PythonInterpreter& pi = PythonInterpreter::Instance(); PythonInterpreter& pi = PythonInterpreter::Instance();
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <ost/io/io_exception.hh> #include <ost/io/io_exception.hh>
#include <ost/io/entity_io_handler.hh> #include <ost/io/entity_io_handler.hh>
#include <ost/io/sequence_io_handler.hh>
#include <ost/io/surface_io_handler.hh> #include <ost/io/surface_io_handler.hh>
#if OST_IMG_ENABLED #if OST_IMG_ENABLED
#include <ost/io/map_io_handler.hh> #include <ost/io/map_io_handler.hh>
...@@ -51,6 +52,7 @@ private: ...@@ -51,6 +52,7 @@ private:
FileLoader(); FileLoader();
static gfx::GfxObjP TryLoadEntity(const QString& filename, io::EntityIOHandlerP handler=io::EntityIOHandlerP(), const QString& selection=QString()); static gfx::GfxObjP TryLoadEntity(const QString& filename, io::EntityIOHandlerP handler=io::EntityIOHandlerP(), const QString& selection=QString());
static gfx::GfxObjP TryLoadSurface(const QString& filename, io::SurfaceIOHandlerPtr handler=io::SurfaceIOHandlerPtr()); static gfx::GfxObjP TryLoadSurface(const QString& filename, io::SurfaceIOHandlerPtr handler=io::SurfaceIOHandlerPtr());
static gfx::GfxObjP TryLoadAlignment(const QString& filename, io::SequenceIOHandlerPtr handler=io::SequenceIOHandlerPtr());
#if OST_IMG_ENABLED #if OST_IMG_ENABLED
static gfx::GfxObjP TryLoadMap(const QString& filename, io::MapIOHandlerPtr handler=io::MapIOHandlerPtr()); static gfx::GfxObjP TryLoadMap(const QString& filename, io::MapIOHandlerPtr handler=io::MapIOHandlerPtr());
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment