LEFT | RIGHT |
1 /* | 1 /* |
2 * ***** BEGIN GPL LICENSE BLOCK ***** | 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or | 4 * This program is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU General Public License | 5 * modify it under the terms of the GNU General Public License |
6 * as published by the Free Software Foundation; either version 2 | 6 * as published by the Free Software Foundation; either version 2 |
7 * of the License, or (at your option) any later version.· | 7 * of the License, or (at your option) any later version.· |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 3575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3586 break; | 3586 break; |
3587 case PROP_ANGLE: | 3587 case PROP_ANGLE: |
3588 r1 = r2 = tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE; | 3588 r1 = r2 = tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE; |
3589 alpha = 0.75; | 3589 alpha = 0.75; |
3590 break; | 3590 break; |
3591 default: | 3591 default: |
3592 tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE; /* note, th
is is a dummy value */ | 3592 tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE; /* note, th
is is a dummy value */ |
3593 alpha = 0.75; | 3593 alpha = 0.75; |
3594 break; | 3594 break; |
3595 } | 3595 } |
3596 | |
3597 /* adjust for DPI, like BKE_brush_size_get */ | |
3598 r1 *= U.pixelsize; | |
3599 r2 *= U.pixelsize; | |
3600 tex_radius *= U.pixelsize; | |
3601 | |
3602 /* Keep cursor in the original place */ | |
3603 x = rc->initial_mouse[0] - ar->winrct.xmin; | |
3604 y = rc->initial_mouse[1] - ar->winrct.ymin; | |
3605 glTranslatef((float)x, (float)y, 0.0f); | |
3606 | |
3607 glEnable(GL_BLEND); | |
3608 glEnable(GL_LINE_SMOOTH); | |
3609 | |
3610 /* apply zoom if available */ | |
3611 if (rc->zoom_prop) { | |
3612 RNA_property_float_get_array(&rc->zoom_ptr, rc->zoom_prop, zoom)
; | |
3613 glScalef(zoom[0], zoom[1], 1); | |
3614 } | |
3615 | |
3616 /* draw rotated texture */ | |
3617 radial_control_paint_tex(rc, tex_radius, alpha); | |
3618 | |
3619 /* set line color */ | |
3620 if (rc->col_prop) | |
3621 RNA_property_float_get_array(&rc->col_ptr, rc->col_prop, col); | |
3622 glColor4f(col[0], col[1], col[2], 0.5); | |
3623 | |
3624 if (rc->subtype == PROP_ANGLE) { | |
3625 glPushMatrix(); | |
3626 /* draw original angle line */ | |
3627 glRotatef(RAD2DEGF(rc->initial_value), 0, 0, 1); | |
3628 fdrawline(0.0f, 0.0f, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0
f); | |
3629 /* draw new angle line */ | |
3630 glRotatef(RAD2DEGF(rc->current_value - rc->initial_value), 0, 0,
1); | |
3631 fdrawline(0.0f, 0.0f, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0
f); | |
3632 glPopMatrix(); | |
3633 } | |
3634 | |
3635 /* draw circles on top */ | |
3636 glutil_draw_lined_arc(0.0, (float)(M_PI * 2.0), r1, 40); | |
3637 glutil_draw_lined_arc(0.0, (float)(M_PI * 2.0), r2, 40); | |
3638 | |
3639 glDisable(GL_BLEND); | |
3640 glDisable(GL_LINE_SMOOTH); | |
3641 } | |
3642 | |
3643 typedef enum { | |
3644 RC_PROP_ALLOW_MISSING = 1, | |
3645 RC_PROP_REQUIRE_FLOAT = 2, | |
3646 RC_PROP_REQUIRE_BOOL = 4, | |
3647 } RCPropFlags; | |
3648 | |
3649 /* attempt to retrieve the rna pointer/property from an rna path; | |
3650 * returns 0 for failure, 1 for success, and also 1 if property is not | |
3651 * set */ | |
3652 static int radial_control_get_path(PointerRNA *ctx_ptr, wmOperator *op, | |
3653 const char *name, PointerRNA *r_ptr, | |
3654 PropertyRNA **r_prop, int req_length, RCPropF
lags flags) | |
3655 { | |
3656 PropertyRNA *unused_prop; | |
3657 int len; | |
3658 char *str; | |
3659 | |
3660 /* check flags */ | |
3661 if ((flags & RC_PROP_REQUIRE_BOOL) && (flags & RC_PROP_REQUIRE_FLOAT)) { | |
3662 BKE_report(op->reports, RPT_ERROR, "Property cannot be both bool
ean and float"); | |
3663 return 0; | |
3664 } | |
3665 | |
3666 /* get an rna string path from the operator's properties */ | |
3667 if (!(str = RNA_string_get_alloc(op->ptr, name, NULL, 0))) | |
3668 return 1; | |
3669 | |
3670 if (str[0] == '\0') { | |
3671 if (r_prop) *r_prop = NULL; | |
3672 MEM_freeN(str); | |
3673 return 1; | |
3674 } | |
3675 | |
3676 if (!r_prop) | |
3677 r_prop = &unused_prop; | |
3678 | |
3679 /* get rna from path */ | |
3680 if (!RNA_path_resolve(ctx_ptr, str, r_ptr, r_prop)) { | |
3681 /* assign map to operators */ | 3596 /* assign map to operators */ |
3682 WM_modalkeymap_assign(keymap, "VIEW3D_OT_select_circle"); | 3597 WM_modalkeymap_assign(keymap, "VIEW3D_OT_select_circle"); |
3683 WM_modalkeymap_assign(keymap, "UV_OT_circle_select"); | 3598 WM_modalkeymap_assign(keymap, "UV_OT_circle_select"); |
3684 | 3599 |
3685 } | 3600 } |
3686 | 3601 |
LEFT | RIGHT |