diff --git a/modules/gui/src/file_loader.cc b/modules/gui/src/file_loader.cc index 258d0ac024421a439cbec541aadd42ac54cd0faf..8552f2dcfb5897abc2e7f53524be82dd83f02513 100644 --- a/modules/gui/src/file_loader.cc +++ b/modules/gui/src/file_loader.cc @@ -38,6 +38,9 @@ #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/surface.hh> #include <ost/gfx/scene.hh> @@ -47,6 +50,7 @@ #include <ost/gui/python_shell/python_interpreter.hh> #include <ost/gui/main_area.hh> #include <ost/gui/file_type_dialog.hh> +#include <ost/gui/sequence/sequence_viewer.hh> #if OST_IMG_ENABLED #include <ost/io/img/load_map.hh> @@ -88,6 +92,13 @@ void FileLoader::LoadObject(const QString& filename, const QString& selection) } } #endif + if (!obj) { + try{ + obj=FileLoader::TryLoadAlignment(filename); + } catch (io::IOFileAlreadyLoadedException&) { + return; + } + } if (!obj) { obj=FileLoader::TryLoadSurface(filename); } @@ -296,6 +307,29 @@ gfx::GfxObjP FileLoader::TryLoadSurface(const QString& filename, io::SurfaceIOHa 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) { PythonInterpreter& pi = PythonInterpreter::Instance(); diff --git a/modules/gui/src/file_loader.hh b/modules/gui/src/file_loader.hh index 7dc110ab1a33ff8c49f65341471570fb5965be8b..4bf5a8ad1fb59d6f83aba2a2791381109e335e9c 100644 --- a/modules/gui/src/file_loader.hh +++ b/modules/gui/src/file_loader.hh @@ -32,6 +32,7 @@ #include <ost/io/io_exception.hh> #include <ost/io/entity_io_handler.hh> +#include <ost/io/sequence_io_handler.hh> #include <ost/io/surface_io_handler.hh> #if OST_IMG_ENABLED #include <ost/io/map_io_handler.hh> @@ -51,6 +52,7 @@ private: FileLoader(); 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 TryLoadAlignment(const QString& filename, io::SequenceIOHandlerPtr handler=io::SequenceIOHandlerPtr()); #if OST_IMG_ENABLED static gfx::GfxObjP TryLoadMap(const QString& filename, io::MapIOHandlerPtr handler=io::MapIOHandlerPtr()); #endif