51 m_FontRotateDegrees(0),
55 m_DisplayOptions(fDefaultDisplayOptions),
57 m_TextColor(0.1f, 0.2f, 0.1f),
58 m_RulerColor(0.2f, 0.2f, 0.2f),
59 m_BackColor(0.95f, 0.95f, 0.95f),
63 m_OppMajorTickSize(0),
64 m_OppMinorTickSize(0),
65 m_OppLabelTickSize(6),
146 unsigned int font_size)
184 int len = end - start + 1;
238 return m_Horz == horz_text;
257 2 * text_space + (
int) ceil(text_v);
290 int v = text_v + metric_v;
360 int max_int =
max(mod_start, mod_end);
361 total_max =
max(total_max, max_int);
384 double max_label_sym = 0;
393 double log = (max_label_sym >= 1.0) ?
log10(max_label_sym) : 0;
396 double base_step = step;
409 groups_n = (
int) (
log / 3);
411 int d_digits = 3 * groups_n - 2;
412 max_label_w =
m_MaxLabelW - d_digits * char_w + groups_n * comma_w;
413 max_label_sym = scale * max_label_w;
415 }
while(groups_n && step > max_label_sym * 10);
422 if(step > max_label_sym * 5) {
423 base_step = step / 10;
426 else if(step > max_label_sym * 2) {
427 base_step = step / 10;
448 int ar_K[] = { 10, 5 ,2 };
449 for(
int i = 0;
i < 3;
i++ ) {
492 pair<TAlignColl::const_iterator, bool> res =
m_Mapping.
find_2(last_elem);
533 int old_from_1 =
range.GetFirstFrom();
534 int old_from_2 =
range.GetSecondFrom();
535 int old_to_1 =
range.GetFirstTo();
536 int old_to_2 =
range.GetSecondTo();
537 update = (from != old_from_1 || from != old_from_2 || to != old_to_1 || to != old_to_2);
554 b_update = b_scale_changed || ! (
m_rcLimits == rc_lim);
595 int prg =
range.GetSecondPosByFirstPos(model);
598 return prg >= 0 ? (prg + 1) : prg;
605 TModelUnit prg = (display > 0) ? (display - 1) : display;
637 rc_back.
Offset(-offset_x, -offset_y);
647 int start_pos =
range.GetSecondPosByFirstPos(
range.GetFirstFrom());
648 int stop_pos =
range.GetSecondPosByFirstPos(
range.GetFirstTo());
650 if (start_pos < stop_pos) {
655 from_offset = from_offset > 0 ? from_offset * 0.5 :
m_BaseOffset;
658 if (start_pos < stop_pos) {
664 to_offset = to_offset > 0 ? to_offset * 0.5 :
m_BaseOffset;
671 int clip_from = clip_r.
GetFrom();
672 int clip_to = clip_r.
GetTo();
674 if( ! clip_r.
Empty()) {
678 int from =
range.GetFirstFrom();
679 int to =
range.GetFirstTo();
681 double MaxU = to + 1;
690 double u1 =
max(MinU, (
double) clip_from);
691 double u2 =
min(MaxU, (
double) clip_to + 1);
693 TModelUnit v0 = 0.0, v1 = 0.0,
v2 = 0.0, v3 = 0.0, v4 = 0.0;
737 gl.
Vertex2d(u1 - offset_x, v0 - offset_y);
738 gl.
Vertex2d(u2 - offset_x, v0 - offset_y);
740 gl.
Vertex2d(v0 - offset_x, u1 - offset_y);
741 gl.
Vertex2d(v0 - offset_x, u2 - offset_y);
749 if (i_last_disp < i_first_disp)
750 swap(i_last_disp, i_first_disp);
754 double v_f = major ? v4 :
v2;
755 double v_t = major ? v3 : v1;
758 if(model >= u1 && model < u2) {
759 double u = model + 0.5;
762 gl.
Vertex2d(u - offset_x, v_f - offset_y);
763 gl.
Vertex2d(u - offset_x, v_t - offset_y);
765 gl.
Vertex2d(v_f - offset_x, u - offset_y);
766 gl.
Vertex2d(v_t - offset_x, u - offset_y);
779 int first_elem,
int last_elem, vector<TModelUnit>& vElemPos)
788 if(i_last_disp < i_first_disp) {
789 for(
int i = i_first_disp;
i >= i_last_disp;
i -= step) {
791 if(model >= first_elem && model <= last_elem) {
792 vElemPos.push_back(model);
796 for(
int i = i_first_disp;
i <= i_last_disp;
i += step) {
798 if(model >= first_elem && model <= last_elem) {
799 vElemPos.push_back(model);
834 vector<TModelUnit> vLabelsPos;
838 double label_size = 0;
839 double label_size_scaled = 0.;
842 double low_limit = clip_r.
GetFrom();
853 low_limit = pos + label_size;
856 int from =
range.GetFirstFrom();
857 int to =
range.GetFirstTo();
864 double label_u = from_offset + from;
875 label_size = label_size_scaled + sep_pix * scale;
877 double label_right = label_u + label_size;
878 if(label_u > low_limit) {
879 if(label_right > high_limit || label_size_scaled >=
range.GetLength()) {
882 low_limit = label_u + label_size + sep_pix * scale;
889 label_u = (to + 1) - to_offset;
896 if (label_u - label_size < low_limit
897 || label_u > high_limit
898 || label_size >=
range.GetLength()) {
901 high_limit = label_u - (label_size + sep_pix * scale);
907 int labels_n = (
int)vLabelsPos.size();
908 for(
int i_label = labels_n - 1; i_label >= 0; i_label-- ) {
915 double shift = -label_size * 0.5;
922 bool b_draw_text = (label_u + shift + label_size < high_limit)
923 && (label_u + shift > low_limit);
925 high_limit = label_u + shift;
930 if ( !
S.empty() || (label_u < high_limit && label_u > low_limit)) {
956 TVPUnit clip_vp_len = clip_vp_right - clip_vp_left + 1;
959 int text_h = (
int) ceil(t_h);
967 int origin_right = clip_vp_left;
975 if(
range.IsDirect()) {
986 TModelUnit text_y = (float) (top_label ? y : (y - text_h));
988 gl.
WriteText(x, text_y, x + or_text_w, text_y + text_h, s.c_str());
991 origin_right += (x + or_text_w);
1002 int pix_l = (
int) ceil(step / scale_x);
1007 int metric_w =
max(pix_l, text_w);
1013 TModelUnit yc = y + (top_label ? half_h : -half_h);
1044 double u_label_offset,
const string& s_text,
1057 double u_label_offset,
const string& s_text,
1076 label_bottom = tick_bottom -
kTextSpaceY - text_v;
1078 label_bottom = tick_bottom - text_v;
1084 label_bottom = tick_bottom + tick_h +
kTextSpaceY;
1113 if (!s_text.empty()) {
1125 gl.
WriteText(x1, y1, text_u, text_v, s_text.c_str(), text_align,
1136 gl.
Vertex2d(pos_u - offset_x, tick_bottom - offset_y);
1137 gl.
Vertex2d(pos_u - offset_x, tick_bottom + tick_h - offset_y);
1144 double u_label_offset,
const string& s_text,
1162 label_left = tick_left - text_v;
1210 gl.
WriteText(x1, y1, text_u, text_v, s_text.c_str(), text_align,
1220 gl.
Vertex2d(tick_left - offset_x, pos_u - offset_y);
1221 gl.
Vertex2d(tick_left + tick_w - offset_x, pos_u - offset_y);
TAlignRangeVector::const_iterator const_iterator
const_iterator insert(const TAlignRange &r)
pair< const_iterator, bool > find_2(position_type pos) const
returns an iterator pointing to a range containing "pos"; if such a range does not exists an iterator...
const_iterator begin() const
CAlignRange Represents an element of pairwise alignment of two sequences.
CGlAttrGuard - guard class for restoring OpenGL attributes.
class CRgbaColor provides a simple abstraction for managing colors.
void SetColor(EColorType type, const CRgbaColor &color)
TModelPoint x_GetLabelSizeUnscaled(CGlPane &pane, const string &label)
CAlignRange< TPos > TAlignRange
void SetRange(int start, int end, int seq_start, bool reverse)
SetRange() activates "manual" mode; in this mode ruler's range in model space is explicitly limited t...
void x_RenderVertPosLabel(CGlPane &pane, double pos_u, double label_offset_u, const string &text, bool draw_tick=true)
virtual string GetTooltip()
void SetTextLabel(const string &label)
void x_CalcStartStopOffsets(const TAlignRange &range, TModelUnit &from_offset, TModelUnit &to_offset)
virtual void SetModelRect(const TModelRect &rc)
void SetFont(CGlTextureFont::EFontFace font_type, unsigned int font_size=12)
TModelRect m_rcLimits
"true" if parameters affecting layout have been changed
virtual TModelRect GetModelRect() const
void x_RenderPosLabel(CGlPane &pane, double pos_u, double label_offset_u, const string &text, bool draw_tick=true)
void x_RenderOriginAndMetric(CGlPane &pane, const TRange &clip_r)
virtual void SetVPRect(const TVPRect &rect)
CGlTextureFont::EFontRotateFlags m_FontRotate
Font rotation flags (rotate around base or cap)
virtual TVPRect GetVPRect() const
void x_RenderBackground(CGlPane &pane, const TModelRect &rc, const TRange &clip_r)
int x_GetOriginMetricSizeV() const
int m_FontRotateDegrees
Use degrees as int for safe comparison to 0, 90, 180 etc.
string x_GetPositionLabel(const TAlignRange &range, int iElem)
TVPPoint GetPreferredSize(int max_num=0) const
CRuler(bool horz=true)
Origin specifies the position in the model space that is represented as "1" in the Ruler's display sp...
EGeometryParam
Ticks and labels placement.
@ eOppLabelTickHeight
tick size at label position (opposite)
@ eOppMajorTickHeight
major tick on the opposite side
@ eOppMinorTickHeight
minor tick on the opposite side
@ eLabelTickHeight
tick size at label position
void x_RenderRange(CGlPane &pane, const TAlignRange &range, const TRange &clip_r)
virtual void SetVisible(bool set)
void SetHorizontal(bool b_horz, ELabelPlacement place=eDefault, ELabelAlign aln=eAln_Center)
int x_GetTicksLabelsSizeV(int max_num) const
Ruler contains two layers.
void SetAutoRange()
SetAutoRange() activates automatic mode; in this mode ruler's range is equal to the provided model li...
void SetLabelOrientation(CGlTextureFont::EFontRotateFlags rotate, int rotate_degrees)
ELabelPlacement m_LabelPlace
void x_UpdatePosLabelsStep(CGlPane &pane)
void SetDisplayOptions(int options)
void x_RenderScale(CGlPane &pane, const TAlignRange &range, const TRange &clip_r)
ELabelAlign
How labels align around ticks.
@ eAln_Bottom
valid for vertical mode only (mapped to eAln_Left for horizontal mode)
@ eAln_Top
valid for vertical mode only (mapped to eAln_Right for horizontal mode)
@ eAln_Right
valid for horizontal mode only (mapped to eAln_Top for vertical mode)
@ eAln_Left
valid for horizontal mode only (mapped to eAln_Bottom for vertical mode)
void x_RenderAllPosLabels(CGlPane &pane, const TAlignRange &range, const TRange &clip_r)
void x_ChooseTickSpace(double scale)
void x_RenderHorzPosLabel(CGlPane &pane, double pos_u, double label_offset_u, const string &text, bool draw_tick=true)
void x_GenerateLabelPositions(const TAlignRange &range, int first_elem, int last_elem, vector< TModelUnit > &vElemPos)
virtual TVPPoint PreferredSize()
virtual void Render(CGlPane &pane)
void x_CalculatePosLabelsStep(CGlPane &Pane)
int x_ToDisplay(const TAlignRange &range, int model) const
TModelUnit x_ToModel(const TAlignRange &range, int display) const
virtual bool NeedTooltip(CGlPane &pane, int vp_x, int vp_y)
void SetGeometryParam(EGeometryParam geom, int value)
TModelPoint x_GetLabelSize(CGlPane &pane, const string &label)
void SetMapping(const TAlignColl &coll)
TAlignColl m_Mapping
range displayed is [m_Start + m_Offset, m_End + m_Offset]
void x_UpdateMappingByPane(CGlPane &pane)
bool x_TextAlongAxis() const
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
void SetSnapToPixel(bool xpix, bool ypix)
If true (the default) text output position is rounded to nearest pixel coordinate,...
virtual void Begin(GLenum mode)=0
Start rendering.
CGlPoint< TVPUnit > TVPPoint
void SetFontRotate(TFontRotateFlags rot)
Set rotation flags (for center of rotation and re-orienting)
virtual void BeginClippingRect(GLint x, GLint y, GLsizei width, GLsizei height)=0
void Offset(T d_x, T d_y)
EFontRotateFlags
Font rotate options.
TVPUnit ProjectX(TModelUnit m_x) const
IRender & GetGl()
convenience function for getting current render manager
void RectC(const TVPRect &rc)
void Vertex2d(GLdouble x, GLdouble y)
TVPRect & GetViewport(void)
virtual TModelUnit TextHeight(const CGlTextureFont *font) const =0
CGlRect< TVPUnit > TVPRect
virtual void BeginText(const CGlTextureFont *font, const CRgbaColor &color)=0
Text is drawn is pixel coordinates.
virtual TModelUnit TextWidth(const CGlTextureFont *font, const char *text) const =0
TModelUnit GetOffsetY() const
static string FormatSeparatedNumber(int number, bool b_postfix=false)
virtual void EndText()=0
Pops matrices and attributes after writing text.
virtual TModelUnit GetMaxWidth(const CGlTextureFont *font, int max_num) const =0
TModelRect & GetModelLimitsRect(void)
void SetFontFace(EFontFace face, bool use_bitmap_overrides=true)
virtual void EndClippingRect()=0
virtual bool IsPrinterFriendly() const =0
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.
EFontFace
Set of pre-defined fonts for which we know we have valid font files.
virtual void WriteText(TModelUnit x, TModelUnit y, const char *text, TModelUnit rotate_degrees=0.0)=0
Write text at specified model coords.
void SetFontSize(unsigned int size)
Set/get font size in points.
TModelRect & GetVisibleRect(void)
CGlRect< TModelUnit > TModelRect
virtual void Disable(GLenum glstate)=0
glDisable()
virtual TModelUnit GetMetric(const CGlTextureFont *font, IGlFont::EMetric metric, const char *text=NULL, int len=-1) const =0
Calls the standard font metric functions except for pdf in which case it first replaces any bitmap fo...
virtual void LineWidth(GLfloat w)=0
Set line width for drawing: glLineWidth()
TModelUnit GetScaleX(void) const
TModelUnit GetScaleY(void) const
TModelUnit GetOffsetX() const
CGlPoint< TModelUnit > TModelPoint
unsigned int GetFontSize() const
virtual void ColorC(const CRgbaColor &c)=0
Set current color (glColor{3,4}{f,d}{v,})
position_type GetToOpen(void) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static const char label[]
void SetFrom(TFrom value)
Assign a value to From data member.
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
void SetTo(TTo value)
Assign a value to To data member.
unsigned int
A callback function used to compare two keys in a database.
range(_Ty, _Ty) -> range< _Ty >
constexpr auto rotate(list< Ts... >) -> decltype((list<>{}+...+rotate_item< Ts >{}))
const struct ncbi::grid::netcache::search::fields::SIZE size
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static const GLdouble origin[]
static int kTextSpaceX
spacing between text and borders or between text and other graphics
static const int kMinMetricPix
minimal size of the metric in pixels
static const int kLabelSepPixY
static const int kOriginOffsetX
distance in pixels between left side of the ruler and origin labels
static const int kLabelSepPixX
static const int kMinTickStepPixels