&
label)
161: m_ExtendedParms(
NULL)
278 stringremainder =
str;
281 floatmarker_size = 2.0f;
282 if(marker_size_str !=
"") {
284 if(marker_size <= 0.0f) marker_size = 2.0f;
288string::size_type idx = remainder.find_first_of(
']');
290 while(idx != string::npos) {
291 string color= remainder.substr(0, idx + 1);
292 size_tstart_idx = remainder.find_first_of(
'[');
293 if(start_idx == string::npos)
302remainder = remainder.substr(idx + 1, remainder.size() - (idx + 1));
303idx = remainder.find_first_of(
']');
352 const string&
value)
357 id= dict.
GetId(name);
368 "CPhyloTreeNode::SetFeature - maximum number of features exceeded");
380 id= dict.
GetId(name);
398 catch(std::exception&) {}
403 if(!
size.empty()) {
409 catch(std::exception&) {}
415 if(!marker.empty()) {
419 catch(std::exception&){}
427 if(sel_id || errno == 0)
438 if(!sel_clusters.empty()) {
439vector<CTempString>
arr;
441 for(
size_t i=0;
i<
arr.size(); ++
i) {
443 if(!sel_id && errno != 0)
457 if(!bounded.empty()) {
471 size_tcolor_idx = -1;
472 if(!node_color.empty()) {
476 if(!
t->FindColor(c, color_idx)) {
477color_idx =
t->AddColor(c);
485 if(!node_color.empty()) {
489 if(!
t->FindColor(c, color_idx)) {
490color_idx =
t->AddColor(c);
499 if(node_color !=
"") {
507 if(!node_color.empty()) {
511 if(!
t->FindColor(c, color_idx)) {
512color_idx =
t->AddColor(c);
519 if(!node_color.empty()) {
523 if(!
t->FindColor(c, color_idx)) {
524color_idx =
t->AddColor(c);
540 SetSeqID(
newobjects::CSeq_id(sid));
550 if(!gi_str.empty()) {
551 SetSeqID(
newobjects::CSeq_id(gi_str));
554 stringlcl_sid =
"lcl|";
556 SetSeqID(
newobjects::CSeq_id(lcl_sid));
559 catch(std::exception&)
564 catch(std::exception&)
647 stringparm_lower = parm;
650 stringfeatures_lower = features;
653 size_tidx = features_lower.find(parm_lower);
654 if(idx != string::npos) {
655 size_tend_idx = features.find_first_of(
" ,\t", idx);
656 if(end_idx == string::npos)
657end_idx = features.size();
659 returnfeatures.substr(idx + parm_lower.length(), end_idx-(idx+parm_lower.length()));
670 floatcos_a = cosf(
a) / scale.
X();
671 floatsin_a = sinf(
a) / scale.
Y();
672 a= atan2f(sin_a, cos_a);
676 if(for_label && cos_a < 0.0f) {
686 floatsize_scaler)
const 700p.
X() += cosf(
a) * node_size * size_scaler * scale.
X();
701p.
Y() += sinf(
a) * node_size * size_scaler * scale.
Y();
704p.
X() += node_size * size_scaler * scale.
X();
715 booltruncate_labels,
728pos_xmin = (
TModelUnit)(
X() + (
r.Left() * scale.
X()));
729pos_xmax = (
TModelUnit)(
X() + (
r.Right() * scale.
X()));
730pos_y = (
TModelUnit)(
Y() + (
r.Bottom() * scale.
Y()));
732 stringtext_out =
m_Text;
738 if(truncate_labels) {
743text_len =
std::min(tw, vp_width - screen_minx);
746text_len =
std::min(tw, screen_maxx);
752text_len =
std::min(text_len, max_len);
757 if(text_len > 0.0 && text_len < tw) {
762std::reverse(text_out.begin(), text_out.end());
763text_out = font.
Truncate(text_out.c_str(), text_len);
764std::reverse(text_out.begin(), text_out.end());
771pos_xmin += (tw - new_width)*scale.
X();
774 if(text_out ==
"...")
789gl.
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
792gl.
Begin(GL_TRIANGLE_STRIP);
803font.
TextOut(pos_xmin, pos_y, text_out.c_str());
811 booltruncate_labels)
819 floatangle_degrees = angle * (360.0f / (2.0f*float(M_PI)));
829gl.
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
832gl.
Begin(GL_TRIANGLE_STRIP);
833gl.
Vertex2f(corners[3].
X(), corners[3].
Y());
834gl.
Vertex2f(corners[0].
X(), corners[0].
Y());
835gl.
Vertex2f(corners[2].
X(), corners[2].
Y());
836gl.
Vertex2f(corners[1].
X(), corners[1].
Y());
840 stringtext_out =
m_Text;
841 if(truncate_labels) {
847 for(
size_t i= 0;
i< 4; ++
i) {
873 if(cos(orig_angle) >= 0.0) {
875 if(screen_minx < vp_width && screen_maxx > vp_width) {
876pct = (vp_width - screen_minx) / (screen_maxx - screen_minx);
879 if(screen_miny < vp_height && screen_maxy > vp_height) {
880pct =
std::min(pct, (vp_height - screen_miny) / (screen_maxy - screen_miny));
883 else if(screen_maxy > 0.0 && screen_miny < 0.0) {
884pct =
std::min(pct, (screen_maxy) / (screen_maxy - screen_miny));
896 if(screen_minx < 0.0 && screen_maxx > 0.0) {
897pct = (screen_maxx) / (screen_maxx - screen_minx);
900 if(screen_miny < vp_height && screen_maxy > vp_height) {
901pct =
std::min(pct, (vp_height - screen_miny) / (screen_maxy - screen_miny));
904 else if(screen_maxy > 0.0 && screen_miny < 0.0) {
905pct =
std::min(pct, (screen_maxy) / (screen_maxy - screen_miny));
914std::reverse(text_out.begin(), text_out.end());
915text_out = font.
Truncate(text_out.c_str(), text_box_len*pct);
916std::reverse(text_out.begin(), text_out.end());
925 float delta= float((tw-new_width)/tw);
926corners[0] = corners[0] + text_dir *
delta;
929 if(text_out ==
"...")
943 float& angle,
floatorig_angle)
const 950 floatcos_a = cosf(angle);
951 floatsin_a = sinf(angle);
955 if(overhang > 0.0f) {
956 if(orig_angle < 0.0f)
958dir.
Set(cosf(orig_angle)*overhang*scale.
X(), sinf(orig_angle)*overhang*scale.
Y());
962 for(
intcorner=0; corner<4; ++corner) {
966 CVect2<float>rpos((pos.
X())*cos_a-pos.
Y()*sin_a, (pos.
X())*sin_a + pos.
Y()*cos_a);
968rpos.
X() =
X() + scale.
X()*rpos.
X() + dir.
X();
969rpos.
Y() =
Y() + scale.
Y()*rpos.
Y() + dir.
Y();
983 floatcos_a = cosf(angle);
984 floatsin_a = sinf(angle);
989 CVect2<float>tpr(tp.
X()*cos_a-tp.
Y()*sin_a, tp.
X()*sin_a + tp.
Y()*cos_a);
993 Y() + tpr.
Y()*scale.
Y());
1001 booltruncate_labels,
1009pos.
X() = (float)(
X() +
1010(
r.Left() * scale.
X()));
1011pos.
Y() = (float)(
Y() +
1012(
r.Bottom() * scale.
Y()));
1015 if(truncate_labels) {
1016 floatscreen_x = (float)(pane.
ProjectX(pos.
X()));
1020 if(screen_x > 0.0f) {
1030std::reverse(text_out.begin(), text_out.end());
1031text_out = font.
Truncate(text_out.c_str(),
r.Width()+screen_x);
1032std::reverse(text_out.begin(), text_out.end());
1052 if(!rotated ||
r.Width() == 0.0f ||
r.Height() == 0.0f) {
1053lower_left.
X() =
X() +
r.Left()*scale.
X();
1054lower_left.
Y() =
Y() +
r.Bottom()*scale.
Y();
1056upper_right.
X() =
X() +
r.Right()*scale.
X();
1057upper_right.
Y() =
Y() +
r.Top()*scale.
Y();
1071 for(
intcorner=0; corner<4; ++corner) {
1072lower_left.
X() =
std::min(lower_left.
X(), corners[corner].
X());
1073lower_left.
Y() =
std::min(lower_left.
Y(), corners[corner].
Y());
1075upper_right.
X() =
std::max(upper_right.
X(), corners[corner].
X());
1076upper_right.
Y() =
std::max(upper_right.
Y(), corners[corner].
Y());
1092pt.
X() *= 1.0f/scale.
X();
1093pt.
Y() *= 1.0f/scale.
Y();
1101 floatcos_a = cosf(
a);
1102 floatsin_a = sinf(
a);
1103 CVect2<float>rpos(pt.
X()*cos_a-pt.
Y()*sin_a, pt.
X()*sin_a + pt.
Y()*cos_a);
1108 if(
r.PtInRect(pt.
X(), pt.
Y()))
1132 floatcos_a = cosf(
a)*1.0f/scale.
X();
1133 floatsin_a = sinf(
a)*1.0f/scale.
Y();
1134 a= atan2f(sin_a, cos_a);
1146 for(
intcorner=0; corner<4; ++corner) {
1150 CVect2<float>rpos(pos.
X()*cos_a-pos.
Y()*sin_a, pos.
X()*sin_a + pos.
Y()*cos_a);
1167 GetLabelRect(scale, lower_left, upper_right, rotated);
1172lower_left.
X() =
std::min(lower_left.
X(),
X()-deltax);
1173lower_left.
Y() =
std::min(lower_left.
Y(),
Y()-deltay);
1174upper_right.
X() =
std::max(upper_right.
X(),
X()+deltax);
1175upper_right.
Y() =
std::max(upper_right.
Y(),
Y()+deltay);
1191 floatdef_node_size = 0;
1193 if(forced_size < 0.0f) {
1203def_node_size = (float)(min_node_size + (max_node_size - min_node_size) *
1204(
log(this_childs_size) -
log(min_child_size)) /
1205(
log(max_child_size) -
log(min_child_size)));
1209def_node_size = (float)scheme->
GetNodeSize()*1.5;
1220def_node_size = (float)forced_size;
1223 returndef_node_size;
1246max_branch_dist > 1e-04f) {
1257 floatscaled_max_child_dist = (
m_MaxChildDistance/ max_branch_dist)*(max_dist - min_dist) + min_dist;
1261 m_NodeWidth= 4.0f*((float)(min_width + (max_width - min_width) *
1262(
log(scaled_max_child_dist) -
log(min_dist)) /
1263(
log(max_dist) -
log(min_dist))));
1285 returntotal_extension > 0.0f ? total_extension : 0.0f;
Features storage for the bio tree node.
CSubtreeBoundary * GetSubtreeBoundary()
Gets current boundary or creates a new one if m_Boundary is NULL.
bool PointInTextBox(const CVect2< float > &scale, CVect2< float > pt, bool rotated=false)
Return true if pt is inside of this nodes text box.
const TLabel & GetLabel() const
void SetClusterID(TClusterID x_id)
void DeleteSubtreeBoundary()
Deletes current boundary (if not NULL).
TSelectedState m_Selected
CVect2< float > m_NodeOffset
void SetLabelBgColorIdx(short idx)
float m_NodeWidth
This is computed by GetNodeWidthScaler(..) for collapsed nodes and we need to hang onto it for node l...
float GetNodeOverhang(const CVect2< float > &scale) const
Get extenstion of node beyond end of edge in pixels.
TSelClusterIDs & GetSelClusters()
CRef< objects::CSeq_id > m_SeqID
void Init(const CBioTreeFeatureDictionary &dict, CRgbaGradColorTable *t)
TBoundingState GetBoundedDisplay() const
CGlRect< float > m_LabelRect
TLabel m_Label
Full label.
void SetVisible(bool b)
Flag to renderer to determine whether to draw label.
void SetNodeFgColorIdx(short idx)
bool m_AlreadyDrawn
Text is alpha-blended so we add a flag to prevent drawing multiple times.
bool x_HasExtendedParms() const
void Sync(CBioTreeFeatureDictionary &dict)
void RenderRotated(const CGlPane &pane, const CGlTextureFont &font, CRgbaGradColorTable *color_table, const CVect3< float > &scale, float orig_angle, bool truncate_labels)
Draw the label and rotate it to match m_Angle (radial text) This form does not support label truncati...
void SetDistance(TDistance x_dist)
static const TColor TNoColor
SExtendedNodeParms * m_ExtendedParms
CRgbaColor m_FgColor
Current text color.
int GetNumLeavesEx() const
short m_NodeEdColorIdx
Node colors defined by scheme.
void SetSeqID(objects::CSeq_id *sid)
void SetBioTreeFeatureList(const CBioTreeFeatureList &btcfl)
CVect2< float > GetNodePosEx(const CVect3< float > &scale, CPhyloTreeScheme *scheme, float &node_size, float size_scaler=1.0f) const
Get modified center of node position - this works for collapsed nodes in rotated layouts and with off...
CVect2< float > GetTextOut(CGlPane &pane, const CGlTextureFont &font, const CVect3< float > &scale, bool truncate_labels, string &text_out)
Return the drawing position and (possibly truncated) text.
void RemoveFeature(CBioTreeFeatureDictionary &dict, const string &name)
void SetLabelColorIdx(short idx)
bool HasNodeMarker() const
int GetPrimaryCluster() const
With selection clusters a node may have multiple cluster ids.
size_t GetNumClusters() const
Return total # of applicable clusters - selection + m_ClusterID.
float GetNodeSize() const
float GetMarkerSize() const
void SetDrawAngle(float angle)
void SetSelClusters(const TSelClusterIDs &sc)
float GetNodeWidthScaler(const CPhyloTreeScheme *scheme) const
Get modified node width (length) for collapsed nodes. Default is 1.
bool HasSelClusters() const
void SetMarkerColors(const string &str)
float GetNodeLayoutSize(const CPhyloTreeScheme *scheme) const
Get modified node size - use this instead of GetDefaultNodeSize when doing layout (doesn't go to 0 if...
string GetMarkerColorsAsString()
void SetMarkerSize(float f)
short m_LabelFgColorIdx
Label color.
float GetScaledAngle(const CVect3< float > &scale, float a, bool for_label=true) const
Utility to get screen rotation angle after scaling.
vector< CRgbaColor > & GetMarkerColors()
void InitFeatures(const CBioTreeFeatureDictionary &dict, CRgbaGradColorTable *t)
TDistance m_MaxChildDistance
void SetNodeEdgeColorIdx(short idx)
TClusterID GetClusterID(void) const
string x_GetParameter(const string &features, const string &parm)
void GetBoundingRect(const CVect2< float > &scale, CVect2< float > &lower_left, CVect2< float > &upper_right, bool rotated=false)
Find the rectangle for the node and label combined given the current zoom level (scale)
void SetNodeSize(float x_sz)
float GetAngle(void) const
void Render(const CGlPane &pane, const CGlTextureFont &font, CRgbaGradColorTable *color_table, const CVect3< float > &scale, bool truncate_labels, TModelUnit max_len=-1.0f)
Draw the label using scale to compute its offset from m_BasePos.
CVect2< float > GetRotatedTextPos(const CVect3< float > &scale, float &angle) const
Return the text starting point rotated to align with radial edges.
void Set(TID x_id, TDistance x_dist, const TLabel &x_label)
CGlRect< float > GetLabelRect() const
float GetDefaultNodeSize(const CPhyloTreeScheme *scheme) const
Get modified node size - includes scaled (BOA) size.
CPhyloNodeData & operator=(const CPhyloNodeData &rhs)
void SetLabel(const TLabel &x_label)
TDisplayChildren GetDisplayChildren() const
TDistance m_DistanceFromRoot
bool m_Children
expand-collapse state (expanded==true)
float GetMinX(const CVect2< float > &scale)
Return labels minimal X coordinate.
void SetDisplayChildren(TDisplayChildren show)
CVect4< CVect2< float > > GetRotatedTextBox(const CVect3< float > &scale, float &angle, float orig_angle=0.0f) const
Return text box (m_LabelRect) rotated to align with radial edges.
vector< int > TSelClusterIDs
string m_Text
Text to render.
CBioTreeFeatureList & GetBioTreeFeatureList()
CRgbaColor m_NodeColor
Current node color.
bool m_EdgeColorGradient
Controls use of gradient coloring for edges - if false, edges will be a single color,...
bool m_Visible
True if node is visible.
CPhyloTreeScheme::TPhyloTreeColors m_ColorType
float m_NodeSize
Scaled node size.
TDistance GetDistance() const
CBioTreeFeatureList m_Features
CVect2< float > m_NodePixelOffset
Pixel offset to apply the node.
void SetFeature(CBioTreeFeatureDictionary &dict, const string &name, const string &value)
bool Expanded() const
Return true if node is currently not collapsed.
void ExpandCollapse(CBioTreeFeatureDictionary &dict, CPhyloNodeData::TDisplayChildren chds)
Set this node to be expanded/collapsed.
bool CanExpandCollapse(CPhyloNodeData::TDisplayChildren chds)
Return true if node can have its expand/collapsed state changed to chds.
void SetLabel(CBioTreeFeatureDictionary &dict, const string &label)
Set label string and synch value to the feature list for this ndoe.
bool IsLeafEx() const
Return true if node is a leaf or is collapsed.
GLdouble GetMaxNumChildren() const
GLdouble GetMaxNodeSize() const
size range for variable-sized collapsed nodes (so min node size here may be greater than node size)
GLdouble GetMaxBranchDist() const
And we scale the length of the collapsed node marker based on the max.
GLdouble GetLeafNodeSize() const
GLdouble GetMinNumChildren() const
collapsed node sizes are scaled from min to max values based on number of children so we need to have...
GLdouble GetMinNodeSize() const
GLdouble GetNodeSize() const
class CRgbaColor provides a simple abstraction for managing colors.
CRgbaGradColorTable Provides a storage for colors (to eliminate color creation overhead) and Function...
void CreateShapes(const std::string &features)
Parse the features to create the shapes and set their options.
CPhyloNodeData & GetValue()
Return the value object for the node.
bool HasParent() const
Check if the node has a parent.
static vector< string > arr
static const char * str(char *buf, int n)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
static bool GetGIString(const string &sid, string *gi_str)
ad-hoc GI extraction (for misformed seq-id strings like: "gi|55823257|ref|YP_141698....
void Color4fv(const GLfloat *v)
virtual void Enable(GLenum glstate)=0
virtual void Begin(GLenum mode)=0
Start rendering.
virtual void BlendFunc(GLenum sfactor, GLenum dfactor)=0
Options to be used when GL_BLEND is enabled.
TVPUnit ProjectX(TModelUnit m_x) const
IRender & GetGl()
convenience function for getting current render manager
void WriteText(TModelUnit x, TModelUnit y, const char *text, TModelUnit rotate_degrees=0.0) const
Write text at specified model coords.
void Vertex2d(GLdouble x, GLdouble y)
TVPRect & GetViewport(void)
TVPUnit ProjectY(TModelUnit m_y) const
TModelUnit UnProjectX(TVPUnit m_x) const
void BeginText() const
WriteText interface The WriteText functions produce the same results as TextOut but they are more eff...
virtual void End()=0
Finish rendering (create buffer and send to renderer)
virtual void PolygonMode(GLenum face, GLenum mode)=0
Set the polygon rasterization mode.
void EndText() const
Pops matrices and attributes after writing text.
virtual TModelUnit GetMetric(EMetric metric, const char *text=NULL, int len=-1) const
virtual TModelUnit TextWidth(const char *text) const
Compute and return font metrics.
virtual void TextOut(const char *text) const
TextOut interface Write the specified text and set up state and transformation as needed.
void Vertex2f(GLfloat x, GLfloat y)
TModelUnit GetScaleX(void) const
TModelUnit GetScaleY(void) const
string Truncate(const char *text, TModelUnit w, ETruncate trunc=eTruncate_Ellipsis) const
Truncate text to the secified width.
TVPPoint Project(TModelUnit m_x, TModelUnit m_y) const
CRgbaColor & GetColor(size_t i)
const float * GetColorArray(void) const
Access the color array directly.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static double StringToDouble(const CTempStringEx str, TStringToNumFlags flags=0)
Convert string to double.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static string & ToLower(string &str)
Convert string to lower case â string& version.
@ fConvErr_NoThrow
Do not throw an exception on error.
unsigned int TBioTreeFeatureId
Feature Id.
void SetFeature(TBioTreeFeatureId id, const string &value)
Set feature value, feature if exists replaced, if not added.
TBioTreeFeatureId GetId(const string &feature_name) const
If feature is already registered returns its id by name.
TBioTreeFeatureId Register(const string &feature_name)
Register new feature, return its id.
const string & GetFeatureValue(TBioTreeFeatureId id) const
Get feature value by id.
bool HasFeature(const string &feature_name) const
Check if feature is listed in the dictionary.
void RemoveFeature(TBioTreeFeatureId id)
Remove feature from the list.
static const char label[]
const struct ncbi::grid::netcache::search::fields::SIZE size
const GenericPointer< typename T::ValueType > T2 value
Int4 delta(size_t dimension_, const Int4 *score_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
#define PHYLO_NODE_MARKER
#define PHYLO_LABEL_BGCOLOR
#define PHYLO_NODE_COLLAPSED
#define PHYLO_FEAT_CLUSTERID
#define PHYLO_LABEL_COLOR
#define PHYLO_NODE_BOUNDED
#define PHYLO_SELECT_CLUSTERS
vector< CRgbaColor > m_MarkerColors
CSubtreeBoundary * m_Boundary
SExtendedNodeParms & operator=(const SExtendedNodeParms &rhs)
vector< int > m_SelClusters
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