: m_CurrentNode(Null())
94 return m_Tree[lhs].GetValue().GetNumLeavesEx() <
m_Tree[rhs].GetValue().GetNumLeavesEx();
97 return m_Tree[lhs].GetValue().GetNumLeavesEx() >
m_Tree[rhs].GetValue().GetNumLeavesEx();
115 return m_Tree[lhs].GetValue().GetDistance() <
m_Tree[rhs].GetValue().GetDistance();
118 return m_Tree[lhs].GetValue().GetDistance() >
m_Tree[rhs].GetValue().GetDistance();
131 constvector<float>& distances,
160 const string&l1 =
m_Tree[lhs].GetValue().GetLabel();
161 const string&l2 =
m_Tree[rhs].GetValue().GetLabel();
181 constvector<pair<string,string> >& labels,
213 m_Nodes[idx].GetChildren().end(), pred);
221 m_Nodes[idx].GetChildren().end(), pred);
229 m_Nodes[idx].GetChildren().end(), pred);
233 constvector<pair<string,string> >& subtree_labels,
239 m_Nodes[idx].GetChildren().end(), pred);
244TNodeVecType::iterator iter;
293ex_sel_node = parent;
300 if(ex_sel_node != *iter && esel.size() > 0) {
301 if(esel[esel.size() - 1] != ex_sel_node) {
302 if(std::find(esel.begin(), esel.end(), ex_sel_node) == esel.end()) {
303esel.push_back(ex_sel_node);
308esel.push_back(ex_sel_node);
324 if(esel.size() == 0)
329 ITERATE(vector<TID>, it, esel) {
349 ITERATE(vector<TID>,iter,ids) {
361vector<TTreeIdx>::const_iterator iter;
363 for(iter=sel.begin(); iter!=sel.end(); ++iter) {
370vector<TTreeIdx> collapsed_nodes;
372 for(
size_t i=0;
i<
m_Nodes.size(); ++
i) {
375collapsed_nodes.push_back(
TTreeIdx(
i));
379 returncollapsed_nodes;
388 if(!
GetNode(parent_idx).Expanded()) {
427 if(new_current_node !=
Null()) {
476parent = &
m_Nodes[parent_idx];
487 boollabels_visible,
boolrotated_labels)
491 if(idx !=
Null()) {
516vector<CPhyloTree::TTreeIdx> selected;
520 for(
size_t i=0;
i<selected.size(); ++
i) {
532 return(selected.size() > 0);
545 booloverride_explicit)
556 if(!override_explicit)
574(*node).SetSelectedState(
state);
608 if(common_idx !=
Null())
616 boolsel_parents)
const 626 else if(!node.
IsLeaf()) {
662 boolall_selected =
true;
663 boolsome_selected =
false;
672all_selected &= sel_state;
673some_selected |= trace_state;
695 while(cursor_idx !=
Null()){
701 if(
m_Nodes[*it].GetValue().GetSelectedState()!=
706 if(iMarkedNodes > 1) {
707common_idx = cursor_idx;
713 if(common_idx !=
Null() && !
m_Nodes[common_idx].IsLeaf())
736sel_state.push_back(
TSelStateValue(idx, (*node).GetSelectedState()));
752sel_state.push_back(
TSelStateValue(*it, (*node).GetSelectedState()));
762 if(parent_idx !=
Null()) {
771 GetNode(node_idx).GetValue().GetDistance());
CNodeOrderPredDist(const CPhyloTree &m, bool order)
const CPhyloTree & m_Tree
bool operator()(const CPhyloTree::TTreeIdx &lhs, const CPhyloTree::TTreeIdx &rhs) const
CNodeOrderPredLabel(const CPhyloTree &m, bool order)
bool operator()(const CPhyloTree::TTreeIdx &lhs, const CPhyloTree::TTreeIdx &rhs) const
const CPhyloTree & m_Tree
bool operator()(const CPhyloTree::TTreeIdx &lhs, const CPhyloTree::TTreeIdx &rhs) const
CNodeOrderPredNumChildren(const CPhyloTree &m, bool order)
const CPhyloTree & m_Tree
CNodeOrderPredSubtreeDist(const CPhyloTree &m, const vector< float > &distances, bool order)
const vector< float > & m_Distances
const CPhyloTree & m_Tree
bool operator()(const CPhyloTree::TTreeIdx &lhs, const CPhyloTree::TTreeIdx &rhs) const
const vector< pair< string, string > > & m_SubtreeLabels
const CPhyloTree & m_Tree
bool operator()(const CPhyloTree::TTreeIdx &lhs, const CPhyloTree::TTreeIdx &rhs) const
CNodeOrderPredSubtreeLabel(const CPhyloTree &m, const vector< pair< string, string > > &labels, bool order)
void Sync(CBioTreeFeatureDictionary &dict)
void SetDistance(TDistance x_dist)
bool Expanded() const
Return true if node is currently not collapsed.
Tree subclass also has functions and data needed for rendering and selection.
CRef< CTreeGraphicsModel > m_GraphicsModel
Model for rendering (updated from current tree state)
void SetExplicitlySelected(const vector< TID > &esel)
Reset explicitly selected nodes to those currently selected nodes that are also found in the vector '...
bool SelectByPoint(const CVect2< float > &pt, bool sel, bool toggle, bool labels_visible, bool rotated_labels=false)
Determine if the point pt is close enough to a node to select or deselect it.
void SetSelectionIDs(const vector< TID > &ids, bool sel=true, bool sel_children=true)
Select a set of nodes - equivalent to calling SetSelection(idx, true, true, true) on each of the node...
void SortSubtreeDist(TTreeIdx idx, const vector< float > &distances, bool order)
Sort the children of a node based on length of longest subtree.
bool IsUnused(TTreeIdx idx) const
Return true if the given position in the array is not currently included as a node in the tree.
TTreeIdx x_CommonNodeSearch(TTreeIdx idx)
Check recursively parents of node and set selection state to eShared if all of their children are sel...
TTIDPhyloTreeNodeMap m_NodesMap
TTreeIdx m_CurrentEdgeChild
Currently active edge (to allow re-rooting by edge).
void SetLeavesExplicitlySelected()
Set the nodes used for iteration to default to the leaf nodes.
void ClearSelection()
Sets selection state of all nodes to eNotSelected and clears m_Selected.
void x_SelectChildren(CPhyloTreeNode &node, bool sel)
Propogate selection operation (selecte/deselect) to a nodes children.
void GetCurrentEdge(TTreeIdx &child_idx, TTreeIdx &parent_idx) const
void Clear()
Clear the tree nodes, graphics model and selected nodes.
TTreeIdx m_CurrentNode
Currently active node (for operations like edit), or Null()
void GetSelectedIDs(vector< TID > &sel) const
Returns the node ids of selected nodes.
void x_SetSelState(TTreeIdx idx, CPhyloNodeData::TSelectedState state, bool override_explicit=true)
Set selected state of anode and add/remove it from m_Selected as needed.
TTreeIdxSet m_ExplicitlySelected
Often when you select a node, it's children or parents may also join the selection set.
bool GetSelectedBoundary(CVect2< float > &ll, CVect2< float > &ur)
Return bounding rectangle from lower-left to upper-right of selected nodes (eSelected) and false if n...
void UpdateNodesMapping()
bool IsVisible(TTreeIdx node_idx)
Determine if the node at node_idx is within a collapsed subtree or not.
void SetCurrentNode(TTreeIdx node_idx)
Set the index of the currently active node.
void SetSelection(TTreeIdx idx, bool sel, bool sel_children=true, bool sel_parents=true)
Select or deselect the node at the specified index and, optionally, its parents and children as well.
CRef< CRgbaGradColorTable > m_ColorTable
Color table to store colors by index.
vector< TSelStateValue > TSelState
TTreeIdx TestForNode(const CVect2< float > &pt, bool labels_visible, bool rotated_labels=false)
Search nodes to find and return closest node to 'pt' that is within the max.
void GetExplicitlySelectedAndNotCollapsed(vector< TTreeIdx > &esel) const
Returns only indices of nodes explicitly selected, but when a node is underneath a collapsed node,...
void x_GetChildState(TSelState &sel_state, TTreeIdx idx) const
Get (and return) selection state for children of a given node.
void x_SelectParents(CPhyloTreeNode &node, bool sel, bool children_selected=true)
Propogate selection (eTraced) to a nodes parents and if children aren't be selected,...
TTreeIdx m_CurrentEdgeParent
virtual void x_ConvertUpstream(TTreeIdx node_idx)
Convert parents of node_idx to be its children.
CPhyloTree()
ctor - need to add nodes to make tree valid
CPhyloTreeNode & GetCurrentNode()
Get reference to currently active node. Throws exception if it's Null()
void x_GetParentState(TSelState &sel_state, TTreeIdx idx) const
Get (and return) selection state for parents of a given node.
CRgbaGradColorTable * GetColorTable()
bool HasCurrentNode() const
Return true if the currently active node is not Null()
void GetExplicitlySelectedIDs(vector< TID > &esel) const
Returns only ids of nodes explicitly selected, not their parents or children, i.e.
TTreeIdx FindNodeById(TID id) const
Return index of the node with the given id or Null().
void GetExplicitlySelected(vector< TTreeIdx > &esel) const
Returns only indices of nodes explicitly selected, not their parents or children, i....
void SetCurrentEdge(TTreeIdx child_idx, TTreeIdx parent_idx)
Set/Get the edge between the two specified nodes as current.
pair< TTreeIdx, CPhyloNodeData::TSelectedState > TSelStateValue
void GetSelected(vector< TTreeIdx > &sel) const
Returns indices of selected nodes.
TTreeIdx GetCollapsedParentIdx(TTreeIdx node_idx) const
Return the index of the given node (node_idx) if none of its parent nodes up to the root are collapse...
void SortLabel(TTreeIdx idx, bool order)
Sort the children of a node based on label comparison (alphabetical order)
void GetSelState(TSelState &sel_state, TTreeIdx idx, bool sel_children=true, bool sel_parents=true) const
Given the selection of node 'idx', store the selection state (selected, traced, shared) of that node ...
void SortLabelRange(TTreeIdx idx, const vector< pair< string, string > > &subtree_labels, bool order)
Sort the children of a node based on the alphanumeric range of their child nodes.
bool HasCurrentEdge() const
CBioTreeFeatureDictionary m_FeatureDict
Feature dictionary.
void Sort(TTreeIdx idx, bool order)
Sort the children of a node based on the number of children they have.
bool SelectByRect(const CVect2< float > &ll, const CVect2< float > &ur, bool toggle)
Select or deselect all nodes in the rectangle bounded by ll and ur.
void x_PropagateCommonState(CPhyloTreeNode &node)
vector< TTreeIdx > GetAllCollapsed() const
Returns indices of nodes thate are currently collapsed.
CTreeGraphicsModel & GetGraphicsModel()
Get model for rendering.
CRgbaGradColorTable Provides a storage for colors (to eliminate color creation overhead) and Function...
vector< size_t > SelectNodes(float x1, float y1, float x2, float y2)
Return all nodes within the region (x1,y1) - (x2,y2)
size_t TestForNode(float x, float y, bool labels_visible, bool rotated_labels=false)
Return node at position (x,y), if any.
class CTreeGraphicsModel Model for rendering tree graphics data.
void Init(CPhyloTree *t)
Allocate any default buffers etc.
CTreeCollisionModel2D & GetCollisionData()
TTreeIdx GetParent() const
Get node's parent.
TNodeList_CI SubNodeEnd() const
Return const iterator to end of subnode list.
TNodeList::iterator TNodeList_I
TData & GetValue()
Return the value object for the node.
bool HasParent() const
Check if the node has a parent.
TNodeList::const_iterator TNodeList_CI
bool IsLeaf() const
Report whether this is a leaf node.
static TTreeIdx Null()
Static function that returns the null value.
TNodeList_CI SubNodeBegin() const
Return const iterator to first subnode index.
TNodeVecType m_Nodes
The list of nodes in the tree.
static TTreeIdx Null()
Return the index value that represents a NULL node.
TNodeType & GetNode(TTreeIdx idx)
Return a reference to the node at the given index.
void Clear()
Remove all nodes (empty array) and set root index to Null.
void AddChild(TTreeIdx parent_idx, TTreeIdx child_idx)
Add the node at 'child_idx' to the children 'parent_idx'.
std::vector< TNodeType > TNodeVecType
void RemoveChild(TTreeIdx parent_idx, TTreeIdx child_idx)
Remove the node at 'child_idx' from its parent 'parent_idx' Nothing is done if the node 'child_idx' i...
iterator_bool insert(const value_type &val)
const_iterator begin() const
parent_type::iterator iterator
const_iterator find(const key_type &key) const
const_iterator end() const
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
virtual void ClearAll()
clear everything - vectors and vertex buffers
const CSeq_id & GetId(const CSeq_loc &loc, CScope *scope)
If all CSeq_ids embedded in CSeq_loc refer to the same CBioseq, returns the first CSeq_id found,...
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
bool IsNull(void) const THROWS_NONE
Check if pointer is null â same effect as Empty().
TObjectType & GetObject(void)
Get object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
constexpr auto sort(_Init &&init)
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
size_t TTreeIdx
Bi-directionaly linked N way tree allocated in a contiguous memory block.
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