Hooking transform operators with manipulator.

It's just a straight application of the normal operator for now, none of the normal manipulator goodies yet (no draw code and you have to click to confirm).
This commit is contained in:
2009-07-09 02:45:48 +00:00
parent b0038be275
commit d7a333f83f
5 changed files with 436 additions and 411 deletions

View File

@@ -87,7 +87,7 @@ enum {
/* Standalone call to get the transformation center corresponding to the current situation
* returns 1 if successful, 0 otherwise (usually means there's no selection)
* (if 0 is returns, *vec is unmodified)
* (if 0 is returns, *vec is unmodified)
* */
int calculateTransformCenter(struct bContext *C, struct wmEvent *event, int centerMode, float *vec);
@@ -128,7 +128,7 @@ void BIF_selectOrientation(void);
void initManipulator(int mode);
void ManipulatorTransform();
int BIF_do_manipulator(struct bContext *C, short mval[2]);
int BIF_do_manipulator(struct bContext *C, struct wmEvent *event, struct wmOperator *op);
void BIF_draw_manipulator(const struct bContext *C);
/* Snapping */
@@ -137,7 +137,7 @@ void BIF_draw_manipulator(const struct bContext *C);
typedef struct DepthPeel
{
struct DepthPeel *next, *prev;
float depth;
float p[3];
float no[3];

View File

@@ -1812,7 +1812,7 @@ static void draw_pose_channels(Scene *scene, View3D *v3d, RegionView3D *rv3d, Ba
if ( (arm->flag & ARM_DRAWAXES) && (arm->flag & ARM_POSEMODE) ) {
glPushMatrix();
glMultMatrixf(pchan->pose_mat);
glTranslatef(0.0f, pchan->bone->length, 0.0f);
//glTranslatef(0.0f, pchan->bone->length, 0.0f);
drawaxes(0.25f*pchan->bone->length, 0, OB_ARROWS);
glPopMatrix();
}
@@ -1996,7 +1996,7 @@ static void draw_ebones(View3D *v3d, RegionView3D *rv3d, Object *ob, int dt)
if (arm->flag & ARM_DRAWAXES) {
glPushMatrix();
set_matrix_editbone(eBone);
glTranslatef(0.0f, eBone->length, 0.0f);
//glTranslatef(0.0f, eBone->length, 0.0f);
drawaxes(eBone->length*0.25f, 0, OB_ARROWS);
glPopMatrix();
}

View File

@@ -95,50 +95,50 @@ static void view3d_boxview_clip(ScrArea *sa)
float clip[6][4];
float x1= 0.0f, y1= 0.0f, z1= 0.0f, ofs[3];
int val;
/* create bounding box */
for(ar= sa->regionbase.first; ar; ar= ar->next) {
if(ar->regiontype==RGN_TYPE_WINDOW) {
RegionView3D *rv3d= ar->regiondata;
if(rv3d->viewlock & RV3D_BOXCLIP) {
if(ELEM(rv3d->view, V3D_VIEW_TOP, V3D_VIEW_BOTTOM)) {
if(ar->winx>ar->winy) x1= rv3d->dist;
else x1= ar->winx*rv3d->dist/ar->winy;
if(ar->winx>ar->winy) y1= ar->winy*rv3d->dist/ar->winx;
else y1= rv3d->dist;
ofs[0]= rv3d->ofs[0];
ofs[1]= rv3d->ofs[1];
}
else if(ELEM(rv3d->view, V3D_VIEW_FRONT, V3D_VIEW_BACK)) {
ofs[2]= rv3d->ofs[2];
if(ar->winx>ar->winy) z1= ar->winy*rv3d->dist/ar->winx;
else z1= rv3d->dist;
}
}
}
}
for(val=0; val<8; val++) {
if(ELEM4(val, 0, 3, 4, 7))
bb->vec[val][0]= -x1 - ofs[0];
else
bb->vec[val][0]= x1 - ofs[0];
if(ELEM4(val, 0, 1, 4, 5))
bb->vec[val][1]= -y1 - ofs[1];
else
bb->vec[val][1]= y1 - ofs[1];
if(val > 3)
bb->vec[val][2]= -z1 - ofs[2];
else
bb->vec[val][2]= z1 - ofs[2];
}
}
/* normals for plane equations */
CalcNormFloat(bb->vec[0], bb->vec[1], bb->vec[4], clip[0]);
CalcNormFloat(bb->vec[1], bb->vec[2], bb->vec[5], clip[1]);
@@ -146,18 +146,18 @@ static void view3d_boxview_clip(ScrArea *sa)
CalcNormFloat(bb->vec[3], bb->vec[0], bb->vec[7], clip[3]);
CalcNormFloat(bb->vec[4], bb->vec[5], bb->vec[6], clip[4]);
CalcNormFloat(bb->vec[0], bb->vec[2], bb->vec[1], clip[5]);
/* then plane equations */
for(val=0; val<5; val++) {
clip[val][3]= - clip[val][0]*bb->vec[val][0] - clip[val][1]*bb->vec[val][1] - clip[val][2]*bb->vec[val][2];
}
clip[5][3]= - clip[5][0]*bb->vec[0][0] - clip[5][1]*bb->vec[0][1] - clip[5][2]*bb->vec[0][2];
/* create bounding box */
for(ar= sa->regionbase.first; ar; ar= ar->next) {
if(ar->regiontype==RGN_TYPE_WINDOW) {
RegionView3D *rv3d= ar->regiondata;
if(rv3d->viewlock & RV3D_BOXCLIP) {
rv3d->rflag |= RV3D_CLIPPING;
memcpy(rv3d->clip, clip, sizeof(clip));
@@ -172,11 +172,11 @@ static void view3d_boxview_sync(ScrArea *sa, ARegion *ar)
{
ARegion *artest;
RegionView3D *rv3d= ar->regiondata;
for(artest= sa->regionbase.first; artest; artest= artest->next) {
if(artest!=ar && artest->regiontype==RGN_TYPE_WINDOW) {
RegionView3D *rv3dtest= artest->regiondata;
if(rv3dtest->viewlock) {
rv3dtest->dist= rv3d->dist;
@@ -198,7 +198,7 @@ static void view3d_boxview_sync(ScrArea *sa, ARegion *ar)
if( ELEM(rv3dtest->view, V3D_VIEW_FRONT, V3D_VIEW_BACK))
rv3dtest->ofs[2]= rv3d->ofs[2];
}
ED_region_tag_redraw(artest);
}
}
@@ -211,11 +211,11 @@ void view3d_boxview_copy(ScrArea *sa, ARegion *ar)
{
ARegion *artest;
RegionView3D *rv3d= ar->regiondata;
for(artest= sa->regionbase.first; artest; artest= artest->next) {
if(artest!=ar && artest->regiontype==RGN_TYPE_WINDOW) {
RegionView3D *rv3dtest= artest->regiondata;
if(rv3dtest->viewlock) {
rv3dtest->dist= rv3d->dist;
VECCOPY(rv3dtest->ofs, rv3d->ofs);
@@ -238,7 +238,7 @@ typedef struct ViewOpsData {
float ofs[3], obofs[3];
float reverse, dist0;
float grid, far;
int origx, origy, oldx, oldy;
int origkey;
@@ -289,11 +289,11 @@ static void viewops_data(bContext *C, wmOperator *op, wmEvent *event)
vod->origx= vod->oldx= event->x;
vod->origy= vod->oldy= event->y;
vod->origkey= event->type;
/* lookup, we dont pass on v3d to prevent confusement */
vod->grid= v3d->grid;
vod->far= v3d->far;
calctrackballvec(&vod->ar->winrct, event->x, event->y, vod->trackvec);
initgrabz(rv3d, -rv3d->ofs[0], -rv3d->ofs[1], -rv3d->ofs[2]);
@@ -523,7 +523,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event)
if(rv3d->viewlock)
return OPERATOR_CANCELLED;
/* makes op->customdata */
viewops_data(C, op, event);
vod= op->customdata;
@@ -557,7 +557,7 @@ void VIEW3D_OT_viewrotate(wmOperatorType *ot)
ot->invoke= viewrotate_invoke;
ot->modal= viewrotate_modal;
ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= OPTYPE_REGISTER;
}
@@ -580,7 +580,7 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y)
window_to_3d_delta(vod->ar, dvec, x-vod->oldx, y-vod->oldy);
VecAddf(vod->rv3d->ofs, vod->rv3d->ofs, dvec);
if(vod->rv3d->viewlock & RV3D_BOXVIEW)
view3d_boxview_sync(vod->sa, vod->ar);
}
@@ -640,7 +640,7 @@ void VIEW3D_OT_viewmove(wmOperatorType *ot)
ot->invoke= viewmove_invoke;
ot->modal= viewmove_modal;
ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= OPTYPE_REGISTER;
}
@@ -650,7 +650,7 @@ void VIEW3D_OT_viewmove(wmOperatorType *ot)
static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my)
{
RegionView3D *rv3d= ar->regiondata;
if(U.uiflag & USER_ZOOM_TO_MOUSEPOS) {
float dvec[3];
float tvec[3];
@@ -800,7 +800,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op)
if(rv3d->viewlock & RV3D_BOXVIEW)
view3d_boxview_sync(CTX_wm_area(C), CTX_wm_region(C));
request_depth_update(CTX_wm_region_view3d(C));
ED_region_tag_redraw(CTX_wm_region(C));
@@ -839,10 +839,10 @@ void VIEW3D_OT_zoom(wmOperatorType *ot)
ot->exec= viewzoom_exec;
ot->modal= viewzoom_modal;
ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= OPTYPE_REGISTER;
RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX);
}
@@ -899,11 +899,11 @@ static int viewhome_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.
if (rv3d->persp==V3D_CAMOB) {
rv3d->persp= V3D_PERSP;
smooth_view(C, NULL, v3d->camera, new_ofs, NULL, &new_dist, NULL);
smooth_view(C, NULL, v3d->camera, new_ofs, NULL, &new_dist, NULL);
}
}
// XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
if(rv3d->viewlock & RV3D_BOXVIEW)
view3d_boxview_copy(CTX_wm_area(C), ar);
@@ -920,10 +920,10 @@ void VIEW3D_OT_viewhome(wmOperatorType *ot)
/* api callbacks */
ot->exec= viewhome_exec;
ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= OPTYPE_REGISTER;
RNA_def_boolean(ot->srna, "center", 0, "Center", "");
}
@@ -1013,7 +1013,7 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with
/* perspective should be a bit farther away to look nice */
if(rv3d->persp==V3D_ORTHO)
size*= 0.7;
if(size <= v3d->near*1.5f) size= v3d->near*1.5f;
new_ofs[0]= -(min[0]+max[0])/2.0f;
@@ -1036,7 +1036,7 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with
if (rv3d->persp==V3D_CAMOB) {
rv3d->persp= V3D_PERSP;
smooth_view(C, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL);
}
}
else {
smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL);
}
@@ -1059,7 +1059,7 @@ void VIEW3D_OT_viewcenter(wmOperatorType *ot)
/* api callbacks */
ot->exec= viewcenter_exec;
ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= OPTYPE_REGISTER;
}
@@ -1071,16 +1071,16 @@ static int render_border_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C);
ARegion *ar= CTX_wm_region(C);
Scene *scene= CTX_data_scene(C);
rcti rect;
rctf vb;
/* get border select values using rna */
rect.xmin= RNA_int_get(op->ptr, "xmin");
rect.ymin= RNA_int_get(op->ptr, "ymin");
rect.xmax= RNA_int_get(op->ptr, "xmax");
rect.ymax= RNA_int_get(op->ptr, "ymax");
/* calculate range */
calc_viewborder(scene, ar, v3d, &vb);
@@ -1088,13 +1088,13 @@ static int render_border_exec(bContext *C, wmOperator *op)
scene->r.border.ymin= ((float)rect.ymin-vb.ymin)/(vb.ymax-vb.ymin);
scene->r.border.xmax= ((float)rect.xmax-vb.xmin)/(vb.xmax-vb.xmin);
scene->r.border.ymax= ((float)rect.ymax-vb.ymin)/(vb.ymax-vb.ymin);
/* actually set border */
/* actually set border */
CLAMP(scene->r.border.xmin, 0.0, 1.0);
CLAMP(scene->r.border.ymin, 0.0, 1.0);
CLAMP(scene->r.border.xmax, 0.0, 1.0);
CLAMP(scene->r.border.ymax, 0.0, 1.0);
/* drawing a border surrounding the entire camera view switches off border rendering
* or the border covers no pixels */
if ((scene->r.border.xmin <= 0.0 && scene->r.border.xmax >= 1.0 &&
@@ -1106,7 +1106,7 @@ static int render_border_exec(bContext *C, wmOperator *op)
} else {
scene->r.mode |= R_BORDER;
}
return OPERATOR_FINISHED;
}
@@ -1114,9 +1114,9 @@ static int render_border_exec(bContext *C, wmOperator *op)
static int view3d_render_border_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
RegionView3D *rv3d= CTX_wm_region_view3d(C);
/* if not in camera view do not exec the operator*/
if (rv3d->persp == V3D_CAMOB) return WM_border_select_invoke(C, op, event);
if (rv3d->persp == V3D_CAMOB) return WM_border_select_invoke(C, op, event);
else return OPERATOR_PASS_THROUGH;
}
@@ -1131,12 +1131,12 @@ void VIEW3D_OT_render_border(wmOperatorType *ot)
ot->invoke= view3d_render_border_invoke;
ot->exec= render_border_exec;
ot->modal= WM_border_select_modal;
ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
/* rna */
RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX);
@@ -1152,7 +1152,7 @@ static int view3d_border_zoom_exec(bContext *C, wmOperator *op)
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d= CTX_wm_region_view3d(C);
Scene *scene= CTX_data_scene(C);
/* Zooms in on a border drawn by the user */
rcti rect;
float dvec[3], vb[2], xscale, yscale, scale;
@@ -1167,16 +1167,16 @@ static int view3d_border_zoom_exec(bContext *C, wmOperator *op)
int had_depth = 0;
double cent[2], p[3];
int xs, ys;
/* note; otherwise opengl won't work */
view3d_operator_needs_opengl(C);
/* get border select values using rna */
rect.xmin= RNA_int_get(op->ptr, "xmin");
rect.ymin= RNA_int_get(op->ptr, "ymin");
rect.xmax= RNA_int_get(op->ptr, "xmax");
rect.ymax= RNA_int_get(op->ptr, "ymax");
/* Get Z Depths, needed for perspective, nice for ortho */
bgl_get_mats(&mats);
draw_depth(scene, ar, v3d, NULL);
@@ -1275,27 +1275,27 @@ static int view3d_border_zoom_exec(bContext *C, wmOperator *op)
}
smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL);
if(rv3d->viewlock & RV3D_BOXVIEW)
view3d_boxview_sync(CTX_wm_area(C), ar);
return OPERATOR_FINISHED;
}
static int view3d_border_zoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
RegionView3D *rv3d= CTX_wm_region_view3d(C);
/* if in camera view do not exec the operator so we do not conflict with set render border*/
if (rv3d->persp != V3D_CAMOB)
return WM_border_select_invoke(C, op, event);
else
if (rv3d->persp != V3D_CAMOB)
return WM_border_select_invoke(C, op, event);
else
return OPERATOR_PASS_THROUGH;
}
void VIEW3D_OT_zoom_border(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Border Zoom";
ot->description = "Zoom in the view to the nearest object contained in the border.";
@@ -1305,12 +1305,12 @@ void VIEW3D_OT_zoom_border(wmOperatorType *ot)
ot->invoke= view3d_border_zoom_invoke;
ot->exec= view3d_border_zoom_exec;
ot->modal= WM_border_select_modal;
ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= OPTYPE_REGISTER;
/* rna */
RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX);
@@ -1335,7 +1335,7 @@ static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, s
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d= CTX_wm_region_view3d(C);
float new_quat[4];
if(rv3d->viewlock) {
/* only pass on if */
if(rv3d->view==V3D_VIEW_FRONT && view==V3D_VIEW_BACK);
@@ -1346,10 +1346,10 @@ static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, s
else if(rv3d->view==V3D_VIEW_TOP && view==V3D_VIEW_BOTTOM);
else return;
}
new_quat[0]= q1; new_quat[1]= q2;
new_quat[2]= q3; new_quat[3]= q4;
rv3d->view= view;
if(rv3d->viewlock) {
@@ -1362,8 +1362,8 @@ static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, s
if (U.uiflag & USER_AUTOPERSP) rv3d->persp= V3D_ORTHO;
else if(rv3d->persp==V3D_CAMOB) rv3d->persp= perspo;
smooth_view(C, v3d->camera, NULL, rv3d->ofs, new_quat, NULL, NULL);
}
smooth_view(C, v3d->camera, NULL, rv3d->ofs, new_quat, NULL, NULL);
}
else {
if (U.uiflag & USER_AUTOPERSP) rv3d->persp= V3D_ORTHO;
@@ -1420,7 +1420,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
QUATCOPY(rv3d->lviewquat, rv3d->viewquat);
rv3d->lview= rv3d->view;
rv3d->lpersp= rv3d->persp;
#if 0
if(G.qual==LR_ALTKEY) {
if(oldcamera && is_an_active_object(oldcamera)) {
@@ -1429,7 +1429,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
handle_view3d_lock();
}
#endif
if(BASACT) {
/* check both G.vd as G.scene cameras */
if((v3d->camera==NULL || scene->camera==NULL) && OBACT->type==OB_CAMERA) {
@@ -1437,14 +1437,14 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
/*handle_view3d_lock();*/
}
}
if(v3d->camera==NULL) {
v3d->camera= scene_find_camera(scene);
/*handle_view3d_lock();*/
}
rv3d->persp= V3D_CAMOB;
smooth_view(C, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens);
}
else{
/* return to settings of last view */
@@ -1472,10 +1472,10 @@ void VIEW3D_OT_viewnumpad(wmOperatorType *ot)
/* api callbacks */
ot->exec= viewnumpad_exec;
ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= OPTYPE_REGISTER;
RNA_def_enum(ot->srna, "type", prop_view_items, 0, "View", "The Type of view");
}
@@ -1490,11 +1490,11 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
{
ARegion *ar= CTX_wm_region(C);
RegionView3D *rv3d= CTX_wm_region_view3d(C);
float phi, si, q1[4];
float phi, si, q1[4];
int orbitdir;
orbitdir = RNA_enum_get(op->ptr, "type");
if(rv3d->viewlock==0) {
if(rv3d->persp != V3D_CAMOB) {
@@ -1528,7 +1528,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
}
}
return OPERATOR_FINISHED;
return OPERATOR_FINISHED;
}
void VIEW3D_OT_view_orbit(wmOperatorType *ot)
@@ -1541,7 +1541,7 @@ void VIEW3D_OT_view_orbit(wmOperatorType *ot)
/* api callbacks */
ot->exec= vieworbit_exec;
ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= OPTYPE_REGISTER;
RNA_def_enum(ot->srna, "type", prop_view_orbit_items, 0, "Orbit", "Direction of View Orbit");
@@ -1557,12 +1557,12 @@ static EnumPropertyItem prop_view_pan_items[] = {
static int viewpan_exec(bContext *C, wmOperator *op)
{
ARegion *ar= CTX_wm_region(C);
RegionView3D *rv3d= CTX_wm_region_view3d(C);
float vec[3];
RegionView3D *rv3d= CTX_wm_region_view3d(C);
float vec[3];
int pandir;
pandir = RNA_enum_get(op->ptr, "type");
initgrabz(rv3d, 0.0, 0.0, 0.0);
if(pandir == V3D_VIEW_PANRIGHT) window_to_3d_delta(ar, vec, -32, 0);
@@ -1578,7 +1578,7 @@ static int viewpan_exec(bContext *C, wmOperator *op)
ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
return OPERATOR_FINISHED;
}
void VIEW3D_OT_view_pan(wmOperatorType *ot)
@@ -1591,7 +1591,7 @@ void VIEW3D_OT_view_pan(wmOperatorType *ot)
/* api callbacks */
ot->exec= viewpan_exec;
ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= OPTYPE_REGISTER;
RNA_def_enum(ot->srna, "type", prop_view_pan_items, 0, "Pan", "Direction of View Pan");
@@ -1600,17 +1600,17 @@ void VIEW3D_OT_view_pan(wmOperatorType *ot)
static int viewpersportho_exec(bContext *C, wmOperator *op)
{
ARegion *ar= CTX_wm_region(C);
RegionView3D *rv3d= CTX_wm_region_view3d(C);
RegionView3D *rv3d= CTX_wm_region_view3d(C);
if(rv3d->viewlock==0) {
if(rv3d->persp!=V3D_ORTHO)
if(rv3d->persp!=V3D_ORTHO)
rv3d->persp=V3D_ORTHO;
else rv3d->persp=V3D_PERSP;
ED_region_tag_redraw(ar);
}
return OPERATOR_FINISHED;
}
void VIEW3D_OT_view_persportho(wmOperatorType *ot)
@@ -1623,7 +1623,7 @@ void VIEW3D_OT_view_persportho(wmOperatorType *ot)
/* api callbacks */
ot->exec= viewpersportho_exec;
ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= OPTYPE_REGISTER;
}
@@ -1725,10 +1725,10 @@ void VIEW3D_OT_clipping(wmOperatorType *ot)
ot->modal= WM_border_select_modal;
ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= OPTYPE_REGISTER;
/* rna */
RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX);
@@ -1745,7 +1745,7 @@ static int view3d_drawtype_exec(bContext *C, wmOperator *op)
dt = RNA_int_get(op->ptr, "draw_type");
dt_alt = RNA_int_get(op->ptr, "draw_type_alternate");
if (dt_alt != -1) {
if (v3d->drawtype == dt)
v3d->drawtype = dt_alt;
@@ -1756,7 +1756,7 @@ static int view3d_drawtype_exec(bContext *C, wmOperator *op)
v3d->drawtype = dt;
ED_area_tag_redraw(CTX_wm_area(C));
return OPERATOR_FINISHED;
}
@@ -1778,10 +1778,10 @@ void VIEW3D_OT_drawtype(wmOperatorType *ot)
ot->exec= view3d_drawtype_exec;
ot->poll= ED_operator_view3d_active;
/* flags */
ot->flag= OPTYPE_REGISTER;
/* rna XXX should become enum */
RNA_def_int(ot->srna, "draw_type", 0, INT_MIN, INT_MAX, "Draw Type", "", INT_MIN, INT_MAX);
RNA_def_int(ot->srna, "draw_type_alternate", -1, INT_MIN, INT_MAX, "Draw Type Alternate", "", INT_MIN, INT_MAX);
@@ -1799,36 +1799,36 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *op, wmEvent *event)
float dx, dy, fz, *fp = NULL, dvec[3], oldcurs[3];
short mx, my, mval[2];
// short ctrl= 0; // XXX
fp= give_cursor(scene, v3d);
// if(obedit && ctrl) lr_click= 1;
VECCOPY(oldcurs, fp);
mx= event->x - ar->winrct.xmin;
my= event->y - ar->winrct.ymin;
project_short_noclip(ar, fp, mval);
initgrabz(rv3d, fp[0], fp[1], fp[2]);
if(mval[0]!=IS_CLIPPED) {
window_to_3d_delta(ar, dvec, mval[0]-mx, mval[1]-my);
VecSubf(fp, fp, dvec);
}
else {
dx= ((float)(mx-(ar->winx/2)))*rv3d->zfac/(ar->winx/2);
dy= ((float)(my-(ar->winy/2)))*rv3d->zfac/(ar->winy/2);
fz= rv3d->persmat[0][3]*fp[0]+ rv3d->persmat[1][3]*fp[1]+ rv3d->persmat[2][3]*fp[2]+ rv3d->persmat[3][3];
fz= fz/rv3d->zfac;
fp[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy+ rv3d->persinv[2][0]*fz)-rv3d->ofs[0];
fp[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy+ rv3d->persinv[2][1]*fz)-rv3d->ofs[1];
fp[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy+ rv3d->persinv[2][2]*fz)-rv3d->ofs[2];
}
// if(lr_click) {
// XXX if(obedit->type==OB_MESH) add_click_mesh();
// else if ELEM(obedit->type, OB_CURVE, OB_SURF) addvert_Nurb(0);
@@ -1837,24 +1837,24 @@ static int set_3dcursor_invoke(bContext *C, wmOperator *op, wmEvent *event)
// }
// XXX notifier for scene */
ED_area_tag_redraw(CTX_wm_area(C));
/* prevent other mouse ops to fail */
return OPERATOR_PASS_THROUGH;
}
void VIEW3D_OT_cursor3d(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Set 3D Cursor";
ot->description = "Set the location of the 3D cursor.";
ot->idname= "VIEW3D_OT_cursor3d";
/* api callbacks */
ot->invoke= set_3dcursor_invoke;
ot->poll= ED_operator_view3d_active;
/* rna later */
}
@@ -1871,28 +1871,28 @@ static int manipulator_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* note; otherwise opengl won't work */
view3d_operator_needs_opengl(C);
if(0==BIF_do_manipulator(C, event->mval))
if(0==BIF_do_manipulator(C, event, op))
return OPERATOR_PASS_THROUGH;
return OPERATOR_FINISHED;
}
void VIEW3D_OT_manipulator(wmOperatorType *ot)
{
/* identifiers */
ot->name= "3D Manipulator";
ot->description = "";
ot->idname= "VIEW3D_OT_manipulator";
/* api callbacks */
ot->invoke= manipulator_invoke;
ot->poll= ED_operator_view3d_active;
/* rna later */
RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", "");
}

