NCBI C++ ToolKit
aln_summary_view.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: aln_summary_view.cpp 39258 2017-08-31 15:28:36Z evgeniev $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Roman Katargin
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
35 
37 #include <gui/core/document.hpp>
38 
41 
42 #include <wx/grid.h>
43 
49 
53 
54 #include <gui/utils/app_popup.hpp>
55 
57 
58 #include <objmgr/util/sequence.hpp>
60 
63 
64 ///////////////////////////////////////////////////////////////////////////////
65 /// CAlnSummaryView
66 
68  "Alignment Summary View", // type name
69  "aln_summary_view", // icon alias
70  "Create an interactive table representation of alignment summary.",
71  "The Alignment Summary View shows summary for a list of alignments",
72  "ALN_SUMMARY_VIEW", // help ID
73  "Alignment", // category
74  false, // not a singleton
75  "Seq-align",
77 );
78 
80 {
81 public:
83 
84  /// @name IView implementation
85  /// @(
86  virtual const CViewTypeDescriptor& GetTypeDescriptor() const
87  {
89  }
90  virtual void CreateViewWindow(wxWindow* parent);
91  /// @}
92 
93 protected:
95  {
97  }
98 };
99 
100 void CAlnSummaryView::CreateViewWindow(wxWindow* parent)
101 {
102  _ASSERT(!m_Window);
103 
104  CGridWidget* widget = new CGridWidget(parent, wxID_ANY, wxDefaultPosition, wxSize(0, 0), wxBORDER_NONE);
105  m_Window = widget;
106  widget->AddListener(this, ePool_Parent);
107 }
108 
109 ///////////////////////////////////////////////////////////////////////////////
110 /// CAlnSummaryViewFactory
112 {
113  static string aln_sid("aln_summary_view_factory");
114  return aln_sid;
115 }
116 
117 
119 {
120  static string aln_slabel("Alignment Summary View Factory");
121  return aln_slabel;
122 }
123 
124 
126 {
127  string alias = GetViewTypeDescriptor().GetIconAlias();
128  provider.RegisterFileAlias(ToWxString(alias), wxT("text_view.png"));
129 }
130 
131 
133 {
135 }
136 
137 
139 {
140  return new CAlnSummaryView();
141 }
142 
144 {
145  return NULL;
146 }
147 
148 
149 bool CAlnSummaryViewFactory::IsCompatibleWith(const CObject& object, objects::CScope& scope)
150 {
151  const type_info& type = typeid(object);
152  if( typeid(CSeq_align) == type ||
153  typeid(CSeq_align_set) == type) {
154  return true;
155  }
156 
157  if( typeid(CSeq_annot) == type ){
158  const CSeq_annot& annot = dynamic_cast<const CSeq_annot&>(object);
159  if (annot.IsAlign()) {
160  return true;
161  }
162  }
163 
164  return false;
165 }
166 
167 
169 {
170  bool found_good = false;
171  bool found_bad = false;
172 
173  for( size_t i = 0; i < objects.size(); i++) {
174  if (IsCompatibleWith(*objects[i].object, *objects[i].scope)) {
175  found_good = true;
176  }
177 
178  found_bad = true;
179  }
180 
181  if (found_good)
182  return fCanShowSeparated | (found_bad ? fCanShowSome : fCanShowAll);
183 
184  return 0; // can show nothing
185 }
186 
USING_SCOPE(objects)
CProjectViewTypeDescriptor s_AlnSummaryViewTypeDescr("Alignment Summary View", "aln_summary_view", "Create an interactive table representation of alignment summary.", "The Alignment Summary View shows summary for a list of alignments", "ALN_SUMMARY_VIEW", "Alignment", false, "Seq-align", eAnyObjectsAccepted)
CAlnSummaryView.
virtual bool IsCompatibleWith(const CObject &object, objects::CScope &scope)
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
virtual const CProjectViewTypeDescriptor & GetProjectViewTypeDescriptor() const
returns a Descriptor for the View Type supported by the Factory
virtual void RegisterIconAliases(wxFileArtProvider &provider)
called by the framework to give Factory a chance to register images used by view
virtual IView * CreateInstance() const
creates a view instance
virtual int TestInputObjects(TConstScopedObjects &objects)
tests input objects (probably using object conversion, or not) and returns a combination of ETestResu...
virtual string GetExtensionIdentifier() const
CAlnSummaryViewFactory.
virtual IView * CreateInstanceByFingerprint(const TFingerprint &fingerprint) const
if fingerprint is recognized - creates and returns a new instance
virtual CIRef< ITableData > x_CreateTableData(TConstScopedObjects &objects)
virtual void CreateViewWindow(wxWindow *parent)
create Window corresponding to the view
virtual const CViewTypeDescriptor & GetTypeDescriptor() const
return an object providing meta information about thei view type
CObject –.
Definition: ncbiobj.hpp:180
CProjectViewTypeDescriptor - holds description of a project view type.
bool IsAlign(void) const
Definition: Seq_annot.cpp:182
CTableView.
Definition: table_view.hpp:54
CViewTypeDescriptor - holds description of a view type.
Definition: view.hpp:98
virtual const CViewTypeDescriptor & GetViewTypeDescriptor() const
returns a Descriptor for the View Type supported by the Factory
IView - represents a standard visual part of Workbench UI.
Definition: view.hpp:73
CFingerprint identifies an instance of IWMClient and is used for labeling layout positions.
Definition: wm_client.hpp:58
virtual void RegisterFileAlias(const wxArtID &anId, const wxArtClient &aClient, const wxSize &aSize, const wxString &aName, long aType=wxBITMAP_TYPE_ANY, int anIndex=-1)
static int type
Definition: getdata.c:31
#define NULL
Definition: ncbistd.hpp:225
wxWindow * m_Window
Definition: table_view.hpp:110
virtual const string & GetIconAlias() const
Definition: ui_object.cpp:130
virtual void AddListener(CEventHandler *listener, int pool_name=ePool_Default)
Add a listener.
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
int i
#define wxT(x)
Definition: muParser.cpp:41
@ eAnyObjectsAccepted
static static static wxID_ANY
Definition: type.c:6
#define _ASSERT
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
Modified on Wed Apr 17 13:08:13 2024 by modify_doxy.py rev. 669887