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

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_PHYLO_TREE_TREE_COLLISION_MODEL_2D_HPP
2 #define GUI_WIDGETS_PHYLO_TREE_TREE_COLLISION_MODEL_2D_HPP
3 
4 /* $Id: tree_collision_model2d.hpp 37891 2017-02-28 20:50:36Z falkrb $
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: Bob Falk
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbiobj.hpp>
36 #include <gui/gui_export.h>
39 
40 #include <gui/utils/vect2.hpp>
41 #include <gui/utils/vect3.hpp>
42 
43 #include <float.h>
44 
46 
48 class CPhyloTreeNode;
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// class CollisionEntry
52 /// This is the class that is stored in the collision data structure - each
53 /// entry in the collision data structure has one of these which stores the
54 /// set of geometry that overlaps that (2d) spatial region.
56  void clear() { m_Labels.clear(); }
57 
58  vector<size_t> m_Labels;
59 };
60 
61 class CTreeGraphicsModel;
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 /// class CTreeCollisionModel2D
65 /// This is a subclass of the spatial collision detection datastructure
66 /// specialized to support data important to (phylogenetic) trees. Currently
67 /// it is focused on the labels in the tree.
68 ///
70 {
71 public:
74 
75  /// Update all geometry (needed when topology changes)
76  void Update(const CGlPane& pane, const CVect2<float>& scale);
77  /// Only update scaled geometry (needed when zoom changes)
78  void UpdateScaled(const CGlPane& pane, const CVect2<float>& scale);
79 
80  /// Insert data from model (labels/nodes)
81  void Sync(const CGlPane& pane, CTreeGraphicsModel* m);
82  /// Set rendering scheme for tree (has info needed for node sizes)
83  void SetScheme(CPhyloTreeScheme& sl);
84 
85  /// Find collisions between labels in visible regions to determine visiblity
86  virtual void UpdateVisibility(const TModelRect& r);
87 
88  /// Utility function returns true if rectangle
89  /// one (ll1-ur1) intersects rectangle 2 (ll2-ur2)
90  static bool RectIntersect(const CVect2<float>& ll1,
91  const CVect2<float>& ur1,
92  const CVect2<float>& ll2,
93  const CVect2<float>& ur2);
94 
95  /// Return node at position (x,y), if any
96  size_t TestForNode(float x, float y, bool labels_visible, bool rotated_labels=false);
97  /// Return all nodes within the region (x1,y1) - (x2,y2)
98  vector<size_t> SelectNodes(float x1, float y1, float x2, float y2);
99 
100 protected:
101  /// Underlying graphics model
104 
107 };
108 
110 
111 
112 
113 
114 #endif // GUI_WIDGETS_PHYLO_TREE_TREE_COLLISION_MODEL_2D_HPP
class CGlPane
Definition: glpane.hpp:62
class CSpatialHash2D Class for simple 2D spatial organization that allows for some collision checking...
virtual void UpdateVisibility(const TModelRect &)
class CTreeCollisionModel2D This is a subclass of the spatial collision detection datastructure speci...
CRef< CPhyloTreeScheme > m_SL
CTreeGraphicsModel * m_Model
Underlying graphics model.
class CTreeGraphicsModel Model for rendering tree graphics data.
#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
Defines to provide correct exporting from DLLs in Windows.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
class CollisionEntry This is the class that is stored in the collision data structure - each entry in...
vector< size_t > m_Labels
Modified on Wed Sep 04 15:03:53 2024 by modify_doxy.py rev. 669887