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:
authorCampbell Barton <ideasman42@gmail.com>2010-11-23 17:14:06 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-11-23 17:14:06 +0300
commit0e9b664fce0ab0c3d5bbf9042c76ffdff8c60fbc (patch)
tree943ca96ca1edb78117fabb5a874121fbd7b05156
parent4aeeee88198b97ede58b09188f588746b0dfe8f1 (diff)
Changes to the ortho grid drawing based on discussion with Ton.
- ortho grid now draws scaled by the view3d 'Scale' setting, venomgfx noticed this was missing. - so as not to confuse add scale next to unit display text, so rather then "Metres" it shows "Metres x 1.5" otherwise its confusing that grid lines are not in exact units. - changed grid spacing to grid scale (needed for more logical behavior with units) - when units are enabled grey out subdivisions.
-rw-r--r--release/scripts/ui/space_view3d.py9
-rw-r--r--source/blender/blenkernel/BKE_unit.h8
-rw-r--r--source/blender/blenkernel/intern/unit.c18
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c16
-rw-r--r--source/blender/makesrna/intern/rna_space.c8
5 files changed, 34 insertions, 25 deletions
diff --git a/release/scripts/ui/space_view3d.py b/release/scripts/ui/space_view3d.py
index 8c85c389c0d..293ee7f7cf8 100644
--- a/release/scripts/ui/space_view3d.py
+++ b/release/scripts/ui/space_view3d.py
@@ -2013,7 +2013,8 @@ class VIEW3D_PT_view3d_display(bpy.types.Panel):
layout = self.layout
view = context.space_data
- gs = context.scene.game_settings
+ scene = context.scene
+ gs = scene.game_settings
ob = context.object
col = layout.column()
@@ -2042,8 +2043,10 @@ class VIEW3D_PT_view3d_display(bpy.types.Panel):
sub = col.column(align=True)
sub.active = (display_all and view.show_floor)
sub.prop(view, "grid_lines", text="Lines")
- sub.prop(view, "grid_spacing", text="Spacing")
- sub.prop(view, "grid_subdivisions", text="Subdivisions")
+ sub.prop(view, "grid_scale", text="Scale")
+ subsub = sub.column(align=True)
+ subsub.active = scene.unit_settings.system == 'NONE'
+ subsub.prop(view, "grid_subdivisions", text="Subdivisions")
col = layout.column()
col.label(text="Shading:")
diff --git a/source/blender/blenkernel/BKE_unit.h b/source/blender/blenkernel/BKE_unit.h
index 7461d43e721..1b53752aae0 100644
--- a/source/blender/blenkernel/BKE_unit.h
+++ b/source/blender/blenkernel/BKE_unit.h
@@ -51,10 +51,10 @@ int bUnit_IsValid(int system, int type);
/* loop over scales, coudl add names later */
//double bUnit_Iter(void **unit, char **name, int system, int type);
-void bUnit_GetSystem(void **usys_pt, int *len, int system, int type);
-char* bUnit_GetName(void *usys_pt, int index);
-char* bUnit_GetNameDisplay(void *usys_pt, int index);
-double bUnit_GetScaler(void *usys_pt, int index);
+void bUnit_GetSystem(void **usys_pt, int *len, int system, int type);
+const char* bUnit_GetName(void *usys_pt, int index);
+const char* bUnit_GetNameDisplay(void *usys_pt, int index);
+double bUnit_GetScaler(void *usys_pt, int index);
/* aligned with PropertyUnit */
#define B_UNIT_NONE 0
diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c
index 4cb59a2ee86..54ecef75108 100644
--- a/source/blender/blenkernel/intern/unit.c
+++ b/source/blender/blenkernel/intern/unit.c
@@ -69,13 +69,13 @@
/* define a single unit */
typedef struct bUnitDef {
- char *name;
- char *name_plural; /* abused a bit for the display name */
- char *name_short; /* this is used for display*/
- char *name_alt; /* keyboard-friendly ASCII-only version of name_short, can be NULL */
+ const char *name;
+ const char *name_plural; /* abused a bit for the display name */
+ const char *name_short; /* this is used for display*/
+ const char *name_alt; /* keyboard-friendly ASCII-only version of name_short, can be NULL */
/* if name_short has non-ASCII chars, name_alt should be present */
- char *name_display; /* can be NULL */
+ const char *name_display; /* can be NULL */
double scalar;
double bias; /* not used yet, needed for converting temperature */
@@ -421,7 +421,7 @@ void bUnit_AsString(char *str, int len_max, double value, int prec, int system,
}
-static char *unit_find_str(char *str, char *substr)
+static char *unit_find_str(char *str, const char *substr)
{
char *str_found;
@@ -476,7 +476,7 @@ static int ch_is_op(char op)
}
}
-static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pref, bUnitDef *unit, char *replace_str)
+static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pref, bUnitDef *unit, const char *replace_str)
{
char *str_found;
@@ -755,11 +755,11 @@ void bUnit_GetSystem(void **usys_pt, int *len, int system, int type)
*len= usys->length;
}
-char *bUnit_GetName(void *usys_pt, int index)
+const char *bUnit_GetName(void *usys_pt, int index)
{
return ((bUnitCollection *)usys_pt)->units[index].name;
}
-char *bUnit_GetNameDisplay(void *usys_pt, int index)
+const char *bUnit_GetNameDisplay(void *usys_pt, int index)
{
return ((bUnitCollection *)usys_pt)->units[index].name_display;
}
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index f05c28fad27..f8e972d1122 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -243,7 +243,7 @@ static void drawgrid_draw(ARegion *ar, float wx, float wy, float x, float y, flo
#define GRID_MIN_PX 6.0f
-static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_unit)
+static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, const char **grid_unit)
{
/* extern short bgpicmode; */
RegionView3D *rv3d= ar->regiondata;
@@ -266,7 +266,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_u
x= (wx)*fx/fw;
y= (wy)*fy/fw;
- vec4[0]=vec4[1]= (unit->system) ? 1.0 : v3d->grid;
+ vec4[0]=vec4[1]= v3d->grid;
vec4[2]= 0.0;
vec4[3]= 1.0;
@@ -306,7 +306,7 @@ static void drawgrid(UnitSettings *unit, ARegion *ar, View3D *v3d, char **grid_u
/* Store the smallest drawn grid size units name so users know how big each grid cell is */
if(*grid_unit==NULL) {
*grid_unit= bUnit_GetNameDisplay(usys, i);
- rv3d->gridview= (scalar / unit->scale_length);
+ rv3d->gridview= (scalar / unit->scale_length) * v3d->grid;
}
blend_fac= 1-((GRID_MIN_PX*2)/dx_scalar);
@@ -2287,7 +2287,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
int retopo= 0, sculptparticle= 0;
unsigned int lay_used;
Object *obact = OBACT;
- char *grid_unit= NULL;
+ const char *grid_unit= NULL;
/* from now on all object derived meshes check this */
v3d->customdata_mask= get_viewedit_datamask(CTX_wm_screen(C), scene, obact);
@@ -2507,8 +2507,14 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
draw_viewport_name(ar, v3d);
}
if (grid_unit) { /* draw below the viewport name */
+ char tstr[32]= "";
+
UI_ThemeColor(TH_TEXT_HI);
- BLF_draw_default(22, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, grid_unit, 65535); /* XXX, use real length */
+ if(v3d->grid != 1.0f) {
+ BLI_snprintf(tstr, sizeof(tstr), "%s x %.4g", v3d->grid, grid_unit);
+ }
+
+ BLF_draw_default(22, ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, tstr[0]?tstr : grid_unit, sizeof(tstr)); /* XXX, use real length */
}
ob= OBACT;
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 7da83a41ab8..0697ce8d056 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1079,13 +1079,13 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_range(prop, 1.0f, FLT_MAX);
RNA_def_property_ui_text(prop, "Clip End", "3D View far clipping distance");
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
-
- prop= RNA_def_property(srna, "grid_spacing", PROP_FLOAT, PROP_DISTANCE);
+
+ prop= RNA_def_property(srna, "grid_scale", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "grid");
- RNA_def_property_ui_text(prop, "Grid Spacing", "The distance between 3D View grid lines");
+ RNA_def_property_ui_text(prop, "Grid Scale", "The distance between 3D View grid lines");
RNA_def_property_range(prop, 0.0f, FLT_MAX);
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL);
-
+
prop= RNA_def_property(srna, "grid_lines", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "gridlines");
RNA_def_property_ui_text(prop, "Grid Lines", "The number of grid lines to display in perspective view");