52 m_UseAbbrev(useAbbrev),
53 m_CoordConverter(
NULL)
59 for(
char d =
'0'; d <=
'9'; ++d) {
79 for(
unsigned int i = 0;
i < x; ++
i) {
101 int digitsI = (num == 0) ? 1 : (
int) floor(
log10((
float)num) + 1);
104 }
else if (digitsI == 2) {
106 }
else if (num > 5) {
130 while (
abs(num) >= 10) {
132 if (++count % 3 == 0) {
139 reverse(
tmp.begin(),
tmp.end());
145 oss.flags(oss.scientific);
152 float decimal = (float)num;
153 while (
abs(num) >= 1000) {
155 decimal = (float) num / 1000;
175 unsigned int size = 0;
177 int digitsL = (left == 0) ? 1 : (
int) floor(
log10((
float)
abs(left)) + 1);
178 int digitsR = (right == 0) ? 1 : (
int) floor(
log10((
float)
abs(right)) + 1);
185 (
unsigned int)((
max(digitsL, digitsR) +
max(digitsL, digitsR) / 3)
197 if (left < 0 || right < 0) {
210 throw runtime_error(
"CGlDrawScale::Draw given non-positive width.");
212 double xScale, yScale;
215 GLdouble mvMatrix[16], projMatrix[16];
216 GLdouble wx1,wx2,wy1,wy2,wz;
218 glGetIntegerv(GL_VIEWPORT, viewport);
219 glGetDoublev(GL_MODELVIEW_MATRIX, mvMatrix);
220 glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
225 gluUnProjectX(glL,0,0, mvMatrix, projMatrix, viewport, &wx1,&wy1,&wz);
226 gluUnProjectX(glR,1,0, mvMatrix, projMatrix, viewport, &wx2,&wy2,&wz);
227 xScale = (wx2-wx1)/(glR-glL);
233 abs(right-left) > width) {
240 int labelInterval = (
int) ceil(((
float)(right-left) / width) *
244 int minBound =
min(left, right);
245 int maxBound =
max(left, right);
248 int labelStart = left;
249 if (labelStart % labelInterval != 0) {
250 labelStart = (labelStart / labelInterval) * labelInterval;
251 if (labelStart < minBound || labelStart > maxBound) {
252 labelStart += labelInterval;
257 for (
int labelPos = labelStart;
258 labelPos >= minBound && labelPos <= maxBound;
259 labelPos += labelInterval) {
265 3.0f * yScale,
label.c_str());
270 int tickInterval =
max(1,
abs(labelInterval) / 5);
271 if (labelInterval < 0) {
274 int tickStart = left;
275 if (tickStart % tickInterval != 0) {
276 tickStart = (tickStart / tickInterval) * tickInterval;
277 if (tickStart < minBound || tickStart > maxBound) {
278 tickStart += tickInterval;
282 for (
int labelPos = tickStart;
283 labelPos >= minBound && labelPos <= maxBound;
284 labelPos += tickInterval) {
287 glVertex2d(glPos, (labelPos % labelInterval == 0) ? -yScale * 4.0
289 glVertex2d(glPos, 0);
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
string x_GenerateLabel(int num, EAbbrevType type) const
virtual TModelUnit TextWidth(const char *text) const =0
void Draw(int width, int left, int right) const
unsigned int x_Exp10(unsigned int x) const
virtual void TextOut(const char *text) const =0
virtual int ToGl(int) const =0
CGlDrawScale(IGlFont &font, EAbbrevType useAbbrev)
TModelUnit m_MaxDigitWidth
static const char * sm_SISymbols
CCoordConverter * m_CoordConverter
unsigned int x_CalcMaxLabelSize(int left, int right, EAbbrevType abbrev) const
void x_Normalize(int &num) const
int gluUnProjectX(GLdouble winx, GLdouble winy, GLdouble winz, const GLdouble modelMatrix[16], const GLdouble projMatrix[16], const GLint viewport[4], GLdouble *objx, GLdouble *objy, GLdouble *objz)
TModelUnit m_MaxSIPrefixWidth
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static const char label[]
unsigned int
A callback function used to compare two keys in a database.
const struct ncbi::grid::netcache::search::fields::SIZE size
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.