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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_SEQ_GRAPHIC___SEQGRAPHIC_RENDER__HPP
2 #define GUI_WIDGETS_SEQ_GRAPHIC___SEQGRAPHIC_RENDER__HPP
3 
4 /* $Id: seqgraphic_render.hpp 37228 2016-12-16 19:13:15Z 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: Vlad Lebedev, Liangshou Wu
30  *
31  * File Description:
32  * Renderer for the Graphic Sequence view widget
33  * Independent from FLTK.
34  *
35  */
36 
37 //#include <gui/opengl/gldlist.hpp>
38 #include <gui/graph/axis.hpp>
44 
45 #include <gui/widgets/gl/ruler.hpp>
47 
48 #include <gui/opengl/glshader.hpp>
49 
50 #include <gui/print/pdf.hpp>
51 
53 
54 
55 class CSGSequenceDS;
56 class CSeqGraphicConfig;
57 
58 
60 {
61 public:
64  typedef vector<CSeqGraphicHairline> THairlineVector;
65 
66  CSeqGraphicRenderer(bool cgi_mode);
68 
69  void SetDSContext(ISGDataSourceContext* ds_ctx);
70  void SetHost(ILayoutTrackHost* host);
71  void SetInputObject(SConstScopedObject& obj);
72  void SetViewWidth(TSeqPos view_width);
73  void SetHighlightsColor(const CRgbaColor &color);
74  void ConfigureTracks();
75  CRef<CSGSequenceDS> GetDS() { return m_DS; }
76 
77  void UpdateConfig(CRef<CSeqGraphicConfig> config);
78  CRef<CSeqGraphicConfig> GetConfig() { return m_ConfigSettings; }
79  void SetHorizontal(bool b_horz, bool b_flip, const TVPRect& rc,
80  bool reset_model_limit = false);
81  void SetVertScroll(TModelUnit val);
82 
83  /// zoom to the given range.
84  /// @param round_to_base round the range to integer base
85  void ZoomOnRange(const TModelRange& range, bool round_to_base = false);
86 
87  void Resize(const TVPRect& rc);
88  void SetExternalGlyphs(const CSeqGlyph::TObjects& objs);
89  void OnDataChanged();
90  void UpdateLayout();
91  void UpdatePdfLayout();
92  void SetUpdateContent();
93  void UpdateData();
94  bool AllJobsFinished() const;
95  bool AllTracksCreated() const;
96  void SaveTrackConfig();
97 
98  /// zoom 10x at the given screen coordinates.
99  void SetLensZoom(int x, int y);
100  void CancelLensZoom();
101 
102  /// Expose a few GlPanes.
103  CGlPane& GetFeatGlPane();
104  CGlPane& GetRulerGlPane();
105  CFeaturePanel* GetFeaturePanel();
106 
107  /// retrieve the expected height of this widget.
108  TModelUnit GetLayoutHeight() const;
109  TModelUnit GetHeight();
110 
111  void Render(void);
112  void RenderPdf();
113 
114  /// @name cgi mode-related delegate methods for feature panel
115  /// @{
116  void Render(TImageInfo& image_info);
117  void Render(TImageInfo* image_info);
118  void SetTrackConfig(const CFeaturePanel::TTrackSettingsSet& settings_set);
119  /// skip track existence verification.
120  /// Assume tracks exist.
121  void SkipGenuineCheck();
122  TSeqRange GetVisibleRange() const;
123 
124  /// turn on an existing track.
125  /// If there is no such a track in the configuration, it does nothing.
126  void ShowTrack(const string& track_key);
127 
128  void HideRuler();
129  /// @}
130 
131 
132  /// Ruler Mark.
133  void SetRulerSeqStart(TSeqPos pos);
134 
135  CRef<CSeqGlyph> HitTest(int x, int y);
136  void GetTooltip(int x, int y, string& tt, string& t_title);
137 
138  void SelectObject(const CObject* obj, bool verified);
139  void SelectObjByRect(const TVPRect& rc);
140  void SelectObjectSig(const string& obj_sig);
141  void SetNeedUpdateSelection();
142  void DeSelectObject(const CObject* obj);
143  void ResetObjectSelection(void);
144  bool IsObjectSelected(const CObject* obj);
145  bool HasSelectedObjects() const;
146  void GetObjectSelection(ncbi::TConstObjects& objs) const;
147  const CSeqGlyph::TConstObjects& GetSelectedLayoutObjects();
148 
149  /// pixels to sequence translation.
150  TSeqPos Screen2Seq(TVPUnit x, TVPUnit y);
151  TSeqPos Screen2SeqWidth(TVPUnit vp);
152 
153  void LoadDefaultTracks();
154  void ExpandAllTracks(bool expand);
155  void ShowAllTracks(bool shown) { m_FeatPanel->ShowAll(shown); }
156 
157 private:
158  void x_Draw(TImageInfo* p_areas);
159  void x_DrawPdf();
160 
161  void x_DimDisplay();
162  void x_DoLensZoom();
163 
164  void x_SetupViewPorts();
165  void x_SetupViewPorts(const TVPRect& rc);
166  void x_SetupModelLimits(bool reset_model_limit);
167  void x_AdjustToMinScale(bool round_to_base);
168 
169 private:
176 
181 
183  TModelUnit m_MaxZoomSeq; ///< X axis zoom limits
186 
189 
190  bool m_Horz;
191  bool m_Flipped;
192 
196 };
197 
198 ///////////////////////////////////////////////////////////////////////////////
199 /// CSeqGraphicRenderer inline methods
200 ///
201 inline
203 {
204  m_DSContext.Reset(ds_ctx);
205  m_FeatPanel->SetDSContext(ds_ctx);
206 }
207 
208 inline
210 {
211  m_FeatPanel->SetHost(host);
212 }
213 
214 inline
216 {
218 }
219 
220 inline
222 {
223  // make don't update data twice since ConfigureTracks()
224  // triggers updating data automatically.
225  m_NeedUpdateContent = false;
227 }
228 
229 inline
231 {
232  m_FP.Scroll(0, val - m_FP.GetVisibleRect().Top());
233 }
234 
235 inline
237 {
240 }
241 
242 inline
244 {
245  m_NeedUpdateLayout = true;
246 }
247 
248 inline
250 {
251  m_FeatPanel->Update(true);
252 }
253 
254 inline
256 {
257  m_NeedUpdateContent = true;
258 }
259 
260 inline
262 {
263  m_FeatPanel->Update(false);
264  m_NeedUpdateContent = false;
265 }
266 
267 inline
269 {
270  return m_FeatPanel->AllJobsFinished();
271 }
272 
273 inline
275 {
276  return m_FeatPanel->AllTracksCreated();
277 }
278 
279 inline
281 {
283 }
284 
285 inline
287 {
288  m_NeedLensZoom = false;
289 }
290 
291 inline
293 {
294  return m_FP;
295 }
296 
297 inline
299 {
300  return m_RP;
301 }
302 
303 inline
305 {
306  return m_FeatPanel;
307 }
308 
309 inline
311 {
312  return m_FeatPanel->GetHeight() + m_RulerPanel.GetSize().Y();
313 }
314 
315 inline
317 {
318  x_Draw(NULL);
319 }
320 
321 inline
323 {
324  x_Draw(&areas);
325 }
326 
327 inline
329 {
330  x_DrawPdf();
331 }
332 
333 inline
335 {
336  x_Draw(p_areas);
337 }
338 
339 inline
341  const CFeaturePanel::TTrackSettingsSet& settings_set)
342 {
343  m_FeatPanel->SetTrackConfig(settings_set);
344 }
345 
346 inline
348 {
350 }
351 
352 inline
354 {
356 }
357 
358 inline
359 void CSeqGraphicRenderer::ShowTrack(const string& track_key)
360 {
361  m_FeatPanel->ShowTrack(track_key);
362 }
363 
364 inline
366 {
367  m_RulerPanel.SetShown(false);
368 }
369 
370 inline
372 {
375 }
376 
377 inline
378 void CSeqGraphicRenderer::SelectObject(const CObject* obj, bool verified)
379 {
380  m_SelManager.SelectObject(obj, verified);
381  m_NeedUpdateSelection = true;
382 }
383 
384 inline
385 void CSeqGraphicRenderer::SelectObjectSig(const string& obj_sig)
386 {
388  m_NeedUpdateSelection = true;
389 }
390 
391 inline
393 { m_NeedUpdateSelection = true; }
394 
395 
396 inline
398 {
400  if ( !m_SelManager.HasSelectedObjects() ) {
402  } else {
403  m_NeedUpdateSelection = true;
404  }
405 }
406 
407 inline
409 {
411 }
412 
413 inline
415 {
416  return m_SelManager.IsObjectSelected(obj);
417 }
418 
419 inline
421 {
423 }
424 
425 inline
427 {
429 }
430 
431 inline
434 {
436 }
437 
438 inline
440 {
442 }
443 
444 inline
446 {
447  m_FeatPanel->ExpandAll(expand);
448 }
449 
451 
452 
453 #endif /* GUI_WIDGETS_SEQ_GRAPHIC___SEQGRAPHIC_RENDER__HPP */
class CSelectionVisitor is a concrete glyph visitor for selection traversal and deselection traversal...
void ShowTrack(const string &track_key)
turn on an existing track.
CFeaturePanel * GetFeaturePanel()
bool HasSelectedObjects() const
BOOL UpdateData(HWND hDlg, CProjBulderApp *pApp, BOOL bGet)
Definition: ptb_gui.cpp:62
void SetSelectedObjectSig(const string &obj_sig)
CSeqGraphicImageInfo TImageInfo
vector< CSeqGraphicHairline > THairlineVector
void ShowAllTracks(bool shown)
const string color[]
Definition: showalign.cpp:95
GLdouble TModelUnit
Definition: gltypes.hpp:48
void SelectObject(const CObject *obj, bool verified)
CGlShader.
Definition: glshader.hpp:61
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:850
void ExpandAll(bool expand)
expand or collapse this track and its subtracks recursively.
TModelRect & GetVisibleRect(void)
Definition: glpane.hpp:357
CRef< CSGSequenceDS > m_DS
void SelectObject(const CObject *obj, bool verified)
const TSeqRange & GetVisSeqRange() const
void DeSelectObject(const CObject *obj)
bool AllTracksCreated() const
TModelUnit m_MaxZoomSeq
X axis zoom limits.
virtual void Update(bool layout_only)
Update content and layout including the bounding box.
void SetHost(ILayoutTrackHost *host)
void SaveTrackConfig()
int TVPUnit
Definition: gltypes.hpp:47
class CGlPane
Definition: glpane.hpp:61
#define NULL
Definition: ncbistd.hpp:225
void SetHighlightsColor(const CRgbaColor &color)
void x_Draw(TImageInfo *p_areas)
vector< CConstRef< CObject > > TConstObjects
Definition: objects.hpp:64
virtual bool AllJobsFinished() const
CRenderingContext offers the basic context and utility methods for rendering layout objects in featur...
void GetObjectSelection(TConstObjects &objs) const
TVPPoint GetSize(int max_num=0) const
Definition: ruler_panel.cpp:93
void ExpandAllTracks(bool expand)
const CSeqGlyph::TConstObjects & GetSelectedLayoutObjects(CSeqGlyph *top_glyph)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
void ResetObjectSelection(CSeqGlyph *glyph)
CRef< CSeqGraphicConfig > m_ConfigSettings
CRef< CFeaturePanel > m_FeatPanel
CRulerPanel – the ruler panel class.
Definition: ruler_panel.hpp:47
CRenderingContext m_RenderingCtx
void GetObjectSelection(ncbi::TConstObjects &objs) const
CRef< CSeqGraphicConfig > GetConfig()
void SetHost(ILayoutTrackHost *host)
list< CConstRef< CSeqGlyph > > TConstObjects
Definition: seq_glyph.hpp:84
void SetRulerSeqStart(TSeqPos pos)
Ruler Mark.
void Scroll(TModelUnit dx, TModelUnit dy)
Definition: glpane.cpp:601
void LoadDefaultTracks()
Reset tracks to the original default track list.
virtual TModelUnit GetHeight() const
Definition: seq_glyph.hpp:556
bool IsObjectSelected(const CObject *obj)
void SetHighlightsColor(const CRgbaColor &c)
void ConfigureTracks()
ILayoutTrackHost An interface used for handling GUI-related events, such as layout change event that ...
TModelUnit GetLayoutHeight() const
retrieve the expected height of this widget.
void SetRulerSeqStart(TSeqPos pos)
bool HasSelectedObjects() const
const CSeqGlyph::TConstObjects & GetSelectedLayoutObjects()
void SetDSContext(ISGDataSourceContext *ds_ctx)
TSeqRange GetVisibleRange() const
void SetTrackConfig(const CFeaturePanel::TTrackSettingsSet &settings_set)
list< TTrackSettings > TTrackSettingsSet
CSelectionVisitor m_SelManager
CIRef< ISGDataSourceContext > m_DSContext
CObject –.
Definition: ncbiobj.hpp:180
T Y() const
Definition: glpoint.hpp:60
void ShowTrack(const string &track_key)
Turn on an existing track.
void SkipGenuineCheck()
skip track existence verification.
bool AllJobsFinished() const
T Top() const
Definition: glrect.hpp:84
void SetVertScroll(TModelUnit val)
CGlPane & GetFeatGlPane()
Expose a few GlPanes.
void SelectObjectSig(const string &obj_sig)
void SetDSContext(ISGDataSourceContext *ds_ctx)
CSeqGraphicRenderer inline methods.
void SetShown(bool f)
bool IsObjectSelected(const CObject *obj)
list< CRef< CSeqGlyph > > TObjects
Definition: seq_glyph.hpp:83
void DeSelectObject(const CObject *obj)
CSeqGlyph::TAreaVector TAreaVector
void SkipGenuineCheck()
skip track existence verification.
CRef< CSGSequenceDS > GetDS()
class CRgbaColor provides a simple abstraction for managing colors.
Definition: rgba_color.hpp:57
vector< CHTMLActiveArea > TAreaVector
Definition: seq_glyph.hpp:82
void SetTrackConfig(const TTrackSettingsSet &settings_set)
ISGDSManager is seqgraphic data source manage that serves as an data source context.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
#define NCBI_GUIWIDGETS_SEQGRAPHIC_EXPORT
Definition: gui_export.h:534
bool AllTracksCreated() const
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:756
Modified on Sat Nov 18 14:32:32 2017 by modify_doxy.py rev. 546573