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

Go to the SVN repository for this file.

1 /* $Id: text_panel.cpp 47487 2023-05-02 14:50:13Z ucko $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Roman Katargin
27  */
28 
29 
30 #include <ncbi_pch.hpp>
31 
32 #include <wx/sizer.h>
33 #include <wx/choice.h>
34 #include <wx/stattext.h>
35 #include <wx/checkbox.h>
36 #include <wx/textctrl.h>
37 #include <wx/button.h>
38 #include <wx/bmpbuttn.h>
39 #include <wx/choice.h>
40 #include <wx/bitmap.h>
41 #include <wx/icon.h>
42 #include <wx/msgdlg.h>
43 #include <wx/filedlg.h>
44 #include <wx/dcclient.h>
45 #include <wx/settings.h>
46 
47 ////@begin includes
48 ////@end includes
49 
50 #include <objmgr/bioseq_ci.hpp>
51 
52 #include <gui/utils/view_event.hpp>
53 
58 
64 
66 
75 #include "text_commands.hpp"
76 #include "fasta_context.hpp"
77 
81 
83 
85 
86 
88 #include "select_sequence_dlg.hpp"
89 
92 
93 ////@begin XPM images
94 ////@end XPM images
95 
96 
97 /*!
98  * CTextPanel type definition
99  */
100 
101 IMPLEMENT_DYNAMIC_CLASS( CTextPanel, wxPanel )
102 
103 
104 /*!
105  * CTextPanel event table definition
106  */
107 
108 BEGIN_EVENT_TABLE( CTextPanel, wxPanel )
109  EVT_TEXT_ENTER( ID_TB_SearchTerm, CTextPanel::OnSearchTermCtrlEnter )
110  EVT_MENU( ID_TB_SearchButton, CTextPanel::OnFindNextClick )
111  EVT_CHOICE( ID_TB_SearchModeCtrl, CTextPanel::OnFindModeSelected )
112  EVT_CHOICE( ID_TB_SequenceListCtrl, CTextPanel::OnSequenceSelected )
113  EVT_MENU( ID_TB_Options, CTextPanel::OnOptionsClick )
114  EVT_CONTEXT_MENU( CTextPanel::OnContextMenu )
116 
117 static const wxChar* pszFlatFile = wxT("Flat File");
118 static const wxChar* pszFastA = wxT("FastA");
119 static const wxChar* pszASN = wxT("ASN");
120 static const wxChar* pszXML = wxT("XML");
121 
122 static const wxChar* pszMainToolbar = wxT("Main Toolbar");
124 
126 static const char* kAllSequences = "All";
127 static const char* kMoreSequences = "More...";
128 const size_t kMaxSeqNumber = 25;
129 
130 static wxColor m_BackgroundColor = *wxWHITE;
132 
134 {
135 public:
137  : m_bVector(bVector), m_Pos(0) {}
138 
139  virtual bool ProcessItem(CTextItem& /*textItem*/) { return true; }
140  virtual bool ProcessItem(CExpandItem& expandItem)
141  {
142  m_bVector.set(m_Pos, expandItem.IsExpanded());
143  ++m_Pos;
144  return true;
145  }
146 
147 private:
149  int m_Pos;
150 };
151 
153 {
154 public:
156  : m_Context(context), m_bVector(bVector), m_Pos(0) {}
157 
158  virtual bool ProcessItem(CTextItem& /*textItem*/) { return true; }
159  virtual bool ProcessItem(CExpandItem& expandItem)
160  {
161  if ((m_bVector[m_Pos] && !expandItem.IsExpanded()) || (!m_bVector[m_Pos] && expandItem.IsExpanded())) {
162  expandItem.Toggle(&m_Context, false);
163  }
164  ++m_Pos;
165  return true;
166  }
167 
168 private:
171  int m_Pos;
172 };
173 
175 {
176  int pointSize = 10;
177  switch (size) {
178  case 0: pointSize = 8; break;
179  case 2: pointSize = 12; break;
180  case 3: pointSize = 14; break;
181  }
182 
183 #ifdef __WXOSX_COCOA__
184  float mult = GetDisplayPPI().y / (float)wxGetDisplayPPI().y;
185  pointSize = (int)(pointSize*mult + .5);
186 #endif
187 
188  return wxFont(pointSize, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
189 }
190 
192 {
194  s_BackgroundColorSet = true;
195 }
196 
197 wxWindow* CTextPanel::CreateForm(wxWindow* parent)
198 {
199  return new CTextPanel(parent);
200 }
201 
202 /*!
203  * CTextPanel constructors
204  */
205 
207 {
208  Init();
209 }
210 
211 CTextPanel::CTextPanel( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
212 {
213  Init();
214  Create(parent, id, pos, size, style);
215  CreateControls();
216 #ifdef _DEBUG
217  LOG_POST(Info << "CTextPanel:: Text item count: " << gITextItemCount.Get());
218 #endif
219 }
220 
221 /*!
222  * CTextPanel destructor
223  */
224 
226 {
227  UpdateRegistry();
228  m_AuiManager.UnInit();
229 
230 ////@begin CTextPanel destruction
231 ////@end CTextPanel destruction
232 
233 #ifdef _DEBUG
234  m_TextWindow->SetMainItem(0, 0);
235  LOG_POST(Info << "~CTextPanel:: Text item count: " << gITextItemCount.Get());
236 #endif
237 }
238 
239 /*!
240  * Member initialisation
241  */
242 
243 static const char
244 *kTextViewPath = "GBENCH.TextView",
245 *kFindMode = "FindMode",
246 *kViewTypeSeq = "ViewTypeSeq",
247 *kViewTypeFeat = "ViewTypeFeat",
248 *kViewTypeGeneric = "ViewTypeGeneric",
249 *kFontSize = "FontSize",
250 *kFlatFileMode = "FlatFileMode",
251 *kShowSequence = "ShowSequence",
252 *kFlatFileSequence = "kFlatFileSequence",
253 *kFeatureMode = "FeatureMode",
254 *kASNShowTypes = "ASNShowTypes",
255 *kASNShowPathToRoot = "ASNShowPathToRoot",
256 *kFFHideVariations = "FFHideVariations",
257 *kFFHideSTS = "FFHideSTS",
258 *kOpenExpanded = "OpenExpanded";
259 
260 
262 {
263 ////@begin CTextPanel member initialisation
265  m_FontSize = 1;
266  m_FlatFileMode = 0;
267  m_ShowSequence = true;
268  m_FeatMode = 0;
269  m_ShowASNTypes = false;
270  m_ShowASNPathToRoot = false;
271  m_FindMode = 0;
272  m_FFHideVariations = false;
273  m_FFHideSTS = false;
274  m_OpenExpanded = true;
278  m_TextWindow = NULL;
279 ////@end CTextPanel member initialisation
280  m_ShowComponentFeats = false;
281 
282  m_WidgetHost = 0;
283  m_CmdProccessor = 0;
284  m_SavedPosX = m_SavedPosY = 0;
285 
286  x_ReadRegistry();
287 }
288 
289 /*!
290  * Control creation for CTextPanel
291  */
292 
294 {
295  SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY);
296 
297  Hide();
298 
299  m_DataSource.Reset(new CTextDataSource(*this));
300 
301  m_AuiManager.SetManagedWindow(this);
302 
303  m_TextWindow = new CTextItemPanel( this, ID_WIDGET, wxDefaultPosition, wxDefaultSize, wxNO_BORDER|wxHSCROLL|wxVSCROLL );
304  m_AuiManager.AddPane(m_TextWindow, wxAuiPaneInfo().CenterPane());
305 
307  m_TextWindow->SetBackgroundColour(m_BackgroundColor);
308  else
309  m_TextWindow->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
310 
311  m_TextWindow->SetFocus();
312 
313  m_AuiManager.Update();
314 /*
315  wxChoice* textType = (wxChoice*)FindWindow(ID_CHOICE1);
316  x_UpdateViewType(textType->GetStringSelection());
317  */
319 }
320 
322 {
323  if (m_FontSize != value) {
324  m_FontSize = value;
326  }
327 }
328 
330 {
331  static bool sImagesRegistered = false;
332  if (!sImagesRegistered) {
334  provider->RegisterFileAlias(wxT("text_panel::search"), wxT("search.png"));
335  provider->RegisterFileAlias(wxT("text_panel::options"), wxT("options.png"));
336  sImagesRegistered = true;
337  }
338 
339  wxAuiPaneInfo& pane = m_AuiManager.GetPane(pszMainToolbar);
340  wxAuiToolBar* toolbar = nullptr;
341  wxString searchTerm;
342 
343  if (pane.IsOk()) {
344  toolbar = (wxAuiToolBar*)pane.window;
345 
346  wxControl* ctrl = toolbar->FindControl(ID_TB_SearchModeCtrl);
347  if (ctrl) ctrl->Destroy();
348  m_FindModeCtrl = 0;
349 
350  ctrl = toolbar->FindControl(ID_TB_SearchTerm);
351  if (ctrl) {
352  searchTerm = ((CRichTextCtrl*)ctrl)->GetValue();
353  ctrl->Destroy();
354  }
355  m_FindTextCtrl = 0;
356 
357  ctrl = toolbar->FindControl(ID_TB_SequenceListCtrl);
358  if (ctrl) ctrl->Destroy();
359  m_SequenceList = 0;
360 
361  toolbar->ClearTools();
362  }
363  else {
364  toolbar = new wxAuiToolBar(this, wxID_ANY, wxDefaultPosition,
365  wxDefaultSize, wxAUI_TB_HORIZONTAL | wxBORDER_NONE);
366  }
367 
368  toolbar->AddLabel(ID_TB_SearchModeLabel, wxT("Find mode:"));
369  wxArrayString strings;
370  strings.Add(_("Match case"));
371  strings.Add(_("Do not match case"));
372  if (m_ViewType == kFlatFile)
373  strings.Add(_("Sequence"));
374  m_FindModeCtrl = new wxChoice(toolbar, ID_TB_SearchModeCtrl, wxDefaultPosition, wxDefaultSize, strings);
375  if (m_FindMode < 0 || m_FindMode >= (int)m_FindModeCtrl->GetCount())
376  m_FindMode = 0;
377  m_FindModeCtrl->SetSelection(m_FindMode);
378  toolbar->AddControl(m_FindModeCtrl);
379 
380  m_FindTextCtrl = new CRichTextCtrl(toolbar, ID_TB_SearchTerm, searchTerm, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
381  m_FindTextCtrl->SetMaxLength(60);
382 
383  wxMenu* menu = new wxMenu();
384  menu->Append(wxID_COPY, _("&Copy"));
385  menu->Append(wxID_PASTE, _("&Paste"));
387 
388  toolbar->AddControl(m_FindTextCtrl, wxT("Enter search term"));
389 
390  toolbar->AddTool(ID_TB_SearchButton, wxT("Search"), wxArtProvider::GetBitmap(wxT("text_panel::search")), wxT("Search"));
391 
392  toolbar->AddSeparator();
393  toolbar->AddTool(ID_TB_Options, wxT("Options"), wxArtProvider::GetBitmap(wxT("text_panel::options")), wxT("Options"));
394 
395  if (m_FlatFileSeqs.size() > 0) {
396  toolbar->AddSeparator();
397  toolbar->AddLabel(ID_TB_SequenceLabel, wxT("Sequence(s):"));
398  m_SequenceList = new wxChoice(toolbar, ID_TB_SequenceListCtrl);
399  toolbar->AddControl(m_SequenceList);
400  }
401 
402  toolbar->AddStretchSpacer();
403 
404  // As part of auto resize tollbar is resized in vertical position for a moment
405  // this is visible on MS windows screen - so hide it
406  toolbar->Hide();
407  toolbar->Realize();
408  toolbar->Show();
409 
410  if (!pane.IsOk())
411  m_AuiManager.AddPane(toolbar, wxAuiPaneInfo()
412  .Name(pszMainToolbar)
413  .Caption(pszMainToolbar)
414  .ToolbarPane()
415  .Top()
416  .TopDockable(true)
417  .LeftDockable(false)
418  .RightDockable(false)
419  .BottomDockable(false)
420  .Floatable(false)
421  .Resizable(true)
422  .DockFixed()
423  .Gripper(false)
424  .DestroyOnClose(true)
425  .Position(0));
426  else
427  pane.BestSize(toolbar->GetClientSize());
428 
429  m_AuiManager.Update();
430 }
431 
433 {
434  SConstScopedObject scoped_object;
435  scoped_object.object = m_SO;
436  scoped_object.scope = m_Scope;
437  objs.push_back(scoped_object);
438 }
439 
441 {
443 
444  m_FlatFileSeqs.clear();
445 
447 
448  Layout();
449 
450  wxBusyCursor wait;
451 
452  string errMsg;
453  try {
454  switch(m_ViewType) {
455  case kFlatFile:
456  x_LoadFlatFile();
457  break;
458  case kFastA:
459  x_LoadFastA();
460  break;
461  case kXML:
462  default:
463  x_LoadASN();
464  break;
465  }
466  } catch (const CException& e) {
467  errMsg = e.GetMsg();
468  } catch (const exception& e) {
469  errMsg = e.what();
470  }
471 
472  if (!errMsg.empty())
473  m_TextWindow->ReportError("Error Loading Data: " + errMsg);
474 }
475 
477  const CSeq_entry* seq_entry = 0;
478  const CSeq_submit* seq_submit = dynamic_cast<const CSeq_submit*>(so);
479  if (seq_submit) {
480  if (seq_submit->IsSetData()) {
481  const CSeq_submit::TData& data = seq_submit->GetData();
482  if (data.IsEntrys()) {
484  if (!entries.empty()) {
485  seq_entry = *entries.begin();
486  }
487  }
488  }
489  }
490  return seq_entry;
491 }
492 
494 {
495  const CSeq_id* seq_id = dynamic_cast<const CSeq_id*>(&so);
496  const CSeq_loc* seq_loc = dynamic_cast<const CSeq_loc*>(&so);
497  const CSeq_entry* seq_entry = dynamic_cast<const CSeq_entry*>(&so);
498  const CBioseq* bioseq = dynamic_cast<const CBioseq*>(&so);
499  const CBioseq_set* bioseq_set = dynamic_cast<const CBioseq_set*>(&so);
500 
501  if (!seq_entry) {
502  seq_entry = GetSeqEntryFromSeqSubmit(&so);
503  }
504 
505  CSeq_entry_Handle seh;
506 
507  if (seq_entry)
508  seh = scope.GetSeq_entryHandle(*seq_entry);
509  else if (bioseq) {
510  CBioseq_Handle handle = scope.GetBioseqHandle(*bioseq);
511  if (handle)
512  seh = handle.GetTopLevelEntry();
513  }
514  else if (bioseq_set) {
515  CBioseq_set_Handle handle = scope.GetBioseq_setHandle(*bioseq_set);
516  if (handle)
517  seh = handle.GetTopLevelEntry();
518  }
519  else if (seq_id) {
520  CBioseq_Handle handle = scope.GetBioseqHandle(*seq_id);
521  if (handle)
522  seh = handle.GetTopLevelEntry();
523  }
524  else if (seq_loc) {
525  CBioseq_Handle handle = scope.GetBioseqHandle(*seq_loc);
526  if (handle)
527  seh = handle.GetTopLevelEntry();
528  }
529 
530  return seh;
531 }
532 
534 {
535  switch (val) {
536  default: return CFlatFileConfig::eMode_GBench;
537  case 1: return CFlatFileConfig::eMode_Entrez;
538  case 2: return CFlatFileConfig::eMode_Release;
539  case 3: return CFlatFileConfig::eMode_Dump;
540  }
541 }
542 
543 static CFlatFileConfig::EStyle s_FFStyle(bool showSequence)
544 {
546 }
547 
549 {
550  if (!m_SO) return;
551 
552  const CSeq_feat* seq_feat = dynamic_cast<const CSeq_feat*>(m_SO.GetPointer());
553  const CSeq_loc* seq_loc = dynamic_cast<const CSeq_loc*>(m_SO.GetPointer());
554  const CSeq_submit* seq_submit = dynamic_cast<const CSeq_submit*>(m_SO.GetPointer());
555  const CSubmit_block* submitBlock = 0;
556 
557  CSeq_entry_Handle seh;
558  if (seq_submit) {
559  if (seq_submit->IsSetData()) {
560  const CSeq_submit::TData& data = seq_submit->GetData();
561  if (data.IsEntrys()) {
563  if (!entries.empty()) {
564  seh = m_Scope->GetSeq_entryHandle(**entries.begin());
565  }
566  }
567  }
568  if (seq_submit->IsSetSub()) {
569  submitBlock = &seq_submit->GetSub();
570  }
571  } else if (!seq_feat) {
572  seh = GetSeqEntryHandle(*m_Scope, *m_SO);
573  }
574 
575  if (!seq_feat && !seh)
576  return;
577 
580 
581  if (seq_feat)
582  m_DataSource->LoadFlatFile(x_CreateFlatFileContext(false), *m_Scope, *seq_feat, m_FeatMode == 0, mode, style);
583  else
584  m_DataSource->GetFlatFileSeqs(seh, submitBlock, seq_loc, style);
585 }
586 
588 {
591 
595  formatter->SetContext(*ctx);
596 
597  CIRef<IBioseqEditor> editor;
598  if (m_CmdProccessor && createEditor)
599  editor = x_CreateEditor();
600 
601  CTextPanelContext* context = new CFlatFileViewContext(*formatter, *m_Scope, m_SO, editor);
602  x_InitContext(*context);
603  return context;
604 }
605 
607 {
608  CIRef<IBioseqEditor> editor;
609  if (m_CmdProccessor)
610  editor = x_CreateEditor();
611 
612  CAsnViewContext* context = new CAsnViewContext(*m_Scope, &so, editor);
613  context->SetShowAsnTypes(GetShowASNTypes());
615  x_InitContext(*context);
616  return context;
617 }
618 
620 {
621  CTextPanelContext* context = new CTextPanelContext(1, m_Scope, &so);
622  x_InitContext(*context);
623  return context;
624 }
625 
627 {
629  x_InitContext(*context);
630  return context;
631 }
632 
634 {
635  context.SetWorkDir(m_WorkDir);
636  context.SetFontDesc(*m_TextWindow);
637  wxClientDC dc(this);
638  wxFont font(context.GetFontDesc());
639  dc.SetFont(font);
640  context.CalcWSize(dc);
641 }
642 
644 {
645  cmd_reg.RegisterCommand(kExpandAll,
646  "&Expand All\tCtrl+E",
647  "Expand All",
650  "Command expands(opens) all of a FlatFile view");
651  wxAcceleratorEntry accelerator(wxACCEL_CTRL, 'E', kExpandAll);
652  cmd_reg.AddAccelerator(accelerator);
653 
654  CFlatFileViewContext::RegisterCommands(cmd_reg, provider);
655 
656  vector<IEditorFactory*> factories;
658 
659  ITERATE(vector<IEditorFactory*>, it, factories) {
660  (*it)->RegisterCommands(cmd_reg, provider);
661  }
662 }
663 
665 {
666  CIRef<IBioseqEditor> editor;
667 
668  vector<IEditorFactory*> factories;
670 
671  ITERATE(vector<IEditorFactory*>, it, factories) {
672  editor.Reset(dynamic_cast<IBioseqEditor*>(
673  (*it)->CreateEditor(typeid(IBioseqEditor).name(), *m_CmdProccessor, m_WidgetHost)));
674 
675  if (editor)
676  break;
677  }
678 
679  return editor;
680 }
681 
683 {
684  if (!m_SO) return;
685 
687  if (!GetSeqEntryFromSeqSubmit(so)) {
689  if (seh) {
691  if (seq_entry)
692  so = seq_entry;
693  }
694  }
695 
697 }
698 
700 {
701  if (!m_SO) return;
702 
704  if (!GetSeqEntryFromSeqSubmit(so)) {
706  if (seh) {
707  CConstRef<CSeq_entry> seq_entry = seh.GetSeq_entryCore();
708  if (seq_entry)
709  so = seq_entry;
710  }
711  }
712 
714 }
715 
717 {
718  if (!m_SO) return;
719 
720  const CSeq_loc* seq_loc = dynamic_cast<const CSeq_loc*>(m_SO.GetPointer());
721  if (seq_loc) {
723  }
724  else {
726  if (!seh) return;
728  }
729 }
730 
731 void CTextPanel::SequenceListLoaded(const vector<CFlatFileSeq>& sequenceList)
732 {
733  m_FlatFileSeqs = sequenceList;
734 
736  bool found = false;
737  for (const auto& i : m_FlatFileSeqs) {
738  if (i.m_Name == m_SequenceShown) {
739  found = true;
740  break;
741  }
742  }
743  if (!found) m_SequenceShown = kAllNucleotides;
744  }
745 
746  if (m_initial && m_FlatFileSeqs.size() > 100 &&
748  m_SequenceShown = m_FlatFileSeqs[0].m_Name;
749  }
750 
751  m_initial = false;
752 
754  x_FillSeqList();
756 }
757 
758 
759 void CTextPanel::DataLoaded(shared_ptr<CRootTextItem> root, shared_ptr<CTextPanelContext> context)
760 {
761  const CSeq_feat* seq_feat = dynamic_cast<const CSeq_feat*>(m_SO.GetPointer());
762  const CSeq_loc* seq_loc = dynamic_cast<const CSeq_loc*>(m_SO.GetPointer());
763 
764  bool sequenceList = (m_ViewType == kFlatFile && !seq_feat) ||
765  (m_ViewType == kFastA && !seq_loc);
766 
767  if (sequenceList) {
768  root->SetDeleteChildren(false);
769  _ASSERT(root->GetItemCount() == m_FlatFileSeqs.size());
770 
771  CExpandTraverser expander(*context, true);
772 
773  for (size_t i = 0; i < root->GetItemCount(); ++i) {
774  ITextItem* item = root->GetItem(i);
775  if (item) {
776  delete m_FlatFileSeqs[i].m_Item;
777  m_FlatFileSeqs[i].m_Item = item;
778 
779  map<string, bm::bvector<> >::iterator it = m_TreeState.find(m_FlatFileSeqs[i].m_Name);
780  if (it != m_TreeState.end()) {
781  CRestoreTreeTraverser trv(*context, it->second);
782  item->Traverse(trv);
783  m_TreeState.erase(it);
784  }
785  else if (m_OpenExpanded) {
786  item->Traverse(expander);
787  }
788  }
789  }
790 
792  return;
793 
794  if (m_PositionOnLoad) {
797  }
798  }
799  else {
800  map<string, bm::bvector<> >::iterator it = m_TreeState.find("");
801  if (it != m_TreeState.end()) {
802  CRestoreTreeTraverser trv(*m_TextWindow->GetContext(), it->second);
803  root->Traverse(trv);
804  root->UpdatePositions();
805  m_TreeState.erase(it);
806  }
807  m_TreeState.clear();
808 
809  m_TextWindow->SetMainItem(root, context);
810 
811  if (m_ViewType == kASN) {
812  CAsnViewContext* context = dynamic_cast<CAsnViewContext*>(m_TextWindow->GetContext());
813  if (context != NULL) {
816  }
817  }
818  }
819 
820  Layout();
821 
822  if (m_SavedPosY > 0) {
823  int x, y;
824  m_TextWindow->GetVirtualSize(&x, &y);
825 
826  int xUnit, yUnit;
827  m_TextWindow->GetScrollPixelsPerUnit(&xUnit, &yUnit);
828  if (y / yUnit > m_SavedPosY)
830  m_SavedPosX = m_SavedPosY = 0;
831  }
832 
833  if (m_WidgetHost) {
838  }
839 }
840 
841 void CTextPanel::AddExtensionToolbar(wxAuiToolBar& toolbar, const wxString& name)
842 {
843  m_AuiManager.AddPane(&toolbar, wxAuiPaneInfo()
844  .Caption(pszMainToolbar)
845  .ToolbarPane()
846  .Top()
847  .TopDockable(true)
848  .LeftDockable(false)
849  .RightDockable(false)
850  .BottomDockable(false)
851  .Floatable(false)
852  .Resizable(true)
853  .DockFixed()
854  .Gripper(false)
855  .DestroyOnClose(true)
856  .Row(1));
857  m_AuiManager.Update();
858 }
859 
861 {
862  return true;
863 }
864 
865 
866 wxBitmap CTextPanel::GetBitmapResource( const wxString& name )
867 {
868  // Bitmap retrieval
869 ////@begin CTextPanel bitmap retrieval
870  wxUnusedVar(name);
871  return wxNullBitmap;
872 ////@end CTextPanel bitmap retrieval
873 }
874 
875 
876 wxIcon CTextPanel::GetIconResource( const wxString& name )
877 {
878  // Icon retrieval
879 ////@begin CTextPanel icon retrieval
880  wxUnusedVar(name);
881  return wxNullIcon;
882 ////@end CTextPanel icon retrieval
883 }
884 
885 void CTextPanel::SetInitialViewType(const string& viewType)
886 {
887  wxString type = ToWxString(viewType);
888 
889  if (type == pszFlatFile) {
891  }
892  else if (type == pszASN) {
893  m_ViewType = kASN;
894  }
895  else if (type == pszFastA) {
896  m_ViewType = kFastA;
897  }
898  else if (type == pszXML) {
899  m_ViewType = kASN;
900  }
901 }
902 
904 {
905  const CSeq_id* seq_id = dynamic_cast<const CSeq_id*>(m_SO.GetPointer());
906  const CSeq_loc* seq_loc = dynamic_cast<const CSeq_loc*>(m_SO.GetPointer());
907  const CSeq_feat* seq_feat = dynamic_cast<const CSeq_feat*>(m_SO.GetPointer());
908  const CSeq_entry* seq_entry = dynamic_cast<const CSeq_entry*>(m_SO.GetPointer());
909  const CBioseq* bioseq = dynamic_cast<const CBioseq*>(m_SO.GetPointer());
910  const CBioseq_set* bioseq_set = dynamic_cast<const CBioseq_set*>(m_SO.GetPointer());
911 
912  if (!seq_entry) {
913  seq_entry = GetSeqEntryFromSeqSubmit(m_SO);
914  }
915 
916  if (seq_feat) {
917  CSeqFeatData::E_Choice type = seq_feat->GetData().Which();
918  if (type != CSeqFeatData::e_Gene &&
921  seq_feat = NULL;
922  }
923 
924  return seq_id || seq_loc || seq_feat || seq_entry || bioseq || bioseq_set;
925 }
926 
928 {
929  const CSeq_loc* seq_loc = dynamic_cast<const CSeq_loc*>(m_SO.GetPointer());
930  if (seq_loc)
931  return true;
932 
933  try {
934  CSeq_entry_Handle seh = GetSeqEntryHandle(const_cast<CScope&>(*m_Scope), *m_SO);
935  if (seh)
936  return true;
937  } NCBI_CATCH("CTextPanel::CanShowFastA()");
938 
939  return false;
940 }
941 
943 {
944  return true;
945 }
946 
948 {
949  return true;
950 }
951 
953 {
954  CIRef<IMenuContributor> contributor;
955  if (m_DataSource) {
957  contributor.Reset(dynamic_cast<IMenuContributor*>(editor.GetPointerOrNull()));
958  }
959  return contributor;
960 }
961 
963 {
964  return dynamic_cast<const CSeq_feat*>(m_SO.GetPointer()) != 0;
965 }
966 
968 {
969  x_SaveViewType();
970 
973 
974  view.Set(kFontSize, m_FontSize);
978  view.Set(kFeatureMode, m_FeatMode);
981 
983  view.Set(kFFHideSTS, m_FFHideSTS);
985 
986  view.Set(kFindMode, m_FindMode);
987 }
988 
990 {
993 
1004 
1006 }
1007 
1009 {
1010  CAsnViewContext* context = dynamic_cast<CAsnViewContext*>(m_TextWindow->GetContext());
1011  if (context != NULL) {
1012  context->SetShowAsnTypes(m_ShowASNTypes);
1014  }
1015  m_TextWindow->Refresh();
1016 }
1017 
1019 {
1020  const CSeq_id* seq_id = dynamic_cast<const CSeq_id*>(m_SO.GetPointer());
1021  const CSeq_loc* seq_loc = dynamic_cast<const CSeq_loc*>(m_SO.GetPointer());
1022  const CSeq_feat* seq_feat = dynamic_cast<const CSeq_feat*>(m_SO.GetPointer());
1023  const CSeq_entry* seq_entry = dynamic_cast<const CSeq_entry*>(m_SO.GetPointer());
1024  const CBioseq* bioseq = dynamic_cast<const CBioseq*>(m_SO.GetPointer());
1025  const CBioseq_set* bioseq_set = dynamic_cast<const CBioseq_set*>(m_SO.GetPointer());
1026 
1027  if (!seq_entry) {
1028  seq_entry = GetSeqEntryFromSeqSubmit(m_SO);
1029  }
1030 
1031  if (seq_feat) {
1032  CSeqFeatData::E_Choice type = seq_feat->GetData().Which();
1033  if (type != CSeqFeatData::e_Gene &&
1036  seq_feat = NULL;
1037  }
1038 
1039  const char* strType = kViewTypeGeneric;
1040 
1041  if (seq_feat)
1042  strType = kViewTypeFeat;
1043  else if (seq_id || seq_loc || seq_entry || bioseq || bioseq_set)
1044  strType = kViewTypeSeq;
1045 
1048  view.Set(strType, (int)m_ViewType);
1049 }
1050 
1051 void CTextPanel::x_UpdateViewType(const wxString& type)
1052 {
1053  TViewType viewType = kASN;
1054 
1055  if (type == pszFlatFile)
1056  viewType = kFlatFile;
1057  else if (type == pszFastA)
1058  viewType = kFastA;
1059 
1060  if (viewType != m_ViewType) {
1061  m_ViewType = viewType;
1062  x_SaveViewType();
1063  GetSizer()->Layout();
1064  Load();
1065  }
1066 }
1067 
1069 {
1070  CTextItemPanel* widget = GetWidget();
1071  if (widget == NULL)
1072  return;
1073 
1074  const wxString caption = wxT("Find Text");
1075 
1076  wxString text = m_FindTextCtrl->GetValue();
1077  if (text.empty()) {
1078  wxMessageBox(wxT("Search string is empty."), caption, wxOK | wxICON_EXCLAMATION);
1079  return;
1080  }
1081 
1082  bool found = false;
1083  if (m_FindMode == 2) {
1084  wxBusyCursor wait;
1085  found = widget->FindSequence(text);
1086  }
1087  else {
1088  wxBusyCursor wait;
1089  found = widget->FindText(text, (m_FindMode == 0), true);
1090  }
1091 
1092  if (!found)
1093  wxMessageBox(wxT("Search string not found."), caption, wxOK | wxICON_EXCLAMATION);
1094 }
1095 
1096 
1097 void CTextPanel::OnFindNextClick( wxCommandEvent& event )
1098 {
1099  x_FindText();
1100 }
1101 
1102 void CTextPanel::OnSearchTermCtrlEnter( wxCommandEvent& event )
1103 {
1104  x_FindText();
1105 }
1106 
1107 void CTextPanel::OnOptionsClick( wxCommandEvent& event )
1108 {
1109  CTextViewOptionsDlg dlg(this);
1110  dlg.SetRegistryPath("Dialogs.CTextViewOptionsDlg");
1111  if (dlg.ShowModal() == wxID_OK) {
1112  dlg.ApplyChanges();
1113  }
1114 }
1115 
1116 // block toolbar event propagation
1117 void CTextPanel::OnContextMenu(wxContextMenuEvent& event)
1118 {
1119 }
1120 
1121 void CTextPanel::OnSequenceSelected( wxCommandEvent& event )
1122 {
1123  if (m_ViewType == kFlatFile || m_ViewType == kFastA) {
1124  string selSeq = ToStdString(event.GetString());
1125  x_SelectFlatFileSequence(selSeq);
1127  }
1128 }
1129 
1130 bool CTextPanel::x_SelectFlatFileSequence(const string& seqName)
1131 {
1132  if (m_ViewType != kFlatFile && m_ViewType != kFastA)
1133  return false;
1134 
1135  vector<pair<CBioseq_Handle, string> > handles(m_FlatFileSeqs.size());
1136  for (size_t i = 0; i < m_FlatFileSeqs.size(); ++i)
1137  handles[i].second = m_FlatFileSeqs[i].m_Name;
1138 
1139  vector<ITextItem*> items;
1140  string errMsg;
1141  bool loaded = true;
1142 
1143  if (seqName.empty() || seqName == kAllNucleotides) {
1145  errMsg = "No nucleotide sequences.";
1146  for (size_t i = 0; i < m_FlatFileSeqs.size(); ++i) {
1147  if (m_FlatFileSeqs[i].m_Handle.IsNucleotide()) {
1148  if (m_FlatFileSeqs[i].m_Item) {
1149  items.push_back(m_FlatFileSeqs[i].m_Item);
1150  }
1151  else {
1152  handles[i].first = m_FlatFileSeqs[i].m_Handle;
1153  loaded = false;
1154  }
1155  }
1156  }
1157  }
1158  else if (seqName == kAllSequences) {
1160  errMsg = "No sequences.";
1161  for (size_t i = 0; i < m_FlatFileSeqs.size(); ++i) {
1162  if (m_FlatFileSeqs[i].m_Item) {
1163  items.push_back(m_FlatFileSeqs[i].m_Item);
1164  } else {
1165  handles[i].first = m_FlatFileSeqs[i].m_Handle;
1166  loaded = false;
1167  }
1168  }
1169  }
1170  else {
1171  string selSeq = seqName;
1172  if (seqName == kMoreSequences) {
1173  m_SequenceList->SetStringSelection(m_SequenceShown);
1175  dlg.SetRegistryPath("Dialogs.CSelectSequenceDlg");
1176  if (dlg.ShowModal() != wxID_OK)
1177  return false;
1178  selSeq = dlg.GetSequenceId();
1179  }
1180 
1181  m_SequenceShown = selSeq;
1182  errMsg = "Sequence '" + selSeq + "' not found.";
1183 
1184  for (size_t i = 0; i < m_FlatFileSeqs.size(); ++i) {
1185  if (selSeq == m_FlatFileSeqs[i].m_Name) {
1186  if (m_FlatFileSeqs[i].m_Item) {
1187  CExpandItem* expandItem = dynamic_cast<CExpandItem*>(m_FlatFileSeqs[i].m_Item);
1188  if (expandItem)
1189  items.push_back(expandItem->GetExpandedItem());
1190  else
1191  items.push_back(m_FlatFileSeqs[i].m_Item);
1192  }
1193  else {
1194  handles[i].first = m_FlatFileSeqs[i].m_Handle;
1195  loaded = false;
1196  }
1197  }
1198  }
1199  }
1200 
1201  if (loaded) {
1202  x_FillSeqList();
1203 
1204  if (items.empty()) {
1205  m_TextWindow->ReportError(errMsg);
1206  }
1207  else {
1208  CRootTextItem* root = new CRootTextItem();
1209  root->InsertItems(0, &items[0], items.size());
1210  root->SetDeleteChildren(false);
1212  m_TextWindow->SetMainItem(root, context);
1213  }
1214  return true;
1215  }
1216 
1218 
1219  if (m_ViewType == kFlatFile) {
1220  const CSeq_loc* seq_loc = dynamic_cast<const CSeq_loc*>(m_SO.GetPointer());
1221  const CSeq_submit* seq_submit = dynamic_cast<const CSeq_submit*>(m_SO.GetPointer());
1222  const CSubmit_block* submitBlock = 0;
1223 
1224  if (seq_submit && seq_submit->IsSetSub())
1225  submitBlock = &seq_submit->GetSub();
1226 
1228  params.m_Mode = s_FFMode(m_FlatFileMode);
1229  params.m_Style = s_FFStyle(m_ShowSequence);
1230  params.m_SeqSubmit.Reset(submitBlock);
1231  params.m_SeqLoc.Reset(seq_loc);
1233  m_DataSource->LoadFlatFile(x_CreateFlatFileContext(), handles, params);
1234  }
1235  else {
1237  }
1238 
1239  return false;
1240 }
1241 
1243 {
1244  if (!m_SequenceList)
1245  return;
1246 
1247  m_SequenceList->SetMinSize(wxDefaultSize); // resizing wxChoice
1248 
1249  m_SequenceList->Clear();
1251  m_SequenceList->Append(kAllSequences);
1252 
1253  size_t seqCount = m_FlatFileSeqs.size();
1254 
1255  long seqIndex = -1;
1256  for (size_t i = 0; i < seqCount; ++i) {
1257  string seqId = m_FlatFileSeqs[i].m_Name;
1258  if (m_FlatFileSeqs[i].m_Name == m_SequenceShown)
1259  seqIndex = i;
1260  }
1261 
1262  long listStart = 0;
1263  if (seqCount > kMaxSeqNumber && seqIndex >= 0) {
1264  listStart = seqIndex - kMaxSeqNumber / 2;
1265  if (listStart < 0)
1266  listStart = 0;
1267  else if (m_FlatFileSeqs.size() - listStart < kMaxSeqNumber)
1268  listStart = seqCount - kMaxSeqNumber;
1269  }
1270 
1271  for (size_t i = (size_t)listStart; i < min(seqCount, (size_t)listStart + kMaxSeqNumber); ++i)
1272  m_SequenceList->Append(m_FlatFileSeqs[i].m_Name);
1273 
1274  if (seqCount > kMaxSeqNumber)
1275  m_SequenceList->Append(kMoreSequences);
1276 
1277 
1278  size_t selection = 0;
1279  if (seqIndex < 0) {
1281  selection = 1;
1282  }
1283  else {
1284  selection = seqIndex - listStart + 2;
1285  }
1286  m_SequenceList->SetSelection(static_cast<int>(selection));
1287  m_SequenceList->SetMinSize(m_SequenceList->GetBestSize()); // resizing wxChoice
1288 
1289  // resizing toolbar programmatically
1290  wxAuiPaneInfo& pane = m_AuiManager.GetPane(pszSequenceToolbar);
1291  if (!pane.IsOk()) return;
1292  wxAuiToolBar* toolbar = dynamic_cast<wxAuiToolBar*>(pane.window);
1293  if (!toolbar) return;
1294  wxAuiToolBarItem* item = toolbar->FindTool(ID_TB_SequenceListCtrl);
1295  if (!item) return;
1296 
1297  item->SetMinSize(wxDefaultSize); // reset item size
1298  toolbar->Realize();
1299 
1300  pane.BestSize(toolbar->GetSize()); // seems no other way to resize programmatically
1301  m_AuiManager.Update();
1302 }
1303 
1304 void CTextPanel::OnFindModeSelected( wxCommandEvent& event )
1305 {
1306  m_FindMode = event.GetSelection();
1307 }
1308 
1309 bool CTextPanel::SetPosition(const CBioseq_Handle& h, const CObject* object)
1310 {
1311  for (const auto& s : m_FlatFileSeqs) {
1312  if (s.m_Handle == h) {
1313  return SetPosition(s.m_Name, object);
1314  }
1315  }
1316  return false;
1317 }
1318 
1319 bool CTextPanel::SetPosition(const string& seq, const CObject* object)
1320 {
1321  if (seq.empty()) return false;
1322 
1323  if (m_ViewType != kFlatFile) {
1324  ClearState();
1326  m_SequenceShown = seq;
1327  m_PositionOnLoad.Reset(object);
1328  Load();
1329  return true;
1330  }
1331 
1332  if (m_DataSource->IsLoading()) {
1333  m_SequenceShown = seq;
1334  m_PositionOnLoad.Reset(object);
1335  return true;
1336  }
1337 
1338  if (seq == m_SequenceShown) {
1339  if (object)
1340  return m_TextWindow->MakeObjectVisible(*object);
1341  else
1342  return true;
1343  }
1344 
1345  if (x_SelectFlatFileSequence(seq)) {
1346  if (object)
1347  return m_TextWindow->MakeObjectVisible(*object);
1348  else
1349  return true;
1350  }
1351  m_PositionOnLoad.Reset(object);
1352 
1353  return true;
1354 }
1355 
1356 /// IGuiWidgetHost implementation
1357 
1359 {
1360  m_WidgetHost = host;
1361 }
1362 
1364 {
1365  if (objects.size() != 1) return false;
1366 
1367  wxBusyCursor wait;
1368 
1369  ClearState();
1370 
1371  m_Scope.Reset(objects.front().scope.GetPointer());
1372  m_SO.Reset(dynamic_cast<const CSerialObject*>(objects.front().object.GetPointer()));
1373 
1374  const CSeq_id* seq_id = dynamic_cast<const CSeq_id*>(m_SO.GetPointer());
1375  const CSeq_loc* seq_loc = dynamic_cast<const CSeq_loc*>(m_SO.GetPointer());
1376  const CSeq_feat* seq_feat = dynamic_cast<const CSeq_feat*>(m_SO.GetPointer());
1377  const CSeq_entry* seq_entry = dynamic_cast<const CSeq_entry*>(m_SO.GetPointer());
1378  const CBioseq* bioseq = dynamic_cast<const CBioseq*>(m_SO.GetPointer());
1379  const CBioseq_set* bioseq_set = dynamic_cast<const CBioseq_set*>(m_SO.GetPointer());
1380 
1381 
1382  if (!seq_entry) {
1383  seq_entry = GetSeqEntryFromSeqSubmit(m_SO);
1384  }
1385 
1386  if (seq_feat) {
1387  CSeqFeatData::E_Choice type = seq_feat->GetData().Which();
1388  if (type != CSeqFeatData::e_Gene &&
1391  seq_feat = NULL;
1392  }
1393 
1394  if (seq_id) {
1395  CBioseq_Handle handle = m_Scope->GetBioseqHandle(*seq_id);
1396  if (!handle) {
1397  string str("failed to retrieve sequence for id ");
1398  seq_id->GetLabel(&str);
1400  }
1401  }
1402 
1403  //wxChoice* textType = (wxChoice*)FindWindow(ID_CHOICE1);
1404  //textType->Clear();
1405 
1406  int viewType = m_ViewType;
1407  wxString viewTypeString;
1408 
1411 
1412  if (seq_id || seq_loc || seq_feat || seq_entry || bioseq || bioseq_set) {
1413  //textType->Append(pszFlatFile);
1414  //if (!seq_feat) textType->Append(pszFastA);
1415  //textType->Append(pszASN);
1416  //textType->Append(pszXML);
1417 
1418  if (viewType == kUninitialized) {
1419  if (seq_feat != NULL)
1420  viewType = view.GetInt(kViewTypeFeat, m_ViewType);
1421  else
1422  viewType = view.GetInt(kViewTypeSeq, m_ViewType);
1423  }
1424 
1425  switch(viewType) {
1426  case kFastA:
1427  viewTypeString = (seq_feat != NULL) ? pszFlatFile : pszFastA;
1428  break;
1429  case kXML:
1430  case kASN:
1431  viewTypeString = pszASN;
1432  break;
1433  case kFlatFile:
1434  case kUninitialized:
1435  default:
1436  viewTypeString = pszFlatFile;
1437  break;
1438  }
1439  }
1440  else {
1441  //textType->Append(pszASN);
1442  //textType->Append(pszXML);
1443 
1444  if (viewType == kUninitialized) {
1445  viewType = view.GetInt(kViewTypeGeneric, viewType);
1446  }
1447  viewTypeString = pszASN;
1448  }
1449 
1450  //textType->SetStringSelection(viewTypeString);
1451 
1453  x_UpdateViewType(viewTypeString);
1454 
1455  TransferDataToWindow();
1456 
1457  return true;
1458 }
1459 
1461 {
1462  return m_SO.GetPointerOrNull();
1463 }
1464 
1466 {
1467  CTextItemPanel* widget = GetWidget();
1468  if (!widget) return;
1469 
1470  CTextPanelContext* context = widget->GetContext();
1471  if (!context) return;
1472 
1473  context->GetSelectedObjects(objects);
1474 }
1475 
1477 {
1478  CTextItemPanel* widget = GetWidget();
1479  if (!widget) return;
1480 
1481  CTextPanelContext* context = widget->GetContext();
1482  if (!context) return;
1483 
1484  context->SetSelectedObjects(objects);
1485 }
1486 
1488 {
1489  m_CmdProccessor = cmdProccessor;
1490 
1491  if (!m_DataSource)
1492  m_DataSource.Reset(new CTextDataSource(*this));
1493 }
1494 
1496 {
1497  if (!m_TextWindow) return;
1498 
1499  SaveState();
1501 }
1502 
1504 {
1505  Load();
1506 }
1507 
1508 void CTextPanel::GetActiveObjects(vector<TConstScopedObjects>& objects)
1509 {
1510  CTextItemPanel* widget = GetWidget();
1511  if (!widget) return;
1512 
1513  CTextPanelContext* context = widget->GetContext();
1514  if (!context) return;
1515 
1516  context->GetActiveObjects(objects);
1517 }
1518 
1520 {
1521  ClearState();
1522 
1523  if (!m_TextWindow || m_DataSource->IsLoading())
1524  return;
1525 
1526  const CSeq_feat* seq_feat = dynamic_cast<const CSeq_feat*>(m_SO.GetPointer());
1527  const CSeq_loc* seq_loc = dynamic_cast<const CSeq_loc*>(m_SO.GetPointer());
1528 
1529  bool sequenceList = (m_ViewType == kFlatFile && !seq_feat) ||
1530  (m_ViewType == kFastA && !seq_loc);
1531 
1532  if (sequenceList) {
1533  for (const auto& i : m_FlatFileSeqs) {
1534  if (i.m_Item) {
1535  if (m_OpenExpanded)
1536  m_TreeState[i.m_Name].set();
1537  CSaveTreeTraverser trv(m_TreeState[i.m_Name]);
1538  i.m_Item->Traverse(trv);
1539  }
1540  }
1541  }
1542  else {
1543  ITextItem* root = m_TextWindow->GetRootItem();
1544  if (root) {
1546  root->Traverse(trv);
1547  }
1548  }
1549 
1550  m_TextWindow->GetViewStart(&m_SavedPosX, &m_SavedPosY);
1551 }
1552 
1554 {
1555  m_TreeState.clear();
1556  m_SavedPosX = m_SavedPosY = 0;
1557 }
1558 
#define static
Nucleotides
Definition: NSeq.hpp:47
User-defined methods of the data storage class.
#define false
Definition: bool.h:36
void SetShowAsnTypes(bool show)
void SetShowPathToRoot(bool show)
CBioseq_Handle –.
CBioseq_set_Handle –.
void InsertItems(size_t index, ITextItem *const *items, size_t count, bool updatePositions=true)
void SetDeleteChildren(bool val)
virtual void SetRegistryPath(const string &path)
Definition: dialog.cpp:59
virtual void Toggle(CTextPanelContext *context, bool update)
Definition: expand_item.cpp:84
virtual bool IsExpanded() const
Definition: expand_item.hpp:63
CTextItem * GetExpandedItem()
Definition: expand_item.hpp:60
static void RegisterCommands(CUICommandRegistry &cmd_reg, wxFileArtProvider &provider)
static CFlatItemFormatter * New(CFlatFileConfig::TFormat format)
CRegistryWriteView GetWriteView(const string &section)
get a read-write view at a particular level.
Definition: registry.cpp:462
static CGuiRegistry & GetInstance()
access the application-wide singleton
Definition: registry.cpp:400
CRegistryReadView GetReadView(const string &section) const
get a read-only view at a particular level.
Definition: registry.cpp:428
CObject –.
Definition: ncbiobj.hpp:180
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
int GetInt(const string &key, int default_val=0) const
access a named key at this level, with no recursion
Definition: reg_view.cpp:230
bool GetBool(const string &key, bool default_val=false) const
Definition: reg_view.cpp:241
string GetString(const string &key, const string &default_val=kEmptyStr) const
Definition: reg_view.cpp:246
void Set(const string &key, int val)
access a named key at this level, with no recursion
Definition: reg_view.cpp:533
const bm::bvector & m_bVector
Definition: text_panel.cpp:170
virtual bool ProcessItem(CTextItem &)
Definition: text_panel.cpp:158
CRestoreTreeTraverser(CTextPanelContext &context, const bm::bvector<> &bVector)
Definition: text_panel.cpp:155
virtual bool ProcessItem(CExpandItem &expandItem)
Definition: text_panel.cpp:159
CTextPanelContext & m_Context
Definition: text_panel.cpp:169
CRichTextCtrl - a wrapper for wxRichTextCtrl that handles additional keyboard events (such as Clipboa...
void SetContextMenu(wxMenu *contextMenu)
virtual bool ProcessItem(CExpandItem &expandItem)
Definition: text_panel.cpp:140
bm::bvector & m_bVector
Definition: text_panel.cpp:148
virtual bool ProcessItem(CTextItem &)
Definition: text_panel.cpp:139
CSaveTreeTraverser(bm::bvector<> &bVector)
Definition: text_panel.cpp:136
CScope –.
Definition: scope.hpp:92
string GetSequenceId() const
CSeq_entry_Handle –.
Definition: Seq_entry.hpp:56
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
Base class for all serializable objects.
Definition: serialbase.hpp:150
CSubmit_block –.
void LoadXml(CTextPanelContext *context, const CSerialObject &so, objects::CScope &scope)
Definition: text_ds.cpp:191
bool IsLoading() const
Definition: text_ds.cpp:65
void LoadFasta(CTextPanelContext *context, const vector< pair< objects::CBioseq_Handle, string > > &handles)
void GetFlatFileSeqs(objects::CSeq_entry_Handle &h, const objects::CSubmit_block *submitBlock, const objects::CSeq_loc *seq_loc, objects::CFlatFileConfig::EStyle style)
Definition: text_ds.cpp:117
void LoadAsn(CTextPanelContext *context, const CSerialObject &so, objects::CScope &scope)
Definition: text_ds.cpp:176
void LoadFlatFile(CTextPanelContext *context, const vector< pair< objects::CBioseq_Handle, string > > &handles, const SFlatFileParams &params)
bool MakeObjectVisible(const CObject &object)
void SetMainItem(ITextItem *item, CTextPanelContext *context)
ITextItem * GetRootItem()
CTextPanelContext * GetContext()
void ReportError(const string &report)
bool FindText(const wxString &text, bool matchCase, bool forward)
bool FindSequence(const wxString &text)
virtual bool SetFont(const wxFont &font)
const wxString & GetFontDesc() const
void SetSelectedObjects(const TConstObjects &objs)
void GetSelectedObjects(TConstObjects &objs)
void SetFontDesc(wxWindow &wnd)
void GetActiveObjects(TConstScopedObjects &objects)
void CalcWSize(wxDC &dc)
void SetWorkDir(const wxString &workDir)
virtual void SetHost(IGuiWidgetHost *host)
IGuiWidgetHost implementation.
CTextPanelContext * x_CreateFastaContext()
Definition: text_panel.cpp:626
CTextPanelContext * x_CreateAsnContext(const CSerialObject &so)
Definition: text_panel.cpp:606
virtual bool SetPosition(const string &seq, const CObject *object)
CTextPanelContext * x_CreateFlatFileContext(bool createEditor=true)
Definition: text_panel.cpp:587
wxBitmap GetBitmapResource(const wxString &name)
Retrieves bitmap resources.
Definition: text_panel.cpp:866
void Init()
Initialises member variables.
Definition: text_panel.cpp:261
CTextItemPanel * m_TextWindow
Definition: text_panel.hpp:241
bool m_ShowSequence
Definition: text_panel.hpp:246
void OnContextMenu(wxContextMenuEvent &event)
wxIcon GetIconResource(const wxString &name)
Retrieves icon resources.
Definition: text_panel.cpp:876
string m_SequenceShown
Definition: text_panel.hpp:297
virtual void SetSelectedObjects(const TConstObjects &objects)
bool m_ShowComponentFeats
Definition: text_panel.hpp:247
CTextPanelContext * x_CreateXmlContext(const CSerialObject &so)
Definition: text_panel.cpp:619
void SetInitialViewType(const string &type)
Definition: text_panel.cpp:885
bool CanShowXML() const
Definition: text_panel.cpp:947
void CreateControls()
Creates the controls and sizers.
Definition: text_panel.cpp:293
IGuiWidgetHost * m_WidgetHost
Definition: text_panel.hpp:300
virtual void DataChanging()
void GetMainObjects(TConstScopedObjects &objs)
Definition: text_panel.cpp:432
static void RegisterCommands(CUICommandRegistry &cmd_reg, wxFileArtProvider &provider)
Definition: text_panel.cpp:643
void ClearState()
bool CanShowASN() const
Definition: text_panel.cpp:942
static bool ShowToolTips()
Should we show tooltips?
Definition: text_panel.cpp:860
bool m_ShowASNTypes
Definition: text_panel.hpp:249
virtual void GetSelectedObjects(TConstObjects &objects) const
void OnFindModeSelected(wxCommandEvent &event)
void x_FillSeqList()
void OnSequenceSelected(wxCommandEvent &event)
vector< CFlatFileSeq > m_FlatFileSeqs
Definition: text_panel.hpp:304
void x_CreateMainToolbar()
Definition: text_panel.cpp:329
static void SetTextBackground(const wxColor &color)
Definition: text_panel.cpp:191
void x_FindText()
void x_LoadXML()
Definition: text_panel.cpp:699
bool m_FFHideSTS
Definition: text_panel.hpp:253
bool x_SelectFlatFileSequence(const string &seqName)
@ ID_TB_SequenceListCtrl
Definition: text_panel.hpp:265
@ ID_TB_SearchModeCtrl
Definition: text_panel.hpp:263
@ ID_TB_SequenceLabel
Definition: text_panel.hpp:264
@ ID_TB_SearchModeLabel
Definition: text_panel.hpp:262
@ ID_TB_SearchButton
Definition: text_panel.hpp:261
bool CanShowFlatFile() const
Definition: text_panel.cpp:903
CRichTextCtrl * m_FindTextCtrl
Definition: text_panel.hpp:238
CConstRef< CObject > m_PositionOnLoad
Definition: text_panel.hpp:298
bool m_initial
Definition: text_panel.hpp:312
CRef< CTextDataSource > m_DataSource
Definition: text_panel.hpp:295
ICommandProccessor * m_CmdProccessor
Definition: text_panel.hpp:306
void x_SaveViewType()
void RefreshView()
void OnFindNextClick(wxCommandEvent &event)
~CTextPanel()
Destructor.
Definition: text_panel.cpp:225
static wxWindow * CreateForm(wxWindow *parent)
Definition: text_panel.cpp:197
void x_InitContext(CTextPanelContext &context)
Definition: text_panel.cpp:633
wxAuiManager m_AuiManager
Definition: text_panel.hpp:302
CConstRef< CSerialObject > m_SO
Definition: text_panel.hpp:293
CTextItemPanel * GetWidget() const
Definition: text_panel.hpp:229
void SetFontSize(int value)
Definition: text_panel.cpp:321
CRef< objects::CScope > m_Scope
Definition: text_panel.hpp:294
int m_FlatFileMode
Definition: text_panel.hpp:245
void OnOptionsClick(wxCommandEvent &event)
map< string, bm::bvector<> > m_TreeState
Definition: text_panel.hpp:308
bool GetShowASNPathToRoot() const
Definition: text_panel.hpp:202
wxChoice * m_FindModeCtrl
Definition: text_panel.hpp:239
wxChoice * m_SequenceList
Definition: text_panel.hpp:240
void AddExtensionToolbar(wxAuiToolBar &toolbar, const wxString &name)
Definition: text_panel.cpp:841
void x_UpdateViewType(const wxString &type)
virtual void GetActiveObjects(vector< TConstScopedObjects > &objects)
bool GetShowASNTypes() const
Definition: text_panel.hpp:199
virtual void SetUndoManager(ICommandProccessor *cmdProccessor)
void x_LoadFlatFile()
Definition: text_panel.cpp:548
CIRef< IBioseqEditor > x_CreateEditor()
Definition: text_panel.cpp:664
wxString m_WorkDir
Definition: text_panel.hpp:314
void SaveState()
void SequenceListLoaded(const vector< CFlatFileSeq > &sequenceList)
Definition: text_panel.cpp:731
virtual bool InitWidget(TConstScopedObjects &objects)
void x_LoadFastA()
Definition: text_panel.cpp:716
void Load()
Definition: text_panel.cpp:440
friend class CAsnViewContext
Definition: text_panel.hpp:98
bool CanShowFastA() const
Definition: text_panel.cpp:927
CIRef< IMenuContributor > GetMenuContributor()
Definition: text_panel.cpp:952
CTextPanel()
Constructors.
Definition: text_panel.cpp:206
bool m_OpenExpanded
Definition: text_panel.hpp:254
bool m_ShowASNPathToRoot
Definition: text_panel.hpp:250
virtual void DataChanged()
void UpdateRegistry()
Definition: text_panel.cpp:967
virtual const CObject * GetOrigObject() const
void DataLoaded(shared_ptr< CRootTextItem > root, shared_ptr< CTextPanelContext > context)
Definition: text_panel.cpp:759
void OnSearchTermCtrlEnter(wxCommandEvent &event)
void x_ReadRegistry()
Definition: text_panel.cpp:989
bool ObjectIsFeature() const
Definition: text_panel.cpp:962
void x_LoadASN()
Definition: text_panel.cpp:682
TViewType m_ViewType
Definition: text_panel.hpp:243
static wxFont GetFont(int size)
Definition: text_panel.cpp:174
bool m_FFHideVariations
Definition: text_panel.hpp:252
CUICommandRegistry is a centralized registry where all application commands should be registered.
Definition: ui_command.hpp:146
int RegisterCommand(CUICommand *cmd)
assumes ownership of the given object returns a command id (useful when registry is used for auto id ...
Definition: ui_command.cpp:198
void AddAccelerator(const wxAcceleratorEntry &entry)
Definition: ui_command.cpp:274
IBioseqEditor.
Undo/Redo interface for editing operations.
virtual void GetAppSelection(TConstObjects &)
Definition: gui_widget.hpp:55
virtual void WidgetSelectionChanged()=0
IMenuContributor - contributes menu to Menu Service.
Definition: ui_command.hpp:371
virtual bool Traverse(ICompositeTraverser &)=0
void erase(iterator pos)
Definition: map.hpp:167
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: map.hpp:338
virtual void RegisterFileAlias(const wxArtID &anId, const wxArtClient &aClient, const wxSize &aSize, const wxString &aName, long aType=wxBITMAP_TYPE_ANY, int anIndex=-1)
char value[7]
Definition: config.c:431
struct config config
#define _(proto)
Definition: ct_nlmzip_i.h:78
CS_CONTEXT * ctx
Definition: t0006.c:12
int Main(int argc, const char *argv[])
const int kFastaTextOffset
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
TValue Get(void) const THROWS_NONE
Get atomic counter value.
Definition: ncbicntr.hpp:168
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
#define NCBI_CATCH(message)
Catch CExceptions as well This macro is deprecated - use *_X or *_XX variant instead of it.
Definition: ncbiexpt.hpp:580
const string & GetMsg(void) const
Get message string.
Definition: ncbiexpt.cpp:461
virtual const char * what(void) const noexcept
Standard report (includes full backlog).
Definition: ncbiexpt.cpp:342
void Info(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1185
CRef< objects::CScope > scope
Definition: objects.hpp:53
void GetExtensionAsInterface(const string &ext_point_id, vector< CIRef< I > > &interfaces)
GetExtensionAsInterface() is a helper function that extracts all extensions implementing the specifie...
vector< CConstRef< CObject > > TConstObjects
Definition: objects.hpp:64
CConstRef< CObject > object
Definition: objects.hpp:52
vector< SConstScopedObject > TConstScopedObjects
Definition: objects.hpp:65
#define ASN(...)
Definition: serialbase.hpp:889
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:2039
CSeq_entry_Handle GetSeq_entryHandle(CDataLoader *loader, const TBlobId &blob_id, EMissing action=eMissing_Default)
Get Seq-entry handle by its blob-id, with possible loading.
Definition: scope.cpp:113
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
CBioseq_set_Handle GetBioseq_setHandle(const CBioseq_set &seqset, EMissing action=eMissing_Default)
Definition: scope.cpp:176
CConstRef< CSeq_entry > GetCompleteSeq_entry(void) const
Complete and get const reference to the seq-entry.
CSeq_entry_Handle GetTopLevelEntry(void) const
Return a handle for the top-level seq-entry.
CSeq_entry_Handle GetTopLevelEntry(void) const
Get top level Seq-entry handle.
CConstRef< CSeq_entry > GetSeq_entryCore(void) const
Get const reference to the seq-entry.
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:1684
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
TObjectType * GetPointerOrNull(void) const THROWS_NONE
Get pointer value.
Definition: ncbiobj.hpp:1672
TObjectType * GetPointerOrNull(void) THROWS_NONE
Get pointer value.
Definition: ncbiobj.hpp:986
#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 NcbiEmptyString
Definition: ncbistr.hpp:122
E_Choice Which(void) const
Which variant is currently selected.
E_Choice
Choice variants.
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
list< CRef< CSeq_entry > > TEntrys
const TEntrys & GetEntrys(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
const TSub & GetSub(void) const
Get the Sub member data.
bool IsSetSub(void) const
Check if a value has been assigned to Sub data member.
bool IsEntrys(void) const
Check if variant Entrys is selected.
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
#define EXT_POINT__EDITOR_FACTORY
n background color
END_EVENT_TABLE()
int i
static void text(MDB_val *v)
Definition: mdb_dump.c:62
#define wxT(x)
Definition: muParser.cpp:41
mdb_mode_t mode
Definition: lmdb++.h:38
const struct ncbi::grid::netcache::search::fields::SIZE size
T min(T x_, T y_)
static const char *const strings[]
Definition: utf8.c:21
static static static wxID_ANY
ViewerWindowBase::OnEditMenu ViewerWindowBase::OnJustification EVT_MENU(MID_SHOW_GEOM_VLTNS, ViewerWindowBase::OnShowGeomVltns) EVT_MENU(MID_FIND_PATTERN
static const char * str(char *buf, int n)
Definition: stats.c:84
CConstRef< objects::CSeq_loc > m_SeqLoc
objects::CFlatFileConfig::EMode m_Mode
CConstRef< objects::CSubmit_block > m_SeqSubmit
objects::CFlatFileConfig::EStyle m_Style
Definition: type.c:6
#define _ASSERT
@ kExpandAll
CAtomicCounter_WithAutoInit gITextItemCount
Definition: text_item.cpp:44
USING_SCOPE(objects)
static const wxChar * pszFlatFile
Definition: text_panel.cpp:117
static const wxChar * pszMainToolbar
Definition: text_panel.cpp:122
static wxColor m_BackgroundColor
Definition: text_panel.cpp:130
static const char * kFeatureMode
Definition: text_panel.cpp:253
static const char * kViewTypeSeq
Definition: text_panel.cpp:246
static const char * kViewTypeFeat
Definition: text_panel.cpp:247
static const char * kMoreSequences
Definition: text_panel.cpp:127
static const char * kAllSequences
Definition: text_panel.cpp:126
static const char * kFFHideSTS
Definition: text_panel.cpp:257
static CSeq_entry_Handle GetSeqEntryHandle(CScope &scope, const CSerialObject &so)
Definition: text_panel.cpp:493
static const char * kShowSequence
Definition: text_panel.cpp:251
static const wxChar * pszASN
Definition: text_panel.cpp:119
const size_t kMaxSeqNumber
Definition: text_panel.cpp:128
static const char * kViewTypeGeneric
Definition: text_panel.cpp:248
static const char * kFontSize
Definition: text_panel.cpp:249
static const char * kFlatFileMode
Definition: text_panel.cpp:250
static const wxChar * pszFastA
Definition: text_panel.cpp:118
static const char * kASNShowPathToRoot
Definition: text_panel.cpp:255
static CFlatFileConfig::EMode s_FFMode(int val)
Definition: text_panel.cpp:533
static const wxChar * pszSequenceToolbar
Definition: text_panel.cpp:123
static CFlatFileConfig::EStyle s_FFStyle(bool showSequence)
Definition: text_panel.cpp:543
static const char * kFindMode
Definition: text_panel.cpp:245
static const char * kOpenExpanded
Definition: text_panel.cpp:258
static const char * kFFHideVariations
Definition: text_panel.cpp:256
static const char * kTextViewPath
Definition: text_panel.cpp:244
static const char * kAllNucleotides
Definition: text_panel.cpp:125
static const char * kFlatFileSequence
Definition: text_panel.cpp:252
static bool s_BackgroundColorSet
Definition: text_panel.cpp:131
static const wxChar * pszXML
Definition: text_panel.cpp:120
static const CSeq_entry * GetSeqEntryFromSeqSubmit(const CSerialObject *so)
Definition: text_panel.cpp:476
static const char * kASNShowTypes
Definition: text_panel.cpp:254
static wxAcceleratorEntry entries[3]
wxFileArtProvider * GetDefaultFileArtProvider()
Definition: wx_utils.cpp:334
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
wxSize GetDisplayPPI()
Mac always seems to return 72 for screen PPI so use wx function for non-mac and on mac divide the dis...
Definition: wx_utils.cpp:1309
#define const
Definition: zconf.h:230
Modified on Tue Nov 28 02:28:40 2023 by modify_doxy.py rev. 669887