Преглед изворни кода

Added input and output ValueProperty for image and file types

MattClarkson пре 12 година
родитељ
комит
a1e64b54c5

+ 26 - 9
Libs/CommandLineModules/Frontend/QtGui/Resources/ctkCmdLineModuleXmlToQtUi.xsl

@@ -49,8 +49,10 @@
   <xsl:param name="floatValueProperty">value</xsl:param>
   <xsl:param name="pointValueProperty">coordinates</xsl:param>
   <xsl:param name="regionValueProperty">coordinates</xsl:param>
-  <xsl:param name="imageValueProperty">currentPath</xsl:param>
-  <xsl:param name="fileValueProperty">currentPath</xsl:param>
+  <xsl:param name="imageInputValueProperty">currentPath</xsl:param>
+  <xsl:param name="imageOutputValueProperty">currentPath</xsl:param>
+  <xsl:param name="fileInputValueProperty">currentPath</xsl:param>
+  <xsl:param name="fileOutputValueProperty">currentPath</xsl:param>
   <xsl:param name="directoryValueProperty">currentPath</xsl:param>
   <xsl:param name="geometryValueProperty">currentPath</xsl:param>
   <xsl:param name="vectorValueProperty">text</xsl:param>
@@ -80,6 +82,7 @@
        (or be convertible to it). -->
   <xsl:function name="ctk:mapTypeToQtValueProperty">
     <xsl:param name="cliType"/>
+    <xsl:param name="cliChannel"/> 
     <xsl:choose>
       <xsl:when test="$cliType='boolean'"><xsl:value-of select="$booleanValueProperty"/></xsl:when>
       <xsl:when test="$cliType='integer'"><xsl:value-of select="$integerValueProperty"/></xsl:when>
@@ -87,8 +90,10 @@
       <xsl:when test="$cliType='double'"><xsl:value-of select="$floatValueProperty"/></xsl:when>
       <xsl:when test="$cliType='point'"><xsl:value-of select="$pointValueProperty"/></xsl:when>
       <xsl:when test="$cliType='region'"><xsl:value-of select="$regionValueProperty"/></xsl:when>
-      <xsl:when test="$cliType='image'"><xsl:value-of select="$imageValueProperty"/></xsl:when>
-      <xsl:when test="$cliType='file'"><xsl:value-of select="$fileValueProperty"/></xsl:when>
+      <xsl:when test="$cliType='image' and $cliChannel='input'"><xsl:value-of select="$imageInputValueProperty"/></xsl:when>
+      <xsl:when test="$cliType='image' and $cliChannel='output'"><xsl:value-of select="$imageOutputValueProperty"/></xsl:when>
+      <xsl:when test="$cliType='file' and $cliChannel='input'"><xsl:value-of select="$fileInputValueProperty"/></xsl:when>
+      <xsl:when test="$cliType='file' and $cliChannel='output'"><xsl:value-of select="$fileOutputValueProperty"/></xsl:when>
       <xsl:when test="$cliType='directory'"><xsl:value-of select="$directoryValueProperty"/></xsl:when>
       <xsl:when test="$cliType='geometry'"><xsl:value-of select="$geometryValueProperty"/></xsl:when>
       <xsl:when test="$cliType='integer-vector'"><xsl:value-of select="$vectorValueProperty"/></xsl:when>
@@ -140,9 +145,16 @@
   <!-- Set the default value by generating a Qt widget specific property which holds
        the current value -->
   <xsl:template match="default">
-    <property name="{ctk:mapTypeToQtValueProperty(name(..))}">
-      <xsl:element name="{ctk:mapTypeToQtDesigner(name(..))}"><xsl:value-of select="text()"/></xsl:element>
-    </property>
+    <xsl:if test="../channel/text()='output'">
+      <property name="{ctk:mapTypeToQtValueProperty(name(..),'output')}">
+        <xsl:element name="{ctk:mapTypeToQtDesigner(name(..))}"><xsl:value-of select="text()"/></xsl:element>
+      </property>
+    </xsl:if>
+    <xsl:if test="../channel/text()='input'">
+      <property name="{ctk:mapTypeToQtValueProperty(name(..),'input')}">
+        <xsl:element name="{ctk:mapTypeToQtDesigner(name(..))}"><xsl:value-of select="text()"/></xsl:element>
+      </property>
+    </xsl:if>
   </xsl:template>
 
   <!-- Set Qt widget (spinbox) specific properties for applying constraints of scalar parameters -->
@@ -176,7 +188,7 @@
   </xsl:template>
 
   <!-- A named template for adding properties common to all Qt widgets -->
-  <xsl:template name="commonWidgetProperties">
+  <xsl:template name="commonWidgetProperties">  
     <xsl:apply-templates select="description"/> <!-- tooltip -->
     <xsl:if test="@hidden='true'"> <!-- widget visibility -->
       <property  name="visible">
@@ -190,7 +202,12 @@
       </property>
     </xsl:if>
     <property name="parameter:valueProperty"> <!-- property name containing current value -->
-      <string><xsl:value-of select="ctk:mapTypeToQtValueProperty(name())"/></string>
+      <xsl:if test="channel/text()='output'">
+        <string><xsl:value-of select="ctk:mapTypeToQtValueProperty(name(),'output')"/></string>
+      </xsl:if>
+      <xsl:if test="channel/text()='input'">
+        <string><xsl:value-of select="ctk:mapTypeToQtValueProperty(name(),'input')"/></string>
+      </xsl:if>      
     </property>
 
     <!-- add additional (optional) information as properties -->