2013-04-01 10:18:01 +00:00
|
|
|
/*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* Contributor(s): Campbell Barton
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file blender/editors/mesh/editmesh_inset.c
|
|
|
|
* \ingroup edmesh
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
|
|
|
#include "BLI_string.h"
|
|
|
|
#include "BLI_math.h"
|
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2013-04-01 10:18:01 +00:00
|
|
|
|
|
|
|
#include "BKE_context.h"
|
2013-04-02 10:48:11 +00:00
|
|
|
#include "BKE_global.h"
|
2013-04-13 20:31:52 +00:00
|
|
|
#include "BKE_editmesh.h"
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
#include "BKE_unit.h"
|
2018-05-12 10:45:51 +02:00
|
|
|
#include "BKE_layer.h"
|
2013-04-01 10:18:01 +00:00
|
|
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
2016-05-14 10:00:52 +02:00
|
|
|
#include "UI_interface.h"
|
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
#include "ED_mesh.h"
|
|
|
|
#include "ED_numinput.h"
|
|
|
|
#include "ED_screen.h"
|
2013-04-02 10:48:11 +00:00
|
|
|
#include "ED_space_api.h"
|
2013-04-01 10:18:01 +00:00
|
|
|
#include "ED_transform.h"
|
|
|
|
#include "ED_view3d.h"
|
|
|
|
|
|
|
|
#include "mesh_intern.h" /* own include */
|
|
|
|
|
2018-05-12 10:45:51 +02:00
|
|
|
typedef struct {
|
|
|
|
BMEditMesh *em;
|
|
|
|
BMBackup mesh_backup;
|
|
|
|
} InsetObjectStore;
|
2013-04-01 10:18:01 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
float old_thickness;
|
|
|
|
float old_depth;
|
2013-04-02 10:48:11 +00:00
|
|
|
bool modify_depth;
|
2013-04-01 10:18:01 +00:00
|
|
|
float initial_length;
|
|
|
|
float pixel_size; /* use when mouse input is interpreted as spatial distance */
|
2013-04-02 10:48:11 +00:00
|
|
|
bool is_modal;
|
|
|
|
bool shift;
|
2013-04-01 10:18:01 +00:00
|
|
|
float shift_amount;
|
|
|
|
NumInput num_input;
|
2013-04-02 10:48:11 +00:00
|
|
|
|
2018-05-12 10:45:51 +02:00
|
|
|
InsetObjectStore *ob_store;
|
|
|
|
uint ob_store_len;
|
|
|
|
|
2013-04-02 10:48:11 +00:00
|
|
|
/* modal only */
|
2013-10-12 03:42:06 +00:00
|
|
|
float mcenter[2];
|
2013-04-02 10:48:11 +00:00
|
|
|
void *draw_handle_pixel;
|
2018-07-15 14:24:10 +02:00
|
|
|
short gizmo_flag;
|
2013-04-01 10:18:01 +00:00
|
|
|
} InsetData;
|
|
|
|
|
|
|
|
|
|
|
|
static void edbm_inset_update_header(wmOperator *op, bContext *C)
|
|
|
|
{
|
|
|
|
InsetData *opdata = op->customdata;
|
|
|
|
|
2017-12-06 16:42:34 +11:00
|
|
|
const char *str = IFACE_(
|
|
|
|
"Confirm: Enter/LClick, Cancel: (Esc/RClick), Thickness: %s, "
|
|
|
|
"Depth (Ctrl to tweak): %s (%s), Outset (O): (%s), Boundary (B): (%s), Individual (I): (%s)"
|
|
|
|
);
|
2013-04-01 10:18:01 +00:00
|
|
|
|
2016-05-14 10:00:52 +02:00
|
|
|
char msg[UI_MAX_DRAW_STR];
|
2013-04-01 10:18:01 +00:00
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
2014-06-30 10:57:39 +02:00
|
|
|
Scene *sce = CTX_data_scene(C);
|
2013-04-01 10:18:01 +00:00
|
|
|
|
|
|
|
if (sa) {
|
|
|
|
char flts_str[NUM_STR_REP_LEN * 2];
|
|
|
|
if (hasNumInput(&opdata->num_input))
|
2014-08-26 12:04:24 +02:00
|
|
|
outputNumInput(&opdata->num_input, flts_str, &sce->unit);
|
2013-04-01 10:18:01 +00:00
|
|
|
else {
|
|
|
|
BLI_snprintf(flts_str, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "thickness"));
|
|
|
|
BLI_snprintf(flts_str + NUM_STR_REP_LEN, NUM_STR_REP_LEN, "%f", RNA_float_get(op->ptr, "depth"));
|
|
|
|
}
|
2016-05-14 10:00:52 +02:00
|
|
|
BLI_snprintf(msg, sizeof(msg), str,
|
2013-04-01 10:18:01 +00:00
|
|
|
flts_str,
|
|
|
|
flts_str + NUM_STR_REP_LEN,
|
2013-10-13 00:32:31 +00:00
|
|
|
WM_bool_as_string(opdata->modify_depth),
|
|
|
|
WM_bool_as_string(RNA_boolean_get(op->ptr, "use_outset")),
|
|
|
|
WM_bool_as_string(RNA_boolean_get(op->ptr, "use_boundary")),
|
|
|
|
WM_bool_as_string(RNA_boolean_get(op->ptr, "use_individual"))
|
2013-04-01 10:18:01 +00:00
|
|
|
);
|
|
|
|
|
2018-06-28 12:06:00 +02:00
|
|
|
ED_area_status_text(sa, msg);
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-08 10:03:51 +00:00
|
|
|
static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal)
|
2013-04-01 10:18:01 +00:00
|
|
|
{
|
|
|
|
InsetData *opdata;
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2018-05-12 10:45:51 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2013-04-08 02:14:58 +00:00
|
|
|
|
2018-03-07 22:19:56 +01:00
|
|
|
if (is_modal) {
|
|
|
|
RNA_float_set(op->ptr, "thickness", 0.01f);
|
|
|
|
RNA_float_set(op->ptr, "depth", 0.0f);
|
|
|
|
}
|
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
op->customdata = opdata = MEM_mallocN(sizeof(InsetData), "inset_operator_data");
|
|
|
|
|
2018-05-12 10:45:51 +02:00
|
|
|
uint objects_used_len = 0;
|
|
|
|
|
|
|
|
{
|
|
|
|
uint ob_store_len = 0;
|
|
|
|
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(view_layer, &ob_store_len);
|
|
|
|
opdata->ob_store = MEM_malloc_arrayN(ob_store_len, sizeof(*opdata->ob_store), __func__);
|
|
|
|
for (uint ob_index = 0; ob_index < ob_store_len; ob_index++) {
|
|
|
|
Object *obedit = objects[ob_index];
|
|
|
|
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
|
|
|
if (em->bm->totvertsel > 0) {
|
|
|
|
opdata->ob_store[objects_used_len].em = em;
|
|
|
|
objects_used_len++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MEM_freeN(objects);
|
|
|
|
opdata->ob_store_len = objects_used_len;
|
|
|
|
}
|
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
opdata->old_thickness = 0.01;
|
|
|
|
opdata->old_depth = 0.0;
|
|
|
|
opdata->modify_depth = false;
|
|
|
|
opdata->shift = false;
|
|
|
|
opdata->shift_amount = 0.0f;
|
|
|
|
opdata->is_modal = is_modal;
|
|
|
|
|
|
|
|
initNumInput(&opdata->num_input);
|
|
|
|
opdata->num_input.idx_max = 1; /* Two elements. */
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
opdata->num_input.unit_sys = scene->unit.system;
|
|
|
|
opdata->num_input.unit_type[0] = B_UNIT_LENGTH;
|
|
|
|
opdata->num_input.unit_type[1] = B_UNIT_LENGTH;
|
2013-04-01 10:18:01 +00:00
|
|
|
|
2013-04-02 10:48:11 +00:00
|
|
|
if (is_modal) {
|
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
ARegion *ar = CTX_wm_region(C);
|
|
|
|
|
2018-05-12 10:45:51 +02:00
|
|
|
for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) {
|
|
|
|
opdata->ob_store[ob_index].mesh_backup = EDBM_redo_state_store(opdata->ob_store[ob_index].em);
|
|
|
|
}
|
|
|
|
|
2017-12-06 16:42:34 +11:00
|
|
|
opdata->draw_handle_pixel = ED_region_draw_cb_activate(
|
|
|
|
ar->type, ED_region_draw_mouse_line_cb, opdata->mcenter, REGION_DRAW_POST_PIXEL);
|
2013-06-24 22:41:37 +00:00
|
|
|
G.moving = G_TRANSFORM_EDIT;
|
2016-04-29 00:00:43 +10:00
|
|
|
if (v3d) {
|
2018-07-15 14:24:10 +02:00
|
|
|
opdata->gizmo_flag = v3d->gizmo_flag;
|
|
|
|
v3d->gizmo_flag = V3D_GIZMO_HIDE;
|
2016-04-29 00:00:43 +10:00
|
|
|
}
|
2013-04-02 10:48:11 +00:00
|
|
|
}
|
2013-04-01 10:18:01 +00:00
|
|
|
|
2013-04-08 10:03:51 +00:00
|
|
|
return true;
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void edbm_inset_exit(bContext *C, wmOperator *op)
|
|
|
|
{
|
|
|
|
InsetData *opdata;
|
|
|
|
ScrArea *sa = CTX_wm_area(C);
|
|
|
|
|
|
|
|
opdata = op->customdata;
|
|
|
|
|
2013-04-02 10:48:11 +00:00
|
|
|
if (opdata->is_modal) {
|
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
|
|
|
ARegion *ar = CTX_wm_region(C);
|
2018-05-12 10:45:51 +02:00
|
|
|
for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) {
|
|
|
|
EDBM_redo_state_free(&opdata->ob_store[ob_index].mesh_backup, NULL, false);
|
|
|
|
}
|
2013-04-02 10:48:11 +00:00
|
|
|
ED_region_draw_cb_exit(ar->type, opdata->draw_handle_pixel);
|
2016-04-29 00:00:43 +10:00
|
|
|
if (v3d) {
|
2018-07-15 14:24:10 +02:00
|
|
|
v3d->gizmo_flag = opdata->gizmo_flag;
|
2016-04-29 00:00:43 +10:00
|
|
|
}
|
2013-06-24 22:41:37 +00:00
|
|
|
G.moving = 0;
|
2013-04-02 10:48:11 +00:00
|
|
|
}
|
2013-04-01 10:18:01 +00:00
|
|
|
|
|
|
|
if (sa) {
|
2018-06-28 12:06:00 +02:00
|
|
|
ED_area_status_text(sa, NULL);
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
2018-05-12 10:45:51 +02:00
|
|
|
|
|
|
|
MEM_SAFE_FREE(opdata->ob_store);
|
|
|
|
MEM_SAFE_FREE(op->customdata);
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
|
|
|
|
2013-10-30 23:08:53 +00:00
|
|
|
static void edbm_inset_cancel(bContext *C, wmOperator *op)
|
2013-04-01 10:18:01 +00:00
|
|
|
{
|
|
|
|
InsetData *opdata;
|
|
|
|
|
|
|
|
opdata = op->customdata;
|
|
|
|
if (opdata->is_modal) {
|
2018-05-12 10:45:51 +02:00
|
|
|
for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) {
|
|
|
|
EDBM_redo_state_free(&opdata->ob_store[ob_index].mesh_backup, opdata->ob_store[ob_index].em, true);
|
|
|
|
EDBM_update_generic(opdata->ob_store[ob_index].em, false, true);
|
|
|
|
}
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
edbm_inset_exit(C, op);
|
|
|
|
|
|
|
|
/* need to force redisplay or we may still view the modified result */
|
|
|
|
ED_region_tag_redraw(CTX_wm_region(C));
|
|
|
|
}
|
|
|
|
|
2013-04-08 10:03:51 +00:00
|
|
|
static bool edbm_inset_calc(wmOperator *op)
|
2013-04-01 10:18:01 +00:00
|
|
|
{
|
|
|
|
InsetData *opdata;
|
|
|
|
BMEditMesh *em;
|
|
|
|
BMOperator bmop;
|
2018-05-12 10:45:51 +02:00
|
|
|
bool changed = false;
|
2013-04-01 10:18:01 +00:00
|
|
|
|
|
|
|
const bool use_boundary = RNA_boolean_get(op->ptr, "use_boundary");
|
|
|
|
const bool use_even_offset = RNA_boolean_get(op->ptr, "use_even_offset");
|
|
|
|
const bool use_relative_offset = RNA_boolean_get(op->ptr, "use_relative_offset");
|
2014-02-15 13:51:54 +11:00
|
|
|
const bool use_edge_rail = RNA_boolean_get(op->ptr, "use_edge_rail");
|
2013-04-01 10:18:01 +00:00
|
|
|
const float thickness = RNA_float_get(op->ptr, "thickness");
|
|
|
|
const float depth = RNA_float_get(op->ptr, "depth");
|
|
|
|
const bool use_outset = RNA_boolean_get(op->ptr, "use_outset");
|
|
|
|
const bool use_select_inset = RNA_boolean_get(op->ptr, "use_select_inset"); /* not passed onto the BMO */
|
2013-04-07 05:13:00 +00:00
|
|
|
const bool use_individual = RNA_boolean_get(op->ptr, "use_individual");
|
|
|
|
const bool use_interpolate = RNA_boolean_get(op->ptr, "use_interpolate");
|
2013-04-01 10:18:01 +00:00
|
|
|
|
|
|
|
opdata = op->customdata;
|
|
|
|
|
2018-05-12 10:45:51 +02:00
|
|
|
for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) {
|
|
|
|
em = opdata->ob_store[ob_index].em;
|
2013-04-01 10:18:01 +00:00
|
|
|
|
2018-05-12 10:45:51 +02:00
|
|
|
if (opdata->is_modal) {
|
|
|
|
EDBM_redo_state_restore(opdata->ob_store[ob_index].mesh_backup, em, false);
|
2014-09-10 16:02:24 +10:00
|
|
|
}
|
2013-04-01 10:18:01 +00:00
|
|
|
|
2018-05-12 10:45:51 +02:00
|
|
|
if (use_individual) {
|
|
|
|
EDBM_op_init(
|
|
|
|
em, &bmop, op,
|
|
|
|
"inset_individual faces=%hf use_even_offset=%b use_relative_offset=%b "
|
|
|
|
"use_interpolate=%b thickness=%f depth=%f",
|
|
|
|
BM_ELEM_SELECT, use_even_offset, use_relative_offset, use_interpolate,
|
|
|
|
thickness, depth);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
EDBM_op_init(
|
|
|
|
em, &bmop, op,
|
|
|
|
"inset_region faces=%hf use_boundary=%b use_even_offset=%b use_relative_offset=%b "
|
|
|
|
"use_interpolate=%b thickness=%f depth=%f use_outset=%b use_edge_rail=%b",
|
|
|
|
BM_ELEM_SELECT, use_boundary, use_even_offset, use_relative_offset, use_interpolate,
|
|
|
|
thickness, depth, use_outset, use_edge_rail);
|
|
|
|
|
|
|
|
if (use_outset) {
|
|
|
|
BMO_slot_buffer_from_enabled_hflag(em->bm, &bmop, bmop.slots_in, "faces_exclude", BM_FACE, BM_ELEM_HIDDEN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BMO_op_exec(em->bm, &bmop);
|
2013-04-01 10:18:01 +00:00
|
|
|
|
2018-05-12 10:45:51 +02:00
|
|
|
if (use_select_inset) {
|
|
|
|
/* deselect original faces/verts */
|
|
|
|
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
|
|
|
|
BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
|
|
|
|
BMO_slot_buffer_hflag_enable(em->bm, bmop.slots_in, "faces", BM_FACE, BM_ELEM_SELECT, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!EDBM_op_finish(em, &bmop, op, true)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
EDBM_update_generic(em, true, true);
|
|
|
|
changed = true;
|
|
|
|
}
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
2018-05-12 10:45:51 +02:00
|
|
|
return changed;
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int edbm_inset_exec(bContext *C, wmOperator *op)
|
|
|
|
{
|
2013-04-08 02:14:58 +00:00
|
|
|
if (!edbm_inset_init(C, op, false)) {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2013-04-01 10:18:01 +00:00
|
|
|
|
|
|
|
if (!edbm_inset_calc(op)) {
|
|
|
|
edbm_inset_exit(C, op);
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
edbm_inset_exit(C, op);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int edbm_inset_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|
|
|
{
|
|
|
|
RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
|
|
|
InsetData *opdata;
|
|
|
|
float mlen[2];
|
|
|
|
float center_3d[3];
|
|
|
|
|
2013-04-08 02:14:58 +00:00
|
|
|
if (!edbm_inset_init(C, op, true)) {
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
2013-04-01 10:18:01 +00:00
|
|
|
|
|
|
|
opdata = op->customdata;
|
|
|
|
|
|
|
|
/* initialize mouse values */
|
2015-12-01 18:52:24 +11:00
|
|
|
if (!calculateTransformCenter(C, V3D_AROUND_CENTER_MEAN, center_3d, opdata->mcenter)) {
|
2013-04-01 10:18:01 +00:00
|
|
|
/* in this case the tool will likely do nothing,
|
|
|
|
* ideally this will never happen and should be checked for above */
|
|
|
|
opdata->mcenter[0] = opdata->mcenter[1] = 0;
|
|
|
|
}
|
|
|
|
mlen[0] = opdata->mcenter[0] - event->mval[0];
|
|
|
|
mlen[1] = opdata->mcenter[1] - event->mval[1];
|
|
|
|
opdata->initial_length = len_v2(mlen);
|
|
|
|
opdata->pixel_size = rv3d ? ED_view3d_pixel_size(rv3d, center_3d) : 1.0f;
|
|
|
|
|
|
|
|
edbm_inset_calc(op);
|
|
|
|
|
|
|
|
edbm_inset_update_header(op, C);
|
|
|
|
|
|
|
|
WM_event_add_modal_handler(C, op);
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int edbm_inset_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|
|
|
{
|
|
|
|
InsetData *opdata = op->customdata;
|
2014-08-25 20:18:43 +02:00
|
|
|
const bool has_numinput = hasNumInput(&opdata->num_input);
|
|
|
|
|
|
|
|
/* Modal numinput active, try to handle numeric inputs first... */
|
|
|
|
if (event->val == KM_PRESS && has_numinput && handleNumInput(C, &opdata->num_input, event)) {
|
|
|
|
float amounts[2] = {RNA_float_get(op->ptr, "thickness"),
|
|
|
|
RNA_float_get(op->ptr, "depth")};
|
|
|
|
applyNumInput(&opdata->num_input, amounts);
|
|
|
|
amounts[0] = max_ff(amounts[0], 0.0f);
|
|
|
|
RNA_float_set(op->ptr, "thickness", amounts[0]);
|
|
|
|
RNA_float_set(op->ptr, "depth", amounts[1]);
|
|
|
|
|
|
|
|
if (edbm_inset_calc(op)) {
|
|
|
|
edbm_inset_update_header(op, C);
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
edbm_inset_cancel(C, op);
|
|
|
|
return OPERATOR_CANCELLED;
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
|
|
|
}
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
else {
|
|
|
|
bool handled = false;
|
|
|
|
switch (event->type) {
|
|
|
|
case ESCKEY:
|
|
|
|
case RIGHTMOUSE:
|
|
|
|
edbm_inset_cancel(C, op);
|
|
|
|
return OPERATOR_CANCELLED;
|
2013-04-01 10:18:01 +00:00
|
|
|
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
case MOUSEMOVE:
|
2014-08-25 20:18:43 +02:00
|
|
|
if (!has_numinput) {
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
float mdiff[2];
|
|
|
|
float amount;
|
|
|
|
|
|
|
|
mdiff[0] = opdata->mcenter[0] - event->mval[0];
|
|
|
|
mdiff[1] = opdata->mcenter[1] - event->mval[1];
|
|
|
|
|
|
|
|
if (opdata->modify_depth)
|
|
|
|
amount = opdata->old_depth + ((len_v2(mdiff) - opdata->initial_length) * opdata->pixel_size);
|
|
|
|
else
|
|
|
|
amount = opdata->old_thickness - ((len_v2(mdiff) - opdata->initial_length) * opdata->pixel_size);
|
|
|
|
|
|
|
|
/* Fake shift-transform... */
|
|
|
|
if (opdata->shift)
|
|
|
|
amount = (amount - opdata->shift_amount) * 0.1f + opdata->shift_amount;
|
|
|
|
|
|
|
|
if (opdata->modify_depth)
|
|
|
|
RNA_float_set(op->ptr, "depth", amount);
|
|
|
|
else {
|
|
|
|
amount = max_ff(amount, 0.0f);
|
|
|
|
RNA_float_set(op->ptr, "thickness", amount);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (edbm_inset_calc(op))
|
|
|
|
edbm_inset_update_header(op, C);
|
|
|
|
else {
|
|
|
|
edbm_inset_cancel(C, op);
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
handled = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LEFTMOUSE:
|
|
|
|
case PADENTER:
|
|
|
|
case RETKEY:
|
2018-04-27 20:37:13 +02:00
|
|
|
if ((event->val == KM_PRESS) ||
|
|
|
|
((event->val == KM_RELEASE) && RNA_boolean_get(op->ptr, "release_confirm")))
|
|
|
|
{
|
2017-12-12 01:38:33 +11:00
|
|
|
edbm_inset_calc(op);
|
|
|
|
edbm_inset_exit(C, op);
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
}
|
|
|
|
break;
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
case LEFTSHIFTKEY:
|
|
|
|
case RIGHTSHIFTKEY:
|
|
|
|
if (event->val == KM_PRESS) {
|
|
|
|
if (opdata->modify_depth)
|
|
|
|
opdata->shift_amount = RNA_float_get(op->ptr, "depth");
|
|
|
|
else
|
|
|
|
opdata->shift_amount = RNA_float_get(op->ptr, "thickness");
|
|
|
|
opdata->shift = true;
|
|
|
|
handled = true;
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
|
|
|
else {
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
opdata->shift_amount = 0.0f;
|
|
|
|
opdata->shift = false;
|
|
|
|
handled = true;
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
break;
|
2013-04-01 10:18:01 +00:00
|
|
|
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
case LEFTCTRLKEY:
|
|
|
|
case RIGHTCTRLKEY:
|
|
|
|
{
|
|
|
|
float mlen[2];
|
2013-04-01 10:18:01 +00:00
|
|
|
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
mlen[0] = opdata->mcenter[0] - event->mval[0];
|
|
|
|
mlen[1] = opdata->mcenter[1] - event->mval[1];
|
2013-04-01 10:18:01 +00:00
|
|
|
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
if (event->val == KM_PRESS) {
|
|
|
|
opdata->old_thickness = RNA_float_get(op->ptr, "thickness");
|
|
|
|
if (opdata->shift)
|
|
|
|
opdata->shift_amount = opdata->old_thickness;
|
|
|
|
opdata->modify_depth = true;
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
|
|
|
else {
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
opdata->old_depth = RNA_float_get(op->ptr, "depth");
|
|
|
|
if (opdata->shift)
|
|
|
|
opdata->shift_amount = opdata->old_depth;
|
|
|
|
opdata->modify_depth = false;
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
opdata->initial_length = len_v2(mlen);
|
|
|
|
|
|
|
|
edbm_inset_update_header(op, C);
|
|
|
|
handled = true;
|
|
|
|
break;
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
|
|
|
|
case OKEY:
|
|
|
|
if (event->val == KM_PRESS) {
|
|
|
|
const bool use_outset = RNA_boolean_get(op->ptr, "use_outset");
|
|
|
|
RNA_boolean_set(op->ptr, "use_outset", !use_outset);
|
|
|
|
if (edbm_inset_calc(op)) {
|
|
|
|
edbm_inset_update_header(op, C);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
edbm_inset_cancel(C, op);
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
handled = true;
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
break;
|
|
|
|
case BKEY:
|
|
|
|
if (event->val == KM_PRESS) {
|
|
|
|
const bool use_boundary = RNA_boolean_get(op->ptr, "use_boundary");
|
|
|
|
RNA_boolean_set(op->ptr, "use_boundary", !use_boundary);
|
|
|
|
if (edbm_inset_calc(op)) {
|
|
|
|
edbm_inset_update_header(op, C);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
edbm_inset_cancel(C, op);
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
handled = true;
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
break;
|
|
|
|
case IKEY:
|
|
|
|
if (event->val == KM_PRESS) {
|
|
|
|
const bool use_individual = RNA_boolean_get(op->ptr, "use_individual");
|
|
|
|
RNA_boolean_set(op->ptr, "use_individual", !use_individual);
|
|
|
|
if (edbm_inset_calc(op)) {
|
|
|
|
edbm_inset_update_header(op, C);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
edbm_inset_cancel(C, op);
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
}
|
|
|
|
handled = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-08-25 20:18:43 +02:00
|
|
|
/* Modal numinput inactive, try to handle numeric inputs last... */
|
|
|
|
if (!handled && event->val == KM_PRESS && handleNumInput(C, &opdata->num_input, event)) {
|
|
|
|
float amounts[2] = {RNA_float_get(op->ptr, "thickness"),
|
|
|
|
RNA_float_get(op->ptr, "depth")};
|
|
|
|
applyNumInput(&opdata->num_input, amounts);
|
|
|
|
amounts[0] = max_ff(amounts[0], 0.0f);
|
|
|
|
RNA_float_set(op->ptr, "thickness", amounts[0]);
|
|
|
|
RNA_float_set(op->ptr, "depth", amounts[1]);
|
|
|
|
|
|
|
|
if (edbm_inset_calc(op)) {
|
|
|
|
edbm_inset_update_header(op, C);
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
edbm_inset_cancel(C, op);
|
|
|
|
return OPERATOR_CANCELLED;
|
2013-04-05 22:21:14 +00:00
|
|
|
}
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
}
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MESH_OT_inset(wmOperatorType *ot)
|
|
|
|
{
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
/* identifiers */
|
|
|
|
ot->name = "Inset Faces";
|
|
|
|
ot->idname = "MESH_OT_inset";
|
|
|
|
ot->description = "Inset new faces into selected faces";
|
|
|
|
|
|
|
|
/* api callbacks */
|
|
|
|
ot->invoke = edbm_inset_invoke;
|
|
|
|
ot->modal = edbm_inset_modal;
|
|
|
|
ot->exec = edbm_inset_exec;
|
|
|
|
ot->cancel = edbm_inset_cancel;
|
|
|
|
ot->poll = ED_operator_editmesh;
|
|
|
|
|
|
|
|
/* flags */
|
2015-04-27 18:44:27 +10:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_CURSOR | OPTYPE_BLOCKING;
|
2013-04-01 10:18:01 +00:00
|
|
|
|
|
|
|
/* properties */
|
2017-12-06 16:42:34 +11:00
|
|
|
RNA_def_boolean(
|
|
|
|
ot->srna, "use_boundary",
|
|
|
|
true, "Boundary", "Inset face boundaries");
|
|
|
|
RNA_def_boolean(
|
|
|
|
ot->srna, "use_even_offset",
|
|
|
|
true, "Offset Even", "Scale the offset to give more even thickness");
|
|
|
|
RNA_def_boolean(
|
|
|
|
ot->srna, "use_relative_offset",
|
|
|
|
false, "Offset Relative", "Scale the offset by surrounding geometry");
|
|
|
|
RNA_def_boolean(
|
|
|
|
ot->srna, "use_edge_rail",
|
|
|
|
false, "Edge Rail", "Inset the region along existing edges");
|
2013-04-01 10:18:01 +00:00
|
|
|
|
2015-12-01 00:58:09 +01:00
|
|
|
prop = RNA_def_float_distance(ot->srna, "thickness", 0.01f, 0.0f, 1e12f, "Thickness", "", 0.0f, 10.0f);
|
2013-04-01 10:18:01 +00:00
|
|
|
/* use 1 rather then 10 for max else dragging the button moves too far */
|
|
|
|
RNA_def_property_ui_range(prop, 0.0, 1.0, 0.01, 4);
|
2017-12-06 16:45:51 +11:00
|
|
|
|
2015-12-01 00:58:09 +01:00
|
|
|
prop = RNA_def_float_distance(ot->srna, "depth", 0.0f, -1e12f, 1e12f, "Depth", "", -10.0f, 10.0f);
|
2013-04-01 10:18:01 +00:00
|
|
|
RNA_def_property_ui_range(prop, -10.0f, 10.0f, 0.01, 4);
|
|
|
|
|
|
|
|
RNA_def_boolean(ot->srna, "use_outset", false, "Outset", "Outset rather than inset");
|
2014-10-13 17:02:21 +02:00
|
|
|
RNA_def_boolean(ot->srna, "use_select_inset", false, "Select Outer", "Select the new inset faces");
|
2013-04-07 05:13:00 +00:00
|
|
|
RNA_def_boolean(ot->srna, "use_individual", false, "Individual", "Individual Face Inset");
|
|
|
|
RNA_def_boolean(ot->srna, "use_interpolate", true, "Interpolate", "Blend face data across the inset");
|
2018-04-27 20:37:13 +02:00
|
|
|
|
|
|
|
prop = RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "");
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|