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

Go to the SVN repository for this file.

1 /* $Id: feature_type_panel.cpp 44427 2019-12-17 17:31:30Z asztalos $
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: Colleen Bollin
27  */
28 
29 
30 // Generated by DialogBlocks (unregistered), 12/06/2013 08:31:07
31 
32 #include <ncbi_pch.hpp>
33 #include <gui/objutils/utils.hpp>
36 
39 #include <wx/sizer.h>
40 #include <wx/toplevel.h>
41 
42 ////@begin XPM images
43 ////@end XPM images
44 
45 
47 
49 
50 /*!
51  * CFeatureTypePanel type definition
52  */
53 
54 IMPLEMENT_DYNAMIC_CLASS( CFeatureTypePanel, CFieldNamePanel )
55 
56 BEGIN_EVENT_TABLE( CFeatureTypePanel, CFieldNamePanel )
57 
59 
61 
62 
63 /*!
64  * CFeatureTypePanel constructors
65  */
66 
68 {
69  Init();
70 }
71 
72 CFeatureTypePanel::CFeatureTypePanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
73 {
74  Init();
75  Create(parent, id, pos, size, style);
76 }
77 
78 
79 /*!
80  * CFeatureTypePanel creator
81  */
82 
83 bool CFeatureTypePanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
84 {
85 ////@begin CFeatureTypePanel creation
86  CFieldNamePanel::Create( parent, id, pos, size, style );
87 
89  if (GetSizer())
90  {
91  GetSizer()->SetSizeHints(this);
92  }
93  Centre();
94 ////@end CFeatureTypePanel creation
95  return true;
96 }
97 
98 
99 /*!
100  * CFeatureTypePanel destructor
101  */
102 
104 {
105 ////@begin CFeatureTypePanel destruction
106 ////@end CFeatureTypePanel destruction
107 }
108 
109 
110 /*!
111  * Member initialisation
112  */
113 
115 {
116 ////@begin CFeatureTypePanel member initialisation
117  m_List = NULL;
118 ////@end CFeatureTypePanel member initialisation
119  m_list_all_feats = false;
120  m_show_legal_only = false;
121 }
122 
123 
124 /*!
125  * Control creation for CFeatureTypePanel
126  */
127 
129 {
130 ////@begin CFeatureTypePanel content construction
131  CFeatureTypePanel* itemCFieldNamePanel1 = this;
132 
133  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
134  itemCFieldNamePanel1->SetSizer(itemBoxSizer2);
135 
136  wxArrayString m_ListStrings;
137  m_List = new wxListBox( itemCFieldNamePanel1, ID_LISTBOX1, wxDefaultPosition, wxSize(128,109), m_ListStrings, wxLB_SINGLE );
138 #ifdef __WXGTK__
139  m_List->SetMinSize(wxSize(170,109));
140 #endif
141  itemBoxSizer2->Add(m_List, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
142 
143 ////@end CFeatureTypePanel content construction
144 }
145 
147 {
148  m_List->Insert(ToWxString("Any"), 0);
149 }
150 
152 {
153  m_List->Insert(ToWxString("All"), 0);
154 }
155 
157 {
158  m_List->SetSelection(wxNOT_FOUND);
159  m_List->SetFirstItem(0);
160 }
161 
162 
163 void CFeatureTypePanel::ListPresentFeaturesFirst(const CSeq_entry_Handle& entry, vector<const CFeatListItem *> *pfeatlist)
164 {
165  set<string> existing;
166  map<pair<int,int>,string> types;
167  m_Featlist.clear();
168 
169  m_List->Freeze();
170  vector<const CFeatListItem *> featlist;
171  if (!pfeatlist)
172  {
173  featlist = GetSortedFeatList(entry);
174  pfeatlist = &featlist;
175  }
176  ITERATE(vector<const CFeatListItem *>, feat_it, *pfeatlist) {
177  const CFeatListItem& item = **feat_it;
178  string desc = item.GetDescription();
179  int feat_type = item.GetType();
180  int feat_subtype = item.GetSubtype();
181  types[pair<int,int>(feat_type,feat_subtype)] = desc;
182  if (existing.find(desc) == existing.end()) {
183  existing.insert(desc);
184  m_Featlist.push_back(desc);
185  }
186  }
187 
188  m_List->Clear();
189  for (size_t i = 1; i < m_Featlist.size(); ++i) {
191  bool legal = !m_show_legal_only || !CSeqFeatData::GetLegalQualifiers(subtype).empty();
192  if ((!s_IsRarelyUsedOrDiscouragedFeatureType(subtype) && !CSeqFeatData::IsRegulatory(subtype) && legal)
193  || m_list_all_feats) {
194  m_List->Append(ToWxString(m_Featlist[i]));
195  }
196  }
197 #ifdef __WXMAC__
198  m_List->EnsureVisible(0);
199 #endif
200  m_Featlist.clear();
201  GetSizer()->SetSizeHints(this);
202  m_List->Thaw();
203 }
204 
205 /*!
206  * Should we show tooltips?
207  */
208 
210 {
211  return true;
212 }
213 
214 /*!
215  * Get bitmap resources
216  */
217 
218 wxBitmap CFeatureTypePanel::GetBitmapResource( const wxString& name )
219 {
220  // Bitmap retrieval
221 ////@begin CFeatureTypePanel bitmap retrieval
222  wxUnusedVar(name);
223  return wxNullBitmap;
224 ////@end CFeatureTypePanel bitmap retrieval
225 }
226 
227 /*!
228  * Get icon resources
229  */
230 
231 wxIcon CFeatureTypePanel::GetIconResource( const wxString& name )
232 {
233  // Icon retrieval
234 ////@begin CFeatureTypePanel icon retrieval
235  wxUnusedVar(name);
236  return wxNullIcon;
237 ////@end CFeatureTypePanel icon retrieval
238 }
239 
240 
241 /*!
242  * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_LISTBOX1
243  */
244 
245 void CFeatureTypePanel::OnListbox1Selected( wxCommandEvent& event )
246 {
247  x_UpdateParent();
248  event.Skip();
249 }
250 
251 
252 string CFeatureTypePanel::GetFieldName(const bool subfield)
253 {
254  return ToStdString(m_List->GetStringSelection());
255 }
256 
257 
258 bool CFeatureTypePanel::SetFieldName(const string& field)
259 {
260  string feature = field;
261  if (NStr::EqualNocase(feature, "cdregion")) {
262  feature = "CDS";
263  }
264  if (NStr::EqualNocase(feature, "miscRNA")) {
265  feature = "misc_RNA";
266  }
267  bool res = m_List->SetStringSelection(ToWxString(feature));
268  int sel = m_List->GetSelection();
269  if (sel == wxNOT_FOUND)
270  sel = 0;
271  m_List->SetFirstItem(sel);
272  return res;
273 }
274 
276 {
277  m_show_legal_only = show;
278 }
279 
281 {
282  if (subtype == CSeqFeatData::eSubtype_bad
283  || subtype == CSeqFeatData::eSubtype_conflict
286  || subtype == CSeqFeatData::eSubtype_STS
287  || subtype == CSeqFeatData::eSubtype_unsure
288  || subtype == CSeqFeatData::eSubtype_allele
290  || subtype == CSeqFeatData::eSubtype_biosrc
291  || subtype == CSeqFeatData::eSubtype_bond
292  || subtype == CSeqFeatData::eSubtype_clone
293  || subtype == CSeqFeatData::eSubtype_gap
294  || subtype == CSeqFeatData::eSubtype_het
295  || subtype == CSeqFeatData::eSubtype_imp
297  || subtype == CSeqFeatData::eSubtype_mutation
299  || subtype == CSeqFeatData::eSubtype_num
300  || subtype == CSeqFeatData::eSubtype_org
301  || subtype == CSeqFeatData::eSubtype_pub
304  || subtype == CSeqFeatData::eSubtype_seq
308  || subtype == CSeqFeatData::eSubtype_virion) {
309  return true;
310  }
311  else {
312  return false;
313  }
314 }
315 
317 
318 
CFeatListItem - basic configuration data for one "feature" type.
int GetSubtype() const
string GetDescription() const
int GetType() const
static bool ShowToolTips()
Should we show tooltips?
virtual bool SetFieldName(const string &field)
void OnListbox1Selected(wxCommandEvent &event)
wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_LISTBOX1
virtual void ClearValues(void)
~CFeatureTypePanel()
Destructor.
bool Create(wxWindow *parent, wxWindowID id=10179, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSIMPLE_BORDER|wxTAB_TRAVERSAL)
Creation.
vector< string > m_Featlist
virtual string GetFieldName(const bool subfield=false)
Returns the name of the field as selected in the panel.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void Init()
Initialises member variables.
CFeatureTypePanel()
Constructors.
static bool s_IsRarelyUsedOrDiscouragedFeatureType(int subtype)
void CreateControls()
Creates the controls and sizers.
virtual void SetShowLegalOnly(bool show)
void ListPresentFeaturesFirst(const objects::CSeq_entry_Handle &entry, vector< const objects::CFeatListItem * > *featlist=nullptr)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void x_UpdateParent(void)
const TLegalQualifiers & GetLegalQualifiers(void) const
Get a list of all the legal qualifiers for the feature.
@ eSubtype_transit_peptide
@ eSubtype_bad
These no longer need to match the FEATDEF values in the C toolkit's objfdef.h.
@ eSubtype_prim_transcript
@ eSubtype_non_std_residue
static ESubtype SubtypeNameToValue(CTempString sName)
Turn a string into its ESubtype which is NOT necessarily related to the identifier of the enum.
static bool IsRegulatory(ESubtype subtype)
CSeq_entry_Handle –.
Definition: map.hpp:338
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
USING_SCOPE(ncbi::objects)
#define ID_LISTBOX1
static void Init(void)
Definition: cursor6.c:76
static const struct type types[]
Definition: type.c:22
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
vector< const objects::CFeatListItem * > GetSortedFeatList(objects::CSeq_entry_Handle seh, size_t max=numeric_limits< size_t >::max())
#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 bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
Definition: ncbistr.hpp:5353
END_EVENT_TABLE()
int i
const struct ncbi::grid::netcache::search::fields::SIZE size
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Wed Apr 17 13:08:10 2024 by modify_doxy.py rev. 669887