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

Go to the SVN repository for this file.

1 /* $Id: vis_range_glyph.cpp 41823 2018-10-17 17:34:58Z katargir $
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  * File Description:
29  * CVisRangeGlyph -- utility class to layout visible ranges of the
30  * sibling views
31  */
32 
33 #include <ncbi_pch.hpp>
36 #include <gui/opengl/irender.hpp>
37 #include <gui/objutils/tooltip.hpp>
38 
39 
41 
43 
45 
47  const list<TSeqRange>& vis_ranges,
48  const CRgbaColor& color,
49  const string& label)
50  : m_Target(target)
51  , m_Color(color)
52  , m_Label(label)
53 {
54  if ( !vis_ranges.empty() ) {
55  TSeqRange r = vis_ranges.front();
56  m_Location.Reset(new CSeq_loc());
57  m_Location->SetInt().SetFrom(r.GetFrom());
58  m_Location->SetInt().SetTo (r.GetTo());
59  } else {
60  _ASSERT(false);
61  NCBI_THROW(CException, eUnknown, "Empty visible range.");
62  }
63 }
64 
65 
67 {
68  return m_Location->GetTotalRange();
69 }
70 
71 
72 bool CVisRangeGlyph::NeedTooltip(const TModelPoint& p, ITooltipFormatter& tt, string& t_title) const
73 {
74  GetTooltip(p, tt, t_title);
75  return true;
76 }
77 
78 
79 void CVisRangeGlyph::GetTooltip(const TModelPoint& /*p*/, ITooltipFormatter& tt, string& /*t_title*/) const
80 {
81  tt.AddRow(m_Label);
82 }
83 
84 
86 {
87  return false;
88 }
89 
90 
92 {
93  IRender& gl = GetGl();
94 
95  TModelRect rcm = GetModelRect();
96  gl.ColorC(m_Color);
97  m_Context->DrawQuad(rcm);
98 }
99 
100 
102 {
103  SetLeft(GetRange().GetFrom());
106 }
107 
108 
CEventHandler.
void DrawQuad(const TModelRect &rc, bool border=false) const
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
CRenderingContext * m_Context
the rendering context
Definition: seq_glyph.hpp:346
virtual void SetHeight(TModelUnit h)
Definition: seq_glyph.hpp:650
virtual void SetWidth(TModelUnit w)
Definition: seq_glyph.hpp:646
virtual void SetLeft(TModelUnit l)
Definition: seq_glyph.hpp:654
TModelRect GetModelRect() const
get the bounding box.
Definition: seq_glyph.hpp:562
virtual TSeqRange GetRange(void) const
get the total range of this object.
virtual void x_UpdateBoundingBox()
Update the bounding box assuming children's sizes are fixed if any.
CVisRangeGlyph(const CEventHandler *target, const list< TSeqRange > &vis_ranges, const CRgbaColor &color, const string &label)
virtual bool NeedTooltip(const TModelPoint &p, ITooltipFormatter &tt, string &t_title) const
Check if need to show tooltip.
CRef< objects::CSeq_loc > m_Location
CRgbaColor m_Color
virtual void x_Draw() const
The default renderer for this layout object.
virtual void GetTooltip(const TModelPoint &p, ITooltipFormatter &tt, string &t_title) const
Get the tooltip if available.
virtual bool IsClickable() const
Query if this glyph is clickable.
primitive interface to arrange tabular data in the tooltips
Definition: tooltip.hpp:55
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
GLdouble TModelUnit
Definition: gltypes.hpp:48
IRender & GetGl()
convenience function for getting current render manager
virtual void ColorC(const CRgbaColor &c)=0
Set current color (glColor{3,4}{f,d}{v,})
virtual void AddRow(const string &sContents="", unsigned colspan=2)=0
add a row with a cell, spanning across all columns
TSeqPos GetLength(const CSeq_id &id, CScope *scope)
Get sequence length if scope not null, else return max possible TSeqPos.
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static const char label[]
n background color
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
#define _ASSERT
USING_SCOPE(objects)
TModelUnit kVisRangeBarHeight
Modified on Tue Apr 23 07:38:34 2024 by modify_doxy.py rev. 669887