From f8dddc8325760c8cf6f05dca7b209daf4532df25 Mon Sep 17 00:00:00 2001 From: arif Date: Thu, 17 Apr 2008 21:01:39 +0000 Subject: [PATCH] z axis is added to rotate a new image file (rotate.raw) has been al so added to share/icons --- cmd/smyrna/draw.c | 14 ++++++++++ cmd/smyrna/draw.h | 1 + cmd/smyrna/glexpose.c | 60 ++++++++++++++++++++++++++++++++++++++++++ cmd/smyrna/topview.c | 61 +++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 134 insertions(+), 2 deletions(-) diff --git a/cmd/smyrna/draw.c b/cmd/smyrna/draw.c index ea499ed5b..ba9d93688 100755 --- a/cmd/smyrna/draw.c +++ b/cmd/smyrna/draw.c @@ -766,3 +766,17 @@ RGBColor GetRGBColor(char *color) } return c; } +void drawEllipse(float xradius, float yradius,int angle1,int angle2) +{ + int i; + glBegin(GL_LINE_STRIP); + + for (i=angle1; i<=angle2; i++) + { + //convert degrees into radians + float degInRad = i*DEG2RAD; + glVertex2f(cos(degInRad)*xradius,sin(degInRad)*yradius); + } + + glEnd(); +} diff --git a/cmd/smyrna/draw.h b/cmd/smyrna/draw.h index 9410a7b76..489d32738 100755 --- a/cmd/smyrna/draw.h +++ b/cmd/smyrna/draw.h @@ -42,5 +42,6 @@ extern int randomize_color(RGBColor * c, int brightness); extern void drawCircle(float x, float y, float radius, float zdepth); extern RGBColor GetRGBColor(char *color); extern void drawBorders(ViewInfo * view); +void drawEllipse(float xradius, float yradius,int angle1,int angle2); #endif diff --git a/cmd/smyrna/glexpose.c b/cmd/smyrna/glexpose.c index d41e22d74..9a4f3e880 100644 --- a/cmd/smyrna/glexpose.c +++ b/cmd/smyrna/glexpose.c @@ -18,6 +18,7 @@ #include "topview.h" #include "glutils.h" #include "topview.h" + /* refreshes camera settings using view parameters such as pan zoom etc if a camera is selected viewport is switched to 3D @@ -48,6 +49,8 @@ int glupdatecamera(ViewInfo * view) // glTranslatef(view->cameras[view->active_camera]->targetx/pow(view->cameras[view->active_camera]->r,0.125),view->cameras[view->active_camera]->targety/pow(view->cameras[view->active_camera]->r,0.125),0); glRotatef(view->cameras[view->active_camera]->angley,1,0,0); glRotatef(view->cameras[view->active_camera]->anglex,0,1,0); + glRotatef(view->cameras[view->active_camera]->anglez,0,0,1); + } GetOGLPosRef(1, view->h - 5, &(view->clipX1), &(view->clipY1), &(view->clipZ1)); @@ -83,6 +86,7 @@ int glexpose_main(ViewInfo * view) glexpose_drawgraph(view); draw_selection_box(view); drawBorders(view); + drawRotatingTools(); /*DEBUG*/ /* if (view->mouse.mouse_mode == MM_PAN) { @@ -150,3 +154,59 @@ int glexpose_drawgraph(ViewInfo * view) } return 0; } + +void drawRotatingTools() +{ + float x,y,z; + float x1,y1,z1; + float x2,y2,z2; + float R1,R2; + if ((view->mouse.mouse_mode == MM_ROTATE) && (view->active_camera >=0)) + { + R1=25; + R2=200; + glCompDrawBegin(); + GetOGLPosRef(1, view->h - 5, &x1, &y1,&z1); + GetOGLPosRef(view->w - 1, 1, &x2,&y2,&z2); + x=(x2-x1)/2.0; + y=(y2-y1)/2.0; + glTranslatef(x,y,0); + if ((view->mouse.rotate_axis==MOUSE_ROTATE_X) || (view->mouse.rotate_axis==MOUSE_ROTATE_XY)) + { + glLineWidth(2); + glColor4f(0,1,0,0.5); + } + else + { + glLineWidth(1); + glColor4f(1,0,0,0.5); + } + drawEllipse(R1,R2,90,270); + if ((view->mouse.rotate_axis==MOUSE_ROTATE_Y) || (view->mouse.rotate_axis==MOUSE_ROTATE_XY)) + { + glLineWidth(2); + glColor4f(0,1,0,0.5); + } + else + { + glLineWidth(1); + glColor4f(1,0,0,0.5); + } + drawEllipse(R2, R1,0,180); + if (view->mouse.rotate_axis==MOUSE_ROTATE_Z) + { + glLineWidth(2); + glColor4f(0,1,0,0.5); + } + else + { + glLineWidth(1); + glColor4f(1,0,0,0.5); + } + + drawEllipse(R2, R2,0,360); + glCompDrawEnd(); + } + +} + diff --git a/cmd/smyrna/topview.c b/cmd/smyrna/topview.c index 4c05e6ed3..7bf4c9bc6 100755 --- a/cmd/smyrna/topview.c +++ b/cmd/smyrna/topview.c @@ -1033,6 +1033,26 @@ void menu_switch_to_fisheye(void* p) } view->Topview->is_top_fisheye=1; } +void menu_click_rotate(void* p) +{ + view->mouse.mouse_mode = MM_ROTATE; +} +void menu_click_rotate_x(void* p) +{ + view->mouse.rotate_axis=MOUSE_ROTATE_X; +} +void menu_click_rotate_y(void* p) +{ + view->mouse.rotate_axis=MOUSE_ROTATE_Y; +} +void menu_click_rotate_xy(void* p) +{ + view->mouse.rotate_axis=MOUSE_ROTATE_XY; +} +void menu_click_rotate_z(void* p) +{ + view->mouse.rotate_axis=MOUSE_ROTATE_Z; +} #ifdef _WIN32 @@ -1041,6 +1061,7 @@ void menu_switch_to_fisheye(void* p) #define SMYRNA_ICON_ZOOMPLUS "c:/zoomplus.raw" #define SMYRNA_ICON_ZOOMMINUS "c:/zoomminus.raw" #define SMYRNA_ICON_FISHEYE "c:/fisheye.raw" +#define SMYRNA_ICON_ROTATE "c:/rotate.raw" #endif static char* smyrna_icon_pan; @@ -1119,7 +1140,7 @@ glCompSet *glcreate_gl_topview_menu() //control panel - p = glCompPanelNew(25, 75, 165, 200); + p = glCompPanelNew(25, 75, 165, 277); p->data = 1; //control panel glCompSetAddPanel(s, p); @@ -1144,7 +1165,43 @@ glCompSet *glcreate_gl_topview_menu() b->groupid = 2; b->callbackfunc = menu_switch_to_fisheye; glCompSetAddButton(s, b); - //pan button + + //rotate + b = glCompButtonNew(5, 197, 72, 72, "", SMYRNA_ICON_ROTATE, + 72, 72); + b->groupid = 3; + b->customptr = view; + b->panel = p; + b->callbackfunc = menu_click_rotate; + glCompSetAddButton(s, b); + + b = glCompButtonNew(80, 251, 40, 20, "X", '\0', 0, 0); + b->customptr = view; + b->panel = p; + b->groupid = 1; + b->callbackfunc = menu_click_rotate_x; + glCompSetAddButton(s, b); + b = glCompButtonNew(125, 251, 40, 20, "Y", '\0', 0, 0); + b->customptr = view; + b->panel = p; + b->groupid = 1; + b->callbackfunc = menu_click_rotate_y; + glCompSetAddButton(s, b); + b = glCompButtonNew(80, 231, 40, 20, "XY", '\0', 0, 0); + b->customptr = view; + b->panel = p; + b->groupid = 1; + b->callbackfunc = menu_click_rotate_xy; + glCompSetAddButton(s, b); + b = glCompButtonNew(125, 231, 40, 20, "Z", '\0', 0, 0); + b->customptr = view; + b->panel = p; + b->groupid = 1; + b->callbackfunc = menu_click_rotate_z; + glCompSetAddButton(s, b); + + + //pan button b = glCompButtonNew(5, 120, 72, 72, "adasasds", SMYRNA_ICON_PAN, 72, 72); b->groupid = 3; -- 2.40.0