📄 legend.hpp
字号:
/* * =========================================================================== * PRODUCTION $Log: legend.hpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 19:48:18 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7 * PRODUCTION * =========================================================================== */#ifndef GUI_GRAPH___LEGEND__HPP#define GUI_GRAPH___LEGEND__HPP/* $Id: legend.hpp,v 1000.1 2004/06/01 19:48:18 gouriano Exp $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors: Andrey Yazhuk * * File Description: * */#include <gui/opengl/glbitmapfont.hpp>#include <gui/graph/igraph.hpp>#include <gui/graph/igraph_data.hpp>/** @addtogroup GUI_GRAPH * * @{ */BEGIN_NCBI_SCOPE////////////////////////////////////////////////////////////////////////////////// ILegendDataSourceclass ILegendDataSource : public IGraphDataSource{public: virtual bool ShowMarkers() = 0; virtual IStringArray* GetLabelArray() = 0; virtual IColorArray* GetColorArray() = 0; virtual INumericArray* GetMarkerArray() = 0; };////////////////////////////////////////////////////////////////////////////////// class CLegendclass NCBI_GUIGRAPH_EXPORT CLegend : public CGraphBase{public: CLegend(); virtual ~CLegend(); void SetBackColor(const CGlColor& Color); const CGlColor& GetBackColor() const; void SetBorderColor(const CGlColor& Color); const CGlColor& GetBorderColor(); // IGraph implementation virtual bool SetDataSource(IGraphDataSource* pDS); virtual const TModelRect& GetLimits() const; virtual void Render(CGlPane* pViewport);protected: ILegendDataSource* GetLegendDataSource() { return dynamic_cast<ILegendDataSource*>(m_pDataSource); }; virtual void CalculateLimits(); virtual void x_RenderItems(CGlPane* pPane); virtual void x_RenderItem(int X, int Y, const string& sLabel, const CGlColor& Color, int iMarker);protected: CGlBitmapFont m_Font; CGlColor m_BackColor; CGlColor m_BorderColor; bool m_bHorz; // horizontal layout int m_Space; int m_BoxW, m_BoxH;};////////////////////////////////////////////////////////////////////////////////// class CLegendDataSourceclass NCBI_GUIGRAPH_EXPORT CLegendDataSource : public CSeriesBase, public ILegendDataSource{public: CLegendDataSource(int Length, bool bShowMarkers = true) : CSeriesBase(Length), m_bShowMarkers(bShowMarkers) {} // Data Manipulation interface // ILegendDataSource implementation virtual bool ShowMarkers() { return m_bShowMarkers; } virtual IStringArray* GetLabelArray() { return x_GetStringArray(0); } virtual IColorArray* GetColorArray() { return x_GetColorArray(1); } virtual INumericArray* GetMarkerArray() { return x_GetNumericArray(2); }protected: typedef CTypedArrayAdapter<IDataArray::eString> TStrAdapter; typedef CTypedArrayAdapter<IDataArray::eColor> TColorAdapter; typedef CTypedArrayAdapter<IDataArray::eNumeric, int> TEnumAdapter; bool m_bShowMarkers;public: typedef TStrAdapter::TCont TStrCont; typedef TColorAdapter::TCont TColorCont; typedef TEnumAdapter::TCont TEnumCont; TStrCont& GetLabelContainer() { return dynamic_cast<TStrAdapter*>(GetArray(0))->GetContainer(); } TColorCont& GetColorContainer() { return dynamic_cast<TColorAdapter*>(GetArray(1))->GetContainer(); } TEnumCont& GetMarkerContainer() { return dynamic_cast<TEnumAdapter*>(GetArray(2))->GetContainer(); } virtual void CreateArrays(); };END_NCBI_SCOPE/* * =========================================================================== * $Log: legend.hpp,v $ * Revision 1000.1 2004/06/01 19:48:18 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7 * * Revision 1.7 2004/05/11 20:26:09 yazhuk * Made some functions virtual * * Revision 1.6 2004/05/11 18:54:43 dicuccio * Added doxygen modules info * * Revision 1.5 2003/10/08 14:11:30 dicuccio * Code clean-up. Use <> instead of "" for #includes. Moved CGlPane into opengl. * Moved CGlPoint and CGlRect into opengl. * * Revision 1.4 2003/09/17 16:15:05 dicuccio * Use CGlBitmapFont instead of CGlutFont * * Revision 1.3 2003/09/04 13:58:42 dicuccio * Added export specifiers. Inlined destructors of interface classes * * Revision 1.2 2003/08/10 14:11:18 dicuccio * Compilation fixes for gcc * * Revision 1.1 2003/08/08 16:01:35 yazhuk * Initial revision. * * =========================================================================== */#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -