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

Go to the SVN repository for this file.

1 /* $Id: importfeature_panel.cpp 38194 2017-04-07 18:54:32Z 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 #include <ncbi_pch.hpp>
34 ////@begin includes
35 ////@end includes
36 
37 #include "importfeature_panel.hpp"
38 
41 
42 ////@begin XPM images
43 ////@end XPM images
44 
45 
46 /*!
47  * CImportFeaturePanel type definition
48  */
49 
50 IMPLEMENT_DYNAMIC_CLASS( CImportFeaturePanel, wxPanel )
51 
52 
53 /*!
54  * CImportFeaturePanel event table definition
55  */
56 
57 BEGIN_EVENT_TABLE( CImportFeaturePanel, wxPanel )
58 
59 ////@begin CImportFeaturePanel event table entries
61 
62 ////@end CImportFeaturePanel event table entries
63 
65 
66 
67 /*!
68  * CImportFeaturePanel constructors
69  */
70 
72 {
73  Init();
74 }
75 
76 CImportFeaturePanel::CImportFeaturePanel( wxWindow* parent, CSerialObject& object, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
77  : m_Object(&object)
78 {
79  m_Object = dynamic_cast<CSeq_feat*>(&object);
80  const CSeq_feat& seqfeat = dynamic_cast<const CSeq_feat&>(*m_Object);
81  m_EditedFeat.Reset((CSerialObject*)CSeq_feat::GetTypeInfo()->Create());
82  m_EditedFeat->Assign(seqfeat);
83  Init();
84  Create(parent, id, caption, pos, size, style);
85 }
86 
87 
88 /*!
89  * CImportFeatureSubPanel creator
90  */
91 
92 bool CImportFeaturePanel::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
93 {
94 ////@begin CImportFeaturePanel creation
95  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
96  wxPanel::Create( parent, id, pos, size, style );
97 
99  if (GetSizer())
100  {
101  GetSizer()->SetSizeHints(this);
102  }
103  Centre();
104 ////@end CImportFeaturePanel creation
105  return true;
106 }
107 
108 
109 /*!
110  * CImportFeaturePanel destructor
111  */
112 
114 {
115 ////@begin CImportFeaturePanel destruction
116 ////@end CImportFeaturePanel destruction
117 }
118 
119 
120 /*!
121  * Member initialisation
122  */
123 
125 {
126 ////@begin CImportFeaturePanel member initialisation
127  m_KeyCtrl = NULL;
128 ////@end CImportFeaturePanel member initialisation
129 }
130 
131 
132 /*!
133  * Control creation for CImportFeatureSubPanel
134  */
135 
137 {
138 ////@begin CImportFeaturePanel content construction
139  CImportFeaturePanel* itemPanel1 = this;
140 
141  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
142  itemPanel1->SetSizer(itemBoxSizer2);
143 
144  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
145  itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
146 
147  wxStaticText* itemStaticText4 = new wxStaticText( itemPanel1, wxID_STATIC, _("Key"), wxDefaultPosition, wxDefaultSize, 0 );
148  itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
149 
150  wxArrayString m_KeyCtrlStrings;
151  m_KeyCtrlStrings.Add(_("C_region"));
152  m_KeyCtrlStrings.Add(_("centromere"));
153  m_KeyCtrlStrings.Add(_("D-loop"));
154  m_KeyCtrlStrings.Add(_("D_segment"));
155  m_KeyCtrlStrings.Add(_("exon"));
156  m_KeyCtrlStrings.Add(_("iDNA"));
157  m_KeyCtrlStrings.Add(_("intron"));
158  m_KeyCtrlStrings.Add(_("J_segment"));
159  m_KeyCtrlStrings.Add(_("misc_binding"));
160  m_KeyCtrlStrings.Add(_("misc_difference"));
161  m_KeyCtrlStrings.Add(_("misc_feature"));
162  m_KeyCtrlStrings.Add(_("misc_recomb"));
163  m_KeyCtrlStrings.Add(_("misc_structure"));
164  m_KeyCtrlStrings.Add(_("mobile_element"));
165  m_KeyCtrlStrings.Add(_("modified_base"));
166  m_KeyCtrlStrings.Add(_("N_region"));
167  m_KeyCtrlStrings.Add(_("operon"));
168  m_KeyCtrlStrings.Add(_("oriT"));
169  m_KeyCtrlStrings.Add(_("polyA_site"));
170  m_KeyCtrlStrings.Add(_("prim_transcript"));
171  m_KeyCtrlStrings.Add(_("primer_bind"));
172  m_KeyCtrlStrings.Add(_("protein_bind"));
173  m_KeyCtrlStrings.Add(_("regulatory"));
174  m_KeyCtrlStrings.Add(_("repeat_region"));
175  m_KeyCtrlStrings.Add(_("rep_origin"));
176  m_KeyCtrlStrings.Add(_("S_region"));
177  m_KeyCtrlStrings.Add(_("stem_loop"));
178  m_KeyCtrlStrings.Add(_("telomere"));
179  m_KeyCtrlStrings.Add(_("unsure"));
180  m_KeyCtrlStrings.Add(_("V_region"));
181  m_KeyCtrlStrings.Add(_("V_segment"));
182  m_KeyCtrlStrings.Add(_("variation"));
183  m_KeyCtrlStrings.Add(_("3'clip"));
184  m_KeyCtrlStrings.Add(_("3'UTR"));
185  m_KeyCtrlStrings.Add(_("5'clip"));
186  m_KeyCtrlStrings.Add(_("5'UTR"));
187  m_KeyCtrl = new wxChoice( itemPanel1, ID_CHOICE3, wxDefaultPosition, wxDefaultSize, m_KeyCtrlStrings, 0 );
188  m_KeyCtrl->SetStringSelection(_("misc_feature"));
189  itemBoxSizer3->Add(m_KeyCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
190 
191  wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
192  itemBoxSizer2->Add(itemBoxSizer6, 1, wxGROW|wxALL, 0);
193 
194 ////@end CImportFeaturePanel content construction
195  CSeq_feat& edited_feat = dynamic_cast<CSeq_feat&>(*m_EditedFeat);
196 
197  if (edited_feat.GetData().GetImp().IsSetKey()) {
198  string key = edited_feat.GetData().GetImp().GetKey();
199  if (!NStr::IsBlank(key)) {
200  m_KeyCtrl->SetStringSelection(ToWxString(key));
201  }
202  }
203 
204  m_GBQualSizer = itemBoxSizer6;
205  m_GBQualPanel = new CGBQualPanel (itemPanel1, *m_Object);
206  m_GBQualSizer->Add(m_GBQualPanel, 1, wxGROW|wxALL, 0);
207 }
208 
209 
211 {
212  if (!wxPanel::TransferDataToWindow())
213  return false;
214 
216 }
217 
218 
220 {
221  CSeq_feat& edited_feat = dynamic_cast<CSeq_feat&>(*m_EditedFeat);
222  if (!wxPanel::TransferDataFromWindow())
223  return false;
224  wxString key = m_KeyCtrl->GetStringSelection ();
225  edited_feat.SetData().SetImp().SetKey(ToStdString(key));
226  m_GBQualPanel->PopulateGBQuals(edited_feat);
227  return true;
228 }
229 
230 
231 void CImportFeaturePanel::PopulateImpFeat(objects::CSeq_feat& seq_feat)
232 {
234  CSeq_feat& edited_feat = dynamic_cast<CSeq_feat&>(*m_EditedFeat);
235  seq_feat.SetData().SetImp().SetKey(edited_feat.GetData().GetImp().GetKey());
236  m_GBQualPanel->PopulateGBQuals(seq_feat);
237 }
238 
239 
240 /*!
241  * Should we show tooltips?
242  */
243 
245 {
246  return true;
247 }
248 
249 /*!
250  * Get bitmap resources
251  */
252 
253 wxBitmap CImportFeaturePanel::GetBitmapResource( const wxString& name )
254 {
255  // Bitmap retrieval
256 ////@begin CImportFeaturePanel bitmap retrieval
257  wxUnusedVar(name);
258  return wxNullBitmap;
259 ////@end CImportFeaturePanel bitmap retrieval
260 }
261 
262 /*!
263  * Get icon resources
264  */
265 
266 wxIcon CImportFeaturePanel::GetIconResource( const wxString& name )
267 {
268  // Icon retrieval
269 ////@begin CImportFeaturePanel icon retrieval
270  wxUnusedVar(name);
271  return wxNullIcon;
272 ////@end CImportFeaturePanel icon retrieval
273 }
274 
275 
276 /*!
277  * wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_CHOICE3
278  */
279 
280 void CImportFeaturePanel::OnChoice3Selected( wxCommandEvent& event )
281 {
283 
284  m_GBQualSizer->DeleteWindows();
285  m_GBQualPanel = new CGBQualPanel (this, *m_EditedFeat);
286  m_GBQualSizer->Add(m_GBQualPanel, 1, wxGROW|wxALL, 0);
287  m_GBQualSizer->Layout();
289 }
290 
291 
virtual bool TransferDataToWindow()
void PopulateGBQuals(objects::CSeq_feat &seq_feat)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void OnChoice3Selected(wxCommandEvent &event)
wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_CHOICE3
void Init()
Initialises member variables.
void PopulateImpFeat(objects::CSeq_feat &seq_feat)
void CreateControls()
Creates the controls and sizers.
static bool ShowToolTips()
Should we show tooltips?
CRef< CSerialObject > m_EditedFeat
bool Create(wxWindow *parent, wxWindowID id=ID_CIMPORTFEATURESUBPANEL, const wxString &caption=_("ImportFeature SubPanel"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
Creation.
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
CImportFeaturePanel()
Constructors.
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
Base class for all serializable objects.
Definition: serialbase.hpp:150
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#define NULL
Definition: ncbistd.hpp:225
#define ID_CHOICE3
Definition: diag_panel.hpp:68
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#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 IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
const TKey & GetKey(void) const
Get the Key member data.
Definition: Imp_feat_.hpp:259
bool IsSetKey(void) const
Check if a value has been assigned to Key data member.
Definition: Imp_feat_.hpp:247
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
const TImp & GetImp(void) const
Get the variant data.
USING_SCOPE(objects)
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Sun Apr 14 05:25:31 2024 by modify_doxy.py rev. 669887