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

Go to the SVN repository for this file.

1 #ifndef __GUI_WIDGETS_SEQ_TEXT___SEQ_TEXT_PANE__HPP
2 #define __GUI_WIDGETS_SEQ_TEXT___SEQ_TEXT_PANE__HPP
3 
4 /* $Id: seq_text_pane.hpp 43713 2019-08-20 19:46:06Z katargir $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Colleen Bollin (adapted from a file by Andrey Yazhuk)
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistl.hpp>
36 
37 #include <gui/objutils/objects.hpp>
38 
39 #include <gui/graph/axis.hpp>
40 #include <gui/widgets/gl/ruler.hpp>
43 #include <gui/widgets/gl/ruler.hpp>
45 
51 
53 
55 
57 
58 class CSeqTextWidget;
59 
60 ////////////////////////////////////////////////////////////////////////////////
61 /// class CSeqTextPane
63  : public CGlWidgetPane,
64  public CEventHandler,
65  public ISeqTextGeometry
66 {
68 public:
70 
72  virtual ~CSeqTextPane();
73 
74 
75  // interface for a Widget
76  virtual void Update(void);
77  virtual TVPPoint GetPortSize(void);
78 
79  const TRangeColl& GetSelection();
80  void SetRangeSelection(const TRangeColl& C);
81  void ResetRangeSelection();
82  void ResetObjectSelection();
83  void DeSelectObject(const CObject* obj);
84  void SelectObject(const CObject* obj);
85  void ResetSelection();
86 
87  /// @}
88 
89  /// @name ISeqTextGeometry implementation
90  /// @{
91  virtual void STG_Redraw();
92  virtual void STG_OnChanged();
93  virtual TSeqPos STG_GetSequenceByWindow(int x, int y);
95  virtual TModelPoint STG_GetModelPointBySequencePos(TSeqPos z, bool *found_in_source);
96  virtual TSeqPos STG_GetSourcePosBySequencePos (TSeqPos z, bool *found_in_source);
97  virtual void STG_GetVisibleRange (TSeqPos& seq_start, TSeqPos &seq_stop);
98  virtual void STG_GetLineInfo(TSeqPos &chars_in_line, TSeqPos &lines_in_seq);
99  virtual objects::CScope& STG_GetScope();
100  virtual const objects::CSeq_loc* STG_GetDataSourceLoc();
101  virtual TModelUnit STG_GetTextHeight();
102  virtual void STG_ReportMouseOverPos(TSeqPos pos);
103  virtual bool STG_IsPointInRightMargin(int x, int y);
104  virtual void STG_RenderSelectedFeature(const objects::CSeq_feat& feat, const objects::CSeq_loc& mapped_loc);
105  virtual void STG_RenderMouseOverFeature(const objects::CSeq_feat& feat);
106  virtual vector<CConstRef<objects::CSeq_feat> > STG_GetFeaturesAtPosition(TSeqPos pos);
107  virtual void STG_SetSubtypesForFeature (CSeqTextDefs::TSubtypeVector &subtypes, const objects::CSeq_loc& loc, int subtype, TSeqPos start_offset, TSeqPos stop_offset);
108  virtual void STG_RenderFeatureExtras(const objects::CMappedFeat& feat);
109  virtual int STG_GetLinesInPane ();
110  virtual void STG_SetDefaultCursor();
111  virtual void STG_SetResizeCursor();
112 
113 
114  /// @}
115 
116  /* used to determine number of rows and number of characters per row for model */
117  virtual TModelPoint CharacterSize();
118  TModelRect GetPreferredModelRect ();
119  TSeqPos GetScrollAdjustmentForLastLineVariations ();
120 
121  void ScrollToPosition (TSeqPos pos, bool notify = true);
122  void ShowFeaturesInUpperCase();
123  void ShowFeaturesInLowerCase();
124  bool GetShowFeaturesInLowerCase();
125  void ChooseCaseFeature(objects::CSeqFeatData::ESubtype subtype);
126  int GetCaseFeatureSubtype();
127  void ReloadSettings();
128  void SetFontSize (int font_size);
129  int GetFontSize ();
130  bool GetShowAbsolutePosition();
131  void Configure();
132  void OnSize(wxSizeEvent& event);
133 
134  void x_CalculateOffsetList(CSeqTextDefs::TVariationGraphVector& variations);
135 
136  TModelUnit x_TopBlank();
137  TModelUnit GetBottomRulerModelAdjustmentHeight();
138 
139  void x_OnShowPopup(wxMouseEvent &event);
140  unsigned int x_GetOffsetForVariations(TModelUnit y);
141  virtual void x_Render(void);
142 
143  virtual int OnCopy(void);
144 
145 protected:
146  void x_ConfigureBottomRuler();
147 
148  void x_SetRulerText();
149 
150  /// CGlWidgetPane overridables
151 
152  //virtual void x_OnShowPopup();
153 
154 
155  CSeqTextWidget* x_GetParent() { return m_pParent; }
156  const CSeqTextWidget* x_GetParent() const { return m_pParent; }
157 
158  virtual bool Layout(void);
159 
160  // Rendering functions
161  void x_RenderContent(void);
162  void x_RenderBottomRuler();
163  void x_RenderLeftRuler();
164  void x_RenderSelHandler();
165  void x_RenderSelHandler(CGlPane& pane);
166 
167  void x_RenderFeatureExtras (const objects::CSeq_feat& feat, const objects::CSeq_loc& mapped_loc);
168  void x_RenderFeatureExtras (const objects::CSeq_feat& feat);
169  void x_RenderCodons (const objects::CSeq_loc& loc, objects::CCdregion_Base::EFrame frame);
170  void x_RenderCodonTick(TSeqPos cds_start, objects::ENa_strand strand);
171 
172  void x_RecalculateOffsets (void);
173 
174  // for rendering found list
175  void x_UnderlineInterval (TSeqPos start, TSeqPos stop);
176  void x_RenderFoundLocations(CGlPane& pane);
177 
179  void x_AdjustBottomRuler (CGlPane& pane);
180 
181  virtual int x_GetAreaByVPPos(TVPUnit vp_x, TVPUnit vp_y);
182 
183  CGlTextureFont *x_ChooseFontForSize(int font_size);
184 
185 
186 protected:
187  // for Clipboard
188  virtual int x_OnPaste(void);
189 
190 
192  fSequenceArea = 0x01,
193  fSubjectRuler = 0x02,
194  fQueryRuler = 0x04,
195  fSubjectGraphs = 0x08,
196  fQueryGraphs = 0x10,
197  fOther = 0x20,
198  fAllAreas = fSequenceArea | fSubjectRuler | fQueryRuler | fSubjectGraphs | fQueryGraphs | fOther
199  };
200 
201  CSeqTextWidget *m_pParent; // parent widget
202 
204 
205  TRangeColl m_Selection; // translated selection
206 
207  // layout information
212 
215 
216 
218 
221 
223 
224 private:
225  // class for managing offsets due to variations
227  {
228  public:
229  COffsetStart(TSeqPos start_row, unsigned int cumulative_extra_rows) { m_StartRow = start_row; m_CumulativeExtraRows = cumulative_extra_rows;};
231  unsigned int m_CumulativeExtraRows;
232  };
233  typedef vector<COffsetStart> TOffsetStart;
234 
236 
237  TSeqPos x_GetSequenceRowFromScrollLine(TModelUnit scroll_line);
238  void x_CalculateOffsetList(CSeqTextDefs::TVariationGraphVector& variations, TOffsetStart& offset_list);
239 
240 public:
241  // for text search
243  {
244  public:
246  : m_CurrFindPos(0), m_LastSearch(kEmptyStr) { m_FoundList.clear(); }
247 
248  const CSeqTextDefs::TSeqPosVector& GetFoundList() const { return m_FoundList; }
249  void Reset()
250  {
251  m_CurrFindPos = 0;
252  m_LastSearch.clear();
253  m_FoundList.clear();
254  }
257  // string that was searched the last time
258  string m_LastSearch;
259 
260  };
261 
263 
264  void ResetTextSearchData() { m_SearchObj.Reset(); }
265  void SetTextSearchData(const CSeqTextSearch& data) { m_SearchObj = data; }
266  const CSeqTextSearch& GetTextSearchData() const { return m_SearchObj; }
267 
268  // for selection
269  void OnMousePush(wxMouseEvent &event);
270  void OnMouseDrag(wxMouseEvent &event);
271  void OnMouseRelease(wxMouseEvent &event);
272 protected:
274 
275  // for Tooltips
276 public:
277  // necessary for
278  virtual bool TC_NeedTooltip(const wxPoint &pt);
279  virtual string TC_GetTooltip(const wxRect &rc);
280 
281 protected:
282  // event handler
284 };
285 
286 
287 
289 
290 #endif // __GUI_WIDGETS_SEQ_TEXT___SEQ_TEXT_PANE__HPP
CEventHandler.
virtual void x_Render()
Definition: glcanvas.cpp:316
class CGlPane
Definition: glpane.hpp:62
CGlWidgetPane represent a window component residing in CGlWidgetBase client area.
virtual bool TC_NeedTooltip(const wxPoint &pt)
Returns "true" if client wants to dispaly a tooltip.
void OnSize(wxSizeEvent &event)
virtual int x_GetAreaByVPPos(TVPUnit vp_x, TVPUnit vp_y)
virtual string TC_GetTooltip(const wxRect &rect)
Returns tooltip string and coordinates for area tootlip associated with.
virtual TVPPoint GetPortSize(void)=0
returns size of the master pane in screen coordinates
CObject –.
Definition: ncbiobj.hpp:180
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:58
CRuler is a renderable object drawing a scale with position labels.
Definition: ruler.hpp:49
vector< CSeqTextVariationGraph > TVariationGraphVector
vector< int > TSubtypeVector
vector< TSeqPos > TSeqPosVector
COffsetStart(TSeqPos start_row, unsigned int cumulative_extra_rows)
const CSeqTextDefs::TSeqPosVector & GetFoundList() const
CSeqTextDefs::TSeqPosVector m_FoundList
class CSeqTextPane
CSeqTextWidget * m_pParent
CSequenceTextGraph * m_SubjectGraph
CSequenceTickGraph * m_SequenceTickGraph
CRgbaColor m_BackColor
TVPRect m_rcSequence
CTextSelHandler::TRangeColl TRangeColl
const CSeqTextSearch & GetTextSearchData() const
void x_RenderFeatureExtras(const objects::CSeq_feat &feat, const objects::CSeq_loc &mapped_loc)
CSeqTextWidget * x_GetParent()
CGlWidgetPane overridables.
CSeqTextSearch m_SearchObj
void SetTextSearchData(const CSeqTextSearch &data)
void x_AdjustLeftRuler(CGlPane &pane)
vector< COffsetStart > TOffsetStart
TVPRect m_rcBottomRuler
CGlPane m_SequencePane
CRef< CSeqTextConfig > m_Config
CTooltipHandler m_TooltipHandler
void ResetTextSearchData()
CRef< CGlTextureFont > m_pSeqFont
const CSeqTextWidget * x_GetParent() const
CRuler m_BottomRuler
void x_RenderFeatureExtras(const objects::CSeq_feat &feat)
TRangeColl m_Selection
CTextSelHandler m_SelHandler
TVPRect m_rcLeftRuler
TOffsetStart m_OffsetList
class CSeqTextWidget
CSequenceTextGraph.
Definition: seq_graph.hpp:60
CSequenceTickGraph.
Class CTextSelHandler represents in GUI a two-dimnesional multi-segment selection.
CTooltipHandler.
class ISeqTextGeometry
virtual void STG_SetDefaultCursor()=0
virtual void STG_SetResizeCursor()=0
virtual void STG_RenderFeatureExtras(const objects::CMappedFeat &feat)=0
virtual void STG_ReportMouseOverPos(TSeqPos pos)=0
virtual const objects::CSeq_loc * STG_GetDataSourceLoc()=0
virtual void STG_RenderSelectedFeature(const objects::CSeq_feat &feat, const objects::CSeq_loc &mapped_loc)=0
virtual void STG_GetVisibleRange(TSeqPos &seq_start, TSeqPos &seq_stop)=0
virtual void STG_SetSubtypesForFeature(CSeqTextDefs::TSubtypeVector &subtypes, const objects::CSeq_loc &loc, int subtype, TSeqPos start_offset, TSeqPos stop_offset)=0
virtual void STG_Redraw()=0
virtual bool STG_IsPointInRightMargin(int x, int y)=0
virtual vector< CConstRef< objects::CSeq_feat > > STG_GetFeaturesAtPosition(TSeqPos pos)=0
virtual TModelUnit STG_GetTextHeight()=0
virtual objects::CScope & STG_GetScope()=0
virtual TModelPoint STG_GetModelPointBySourcePos(TSeqPos z)=0
virtual TSeqPos STG_GetSourcePosBySequencePos(TSeqPos z, bool *found_in_source)=0
virtual int STG_GetLinesInPane()=0
virtual void STG_RenderMouseOverFeature(const objects::CSeq_feat &feat)=0
virtual TSeqPos STG_GetSequenceByWindow(int x, int y)=0
virtual void STG_GetLineInfo(TSeqPos &chars_in_line, TSeqPos &lines_in_pane)=0
virtual TModelPoint STG_GetModelPointBySequencePos(TSeqPos z, bool *found_in_source)=0
virtual void STG_OnChanged()=0
#define C(s)
Definition: common.h:231
char data[12]
Definition: iconv.c:80
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
GLdouble TModelUnit
Definition: gltypes.hpp:48
int TVPUnit
Definition: gltypes.hpp:47
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define kEmptyStr
Definition: ncbistr.hpp:123
#define NCBI_GUIWIDGETS_SEQTEXT_EXPORT
Definition: gui_export.h:538
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
The NCBI C++/STL use hints.
Modified on Sun Apr 14 05:27:15 2024 by modify_doxy.py rev. 669887