A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/tree__collision__model2d_8cpp_source.html below:

NCBI C++ ToolKit: src/gui/widgets/phylo_tree/tree_collision_model2d.cpp Source File

50 #ifdef ATTRIB_MENU_SUPPORT 70 #ifdef ATTRIB_MENU_SUPPORT 101

vector<size_t>::const_iterator iter;

102  for

(iter=node_indices.begin(); iter!=node_indices.end(); ++iter) {

110  float

default_angle =

n

->GetAngle();

113  n

->SetAngle(scaled_angle);

115  n

->SetAngle(default_angle);

145  for

(grid_pos.Y() = posi_ll.

Y

(); grid_pos.Y()<=posi_ur.

Y

(); ++grid_pos.Y()) {

146  for

(grid_pos.X() = posi_ll.

X

(); grid_pos.X()<=posi_ur.

X

(); ++grid_pos.X()) {

170  long

best_vis_idx = -1;

171  float

best_vis_label_dist = FLT_MAX;

173  long

best_hidden_idx = -1;

174  float

best_hidden_label_dist = FLT_MAX;

180  for

(

size_t i

=0;

i

<cell_nodes.size(); ++

i

) {

195  float

xdelta = (x-p.

X

()) * 1.0f/

m_Scale

.

X

();

196  float

ydelta = (y-p.

Y

()) * 1.0f/

m_Scale

.

Y

();

198  float

dist = sqrtf( xdelta*xdelta + ydelta*ydelta );

201  bool

vis_label = node->GetVisible() && labels_visible;

204  if

(vis_label && dist < best_vis_label_dist) {

205

best_vis_idx = cell_nodes[

i

];

206

best_vis_label_dist = dist;

208  else if

(!vis_label && dist < best_hidden_label_dist) {

209

best_hidden_idx = cell_nodes[

i

];

210

best_hidden_label_dist = dist;

214  else if

(node->GetVisible() && labels_visible) {

222

best_vis_idx = cell_nodes[

i

];

223

best_vis_label_dist = node->GetNodeSize();

228  if

(best_vis_idx > -1) {

229

tree_idx = best_vis_idx;

231  else if

(best_hidden_idx != -1) {

232

tree_idx = best_hidden_idx;

240

vector<CPhyloTree::TTreeIdx> sel_nodes;

261  for

(

int

x = idx1.

X

(); x <= idx2.

X

(); ++x) {

262  for

(

int

y = idx1.

Y

(); y <= idx2.

Y

(); ++y) {

268  for

(

size_t i

= 0;

i

<cell_nodes.size(); ++

i

) {

273  if

(p.

X

() >= x1 && p.

X

() <= x2 &&

274

p.

Y

() >= y1 && p.

Y

() <= y2) {

276

sel_nodes.push_back(cell_nodes[

i

]);

284  sort

(sel_nodes.begin(), sel_nodes.end());

285

sel_nodes.erase(std::unique(sel_nodes.begin(), sel_nodes.end()), sel_nodes.end());

307  bool

xoverlap = !( (ll2.

X

() > ur1.

X

() || ur2.

X

() < ll1.

X

()) );

308  bool

yoverlap = !( (ll2.

Y

() > ur1.

Y

() || ur2.

Y

() < ll1.

Y

()) );

310  return

(xoverlap && yoverlap);

375

prev_posi_ll.

X

() =

std::max

(prev_posi_ll.

X

(), 0);

378

prev_posi_ll.

Y

() =

std::max

(prev_posi_ll.

Y

(), 0);

381

prev_posi_ur.

X

() =

std::max

(prev_posi_ur.

X

(), 0);

384

prev_posi_ur.

Y

() =

std::max

(prev_posi_ur.

Y

(), 0);

398  for

(

int

x = prev_posi_ll.

X

(); x <= prev_posi_ur.

X

(); ++x) {

399  for

(

int

y = prev_posi_ll.

Y

(); y <= prev_posi_ur.

Y

(); ++y) {

402

std::vector<size_t>& cell_nodes =

Get

(idx).

m_Labels

;

404  for

(

size_t i

=0;

i

<cell_nodes.size(); ++

i

) {

405

(*tree)[cell_nodes[

i

]]->SetVisible(

false

);

413  for

(

int

x = posi_ll.

X

(); x <= posi_ur.

X

(); ++x) {

414  for

(

int

y = posi_ll.

Y

(); y <= posi_ur.

Y

(); ++y) {

416

std::vector<size_t>& cell_nodes =

Get

(idx).

m_Labels

;

430  for

(

size_t i

=0;

i

<cell_nodes.size(); ++

i

) {

431  if

((*

tree

)[cell_nodes[

i

]]->GetDisplayLabel() !=

""

)

432

(*tree)[cell_nodes[

i

]]->SetVisible(

true

);

444  for

(

int

x = posi_ll.

X

(); x <= posi_ur.

X

(); ++x) {

445  for

(

int

y = posi_ll.

Y

(); y <= posi_ur.

Y

(); ++y) {

448

std::vector<size_t> cell_nodes =

Get

(idx).

m_Labels

;

451  for

(

size_t i

=0;

i

<cell_nodes.size(); ++

i

) {

457  bool

label1_visible = (l1->GetVisible() && l1->GetDisplayLabel().length() > 0);

462  float

scaled_nodesize_x1 = l1->GetNodeDisplaySize()*

m_Scale

.

X

();

463  float

scaled_nodesize_y1 = l1->GetNodeDisplaySize()*

m_Scale

.

Y

();

465

nll1.

X

() = l1->X()-scaled_nodesize_x1;

466

nll1.

Y

() = l1->Y()-scaled_nodesize_y1;

467

nur1.

X

() = l1->X()+scaled_nodesize_x1;

468

nur1.

Y

() = l1->Y()+scaled_nodesize_y1;

470  for

(

size_t

j=

i

+1; j<cell_nodes.

size

(); ++j) {

472  bool

label2_visible = (l2->GetVisible() && l2->GetDisplayLabel().length() > 0);

475  if

(label2_visible) {

479

l2->SetVisible(

false

);

483

l2->SetVisible(

false

);

488  if

(label1_visible) {

489  float

scaled_nodesize_x2 = l1->GetNodeDisplaySize()*

m_Scale

.

X

();

490  float

scaled_nodesize_y2 = l1->GetNodeDisplaySize()*

m_Scale

.

Y

();

491

nll2.

X

() = l2->X()-scaled_nodesize_x2;

492

nll2.

Y

() = l2->Y()-scaled_nodesize_y2;

493

nur2.

X

() = l2->X()+scaled_nodesize_x2;

494

nur2.

Y

() = l2->Y()+scaled_nodesize_y2;

497

l1->SetVisible(

false

);

Tree subclass also has functions and data needed for rendering and selection.

class CSpatialHash2D Class for simple 2D spatial organization that allows for some collision checking...

CVect2< int > m_VisMinIdx

Range of visible indices from previous call to UpdateVisibility.

int m_Width

Width and heigt of table (m_MaxIdx-m_MinIdx)

TElemType & Get(const TVeci &item)

float m_ResolutionX

Divisor for dividing model-space resolution into table indices.

CVect2< float > m_PrevVisMax

CVect2< float > m_PrevVisMin

Visible rectangle area from previous call to UpdateVisibility.

TElemType GetSafe(const TVeci &item) const

Return an empty TElemType if index is out of range.

CVect2< int > m_VisMaxIdx

TVeci m_MinIdx

Min/Max indicies in the table.

CVect2< float > m_Scale

Current scaling factor of model for viewing in x and y.

void Update(const CGlPane &pane, const CVect2< float > &scale)

Update all geometry (needed when topology changes)

CRef< CPhyloTreeScheme > m_SL

void UpdateScaled(const CGlPane &pane, const CVect2< float > &scale)

Only update scaled geometry (needed when zoom changes)

void Sync(const CGlPane &pane, CTreeGraphicsModel *m)

Insert data from model (labels/nodes)

CTreeGraphicsModel * m_Model

Underlying graphics model.

vector< size_t > SelectNodes(float x1, float y1, float x2, float y2)

Return all nodes within the region (x1,y1) - (x2,y2)

virtual void UpdateVisibility(const TModelRect &r)

Find collisions between labels in visible regions to determine visiblity.

size_t TestForNode(float x, float y, bool labels_visible, bool rotated_labels=false)

Return node at position (x,y), if any.

void SetScheme(CPhyloTreeScheme &sl)

Set rendering scheme for tree (has info needed for node sizes)

static bool RectIntersect(const CVect2< float > &ll1, const CVect2< float > &ur1, const CVect2< float > &ll2, const CVect2< float > &ur2)

Utility function returns true if rectangle one (ll1-ur1) intersects rectangle 2 (ll2-ur2)

class CTreeGraphicsModel Model for rendering tree graphics data.

vector< size_t > & GetNodeIndices()

Get all the nodes (indicies point to nodes in phylo tree)

CPhyloTree * GetTree()

Get the tree (to which the node indices belong)

bool GetRotateLabels() const

float GetCurrentRotationAngle(const CGlPane &pane, const CPhyloTreeNode &n, bool &visible) const

Return node's label rotation angle for current zoom level.

static TTreeIdx Null()

Return the index value that represents a NULL node.

TObjectType * GetPointer(void) THROWS_NONE

Get pointer,.

void Reset(void)

Reset reference object.

#define END_NCBI_SCOPE

End previously defined NCBI scope.

#define BEGIN_NCBI_SCOPE

Define ncbi namespace.

constexpr auto sort(_Init &&init)

The NCBI C++/STL use hints.

Defines: CTimeFormat - storage class for time format.

double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)

vector< size_t > m_Labels

CompareLabelX(CPhyloTree *tree, const CVect2< float > &s)

bool operator()(size_t lhs, size_t rhs)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4