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

Go to the SVN repository for this file.

1 /* $Id: feature_panel.cpp 47036 2022-05-24 18:52:09Z evgeniev $
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: Vlad Lebedev, Liangshou Wu
27  *
28  */
29 #include <ncbi_pch.hpp>
30 
31 
43 #include <gui/opengl/glutils.hpp>
44 #include <gui/opengl/irender.hpp>
47 
48 #include <objmgr/scope.hpp>
49 #include <objmgr/util/feature.hpp>
50 #include <objmgr/util/sequence.hpp>
52 #include <corelib/ncbitime.hpp>
53 #include <serial/iterator.hpp>
55 
56 #include "configure_tracks_dlg.hpp"
57 
59 
68 
80 
82 
83 #include <algorithm>
84 #include <ctype.h>
85 #include <math.h>
86 #include <unordered_set>
87 
88 #include <wx/menu.h>
89 #include <wx/utils.h>
90 #include <wx/string.h>
91 
92 #include <wx/msgdlg.h>
93 #include <wx/richmsgdlg.h>
94 
97 
98 /// cell sizes for CDS grid
99 static const int kMinCellSize = 30;
100 static const int kMaxCellSize = 72;
101 // CDS grid to follow codon boundaries
102 static const int kSteps[] = { 3, 6, 9 };
103 
104 /// maximal display level in multiple level layout.
105 static const int kMaxDisplayLevel = 3;
106 
107 static const string kBaseKey("GBPlugins.SeqGraphicFeatPanel");
108 
109 static const int kLevelTrackBaseID = 10000;
110 
112 CFeaturePanel::m_TypeInfo("feature_panel_track", "Feature Panel");
113 
115  : CTrackContainer(r_cntx)
116  , m_SelFeatures(NULL)
117  , m_SelCDSFeatures(NULL)
118  , m_IsMultiLevel(false)
119  , m_IconTexInitialized(false)
120  , m_CgiMode(cgi_mode)
121  , m_ImageInfo(NULL)
122  , m_ConfigKey(kBaseKey)
123  , m_AssemblyLoaded(false)
124 {
126 
130 
131  SetLeft(0.0);
132  SetTop(0.0);
133 
134  // we want to make sure the direct children of feature panel have
135  // zero indentation. So it must be -1 here.
136  m_IndentLevel = -1;
137 
138  TTrackAttrFlags attr =
140  SetTrackAttr(attr);
141 
142  // register track icons
143  // we want to put help icon at the end, so deregister conten, and
144  // add it back later.
147  "Content", true, "track_content", "", "track_content_lite"));
149  "Layout style", true, "track_layout", "", "track_layout_lite"));
151  "Color", true, "track_color_theme", "", "track_color_theme_lite"));
153  "Size", true, "track_size", "", "track_size_lite"));
154  x_RegisterIcon(SIconInfo(eIcon_Decoration, "Feature decoration",
155  true, "track_decoration", "", "track_decoration_lite"));
157  "Label position", true, "track_label", "", "track_label_lite"));
158 
160 
161  // setup grid
162  m_Gen.SetIntegerMode(true, true);
163  m_Gen.EnableMinusOneBased(true, true);
164  // don't update step automatically, the step will be updated
165  // externally according to ruler's major ticks.
166  m_Gen.SetAutoStepUpdate(false);
168 }
169 
170 
172 {
173  if (m_DS && !m_CgiMode) {
174  SaveTrackConfig();
175  }
176  DeleteAllJobs();
177 }
178 
179 
180 void CFeaturePanel::Update(bool layout_only)
181 {
182  if (m_IsMultiLevel) {
183 /*
184  if (!layout_only) {
185  if ( !m_DS->AllJobsFinished() ) {
186  m_DS->DeleteAllJobs();
187  SetTrackInitDone(true);
188  }
189  x_SetStartStatus();
190  }
191 */
192  // make sure we keep the track info up to date
193  // E.g. the track titles get changed to more meaningful ones
194  // when actual data get loaded.
195  x_UpdateMsg();
196 
197  // we need to do something differently from CTrackContainer to
198  // make sure that we will see data in layout tracks at level 1 and 2
199  // before the tracks at level 3 get initialized which might be time
200  // consumming.
201  bool update_level_3 = true;
202  TTrackProxies proxies = m_TrackProxies;
204  NON_CONST_ITERATE (TTrackProxies, iter, proxies) {
205  if ( !(*iter)->GetShown() ) continue;
206 
207  CLayoutTrack* track = (*iter)->GetTrack();
208  if ( !track) continue;
209 
210  const CTrackContainer* cont =
211  dynamic_cast<const CTrackContainer*>(track);
212 
213  int level = -1;
214  if ( cont ) {
215  level = cont->GetAnnotLevel();
216  }
217  if (level < 0) {
218  track->Update(layout_only);
219  } else if (level < 2) {
220  track->Update(layout_only);
221  if ( !cont->IsTrackInitDone() ) {
222  update_level_3 = false;
223  }
224  } else if (update_level_3) {
225  const TSeqRange& curr_range = m_Context->GetVisSeqRange();
226  if (layout_only) {
227  if (curr_range != (*iter)->GetVisitedRange()) {
228  (*iter)->SetVisitedRange(m_Context->GetVisSeqRange());
229  track->Update(false);
230  } else {
231  track->Update(true);
232  }
233  } else {
234  track->Update(false);
235  (*iter)->SetVisitedRange(curr_range);
236  }
237  } else {
238  track->Update(true);
239  }
240  }
241  if (!layout_only) {
242  x_UpdateData();
243  } else {
244  x_UpdateLayout();
245  // check if we need to reinitialize the sub tracks.
247  }
248  } else {
249  CDataTrack::Update(layout_only);
250  }
251 
252  if (m_CgiMode) {
253  if ( !layout_only ) {
254  int order_id = 0;
255  TTrackProxies proxies;
256  SetChildren().clear();
257  x_MakeTopLevelTracks(this, proxies, order_id, "", m_IndentLevel + 1);
258  SetSubtrackProxies(proxies);
259  x_UpdateLayout();
260  }
261  SetMsg("");
262  }
263 }
264 
265 
267 {
268  CRef<CSeqGlyph> glyph;
269  // this is a special case since feature panel is a special track
270  if (x_HitTitleBar(p)) {
271  glyph.Reset(this);
272  } else {
273  glyph = CGlyphContainer::HitTest(p);
274  }
275  return glyph;
276 }
277 
279 {
280  return CGlyphContainer::HitTestHor(x, obj);
281 }
282 
284 {
285  m_InputObj = obj;
287  m_DSContext->GetDS(typeid(CFeaturePanelDSType).name(), obj);
288  m_DS.Reset(dynamic_cast<CFeaturePanelDS*>(ds.GetPointer()));
289  m_DS->SetJobListener(this);
292 
294  string tmsContext = "GBench_3-0";
295  bool useEutils = reg.GetBool("NA_TRACKS", "USE_EUTILS", true);
296  m_DS->SetTMSContext(tmsContext);
297  m_DS->SetUseEUtils(useEutils);
298 }
299 
301 {
302  CRef<CTrackProxy> proxy{ AddNewTrack(data.GetKey(), data.GetAnnots(), data.GetDisplayName(), data.GetDisplayName(), "", data.GetSubkey()) };
303  if (!proxy)
304  return;
305  proxy->SetCategory(data.GetCategory());
306  proxy->SetSubcategory(data.GetSubcategory());
307 }
308 
309 void CFeaturePanel::SetAssembly(const string& assembly)
310 {
311  if (!m_DS || m_DS->GetAssembly() == assembly)
312  return;
313 
314  m_DS->SetAssembly(assembly);
315  m_NAData.clear();
316  ConfigureTracks();
317 }
318 
320 {
321  string assembly;
322  if (m_DS)
323  assembly = m_DS->GetAssembly();
324  return assembly;
325 }
326 
327 namespace
328 {
329  class CTrackCounter
330  {
331  public:
332  CTrackCounter() : m_Count(0) {}
333 
334  size_t GetCount() const { return m_Count; }
335 
336  bool ContainerBegin(const CTempTrackProxy*, const CTrackContainer*, bool) const { return true; }
337  void ContainerEnd(const CTempTrackProxy*, const CTrackContainer*, bool) const { ;; }
338  bool Track(const CTempTrackProxy*, const CLayoutTrack*, bool /*visible*/) { ++m_Count; return true; }
339 
340  private:
341  size_t m_Count;
342  };
343 } // namespace
344 
345 void CFeaturePanel::ShowConfigureTracksDlg(const string& category)
346 {
347  CTrackCounter counter;
348  Traverse(counter, true);
349 
350  if (counter.GetCount() == 0) {
351  wxMessageBox(wxT("Track information is not loaded. Please wait."), wxT("Track Initialization"), wxOK | wxICON_EXCLAMATION);
352  return;
353  }
354 
355  if (!IsTrackInitDone()) {
356  static bool showDialog = true;
357  if (showDialog) {
358  wxRichMessageDialog dlg(NULL, wxT("Not all tracks are loaded.\nConfigure Tracks dialog will not show all available tracks."),
359  wxT("Warning"), wxOK | wxICON_EXCLAMATION);
360  dlg.ShowCheckBox(wxT("Don't show this dialog in the current session"));
361  dlg.ShowModal();
362  if (dlg.IsCheckBoxChecked())
363  showDialog = false;
364  }
365  }
366 
367  CConfigureTracksDlg dlg(NULL, this);
368  dlg.SetRegistryPath("Dialogs.ConfigureTracks");
369  dlg.SetCategory(category);
370  dlg.ShowModal();
371 }
372 
374 {
375  m_search_results.clear();
376  m_next_result = 0;
377  m_search_text.clear();
378  if (m_ServiceLocator) {
380  sb_srv->SetStatusMessage(kEmptyStr);
381  }
382 }
383 
384 
385 CMappedFeatOrObject CFeaturePanel::FindText(const string &text, bool match_case)
386 {
389 
391  if (text != m_search_text || match_case != m_search_match_case)
392  {
393  ResetSearch();
395  m_search_match_case = match_case;
397  }
398  if (m_search_results.empty())
399  {
400  sb_srv->SetStatusMessage(kEmptyStr);
401  return mfo;
402  }
403  if ( m_next_result >= m_search_results.size())
404  {
405  if (wxMessageBox(_("No more matches found, wrapping over"), wxT("Confirm"), wxOK | wxCANCEL) == wxOK)
406  m_next_result = 0;
407  else
408  m_next_result = m_search_results.size() - 1;
409  }
411  ++m_next_result;
413  str << "Search result " << m_next_result << " of " << m_search_results.size();
414  sb_srv->SetStatusMessage(CNcbiOstrstreamToString(str));
415  return mfo;
416 }
417 
419 {
421  Traverse(subtypes, true);
422  set<string> annot_names = subtypes.GetAnnotsSnp();
423  return annot_names;
424 }
425 
427 {
428  if (m_TrackSettings.empty()) {
429  x_LoadSettings();
430  }
431  if (m_DS.NotNull()) {
432  if (m_DiscoverTracks && !m_CgiMode && m_NAData.empty()) {
433  // we might need to retrieve meta-data for NAAs
434  SetTrackInitDone(false);
437  }
438  else {
440  }
442  }
443 }
444 
446 {
447  string seqAcc;
448  const CSeq_id* seqId = dynamic_cast<const CSeq_id*>(m_InputObj.object.GetPointerOrNull());
449  if (seqId && !seqId->IsLocal()) {
451  try {
452  if (h.IsGi()) {
454  input.push_back(h);
455  m_InputObj.scope->GetAccVers(&result, input);
456  if (result.size() == 1)
457  h = result.front();
458  }
459  } NCBI_CATCH("CGraphicPanel: converting GI Seq-id.");
460 
462  seqAcc = id ? id->GetSeqIdString(true) : seqId->GetSeqIdString(true);
463  }
464 
465  list<CRef<objects::CGC_Assembly> > assemblies;
466  if (seqAcc.empty() || CAssemblyCache::GetInstance().GetAssemblies(seqAcc, assemblies))
467  x_OnAssemblyLoaded(assemblies);
468  else
469  m_DS->GetAssemblies(seqAcc);
470 }
471 
473 {
474  m_AssemblyLoaded = true;
475  m_Assemblies.assign(assemblies.begin(), assemblies.end());
476 
477  string a = m_DS->GetAssembly(), cur, def;
478  if (!m_Assemblies.empty()) {
479  def = m_Assemblies.front()->GetAccession();
480  for (const auto& i : m_Assemblies) {
481  string acc = i->GetAccession();
482  if (acc == a)
483  cur = acc;
484  if (acc == m_DefaultAssembly)
485  def = acc;
486  }
487  }
488 
489  if (cur.empty())
490  m_DS->SetAssembly(def);
491 
492  m_NAData.clear();
493  m_DS->GetAnnotMetaData("Retrieve NA meta-data");
494 }
495 
497 {
498  ClearTracks();
500  Update(true);
501 }
502 
503 
504 namespace
505 {
506  class CLoadProfile
507  {
508  public:
509 
510  bool ContainerBegin(CTempTrackProxy* proxy, CTrackContainer* container, bool visible)
511  {
512  Track(proxy, container, visible);
513  return true;
514  }
515 
516  void ContainerEnd(CTempTrackProxy* proxy, CTrackContainer* container, bool visible)
517  {
518  ;;
519  }
520 
521  bool Track(CTempTrackProxy* proxy, CLayoutTrack* track, bool)
522  {
523  if (track) {
524  track->LoadProfile(track->GetProfile());
525  if (proxy) {
526  track->SetComments(proxy->GetComments());
527  track->SetHighlights(proxy->GetHighlights());
528  track->SetHighlightsColor(proxy->GetHighlightsColor());
529  track->SetShowTitle(proxy->GetShowTitle() && track->GetShowTitle());
530  }
531  }
532  return false;
533  }
534  };
535 
536  class CSaveProfile
537  {
538  public:
539  bool ContainerBegin(CTempTrackProxy* proxy, CTrackContainer* container, bool visible)
540  {
541  return true;
542  }
543 
544  void ContainerEnd(CTempTrackProxy* proxy, CTrackContainer* container, bool visible)
545  {
546  Track(proxy, container, visible);
547  }
548 
549  bool Track(CTempTrackProxy*, CLayoutTrack* track, bool)
550  {
551  if (track)
552  track->SaveProfile();
553  return false;
554  }
555  };
556 }
557 
559 {
560  Traverse(CSaveProfile(), true);
561  Traverse(CLoadProfile(), true);
563 }
564 
565 
567 {
568  if (objs.empty() && !m_ExtLayoutTrack)
569  return;
570  if ( !m_ExtLayoutTrack ) {
572  m_ExtLayoutTrack->SetTitle("View reflection");
573  SetTrack(m_ExtLayoutTrack, -100);
574  }
576  m_ExtLayoutTrack->Update(true);
578 }
579 
580 
582 {
583  // remove the old track prifile from gui registry
584  string path = m_ConfigKey + CGuiRegistry::kDecimalDot +
586  string profile = GetProfile();
587 
589  string regPath = path + profile + ".Tracks";
590 
592  registry.GetReadView(regPath).GetTopKeys(keys);
593 
594  CRegistryWriteView view = registry.GetWriteView(regPath);
595  ITERATE(CRegistryReadView::TKeys, iter, keys)
596  view.DeleteField(iter->key);
597 
598  // set the track profile name to the global default
599  string default_profile = CSGConfigUtils::DefTrackProfile();
600  SetProfile(default_profile);
601  m_gConfig->SetTrackProfile(default_profile);
602  m_gConfig->SetDirty(true);
603  x_LoadSettings();
604  x_ConfigureTracks(true);
605 }
606 
607 
609 {
610  GetConfigMgr()->SetTrackConfig(m_TrackSettings, settings_set);
611 }
612 
613 
615 {
616  Traverse(CSaveProfile(), true);
617 }
618 
619 
620 void CFeaturePanel::ShowTrack(const string& track_key)
621 {
622  for (auto& s : m_TrackSettings) {
623  CTrackProxy* track = dynamic_cast<CTrackProxy*>(s.GetPointer());
624  if (track && track_key == track->GetKey()) {
625  track->SetShown(true);
626  break;
627  }
628  }
629 }
630 
631 
633 {
634  return m_TypeInfo;
635 }
636 
637 
639 {
640  if (!m_IsMultiLevel) return;
641 
642  const CTrackContainer* cont = dynamic_cast<const CTrackContainer*>(sender);
643 
644  if (!cont || cont->GetAnnotLevel() == 2) return;
645 
646  bool update_level_3 = true;
647  TTrackProxies proxies = m_TrackProxies;
649  NON_CONST_ITERATE (TTrackProxies, iter, proxies) {
650  if ( !(*iter)->GetShown() ) continue;
651 
652  CTrackContainer* cont_track =
653  dynamic_cast<CTrackContainer*>((*iter)->GetTrack());
654  if ( !cont_track) continue;
655 
656  int level = cont_track->GetAnnotLevel();
657  if (level < 2) {
658  if ( !cont->IsTrackInitDone() ) {
659  update_level_3 = false;
660  }
661  } else if (update_level_3) {
662  const TSeqRange& curr_range = m_Context->GetVisSeqRange();
663  if (curr_range != (*iter)->GetVisitedRange()) {
664  (*iter)->SetVisitedRange(m_Context->GetVisSeqRange());
665  cont_track->Update(false);
667  }
668  }
669  }
670 }
671 
672 
674 {
675  IRender& gl = GetGl();
676 
677  CGlPane* pane = m_Context->GetGlPane();
678 
679  // draw grid
683  if (x_NeedSpecialGrid()) {
684  v_color.Lighten(0.2f);
685  h_color.Lighten(0.2f);
686  }
687  {{
689  grid->SetHorzColor(h_color);
690  grid->SetVertColor(v_color);
691  }}
692  m_Grid.Render(pane, pane, const_cast<CRegularGridGen*>(&m_Gen));
693  }
694 
695  CGlPaneGuard GUARD(*pane, CGlPane::eOrtho);
696 
697  // make sure the icon texture objects have been generated.
698  // don't initalize textures in cgi mode sinc we don't need them.
699  if ( !m_IconTexInitialized && !m_CgiMode) {
700  // this call will check if the texture objects are truely invalid.
702  }
703 
704  bool horz = m_Context->IsHorizontal();
705  TModelUnit off_y = horz ? pane->GetOffsetY() : pane->GetOffsetX();
706  gl.PushMatrix();
707  gl.Translatef(0.0f, -off_y, 0.0f);
708 
709  // render speciality grid for selected CDSs
711 
712  // Render all fair-lines for selected features
713  gl.Disable(GL_LINE_SMOOTH);
715 
716  gl.Enable(GL_BLEND);
717  gl.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
718  gl.Enable(GL_LINE_SMOOTH);
719  glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
720  gl.LineWidth(1.0f);
721  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
722 
723  GetGroup().Draw();
724  if (!m_Context->IsSkipControls()) {
725  // Don't render icons/menu on vector output
726  if (!gl.IsPrinterFriendly())
728 
729  if (!IsTrackInitDone() && !m_CgiMode) {
730 
731  gl.LineWidth(1.0);
732 
733  //gl.Color4f(1.0f, 0.0f, 0.0f, 1.0f);
735  TModelRect rcm;
736  x_GetTBRect(rcm);
738  m_Context->ScreenToSeq(10.0);
740  static const string kInitTrackStr = "Discovering tracks...";
741  TModelUnit w = m_Context->ScreenToSeq(font.TextWidth(kInitTrackStr.c_str()));
742  TModelUnit h = font.TextHeight();
743  gl.Color3f(1.f, 1.f, 1.f);
744  TModelRect rect(x, rcm.Bottom() - 4.0, x + w, rcm.Bottom() - 4.0 - h);
745  m_Context->DrawBackground(rect, 2);
746  gl.ColorC(CRgbaColor("gray"));
747  m_Context->TextOut(&font, kInitTrackStr.c_str(),
748  x, rcm.Bottom() - 4.0, false, false);
749  }
750  }
751  gl.PopMatrix();
752 
753  gl.Disable(GL_BLEND);
754  gl.Disable(GL_LINE_SMOOTH);
755 }
756 
757 
759 {
760  if (m_DS->IsMetaDataJob(id)) {
761  return true;
762  }
763  return m_DS->IsJobNeeded(id);
764 }
765 
766 
768 {
769  CRef<CObject> res_obj = notify.GetResult();
770  CGetAssembliesJobResult* assembliesResult =
771  dynamic_cast<CGetAssembliesJobResult*>(&*res_obj);
772 
773  if (assembliesResult) {
775  x_OnAssemblyLoaded(assembliesResult->m_Assemblies);
776  return;
777  }
778 
780  dynamic_cast<CAnnotMetaDataJobResult*>(&*res_obj);
781  if (result) {
783  if ( !result->m_Annots.empty() ) {
784  m_NAData = result->m_Annots;
785  x_InitNATracks(false);
786  }
787  } else {
789  }
790 }
791 
792 void CFeaturePanel::x_InitNATracks(bool makeContainersVisible)
793 {
794  if (m_IsMultiLevel) {
795  for (auto& i : m_TrackProxies) {
796  CTrackContainer* cont = dynamic_cast<CTrackContainer*>(i->GetTrack());
797  if (!cont) continue;
798  cont->InitNATracks(m_NAData, makeContainersVisible);
799  }
800  }
801  else
802  InitNATracks(m_NAData, makeContainersVisible);
803 }
804 
806 {
807  return GetChildren().empty();
808 }
809 
810 
811 void CFeaturePanel::x_LoadSettings(const string& preset_style,
812  const TKeyValuePairs& /*settings*/)
813 {
814  if (preset_style.empty()) {
816  } else {
817  SetProfile(preset_style);
818  }
819  x_LoadSettings();
820 }
821 
822 
823 void CFeaturePanel::x_SaveSettings(const string& /*preset_style*/)
824 {
825  x_SaveSettings();
826 }
827 
828 
830 {
831  int icon_s = m_gConfig->GetIconSize();
832  TModelUnit h = icon_s * 1.5;
833  TModelUnit w = (m_Icons.size() * 1.5 + 0.5)* icon_s;
834  w = m_Context->ScreenToSeq(w) * 0.5;
835  TModelUnit center_x =
837  const CGlPane* pane = m_Context->GetGlPane();
838  TModelUnit bottom = pane->GetVisibleRect().Bottom();
839  if ( !m_Context->IsHorizontal() ) {
840  bottom = pane->GetVisibleRect().Left();
841  }
842  rect.Init(center_x - w, bottom, center_x + w, bottom - h);
843 }
844 
845 
847 {
848  IRender& gl = GetGl();
849 
850  if (m_Icons.empty() || m_CgiMode) {
851  return;
852  }
853 
855 
856  // render track frame
857  TModelRect rcm;
858  x_GetTBRect(rcm);
859  if (m_Attrs & fFrameVisible) {
860  TModelUnit left = rcm.Left();
861  TModelUnit right = rcm.Right();
862  // m_Context->AdjustToOrientation(left);
863 // m_Context->AdjustToOrientation(right);
864  TModelRect rcm_adj(left, rcm.Bottom(), right, rcm.Top());
865  TModelUnit w = m_Context->SeqToScreen(rcm_adj.Width());
866  TModelUnit diff = 0;
867  if (w < 100) {
868  diff = m_Context->ScreenToSeq(100 - w);
869  w = m_Context->ScreenToSeq(200.0);
870  }
871  rcm_adj.Inflate(diff, 0.0);
872 
873  if (m_ShowFrame) {
874  gl.Color4f(0.83f, 0.83f, 0.83f, 0.9f);
875 
876  int numSegments = 8;
877  float delta = 3.141592653589793238463f / numSegments / 2;
878 
879  float l = rcm_adj.Left() - m_Context->GetOffset(),
880  r = rcm_adj.Right() - m_Context->GetOffset();
881  float b = rcm_adj.Bottom(), ry = rcm.Bottom() - rcm.Top();
882  float rx = ry * m_Context->GetScale();
883 
884  gl.PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
885 
886  gl.Begin(GL_TRIANGLE_STRIP);
887  gl.Vertex2f(l - rx, b);
888  gl.Vertex2f(r + rx, b);
889 
890  float a = delta;
891  for (int i = 0; i < numSegments - 1; ++i) {
892  float sina = ry*sin(a), cosa = rx*cos(a);
893  gl.Vertex2f(l - cosa, b - sina);
894  gl.Vertex2f(r + cosa, b - sina);
895  a += delta;
896  }
897 
898  gl.Vertex2f(l, b - ry);
899  gl.Vertex2f(r, b - ry);
900  gl.End();
901  }
902 
903  size_t icon_num = m_Icons.size();
904  for (size_t idx = 0; idx < icon_num; ++idx) {
906  }
907 
908  if (!m_ShowFrame) {
909  gl.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
910  }
911  }
912 }
913 
914 
916 {
917  switch (id) {
918  case eIcon_Layout:
920  break;
921  case eIcon_Color:
923  break;
924  case eIcon_Size:
926  break;
927  case eIcon_Decoration:
929  break;
930  case eIcon_Label:
932  break;
933  default:
934  // use default handlers
936  }
937 }
938 
939 
941 {
943  TStyleMap styles;
944  int id_base = 10000;
945  styles[id_base] = wxT("Default");
946  styles[id_base + 1] = wxT("Multiple level");
947 
948  wxMenu menu;
949  UseDefaultMarginWidth(menu);
950 
951  int id = 0;
952  ITERATE (TStyleMap, iter, styles) {
953  wxMenuItem* item = menu.AppendRadioItem(iter->first, iter->second);
954  if (m_IsMultiLevel && id == 1) {
955  item->Check();
956  } else if (id == 0) {
957  item->Check();
958  }
959  ++id;
960  }
961 
962  m_LTHost->LTH_PopupMenu(&menu);
963  wxMenuItemList& item_list = menu.GetMenuItems();
964  ITERATE (wxMenuItemList, iter, item_list) {
965  if ((*iter)->IsChecked()) {
966  id = (*iter)->GetId() - id_base;
967  break;
968  }
969  }
970 
971  if ((id == 0 && m_IsMultiLevel) || (id == 1 && !m_IsMultiLevel)) {
972  Traverse(CSaveProfile(), true);
973  Traverse(CLoadProfile(), true);
976  LOG_POST(Info << "Graphical view: switch to " <<
977  (m_IsMultiLevel ? "multiple level layout" : "default layout mode"));
978  }
979 }
980 
981 
983 {
984  // prohibit change settings before initialization gets finished
985  if ( !IsTrackInitDone() ) return;
986 
987  typedef map <int, wxString> TMenuItems;
988  TMenuItems items;
989  int id_base = 10000;
990  items[id_base] = wxT("Greyscale");
991  items[id_base + 1] = wxT("Color");
992 
993  wxMenu menu;
994  UseDefaultMarginWidth(menu);
995  ITERATE (TMenuItems, iter, items) {
996  wxMenuItem* item = menu.AppendRadioItem(iter->first, iter->second);
997  if (iter->second == ToWxString(m_gConfig->GetColorTheme())) {
998  item->Check();
999  }
1000  }
1001 
1002  m_LTHost->LTH_PopupMenu(&menu);
1003  wxMenuItemList& item_list = menu.GetMenuItems();
1004  ITERATE (wxMenuItemList, iter, item_list) {
1005  const string& new_color = ToStdString(items[(*iter)->GetId()]);
1006  if ((*iter)->IsChecked() && new_color != m_gConfig->GetColorTheme()) {
1007  LOG_POST(Info << "Graphical view: switch color theme from " <<
1008  m_gConfig->GetColorTheme() << " to " << new_color);
1009  Traverse(CSaveProfile(), true);
1010  m_gConfig->SaveSettings(true);
1011  m_gConfig->SetColorTheme(new_color);
1013  if (m_DS->GetBioseqHandle().IsProtein()) {
1015  }
1016  Traverse(CLoadProfile(), true);
1017  m_gConfig->SetDirty(true);
1020  Update(false);
1021  break;
1022  }
1023  }
1024 }
1025 
1026 
1028 {
1029  // prohibit change settings before initialization gets finished
1030  if ( !IsTrackInitDone() ) return;
1031 
1032  typedef map <int, wxString> TMenuItems;
1033  TMenuItems items;
1034  int id_base = 10000;
1035  items[id_base] = wxT("Compact");
1036  items[id_base + 1] = wxT("Normal");
1037  items[id_base + 2] = wxT("Oversize");
1038 
1039  wxMenu menu;
1040  UseDefaultMarginWidth(menu);
1041  ITERATE (TMenuItems, iter, items) {
1042  wxMenuItem* item = menu.AppendRadioItem(iter->first, iter->second);
1043  if (iter->second == ToWxString(m_gConfig->GetSizeLevel())) {
1044  item->Check();
1045  }
1046  }
1047 
1048  m_LTHost->LTH_PopupMenu(&menu);
1049  wxMenuItemList& item_list = menu.GetMenuItems();
1050  ITERATE (wxMenuItemList, iter, item_list) {
1051  const string& new_size = ToStdString(items[(*iter)->GetId()]);
1052  if ((*iter)->IsChecked() && new_size != m_gConfig->GetSizeLevel()) {
1053  LOG_POST(Info << "Graphical view: switch size level from " <<
1054  m_gConfig->GetSizeLevel() << " to " << new_size);
1055  Traverse(CSaveProfile(), true);
1056  m_gConfig->SaveSettings(true);
1057  m_gConfig->SetSizeLevel(new_size);
1059  if (m_DS->GetBioseqHandle().IsProtein()) {
1061  }
1062  Traverse(CLoadProfile(), true);
1063  m_gConfig->SetDirty(true);
1064  Update(false);
1065  break;
1066  }
1067  }
1068 }
1069 
1070 
1072 {
1073  // prohibit change settings before initialization gets finished
1074  if ( !IsTrackInitDone() ) return;
1075 
1076  typedef map <int, wxString> TMenuItems;
1077  TMenuItems items;
1078  int id_base = 10000;
1079  items[id_base] = wxT("Default");
1080  items[id_base + 1] = wxT("Arrows");
1081  items[id_base + 2] = wxT("SquareAnchor");
1082  items[id_base + 3] = wxT("CircleAnchor");
1083  items[id_base + 4] = wxT("Fancy");
1084 
1085  wxMenu menu;
1086  UseDefaultMarginWidth(menu);
1087  ITERATE (TMenuItems, iter, items) {
1088  wxMenuItem* item = menu.AppendRadioItem(iter->first, iter->second);
1089  if (iter->second == ToWxString(m_gConfig->GetDecorateStyle())) {
1090  item->Check();
1091  }
1092  }
1093 
1094  m_LTHost->LTH_PopupMenu(&menu);
1095  wxMenuItemList& item_list = menu.GetMenuItems();
1096  ITERATE (wxMenuItemList, iter, item_list) {
1097  const string& new_decor = ToStdString(items[(*iter)->GetId()]);
1098  if ((*iter)->IsChecked() && new_decor != m_gConfig->GetDecorateStyle()) {
1099  LOG_POST(Info << "Graphical view: switch feature decoration from " <<
1100  m_gConfig->GetDecorateStyle() << " to " << new_decor);
1101  x_SaveSettings();
1102  m_gConfig->SaveSettings(true);
1103  m_gConfig->SetDecorateStyle(new_decor);
1105  if (m_DS->GetBioseqHandle().IsProtein()) {
1107  }
1108  m_gConfig->SetDirty(true);
1109  Update(false);
1110  break;
1111  }
1112  }
1113 }
1114 
1115 
1117 {
1118  // prohibit change settings before initialization gets finished
1119  if ( !IsTrackInitDone() ) return;
1120 
1121  const string& old_label_pos = m_gConfig->GetLabelPos();
1122  typedef map <int, wxString> TMenuItems;
1123  TMenuItems items;
1124  int id_base = 10000;
1125  items[id_base] = wxT("Default");
1126  items[id_base + 1] = wxT("Top label");
1127  items[id_base + 2] = wxT("Side label");
1128  items[id_base + 3] = wxT("No label");
1129 
1130  wxMenu menu;
1131  UseDefaultMarginWidth(menu);
1132  ITERATE (TMenuItems, iter, items) {
1133  wxMenuItem* item = menu.AppendRadioItem(iter->first, iter->second);
1134  if (iter->second == ToWxString(old_label_pos)) {
1135  item->Check();
1136  }
1137  }
1138 
1139  m_LTHost->LTH_PopupMenu(&menu);
1140  wxMenuItemList& item_list = menu.GetMenuItems();
1141  ITERATE (wxMenuItemList, iter, item_list) {
1142  const string& new_label_pos = ToStdString(items[(*iter)->GetId()]);
1143  if ((*iter)->IsChecked() && new_label_pos != old_label_pos) {
1144  LOG_POST(Info << "Graphical view: switch feature label position from " <<
1145  old_label_pos << " to " << new_label_pos);
1146  Traverse(CSaveProfile(), true);
1147  m_gConfig->SaveSettings(true);
1148  m_gConfig->SetLabelPos(new_label_pos);
1150  if (m_DS->GetBioseqHandle().IsProtein()) {
1152  }
1153  Traverse(CLoadProfile(), true);
1154  m_gConfig->SetDirty(true);
1155  Update(false);
1156  break;
1157  }
1158  }
1159 }
1160 
1161 
1162 void CFeaturePanel::x_ConfigureTracks(bool makeContainersVisible)
1163 {
1165  if (config) {
1166  // we don't need to show strand indicator for features on protein.
1167  // make sure we turn them off if this is a protein sequnce.
1168  if (m_DS->GetBioseqHandle().IsProtein()) {
1169  config->IgnoreFeatureStrand();
1170  }
1171 
1172  ClearTracks();
1173 
1174  if (m_IsMultiLevel) {
1175  // feature panel track will hold only globally unique tracks,
1176  // which have no annot level concept (that is why we use -2),
1177  // and the track containers with level 0, 1, and 2
1178  SetAnnotLevel(-2);
1179  SetAdaptive(false);
1180 
1181  /// configure those tracks with no level concept.
1183  // configure other level-dependent tracks
1184  // to avoid track order conflict with the level-independent
1185  // tracks, we start the level track order = 100000
1186  int id = kLevelTrackBaseID;
1188  if ((*iter)->GetOrder() >= id)
1189  id = (*iter)->GetOrder() + 1;
1190  }
1191 
1192  for (int level = 0; level < kMaxDisplayLevel; ++level) {
1193  string track_name = "Level " + NStr::IntToString(level + 1);
1194  bool shown = (find(m_DisplayLevels.begin(),
1195  m_DisplayLevels.end(), level) != m_DisplayLevels.end());
1196  CRef<CTrackContainer> cont =
1197  x_CreateLevelTrack(level, id++, track_name, shown);
1199  }
1200  } else {
1201  // feature panel uses adaptive annot selector
1202  if (config->GetAnnotDepth() == CSeqGraphicConfig::eDepth_unknown) {
1203  SetAdaptive(true);
1204  /*
1205  int depth = 0;
1206  // first check if any feature fetch depth set explicitly
1207  if ( !CSGUtils::GetFeatFetchDepth(m_DS->GetBioseqHandle(),
1208  m_DS->GetScope(), depth) ) {
1209  // sequence-specific
1210  if (CSGUtils::IsChromosome(m_DS->GetBioseqHandle(), m_DS->GetScope())) {
1211  depth = 1;
1212  } else if (CSGUtils::IsSegSet(m_DS->GetBioseqHandle(), m_DS->GetScope())) {
1213  depth = -1;
1214  }
1215  }
1216  SetAnnotLevel(depth);
1217  */
1218  SetAnnotLevel(-1);
1219  } else if (config->GetAnnotDepth() == CSeqGraphicConfig::eDepth_nolimit) {
1220  SetAdaptive(true);
1221  SetAnnotLevel(-1);
1222  } else {
1223  // use exact depth
1224  SetAdaptive(false);
1225  SetAnnotLevel((int)config->GetAnnotDepth());
1226  }
1228  }
1229  }
1230  Update(false);
1231  if (!m_NAData.empty()) {
1232  x_InitNATracks(makeContainersVisible);
1233  }
1234 }
1235 
1236 
1238  const TTrackProxies& settings,
1239  int level)
1240 {
1241  set<string> usedFeatureSubkeys;
1243 
1244  ITERATE (TTrackProxies, t_iter, settings) {
1245  const CTrackProxy* param =
1246  dynamic_cast<const CTrackProxy*>(t_iter->GetPointer());
1247  if (!param) {
1248  /// the track and its siblings are temporary tracks that
1249  /// will be created by its parent. We skip them here.
1250  break;
1251  }
1252  CTrackContainer* cont = x_ConfigureSubtracks(parent, param, level, usedFeatureSubkeys);
1253  if (cont) {
1254  x_ConfigureSubtracks_Recursive(cont, param->GetChildren(), level);
1255  }
1256  }
1257 }
1258 
1259 
1262  const CTrackProxy* param,
1263  int level,
1264  const set<string>& usedFeatureSubkeys)
1265 {
1266  // returned track container.
1267  // set this value if the created track is a container track.
1268  // the returned container track will serve as the parent
1269  // for recursive track loading.
1270  CTrackContainer* cont_track = NULL;
1271  CRef<CTrackProxy> t_proxy;
1272 
1273  const ILayoutTrackFactory* factory =
1274  GetConfigMgr()->GetTrackFactory(param->GetKey());
1275  if ( !factory ) return cont_track;
1276 
1277  // this is a track that doesn't understand annotation level concept,
1278  // but we only want to show the tracks in a given annotation level (>=0)
1279  if (level >=0 && !factory->UnderstandLevel()) return cont_track;
1280 
1281  // this is a track that does understand annotation level concept,
1282  // but we only want to show the tracks with no annot concept.
1283  if (level == -2 && factory->UnderstandLevel()) return cont_track;
1284 
1285  int depth = level;
1286  if (GetAdaptive()) {
1287  depth = GetAnnotLevel();
1288  }
1289 
1290  // create track proxy for the track
1291  t_proxy.Reset(new CTrackProxy(*param));
1292 
1293  // create track immediately if no background initialization is required
1294  if ( !factory->NeedBackgroundInit() &&
1295  (!m_CgiMode || t_proxy->GetShown())) {
1296  ILayoutTrackFactory::SExtraParams extra_params(
1297  depth, GetAdaptive(), &t_proxy->GetAnnots(),
1298  t_proxy->GetSubkey(), t_proxy->GetFilter(), t_proxy->GetSortBy());
1299  extra_params.m_SkipGenuineCheck = GetSkipGenuineCheck();
1300  extra_params.m_SubTracks = t_proxy->GetSubTracks();
1301  extra_params.m_UsedFeatureSubkeys = usedFeatureSubkeys;
1302  extra_params.m_RemotePath = t_proxy->GetRemotePath();
1303 
1304  TTrackMap tracks = factory->CreateTracks(m_InputObj, m_DSContext,
1305  m_Context, extra_params, TAnnotMetaDataList());
1306 
1307  if ( !tracks.empty()) {
1308  parent->AddTracks(t_proxy, tracks);
1309  CLayoutTrack* track = tracks.begin()->second;
1310  if ((cont_track = dynamic_cast<CTrackContainer*>(track))) {
1311  cont_track->SetSubtrackProxies(t_proxy->GetChildren());
1312  cont_track->SetConfigMgr(GetConfigMgr());
1313  }
1314 
1315  if (CAllOtherFeaturesTrack* feats_track =
1316  dynamic_cast<CAllOtherFeaturesTrack*>(track)) {
1317  feats_track->SetProxy(t_proxy);
1318  }
1319  }
1320  } else {
1321  // add the track proxy to the parent track.
1322  parent->AddTrackProxy(t_proxy);
1323  }
1324 
1325  return cont_track;
1326 }
1327 
1328 static const string k_multi_level = "MultiLevel";
1329 static const string k_display_level = "DisplayLevels";
1330 
1332  CTempTrackProxy::TTrackProxies& defaultProxies)
1333 {
1334  if (defaultProxies.empty())
1335  return;
1336 
1337  auto NameComp = [](const CRef<CTempTrackProxy>& t1, const CRef<CTempTrackProxy>& t2) ->
1338  bool { return t1->GetName() < t2->GetName(); };
1339 
1340  defaultProxies.sort(NameComp);
1341  if (!proxies.empty())
1342  proxies.sort(NameComp);
1343 
1344  for (auto sit = defaultProxies.begin(), dit = proxies.begin(); sit != defaultProxies.end() || dit != proxies.end();) {
1345  while (dit != proxies.end() && (sit == defaultProxies.end() || (*dit)->GetName() < (*sit)->GetName()))
1346  dit = proxies.erase(dit);
1347  while (dit != proxies.end() && sit != defaultProxies.end() && (*dit)->GetName() == (*sit)->GetName())
1348  ++sit, ++dit;
1349  while (sit != defaultProxies.end() && (dit == proxies.end() || (*sit)->GetName() < (*dit)->GetName())) {
1350  dit = proxies.insert(dit, (*sit)->Clone());
1351  ++sit, ++dit;
1352  }
1353  }
1354  proxies.sort([](const CRef<CTempTrackProxy>& t1, const CRef<CTempTrackProxy>& t2) ->
1355  bool { return t1->GetOrder() < t2->GetOrder(); });
1356 }
1357 
1358 
1360 {
1365  //m_Grid.SetShowVertGrid(g_conf->GetShowVertGrid());
1366  // no vertical grids for graphical sequence view
1367  m_Grid.SetShowVertGrid(false);
1368 
1370 
1371  // loading layout level settings
1374  path, g_conf->GetLayout(), CSGConfigUtils::DefLayout());
1375  m_IsMultiLevel = view.GetBool(k_multi_level, false);
1376  m_DisplayLevels.clear();
1377 
1379  if (f) {
1380  if (f->GetData().Which() == CUser_field::TData::e_Ints) {
1381  m_DisplayLevels = f->GetData().GetInts();
1382  } else if (f->GetData().Which() == CUser_field::TData::e_Str) {
1383  string str = f->GetData().GetStr();
1385  string::size_type sb = str.find_first_not_of("([");
1386  if (sb == string::npos) {
1387  sb = 0;
1388  }
1389  string::size_type se = str.find_last_not_of (")] ");
1390  if (se == string::npos) {
1391  se = str.size() - 1;
1392  }
1393  list<string> toks;
1394  NStr::Split(str.substr(sb, se - sb + 1), ", ", toks, NStr::fSplit_Tokenize);
1395  try {
1396  ITERATE (list<string>, iter, toks) {
1397  int level = NStr::StringToInt(*iter);
1398  x_SetShowDisplayLevel(level, true);
1399  }
1400  } catch (CException& e) {
1401  LOG_POST(Error << "Feature panel: errors when parsing "
1402  <<"display level settings, " << e.GetMsg());
1403  }
1404  } else {
1405  x_SetShowDisplayLevel(f->GetData().GetInt(), true);
1406  }
1407  }
1408  vector<string> icons;
1409  NStr::Split(view.GetString("Icons"), ",", icons, NStr::fSplit_Tokenize);
1410  if (!icons.empty()) {
1411  static map<string, int> kIconName2Id =
1412  {
1413  { "content", eIcon_Content },
1414  { "help", eIcon_Help },
1415  { "layout", eIcon_Layout },
1416  { "color", eIcon_Color },
1417  { "size", eIcon_Size },
1418  { "decor", eIcon_Decoration },
1419  { "label", eIcon_Label }
1420  };
1421 
1422  // if "Icons" are defined
1423  // Deregister icons that are not found in "Icons: list
1424  set<int> requested_icons;
1425  for (auto&& it : icons) {
1426  string icon = NStr::ToLower(it);
1427  if (kIconName2Id.count(icon) != 0)
1428  requested_icons.insert(kIconName2Id[icon]);
1429  }
1430  if (!requested_icons.empty()) {
1431  m_Icons.erase(remove_if(m_Icons.begin(), m_Icons.end(),
1432  [&](const SIconInfo& info) { return requested_icons.count(info.m_Id) == 0; }),
1433  m_Icons.end());
1434  }
1435  }
1436 
1437  m_TrackSettings.clear();
1438 
1439  string profile = GetProfile();
1442 
1444 
1446  CTempTrackProxy::TTrackProxies defaultProxies;
1448  s_StabilizeBaseContainers(m_TrackSettings, defaultProxies);
1449  }
1450 
1451  // remove the track that marked as 'empty' (need to removed)
1452  TTrackProxies::iterator iter = m_TrackSettings.begin();
1453  while (iter != m_TrackSettings.end()) {
1454  if ((*iter)->IsEmpty()) {
1455  iter = m_TrackSettings.erase(iter);
1456  } else {
1457  ++iter;
1458  }
1459  }
1460 
1461  for (auto& p : m_TrackSettings) {
1462  int order = 0;
1463  for (auto& c : p->GetChildren())
1464  c->SetOrder(++order);
1465  }
1466 }
1467 
1468 
1470 {
1473  if ( !g_conf ) return;
1474 
1475  // saving layout level settings
1477  CRegistryWriteView view =
1481  string levels = kEmptyStr;
1483  levels += " " + NStr::IntToString(*iter);
1484  }
1486  field->SetData().SetStr(CUtf8::AsUTF8(levels, eEncoding_Ascii));
1487 
1488  if (m_IsMultiLevel) {
1489  for (int i = 2; i >= 0; --i) {
1491  const CTrackContainer* cont =
1492  dynamic_cast<const CTrackContainer*>((*iter)->GetTrack());
1493  if (cont && cont->GetAnnotLevel() == i) {
1494  cont->SyncSettings(m_TrackSettings, i);
1495  }
1496  }
1497  }
1499  } else {
1501  }
1502 
1505  string profile = GetProfile();
1506 
1507  // Use a different track profile name to differentiate it from the one
1508  // shipped with GBench so that users can restore/update the track
1509  // profile to the original default one
1511  // this is done only once when GBench creates GenomeWorkbench2 folder
1512  // and save user settings for the first time.
1513  profile = CSGConfigUtils::UserSettingPrefix() + profile;
1514  SetProfile(profile);
1515  m_gConfig->SetTrackProfile(profile);
1516  // track profile name changed. It needs to be saved.
1517  m_gConfig->SetDirty(true);
1519  }
1520  else {
1521  // clear original tracks
1522  string regPath = path + profile + ".Tracks";
1524  registry.GetReadView(regPath).GetTopKeys(keys);
1525  view = registry.GetWriteView(regPath);
1526  ITERATE(CRegistryReadView::TKeys, iter, keys) {
1527  view.DeleteField(iter->key);
1528  }
1529  }
1531 }
1532 
1533 
1535 {
1536  static bool icon_image_registered = false;
1537  if ( !icon_image_registered && !m_CgiMode) {
1540  GetConfigMgr()->GetTrackFactories()) {
1541  const IIconProvider* icon_track =
1542  dynamic_cast<const IIconProvider*>(iter->second.GetPointer());
1543  if (icon_track) {
1544  icon_track->RegisterIconImages();
1545  }
1546  }
1547 
1548  // register icon images for feature panel
1549  RegisterIconImage("track_color_theme", "track_color_theme.png");
1550  RegisterIconImage("track_size", "track_size.png");
1551  RegisterIconImage("track_decoration", "track_decoration.png");
1552  RegisterIconImage("track_label", "track_label.png");
1553 
1554  // lite versions
1555  RegisterIconImage("track_color_theme_lite", "track_color_theme_lite.png");
1556  RegisterIconImage("track_size_lite", "track_size_lite.png");
1557  RegisterIconImage("track_decoration_lite", "track_decoration_lite.png");
1558  RegisterIconImage("track_label_lite", "track_label_lite.png");
1559  icon_image_registered = true;
1560  }
1561 }
1562 
1563 
1565 {
1566  if (!m_SelFeatures) {
1567  return;
1568  }
1569  // check hairline_options_dlg for values
1570  // 0. Show no hairlines with selections
1571  // 1. Show all hairlines with selections
1572  // 2. Show only hairlines that are not shared (i.e., places that are different)
1573  // 3. Show only hairlines that are shared by any two of the selections
1574  // 4. Show hairlines shared by *all* of the selections.
1575 
1576  int opt = m_gConfig->GetHairlineOption();
1577  if (opt == 0)
1578  return;
1579 
1580  CGlPane* pane = m_Context->GetGlPane();
1581  int vp_min = pane->GetViewport().Left();
1582  int vp_max = pane->GetViewport().Right() + 1;
1583  vector<bool> has_line(vp_max-vp_min, false);
1584 
1585  // cerr << "CFeaturePanel::x_RenderHairLineSelections(): vp_min/max: " << vp_min << " : " << vp_max << endl;
1586  // first, gather all From and To positions
1587  multiset <TSeqPos> all_pos;
1588  size_t total_glyph = 0;
1590  CWeakRef<CSeqGlyph>::TRefType glyph = iter->Lock();
1591  if ( !glyph ) continue;
1592 
1593  const IObjectBasedGlyph* obj =
1594  dynamic_cast<const IObjectBasedGlyph*>(glyph.GetPointer());
1595  _ASSERT(obj);
1597  const TSeqRange& curr = *iter_i;
1598  all_pos.insert(curr.GetFrom());
1599  all_pos.insert(curr.GetTo() + 1);
1600  // cerr << "all_pos: " << curr.GetFrom() << " : " << curr.GetTo() + 1 << endl;
1601  }
1602  ++total_glyph;
1603  } // done
1604 
1605  TModelUnit flip_sign = (m_Context->IsFlippedStrand()) ? -1.0 : 1.0;
1606 
1607  // finally, render hair-lines
1609  CWeakRef<CSeqGlyph>::TRefType glyph = iter->Lock();
1610  if ( !glyph ) continue;
1611 
1612  TModelPoint top_left;
1613  glyph->GetPosInWorld(top_left);
1614  TModelUnit line_y = top_left.Y();
1615  const CFeatGlyph* feat =
1616  dynamic_cast<const CFeatGlyph*>(glyph.GetPointer());
1617  if (feat) {
1618  line_y += feat->GetBarCenter();
1619  }
1620 
1621  const IObjectBasedGlyph* obj =
1622  dynamic_cast<const IObjectBasedGlyph*>(glyph.GetPointer());
1624  const TSeqRange& curr = *iter_i;
1625 
1626  int x = int(floor(m_Context->SeqToScreenXInModelUnit(curr.GetFrom())) * flip_sign);
1627  // cerr << "processing pos: " << curr.GetFrom() << " with x: " << x << endl;
1628  if (x>=vp_min && x<vp_max && !has_line[x-vp_min] && x_DrawHairLine(opt, total_glyph, all_pos, curr.GetFrom(), line_y)) {
1629  has_line[x-vp_min] = true;
1630  }
1631 
1632  x = int(floor(m_Context->SeqToScreenXInModelUnit(curr.GetTo() + 1)) * flip_sign);
1633  // cerr << "processing pos: " << curr.GetTo() + 1 << " with x: " << x << endl;
1634  if (x>=vp_min && x<vp_max && !has_line[x-vp_min] && x_DrawHairLine(opt, total_glyph, all_pos, curr.GetTo()+1, line_y)) {
1635  has_line[x-vp_min] = true;
1636  }
1637  }
1638  }
1639 }
1640 
1641 
1642 bool CFeaturePanel::x_DrawHairLine(int opt, size_t total, const multiset <TSeqPos>& all_pos,
1643  TSeqPos pos, TModelUnit line_y) const
1644 {
1645  IRender& gl = GetGl();
1646 
1647  // use light color when no intersection, dark otherwise
1650 
1651  // if only one selected feature, we show all hairlines
1652  // This is for considering merged feature
1653  if (total == 1) {
1654  opt = 1;
1655  }
1656 
1657  bool need_line = true;
1658  CRgbaColor color;
1659  switch (opt) {
1660  case 1: // 1. Show all hairlines with selections
1661  color = all_pos.count(pos) > 1 ? c_dark : c_light;
1662  break;
1663  case 2: // 2. Show only hairlines that are not shared (i.e., places that are different)
1664  color = c_light;
1665  need_line = all_pos.count(pos) == 1;
1666  break;
1667  case 3: // 3. Show only hairlines that are shared by any two of the selections
1668  color = c_dark;
1669  need_line = all_pos.count(pos) >= 2;
1670  break;
1671  case 4: // 4. Show hairlines shared by *all* of the selections.
1672  color = c_dark;
1673  need_line = all_pos.count(pos) == total;
1674  break;
1675  }
1676  // cerr << "CFeaturePanel::x_DrawHairLine(): opt: " << opt << ", need_line: " << need_line << ", pos: " << pos << endl;
1677  // render "From"
1678  if (need_line) {
1679  gl.ColorC(color);
1680  m_Context->DrawLine(pos, line_y, pos, GetTop());
1681 
1684  m_Context->DrawLine(pos, GetBottom()+1, pos, line_y);
1685  }
1686 
1687  if (m_ImageInfo != NULL) {
1688  CSeqGraphicHairline hinfo;
1689  hinfo.m_TopColor = color;
1690 
1691  TModelUnit flip_sign = (m_Context->IsFlippedStrand()) ? -1.0 : 1.0;
1692 
1693  // Javascript takes floor anyway so do it here - otherwise
1694  // we get rounding errors.
1695  TModelUnit x1 = floor(m_Context->SeqToScreenXInModelUnit(pos) * flip_sign);
1696 
1697  hinfo.SetPos(x1);
1700  m_ImageInfo->m_Hairlines.push_back(hinfo);
1701  }
1702  }
1703  return need_line;
1704 }
1705 
1706 
1708 {
1709  IRender& gl = GetGl();
1710 
1711  if ( !m_gConfig->GetShowHorzGrid() || !x_NeedSpecialGrid()) return;
1712 
1714  color.Darken(0.1f);
1715  gl.ColorC(color);
1716 
1717  ITERATE (TSelectedGlyphs, obj_iter, *m_SelCDSFeatures) {
1718  CWeakRef<CSeqGlyph>::TRefType glyph = obj_iter->Lock();
1719  const CFeatGlyph* feat =
1720  dynamic_cast<const CFeatGlyph*>(glyph.GetPointer());
1721  if ( !feat ) continue;
1722 
1723  TSeqRange range = feat->GetRange();
1724 
1725  // calculate grid spes for each CDS
1726  double length = range.GetTo() - range.GetFrom();
1727  // less than 3 bases, don't draw anything
1728  if (length < 2) continue;
1729 
1730  double logRange = log10(length);
1731  logRange = ceil(logRange) - 1;
1732  double step = pow(10.0, logRange);
1733 
1734  // selecting base_step as step divided by 1, 2 or 5
1735  double base_step = step;
1736  double tick_num = length / base_step;
1737  int i=0;
1738  while(tick_num < 8) {
1739  base_step = step / kSteps[i++];
1740  tick_num = length / base_step;
1741  }
1742 
1743  double min_cell = m_Context->ScreenToSeq(kMinCellSize);
1744  double max_cell = m_Context->ScreenToSeq(kMaxCellSize);
1745  int grid_step = (int)x_CalcGridStep(base_step, min_cell, max_cell);
1746  auto &visible_range = m_Context->GetVisibleRange();
1747 
1748  bool neg_strand = (sequence::GetStrand(feat->GetLocation()) == eNa_strand_minus);
1749  TModelPoint top_left;
1750  feat->GetPosInWorld(top_left);
1751 
1752  ITERATE (vector<TSeqRange>, iter, feat->GetIntervals()) {
1753  const TSeqRange& curr = *iter;
1754  TModelUnit f = curr.GetFrom();
1755  TModelUnit t = curr.GetTo();
1756 
1757  if (neg_strand) {
1758  int end = (int)floor(f - 1);
1759  for (i = (int)ceil(t); i >= end; i -= grid_step) {
1760  if (((i + 1) < visible_range.GetFrom()) || ((i + 1) > visible_range.GetTo()))
1761  continue;
1762  m_Context->DrawLine(i + 1, GetBottom(), i + 1, GetTop());
1763  }
1764  } else {
1765  int end = (int)ceil(t + 1);
1766  for (i = (int)floor(f); i <= end; i += grid_step) {
1767  if ((i < visible_range.GetFrom()) || (i > visible_range.GetTo()))
1768  continue;
1769  m_Context->DrawLine(i, GetBottom(), i, GetTop());
1770  }
1771  }
1772  } // ITERATE
1773  } // ITERATE
1774 }
1775 
1776 
1777 double CFeaturePanel::x_CalcGridStep(double base_step,
1778  double min_step,
1779  double max_step) const
1780 {
1781  if ((base_step >= min_step && base_step <= max_step) || (min_step == max_step))
1782  return base_step;
1783  else {
1784  // base_step has a form M * pow(10, P), where P is power
1785  double Power = log10(base_step);
1786  double P = ceil(Power) -1;
1787  double pow10P = pow(10.0, P);
1788  double M = base_step / pow10P;
1789  if (M >= 10) {
1790  M /= 10;
1791  pow10P *= 10;
1792  }
1793 
1794  int oldK = 1, K = 1, Index = 0;
1795  if(base_step < min_step) // reasing base_step to make it more then minPix
1796  {
1797  double minK = min_step / pow10P;
1798  while (K < minK)
1799  {
1800  if(Index <2)
1801  K = oldK * kSteps[Index++];
1802  else {
1803  K = oldK = oldK * 10;
1804  Index = 0;
1805  }
1806  }
1807  base_step = pow10P * K;
1808  } else if (base_step > max_step) { // decreasing base_step to make it less then maxPix
1809  pow10P *= 10;
1810  double maxK = pow10P / max_step;
1811  while (K < maxK)
1812  {
1813  if(Index <2)
1814  K = oldK * kSteps[Index++];
1815  else {
1816  K = oldK = oldK * 10;
1817  Index = 0;
1818  }
1819  }
1820  base_step = pow10P / K;
1821  }
1822  return base_step;
1823  }
1824 }
1825 
1826 
1828 {
1829  return find(m_DisplayLevels.begin(), m_DisplayLevels.end(), level)
1830  != m_DisplayLevels.end();
1831 }
1832 
1833 
1835 {
1836  TDisplayLevels::iterator iter =
1837  find(m_DisplayLevels.begin(), m_DisplayLevels.end(), level);
1838  if (show && iter == m_DisplayLevels.end()) {
1839  m_DisplayLevels.push_back(level);
1840  } else if (!show && iter != m_DisplayLevels.end()) {
1841  m_DisplayLevels.erase(iter);
1842  }
1843 }
1844 
1845 
1847  int id,
1848  const string& track_name,
1849  bool shown)
1850 {
1851  CRef<CTrackContainer> cont_track;
1852 
1853  const string& cont_key = CTrackContainerFactory::GetTypeInfo().GetId();
1854  const ILayoutTrackFactory* factory =
1855  GetConfigMgr()->GetTrackFactory(cont_key);
1856  if ( !factory ) return cont_track;
1857 
1858  // create track proxy for the track
1859  CRef<CTempTrackProxy> t_proxy(new CTempTrackProxy(id, track_name, shown));
1860 
1861  ILayoutTrackFactory::SExtraParams e_params(level, false, NULL);
1863  TTrackMap tracks = factory->CreateTracks(m_InputObj, m_DSContext,
1864  m_Context, e_params);
1865 
1866  CLayoutTrack* track = tracks.begin()->second;
1867  cont_track = dynamic_cast<CTrackContainer*>(track);
1868  cont_track->SetConfigMgr(GetConfigMgr());
1869  AddTracks(t_proxy, tracks);
1870 
1871  return cont_track;
1872 }
1873 
1874 
1875 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
#define false
Definition: bool.h:36
void remove_if(Container &c, Predicate *__pred)
Definition: chainer.hpp:69
CAnnotMetaDataJobResult.
CAppJobNotification Notification send by CAppJobEventTranslator.
bool GetAssemblies(const string &seqAcc, list< CRef< objects::CGC_Assembly > > &assAcc)
static CAssemblyCache & GetInstance()
void SetCategory(const string &category)
virtual void Update(bool layout_only)
Update content and layout including the bounding box.
Definition: data_track.cpp:52
void x_UpdateLayout()
Definition: data_track.hpp:127
virtual void SetRegistryPath(const string &path)
Definition: dialog.cpp:59
CExternalLayoutTrack – the layout track for holding and visualizing the external graphical views' vis...
virtual const objects::CSeq_loc & GetLocation(void) const
access the position of this object.
TModelUnit GetBarCenter() const
virtual TSeqRange GetRange(void) const
get the total range of this object.
virtual const TIntervals & GetIntervals(void) const
access sub-intervals (if any).
CFeaturePanelDSType.
CFeaturePanelDS.
void SetTMSContext(const string &tms_context)
void SetDSContext(ISGDataSourceContext *ds_context)
void GetAssemblies(const string &seqAcc)
void SetUseEUtils(bool use)
bool IsMetaDataJob(TJobID id) const
CFeaturePanelDS inline methods.
void SetAssembly(const string &assembly)
void SetRenderingContext(CRenderingContext *r_cntx)
const string & GetAssembly() const
void GetAnnotMetaData(const string &desc)
retrieve a list of annotations with their meta data.
void x_RenderFeatureGrid() const
void x_ConfigureSubtracks_Recursive(CTrackContainer *parent, const TTrackProxies &proxies, int level)
Create all the exsiting layout tracks.
CRegularGridGen m_Gen
graphical grid.
CIRef< ISGDataSourceContext > m_DSContext
void x_OnLayoutIconClicked()
void x_LoadSettings()
Load settings for feature panel.
void x_OnColorIconClicked()
virtual bool HitTestHor(TSeqPos x, const CObject *obj)
const TSelectedGlyphs * m_SelCDSFeatures
IServiceLocator * m_ServiceLocator
void SaveTrackConfig()
double x_CalcGridStep(double base_step, double min_step, double max_step) const
void x_RenderHairLineSelections() const
void x_ConfigureTracks(bool makeContainersVisible=false)
reset the track status to be ready for reconfiguring layout tracks.
vector< TLevel > TDisplayLevels
bool m_CgiMode
special flag indicating if it is in cgi mode.
void x_OnSizeIconClicked()
bool x_GetShowDisplayLevel(TLevel level) const
Only meaningful if Multilevel is true.
const TSelectedGlyphs * m_SelFeatures
void x_OnAssemblyLoaded(const list< CRef< objects::CGC_Assembly > > &assemblies)
string m_DefaultAssembly
CTrackContainer * x_ConfigureSubtracks(CTrackContainer *parent, const CTrackProxy *param, int level, const set< string > &usedFeatureSubkeys)
void x_SetShowDisplayLevel(TLevel level, bool show)
SConstScopedObject m_InputObj
set< string > GetAnnotNames()
bool x_NeedSpecialGrid() const
need show special grid for the selected cds features.
void SetInputObject(SConstScopedObject &obj)
vector< CRef< objects::CGC_Assembly > > m_Assemblies
virtual void x_Draw() const
The default renderer for this layout object.
virtual void x_OnIconClicked(TIconID id)
override method in CLayoutTrack to handle speical cases.
CRegularGridRenderer m_Grid
TAnnotMetaDataList m_NAData
CFeaturePanel(CRenderingContext *r_cntx, bool cgi_mode)
vector< CMappedFeatOrObject > m_search_results
static CTrackTypeInfo m_TypeInfo
bool m_IconTexInitialized
flag indicating whether icon textures have been created.
string GetCurrentAssembly() const
void x_OnDecorationIconClicked()
virtual void Update(bool layout_only)
Update content and layout including the bounding box.
virtual bool x_IsJobNeeded(CAppJobDispatcher::TJobID id) const
virtual CRef< CSeqGlyph > HitTest(const TModelPoint &p)
Hit testing.
void LoadDefaultTracks()
Reset tracks to the original default track list.
CMappedFeatOrObject FindText(const string &text, bool match_case)
virtual void OnTrackInitFinished(const CLayoutTrack *sender)
TImageInfo * m_ImageInfo
Information about image that can be returned to client.
CRef< CExternalLayoutTrack > m_ExtLayoutTrack
void SetExternalGlyphs(const CSeqGlyph::TObjects &objs)
virtual void x_GetTBRect(TModelRect &rect) const
Get title bar rectange exclude top margin.
void x_InitNATracks(bool makeContainersVisible)
virtual void x_RenderTitleBar() const
Method for rendering the track title bar.
void SetAssembly(const string &assembly)
void ShowTrack(const string &track_key)
Turn on an existing track.
void ShowConfigureTracksDlg(const string &category)
void SetTrackConfig(const TTrackSettingsSet &settings_set)
void x_OnLabelIconClicked()
@ eIcon_Color
color theme
@ eIcon_Size
size level
@ eIcon_Label
feature label position
@ eIcon_Decoration
feature decoration
CRef< CTrackContainer > x_CreateLevelTrack(int level, int id, const string &track_name, bool shown)
create track container for a given annotation level.
bool x_DrawHairLine(int opt, size_t total, const multiset< TSeqPos > &all_pos, TSeqPos pos, TModelUnit line_y) const
string m_ConfigKey
Base regitry key for panel setting and tracks default "GBPlugins.SeqGraphicFeatPanel" is for SV MSA s...
virtual void x_OnJobCompleted(CAppJobNotification &notify)
void ConfigureTracks()
virtual ~CFeaturePanel()
TDisplayLevels m_DisplayLevels
void x_SaveSettings()
Save settings for feature panel.
void x_StartAssemblyJob()
virtual void ResetSearch()
void SetNonAsnInput(const INonAsnTrackData &data)
list< TTrackSettings > TTrackSettingsSet
TTrackProxies m_TrackSettings
initial track layout settings.
list< CWeakRef< CSeqGlyph > > TSelectedGlyphs
virtual const CTrackTypeInfo & GetTypeInfo() const
virtual bool x_Empty() const
CAnnotMetaDataJobResult.
list< CRef< objects::CGC_Assembly > > m_Assemblies
class CGlPane
Definition: glpane.hpp:62
virtual void x_UpdateBoundingBox()
Update the bounding box assuming children's sizes are fixed if any.
virtual CRef< CSeqGlyph > HitTest(const TModelPoint &p)
Hit testing.
virtual bool HitTestHor(TSeqPos x, const CObject *obj)
void SetObjects(const CLayoutGroup::TObjectList &objs)
CLayoutGroup & SetGroup()
const CLayoutGroup::TObjectList & GetChildren() const
virtual void Update(bool layout_only)
Update content and layout including the bounding box.
const CLayoutGroup & GetGroup() const
CLayoutGroup::TObjectList & SetChildren()
CRef< CSimpleLayout > m_Simple
void SetLayoutPolicy(ILayoutPolicy *policy)
Set policy on how to deploy the layout of its children.
static const string kDecimalDot
Definition: registry.hpp:45
static CGuiRegistry & GetInstance()
access the application-wide singleton
Definition: registry.cpp:400
void UpdateLayout()
update group's bounding box only, and its parent layout.
File Description:
void SetTrackAttr(TTrackAttrFlags flags)
int m_IndentLevel
track hierachy indentation level.
void x_DeregisterIcon(TIconID id)
deregister an icon if already registered.
void SetShowTitle(bool flag)
void SetTitle(const string &label, const string &default_title=NcbiEmptyString)
@ eIcon_Content
icon id for setting content
@ eIcon_Layout
icon id for setting layout style
@ eIcon_Help
icon id for track help
bool GetShowTitle() const
static bool InitIconTextures()
initialize OpenGL ttexture objects for icons.
ILayoutTrackHost * m_LTHost
Top level host owning the tracks.
virtual void SetComments(const string &)
set comments.
bool m_ShowFrame
need to draw frame, not title
void x_OnLayoutChanged()
update the layout.
TTrackAttrFlags m_Attrs
various track attributes
virtual void x_RenderIcon(TIconID id, bool highlighted, bool lite_version=false) const
Render track icons.
TIcons m_Icons
registered icon info
void LoadProfile(const string &profile_str)
set track profile and load settings.
@ fFrameVisible
track frame will be rendered when triggered.
@ fShowAlways
always be rendered even for an empty track.
@ fFullTrack
track occupying the full horizontal screen.
@ fShowIcons
Track has control icons at the bottom.
const string & GetProfile() const
unsigned TTrackAttrFlags
bool x_HitTitleBar(const TModelPoint &p) const
hit the title bar?.
void SetMsg(const string &msg)
static void RegisterIconImage(const TIconAlias &key, const string &img_file)
register the image for an icon.
int m_HighlightedIcon
the highlighted icon index
CConstRef< CSeqGraphicConfig > x_GetGlobalConfig() const
Method for getting global configuration from rendering context.
void SetProfile(const string &preset_style)
CLayoutTrack inline method implmentation.
CRef< CSeqGraphicConfig > m_gConfig
global configuration.
int TIconID
use int as TIconID instead of EIconID.
virtual void SetHighlights(const string &)
string m_Id
track identifier
static void RegisterCommonIconImages()
register images for the common icons.
void x_RegisterIcon(const SIconInfo &icon)
register track icons.
static CNcbiApplication * Instance(void)
Singleton method.
Definition: ncbiapp.cpp:244
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
CNcbiRegistry –.
Definition: ncbireg.hpp:913
CObject –.
Definition: ncbiobj.hpp:180
class CRegistryReadView provides a nested hierarchical view at a particular key.
Definition: reg_view.hpp:58
bool GetBool(const string &key, bool default_val=false) const
Definition: reg_view.cpp:241
list< SKeyInfo > TKeys
retrieve information about all keys in the registry
Definition: reg_view.hpp:68
string GetString(const string &key, const string &default_val=kEmptyStr) const
Definition: reg_view.cpp:246
CConstRef< objects::CUser_field > GetField(const string &key) const
provide raw field access
Definition: reg_view.cpp:104
CRef< objects::CUser_field > SetField(const string &key)
provide raw field access
Definition: reg_view.cpp:502
void Set(const string &key, int val)
access a named key at this level, with no recursion
Definition: reg_view.cpp:533
bool DeleteField(const string &key)
delete the specified field (and any of its subfields) from this view and from its registry.
Definition: reg_view.cpp:523
CRegularGridGen.
CRegularGridRenderer.
CRenderingContext offers the basic context and utility methods for rendering layout objects in featur...
bool IsSkipGrid() const
bool IsHorizontal() const
void TextOut(const CGlTextureFont *font, const char *text, TModelUnit x, TModelUnit y, bool center, bool adjust_flip=true) const
TModelUnit GetVisibleFrom() const
const TSeqRange & GetVisSeqRange() const
CGlPane * GetGlPane()
inline method implementations
const TModelUnit & GetOffset() const
const TModelRange & GetVisibleRange() const
void SetSelectionColor(const CRgbaColor &c)
void DrawLine(TModelUnit x1, TModelUnit y1, TModelUnit x2, TModelUnit y2) const
TModelUnit GetVisibleTo() const
const TModelUnit & GetScale() const
bool IsSkipControls() const
TModelUnit SeqToScreen(const TModelUnit &size) const
convert from sequence positions to screen pixels
TModelUnit SeqToScreenXInModelUnit(const TModelUnit &size) const
TModelUnit ScreenToSeq(const TModelUnit &size) const
convert from screen pixels to sequence positions
bool IsFlippedStrand() const
void SetSelLabelColor(const CRgbaColor &c)
void DrawBackground(const TModelRect &rcm, TModelUnit border) const
void AdjustToOrientation(TModelUnit &x) const
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
static const string & DefTrackProfile()
static CRegistryReadView GetReadView(const CGuiRegistry &reg, const string &base_key, const string &curr_key, const string &def_key1="", const string &def_key2="", const string &def_key3="")
read/readwrite view creation helper methods.
static CRegistryWriteView GetWriteView(CGuiRegistry &reg, const string &base_key, const string &curr_key, const string &def_key1="", const string &def_key2="", const string &def_key3="")
static const string & LayoutKey()
static const string & TrackProfileKey()
static const string & UserSettingPrefix()
static const string & DefLayout()
bool IsJobNeeded(TJobID job_id) const
objects::CScope & GetScope(void) const
Get the scope from the handle.
void SetJobListener(CEventHandler *listener)
Set JobDispatcher listener.
objects::CBioseq_Handle & GetBioseqHandle(void)
Get the underlying bioseq handle.
void SetHighlightsColor(const CRgbaColor &hl_color)
Definition: seq_glyph.hpp:640
CRenderingContext * m_Context
the rendering context
Definition: seq_glyph.hpp:346
virtual void SetLeft(TModelUnit l)
Definition: seq_glyph.hpp:654
virtual TModelUnit GetTop() const
Definition: seq_glyph.hpp:599
virtual void Update(bool)
Update content and layout including the bounding box.
Definition: seq_glyph.cpp:86
virtual void SetTop(TModelUnit b)
Definition: seq_glyph.hpp:658
void Draw() const
render the layout.
Definition: seq_glyph.cpp:92
void GetPosInWorld(TModelPoint &pos) const
Get top left position in world coordinate.
Definition: seq_glyph.hpp:615
virtual TModelUnit GetBottom() const
Definition: seq_glyph.hpp:607
list< CRef< CSeqGlyph > > TObjects
Definition: seq_glyph.hpp:85
@ eDepth_nolimit
adaptive and no depth limitation,
@ eDepth_unknown
sequence-specific, up to app to decide
bool GetShowVertGrid() const
const CRgbaColor & GetSelectionColor() const
const string & GetLayout() const
const string & GetLabelPos() const
const string & GetSizeLevel() const
void SetLabelPos(const string &label_pos)
bool GetShowHorzGrid() const
void SetDecorateStyle(const string &style)
const CRgbaColor & GetVerticalGridColor() const
const CRgbaColor & GetSelHairlineDownColor() const
void SetTrackProfile(const string &profile)
const CRgbaColor & GetSelHairlineManyColor() const
void IgnoreFeatureStrand()
Set show feature strand indicator to false for all features.
void SetColorTheme(const string &theme)
bool GetShowDownwardHairlines() const
const string & GetDecorateStyle() const
const string & GetColorTheme() const
void LoadSettings()
update the cached settings.
const CRgbaColor & GetSelHairlineOneColor() const
int GetHairlineOption() const
void SaveSettings(bool clear_themes=false)
const CRgbaColor & GetSelLabelColor() const
const CRgbaColor & GetHorizontalGridColor() const
void SetSizeLevel(const string &size)
Simple class to represent hairlines drawn on top of seqgraphic images.
void SetPos(float pos)
void ShowDownwardHairline(bool b)
void SetBottomColor(const CRgbaColor &c)
class CStaticArrayMap<> provides access to a static array in much the same way as CStaticArraySet<>,...
Definition: static_map.hpp:175
File Description:
void SetShown(bool shown)
void SetCategory(const string &cat)
list< CRef< CTempTrackProxy > > TTrackProxies
bool GetShowTitle() const
const string & GetKey() const
const string & GetHighlightsColor() const
static void LoadFromRegistry(TTrackProxies &proxies, const string &path, bool isMergeWithExisting=false)
if isMergeWithExisting is true, then load should skip all registry tracks that have keys as in the al...
const string & GetHighlights() const
void SetSubcategory(const string &scat)
static void SaveToRegistry(const TTrackProxies &proxies, const string &path)
const TTrackProxies & GetChildren() const
const string & GetName() const
const string & GetComments() const
static void SetTrackConfig(TTrackProxies &t_settings, const TTrackSettingsSet &in_settings, int order_offset=0)
Reset the track configuration with input settings.
const ILayoutTrackFactory * GetTrackFactory(const string &key) const
static void GetUsedFeatureKeys(set< string > &subkeys, const TTrackProxies &proxies)
static const CTrackTypeInfo & GetTypeInfo()
CTrackContainer - a track container in the form of layout track.
virtual void x_OnJobCompleted(CAppJobNotification &notify)
void Traverse(Tr &&tr, bool visible)
virtual void x_UpdateData()
update track content.
ILayoutTrackFactory::TAnnotMetaDataList TAnnotMetaDataList
void AddTrackProxy(CTempTrackProxy *proxy, bool upgateMsg=true)
Add a track proxy.
virtual void DeleteAllJobs()
CTrackProxy * AddNewTrack(const string &track_key, const CTrackProxy::TAnnots &annots, const string &disp_name, const string &name="", const string &filter="", const string &sub_key="")
Add a new empty track proxy.
void SetAdaptive(bool flag)
CTrackConfigManager * GetConfigMgr()
void SetAnnotLevel(int level)
void ClearTracks()
Remove all tracks.
virtual void x_OnIconClicked(TIconID id)
override method in CLayoutTrack to handle speical cases.
void x_MakeTopLevelTracks(CGlyphContainer *featurePanel, TTrackProxies &dst_proxies, int &order, const string &base_name, int indent)
Make all the tracks at different levels as top-level tracks.
void x_UpdateMsg()
udpate message in track title bar.
void SyncSettings(TTrackProxies &dst_proxies, int level) const
synchronize and merge track settings.
void SetConfigMgr(CTrackConfigManager *cfg_mgr)
void AddTracks(CTempTrackProxy *t_proxy, TTrackMap &tracks)
add sub tracks after tracks get created.
CRef< CFeaturePanelDS > m_DS
virtual void SetTrack(CLayoutTrack *track, int order, bool shown=true)
Replace the track by the given track order.
virtual void x_ReinitSubtracks()
reinitialize all subtracks if necessary.
CTempTrackProxy::TTrackProxies TTrackProxies
TTrackProxies m_TrackProxies
all the tracks including on and off.
void SetSubtrackProxies(const TTrackProxies &proxies)
void InitNATracks(const TAnnotMetaDataList &annots, bool makeContainersVisible)
bool GetSkipGenuineCheck() const
CTrackProxy data structure contains information about the position of a track in its parent scope,...
CTrackTypeInfo - holds description of a layout track type.
const string & GetDescr() const
const string & GetId() const
CWeakRef –.
Definition: ncbiobj.hpp:2658
IIconProvider interface for tracks providing track icons.
virtual void RegisterIconImages() const =0
ILayoutTrackFactory.
virtual bool UnderstandLevel() const =0
Have any concept of level.
virtual TTrackMap CreateTracks(SConstScopedObject &object, ISGDataSourceContext *ds_context, CRenderingContext *r_cntx, const SExtraParams &params=SExtraParams(), const TAnnotMetaDataList &src_annots=TAnnotMetaDataList()) const =0
create layout tracks based on input object and extra parameters.
virtual bool NeedBackgroundInit() const =0
Background track initialization.
virtual void LTH_PopupMenu(wxMenu *menu)=0
show track-specific context menu.
File Description:
virtual const TIntervals & GetIntervals(void) const =0
access sub-intervals (if any).
vector< TSeqRange > TIntervals
const set< string > & GetAnnotsSnp()
const_iterator begin() const
Definition: map.hpp:151
bool empty() const
Definition: map.hpp:149
void clear()
Definition: map.hpp:169
iterator insert(const value_type &val)
Definition: set.hpp:300
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
bool empty() const
Definition: set.hpp:133
static CMemoryRegistry registry
Definition: cn3d_tools.cpp:81
#define _(proto)
Definition: ct_nlmzip_i.h:78
static unsigned char depth[2 *(256+1+29)+1]
USING_SCOPE(objects)
static const string k_multi_level
static const int kSteps[]
void s_StabilizeBaseContainers(CTempTrackProxy::TTrackProxies &proxies, CTempTrackProxy::TTrackProxies &defaultProxies)
static const int kMaxCellSize
static const int kLevelTrackBaseID
static const string k_display_level
static const int kMinCellSize
cell sizes for CDS grid
static const string kBaseKey("GBPlugins.SeqGraphicFeatPanel")
static const int kMaxDisplayLevel
maximal display level in multiple level layout.
CStaticArrayMap< string, CGeneModelConfig::EMergeStyle > TStyleMap
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define NULL
Definition: ncbistd.hpp:225
#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
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
#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
void Info(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1185
CIRef< T > GetServiceByType()
retrieves a typed reference to a service, the name of C++ type is used as the name of the service.
Definition: service.hpp:91
void Render(CGlPane *pAreaPane, CGlPane *pPane, CRegularGridGen *pGenerator) const
void SetShowVertGrid(bool f)
void SetShowHorzGrid(bool f)
void SetAutoStepUpdate(bool f)
void EnableMinusOneBased(bool en_x, bool en_y)
void SetIntegerMode(bool IntegerX, bool IntegerY)
CRegularGridGen inline methods.
void EnableIntegerCentering(bool b_en)
void SetHorzColor(const CRgbaColor &color)
void SetVertColor(const CRgbaColor &color)
virtual const TAnnots & GetAnnots() const =0
virtual const string & GetKey() const =0
virtual const string & GetSubcategory() const =0
virtual const string & GetDisplayName() const =0
virtual const string & GetSubkey() const =0
virtual const string & GetCategory() const =0
GLdouble TModelUnit
Definition: gltypes.hpp:48
virtual void Translatef(GLfloat x, GLfloat y, GLfloat z)=0
virtual void Enable(GLenum glstate)=0
void Init()
Definition: glrect.hpp:62
virtual void Begin(GLenum mode)=0
Start rendering.
T Top() const
Definition: glrect.hpp:84
virtual void BlendFunc(GLenum sfactor, GLenum dfactor)=0
Options to be used when GL_BLEND is enabled.
void Color3f(GLfloat r, GLfloat g, GLfloat b)
Definition: irender.hpp:95
T Bottom() const
Definition: glrect.hpp:82
T Width() const
Definition: glrect.hpp:86
IRender & GetGl()
convenience function for getting current render manager
T Right() const
Definition: glrect.hpp:83
TVPRect & GetViewport(void)
Definition: glpane.hpp:332
TModelUnit GetOffsetY() const
Definition: glpane.hpp:415
virtual void PopMatrix()=0
T Left() const
Definition: glrect.hpp:81
T Y() const
Definition: glpoint.hpp:60
virtual bool IsPrinterFriendly() const =0
virtual void End()=0
Finish rendering (create buffer and send to renderer)
void Inflate(T d_x, T d_y)
Definition: glrect.hpp:178
virtual void PolygonMode(GLenum face, GLenum mode)=0
Set the polygon rasterization mode.
void Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
Definition: irender.hpp:97
virtual TModelUnit TextWidth(const char *text) const
Compute and return font metrics.
virtual TModelUnit TextHeight(void) const
TModelRect & GetVisibleRect(void)
Definition: glpane.hpp:357
void Vertex2f(GLfloat x, GLfloat y)
Definition: irender.hpp:182
virtual void Disable(GLenum glstate)=0
glDisable()
virtual void LineWidth(GLfloat w)=0
Set line width for drawing: glLineWidth()
TModelUnit GetOffsetX() const
Definition: glpane.hpp:410
virtual void ColorC(const CRgbaColor &c)=0
Set current color (glColor{3,4}{f,d}{v,})
virtual void PushMatrix()=0
@ eOrtho
Definition: glpane.hpp:66
CRef< objects::CScope > scope
Definition: objects.hpp:53
CRef< CObject > GetResult() const
returns non-null pointer only if Completed or Running and has temporary results available
void Lighten(float scale)
Definition: rgba_color.cpp:463
CConstRef< CObject > object
Definition: objects.hpp:52
string GetSeqIdString(bool with_version=false) const
Return seqid string with optional version for text seqid type.
Definition: Seq_id.cpp:2144
CConstRef< CSeq_id > GetSeqIdOrNull(void) const
bool IsGi(void) const
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
ENa_strand GetStrand(const CSeq_loc &loc, CScope *scope=0)
Returns eNa_strand_unknown if multiple Bioseqs in loc Returns eNa_strand_other if multiple strands in...
vector< CSeq_id_Handle > TSeq_id_Handles
Bulk retrieval methods Common argument typedef - vector of requested ids.
Definition: scope.hpp:518
bool NotNull(void) const THROWS_NONE
Check if pointer is not null – same effect as NotEmpty().
Definition: ncbiobj.hpp:744
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
TRefType Lock(void) const
Lock the object and return reference to it.
Definition: ncbiobj.hpp:2713
TObjectType * GetPointerOrNull(void) const THROWS_NONE
Get pointer value.
Definition: ncbiobj.hpp:1672
virtual bool GetBool(const string &section, const string &name, bool default_value, TFlags flags=0, EErrAction err_action=eThrow) const
Get boolean value of specified parameter name.
Definition: ncbireg.cpp:391
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3457
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
Definition: ncbistr.cpp:3197
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5084
static CStringUTF8 AsUTF8(const CTempString &src, EEncoding encoding, EValidate validate=eNoValidate)
Convert into UTF8 from a C/C++ string.
Definition: ncbistr.hpp:3889
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 & ToLower(string &str)
Convert string to lower case – string& version.
Definition: ncbistr.cpp:405
@ eEncoding_Ascii
Definition: ncbistr.hpp:202
@ fSplit_Tokenize
All delimiters are merged and trimmed, to get non-empty tokens only.
Definition: ncbistr.hpp:2508
TTo GetTo(void) const
Get the To member data.
Definition: Range_.hpp:269
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
void SetData(TData &value)
Assign a value to Data data member.
bool IsLocal(void) const
Check if variant Local is selected.
Definition: Seq_id_.hpp:775
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
n background color
static int input()
int i
#define P(a, b, c, d, k, s, t)
static void text(MDB_val *v)
Definition: mdb_dump.c:62
static MDB_envinfo info
Definition: mdb_load.c:37
#define wxT(x)
Definition: muParser.cpp:41
void GatherFeatures(const string &text, bool match_case, objects::CBioseq_Handle bsh, objects::CScope &scope, CFeaturePanel *panel, vector< CMappedFeatOrObject > &search_results)
range(_Ty, _Ty) -> range< _Ty >
unsigned int a
Definition: ncbi_localip.c:102
EIPRangeType t
Definition: ncbi_localip.c:101
Defines: CTimeFormat - storage class for time format.
T log10(T x_)
Int4 delta(size_t dimension_, const Int4 *score_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
#define K
static const char * str(char *buf, int n)
Definition: stats.c:84
A help struct for storing information about a icon.
static bool s_CompareCRefs(const CRef< CTempTrackProxy > &t1, const CRef< CTempTrackProxy > &t2)
extra parameter for initializing a track.
string m_RemotePath
Track remote path.
set< string > m_UsedFeatureSubkeys
Already used feature track subkeys To be used by CAllOtherFeaturesTrack container.
bool m_SkipGenuineCheck
Flag indicating if track verification is required.
TSubTracks m_SubTracks
List of subTracks.
#define _ASSERT
else result
Definition: token2.c:20
void UseDefaultMarginWidth(wxMenu &menu)
Using default menu item margin width.
Definition: wx_utils.cpp:693
wxString ToWxString(const string &s)
Definition: wx_utils.hpp:173
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Fri Mar 01 10:07:44 2024 by modify_doxy.py rev. 669887