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

Go to the SVN repository for this file.

1 #ifndef __GUI_WIDGETS_ALNMULTI___ALIGN_ROW__HPP
2 #define __GUI_WIDGETS_ALNMULTI___ALIGN_ROW__HPP
3 
4 /* $Id: align_row.hpp 45569 2020-09-10 14:44:41Z 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: Andrey Yazhuk, Anatoliy Kuznetsov, Andrei Shkeda, Victor Joukov
30  *
31  * File Description:
32  *
33  */
34 
36 
39 
43 
47 
49 
50 
51 class CScoreCache;
52 class IAlnVecRowGraph;
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 /// CAlnRowState - implements state management for Align Row
57 ///
58 
60 {
61 public:
62  CAlnRowState();
63 
64  virtual int GetRowState() const;
65  virtual void SetRowState(int mask, bool b_set);
66 
67 private:
69 };
70 
71 ////////////////////////////////////////////////////////////////////////////////
72 /// class CAlnVecRow - implementation of IAlignRow for CAlnVec-based alignments.
73 /// CAlnVecRow uses CAlnVecRowHandle as proxy for accesing data in CAlnVec.
74 
76  public CObjectEx,
77  public CEventHandler,
78  public ILayoutTrackHost,
79  public ITrackHandlerHost, ///< for layout track interaction
80  public IGenericHandlerHost,
81  public CAlnRowState
82 {
83 public:
85 
86 public:
87  CAlnVecRow(const IAlignRowHandle& handle);// , bool skip_label = false);
88  ~CAlnVecRow();
89 
90  void SetConsensus(CConsensusRow* crow) { m_ConsensusRow = crow; }
91 
92  /// @name IAlignRow implementation
93  /// @{
94  virtual void SetHost(IAlignRowHost* host);
95 
96  virtual void SetDisplayStyle(const CRowDisplayStyle* style);
97  virtual const CRowDisplayStyle* GetDisplayStyle();
98 
99  virtual int GetRowNum() const;
100  virtual int GetHeightPixels() const;
101 
102  virtual void RenderColumn(TColumnType col_type);
103  virtual void OnMouseEvent(wxMouseEvent& event, TColumnType col_type, CGlPane& pane);
104 
105  /// returns tooltip text by point in the viewport coordinates
106  virtual void GetTooltip(const TVPPoint& vp_pt, TColumnType col_type, CGlPane& pane, ITooltipFormatter& tooltip);
107 
108  virtual void GetHTMLActiveAreas(TColumnType col_type, CGlPane& pane, TAreaVector& areas);
109 
110  virtual void UpdateOnStyleChanged();
111  virtual void UpdateOnAnchorChanged();
112  virtual void Update(const CGlPane& pane, bool layout_only = false);
113 
114  virtual void PrepareRendering(CGlPane& pane, TVPUnit row_top, int state);
115  /// @}
116 
117  virtual void SetScoreCache(CScoreCache* cache);
118 
119  virtual bool IsExpandable() const;
120  virtual bool IsExpanded() const;
121  virtual void Expand(bool b_exp, CGlPane& pane);
122  virtual void UseExternalOrganismLookup(bool f);
123 
124  // MSA methods
125  // ad-hoc method for correct synchronous layout of graphs
126  virtual string GetAlignmentTooltip(TSeqPos pos, TSeqPos half_width);
127  //
128 
129  virtual const IAlnRowGraphProperties* GetProperties() const;
130  virtual void SetProperties(IAlnRowGraphProperties* props);
131 
132  virtual TSeqPos GetColumnAsSeqPos(TColumnType type, const TModelRect& rc_vis) const;
133  virtual string& GetColumnText(TColumnType col_type, string& text, bool for_printer = false) const;
134  virtual float GetColumnAsFloat(TColumnType type) const;
135 
136 
137  virtual string& GetAlnSeqString(string &buffer, const IAlnExplorer::TSignedRange &aln_rng) const;
138  virtual string& GetStringAtPos(string& buffer, TSignedSeqPos aln_pos) const;
139 
140  virtual void GetRowStatistics(ITooltipFormatter& tooltip) const;
141 
142  virtual bool UsesAATranslation() const;
143  virtual bool IsNucProtAlignment() const;
144 
145  const IAlignRowHandle& GetRowHandle() const;
146 
147  // ILayoutTrackHost implementation
148  virtual void LTH_OnLayoutChanged();
149  virtual void LTH_ZoomOnRange(const TSeqRange &range) {}
150  virtual void LTH_PopupMenu(wxMenu *menu);
151  virtual void LTH_PushEventHandler(wxEvtHandler *handler);
152  virtual void LTH_PopEventHandler();
153  virtual void LTH_ConfigureTracksDlg(const string& category);
154 
155  /// @name class ITrackHandlerHost implementation
156  /// @{
157  virtual CRef<CLayoutTrack> THH_GetLayoutTrack();
158  virtual TModelPoint THH_GetModelByWindow(const wxPoint& pt);
159  /// @}
160 
161  /// @name class IGenericHandlerHost implementation
162  virtual void GHH_Redraw();
163  virtual void GHH_SetCursor(const wxCursor &cursor);
164  virtual void GHH_CaptureMouse();
165  virtual void GHH_ReleaseMouse();
166  /// @}
167 
168 
169  void SaveTrackConfig();
170 
171  void LoadDefaultTracks();
172  void ConfigureTracks(bool reset = false);
173  void ConfigureTracksDialog(const string& category = NcbiEmptyString);
174 
175  size_t GetTrackCount(CGlPane& pane);
176 
177  void GetTaxonomy(string& taxonomy) const;
178 
179 protected:
181 
182  enum EButtons {
183  eInvalid = -1,
186  eSetupGraphs
187  };
188  typedef CScoreCache::TScoreColl::const_iterator TScoreConstIterator;
189 
190  virtual int x_GetBaseHeight() const;
191 
192  virtual void x_RenderDescr();
193  virtual void x_RenderAlign();
194  virtual void x_RenderIcons();
195  virtual void x_RenderIconStrand();
196  virtual void x_RenderIconExpand();
197  virtual void x_RenderEmptyBox();
198 
199  virtual void x_RenderInserts(CGlPane& pane, int from, int to,
200  TModelUnit top_y, TModelUnit bottom_y);
201  virtual void x_RenderUnaligned(CGlPane& pane, int from, int to,
202  TModelUnit top_y, TModelUnit bottom_y);
203  virtual void x_RenderAlignSegments(CGlPane& pane, IAlnSegmentIterator& it_seg,
204  TModelUnit top_y, TModelUnit bottom_y,
205  const CRgbaColor& color);
206  virtual void x_RenderAlignScores(IAlnSegmentIterator& it_seg,
207  int top_y, int bottom_y, bool averageable);
208  virtual void x_RenderAveragableScores(CGlPane& pane,
209  IAlnSegmentIterator& it_seg,
211  const TScoreConstIterator it_end,
212  int vp_top_y, int vp_bottom_y);
213 
214  virtual void x_RenderNonAveragableScores(CGlPane& pane,
215  IAlnSegmentIterator& it_seg,
217  const TScoreConstIterator it_end,
218  int vp_top_y, int vp_bottom_y);
219  virtual bool x_CanRenderSeq(CGlPane& pane);
220  virtual void x_RenderSequence(CGlPane& pane, TModelUnit top_y, TModelUnit bottom_y,
221  int start, int stop);
222  virtual void x_RenderGraph(const TSignedRange& range);
223 
224  virtual void x_RenderAlnPos(TSeqPos aln_pos, IAlnExplorer::ESearchDirection dir);
225  virtual void x_RenderTextCell(const string& text, IGlFont::TAlign align);
226  virtual TVPRect x_GetButtonRect(EButtons btn, int shift=1);
227  virtual EButtons x_HitTestButton(CGlPane& pane, const TVPPoint& pt);
228  virtual void x_OnClickExpandBtn(CGlPane& pane);
229 
230  virtual void x_GetDescrTooltip (const TVPPoint& pt, CGlPane& pane, ITooltipFormatter& tooltip);
231  virtual void x_GetIconsTooltip (const TVPPoint& pt, CGlPane& pane, ITooltipFormatter& tooltip);
232  virtual void x_GetAlignmentTooltip(const TVPPoint& pt, CGlPane& pane, ITooltipFormatter& tooltip);
233 
234  void x_GetAlnPosLabel(TSeqPos aln_pos, IAlnExplorer::ESearchDirection dir, string& label) const;
235 
236  void x_GetAlignmentTooltip_Helper(TSeqPos pos, TSignedRange& range, ITooltipFormatter& tooltip);
237  void x_GetAlignmentTooltip_General(TSeqPos pos, ITooltipFormatter& tooltip);
238  //void x_GetAlignmentTooltip_General(const TSeqPos pos, ITooltipFormatter& tooltip);
239  void x_GetAlignmentTooltip_Insert(const TSignedSeqRange& aln_r,
240  const TSignedSeqRange& seq_r,
241  ITooltipFormatter& tooltip);
242  void x_GetAlignmentTooltip_Gap(const TSignedSeqRange& aln_r,
243  const TSignedSeqRange& seq_r,
244  ITooltipFormatter& tooltip);
245  void x_GetAlignmentTooltip_Unaligned(TSignedSeqPos aln_prev_to,
246  TSignedSeqPos aln_from,
247  TSignedSeqPos prev_to,
248  TSignedSeqPos from,
249  ITooltipFormatter& tooltip);
250  string x_GetTooltipSequence(TSeqPos from, TSeqPos to);
251 
252  IAlignRowHost* x_GetHost() { return m_Host; }
253 
254  void x_OnGraphContentChanged(CEvent* evt);
255  void x_OnGraphSizeChanged(CEvent* evt);
256 
257  virtual void x_UpdateRowHeight();
258 
259  virtual void x_CreateTrackPanel(CGlPane& pane);
260  virtual void x_ResetTrackPanel();
261  bool x_InitTrackPane(const CGlPane& row_pane, CGlPane& track_pane);
262  void x_RenderTracks(CGlPane& pane, const TSignedRange& range);
263  CRef<CSeqGlyph> x_HitTest(const TVPPoint& vp_pt, CGlPane& pane, TModelPoint& hit_point);
264  void x_ForEachAlnSeg(const IAlnExplorer::TSignedRange& range,
265  const CGlPane& src_pane,
266  CGlPane& target_pane,
267  const function <bool(CGlPane& pane)>& f);
268 protected:
270 
272 
274 
275  int m_Height;
277  //string m_Text;
278  //mutable int m_TaxId;
279  //mutable bool m_fTaxLabelInit;
280  //mutable string m_TaxLabel;
281 
284 
285  const CRowDisplayStyle* m_Style; /// row display style
286 
288 
289  unique_ptr<CRenderingContext> m_RenderingCtx;
290  unique_ptr<CRenderingContext> m_SequenceRenderingCtx;
291  unique_ptr<CGlPane> m_TrackPane;
293  bool m_NeedUpdateContent = false;
294  bool m_NeedUpdateLayout = false;
295  bool m_NeedUpdateSelection = false;
297  //CWeakRef<CSeqGlyph> m_LastHitGlyph;
299 
300  /// Graphics caching
301  TVPUnit m_PixLeft, m_PixRight;
302  TModelUnit m_ModelLeft, m_ModelRight;
303 };
304 
305 
306 inline
308 {
309  return m_Handle;
310 }
311 
312 
314 
315 #endif // __GUI_WIDGETS_ALNMULTI___ALIGN_ROW__HPP
ncbi::TMaskedQueryRegions mask
CAlnRowState - implements state management for Align Row.
Definition: align_row.hpp:60
class CAlnVecRow - implementation of IAlignRow for CAlnVec-based alignments.
Definition: align_row.hpp:82
const CRowDisplayStyle * m_Style
Definition: align_row.hpp:285
const IAlignRowHandle & m_Handle
Definition: align_row.hpp:269
const IAlignRowHandle & GetRowHandle() const
Definition: align_row.hpp:307
int m_BaseHeight
Definition: align_row.hpp:276
CScoreCache::TScoreColl::const_iterator TScoreConstIterator
Definition: align_row.hpp:188
void SetConsensus(CConsensusRow *crow)
Definition: align_row.hpp:90
CRef< CFeaturePanel > m_TrackPanel
Definition: align_row.hpp:292
AutoPtr< CLayoutTrackHandler > m_TrackHandler
Definition: align_row.hpp:296
unique_ptr< CGlPane > m_TrackPane
Definition: align_row.hpp:291
virtual void LTH_ZoomOnRange(const TSeqRange &range)
notifies the host we need to zoom on to a range.
Definition: align_row.hpp:149
unique_ptr< CRenderingContext > m_RenderingCtx
Definition: align_row.hpp:289
IAlignRowHost * m_Host
Definition: align_row.hpp:273
bool m_bExpanded
Definition: align_row.hpp:282
CWeakRef< CLayoutTrack > m_LastHitTrack
Definition: align_row.hpp:298
IAlignRowHost * x_GetHost()
Definition: align_row.hpp:252
bool m_fExtOrgLookup
Definition: align_row.hpp:283
TModelUnit m_ModelRight
Definition: align_row.hpp:302
IAlnExplorer::TSignedRange TSignedRange
Definition: align_row.hpp:84
CConsensusRow * m_ConsensusRow
Definition: align_row.hpp:271
CScoreCache * m_Cache
row display style
Definition: align_row.hpp:287
unique_ptr< CRenderingContext > m_SequenceRenderingCtx
Definition: align_row.hpp:290
TVPUnit m_PixRight
Definition: align_row.hpp:301
Class CConsensusRow - Simple interface to a row that represents the consensus for rendering purposes.
CEventHandler.
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
class CGlPane
Definition: glpane.hpp:62
CObjectEx –.
Definition: ncbiobj.hpp:2531
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
CRowDisplayStyle is a base class representing a display style for IAlignRow.
IAlignRowHandle provides an abstract way to access alignment row data.
Definition: alnmulti_ds.hpp:59
IAlignRowHost represents a context in which IAlignRow lives.
Definition: ialign_row.hpp:192
Interface IAlignRow - abstracts row rendering in Multiple Alignment Widget.
Definition: ialign_row.hpp:67
virtual int GetRowNum() const =0
Returns index of row in IAlnMultiDataSource.
virtual bool UsesAATranslation() const =0
virtual void UpdateOnAnchorChanged()
Definition: ialign_row.hpp:148
virtual string & GetColumnText(TColumnType col_type, string &text, bool for_printer=false) const =0
virtual void GetTooltip(const TVPPoint &pt, TColumnType col_type, CGlPane &pane, ITooltipFormatter &tooltip)=0
virtual TSeqPos GetColumnAsSeqPos(TColumnType type, const TModelRect &rc_vis) const =0
virtual string & GetAlnSeqString(string &buffer, const IAlnExplorer::TSignedRange &aln_rng) const =0
virtual void SetHost(IAlignRowHost *pHost)=0
virtual const CRowDisplayStyle * GetDisplayStyle()=0
virtual void GetHTMLActiveAreas(TColumnType col_type, CGlPane &pane, TAreaVector &areas)=0
virtual void RenderColumn(TColumnType col_type)=0
Renders a row cell corresponding to column specified by "col_type".
virtual float GetColumnAsFloat(TColumnType type) const =0
virtual string & GetStringAtPos(string &buffer, TSignedSeqPos aln_pos) const =0
virtual int GetRowState() const =0
Returns row state (combination of EState flags)
virtual void SetRowState(int mask, bool b_set)=0
Set/Clear Row State.
virtual void SetDisplayStyle(const CRowDisplayStyle *style)=0
virtual void OnMouseEvent(wxMouseEvent &event, TColumnType col_type, CGlPane &pane)=0
virtual void GetRowStatistics(ITooltipFormatter &tooltip) const =0
virtual void UpdateOnStyleChanged()=0
virtual int GetHeightPixels() const =0
Returns height of the row in pixels.
virtual void Update(const CGlPane &pane, bool layout_only=false)
Definition: ialign_row.hpp:149
virtual void PrepareRendering(CGlPane &pane, TVPUnit row_top, int state)=0
virtual bool IsNucProtAlignment() const =0
ESearchDirection
Position search options.
IAlnRowGraphProperties.
Alignment segment iterator interface.
IAlnVecRowGraph - abstract graph that can be rendered in the "expandable" space below the CAlnVecRow.
IGenericHandlerHost.
ILayoutTrackHost An interface used for handling GUI-related events, such as layout change event that ...
primitive interface to arrange tabular data in the tooltips
Definition: tooltip.hpp:55
ITrackHandlerHost ITrackHandlerHost represents a context for handling the user interactions on a layo...
void(*)(CSeq_entry_Handle seh, IWorkbench *wb, const CSerialObject &obj) handler
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
int TSignedSeqPos
Type for signed sequence position.
Definition: ncbimisc.hpp:887
GLdouble TModelUnit
Definition: gltypes.hpp:48
int TVPUnit
Definition: gltypes.hpp:47
int TAlign
Definition: glfont.hpp:113
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NcbiEmptyString
Definition: ncbistr.hpp:122
#define NCBI_GUIWIDGETS_ALNMULTIPLE_EXPORT
Definition: gui_export.h:520
static const char label[]
n background color
static void text(MDB_val *v)
Definition: mdb_dump.c:62
range(_Ty, _Ty) -> range< _Ty >
double f(double x_, const double &y_)
Definition: njn_root.hpp:188
static pcre_uint8 * buffer
Definition: pcretest.c:1051
Definition: type.c:6
Modified on Wed Feb 28 07:13:08 2024 by modify_doxy.py rev. 669887