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

Go to the SVN repository for this file.

1 /* $Id: ld_track.cpp 46174 2021-01-28 02:26:06Z 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: Melvin Quintos
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
44 
45 #include <gui/utils/rgba_color.hpp>
46 #include <gui/objutils/utils.hpp>
47 #include <gui/objutils/label.hpp>
48 
49 #include <objmgr/util/feature.hpp>
50 #include <objmgr/util/sequence.hpp>
51 #include <objmgr/annot_ci.hpp>
52 
54 
55 #include <wx/menu.h>
56 
59 
60 ///////////////////////////////////////////////////////////////////////////////
61 /// CLDBlockTrack
62 ///////////////////////////////////////////////////////////////////////////////
63 
64 CTrackTypeInfo CLDBlockTrack::m_TypeInfo("SNP_LDBlock_track",
65  "Graphical View LD Block Track");
66 
68  : CDataTrack(r_cntx)
69  , m_DS(ds)
70  , m_IconFilter(eIcon_Settings, "Filters", true, "track_settings")
71 {
72  m_DS->SetJobListener(this);
73  m_Params.filterScore = 0.0;
77 }
78 
79 
81 {
82  if ( !m_DS->AllJobsFinished() ) {
84  }
85 }
86 
88 {
89  static double kNPP_Cutoff= 50; // Nucliotides per pixel cutoff for SNP Overview
90  return (m_Context->GetScale() > kNPP_Cutoff);
91 }
92 
93 /// @name CLayoutTrack reimplemented methods.
94 /// @{
96 {
97  return m_TypeInfo;
98 }
99 
101 {
102  bool bIsLayoutOnlyChange = true;
103 
104  if (id == eIcon_Settings) {
105  // create structure
106  CLDFilterParams param;
107  int lenExp = m_Params.filterLength;
108  lenExp = (lenExp<1) ? 0 : (int)log10((float)lenExp);
109 
110  param.SetScore((int)(m_Params.filterScore*100));
111  param.SetLengthExp(lenExp);
112 
113  // load current settings
114  CLDFilterDialog dlg(NULL);
115  dlg.SetData(param);
116 
117  // do dialog window
118  if (dlg.ShowModal() == wxID_OK) {
119  // save settings
120  const CLDFilterParams &p = dlg.GetData();
121  float lenPow = pow(10.0f, p.GetLengthExp());
122  m_Params.filterLength = (int)lenPow;
123  m_Params.filterScore = p.GetScore()/100.0f;
124  bIsLayoutOnlyChange = false;
125  }
126  } else {
127  // use default handlers
129  }
130 
131  Update(bIsLayoutOnlyChange);
133 }
134 /// @}
135 
136 
137 /// @name CDataTrack pure virtual interfaces
138 /// @{
139 
141 {
142  bool bShowLabels = (m_eLayout == eLayout_Labels);
143  m_DS->DeleteAllJobs();
145 
150  m_Params.preferFeats = bShowLabels; // fetch features if we show labels.
151 
153 }
154 
155 
157 {
158  m_DS->ClearJobID(notify.GetJobID());
159  CRef<CObject> res_obj = notify.GetResult();
160  CSGJobResult* result = dynamic_cast<CSGJobResult*>(&*res_obj);
161  if (!result) {
162  ERR_POST("CLDBlockTrack::x_OnJobCompleted() notification for job \
163  does not contain results.");
164  return;
165  }
166 
167  SetMsg("");
169 }
170 
171 /// @}
172 
174 {
175  const CSeqGlyph::TObjects& objs = result.m_ObjectList;
176 
177  m_Group.Clear();
178 
179  if (objs.empty()) {
180  Update(true);
182  return;
183  }
184 
187 
188  ITERATE(CSeqGlyph::TObjects, it, objs) {
189  CSeqGlyph* glyph = const_cast<CSeqGlyph*> (it->GetPointer());
190 
191  if (typeid(*glyph) == typeid(CHistogramGlyph)) {
192  CHistogramGlyph *hist = dynamic_cast<CHistogramGlyph*> (glyph);
193  hist->SetConfig(*x_GetGlobalConfig());
194  }
195  else {
196  CGlyphContainer* track = dynamic_cast<CGlyphContainer*> (glyph);
197  track->SetConfig(m_gConfig);
198  track->SetLayoutPolicy(m_Inline);
199  //track->SetIndent(m_IndentLevel + 1);
200  track->SetTrackAttr(attrib);
201  }
202 
203  Add(glyph);
204  }
205 
206  Update(true);
208 }
209 
210 
211 
212 ///////////////////////////////////////////////////////////////////////////////
213 /// CLDBlockTrackFactory
214 ///////////////////////////////////////////////////////////////////////////////
217  ISGDataSourceContext* ds_context,
218  CRenderingContext* r_cntx,
219  const SExtraParams& params,
220  const TAnnotMetaDataList& src_annots) const
221 {
222  TTrackMap tracks;
223 
224  TAnnotNameTitleMap annots;
225  if (params.m_SkipGenuineCheck && !params.m_Annots.empty()) {
226  ITERATE (SExtraParams::TAnnots, iter, params.m_Annots) {
227  annots.insert(TAnnotNameTitleMap::value_type(*iter, ""));
228  }
229  } else {
230 
231  CLDBlockDS::GetTrackNames(object, annots, r_cntx->GetVisSeqRange(), params);
232  if ( !src_annots.empty() ) {
233  GetMatchedAnnots(src_annots, params, annots);
234  }
235  }
236 
237  // create feature tracks
238  ITERATE (TAnnotNameTitleMap, iter, annots) {
239  // Create a new DS object for each track
240  CIRef<ISGDataSource> pre_ds = ds_context->GetDS(typeid(CLDBlockDSType).name(),
241  object);
242  CLDBlockDS* seq_ds = dynamic_cast<CLDBlockDS*>(pre_ds.GetPointer());
243  seq_ds->SetDepth(params.m_Level);
244  seq_ds->SetAdaptive(params.m_Adaptive);
245  seq_ds->SetName(iter->first);
246  CRef<CLDBlockTrack> track(new CLDBlockTrack(seq_ds, r_cntx));
247  if ( !iter->second.empty() ) {
248  track->SetTitle(iter->second);
249  }
250  tracks[iter->first] = track.GetPointer();
251  }
252 
253  return tracks;
254 }
255 
257  const TAnnotMetaDataList& src_annots,
258  const ILayoutTrackFactory::SExtraParams& params,
259  TAnnotNameTitleMap& out_annots) const
260 {
261  ILayoutTrackFactory::GetMatchedAnnots(src_annots, params.m_Annots, "ftable", "HapMapLDBlock", out_annots);
262 }
263 
264 
266 {
268 }
269 
271 {
273 }
274 
275 
CAppJobNotification Notification send by CAppJobEventTranslator.
CDataTrack - a abstract base class for layout tracks which need to deal with background data retrieva...
Definition: data_track.hpp:55
virtual void Update(bool layout_only)
Update content and layout including the bounding box.
Definition: data_track.cpp:52
File Description:
void Add(CSeqGlyph *obj)
Append a layout object to the end.
CRef< CInlineLayout > m_Inline
CRef< CSimpleLayout > m_Simple
void SetLayoutPolicy(ILayoutPolicy *policy)
Set policy on how to deploy the layout of its children.
void SetConfig(const CSeqGraphicConfig &config)
void SetName(const string &)
Definition: ld_ds.cpp:228
void LoadData(const SParams &param)
Definition: ld_ds.cpp:233
static void GetTrackNames(SConstScopedObject &object, TAnnotNameTitleMap &names, const TSeqRange &range, const ILayoutTrackFactory::SExtraParams &params)
Definition: ld_ds.cpp:204
virtual TTrackMap CreateTracks(SConstScopedObject &object, ISGDataSourceContext *ds_context, CRenderingContext *r_cntx, const SExtraParams &params=SExtraParams(), const TAnnotMetaDataList &src_annots=TAnnotMetaDataList()) const
CLDBlockTrackFactory.
Definition: ld_track.cpp:216
virtual void GetMatchedAnnots(const TAnnotMetaDataList &src_annots, const ILayoutTrackFactory::SExtraParams &params, TAnnotNameTitleMap &out_annots) const
Definition: ld_track.cpp:256
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
Definition: ld_track.cpp:265
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" )
Definition: ld_track.cpp:270
CLDBlockDS::SParams m_Params
Definition: ld_track.hpp:104
bool x_IsOverviewMode() const
Definition: ld_track.cpp:87
@ eLayout_Labels
Show labels and cascade features (CLayeredLayoutPolicy)
Definition: ld_track.hpp:98
virtual void x_UpdateData()
update track content.
Definition: ld_track.cpp:140
virtual void x_OnJobCompleted(CAppJobNotification &notify)
Definition: ld_track.cpp:156
virtual void x_OnIconClicked(TIconID id)
Mouse left-click event handler on an icon.
Definition: ld_track.cpp:100
static CTrackTypeInfo m_TypeInfo
CLDBlockTrack.
Definition: ld_track.hpp:110
CRef< CLDBlockDS > m_DS
Definition: ld_track.hpp:103
virtual const CTrackTypeInfo & GetTypeInfo() const
Definition: ld_track.cpp:95
CLDBlockTrack(CLDBlockDS *ds, CRenderingContext *r_cntx)
Definition: ld_track.cpp:67
virtual ~CLDBlockTrack()
Definition: ld_track.cpp:80
SIconInfo m_IconFilter
Definition: ld_track.hpp:107
void x_CreateLayout(const CSGJobResult &result)
Definition: ld_track.cpp:173
CLDFilterParams & GetData()
Data access.
void SetData(const CLDFilterParams &data)
void SetScore(int value)
void SetLengthExp(int value)
int GetLengthExp() const
int GetScore() const
void SetTrackAttr(TTrackAttrFlags flags)
@ eIcon_Settings
icon id for track settings
void x_OnLayoutChanged()
update the layout.
void SetConfig(CRef< CSeqGraphicConfig > conf)
virtual void x_OnIconClicked(TIconID id)
Mouse left-click event handler on an icon.
@ fFullTrack
track occupying the full horizontal screen.
unsigned TTrackAttrFlags
void SetMsg(const string &msg)
CConstRef< CSeqGraphicConfig > x_GetGlobalConfig() const
Method for getting global configuration from rendering context.
CRef< CSeqGraphicConfig > m_gConfig
global configuration.
int TIconID
use int as TIconID instead of EIconID.
void x_RegisterIcon(const SIconInfo &icon)
register track icons.
CRenderingContext offers the basic context and utility methods for rendering layout objects in featur...
const TSeqRange & GetVisSeqRange() const
const TModelUnit & GetScale() const
virtual bool AllJobsFinished() const
void SetJobListener(CEventHandler *listener)
Set JobDispatcher listener.
virtual void ClearJobID(TJobID job_id)
void SetDepth(int depth)
Set the annotation selector resolving depth.
virtual void DeleteAllJobs()
Remove waiting jobs from queue or cancel the unfinished jobs.
void SetAdaptive(bool flag)
CSGJobResult – the data structure holding the seqgraphic job results.
class CSeqGlyph defines an interface that wraps a rectilinear abstract object.
Definition: seq_glyph.hpp:82
CRenderingContext * m_Context
the rendering context
Definition: seq_glyph.hpp:346
const CRenderingContext * GetRenderingContext() const
Get the rendering context.
Definition: seq_glyph.hpp:690
list< CRef< CSeqGlyph > > TObjects
Definition: seq_glyph.hpp:85
CTrackTypeInfo - holds description of a layout track type.
const string & GetDescr() const
const string & GetId() const
static void GetMatchedAnnots(const TAnnotMetaDataList &src_annots, const vector< string > &target_annots, const string &annot_type, const string &track_type, TAnnotNameTitleMap &out_annots)
Help function to find matched annotations.
ISGDSManager is seqgraphic data source manage that serves as an data source context.
virtual CIRef< ISGDataSource > GetDS(const string &type, SConstScopedObject &object)=0
Get a seqgraphic data source instance of the specified type.
iterator_bool insert(const value_type &val)
Definition: map.hpp:165
bool empty() const
Definition: map.hpp:149
#define true
Definition: bool.h:35
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
Definition: ncbidiag.hpp:186
CRef< CObject > GetResult() const
returns non-null pointer only if Completed or Running and has temporary results available
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
USING_SCOPE(objects)
T log10(T x_)
TSeqRange range
Definition: ld_ds.hpp:66
CRenderingContext * r_cntx
Definition: ld_ds.hpp:65
TModelUnit scale
Definition: ld_ds.hpp:67
extra parameter for initializing a track.
bool m_Adaptive
Adaptive/Exact selector.
TAnnots m_Annots
particular annotations the track will be looking at.
int m_Level
layout level that limits feature retrieving used by annotation selector.
bool m_SkipGenuineCheck
Flag indicating if track verification is required.
else result
Definition: token2.c:20
Modified on Tue Apr 16 20:12:37 2024 by modify_doxy.py rev. 669887