Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed flange symbol #27

Merged
merged 6 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 46 additions & 7 deletions www/RunGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,52 @@ Before you start, ensure that you have the following repository structure on you

```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"
width="277.791mm" height="93.6551mm" viewBox="-64.8125 -10.8125 65.625 22.125">
<defs vector-effect="non-scaling-stroke" />
<g>
</g>
</svg>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"
width="3.43931mm" height="17.4611mm" viewBox="-0.40625 -2.03125 0.8125 4.125">
<defs vector-effect="non-scaling-stroke" />
<g>
<g id="cell-SPPeGkMqv3PPZ88ONVvg-0" layer="Symbol">
<path d="M0 2L0-2" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10"
pointer-events="stroke" stroke-width="0.25" stroke-linecap="round"
stroke-linejoin="round" />
</g>

<g id="cell-JrQDJ3AAwTKKgfP51pYv-3"
content="&lt;object label=&quot;Connection&quot; PipingConnector=&quot;Y&quot; LabelConnector=&quot;N&quot; SignalConnector=&quot;Y&quot; Direction=&quot;0, 180&quot; AuxiliaryConnector=&quot;N&quot;/&gt;"
data-label="Connection" data-PipingConnector="Y" data-LabelConnector="N"
data-SignalConnector="Y" data-Direction="0, 180" data-AuxiliaryConnector="N"
layer="Connection">
<ellipse cx="0" cy="0" rx="0.375" ry="0.375" fill="none" stroke="#00ff00"
vector-effect="non-scaling-stroke" />
</g>
<g id="cell-JrQDJ3AAwTKKgfP51pYv-1" content="&lt;object label=&quot;origo&quot;/&gt;"
data-label="origo" layer="Origo">
<ellipse cx="0" cy="0" rx="0.25" ry="0.25" fill="none" stroke="#ff0000"
vector-effect="non-scaling-stroke" />
</g>

<g id="cell-SPPeGkMqv3PPZ88ONVvg-0" layer="Symbol">
<path d="M2 2L2-2" fill="none" stroke="rgb(0, 0, 0)" stroke-miterlimit="10"
pointer-events="stroke" stroke-width="0.25" stroke-linecap="round"
stroke-linejoin="round" />
</g>

<g id="cell-JrQDJ3AAwTKKgfP51pYv-30"
content="&lt;object label=&quot;Connection&quot; PipingConnector=&quot;Y&quot; LabelConnector=&quot;N&quot; SignalConnector=&quot;Y&quot; Direction=&quot;0, 180&quot; AuxiliaryConnector=&quot;N&quot;/&gt;"
data-label="Connection" data-PipingConnector="Y" data-LabelConnector="N"
data-SignalConnector="Y" data-Direction="0, 180" data-AuxiliaryConnector="N"
layer="Connection">
<ellipse cx="2" cy="0" rx="0.375" ry="0.375" fill="none" stroke="#00ff00"
vector-effect="non-scaling-stroke" />
</g>
<g id="cell-JrQDJ3AAwTKKgfP51pYv-10" content="&lt;object label=&quot;origo&quot;/&gt;"
data-label="origo" layer="Origo">
<ellipse cx="2" cy="0" rx="0.25" ry="0.25" fill="none" stroke="#ff0000"
vector-effect="non-scaling-stroke" />
</g>
</g>
</svg>
```

Name this file `PV001A_Origio.svg`.
Expand Down
158 changes: 73 additions & 85 deletions www/dexpisvgNoaka.xslt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
<xsl:text>#000000</xsl:text>
</xsl:attribute>
<xsl:attribute name="stroke-width">
<xsl:text>0.5</xsl:text>
<!-- <xsl:value-of select="Presentation/@LineWeight" /> -->
<xsl:text>0.25</xsl:text>
</xsl:attribute>
<xsl:choose>
<xsl:when test="parent::InformationFlow">
Expand Down Expand Up @@ -196,32 +197,12 @@
</xsl:if>
</xsl:template>

