Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/transform/transform_orientations.c')
-rw-r--r--source/blender/editors/transform/transform_orientations.c106
1 files changed, 61 insertions, 45 deletions
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 332a1e5a324..6cda535516e 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -60,6 +60,8 @@
#include "UI_interface.h"
+#include "RNA_define.h"
+
#include "transform.h"
/* *********************** TransSpace ************************** */
@@ -355,19 +357,48 @@ void BIF_selectTransformOrientationValue(bContext *C, int orientation) {
v3d->twmode = orientation;
}
-void BIF_menuTransformOrientation(bContext *C, uiLayout *layout, void *arg)
+EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
{
- ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
- TransformOrientation *ts;
- int i= V3D_MANIP_CUSTOM;
+ Scene *scene;
+ ListBase *transform_spaces;
+ TransformOrientation *ts= NULL;
+
+ EnumPropertyItem global = {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", ""};
+ EnumPropertyItem normal = {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", ""};
+ EnumPropertyItem local = {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", ""};
+ EnumPropertyItem view = {V3D_MANIP_VIEW, "VIEW", 0, "View", ""};
+ EnumPropertyItem sepr = {0, "", 0, NULL, NULL};
+ EnumPropertyItem tmp = {0, "", 0, "", ""};
+ EnumPropertyItem *item= NULL;
+ int i = V3D_MANIP_CUSTOM, totitem= 0;
+
+ RNA_enum_item_add(&item, &totitem, &global);
+ RNA_enum_item_add(&item, &totitem, &normal);
+ RNA_enum_item_add(&item, &totitem, &local);
+ RNA_enum_item_add(&item, &totitem, &view);
+
+ if(C) {
+ scene= CTX_data_scene(C);
+
+ if(scene) {
+ transform_spaces = &scene->transform_spaces;
+ ts = transform_spaces->first;
+ }
+ }
+
+ if(ts)
+ RNA_enum_item_add(&item, &totitem, &sepr);
+
+ for(; ts; ts = ts->next) {
+ tmp.identifier = "CUSTOM";
+ tmp.name= ts->name;
+ tmp.value = i++;
+ RNA_enum_item_add(&item, &totitem, &tmp);
+ }
- uiItemEnumO(layout, NULL, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_GLOBAL);
- uiItemEnumO(layout, NULL, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_LOCAL);
- uiItemEnumO(layout, NULL, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_NORMAL);
- uiItemEnumO(layout, NULL, 0, "TFM_OT_select_orientation", "orientation", V3D_MANIP_VIEW);
+ RNA_enum_item_end(&item, &totitem);
- for(ts = transform_spaces->first; ts; ts = ts->next)
- uiItemIntO(layout, ts->name, 0, "TFM_OT_select_orientation", "custom_index", i++);
+ return item;
}
char * BIF_menustringTransformOrientation(const bContext *C, char *title) {
@@ -403,7 +434,7 @@ int BIF_countTransformOrientation(const bContext *C) {
return count;
}
-void applyTransformOrientation(bContext *C, TransInfo *t) {
+void applyTransformOrientation(const bContext *C, TransInfo *t) {
TransformOrientation *ts;
View3D *v3d = CTX_wm_view3d(C);
int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
@@ -533,7 +564,7 @@ void initTransformOrientation(bContext *C, TransInfo *t)
}
}
-int getTransformOrientation(bContext *C, float normal[3], float plane[3], int activeOnly)
+int getTransformOrientation(const bContext *C, float normal[3], float plane[3], int activeOnly)
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
@@ -591,14 +622,11 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac
BMFace *efa;
BMIter iter;
- efa = BMIter_New(&iter, em->bm, BM_FACES_OF_MESH, NULL);
- for( ; efa; efa=BMIter_Step(&iter))
- {
- if(BM_TestHFlag(efa, BM_SELECT))
- {
+ BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
+ if(BM_TestHFlag(efa, BM_SELECT)) {
VECADD(normal, normal, efa->no);
VecSubf(vec, efa->loopbase->v->co,
- ((BMLoop*)efa->loopbase->head.next)->v->co);
+ ((BMLoop*)efa->loopbase->head.next)->v->co);
VECADD(plane, plane, vec);
}
}
@@ -610,11 +638,9 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac
BMVert *v1 = NULL, *v2 = NULL, *v3 = NULL;
BMIter iter;
float cotangent[3];
-
- eve = BMIter_New(&iter, em->bm, BM_VERTS_OF_MESH, NULL);
- for( ; eve; eve=BMIter_Step(&iter))
- {
- if ( BM_TestHFlag(eve, BM_SELECT) ) {
+
+ BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
+ if (BM_TestHFlag(eve, BM_SELECT)) {
if (v1 == NULL) {
v1 = eve;
}
@@ -637,9 +663,8 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac
{
BMEdge *eed = NULL;
BMIter iter;
-
- eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL);
- for( ; eed; eed=BMIter_Step(&iter)) {
+
+ BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
if(BM_TestHFlag(eed, BM_SELECT)) {
VecSubf(plane, eed->v2->co, eed->v1->co);
break;
@@ -653,9 +678,8 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac
{
BMEdge *eed = NULL;
BMIter iter;
-
- eed = BMIter_New(&iter, em->bm, BM_EDGES_OF_MESH, NULL);
- for( ; eed; eed=BMIter_Step(&iter)) {
+
+ BM_ITER(eed, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
if(BM_TestHFlag(eed, BM_SELECT)) {
/* use average vert normals as plane and edge vector as normal */
VECCOPY(plane, eed->v1->no);
@@ -668,13 +692,11 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac
}
else if (em->bm->totvertsel == 2)
{
- BMVert *v1=NULL, *v2=NULL;
+ BMVert *v1 = NULL, *v2 = NULL;
BMIter iter;
- eve = BMIter_New(&iter, em->bm, BM_VERTS_OF_MESH, NULL);
- for( ; eve; eve=BMIter_Step(&iter))
- {
- if ( BM_TestHFlag(eve, BM_SELECT) ) {
+ BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
+ if (BM_TestHFlag(eve, BM_SELECT)) {
if (v1 == NULL) {
v1 = eve;
}
@@ -694,10 +716,8 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac
{
BMIter iter;
- eve = BMIter_New(&iter, em->bm, BM_VERTS_OF_MESH, NULL);
- for( ; eve; eve=BMIter_Step(&iter))
- {
- if ( BM_TestHFlag(eve, BM_SELECT) ) {
+ BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
+ if (BM_TestHFlag(eve, BM_SELECT)) {
VECCOPY(normal, eve->no);
break;
}
@@ -707,14 +727,10 @@ int getTransformOrientation(bContext *C, float normal[3], float plane[3], int ac
else if (em->bm->totvertsel > 3)
{
BMIter iter;
-
- eve = BMIter_New(&iter, em->bm, BM_VERTS_OF_MESH, NULL);
-
normal[0] = normal[1] = normal[2] = 0;
-
- for( ; eve; eve=BMIter_Step(&iter))
- {
- if ( BM_TestHFlag(eve, BM_SELECT) ) {
+
+ BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
+ if (BM_TestHFlag(eve, BM_SELECT)) {
VecAddf(normal, normal, eve->no);
}
}