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

📄 alnmulti_model.hpp

📁 ncbi源码
💻 HPP
字号:
/* * =========================================================================== * PRODUCTION $Log: alnmulti_model.hpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 19:51:36  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6 * PRODUCTION * =========================================================================== */#ifndef GUI_WIDGETS_ALNMULTI___ALNMULTI_MODEL__HPP#define GUI_WIDGETS_ALNMULTI___ALNMULTI_MODEL__HPP/*  $Id: alnmulti_model.hpp,v 1000.1 2004/06/01 19:51:36 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: *   CAlnMultiModel - representation of alignment for rendering. */#include <corelib/ncbiobj.hpp>#include <util/range_coll.hpp>#include <gui/opengl/glviewport.hpp>#include <gui/widgets/aln_multiple/sel_list_model_impl.hpp>#include <gui/widgets/aln_multiple/alnmulti_ds.hpp>#include <gui/widgets/aln_multiple/alnmulti_base_pane.hpp>BEGIN_NCBI_SCOPEclass IAlnMultiDataSource;typedef CSelListModelImpl<IAlnMultiDataSource::TNumrow> TNumrowModelImpl;/////////////////////////////////////////////////////////////////////////////////// class CAlnMultiModel - represents visual model of alignment used by Renderer/// to draw alignment in a widget or to generate alignment image in CGI.////// Model presents alignment as set of graphical areas corresponding to alignment/// rows. Each ares is represented by an instance if IAlignRow-derived class and/// has attributes such as "visible" and "selected". Order of areas on screen (lines)/// may be different from order of rows in alignment./// Model holds data necessary for rendering such as IAlignRow-derived objects/// represnting rows, row attaributes and indixes facilitating operations with/// model (line <-> row, row_num <-> row).class NCBI_GUIWIDGETS_ALNMULTIPLE_EXPORT CAlnMultiModel    : public IAlnMultiRendererContext, // context for Renderer      public TNumrowModelImpl   // ISelListModel implementation{public:    typedef int TLine;    typedef list<objects::CSeq_loc*>    TPSeqLocList;    typedef CRangeCollection<TSeqPos>   TRangeColl;public:    CAlnMultiModel();    virtual ~CAlnMultiModel();    virtual void SetDataSource(IAlnMultiDataSource* p_ds);    virtual void    SetStyleCatalog(const CRowStyleCatalog* catalog);    virtual const CWidgetDisplayStyle*      GetDisplayStyle() const;    CGlPane& GetAlignPort();        IAlignRow*  GetRow(TNumrow  row);    const IAlignRow*  GetRow(TNumrow  row) const;    bool        IsRowVisible(TNumrow  row) const;    bool        IsRowSelected(TNumrow  row) const;        /// returns a combination of IAlignRow::EState flags    int   GetRowState(TNumrow row)    const;        inline void    GetSelectedRows(vector<TNumrow>& rows);    virtual void    CreateRows(void); /// create    virtual void    ClearRows(void);    void    SetPortLimits(void);             /// changes Master (Anchor) an perform necessary updates    virtual void    SetMasterRow(TNumrow new_row);        /// enables auto sorting but does not perform any updates    virtual void    EnableAutoSorting(bool b_en);    /// enables auto sorting of rows, sorts rows using x_SortRows() and     /// performs necessary updates    virtual void    UpdateSortOrder(void);        /// disables auto sorting, reorders rows in alignment so that rows from    /// the given vector appear in the specified order in the position specified by "pos"    virtual void    SetRowOrder(const vector<TNumrow>& rows, int pos = 0);        /// makes specified rows visible/hidden, if b_invert_others == "true"    /// then visibility of all rows not in "rows" will be changed to ! b_visible    void    SetVisible(const vector<TNumrow>& rows, bool b_visible,                        bool b_invert_others = false);    void    ShowAll();    /// updates model after row height changed        virtual void    UpdateOnRowHChanged(void);        /// @name IAlnMultiRendererContext implementation     /// @{    virtual const CGlPane& GetAlignPort() const;    virtual bool        IsRendererFocused();    virtual TNumrow     GetLinesCount();    virtual int     GetFocusedItemIndex() const;    virtual bool    IsItemSelected(int index) const;        virtual IAlignRow*  GetMasterRow();    virtual IAlignRow*  GetRowByLine(TLine line);        virtual int         GetLineByRowNum(TNumrow row) const;    virtual int         GetLineByModelY(int Y) const;    virtual int         GetLinePosY(TLine line) const;    virtual int         GetLineHeight(TLine line) const;        /// @}            protected:      // SRowRecord is a record representing a single alignment row    struct  SRowRecord    {        IAlignRow*  m_pRow; // row object        TLine       m_Line; // visual line index        int         m_State; // row state, combination of IAlignRow::EState flags    public:        SRowRecord()             : m_pRow(NULL), m_Line(-1), m_State(0) {}        SRowRecord(IAlignRow* p_row, TLine line)             : m_pRow(p_row), m_Line(line), m_State(0) {}        SRowRecord(const SRowRecord& proto)             : m_pRow(proto.m_pRow), m_Line(proto.m_Line), m_State(0)    {}        inline void     SetState(int mask, bool b_set = true);        inline  int     GetState(int mask) const;        inline  bool    IsVisible() const;        inline  bool    IsSelected() const;        static bool    PRecLineLess(const SRowRecord* rec1,                                     const SRowRecord* rec2);    };protected:   inline SRowRecord&     x_GetRecordByRow(TNumrow row);   inline const SRowRecord&     x_GetRecordByRow(TNumrow row) const;        // factory method for creation IAlignRow instances    virtual IAlignRow*  x_CreateRow(TNumrow row)  = 0;    virtual void    x_UpdateOnDataChanged();    /// This is a sorting callback automatically invoked by CAlnMultiModel when    /// necessary. Override this function in derived classes - default     /// implementation doesn't do anything.     /// x_SortRows() should rearrange eleemnts of m_vVisibleRows and return "true"     /// if any changes have been made - this will force necessary updates.    virtual bool    x_SortRows(void);     /// performs sorting by invoking x_SortRows() and updates line numbers    virtual void    x_DoUpdateRowsOrder(void);    /// recalculates vertical coordinates of row objects    virtual void    x_DoUpdateRowPositions(void);        void    x_DoUpdateRowLines(void); /// updates line numbers in SRowRecords       /// @TNumrowModelImpl extension    /// @{    virtual void    x_SelectItem(TIndex index, bool b_sel);    virtual bool    x_IsItemSelected(TIndex index) const;    virtual TIndex  x_GetItemsCount()   const;    virtual TItem   x_GetItem(TIndex index)    const;    virtual void    x_SetEntries(const TEntryVector& v_entries);    virtual TIndex  x_GetItemIndex(const TItem& item);        virtual void    x_InsertItem(TIndex index, const TItemEntry& entry);    virtual void    x_CompleteInsertion();     virtual void    x_MarkItemForErase(TIndex index);    virtual void    x_EraseMarkedItems(void);    virtual void    x_ClearItems(void);    /// @}      IAlignRow*  x_GetRowByLine(int Index);    const IAlignRow*  x_GetRowByLine(int Index)   const;protected:    typedef vector<SRowRecord*>     TRowRecVector;    typedef vector<SRowRecord*>     TRowToRecMap;        CWidgetDisplayStyle     m_Style;    const CRowStyleCatalog* m_pStyleCatalog;        IAlnMultiDataSource* m_pDataSource;    TRowToRecMap    m_RowToRec; /// map storing records for all rows    IAlignRow*      m_pMasterRow; /// IAligRow corresponding to Anchor    TRowRecVector   m_vVisibleRows; /// line number -> SRowRecord* for visible rows    vector<int>     m_vVisibleRowPos; /// bottom positions for visible rows[line]           CGlPane  m_Port;     bool    m_bAutoSort; /// enables automating sorting of rows using x_SortRows() callback};/////////////////////////////////////////////////////////////////////////////////// CAlnMultiModel inline functionsinline IAlignRow*  CAlnMultiModel::GetRow(TNumrow  row){    _ASSERT(row >= 0  &&  (size_t) row < m_RowToRec.size());    return m_RowToRec[row]->m_pRow;}const inline IAlignRow*  CAlnMultiModel::GetRow(TNumrow  row) const{    _ASSERT(row >= 0  &&  (size_t) row < m_RowToRec.size());    return m_RowToRec[row]->m_pRow;}inline bool     CAlnMultiModel::IsRowVisible(TNumrow  row) const{    _ASSERT(row >= 0  &&  (size_t) row < m_RowToRec.size());    return m_RowToRec[row]->IsVisible();}inline bool     CAlnMultiModel::IsRowSelected(TNumrow  row) const{    _ASSERT(row >= 0  &&  (size_t) row < m_RowToRec.size());    return m_RowToRec[row]->IsSelected();}inline CAlnMultiModel::SRowRecord&     CAlnMultiModel::x_GetRecordByRow(TNumrow row){    _ASSERT(row >= 0  &&  (size_t) row < m_RowToRec.size());    return *m_RowToRec[row];}inline const CAlnMultiModel::SRowRecord&     CAlnMultiModel::x_GetRecordByRow(TNumrow row) const{    _ASSERT(row >= 0  &&  (size_t) row < m_RowToRec.size());    return *m_RowToRec[row];} inline void CAlnMultiModel::SRowRecord::SetState(int mask, bool b_set) {    if(b_set)   {        m_State |= mask;    } else {        m_State &= ~mask;    }}inline  int    CAlnMultiModel::SRowRecord::GetState(int mask) const{    return m_State & mask;}inline  bool    CAlnMultiModel::SRowRecord::IsVisible() const{    return (m_State & IAlignRow::fItemHidden) == 0;}inline  bool    CAlnMultiModel::SRowRecord::IsSelected() const{    return (m_State & IAlignRow::fItemSelected) != 0;}inline void    CAlnMultiModel::GetSelectedRows(vector<TNumrow>& rows){    SLM_GetSelectedItems(rows);}END_NCBI_SCOPE#endif  // GUI_WIDGETS_ALNMULTI___ALNMULTI_MODEL__HPP/* * =========================================================================== * $Log: alnmulti_model.hpp,v $ * Revision 1000.1  2004/06/01 19:51:36  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.6 * * Revision 1.6  2004/04/27 15:34:59  yazhuk * Added PRecLineLess() to SRowRecord * * Revision 1.5  2004/04/06 16:03:21  yazhuk * Added GetSelectedRows(), EnableAutoSorting(), SetRowOrder() * * Revision 1.4  2004/04/02 16:35:29  yazhuk * Added GetRow(), IsRowVisible(), IsRowSelected(); comments * * Revision 1.3  2004/03/18 17:07:27  yazhuk * Added "b_invert_others" argument to SetVisible() * * Revision 1.2  2004/03/17 20:15:07  yazhuk * Refactored CAlnMultiModel interface * * Revision 1.1  2004/03/09 20:59:01  yazhuk * Initial revision. Factored out from CAlnMultiWidget. * * =========================================================================== */

⌨️ 快捷键说明

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