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

Go to the SVN repository for this file.

1 /* $Id: macro_choicetype_constraint_panel.cpp 46865 2021-11-15 20:54:03Z 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: Igor Filippov
27  *
28  * File Description:
29  *
30  */
31 #include <ncbi_pch.hpp>
35 
36 #include <wx/sizer.h>
37 #include <wx/stattext.h>
38 #include <wx/listbox.h>
39 #include <wx/icon.h>
40 
43 
44 /*
45  * CMacroChoiceTypePanel type definition
46  */
47 
49 
50 
51 /*
52  * CMacroChoiceTypePanel event table definition
53  */
54 
55 BEGIN_EVENT_TABLE( CMacroChoiceTypePanel, wxPanel )
56 
57 ////@begin CMacroChoiceTypePanel event table entries
58 ////@end CMacroChoiceTypePanel event table entries
59 
61 
62 
63 /*
64  * CMacroChoiceTypePanel constructors
65  */
66 
68 {
69  Init();
70 }
71 
72 CMacroChoiceTypePanel::CMacroChoiceTypePanel( wxWindow* parent, const string& target, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
73  : m_target(target)
74 {
75  Init();
76  Create( parent, id, pos, size, style );
77 }
78 
79 
80 /*
81  * CMacroChoiceTypePanel creator
82  */
83 
84 bool CMacroChoiceTypePanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
85 {
86 ////@begin CMacroChoiceTypePanel creation
87  wxPanel::Create( parent, id, pos, size, style );
88 
90  Centre();
91 ////@end CMacroChoiceTypePanel creation
92  return true;
93 }
94 
95 
96 /*
97  * CMacroChoiceTypePanel destructor
98  */
99 
101 {
102 ////@begin CMacroChoiceTypePanel destruction
103 ////@end CMacroChoiceTypePanel destruction
104 }
105 
106 
107 /*
108  * Member initialisation
109  */
110 
112 {
113 ////@begin CMacroChoiceTypePanel member initialisation
114  m_List = NULL;
115 ////@end CMacroChoiceTypePanel member initialisation
116 }
117 
118 
119 /*
120  * Control creation for CMacroChoiceTypePanel
121  */
122 
124 {
125 ////@begin CMacroChoiceTypePanel content construction
126  CMacroChoiceTypePanel* itemPanel2 = this;
127 
128  wxBoxSizer* itemBoxSizer1 = new wxBoxSizer(wxVERTICAL);
129  itemPanel2->SetSizer(itemBoxSizer1);
130 
131  wxStaticText* itemStaticText18 = new wxStaticText( itemPanel2, wxID_STATIC, _("Select only"), wxDefaultPosition, wxDefaultSize, 0 );
132  itemBoxSizer1->Add(itemStaticText18, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
133 
134  wxArrayString listStrings;
135  m_List = new wxListBox( itemPanel2, wxID_ANY, wxDefaultPosition, wxSize(-1,109), listStrings, wxLB_SINGLE );
136 #ifdef __WXGTK__
137  m_List->SetMinSize(wxSize(170,109));
138 #endif
139  x_PopulateList();
140  itemBoxSizer1->Add(m_List, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
141 
142 ////@end CMacroChoiceTypePanel content construction
143 }
144 
146 {
147  m_List->Clear();
148  if (m_target == macro::CMacroBioData::sm_SeqFeat) {
149  m_field = "\"data\"";
150  m_List->Append(_("gene"));
151  m_List->Append(_("org"));
152  m_List->Append(_("cdregion"));
153  m_List->Append(_("prot"));
154  m_List->Append(_("rna"));
155  m_List->Append(_("pub")); ///< publication applies to this seq
156  m_List->Append(_("seq")); ///< to annotate origin from another seq
157  m_List->Append(_("imp"));
158  m_List->Append(_("region")); ///< named region (globin locus)
159  m_List->Append(_("comment")); ///< just a comment
160  m_List->Append(_("bond"));
161  m_List->Append(_("site"));
162  m_List->Append(_("rsite")); ///< restriction site (for maps really)
163  m_List->Append(_("user")); ///< user defined structure
164  m_List->Append(_("txinit")); ///< transcription initiation
165  m_List->Append(_("num")); ///< a numbering system
166  m_List->Append(_("psec-str"));
167  m_List->Append(_("non-std-residue")); ///< non-standard residue here in seq
168  m_List->Append(_("het")); ///< cofactor, prosthetic grp, etc, bound to seq
169  m_List->Append(_("biosrc"));
170  m_List->Append(_("clone"));
171  m_List->Append(_("variation"));
172  }
173 
174  if (m_target == macro::CMacroBioData::sm_Seqdesc) {
175  m_field = "";
176  for (int i = CSeqdesc::e_not_set+1; i != CSeqdesc::e_MaxChoice; ++i) {
177  m_List->Append(wxString(CSeqdesc::SelectionName(static_cast<CSeqdesc::E_Choice>(i))));
178  }
179  }
180 
181  if (m_target == macro::CMacroBioData::sm_UserObject) {
182  m_field = "\"type\"";
183  m_List->Append(_("str"));
184  }
185 
186  if (m_target == macro::CMacroBioData::sm_ImpFeat) {
187  m_field = "data.imp.key";
190  m_List->Append(wxString(CSeqFeatData::SubtypeValueToName(static_cast<CSeqFeatData::ESubtype>(i))));
191  }
192  }
193  }
194 
195  if (m_target == macro::CMacroBioData::sm_RNA) {
196  m_field = "data.rna.type";
197  CEnumeratedTypeValues::TValues type_values = CRNA_ref::ENUM_METHOD_NAME(EType)()->GetValues();
198  for (CEnumeratedTypeValues::TValues::const_iterator i = type_values.begin(); i != type_values.end(); ++i) {
199  m_List->Append(wxString(i->first));
200  }
201  }
202 
203  if (m_target == macro::CMacroBioData::sm_SeqSet) {
204  m_field = "class ";
205  CEnumeratedTypeValues::TValues type_values = CBioseq_set::ENUM_METHOD_NAME(EClass)()->GetValues();
206  for (CEnumeratedTypeValues::TValues::const_iterator i = type_values.begin(); i != type_values.end(); ++i) {
207  m_List->Append(wxString(i->first));
208  }
209  }
210 }
211 
212 /*
213  * Should we show tooltips?
214  */
215 
217 {
218  return true;
219 }
220 
221 /*
222  * Get bitmap resources
223  */
224 
225 wxBitmap CMacroChoiceTypePanel::GetBitmapResource( const wxString& name )
226 {
227  // Bitmap retrieval
228 ////@begin CMacroChoiceTypePanel bitmap retrieval
229  wxUnusedVar(name);
230  return wxNullBitmap;
231 ////@end CMacroChoiceTypePanel bitmap retrieval
232 }
233 
234 /*
235  * Get icon resources
236  */
237 
238 wxIcon CMacroChoiceTypePanel::GetIconResource( const wxString& name )
239 {
240  // Icon retrieval
241 ////@begin CMacroChoiceTypePanel icon retrieval
242  wxUnusedVar(name);
243  return wxNullIcon;
244 ////@end CMacroChoiceTypePanel icon retrieval
245 }
246 
247 
248 
249 pair<string,string> CMacroChoiceTypePanel::GetMatcher(const pair<string, string> &target, size_t num)
250 {
251  string choice = m_List->GetStringSelection().ToStdString();
252  return make_pair(GetDescription(choice), GetLocationConstraint(choice));
253 }
254 
256 {
257  string str;
258  if (!choice.empty()) {
259  if (m_target == macro::CMacroBioData::sm_ImpFeat ||
260  m_target == macro::CMacroBioData::sm_RNA ||
261  m_target == macro::CMacroBioData::sm_SeqSet) {
262  str = m_field + " = \"" + choice + "\"";
263  }
264  else {
265  str = "CHOICETYPE(" + m_field + ") = \"" + choice + "\"";
266  }
267  }
268 
269  return str;
270 }
271 
272 string CMacroChoiceTypePanel::GetDescription(const string& choice) const
273 {
274  string str;
275  if (!choice.empty()) {
276  if (m_target == macro::CMacroBioData::sm_SeqFeat)
277  str = "Feature ";
278  if (m_target == macro::CMacroBioData::sm_Seqdesc)
279  str = "Descriptor ";
280  if (m_target == macro::CMacroBioData::sm_UserObject)
281  str = "User object ";
282  if (m_target == macro::CMacroBioData::sm_ImpFeat ||
283  m_target == macro::CMacroBioData::sm_RNA ||
284  m_target == macro::CMacroBioData::sm_SeqSet) {
285  str = m_target + " ";
286  }
287  str += "is of the type " + choice;
288  }
289  return str;
290 }
291 
292 
static bool ShowToolTips()
Should we show tooltips?
string GetDescription(const string &feat) const
void CreateControls()
Creates the controls and sizers.
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
string GetLocationConstraint(const string &feat)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void Init()
Initialises member variables.
virtual pair< string, string > GetMatcher(const pair< string, string > &target, size_t num)
static E_Choice GetTypeFromSubtype(ESubtype subtype)
@ eSubtype_bad
These no longer need to match the FEATDEF values in the C toolkit's objfdef.h.
static CTempString SubtypeValueToName(ESubtype eSubtype)
Turns a ESubtype into its string value which is NOT necessarily related to the identifier of the enum...
#define _(proto)
Definition: ct_nlmzip_i.h:78
IMPLEMENT_CLASS(CFloatingFrame, CFloatingFrameBaseClass) const static long kFloatFrameStyle
CFloatingFrame.
static void Init(void)
Definition: cursor6.c:76
static const char * str(char *buf, int n)
Definition: stats.c:84
#define NULL
Definition: ncbistd.hpp:225
list< pair< string, TEnumValueType > > TValues
Definition: enumvalues.hpp:54
#define ENUM_METHOD_NAME(EnumName)
Definition: serialbase.hpp:994
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
E_Choice
Choice variants.
Definition: Seqdesc_.hpp:109
static string SelectionName(E_Choice index)
Retrieve selection name (for diagnostic purposes).
Definition: Seqdesc_.cpp:218
@ e_MaxChoice
== e_Modelev+1
Definition: Seqdesc_.hpp:139
@ e_not_set
No variant selected.
Definition: Seqdesc_.hpp:110
END_EVENT_TABLE()
int i
USING_SCOPE(objects)
const struct ncbi::grid::netcache::search::fields::SIZE size
static static static wxID_ANY
Modified on Wed Apr 17 13:08:20 2024 by modify_doxy.py rev. 669887