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

Go to the SVN repository for this file.

1 /* $Id: locationl_list_ctrl.cpp 47123 2022-08-26 20:33:30Z 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: Roman Katargin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 #include <set>
32 
35 #include <objmgr/bioseq_ci.hpp>
36 #include <objmgr/bioseq_handle.hpp>
37 #include <objmgr/scope.hpp>
38 #include <objmgr/util/sequence.hpp>
39 
40 #include <util/xregexp/regexp.hpp>
41 
46 #include <gui/objutils/label.hpp>
47 
48 #include <wx/hyperlink.h>
49 #include <wx/sizer.h>
50 #include <wx/button.h>
51 #include <wx/scrolwin.h>
52 #include <wx/stattext.h>
53 #include <wx/radiobox.h>
54 #include <wx/bitmap.h>
55 #include <wx/icon.h>
56 
59 
60 /*!
61  * CLocationListCtrl type definition
62  */
63 
64 IMPLEMENT_DYNAMIC_CLASS( CLocationListCtrl, wxPanel )
65 
66 
67 /*!
68  * CLocationListCtrl event table definition
69  */
70 
71 BEGIN_EVENT_TABLE( CLocationListCtrl, wxPanel )
72 
75  EVT_COMMAND(wxID_ANY, wxEVT_LARGE_SPIN_CTRL_EVENT, CLocationListCtrl::OnSpinCtrl)
78 
79 
80 /*!
81  * CLocationListCtrl constructors
82  */
83 
85 {
86  Init();
87 }
88 
89 CLocationListCtrl::CLocationListCtrl( wxWindow* parent, CRef<objects::CScope> scope, bool allow_nuc, bool allow_prot, bool is_aa,
90  wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
91  : m_AllowNuc(allow_nuc), m_AllowProt(allow_prot), m_Scope(scope), m_is_aa(is_aa)
92 {
93  Init();
94  Create(parent, id, pos, size, style);
95 }
96 
97 
98 /*!
99  * CLocationListCtrl creator
100  */
101 
102 bool CLocationListCtrl::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
103 {
104 ////@begin CLocationListCtrl creation
105  wxPanel::Create( parent, id, pos, size, style );
106 
107  CreateControls();
108  if (GetSizer())
109  {
110  GetSizer()->SetSizeHints(this);
111  }
112  Centre();
113 ////@end CLocationListCtrl creation
114  return true;
115 }
116 
117 
118 /*!
119  * CLocationListCtrl destructor
120  */
121 
123 {
124 }
125 
126 
127 /*!
128  * Member initialisation
129  */
130 
132 {
133 ////@begin CLocationListCtrl member initialisation
134  m_LocType = 0;
136  m_Partial5 = NULL;
137  m_Partial3 = NULL;
138 ////@end CLocationListCtrl member initialisation
139  m_Sizer = NULL;
140  m_LastFrom = NULL;
141  m_LastTo = NULL;
142  m_LastStrand = NULL;
143  m_LastId = NULL;
144  m_LastIdSelection = wxNOT_FOUND;
145  m_LastStrandSelection = wxNOT_FOUND;
146  m_CtrlColNum = 5;
147  if (m_is_aa)
148  m_CtrlColNum = 4;
149 }
150 
151 
152 /*!
153  * Control creation for CLocationListCtrl
154  */
155 
157 {
158 ////@begin CLocationListCtrl content construction
159  CLocationListCtrl* itemPanel1 = this;
160 
161  wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
162  itemPanel1->SetSizer(itemBoxSizer2);
163 
164  wxStaticBox* itemStaticBoxSizer14Static = new wxStaticBox(itemPanel1, wxID_ANY, _("Partialness"));
165  wxStaticBoxSizer* itemStaticBoxSizer14 = new wxStaticBoxSizer(itemStaticBoxSizer14Static, wxHORIZONTAL);
166  itemBoxSizer2->Add(itemStaticBoxSizer14, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
167 
168  wxString start_label = _("5'");
169  if (m_is_aa)
170  start_label = _("NH2");
171  m_Partial5 = new wxCheckBox( itemPanel1, ID_CHECKBOX1, start_label, wxDefaultPosition, wxDefaultSize, 0 );
172  m_Partial5->SetValue(false);
173  itemStaticBoxSizer14->Add(m_Partial5, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
174 
175  wxString stop_label = _("3'");
176  if (m_is_aa)
177  stop_label = _("CO2H");
178  m_Partial3 = new wxCheckBox( itemPanel1, ID_CHECKBOX2, stop_label, wxDefaultPosition, wxDefaultSize, 0 );
179  m_Partial3->SetValue(false);
180  itemStaticBoxSizer14->Add(m_Partial3, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
181 
182 
183  wxPanel* itemPanel3 = new wxPanel( itemPanel1, ID_PANEL1, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxTAB_TRAVERSAL );
184  itemBoxSizer2->Add(itemPanel3, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
185 
186  wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
187  itemPanel3->SetSizer(itemBoxSizer4);
188 
189  wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
190  itemBoxSizer4->Add(itemBoxSizer5, 0, wxALIGN_LEFT|wxALL, 0);
191 
192  wxStaticText* itemStaticText6 = new wxStaticText( itemPanel3, wxID_STATIC, _("From"), wxDefaultPosition, wxSize(itemPanel3->ConvertDialogToPixels(wxSize(45, -1)).x, -1), wxALIGN_CENTRE );
193  itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
194 
195  wxStaticText* itemStaticText7 = new wxStaticText( itemPanel3, wxID_STATIC, _("To"), wxDefaultPosition, wxSize(itemPanel3->ConvertDialogToPixels(wxSize(45, -1)).x, -1), wxALIGN_CENTRE );
196  itemBoxSizer5->Add(itemStaticText7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
197 
198  if (!m_is_aa)
199  {
200  wxStaticText* itemStaticText8 = new wxStaticText( itemPanel3, wxID_STATIC, _("Strand"), wxDefaultPosition, wxSize(itemPanel3->ConvertDialogToPixels(wxSize(45, -1)).x, -1), wxALIGN_CENTRE );
201  itemBoxSizer5->Add(itemStaticText8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
202  }
203 
204  wxStaticText* itemStaticText9 = new wxStaticText( itemPanel3, wxID_STATIC, _("SeqID"), wxDefaultPosition, wxSize(itemPanel3->ConvertDialogToPixels(wxSize(80, -1)).x, -1), wxALIGN_CENTRE );
205  itemBoxSizer5->Add(itemStaticText9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 2);
206 
207  itemBoxSizer5->Add(92, 8, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
208 
209  wxStaticLine* itemStaticLine11 = new wxStaticLine( itemPanel3, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
210  itemBoxSizer4->Add(itemStaticLine11, 0, wxGROW|wxALL, 1);
211 
212  m_ScrolledWindow = new wxScrolledWindow( itemPanel3, ID_SCROLLEDWINDOW1, wxDefaultPosition, wxSize(-1, 100), wxTAB_TRAVERSAL );
213  itemBoxSizer4->Add(m_ScrolledWindow, 1, wxGROW |wxTOP|wxBOTTOM, 0);
214  m_ScrolledWindow->SetScrollbars(1, 1, 0, 0);
215 
216  wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL);
217  itemBoxSizer2->Add(itemBoxSizer13, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 0);
218 
219  wxArrayString itemRadioBox17Strings;
220  itemRadioBox17Strings.Add(_("&join()"));
221  itemRadioBox17Strings.Add(_("&order()"));
222  wxRadioBox* itemRadioBox17 = new wxRadioBox( itemPanel1, ID_RADIOBOX6, _("Save As"), wxDefaultPosition, wxDefaultSize, itemRadioBox17Strings, 1, wxRA_SPECIFY_ROWS );
223  itemRadioBox17->SetSelection(0);
225  itemRadioBox17->SetToolTip(_("If each interval is separate, and should not be joined with the others to describe the feature, choose order (for example, when annotating multiple primer binding sites)."));
226  itemBoxSizer13->Add(itemRadioBox17, 0, wxALIGN_CENTER_VERTICAL|wxALL, 0);
227 
228  wxButton* itemButton18 = new wxButton( itemPanel1, ID_BUTTON1, _("Sort"), wxDefaultPosition, wxDefaultSize, 0 );
229  itemBoxSizer13->Add(itemButton18, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
230 
231  // Set validators
232  itemRadioBox17->SetValidator( wxGenericValidator(& m_LocType) );
233 ////@end CLocationListCtrl content construction
234 
235  m_Sizer = new wxFlexGridSizer(0, m_CtrlColNum, 0, 0);
236  m_ScrolledWindow->SetSizer(m_Sizer);
237  m_ScrolledWindow->FitInside();
238 
239  //m_AddIntHyperlink->SetVisitedColour(m_AddIntHyperlink->GetNormalColour());
240  m_ScrolledWindow->SetScrollRate(0, 5);
241 }
242 
243 void CLocationListCtrl::AddRow(int from, int to, int strand, const wxString& seqID, const bool fuzz)
244 {
245  int comboIndex = 0;
246  switch(strand) {
247  default :
248  break;
249  case eNa_strand_plus :
250  comboIndex = 0;
251  break;
252  case eNa_strand_minus :
253  comboIndex = 1;
254  break;
255  case eNa_strand_both :
256  comboIndex = 2;
257  break;
258  case eNa_strand_other :
259  comboIndex = 3;
260  break;
261  }
262 
263 
264 
265  SIntData intData;
266  intData.m_From = from;
267  intData.m_To = to;
268  intData.m_Strand = comboIndex;
269  intData.m_SeqId = seqID;
270  intData.m_Empty = false;
271  intData.m_Fuzz = fuzz;
272  m_Data.push_back(intData);
273 }
274 
275 void CLocationListCtrl::SetPartials(bool partial5, bool partial3)
276 {
277  m_Partial5->SetValue(partial5);
278  m_Partial3->SetValue(partial3);
279 }
280 
282 {
283  SIntData intData;
284  intData.m_Empty = true;
285  m_Data.push_back(intData);
286 }
287 
289 {
290  m_Data.clear();
291  m_Sizer->Clear(true);
292 }
293 
294 void s_FinishLoc(CSeq_loc& loc, bool partial5, bool partial3)
295 {
296  if (!loc.IsNull()) {
297  loc.SetPartialStart(partial5, eExtreme_Biological);
298  loc.SetPartialStop(partial3, eExtreme_Biological);
299  }
300 }
301 
302 
304 {
305  CRef<CSeq_loc> loc(new CSeq_loc());
306  if (m_Data.empty()) {
307  loc->CSeq_loc_Base::SetNull();
308  return loc;
309  }
310 
311  bool partial5 = m_Partial5->GetValue();
312  bool partial3 = m_Partial3->GetValue();
313 
314  if (m_Data.size() == 1 || (m_Data.size() == 2 && m_Data.back().m_Empty)) {
315  if (m_Data[0].m_Empty) {
316  loc->CSeq_loc_Base::SetNull();
317  } else {
318  loc.Reset();
319  loc = x_GetInterval(0, false);
320  s_FinishLoc(*loc, partial5, partial3);
321  }
322  return loc;
323  }
324 
325  if (m_LocType == 0) {
326  CRef<CPacked_seqint> packed(new CPacked_seqint());
327  for (size_t i = 0; i < m_Data.size(); ++i) {
328  CRef<CSeq_loc> seq_int = x_GetInterval(i, true);
329  if (seq_int && seq_int->IsInt()) {
330  CRef<CSeq_interval> new_int(new CSeq_interval);
331  new_int->Assign(seq_int->GetInt());
332  packed->Set().push_back(new_int);
333  }
334  }
335  if (packed->Set().size() == 1) {
336  loc->SetInt().Assign(*(packed->Set().front()));
337  } else if (packed->Set().size() == 0) {
338  loc->SetNull();
339  } else {
340  loc->CSeq_loc_Base::SetPacked_int(*packed);
341  }
342  }
343  else {
344  CRef<CSeq_loc_mix> mix(new CSeq_loc_mix());
345 
346  for (size_t i = 0; i < m_Data.size(); ++i) {
347  CRef<CSeq_loc> seq_int = x_GetInterval(i, false);
348  if (seq_int) {
349  mix->Set().push_back(seq_int);
350  CRef<CSeq_loc> null_loc(new CSeq_loc());
351  null_loc->CSeq_loc_Base::SetNull();
352  mix->Set().push_back(null_loc);
353  }
354  }
355  if (mix->Set().back()->IsNull()) {
356  mix->Set().pop_back();
357  }
358  if (mix->Set().size() == 0) {
359  loc->SetNull();
360  } else if (mix->Set().size() == 1) {
361  loc->SetInt().Assign(*(mix->Set().front()));
362  } else {
363  loc->CSeq_loc_Base::SetMix(*mix);
364  }
365  }
366  s_FinishLoc(*loc, partial5, partial3);
367  return loc;
368 }
369 
371 {
372  ENa_strand strand = x_GetStrandFromForm(index);
373  if (strand == eNa_strand_unknown)
374  {
375  for (size_t i = 0; i < m_Data.size(); i++)
376  {
378  if (tmp != eNa_strand_unknown)
379  {
380  strand = tmp;
381  break;
382  }
383  }
384  }
385  return strand;
386 }
387 
389 {
391  switch(m_Data[index].m_Strand) {
392  case 0 :
393  strand = eNa_strand_plus;
394  break;
395  case 1 :
396  strand = eNa_strand_minus;
397  break;
398  case 2 :
399  strand = eNa_strand_both;
400  break;
401  case 3 :
402  strand = eNa_strand_other;
403  break;
404  default:
405  strand = eNa_strand_unknown;
406  break;
407  }
408 
409  return strand;
410 }
411 
413 {
414  CRef<CSeq_id> seq_id(new CSeq_id());
415 
416  string id_str = ToStdString(m_Data[index].m_SeqId);
417  if (id_str.empty())
418  {
419  for (size_t i = 0; i < m_Data.size(); i++)
420  {
421  if (!(m_Data[i].m_SeqId.IsEmpty()))
422  {
423  id_str = ToStdString(m_Data[i].m_SeqId);
424  break;
425  }
426  }
427  }
428 
429  if (id_str.empty())
430  {
431  for (wxArrayString::iterator it = m_SeqIds.begin(); it != m_SeqIds.end(); ++it)
432  {
433  if (!it->IsEmpty())
434  {
435  id_str = it->ToStdString();
436  break;
437  }
438  }
439  }
440 
441  if (m_str_to_id.find(id_str) != m_str_to_id.end())
442  {
443  seq_id->Assign(*m_str_to_id[id_str]);
444  return seq_id;
445  }
446 
447  try {
448  seq_id->Set(id_str);
449  } catch (CSeqIdException&) {
450  // make a local ID
451  seq_id->SetLocal().SetStr(id_str);
452  }
453  if (seq_id->IsGi()) {
454  // does a sequence with this GI exist in the scope?
455  if (!m_Scope || !m_Scope->GetBioseqHandle(*seq_id)) {
456  seq_id->SetLocal().SetGi(GI_TO(TIntId, seq_id->GetGi()));
457  }
458  }
459  else if (m_Scope) {
460  try
461  {
462  TGi gi = sequence::GetGiForId(*seq_id, *m_Scope);
463  if (gi > ZERO_GI) {
464  seq_id->SetGi(gi);
465  }
466  }
467  catch(CLoaderException&) {}
468  }
469 
470  return seq_id;
471 }
472 
474 {
475  if (m_Data[index].m_Empty) {
476  return CRef<CSeq_loc>();
477  }
478  CRef<CSeq_loc> seq_loc(new CSeq_loc);
479  if (m_Data[index].m_From == m_Data[index].m_To && !int_only)
480  {
481  CRef<CSeq_point> seq_pnt(new CSeq_point);
482  seq_pnt->SetPoint(m_Data[index].m_From - 1);
483  if (!m_is_aa)
484  {
485  ENa_strand strand = GetStrandFromForm(index);
486  seq_pnt->SetStrand(strand);
487  }
488  CRef<CSeq_id> seq_id = GetIdFromForm(index);
489  seq_pnt->SetId(*seq_id);
490  seq_loc->SetPnt(*seq_pnt);
491  }
492  else if (m_Data[index].m_Fuzz && abs(m_Data[index].m_To - m_Data[index].m_From) <= 1 && !int_only)
493  {
494  CRef<CSeq_point> seq_pnt(new CSeq_point);
495  seq_pnt->SetPoint(m_Data[index].m_From - 1);
496  if (!m_is_aa)
497  {
498  ENa_strand strand = GetStrandFromForm(index);
499  seq_pnt->SetStrand(strand);
500  }
501  CRef<CSeq_id> seq_id = GetIdFromForm(index);
502  seq_pnt->SetId(*seq_id);
503  seq_pnt->SetFuzz().SetLim(CInt_fuzz::eLim_tr);
504  seq_loc->SetPnt(*seq_pnt);
505  }
506  else
507  {
508  CRef<CSeq_interval> seq_int(new CSeq_interval());
509  seq_int->SetFrom(m_Data[index].m_From - 1);
510  seq_int->SetTo(m_Data[index].m_To - 1);
511  if (!m_is_aa)
512  {
513  ENa_strand strand = GetStrandFromForm(index);
514  seq_int->SetStrand(strand);
515  }
516  CRef<CSeq_id> seq_id = GetIdFromForm(index);
517  seq_int->SetId(*seq_id);
518  seq_loc->SetInt(*seq_int);
519  }
520  return seq_loc;
521 }
522 
523 void CLocationListCtrl::DeleteRow(wxSizerItemList::iterator row, wxSizerItemList& itemList)
524 {
525  wxSizerItemList::iterator node = row;
526  for (int i = 0; node != itemList.end() && i < m_CtrlColNum; ++i) {
527  wxSizer* sizer = (**node).GetSizer();
528 
529  if (m_LastFrom &&
530  ((sizer && sizer->GetItem(m_LastFrom))
531  || (**node).GetWindow() == m_LastFrom) )
532  {
533  m_LastFrom = NULL;
534  m_LastTo = NULL;
535  m_LastStrand = NULL;
536  m_LastId = NULL;
537  }
538  (**node).DeleteWindows();
539  node = itemList.erase(node);
540  }
541 }
542 
543 wxSizerItemList::iterator CLocationListCtrl::x_FindRow(wxWindow* wnd, wxSizerItemList& itemList)
544 {
545  if (NULL == wnd)
546  return itemList.end();
547 
548  wxSizerItemList::iterator row, it = itemList.begin();
549 
550  for(int index = 0; it != itemList.end(); ++it, --index) {
551  if (index == 0) {
552  row = it;
553  index = m_CtrlColNum;
554  }
555 
556  wxSizer* sizer = (**it).GetSizer();
557  if (sizer && sizer->GetItem(wnd))
558  return row;
559  else if ((**it).GetWindow() == wnd)
560  return row;
561  }
562 
563  return it;
564 }
565 
566 wxSizerItemList::iterator CLocationListCtrl::x_NextRow(wxSizerItemList::iterator row, wxSizerItemList& itemList)
567 {
568  wxSizerItemList::iterator it = row;
569  for (int i = 0; i < m_CtrlColNum; ++i, ++it) {
570  if (it == itemList.end())
571  return itemList.end();
572  }
573  return it;
574 }
575 
576 wxSizerItemList::iterator CLocationListCtrl::x_PrevRow(wxSizerItemList::iterator row, wxSizerItemList& itemList)
577 {
578  wxSizerItemList::iterator it = row;
579  for (int i = 0; i < m_CtrlColNum; ++i, --it) {
580  if (it == itemList.begin())
581  return itemList.end();
582  }
583  return it;
584 }
585 
586 static void s_SwapRows(wxSizerItemList::iterator row1,
587  wxSizerItemList::iterator row2,
588  wxSizerItemList& itemList)
589 {
590  for (int i = 0; i < 4; ++i) {
591  if (row1 == itemList.end() || row2 == itemList.end())
592  break;
593  swap(*row1++, *row2++);
594  }
595 }
596 
597 void CLocationListCtrl::x_GetRowData(wxSizerItemList::iterator row, wxSizerItemList& itemList,
598  int& from, int& to, int& strand, wxString& seqID, bool &fuzz)
599 {
600  wxSizerItemList::iterator node = row;
601 
602  if (node == itemList.end())return;
603 
604  fuzz = false;
605 
606  wxTextCtrl* text = (wxTextCtrl*)(**node).GetWindow();
607  fuzz |= NStr::StartsWith(text->GetValue().ToStdString(),"^") || NStr::EndsWith(text->GetValue().ToStdString(),"^");
608  from = wxAtoi(text->GetValue());
609  if (++node == itemList.end()) return;
610 
611  text = (wxTextCtrl*)(**node).GetWindow();
612  fuzz |= NStr::StartsWith(text->GetValue().ToStdString(),"^") || NStr::EndsWith(text->GetValue().ToStdString(),"^");
613  to = wxAtoi(text->GetValue());
614  if (++node == itemList.end()) return;
615 
616  strand = 0;
617  if (!m_is_aa)
618  {
619  wxChoice* strand_ctrl = dynamic_cast<wxChoice*>((**node).GetWindow());
620  strand = strand_ctrl->GetSelection();
621  if (++node == itemList.end()) return;
622  }
623 
624  if (strand == 1) // eNa_strand_minus
625  swap(from,to);
626  wxComboBox *combo = (wxComboBox*)(**node).GetWindow();
627  seqID = combo->GetValue();
628 }
629 
630 void CLocationListCtrl::OnStrandChange(wxCommandEvent& event)
631 {
632  wxSizerItemList& itemList = m_Sizer->GetChildren();
633  wxSizerItemList::iterator row = x_FindRow((wxWindow*)event.GetEventObject(), itemList);
634  if (row == itemList.end())
635  return;
636  wxSizerItemList::iterator node = row;
637 
638  wxTextCtrl* from_ctrl = (wxTextCtrl*)(**node).GetWindow();
639  int from = wxAtoi(from_ctrl->GetValue());
640  if (++node == itemList.end()) return;
641 
642  wxTextCtrl* to_ctrl = (wxTextCtrl*)(**node).GetWindow();
643  int to = wxAtoi(to_ctrl->GetValue());
644  if (++node == itemList.end()) return;
645 
646  int strand = 0;
647 
648  if (!m_is_aa)
649  {
650  wxChoice* strand_ctrl = dynamic_cast<wxChoice*>((**node).GetWindow());
651  strand = strand_ctrl->GetSelection();
652  }
653 
654  if ((strand == 1 && from < to) || (strand != 1 && from > to) ) // eNa_strand_minus
655  {
656  from_ctrl->SetValue(wxEmptyString);
657  to_ctrl->SetValue(wxEmptyString);
658  *from_ctrl << to;
659  *to_ctrl << from;
660  }
661 }
662 
663 void CLocationListCtrl::OnDelete (wxHyperlinkEvent& event)
664 {
665  wxSizerItemList& itemList = m_Sizer->GetChildren();
666  wxSizerItemList::iterator row = x_FindRow((wxWindow*)event.GetEventObject(), itemList);
667  DeleteRow(row, itemList);
668  if (m_Sizer->GetChildren().empty()) {
669  m_LastFrom = NULL;
670  m_LastTo = NULL;
671  m_LastStrand = NULL;
672  m_LastId = NULL;
673  x_AddEmptyRow();
674  }
675  m_ScrolledWindow->FitInside();
676 }
677 
678 void CLocationListCtrl::OnSpinCtrl ( wxCommandEvent& evt )
679 {
680  wxWindow* spnCtrl = (wxWindow*)evt.GetEventObject();
681 
682  wxSizerItemList& itemList = m_Sizer->GetChildren();
683  wxSizerItemList::iterator row = x_FindRow(spnCtrl, itemList);
684  if (row == itemList.end())
685  return;
686 
687  wxSizerItemList::iterator row2;
688 
689  switch (evt.GetId()) {
691  row2 = x_PrevRow(row, itemList);
692  s_SwapRows(row, row2, itemList);
693  m_Sizer->Layout();
694  m_ScrolledWindow->Refresh();
695  break;
697  row2 = x_NextRow(row, itemList);
698  s_SwapRows(row, row2, itemList);
699  m_Sizer->Layout();
700  m_ScrolledWindow->Refresh();
701  break;
702  case 2 + CLargeSpinControl::kBtnUp:
703  {{
704  size_t rowPos = itemList.IndexOf(*row);
705 
706  int from = 1, to = 1, strand = 0;
707  wxString seqID;
708  bool fuzz = false;
709  x_GetRowData(row, itemList, from, to, strand, seqID, fuzz);
710  if (from > 1)
711  --from;
712 #if 1
713  x_AddEmptyRow(rowPos);
714 #else
715  x_AddRow(from, from, strand, seqID, fuzz, rowPos);
716 #endif
717  m_Sizer->Layout();
718  m_ScrolledWindow->FitInside();
719  m_ScrolledWindow->Refresh();
720  }}
721  break;
722  case 2 + CLargeSpinControl::kBtnDn:
723  {{
724  int from = 1, to = 1, strand = 0;
725  wxString seqID;
726  bool fuzz = false;
727  x_GetRowData(row, itemList, from, to, strand, seqID, fuzz);
728 
729  row = x_NextRow(row, itemList);
730  size_t rowPos = (row == itemList.end()) ? (size_t)-1 : itemList.IndexOf(*row);
731  ++to;
732 #if 1
733  x_AddEmptyRow(rowPos);
734 #else
735  x_AddRow(to, to, strand, seqID, fuzz, rowPos);
736 #endif
737  m_Sizer->Layout();
738  m_ScrolledWindow->FitInside();
739  m_ScrolledWindow->Refresh();
740  }}
741  break;
742  }
743 }
744 
745 void CLocationListCtrl::x_AddRow(int from, int to, int strand, const wxString& seqID, const bool fuzz, size_t rowPos)
746 {
747  if (strand == 1) //eNa_strand_minus
748  swap(from,to);
749  wxTextCtrl *textFrom;
750  textFrom = new wxTextCtrl(m_ScrolledWindow, wxID_ANY, wxT(""), wxDefaultPosition,
751  wxSize(m_ScrolledWindow->ConvertDialogToPixels(wxSize(45, -1)).x, -1),
752  wxTE_RIGHT);
753  *textFrom << from;
754  if (fuzz)
755  *textFrom << "^";
756  if (rowPos == (size_t)-1)
757  m_Sizer->Add(textFrom, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
758  else
759  m_Sizer->Insert(rowPos++, textFrom, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
760 
761  wxTextCtrl *text;
762  text = new wxTextCtrl(m_ScrolledWindow, wxID_ANY, wxT(""), wxDefaultPosition,
763  wxSize(m_ScrolledWindow->ConvertDialogToPixels(wxSize(45, -1)).x, -1),
764  wxTE_RIGHT);
765  *text << to;
766  if (rowPos == (size_t)-1)
767  m_Sizer->Add(text, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
768  else
769  m_Sizer->Insert(rowPos++, text, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
770 
771  if (!m_is_aa)
772  {
773  wxArrayString itemComboBoxStrings;
774  itemComboBoxStrings.Add(wxT("Plus"));
775  itemComboBoxStrings.Add(wxT("Minus"));
776  itemComboBoxStrings.Add(wxT("Both"));
777  itemComboBoxStrings.Add(wxT("Other"));
778 
779  wxChoice* strand_ctrl = new CNoTabChoice(m_ScrolledWindow, wxID_ANY,
780  wxDefaultPosition,
781  wxSize(m_ScrolledWindow->ConvertDialogToPixels(wxSize(45, -1)).x, -1),
782  itemComboBoxStrings);
783  strand_ctrl->SetSelection(strand);
784 
785  if (rowPos == (size_t)-1)
786  m_Sizer->Add(strand_ctrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
787  else
788  m_Sizer->Insert(rowPos++, strand_ctrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
789  }
790 
792  wxDefaultPosition,
793  wxSize(m_ScrolledWindow->ConvertDialogToPixels(wxSize(80, -1)).x, -1),
794  m_SeqIds);
795  if (rowPos == (size_t)-1)
796  m_Sizer->Add(combo, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
797  else
798  m_Sizer->Insert(rowPos++, combo, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
799 
800  wxBoxSizer* controlsSizer = new wxBoxSizer(wxHORIZONTAL);
801  if (rowPos == (size_t)-1)
802  m_Sizer->Add(controlsSizer);
803  else
804  m_Sizer->Insert(rowPos++, controlsSizer);
805 
806  CLargeNoTabSpinControl* spinCtrl1 = new CLargeNoTabSpinControl(m_ScrolledWindow, wxID_ANY, wxDefaultPosition);
807  spinCtrl1->SetToolTip(_("Use insert controls to insert blank location intervals"));
808  spinCtrl1->UseImageSet(1);
809  controlsSizer->Add(spinCtrl1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 0);
810 
811  CLargeNoTabSpinControl* spinCtrl2 = new CLargeNoTabSpinControl(m_ScrolledWindow, wxID_ANY, wxDefaultPosition);
812  spinCtrl2->SetToolTip(_("Use arrow controls to reorder location intervals"));
813  controlsSizer->Add(spinCtrl2, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 0);
814 
815  CNoTabHyperlinkCtrl* itemHyperLink = new CNoTabHyperlinkCtrl(m_ScrolledWindow, wxID_ANY, wxT("Delete"), wxT(""));
816  itemHyperLink->SetVisitedColour(itemHyperLink->GetNormalColour());
817  controlsSizer->Add(itemHyperLink, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 0);
818 
819  textFrom->SetFocus();
820  textFrom->SetSelection(-1, -1);
821  m_LastIdSelection = combo->GetSelection();
822  m_LastStrandSelection = strand;
823  m_LastIdValue = combo->GetValue();
824 }
825 
827 {
828  if (m_LastFrom)
829  m_LastFrom->Unbind(wxEVT_TEXT_ENTER, &CLocationListCtrl::OnNewText, this);
830  if (m_LastTo)
831  m_LastTo->Unbind(wxEVT_TEXT_ENTER, &CLocationListCtrl::OnNewText, this);
832 
833 
834  m_LastFrom = new wxTextCtrl(m_ScrolledWindow, wxID_ANY, wxT(""), wxDefaultPosition,
835  wxSize(m_ScrolledWindow->ConvertDialogToPixels(wxSize(45, -1)).x, -1),
836  wxTE_RIGHT|wxTE_PROCESS_ENTER);
837  if (rowPos == (size_t)-1)
838  m_Sizer->Add(m_LastFrom, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
839  else
840  m_Sizer->Insert(rowPos++, m_LastFrom, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
841 
842  m_LastTo = new wxTextCtrl(m_ScrolledWindow, wxID_ANY, wxT(""), wxDefaultPosition,
843  wxSize(m_ScrolledWindow->ConvertDialogToPixels(wxSize(45, -1)).x, -1),
844  wxTE_RIGHT|wxTE_PROCESS_ENTER);
845  if (rowPos == (size_t)-1)
846  m_Sizer->Add(m_LastTo, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
847  else
848  m_Sizer->Insert(rowPos++, m_LastTo, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
849 
850  wxArrayString itemComboBoxStrings;
851  itemComboBoxStrings.Add(wxT("Plus"));
852  itemComboBoxStrings.Add(wxT("Minus"));
853  itemComboBoxStrings.Add(wxT("Both"));
854  itemComboBoxStrings.Add(wxT("Other"));
855  if (!m_is_aa)
856  {
858  wxDefaultPosition,
859  wxSize(m_ScrolledWindow->ConvertDialogToPixels(wxSize(45, -1)).x, -1),
860  itemComboBoxStrings);
861  m_LastStrand->SetSelection(m_LastStrandSelection);
862 
863  if (rowPos == (size_t)-1)
864  m_Sizer->Add(m_LastStrand, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
865  else
866  m_Sizer->Insert(rowPos++, m_LastStrand, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
867  }
868 
870  wxDefaultPosition,
871  wxSize(m_ScrolledWindow->ConvertDialogToPixels(wxSize(80, -1)).x, -1),
872  m_SeqIds);
873  m_LastId->SetValue(m_LastIdValue);
874  if (rowPos == (size_t)-1)
875  m_Sizer->Add(m_LastId, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
876  else
877  m_Sizer->Insert(rowPos++, m_LastId, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 0);
878 
879  wxBoxSizer* controlsSizer = new wxBoxSizer(wxHORIZONTAL);
880  if (rowPos == (size_t)-1)
881  m_Sizer->Add(controlsSizer);
882  else
883  m_Sizer->Insert(rowPos++, controlsSizer);
884 
885  CLargeSpinControl* spinCtrl1 = new CLargeNoTabSpinControl(m_ScrolledWindow, wxID_ANY, wxDefaultPosition);
886  spinCtrl1->UseImageSet(1);
887  controlsSizer->Add(spinCtrl1, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 0);
888 
889  CLargeSpinControl* spinCtrl2 = new CLargeNoTabSpinControl(m_ScrolledWindow, wxID_ANY, wxDefaultPosition);
890  controlsSizer->Add(spinCtrl2, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 0);
891 
892  wxHyperlinkCtrl* itemHyperLink = new CNoTabHyperlinkCtrl(m_ScrolledWindow, wxID_ANY, wxT("Delete"), wxT(""));
893  itemHyperLink->SetVisitedColour(itemHyperLink->GetNormalColour());
894  controlsSizer->Add(itemHyperLink, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 0);
895 
896  m_LastFrom->SetFocus();
897  m_LastFrom->SetSelection(-1, -1);
898 
899  m_LastFrom->Bind(wxEVT_TEXT_ENTER, &CLocationListCtrl::OnNewText, this);
900  m_LastTo->Bind(wxEVT_TEXT_ENTER, &CLocationListCtrl::OnNewText, this);
901 }
902 
903 void CLocationListCtrl::OnSortClick( wxCommandEvent& WXUNUSED(event) )
904 {
905  vector<SIntData> intVec;
906 
907  SIntData intData;
908  wxSizerItemList& children = m_Sizer->GetChildren();
909  wxSizerItemList::iterator node = children.begin();
910 
911  for (; node != children.end(); ) {
912  wxTextCtrl* text = (wxTextCtrl*)(**node).GetWindow();
913  if (++node == children.end()) break;
914  wxString from = text->GetValue();
915 
916  text = (wxTextCtrl*)(**node).GetWindow();
917  if (++node == children.end()) break;
918  wxString to = text->GetValue();
919 
920  wxChoice* strand_combo = NULL;
921  if (!m_is_aa)
922  {
923  strand_combo = dynamic_cast<wxChoice*>((**node).GetWindow());
924  if (++node == children.end()) break;
925  }
926 
927  wxComboBox* id_combo = (wxComboBox*)(**node).GetWindow();
928  if (++node == children.end()) break;
929 
930  ++node; // Controls sizer
931 
932  if (from.IsEmpty() && to.IsEmpty()) {
933  intData.m_Empty = true;
934  } else {
935  intData.m_Fuzz = NStr::StartsWith(from.ToStdString(),"^") || NStr::EndsWith(from.ToStdString(),"^") || NStr::StartsWith(to.ToStdString(),"^") || NStr::EndsWith(to.ToStdString(),"^");
936  intData.m_From = wxAtoi(from);
937  intData.m_To = wxAtoi(to);
938  intData.m_Empty = false;
939  }
940 
941  intData.m_Strand = 0;
942  if (strand_combo)
943  intData.m_Strand = strand_combo->GetSelection();
944  intData.m_SeqId = id_combo->GetValue();
945  if (intData.m_Strand == 1) // eNa_strand_minus
946  swap(intData.m_From, intData.m_To);
947 
948  intVec.push_back(intData);
949  }
950 
951  if (intVec.empty())
952  return;
953 
954  sort(intVec.begin(), intVec.end());
955 
956  for (node = children.begin(); node != children.end(); ++node)
957  {
958 
959  (**node).DeleteWindows();
960  }
961 
962  children.clear();
963 
964  vector<SIntData>::const_iterator it;
965  int num_added = 0;
966  for (it = intVec.begin(); it != intVec.end(); ++it) {
967  if (!it->m_Empty) {
968  x_AddRow(it->m_From, it->m_To, it->m_Strand, it->m_SeqId, it->m_Fuzz);
969  num_added++;
970  }
971  }
972  m_LastFrom = NULL;
973  m_LastTo = NULL;
974  m_LastStrand = NULL;
975  m_LastId = NULL;
976  x_AddEmptyRow();
977 
978 
979  m_ScrolledWindow->FitInside();
980 }
981 
982 
984 {
985  vector<SIntData>::const_iterator it;
986  set<wxString> idsSet;
987  for (it = m_Data.begin(); it != m_Data.end(); ++it)
988  idsSet.insert(it->m_SeqId);
989 
990  m_SeqIds.Empty();
991  m_str_to_id.clear();
992  if (m_Scope && (m_AllowNuc || m_AllowProt)) {
994  m_Scope->GetAllTSEs(tses, CScope::eAllTSEs);
995  if (m_AllowNuc && m_AllowProt) {
996  ITERATE (CScope::TTSE_Handles, handle, tses) {
997  for (CBioseq_CI bioseq_it(*handle); bioseq_it; ++bioseq_it) {
998  try {
999  string str;
1000  CLabel::GetLabel(*(bioseq_it->GetSeqId()), &str, CLabel::eUserTypeAndContent, m_Scope);
1001  m_str_to_id[str] = bioseq_it->GetSeqId();
1002  m_SeqIds.Add(ToWxString(str));
1003  }
1004  catch (const CException&) {}
1005  }
1006  }
1007  } else if (m_AllowNuc) {
1008  ITERATE (CScope::TTSE_Handles, handle, tses) {
1009  for (CBioseq_CI bioseq_it(*handle, CSeq_inst::eMol_na); bioseq_it; ++bioseq_it) {
1010  string str;
1011  CLabel::GetLabel(*(bioseq_it->GetSeqId()), &str, CLabel::eUserTypeAndContent, m_Scope);
1012  m_str_to_id[str] = bioseq_it->GetSeqId();
1013  m_SeqIds.Add(ToWxString (str));
1014  }
1015  }
1016  } else {
1017  ITERATE (CScope::TTSE_Handles, handle, tses) {
1018  for (CBioseq_CI bioseq_it(*handle, CSeq_inst::eMol_aa); bioseq_it; ++bioseq_it) {
1019  string str;
1020  CLabel::GetLabel(*(bioseq_it->GetSeqId()), &str, CLabel::eUserTypeAndContent, m_Scope);
1021  m_str_to_id[str] = bioseq_it->GetSeqId();
1022  m_SeqIds.Add(ToWxString (str));
1023  }
1024  }
1025  }
1026  } else {
1028  for (it2 = idsSet.begin(); it2 != idsSet.end(); ++it2)
1029  m_SeqIds.Add(*it2);
1030  }
1031 }
1032 
1033 
1035 {
1036  if (!wxPanel::TransferDataToWindow())
1037  return false;
1038 
1039  wxSizerItemList& children = m_Sizer->GetChildren();
1040  wxSizerItemList::iterator node = children.begin();
1041  for (; node != children.end(); ++node)
1042  {
1043  (**node).DeleteWindows();
1044  }
1045  children.clear();
1046  m_LastFrom = NULL;
1047  m_LastTo = NULL;
1048  m_LastStrand = NULL;
1049  m_LastId = NULL;
1050 
1051  if (m_SeqIds.IsEmpty()) {
1053  }
1054  bool last_empty = false;
1055  vector<SIntData>::const_iterator it;
1056  for (it = m_Data.begin(); it != m_Data.end(); ++it) {
1057  if (it->m_Empty) {
1058  x_AddEmptyRow ();
1059  last_empty = true;
1060  } else {
1061  x_AddRow(it->m_From, it->m_To, it->m_Strand, it->m_SeqId, it->m_Fuzz);
1062  last_empty = false;
1063  }
1064  }
1065 
1066  if (!last_empty)
1067  {
1068  x_AddEmptyRow ();
1069  }
1070  m_ScrolledWindow->FitInside();
1071 
1072  return true;
1073 }
1074 
1076 {
1077  if (!wxPanel::TransferDataFromWindow())
1078  return false;
1079 
1080  m_Data.clear();
1081 
1082  SIntData intData;
1083  wxSizerItemList& children = m_Sizer->GetChildren();
1084  wxSizerItemList::iterator node = children.begin();
1085 
1086  for (; node != children.end(); ) {
1087  wxTextCtrl* text = (wxTextCtrl*)(**node).GetWindow();
1088  if (++node == children.end()) break;
1089  wxString from = text->GetValue();
1090 
1091  text = (wxTextCtrl*)(**node).GetWindow();
1092  if (++node == children.end()) break;
1093  wxString to = text->GetValue();
1094 
1095  wxChoice* strand_combo = NULL;
1096  if (!m_is_aa)
1097  {
1098  strand_combo = dynamic_cast<wxChoice*>((**node).GetWindow());
1099  if (++node == children.end()) break;
1100  }
1101 
1102  wxComboBox* id_combo = (wxComboBox*)(**node).GetWindow();
1103  if (++node == children.end()) break;
1104 
1105  ++node; // "Delete" Hyperlink
1106 
1107  if (from.IsEmpty() && to.IsEmpty()) {
1108  intData.m_Empty = true;
1109  } else {
1110  if (from.IsEmpty()) {
1111  from = to;
1112  } else if (to.IsEmpty()) {
1113  to = from;
1114  }
1115 
1116  string from_str = from.ToStdString();
1117  string to_str = to.ToStdString();
1118  intData.m_Fuzz = NStr::StartsWith(from_str,"^") || NStr::EndsWith(from_str,"^") || NStr::StartsWith(to_str,"^") || NStr::EndsWith(to_str,"^");
1119  if (intData.m_Fuzz) {
1120  NStr::ReplaceInPlace(from_str, "^", "");
1121  NStr::ReplaceInPlace(to_str, "^", "");
1122  }
1123  NStr::TruncateSpacesInPlace(from_str);
1125  intData.m_From = NStr::StringToInt(from_str);
1126  intData.m_To = NStr::StringToInt(to_str);
1127  intData.m_Strand = 0;
1128  if (strand_combo)
1129  intData.m_Strand = strand_combo->GetSelection();
1130  intData.m_SeqId = id_combo->GetValue();
1131  intData.m_Empty = false;
1132  if (intData.m_Strand == 1) // eNa_strand_minus
1133  swap(intData.m_From, intData.m_To);
1134  }
1135  m_Data.push_back(intData);
1136  }
1137 
1138  return true;
1139 }
1140 
1141 void CLocationListCtrl::OnNewText(wxCommandEvent& event)
1142 {
1143  if (m_LastFrom && m_LastTo && !m_LastFrom->GetValue().IsEmpty() && !m_LastTo->GetValue().IsEmpty())
1144  {
1145  if (m_LastId->GetValue().IsEmpty())
1146  {
1147  if (m_LastIdSelection != wxNOT_FOUND)
1148  m_LastId->SetSelection(m_LastIdSelection);
1149  else
1150  m_LastId->ChangeValue(m_LastIdValue);
1151  }
1152  else
1153  {
1154  m_LastIdSelection = m_LastId->GetSelection();
1155  m_LastIdValue = m_LastId->GetValue();
1156  }
1157  if (m_LastStrand)
1158  {
1159  if (m_LastStrand->GetSelection() == wxNOT_FOUND)
1160  {
1161  m_LastStrand->SetSelection(m_LastStrandSelection);
1162  }
1163  else
1164  {
1165  m_LastStrandSelection = m_LastStrand->GetSelection();
1166  }
1167  }
1168  x_AddEmptyRow();
1169  m_ScrolledWindow->FitInside();
1170  }
1171 }
1172 
1174 {
1175  wxArrayString::iterator it = m_SeqIds.begin();
1176  while (it != m_SeqIds.end()) {
1177  if (str == *it) {
1178  return true;
1179  }
1180  it++;
1181  }
1182  return false;
1183 }
1184 
1185 
1187 {
1188  if (m_SeqIds.IsEmpty()) {
1190  }
1191  string str;
1192  if (m_Scope)
1194  else
1195  seq_id.GetLabel(&str, CSeq_id::eContent);
1196  wxString seqId = ToWxString(str);
1197  if (!IsInIdList(seqId) && m_Scope) {
1198  // if this seqID is not in the list for the location editor,
1199  // try to find a different ID from the same BioSeq that is
1200  CBioseq_Handle bsh = m_Scope->GetBioseqHandle(seq_id);
1201  if (bsh) {
1202  ITERATE(CBioseq::TId, id_it, bsh.GetCompleteBioseq()->GetId()) {
1203  string check;
1205  wxString wxchk = ToWxString(check);
1206  if (IsInIdList(wxchk)) {
1207  seqId = wxchk;
1208  break;
1209  }
1210  }
1211  }
1212  }
1213  return seqId;
1214 }
1215 
1216 
1217 /*!
1218  * Should we show tooltips?
1219  */
1220 
1222 {
1223  return true;
1224 }
1225 
1226 /*!
1227  * Get bitmap resources
1228  */
1229 
1230 wxBitmap CLocationListCtrl::GetBitmapResource( const wxString& name )
1231 {
1232  // Bitmap retrieval
1233 ////@begin CLocationListCtrl bitmap retrieval
1234  wxUnusedVar(name);
1235  return wxNullBitmap;
1236 ////@end CLocationListCtrl bitmap retrieval
1237 }
1238 
1239 /*!
1240  * Get icon resources
1241  */
1242 
1243 wxIcon CLocationListCtrl::GetIconResource( const wxString& name )
1244 {
1245  // Icon retrieval
1246 ////@begin CLocationListCtrl icon retrieval
1247  wxUnusedVar(name);
1248  return wxNullIcon;
1249 ////@end CLocationListCtrl icon retrieval
1250 }
1251 
1253 
1254 
static CRef< CScope > m_Scope
@ eExtreme_Biological
5' and 3'
Definition: Na_strand.hpp:62
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
void UseImageSet(int set)
Data loader exceptions, used by GenBank loader.
CLocationListCtrl()
Constructors.
void x_GetRowData(wxSizerItemList::iterator row, wxSizerItemList &itemList, int &from, int &to, int &strand, wxString &seqID, bool &fuzz)
~CLocationListCtrl()
Destructor.
void OnDelete(wxHyperlinkEvent &event)
void OnSortClick(wxCommandEvent &event)
wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BUTTON1
wxScrolledWindow * m_ScrolledWindow
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
wxFlexGridSizer * m_Sizer
CNoTabChoice * m_LastStrand
CRef< objects::CSeq_id > GetIdFromForm(size_t index)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
void Init()
Initialises member variables.
CRef< objects::CSeq_loc > GetSeq_loc()
CRef< objects::CScope > m_Scope
CRef< objects::CSeq_loc > x_GetInterval(size_t index, bool int_only)
vector< SIntData > m_Data
void DeleteRow(wxSizerItemList::iterator row, wxSizerItemList &itemList)
void OnStrandChange(wxCommandEvent &event)
objects::ENa_strand x_GetStrandFromForm(size_t index)
virtual bool TransferDataToWindow()
virtual bool TransferDataFromWindow()
wxSizerItemList::iterator x_FindRow(wxWindow *wnd, wxSizerItemList &itemList)
void OnNewText(wxCommandEvent &event)
bool Create(wxWindow *parent, wxWindowID id=ID_CLOCATIONLISTCTRL, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSUNKEN_BORDER|wxTAB_TRAVERSAL)
Creation.
void OnSpinCtrl(wxCommandEvent &evt)
CNoTabComboBox * m_LastId
objects::ENa_strand GetStrandFromForm(size_t index)
void AddRow(int from, int to, int strand, const wxString &seqID, const bool fuzz)
static bool ShowToolTips()
Should we show tooltips?
wxSizerItemList::iterator x_PrevRow(wxSizerItemList::iterator row, wxSizerItemList &itemList)
bool IsInIdList(wxString str)
wxSizerItemList::iterator x_NextRow(wxSizerItemList::iterator row, wxSizerItemList &itemList)
void SetPartials(bool partial5, bool partial3)
wxString GetListIdStrForSeqId(const objects::CSeq_id &seq_id)
void x_AddRow(int from, int to, int strand, const wxString &seqID, const bool fuzz, size_t rowPos=-1)
void x_AddEmptyRow(size_t rowPos=-1)
map< string, CConstRef< objects::CSeq_id > > m_str_to_id
void CreateControls()
Creates the controls and sizers.
void SetGi(TGi value)
Definition: Object_id.hpp:190
CSeqIdException –.
Definition: Seq_id.hpp:1001
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
Definition: set.hpp:45
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator begin() const
Definition: set.hpp:135
const_iterator end() const
Definition: set.hpp:136
#define _(proto)
Definition: ct_nlmzip_i.h:78
#define ID_BUTTON1
static void Init(void)
Definition: cursor6.c:76
#define check(s)
Definition: describecol2.c:21
static const char * str(char *buf, int n)
Definition: stats.c:84
static char tmp[3200]
Definition: utf8.c:42
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
Int8 TIntId
Definition: ncbimisc.hpp:999
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
Definition: ncbimisc.hpp:1508
#define ZERO_GI
Definition: ncbimisc.hpp:1088
#define GI_TO(T, gi)
Definition: ncbimisc.hpp:1085
#define NULL
Definition: ncbistd.hpp:225
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
Definition: label.cpp:140
@ eUserTypeAndContent
Definition: label.hpp:66
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Optimized implementation of CSerialObject::Assign, which is not so efficient.
Definition: Seq_id.cpp:318
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
Definition: Seq_id.cpp:2040
CSeq_id & Set(const CTempString &the_id, TParseFlags flags=fParse_AnyRaw)
Reassign based on flat specifications; arguments interpreted as with constructors.
Definition: Seq_id.cpp:2457
@ eContent
Untagged human-readable accession or the like.
Definition: Seq_id.hpp:605
void SetPnt(TPnt &v)
Definition: Seq_loc.hpp:985
void SetInt(TInt &v)
Definition: Seq_loc.hpp:983
void SetPartialStart(bool val, ESeqLocExtremes ext)
set / remove e_Lim fuzz on start or stop (lt/gt - indicating partial interval)
Definition: Seq_loc.cpp:3280
void SetPartialStop(bool val, ESeqLocExtremes ext)
Definition: Seq_loc.cpp:3313
void SetNull(void)
Override all setters to incorporate cache invalidation.
Definition: Seq_loc.hpp:960
TGi GetGiForId(const objects::CSeq_id &id, CScope &scope, EGetIdType flags=0)
Given a Seq-id retrieve the corresponding GI.
Definition: sequence.cpp:668
vector< CSeq_entry_Handle > TTSE_Handles
Definition: scope.hpp:645
@ eAllTSEs
Definition: scope.hpp:643
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
Definition: ncbiobj.hpp:735
#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 int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
Definition: ncbistr.hpp:5430
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
Definition: ncbistr.cpp:3201
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
Definition: ncbistr.hpp:5412
static string & ReplaceInPlace(string &src, const string &search, const string &replace, 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:3405
TStr & SetStr(void)
Select the variant.
Definition: Object_id_.hpp:304
@ eLim_tr
space to right of position
Definition: Int_fuzz_.hpp:213
void SetTo(TTo value)
Assign a value to To data member.
void SetPoint(TPoint value)
Assign a value to Point data member.
Definition: Seq_point_.hpp:312
void SetId(TId &value)
Assign a value to Id data member.
Definition: Seq_point_.cpp:61
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
void SetId(TId &value)
Assign a value to Id data member.
void SetStrand(TStrand value)
Assign a value to Strand data member.
Definition: Seq_point_.hpp:359
void SetFuzz(TFuzz &value)
Assign a value to Fuzz data member.
Definition: Seq_point_.cpp:71
void SetFrom(TFrom value)
Assign a value to From data member.
TGi GetGi(void) const
Get the variant data.
Definition: Seq_id_.hpp:889
TGi & SetGi(void)
Select the variant.
Definition: Seq_id_.hpp:896
TLocal & SetLocal(void)
Select the variant.
Definition: Seq_id_.cpp:199
bool IsGi(void) const
Check if variant Gi is selected.
Definition: Seq_id_.hpp:883
bool IsInt(void) const
Check if variant Int is selected.
Definition: Seq_loc_.hpp:528
const TInt & GetInt(void) const
Get the variant data.
Definition: Seq_loc_.cpp:194
bool IsNull(void) const
Check if variant Null is selected.
Definition: Seq_loc_.hpp:504
void SetStrand(TStrand value)
Assign a value to Strand data member.
@ eNa_strand_plus
Definition: Na_strand_.hpp:66
@ eNa_strand_other
Definition: Na_strand_.hpp:70
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
@ eNa_strand_unknown
Definition: Na_strand_.hpp:65
@ eNa_strand_both
in forward orientation
Definition: Na_strand_.hpp:68
const TId & GetId(void) const
Get the Id member data.
Definition: Bioseq_.hpp:290
list< CRef< CSeq_id > > TId
Definition: Bioseq_.hpp:94
@ eMol_na
just a nucleic acid
Definition: Seq_inst_.hpp:113
END_EVENT_TABLE()
int i
USING_SCOPE(objects)
static void s_SwapRows(wxSizerItemList::iterator row1, wxSizerItemList::iterator row2, wxSizerItemList &itemList)
void s_FinishLoc(CSeq_loc &loc, bool partial5, bool partial3)
static void text(MDB_val *v)
Definition: mdb_dump.c:62
#define wxT(x)
Definition: muParser.cpp:41
constexpr auto sort(_Init &&init)
const struct ncbi::grid::netcache::search::fields::SIZE size
#define abs(a)
Definition: ncbi_heapmgr.c:130
static static static wxID_ANY
#define row(bind, expected)
Definition: string_bind.c:73
C++ wrappers for the Perl-compatible regular expression (PCRE) library.
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Sun May 12 04:55:29 2024 by modify_doxy.py rev. 669887