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

Go to the SVN repository for this file.

1 /* $Id: wx_annot_config_dlg.cpp 30962 2014-08-13 18:38:46Z falkrb $
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:
27  *
28  * File Description:
29  *
30  */
31 #include <ncbi_pch.hpp>
34 
36 
37 #include <wx/bitmap.h>
38 #include <wx/icon.h>
39 
40 ////@begin includes
41 ////@end includes
42 
43 #include "wx_annot_config_dlg.hpp"
44 #include <gui/objutils/label.hpp>
45 #include <gui/objutils/utils.hpp>
46 
47 ////@begin XPM images
48 ////@end XPM images
49 
52 
53 
54 IMPLEMENT_DYNAMIC_CLASS( CwxAnnotConfigDlg, wxDialog )
55 
56 BEGIN_EVENT_TABLE( CwxAnnotConfigDlg, wxDialog )
57 
58 ////@begin CwxAnnotConfigDlg event table entries
60 
62 
63  EVT_BUTTON( wxID_OK, CwxAnnotConfigDlg::OnOkClick )
64 
65 ////@end CwxAnnotConfigDlg event table entries
66 
68 
70 {
71  Init();
72 }
73 
74 CwxAnnotConfigDlg::CwxAnnotConfigDlg( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
75 {
76  Init();
77  Create(parent, id, caption, pos, size, style);
78 }
79 
80 bool CwxAnnotConfigDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
81 {
82 ////@begin CwxAnnotConfigDlg creation
83  SetExtraStyle(wxWS_EX_BLOCK_EVENTS|wxDIALOG_EX_CONTEXTHELP);
84  wxDialog::Create( parent, id, caption, pos, size, style );
85 
87  if (GetSizer())
88  {
89  GetSizer()->SetSizeHints(this);
90  }
91  Centre();
92 ////@end CwxAnnotConfigDlg creation
93  return true;
94 }
95 
97 {
98 ////@begin CwxAnnotConfigDlg destruction
99 ////@end CwxAnnotConfigDlg destruction
100 }
101 
103 {
104 ////@begin CwxAnnotConfigDlg member initialisation
106  m_SmearAln = NULL;
107  m_ShowLabel = NULL;
109 ////@end CwxAnnotConfigDlg member initialisation
110 }
111 
113 {
114 ////@begin CwxAnnotConfigDlg content construction
115  CwxAnnotConfigDlg* itemDialog1 = this;
116 
117  wxFlexGridSizer* itemFlexGridSizer2 = new wxFlexGridSizer(2, 2, 0, 0);
118  itemDialog1->SetSizer(itemFlexGridSizer2);
119 
120  wxArrayString m_AnnotBrowserStrings;
121  m_AnnotBrowser = new wxListBox( itemDialog1, ID_LISTBOX1, wxDefaultPosition, wxSize(250, 320), m_AnnotBrowserStrings, wxLB_SINGLE );
122  itemFlexGridSizer2->Add(m_AnnotBrowser, 0, wxGROW|wxGROW|wxALL, 5);
123 
124  wxStaticBox* itemStaticBoxSizer4Static = new wxStaticBox(itemDialog1, wxID_ANY, _("Options"));
125  wxStaticBoxSizer* itemStaticBoxSizer4 = new wxStaticBoxSizer(itemStaticBoxSizer4Static, wxVERTICAL);
126  itemFlexGridSizer2->Add(itemStaticBoxSizer4, 0, wxGROW|wxALIGN_TOP|wxALL, 5);
127 
128  m_SmearAln = new wxCheckBox( itemDialog1, ID_CHECKBOX1, _("Smear Alignments"), wxDefaultPosition, wxDefaultSize, 0 );
129  m_SmearAln->SetValue(false);
130  itemStaticBoxSizer4->Add(m_SmearAln, 0, wxALIGN_LEFT|wxALL, 5);
131 
132  m_ShowLabel = new wxCheckBox( itemDialog1, ID_CHECKBOX2, _("Show Labels"), wxDefaultPosition, wxDefaultSize, 0 );
133  m_ShowLabel->SetValue(false);
134  itemStaticBoxSizer4->Add(m_ShowLabel, 0, wxALIGN_LEFT|wxALL, 5);
135 
136  m_AnnotColorPicker = new wxBoxSizer(wxHORIZONTAL);
137  itemStaticBoxSizer4->Add(m_AnnotColorPicker, 0, wxALIGN_LEFT|wxALL, 0);
138 
139  wxColourPickerCtrl* itemColourPickerCtrl8 = new wxColourPickerCtrl( itemDialog1, ID_COLOURPICKERCTRL );
140  m_AnnotColorPicker->Add(itemColourPickerCtrl8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
141 
142  wxStaticText* itemStaticText9 = new wxStaticText( itemDialog1, wxID_STATIC, _("Annotation Background Color"), wxDefaultPosition, wxDefaultSize, 0 );
143  m_AnnotColorPicker->Add(itemStaticText9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
144 
145  itemFlexGridSizer2->Add(5, 5, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
146 
147  wxStdDialogButtonSizer* itemStdDialogButtonSizer11 = new wxStdDialogButtonSizer;
148 
149  itemFlexGridSizer2->Add(itemStdDialogButtonSizer11, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
150  wxButton* itemButton12 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
151  itemButton12->SetDefault();
152  itemStdDialogButtonSizer11->AddButton(itemButton12);
153 
154  wxButton* itemButton13 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
155  itemStdDialogButtonSizer11->AddButton(itemButton13);
156 
157  itemStdDialogButtonSizer11->Realize();
158 
159  itemFlexGridSizer2->AddGrowableRow(0);
160  itemFlexGridSizer2->AddGrowableCol(0);
161 
162  // Set validators
163  itemColourPickerCtrl8->SetValidator( CColorPickerValidator(& m_AnnotBgColor) );
164 ////@end CwxAnnotConfigDlg content construction
165 }
166 
167 
168 void CwxAnnotConfigDlg::OnOkClick( wxCommandEvent& event )
169 {
171  m_AnnotConfig.SaveConfig();
172  event.Skip();
173 }
174 
175 
176 
177 void CwxAnnotConfigDlg::SetBioseq(const objects::CBioseq_Handle& bsh)
178 {
179  x_InitAnnotList(bsh);
181 }
182 
183 
185 {
186  int sel_idx = m_AnnotBrowser->GetSelection();
187  if (sel_idx == wxNOT_FOUND) {
188  return false;
189  }
190 
191  wxString browser_text = m_AnnotBrowser->GetStringSelection();
192 
193  string the_state = ToStdString(browser_text);
194  name.swap(the_state);
195  return true;
196 }
197 
198 
200 {
202  if ( am_it == m_LabelAnnots.end()) {
203  return CRef<objects::CSeq_annot>();
204  }
205  return am_it->second;
206 }
207 
208 
210 {
212 
213  set<CSeq_annot_Handle> annots;
215  CAlign_CI align_iter(bsh, sel);
216  for ( ; align_iter; ++align_iter) {
217  annots.insert(align_iter.GetSeq_align_Handle().GetAnnot());
218  }
219 
220  ITERATE (set<CSeq_annot_Handle>, iter, annots) {
221  const CSeq_annot_Handle& sah = *iter;
222  // CSeq_annot_EditHandle saeh = sah.GetEditHandle();
223  CConstRef<CSeq_annot> sannot_cref = sah.GetCompleteSeq_annot();
224  /*****
225  Following const_cast is a kludge to get around the
226  lack of accessors in CSeq_annot_EditHandle.
227  *****/
228  CRef<CSeq_annot> sannot_ref( & const_cast<CSeq_annot&> (*sannot_cref) );
229 
230  string label;
231  CLabel::GetLabel(*sannot_ref, &label, CLabel::eContent);
232  m_LabelAnnots[label] = sannot_ref;
233 
234  m_AnnotBrowser->Append(ToWxString(label));
235  }
236  m_AnnotBrowser->SetSelection(0);
237 }
238 
239 
241 {
242  return true;
243 }
244 
245 
246 wxBitmap CwxAnnotConfigDlg::GetBitmapResource( const wxString& name )
247 {
248  // Bitmap retrieval
249 ////@begin CwxAnnotConfigDlg bitmap retrieval
250  wxUnusedVar(name);
251  return wxNullBitmap;
252 ////@end CwxAnnotConfigDlg bitmap retrieval
253 }
254 wxIcon CwxAnnotConfigDlg::GetIconResource( const wxString& name )
255 {
256  // Icon retrieval
257 ////@begin CwxAnnotConfigDlg icon retrieval
258  wxUnusedVar(name);
259  return wxNullIcon;
260 ////@end CwxAnnotConfigDlg icon retrieval
261 }
262 
263 
265 {
266  CAnnotWriteConfig::CAnnotConfigSettings settings;
267 
268  if (TransferDataFromWindow()) {
269  settings.m_Smear = m_SmearAln->GetValue();
270  settings.m_ShowLabel = m_ShowLabel->GetValue();
271  settings.m_BGColor = m_AnnotBgColor;
272 
273  m_AnnotConfig.SetAnnotConfigSettings(settings);
274  }
275 }
276 
277 
279 {
280  CAnnotWriteConfig::CAnnotConfigSettings settings;
281  m_AnnotConfig.GetAnnotConfigSettings(settings);
282 
283  m_SmearAln->SetValue(settings.m_Smear);
284  m_ShowLabel->SetValue(settings.m_ShowLabel);
285  m_AnnotBgColor = settings.m_BGColor;
286 
287  x_CheckControls();
288 }
289 
290 
292 {
293  bool val = !m_SmearAln->GetValue();
294  m_ShowLabel->Show(val);
295  m_AnnotColorPicker->Show(val);
296 }
297 
299 {
300  string annot_name;
301  if (x_GetSelectedAnnotName(annot_name)) {
302  CRef<objects::CSeq_annot> annot = x_FindAnnot(annot_name);
303  _ASSERT(annot);
305  m_AnnotConfig.SetAnnot(*annot);
307  }
308 }
309 
310 void CwxAnnotConfigDlg::OnSmearAlnClicked( wxCommandEvent& event )
311 {
312  x_CheckControls();
313 }
314 
315 void CwxAnnotConfigDlg::OnAnnotBrowserSelected( wxCommandEvent& event )
316 {
318 }
319 
321 
322 
323 
EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX, CAdjustFeaturesForGaps::OnKnownUnknownSelected) EVT_CHECKBOX(ID_CADJUSTFEATURES_CHECKBOX1
#define ID_CHECKBOX2
CAlign_CI –.
Definition: align_ci.hpp:63
CBioseq_Handle –.
CSeq_annot_Handle –.
void OnSmearAlnClicked(wxCommandEvent &event)
void x_InitAnnotList(const objects::CBioseq_Handle &bsh)
wxBoxSizer * m_AnnotColorPicker
wxIcon GetIconResource(const wxString &name)
wxBitmap GetBitmapResource(const wxString &name)
bool x_GetSelectedAnnotName(string &name)
bool Create(wxWindow *parent, wxWindowID id=10013, const wxString &caption=_("Annotation Rendering Options"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX|wxTAB_TRAVERSAL)
void OnOkClick(wxCommandEvent &event)
CRef< objects::CSeq_annot > x_FindAnnot(const string &label)
CAnnotWriteConfig m_AnnotConfig
void SetBioseq(const objects::CBioseq_Handle &bsh)
void OnAnnotBrowserSelected(wxCommandEvent &event)
const_iterator end() const
Definition: map.hpp:152
void clear()
Definition: map.hpp:169
const_iterator find(const key_type &key) const
Definition: map.hpp:153
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
#define _(proto)
Definition: ct_nlmzip_i.h:78
static void Init(void)
Definition: cursor6.c:76
#define ID_LISTBOX1
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
Definition: utils.cpp:167
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
Definition: label.cpp:140
@ eContent
Definition: label.hpp:62
CConstRef< CSeq_annot > GetCompleteSeq_annot(void) const
Complete and return const reference to the current seq-annot.
const CSeq_annot_Handle & GetAnnot(void) const
Get handle to the seq-annot.
CSeq_align_Handle GetSeq_align_Handle(void) const
Get original alignment handle.
Definition: align_ci.cpp:233
#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 const char label[]
END_EVENT_TABLE()
const struct ncbi::grid::netcache::search::fields::SIZE size
static static static wxID_ANY
SAnnotSelector –.
#define _ASSERT
USING_SCOPE(objects)
#define ID_COLOURPICKERCTRL
#define ID_CHECKBOX1
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Sat Dec 09 04:47:17 2023 by modify_doxy.py rev. 669887