Commit 239df1cf authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

Save and restore view state, batch render in Examples/DrawGrid

parent 7fa34b10
......@@ -88,6 +88,35 @@ namespace INMOST
colors.push_back(color_t(0.45, 0, 0.55));
colors.push_back(color_t(0, 0, 0));
//colors.push_back(color_t(1,0,0));
}
color_t color_bar::pick_color(float value) const
{
if (value < min)
return color_t(0.4, 1.0, 0.4);
if (value > max)
return color_t(0, 0.6, 0);
float t = (value - min) / (max - min);
std::vector<float>::const_iterator it = std::lower_bound(ticks.begin(), ticks.end(), t);
size_t pos = it - ticks.begin();
if (it == ticks.end() || pos >= ticks.size())
{
return colors.back();
}
if (pos == 0)
{
return colors[0];
}
float interp = (t - ticks[pos - 1]) / (ticks[pos] - ticks[pos - 1]);
return (colors[pos] * interp + colors[pos - 1] * (1 - interp));
}
void color_bar::InitTexture()
{
samples = 4096;
float * pixel_array = new float[(samples + 2) * 4];
......@@ -139,32 +168,8 @@ namespace INMOST
UnbindTexture();
delete[] pixel_array;
//colors.push_back(color_t(1,0,0));
}
color_t color_bar::pick_color(float value) const
{
if (value < min)
return color_t(0.4, 1.0, 0.4);
if (value > max)
return color_t(0, 0.6, 0);
float t = (value - min) / (max - min);
std::vector<float>::const_iterator it = std::lower_bound(ticks.begin(), ticks.end(), t);
size_t pos = it - ticks.begin();
if (it == ticks.end() || pos >= ticks.size())
{
return colors.back();
}
if (pos == 0)
{
return colors[0];
}
float interp = (t - ticks[pos - 1]) / (ticks[pos] - ticks[pos - 1]);
return (colors[pos] * interp + colors[pos - 1] * (1 - interp));
}
void color_bar::BindTexture()
{
//glDisable( GL_TEXTURE_GEN_S );
......
......@@ -19,6 +19,7 @@ namespace INMOST
std::string comment;
unsigned texture;
int samples;
void InitTexture();
public:
color_bar();
~color_bar();
......@@ -42,6 +43,7 @@ namespace INMOST
static bool isVisualizationSmooth() { return smooth; }
static void SetVisualizationTag(Tag t, ElementType et, bool st) { vtag = t; vtype = et; smooth = st; }
static void UnsetVisualizationTag() { vtag = Tag(); vtype = NONE;}
static void InitColorBarTexture() { CommonColorBar->InitTexture(); }
};
Tag GetVisualizationTag();
......@@ -51,4 +53,4 @@ namespace INMOST
bool isColorBarEnabled();
}
#endif
\ No newline at end of file
#endif
This diff is collapsed.
......@@ -2,9 +2,18 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
int font_size = 10;
void printtext(const char * fmt, ...)
{
void * font;
if( font_size <= 10 )
font = GLUT_BITMAP_TIMES_ROMAN_10;
else if ( font_size <= 12 )
font = GLUT_BITMAP_HELVETICA_12;
else if ( font_size <= 18 )
font = GLUT_BITMAP_HELVETICA_18;
else
font = GLUT_BITMAP_TIMES_ROMAN_24;
unsigned int i;
char stext[131072];
va_list ap;
......@@ -14,7 +23,7 @@ void printtext(const char * fmt, ...)
va_end(ap);
for (i = 0; i<strlen(stext); i++)
{
glutBitmapCharacter(GLUT_BITMAP_HELVETICA_10,
glutBitmapCharacter(font,
stext[i]);
}
}
\ No newline at end of file
}
......@@ -292,6 +292,31 @@ void quatget(double *vec)
vec[2] = q.z / q.w;
}
void quatget4(double gq[4])
{
gq[0] = q.x;
gq[1] = q.y;
gq[2] = q.z;
gq[3] = q.w;
}
void quatget4_from_stack(double gq[4])
{
gq[0] = storage.back().x;
gq[1] = storage.back().y;
gq[2] = storage.back().z;
gq[3] = storage.back().w;
}
void quatset4(double gq[4])
{
q.x = gq[0];
q.y = gq[1];
q.z = gq[2];
q.w = gq[3];
}
void reverse_rotatevector_from_stack(double * vec)
{
int i;
......
......@@ -32,4 +32,8 @@ void revrotatevector(double * vec);
void rotatevector_from_stack(double * vec);
void reverse_rotatevector_from_stack(double * vec);
void quatget4(double gq[4]);
void quatget4_from_stack(double gq[4]);
void quatset4(double gq[4]);
#endif
......@@ -262,7 +262,7 @@ namespace INMOST
Storage::real coef, len, size;
coord next = pos, vel;
Element c;
const int maxsteps = 8000;
const int maxsteps = 25000;
points.reserve(maxsteps / 2);
velarr.reserve(maxsteps / 2);
points.push_back(pos);
......@@ -283,10 +283,10 @@ namespace INMOST
c.SetMarker(visited);
GetVelocity(c, velocity_tag, velocity_defined, next, vel);
len = vel.length();
if (len < 1.0e-7) break;
if (len < 1.0e-12) break;
//size = GetSize(c, cell_size);// c->RealDF(cell_size);
size = GetSizeProj(c,vel);
coef = 0.02*size / len;
coef = 0.01*size / len;
next += vel*coef*sign;
points.push_back(next);
velarr.push_back((log(len + 1.0e-25) - velocity_min) / (velocity_max - velocity_min));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment