#include "xdot.h"
#include "viewport.h"
#include "topfisheyeview.h"
+#include "appmouse.h"
//delta values
static float dx = 0.0;
static void set_options(sdot_op * op, int param)
{
- if ((param == 1) && (view->mouse.mouse_mode == 10) && (view->mouse.down == 1)) //selected, if there is move, move it
+ int a=get_mode(view);
+ if ((param == 1) && (a == 10) && (view->mouse.down == 1)) //selected, if there is move, move it
{
dx = view->mouse.GLinitPos.x-view->mouse.GLfinalPos.x;
dy = view->mouse.GLinitPos.y-view->mouse.GLfinalPos.y;
void draw_selection_box(ViewInfo * view)
{
- if (((view->mouse.mouse_mode == 4) || (view->mouse.mouse_mode == 5))
+/* if (((view->mouse.mouse_mode == 4) || (view->mouse.mouse_mode == 5))
&& view->mouse.down) {
glColor4f(view->Selection.SelectionColor.R,
view->Selection.SelectionColor.G,
if (view->mouse.mouse_mode == 5)
glDisable(GL_LINE_STIPPLE);
- }
+ }*/
}
void draw_magnifier(ViewInfo * view)
{
- if ((view->mouse.mouse_mode == MM_MAGNIFIER)
+ if ((get_mode(view) == MM_MAGNIFIER)
&& (view->mouse.down)) {
GLfloat mg_x, mg_y, mg_z;
GLUquadric *fisheyesphere;
void draw_fisheye_magnifier(ViewInfo * view)
{
- if ((view->mouse.mouse_mode == 21) && (view->mouse.down)) {
+ if (get_mode(view)==MM_FISHEYE_MAGNIFIER)
+
+ {
float a;
GLfloat mg_x, mg_y, mg_z;
a = GetOGLDistance((int) view->fmg.constantR);
view->borderColor.G, view->borderColor.A);
glLineWidth(2);
glBegin(GL_LINE_STRIP);
- glVertex2d(view->bdxLeft, view->bdyBottom);
- glVertex2d(view->bdxRight, view->bdyBottom);
- glVertex2d(view->bdxRight, view->bdyTop);
- glVertex2d(view->bdxLeft, view->bdyTop);
- glVertex2d(view->bdxLeft, view->bdyBottom);
+ glVertex3d(view->bdxLeft, view->bdyBottom,0);
+ glVertex3d(view->bdxRight, view->bdyBottom,0);
+ glVertex3d(view->bdxRight, view->bdyTop,0);
+ glVertex3d(view->bdxLeft, view->bdyTop,0);
+ glVertex3d(view->bdxLeft, view->bdyBottom,0);
glEnd();
glLineWidth(1);
}
void drawRotatingAxis(void)
{
-#ifdef UNUSED
- float x, y;
- float x1, y1, z1;
- float x2, y2, z2;
- float R1, R2;
-#endif
static GLUquadricObj *quadratic = (GLUquadricObj *) 0;
+ float AL = 45;
+
+ if (get_mode(view) != MM_ROTATE)
+ return;
+
if (!quadratic) {
quadratic = gluNewQuadric(); // Create A Pointer To The Quadric Object
gluQuadricNormals(quadratic, GLU_SMOOTH); // Create Smooth Normals
}
- if ((view->mouse.mouse_mode == MM_ROTATE)
- && (view->active_camera >= 0)) {
- float AL = 45;
glPushMatrix();
glLoadIdentity();
glMultMatrixf(view->arcball->Transform.M); /*arcball transformations , experimental */
glLineWidth(1);
glPopMatrix();
- }
}
draw_fisheye_magnifier(view);
draw_magnifier(view);
glexpose_drawgraph(view);
- draw_selection_box(view);
drawBorders(view);
// drawRotatingTools();
// draw_cube();
GtkWidget * widget)
{
+ int a=get_mode(v);
redraw = FALSE;
- view->FontSizeConst = GetOGLDistance(14);
/*panning */
- if ((event->state & GDK_BUTTON1_MASK)
- && (v->mouse.mouse_mode == MM_PAN))
+ if (a == MM_PAN)
glmotion_pan(v);
-
/*rotating, only in 3d v */
- if ((v->active_camera >= 0) && (v->mouse.mouse_mode == MM_ROTATE))
+ if (a == MM_ROTATE)
glmotion_rotate(v);
/*zooming */
- if ((event->state & GDK_BUTTON1_MASK)
- && (v->mouse.mouse_mode == MM_ZOOM))
+ if (a == MM_ZOOM)
glmotion_zoom(v);
-
/*selection rect */
- if ((event->state & GDK_BUTTON1_MASK)
- && ((v->mouse.mouse_mode == MM_RECTANGULAR_SELECT)
- || (v->mouse.mouse_mode == 5))) {
+ if ((a == MM_RECTANGULAR_SELECT) || (a == 5))
+ {
GetFixedOGLPos((int) event->x, (int) event->y, v->GLDepth,
&(v->mouse.GLfinalPos.x), &(v->mouse.GLfinalPos.y), &(v->mouse.GLfinalPos.z));
redraw = TRUE;
}
- if ((event->state & GDK_BUTTON1_MASK)
- && (v->mouse.mouse_mode == MM_MOVE)) {
+ if (a == MM_MOVE)
+ {
GetFixedOGLPos((int) event->x, (int) event->y, v->GLDepth,
&(v->mouse.GLfinalPos.x), &(v->mouse.GLfinalPos.y), &(v->mouse.GLfinalPos.z));
redraw = TRUE;
}
- if ((event->state & GDK_BUTTON1_MASK)
- && ((v->mouse.mouse_mode == MM_MAGNIFIER)
- || (v->mouse.mouse_mode == MM_FISHEYE_MAGNIFIER))) {
- v->mouse.pos.x = (float) event->x;
- v->mouse.pos.y = (float) event->y;
- redraw = TRUE;
- }
-
if (redraw)
gdk_window_invalidate_rect(widget->window, &widget->allocation,
FALSE);
dy = 0.0;
return FALSE;
}
+static gboolean key_press_event(GtkWidget * widget, GdkEventKey * event, gpointer data)
+{
+ view->keymap.down=1;
+ view->keymap.keyVal=event->keyval;
+// printf ("key is pressed:%d\n",event->keyval);
+
+}
+static gboolean key_release_event(GtkWidget * widget, GdkEventKey * event, gpointer data)
+{
+ // printf ("key is released:%d\n",event->keyval);
+ view->keymap.down=0;
+}
+
static gboolean
scroll_event(GtkWidget * widget, GdkEventScroll * event, gpointer data)
dx = x - begin_x;
dy = y - begin_y;
-
view->mouse.dragX = dx;
view->mouse.dragY = dy;
-
-
- if((view->mouse.t==glMouseLeftButton) && (view->mouse.down))
+ if((view->mouse.t==glMouseLeftButton) && (view->mouse.down) )
{
appmouse_left_drag(view,(int)event->x,(int)event->y);
redraw = TRUE;
}
#endif
-/*
- call back for mouse mode changes,
- params:GtkMenuItem is not used, mouse_mode is the new mouse_mode
- return value:none
-*/
-void switch_Mouse(GtkMenuItem * menuitem, int mouse_mode)
-{
- switch (mouse_mode) {
-
- case -1:
- change_cursor(GDK_TOP_LEFT_ARROW);
- break;
- case 0:
- change_cursor(GDK_HAND2);
- break;
- case 1:
- change_cursor(GDK_SIZING);
- break;
- case 3:
- change_cursor(GDK_CROSS);
- break;
- case 4:
- change_cursor(GDK_TCROSS);
- break;
- case 5:
- change_cursor(GDK_CROSSHAIR);
- break;
- case 10:
- change_cursor(GDK_FLEUR);
- break;
- case MM_ROTATE:
- change_cursor(GDK_EXCHANGE);
- break;
- default:
- break;
- };
- view->mouse.mouse_mode = mouse_mode;
-}
-
/*
call back for mouse right click, this function activates the gtk right click pop up menu
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS |
GDK_BUTTON_RELEASE_MASK |
- GDK_SCROLL | GDK_VISIBILITY_NOTIFY_MASK);
+ GDK_SCROLL | GDK_VISIBILITY_NOTIFY_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK );
g_signal_connect_after(G_OBJECT(view->drawing_area), "realize",
G_CALLBACK(realize), NULL);
/* g_signal_connect(G_OBJECT(view->drawing_area), "2button_press_event",
G_CALLBACK(button_press_event), NULL);*/
- g_signal_connect(G_OBJECT(view->drawing_area), "button_release_event",
- G_CALLBACK(button_release_event), NULL);
- g_signal_connect(G_OBJECT(view->drawing_area), "key_release_event",
- G_CALLBACK(button_release_event), NULL);
- g_signal_connect(G_OBJECT(view->drawing_area), "key_press_event",
- G_CALLBACK(button_release_event), NULL);
+ g_signal_connect(G_OBJECT(view->drawing_area), "button_release_event",G_CALLBACK(button_release_event), NULL);
+ g_signal_connect(G_OBJECT(view->drawing_area), "key_release_event", G_CALLBACK(key_release_event), NULL);
+ g_signal_connect(G_OBJECT(view->drawing_area), "key_press_event", G_CALLBACK(key_press_event), NULL);
g_signal_connect(G_OBJECT(view->drawing_area), "scroll_event",
G_CALLBACK(scroll_event), NULL);
G_CALLBACK(motion_notify_event), NULL);
+//gtk_accel_group_connect (GTK_ACCEL_GROUP (mainw->accel_group), GDK_Page_Up, GDK_CONTROL_MASK, 0, g_cclosure_new (G_CALLBACK (prevclip_callback),NULL,NULL));
gtk_box_pack_start(GTK_BOX(vbox), view->drawing_area, TRUE, TRUE, 0);
gtk_widget_show(view->drawing_area);
+
+
+ gtk_widget_add_events(glade_xml_get_widget(xml, "frmMain"),
+ GDK_BUTTON_MOTION_MASK |
+ GDK_POINTER_MOTION_MASK |
+ GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_SCROLL | GDK_VISIBILITY_NOTIFY_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK );
+
+
+ g_signal_connect(G_OBJECT(glade_xml_get_widget(xml, "frmMain")), "key_release_event", G_CALLBACK(key_release_event), NULL);
+ g_signal_connect(G_OBJECT(glade_xml_get_widget(xml, "frmMain")), "key_press_event", G_CALLBACK(key_press_event), NULL);
+
+
/* Popup menu. */
#ifdef UNUSED
}
static void appmouse_left_click(ViewInfo* v,int x,int y)
{
- if (v->mouse.mouse_mode == MM_SINGLE_SELECT) //single select
- {
- v->Selection.Active = 1;
- v->Selection.Type = 0;
- v->Selection.AlreadySelected = 0;
- }
}
static void appmouse_right_click(ViewInfo* v,int x,int y)
static void appmouse_down(ViewInfo* v,int x,int y)
{
+ view->mouse.dragX = 0;
+ view->mouse.dragY = 0;
v->mouse.down=1;
v->mouse.initPos.x=x;
v->mouse.initPos.y=y;
v->mouse.down=0;
v->mouse.finalPos.x=x;
v->mouse.finalPos.y=y;
+ view->mouse.dragX = 0;
+ view->mouse.dragY = 0;
+
GetFixedOGLPos((float) x,y,v->GLDepth, &v->mouse.GLfinalPos.x,&v->mouse.GLfinalPos.y,&v->mouse.GLfinalPos.z);
if(singleclick(v))
{
y2=v->mouse.GLpos.y;
// v->mouse.dragX=x2-prevX;
// v->mouse.dragY=y2-prevY;
- //printf ("(%f,%f)->(%f,%f) : %f %f \n",prevX,prevY,v->mouse.GLpos.x,v->mouse.GLpos.y,v->mouse.dragX,v->mouse.dragY);
prevX=x2;
prevY=y2;
}
-void appmouse_left_click_up(ViewInfo* v,int x,int y)
+int get_mode(ViewInfo* v)
{
- appmouse_up(v,x,y);
- if (v->mouse.mouse_mode == MM_MOVE)
- move_TVnodes();
+/*#define MM_PAN 0
+#define MM_ZOOM 1
+#define MM_ROTATE 2
+#define MM_SINGLE_SELECT 3
+#define MM_RECTANGULAR_SELECT 4
+#define MM_RECTANGULAR_X_SELECT 5
+#define MM_MOVE 10
+#define MM_MAGNIFIER 20
+#define MM_FISHEYE_MAGNIFIER 21*/
- if ((v->mouse.mouse_mode == MM_FISHEYE_MAGNIFIER) || (v->mouse.mouse_mode == MM_MAGNIFIER)) //fisheye mag mouse release, stop distortion
- {
+
+ if ((view->mouse.t==glMouseLeftButton)&&(view->keymap.down) && (view->keymap.keyVal == B_LSHIFT/*left shift*/) && (view->active_camera==-1))
+ return MM_FISHEYE_MAGNIFIER;
+ if ((view->mouse.t==glMouseLeftButton)&&(view->keymap.down) && (view->keymap.keyVal == B_LSHIFT/*left shift*/) && (view->active_camera>-1))
+ return MM_ROTATE;
+ if ((view->mouse.t==glMouseLeftButton)&&(view->keymap.down) && (view->keymap.keyVal == B_LCTRL/*left CTRL*/))
+ return MM_MOVE;
+ if ((view->mouse.t==glMouseLeftButton)&&(view->mouse.down) )
+ return MM_PAN;
+
+
+
+
+}
+void appmouse_left_click_up(ViewInfo* v,int x,int y)
+{
+ int a=get_mode(v);
+ appmouse_up(v,x,y);
+/* if (v->mouse.mouse_mode == MM_MOVE)
+ move_TVnodes();*/
+ if ((a== MM_FISHEYE_MAGNIFIER) || (a == MM_MAGNIFIER)) //fisheye mag mouse release, stop distortion
originate_distorded_coordinates(v->Topview);
- }
}
void appmouse_left_drag(ViewInfo* v,int x,int y)
{
+ int a=get_mode(v);
appmouse_drag(v,x,y);
- switch (view->mouse.mouse_mode)
+
+ if (a==MM_ROTATE)
+
{
- case MM_PAN:
- glmotion_pan(v);
- break;
- case MM_ROTATE:
- view->arcball->MousePt.s.X = (GLfloat) x;
- view->arcball->MousePt.s.Y = (GLfloat) y;
- if (!view->arcball->isDragging) {
- arcmouseClick(view);
- view->arcball->isDragging = 1;
-
- } else
+ view->arcball->MousePt.s.X = (GLfloat) x;
+ view->arcball->MousePt.s.Y = (GLfloat) y;
+ if (!view->arcball->isDragging) {
+ arcmouseClick(view);
+ view->arcball->isDragging = 1;
+ } else
arcmouseDrag(view);
- break;
+ return;
}
+ if (a==MM_PAN)
+ glmotion_pan(v);
+ if (a==MM_MOVE)
+ move_TVnodes();
+
}
void appmouse_right_click_down(ViewInfo* v,int x,int y)
}
else /*update selection values*/
- {
- if (v->mouse.GLinitPos.x <= v->mouse.GLfinalPos.x)
- v->Selection.X = v->mouse.GLinitPos.x;
- else
- v->Selection.X = v->mouse.GLfinalPos.x;
- if (v->mouse.GLinitPos.y <= v->mouse.GLfinalPos.y)
- v->Selection.Y = v->mouse.GLinitPos.y;
- else
- v->Selection.Y = v->mouse.GLfinalPos.y;
- v->Selection.W = ABS(v->mouse.GLfinalPos.x - v->mouse.GLinitPos.x);
- v->Selection.H = ABS(v->mouse.GLfinalPos.y - v->mouse.GLinitPos.y);
- if (v->Selection.H < 0)
- v->Selection.H = v->Selection.H * -1;
- if (v->mouse.mouse_mode == 4)
- v->Selection.Type = 1;
- else
- v->Selection.Type = 2;
- v->Selection.Active = 1;
- }
-
-
-
+ rectangle_select(v);
}
void appmouse_right_drag(ViewInfo* v,int x,int y)
{
appmouse_drag(v,x,y);
}
+
+
+
extern void appmouse_right_click_down(ViewInfo* v,int x,int y);
extern void appmouse_right_click_up(ViewInfo* v,int x,int y);
extern void appmouse_right_drag(ViewInfo* v,int x,int y);
+extern int get_mode(ViewInfo* v);
#endif
/* static glCompPanel *controlPanel; */
/* static glCompButton *rotatebutton; */
static glCompPanel *sel = NULL;
+static glCompLabel *selLabel=NULL;
static glCompButton *to3DBtn;
static glCompButton *to2DBtn;
static glCompButton *rotateBtn;
static void menu_click_pan(void *obj, GLfloat x, GLfloat y,
glMouseButtonType t)
{
- switch_Mouse(NULL, MM_PAN);
}
}
#endif
-static void menu_click_fisheye_magnifier(void *obj, GLfloat x, GLfloat y,
- glMouseButtonType t)
-{
- view->mouse.mouse_mode = MM_FISHEYE_MAGNIFIER;
-}
static void menu_click_zoom_minus(void *obj, GLfloat x, GLfloat y,
glMouseButtonType t)
}
}
-static void menu_click_rotate(void *obj, GLfloat x, GLfloat y,
- glMouseButtonType t)
-{
- switch_Mouse(NULL, MM_ROTATE);
- view->mouse.mouse_mode = MM_ROTATE;
-}
static void menu_click_center(void *obj, GLfloat x, GLfloat y,
}
glCompButtonShow(to2DBtn);
glCompButtonHide(to3DBtn);
- glCompButtonShow(rotateBtn);
img3D->common.visible = 1;
} else { /*switch to 2d */
view->active_camera = -1; /*set to camera */
glCompButtonShow(to3DBtn);
glCompButtonHide(to2DBtn);
- glCompButtonHide(rotateBtn);
panBtn->common.callbacks.click(panBtn, (GLfloat) 0,
(GLfloat) 0,
(glMouseButtonType) 0);
b->groupid = 1;
y = y + off;
- b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
- glCompButtonAddPngGlyph(b, smyrnaPath("magnifier.png"));
- b->common.callbacks.click = menu_click_fisheye_magnifier;
- b->groupid = 1;
y = y + off;
- b = glCompButtonNew((glCompObj *) p, 1, y, 42, 42, "");
- glCompButtonAddPngGlyph(b, smyrnaPath("rotate.png"));
- b->groupid = 1;
- b->common.callbacks.click = menu_click_rotate;
- glCompButtonHide(b);
- rotateBtn = b;
p = glCompPanelNew((glCompObj *) p, 1, 25, 80, 255);
p->common.color.A = 0.2;
p->common.visible = 0;
sel = p;
-
s->common.callbacks.mouseover = glCompMouseMove;
s->common.callbacks.mouseup = CBglCompMouseUp;
}
-void mMenuPan(GtkWidget * widget, gpointer user_data)
-{
- view->mouse.mouse_mode = MM_PAN;
-
-}
-
-void mMenuZoom(GtkWidget * widget, gpointer user_data)
-{
- view->mouse.mouse_mode = MM_ZOOM;
-
-}
void mShowConsoleSlot(GtkWidget * widget, gpointer user_data)
{
// deselect_all_graphs(view->g[view->activeGraph]);
}
-void mSingleSelectSlot(GtkWidget * widget, gpointer user_data)
-{
- view->mouse.mouse_mode = MM_SINGLE_SELECT;
-}
-
-void mSelectAreaSlot(GtkWidget * widget, gpointer user_data)
-{
- view->mouse.mouse_mode = MM_RECTANGULAR_SELECT;
-}
-
-void mSelectAreaXSlot(GtkWidget * widget, gpointer user_data)
-{
- view->mouse.mouse_mode = MM_RECTANGULAR_X_SELECT;
-}
//help
void mAbout(GtkWidget * widget, gpointer user_data)
{
deselect_all(view->g[view->activeGraph]);
//gtk_toggle_tool_button_set_active ((GtkToggleToolButton*)widget,1);
- switch_Mouse(NULL, 3);
}
void btnToolRectSelect_clicked(GtkWidget * widget, gpointer user_data)
{
deselect_all(view->g[view->activeGraph]);
- view->Selection.Anti = 0;
- switch_Mouse(NULL, 4);
}
void btnToolRectXSelect_clicked(GtkWidget * widget, gpointer user_data)
{
deselect_all(view->g[view->activeGraph]);
view->Selection.Anti = 0;
- switch_Mouse(NULL, 5);
}
void btnToolAntiRectSelect_clicked(GtkWidget * widget, gpointer user_data)
{
view->Selection.Anti = 1;
- switch_Mouse(NULL, 4);
}
void btnToolAntiRectXSelect_clicked(GtkWidget * widget, gpointer user_data)
{
view->Selection.Anti = 1;
- switch_Mouse(NULL, 5);
}
{
- switch_Mouse(NULL, 0);
}
void btnToolZoom_clicked(GtkWidget * widget, gpointer user_data)
{
- switch_Mouse(NULL, 1);
}
void btnToolZoomIn_clicked(GtkWidget * widget, gpointer user_data)
void btnToolMove_clicked(GtkWidget * widget, gpointer user_data)
{
- switch_Mouse(NULL, 10);
}
void btnToolAddNode_clicked(GtkWidget * widget, gpointer user_data)
}
void btnToolCursor_clicked(GtkWidget * widget, gpointer user_data)
{
- switch_Mouse(NULL, -1);
}
void write_to_console(char *text)
{
float x, y, m, iter;
float RX, RY, RW, RH;
int intersects, in;
- if (view->mouse.mouse_mode == MM_SINGLE_SELECT) {
- RW = 10;
- RH = 10;
- }
-
RX = view->Selection.X;
RY = view->Selection.Y;
if ((is_point_in_rectangle(X1, Y1, RX, RY, RW, RH))
}
+
+static int select_topview_node(topview_node * n)
+{
+ static float x1,y1,x2,y2,x,y;
+ static int sel_type=0; /*0:select all , 1:only nodes 2:only edges*/
+ x=n->distorted_x;
+ y=n->distorted_y;
+ if(view->mouse.GLfinalPos.x > view->mouse.GLinitPos.x)
+ {
+ x1=view->mouse.GLinitPos.x;
+ x2=view->mouse.GLfinalPos.x;
+ }
+ else
+ {
+ x2=view->mouse.GLinitPos.x;
+ x1=view->mouse.GLfinalPos.x;
+
+ }
+ if(view->mouse.GLfinalPos.y > view->mouse.GLinitPos.y)
+ {
+ y1=view->mouse.GLinitPos.y;
+ y2=view->mouse.GLfinalPos.y;
+ }
+ else
+ {
+ y2=view->mouse.GLinitPos.y;
+ y1=view->mouse.GLfinalPos.y;
+ }
+ if(is_point_in_rectangle(x,y,x1,y1,x2-x1,y2-y1))
+ {
+ agset(n->Node,"selected","1");
+ n->data.Selected=1;
+ }
+}
+
+static int select_topview_edge(topview_edge* e)
+{
+ static float x1,y1,x2,y2,n1x,n1y,n2x,n2y;
+ static int sel_type=0; /*0:select all , 1:only nodes 2:only edges*/
+ n1x=e->Node1->distorted_x;
+ n1y=e->Node1->distorted_y;
+ n2x=e->Node2->distorted_x;
+ n2y=e->Node2->distorted_y;
+ if(view->mouse.GLfinalPos.x > view->mouse.GLinitPos.x)
+ {
+ x1=view->mouse.GLinitPos.x;
+ x2=view->mouse.GLfinalPos.x;
+ }
+ else
+ {
+ x2=view->mouse.GLinitPos.x;
+ x1=view->mouse.GLfinalPos.x;
+
+ }
+ if(view->mouse.GLfinalPos.y > view->mouse.GLinitPos.y)
+ {
+ y1=view->mouse.GLinitPos.y;
+ y2=view->mouse.GLfinalPos.y;
+ }
+ else
+ {
+ y2=view->mouse.GLinitPos.y;
+ y1=view->mouse.GLfinalPos.y;
+ }
+ if((is_point_in_rectangle(n1x,n1y,x1,y1,x2-x1,y2-y1))
+ &&
+ (is_point_in_rectangle(n2x,n2y,x1,y1,x2-x1,y2-y1)) )
+ {
+ agset(e->Edge,"selected","1");
+ e->data.Selected=1;
+ }
+}
+
+static void node_rectangle_select(ViewInfo* v)
+{
+ int ind;
+ topview_node* n;
+
+ for (ind = 0; ind < v->Topview->Nodecount; ind++)
+ {
+ n = v->Topview->Nodes + ind;
+ select_topview_node(n);
+ }
+
+}
+static void edge_rectangle_select(ViewInfo* v)
+{
+ int ind;
+ topview_edge* e;
+
+ for (ind = 0; ind < v->Topview->Edgecount; ind++)
+ {
+ e = v->Topview->Edges + ind;
+ select_topview_edge(e);
+ }
+
+}
+void rectangle_select(ViewInfo* v)
+{
+ node_rectangle_select(v);
+ edge_rectangle_select(v);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#ifdef UNUSED
static int line_intersects(float *x, float *y, float *X, float *Y)
{
float distance_to_line(float ax, float ay, float bx, float by,
float cx, float cy);
+ extern void rectangle_select(ViewInfo* v);
+
#ifdef __cplusplus
} /* end extern "C" */
#endif
RelativePath=".\glexpose.h"
>
</File>
- <File
- RelativePath=".\gui\glmenu.h"
- >
- </File>
<File
RelativePath=".\glmotion.h"
>
RelativePath=".\glexpose.c"
>
</File>
- <File
- RelativePath=".\gui\glmenu.c"
- >
- </File>
<File
RelativePath=".\glmotion.c"
>
#define MM_MOVE 10
#define MM_MAGNIFIER 20
#define MM_FISHEYE_MAGNIFIER 21
+
+#define B_LSHIFT 65505
+#define B_RSHIFT 65506
+#define B_LCTRL 65507
+#define B_RCTRL 65508
+
+
#define GLOBAL_Z_OFFSET 0.001
#define MAX_ZOOM 500
typedef enum {attr_alpha,attr_float,attr_int,attr_bool,attr_drowdown,attr_color} attr_data_type;
+
+typedef struct{
+ int keyVal;
+ int down;
+}keymap_t;
+
+
+
typedef struct {
int index;
char* name;
int script_count; /*# of scripts */
GtkComboBox *graphComboBox; /*pointer to graph combo box at top right */
ArcBall_t *arcball;
+ keymap_t keymap;
} ViewInfo;
/*rotation steps*/
continue;
/*check for each node if it needs to be selected or picked */
- select_topview_node(v);
//UPDATE view->Topview data from cgraph
/* if (v->update_required) */
/* update_topview_node_from_cgraph(v); */
-static int select_topview_node(topview_node * n)
-{
- if (!view->Selection.Active) {
- //implement hint box here
-/* if (view->mouse.button== rightmousebutton)
- {
- if (pick_node(n))
- view->mouse.button = -1;
- }
- return 0;*/
- }
- if (((view->Selection.Type == 0) && (view->Selection.Active))
- || (view->mouse.t == rightmousebutton)) //single selection or right click (picking)
- {
- float dist =
- (float) DIST2(view->Selection.X - n->distorted_x,
- view->Selection.Y - n->distorted_y);
-
- if ((view->Selection.node_distance == -1)
- || (dist < view->Selection.node_distance)) {
- view->Selection.node_distance = dist;
- view->Selection.single_selected_node = n;
- }
-
- return 0;
-
-/* if (OD_Selected(n->Node) == 0)
- {
- OD_Selected(n->Node) = 1;
- select_object(view->g[view->activeGraph], n->Node);
- } else {
- OD_Selected(n->Node) = 1;
- deselect_object(view->g[view->activeGraph], n->Node);
- }
- break;*/
-
- }
- if (view->Selection.Active == 0)
- return 0;
- if (is_point_in_rectangle
- (n->x, n->y, view->Selection.X, view->Selection.Y,
- view->Selection.W, view->Selection.H)) {
-
- switch (view->Selection.Type) {
-
-/*
- int Active; //0 there is no selection need to be applied
- char Type; //0 single selection , 1 rectangle , 2 rectangleX
- float X, Y, W, H; //selection boundries
- int Anti; //subtract selections if 1
- int AlreadySelected; //for single selections to avoid selecting more than one object
- glCompColor SelectionColor;
-*/
-
-
- case 1:
- case 2:
- if (view->Selection.Anti == 0) {
- select_node(n);
- view->Selection.AlreadySelected = 1;
- } else {
-
- deselect_node(n);
- view->Selection.AlreadySelected = 1;
- }
- break;
-
- }
- }
- return 1;
-}
#ifdef UNUSED
static void set_topview_options(void)
{
- if ((view->mouse.mouse_mode == 10) && (view->mouse.down == 1)) //selected, if there is move move it, experimental
+ int a=get_mode(view);
+ if ((a == 10) && (view->mouse.down == 1)) //selected, if there is move move it, experimental
{
dx = view->mouse.GLinitPos.x - view->mouse.GLfinalPos.x;
dy = view->mouse.GLinitPos.y - view->mouse.GLfinalPos.y;
view->selectedEdgeColor.B, view->selectedEdgeColor.A);
return return_value;
}
- /*if both head and tail nodes are highlighted use edge highlight color */
- if ((e->Node1->data.Highlighted)
- && (e->Node2->data.Highlighted)) {
- glColor4f(view->highlightedEdgeColor.R,
- view->highlightedEdgeColor.G,
- view->highlightedEdgeColor.B,
- view->highlightedEdgeColor.A);
- return return_value;
- }
/*edge maybe in a group and group may be selected, then use groups's color example:ATT hosts */
if ((e->Node1->GroupIndex >= 0) || (e->Node2->GroupIndex >= 0)) {
if (view->Topview->TopviewData->hostactive[e->Node1->GroupIndex] ==
int move_TVnodes(void)
{
+ float delX,delY;
topview_node *v;
+ static flag=0;
int ind = 0;
+ if (!flag)
+ {
+// printf ("dragx:%f dragy:%f\n",view->mouse.dragX,view->mouse.dragY);
+ flag=1;
+ return;
+ }
+
+ delX = GetOGLDistance((int) view->mouse.dragX);
+ delY = GetOGLDistance((int) view->mouse.dragY);
for (ind = 0; ind < view->Topview->Nodecount; ind++) {
v = &view->Topview->Nodes[ind];
if (v->data.Selected) {
- v->distorted_x = v->distorted_x - dx;
- v->distorted_y = v->distorted_y - dy;
+ v->distorted_x = v->distorted_x + delX;
+ v->distorted_y = v->distorted_y - delY;
}
}
return 1;
view->gridVisible = 0; //show grids in light gray
//mouse mode=pan
- view->mouse.mouse_mode = 0;
//pen color
view->penColor.R = 0;
view->penColor.G = 0;
view->colschms = NULL;
view->flush = 1;
view->arcball = NEW(ArcBall_t);
+ view->keymap.down=0;
/*add default camera */
//create fontset
}
glCompCallBacks callbacks;
glCompCallBacks functions;
int down;
- int mouse_mode; /*some data value to store custom defined mouse modes*/
} glCompMouse;