OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
sequence_viewer.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_SEQUENCE_VIEWER_SEQUENCE_VIEWER
20 #define OST_SEQUENCE_VIEWER_SEQUENCE_VIEWER
21 
22 /*
23  Author: Stefan Scheuber
24  */
25 
26 
28 
29 #include <ost/gfx/scene.hh>
30 #include <ost/gfx/gfx_object.hh>
31 #include <ost/gfx/entity.hh>
32 #include <ost/gui/widget.hh>
33 
34 #include <ost/gui/module_config.hh>
35 
36 
37 #include <QWidget>
38 #include <QActionGroup>
39 #include <QToolBar>
40 #include <QModelIndex>
41 #include <QItemSelection>
42 
43 namespace ost {
44 
45 namespace gui {
46 
47 class SeqSearchBar;
48 class SequenceModel;
49 class SequenceTableView;
50 
51 
54  Q_OBJECT
55 public:
56  SequenceViewer(bool stand_alone=true, bool observe_scene=false,
57  const QString& title="Sequence Viewer",
58  QWidget* parent=NULL);
59  ~SequenceViewer();
60 
61  virtual void SelectionChanged(const gfx::GfxObjP& o, const mol::EntityView& view);
62 
63  virtual void AddEntity(const gfx::EntityP& entity);
64  virtual void RemoveEntity(const gfx::EntityP& entity);
65  void SetObserveScene(bool flag) { observe_scene_=flag; }
66  bool IsObservingScene() const { return observe_scene_; }
67  virtual void AddAlignment(const seq::AlignmentHandle& alignment);
68 
69  void SetAlignment(const seq::AlignmentHandle& alignment);
70 
71  virtual void RemoveAlignment(const seq::AlignmentHandle& alignment);
72 
73  virtual bool Restore(const QString&){ return true; };
74  virtual bool Save(const QString&){ return true; };
75 
76  virtual const QStringList& GetDisplayModes();
77  virtual const QStringList& GetDisplayModes(const seq::AlignmentHandle& alignment);
78  virtual const QStringList& GetDisplayModes(const gfx::EntityP& entity);
79 
80  virtual const QString& GetCurrentDisplayMode();
81  virtual const QString& GetCurrentDisplayMode(const seq::AlignmentHandle& alignment);
82  virtual const QString& GetCurrentDisplayMode(const gfx::EntityP& entity);
83 
84  virtual ActionList GetActions();
85 signals:
86  void AlignmentChanged();
87 public slots:
88  void ChangeDisplayMode(const QString&);
89  void ChangeDisplayMode(const seq::AlignmentHandle&, const QString&);
90  void ChangeDisplayMode(const gfx::EntityP&, const QString&);
91  void DisplayMenu();
92  //internal
93  void OnSearchBarUpdate(const QString&, bool, const QString&);
94 
95 private:
96  virtual void NodeAdded(const gfx::GfxNodeP& node);
97  virtual void NodeRemoved(const gfx::GfxNodeP& node);
98  void FitToContents();
99  void InitActions();
100  void InitView();
101  void InitSearchBar();
102  void InitMenuBar();
103  void UpdateSearchBar();
104  void SelectList(const QModelIndexList& list);
105  QToolBar* toolbar_;
106  SeqSearchBar* seq_search_bar_;
107  SequenceModel* model_;
108  SequenceTableView* seq_table_view_;
109 
110  ActionList action_list_;
111 
112  QActionGroup* display_mode_actions_;
113  bool observe_scene_;
114 private slots:
115  void ChangeDisplayMode();
116  void FindInSequence();
117  void SelectionModelChanged(const QItemSelection&, const QItemSelection&);
118  void DoubleClicked(const QModelIndex& index);
119  void MouseWheelEvent(QWheelEvent* event);
120  void CopyEvent(QKeyEvent* event);
121 
122 };
123 
124 }}
125 
126 #endif