NCBI C++ ToolKit
include
gui
widgets
phylo_tree
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
>
37
#include <
gui/opengl/spatialhash2d.hpp
>
38
#include <
gui/widgets/phylo_tree/phylo_tree_scheme.hpp
>
39
40
#include <
gui/utils/vect2.hpp
>
41
#include <
gui/utils/vect3.hpp
>
42
43
#include <float.h>
44
45
BEGIN_NCBI_SCOPE
46
47
class
CTreeCollisionModel2D
;
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.
55
struct
CollisionEntry
{
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
///
69
class
NCBI_GUIWIDGETS_PHYLO_TREE_EXPORT
CTreeCollisionModel2D
:
public
CSpatialHash2D
<CollisionEntry>
70
{
71
public
:
72
CTreeCollisionModel2D
();
73
~
CTreeCollisionModel2D
();
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
102
CTreeGraphicsModel
*
m_Model
;
103
CRef<CPhyloTreeScheme>
m_SL
;
104
105
float
m_VisUpdateTime
;
106
float
m_ScaleUpdateTime
;
107
};
108
109
END_NCBI_SCOPE
110
111
112
113
114
#endif
// GUI_WIDGETS_PHYLO_TREE_TREE_COLLISION_MODEL_2D_HPP
CGlPane
class CGlPane
Definition:
glpane.hpp:62
CGlRect< TModelUnit >
CPhyloTreeNode
Definition:
phylo_tree_node.hpp:491
CPhyloTreeScheme
Definition:
phylo_tree_scheme.hpp:49
CRef< CPhyloTreeScheme >
CSpatialHash2D
class CSpatialHash2D Class for simple 2D spatial organization that allows for some collision checking...
Definition:
spatialhash2d.hpp:64
CSpatialHash2D::UpdateVisibility
virtual void UpdateVisibility(const TModelRect &)
Definition:
spatialhash2d.hpp:127
CTreeCollisionModel2D
class CTreeCollisionModel2D This is a subclass of the spatial collision detection datastructure speci...
Definition:
tree_collision_model2d.hpp:70
CTreeCollisionModel2D::m_ScaleUpdateTime
float m_ScaleUpdateTime
Definition:
tree_collision_model2d.hpp:106
CTreeCollisionModel2D::m_VisUpdateTime
float m_VisUpdateTime
Definition:
tree_collision_model2d.hpp:105
CTreeCollisionModel2D::m_SL
CRef< CPhyloTreeScheme > m_SL
Definition:
tree_collision_model2d.hpp:103
CTreeCollisionModel2D::m_Model
CTreeGraphicsModel * m_Model
Underlying graphics model.
Definition:
tree_collision_model2d.hpp:102
CTreeGraphicsModel
class CTreeGraphicsModel Model for rendering tree graphics data.
Definition:
tree_graphics_model.hpp:125
CVect2< float >
END_NCBI_SCOPE
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition:
ncbistl.hpp:103
BEGIN_NCBI_SCOPE
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition:
ncbistl.hpp:100
NCBI_GUIWIDGETS_PHYLO_TREE_EXPORT
#define NCBI_GUIWIDGETS_PHYLO_TREE_EXPORT
Definition:
gui_export.h:535
gui_export.h
Defines to provide correct exporting from DLLs in Windows.
ncbiobj.hpp
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
r
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
phylo_tree_scheme.hpp
spatialhash2d.hpp
CollisionEntry
class CollisionEntry This is the class that is stored in the collision data structure - each entry in...
Definition:
tree_collision_model2d.hpp:55
CollisionEntry::clear
void clear()
Definition:
tree_collision_model2d.hpp:56
CollisionEntry::m_Labels
vector< size_t > m_Labels
Definition:
tree_collision_model2d.hpp:58
vect2.hpp
vect3.hpp
Generated by
1.9.0
Modified on Wed Sep 04 15:03:53 2024 by modify_doxy.py rev. 669887