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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_SEQ_GRAPHIC___SEQGRAPHIC_WIDGET__HPP
2 #define GUI_WIDGETS_SEQ_GRAPHIC___SEQGRAPHIC_WIDGET__HPP
3 
4 /* $Id: seqgraphic_widget.hpp 47374 2023-02-23 00:42:16Z evgeniev $
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  * Graphic Sequence Widget
33  *
34  */
35 
36 #include <corelib/ncbiobj.hpp>
37 
38 #include <util/range_coll.hpp>
39 
40 #include <gui/gui.hpp>
41 #include <gui/opengl/gltypes.hpp>
42 #include <gui/utils/command.hpp>
43 #include <gui/utils/menu_item.hpp>
46 
52 
53 class wxFileArtProvider;
54 
56 
57 class CUICommandRegistry;
58 
59 class CObjectIndex;
60 class CSeqGraphicConfig;
61 class CSeqGraphicPane;
62 class CSGSequenceDS;
63 class CLayout;
64 class CPrintOptions;
65 class CLayoutTrack;
66 class CwxMarkerInfoDlg;
67 class CSeqMarkerEvent;
68 class CSeqMarkerDlgEvent;
69 class CFeaturePanel;
70 class INonAsnTrackData;
71 
72 class ICommandProccessor;
73 
75  class CSeq_loc;
77 
78 
79 /// Definitions for Sequence Graphical Widget commands
80 ///
108 
109  /// track-related coommands
126 
127  /// dbSNP-specific commands
132  eCmdStudyDisplayToggle // toggle how study graph is displayed
133 };
134 
135 enum {
136  ID_GLCHILDPANE = wxID_HIGHEST + 400,
139 };
140 
142  : public CGlWidgetBase
143  , public IBioseqEditorCB
144  //, public CCommandTarget
145  //, public CScrollbar::IListener
146 {
147  DECLARE_EVENT_TABLE()
148 
149 public:
150  enum FZoomFlag {
151  fAddMargins = 1 << 0,
152  fSaveRange = 1 << 1
153  };
154 
155  typedef int TZoomFlag;
156 
158 
159  static void RegisterCommands(CUICommandRegistry& cmd_reg,
160  wxFileArtProvider& provider);
161 
162  CSeqGraphicWidget(wxWindow* parent,
163  wxWindowID id = wxID_ANY,
164  const wxPoint& pos = wxDefaultPosition,
165  const wxSize& size = wxDefaultSize,
166  long style = wxTAB_TRAVERSAL);
167 
168  //CSeqGraphicWidget(int x, int y, int w, int h, const char* label = NULL);
169  virtual ~CSeqGraphicWidget();
170 
171  void InitBioseqEditor(ICommandProccessor& cmdProcessor);
172  /// @name CGlWidgetBase implementation
173  /// @{
174  virtual CGlPane& GetPort() override;
175  virtual const CGlPane& GetPort() const override;
176  /// @}
177 
178  void OnDataChanging();
179  void OnDataChanged();
180 
181  /// access the data source
182  void SetInputObject(SConstScopedObject& obj);
183  void SetNonAsnInput(const INonAsnTrackData& data);
184  void InitDataSource(SConstScopedObject& obj);
185  CSGSequenceDS* GetDataSource(void) const;
186 
187  CFeaturePanel* GetFeaturePanel();
188 
189  void ConfigureTracksDlg();
190 
191  bool FindText(const string &text, bool match_case);
192  void ResetSearch();
193 
194  void SetExternalGlyphs(const CSeqGlyph::TObjects& objs);
195 
196  void ZoomOnRange(TSeqRange range, TZoomFlag flag);
197 
198  void SetHorizontal(bool b_horz, bool b_flip);
199  bool IsHorizontal() const;
200  bool IsFlipped() const;
201  //bool IsSequenceLabel();
202 
203 
204  /// returns the visible sequence range
205  TModelRange GetVisibleRange(void) const;
206  TSeqRange GetVisibleSeqRange() const;
207 
208  /// indicates visible sequence range has changes
209  bool VisibleRangeChanged() const;
210  void ResetVisibleRangeChanged();
211 
212  /// set/clear selections
213  void SelectObject(const CObject* obj, bool verified);
214  void SelectSeqLoc(const objects::CSeq_loc* loc); // TO DO - clarify semantics
215  void ResetSelection();
216  void ResetRangeSelection();
217  void ResetObjectSelection();
218 
219  /// retrieve selected objects from this widget
220  void GetObjectSelection(TConstObjects& objs) const;
221 
222  /// retrieve set of intervals selected on the sequence
223  const TRangeColl& GetRangeSelection(void) const;
224  void SetRangeSelection(const TRangeColl& ranges);
225  void GetRangeOrObjectSelection(TRangeColl& ranges) const;
226 
227  /// Here is the config object you are going to use to configure yourself.
228  /// make sure all your children who need it have references to it.
229  CRef<CSeqGraphicConfig> GetConfig();
230  /// The config object has changed. Do what is necessary.
231  void UpdateConfig();
232 
233 
234  // Popup
235  //void OnShowPopup(int area);
236  //void SetViewPopupMenuItems(CMenuItem * itm_view, CMenuItem * itm_default);
237  //void OnEditFeature(ncbi::CEvent* evt);
238 
239  void SetScaleX(TModelUnit scale, const TModelPoint& point);
240  void UpdateHeight(TModelUnit height);
241 
242  /// @name Event Handling
243  /// @{
244  void OnSize(wxSizeEvent& event);
245  void OnScrollEnd(wxScrollEvent& event);
246  void OnContextMenu(wxContextMenuEvent& event);
247  void OnSavePdf(wxCommandEvent & evt);
248  void OnEnableSavePdfCmdUpdate(wxUpdateUIEvent& evt);
249  void OnSaveSvg(wxCommandEvent & evt);
250  void OnEnableSaveSvgCmdUpdate(wxUpdateUIEvent& evt);
251 
253 
254  void OnZoomObject(wxCommandEvent& event);
255  void OnPrevSplice(wxCommandEvent& event);
256  void OnNextSplice(wxCommandEvent& event);
257  void OnLoadDefaultTracks(wxCommandEvent& event);
258  void OnCollapseAllTracks(wxCommandEvent& event);
259  void OnExpandAllTracks(wxCommandEvent& event);
260  void OnShowAllTracks(wxCommandEvent& event);
261  void OnHideAllTracks(wxCommandEvent& event);
262  void OnCollapseAllSubtracks(wxCommandEvent& event);
263  void OnExpandAllSubtracks(wxCommandEvent& event);
264  void OnMoveTrackToTop(wxCommandEvent& event);
265  void OnMoveTrackToBottom(wxCommandEvent& event);
266 
267  void OnCloneTrack(wxCommandEvent& event);
268  void OnRemoveTrack(wxCommandEvent& event);
269  void OnAddTrack(wxCommandEvent& event);
270  void OnRenameTrack(wxCommandEvent& event);
271 
272  void OnZoomSelection(wxCommandEvent& event);
273  void OnZoomSequence(wxCommandEvent& event);
274 
275  // update
276  void OnUpdateZoomSelection(wxUpdateUIEvent& event);
277  void OnUpdateZoomObject(wxUpdateUIEvent& event);
278 
279  void OnSetMarker(wxCommandEvent& event);
280  void OnSetSeqMarkerDlg(wxCommandEvent& event);
281  void OnSetSeqMarkerForSelDlg(wxCommandEvent& event);
282  void OnUpdateSetSeqMarkerForSelDlg(wxUpdateUIEvent& event);
283  void OnRenameMarkerDlg(wxCommandEvent& event);
284  void OnModifyMarkerDlg(wxCommandEvent& event);
285  void OnMarkerDetailsDlg(wxCommandEvent& event);
286  void OnZoomAtMarker(wxCommandEvent& event);
287  void OnGoToMarker(wxCommandEvent& event);
288  void OnRemoveMarker(wxCommandEvent& event);
289  void OnRemoveAllMarkersCmd(wxCommandEvent& event);
290  void OnMarkerChanged();
291  void OnResetSeqStart(wxCommandEvent& event);
292  void OnSetSwitchPoint(wxCommandEvent& event);
293 
294  void OnSetSeqStart(wxCommandEvent& event);
295  void OnSetSeqStartMarker(wxCommandEvent& event);
296 
297  void OnAdjustRuler(wxCommandEvent& event);
298  void OnUpdateAdjustRuler(wxUpdateUIEvent& event);
299 
300  void OnHairlineOptions(wxCommandEvent& event);
301  void OnSeqGotoCmd(wxCommandEvent& event);
302  //void OnViewProperties(wxCommandEvent& event);
303 
304 
305  // Back / Forward
306  void OnUpdateGoBack(wxUpdateUIEvent& event);
307  void OnUpdateGoForward(wxUpdateUIEvent& event);
308  void OnGoBack(wxCommandEvent& event);
309  void OnGoForward(wxCommandEvent& event);
310 
311  void OnVertical(wxCommandEvent& event);
312  void OnUpdateVertical(wxUpdateUIEvent& event);
313 
314  void OnUpdateSetSwitchPoint(wxUpdateUIEvent& event);
315 
316  void OnFlipStrands(wxCommandEvent& event);
317  void OnUpdateFlipStrands(wxUpdateUIEvent& event);
318 
319  //void OnEditUndo();
320  //void OnEditRedo();
321  void OnEditCut(wxCommandEvent& event);
322  void OnEditCopy(wxCommandEvent& event);
323  void OnEditPaste(wxCommandEvent& event);
327 
328  void OnObjToRangeSelection();
329  void OnRangeToObjSelection();
330 
331  void OnSeqGoto(CSequenceGotoEvent& event);
332  void OnSeqGotoClose(CSequenceGotoEvent& event);
333  void OnRemoveAllMarkers(CSeqMarkerDlgEvent& event);
334  void OnRemoveMarker_Info(CSeqMarkerEvent& event);
335  void OnMarkerInfoDlgClose(CSeqMarkerDlgEvent& event);
336 
337  /// @name event handler for sticky tooltip
338  /// @{
339  void OnSearchTip(wxCommandEvent& evt);
340  void OnZoomTip(wxCommandEvent& evt);
341  void OnInfoTip(wxCommandEvent& evt);
342  void OnTipActivated(wxCommandEvent& evt);
343  void OnTipDeactivated(wxCommandEvent& evt);
344  void OnMoveTip(wxCommandEvent& evt);
345  void OnTipAdded(wxCommandEvent& evt);
346  void OnTipRemoved(wxCommandEvent& evt);
347  /// @}
348 
349  /// Get markers as a string.
350  /// The syntax for markers string is: pos|name|color[,pos|name|color].
351  /// Name and color are optional.
352  string GetMarkers() const;
353  void SetMarkers(const string& markers);
354 
355  void SaveViewSettings();
356 
357  /// check if there is any visible range or marker change
358  bool IsDirty() const;
359  void SetDirty(bool flag);
360 
361  // IBioseqEditorCB
362  virtual void GetItemSelection(TFlatItemList&) override {}
363  virtual void GetCurrentSelection(TEditObjectList& objs) override;
364  virtual objects::CBioseq_Handle GetCurrentBioseq() override;
365  virtual wxString GetWorkDir() const override {return m_WorkDir;}
366  virtual bool MayCreateFeatures() const override { return false; }
367 
368  void SetWorkDir(const wxString& workDir) { m_WorkDir = workDir; }
369 protected:
370  /// Creates Pane, Scrollbars and other child widgets, called from Create()
371  //virtual void x_CreateControls();
372 
373  /// @name CGlWidgetBase overridables
374  /// @{
375  virtual void x_CreatePane() override;
376  virtual CGlWidgetPane* x_GetPane() override;
377  virtual void x_Update() override;
378  virtual void x_SaveStates() override;
379  virtual void x_SetPortLimits() override;
380  virtual void x_UpdateOnVScroll() override;
381  /// @}
382 
383  /// @name CScrollbar::IListener implementation
384  /// @{gg
385  //virtual void OnScroll(CScrollbar* scrollbar);
386  //virtual void OnEndScroll(CScrollbar* scrollbar);
387  /// @}
388 
389  virtual void x_UpdatePane();
390 private:
391  void x_SaveDefaultScoringMethod(string name);
392  /// forbidden
393  //CSeqGraphicWidget(const CSeqGraphicWidget&);
394  //CSeqGraphicWidget& operator=(const CSeqGraphicWidget&);
395  wxMenu* x_CreatePopupMenu(int area);
396  CLayoutTrack* x_GetCurrentHitTrack();
397  void x_RemoveAllMarkers();
398  void x_UpdateMarkerInfo();
399  void x_SaveVectorImage(CPrintOptions::EOutputFormat format);
400 
401 protected:
403 
404 private:
406 
407  //friend class CSeqGraphicPane;
408  //CScrollbar* m_ScrollX;
409  //CScrollbar* m_ScrollY;
410 
411  //CSeqGraphicPane* m_SeqGraphicPane;
412  unique_ptr<CSeqGraphicPane> m_SeqGraphicPane;
413 
414  //CMenuItem* m_pViewPopupItems;
415  //CMenuItem* m_pViewDefaultPopupItems;
416 
418 
419 
423 
424  // flag indicating if any change on visible range or marker.
425  bool m_Dirty;
426 
428  wxString m_WorkDir;
431 };
432 
433 ///////////////////////////////////////////////////////////////////////////////
434 /// CSeqGraphicWidget inline methods
435 ///
436 inline
438 {
439  const TModelRect& mrc = m_Port.GetVisibleRect();
440  return TModelRange(mrc.Left(), mrc.Right());
441 }
442 
443 inline
445 {
446  const TModelRect& mrc = m_Port.GetVisibleRect();
447  return TSeqRange(TSeqPos(mrc.Left()), TSeqPos(mrc.Right()));
448 }
449 
450 
451 
453 
454 #endif /* GUI_WIDGETS_SEQ_GRAPHIC___SEQGRAPHIC_WIDGET__HPP */
class CGlPane
Definition: glpane.hpp:62
class CGlWidgetBase
void OnSize(wxSizeEvent &event)
virtual void x_UpdateOnVScroll()
virtual void x_SaveStates()
virtual CGlPane & GetPort()=0
implement these 2 functions in derived classes
virtual void x_SetPortLimits(void)=0
updates model limits of the Master CGlPane
virtual void x_CreatePane()=0
factory method creating master pane, called form x_CreateControls()
virtual CGlWidgetPane * x_GetPane()
virtual void x_Update()
Update handlers.
CGlWidgetPane represent a window component residing in CGlWidgetBase client area.
File Description:
class CLayout is a container of objects laid out in a series of rows or tracks.
Definition: layout.hpp:229
CObject –.
Definition: ncbiobj.hpp:180
list< CRef< CSeqGlyph > > TObjects
Definition: seq_glyph.hpp:85
class CSeqGraphicPane
CwxMarkerInfoDlg * m_MarkerInfoDlg
TSeqRange GetVisibleSeqRange() const
void OnDeleteSelection()
TModelRange GetVisibleRange(void) const
returns the visible sequence range
virtual const CGlPane & GetPort() const override
implement these 2 functions in derived classes
void x_SaveDefaultScoringMethod(string name)
void OnDeleteSelectionAndOrphaned()
map< int, string > TCmdToName
virtual wxString GetWorkDir() const override
CRangeCollection< TSeqPos > TRangeColl
CSequenceGotoDlg * m_SequenceGotoDlg
void SetWorkDir(const wxString &workDir)
unique_ptr< CSeqGraphicPane > m_SeqGraphicPane
virtual bool MayCreateFeatures() const override
virtual void GetItemSelection(TFlatItemList &) override
CSequenceGotoData m_SequenceGotoData
CIRef< IBioseqEditor > m_BioseqEditor
CUICommandRegistry is a centralized registry where all application commands should be registered.
Definition: ui_command.hpp:146
virtual objects::CBioseq_Handle GetCurrentBioseq()=0
virtual void GetCurrentSelection(TEditObjectList &)=0
Undo/Redo interface for editing operations.
GUI command routing and handling framework.
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
T Right() const
Definition: glrect.hpp:83
T Left() const
Definition: glrect.hpp:81
CRange< TModelUnit > TModelRange
Definition: gltypes.hpp:56
TModelRect & GetVisibleRect(void)
Definition: glpane.hpp:357
vector< CConstRef< CObject > > TConstObjects
Definition: objects.hpp:64
@ eBaseCmdLast
Definition: command.hpp:111
CRange< TSeqPos > TSeqRange
typedefs for sequence ranges
Definition: range.hpp:419
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define NCBI_GUIWIDGETS_SEQGRAPHIC_EXPORT
Definition: gui_export.h:536
vector< CEditObject > TEditObjectList
vector< CConstRef< objects::IFlatItem > > TFlatItemList
static void text(MDB_val *v)
Definition: mdb_dump.c:62
range(_Ty, _Ty) -> range< _Ty >
const struct ncbi::grid::netcache::search::fields::SIZE size
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
static Format format
Definition: njn_ioutil.cpp:53
static static static wxID_ANY
@ ID_VSCROPLLBAR
@ ID_HSCROPLLBAR
@ ID_GLCHILDPANE
ESeqGraphicsCommands
Definitions for Sequence Graphical Widget commands.
@ eCmdMoveTrackToBottom
@ eCmdStrandFlipped
@ eCmdSetMarkerDlg
@ eCmdCollapseAllTracks
@ eCmdFlipStrand
@ eCmdSetSeqStart
@ eCmdSetSeqStartMarker
@ eCmdSnpTable
@ eCmdMarkerDetailsDlg
@ eCmdSequenceLabel
@ eCmdSnpFilter
@ eCmdRemoveMarker
@ eCmdTrackSettings
@ eCmdCollapseAllSubtracks
@ eCmdCreateSnpFilteredTrack
@ eCmdZoomObject
@ eCmdCloneTrack
@ eCmdShowAllTracks
@ eCmdGoToMarker
@ eCmdRemoveTrackFromOverlay
@ eCmdSetMarkerForSelDlg
@ eCmdSetMarker
@ eCmdPrevSplice
@ eCmdStudyDisplayToggle
@ eCmdResetSeqStart
@ eCmdLoadDefaultTracks
track-related coommands
@ eCmdExpandAllSubtracks
@ eCmdResetSeqMarker
@ eCmdRenameTrack
@ eCmdModifyMarkerDlg
@ eCmdRenameMarkerDlg
@ eCmdSetSwitchPoint
@ eCmdHideAllTracks
@ eCmdChangeViewMode
@ eCmdAddTrack
@ eCmdResetMarker
@ eCmdConfigChanged
@ eCmdMoveTrackToTop
@ eCmdSnpWebLinkout
dbSNP-specific commands
@ eCmdRemoveTrack
@ eCmdHideTrack
@ eCmdZoomAtMarker
@ eCmdAdjustRuler
@ eCmdHairlineOptions
@ eCmdExpandAllTracks
@ eCmdAnnotConfig
@ eCmdNextSplice
Modified on Wed Jul 17 13:19:11 2024 by modify_doxy.py rev. 669887