summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid E. Narvaez <[email protected]>2014-01-15 04:00:40 -0500
committerDavid E. Narvaez <[email protected]>2014-01-15 04:00:40 -0500
commit1ed46f4262622ed097536a4640dfc887a1149cbf (patch)
treef793e2b27b99d8dba83ee51ef5f6829a91291aa2
parentd7ec66e1be4d0bd060208b0272057eeae0da6fb2 (diff)
Adding More AB-Types
Adding support for Line, Ray and Midpoint by generalizing the template used to support Segments. This code generates duplicated objects.
-rw-r--r--filters/geogebra-filter.cpp8
-rw-r--r--filters/geogebra.xsl29
2 files changed, 33 insertions, 4 deletions
diff --git a/filters/geogebra-filter.cpp b/filters/geogebra-filter.cpp
index 8db1ba2..5f93565 100644
--- a/filters/geogebra-filter.cpp
+++ b/filters/geogebra-filter.cpp
@@ -207,6 +207,14 @@ void KigFilterGeogebra::startElement(const QXmlName& name)
{
m_currentObject = SegmentABType::instance();
}
+ else if( name.localName( m_np ) == QLatin1String( "RayAB" ) )
+ {
+ m_currentObject = RayABType::instance();
+ }
+ else if( name.localName( m_np ) == QLatin1String( "Midpoint" ) )
+ {
+ m_currentObject = MidPointType::instance();
+ }
break;
case KigFilterGeogebra::ReadingArguments:
diff --git a/filters/geogebra.xsl b/filters/geogebra.xsl
index 89169b6..4ede1db 100644
--- a/filters/geogebra.xsl
+++ b/filters/geogebra.xsl
@@ -10,14 +10,18 @@
</FixedPoint>
</xsl:template>
- <xsl:template match="element" name="segmentTemplate">
+ <xsl:template match="element" name="abTemplate">
+ <xsl:param name="abType" as="xs:string"/>
<xsl:variable name="label" as="xs:string" select="./output/@a0"/>
<xsl:variable name="A" as="xs:string" select="./input/@a0"/>
<xsl:variable name="B" as="xs:string" select="./input/@a1"/>
- <SegmentAB label="{$label}">
+ <xsl:element name="{$abType}">
+ <xsl:attribute name="label" type="xs:string">
+ <xsl:value-of select="$label"/>
+ </xsl:attribute>
<Parent label="{$A}"/>
<Parent label="{$B}"/>
- </SegmentAB>
+ </xsl:element>
</xsl:template>
<xsl:template match="/geogebra/construction">
@@ -28,7 +32,24 @@
<xsl:call-template name="pointTemplate"/>
</xsl:when>
<xsl:when test="(name(.) = 'command') and (./@name = 'Segment')">
- <xsl:call-template name="segmentTemplate"/>
+ <xsl:call-template name="abTemplate">
+ <xsl:with-param name="abType" select="'SegmentAB'"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="(name(.) = 'command') and (./@name = 'Line')">
+ <xsl:call-template name="abTemplate">
+ <xsl:with-param name="abType" select="'LineAB'"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="(name(.) = 'command') and (./@name = 'Ray')">
+ <xsl:call-template name="abTemplate">
+ <xsl:with-param name="abType" select="'RayAB'"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="(name(.) = 'command') and (./@name = 'Midpoint')">
+ <xsl:call-template name="abTemplate">
+ <xsl:with-param name="abType" select="'Midpoint'"/>
+ </xsl:call-template>
</xsl:when>
</xsl:choose>
</xsl:for-each>