NCBI C++ ToolKit
graph_track.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_SEQ_GRAPHIC___GRAPH_TRACK__HPP
2 #define GUI_WIDGETS_SEQ_GRAPHIC___GRAPH_TRACK__HPP
3 
4 /* $Id: graph_track.hpp 37640 2017-01-31 18:24:42Z shkeda $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Liangshou Wu
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbiobj.hpp>
36 #include <gui/utils/extension.hpp>
41 
42 
44 
45 //class CSGGraphDS;
46 
47 ///////////////////////////////////////////////////////////////////////////////
48 /// CGraphTrack --
49 ///
50 
52  public CDataTrack,
53  public ILegendProvider,
54  public IDroppable
55 {
56  friend class CGraphTrackFactory;
57 
58 public:
59  enum ELayout
60  {
61  eLayout_Layered, // typical mode: all children histograms are stacked
62  eLayout_Overlay, // Histograms are overlayed
63  eLayout_Overlayed // Histograms are overlayed and the whole track is a part of graph overlay
64  };
65 
66  static const string kOverlayed;
67 
69  virtual ~CGraphTrack();
70 
71  /// @name CLayoutTrack public methods.
72  /// @{
73  virtual const CTrackTypeInfo& GetTypeInfo() const;
74  /// @}
75 
76 
77  /// @name ILegendProvide methods.
78  /// @{
79  virtual void GetLegend(const CTempTrackProxy* track_proxy, objects::CTrackConfig::TLegend& legend) const;
80  /// @}
81 
83  virtual CConstRef<CSGGenBankDS> GetDataSource() const;
84 
85  virtual void GetHTMLActiveAreas(TAreaVector* p_areas) const;
86  virtual CHTMLActiveArea* InitHTMLActiveArea(TAreaVector* p_areas) const;
87 
88  void SetAnnot(const string& annot);
89  const string& GetAnnot() const;
90 
91  void SetLayout(ELayout layout);
92 
93  /// @name IDroppable virtual methods overloading.
94  /// @{
95  virtual bool CanDrop(CRef<CLayoutTrack>& track);
96  virtual bool Drop(CRef<CLayoutTrack>& track);
97  /// @}
98 
99 protected:
100  /// @name CLayoutTrack virtual methods overloading.
101  /// @{
102  virtual void x_LoadSettings(const string& preset_style,
103  const TKeyValuePairs& settings);
104 
105  /// save part of settings to a profile string.
106  /// Only the potential settings changed by users will be saved.
107  virtual void x_SaveSettings(const string& preset_style);
108 
109  virtual void x_OnIconClicked(TIconID id);
110 
111  virtual void x_OnLayoutChanged();
112 
113  /// @}
114 
115  /// @name CDataTrack pure virtual interfaces
116  /// @{
117  virtual void x_UpdateData();
118  virtual void x_OnJobCompleted(CAppJobNotification& notify);
119 
120  /// @}
121 
122  /// @name CGlyphContainerpure virtual interfaces
123  /// @{
124  virtual void x_UpdateBoundingBox();
125  virtual void x_RenderContent() const;
126  /// @}
127 
128 
129  objects::SAnnotSelector& x_GetAnnotSelector();
130  CSGGraphDS& x_GetGraphDS();
131 
132  bool CreateOverlay(vector<CRef<CGraphTrack>>& tracks);
133 
134  static CNetICacheClient s_InitICache();
135  static CNetICacheClient& s_GetICacheInstance();
136 
137 private:
138  /// @name prohibited copy constructor and assignment operator.
139  /// @{
142  /// @}
143 
144  void x_OnSettingsIconClicked();
145  void x_InitGrid();
146  void x_CollectAllGraphs(vector<CRef<CHistogramGlyph>>& graphs) const;
147 
148 private:
149  string m_AnnotName;
151  objects::SAnnotSelector m_Sel;
152 
153  /// Dynamic or fixed graph scale.
154  /// By default, the graph scale is a dynamic value which
155  /// is updated within the visible range.
157  /// Graph y limits stored when FixedScale is set
159 
161 
163  static ELayout x_LayoutStrToValue(const string& layout);
164  static string x_LayoutValueToStr(ELayout layout);
165 
167 };
168 
169 ///////////////////////////////////////////////////////////////////////////////
170 /// CGraphTrackFactory
171 ///
173  public CObject,
174  public ILayoutTrackFactory,
175  public ITrackConfigurable,
176  public IExtension
177 {
178 public:
180 
181  /// create a layout track based on the input objects and extra parameters.
182  virtual TTrackMap CreateTracks(
183  SConstScopedObject& object,
184  ISGDataSourceContext* ds_context,
185  CRenderingContext* r_cntx,
186  const SExtraParams& params = SExtraParams(),
187  const TAnnotMetaDataList& src_annots = TAnnotMetaDataList()) const;
188 
189  virtual void GetMatchedAnnots(
190  const TAnnotMetaDataList& src_annots,
191  const ILayoutTrackFactory::SExtraParams& params,
192  TAnnotNameTitleMap& out_annots) const;
193 
194  virtual bool UnderstandLevel() const
195  { return true; }
196 
197  virtual bool NeedBackgroundInit() const
198  { return true; }
199 
200  virtual const CTrackTypeInfo& GetThisTypeInfo() const
201  { return GetTypeInfo(); }
202 
203  static const CTrackTypeInfo& GetTypeInfo()
204  { return CGraphTrack::m_TypeInfo; }
205 
206  /// @name ITrackConfigurable interface implementation
207  /// @{
209  GetSettings(const string& profile,
210  const TKeyValuePairs& settings,
211  const CTempTrackProxy* track_proxy) const;
212  /// @}
213 
214  /// @name IExtension interface implementation
215  /// @{
216  virtual string GetExtensionIdentifier() const;
217  virtual string GetExtensionLabel() const;
218  /// @}
219 };
220 
221 inline
222 const string& CGraphTrack::GetAnnot() const
223 {
224  return m_AnnotName;
225 }
226 
227 inline
228 objects::SAnnotSelector& CGraphTrack::x_GetAnnotSelector()
229 {
230  return m_Sel;
231 }
232 
233 
235 {
236  return *m_DS;
237 }
238 
239 
241 
242 #endif // GUI_WIDGETS_SEQ_GRAPHIC___GRAPH_TRACK__HPP
CAppJobNotification Notification send by CAppJobEventTranslator.
CConstRef –.
Definition: ncbiobj.hpp:1266
CDataTrack - a abstract base class for layout tracks which need to deal with background data retrieva...
Definition: data_track.hpp:55
virtual CRef< CSGGenBankDS > GetDataSource()=0
Method for accessing the data source.
virtual void x_UpdateData()=0
update track content.
virtual void x_OnJobCompleted(CAppJobNotification &notify)=0
virtual void x_UpdateBoundingBox()
Update the bounding box assuming children's sizes are fixed if any.
virtual void x_RenderContent() const
The content rendering must be implemented in the derived layout tracks.
virtual void GetHTMLActiveAreas(TAreaVector *p_areas) const
Get html active areas.
virtual const CTrackTypeInfo & GetTypeInfo() const
CGraphTrackFactory.
virtual bool NeedBackgroundInit() const
Background track initialization.
static const CTrackTypeInfo & GetTypeInfo()
virtual bool UnderstandLevel() const
Have any concept of level.
virtual const CTrackTypeInfo & GetThisTypeInfo() const
CGraphTrack –.
Definition: graph_track.hpp:55
objects::SAnnotSelector m_Sel
CSGGraphDS & x_GetGraphDS()
string m_AnnotName
CGraphTrack & operator=(const CGraphTrack &)
static const string kOverlayed
Definition: graph_track.hpp:66
bool m_FixedScale
Dynamic or fixed graph scale.
const string & GetAnnot() const
CRef< CHistogramGlyph > m_Grid
ELayout m_Layout
objects::SAnnotSelector & x_GetAnnotSelector()
CSGGraphDS::TAxisLimits m_YLimits
Graph y limits stored when FixedScale is set.
CRef< CSGGraphDS > m_DS
static CTrackTypeInfo m_TypeInfo
CGraphTrack(const CGraphTrack &)
virtual void x_SaveSettings(const string &preset_style)
save the track settings to a profile string.
virtual void x_LoadSettings(const string &preset_style, const TKeyValuePairs &settings)
load the track settings.
void x_OnLayoutChanged()
update the layout.
virtual void x_OnIconClicked(TIconID id)
Mouse left-click event handler on an icon.
int TIconID
use int as TIconID instead of EIconID.
virtual CHTMLActiveArea * InitHTMLActiveArea(TAreaVector *p_areas) const
Initialize the HTML active area for a track.
Client to NetCache server (implements ICache interface)
CObject –.
Definition: ncbiobj.hpp:180
CRef –.
Definition: ncbiobj.hpp:618
CRenderingContext offers the basic context and utility methods for rendering layout objects in featur...
vector< CHTMLActiveArea > TAreaVector
Definition: seq_glyph.hpp:84
File Description:
CTrackTypeInfo - holds description of a layout track type.
IDroppable The interface for tracks that support drag&drop.
virtual bool Drop(CRef< CLayoutTrack > &track)=0
virtual bool CanDrop(CRef< CLayoutTrack > &track)=0
IExtension IExtension interface represents an abstract pluggable component.
Definition: extension.hpp:57
ILayoutTrackFactory.
ILegendProvider interface for tracks that are have legend This is currently for sviewer (cgi) purpose...
virtual void GetLegend(const CTempTrackProxy *track_proxy, objects::CTrackConfig::TLegend &legend) const =0
ISGDSManager is seqgraphic data source manage that serves as an data source context.
ITrackConfigurable interface for tracks that are configurable.
#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 NCBI_GUIWIDGETS_SEQGRAPHIC_EXPORT
Definition: gui_export.h:536
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
NetCache ICache client specs.
static SAnnotSelector x_GetAnnotSelector()
Definition: objcoords.cpp:1129
extra parameter for initializing a track.
Modified on Fri Sep 20 14:57:06 2024 by modify_doxy.py rev. 669887