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

Go to the SVN repository for this file.

1 /* $Id: subprepmainpanel.cpp 47479 2023-05-02 13:24:02Z ucko $
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 
32 ////@begin includes
33 ////@end includes
34 
39 
40 ////@begin XPM images
41 ////@end XPM images
42 
44 
45 /*!
46  * CSubmissionPrepMainPanel type definition
47  */
48 
49 IMPLEMENT_DYNAMIC_CLASS( CSubmissionPrepMainPanel, wxPanel )
50 
51 
52 /*!
53  * CSubmissionPrepMainPanel event table definition
54  */
55 
56 BEGIN_EVENT_TABLE( CSubmissionPrepMainPanel, wxPanel )
57 
58 ////@begin CSubmissionPrepMainPanel event table entries
60 
62 
64 
66 
68 
70 
71 ////@end CSubmissionPrepMainPanel event table entries
72 
74 
75 
76 /*!
77  * CSubmissionPrepMainPanel constructors
78  */
79 
81 {
82  Init();
83 }
84 
85 CSubmissionPrepMainPanel::CSubmissionPrepMainPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
86 {
87  Init();
88  Create(parent, id, pos, size, style);
89 }
90 
91 
92 /*!
93  * CSubmissionPrepMainPanel creator
94  */
95 
96 bool CSubmissionPrepMainPanel::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
97 {
98 ////@begin CSubmissionPrepMainPanel creation
99  wxPanel::Create( parent, id, pos, size, style );
100 
101  CreateControls();
102  if (GetSizer())
103  {
104  GetSizer()->SetSizeHints(this);
105  }
106  Centre();
107 ////@end CSubmissionPrepMainPanel creation
108  return true;
109 }
110 
111 
112 /*!
113  * CSubmissionPrepMainPanel destructor
114  */
115 
117 {
118 ////@begin CSubmissionPrepMainPanel destruction
119 ////@end CSubmissionPrepMainPanel destruction
120 }
121 
122 
124  CSubmissionPrepMainPanel::TWizardSrcTypeName(CSourceRequirements::eWizardSrcType_any, "Not listed above or mixed set of different viruses"),
141 };
143 
144 
145 /*!
146  * Member initialisation
147  */
148 
150 {
151 ////@begin CSubmissionPrepMainPanel member initialisation
152  m_StarTech = NULL;
156  m_SourceType = NULL;
157  m_StarSource = NULL;
166  m_ExtraGrid = NULL;
169 ////@end CSubmissionPrepMainPanel member initialisation
170 
171  m_SrcTypeNames.clear();
172  for (int i = 0; i < num_srctype_names; i++) {
173  m_SrcTypeNames.push_back(s_srctype_names[i]);
174  }
177 }
178 
179 
180 /*!
181  * Control creation for CSubmissionPrepMainPanel
182  */
183 
185 {
186 ////@begin CSubmissionPrepMainPanel content construction
187  // Generated by DialogBlocks, 10/06/2013 17:53:07 (unregistered)
188 
189  CSubmissionPrepMainPanel* itemPanel1 = this;
190 
191  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
192  itemPanel1->SetSizer(itemBoxSizer2);
193 
194  wxFlexGridSizer* itemFlexGridSizer3 = new wxFlexGridSizer(0, 4, 0, 0);
195  itemBoxSizer2->Add(itemFlexGridSizer3, 0, wxALIGN_LEFT|wxALL, 5);
196 
197  wxStaticText* itemStaticText4 = new wxStaticText( itemPanel1, wxID_STATIC, _("Sequencing Technology"), wxDefaultPosition, wxSize(60, -1), 0 );
198  itemStaticText4->Wrap(20);
199  itemFlexGridSizer3->Add(itemStaticText4, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
200 
201  m_StarTech = new wxStaticText( itemPanel1, wxID_STATIC, _("*"), wxDefaultPosition, wxDefaultSize, 0 );
202  m_StarTech->SetForegroundColour(wxColour(255, 0, 0));
203  m_StarTech->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma")));
204  itemFlexGridSizer3->Add(m_StarTech, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
205 
206  m_SequencingTechLabel = new wxTextCtrl( itemPanel1, ID_TEXTCTRL, wxEmptyString, wxDefaultPosition, wxSize(400, -1), wxTE_MULTILINE|wxTE_READONLY );
207  itemFlexGridSizer3->Add(m_SequencingTechLabel, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
208 
209  m_SeqTechEdit = new wxHyperlinkCtrl( itemPanel1, ID_HYPERLINKCTRL1, _("Edit"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
210  itemFlexGridSizer3->Add(m_SeqTechEdit, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
211 
212  wxStaticText* itemStaticText8 = new wxStaticText( itemPanel1, wxID_STATIC, _("Source Type"), wxDefaultPosition, wxDefaultSize, 0 );
213  itemFlexGridSizer3->Add(itemStaticText8, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
214 
215  m_StarSourceType = new wxStaticText( itemPanel1, wxID_STATIC, _("*"), wxDefaultPosition, wxDefaultSize, 0 );
216  m_StarSourceType->SetForegroundColour(wxColour(255, 0, 0));
217  m_StarSourceType->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma")));
218  itemFlexGridSizer3->Add(m_StarSourceType, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
219 
220  wxArrayString m_SourceTypeStrings;
221  m_SourceType = new wxChoice( itemPanel1, ID_SOURCETYPE, wxDefaultPosition, wxDefaultSize, m_SourceTypeStrings, 0 );
223  m_SourceType->SetToolTip(_("If you provide correct information about the type of organism the sample was isolated, this tool will suggest the required and recommended information needed to help the submission be processed more quickly by GenBank staff.\n"));
224  itemFlexGridSizer3->Add(m_SourceType, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
225 
226  itemFlexGridSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
227 
228  wxStaticText* itemStaticText12 = new wxStaticText( itemPanel1, wxID_STATIC, _("Source"), wxDefaultPosition, wxDefaultSize, 0 );
229  itemFlexGridSizer3->Add(itemStaticText12, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
230 
231  m_StarSource = new wxStaticText( itemPanel1, wxID_STATIC, _("*"), wxDefaultPosition, wxDefaultSize, 0 );
232  m_StarSource->SetForegroundColour(wxColour(255, 0, 0));
233  m_StarSource->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma")));
234  itemFlexGridSizer3->Add(m_StarSource, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
235 
236  m_SourceLabel = new wxTextCtrl( itemPanel1, ID_TEXTCTRL2, wxEmptyString, wxDefaultPosition, wxSize(-1, 50), wxTE_MULTILINE|wxTE_READONLY );
237  itemFlexGridSizer3->Add(m_SourceLabel, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
238 
239  m_EditSourceLink = new wxHyperlinkCtrl( itemPanel1, ID_HYPERLINKCTRL2, _("Edit"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
240  itemFlexGridSizer3->Add(m_EditSourceLink, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
241 
242  wxStaticText* itemStaticText16 = new wxStaticText( itemPanel1, wxID_STATIC, _("Features"), wxDefaultPosition, wxDefaultSize, 0 );
243  itemFlexGridSizer3->Add(itemStaticText16, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
244 
245  m_StarFeatures = new wxStaticText( itemPanel1, wxID_STATIC, _("*"), wxDefaultPosition, wxDefaultSize, 0 );
246  m_StarFeatures->SetForegroundColour(wxColour(255, 0, 0));
247  m_StarFeatures->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma")));
248  itemFlexGridSizer3->Add(m_StarFeatures, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
249 
250  m_FeaturesLabel = new wxTextCtrl( itemPanel1, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
251  itemFlexGridSizer3->Add(m_FeaturesLabel, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
252 
253  wxBoxSizer* itemBoxSizer19 = new wxBoxSizer(wxVERTICAL);
254  itemFlexGridSizer3->Add(itemBoxSizer19, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
255 
256  m_FeatureAddBtn = new wxHyperlinkCtrl( itemPanel1, ID_HYPERLINKCTRL3, _("Add"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
257  itemBoxSizer19->Add(m_FeatureAddBtn, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
258 
259  m_FeatureImportBtn = new wxHyperlinkCtrl( itemPanel1, ID_HYPERLINKCTRL4, _("Import File"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
260  itemBoxSizer19->Add(m_FeatureImportBtn, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
261 
262  m_RemoveFeaturesBtn = new wxHyperlinkCtrl( itemPanel1, ID_REMOVE_FEAT, _("Remove All Features"), wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
263  itemBoxSizer19->Add(m_RemoveFeaturesBtn, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
264 
265  m_WizardExtras = new wxBoxSizer(wxVERTICAL);
266  itemBoxSizer2->Add(m_WizardExtras, 0, wxALIGN_LEFT|wxALL, 0);
267 
268  m_ExtraGrid = new wxFlexGridSizer(0, 4, 0, 0);
269  m_WizardExtras->Add(m_ExtraGrid, 0, wxALIGN_LEFT|wxALL, 0);
270 
271  m_ChimeraSizer = new wxBoxSizer(wxVERTICAL);
272  itemBoxSizer2->Add(m_ChimeraSizer, 0, wxALIGN_LEFT|wxALL, 0);
273 
274  m_VirusMolSizer = new wxBoxSizer(wxVERTICAL);
275  itemBoxSizer2->Add(m_VirusMolSizer, 0, wxALIGN_LEFT|wxALL, 5);
276 
277  // Connect events and objects
278  m_SequencingTechLabel->Connect(ID_TEXTCTRL, wxEVT_LEFT_DOWN, wxMouseEventHandler(CSubmissionPrepMainPanel::OnClickSeqTechSummary), NULL, this);
279  m_SourceLabel->Connect(ID_TEXTCTRL2, wxEVT_LEFT_DOWN, wxMouseEventHandler(CSubmissionPrepMainPanel::OnClickSrcSummary), NULL, this);
280  m_FeaturesLabel->Connect(ID_TEXTCTRL1, wxEVT_LEFT_DOWN, wxMouseEventHandler(CSubmissionPrepMainPanel::OnClickFeatureSummary), NULL, this);
281 ////@end CSubmissionPrepMainPanel content construction
282 }
283 
284 
285 /*!
286  * Should we show tooltips?
287  */
288 
290 {
291  return true;
292 }
293 
294 /*!
295  * Get bitmap resources
296  */
297 
298 wxBitmap CSubmissionPrepMainPanel::GetBitmapResource( const wxString& name )
299 {
300  // Bitmap retrieval
301 ////@begin CSubmissionPrepMainPanel bitmap retrieval
302  wxUnusedVar(name);
303  return wxNullBitmap;
304 ////@end CSubmissionPrepMainPanel bitmap retrieval
305 }
306 
307 /*!
308  * Get icon resources
309  */
310 
311 wxIcon CSubmissionPrepMainPanel::GetIconResource( const wxString& name )
312 {
313  // Icon retrieval
314 ////@begin CSubmissionPrepMainPanel icon retrieval
315  wxUnusedVar(name);
316  return wxNullIcon;
317 ////@end CSubmissionPrepMainPanel icon retrieval
318 }
319 
320 
322 {
323  wxWindow* w = this->GetParent();
324  while (w != NULL) {
325  CSubPrep_panel* parent = dynamic_cast<CSubPrep_panel*>(w);
326  if (parent) {
327  return parent;
328  } else {
329  w = w->GetParent();
330  }
331  }
332  return NULL;
333 }
334 
335 
336 static void s_ShowStar(wxStaticText* star, bool show)
337 {
338  if (show) {
339  star->SetLabel(wxT("*"));
340  } else {
341  star->SetLabel(wxT(" "));
342  }
343 }
344 
345 
347 {
348  CSubPrep_panel* parent = x_GetParent();
349  if (!parent) {
350  return;
351  }
352 
353  bool required = parent->IsSequencingTechnologyRequired (wizard_type);
354 
355  bool ok_to_bulk_edit = true;
356  string message = "";
357 
358  bool missing_required = false;
359 
361 
362  if (table) {
363  string mixed = "";
364  string missing = "";
365  string all_summary = "";
366  bool any_data = false;
367  bool missing_required_col = false;
368  for (size_t i = 1; i < table->GetColumns().size(); i++) {
369  string title = table->GetColumns()[i]->GetHeader().GetTitle();
370  if (AreAllColumnValuesTheSame(table->SetColumns()[i], "")) {
371  string first_val = table->GetColumns()[i]->GetData().GetString()[0];
372  if (!NStr::IsBlank(first_val)) {
373  any_data = true;
374  if (!NStr::IsBlank(all_summary)) {
375  all_summary += "\n";
376  }
377  all_summary += title + ":" + first_val;
378  }
379  } else {
380  any_data = true;
381  ok_to_bulk_edit = false;
382  if (NStr::IsBlank(mixed)) {
383  mixed = "Record contains mixed values for ";
384  } else {
385  mixed += ", ";
386  }
387  mixed += title;
388  }
389  if (AreAnyColumnValuesMissing(table->SetColumns()[i])) {
390  if (NStr::Equal(title, "Sequencing Technology")) {
391  missing += "Missing required Sequencing Technology information. ";
392  missing_required_col = true;
393  }
394  }
395  }
396  if (!NStr::IsBlank(mixed)) {
397  mixed += ".";
398  }
399  if ((required || any_data) && missing_required_col) {
400  missing_required = true;
401  }
402  if (any_data) {
403  message = missing + mixed;
404  } else if (required) {
405  message = "Missing required sequencing technology information";
406  missing_required = true;
407  }
408  if (NStr::IsBlank(message)) {
409  message = all_summary;
410  }
411  } else {
412  if (required) {
413  message = "Missing required sequencing technology information";
414  missing_required = true;
415  }
416  }
417 
418  // update controls
419  m_SequencingTechLabel->SetValue(ToWxString (message));
420  s_ShowStar (m_StarTech, missing_required);
421  if (missing_required) {
422  parent->SetSubmissionNotReady(message);
423  }
424  if (ok_to_bulk_edit) {
425  m_SeqTechEdit->SetLabel(wxT("Edit"));
426  } else {
427  m_SeqTechEdit->SetLabel(wxT("Clear"));
428  }
429 }
430 
431 
432 /*!
433  * wxEVT_LEFT_DOWN event handler for ID_TEXTCTRL2
434  */
435 
437 {
438  CSubPrep_panel* parent = x_GetParent();
439  if (!parent) {
440  return;
441  }
442  parent->LaunchSourceEditor();
443 }
444 
445 
446 /*!
447  * wxEVT_LEFT_DOWN event handler for ID_TEXTCTRL
448  */
449 
451 {
452  CSubPrep_panel* parent = x_GetParent();
453  if (!parent) {
454  return;
455  }
456  if (parent->OkToBulkEditSeqTech()) {
457  parent->LaunchSeqTechEditor();
458  }
459 }
460 
461 
462 /*!
463  * wxEVT_COMMAND_HYPERLINK event handler for ID_HYPERLINKCTRL1
464  */
465 
467 {
468  CSubPrep_panel* parent = x_GetParent();
469  if (!parent) {
470  return;
471  }
472  wxHyperlinkCtrl* link_ctrl = dynamic_cast<wxHyperlinkCtrl*>(event.GetEventObject());
473  if (link_ctrl) {
474  if (NStr::Equal("Edit", ToStdString(link_ctrl->GetLabel()))) {
475  parent->LaunchSeqTechEditor();
476  } else {
477  parent->ClearSeqTechValues();
478  }
479  }
480 }
481 
482 
484 {
485  m_SourceType->Clear();
486  switch (wizard_type) {
488  m_SourceType->Append (wxT("Norovirus, Sapovirus (Caliciviridae)"));
489  m_SourceType->Append (wxT("Foot-and-mouth disease virus"));
490  m_SourceType->Append (wxT("Influenza virus"));
491  m_SourceType->Append (wxT("Rotavirus"));
492  m_SourceType->Append (wxT("Not listed above or mixed set of different viruses"));
493  m_SourceType->Enable (true);
494  break;
496  m_SourceType->Append (wxT("Bacteria or Archaea"));
497  m_SourceType->Append (wxT("Fungi"));
498  m_SourceType->Append (wxT("Some other organism"));
499  m_SourceType->Enable (true);
500  break;
502  m_SourceType->Append (wxT("Cultured Bacteria or Archaea"));
503  m_SourceType->Append (wxT("Cultured Fungus"));
504  m_SourceType->Append (wxT("Vouchered Fungus"));
505  m_SourceType->Append (wxT("Something else"));
506  m_SourceType->Enable (true);
507  break;
509  m_SourceType->Append (wxT("Culutured fungal samples"));
510  m_SourceType->Append (wxT("Vouchered fungal samples"));
511  m_SourceType->Append (wxT("Plant"));
512  m_SourceType->Append (wxT("Animal"));
513  m_SourceType->Enable (true);
514  break;
519  default:
520  m_SourceType->Append (wxT("Any"));
521  m_SourceType->SetSelection(0);
522  m_SourceType->Enable (false);
523  break;
524  }
525 }
526 
527 
529 {
530  CSubPrep_panel* parent = x_GetParent();
531  if (!parent) {
532  return;
533  }
534  CSourceRequirements::EWizardType wizard_type = parent->GetWizardType();
535 
536  bool is_unchosen = false;
537  if (src_type == CSourceRequirements::eWizardSrcType_any) {
538  CSubPrep_panel* parent = x_GetParent();
539  if (parent && NStr::IsBlank(parent->GetWizardSrcTypeField())) {
540  CSourceRequirements::EWizardType wizard_type = parent->GetWizardType();
542  || wizard_type == CSourceRequirements::eWizardType_tsa
544  || wizard_type == CSourceRequirements::eWizardType_d_loop) {
545  } else {
546  is_unchosen = true;
547  }
548  }
549  }
550 
551  wxArrayString choices = m_SourceType->GetStrings();
552  if (!is_unchosen) {
553  // if the last option is blank, get rid of it
554  if (choices.size() > 0 && choices.Last() == wxEmptyString) {
555  SetSourceTypeOptions(wizard_type);
556  }
557  is_unchosen = true;
559  if (kit->first == src_type) {
560  wxArrayString::iterator it = choices.begin();
561  int pos = 0;
562  while (it != choices.end() && !NStr::EqualNocase(kit->second, ToStdString (*it))) {
563  pos++;
564  it++;
565  }
566  if (it != choices.end()) {
567  m_SourceType->SetSelection(pos);
568  is_unchosen = false;
569  break;
570  }
571  }
572  }
573  }
574 
575  s_ShowStar (m_StarSourceType, is_unchosen && choices.size() > 1);
576 
577  if (is_unchosen && choices.size() > 1) {
578  m_SourceType->AppendString(wxEmptyString);
579  m_SourceType->SetSelection(static_cast<int>(choices.size()));
580  parent->SetSubmissionNotReady("Must choose source type");
581  // disable controls below
582  m_SourceLabel->Enable(false);
583  m_EditSourceLink->Enable(false);
584  m_FeaturesLabel->Enable(false);
585  m_FeatureAddBtn->Enable(false);
586  m_FeatureImportBtn->Enable(false);
587  m_RemoveFeaturesBtn->Enable(false);
588  } else {
589  // enable controls below
590  m_SourceLabel->Enable(true);
591  m_EditSourceLink->Enable(true);
592  m_FeaturesLabel->Enable(true);
593  m_FeatureAddBtn->Enable(true);
594  m_FeatureImportBtn->Enable(true);
595  m_RemoveFeaturesBtn->Enable(true);
596  }
597 }
598 
599 
601 {
602  int val = m_SourceType->GetSelection();
604 
605  switch (wizard_type) {
607  switch (val) {
608  case 0:
610  break;
611  case 1:
613  break;
614  case 2:
616  break;
617  case 3:
619  break;
620  default:
622  break;
623  }
624  break;
626  switch (val) {
627  case 0:
629  break;
630  case 1:
632  break;
633  default:
635  break;
636  }
637  break;
639  switch (val) {
640  case 0:
642  break;
643  case 1:
645  break;
646  case 2:
648  break;
649  default:
651  break;
652  }
653  break;
655  switch (val) {
656  case 0:
658  break;
659  case 1:
661  break;
662  case 2:
664  break;
665  case 3:
667  break;
668  default:
670  break;
671  }
672  break;
673  default:
675  break;
676  }
677 
678  return src_type;
679 }
680 
681 
683 {
686  if (NStr::EqualNocase (kit->second, name)) {
687  src_type = kit->first;
688  break;
689  }
690  }
691  return src_type;
692 }
693 
694 
695 /*!
696  * wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_SOURCETYPE
697  */
698 
700 {
701  CSubPrep_panel* parent = x_GetParent();
702  if (!parent) {
703  return;
704  }
705  parent->SetSourceType(ToStdString(m_SourceType->GetStringSelection()));
706  s_ShowStar (m_StarSourceType, false);
707 }
708 
709 
711 {
712  m_SourceLabel->SetValue(ToWxString(label));
713 }
714 
715 
717 {
719 }
720 
721 
723 {
724  NON_CONST_ITERATE(vector<bool>, it, m_FieldsInUse) {
725  *it = false;
726  }
727 }
728 
729 
731 {
732  int num_keep = 0;
733  for (int pos = static_cast<int>(m_FieldsInUse.size()) - 1; pos > -1; pos--) {
734  if (m_FieldsInUse[pos]) {
735  num_keep ++;
736  } else {
737  // note - delete item pos + 1, because m_ExtraGrid is the first element in the sizer
738  m_WizardExtras->GetItem(pos + 1)->DeleteWindows();
739  m_WizardExtras->Remove(pos + 1);
740  if (pos < m_ExtraFields.size()) {
741  m_ExtraFields[pos] = NULL;
742  }
743  }
744  }
745 
746  m_FieldsInUse.clear();
747  for (int pos = 0; pos < num_keep; pos++) {
748  m_FieldsInUse.push_back(true);
749  }
750  vector<CSubPrepFieldEditor * >::iterator it = m_ExtraFields.begin();
751  while (it != m_ExtraFields.end()) {
752  if ((*it) == NULL) {
753  it = m_ExtraFields.erase(it);
754  } else {
755  it++;
756  }
757  }
758 }
759 
760 
761 void CSubmissionPrepMainPanel::AddField(objects::CSeq_entry_Handle seh,
762  ICommandProccessor* processor,
763  IWorkbench* workbench,
764  string label, string column_name,
765  CTableFieldCommandConverter * converter,
766  bool must_choose, bool required,
767  string default_val, string url,
768  bool allow_mix)
769 {
770  CSubPrepFieldEditor* new_field = NULL;
771  // first, see if we already have one, and if so, mark it as in use
772  size_t pos = 0;
773  ITERATE(vector<CSubPrepFieldEditor* >, it, m_ExtraFields) {
774  if (NStr::Equal((*it)->GetColumnName(), column_name)) {
775  new_field = *it;
776  break;
777  }
778  pos++;
779  }
780 
781  if (new_field == NULL) {
782  new_field = new CSubPrepFieldEditor(this, seh, processor, workbench);
783  m_WizardExtras->Add(new_field, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0);
784  m_ExtraFields.push_back(new_field);
785  m_FieldsInUse.push_back(true);
786  } else {
787  m_FieldsInUse[pos] = true;
788  }
789 
790  new_field->SetConverter(label, column_name, converter, must_choose, required, default_val, url, allow_mix);
791  // update
792  Layout();
793  Refresh();
794 }
795 
796 
797 /*!
798  * wxEVT_COMMAND_HYPERLINK event handler for ID_HYPERLINKCTRL2
799  */
800 
801 void CSubmissionPrepMainPanel::OnEditSourceClicked( wxHyperlinkEvent& event )
802 {
803  CSubPrep_panel* parent = x_GetParent();
804  if (!parent) {
805  return;
806  }
807  parent->LaunchSourceEditor();
808 }
809 
810 
811 /*!
812  * wxEVT_COMMAND_HYPERLINK event handler for ID_HYPERLINKCTRL3
813  */
814 
815 void CSubmissionPrepMainPanel::OnAddFeaturesClicked( wxHyperlinkEvent& event )
816 {
817  CSubPrep_panel* parent = x_GetParent();
818  if (!parent) {
819  return;
820  }
821  parent->LaunchFeatureAdder();
822 }
823 
824 
825 /*!
826  * wxEVT_COMMAND_HYPERLINK event handler for ID_HYPERLINKCTRL4
827  */
828 
830 {
831  CSubPrep_panel* parent = x_GetParent();
832  if (!parent) {
833  return;
834  }
835  parent->ImportFeatureTableFile();
836 }
837 
838 
839 /*!
840  * wxEVT_LEFT_DOWN event handler for ID_TEXTCTRL1
841  */
842 
844 {
845  CSubPrep_panel* parent = x_GetParent();
846  if (!parent) {
847  return;
848  }
849  parent->LaunchFeatureAdder();
850 }
851 
852 
854 {
856 }
857 
858 
860 {
861  m_FeaturesLabel->SetValue(ToWxString(label));
862 }
863 
864 
866 {
867  m_FeatureAddBtn->Show(val);
868 }
869 
870 
871 wxStaticText* CSubmissionPrepMainPanel::x_AddStar(wxFlexGridSizer* sizer)
872 {
873  wxStaticText* star = new wxStaticText( this, wxID_STATIC, _("*"), wxDefaultPosition, wxDefaultSize, 0 );
874  star->SetForegroundColour(wxColour(255, 0, 0));
875  sizer->Add(star, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
876  star->SetFont(wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Tahoma")));
877  return star;
878 }
879 
880 
881 void CSubmissionPrepMainPanel::CreateSetChoice (CSourceRequirements::EWizardType wizard_type, objects::CSeq_entry_Handle seh)
882 {
883  // clear previous set choice control if it exists
884  while (m_ExtraGrid->GetItemCount() > 0) {
885  int pos = 0;
886  m_ExtraGrid->GetItem(pos)->DeleteWindows();
887  m_ExtraGrid->Remove(pos);
888  }
889 
890  CSubPrep_panel* parent = x_GetParent();
891  if (!parent) {
892  return;
893  }
894 
895  if (!seh || !seh.IsSet()) {
896  // don't need a set type if not a set
897  return;
898  }
899  int set_class = objects::CBioseq_set::eClass_not_set;
900  if (seh.GetSet().IsSetClass()) {
901  set_class = seh.GetSet().GetClass();
902  }
903 
904  wxArrayString set_strings;
905  wxString tooltip_text = wxEmptyString;
906 
907  wxString sel = wxEmptyString;
908  switch (set_class) {
909  case objects::CBioseq_set::eClass_pop_set:
910  sel = "Population Study";
911  break;
912  case objects::CBioseq_set::eClass_phy_set:
913  sel = "Phylogenetic Study";
914  break;
915  case objects::CBioseq_set::eClass_mut_set:
916  sel = "Mutation Study";
917  break;
918  case objects::CBioseq_set::eClass_eco_set:
919  sel = "Environmental set";
920  break;
921  case objects::CBioseq_set::eClass_genbank:
922  sel = "Batch";
923  break;
924  default:
925  // do nothing
926  break;
927  }
928 
929  switch (wizard_type) {
931  tooltip_text.append(wxT("Batch: Do not process as a set.\n"));
932  tooltip_text.append(wxT("Population Study: a set of sequences that were derived by sequencing the same gene from different isolates of the same organism.\n"));
933  tooltip_text.append(wxT("Phylogenetic Study: a set of sequences that were derived by sequencing the same gene from different organisms.\n"));
934  tooltip_text.append(wxT("Mutation Study: a set of sequences that were derived by sequencing multiple mutations of a single gene.\n"));
935  tooltip_text.append(wxT("Environmental set: a set of sequences that were derived by sequencing the same gene from a population of unclassified or unknown organisms."));
936 
937  set_strings.push_back(wxT("Batch"));
938  set_strings.push_back(wxT("Population Study"));
939  set_strings.push_back(wxT("Phylogenetic Study"));
940  set_strings.push_back(wxT("Mutation Study"));
941  set_strings.push_back(wxT("Environmental set"));
942  break;
944  tooltip_text.append(wxT("Batch: Do not process as a set.\n"));
945  tooltip_text.append(wxT("Environmental set: a set of sequences that were derived by sequencing the same gene from a population of unclassified or unknown organisms."));
946  set_strings.push_back(wxT("Batch"));
947  set_strings.push_back(wxT("Environmental set"));
948  break;
953  tooltip_text.append(wxT("Batch: Do not process as a set.\n"));
954  tooltip_text.append(wxT("Population Study: a set of sequences that were derived by sequencing the same gene from different isolates of the same organism.\n"));
955  tooltip_text.append(wxT("Phylogenetic Study: a set of sequences that were derived by sequencing the same gene from different organisms.\n"));
956  tooltip_text.append(wxT("Mutation Study: a set of sequences that were derived by sequencing multiple mutations of a single gene.\n"));
957  tooltip_text.append(wxT("Environmental set: a set of sequences that were derived by sequencing the same gene from a population of unclassified or unknown organisms."));
958 
959  set_strings.push_back(wxT("Batch"));
960  set_strings.push_back(wxT("Population Study"));
961  set_strings.push_back(wxT("Phylogenetic Study"));
962  set_strings.push_back(wxT("Mutation Study"));
963  set_strings.push_back(wxT("Environmental set"));
964  break;
965  default:
966  if (set_class == objects::CBioseq_set::eClass_genbank) {
967  // do nothing
968  } else {
969  set_strings.push_back(wxT("Batch"));
970  }
971  break;
972  }
973  if (set_strings.empty()) {
974  // nothing to choose
975  return;
976  } else {
977  wxStaticText* itemStaticText = new wxStaticText( this, wxID_STATIC, wxT("Set Type"),
978  wxDefaultPosition, wxSize(60, -1), wxALIGN_CENTRE );
979  m_ExtraGrid->Add(itemStaticText, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
980 
981  wxStaticText* star = x_AddStar(m_ExtraGrid);
982 
983  wxChoice *choice = new wxChoice( this, ID_SET_CHOICE, wxDefaultPosition, wxSize(400, -1), set_strings, 0 );
984  m_ExtraGrid->Add(choice, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
985  wxString please_choose = wxT("Please choose a set type");
986  if (sel.empty() || !choice->SetStringSelection(sel)) {
987  choice->AppendString(please_choose);
988  choice->SetStringSelection(please_choose);
989  parent->SetSubmissionNotReady("Must choose set type");
990  s_ShowStar (star, true);
991  } else {
992  s_ShowStar (star, false);
993  }
994 
995  if (CSubmissionPrepMainPanel::ShowToolTips() && !tooltip_text.IsEmpty())
996  choice->SetToolTip(tooltip_text);
997 
998  // add spacer as place holder
999  m_ExtraGrid->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
1000 
1001  Layout();
1002  Refresh();
1003  }
1004 }
1005 
1006 
1007 void CSubmissionPrepMainPanel::ShowChimera (objects::CSeq_entry_Handle seh,
1008  ICommandProccessor* processor,
1009  IWorkbench* workbench, bool show)
1010 {
1011  if (!m_ChimeraPanel) {
1012  m_ChimeraPanel = new CChimeraPanel(this, seh, processor, workbench);
1014  }
1016  Fit();
1017  Layout();
1018  Refresh();
1019 }
1020 
1021 
1022 void CSubmissionPrepMainPanel::CreateVirusMoleculeOptions (objects::CSeq_entry_Handle seh, ICommandProccessor* processor)
1023 {
1026  if (moltype_col && DoesColumnHaveValue (moltype_col, "mRNA")) {
1027  if (m_VirusMolQuestions) {
1028  m_VirusMolQuestions->Show(true);
1029  } else {
1030  m_VirusMolQuestions = new CVirusMoleculeQuestionsPanel(this, seh, processor);
1031  m_VirusMolSizer->Add(m_VirusMolQuestions, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
1032  }
1034  } else {
1035  if (m_VirusMolQuestions) {
1036  m_VirusMolQuestions->Show(false);
1037  }
1038  }
1039  Fit();
1040  Layout();
1041  Refresh();
1042 }
1043 
1044 
1045 /*!
1046  * wxEVT_COMMAND_HYPERLINK event handler for ID_REMOVE_FEAT
1047  */
1048 
1050 {
1051  CSubPrep_panel* parent = x_GetParent();
1052  if (!parent) {
1053  return;
1054  }
1055  parent->RemoveAllFeatures();
1056 }
1057 
1058 
1060 
1061 
void SetConverter(string label, string column_name, CTableFieldCommandConverter *converter, bool must_choose=false, bool required=false, string default_val="", string url="", bool allow_mix=true)
void ImportFeatureTableFile()
void SetSubmissionNotReady(string error)
bool OkToBulkEditSeqTech()
bool IsSequencingTechnologyRequired(CSourceRequirements::EWizardType wizard_type)
string GetWizardSrcTypeField()
CRef< objects::CSeq_table > GetSeqTechTable()
void LaunchSeqTechEditor()
void SetSourceType(string src_type)
CSourceRequirements::EWizardType GetWizardType()
CVirusMoleculeQuestionsPanel * m_VirusMolQuestions
static bool ShowToolTips()
Should we show tooltips?
wxHyperlinkCtrl * m_SeqTechEdit
void OnClickSeqTechSummary(wxMouseEvent &event)
wxEVT_LEFT_DOWN event handler for ID_TEXTCTRL
wxHyperlinkCtrl * m_FeatureImportBtn
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
void OnAddFeaturesClicked(wxHyperlinkEvent &event)
wxEVT_COMMAND_HYPERLINK event handler for ID_HYPERLINKCTRL3
void AddField(objects::CSeq_entry_Handle seh, ICommandProccessor *processor, IWorkbench *workbench, string label, string column_name, CTableFieldCommandConverter *converter, bool must_choose=false, bool required=false, string default_val="", string url="", bool allow_mix=true)
void OnEditSourceClicked(wxHyperlinkEvent &event)
wxEVT_COMMAND_HYPERLINK event handler for ID_HYPERLINKCTRL2
void ShowSourceLabelStar(bool val)
wxHyperlinkCtrl * m_EditSourceLink
CSubmissionPrepMainPanel()
Constructors.
~CSubmissionPrepMainPanel()
Destructor.
CSourceRequirements::EWizardSrcType GetWizardSrcTypeFromCtrls(CSourceRequirements::EWizardType wizard_type)
void Init()
Initialises member variables.
void OnSourceTypeSelected(wxCommandEvent &event)
wxEVT_COMMAND_CHOICE_SELECTED event handler for ID_SOURCETYPE
void SetSourceType(CSourceRequirements::EWizardSrcType src_type)
wxHyperlinkCtrl * m_RemoveFeaturesBtn
void OnRemoveFeatHyperlinkClicked(wxHyperlinkEvent &event)
wxEVT_COMMAND_HYPERLINK event handler for ID_REMOVE_FEAT
void SetFeaturesLabel(string label)
void SetSourceTypeOptions(CSourceRequirements::EWizardType wizard_type)
pair< CSourceRequirements::EWizardSrcType, string > TWizardSrcTypeName
CSourceRequirements::EWizardSrcType GetWizardSrcTypeFromName(string name)
CSubPrep_panel * x_GetParent()
vector< CSubPrepFieldEditor * > m_ExtraFields
void OnClickFeatureSummary(wxMouseEvent &event)
wxEVT_LEFT_DOWN event handler for ID_TEXTCTRL1
void OnImportFeatureTableFile(wxHyperlinkEvent &event)
wxEVT_COMMAND_HYPERLINK event handler for ID_HYPERLINKCTRL4
void OnEditSequencingTechnologyClicked(wxHyperlinkEvent &event)
wxEVT_COMMAND_HYPERLINK event handler for ID_HYPERLINKCTRL1
TWizardSrcTypeNameList m_SrcTypeNames
void CreateSetChoice(CSourceRequirements::EWizardType wizard_type, objects::CSeq_entry_Handle seh)
vector< TWizardSrcTypeName > TWizardSrcTypeNameList
void UpdateSeqTechCtrls(CSourceRequirements::EWizardType wizard_type)
bool Create(wxWindow *parent, wxWindowID id=10001, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxTAB_TRAVERSAL)
Creation.
wxFlexGridSizer * m_ExtraGrid
void SetSourceLabel(string label)
void CreateVirusMoleculeOptions(objects::CSeq_entry_Handle seh, ICommandProccessor *processor)
void OnClickSrcSummary(wxMouseEvent &event)
wxEVT_LEFT_DOWN event handler for ID_TEXTCTRL2
wxStaticText * x_AddStar(wxFlexGridSizer *sizer)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
wxHyperlinkCtrl * m_FeatureAddBtn
void CreateControls()
Creates the controls and sizers.
void ShowChimera(objects::CSeq_entry_Handle seh, ICommandProccessor *processor, IWorkbench *workbench, bool show)
Undo/Redo interface for editing operations.
IWorkbench is the central interface in the application framework.
Definition: workbench.hpp:113
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
const char * kMoleculeType
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
#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:5352
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
Definition: ncbistr.hpp:5383
static const char label[]
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
END_EVENT_TABLE()
int i
CRef< objects::CSeq_table > BuildMolInfoValuesTableFromSeqEntry(objects::CSeq_entry_Handle seh, CSourceRequirements::EWizardType wizard_type)
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
CRef< CSeqTable_column > FindSeqTableColumnByName(CRef< objects::CSeq_table > values_table, string column_name)
#define ID_SET_CHOICE
bool AreAnyColumnValuesMissing(CRef< objects::CSeqTable_column > col)
bool AreAllColumnValuesTheSame(CRef< objects::CSeqTable_column > col, string default_val="")
bool DoesColumnHaveValue(CRef< objects::CSeqTable_column > col, string val)
static int num_srctype_names
static CSubmissionPrepMainPanel::TWizardSrcTypeName s_srctype_names[]
static void s_ShowStar(wxStaticText *star, bool show)
#define ID_SOURCETYPE
#define ID_HYPERLINKCTRL1
#define ID_HYPERLINKCTRL3
#define ID_TEXTCTRL1
#define ID_HYPERLINKCTRL2
#define ID_REMOVE_FEAT
#define ID_TEXTCTRL
#define ID_TEXTCTRL2
#define ID_HYPERLINKCTRL4
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Thu Nov 30 04:54:38 2023 by modify_doxy.py rev. 669887