首页 \ 问答 \ 如何使用变量值创建参数类(How to create a parameter class with variant value)

如何使用变量值创建参数类(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
更新时间:2024-05-03 20:05

最满意答案

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 the scipy.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 pass axes=(1,2), to rotate around the second axis (y) useaxes=(0,2)

相关问答

更多
  • 您必须调用TransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE)以允许在运行时修改转换。 然后,您必须稍后调用TransformGroup.setTransform()来修改其转换。 您可以通过不同的转换来传递它,使其旋转,移动,...您可以使用以下示例: http : //www.java3d.org/animationinteraction.html 您可以使用计时器定期执行任务。 此任务可以修改转换(通过计算前一个转换的新转 ...
  • 当您单独绘制每个顶点时,我认为您需要对每个顶点应用旋转。 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 ...

相关文章

更多

最新问答

更多
  • sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
  • 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
  • AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
  • Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
  • 湖北京山哪里有修平板计算机的
  • SimplePie问题(SimplePie Problem)
  • 在不同的任务中,我们可以同时使用多少“上下文”?(How many 'context' we can use at a time simultaneously in different tasks?)
  • HTML / Javascript:从子目录启用文件夹访问(HTML/Javascript: Enabling folder access from a subdirectory)
  • 为什么我会收到链接错误?(Why do I get a linker error?)
  • 如何正确定义析构函数(How to properly define destructor)
  • 垂直切换菜单打开第3级父级。(Vertical toggle menu 3rd level parent stay opened. jQuery)
  • 类型不匹配 - JavaScript(Type mismatch - JavaScript)
  • 为什么当我将模型传递给我的.Net MVC 4控制器操作时,它坚持在部分更新中使用它?(Why is it that when I pass a Model to my .Net MVC 4 Controller Action it insists on using it in the Partial Update?)
  • 在使用熊猫和statsmodels时拉取变量名称(Pulling variable names when using pandas and statsmodels)
  • 如何开启mysql计划事件
  • 检查数组的总和是否大于最大数,反之亦然javascript(checking if sum of array is greater than max number and vice versa javascript)
  • 使用OpenGL ES绘制轮廓(Drawing Outline with OpenGL ES)
  • java日历格式(java Calendar format)
  • Python PANDAS:将pandas / numpy转换为dask数据框/数组(Python PANDAS: Converting from pandas/numpy to dask dataframe/array)
  • 如何搜索附加在elasticsearch索引中的文档的内容(How to search a content of a document attached in elasticsearch index)
  • LinQ to Entities:做相反的查询(LinQ to Entities: Doing the opposite query)
  • 从ExtJs 4.1商店中删除记录时会触发哪些事件(Which events get fired when a record is removed from ExtJs 4.1 store)
  • 运行javascript后如何截取网页截图[关闭](How to take screenshot of a webpage after running javascript [closed])
  • 如何使用GlassFish打印完整的堆栈跟踪?(How can I print the full stack trace with GlassFish?)
  • 如何获取某个exe应用程序的出站HTTP请求?(how to get the outbound HTTP request of a certain exe application?)
  • 嗨,Android重叠背景片段和膨胀异常(Hi, Android overlapping background fragment and inflate exception)
  • Assimp详细说明typedef(Assimp elaborated type refers to typedef)
  • 初始化继承类中不同对象的列表(initialize list of different objects in inherited class)
  • 使用jquery ajax在gridview行中保存星级评分(Save star rating in a gridview row using jquery ajax)
  • Geoxml3 groundOverlay zIndex(Geoxml3 groundOverlay zIndex)