File diff suppressed because it is too large Load Diff

View File

@@ -89,6 +89,7 @@ char OP_SHEAR[] = "TFM_OT_shear";
char OP_WARP[] = "TFM_OT_warp";
char OP_SHRINK_FATTEN[] = "TFM_OT_shrink_fatten";
char OP_TILT[] = "TFM_OT_tilt";
char OP_TRACKBALL[] = "TFM_OT_trackball";
TransformModeItem transform_modes[] =
@@ -101,6 +102,7 @@ TransformModeItem transform_modes[] =
{OP_WARP, TFM_WARP},
{OP_SHRINK_FATTEN, TFM_SHRINKFATTEN},
{OP_TILT, TFM_TILT},
{OP_TRACKBALL, TFM_TRACKBALL},
{NULL, 0}
};
@@ -111,7 +113,7 @@ static int select_orientation_exec(bContext *C, wmOperator *op)
if(orientation == V3D_MANIP_CUSTOM)
orientation += custom_index;
BIF_selectTransformOrientationValue(C, orientation);
return OPERATOR_FINISHED;
@@ -121,15 +123,15 @@ static int select_orientation_invoke(bContext *C, wmOperator *op, wmEvent *event
{
uiPopupMenu *pup;
uiLayout *layout;
pup= uiPupMenuBegin(C, "Orientation", 0);
layout= uiPupMenuLayout(pup);
BIF_menuTransformOrientation(C, layout, NULL);
uiPupMenuEnd(C, pup);
return OPERATOR_CANCELLED;
}
void TFM_OT_select_orientation(struct wmOperatorType *ot)
{
static EnumPropertyItem orientation_items[]= {
@@ -183,27 +185,27 @@ static int transformops_data(bContext *C, wmOperator *op, wmEvent *event)
}
retval = initTransform(C, t, op, event, mode);
/* store data */
op->customdata = t;
}
return retval; /* return 0 on error */
}
static int transform_modal(bContext *C, wmOperator *op, wmEvent *event)
{
int exit_code;
TransInfo *t = op->customdata;
transformEvent(t, event);
transformApply(C, t);
exit_code = transformEnd(C, t);
if (exit_code != OPERATOR_RUNNING_MODAL)
{
transformops_exit(C, op);
@@ -215,11 +217,11 @@ static int transform_modal(bContext *C, wmOperator *op, wmEvent *event)
static int transform_cancel(bContext *C, wmOperator *op)
{
TransInfo *t = op->customdata;
t->state = TRANS_CANCEL;
transformEnd(C, t);
transformops_exit(C, op);
return OPERATOR_CANCELLED;
}
@@ -237,11 +239,11 @@ static int transform_exec(bContext *C, wmOperator *op)
t->options |= CTX_AUTOCONFIRM;
transformApply(C, t);
transformEnd(C, t);
transformops_exit(C, op);
return OPERATOR_FINISHED;
}
@@ -279,7 +281,7 @@ void Properties_Snapping(struct wmOperatorType *ot, short align)
RNA_def_boolean(ot->srna, "snap", 0, "Snap to Point", "");
RNA_def_enum(ot->srna, "snap_mode", snap_mode_types, 0, "Mode", "");
RNA_def_float_vector(ot->srna, "snap_point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "", -FLT_MAX, FLT_MAX);
if (align)
{
RNA_def_boolean(ot->srna, "snap_align", 0, "Align with Point Normal", "");
@@ -314,7 +316,7 @@ void TFM_OT_translation(struct wmOperatorType *ot)
RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
Properties_Constraints(ot);
Properties_Snapping(ot, 1);
}
@@ -339,10 +341,32 @@ void TFM_OT_resize(struct wmOperatorType *ot)
RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
Properties_Constraints(ot);
Properties_Snapping(ot, 0);
}
void TFM_OT_trackball(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Trackball";
ot->idname = OP_TRACKBALL;
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
/* api callbacks */
ot->invoke = transform_invoke;
ot->exec = transform_exec;
ot->modal = transform_modal;
ot->cancel = transform_cancel;
ot->poll = ED_operator_areaactive;
RNA_def_float_vector(ot->srna, "value", 2, VecOne, -FLT_MAX, FLT_MAX, "angle", "", -FLT_MAX, FLT_MAX);
Properties_Proportional(ot);
RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
}
void TFM_OT_rotation(struct wmOperatorType *ot)
{
/* identifiers */
@@ -364,7 +388,7 @@ void TFM_OT_rotation(struct wmOperatorType *ot)
RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
Properties_Constraints(ot);
Properties_Snapping(ot, 0);
}
@@ -547,10 +571,11 @@ void transform_operatortypes(void)
WM_operatortype_append(TFM_OT_warp);
WM_operatortype_append(TFM_OT_shrink_fatten);
WM_operatortype_append(TFM_OT_tilt);
WM_operatortype_append(TFM_OT_trackball);
WM_operatortype_append(TFM_OT_select_orientation);
}
void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *keymap, int spaceid)
{
wmKeymapItem *km;
@@ -558,9 +583,9 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key
{
case SPACE_VIEW3D:
km = WM_keymap_add_item(keymap, "TFM_OT_translation", GKEY, KM_PRESS, 0, 0);
km= WM_keymap_add_item(keymap, "TFM_OT_translation", EVT_TWEAK_S, KM_ANY, 0, 0);
km = WM_keymap_add_item(keymap, "TFM_OT_rotation", RKEY, KM_PRESS, 0, 0);
km = WM_keymap_add_item(keymap, "TFM_OT_resize", SKEY, KM_PRESS, 0, 0);
@@ -568,9 +593,9 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key
km = WM_keymap_add_item(keymap, "TFM_OT_warp", WKEY, KM_PRESS, KM_SHIFT, 0);
km = WM_keymap_add_item(keymap, "TFM_OT_tosphere", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
km = WM_keymap_add_item(keymap, "TFM_OT_shear", SKEY, KM_PRESS, KM_ALT|KM_CTRL|KM_SHIFT, 0);
km = WM_keymap_add_item(keymap, "TFM_OT_shrink_fatten", SKEY, KM_PRESS, KM_ALT, 0);
km = WM_keymap_add_item(keymap, "TFM_OT_tilt", TKEY, KM_PRESS, 0, 0);
@@ -581,55 +606,55 @@ void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *key
case SPACE_ACTION:
km= WM_keymap_add_item(keymap, "TFM_OT_transform", GKEY, KM_PRESS, 0, 0);
RNA_int_set(km->ptr, "mode", TFM_TIME_TRANSLATE);
km= WM_keymap_add_item(keymap, "TFM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0);
RNA_int_set(km->ptr, "mode", TFM_TIME_TRANSLATE);
km= WM_keymap_add_item(keymap, "TFM_OT_transform", EKEY, KM_PRESS, 0, 0);
RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND);
km= WM_keymap_add_item(keymap, "TFM_OT_transform", SKEY, KM_PRESS, 0, 0);
RNA_int_set(km->ptr, "mode", TFM_TIME_SCALE);
km= WM_keymap_add_item(keymap, "TFM_OT_transform", TKEY, KM_PRESS, 0, 0);
RNA_int_set(km->ptr, "mode", TFM_TIME_SLIDE);
break;
case SPACE_IPO:
km= WM_keymap_add_item(keymap, "TFM_OT_translation", GKEY, KM_PRESS, 0, 0);
km= WM_keymap_add_item(keymap, "TFM_OT_translation", EVT_TWEAK_S, KM_ANY, 0, 0);
// XXX the 'mode' identifier here is not quite right
km= WM_keymap_add_item(keymap, "TFM_OT_transform", EKEY, KM_PRESS, 0, 0);
RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND);
km = WM_keymap_add_item(keymap, "TFM_OT_rotation", RKEY, KM_PRESS, 0, 0);
km = WM_keymap_add_item(keymap, "TFM_OT_resize", SKEY, KM_PRESS, 0, 0);
break;
case SPACE_NODE:
km= WM_keymap_add_item(keymap, "TFM_OT_translation", GKEY, KM_PRESS, 0, 0);
km= WM_keymap_add_item(keymap, "TFM_OT_translation", EVT_TWEAK_A, KM_ANY, 0, 0);
km= WM_keymap_add_item(keymap, "TFM_OT_translation", EVT_TWEAK_S, KM_ANY, 0, 0);
km = WM_keymap_add_item(keymap, "TFM_OT_rotation", RKEY, KM_PRESS, 0, 0);
km = WM_keymap_add_item(keymap, "TFM_OT_resize", SKEY, KM_PRESS, 0, 0);
break;
case SPACE_SEQ:
km= WM_keymap_add_item(keymap, "TFM_OT_translation", GKEY, KM_PRESS, 0, 0);
km= WM_keymap_add_item(keymap, "TFM_OT_translation", EVT_TWEAK_S, KM_ANY, 0, 0);
km= WM_keymap_add_item(keymap, "TFM_OT_transform", EKEY, KM_PRESS, 0, 0);
RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND);
break;
case SPACE_IMAGE:
km = WM_keymap_add_item(keymap, "TFM_OT_translation", GKEY, KM_PRESS, 0, 0);
km= WM_keymap_add_item(keymap, "TFM_OT_translation", EVT_TWEAK_S, KM_ANY, 0, 0);
km = WM_keymap_add_item(keymap, "TFM_OT_rotation", RKEY, KM_PRESS, 0, 0);
km = WM_keymap_add_item(keymap, "TFM_OT_resize", SKEY, KM_PRESS, 0, 0);