<!-- Template for Equipment, Nozzle, stuff-->
<xsl:template match="*">
<xsl:param name="height" />
<xsl:if
test="@ComponentName">
<use>
<xsl:attribute name="href">
<xsl:value-of select="concat('#', @ComponentName)" />
</xsl:attribute>
<xsl:call-template name="Position">
<xsl:with-param name="height" select="$height" />
<xsl:with-param name="PositionNode" select="Position" />
<xsl:with-param name="ScaleNode" select="Scale" />
</xsl:call-template>
</use>
</xsl:if>
<xsl:apply-templates>
<xsl:with-param name="height" select="$height" />
</xsl:apply-templates>
</xsl:template>

<!-- Template for * shapes except lines -->
<xsl:template match="*">
<xsl:param name="height" />
<xsl:variable name="id" select="@ID" />
<xsl:variable name="componentName" select="@ComponentName" />
<xsl:variable name="componentClass" select="@ComponentClass" />
<xsl:variable name="shapeId" select="concat($id, '-', $componentName)"/>
<xsl:variable name="label">
<xsl:choose>
Expand Down Expand Up @@ -271,6 +252,7 @@
select="$doc//svg:g/*">
<xsl:with-param name="labelParam" select="$label" />
<xsl:with-param name="idValue" select="$id" />
<xsl:with-param name="componentClass" select="$componentClass" />
</xsl:apply-templates>
</symbol>
</defs>
Expand All @@ -290,76 +272,16 @@
</xsl:if>
</xsl:template>

<!-- Shape catalogue-->
<!-- Shape catalogue, is kept empty so that no other template matches on shapecatalogue.-->
<xsl:template match="ShapeCatalogue">
<defs>
<xsl:for-each
select="*[not(self::Nozzle) and not(self::PipingComponent) and not(self::Equipment)]">
<xsl:variable name="parentName" select="name()" />
<xsl:variable
name="currentComponentName" select="@ComponentName" />
<symbol overflow="visible">
<xsl:attribute name="id">
<xsl:value-of select="@ComponentName" />
</xsl:attribute>
<xsl:attribute name="shapeName">
<xsl:value-of select="GenericAttributes/GenericAttribute/@Value" />
</xsl:attribute>
<xsl:attribute name="path">
<xsl:value-of
select="concat('../../../../NOAKADEXPI/Symbols/Origo/',GenericAttributes/GenericAttribute/@Value,'_Origo.svg')" />
</xsl:attribute>
<xsl:variable name="matchedElement"
select="//*[name() = $parentName and @ComponentName = $currentComponentName]" />
<xsl:variable name="displayNameValue">
<xsl:choose>
<!-- First try to select the 'Value' attribute of the 'GenericAttribute'
with the specific 'Name' -->
<xsl:when
test="$matchedElement/GenericAttributes/GenericAttribute[@Name='ObjectDisplayNameAssignmentClass']/@Value">
<xsl:value-of
select="$matchedElement/GenericAttributes/GenericAttribute[@Name='ObjectDisplayNameAssignmentClass']/@Value" />
</xsl:when>
<!-- Selects the text for the offpageconnectors -->
<xsl:when
test="$matchedElement/*/GenericAttributes/GenericAttribute[@Name='ReferencedDrawingNumberAssignmentClass']/@Value">
<xsl:value-of
select="$matchedElement/*/GenericAttributes/GenericAttribute[@Name='ReferencedDrawingNumberAssignmentClass']/@Value" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="$matchedElement/GenericAttributes/GenericAttribute[@Name='ItemTagAssignmentClass']/@Value" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

