| 1 |
/************************************************************************* |
| 2 |
* Copyright (c) 2011 AT&T Intellectual Property |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* https://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: Details at https://graphviz.org |
| 9 |
*************************************************************************/ |
| 10 |
|
| 11 |
#include "config.h" |
| 12 |
|
| 13 |
#include "appmouse.h" |
| 14 |
#include "topfisheyeview.h" |
| 15 |
#include "arcball.h" |
| 16 |
#include "glmotion.h" |
| 17 |
#include "hotkeymap.h" |
| 18 |
|
| 19 |
#include "selectionfuncs.h" |
| 20 |
#include <stdbool.h> |
| 21 |
#include <stdint.h> |
| 22 |
#include <util/list.h> |
| 23 |
#include "topviewfuncs.h" |
| 24 |
|
| 25 |
static int lastAction; |
| 26 |
|
| 27 |
static void apply_actions(ViewInfo* v,int x,int y) |
| 28 |
{ |
| 29 |
int a; |
| 30 |
gdouble seconds; |
| 31 |
a=get_mode(v); |
| 32 |
if (a == MM_PAN && view->guiMode == GUI_FULLSCREEN && |
| 33 |
v->active_camera != SIZE_MAX) |
| 34 |
a=MM_ROTATE; |
| 35 |
switch (a) { |
| 36 |
case MM_ROTATE : |
| 37 |
seconds = g_timer_elapsed(view->timer3, NULL); |
| 38 |
if (seconds > 0.1) { |
| 39 |
g_timer_stop(view->timer3); |
| 40 |
view->arcball->MousePt.X = (float)x; |
| 41 |
view->arcball->MousePt.Y = (float)y; |
| 42 |
if (!view->arcball->isDragging) { |
| 43 |
arcmouseClick(); |
| 44 |
view->arcball->isDragging = 1; |
| 45 |
} |
| 46 |
else |
| 47 |
arcmouseDrag(); |
| 48 |
g_timer_start(view->timer3); |
| 49 |
} |
| 50 |
return; |
| 51 |
case MM_PAN : |
| 52 |
glmotion_pan(v); |
| 53 |
break; |
| 54 |
case MM_MOVE : |
| 55 |
break; |
| 56 |
case MM_RECTANGULAR_SELECT : |
| 57 |
if (!view->mouse.down) { |
| 58 |
pick_objects_rect(view->g[view->activeGraph]) ; |
| 59 |
} |
| 60 |
break; |
| 61 |
case MM_POLYGON_SELECT : |
| 62 |
add_selpoly(view->g[view->activeGraph],&view->Topview->sel.selPoly,view->mouse.GLfinalPos); |
| 63 |
break; |
| 64 |
case MM_SINGLE_SELECT : |
| 65 |
pick_object_xyz(view->g[view->activeGraph],view->Topview,view->mouse.GLfinalPos.x,view->mouse.GLfinalPos.y,view->mouse.GLfinalPos.z); |
| 66 |
break; |
| 67 |
case MM_FISHEYE_PICK : |
| 68 |
if (view->activeGraph >= 0) { |
| 69 |
if (view->Topview->fisheyeParams.active) |
| 70 |
changetopfishfocus(view->Topview, &view->mouse.GLpos.x, &view->mouse.GLpos.y, 1); |
| 71 |
|
| 72 |
} |
| 73 |
break; |
| 74 |
} |
| 75 |
lastAction=a; |
| 76 |
} |
| 77 |
|
| 78 |
static void appmouse_down(ViewInfo* v,int x,int y) |
| 79 |
{ |
| 80 |
view->mouse.dragX = 0; |
| 81 |
view->mouse.dragY = 0; |
| 82 |
v->mouse.down = true; |
| 83 |
v->mouse.x = x; |
| 84 |
v->mouse.y = y; |
| 85 |
|
| 86 |
to3D(x,y,&v->mouse.GLinitPos.x,&v->mouse.GLinitPos.y,&v->mouse.GLinitPos.z); |
| 87 |
to3D( x,y, &v->mouse.GLpos.x,&v->mouse.GLpos.y,&v->mouse.GLpos.z); |
| 88 |
} |
| 89 |
|
| 90 |
void appmouse_up(ViewInfo *v, int x, int y) { |
| 91 |
v->mouse.down = false; |
| 92 |
to3D(x,y, &v->mouse.GLfinalPos.x,&v->mouse.GLfinalPos.y,&v->mouse.GLfinalPos.z); |
| 93 |
apply_actions(v,x,y); |
| 94 |
view->mouse.dragX = 0; |
| 95 |
view->mouse.dragY = 0; |
| 96 |
view->arcball->isDragging=0; |
| 97 |
|
| 98 |
|
| 99 |
} |
| 100 |
|
| 101 |
void appmouse_drag(ViewInfo *v, int x, int y) { |
| 102 |
v->mouse.x = x; |
| 103 |
v->mouse.y = y; |
| 104 |
to3D( x,y, &v->mouse.GLpos.x,&v->mouse.GLpos.y,&v->mouse.GLpos.z); |
| 105 |
apply_actions(v,x,y); |
| 106 |
} |
| 107 |
|
| 108 |
void appmouse_left_click_down(ViewInfo* v,int x,int y) |
| 109 |
{ |
| 110 |
v->mouse.t=glMouseLeftButton; |
| 111 |
appmouse_down(v,x,y); |
| 112 |
|
| 113 |
|
| 114 |
} |
| 115 |
|
| 116 |
void appmouse_right_click_down(ViewInfo* v,int x,int y) |
| 117 |
{ |
| 118 |
v->mouse.t=glMouseRightButton; |
| 119 |
appmouse_down(v,x,y); |
| 120 |
|
| 121 |
|
| 122 |
} |
| 123 |
|
| 124 |
void appmouse_middle_click_down(ViewInfo* v,int x,int y) |
| 125 |
{ |
| 126 |
v->mouse.t=glMouseMiddleButton; |
| 127 |
appmouse_down(v,x,y); |
| 128 |
|
| 129 |
|
| 130 |
} |
| 131 |
|
| 132 |
void appmouse_move(ViewInfo* v,int x,int y) |
| 133 |
{ |
| 134 |
to3D( x,y, &v->mouse.GLpos.x,&v->mouse.GLpos.y,&v->mouse.GLpos.z); |
| 135 |
} |
| 136 |
void appmouse_key_release(ViewInfo* v) |
| 137 |
{ |
| 138 |
if(lastAction==MM_POLYGON_SELECT) |
| 139 |
{ |
| 140 |
LIST_FREE(&view->Topview->sel.selPoly); |
| 141 |
glexpose(); |
| 142 |
} |
| 143 |
v->keyVal = 0; |
| 144 |
} |
| 145 |
void appmouse_key_press(ViewInfo* v,int key) |
| 146 |
{ |
| 147 |
v->keyVal = key; |
| 148 |
} |
| 149 |
|
| 150 |
|