14 int main(
int argc,
char **argv)
54 void RunHOGGUI(
int argc,
char** argv,
int windowDimension)
56 RunHOGGUI(argc, argv, windowDimension, windowDimension);
59 void RunHOGGUI(
int argc,
char* argv[],
int xDimension,
int yDimension)
64 srandom(
unsigned(time(0)));
73 glutInit(&argc, argv);
74 glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
75 glutInitWindowPosition(0, 0);
76 glutInitWindowSize(xDimension, yDimension);
77 glutCreateWindow(
"Map Abstraction");
116 bool shift = (glutGetModifiers() == GLUT_ACTIVE_SHIFT);
117 bool alt = (glutGetModifiers() == GLUT_ACTIVE_ALT);
118 bool cntrl = (glutGetModifiers() == GLUT_ACTIVE_CTRL);
134 if (
gPan == GL_FALSE)
140 glutSetCursor(GLUT_CURSOR_NONE);
147 float rotation[4] = {0.0f, 0.0f, 0.0f, 0.0f};
244 if (state == GLUT_DOWN) {
263 else if ((button == GLUT_RIGHT_BUTTON) || ((button == GLUT_LEFT_BUTTON) && (
modifiers == GLUT_ACTIVE_CTRL)))
306 else if ((button == GLUT_MIDDLE_BUTTON) || ((button == GLUT_LEFT_BUTTON) && (
modifiers == GLUT_ACTIVE_SHIFT)))
349 else if (button == GLUT_LEFT_BUTTON)
373 if (state == GLUT_UP)
499 static double lastTime = ((double)clock()/CLOCKS_PER_SEC);
500 double currTime = ((double)clock()/CLOCKS_PER_SEC);
502 if ((currTime - lastTime) > (1/
fps)) {
562 GLdouble ratio, radians, wd2;
570 minVal = maxVal = viewPort;
572 for (
int x = minVal; x <= maxVal; x++)
601 glMatrixMode(GL_MODELVIEW);
686 glCallList (fontList + cstrOut[i++]);
698 point3d a(-.95, .95, -.95), b(.95, -.95, .95);
708 point3d a(-.95, .95, -.95), b(.95, -.95, .95);
719 for (
auto &i : display.
text)
721 if (i.viewport != port)
723 glColor3f(i.c.r, i.c.g, i.c.b);
727 DrawText(i.loc.x, i.loc.y,i.loc.z, i.size*2, i.s.c_str());
737 if (i.viewport != port)
739 glColor3f(i.c.r, i.c.g, i.c.b);
742 for (
int t = 0; t < i.points.size()-1; t++)
744 GLfloat xOff = i.points[t].x-i.points[t+1].x;
745 GLfloat yOff = i.points[t].y-i.points[t+1].y;
746 GLfloat ratio = i.size/sqrt(xOff*xOff+yOff*yOff);
747 glVertex3f(i.points[t].x-ratio*yOff, i.points[t].y-ratio*xOff, i.points[t].z);
748 glVertex3f(i.points[t].x+ratio*yOff, i.points[t].y+ratio*xOff, i.points[t].z);
749 glVertex3f(i.points[t+1].x+ratio*yOff, i.points[t+1].y+ratio*xOff, i.points[t].z);
750 glVertex3f(i.points[t+1].x-ratio*yOff, i.points[t+1].y-ratio*xOff, i.points[t].z);
763 for (
int x = display.
drawCommands.size()-1; x >= 0; x--)
767 if (i.viewport != port)
773 glColor3f(i.shape.c.r, i.shape.c.g, i.shape.c.b);
775 glVertex2f(i.shape.r.left, i.shape.r.bottom);
776 glVertex2f(i.shape.r.left, i.shape.r.top);
777 glVertex2f(i.shape.r.right, i.shape.r.top);
778 glVertex2f(i.shape.r.right, i.shape.r.bottom);
785 glColor3f(i.shape.c.r, i.shape.c.g, i.shape.c.b);
786 glLineWidth(i.shape.width);
794 glBegin(GL_TRIANGLE_STRIP);
795 GLfloat rad = i.shape.width/2.0;
796 glVertex2f(i.shape.r.left-rad, i.shape.r.bottom+rad);
797 glVertex2f(i.shape.r.left+rad, i.shape.r.bottom-rad);
799 glVertex2f(i.shape.r.left-rad, i.shape.r.top-rad);
800 glVertex2f(i.shape.r.left+rad, i.shape.r.top+rad);
802 glVertex2f(i.shape.r.right+rad, i.shape.r.top-rad);
803 glVertex2f(i.shape.r.right-rad, i.shape.r.top+rad);
805 glVertex2f(i.shape.r.right+rad, i.shape.r.bottom+rad);
806 glVertex2f(i.shape.r.right-rad, i.shape.r.bottom-rad);
808 glVertex2f(i.shape.r.left-rad, i.shape.r.bottom+rad);
809 glVertex2f(i.shape.r.left+rad, i.shape.r.bottom-rad);
817 glColor3f(i.shape.c.r, i.shape.c.g, i.shape.c.b);
819 DrawCircle((i.shape.r.right+i.shape.r.left)/2, (i.shape.r.top+i.shape.r.bottom)/2, fabs(i.shape.r.top-i.shape.r.bottom)/2.0, 64);
824 glColor3f(i.shape.c.r, i.shape.c.g, i.shape.c.b);
825 FrameCircle((i.shape.r.right+i.shape.r.left)/2, (i.shape.r.top+i.shape.r.bottom)/2,
826 fabs(i.shape.r.top-i.shape.r.bottom)/2.0,
833 glColor3f(i.polygon.c.r, i.polygon.c.g, i.polygon.c.b);
834 DrawCircle(i.polygon.center.x, i.polygon.center.y, i.polygon.radius, i.polygon.segments, i.polygon.rotate);
839 glColor3f(i.polygon.c.r, i.polygon.c.g, i.polygon.c.b);
845 glLineWidth(i.line.width);
847 glColor3f(i.line.c.r, i.line.c.g, i.line.c.b);
848 glVertex2f(i.line.start.x, i.line.start.y);
849 glVertex2f(i.line.end.x, i.line.end.y);
857 if (i.viewport != port)
859 glColor3f(i.c.r, i.c.g, i.c.b);
862 for (
int t = 0; t < i.points.size()-1; t++)
864 GLfloat xOff = i.points[t].x-i.points[t+1].x;
865 GLfloat yOff = i.points[t].y-i.points[t+1].y;
866 GLfloat ratio = i.size/sqrt(xOff*xOff+yOff*yOff);
867 glVertex3f(i.points[t].x-ratio*yOff, i.points[t].y-ratio*xOff, i.points[t].z);
868 glVertex3f(i.points[t].x+ratio*yOff, i.points[t].y+ratio*xOff, i.points[t].z);
869 glVertex3f(i.points[t+1].x+ratio*yOff, i.points[t+1].y+ratio*xOff, i.points[t].z);
870 glVertex3f(i.points[t+1].x-ratio*yOff, i.points[t+1].y-ratio*xOff, i.points[t].z);
886 if (i.viewport != port)
892 glColor3f(i.shape.c.r, i.shape.c.g, i.shape.c.b);
895 glVertex2f(i.shape.r.left, i.shape.r.bottom);
896 glVertex2f(i.shape.r.left, i.shape.r.top);
897 glVertex2f(i.shape.r.right, i.shape.r.top);
898 glVertex2f(i.shape.r.right, i.shape.r.bottom);
905 glColor3f(i.shape.c.r, i.shape.c.g, i.shape.c.b);
906 glLineWidth(i.shape.width);
914 glBegin(GL_TRIANGLE_STRIP);
915 GLfloat rad = i.shape.width/2.0;
916 glVertex2f(i.shape.r.left-rad, i.shape.r.bottom+rad);
917 glVertex2f(i.shape.r.left+rad, i.shape.r.bottom-rad);
919 glVertex2f(i.shape.r.left-rad, i.shape.r.top-rad);
920 glVertex2f(i.shape.r.left+rad, i.shape.r.top+rad);
922 glVertex2f(i.shape.r.right+rad, i.shape.r.top-rad);
923 glVertex2f(i.shape.r.right-rad, i.shape.r.top+rad);
925 glVertex2f(i.shape.r.right+rad, i.shape.r.bottom+rad);
926 glVertex2f(i.shape.r.right-rad, i.shape.r.bottom-rad);
928 glVertex2f(i.shape.r.left-rad, i.shape.r.bottom+rad);
929 glVertex2f(i.shape.r.left+rad, i.shape.r.bottom-rad);
938 glColor3f(i.shape.c.r, i.shape.c.g, i.shape.c.b);
939 DrawCircle((i.shape.r.right+i.shape.r.left)/2, (i.shape.r.top+i.shape.r.bottom)/2, fabs(i.shape.r.top-i.shape.r.bottom)/2.0, 64);
944 glColor3f(i.polygon.c.r, i.polygon.c.g, i.polygon.c.b);
945 DrawCircle(i.polygon.center.x, i.polygon.center.y, i.polygon.radius, i.polygon.segments, i.polygon.rotate);
950 glColor3f(i.polygon.c.r, i.polygon.c.g, i.polygon.c.b);
961 glLineWidth(i.line.width);
963 glColor3f(i.line.c.r, i.line.c.g, i.line.c.b);
964 glVertex2f(i.line.start.x, i.line.start.y);
965 glVertex2f(i.line.end.x, i.line.end.y);
993 glClear(GL_COLOR_BUFFER_BIT);
997 glClear(GL_DEPTH_BUFFER_BIT);
1003 glMatrixMode(GL_PROJECTION);
1016 glMatrixMode(GL_PROJECTION); glLoadIdentity();
1017 glMatrixMode(GL_MODELVIEW); glLoadIdentity();
1019 glDisable(GL_LIGHTING);
1020 glColor3ub(255, 255, 255);
1021 glBegin(GL_LINE_LOOP);
1092 CGRect viewRect = {{0.0f, 0.0f}, {0.0f, 0.0f}};
1113 glEnable(GL_DEPTH_TEST);
1115 glShadeModel(GL_SMOOTH);
1116 glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
1117 glFrontFace(GL_CCW);
1118 glPolygonOffset (1.0, 1.0);
1120 glClearColor(0.0,0.0,0.0,0.0);
1123 viewRect.
size.
width = scale*glutGet(GLUT_WINDOW_WIDTH);
1124 viewRect.
size.
height = scale*glutGet(GLUT_WINDOW_HEIGHT);