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 35413 2016-05-04 17:51:26Z 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  * 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/glrender.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  CGlRender& 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 
virtual void SetWidth(TModelUnit w)
Definition: seq_glyph.hpp:580
CRenderingContext * m_Context
the rendering context
Definition: seq_glyph.hpp:310
const string color[]
Definition: showalign.cpp:95
virtual void x_UpdateBoundingBox()
Update the bounding box assuming children's sizes are fixed if any.
virtual void ColorC(const CRgbaColor &color)
Definition: glrender.cpp:325
GLdouble TModelUnit
Definition: gltypes.hpp:48
void DrawQuad(const TModelRect &rc, bool border=false) const
virtual void SetHeight(TModelUnit h)
Definition: seq_glyph.hpp:584
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
USING_SCOPE(objects)
virtual void GetTooltip(const TModelPoint &p, ITooltipFormatter &tt, string &t_title) const
Get the tooltip if available.
CGlRender.
Definition: glrender.hpp:186
virtual void SetLeft(TModelUnit l)
Definition: seq_glyph.hpp:588
CRef< objects::CSeq_loc > m_Location
primitive interface to arrange tabular data in the tooltips
Definition: tooltip.hpp:54
position_type GetTo(void) const
Definition: range.hpp:142
position_type GetFrom(void) const
Definition: range.hpp:134
CException –.
Definition: ncbiexpt.hpp:709
TModelUnit kVisRangeBarHeight
CRgbaColor m_Color
virtual bool NeedTooltip(const TModelPoint &p, ITooltipFormatter &tt, string &t_title) const
Check if need to show tooltip.
virtual TSeqRange GetRange(void) const
get the total range of this object.
virtual void x_Draw() const
The default renderer for this layout object.
CEventHandler.
#define _ASSERT
virtual bool IsClickable() const
Query if this glyph is clickable.
#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:546
virtual void AddRow(const string &sContents="", unsigned colspan=2)=0
add a row with a cell, spanning across all columns
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
CVisRangeGlyph(const CEventHandler *target, const list< TSeqRange > &vis_ranges, const CRgbaColor &color, const string &label)
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:57
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:756
TModelRect GetModelRect() const
get the bounding box.
Definition: seq_glyph.hpp:518
TSeqPos GetLength(const CSeq_id &id, CScope *scope)
Get sequence length if scope not null, else return max possible TSeqPos.
CGlRender & GetGl()
convenience function for getting current render manager
Definition: glrender.cpp:49
Modified on Sun Aug 28 17:59:52 2016 by modify_doxy.py rev. 506947