NCBI C++ ToolKit
constraint_panel.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: constraint_panel.hpp 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 
32 #ifndef CONSTRAINT_PANEL__HPP
33 #define CONSTRAINT_PANEL__HPP
34 
35 
36 #include <corelib/ncbistd.hpp>
37 #include <wx/listbook.h>
38 #include <wx/choicebk.h>
39 #include <wx/checklst.h>
40 
53 
54 
55 class wxListbook;
56 class wxComboBox;
57 
59 
60 /*!
61  * Control identifiers
62  */
63 #define ID_CONSTRAINT_CHOICEBOOK 14002
64 #define ID_CONSTRAINT_ADD 14003
65 #define ID_CONSTRAINT_REMOVE 14004
66 #define ID_CONSTRAINT_LIST 14005
67 
69 {
70 public:
71  virtual ~IConstraintPanelBase() {}
72  virtual CRef<CEditingActionConstraint> GetConstraint(const string &field, CFieldNamePanel::EFieldType field_type, int subtype, const string& ncRNA_class) = 0;
73 };
74 
75 
76 // Basic constraint panel containing a simple string constraint (case sensitivite and ignore_space options)
77 class CConstraintPanel: public wxPanel, public CFieldNamePanelParent, public IConstraintPanelBase
78 {
79  DECLARE_DYNAMIC_CLASS( CConstraintPanel )
80  DECLARE_EVENT_TABLE()
81 
82 public:
84  CConstraintPanel( wxWindow* parent,
85  objects::CSeq_entry_Handle seh,
86  vector<const objects::CFeatListItem *> *featlist = nullptr,
87  bool load_macro_fields = false,
88  wxWindowID id = wxID_ANY,
89  const wxPoint& pos = wxDefaultPosition,
90  const wxSize& size = wxDefaultSize,
91  long style = wxTAB_TRAVERSAL|wxSIMPLE_BORDER );
92 
93  bool Create( wxWindow* parent,
94  wxWindowID id = wxID_ANY,
95  const wxPoint& pos = wxDefaultPosition,
96  const wxSize& size = wxDefaultSize,
97  long style = wxTAB_TRAVERSAL );
98 
100 
101  void Init();
102  void CreateControls();
103 
104  void OnPageChanged(wxBookCtrlEvent& event);
105 
106  void SetSelection(int page);
108 
110  string GetMacroStringConstraint(const string& field_name);
111 
113  string GetFieldType(void) const;
114  bool SetFieldName(const string& field);
115  void ClearValues(void);
116  void ListPresentFeaturesFirst(objects::CSeq_entry_Handle seh) { m_feat_field_panel->ListPresentFeaturesFirst(seh); }
117 
118  // inherited from CFieldNamePanelParent
119  virtual void UpdateEditor(void);
120 
121  // inherited from CConstraintPanelBase
122  virtual CRef<CEditingActionConstraint> GetConstraint(const string &field,
123  CFieldNamePanel::EFieldType field_type, int subtype, const string& ncRNA_class);
124 
125  wxBitmap GetBitmapResource(const wxString& name);
126  wxIcon GetIconResource(const wxString& name);
127  static bool ShowToolTips();
128 
129 private:
130  wxChoicebook* m_Notebook;
133  objects::CSeq_entry_Handle m_TopSeqEntry;
134  vector<const objects::CFeatListItem *> *m_featlist;
135  bool m_LoadMacroFields{ false };
136 };
137 
139 {
141  field_type(CFieldNamePanel::eFieldType_Unknown),
142  subtype(-1),
143  enabled(false),
144  subtype2(-1),
145  enabled2(false),
146  top_level(-1),
147  second_level(-1) {}
148 
149  string field;
151  int subtype;
152  string m_ncRNAClass;
154  bool enabled;
155 
156  string field2;
158  int subtype2;
161  bool enabled2;
162 
163  int top_level;
165  string full_field;
166  string full_field2;
169 };
170 
171 // Panel that allows for managing constraints (adding, deleting, editing)
172 class CCompoundConstraintPanel: public wxPanel, public IConstraintPanelBase
173 {
174  DECLARE_DYNAMIC_CLASS( CCompoundConstraintPanel )
175  DECLARE_EVENT_TABLE()
176 
177 public:
179  CCompoundConstraintPanel( wxWindow* parent, objects::CSeq_entry_Handle seh, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
180  bool Create( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
182  void Init();
183  void CreateControls();
184  wxBitmap GetBitmapResource( const wxString& name );
185  wxIcon GetIconResource( const wxString& name );
186  static bool ShowToolTips();
187  void SetSelection(int page);
188  void ClearValues(void);
189 
190  virtual CRef<CEditingActionConstraint> GetConstraint(const string &field, CFieldNamePanel::EFieldType field_type, int subtype, const string& ncRNA_class);
191  void OnAddConstraint( wxCommandEvent& event );
192  void OnRemoveConstraint( wxCommandEvent& event );
193  void OnEditConstraint( wxCommandEvent& event );
194  void AddConstraint(pair<string, SFieldTypeAndMatcher> item, int id);
195 private:
196  wxCheckListBox *m_CheckListBox;
197  objects::CSeq_entry_Handle m_TopSeqEntry;
199  int m_page;
200 };
201 
202 
203 class CAdvancedConstraintPanel: public wxPanel
204 {
205  DECLARE_DYNAMIC_CLASS( CAdvancedConstraintPanel )
206  DECLARE_EVENT_TABLE()
207 
208 public:
210  CAdvancedConstraintPanel( wxWindow* parent, objects::CSeq_entry_Handle seh, vector<const objects::CFeatListItem *> *featlist = nullptr,
211  wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
212  bool Create( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL );
214  void Init();
215  void CreateControls();
216  wxBitmap GetBitmapResource( const wxString& name );
217  wxIcon GetIconResource( const wxString& name );
218  static bool ShowToolTips();
219  void SetSelection(int page);
220  void ClearValues(void);
221 
222  CRef<CEditingActionConstraint> GetConstraint(const string &field, CFieldNamePanel::EFieldType field_type, int subtype, const string& ncRNA_class);
223 private:
224  wxNotebook* m_Notebook;
227  objects::CSeq_entry_Handle m_TopSeqEntry;
228  vector<const objects::CFeatListItem *> *m_featlist;
229 };
230 
231 
233 
234 #endif // CONSTRAINT_PANEL__HPP
User-defined methods of the data storage class.
CConstraintPanel * m_BasicConstraintPanel
CCompoundConstraintPanel * m_CompoundConstraintPanel
wxIcon GetIconResource(const wxString &name)
vector< const objects::CFeatListItem * > * m_featlist
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
CRef< CEditingActionConstraint > GetConstraint(const string &field, CFieldNamePanel::EFieldType field_type, int subtype, const string &ncRNA_class)
wxBitmap GetBitmapResource(const wxString &name)
objects::CSeq_entry_Handle m_TopSeqEntry
wxBitmap GetBitmapResource(const wxString &name)
void OnRemoveConstraint(wxCommandEvent &event)
void AddConstraint(pair< string, SFieldTypeAndMatcher > item, int id)
void OnAddConstraint(wxCommandEvent &event)
bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL)
objects::CSeq_entry_Handle m_TopSeqEntry
void OnEditConstraint(wxCommandEvent &event)
wxIcon GetIconResource(const wxString &name)
wxCheckListBox * m_CheckListBox
map< string, SFieldTypeAndMatcher > m_label_to_constraint
virtual CRef< CEditingActionConstraint > GetConstraint(const string &field, CFieldNamePanel::EFieldType field_type, int subtype, const string &ncRNA_class)
CFeatureFieldNamePanel * m_feat_field_panel
static bool ShowToolTips()
virtual void UpdateEditor(void)
virtual CRef< CEditingActionConstraint > GetConstraint(const string &field, CFieldNamePanel::EFieldType field_type, int subtype, const string &ncRNA_class)
CStringConstraintPanel * m_StringConstraintPanel
void SetSelection(int page)
vector< const objects::CFeatListItem * > * m_featlist
objects::CSeq_entry_Handle m_TopSeqEntry
string GetFieldType(void) const
CFieldNamePanel * GetFieldNamePanel(void)
wxBitmap GetBitmapResource(const wxString &name)
void ListPresentFeaturesFirst(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)
string GetMacroStringConstraint(const string &field_name)
CStringConstraintPanel * GetStringConstraintPanel()
wxChoicebook * m_Notebook
bool SetFieldName(const string &field)
wxIcon GetIconResource(const wxString &name)
void OnPageChanged(wxBookCtrlEvent &event)
CRef< edit::CStringConstraint > GetStringConstraint(void)
void ListPresentFeaturesFirst(objects::CSeq_entry_Handle seh, vector< const objects::CFeatListItem * > *featlist=nullptr)
virtual CRef< CEditingActionConstraint > GetConstraint(const string &field, CFieldNamePanel::EFieldType field_type, int subtype, const string &ncRNA_class)=0
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define false
Definition: bool.h:36
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
const struct ncbi::grid::netcache::search::fields::SIZE size
static static static wxID_ANY
CRef< CConstraintMatcher > matcher
CFieldNamePanel::EFieldType field_type2
CRef< CConstraintMatcher > matcher2
CFieldNamePanel::EFieldType field_type
CRef< CString_constraint > string_constraint
CRef< objects::CLocation_constraint > location_constraint
Modified on Wed Sep 04 14:58:42 2024 by modify_doxy.py rev. 669887