From 96882628204227274a8abd8d545105f823db77fd Mon Sep 17 00:00:00 2001
From: stefan <stefan@5a81b35b-ba03-0410-adc8-b2c5c5119f08>
Date: Thu, 6 May 2010 12:59:53 +0000
Subject: [PATCH] Added new sequenceviewer to gosty and per default to widget
 pool

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2187 5a81b35b-ba03-0410-adc8-b2c5c5119f08
---
 modules/gui/pymod/export_gosty.cc           |  4 ++++
 modules/gui/src/gosty_app.cc                | 11 ++++++++++-
 modules/gui/src/gosty_app.hh                |  3 +++
 modules/gui/src/sequence/sequence_viewer.cc | 21 ++++++++++++++++++---
 scripts/init.py                             |  1 +
 5 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/modules/gui/pymod/export_gosty.cc b/modules/gui/pymod/export_gosty.cc
index 88bb73287..9cd97b7fd 100644
--- a/modules/gui/pymod/export_gosty.cc
+++ b/modules/gui/pymod/export_gosty.cc
@@ -96,6 +96,10 @@ void export_Gosty()
         return_value_policy<reference_existing_object>())
     .add_property("seq_viewer", make_function(&GostyApp::GetSequenceViewer,
         return_value_policy<reference_existing_object>()))
+    .def("GetSequenceViewerV2", &GostyApp::GetSequenceViewerV2,
+        return_value_policy<reference_existing_object>())
+    .add_property("seq_viewer_v2", make_function(&GostyApp::GetSequenceViewerV2,
+        return_value_policy<reference_existing_object>()))
     .def("GetToolOptionsWin", &GostyApp::GetToolOptionsWin,
         return_value_policy<reference_existing_object>())
     .add_property("tool_options_win", make_function(&GostyApp::GetToolOptionsWin,
diff --git a/modules/gui/src/gosty_app.cc b/modules/gui/src/gosty_app.cc
index 8eed58bea..bf4398b38 100644
--- a/modules/gui/src/gosty_app.cc
+++ b/modules/gui/src/gosty_app.cc
@@ -46,7 +46,7 @@ GostyApp* GostyApp::app_=NULL;
 
 GostyApp::GostyApp():
   py_shell_(NULL), w_py_shell_(NULL), gl_win_(NULL), w_gl_win_(NULL),
-  scene_win_(NULL), w_scene_win_(NULL), seq_viewer_(NULL), tool_options_win_(NULL),
+  scene_win_(NULL), w_scene_win_(NULL), seq_viewer_(NULL), seq_viewer_v2_(NULL), tool_options_win_(NULL),
   w_tool_options_(NULL), main_(new GostyMainWindow), 
   perspective_(NULL), external_widgets_(QMap<QString,WidgetGeomHandler *>())
 {
@@ -104,6 +104,15 @@ SequenceViewer* GostyApp::GetSequenceViewer()
   return seq_viewer_;
 }
 
+SequenceViewerV2* GostyApp::GetSequenceViewerV2()
+{
+  if (seq_viewer_v2_==NULL) {
+    seq_viewer_v2_=new SequenceViewerV2;
+    seq_viewer_v2_->SetDestroyOnClose(false);
+  }
+  return seq_viewer_v2_;
+}
+
 #if OST_IMG_ENABLED
 ost::img::gui::DataViewer* GostyApp::CreateDataViewer(const ost::img::Data& d, const QString& name)
 {
diff --git a/modules/gui/src/gosty_app.hh b/modules/gui/src/gosty_app.hh
index 2bf1e2eee..46381ff16 100644
--- a/modules/gui/src/gosty_app.hh
+++ b/modules/gui/src/gosty_app.hh
@@ -31,6 +31,7 @@
 #include <ost/gui/module_config.hh>
 #include <ost/gui/scene_win/scene_win.hh>
 #include <ost/gui/sequence_viewer/sequence_viewer.hh>
+#include <ost/gui/sequence/sequence_viewer.hh>
 #include <ost/gui/main.hh>
 #include <ost/gui/widget_geom_handler.hh>
 #if OST_IMG_ENABLED
@@ -92,6 +93,7 @@ public:
   /// The sequence viewer is initialized when this method is first called. All
   /// subsequent calls will return the same SequenceViewer instance.
   SequenceViewer* GetSequenceViewer();
+  SequenceViewerV2* GetSequenceViewerV2();
   
   /// \brief get tool options window
   /// 
@@ -155,6 +157,7 @@ private:
   QWidget*          w_scene_win_;
 
   SequenceViewer*   seq_viewer_;
+  SequenceViewerV2* seq_viewer_v2_;
 
   ToolOptionsWin*   tool_options_win_;
   QWidget*          w_tool_options_;  
diff --git a/modules/gui/src/sequence/sequence_viewer.cc b/modules/gui/src/sequence/sequence_viewer.cc
index 269590dfc..fd6a3cf2b 100644
--- a/modules/gui/src/sequence/sequence_viewer.cc
+++ b/modules/gui/src/sequence/sequence_viewer.cc
@@ -36,14 +36,27 @@
 #include <ost/gfx/scene.hh>
 #include <ost/gfx/gfx_node_visitor.hh>
 
-#include "sequence_model.hh"
+#include <ost/gui/widget_registry.hh>
+#include <ost/gui/gosty_app.hh>
 
+#include "sequence_model.hh"
 #include "sequence_viewer.hh"
 
-#include "sequence_delegate.hh"
-
 namespace ost { namespace gui {
 
+class SequenceViewerV2Factory: public WidgetFactory {
+public:
+  SequenceViewerV2Factory() :
+    WidgetFactory("ost::gui::SequenceViewerV2", "Sequence Viewer V2") {
+  }
+
+  virtual Widget* Create(QWidget* parent) {
+    return GostyApp::Instance()->GetSequenceViewerV2();
+  }
+};
+
+OST_REGISTER_WIDGET(SequenceViewerV2, SequenceViewerV2Factory);
+
 struct GetNodesVisitor: public gfx::GfxNodeVisitor {
   GetNodesVisitor(): nodes_() {}
   virtual void VisitObject(gfx::GfxObj* o, const Stack& st) {
@@ -59,6 +72,8 @@ SequenceViewerV2::SequenceViewerV2(QWidget* parent): Widget(NULL,parent)
   model_ = new SequenceModel(this);
 
   QVBoxLayout* layout = new QVBoxLayout(this);
+  layout->setMargin(0);
+  layout->setSpacing(0);
 
   seq_table_view_ = new SequenceTableView(model_);
   layout->addWidget(seq_table_view_);
diff --git a/scripts/init.py b/scripts/init.py
index 6df88ea01..020a66079 100644
--- a/scripts/init.py
+++ b/scripts/init.py
@@ -36,6 +36,7 @@ def _InitPanels(app):
   panels.AddWidgetToPool('ost.gui.RemoteLoader', -1)
   panels.AddWidgetToPool('ost.gui.SceneWin', 1)
   panels.AddWidgetToPool('ost.gui.SequenceViewer', 1)
+  panels.AddWidgetToPool('ost.gui.SequenceViewerV2', 1)
   if not panels.Restore("ui/perspective/panels"):
     panels.AddWidget(gui.PanelPosition.LEFT_PANEL, app.scene_win)
     panels.AddWidgetByName(gui.PanelPosition.LEFT_PANEL, 
-- 
GitLab