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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_PHYLO_TREE___PHYLO_TREE_WIDGET__HPP
2 #define GUI_WIDGETS_PHYLO_TREE___PHYLO_TREE_WIDGET__HPP
3 
4 /* $Id: phylo_tree_widget.hpp 42391 2019-02-14 18:25:12Z 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: Vladimir Tereshkov
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbiobj.hpp>
36 
39 
41 
42 #include <gui/utils/command.hpp>
43 #include <gui/utils/menu_item.hpp>
44 
47 
48 #include <gui/opengl/gldlist.hpp>
49 #include <gui/opengl/gltypes.hpp>
50 
52 
53 #include <wx/tglbtn.h>
54 #include <wx/statline.h>
55 #include <wx/panel.h>
56 #include <wx/stattext.h>
57 #include <wx/statline.h>
58 #include <wx/statbox.h>
59 #include <wx/combobox.h>
60 #include <wx/sizer.h>
61 #include <wx/button.h>
62 #include <wx/srchctrl.h>
63 #include <wx/checkbox.h>
64 #include <wx/animate.h>
65 #include <wx/toolbar.h>
66 
67 
68 class wxFileArtProvider;
69 
71 
72 class CUICommandRegistry;
73 class CGuiRegistry;
74 class CMacroQueryExec;
75 
76 
77 /// Definitions for Phylo Tree Widget commands
111 
115 
117 
121 
131 
146 };
147 
148 ////////////////////////////////////////////////////////////////////////////////
149 /// class CPhyloTreeWidget
151  : public CGlWidgetBase
152  , public IQueryWidget
153 {
154  DECLARE_EVENT_TABLE()
155 public:
156 
157  static void RegisterCommands(CUICommandRegistry& cmd_reg, wxFileArtProvider& provider);
158 
159  CPhyloTreeWidget(wxWindow* parent,
160  wxWindowID id = wxID_ANY,
161  const wxPoint& pos = wxDefaultPosition,
162  const wxSize& size = wxDefaultSize,
163  long style = wxTAB_TRAVERSAL,
164  const wxString& name = wxT("panel"));
165 
166  virtual ~CPhyloTreeWidget();
167 
168  virtual void SetDataSourceNoUpdate(CPhyloTreeDataSource* p_ds);
169  virtual void SetDataSource(CPhyloTreeDataSource* p_ds);
170  virtual void RemoveCurrentDataSource();
171  /// Force tree to be re-masured and call layout
172  virtual void RedrawDataSource();
173 
174  virtual CPhyloTreeDataSource* GetDS(void);
175  virtual CGlPane& GetPort();
176  virtual const CGlPane& GetPort() const;
177  virtual void OnSetScaleXY(TModelUnit scale_x, const TModelPoint& point);
178 
179  /// this will forward events to fix opengl bug (windows) to pane
180  virtual void DlgOverlayFix(wxWindow* win);
181 
182  /// Command handlers
183 
184  void OnContextMenu(wxContextMenuEvent&);
185 
186  void OnPrint(wxCommandEvent & evt);
187  void OnEnablePrintCmdUpdate(wxUpdateUIEvent& evt);
188  void OnSaveImages(wxCommandEvent & evt);
189  void OnSetEqualScale(wxCommandEvent & evt);
190  void OnEnableSaveImagesCmdUpdate(wxUpdateUIEvent& evt);
191  void OnSavePdf(wxCommandEvent & evt);
192  void OnEnableSavePdfCmdUpdate(wxUpdateUIEvent& evt);
193  void OnSetGraphType1(wxCommandEvent & evt);
194  void OnSetGraphType2(wxCommandEvent & evt);
195  void OnSetGraphType3(wxCommandEvent & evt);
196  void OnSetGraphType4(wxCommandEvent & evt);
197  void OnSetGraphType5(wxCommandEvent & evt);
198  void OnRotateLabels(wxCommandEvent & evt);
199  void OnStopLayout(wxCommandEvent & evt);
200  void OnUseDistances(wxCommandEvent & evt);
201  void OnUseSplines(wxCommandEvent & evt);
202  void OnOpenPropertiesDlg(wxCommandEvent & evt);
203  void OnRerootTree(wxCommandEvent & evt);
204  void OnRerootTreeAtEdge(wxCommandEvent & evt);
205  void OnSetMidpointRoot(wxCommandEvent & evt);
206  void OnSelectAll(wxCommandEvent & evt);
207  void OnClearSelection(wxCommandEvent & evt);
208  void OnAddSelectionSet(wxCommandEvent & evt);
209  void OnExportSelection(wxCommandEvent & evt);
210  void OnExportTree(wxCommandEvent & evt);
211  void OnInverseSelection(wxCommandEvent & evt);
212  void OnExpandChildren(wxCommandEvent & evt);
213  void OnHighlightCollapsed(wxCommandEvent & evt);
214  void OnHighlightEdges(wxCommandEvent & evt);
215  void OnCollapseToViewport(wxCommandEvent & evt);
216  void OnCollapseSelected(wxCommandEvent & evt);
217  void OnCollapseChildren(wxCommandEvent & evt);
218  void OnZoomToSubtree(wxCommandEvent & evt);
219  void OnShowAll(wxCommandEvent & evt);
220  void OnEditNode(wxCommandEvent & evt);
221  void OnFilterDistances(wxCommandEvent & evt);
222  void OnZoomXY(wxCommandEvent & evt);
223  void OnZoomX(wxCommandEvent & evt);
224  void OnZoomY(wxCommandEvent & evt);
225  void OnZoomToSelection(wxCommandEvent & evt);
226  void OnGoBack(wxCommandEvent& evt);
227  void OnGoForward(wxCommandEvent& evt);
228  void OnUpdateGoBack(wxUpdateUIEvent& evt);
229  void OnUpdateGoForward(wxUpdateUIEvent& evt);
230 
231 
232  void OnSort(wxCommandEvent & evt);
233  void OnSortAscending(wxCommandEvent & evt);
234  void OnClean(wxCommandEvent & evt);
235  void OnFilter(wxCommandEvent & evt);
236  void OnEditLabel(wxCommandEvent & evt);
237  void OnLoadAttributes(wxCommandEvent & evt);
238 
239  void OnLabels(wxCommandEvent & evt);
240  void OnUpdateLabels(wxUpdateUIEvent& evt);
241 
242  void OnUpdateEditLabel(wxUpdateUIEvent& evt);
243 
244  void OnSetTreeLabel(wxCommandEvent & evt);
245 
246  void OnAl(wxCommandEvent & evt);
247  void OnUpdateAl(wxUpdateUIEvent& evt);
248 
249  void OnEdit(wxCommandEvent & evt);
250  void OnUpdateEdit(wxUpdateUIEvent& evt);
251 
252 
253  // modded zoom handlers
254  virtual void x_ZoomIn(int options);
255  virtual void x_ZoomOut(int options);
256 
257  // update handlers
258  void OnUpdateZoomXY(wxUpdateUIEvent& evt);
259  void OnUpdateZoomX(wxUpdateUIEvent& evt);
260  void OnUpdateZoomY(wxUpdateUIEvent& evt);
261  void OnUpdateZoomSel(wxUpdateUIEvent& evt);
262 
263  void OnUpdateEditNode(wxUpdateUIEvent& evt);
264  void OnUpdateRotateLabels(wxUpdateUIEvent& evt);
265  void OnUpdateStopLayout(wxUpdateUIEvent& evt);
266  void OnUpdateUseDistances(wxUpdateUIEvent& evt);
267  void OnUpdateSortAscending(wxUpdateUIEvent& evt);
268  void OnUpdateUseSplines(wxUpdateUIEvent& evt);
269  void OnUpdateSetGraphType1(wxUpdateUIEvent& evt);
270  void OnUpdateSetGraphType2(wxUpdateUIEvent& evt);
271  void OnUpdateSetGraphType3(wxUpdateUIEvent& evt);
272  void OnUpdateSetGraphType4(wxUpdateUIEvent& evt);
273  void OnUpdateSetGraphType5(wxUpdateUIEvent& evt);
274  void OnUpdateRerootTree(wxUpdateUIEvent& evt);
275  void OnUpdateRerootTreeAtEdge(wxUpdateUIEvent& evt);
276  void OnUpdateSetMidpointRoot(wxUpdateUIEvent& evt);
277  void OnUpdateShowAll(wxUpdateUIEvent& evt);
278 
279  void OnUpdateCollapseChildren(wxUpdateUIEvent& evt);
280  void OnUpdateExpandChildren(wxUpdateUIEvent& evt);
281  void OnUpdateCollapseSelected(wxUpdateUIEvent& evt);
282 
283  void OnUpdateZoomToSubtree(wxUpdateUIEvent& evt);
284 
285  void OnSubtreeFromSelection(wxCommandEvent & evt);
286 
287  void OnSearchTip(wxCommandEvent & evt);
288  void OnZoomTip(wxCommandEvent & evt);
289  void OnInfoTip(wxCommandEvent & evt);
290  void OnTipActivated(wxCommandEvent & evt);
291  void OnTipDeactivated(wxCommandEvent & evt);
292  void OnUpdateSubtreeFromSelection(wxUpdateUIEvent& evt);
293 
294  void OnUpdateSelChanged();
295 
296  void UpdateViewingArea();
297 
298  void SetCurrRenderer(int idx);
299  int GetCurrRenderer() const;
300  vector<string> GetRenderersNames(void);
301 
302  virtual void OnShowPopup() {}
303 
304  void SendSelChangedEvent();
305  void SendEditEvent(EPhyloTreeEditCommand ec=eCmdSomethingEdited);
306  void SetPortLimits(const TModelRect & rect, bool bZoomAll=true);
307  void SetPopupMenuItems(CMenuItem * itm);
308  void SetScheme(CPhyloTreeScheme & sl);
309  void SetRegistryPath(const string& reg_path);
310  void LoadSettings();
311  void SaveSettings() const;
312  void SetUseDistances(bool bDist);
313  bool GetUseDistances() const;
314  void SetRotateLabels(bool rot);
315  bool GetRotateLabels() const;
316  void EditLabel();
317 
318  bool HasScheme(void) {return !m_pScheme.Empty(); }
319  CPhyloTreeScheme & GetScheme(void) {return m_pScheme.GetObject(); }
320 
321  /// @name IQueryWidget interface implementation
322  /// @{
323  virtual string GetSearchHelpAddr() const
324  { return string("www.ncbi.nlm.nih.gov/tools/gbench/tutorial3/#Tree_View_Search"); }
325 
326  /// Disable any widgets that the user should not use during the query
327  virtual void QueryStart();
328  /// Re-enable any widgets disabled during the query.
329  virtual void QueryEnd(CMacroQueryExec* exec);
330 
331  /// Advance to previous/next selected row from query (in current sort order)
332  void IterateSelection(int dir);
333  /// Set to true to show all rows selected by most recent query as selected
334  virtual void SetSelectAll(bool b);
335 
336  /// If true, only rows that were selected by prevous query will be shown
337  virtual void SetHideUnselected(bool b);
338  /// @}
339 
340  void SetQueryPanel(CQueryParsePanel* queryPanel);
341 
342 protected:
343  // CGlWidgetBase overridables
344  virtual void x_CreatePane(void);
345  virtual CGlWidgetPane* x_GetPane();
346 
347  virtual void x_SetPortLimits(void);
348 
349  virtual void x_Update();
350  virtual void x_UpdatePane();
351  virtual void x_SoftUpdate();
352 
353  virtual void x_SaveStates();
354 
355  virtual void x_CreateControls();
356 
357  void x_IterateSelection(int dir);
358 
359 protected:
368 
369  // This is to allows us to recenter the view after expand/collapse
371  CGlPane m_PrevPane; // projection pane before expand/collapse
372  CVect2<float> m_PrevPos; // position of node before expand/collapse
373 };
374 
375 
377 
378 #endif // GUI_WIDGETS_PHYLO_TREE___PHYLO_TREE_WIDGET__HPP
class CGlPane
Definition: glpane.hpp:62
class CGlWidgetBase
virtual void SetRegistryPath(const string &reg_path)
virtual void x_SaveStates()
virtual void x_ZoomIn(int options)
Zoom functions.
virtual void LoadSettings()
virtual CGlPane & GetPort()=0
implement these 2 functions in derived classes
virtual void x_ZoomOut(int options)
virtual void x_CreateControls(void)
creates Pane, Scrollbars and other child widgets, called from Create()
virtual void x_SetPortLimits(void)=0
updates model limits of the Master CGlPane
virtual void SaveSettings() const
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.
class CMacroQueryExec
CMenuItem - represents a menu items in IMenu-style menus.
Definition: menu_item.hpp:53
class CPhyloTreePane
class CPhyloTreeWidget
void OnHighlightCollapsed(wxCommandEvent &evt)
CRef< CPhyloTreeDataSource > m_DataSource
CVect2< float > m_PrevPos
virtual void OnShowPopup()
CPhyloTreePane * m_pPhyloTreePane
CRef< CGuiRegistry > m_ConfigCache
void OnInverseSelection(wxCommandEvent &evt)
void x_IterateSelection(int dir)
CRef< CPhyloTreeScheme > m_pScheme
virtual string GetSearchHelpAddr() const
Return web-address for the help page that disusses help for the specific widget.
CQueryParsePanel * m_QueryPanel
CPhyloTreeScheme & GetScheme(void)
EPhyloTreeEditCommand m_LastCommand
CQueryParsePanel.
CUICommandRegistry is a centralized registry where all application commands should be registered.
Definition: ui_command.hpp:146
IQueryWidget.
virtual void SetHideUnselected(bool)
set to true to hide/obscure elements not selected by most recent query
virtual void IterateSelection(int)
go to next(1), previous(-1) or first(0) element from most recent query
virtual void SetSelectAll(bool)
set to yes to show all queried elements as selected
virtual void QueryStart()
Disable any widgets and/or set cursor/scroll as needed when query starts.
virtual void DlgOverlayFix(wxWindow *win)
let widget send fake resize to fix windows opengl bug.
virtual void QueryEnd(CMacroQueryExec *exec)
Re-enable widgets and/or set cursor/scroll as needed when query ends.
GUI command routing and handling framework.
string
Definition: cgiapp.hpp:687
GLdouble TModelUnit
Definition: gltypes.hpp:48
@ eBaseCmdLast
Definition: command.hpp:111
#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 NCBI_GUIWIDGETS_PHYLO_TREE_EXPORT
Definition: gui_export.h:535
#define wxT(x)
Definition: muParser.cpp:41
const struct ncbi::grid::netcache::search::fields::SIZE size
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
EPhyloTreeEditCommand
@ eCmdSomethingEdited
EPhyloTreeCommands
Definitions for Phylo Tree Widget commands.
@ eCmdSortLabelRange
@ eCmdMoveDown
@ eCmdResetNodeSelection
@ eCmdExportSelection
@ eCmdSubtreeFromSelected
@ eCmdNodePaste
@ eCmdEditNode
@ eClearSelection
@ eCmdExportSelected
@ eCmdEditLabel
@ eCmdSortAscending
@ eCmdSetGraphType2
@ eCmdRelayout
@ eCmdRotateLabels
@ eCmdZoomToSubtree
@ eCmdShowAll
@ eCmdLabelsHidden
@ eCmdZoomX
@ eCmdSort
@ eSelectAll
@ eCmdRemoveSubtree
@ eCmdRerootTreeAtEdge
@ eCmdLoadAttributes
@ eCmdSetGraphType5
@ eCmdClean
@ eCmdMoveUp
@ eCmdHighlightEdges
@ eCmdLabelsVisible
@ eCmdAlPaml
@ eCmdSetGraphType4
@ eCmdCollapseChildren
@ eCmdStopLayout
@ eCmdAlPhylip
@ eCmdUseSplines
@ eCmdNodeCut
@ eCmdMidpointRoot
@ eCmdRerootTree
@ eCmdSetTreeLabel
@ eCmdRestoreView
@ eCmdExportSelectedNew
@ eCmdNodeNewChild
@ eCmdZoomY
@ eCmdFilter
@ eCmdSetGraphType3
@ eCmdZoomXY
@ eCmdSortDist
@ eCmdExportTree
@ eCmdUseDistances
@ eCmdChooseSeq
@ eCmdMySettings
@ eCmdCollapseToViewport
@ eCmdAlNone
@ eCmdExpandChildren
@ eCmdFilterDistances
@ eCmdRemoveSelected
@ eCmdSetGraphType1
@ eCmdAddSelectionSet
@ eCmdLabelsForLeavesOnly
@ eCmdCollapseSelected
@ eCmdNodeNewParent
@ eCmdSortLabel
@ eCmdRemoveNode
static static static wxID_ANY
Modified on Wed Apr 24 14:14:09 2024 by modify_doxy.py rev. 669887