⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glpane.hpp

📁 ncbi源码
💻 HPP
📖 第 1 页 / 共 2 页
字号:
/* * =========================================================================== * PRODUCTION $Log: glpane.hpp,v $ * PRODUCTION Revision 1000.4  2004/06/01 19:50:09  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.11 * PRODUCTION * =========================================================================== */#ifndef GUI_GRAPH___GLPANE__HPP#define GUI_GRAPH___GLPANE__HPP/*  $Id: glpane.hpp,v 1000.4 2004/06/01 19:50:09 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 <corelib/ncbistl.hpp>#include <corelib/ncbidiag.hpp>#include <gui/opengl.h>#include <gui/opengl/glcolor.hpp>#include <gui/opengl/glrect.hpp>/** @addtogroup GUI_OPENGL * * @{ */BEGIN_NCBI_SCOPE// units for coordinates representation on the output device (pixels) and in the model spacetypedef int         TVPUnit; typedef GLdouble    TModelUnit;typedef CGlPoint<TVPUnit>   TVPPoint;typedef CGlPoint<TModelUnit>    TModelPoint;typedef CGlRect<TVPUnit>      TVPRect;typedef CGlRect<TModelUnit>   TModelRect;enum EScaleType {        eDec,        eLog10,        eLog2,         eLn    };enum    EOrientation    {    eHorz,    eVert};/////////////////////////////////////////////////////////////////////////////////// class CGlPane// CGlPane represents a rectangular area used for drawing graphs and decorations// (such as grid, axes, labels etc.) CGlPane provides means for using OpenGL// projections in order to draw graphs in coordinates of their model space. class NCBI_GUIOPENGL_EXPORT CGlPane{public:        enum EProjectionMode {        eNone = -1, // closed or invalid        eOrtho, // orthographic projection, drawing in model space coords        ePixels // orthographic projection, drawing in pixels    };    /// Specifies what point should be preserved during various coordinate     /// space adjustments.    enum EOriginType {        eOriginLeft,        eOriginRight,        eOriginBottom,        eOriginTop,        eOriginCenter    };    /// EProjMatrixPolicy controls CGlPane behavior in respect to obtaining    /// projection matrices for future use in Project..(), UnProject...()    /// functions.    enum EProjMatrixPolicy    {        eNeverUpdate,        eAlwaysUpdate    };    /// EAdjustmentPolicy specifies how visible area should be adjusted if     /// some of the prjection parameters change    enum EAdjustmentPolicy    {        fShiftToLimits = 0x1,        fScaleToLimits = 0x2,        fAdjustAll = fShiftToLimits | fScaleToLimits    };    /// EZoomOptions flags control behavior of Zoom operations.    enum EZoomOptions    {        fZoomX = 0x1,   // zoom by X coordinate        fZoomY = 0x2,   // zoom by Y coordinate        fForce = 0x4,   // overrides enable/disable settings in the pane        fZoomXY = fZoomX | fZoomY            };public:    CGlPane(EProjMatrixPolicy policy = eAlwaysUpdate);    virtual ~CGlPane();    // Viewport manipulation    void    SetViewport(const TVPRect& R);    TVPRect&        GetViewport(void);    const TVPRect&  GetViewport(void) const;    // Model Space manipulation    void    SetModelLimitsRect(const TModelRect& R);    TModelRect&       GetModelLimitsRect(void);    const TModelRect& GetModelLimitsRect(void) const;    // Ortho projection - visible ares    void    SetVisibleRect(const TModelRect& R);    TModelRect&         GetVisibleRect(void);    const TModelRect&   GetVisibleRect(void) const;        /// set clipping rect that will be used by glScissor, NULL for reset            void    SetClipRect(const TVPRect* rc_clip = NULL);    /// Offset is used as a workaround for OpenGL precision problems emerging    /// when  size of visible range is small in comparision to coordinates in    /// this range.    void    EnableOffset(bool b_en = true);    TModelUnit  GetOffsetX()    const;    TModelUnit  GetOffsetY()    const;    TModelPoint GetOffset() const;    bool    Open(EProjectionMode Mode);    bool    OpenOrtho();    bool    OpenPixels();    void    Close(void);        EProjectionMode GetProjMode(void) const;    // scale Model space units per pixel    TModelUnit  GetScaleX(void) const;    TModelUnit  GetScaleY(void) const;        void    SetMinScaleX(TModelUnit scale);    void    SetMinScaleY(TModelUnit scale);    TModelUnit    GetMinScaleX(void) const;    TModelUnit    GetMinScaleY(void) const;        TModelUnit    GetZoomAllScaleX(void) const;    TModelUnit    GetZoomAllScaleY(void) const;    // in Proportional mode CGlPane will keep horz. and vert. scales equal    void    SetProportionalMode(bool set);    bool    IsProportionalMode(void) const;    void    SetOriginType(EOriginType type_x, EOriginType type_y);    void    SetAdjustmentPolicy(int adjust_x, int adjust_y);    void    SetAdjustToLimits(bool adjust_x, bool adjust_y);    // Zoom functions    void    EnableZoom(bool en_x, bool en_y);    bool    IsZoomInAvaiable(void);    bool    IsZoomOutAvaiable(void);    void    SetZoomFactor(TModelUnit factor = 2.0);        void    ZoomAll(int options = fZoomXY);        void    ZoomInCenter(int options = fZoomXY);    void    ZoomIn(TModelUnit x, TModelUnit y, int options = fZoomXY);    void    ZoomIn(TModelPoint p, int options = fZoomXY);        void    ZoomOutCenter(int options = fZoomXY);    void    ZoomOut(TModelUnit x, TModelUnit y, int options = fZoomXY);    void    ZoomOut(TModelPoint p, int options = fZoomXY);            void    ZoomPoint(TModelUnit x, TModelUnit y, TModelUnit factor, int options = fZoomXY);    void    ZoomPoint(TModelPoint p, TModelUnit factor, int options = fZoomXY);        void    ZoomRect(const TModelRect& r);            // Zooms so that p_center becomes a center of visible area, the size of    // visible area is calculated based on given scales    void    SetScale(TModelUnit scale_x, TModelUnit scale_y, TModelPoint p_center);    void    SetScaleRefPoint(TModelUnit scale_x, TModelUnit scale_y,                              TModelPoint p_ref);    // this function preserves current center point    void    SetScale(TModelUnit scale_x, TModelUnit scale_y);    // Scroll functions    bool    NeedsScrollX(void) const;    bool    NeedsScrollY(void) const;    void    Scroll(TModelUnit dx, TModelUnit dy);    void    AdjustToLimits();    // Coordinate transformations - now only for Ortho mode    TVPUnit ProjectX(TModelUnit m_x) const;    TVPUnit ProjectY(TModelUnit m_y) const;    TVPPoint    Project(TModelUnit m_x, TModelUnit m_y) const;        TModelUnit UnProjectX(TVPUnit m_y) const;    TModelUnit UnProjectY(TVPUnit m_y) const;    TModelPoint UnProject(TVPUnit m_x, TVPUnit m_y) const;    TModelUnit  UnProjectWidth(TVPUnit vp_w);    TModelUnit  UnProjectHeight(TVPUnit vp_h);protected:    bool    x_OpenOrtho();    bool    x_OpenPixels();    void    x_Open_SetViewport();        void    x_UpdateProjectMatrices(void);    // functions enforcing constraints in the display validity    void    x_CorrectScale(TModelPoint p_center);        // shifts visible area so that it is located within limits    void    x_ShiftToFitLimits(void);    void    x_ScaleToFitLimits(void);        void    x_AdjustVisibleRect(void);        static double  s_GetShift(TModelUnit low_shift, TModelUnit high_shift, bool neg_range, EOriginType type);    void    x_AssertNotOpen(void) const;    void    x_AssertOrtho(void) const;protected:    TVPRect m_rcVP;    TModelRect  m_rcLimits;    TModelRect  m_rcVisible;    TModelRect  m_rcOrigVisible; // used in ProportionalMode    const TVPRect *m_prcClip;    EProjectionMode     m_Mode;    EProjMatrixPolicy   m_MatrixPolicy;    int   m_AdjustX;    int   m_AdjustY;    bool  m_bEnableOffset;        bool    m_bZoomEnX;    bool    m_bZoomEnY;    TModelUnit  m_ZoomFactor;    bool    m_bProportionalMode;    EOriginType     m_TypeX;    EOriginType     m_TypeY;        TModelUnit  m_MinScaleX;    TModelUnit  m_MinScaleY;    // matrices for using with gluProject gluUnProject

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -