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

Go to the SVN repository for this file.

1 /* $Id: ref_gene_tracking_panel.cpp 40132 2017-12-22 15:45:12Z 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>
31 ////@begin includes
32 ////@end includes
33 
37 
38 #include <wx/stattext.h>
39 
40 ////@begin XPM images
41 ////@end XPM images
42 
45 
46 /*!
47  * CRefGeneTrackingPanel type definition
48  */
49 
50 IMPLEMENT_DYNAMIC_CLASS( CRefGeneTrackingPanel, wxPanel )
51 
52 
53 /*!
54  * CRefGeneTrackingPanel event table definition
55  */
56 
57 BEGIN_EVENT_TABLE( CRefGeneTrackingPanel, wxPanel )
58 
59 ////@begin CRefGeneTrackingPanel event table entries
61 
62 ////@end CRefGeneTrackingPanel event table entries
63 
65 
66 
67 /*!
68  * CRefGeneTrackingPanel constructors
69  */
70 
72 {
73  Init();
74 }
75 
76 CRefGeneTrackingPanel::CRefGeneTrackingPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
77 {
78  Init();
79  Create(parent, id, pos, size, style);
80 }
81 
82 
83 /*!
84  * CRefGeneTrackingPanel creator
85  */
86 
87 bool CRefGeneTrackingPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
88 {
89 ////@begin CRefGeneTrackingPanel creation
90  wxPanel::Create( parent, id, pos, size, style );
91 
93  if (GetSizer())
94  {
95  GetSizer()->SetSizeHints(this);
96  }
97  Centre();
98 ////@end CRefGeneTrackingPanel creation
99  return true;
100 }
101 
102 
103 /*!
104  * CRefGeneTrackingPanel destructor
105  */
106 
108 {
109 ////@begin CRefGeneTrackingPanel destruction
110 ////@end CRefGeneTrackingPanel destruction
111 }
112 
113 
114 /*!
115  * Member initialisation
116  */
117 
119 {
120 ////@begin CRefGeneTrackingPanel member initialisation
127  m_ModelBtn = NULL;
128  m_WgsBtn = NULL;
131  m_CuratorTxt = NULL;
133  m_URLTxt = NULL;
135 ////@end CRefGeneTrackingPanel member initialisation
136  m_User.Reset(NULL);
137 }
138 
139 
140 /*!
141  * Control creation for CRefGeneTrackingPanel
142  */
143 
145 {
146 ////@begin CRefGeneTrackingPanel content construction
147  CRefGeneTrackingPanel* itemPanel1 = this;
148 
149  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
150  itemPanel1->SetSizer(itemBoxSizer2);
151 
152  m_StatusSizer = new wxBoxSizer(wxHORIZONTAL);
153  itemBoxSizer2->Add(m_StatusSizer, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
154 
155  m_InferredBtn = new wxRadioButton( itemPanel1, ID_RADIOBUTTON, _("Inferred"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
156  m_InferredBtn->SetValue(false);
157  m_StatusSizer->Add(m_InferredBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
158 
159  m_PredictedBtn = new wxRadioButton( itemPanel1, ID_RADIOBUTTON1, _("Predicted"), wxDefaultPosition, wxDefaultSize, 0 );
160  m_PredictedBtn->SetValue(false);
161  m_StatusSizer->Add(m_PredictedBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
162 
163  m_ProvisionalBtn = new wxRadioButton( itemPanel1, ID_RADIOBUTTON2, _("Provisional"), wxDefaultPosition, wxDefaultSize, 0 );
164  m_ProvisionalBtn->SetValue(false);
165  m_StatusSizer->Add(m_ProvisionalBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
166 
167  m_ValidatedBtn = new wxRadioButton( itemPanel1, ID_RADIOBUTTON3, _("Validated"), wxDefaultPosition, wxDefaultSize, 0 );
168  m_ValidatedBtn->SetValue(false);
169  m_StatusSizer->Add(m_ValidatedBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
170 
171  m_ReviewedBtn = new wxRadioButton( itemPanel1, ID_RADIOBUTTON4, _("Reviewed"), wxDefaultPosition, wxDefaultSize, 0 );
172  m_ReviewedBtn->SetValue(false);
173  m_StatusSizer->Add(m_ReviewedBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
174 
175  m_ModelBtn = new wxRadioButton( itemPanel1, ID_RADIOBUTTON5, _("Model"), wxDefaultPosition, wxDefaultSize, 0 );
176  m_ModelBtn->SetValue(false);
177  m_StatusSizer->Add(m_ModelBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
178 
179  m_WgsBtn = new wxRadioButton( itemPanel1, ID_RADIOBUTTON6, _("WGS"), wxDefaultPosition, wxDefaultSize, 0 );
180  m_WgsBtn->SetValue(false);
181  m_StatusSizer->Add(m_WgsBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
182 
183  m_PipelineBtn = new wxRadioButton( itemPanel1, ID_RADIOBUTTON7, _("Pipeline"), wxDefaultPosition, wxDefaultSize, 0 );
184  m_PipelineBtn->SetValue(false);
185  m_PipelineBtn->Enable(false);
186  m_StatusSizer->Add(m_PipelineBtn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
187 
188  wxFlexGridSizer* itemFlexGridSizer12 = new wxFlexGridSizer(2, 5, 0, 0);
189  itemBoxSizer2->Add(itemFlexGridSizer12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
190 
191  m_GeneratedBtn = new wxCheckBox( itemPanel1, ID_CHECKBOX16, _("Generated"), wxDefaultPosition, wxDefaultSize, 0 );
192  m_GeneratedBtn->SetValue(false);
193  itemFlexGridSizer12->Add(m_GeneratedBtn, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
194 
195  wxStaticText* itemStaticText14 = new wxStaticText( itemPanel1, wxID_STATIC, _("Curator"), wxDefaultPosition, wxDefaultSize, 0 );
196  itemFlexGridSizer12->Add(itemStaticText14, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
197 
198  m_CuratorTxt = new wxTextCtrl( itemPanel1, ID_TEXTCTRL4, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
199  itemFlexGridSizer12->Add(m_CuratorTxt, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
200 
201  wxStaticText* itemStaticText16 = new wxStaticText( itemPanel1, wxID_STATIC, _("Genomic Source"), wxDefaultPosition, wxDefaultSize, 0 );
202  itemFlexGridSizer12->Add(itemStaticText16, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
203 
204  m_GenomicSourceTxt = new wxTextCtrl( itemPanel1, ID_TEXTCTRL9, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
205  itemFlexGridSizer12->Add(m_GenomicSourceTxt, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
206 
207  itemFlexGridSizer12->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
208 
209  wxStaticText* itemStaticText19 = new wxStaticText( itemPanel1, wxID_STATIC, _("URL"), wxDefaultPosition, wxDefaultSize, 0 );
210  itemFlexGridSizer12->Add(itemStaticText19, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
211 
212  m_URLTxt = new wxTextCtrl( itemPanel1, ID_TEXTCTRL21, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
213  itemFlexGridSizer12->Add(m_URLTxt, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
214 
215  m_AccessionsPanel = new CRefGeneTrackLocListPanel( itemPanel1, ID_FOREIGN, wxDefaultPosition, wxSize(100, 100), wxSIMPLE_BORDER );
216  itemBoxSizer2->Add(m_AccessionsPanel, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
217 
218 ////@end CRefGeneTrackingPanel content construction
219 }
220 
221 
222 /*!
223  * Should we show tooltips?
224  */
225 
227 {
228  return true;
229 }
230 
231 /*!
232  * Get bitmap resources
233  */
234 
235 wxBitmap CRefGeneTrackingPanel::GetBitmapResource( const wxString& name )
236 {
237  // Bitmap retrieval
238 ////@begin CRefGeneTrackingPanel bitmap retrieval
239  wxUnusedVar(name);
240  return wxNullBitmap;
241 ////@end CRefGeneTrackingPanel bitmap retrieval
242 }
243 
244 /*!
245  * Get icon resources
246  */
247 
248 wxIcon CRefGeneTrackingPanel::GetIconResource( const wxString& name )
249 {
250  // Icon retrieval
251 ////@begin CRefGeneTrackingPanel icon retrieval
252  wxUnusedVar(name);
253  return wxNullIcon;
254 ////@end CRefGeneTrackingPanel icon retrieval
255 }
256 
257 
258 void CRefGeneTrackingPanel::x_SetStatus(const string& val)
259 {
260  size_t status_items = m_StatusSizer->GetItemCount();
261  for (size_t pos = 0; pos < status_items; pos++) {
262  wxRadioButton *but = dynamic_cast<wxRadioButton*>(m_StatusSizer->GetItem(pos)->GetWindow());
263  if (but) {
264  if (NStr::EqualNocase(ToStdString(but->GetLabel()), val)) {
265  but->SetValue(true);
266  } else {
267  but->SetValue(false);
268  }
269  }
270  }
271  if (NStr::EqualNocase(val, "Pipeline")) {
272  m_PipelineBtn->Enable(true);
273  } else {
274  m_PipelineBtn->Enable(false);
275  }
276 }
277 
278 
280 {
281  string status = "";
282  size_t status_items = m_StatusSizer->GetItemCount();
283  for (size_t pos = 0; pos < status_items; pos++) {
284  wxRadioButton *but = dynamic_cast<wxRadioButton*>(m_StatusSizer->GetItem(pos)->GetWindow());
285  if (but && but->GetValue()) {
286  status = ToStdString(but->GetLabel());
287  break;
288  }
289  }
290  return status;
291 }
292 
293 
294 static const string kStatus = "Status";
295 static const string kGenomicSource = "GenomicSource";
296 static const string kGenerated = "Generated";
297 static const string kCollaborator = "Collaborator";
298 static const string kURL = "CollaboratorURL";
299 
301 {
302  if (user) {
303  m_User.Reset(new CUser_object());
304  m_User->Assign(*user);
305  } else {
306  m_User.Reset(NULL);
307  }
308  string status = "";
309  string genomic_source = "";
310  string collaborator = "";
311  string url = "";
312  bool generated = false;
313 
314  if (m_User) {
315  // search for fields in user object
316  ITERATE(CUser_object::TData, it, m_User->GetData()) {
317  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr()) {
318  if (NStr::EqualNocase((*it)->GetLabel().GetStr(), kStatus)) {
319  if ((*it)->IsSetData() && (*it)->GetData().IsStr()) {
320  status = (*it)->GetData().GetStr();
321  }
322  } else if (NStr::EqualNocase((*it)->GetLabel().GetStr(), kGenomicSource)) {
323  if ((*it)->IsSetData() && (*it)->GetData().IsStr()) {
324  genomic_source = (*it)->GetData().GetStr();
325  }
326  } else if (NStr::EqualNocase((*it)->GetLabel().GetStr(), kGenerated)) {
327  if ((*it)->IsSetData() && (*it)->GetData().IsBool() && (*it)->GetData().GetBool()) {
328  generated = true;
329  }
330  } else if (NStr::EqualNocase((*it)->GetLabel().GetStr(), kCollaborator)) {
331  if ((*it)->IsSetData() && (*it)->GetData().IsStr()) {
332  collaborator = (*it)->GetData().GetStr();
333  }
334  } else if (NStr::EqualNocase((*it)->GetLabel().GetStr(), kURL)) {
335  if ((*it)->IsSetData() && (*it)->GetData().IsStr()) {
336  url = (*it)->GetData().GetStr();
337  }
338  }
339  }
340  }
341  }
342  x_SetStatus (status);
343  m_GenomicSourceTxt->SetValue(ToWxString(genomic_source));
344  m_CuratorTxt->SetValue(ToWxString(collaborator));
345  m_URLTxt->SetValue(ToWxString(url));
346  m_GeneratedBtn->SetValue(generated);
348 }
349 
350 
352 {
353  if (NStr::EqualNocase(field, kStatus)
355  || NStr::EqualNocase(field, kGenerated)
357  || NStr::EqualNocase(field, kURL)){
358  return true;
359  }
360  return false;
361 }
362 
363 
365 {
366  TransferDataFromWindow();
367  CRef<CUser_object> user(new CUser_object());
368 
369  if (m_User) {
370  user->Assign(*m_User);
371  } else {
372  user->SetType().SetStr("RefGeneTracking");
373  }
374 
375  // remove previous fields
376  if (user->IsSetData()) {
377  CUser_object::TData::iterator it = user->SetData().begin();
378  while (it != user->SetData().end()) {
379  if ((*it)->IsSetLabel() && (*it)->GetLabel().IsStr() && x_IsControlledField((*it)->GetLabel().GetStr())) {
380  it = user->SetData().erase(it);
381  } else {
382  ++it;
383  }
384  }
385  }
386  string status = x_GetStatus();
387  if (!NStr::IsBlank(status)) {
388  CRef<CUser_field> new_field(new CUser_field());
389  new_field->SetLabel().SetStr(kStatus);
390  new_field->SetData().SetStr(status);
391  user->SetData().push_back(new_field);
392  }
393  string genomic_source = ToStdString(m_GenomicSourceTxt->GetValue());
394  if (!NStr::IsBlank(genomic_source)) {
395  CRef<CUser_field> new_field(new CUser_field());
396  new_field->SetLabel().SetStr(kGenomicSource);
397  new_field->SetData().SetStr(genomic_source);
398  user->SetData().push_back(new_field);
399  }
400 
401  bool generated = m_GeneratedBtn->GetValue();
402  if (generated) {
403  CRef<CUser_field> new_field(new CUser_field());
404  new_field->SetLabel().SetStr(kGenerated);
405  new_field->SetData().SetBool(true);
406  user->SetData().push_back(new_field);
407  }
408  string collaborator = ToStdString(m_CuratorTxt->GetValue());
409  if (!NStr::IsBlank(collaborator)) {
410  CRef<CUser_field> new_field(new CUser_field());
411  new_field->SetLabel().SetStr(kCollaborator);
412  new_field->SetData().SetStr(collaborator);
413  user->SetData().push_back(new_field);
414  }
415  string url = ToStdString(m_URLTxt->GetValue());
416  if (!NStr::IsBlank(url)) {
417  CRef<CUser_field> new_field(new CUser_field());
418  new_field->SetLabel().SetStr(kURL);
419  new_field->SetData().SetStr(url);
420  user->SetData().push_back(new_field);
421  }
422 
425  return user;
426 }
427 
428 
429 void CRefGeneTrackingPanel::ChangeSeqdesc(const objects::CSeqdesc& desc)
430 {
432  tmp->Assign(desc.GetUser());
435  TransferDataToWindow();
436 }
437 
438 
439 void CRefGeneTrackingPanel::UpdateSeqdesc(objects::CSeqdesc& desc)
440 {
441  TransferDataFromWindow();
443  desc.SetUser(*user);
444 }
445 
446 
447 /*!
448  * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXTCTRL9
449  */
450 
452 {
453  if (m_GenomicSourceTxt->IsEmpty() || !m_AccessionsPanel->IsEmpty()) {
454  m_AccessionsPanel->Enable(true);
455  } else {
456  m_AccessionsPanel->Enable(false);
457  }
458 }
459 
CRef< objects::CUser_object > GetUser_object()
CRef< objects::CUser_object > m_User
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
virtual void UpdateSeqdesc(objects::CSeqdesc &desc)
bool x_IsControlledField(const string &field)
void x_SetStatus(const string &val)
void OnGenomicSourceTextUpdated(wxCommandEvent &event)
wxEVT_COMMAND_TEXT_UPDATED event handler for ID_TEXTCTRL9
void SetUser_object(CRef< objects::CUser_object > user)
void CreateControls()
Creates the controls and sizers.
bool Create(wxWindow *parent, wxWindowID id=ID_CREFGENETRACKINGPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
void Init()
Initialises member variables.
static bool ShowToolTips()
Should we show tooltips?
CRefGeneTrackLocListPanel * m_AccessionsPanel
virtual void ChangeSeqdesc(const objects::CSeqdesc &desc)
void SetUser_object(CRef< objects::CUser_object > user)
void PopulateFields(objects::CUser_object &user_obj)
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
static char tmp[3200]
Definition: utf8.c:42
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
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
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
bool IsSetData(void) const
the object itself Check if a value has been assigned to Data data member.
TData & SetData(void)
Assign a value to Data data member.
void SetLabel(TLabel &value)
Assign a value to Label data member.
void SetType(TType &value)
Assign a value to Type data member.
void SetData(TData &value)
Assign a value to Data data member.
vector< CRef< CUser_field > > TData
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
USING_SCOPE(objects)
static const string kURL
static const string kGenerated
static const string kStatus
static const string kCollaborator
static const string kGenomicSource
#define ID_TEXTCTRL9
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Tue May 28 05:54:02 2024 by modify_doxy.py rev. 669887