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

Go to the SVN repository for this file.

1 /* $Id: paint_alignment.hpp 44314 2019-11-27 14:31:38Z filippov $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Igor Filippov
27  */
28 #ifndef _PAINT_ALIGNMENT_H_
29 #define _PAINT_ALIGNMENT_H_
30 
31 #include <corelib/ncbistd.hpp>
35 #include <objmgr/bioseq_handle.hpp>
37 /*!
38  * Includes
39  */
40 
41 ////@begin includes
42 ////@end includes
43 
44 
45 #include <wx/scrolwin.h>
46 #include <wx/vscroll.h>
47 #include <wx/textwrapper.h>
48 #include <wx/dcbuffer.h>
49 #include <wx/platform.h>
50 
51 
52 /*!
53  * Forward declarations
54  */
55 
56 ////@begin forward declarations
57 ////@end forward declarations
58 
62 
63 class CPaintAlignment : public wxVScrolledWindow
64 {
65  DECLARE_DYNAMIC_CLASS( CPaintAlignment )
66  DECLARE_EVENT_TABLE()
67 public:
68  CPaintAlignment() : wxVScrolledWindow() {}
69  CPaintAlignment(wxWindow *parent, CSeq_align_Handle ah, const vector<vector<vector<pair<TSeqPos,TSeqPos> > > > &feat_ranges,
70  const vector< vector<pair<string,objects::CSeqFeatData::ESubtype> > > &feat_types,
71  const vector< vector<objects::CBioseq_Handle::EVectorStrand> > &feat_strand,
72  wxWindowID id = wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize);
73  virtual ~CPaintAlignment();
74  void OnKeyDown(wxKeyEvent& event);
75  void OnMouseDrag(wxMouseEvent& evt);
76  void OnMouseDown(wxMouseEvent& evt);
77  void SetPos(int pos);
78  void SetPosSeq(int pos);
79  void SetTarget(int row);
80  void EnableFeatures(bool enable);
81  void EnableSubstitute(bool enable);
82  bool IsSelection();
83  pair<int,int> GetSelection(int row);
85  int GetVisibleRow() {return m_SelAlignRow;}
86  pair<int,int> GetAlignSelection(void);
88  void SetAlign(CSeq_align_Handle ah);
89  void RefreshWithScroll();
90  virtual void OnPaint(wxPaintEvent& event);
91  virtual void OnEraseBackground(wxEraseEvent& event);
92  virtual wxCoord OnGetRowHeight( size_t row ) const;
93 
94  virtual void OnUpdate();
95  void OnResize(wxSizeEvent&);
96  void UpdateFeatures(const vector< vector<vector<pair<TSeqPos,TSeqPos> > > > &feat_ranges,
97  const vector< vector<pair<string,objects::CSeqFeatData::ESubtype> > > &feat_types,
98  const vector< vector<objects::CBioseq_Handle::EVectorStrand> > &feat_strand);
99 
100  static string GetSeqTitle(CBioseq_Handle bsh);
101  string GetExportInter();
102  string GetExportCont();
103  int AlignPosToSeqPos(int pos, int row, bool left) const;
104  size_t GetTotalLength() const {return m_TotalLength;}
105 private:
106  void NormalizeCursorColRows();
107  void ScrollWithCursor();
108  void SeqPosToColRow();
109  void ColRowToSeqPos();
110  unsigned int PosToSegment();
111  void ClearScreen(wxGraphicsContext *gc);
112  void CalculateFontWidthAndHeight(wxGraphicsContext *gc);
113  int CalculateNumCols();
114  void DrawTextLine(const unsigned int start, int &y_label, int row, int align_row, wxGraphicsContext *gc, unsigned int &seq_pos);
115  void DrawTextCell(const unsigned int start, int col, int row, int align_row, unsigned int seq_pos, int x, int &y,
116  const vector<unsigned int> &feats_in_row, const map<unsigned int, vector<unsigned int> > &feats_with_exons, wxGraphicsContext *gc) const;
117  void DrawCursor(int col, int row, int x, int &y, wxGraphicsContext *gc) const;
118  const wxPen *GetColorForFeature(objects::CSeqFeatData::ESubtype subtype) const;
119  void DrawFeatures(int row, int align_row, unsigned int seq_pos, int x, int &y, const vector<unsigned int> &feats_in_row, const map<unsigned int, vector<unsigned int> > &feats_with_exons, wxGraphicsContext *gc) const;
120  void DrawFeatureLabels(int row, int align_row, int x, int &y, const vector<unsigned int> &feats_in_row, const map<unsigned int, vector<unsigned int> > &feats_with_exons, wxGraphicsContext *gc) const;
121  int LeftMarginWidth() const;
122  void DrawLineNumber(int align_row, unsigned int seq_pos, int x, int &y, wxGraphicsContext *gc) const;
123  bool MouseToSeqPos(wxPoint p, int &row, int &y_row);
124  int FindRowByCoord(int y, int &y_row);
125  int TopMarginHeight() {return 5;}
126  void DrawLabelCell(unsigned int pos, int x, int &y, int row, int align_row, const vector<unsigned int> &feats_in_row, const map<unsigned int, vector<unsigned int> > &feats_with_exons, wxGraphicsContext *gc) const;
127  vector<unsigned int> GetFeaturesInRow(int row, int align_row) const;
128  void GetFeatWholeRange();
129  vector<unsigned int> IsExonPresent(int i, int row, int align_row) const;
130  map<unsigned int, vector<unsigned int> > GetFeatsWithExons(int row, int align_row, const vector<unsigned int> &feats_in_row) const;
131  void GetSegments();
132  void DrawTopLineNumbers(int align_row, unsigned int seq_pos, int col, int x, int &y, wxGraphicsContext *gc) const;
133  int SeqPosToAlignPos(int pos, int row, bool left);
134 
136  vector<string> m_Seqs;
139  vector<string> m_Labels;
140 
141  vector<vector<vector<pair<TSeqPos,TSeqPos> > > > m_FeatRanges;
142  vector<vector<pair<string,CSeqFeatData::ESubtype> > > m_FeatTypes;
143  vector<vector<CBioseq_Handle::EVectorStrand> > m_FeatStrand;
144 
145  vector<vector<pair<TSeqPos,TSeqPos> > > m_FeatWholeRange;
146  vector<vector< vector<TSeqPos> > > m_FeatLengthBefore;
147  vector< vector<TSeqPos> >m_FeatTotalLength;
148 
149  wxFont m_Font;
156  vector<CDense_seg::TDim> m_visible_to_row;
157 };
158 
159 
160 
162 
163 #endif
164  // _PAINT_SEQUENCE_H_
CBioseq_Handle –.
vector< vector< TSeqPos > > m_FeatTotalLength
void CalculateFontWidthAndHeight(wxGraphicsContext *gc)
vector< vector< vector< TSeqPos > > > m_FeatLengthBefore
virtual void OnUpdate()
Notification for the derived class that moment is good for doing its update and drawing stuff.
CAlignmentAssistant * m_Parent
void SetPos(int pos)
int AlignPosToSeqPos(int pos, int row, bool left) const
int FindRowByCoord(int y, int &y_row)
void DrawLabelCell(unsigned int pos, int x, int &y, int row, int align_row, const vector< unsigned int > &feats_in_row, const map< unsigned int, vector< unsigned int > > &feats_with_exons, wxGraphicsContext *gc) const
vector< CDense_seg::TDim > m_visible_to_row
static string GetSeqTitle(CBioseq_Handle bsh)
virtual void OnEraseBackground(wxEraseEvent &event)
vector< unsigned int > IsExonPresent(int i, int row, int align_row) const
void OnMouseDown(wxMouseEvent &evt)
CSeq_align_Handle m_Alignment
vector< vector< vector< pair< TSeqPos, TSeqPos > > > > m_FeatRanges
void DrawTextLine(const unsigned int start, int &y_label, int row, int align_row, wxGraphicsContext *gc, unsigned int &seq_pos)
vector< vector< pair< string, CSeqFeatData::ESubtype > > > m_FeatTypes
pair< int, int > GetSelection(int row)
void OnMouseDrag(wxMouseEvent &evt)
void SetAlign(CSeq_align_Handle ah)
void SetTarget(int row)
void DrawFeatureLabels(int row, int align_row, int x, int &y, const vector< unsigned int > &feats_in_row, const map< unsigned int, vector< unsigned int > > &feats_with_exons, wxGraphicsContext *gc) const
vector< string > m_Labels
void EnableSubstitute(bool enable)
virtual ~CPaintAlignment()
const wxPen * GetColorForFeature(objects::CSeqFeatData::ESubtype subtype) const
void ClearScreen(wxGraphicsContext *gc)
void DrawTopLineNumbers(int align_row, unsigned int seq_pos, int col, int x, int &y, wxGraphicsContext *gc) const
bool MouseToSeqPos(wxPoint p, int &row, int &y_row)
int SeqPosToAlignPos(int pos, int row, bool left)
void DrawCursor(int col, int row, int x, int &y, wxGraphicsContext *gc) const
void DrawFeatures(int row, int align_row, unsigned int seq_pos, int x, int &y, const vector< unsigned int > &feats_in_row, const map< unsigned int, vector< unsigned int > > &feats_with_exons, wxGraphicsContext *gc) const
int LeftMarginWidth() const
map< unsigned int, vector< unsigned int > > GetFeatsWithExons(int row, int align_row, const vector< unsigned int > &feats_in_row) const
void EnableFeatures(bool enable)
pair< int, int > GetAlignSelection(void)
size_t GetTotalLength() const
void OnResize(wxSizeEvent &)
virtual void OnPaint(wxPaintEvent &event)
Painting.
void SetPosSeq(int pos)
vector< unsigned int > GetFeaturesInRow(int row, int align_row) const
vector< string > m_Seqs
unsigned int PosToSegment()
void UpdateFeatures(const vector< vector< vector< pair< TSeqPos, TSeqPos > > > > &feat_ranges, const vector< vector< pair< string, objects::CSeqFeatData::ESubtype > > > &feat_types, const vector< vector< objects::CBioseq_Handle::EVectorStrand > > &feat_strand)
vector< vector< CBioseq_Handle::EVectorStrand > > m_FeatStrand
vector< vector< pair< TSeqPos, TSeqPos > > > m_FeatWholeRange
void OnKeyDown(wxKeyEvent &event)
void DrawLineNumber(int align_row, unsigned int seq_pos, int x, int &y, wxGraphicsContext *gc) const
virtual wxCoord OnGetRowHeight(size_t row) const
void DrawTextCell(const unsigned int start, int col, int row, int align_row, unsigned int seq_pos, int x, int &y, const vector< unsigned int > &feats_in_row, const map< unsigned int, vector< unsigned int > > &feats_with_exons, wxGraphicsContext *gc) const
Definition: map.hpp:338
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
int i
const struct ncbi::grid::netcache::search::fields::SIZE size
USING_SCOPE(ncbi::objects)
static static static wxID_ANY
#define row(bind, expected)
Definition: string_bind.c:73
Modified on Sat Jun 15 11:51:03 2024 by modify_doxy.py rev. 669887