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

Go to the SVN repository for this file.

1 /* $Id: feature_filter_dlg.cpp 47479 2023-05-02 13:24:02Z ucko $
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 
33 #include <ncbi_pch.hpp>
34 
36 
38 
39 #include <wx/stattext.h>
40 #include <wx/statbox.h>
41 #include <wx/textctrl.h>
42 #include <wx/checkbox.h>
43 #include <wx/checklst.h>
44 #include <wx/radiobut.h>
45 #include <wx/button.h>
46 #include <wx/panel.h>
47 #include <wx/sizer.h>
48 #include <wx/icon.h>
49 #include <wx/valgen.h>
50 #include <wx/valtext.h>
51 
52 
54 
55 IMPLEMENT_DYNAMIC_CLASS( CFeatureFilterDlg, CDialog )
56 
57 BEGIN_EVENT_TABLE( CFeatureFilterDlg, CDialog )
58 
59 ////@begin CFeatureFilterDlg event table entries
61 
63 
64 ////@end CFeatureFilterDlg event table entries
65 
67 
69 {
70  Init();
71 }
72 
73 CFeatureFilterDlg::CFeatureFilterDlg( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
74 {
75  Init();
76  Create(parent, id, caption, pos, size, style);
77 }
78 
79 bool CFeatureFilterDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
80 {
81 ////@begin CFeatureFilterDlg creation
82  SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY|wxWS_EX_BLOCK_EVENTS);
83  CDialog::Create( parent, id, caption, pos, size, style );
84 
86  if (GetSizer())
87  {
88  GetSizer()->SetSizeHints(this);
89  }
90  Centre();
91 ////@end CFeatureFilterDlg creation
92  return true;
93 }
94 
96 {
97 ////@begin CFeatureFilterDlg destruction
98 ////@end CFeatureFilterDlg destruction
99 }
100 
102 {
103 ////@begin CFeatureFilterDlg member initialisation
104  m_FromLocStr = wxEmptyString;
105  m_ToLocStr = wxEmptyString;
106  m_LengthLocStr = wxEmptyString;
108  m_TypesBox = NULL;
110 ////@end CFeatureFilterDlg member initialisation
111 }
112 
114 {
115 ////@begin CFeatureFilterDlg content construction
116  CFeatureFilterDlg* itemCDialog1 = this;
117 
118  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
119  itemCDialog1->SetSizer(itemBoxSizer2);
120 
121  m_ParamsPanel = new wxPanel( itemCDialog1, ID_PARAMS_PANEL, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxTAB_TRAVERSAL );
122  itemBoxSizer2->Add(m_ParamsPanel, 0, wxGROW|wxALL, 5);
123 
124  wxStaticBox* itemStaticBoxSizer4Static = new wxStaticBox(m_ParamsPanel, wxID_ANY, _("Select features to be shown"));
125  wxStaticBoxSizer* itemStaticBoxSizer4 = new wxStaticBoxSizer(itemStaticBoxSizer4Static, wxVERTICAL);
126  m_ParamsPanel->SetSizer(itemStaticBoxSizer4);
127 
128  wxFlexGridSizer* itemFlexGridSizer5 = new wxFlexGridSizer(0, 2, 0, 0);
129  itemFlexGridSizer5->AddGrowableCol(1);
130  itemStaticBoxSizer4->Add(itemFlexGridSizer5, 0, wxGROW|wxALL, 5);
131 
132  wxStaticText* itemStaticText6 = new wxStaticText( m_ParamsPanel, wxID_LABEL_TEXT, _("Label:"), wxDefaultPosition, wxDefaultSize, 0 );
133  itemFlexGridSizer5->Add(itemStaticText6, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
134 
135  wxTextCtrl* itemTextCtrl7 = new wxTextCtrl( m_ParamsPanel, ID_LABELTEXT, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
136  itemFlexGridSizer5->Add(itemTextCtrl7, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
137 
138  wxStaticText* itemStaticText8 = new wxStaticText( m_ParamsPanel, wxID_STATIC, _("Type: "), wxDefaultPosition, wxDefaultSize, 0 );
139  itemFlexGridSizer5->Add(itemStaticText8, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
140 
141  wxArrayString m_TypesBoxStrings;
142  m_TypesBox = new wxCheckListBox( m_ParamsPanel, ID_TYPELIST, wxDefaultPosition, wxDefaultSize, m_TypesBoxStrings, wxLB_SINGLE );
143  itemFlexGridSizer5->Add(m_TypesBox, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
144 
145  wxStaticText* itemStaticText10 = new wxStaticText( m_ParamsPanel, wxID_STATIC, _("From:"), wxDefaultPosition, wxDefaultSize, 0 );
146  itemFlexGridSizer5->Add(itemStaticText10, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
147 
148  wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxHORIZONTAL);
149  itemFlexGridSizer5->Add(itemBoxSizer11, 1, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
150 
151  wxTextCtrl* itemTextCtrl12 = new wxTextCtrl( m_ParamsPanel, ID_FROMINT, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
152  itemBoxSizer11->Add(itemTextCtrl12, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5);
153 
154  itemBoxSizer11->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
155 
156  wxStaticText* itemStaticText14 = new wxStaticText( m_ParamsPanel, wxID_STATIC, _("To:"), wxDefaultPosition, wxDefaultSize, 0 );
157  itemBoxSizer11->Add(itemStaticText14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
158 
159  wxTextCtrl* itemTextCtrl15 = new wxTextCtrl( m_ParamsPanel, ID_TOINT, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
160  itemBoxSizer11->Add(itemTextCtrl15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
161 
162  itemFlexGridSizer5->Add(5, 5, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
163 
164  wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL);
165  itemFlexGridSizer5->Add(itemBoxSizer17, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5);
166 
167  wxRadioButton* itemRadioButton18 = new wxRadioButton( m_ParamsPanel, ID_RADIOINTERSECT, _("Features intersecting the range"), wxDefaultPosition, wxDefaultSize, 0 );
168  itemRadioButton18->SetValue(false);
169  itemBoxSizer17->Add(itemRadioButton18, 0, wxALIGN_LEFT|wxALL, 5);
170 
171  wxRadioButton* itemRadioButton19 = new wxRadioButton( m_ParamsPanel, ID_RADIOINCLUDE, _("Features within the range only"), wxDefaultPosition, wxDefaultSize, 0 );
172  itemRadioButton19->SetValue(false);
173  itemBoxSizer17->Add(itemRadioButton19, 0, wxALIGN_LEFT|wxALL, 5);
174 
175  wxStaticText* itemStaticText20 = new wxStaticText( m_ParamsPanel, wxID_STATIC, _("Length:"), wxDefaultPosition, wxDefaultSize, 0 );
176  itemFlexGridSizer5->Add(itemStaticText20, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
177 
178  wxTextCtrl* itemTextCtrl21 = new wxTextCtrl( m_ParamsPanel, ID_TEXTCTRL3, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
179  itemFlexGridSizer5->Add(itemTextCtrl21, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
180 
181  wxStaticText* itemStaticText22 = new wxStaticText( m_ParamsPanel, wxID_STATIC, _("Product:"), wxDefaultPosition, wxDefaultSize, 0 );
182  itemFlexGridSizer5->Add(itemStaticText22, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
183 
184  wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxHORIZONTAL);
185  itemFlexGridSizer5->Add(itemBoxSizer23, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
186 
187  m_ProductCtrl = new wxTextCtrl( m_ParamsPanel, ID_PRODUCT_CTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
188  itemBoxSizer23->Add(m_ProductCtrl, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP|wxBOTTOM, 5);
189 
190  itemBoxSizer23->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
191 
192  wxCheckBox* itemCheckBox26 = new wxCheckBox( m_ParamsPanel, ID_NO_PRODUCT, _("No product"), wxDefaultPosition, wxDefaultSize, 0 );
193  itemCheckBox26->SetValue(false);
194  itemBoxSizer23->Add(itemCheckBox26, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
195 
196  wxCheckBox* itemCheckBox27 = new wxCheckBox( itemCDialog1, ID_CANCEL_CHECK, _("Cancel filtering"), wxDefaultPosition, wxDefaultSize, 0 );
197  itemCheckBox27->SetValue(false);
198  itemBoxSizer2->Add(itemCheckBox27, 0, wxALIGN_LEFT|wxALL, 5);
199 
200  wxStdDialogButtonSizer* itemStdDialogButtonSizer28 = new wxStdDialogButtonSizer;
201 
202  itemBoxSizer2->Add(itemStdDialogButtonSizer28, 0, wxALIGN_RIGHT|wxALL, 5);
203  wxButton* itemButton29 = new wxButton( itemCDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
204  itemStdDialogButtonSizer28->AddButton(itemButton29);
205 
206  wxButton* itemButton30 = new wxButton( itemCDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
207  itemStdDialogButtonSizer28->AddButton(itemButton30);
208 
209  itemStdDialogButtonSizer28->Realize();
210 
211  // Set validators
212  itemTextCtrl7->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Params.m_Label ) );
213  itemTextCtrl12->SetValidator( wxTextValidator(wxFILTER_NUMERIC, & m_FromLocStr) );
214  itemTextCtrl15->SetValidator( wxTextValidator(wxFILTER_NUMERIC, & m_ToLocStr) );
215  itemRadioButton18->SetValidator( wxGenericValidator(& m_Intersect) );
216  itemRadioButton19->SetValidator( wxGenericValidator( &m_Params.m_InclLoc ) );
217  itemTextCtrl21->SetValidator( wxTextValidator(wxFILTER_NUMERIC, & m_LengthLocStr) );
218  m_ProductCtrl->SetValidator( wxTextValidator( wxFILTER_NONE, &m_Params.m_Product ) );
219  itemCheckBox26->SetValidator( wxGenericValidator( &m_Params.m_NoProduct ) );
220  itemCheckBox27->SetValidator( wxGenericValidator(& m_Params.m_Disabled) );
221 ////@end CFeatureFilterDlg content construction
222 }
223 
225 {
229 
231 
232  for( size_t ix = 0; ix < m_Params.m_Types.GetCount(); ix++ ){
233  int type_ix = m_TypesBox->FindString( m_Params.m_Types[ix] );
234  if( type_ix !=wxNOT_FOUND ){
235  m_TypesBox->Check( type_ix );
236  }
237  }
238 
239  if( !CDialog::TransferDataToWindow() ){
240  return false;
241  }
242 
243  m_ProductCtrl->Enable( !m_Params.m_NoProduct );
244 
245  m_ParamsPanel->Enable( !m_Params.m_Disabled );
246 
247  return true;
248 }
249 
251 {
252  if( !CDialog::TransferDataFromWindow() ){
253  return false;
254  }
255 
259 
260  m_Params.m_Types.Empty();
261  for( unsigned int ix = 0; ix < m_TypesBox->GetCount(); ix++ ){
262  if( m_TypesBox->IsChecked( ix ) ){
263  m_Params.m_Types.Add( m_TypesBox->GetString( ix ) );
264  }
265  }
266 
267  return true;
268 }
269 
271 {
272  if( m_TypesBox ){
273  m_TypesBox->Set( types );
274  }
275 }
276 
277 
279 {
280  return true;
281 }
282 wxBitmap CFeatureFilterDlg::GetBitmapResource( const wxString& name )
283 {
284  // Bitmap retrieval
285 ////@begin CFeatureFilterDlg bitmap retrieval
286  wxUnusedVar(name);
287  return wxNullBitmap;
288 ////@end CFeatureFilterDlg bitmap retrieval
289 }
290 wxIcon CFeatureFilterDlg::GetIconResource( const wxString& name )
291 {
292  // Icon retrieval
293 ////@begin CFeatureFilterDlg icon retrieval
294  wxUnusedVar(name);
295  return wxNullIcon;
296 ////@end CFeatureFilterDlg icon retrieval
297 }
298 
299 void CFeatureFilterDlg::OnCancelFilteringClick( wxCommandEvent& event )
300 {
301  m_ParamsPanel->Enable( !event.IsChecked() );
302 }
303 
304 void CFeatureFilterDlg::OnNoProductClick( wxCommandEvent& event )
305 {
306  m_ProductCtrl->Enable( !event.IsChecked() );
307 }
308 
309 
311 
EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX, CAdjustFeaturesForGaps::OnKnownUnknownSelected) EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX1
CDialog.
Definition: dialog.hpp:47
wxCheckListBox * m_TypesBox
virtual bool TransferDataFromWindow()
void OnCancelFilteringClick(wxCommandEvent &event)
wxBitmap GetBitmapResource(const wxString &name)
void OnNoProductClick(wxCommandEvent &event)
void SetTypeNames(wxArrayString &types)
wxIcon GetIconResource(const wxString &name)
bool Create(wxWindow *parent, wxWindowID id=10000, const wxString &caption=_("Feature Filter"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
virtual bool TransferDataToWindow()
static bool ShowToolTips()
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#define ID_TOINT
#define ID_PRODUCT_CTRL
#define ID_PARAMS_PANEL
#define ID_TYPELIST
#define ID_CANCEL_CHECK
#define ID_NO_PRODUCT
#define ID_FROMINT
#define ID_RADIOINCLUDE
#define ID_RADIOINTERSECT
#define wxID_LABEL_TEXT
#define ID_LABELTEXT
#define NULL
Definition: ncbistd.hpp:225
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
static string LongToString(long value, TNumToStringFlags flags=0, int base=10)
Convert Int to string.
Definition: ncbistr.hpp:5141
#define ID_TEXTCTRL3
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
static static static wxID_ANY
wxArrayString m_Types
static const struct type types[]
Definition: type.c:22
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Fri Mar 01 10:04:30 2024 by modify_doxy.py rev. 669887