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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_ALNMULTI___ALNMULTI_WIDGET__HPP
2 #define GUI_WIDGETS_ALNMULTI___ALNMULTI_WIDGET__HPP
3 
4 /* $Id: alnmulti_widget.hpp 44954 2020-04-27 17:57:36Z 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: Andrey Yazhuk
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbiobj.hpp>
36 
40 
41 #include <gui/utils/command.hpp>
42 #include <gui/utils/menu_item.hpp>
43 
45 
47 
48 #include <util/range_coll.hpp>
49 
50 class wxMenu;
51 class wxFileArtProvider;
52 
54 
55 /// Definitions for Multiple Alignment Widget commands
56 ///
58  eCmdSetSelMaster = eBaseCmdLast + 1, // make selected sequence Master
60 
64 
69 
71 
73 };
74 
75 
76 class CUICommandRegistry;
78 class CGuiRegistry;
79 
81  class CScope;
83 
84 ////////////////////////////////////////////////////////////////////////////////
85 /// class CAlnMultiWidget
86 ///
87 /// CAlnMultiWidget is a reusable component for visual presntations of multiple
88 /// alignments. CAlnMultiWidget works as Mediator to organize interaction of its
89 /// internal components and to support communication with external components.
90 /// Data Source is an external component that serves as a source of alignment
91 /// data. CAlnMultiWidget builds a visual Model object around provided Data
92 /// Source and uses CAlnMultiPane component to represent this model.
93 /// CAlnMultiWidget provides API for external components allowing for
94 /// executing commands and retrieving state information such as selections.
95 
97  : public CGlWidgetBase,
98  public IAlnMultiPaneParent, // Widget-Pane relashionship
99  public CDataChangeNotifier::IListener,
100  public CScoreCache::IListener
101 {
102  DECLARE_EVENT_TABLE()
103 public:
105  typedef int TLine;
106  typedef list<objects::CSeq_loc*> TPSeqLocList;
108  typedef vector<CConstRef<objects::CSeq_id> > TRSeqIdVector;
109 
110  static void RegisterCommands(CUICommandRegistry& cmd_reg, wxFileArtProvider& provider);
111 
112  CAlnMultiWidget(wxWindow* parent,
113  wxWindowID id = wxID_ANY,
114  const wxPoint& pos = wxDefaultPosition,
115  const wxSize& size = wxDefaultSize,
116  long style = 0,
117  const wxString& name = wxT("panel"));
118  virtual ~CAlnMultiWidget();
119 
120  /// @name CGlWidgetBase virtual functions
121  /// @{
122  virtual CGlPane& GetPort();
123  virtual const CGlPane& GetPort() const;
124  virtual void x_SetPortLimits(void) {};
125  virtual CGlWidgetPane* x_GetPane();
126 
127  virtual void LoadSettings();
128  virtual void SaveSettings() const;
129  /// @}
130 
131  virtual void SetDataSource(IAlnMultiDataSource* p_ds, objects::CScope* scope);
132 
133  /// performs initialization, creates Model and Controls. Call Create()
134  /// right after constructing CAlnMultiWidget; assumes ownership of the
135  /// model. If model == NULL, creates a default model
136  virtual void CreateWidget(CAlnMultiModel* model=NULL);
137 
138  virtual CAlnMultiModel* GetModel();
139  virtual const CAlnMultiModel* GetModel() const;
140 
141  virtual void SetStyleCatalog(const CRowStyleCatalog* catalog);
142  virtual const CWidgetDisplayStyle* GetDisplayStyle() const;
143 
144  /// makes specified rows visible/hidden, other rows aren't affected
145  virtual void SetVisible(const vector<TNumrow>& rows, bool b_visible,
146  bool b_invert_others = false);
147 
148  virtual void Select(const vector<TNumrow>& rows, bool b_select,
149  bool b_invert_others = false);
150 
151  /// @name IAlnMultiRenderContext implementation
152  /// @{
153  virtual bool IsRendererFocused();
154  /// @}
155 
156  virtual IAlnMultiDataSource* GetDataSource();
157 
158  /// @name IAlnMultiPaneParent implementation
159  /// @{
160  virtual const IAlnMultiDataSource* GetDataSource() const;
161  virtual TNumrow GetRowNumByLine(TLine line) const;
162  virtual int GetLineByRowNum(TNumrow Row) const;
163 
164  virtual void OnChildResize();
165  virtual void SetScaleX(TModelUnit scale_x, const TModelPoint& point);
166  virtual void ZoomRect(const TModelRect& rc);
167  virtual void ZoomPoint(const TModelPoint& point, TModelUnit factor);
168  virtual void Scroll(TModelUnit d_x, TModelUnit d_y);
169  virtual void OnRowChanged(IAlignRow* p_row);
170 
171  virtual void OnColumnsChanged();
172  /// @}
173 
174  /// @name CUIDataSource::IListener implementation
175  /// @{
176  virtual void OnDSChanged(CDataChangeNotifier::CUpdate& update);
177  /// @}
178 
179  /// @name CAlnMultiModel::IListener implementation
180  /// @{
181  virtual void OnScoringProgress(float progress, const string& msg);
182  virtual void OnScoringFinished();
183  /// @}
184 
185  void OnContextMenu(wxContextMenuEvent& event);
186 
187  /// @name Command Handlers
188  /// @{
189  void OnSavePdf(wxCommandEvent & evt);
190  void OnEnableSavePdfCmdUpdate(wxUpdateUIEvent& evt);
191  void OnSaveSvg(wxCommandEvent & evt);
192  void OnEnableSaveSvgCmdUpdate(wxUpdateUIEvent& evt);
193 
194  void OnZoomSequence(wxCommandEvent& event);
195  void OnZoomSelection(wxCommandEvent& event);
196  void OnUpdateZoomSelection(wxUpdateUIEvent& event);
197 
198  void OnMakeSelectedRowMaster(wxCommandEvent& event);
199  void OnUpdateMakeSelectedRowMaster(wxUpdateUIEvent& event);
200  void OnUnsetMaster(wxCommandEvent& event);
201  void OnUpdateUnsetMaster(wxUpdateUIEvent& event);
202  void OnMakeConsensusRowMaster(wxCommandEvent& event);
203  void OnUpdateMakeConsensusRowMaster(wxUpdateUIEvent& event);
204 
205  void OnResetSelection(wxCommandEvent& event);
206 
207  void OnMarkSelected(wxCommandEvent& event); /// mark selected regions of selected rows
208  void OnUnMarkSelected(wxCommandEvent& event); /// unmark selected regions of selected rows
209  void OnUpdateMarkSelected(wxUpdateUIEvent& event);
210  void OnUnMarkAll(wxCommandEvent& event); // remove all marks
211 
212  void OnHideSelected(wxCommandEvent& event); /// hide selected rows
213  void OnUnhideSelected(wxCommandEvent& event); /// hide selected rows
214  void OnUpdateUnhideSelected(wxUpdateUIEvent& event);
215 
216  void OnHasSelected(wxUpdateUIEvent& event);
217  void OnShowOnlySelected(wxCommandEvent& event); /// hide rows that are not selected
218  void OnShowAll(wxCommandEvent& event); /// show all hidden rows
219 
220  void OnMoveSelectedUp(wxCommandEvent& event);
221 
222  void OnSettings(wxCommandEvent& event);
223  void OnUpdateSettings(wxUpdateUIEvent& event);
224  /// @}
225 
226  /// @name Command handler for Scoring methods management
227  /// @{
228  void OnShowMethodDlg(wxCommandEvent& event);
229  void OnUpdateShowMethodDlg(wxUpdateUIEvent& event);
230 
231  void OnDisableScoring(wxCommandEvent& event);
232  void OnUpdateDisableScoring(wxUpdateUIEvent& event);
233 
234  void OnMethodProperties(wxCommandEvent& event);
235  void OnUpdateMethodProperties(wxUpdateUIEvent& event);
236 
237  void OnScoringMethod(wxCommandEvent& event);
238  void OnUpdateScoringMethod(wxUpdateUIEvent& event);
239 
240  void OnSetAsDefaultMethod(wxCommandEvent& event);
241  /// @}
242 
243  /// @name Selection handling
244  /// @{
245  void GetSelectedIds(TRSeqIdVector& ids) const;
246  void SetSelectedIds(const TRSeqIdVector& ids, objects::CScope& scope);
247  void GetSelectedRows(vector<TNumrow>& rows);
248 
249  const TRangeColl& GetSelection(void) const;
250  void SetSelection(const TRangeColl& coll);
251  void GetMarks(TPSeqLocList& ls_locs) const;
252  void GetObjectSelection(TConstObjects &objs) const;
253  bool HasSelectedObjects() const;
254  /// @}
255 
256  virtual void UpdateSortOrder();
257  virtual void UpdateOnScoringChanged();
258 
259  void ZoomToSelection();
260 
261  void Print(const string& filename);
262  void UpdateView();
263 
264  bool SaveVectorImage(CPrintOptions::EOutputFormat format, string const &path, string const &file_name, bool show_header, bool simplified);
265 
266 protected:
267  void x_CreatePane(void);
268 
269  /// factory method creating and initializing a default model
270  virtual CAlnMultiModel* x_CreateModel();
271 
272  //virtual void x_CreateControls(void); ///factory method
273 
274  /// @name Update handlers
275  /// Functions in this group are called by the widget when something changes.
276  /// Each functions performs minimal set of operations needed to keep widget
277  /// up-to-date.
278  /// @{
279  virtual void x_UpdateOnDataChanged(bool b_reset = true);
280 
281  virtual void x_UpdateOnRowHChanged(void);
282  virtual void x_UpdateOnSwitchMaster(TNumrow NewMasterRow);
283  virtual void x_UpdateOnZoom(void);
284  virtual void x_UpdateOnStylesChanged(void);
285  virtual void x_OnResize(void);
286  /// @}
287 
288  //virtual void x_SetScrollbars(void);
289  virtual void x_AdjustVisible(bool b_reset);
290  virtual void x_RedrawControls(void);
291 
292  virtual void x_UpdateStyleColumns();
293 
294  void x_ZoomToRange(TSeqPos from, TSeqPos to);
295 
296  void x_MakeVisibleHorz(TSeqPos pos);
297  void x_MakeVisibleHorz(TSeqPos from, TSeqPos to);
298 
299  virtual wxMenu* x_CreatePopupMenu();
300 
301  virtual string x_GetCurrentMethodName() const;
302  virtual void x_SetScoringMethod(const string& method_name, bool save);
303  virtual void x_CreateScoringMethodsMenu(wxMenu& color_menu);
304 
305  virtual string* x_GetDefMethodName();
306  virtual string x_GetScoringMRUListName();
307 
308  void x_GetMatchingHiddenRows(vector<TNumrow>& rows);
309 
310  void x_OnSaveVectorImage(CPrintOptions::EOutputFormat format);
311 protected:
313 
314  IAlnMultiDataSource* m_DataSource; /// source of alignment data
315 
316  CAlnMultiModel* m_Model; /// representation of alignment data
317 
318  CAlnMultiPane* m_AlignPane; /// widget rendering data and handling events
319 
321 };
322 
323 
325 
326 
327 #endif // GUI_WIDGETS_ALNMULTI___ALNMULTI_WIDGET__HPP
EAlnMultiCommands
Definitions for Multiple Alignment Widget commands.
@ eCmdMarkSelected
@ eCmdShowAll
@ eCmdUnsetMaster
@ eCmdUnMarkAll
@ eCmdMoveSelectedUp
@ eCmdUnMarkSelected
@ eCmdRebuildAlignment
@ eCmdSetSelMaster
@ eCmdShowOnlySelected
@ eCmdUnhideSelected
@ eCmdHideSelected
class CAlnMultiModel - represents a visual model of an alignment.
class CAlnMultiPane
class CAlnMultiWidget
CAlnMultiModel::TNumrow TNumrow
CAlnMultiPane * m_AlignPane
representation of alignment data
IAlnMultiDataSource * m_DataSource
TCmdToName m_CmdToName
widget rendering data and handling events
vector< CConstRef< objects::CSeq_id > > TRSeqIdVector
virtual void x_SetPortLimits(void)
updates model limits of the Master CGlPane
CAlnMultiModel * m_Model
source of alignment data
list< objects::CSeq_loc * > TPSeqLocList
map< int, string > TCmdToName
CRangeCollection< TSeqPos > TRangeColl
CUpdate - notification send by CUIDataSource to the listener.
Data notification relay class, sends data change notifications to the subscribed listener.
class CGlPane
Definition: glpane.hpp:62
class CGlWidgetBase
CGlWidgetPane represent a window component residing in CGlWidgetBase client area.
CRowStyleCatalog is a collection of CRowDisplayStyle-s assigned to rows in alignment.
CScope –.
Definition: scope.hpp:92
CUICommandRegistry is a centralized registry where all application commands should be registered.
Definition: ui_command.hpp:146
CWidgetDisplayStyle is a collection of display properties common for all rows in the CAlnMultiWidget.
Interface IAlignRow - abstracts row rendering in Multiple Alignment Widget.
Definition: ialign_row.hpp:67
IAlnMultiDataSource - interface to a data source representing an abstract multiple alignment.
Interface IAlnMultiPaneParent represents a context in which an instance of CAlnMultiPane lives.
IAlnExplorer::TNumrow TNumrow
GUI command routing and handling framework.
void Print(const CCompactSAMApplication::AlignInfo &ai)
const char * file_name[]
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define NULL
Definition: ncbistd.hpp:225
GLdouble TModelUnit
Definition: gltypes.hpp:48
vector< CConstRef< CObject > > TConstObjects
Definition: objects.hpp:64
@ eBaseCmdLast
Definition: command.hpp:111
#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
unsigned short GetPort() const
Get the listening port number back.
#define NCBI_GUIWIDGETS_ALNMULTIPLE_EXPORT
Definition: gui_export.h:520
#define wxT(x)
Definition: muParser.cpp:41
vector< CConstRef< CSeq_id > > TRSeqIdVector
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
static const char * catalog
Definition: stats.c:19
Modified on Wed Feb 28 07:13:50 2024 by modify_doxy.py rev. 669887