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 32132 2015-01-06 17:46:58Z bollin $
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 
41 ////@begin XPM images
42 ////@end XPM images
43 
44 
46 
48 
49 /*!
50  * CFeatureTypePanel type definition
51  */
52 
53 IMPLEMENT_DYNAMIC_CLASS( CFeatureTypePanel, CFieldNamePanel )
54 
55 BEGIN_EVENT_TABLE( CFeatureTypePanel, CFieldNamePanel )
56 
57  EVT_LISTBOX( ID_LISTBOX1, CFeatureTypePanel::OnListbox1Selected )
58 
60 
61 
62 /*!
63  * CFeatureTypePanel constructors
64  */
65 
66 CFeatureTypePanel::CFeatureTypePanel()
67 {
68  Init();
69 }
70 
71 CFeatureTypePanel::CFeatureTypePanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
72 {
73  Init();
74  Create(parent, id, pos, size, style);
75 }
76 
77 
78 /*!
79  * CFeatureTypePanel creator
80  */
81 
82 bool CFeatureTypePanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
83 {
84 ////@begin CFeatureTypePanel creation
85  CFieldNamePanel::Create( parent, id, pos, size, style );
86 
88  if (GetSizer())
89  {
90  GetSizer()->SetSizeHints(this);
91  }
92  Centre();
93 ////@end CFeatureTypePanel creation
94  return true;
95 }
96 
97 
98 /*!
99  * CFeatureTypePanel destructor
100  */
101 
103 {
104 ////@begin CFeatureTypePanel destruction
105 ////@end CFeatureTypePanel destruction
106 }
107 
108 
109 /*!
110  * Member initialisation
111  */
112 
114 {
115 ////@begin CFeatureTypePanel member initialisation
116  m_List = NULL;
117 ////@end CFeatureTypePanel member initialisation
118 }
119 
120 
121 /*!
122  * Control creation for CFeatureTypePanel
123  */
124 
126 {
127 ////@begin CFeatureTypePanel content construction
128  CFeatureTypePanel* itemCFieldNamePanel1 = this;
129 
130  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
131  itemCFieldNamePanel1->SetSizer(itemBoxSizer2);
132 
133  wxArrayString m_ListStrings;
134  m_List = new wxListBox( itemCFieldNamePanel1, ID_LISTBOX1, wxDefaultPosition, wxSize(-1,109), m_ListStrings, wxLB_SINGLE );
135 #ifdef __WXGTK__
136  m_List->SetMinSize(wxSize(170,109));
137 #endif
138  itemBoxSizer2->Add(m_List, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
139 
140 ////@end CFeatureTypePanel content construction
141 }
142 
144 {
145  m_List->Insert(ToWxString("Any"), 0);
146 }
147 
149 {
150  set<string> existing;
151  map<pair<int,int>,string> types;
152  m_Featlist.clear();
153 
154  m_List->Freeze();
155  vector<const CFeatListItem *> featlist = GetSortedFeatList(entry, true);
156  ITERATE(vector<const CFeatListItem *>, feat_it, featlist) {
157  const CFeatListItem& item = **feat_it;
158  string desc = item.GetDescription();
159  int feat_type = item.GetType();
160  int feat_subtype = item.GetSubtype();
161  types[pair<int,int>(feat_type,feat_subtype)] = desc;
162  if (existing.find(desc) == existing.end()) {
163  existing.insert(desc);
164  m_Featlist.push_back(desc);
165  }
166  }
167 
168  m_List->Clear();
169  for (size_t i = 1; i < m_Featlist.size(); ++i) {
172  !CSeqFeatData::IsRegulatory(subtype)) {
173  m_List->Append(ToWxString(m_Featlist[i]));
174  }
175  }
176 #ifdef __WXMAC__
177  m_List->EnsureVisible(0);
178 #endif
179  m_Featlist.clear();
180  this->SetSizerAndFit(GetSizer());
181  m_List->Thaw();
182 }
183 
184 /*!
185  * Should we show tooltips?
186  */
187 
189 {
190  return true;
191 }
192 
193 /*!
194  * Get bitmap resources
195  */
196 
197 wxBitmap CFeatureTypePanel::GetBitmapResource( const wxString& name )
198 {
199  // Bitmap retrieval
200 ////@begin CFeatureTypePanel bitmap retrieval
201  wxUnusedVar(name);
202  return wxNullBitmap;
203 ////@end CFeatureTypePanel bitmap retrieval
204 }
205 
206 /*!
207  * Get icon resources
208  */
209 
210 wxIcon CFeatureTypePanel::GetIconResource( const wxString& name )
211 {
212  // Icon retrieval
213 ////@begin CFeatureTypePanel icon retrieval
214  wxUnusedVar(name);
215  return wxNullIcon;
216 ////@end CFeatureTypePanel icon retrieval
217 }
218 
219 
220 /*!
221  * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_LISTBOX1
222  */
223 
224 void CFeatureTypePanel::OnListbox1Selected( wxCommandEvent& event )
225 {
226  x_UpdateParent();
227  event.Skip();
228 }
229 
230 
231 string CFeatureTypePanel::GetFieldName(const bool subfield)
232 {
233  return ToStdString(m_List->GetStringSelection());
234 }
235 
236 
237 bool CFeatureTypePanel::SetFieldName(const string& field)
238 {
239  return m_List->SetStringSelection(ToWxString(field));
240 }
241 
243 
244 
void OnListbox1Selected(wxCommandEvent &event)
wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_LISTBOX1
int GetType() const
#define ID_LISTBOX1
static ESubtype SubtypeNameToValue(const string &sName)
Turn a string into its ESubtype which is NOT necessarily related to the identifier of the enum...
vector< string > m_Featlist
static bool IsRegulatory(ESubtype subtype)
END_EVENT_TABLE()
wxString ToWxString(const char *s)
Definition: wx_utils.hpp:156
USING_SCOPE(ncbi::objects)
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
void x_UpdateParent(void)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
~CFeatureTypePanel()
Destructor.
const_iterator find(const key_type &key) const
Definition: set.hpp:137
#define NULL
Definition: ncbistd.hpp:225
const_iterator end() const
Definition: set.hpp:136
void CreateControls()
Creates the controls and sizers.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:893
vector< const objects::CFeatListItem * > GetSortedFeatList(objects::CSeq_entry_Handle seh, bool for_removal)
int i
CFeatListItem - basic configuration data for one "feature" type.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
virtual string GetFieldName(const bool subfield=false)
Returns the name of the field as selected in the panel.
void ListPresentFeaturesFirst(const objects::CSeq_entry_Handle &entry)
static const struct type types[]
Definition: type.c:25
bool Create(wxWindow *parent, wxWindowID id=10179, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSIMPLE_BORDER|wxTAB_TRAVERSAL)
Creation.
int size
CSeq_entry_Handle –.
Definition: map.hpp:337
bool s_IsRarelyUsedOrDiscouragedFeatureType(int subtype)
static void Init(void)
Definition: cursor6.c:79
virtual bool SetFieldName(const string &field)
void Init()
Initialises member variables.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
CFeatureTypePanel()
Constructors.
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:144
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
int GetSubtype() const
static bool ShowToolTips()
Should we show tooltips?
string GetDescription() const
Modified on Sun May 01 16:33:29 2016 by modify_doxy.py rev. 426318