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

Go to the SVN repository for this file.

1 /* $Id: alnspan_widget.cpp 38774 2017-06-16 15:57:03Z katargir $
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: Yury Voronov
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
40 
41 #include <gui/utils/view_event.hpp>
43 
44 #include <serial/iterator.hpp>
45 
48 
49 /// Definitions for Align Span Widget commands
50 ///
51 /*
52 enum EAlignSpanTableCommands {
53  eCmdFind = eBaseCmdLast + 300,
54  eCmdSelectActiveColumns,
55  eCmdVisibleRangeChange,
56  eCmdFilter,
57  eCmdExportToCSV
58 };
59 */
60 
61 
62 BEGIN_EVENT_TABLE(CAlnSpanWidget, CwxTableListCtrl)
66  EVT_LIST_ITEM_SELECTED( wxID_ANY, CAlnSpanWidget::OnSelectionChanged )
67  EVT_LIST_ITEM_DESELECTED( wxID_ANY, CAlnSpanWidget::OnSelectionChanged )
69 
70 
72  wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style
73 )
74  : CwxTableListCtrl( parent, id, pos, size, style )
75 {
76 }
77 
79 {
80 }
81 
83 {
85 
86  for( int i = 0; i < model.GetNumSequences(); i++ ){
87  SetColumnWidth( i, 100 );
88  }
89 }
90 
92 {
93  //((CAlnSpanVertModel*)GetModel())->Update();
94 }
95 
97 {
98  wxArrayInt objIxs = GetDataRowsSelected();
99 
100  IwxTableModel* imodel = GetModel();
101  const CAlnSpanVertModel* model = dynamic_cast<const CAlnSpanVertModel*>( imodel );
102  _ASSERT( model != NULL );
103 
104  for( int i = 0; i < (int)objIxs.size(); ++i ){
105  const CAlnSpanVertModel::SSpanRow& row = model->GetData( objIxs[i] );
106 
107  ///
108  /// we need to extract a location from each row
109  /// we have two locations to provide: one for the object
110  /// and one for the component
111  ///
112  ITERATE( vector< CConstRef<CSeq_loc> >, iter, row.locs ){
113  if( *iter ){
114  locs.push_back(*iter);
115  }
116  }
117  }
118 }
119 
120 // send an event to parents notifing that selection has changed
122 {
124  Send(&evt, ePool_Parent);
125 }
126 
127 // send an event to parents notifing that selected seq range has changed
129 {
131  Send(&evt, ePool_Parent);
132 }
133 
134 
135 void CAlnSpanWidget::AppendMenuItems( wxMenu& aMenu )
136 {
138 
139  aMenu.Append( wxID_SEPARATOR, wxT("Actions") );
140  aMenu.Append( CwxTableListCtrl::eCmdExportToCSV, wxT("Export to CSV...") );
141 
142  aMenu.Append( wxID_SEPARATOR, wxT("Settings") );
143  aMenu.Append( eCmdSettings, wxT("Settings...") );
144 }
145 
146 
147 void CAlnSpanWidget::OnExportToCSV( wxCommandEvent& event )
148 {
150 }
151 
152 void CAlnSpanWidget::OnSettings( wxCommandEvent& event )
153 {
154  CAlnSpanVertModel* model = dynamic_cast<CAlnSpanVertModel*>( GetModel() );
155  _ASSERT( model != NULL );
156 
157  CAlnSpanSettingsDlg dlg( this );
158  dlg.SetThreshold( model->GetThreshold() );
159  dlg.SetShowIndels( model->GetShowIndels() );
160  if( dlg.ShowModal() == wxID_OK ){
161  model->SetThreshold( dlg.GetThreshold() );
162  model->SetShowIndels( dlg.GetShowIndels() );
163  model->UpdateRows();
164 
165  //HACK
166  // This is to update status bar
167  // We need a special x_NotifyWidgetDataChanged() call
169  }
170 }
171 
172 void CAlnSpanWidget::OnSettingsUpdateUI( wxUpdateUIEvent& event )
173 {
174  event.Enable( true );
175 }
176 
177 
178 void CAlnSpanWidget::x_OnSelectionChanged( bool on, int start_row, int end_row )
179 {
181 }
182 
184 
185 /*
186  * ===========================================================================
187  * $Log$
188  * ===========================================================================
189  */
EVT_UPDATE_UI(eCmdAlnShowMethodsDlg, CAlnMultiWidget::OnUpdateShowMethodDlg) EVT_UPDATE_UI(eCmdMethodProperties
USING_SCOPE(objects)
void SetShowIndels(bool indel)
void SetShowIndels(bool indel)
const SSpanRow & GetData(size_t row) const
access a given row's data
bool GetShowIndels() const
void GetSelection(TLocations &locs) const
void OnExportToCSV(wxCommandEvent &event)
list< CConstRef< objects::CSeq_loc > > TLocations
void SetAlnModel(CAlnSpanVertModel &model)
void x_NotifyWidgetSelChanged()
void OnSettings(wxCommandEvent &event)
void x_NotifyWidgetRangeChanged()
virtual void AppendMenuItems(wxMenu &aMenu)
void OnSettingsUpdateUI(wxUpdateUIEvent &event)
virtual void x_OnSelectionChanged(bool on, int start_row, int end_row=-1)
virtual ~CAlnSpanWidget()
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
@ eWidgetSelectionChanged
a view has been destroyed
Definition: view_event.hpp:55
@ eWidgetRangeChanged
notification from child to parent that the visible range has changed
Definition: view_event.hpp:58
CwxTableListCtrl - generic wxListCtrl-based Table Control.
void OnSelectionChanged(wxListEvent &event)
IwxTableModel * GetModel() const
wxArrayInt GetDataRowsSelected() const
virtual void AppendMenuItems(wxMenu &aMenu)
void SetModel(IwxTableModel *data_model, bool own=false)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
virtual bool Send(CEvent *evt, EDispatch disp_how=eDispatch_Default, int pool_name=ePool_Default)
Sends an event synchronously.
@ eCmdSettings
Definition: command.hpp:85
@ eEvent_Message
message from one class to another
Definition: event.hpp:99
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
END_EVENT_TABLE()
int i
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
static static static wxID_ANY
ViewerWindowBase::OnEditMenu ViewerWindowBase::OnJustification EVT_MENU(MID_SHOW_GEOM_VLTNS, ViewerWindowBase::OnShowGeomVltns) EVT_MENU(MID_FIND_PATTERN
#define row(bind, expected)
Definition: string_bind.c:73
the alignment we store with its parsed data
#define _ASSERT
#define const
Definition: zconf.h:232
Modified on Tue Jul 16 13:18:36 2024 by modify_doxy.py rev. 669887