phylo_tree_render.hpp
上传用户:yhdzpy8989
上传日期:2007-06-13
资源大小:13604k
文件大小:7k
- /*
- * ===========================================================================
- * PRODUCTION $Log: phylo_tree_render.hpp,v $
- * PRODUCTION Revision 1000.1 2004/06/01 19:53:02 gouriano
- * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.11
- * PRODUCTION
- * ===========================================================================
- */
- #ifndef __GUI_WIDGETS_PHYLO_TREE___PHYLO_TREE_RENDER__HPP
- #define __GUI_WIDGETS_PHYLO_TREE___PHYLO_TREE_RENDER__HPP
- /* $Id: phylo_tree_render.hpp,v 1000.1 2004/06/01 19:53:02 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: Vladimir Tereshkov
- *
- * File Description:
- *
- */
- #include <corelib/ncbistl.hpp>
- #include <gui/opengl/glcolor.hpp>
- #include <gui/opengl/glpane.hpp>
- #include <gui/opengl/glbitmapfont.hpp>
- #include <gui/widgets/gl/ievent_handler.hpp>
- #include <gui/widgets/hit_matrix/hit_data_adapter.hpp>
- #include <gui/widgets/phylo_tree/phylo_tree_ds.hpp>
- #include <gui/widgets/phylo_tree/phylo_tree_scheme.hpp>
- #include <gui/widgets/phylo_tree/phylo_tree_label.hpp>
- #include <gui/widgets/fl/tooltip.hpp>
- #include <gui/math/curve_bezier.hpp>
- #include <gui/opengl/glcurve.hpp>
- #include <gui/opengl/gltube.hpp>
- #include <gui/opengl/gldlist.hpp>
- BEGIN_NCBI_SCOPE
- class IPhyloTreeRendererHost
- {
- public:
- virtual ~IPhyloTreeRendererHost() {};
- virtual void HMGH_Redraw(void) = 0;
- virtual TVPUnit HMGH_GetVPPosByY(int y) const = 0;
- virtual void FireCBEvent(void) = 0;
- };
- // rendering interface
- class IPhyloTreeRenderer : public IEventHandler,
- public CPhyloTreeScheme,
- public ITooltipClient
- {
- protected:
- CPhyloTreeDataSource * m_DS;
- double m_DimX, m_DimY;
- double m_xStep, m_yStep;
- double m_NormDistance;
-
- CGlBitmapFont *m_pLabelFont;
- IPhyloTreeRendererHost *m_pHost;
- // display list for our scene
- CGlDisplayList m_Dlist;
- CGlCurve<CCurveBezier> m_Curve;
- CTooltip m_Tooltip;
- CPhyloTreeLabel m_Label;
- TModelRect m_RasterRect;
- /// event handling state
- enum EState {
- eIdle,
- eSelPoint, /// selecting a single glyph by point
- eSelRect /// selecting multiple glyphs by rectangle
- };
-
- /// label alignment
- enum ELabelAlign {
- eLeft,
- eRight
- };
- /// event handling
- CGlPane *m_pPane;
- EState m_State;
- TVPPoint m_StartPoint;
- TVPPoint m_DragPoint;
- Fl_Cursor m_Cursor;
- vector<int> m_SelectedIDs;
- bool m_bDistMode;
-
- void x_RenderSelection(CGlPane& pane);
- void x_RenderLine(double x1, double y1, double x2, double y2, double width, CGlColor color1, CGlColor color2);
- void x_RenderNode(double x, double y, double size, CGlColor color);
- void x_RenderSpline(double x1, double y1, double x2, double y2);
-
- /// user event handlers - translate event to signals
- int x_OnMousePush(CGUIEvent& event);
- int x_OnMouseDrag(CGUIEvent& event);
- int x_OnMouseRelease(CGUIEvent& event);
- int x_OnMouseMove(void);
- int x_OnKeyDown(void);
- int x_OnKeyUp(void);
- void x_OnSelectCursor(void);
- bool x_SelectByPoint(CPhyloTreeNode * node);
- bool x_SelectByRect(CPhyloTreeNode * node);
- void x_BuildSelVector(CPhyloTreeNode * node);
-
- CPhyloTreeNode * x_TestForNode(CPhyloTreeNode * node);
- virtual void x_Layout(CPhyloTreeDataSource& ds) = 0;
- virtual void x_Render(CGlPane& pane, CPhyloTreeDataSource& ds) = 0;
-
- public:
- IPhyloTreeRenderer();
- virtual ~IPhyloTreeRenderer(){}
- // selection set/retrieve
- const vector<int> & GetSelectedIDs(void) { return m_SelectedIDs; };
- void SetSelectedIDs(const vector<int> & vect);
- bool IsSelected(CPhyloTreeNode * node);
-
- // ITooltipClient implementation (chain call)
- virtual bool TC_NeedTooltip(int x, int y);
- virtual string TC_GetTooltip(int& x, int& y, int& w, int& h);
- void SetHost(IPhyloTreeRendererHost* pHost);
- void SetFont(CGlBitmapFont * font) {m_pLabelFont = font;}
- void SetDistRendering(bool flag) {m_bDistMode = flag;}
- bool GetDistRendering(void) {return m_bDistMode;}
-
- virtual string GetDescription(void) = 0;
- virtual void Render(CGlPane& pane, CPhyloTreeDataSource& ds);
- virtual void Layout(CPhyloTreeDataSource& ds);
-
- /// IEventHandler implementation
- virtual int handle(CGUIEvent& event, CGlPane& pane);
- //
- const TModelRect & GetRasterRect(void) { return m_RasterRect; }
- // metrics
- const static double GetDimX(void);
- const static double GetDimY(void);
- };
- END_NCBI_SCOPE
- /*
- * ===========================================================================
- * $Log: phylo_tree_render.hpp,v $
- * Revision 1000.1 2004/06/01 19:53:02 gouriano
- * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.11
- *
- * Revision 1.11 2004/05/11 20:53:38 tereshko
- * Work in progress
- *
- * Revision 1.10 2004/05/06 19:41:07 tereshko
- * Added force layout
- *
- * Revision 1.9 2004/04/28 19:27:27 tereshko
- * Added support for distances rendering
- *
- * Revision 1.8 2004/04/20 21:57:37 tereshko
- * Major rendering, labeling and performance improvements
- *
- * Revision 1.7 2004/04/13 20:29:22 tereshko
- * Numerous renderers improvements
- *
- * Revision 1.6 2004/04/01 21:47:13 tereshko
- * Code clean-up
- *
- * Revision 1.5 2004/03/30 17:11:08 tereshko
- * Added support for events broadcasting
- *
- * Revision 1.4 2004/03/03 21:42:31 tereshko
- * Added tooltips support
- *
- * Revision 1.3 2004/03/02 18:29:24 tereshko
- * Added radial tree layout
- *
- * Revision 1.2 2004/02/23 22:52:47 tereshko
- * Rendering Improvements
- *
- * Revision 1.1 2004/02/13 17:00:04 tereshko
- * Phylogenetic Tree Widget initial revision
- *
- * ===========================================================================
- */
- #endif // __GUI_WIDGETS_PHYLO_TREE___PHYLO_TREE_RENDER__HPP