<xsl:variable name="IDValue" select="$matchedElement/@ID" />
<xsl:variable name="attributeValue"
select="GenericAttributes/GenericAttribute/@Value" />
<xsl:variable name="docPath"
select="concat('../../../../NOAKADEXPI/Symbols/Origo/', $attributeValue, '_Origo.svg')" />
<xsl:variable name="label"
select="GenericAttributes/GenericAttribute[@Name='ObjectDisplayNameAssignmentClass']/@Value" />
<xsl:if
test="not($docPath = '../../../../NOAKADEXPI/Symbols/Origo/BORDER_A1_Origo.svg')">
<xsl:variable name="doc" select="document($docPath)" />
<xsl:apply-templates
select="$doc//svg:g/*">
<xsl:with-param name="labelParam" select="$displayNameValue" />
<xsl:with-param name="idValue" select="$IDValue" />
</xsl:apply-templates>
</xsl:if>
<xsl:apply-templates />
</symbol>
</xsl:for-each>
</defs>
</xsl:template>

<xsl:template match="svg:text[not(preceding::svg:text)]">
<xsl:param name="labelParam" />
<xsl:param name="idValue" />
<xsl:param name="componentClass" />
<xsl:if
test="string-length($labelParam > 0)">
test="string-length($labelParam) > 0 and not(contains($componentClass, 'Nozzle'))">
<a id="{concat('https://assetid.equinor.com/plantx#', $idValue)}" class="node">
<text fill="#000000" font-family="Helvetica" font-size="40px" x="{@x - 70}"
y="{@y+15}" transform="{@transform}">
Expand Down Expand Up @@ -414,4 +336,70 @@
<xsl:copy />
</xsl:template>


<!-- Template for labels(only nozzles have labels in NOAKADEXPI) -->
<xsl:template match="Nozzle/Label">
<xsl:param name="height" />
<xsl:variable name="ID" select="../@ID" />
<xsl:variable
name="displayText"
select="following-sibling::GenericAttributes/GenericAttribute[@Name='ObjectDisplayNameAssignmentClass' or @Name='LineDescriptionAssignmentClass']/@Value" />
<xsl:if
test="$displayText">
<a id="{concat('https://assetid.equinor.com/plantx#', $ID)}" class="node">
<text>
<xsl:attribute name="x">
<xsl:value-of select="Position/Location/@X | Text/Position/Location/@X" />
JohannesETelle marked this conversation as resolved.
Show resolved Hide resolved
</xsl:attribute>
<xsl:attribute name="y">
<xsl:value-of
select="$height - (Position/Location/@Y | Text/Position/Location/@Y)" />
JohannesETelle marked this conversation as resolved.
Show resolved Hide resolved
</xsl:attribute>
<xsl:attribute name="font-size">
<xsl:value-of select="Text/@Height" />
</xsl:attribute>
<xsl:attribute name="font-family">
<xsl:value-of
select="Text/@Font" />
</xsl:attribute>
<xsl:attribute name="text-anchor">
<xsl:choose>
<xsl:when test="Text/@Justification = 'RightCenter'">
<xsl:text>End</xsl:text>
</xsl:when>
<xsl:when test="Text/@Justification = 'LeftCenter'">
<xsl:text>Start</xsl:text>
</xsl:when>
<xsl:when test="Text/@Justification = 'CenterCenter'">
<xsl:text>Middle</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>Middle</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="transform">
<xsl:variable name="refX"
select="Position/Reference/@X | Text/Position/Reference/@X" />
<xsl:variable
name="refY" select="Position/Reference/@Y | Text/Position/Reference/@Y" />
<!-- Assuming that a Reference of (1,0,0) means horizontal text, calculate
the rotation angle -->
<xsl:variable
name="posX" select="Text/Position/Location/@X" />
<xsl:variable
name="posY" select="Text/Position/Location/@Y" />
<xsl:variable
name="textRotationAngle">
<xsl:value-of select="Text/@TextAngle" />
</xsl:variable>
<xsl:value-of
select="concat('rotate(', 360 - $textRotationAngle, ' ', $posX, ' ', $height - $posY, ')')" />
</xsl:attribute>
<xsl:value-of select="$displayText" />
</text>
</a>
</xsl:if>
</xsl:template>

</xsl:stylesheet>