mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-30 21:42:59 +00:00 
			
		
		
		
	refactored the parameter (saver/setting) system
This commit is contained in:
		
							
								
								
									
										60
									
								
								models.cpp
									
									
									
									
									
								
							
							
						
						
									
										60
									
								
								models.cpp
									
									
									
									
									
								
							| @@ -919,14 +919,14 @@ EX namespace models { | ||||
|   #endif   | ||||
|  | ||||
|   void add_model_config() { | ||||
|     addsaver(polygonal::SI, "polygon sides"); | ||||
|     param_f(polygonal::STAR, "star", "polygon star factor"); | ||||
|     addsaver(polygonal::deg, "polygonal degree"); | ||||
|     param_i(polygonal::SI, "polygon sides"); | ||||
|     param_f(polygonal::STAR, parameter_names("star", "polygon star factor")); | ||||
|     param_i(polygonal::deg, "polygonal degree"); | ||||
|  | ||||
|     addsaver(polygonal::maxcoef, "polynomial degree"); | ||||
|     param_i(polygonal::maxcoef, "polynomial degree"); | ||||
|     for(int i=0; i<polygonal::MSI; i++) { | ||||
|       addsaver(polygonal::coefr[i], "polynomial "+its(i)+".real"); | ||||
|       addsaver(polygonal::coefi[i], "polynomial "+its(i)+".imag"); | ||||
|       param_f(polygonal::coefr[i], "polynomial "+its(i)+".real"); | ||||
|       param_f(polygonal::coefi[i], "polynomial "+its(i)+".imag"); | ||||
|       } | ||||
|  | ||||
|     auto setrot = [] { | ||||
| @@ -941,7 +941,7 @@ EX namespace models { | ||||
|     param_matrix(models::rotation.v3, "rotation3", 3)->editable("auto rotation in 3D", "", 'r')->set_extra(setrot); | ||||
|     param_i(models::do_rotate, "auto_rotation_mode", 1); | ||||
|  | ||||
|     param_f(pconf.halfplane_scale, "hp", "halfplane scale", 1); | ||||
|     param_f(pconf.halfplane_scale, parameter_names("hp", "halfplane scale"), 1); | ||||
|      | ||||
|     auto add_all = [&] (projection_configuration& p, string pp, string sp) { | ||||
|  | ||||
| @@ -949,8 +949,8 @@ EX namespace models { | ||||
|       dynamicval<function<bool()>> ds(auto_restrict); | ||||
|       auto_restrict = [&p] { return &vpconf == &p; }; | ||||
|  | ||||
|       addsaverenum(p.model, pp+"used model", mdDisk); | ||||
|       if(&p.model == &pmodel) param_custom(pmodel, "projection|Poincare|Klein|half-plane|perspective", menuitem_projection, '1'); | ||||
|       param_enum(p.model, parameter_names(pp+"used_model", pp+"used model"), mdDisk); | ||||
|       if(&p.model == &pmodel) param_custom_int(pmodel, "projection|Poincare|Klein|half-plane|perspective", menuitem_projection, '1'); | ||||
|  | ||||
|       param_matrix(p.mori().v2, pp+"mori", 2) | ||||
|       -> editable("model orientation", "", 'o'); | ||||
| @@ -960,32 +960,32 @@ EX namespace models { | ||||
|       param_f(p.top_z, sp+"topz", 5) | ||||
|       -> editable(1, 20, .25, "maximum z coordinate to show", "maximum z coordinate to show", 'l');        | ||||
|  | ||||
|       param_f(p.model_transition, pp+"mtrans", sp+"model transition", 1) | ||||
|       param_f(p.model_transition, parameter_names(pp+"mtrans", sp+"model transition"), 1) | ||||
|       -> editable(0, 1, .1, "model transition",  | ||||
|           "You can change this parameter for a transition from another model to this one.", 't');           | ||||
|        | ||||
|       param_f(p.rotational_nil, sp+"rotnil", 1); | ||||
|    | ||||
|       param_f(p.clip_min, pp+"clipmin", sp+"clip-min", rug ? -100 : -1); | ||||
|       param_f(p.clip_max, pp+"clipmax", sp+"clip-max", rug ? +10 : +1); | ||||
|       param_f(p.clip_min, parameter_names(pp+"clipmin", sp+"clip-min"), rug ? -100 : -1); | ||||
|       param_f(p.clip_max, parameter_names(pp+"clipmax", sp+"clip-max"), rug ? +10 : +1); | ||||
|    | ||||
|       param_f(p.euclid_to_sphere, pp+"ets", sp+"euclid to sphere projection", 1.5) | ||||
|       param_f(p.euclid_to_sphere, parameter_names(pp+"ets", sp+"euclid to sphere projection"), 1.5) | ||||
|       -> editable(1e-1, 10, .1, "ETS parameter", "Stereographic projection to a sphere. Choose the radius of the sphere.", 'l') | ||||
|       -> set_sets(dialog::scaleLog); | ||||
|  | ||||
|       param_f(p.twopoint_param, pp+"twopoint", sp+"twopoint parameter", 1) | ||||
|       param_f(p.twopoint_param, parameter_names(pp+"twopoint", sp+"twopoint parameter"), 1) | ||||
|       -> editable(1e-3, 10, .1, "two-point parameter", "In two-point-based models, this parameter gives the distance from each of the two points to the center.", 'b') | ||||
|       -> set_sets(dialog::scaleLog); | ||||
|  | ||||
|       param_f(p.axial_angle, pp+"axial", sp+"axial angle", 90) | ||||
|       param_f(p.axial_angle, parameter_names(pp+"axial", sp+"axial angle"), 90) | ||||
|       -> editable(1e-3, 10, .1, "angle between the axes", "In two-axe-based models, this parameter gives the angle between the two axes.", 'x') | ||||
|       -> set_sets(dialog::scaleLog); | ||||
|  | ||||
|       param_f(p.fisheye_param, pp+"fisheye", sp+"fisheye parameter", 1) | ||||
|       param_f(p.fisheye_param, parameter_names(pp+"fisheye", sp+"fisheye parameter"), 1) | ||||
|       -> editable(1e-3, 10, .1, "fisheye parameter", "Size of the fish eye.", 'b') | ||||
|       -> set_sets(dialog::scaleLog); | ||||
|  | ||||
|       param_f(p.fisheye_alpha, pp+"fishalpha", sp+"off-center parameter", 0) | ||||
|       param_f(p.fisheye_alpha, parameter_names(pp+"fishalpha", sp+"off-center parameter"), 0) | ||||
|       -> editable(1e-1, 10, .1, "off-center parameter", | ||||
|         "This projection is obtained by composing gnomonic projection and inverse stereographic projection. " | ||||
|         "This parameter changes the center of the first projection (0 = gnomonic, 1 = stereographic). Use a value closer to 1 " | ||||
| @@ -999,9 +999,9 @@ EX namespace models { | ||||
|       param_f(p.product_z_scale, pp+"zstretch") | ||||
|       -> editable(0.1, 10, 0.1, "product Z stretch", "", 'Z'); | ||||
|    | ||||
|       param_f(p.collignon_parameter, pp+"collignon", sp+"collignon-parameter", 1) | ||||
|       param_f(p.collignon_parameter, parameter_names(pp+"collignon", sp+"collignon-parameter"), 1) | ||||
|       -> editable(-1, 1, .1, "Collignon parameter", "", 'b') | ||||
|       -> modif([] (float_setting* f) { | ||||
|       -> modif([] (float_parameter* f) { | ||||
|         f->unit = vpconf.collignon_reflected ? " (r)" : ""; | ||||
|         }) | ||||
|       -> set_extra([&p] {  | ||||
| @@ -1044,9 +1044,9 @@ EX namespace models { | ||||
|       param_b(p.dualfocus_autoscale, sp+"dualfocus_autoscale", 0) | ||||
|       -> editable("autoscale dual focus", 'A'); | ||||
|        | ||||
|       addsaver(p.formula, sp+"formula"); | ||||
|       addsaverenum(p.basic_model, sp+"basic model"); | ||||
|       addsaver(p.use_atan, sp+"use_atan");   | ||||
|       param_str(p.formula, sp+"formula"); | ||||
|       param_enum(p.basic_model, sp+"basic model"); | ||||
|       param_b(p.use_atan, sp+"use_atan"); | ||||
|    | ||||
|       param_f(p.spiral_angle, sp+"sang") | ||||
|       -> editable(0, 360, 15, "spiral angle", "set to 90° for the ring projection", 'x') | ||||
| @@ -1062,11 +1062,13 @@ EX namespace models { | ||||
|  | ||||
|       param_i(p.back_and_front, sp+"backandfront", 0); | ||||
|  | ||||
|       auto projsaver = addsaver(p.alpha, sp+"projection", 1); | ||||
|       if(&p.model == &pmodel) { | ||||
|         auto proj = param_custom(p.alpha, sp+"projection", menuitem_projection_distance, 'p'); | ||||
|         auto proj = param_custom_ld(p.alpha, sp+"projection", menuitem_projection_distance, 'p'); | ||||
|         proj->help_text = "projection distance|Gans Klein Poincare orthographic stereographic"; | ||||
|         proj->saver = projsaver; | ||||
|         p.alpha = 1; | ||||
|         } | ||||
|       else { | ||||
|         param_f(p.alpha, sp+"projection", 1); | ||||
|         } | ||||
|  | ||||
|       param_matrix(p.cam(), pp+"cameraangle", 3) | ||||
| @@ -1093,16 +1095,16 @@ EX namespace models { | ||||
|         "(2) in hyperbolic geometry, with spiral angle being +90° or -90°\n" | ||||
|         "(3) in hyperbolic geometry, with other spiral angles (1 makes the bands fit exactly)"; | ||||
|        | ||||
|       param_f(p.sphere_spiral_multiplier, "sphere_spiral_multiplier") | ||||
|       param_f(p.sphere_spiral_multiplier, pp+"sphere_spiral_multiplier") | ||||
|       -> editable(0, 10, .1, "sphere spiral multiplier", help, 'M')->unit = "°"; | ||||
|  | ||||
|       param_f(p.right_spiral_multiplier, "right_spiral_multiplier") | ||||
|       param_f(p.right_spiral_multiplier, pp+"right_spiral_multiplier") | ||||
|       -> editable(0, 10, .1, "right spiral multiplier", help, 'M')->unit = "°"; | ||||
|  | ||||
|       param_f(p.any_spiral_multiplier, "any_spiral_multiplier") | ||||
|       param_f(p.any_spiral_multiplier, pp+"any_spiral_multiplier") | ||||
|       -> editable(0, 10, .1, "any spiral multiplier", help, 'M')->unit = "°"; | ||||
|  | ||||
|       param_f(p.spiral_cone, "spiral_cone") | ||||
|       param_f(p.spiral_cone, pp+"spiral_cone") | ||||
|       -> editable(0, 360, -45, "spiral cone", "", 'C')->unit = "°"; | ||||
|       }; | ||||
|      | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue