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

Go to the SVN repository for this file.

1 /*
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: Andrei Shkeda
27  *
28  * File Description:
29  */
30 
31 #include <ncbi_pch.hpp>
33 
34 #include <gui/opengl/irender.hpp>
36 
39 
40 static const int kLegendBarWidth = 30;
41 static const int kLegendLabelGap = 5;
42 
43 
44 CLegendItemGlyph::CLegendItemGlyph(const string& source_name, const string& label, const string& id,
45  const CRgbaColor& legend_color, const CRgbaColor& text_color)
46  : m_SourceName(source_name)
47  , m_Label(label)
48  , m_Id(id)
49  , m_LegendColor(legend_color)
50  , m_TextColor(text_color)
51 {
52 }
53 
55 {
56  if (!m_LHost)
57  return false;
59  return true;
60 }
61 
62 bool CLegendItemGlyph::OnContextMenu(wxContextMenuEvent&)
63 {
64  if (!m_LHost)
65  return false;
67  return true;
68 }
69 
71 {
72  CHTMLActiveArea area;
73 
74  TVPUnit x1 = GetLeft();
75  TVPUnit x2 = GetRight();
76  TModelUnit t_x = 0;
77  TModelUnit t_y = 0;
78  x_Local2World(t_x, t_y);
79  // Round y values to nearest integer and add 2 to the height
80  // to give some space around the glyph
81  TVPUnit y1 = TVPUnit(floor(t_y + 0.5));
82  TVPUnit y2 = TVPUnit(floor(t_y + GetHeight() + 2.5));
83  area.m_Bounds.Init(x1, y2, x2, y1);
89  area.m_ID = m_Id;
90  area.m_Signature = m_Label;
92  p_areas->push_back(area);
93 
94 }
95 
97 {
98  IRender& gl = GetGl();
100  TModelUnit x1 = GetLeft();
102  m_Context->DrawQuad(x1, GetTop(), x2, GetBottom());
104  //_ASSERT(m_gConfig);
105  //if (!m_gConfig)
106  //return;
109 
110  _ASSERT(font);
111  if (!font)
112  return;
113  gl.ColorC(m_TextColor);
114  m_Context->TextOut (&*font, m_Label.c_str(), x2, GetBottom(), false);
115 };
116 
117 
118 
119 
@ fNoTooltip
do not request and show tooltip
@ fNoPin
tooltip is not pinnable
@ fNoSelection
the object can't be selected
string m_Color
optional area color (used for legen items)
string m_ID
area identifier
int m_Flags
area flags, will need to replace m_Type
ILegendHost * m_LHost
CConstRef< CSeqGraphicConfig > m_gConfig
virtual void GetHTMLActiveAreas(TAreaVector *p_ares) const
Get html active areas.
CLegendItemGlyph(const string &source_name, const string &label, const string &id, const CRgbaColor &legend_color, const CRgbaColor &text_color)
virtual bool OnLeftDblClick(const TModelPoint &)
virtual bool OnContextMenu(wxContextMenuEvent &)
virtual void x_Draw() const
The default renderer for this layout object.
void TextOut(const CGlTextureFont *font, const char *text, TModelUnit x, TModelUnit y, bool center, bool adjust_flip=true) const
TSeqPos GetVisSeqTo() const
void DrawQuad(const TModelRect &rc, bool border=false) const
TModelUnit ScreenToSeq(const TModelUnit &size) const
convert from screen pixels to sequence positions
TSeqPos GetVisSeqFrom() 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 TModelUnit GetRight() const
Definition: seq_glyph.hpp:603
virtual TModelUnit GetTop() const
Definition: seq_glyph.hpp:599
virtual TModelUnit GetHeight() const
Definition: seq_glyph.hpp:587
void x_Local2World(TModelPoint &p) const
Transform the coordiantes from local coord. to world coord.
Definition: seq_glyph.hpp:726
virtual TModelUnit GetLeft() const
Definition: seq_glyph.hpp:595
vector< CHTMLActiveArea > TAreaVector
Definition: seq_glyph.hpp:84
virtual TModelUnit GetBottom() const
Definition: seq_glyph.hpp:607
CRef< CGlTextureFont > GetLabelFont() const
virtual void LH_OnItemDblClick(const string &source_name)=0
notifies the host about changes of the track.
virtual void LH_OnItemRightClick(const string &source_name)=0
notifies the host about changes of the track.
GLdouble TModelUnit
Definition: gltypes.hpp:48
void Init()
Definition: glrect.hpp:62
IRender & GetGl()
convenience function for getting current render manager
int TVPUnit
Definition: gltypes.hpp:47
virtual void ColorC(const CRgbaColor &c)=0
Set current color (glColor{3,4}{f,d}{v,})
string ToString(bool printAlpha=true, bool uchars=true) const
Return a string representation of the current color.
Definition: rgba_color.cpp:309
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
Definition: ncbiobj.hpp:2015
TThisType & Set(position_type from, position_type to)
Definition: range.hpp:188
#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[]
USING_SCOPE(objects)
static const int kLegendBarWidth
static const int kLegendLabelGap
#define _ASSERT
Modified on Mon Feb 26 04:02:43 2024 by modify_doxy.py rev. 669887