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

Go to the SVN repository for this file.

1 #ifndef GUI_GRAPH___LEGEND__HPP
2 #define GUI_GRAPH___LEGEND__HPP
3 
4 /* $Id: legend.hpp 15168 2007-10-15 19:11:34Z dicuccio $
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
30  *
31  * File Description:
32  *
33  */
34 
36 
37 #include <gui/graph/igraph.hpp>
39 
40 /** @addtogroup GUI_GRAPH
41  *
42  * @{
43  */
44 
46 
47 ///////////////////////////////////////////////////////////////////////////////
48 /// ILegendDataSource
49 
51 {
52 public:
53  virtual bool ShowMarkers() = 0;
54  virtual IStringArray* GetLabelArray() = 0;
55  virtual IColorArray* GetColorArray() = 0;
56  virtual INumericArray* GetMarkerArray() = 0;
57 };
58 
59 ///////////////////////////////////////////////////////////////////////////////
60 /// class CLegend
61 
63 {
64 public:
65  CLegend();
66  virtual ~CLegend();
67 
68  void SetBackColor(const CRgbaColor& Color);
69  const CRgbaColor& GetBackColor() const;
70 
71  void SetBorderColor(const CRgbaColor& Color);
72  const CRgbaColor& GetBorderColor();
73 
74  // IGraph implementation
75  virtual bool SetDataSource(IGraphDataSource* pDS);
76  virtual const TModelRect& GetLimits() const;
77  virtual void Render(CGlPane* pViewport, TElemVector* elems = NULL);
78 
79 protected:
81  { return dynamic_cast<ILegendDataSource*>(m_pDataSource); };
82  virtual void CalculateLimits();
83 
84  virtual void x_RenderItems(CGlPane* pPane);
85  virtual void x_RenderItem(int X, int Y, const string& sLabel, const CRgbaColor& Color, int iMarker);
86 protected:
88 
91 
92  bool m_bHorz; // horizontal layout
93  int m_Space;
94  int m_BoxW, m_BoxH;
95 };
96 
97 ///////////////////////////////////////////////////////////////////////////////
98 /// class CLegendDataSource
99 
101  : public CSeriesBase, public ILegendDataSource
102 {
103 public:
104  CLegendDataSource(int Length, bool bShowMarkers = true)
105  : CSeriesBase(Length), m_bShowMarkers(bShowMarkers) {}
106  // Data Manipulation interface
107 
108  // ILegendDataSource implementation
109  virtual bool ShowMarkers() { return m_bShowMarkers; }
110  virtual IStringArray* GetLabelArray() { return x_GetStringArray(0); }
111  virtual IColorArray* GetColorArray() { return x_GetColorArray(1); }
112  virtual INumericArray* GetMarkerArray() { return x_GetNumericArray(2); }
113 
114 protected:
118 
120 public:
124 
125  TStrCont& GetLabelContainer() { return dynamic_cast<TStrAdapter*>(GetArray(0))->GetContainer(); }
126  TColorCont& GetColorContainer() { return dynamic_cast<TColorAdapter*>(GetArray(1))->GetContainer(); }
127  TEnumCont& GetMarkerContainer() { return dynamic_cast<TEnumAdapter*>(GetArray(2))->GetContainer(); }
128 
129  virtual void CreateArrays();
130 };
131 
133 
134 #endif
class CGlPane
Definition: glpane.hpp:62
CGraphBase.
Definition: igraph.hpp:99
class CLegendDataSource
Definition: legend.hpp:102
class CLegend
Definition: legend.hpp:63
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
class CSeriesBase CSeries represents a set of colinear IDataArrays and provides basic access and mana...
class CTypedArrayAdapter<Type, TBase>
Definition: svg.hpp:122
IGraphDataSource.
Definition: igraph.hpp:55
ILegendDataSource.
Definition: legend.hpp:51
class ITypedDataArray<Type>
Definition: igraph_data.hpp:90
#define NULL
Definition: ncbistd.hpp:225
virtual IColorArray * GetColorArray()=0
virtual IColorArray * GetColorArray()
Definition: legend.hpp:111
virtual bool ShowMarkers()
Definition: legend.hpp:109
TStrCont & GetLabelContainer()
Definition: legend.hpp:125
int m_Space
Definition: legend.hpp:93
vector< SGraphElem * > TElemVector
Definition: igraph.hpp:72
CTypedArrayAdapter< IDataArray::eString > TStrAdapter
Definition: legend.hpp:115
CTypedArrayAdapter< IDataArray::eNumeric, int > TEnumAdapter
Definition: legend.hpp:117
bool m_bHorz
Definition: legend.hpp:92
virtual const TModelRect & GetLimits() const
Definition: igraph.cpp:73
CGlBitmapFont m_Font
Definition: legend.hpp:87
TEnumAdapter::TCont TEnumCont
Definition: legend.hpp:123
CRgbaColor m_BorderColor
Definition: legend.hpp:90
TColorCont & GetColorContainer()
Definition: legend.hpp:126
int m_BoxW
Definition: legend.hpp:94
virtual INumericArray * GetMarkerArray()=0
IGraphDataSource * m_pDataSource
Definition: igraph.hpp:122
virtual IStringArray * GetLabelArray()
Definition: legend.hpp:110
virtual void Render(CGlPane *pPane, TElemVector *elems=NULL)=0
Definition: igraph.cpp:78
CRgbaColor m_BackColor
Definition: legend.hpp:89
vector< TBase > TCont
TEnumCont & GetMarkerContainer()
Definition: legend.hpp:127
CLegendDataSource(int Length, bool bShowMarkers=true)
Definition: legend.hpp:104
TColorAdapter::TCont TColorCont
Definition: legend.hpp:122
TStrAdapter::TCont TStrCont
Definition: legend.hpp:121
virtual IStringArray * GetLabelArray()=0
virtual void CalculateLimits()=0
virtual bool ShowMarkers()=0
CTypedArrayAdapter< IDataArray::eColor > TColorAdapter
Definition: legend.hpp:116
virtual bool SetDataSource(IGraphDataSource *pDS)
Definition: igraph.cpp:61
ILegendDataSource * GetLegendDataSource()
Definition: legend.hpp:80
virtual INumericArray * GetMarkerArray()
Definition: legend.hpp:112
#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_GUIGRAPH_EXPORT
Definition: gui_export.h:510
Modified on Wed Jun 19 17:02:18 2024 by modify_doxy.py rev. 669887