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

Go to the SVN repository for this file.

1 /* $Id: add_constraint_panel.cpp 45436 2020-08-03 17:23:15Z 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>
32 
33 // For compilers that support precompilation, includes "wx/wx.h".
34 #include "wx/wxprec.h"
35 
36 #ifdef __BORLANDC__
37 #pragma hdrstop
38 #endif
39 
40 #ifndef WX_PRECOMP
41 #include "wx/wx.h"
42 #endif
43 
58 
65 
67 
68 template <typename T>
69 class CTripleConstraintPanel: public wxPanel, public IItemConstraintPanel
70 {
72 public:
74  CTripleConstraintPanel( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
75  bool Create( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
77  void Init();
78  void CreateControls();
79  wxBitmap GetBitmapResource( const wxString& name );
80  wxIcon GetIconResource( const wxString& name );
81  static bool ShowToolTips();
82 
83  virtual pair<string, SFieldTypeAndMatcher> GetItem(CFieldNamePanel::EFieldType field_type);
84  virtual void SetItem(const SFieldTypeAndMatcher &item);
85 
86  void SetFieldName(const string& field);
87  void PopulateFeatureListbox(objects::CSeq_entry_Handle seh);
88  void SetFieldNames(const vector<string>& field_names);
89 
90 private:
91  wxNotebook* m_Notebook;
92 };
93 
94 template<typename T>
95 class CPresentMatcherPanel : public CMatcherPanelBase, public wxPanel
96 {
98 
99 public:
101  CPresentMatcherPanel(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
102  bool Create( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
104  void Init();
105  void CreateControls();
106  wxBitmap GetBitmapResource( const wxString& name );
107  wxIcon GetIconResource( const wxString& name );
108  static bool ShowToolTips();
109 
111  virtual void SetMatcher(const SFieldTypeAndMatcher &item);
112  virtual string GetLabel(void);
113  virtual void SetFieldName(const string& field);
114  virtual void PopulateFeatureListbox(objects::CSeq_entry_Handle seh);
115  virtual void SetFieldNames(const vector<string>& field_names);
116 private:
118 };
119 
120 template<typename T>
121 class CSameMatcherPanel : public CMatcherPanelBase, public wxPanel
122 {
124 
125 public:
127  CSameMatcherPanel(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
128  bool Create( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
130  void Init();
131  void CreateControls();
132  wxBitmap GetBitmapResource( const wxString& name );
133  wxIcon GetIconResource( const wxString& name );
134  static bool ShowToolTips();
135 
137  virtual void SetMatcher(const SFieldTypeAndMatcher &item);
138  virtual string GetLabel(void);
139  virtual void SetFieldName(const string& field);
140  virtual void PopulateFeatureListbox(objects::CSeq_entry_Handle seh);
141  virtual void SetFieldNames(const vector<string>& field_names);
142 private:
145 };
146 
147 /*!
148  * Control identifiers
149  */
150 
151 ////@begin control identifiers
152 #define SYMBOL_CADVSTRINGCONSTRAINTPANEL_STYLE wxTAB_TRAVERSAL
153 #define SYMBOL_CADVSTRINGCONSTRAINTPANEL_TITLE _("StringConstraintPanel")
154 #define SYMBOL_CADVSTRINGCONSTRAINTPANEL_IDNAME ID_CADVSTRINGCONSTRAINTPANEL
155 #define SYMBOL_CADVSTRINGCONSTRAINTPANEL_SIZE wxDefaultSize
156 #define SYMBOL_CADVSTRINGCONSTRAINTPANEL_POSITION wxDefaultPosition
157 ////@end control identifiers
158 
159 
160 /*!
161  * CAdvStringConstraintPanel class declaration
162  */
163 template<typename T>
165 {
167 public:
168  /// Constructors
170  CAdvStringConstraintPanel( wxWindow* parent,
172  const wxPoint& pos = SYMBOL_CADVSTRINGCONSTRAINTPANEL_POSITION,
175 
176  /// Creation
177  bool Create( wxWindow* parent,
179  const wxPoint& pos = SYMBOL_CADVSTRINGCONSTRAINTPANEL_POSITION,
182 
183  /// Destructor
185 
186  /// Initialises member variables
187  void Init();
188 
189  /// Creates the controls and sizers
190  void CreateControls();
191 
192 ////@begin CStringConstraintPanel event handler declarations
193  void OnClear( wxCommandEvent& event );
194  void OnMatchTypeSelected( wxCommandEvent& event );
195  void OnWordSubstitution( wxCommandEvent& event );
196 ////@end CStringConstraintPanel event handler declarations
197 
198 ////@begin CStringConstraintPanel member function declarations
199 
200  enum EMatchType {
211  };
212 
213 
214  void ClearValues(void);
215  void SetChoices(const vector<string> &choices);
216  void ShowChoiceOrText(void);
217  /// Retrieves bitmap resources
218  wxBitmap GetBitmapResource( const wxString& name );
219 
220  /// Retrieves icon resources
221  wxIcon GetIconResource( const wxString& name );
222 ////@end CStringConstraintPanel member function declarations
223 
224  /// Should we show tooltips?
225  static bool ShowToolTips();
226 
228  virtual void SetMatcher(const SFieldTypeAndMatcher &item);
229  virtual string GetLabel(void);
230 
231 
232  // inherited from CFieldNamePanelParent
233  virtual void UpdateEditor(void);
234 
236  string GetDescription();
237 
239  virtual void SetFieldName(const string& field);
240  virtual void PopulateFeatureListbox(objects::CSeq_entry_Handle seh);
241  virtual void SetFieldNames(const vector<string>& field_names);
242 private:
244 
245 ////@begin CStringConstraintPanel member variables
246  wxChoice* m_MatchType;
247  wxTextCtrl* m_MatchText;
248  wxCheckBox* m_IgnoreCase;
249  wxCheckBox* m_IgnoreSpace;
250  wxCheckBox* m_WholeWord;
251  wxCheckBox* m_IgnorePunct;
252  wxCheckBox* m_IgnoreSyn;
253  wxRadioButton* m_AnyLetters;
254  wxRadioButton* m_AllUpper;
255  wxRadioButton* m_AllLower;
256  wxRadioButton* m_AllPunct;
257  wxComboBox* m_MatchChoice;
258  wxButton* m_ClearButton;
259  wxButton* m_WordSubst;
260 ////@end CStringConstraintPanel member variables
261 
262  enum {
277  };
278 
279  wxBoxSizer* m_TextSizer;
282 };
283 
284 IMPLEMENT_DYNAMIC_CLASS( CAddConstraint, wxFrame )
285 
286 BEGIN_EVENT_TABLE( CAddConstraint, wxFrame )
287 
288 ////@begin CAddConstraint event table entries
289  EVT_BUTTON( wxID_OK, CAddConstraint::OnAccept )
290  EVT_BUTTON( wxID_CANCEL, CAddConstraint::OnCancel )
291 ////@end CAddConstraint event table entries
292 
294 
296 {
297  Init();
298 }
299 
300 CAddConstraint::CAddConstraint( wxWindow* parent, objects::CSeq_entry_Handle seh, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
301  : m_TopSeqEntry(seh), m_id(-1)
302 {
303  Init();
304  Create(parent, id, caption, pos, size, style);
305 }
306 
307 bool CAddConstraint::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
308 {
309 ////@begin CAddConstraint creation
310  SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
311  wxFrame::Create( parent, id, caption, pos, size, style );
312 
313  CreateControls();
314  if (GetSizer())
315  {
316  GetSizer()->SetSizeHints(this);
317  }
318  Centre(wxBOTH|wxCENTRE_ON_SCREEN);
319 ////@end CAddConstraint creation
320  return true;
321 }
322 
324 {
325 ////@begin CAddConstraint destruction
326 ////@end CAddConstraint destruction
327 }
328 
330 {
331 ////@begin CAddConstraint member initialisation
332  m_Notebook = NULL;
333 ////@end CAddConstraint member initialisation
334 }
335 
337 {
338  wxBoxSizer* itemBoxSizer1 = new wxBoxSizer(wxVERTICAL);
339  SetSizer(itemBoxSizer1);
340 
341  wxPanel* itemCBulkCmdDlg1 = new wxPanel(this, wxID_ANY);
342  itemBoxSizer1->Add(itemCBulkCmdDlg1, 1, wxGROW, 0);
343 
344  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
345  itemCBulkCmdDlg1->SetSizer(itemBoxSizer2);
346 
347  m_Notebook = new wxChoicebook( itemCBulkCmdDlg1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxCHB_TOP );
348 
349  itemBoxSizer2->Add(m_Notebook, 1, wxGROW|wxALL, 5);
350 
352  m_Notebook->AddPage(panel1,_("Taxname"));
353  panel1->SetFieldName("taxname");
354 
356  m_Notebook->AddPage(panel2,_("Source"));
357 
359  m_Notebook->AddPage(panel3,_("Feature"));
361 
363  m_Notebook->AddPage(panel4,_("CDS-Gene-Prot-mRNA"));
364  panel4->SetFieldName("protein name");
365 
367  m_Notebook->AddPage(panel5,_("RNA"));
368  panel5->SetFieldName("product");
369 
372  m_Notebook->AddPage(panel6,_("MolInfo"));
373  panel6->SetFieldName("molecule");
374 
377  m_Notebook->AddPage(panel7,_("Pub"));
378  panel7->SetFieldName("title");
379 
381  m_Notebook->AddPage(panel8,_("Structured Comment"));
382 
385  m_Notebook->AddPage(panel9,_("DBLink"));
386  panel9->SetFieldName("title");
387 
390  m_Notebook->AddPage(panel10,_("Misc"));
392 
394  m_Notebook->AddPage(panel11,_("Location"));
395 
396  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
397  itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL, 0);
398 
399  wxButton* itemButton13 = new wxButton( itemCBulkCmdDlg1, wxID_OK, _("Accept"), wxDefaultPosition, wxDefaultSize, 0 );
400  itemBoxSizer3->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
401 
402  wxButton* itemButton14 = new wxButton( itemCBulkCmdDlg1, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
403  itemBoxSizer3->Add(itemButton14, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
404 
405 }
406 
408 {
409  return true;
410 }
411 wxBitmap CAddConstraint::GetBitmapResource( const wxString& name )
412 {
413  // Bitmap retrieval
414 ////@begin CAddConstraint bitmap retrieval
415  wxUnusedVar(name);
416  return wxNullBitmap;
417 ////@end CAddConstraint bitmap retrieval
418 }
419 wxIcon CAddConstraint::GetIconResource( const wxString& name )
420 {
421  // Icon retrieval
422 ////@begin CAddConstraint icon retrieval
423  wxUnusedVar(name);
424  return wxNullIcon;
425 ////@end CAddConstraint icon retrieval
426 }
427 
428 void CAddConstraint::OnCancel( wxCommandEvent& event )
429 {
430  Close();
431 }
432 
433 void CAddConstraint::OnAccept( wxCommandEvent& event )
434 {
435  wxWindow* win = m_Notebook->GetCurrentPage();
436  IItemConstraintPanel* panel = dynamic_cast<IItemConstraintPanel*>(win);
437  pair<string, SFieldTypeAndMatcher> item = panel->GetItem(CFieldNamePanel::GetFieldTypeFromName(m_Notebook->GetPageText(m_Notebook->GetSelection()).ToStdString()));
438  if (!item.second.enabled)
439  {
440  event.Skip();
441  return;
442  }
443  item.second.top_level = m_Notebook->GetSelection();
444  wxWindow* parent = GetParent();
445  CCompoundConstraintPanel* compound_panel = dynamic_cast<CCompoundConstraintPanel*>(parent);
446  compound_panel->AddConstraint(item, m_id);
447  Close();
448 }
449 
451 {
452  if (page != wxNOT_FOUND)
453  {
454  m_Notebook->ChangeSelection(page);
455  }
456 }
457 
459 {
460  m_Notebook->SetSelection(constraint.top_level);
461  wxWindow* win = m_Notebook->GetCurrentPage();
462  IItemConstraintPanel* panel = dynamic_cast<IItemConstraintPanel*>(win);
463  panel->SetItem(constraint);
464 }
465 
466 /*!
467  * CTripleConstraintPanel constructors
468  */
469 template <typename T>
471 {
472  Init();
473 }
474 
475 template <typename T>
476 CTripleConstraintPanel<T>::CTripleConstraintPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
477 {
478  Init();
479  Create(parent, id, pos, size, style);
480 }
481 
482 
483 /*!
484  * CTripleConstraintPanel creator
485  */
486 template <typename T>
487 bool CTripleConstraintPanel<T>::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
488 {
489 ////@begin CTripleConstraintPanel creation
490  wxPanel::Create( parent, id, pos, size, style );
491 
492  CreateControls();
493  if (GetSizer())
494  {
495  GetSizer()->SetSizeHints(this);
496  }
497  Centre();
498 ////@end CTripleConstraintPanel creation
499  return true;
500 }
501 
502 
503 /*!
504  * CTripleConstraintPanel destructor
505  */
506 template <typename T>
508 {
509 ////@begin CTripleConstraintPanel destruction
510 ////@end CTripleConstraintPanel destruction
511 }
512 
513 
514 /*!
515  * Member initialisation
516  */
517 template <typename T>
519 {
520 ////@begin CTripleConstraintPanel member initialisation
521 ////@end CTripleConstraintPanel member initialisation
522  m_Notebook = NULL;
523 }
524 
525 
526 /*!
527  * Control creation for CTripleConstraintPanel
528  */
529 template <typename T>
531 {
532 ////@begin CTripleConstraintPanel content construction
533  CTripleConstraintPanel* itemPanel1 = this;
534 
535  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
536  itemPanel1->SetSizer(itemBoxSizer2);
537 
538  m_Notebook = new wxNotebook(itemPanel1, wxID_ANY, wxDefaultPosition, wxDefaultSize);
539  itemBoxSizer2->Add(m_Notebook, 1, wxGROW|wxALL, 0);
540 
541  CPresentMatcherPanel<T>* panel1 = new CPresentMatcherPanel<T>(m_Notebook);
542  m_Notebook->AddPage(panel1,_("When qualifier present"));
543 
545  m_Notebook->AddPage(panel2,_("String constraint"));
546 
547  CSameMatcherPanel<T>* panel3 = new CSameMatcherPanel<T>(m_Notebook);
548  m_Notebook->AddPage(panel3,_("When qualifiers match"));
549 }
550 
551 /*!
552  * Should we show tooltips?
553  */
554 template <typename T>
556 {
557  return true;
558 }
559 
560 /*!
561  * Get bitmap resources
562  */
563 template <typename T>
564 wxBitmap CTripleConstraintPanel<T>::GetBitmapResource( const wxString& name )
565 {
566  // Bitmap retrieval
567 ////@begin CTripleConstraintPanel bitmap retrieval
568  wxUnusedVar(name);
569  return wxNullBitmap;
570 ////@end CTripleConstraintPanel bitmap retrieval
571 }
572 
573 /*!
574  * Get icon resources
575  */
576 template <typename T>
577 wxIcon CTripleConstraintPanel<T>::GetIconResource( const wxString& name )
578 {
579  // Icon retrieval
580 ////@begin CTripleConstraintPanel icon retrieval
581  wxUnusedVar(name);
582  return wxNullIcon;
583 ////@end CTripleConstraintPanel icon retrieval
584 }
585 
586 template <typename T>
587 pair<string, SFieldTypeAndMatcher > CTripleConstraintPanel<T>::GetItem(CFieldNamePanel::EFieldType field_type)
588 {
589  wxWindow *win = m_Notebook->GetCurrentPage();
590  SFieldTypeAndMatcher field_type_matcher;
591  field_type_matcher.enabled = false;
592 
593  CMatcherPanelBase* matcher_panel = dynamic_cast<CMatcherPanelBase*>(win);
594  if (!matcher_panel)
595  return make_pair(kEmptyStr, field_type_matcher);
596 
597  string label = matcher_panel->GetLabel();
598  field_type_matcher = matcher_panel->GetMatcher(field_type);
599  field_type_matcher.second_level = m_Notebook->GetSelection();
600 
601  return make_pair(label, field_type_matcher);
602 }
603 
604 template <typename T>
606 {
607  m_Notebook->SetSelection(item.second_level);
608  wxWindow *win = m_Notebook->GetCurrentPage();
609  CMatcherPanelBase* matcher_panel = dynamic_cast<CMatcherPanelBase*>(win);
610  matcher_panel->SetMatcher(item);
611 }
612 
613 template <typename T>
615 {
616  for (size_t i = 0; i < m_Notebook->GetPageCount(); i++)
617  {
618  wxWindow *win = m_Notebook->GetPage(i);
619  CMatcherPanelBase* matcher_panel = dynamic_cast<CMatcherPanelBase*>(win);
620  if (matcher_panel)
621  matcher_panel->SetFieldName(field);
622  }
623 }
624 
625 template <typename T>
626 void CTripleConstraintPanel<T>::PopulateFeatureListbox(objects::CSeq_entry_Handle seh)
627 {
628  for (size_t i = 0; i < m_Notebook->GetPageCount(); i++)
629  {
630  wxWindow *win = m_Notebook->GetPage(i);
631  CMatcherPanelBase* matcher_panel = dynamic_cast<CMatcherPanelBase*>(win);
632  if (matcher_panel)
633  matcher_panel->PopulateFeatureListbox(seh);
634  }
635 }
636 
637 template <typename T>
638 void CTripleConstraintPanel<T>::SetFieldNames(const vector<string>& field_names)
639 {
640  for (size_t i = 0; i < m_Notebook->GetPageCount(); i++)
641  {
642  wxWindow *win = m_Notebook->GetPage(i);
643  CMatcherPanelBase* matcher_panel = dynamic_cast<CMatcherPanelBase*>(win);
644  if (matcher_panel)
645  matcher_panel->SetFieldNames(field_names);
646  }
647 }
648 
649 
650 template<typename T>
652 {
653  Init();
654 }
655 
656 template<typename T>
657 CPresentMatcherPanel<T>::CPresentMatcherPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
658 {
659  Init();
660  Create(parent, id, pos, size, style);
661 }
662 
663 template<typename T>
664 bool CPresentMatcherPanel<T>::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
665 {
666  wxPanel::Create( parent, id, pos, size, style );
667 
668  CreateControls();
669  if (GetSizer())
670  {
671  GetSizer()->SetSizeHints(this);
672  }
673  Centre();
674  return true;
675 }
676 
677 template<typename T>
679 {
680 }
681 
682 template<typename T>
684 {
685  m_panel = NULL;
686 }
687 
688 template<typename T>
690 {
691  CPresentMatcherPanel<T>* itemPanel1 = this;
692 
693  wxBoxSizer* itemBoxSizer1 = new wxBoxSizer(wxVERTICAL);
694  itemPanel1->SetSizer(itemBoxSizer1);
695 
696  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
697  itemBoxSizer1->Add(itemBoxSizer2, 0, wxALIGN_CENTER_HORIZONTAL, 0);
698 
699  m_panel= new T(itemPanel1);
700  itemBoxSizer2->Add(m_panel, 0, wxALIGN_TOP|wxALL, 5);
701 }
702 
703 
704 template<typename T>
706 {
707  return true;
708 }
709 
710 template<typename T>
711 wxBitmap CPresentMatcherPanel<T>::GetBitmapResource( const wxString& name )
712 {
713  wxUnusedVar(name);
714  return wxNullBitmap;
715 }
716 
717 template<typename T>
718 wxIcon CPresentMatcherPanel<T>::GetIconResource( const wxString& name )
719 {
720  wxUnusedVar(name);
721  return wxNullIcon;
722 }
723 
724 template <typename T>
726 {
727  CFieldNamePanel* field_name_panel = dynamic_cast<CFieldNamePanel*>(m_panel);
728  SFieldTypeAndMatcher field_type_matcher;
729  string field = field_name_panel ? field_name_panel->GetFieldName(true) : CFieldNamePanel::GetFieldTypeName(field_type);
730  field_type_matcher.field = field;
731 
732  string ncRNA_class;
733  field_type_matcher.subtype = GetSubtype(field_name_panel, ncRNA_class);
734  field_type_matcher.m_ncRNAClass = ncRNA_class;
735 
736  field_type_matcher.field_type = field_type;
738  field_type_matcher.enabled = !field.empty();
739  field_type_matcher.full_field = field_name_panel->GetFieldName(false);
740  return field_type_matcher;
741 }
742 
743 template <typename T>
745 {
746  m_panel->SetFieldName(matcher.full_field);
747 }
748 
749 template <typename T>
751 {
752  CFieldNamePanel* field_name_panel = dynamic_cast<CFieldNamePanel*>(m_panel);
753  if (field_name_panel)
754  {
755  string field = field_name_panel->GetFieldName(false);
756  return "where " + field + " is present";
757  }
758  return kEmptyStr;
759 }
760 
761 template <typename T>
762 void CPresentMatcherPanel<T>::SetFieldName(const string& field)
763 {
764  m_panel->SetFieldName(field);
765 }
766 
767 template <typename T>
768 void CPresentMatcherPanel<T>::PopulateFeatureListbox(objects::CSeq_entry_Handle seh)
769 {
770  CFeatureFieldNamePanel *panel = dynamic_cast<CFeatureFieldNamePanel*>(m_panel);
771  if (panel)
772  panel->ListPresentFeaturesFirst(seh);
773 }
774 
775 template <typename T>
776 void CPresentMatcherPanel<T>::SetFieldNames(const vector<string>& field_names)
777 {
778  CFieldHandlerNamePanel *panel = dynamic_cast<CFieldHandlerNamePanel*>(m_panel);
779  if (panel)
780  panel->SetFieldNames(field_names);
781 }
782 
783 
784 // Dual Source Panel
785 
786 template<typename T>
788 {
789  Init();
790 }
791 
792 template<typename T>
793 CSameMatcherPanel<T>::CSameMatcherPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
794 {
795  Init();
796  Create(parent, id, pos, size, style);
797 }
798 
799 template<typename T>
800 bool CSameMatcherPanel<T>::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
801 {
802  wxPanel::Create( parent, id, pos, size, style );
803 
804  CreateControls();
805  if (GetSizer())
806  {
807  GetSizer()->SetSizeHints(this);
808  }
809  Centre();
810  return true;
811 }
812 
813 template<typename T>
815 {
816 }
817 
818 template<typename T>
820 {
821  m_panel1 = NULL;
822  m_panel2 = NULL;
823 }
824 
825 template<typename T>
827 {
828  CSameMatcherPanel<T>* itemPanel1 = this;
829 
830  wxBoxSizer* itemBoxSizer1 = new wxBoxSizer(wxVERTICAL);
831  itemPanel1->SetSizer(itemBoxSizer1);
832 
833  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
834  itemBoxSizer1->Add(itemBoxSizer2, 0, wxALIGN_CENTER_HORIZONTAL, 0);
835 
836  m_panel1 = new T(itemPanel1);
837  itemBoxSizer2->Add(m_panel1, 0, wxALIGN_TOP|wxALL, 5);
838 
839  m_panel2 = new T(itemPanel1);
840  itemBoxSizer2->Add(m_panel2, 0, wxALIGN_TOP|wxALL, 5);
841 }
842 
843 
844 template<typename T>
846 {
847  return true;
848 }
849 
850 template<typename T>
851 wxBitmap CSameMatcherPanel<T>::GetBitmapResource( const wxString& name )
852 {
853  wxUnusedVar(name);
854  return wxNullBitmap;
855 }
856 
857 template<typename T>
858 wxIcon CSameMatcherPanel<T>::GetIconResource( const wxString& name )
859 {
860  wxUnusedVar(name);
861  return wxNullIcon;
862 }
863 
864 template <typename T>
866 {
867  SFieldTypeAndMatcher field_type_matcher;
868  CFieldNamePanel* field_name_panel1 = dynamic_cast<CFieldNamePanel*>(m_panel1);
869  string field1 = field_name_panel1 ? field_name_panel1->GetFieldName(true) : CFieldNamePanel::GetFieldTypeName(field_type);
870  field_type_matcher.field = field1;
871 
872  string ncRNA_class_1;
873  field_type_matcher.subtype = GetSubtype(field_name_panel1, ncRNA_class_1);
874  field_type_matcher.m_ncRNAClass = ncRNA_class_1;
875 
876  field_type_matcher.field_type = field_type;
877 
878  CFieldNamePanel* field_name_panel2 = dynamic_cast<CFieldNamePanel*>(m_panel2);
879  string field2 = field_name_panel2 ? field_name_panel2->GetFieldName(true) : CFieldNamePanel::GetFieldTypeName(field_type);
880  string ncRNA_class_2;
881  int subtype2 = GetSubtype(field_name_panel2, ncRNA_class_2);
882  field_type_matcher.matcher = CRef<CConstraintMatcher>(new CSameConstraintMatcher(field2, field_type, subtype2, ncRNA_class_2));
883  field_type_matcher.enabled = !field1.empty() && !field2.empty();
884 
885  field_type_matcher.field2 = field2;
886  field_type_matcher.subtype2 = subtype2;
887  field_type_matcher.field_type2 = field_type;
888  field_type_matcher.matcher2 = CRef<CConstraintMatcher>(new CSameConstraintMatcher(field1, field_type, field_type_matcher.subtype, ncRNA_class_1));
889  field_type_matcher.enabled2 = !field1.empty() && !field2.empty();
890 
891  field_type_matcher.full_field = field_name_panel1->GetFieldName(false);
892  field_type_matcher.full_field2 = field_name_panel2->GetFieldName(false);
893 
894  return field_type_matcher;
895 }
896 
897 template <typename T>
899 {
900  m_panel1->SetFieldName(matcher.full_field);
901  m_panel2->SetFieldName(matcher.full_field2);
902 }
903 
904 template <typename T>
906 {
907  CFieldNamePanel* field_name_panel1 = dynamic_cast<CFieldNamePanel*>(m_panel1);
908  CFieldNamePanel* field_name_panel2 = dynamic_cast<CFieldNamePanel*>(m_panel2);
909  if (field_name_panel1 && field_name_panel2)
910  {
911  string field1 = field_name_panel1->GetFieldName(false);
912  string field2 = field_name_panel2->GetFieldName(false);
913  return "where " + field1 + " matches " + field2;
914  }
915  return kEmptyStr;
916 }
917 
918 template <typename T>
919 void CSameMatcherPanel<T>::SetFieldName(const string& field)
920 {
921  m_panel1->SetFieldName(field);
922  m_panel2->SetFieldName(field);
923 }
924 
925 template <typename T>
926 void CSameMatcherPanel<T>::PopulateFeatureListbox(objects::CSeq_entry_Handle seh)
927 {
928  CFeatureFieldNamePanel *panel1 = dynamic_cast<CFeatureFieldNamePanel*>(m_panel1);
929  if (panel1)
930  panel1->ListPresentFeaturesFirst(seh);
931  CFeatureFieldNamePanel *panel2 = dynamic_cast<CFeatureFieldNamePanel*>(m_panel2);
932  if (panel2)
933  panel2->ListPresentFeaturesFirst(seh);
934 }
935 
936 template <typename T>
937 void CSameMatcherPanel<T>::SetFieldNames(const vector<string>& field_names)
938 {
939  CFieldHandlerNamePanel *panel1 = dynamic_cast<CFieldHandlerNamePanel*>(m_panel1);
940  if (panel1)
941  panel1->SetFieldNames(field_names);
942  CFieldHandlerNamePanel *panel2 = dynamic_cast<CFieldHandlerNamePanel*>(m_panel2);
943  if (panel2)
944  panel2->SetFieldNames(field_names);
945 }
946 
947 
948 
949 /*!
950  * CAdvStringConstraintPanel constructors
951  */
952 template<typename T>
954 {
955  Init();
956 }
957 
958 template<typename T>
959 CAdvStringConstraintPanel<T>::CAdvStringConstraintPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
960 {
961  Init();
962  Create(parent, id, pos, size, style);
963 }
964 
965 
966 /*!
967  * CAdvStringConstraintPanel creator
968  */
969 template<typename T>
970 bool CAdvStringConstraintPanel<T>::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
971 {
972 ////@begin CAdvStringConstraintPanel creation
973  wxPanel::Create( parent, id, pos, size, style );
974 
975  CreateControls();
976  if (GetSizer())
977  {
978  GetSizer()->SetSizeHints(this);
979  }
980  Centre();
981 ////@end CAdvStringConstraintPanel creation
982  ShowChoiceOrText();
983 
984  return true;
985 }
986 
987 
988 /*!
989  * CAdvStringConstraintPanel destructor
990  */
991 template<typename T>
993 {
994 ////@begin CAdvStringConstraintPanel destruction
995 ////@end CAdvStringConstraintPanel destruction
996 }
997 
998 
999 /*!
1000  * Member initialisation
1001  */
1002 template<typename T>
1004 {
1005 ////@begin CAdvStringConstraintPanel member initialisation
1006  m_panel = NULL;
1007  m_MatchType = NULL;
1008  m_MatchText = NULL;
1009  m_IgnoreCase = NULL;
1010  m_IgnoreSpace = NULL;
1011  m_WholeWord = NULL;
1012  m_IgnorePunct = NULL;
1013  m_IgnoreSyn = NULL;
1014  m_AnyLetters = NULL;
1015  m_AllUpper = NULL;
1016  m_AllLower = NULL;
1017  m_AllPunct = NULL;
1018  m_MatchChoice = NULL;
1019  m_TextSizer = NULL;
1020  m_ClearButton = NULL;
1021  m_WordSubst = NULL;
1022  m_is_choice = false;
1023 ////@end CAdvStringConstraintPanel member initialisation
1024 }
1025 
1026 
1027 /*!
1028  * Control creation for CAdvStringConstraintPanel
1029  */
1030 template<typename T>
1032 {
1033 ////@begin CAdvStringConstraintPanel content construction
1034  //CAdvStringConstraintPanel* itemPanel1 = this;
1035  wxPanel* parentPanel = this;
1036  wxBoxSizer* itemBoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
1037  parentPanel->SetSizer(itemBoxSizer1);
1038 
1039  m_panel = new T(parentPanel);
1040  itemBoxSizer1->Add(m_panel, 0, wxALIGN_TOP|wxALL, 5);
1041 
1042  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
1043  itemBoxSizer1->Add(itemBoxSizer2, 0, wxALIGN_TOP|wxALL, 5);
1044 
1045  wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
1046  itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
1047 
1048  wxArrayString m_MatchTypeStrings;
1049  m_MatchTypeStrings.Add(_("Contains"));
1050  m_MatchTypeStrings.Add(_("Does not contain"));
1051  m_MatchTypeStrings.Add(_("Equals"));
1052  m_MatchTypeStrings.Add(_("Does not equal"));
1053  m_MatchTypeStrings.Add(_("Starts with"));
1054  m_MatchTypeStrings.Add(_("Ends with"));
1055  m_MatchTypeStrings.Add(_("Is one of"));
1056  m_MatchTypeStrings.Add(_("Is not one of"));
1057  m_MatchTypeStrings.Add(_("Does not start with"));
1058  m_MatchTypeStrings.Add(_("Does not end with"));
1059 
1060  m_MatchType = new wxChoice( parentPanel, ID_STRING_CONSTRAINT_MATCH_CHOICE, wxDefaultPosition, wxDefaultSize, m_MatchTypeStrings, 0 );
1061  m_MatchType->SetStringSelection(_("Contains"));
1062  itemBoxSizer3->Add(m_MatchType, 0, wxALIGN_TOP|wxLEFT|wxRIGHT|wxBOTTOM, 5);
1063  m_MatchType->Bind(wxEVT_CHOICE, &CAdvStringConstraintPanel<T>::OnMatchTypeSelected, this);
1064 
1065  m_TextSizer = new wxBoxSizer(wxVERTICAL);
1066  itemBoxSizer3->Add(m_TextSizer, 0, wxALIGN_TOP, 0);
1067 
1068  m_MatchText = new wxTextCtrl( parentPanel, ID_STRING_CONSTRAINT_MATCH_TEXT, wxEmptyString, wxDefaultPosition, wxSize(300, -1), wxTE_MULTILINE );
1069  m_TextSizer->Add(m_MatchText, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5);
1070  wxArrayString choice_strings;
1071  m_MatchChoice = new wxComboBox(parentPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(300, -1), choice_strings, 0 );
1072  m_MatchChoice->Hide();
1073 
1074 
1075  wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
1076  itemBoxSizer2->Add(itemBoxSizer6, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
1077 
1078  m_IgnoreCase = new wxCheckBox( parentPanel, ID_STRING_CONSTRAINT_CHECKBOX5, _("Ignore Case"), wxDefaultPosition, wxDefaultSize, 0 );
1079  m_IgnoreCase->SetValue(false);
1080  itemBoxSizer6->Add(m_IgnoreCase, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1081 
1082  m_IgnoreSpace = new wxCheckBox( parentPanel, ID_STRING_CONSTRAINT_CHECKBOX6, _("Ignore Space"), wxDefaultPosition, wxDefaultSize, 0 );
1083  m_IgnoreSpace->SetValue(false);
1084  itemBoxSizer6->Add(m_IgnoreSpace, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1085 
1086  m_IgnorePunct = new wxCheckBox( parentPanel, ID_STRING_CONSTRAINT_CHECKBOX8, _("Ignore Punctuation"), wxDefaultPosition, wxDefaultSize, 0 );
1087  m_IgnorePunct->SetValue(false);
1088  itemBoxSizer6->Add(m_IgnorePunct, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1089 
1090  wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
1091  itemBoxSizer2->Add(itemBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
1092 
1093  m_WholeWord = new wxCheckBox( parentPanel, ID_STRING_CONSTRAINT_CHECKBOX7, _("Whole Word"), wxDefaultPosition, wxDefaultSize, 0 );
1094  m_WholeWord->SetValue(false);
1095  itemBoxSizer7->Add(m_WholeWord, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1096 
1097  m_IgnoreSyn = new wxCheckBox( parentPanel, ID_STRING_CONSTRAINT_CHECKBOX9, _("Ignore 'putative' synonyms"), wxDefaultPosition, wxDefaultSize, 0 );
1098  m_IgnoreSyn->SetValue(false);
1099  itemBoxSizer7->Add(m_IgnoreSyn, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1100 
1101  wxBoxSizer* itemBoxSizer8 = new wxBoxSizer(wxHORIZONTAL);
1102  itemBoxSizer2->Add(itemBoxSizer8, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
1103 
1104  m_AnyLetters = new wxRadioButton( parentPanel, ID_STRING_CONSTRAINT_RADIO0, _("Any letters"), wxDefaultPosition, wxDefaultSize, 0 );
1105  m_AnyLetters->SetValue(true);
1106  itemBoxSizer8->Add(m_AnyLetters, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1107 
1108  m_AllUpper = new wxRadioButton( parentPanel, ID_STRING_CONSTRAINT_RADIO1, _("All letters are upper case"), wxDefaultPosition, wxDefaultSize, 0 );
1109  m_AllUpper->SetValue(false);
1110  itemBoxSizer8->Add(m_AllUpper, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1111 
1112  m_AllLower = new wxRadioButton( parentPanel, ID_STRING_CONSTRAINT_RADIO2, _("All letters are lower case"), wxDefaultPosition, wxDefaultSize, 0 );
1113  m_AllLower->SetValue(false);
1114  itemBoxSizer8->Add(m_AllLower, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1115 
1116  m_AllPunct = new wxRadioButton( parentPanel, ID_STRING_CONSTRAINT_RADIO3, _("All characters are punctuation"), wxDefaultPosition, wxDefaultSize, 0 );
1117  m_AllPunct->SetValue(false);
1118  itemBoxSizer8->Add(m_AllPunct, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1119 
1120  wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxHORIZONTAL);
1121  itemBoxSizer2->Add(itemBoxSizer9, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
1122 
1123  m_ClearButton = new wxButton( parentPanel, ID_STRING_CONSTRAINT_CLEAR_BUTTON, _("Clear Constraint"), wxDefaultPosition, wxDefaultSize, 0 );
1124  itemBoxSizer9->Add(m_ClearButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1125  //m_ClearButton->Bind(wxEVT_BUTTON, &CAdvStringConstraintPanel<T>::OnClear, this);
1126  m_ClearButton->Connect(ID_STRING_CONSTRAINT_CLEAR_BUTTON, wxEVT_BUTTON, wxCommandEventHandler(CAdvStringConstraintPanel<T>::OnClear), NULL, this);
1127 
1128  m_WordSubst = new wxButton( parentPanel, ID_STRING_CONSTRAINT_WORDSUBST_BUTTON, _("Word Substitutions"), wxDefaultPosition, wxDefaultSize, 0 );
1129  itemBoxSizer9->Add(m_WordSubst, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
1130  //m_WordSubst->Bind(wxEVT_BUTTON, &CAdvStringConstraintPanel<T>::OnWordSubstitution, this);
1131  m_WordSubst->Connect(ID_STRING_CONSTRAINT_WORDSUBST_BUTTON, wxEVT_BUTTON, wxCommandEventHandler(CAdvStringConstraintPanel<T>::OnWordSubstitution), NULL, this);
1132 
1133  ////@end CAdvStringConstraintPanel content construction
1134 
1135  CFieldNamePanel* panel = dynamic_cast<CFieldNamePanel*>(m_panel);
1136  if (panel)
1137  {
1138  bool allow_other = true;
1139  vector<string> choices = panel->GetChoices(allow_other);
1140  SetChoices(choices);
1141  }
1142 }
1143 
1144 template<typename T>
1145 void CAdvStringConstraintPanel<T>::OnClear( wxCommandEvent& event )
1146 {
1147  ClearValues();
1148 }
1149 
1150 template<typename T>
1152 {
1153  if (m_is_choice)
1154  {
1155  m_MatchChoice->Hide();
1156  m_TextSizer->Replace(m_MatchChoice, m_MatchText);
1157  m_MatchText->Show();
1158  m_is_choice = false;
1159  Layout();
1160  Fit();
1161  }
1162  m_MatchType->SetStringSelection(_("Contains"));
1163  m_MatchText->SetValue(wxEmptyString);
1164  m_IgnoreCase->SetValue(false);
1165  m_IgnoreSpace->SetValue(false);
1166  m_WholeWord->SetValue(false);
1167  m_IgnorePunct->SetValue(false);
1168  m_IgnoreSyn->SetValue(false);
1169  m_AnyLetters->SetValue(true);
1170  m_AllUpper->SetValue(false);
1171  m_AllLower->SetValue(false);
1172  m_AllPunct->SetValue(false);
1173  m_word_subst.Reset();
1174 }
1175 
1176 template<typename T>
1177 void CAdvStringConstraintPanel<T>::SetChoices(const vector<string> &choices)
1178 {
1179  wxArrayString choice_strings;
1180  ITERATE(vector<string>, it, choices)
1181  {
1182  choice_strings.Add(ToWxString(*it));
1183  }
1184  m_MatchChoice->Set(choice_strings);
1185  ShowChoiceOrText();
1186 }
1187 
1188 template<typename T>
1190 {
1191  if (!m_MatchChoice->IsListEmpty() && (m_MatchType->GetSelection() == eMatchType_Equals || m_MatchType->GetSelection() == eMatchType_DoesNotEqual) )
1192  {
1193  if (!m_is_choice)
1194  {
1195  m_MatchText->Hide();
1196  m_TextSizer->Replace(m_MatchText, m_MatchChoice);
1197  m_MatchChoice->Show();
1198  }
1199  m_is_choice = true;
1200  }
1201  else
1202  {
1203  if (m_is_choice)
1204  {
1205  m_MatchChoice->Hide();
1206  m_TextSizer->Replace(m_MatchChoice, m_MatchText);
1207  m_MatchText->Show();
1208  }
1209  m_is_choice = false;
1210  }
1211  Layout();
1212  Fit();
1213 
1214 }
1215 
1216 template<typename T>
1218 {
1219  ShowChoiceOrText();
1220  event.Skip();
1221 }
1222 
1223 /*!
1224  * Should we show tooltips?
1225  */
1226 template<typename T>
1228 {
1229  return true;
1230 }
1231 
1232 /*!
1233  * Get bitmap resources
1234  */
1235 template<typename T>
1236 wxBitmap CAdvStringConstraintPanel<T>::GetBitmapResource( const wxString& name )
1237 {
1238  // Bitmap retrieval
1239 ////@begin CAdvStringConstraintPanel bitmap retrieval
1240  wxUnusedVar(name);
1241  return wxNullBitmap;
1242 ////@end CAdvStringConstraintPanel bitmap retrieval
1243 }
1244 
1245 /*!
1246  * Get icon resources
1247  */
1248 template<typename T>
1250 {
1251  // Icon retrieval
1252 ////@begin CAdvStringConstraintPanel icon retrieval
1253  wxUnusedVar(name);
1254  return wxNullIcon;
1255 ////@end CAdvStringConstraintPanel icon retrieval
1256 }
1257 
1258 template <typename T>
1260 {
1261  CFieldNamePanel* panel = dynamic_cast<CFieldNamePanel*>(m_panel);
1262  if (panel)
1263  {
1264  bool allow_other = true;
1265  vector<string> choices = panel->GetChoices(allow_other);
1266  SetChoices(choices);
1267  }
1268 }
1269 
1270 template <typename T>
1272 {
1273  CFieldNamePanel* field_name_panel = dynamic_cast<CFieldNamePanel*>(m_panel);
1274  SFieldTypeAndMatcher field_type_matcher;
1275  string field = field_name_panel ? field_name_panel->GetFieldName(true) : CFieldNamePanel::GetFieldTypeName(field_type);
1276  field_type_matcher.field = field;
1277 
1278  string ncRNA_class;
1279  field_type_matcher.subtype = GetSubtype(field_name_panel, ncRNA_class);
1280  field_type_matcher.m_ncRNAClass = ncRNA_class;
1281 
1282  field_type_matcher.field_type = field_type;
1283  CRef<CString_constraint> sc = GetStringConstraint();
1284  field_type_matcher.matcher = CRef<CConstraintMatcher>(new CAdvancedConstraintMatcher(sc));
1285  field_type_matcher.enabled = !field.empty() && !sc->Empty();
1286  field_type_matcher.full_field = field_name_panel->GetFieldName(false);
1287  field_type_matcher.string_constraint = sc;
1288  return field_type_matcher;
1289 }
1290 
1291 template <typename T>
1293 {
1294  CFieldNamePanel* field_name_panel = dynamic_cast<CFieldNamePanel*>(m_panel);
1295  if (field_name_panel)
1296  {
1297  string field = field_name_panel->GetFieldName(false);
1298  return "where " + field + " " + GetDescription();
1299  }
1300  return kEmptyStr;
1301 }
1302 
1303 template <typename T>
1305 {
1306  string match_text;
1307  if (!m_is_choice)
1308  match_text = NStr::Replace(NStr::Replace(ToStdString(m_MatchText->GetValue()),"\r"," "),"\n"," ");
1309  else
1310  match_text = NStr::Replace(NStr::Replace(ToStdString(m_MatchChoice->GetValue()),"\r"," "),"\n"," ");
1311 
1313  c->SetMatch_text(match_text);
1314  c->SetCase_sensitive(!m_IgnoreCase->GetValue());
1315  c->SetIgnore_space(m_IgnoreSpace->GetValue());
1316  c->SetIgnore_punct(m_IgnorePunct->GetValue());
1317  c->SetWhole_word(m_WholeWord->GetValue());
1318  c->SetIs_all_caps(m_AllUpper->GetValue());
1319  c->SetIs_all_lower(m_AllLower->GetValue());
1320  c->SetIs_all_punct(m_AllPunct->GetValue());
1321  c->SetIgnore_weasel(m_IgnoreSyn->GetValue());
1322 
1323  if (m_word_subst && m_word_subst->IsSet() && !m_word_subst->Get().empty())
1324  {
1325  c->SetIgnore_words(*m_word_subst);
1326  }
1327 
1328  switch(m_MatchType->GetSelection()) {
1329  case eMatchType_Contains:
1331  break;
1332  case eMatchType_DoesNotContain:
1334  c->SetNot_present(true);
1335  break;
1336  case eMatchType_Equals:
1338  break;
1339  case eMatchType_DoesNotEqual:
1341  c->SetNot_present(true);
1342  break;
1343  case eMatchType_StartsWith:
1345  break;
1346  case eMatchType_EndsWith:
1348  break;
1349  case eMatchType_IsOneOf:
1351  break;
1352  case eMatchType_IsNotOneOf:
1354  c->SetNot_present(true);
1355  break;
1356  case eMatchType_DoesNotStartWith:
1358  c->SetNot_present(true);
1359  break;
1360  case eMatchType_DoesNotEndWith:
1362  c->SetNot_present(true);
1363  break;
1364  default: c.Reset(); break;
1365  }
1366 
1367  return c;
1368 }
1369 
1370 template <typename T>
1372 {
1373  string str;
1374 
1375  string match_text;
1376  if (!m_is_choice)
1377  match_text = NStr::Replace(NStr::Replace(ToStdString(m_MatchText->GetValue()),"\r"," "),"\n"," ");
1378  else
1379  match_text = NStr::Replace(NStr::Replace(ToStdString(m_MatchChoice->GetValue()),"\r"," "),"\n"," ");
1380 
1381  if (!match_text.empty())
1382  {
1383  switch(m_MatchType->GetSelection()) {
1384  case eMatchType_Contains:
1385  str = "contains ";
1386  break;
1387  case eMatchType_DoesNotContain:
1388  str = "does not contain ";
1389  break;
1390  case eMatchType_Equals:
1391  str = "equals ";
1392  break;
1393  case eMatchType_DoesNotEqual:
1394  str = "does not equal ";
1395  break;
1396  case eMatchType_StartsWith:
1397  str = "starts with ";
1398  break;
1399  case eMatchType_EndsWith:
1400  str = "ends with ";
1401  break;
1402  case eMatchType_IsOneOf:
1403  str = "is one of ";
1404  break;
1405  case eMatchType_IsNotOneOf:
1406  str = "is not one of ";
1407  break;
1408  case eMatchType_DoesNotStartWith:
1409  str = "does not start with ";
1410  break;
1411  case eMatchType_DoesNotEndWith:
1412  str = "does not ends with ";
1413  break;
1414  default: break;
1415  }
1416 
1417 
1418  str += "'" + match_text + "' ";
1419 
1420  vector<string> subs;
1421  if (!m_IgnoreCase->GetValue())
1422  subs.push_back("case-sensitive");
1423 
1424  if (m_IgnoreSpace->GetValue())
1425  subs.push_back("ignore spaces");
1426 
1427  if (m_IgnorePunct->GetValue())
1428  subs.push_back("ignore punctuation");
1429 
1430  if (m_WholeWord->GetValue())
1431  subs.push_back("whole word");
1432 
1433  if (m_IgnoreSyn->GetValue())
1434  subs.push_back("ignore 'putative' synonyms");
1435 
1436  if (!subs.empty())
1437  {
1438  string sub = NStr::Join(subs, ", ");
1439  str += "(" + sub + ")";
1440  }
1441 
1442  if (m_word_subst && m_word_subst->IsSet())
1443  {
1444  for (auto ws : m_word_subst->Set())
1445  {
1447  str += ", " + label;
1448  }
1449  }
1450 
1451  }
1452 
1453 
1454  string sub;
1455  if (m_AllUpper->GetValue())
1456  sub = "all letters are upper case";
1457 
1458  if (m_AllLower->GetValue())
1459  sub = "all letters are lower case";
1460 
1461  if (m_AllPunct->GetValue())
1462  sub = "all characters are punctiation";
1463 
1464  if (!sub.empty())
1465  {
1466  if (!str.empty())
1467  str += ", ";
1468  str += sub;
1469  }
1470 
1471  return str;
1472 }
1473 
1474 template <typename T>
1476 {
1477  CWordSubstitutionDlg * dlg = new CWordSubstitutionDlg(this, m_word_subst);
1478  dlg->Show(true);
1479 }
1480 
1481 template <typename T>
1483 {
1484  m_word_subst = word_subst;
1485 }
1486 
1487 template <typename T>
1489 {
1490  m_panel->SetFieldName(field);
1491 }
1492 
1493 template <typename T>
1495 {
1496  m_panel->SetFieldName(item.full_field);
1498 
1499  string match_text = c->GetMatch_text();
1500 
1501  m_IgnoreCase->SetValue(!c->GetCase_sensitive());
1502  m_IgnoreSpace->SetValue(c->GetIgnore_space());
1503  m_IgnorePunct->SetValue(c->GetIgnore_punct());
1504  m_WholeWord->SetValue(c->GetWhole_word());
1505  m_AllUpper->SetValue(c->GetIs_all_caps());
1506  m_AllLower->SetValue(c->GetIs_all_lower());
1507  m_AllPunct->SetValue(c->GetIs_all_punct());
1508  m_IgnoreSyn->SetValue(c->GetIgnore_weasel());
1509 
1510  if (c->IsSetIgnore_words())
1511  {
1512  m_word_subst.Reset(new objects::CWord_substitution_set);
1513  m_word_subst->Assign(c->GetIgnore_words());
1514  }
1515 
1516  if (c->IsSetNot_present() && c->GetNot_present())
1517  {
1518  switch (c->GetMatch_location())
1519  {
1520  case eString_location_contains : m_MatchType->SetSelection(eMatchType_DoesNotContain); break;
1521  case eString_location_equals : m_MatchType->SetSelection(eMatchType_DoesNotEqual); break;
1522  case eString_location_starts : m_MatchType->SetSelection(eMatchType_DoesNotStartWith); break;
1523  case eString_location_ends : m_MatchType->SetSelection(eMatchType_DoesNotEndWith); break;
1524  case eString_location_inlist : m_MatchType->SetSelection(eMatchType_IsNotOneOf); break;
1525  default : break;
1526  }
1527  }
1528  else
1529  {
1530  switch (c->GetMatch_location())
1531  {
1532  case eString_location_contains : m_MatchType->SetSelection(eMatchType_Contains); break;
1533  case eString_location_equals : m_MatchType->SetSelection(eMatchType_Equals); break;
1534  case eString_location_starts : m_MatchType->SetSelection(eMatchType_StartsWith); break;
1535  case eString_location_ends : m_MatchType->SetSelection(eMatchType_EndsWith); break;
1536  case eString_location_inlist : m_MatchType->SetSelection(eMatchType_IsOneOf); break;
1537  default : break;
1538  }
1539  }
1540 
1541  ShowChoiceOrText();
1542 
1543  if (!m_is_choice)
1544  m_MatchText->SetValue(wxString(match_text));
1545  else
1546  m_MatchChoice->SetValue(wxString(match_text));
1547 }
1548 
1549 template <typename T>
1550 void CAdvStringConstraintPanel<T>::PopulateFeatureListbox(objects::CSeq_entry_Handle seh)
1551 {
1552  CFeatureFieldNamePanel *panel = dynamic_cast<CFeatureFieldNamePanel*>(m_panel);
1553  if (panel)
1554  panel->ListPresentFeaturesFirst(seh);
1555 }
1556 
1557 template <typename T>
1558 void CAdvStringConstraintPanel<T>::SetFieldNames(const vector<string>& field_names)
1559 {
1560  CFieldHandlerNamePanel *panel = dynamic_cast<CFieldHandlerNamePanel*>(m_panel);
1561  if (panel)
1562  panel->SetFieldNames(field_names);
1563 }
1564 
1566 {
1567  wxPanel::Create( parent);
1568  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
1569  SetSizer(itemBoxSizer2);
1571  itemBoxSizer2->Add(win, 1, wxGROW|wxALL, 0);
1572  m_panel = win;
1573 
1574  if (GetSizer())
1575  {
1576  GetSizer()->SetSizeHints(this);
1577  }
1578  Centre();
1579 }
1580 
#define SYMBOL_CADVSTRINGCONSTRAINTPANEL_STYLE
#define SYMBOL_CADVSTRINGCONSTRAINTPANEL_IDNAME
#define SYMBOL_CADVSTRINGCONSTRAINTPANEL_POSITION
#define SYMBOL_CADVSTRINGCONSTRAINTPANEL_SIZE
wxChoicebook * m_Notebook
static bool ShowToolTips()
wxBitmap GetBitmapResource(const wxString &name)
void OnCancel(wxCommandEvent &event)
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &caption=_("Constraint"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
wxIcon GetIconResource(const wxString &name)
objects::CSeq_entry_Handle m_TopSeqEntry
void SetSelection(int page)
void OnAccept(wxCommandEvent &event)
void SetConstraint(const SFieldTypeAndMatcher &constraint)
CRef< objects::CWord_substitution_set > m_word_subst
void SetChoices(const vector< string > &choices)
void Init()
Initialises member variables.
virtual void SetMatcher(const SFieldTypeAndMatcher &item)
void CreateControls()
Creates the controls and sizers.
virtual void SetFieldNames(const vector< string > &field_names)
virtual void AddWordSubstSet(CRef< objects::CWord_substitution_set > word_subst)
void OnWordSubstitution(wxCommandEvent &event)
void OnClear(wxCommandEvent &event)
static bool ShowToolTips()
Should we show tooltips?
virtual SFieldTypeAndMatcher GetMatcher(CFieldNamePanel::EFieldType field_type)
void OnMatchTypeSelected(wxCommandEvent &event)
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
wxDECLARE_NO_COPY_CLASS(CAdvStringConstraintPanel)
virtual void SetFieldName(const string &field)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
bool Create(wxWindow *parent, wxWindowID id=ID_CADVSTRINGCONSTRAINTPANEL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
Creation.
CRef< objects::CString_constraint > GetStringConstraint()
virtual void PopulateFeatureListbox(objects::CSeq_entry_Handle seh)
void AddConstraint(pair< string, SFieldTypeAndMatcher > item, int id)
static vector< string > GetFieldNames()
void ListPresentFeaturesFirst(objects::CSeq_entry_Handle seh, vector< const objects::CFeatListItem * > *featlist=nullptr)
void SetFieldNames(const vector< string > &field_names)
virtual string GetFieldName(const bool subfield=false)=0
Returns the name of the field as selected in the panel.
virtual vector< string > GetChoices(bool &allow_other)
static string GetFieldTypeName(EFieldType field_type)
static EFieldType GetFieldTypeFromName(const string &field_type_name)
virtual string GetLabel(void)=0
virtual void PopulateFeatureListbox(objects::CSeq_entry_Handle seh)
virtual void SetMatcher(const SFieldTypeAndMatcher &item)=0
virtual void SetFieldNames(const vector< string > &field_names)
virtual void SetFieldName(const string &field)
virtual SFieldTypeAndMatcher GetMatcher(CFieldNamePanel::EFieldType field_type)=0
static vector< string > GetStrings()
static vector< string > GetFieldNames()
wxBitmap GetBitmapResource(const wxString &name)
virtual string GetLabel(void)
wxDECLARE_NO_COPY_CLASS(CPresentMatcherPanel)
virtual void SetFieldNames(const vector< string > &field_names)
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
virtual void SetMatcher(const SFieldTypeAndMatcher &item)
wxIcon GetIconResource(const wxString &name)
virtual void PopulateFeatureListbox(objects::CSeq_entry_Handle seh)
virtual SFieldTypeAndMatcher GetMatcher(CFieldNamePanel::EFieldType field_type)
virtual void SetFieldName(const string &field)
static vector< string > GetFieldNames(bool extended=false)
virtual SFieldTypeAndMatcher GetMatcher(CFieldNamePanel::EFieldType field_type)
virtual void PopulateFeatureListbox(objects::CSeq_entry_Handle seh)
wxIcon GetIconResource(const wxString &name)
wxBitmap GetBitmapResource(const wxString &name)
virtual void SetFieldName(const string &field)
wxDECLARE_NO_COPY_CLASS(CSameMatcherPanel)
virtual string GetLabel(void)
virtual void SetMatcher(const SFieldTypeAndMatcher &item)
virtual void SetFieldNames(const vector< string > &field_names)
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
void SetMatch_text(const TMatch_text &value)
void SetFieldName(const string &field)
wxDECLARE_NO_COPY_CLASS(CTripleConstraintPanel)
virtual pair< string, SFieldTypeAndMatcher > GetItem(CFieldNamePanel::EFieldType field_type)
virtual void SetItem(const SFieldTypeAndMatcher &item)
void SetFieldNames(const vector< string > &field_names)
wxIcon GetIconResource(const wxString &name)
wxBitmap GetBitmapResource(const wxString &name)
void PopulateFeatureListbox(objects::CSeq_entry_Handle seh)
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
static string GetDescription(CRef< objects::CWord_substitution > ws)
virtual pair< string, SFieldTypeAndMatcher > GetItem(CFieldNamePanel::EFieldType field_type)=0
virtual void SetItem(const SFieldTypeAndMatcher &item)=0
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#define T(s)
Definition: common.h:230
int GetSubtype(CFieldNamePanel *field_name_panel, string &ncRNA_class)
const char * kDefinitionLineLabel
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
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
#define kEmptyStr
Definition: ncbistr.hpp:123
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
Definition: ncbistr.hpp:2697
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
Definition: ncbistr.cpp:3310
static const char label[]
TCase_sensitive GetCase_sensitive(void) const
Get the Case_sensitive member data.
const TIgnore_words & GetIgnore_words(void) const
Get the Ignore_words member data.
void SetIs_all_lower(TIs_all_lower value)
Assign a value to Is_all_lower data member.
TIgnore_space GetIgnore_space(void) const
Get the Ignore_space member data.
TMatch_location GetMatch_location(void) const
Get the Match_location member data.
TIs_all_caps GetIs_all_caps(void) const
Get the Is_all_caps member data.
void SetIs_all_punct(TIs_all_punct value)
Assign a value to Is_all_punct data member.
bool IsSetNot_present(void) const
Check if a value has been assigned to Not_present data member.
TWhole_word GetWhole_word(void) const
Get the Whole_word member data.
TIgnore_weasel GetIgnore_weasel(void) const
Get the Ignore_weasel member data.
void SetIgnore_punct(TIgnore_punct value)
Assign a value to Ignore_punct data member.
TIgnore_punct GetIgnore_punct(void) const
Get the Ignore_punct member data.
void SetIgnore_words(TIgnore_words &value)
Assign a value to Ignore_words data member.
void SetMatch_location(TMatch_location value)
Assign a value to Match_location data member.
const TMatch_text & GetMatch_text(void) const
Get the Match_text member data.
TNot_present GetNot_present(void) const
Get the Not_present member data.
void SetIs_all_caps(TIs_all_caps value)
Assign a value to Is_all_caps data member.
TIs_all_punct GetIs_all_punct(void) const
Get the Is_all_punct member data.
TIs_all_lower GetIs_all_lower(void) const
Get the Is_all_lower member data.
void SetCase_sensitive(TCase_sensitive value)
Assign a value to Case_sensitive data member.
void SetIgnore_space(TIgnore_space value)
Assign a value to Ignore_space data member.
void SetWhole_word(TWhole_word value)
Assign a value to Whole_word data member.
void SetIgnore_weasel(TIgnore_weasel value)
Assign a value to Ignore_weasel data member.
void SetNot_present(TNot_present value)
Assign a value to Not_present data member.
bool IsSetIgnore_words(void) const
Check if a value has been assigned to Ignore_words data member.
@ eString_location_inlist
@ eString_location_equals
@ eString_location_contains
@ eString_location_starts
@ eString_location_ends
END_EVENT_TABLE()
int i
const struct ncbi::grid::netcache::search::fields::SIZE size
static static static wxID_ANY
static const char * str(char *buf, int n)
Definition: stats.c:84
CRef< CConstraintMatcher > matcher
CFieldNamePanel::EFieldType field_type2
CRef< CConstraintMatcher > matcher2
CFieldNamePanel::EFieldType field_type
CRef< CString_constraint > string_constraint
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Thu Mar 28 17:05:21 2024 by modify_doxy.py rev. 669887