如何使用变量值创建参数类(How to create a parameter class with variant value)
我想创建一个params集合。 使用泛型创建集合非常简单:
List<Param> Params = new List<Param>();
我可以简单地添加这样的参数:
List<Param> Params = new List<Param>() { new Param() { Label = "Param 1", Type = Param.ParamType.Text }, new Param() { Label = "Param 2", Type = Param.ParamType.Select } }
现在,如何为每个参数添加一个类型值属性?
喜欢:
- 文本的字符串
- 选择的选项列表
- 一个日期,一个布尔......
我认为有一个更好的解决方案:
new Param() { Label = "Param 1", Type = Param.ParamType.Text, StringValue = "text" }, new Param() { Label = "Param 1", Type = Param.ParamType.Text, StringValue = "text" }, new Param() { Label = "Param 1", Type = Param.ParamType.CheckBox, BoolValue = true }
I want to create a params collection. Create a collection with generics is very simple:
List<Param> Params = new List<Param>();
And I can simply add params like this:
List<Param> Params = new List<Param>() { new Param() { Label = "Param 1", Type = Param.ParamType.Text }, new Param() { Label = "Param 2", Type = Param.ParamType.Select } }
Now, how do I add a typed value property for each param?
Like:
- a string for the text
- an options list for the select
- a date, a boolean…
I think there are a better solution like that:
new Param() { Label = "Param 1", Type = Param.ParamType.Text, StringValue = "text" }, new Param() { Label = "Param 1", Type = Param.ParamType.Text, StringValue = "text" }, new Param() { Label = "Param 1", Type = Param.ParamType.CheckBox, BoolValue = true }
原文:https://stackoverflow.com/questions/18368909
最满意答案
在
ImageAugmentation()
合并更加困难,但默认情况下scipy.ndimage.rotate
函数正确旋转3D图像并获取指定旋转平面的axes参数( https://docs.scipy.org/doc) /scipy-0.16.1/reference/generated/scipy.ndimage.interpolation.rotate.html )。 绕第一轴(x)旋转意味着传递axes=(1,2)
,绕第二轴旋转(y)使用axes=(0,2)
It is more difficult to incorporate in the
ImageAugmentation()
but thescipy.ndimage.rotate
function by default rotates 3D images correctly and takes the axes argument which specifies which specify the plane of rotation (https://docs.scipy.org/doc/scipy-0.16.1/reference/generated/scipy.ndimage.interpolation.rotate.html). Rotating around the first axis (x) means you passaxes=(1,2)
, to rotate around the second axis (y) useaxes=(0,2)
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
如何在Java 3D中以特定角度连续旋转矩形(How to rotate a rectangle continously in a specific angle in Java 3D)[2022-04-20]
您必须调用TransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE)以允许在运行时修改转换。 然后,您必须稍后调用TransformGroup.setTransform()来修改其转换。 您可以通过不同的转换来传递它,使其旋转,移动,...您可以使用以下示例: http : //www.java3d.org/animationinteraction.html 您可以使用计时器定期执行任务。 此任务可以修改转换(通过计算前一个转换的新转 ... -
在python中旋转一个3d对象(Rotate a 3d object in python)[2023-01-23]
当您单独绘制每个顶点时,我认为您需要对每个顶点应用旋转。 3D旋转可能会令人困惑,有很多种方法可以定义这种旋转,并且根据您想要旋转的方式,它将取决于您将选择哪种旋转。 你说你想要水平旋转它,在这样的3D图片中,目前还不清楚这是什么意思所以请原谅我,如果我错误地假设你想要旋转它说z轴的角度为theta 。 要旋转长度为3的向量p ,我们保持第三个组件不变并对其他两个组件应用旋转。 通过矩阵乘法可以很好地理解这一点,但我会将解释留给Wolfram页面 : p_rotated_x = p_x * sin(thet ... -
根据我的评论: import mayavi.mlab as mlab import numpy as np x,y = np.mgrid[-1:1:0.001, -1:1:0.001] z = x**2+y**2 s = mlab.mesh(x, y, z) alpha = 30 # degrees mlab.view(azimuth=0, elevation=90, roll=-90+alpha) mlab.show() 或者在@Tamas之后回答: #parabaloid import numpy ...
-
瞄准广场非常容易,只需应用比例: ctx.scale(1, 2/3); // squish it to 2/3 vertical size 然而,你必须通过(opposite fraction * the height) / 2来翻译它以使其居中。 因此,要旋转然后挤压200x200的方形图像,您只需: // rotation first ctx.translate(100,100); ctx.rotate(.3); ctx.translate(-100,-100); // than scale ctx. ...
-
您所指的视频实际上并不显示3D图像(根据定义,所有图像都是二维的)。 这是一个自定义模式演示,非常类似于两个视图控制器之间的iOS内置模式演示,使用过渡类型“翻转水平”。 视图控制器之间的厚度是非标准的,可能需要实现为自定义segue。 如果你可以没有厚度,你可以在Interface Builder中创建没有任何代码的标准iOS翻转: 从单个视图应用程序开始 在故事板中创建第二个视图控制器 在第一个视图控制器上创建一个按钮 控制从第一个按钮拖动到第二个视图控制器 选择刚刚创建的segue 在“属性”检查器中 ...
-
您将以像素而不是物理空间设置旋转中心。 SimpleITK(和ITK)在物理空间而不是索引空间中执行转换和重新采样。 不必将图像的原点设置为0 。 我相信你应该使用imagetoresize.TransformContinuousIndexToPhysicalPoint(center_index)来获得物理空间的中心。 You are setting the center of rotation in pixels and not in physical space. SimpleITK ( and ITK ...
-
从理论上讲,你可以为每个偏航,俯仰和滚动做三个嵌套for循环,从0度到180度(因为XMMatrixRotationRollPitchYaw需要弧度而不是度数,因此实际上从0到XM_PI弧度运行)。 但请注意,您可能会遇到使用欧拉角的万向节锁定问题,这就是四元数通常用于相机旋转控制的原因。 当然,这假设您希望从每个单度角度看到对象。 如果您只想确保对象的每个部分都可见,则可以使用较大的增量(例如45度)(XM_PI / 4.f弧度)来实现。 并且您将最终得到一些重复,因为您可以组合不同的欧拉角度以产生相同的 ...
-
在ImageAugmentation()合并更加困难,但默认情况下scipy.ndimage.rotate函数正确旋转3D图像并获取指定旋转平面的axes参数( https://docs.scipy.org/doc) /scipy-0.16.1/reference/generated/scipy.ndimage.interpolation.rotate.html )。 绕第一轴(x)旋转意味着传递axes=(1,2) ,绕第二轴旋转(y)使用axes=(0,2) It is more difficult t ...