示例#1
0
 def plot(self, xS, theTl, theWsdS=None):
     """Write the header to the SVG stream at position offset top left.
     theWsd is a list of records that contain well site data.
     Will raise ExceptionLogHeader is wrong type of Logical Record."""
     self._checkWsd(theWsdS)
     #        self._traceTopLeftAndViewBox(theTl, xS)
     groupAttrs = {
         'transform':
         "translate({:g},{:g})".format(
             theTl.x.value * TRANSFORM_UNITS_PER_PLOT_UNITS,
             theTl.y.value * TRANSFORM_UNITS_PER_PLOT_UNITS,
         ),
     }
     with SVGWriter.SVGGroup(xS, groupAttrs):
         if self._isTopOfLog:
             # Make this all one group so it can be rotated etc.
             groupAttrs = {
                 'transform':
                 "translate({:g},0) rotate(90)".format(
                     self._width().value *
                     TRANSFORM_UNITS_PER_PLOT_UNITS, ),
             }
             with SVGWriter.SVGGroup(xS, groupAttrs):
                 self._plot(xS, theWsdS)
         else:
             self._plot(xS, theWsdS)
示例#2
0
 def _plotWsd(self, xS, theWsdS):
     """Plot dynamic information from well site data."""
     if theWsdS is not None and len(theWsdS) > 0:
         for st in STATICS:
             self._plotStaticIfCONS(xS, theWsdS, st)
         for (x, y, r), stS in STATICS_VERT:
             if any([st.mnem is not None for st in stS]):
                 with SVGWriter.SVGGroup(xS,
                                         self._uprightGroupAttrs(x, y, r)):
                     for st in stS:
                         self._plotStaticIfCONS(xS, theWsdS, st)
示例#3
0
 def _plot(self, xS, theWsdS):
     # Write background
     self._plotBackGround(xS)
     # Page 1 bounding box
     with SVGWriter.SVGRect(xS, self._ptZero(), self._size(False), {
             'fill': "none",
             'stroke': "blue",
             'stroke-width': ".5",
     }):
         pass
     # Write statics
     for st in STATICS:
         self._plotStatic(xS, st)
     for (x, y, r), stS in STATICS_VERT:
         with SVGWriter.SVGGroup(xS, self._uprightGroupAttrs(x, y, r)):
             for st in stS:
                 self._plotStatic(xS, st)
     self._plotWsd(xS, theWsdS)
示例#4
0
    def test_04(self):
        """TestSVGlWriter.test_04(): a line.
        Based on http://www.w3.org/TR/2003/REC-SVG11-20030114/shapes.html#LineElement"""
        myF = io.StringIO()
        myViewPort = Coord.Box(
            Coord.Dim(12, 'cm'),
            Coord.Dim(4, 'cm'),
        )
        with SVGWriter.SVGWriter(myF, myViewPort) as xS:
            with XmlWrite.Element(xS, 'desc'):
                xS.characters(
                    'Example line01 - lines expressed in user coordinates')
            #xS.comment(" Show outline of canvas using 'rect' element ")
            myPt = Coord.Pt(Coord.baseUnitsDim(1), Coord.baseUnitsDim(1))
            myBx = Coord.Box(Coord.baseUnitsDim(1198), Coord.baseUnitsDim(398))
            with SVGWriter.SVGRect(xS, myPt, myBx, {
                    'fill': "none",
                    'stroke': "blue",
                    'stroke-width': "2"
            }):
                pass
            # Make a group
            with SVGWriter.SVGGroup(xS, {'stroke': 'green'}):
                with SVGWriter.SVGLine(
                        xS,
                        Coord.Pt(Coord.baseUnitsDim(100),
                                 Coord.baseUnitsDim(300)),
                        Coord.Pt(Coord.baseUnitsDim(300),
                                 Coord.baseUnitsDim(100)),
                    {'stroke-width': "5"}):
                    pass
                with SVGWriter.SVGLine(
                        xS,
                        Coord.Pt(Coord.baseUnitsDim(300),
                                 Coord.baseUnitsDim(300)),
                        Coord.Pt(Coord.baseUnitsDim(500),
                                 Coord.baseUnitsDim(100)),
                    {'stroke-width': "10"}):
                    pass
                with SVGWriter.SVGLine(
                        xS,
                        Coord.Pt(Coord.baseUnitsDim(500),
                                 Coord.baseUnitsDim(300)),
                        Coord.Pt(Coord.baseUnitsDim(700),
                                 Coord.baseUnitsDim(100)),
                    {'stroke-width': "15"}):
                    pass
                with SVGWriter.SVGLine(
                        xS,
                        Coord.Pt(Coord.baseUnitsDim(700),
                                 Coord.baseUnitsDim(300)),
                        Coord.Pt(Coord.baseUnitsDim(900),
                                 Coord.baseUnitsDim(100)),
                    {'stroke-width': "20"}):
                    pass
                with SVGWriter.SVGLine(
                        xS,
                        Coord.Pt(Coord.baseUnitsDim(900),
                                 Coord.baseUnitsDim(300)),
                        Coord.Pt(Coord.baseUnitsDim(1100),
                                 Coord.baseUnitsDim(100)),
                    {'stroke-width': "25"}):
                    pass
        # print()
        # print(myF.getvalue())
#        self.maxDiff = None
        self.assertEqual(
            """<?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 height="4.000cm" version="1.1" width="12.000cm" xmlns="http://www.w3.org/2000/svg">
  <desc>Example line01 - lines expressed in user coordinates</desc>
  <rect fill="none" height="398.000px" stroke="blue" stroke-width="2" width="1198.000px" x="1.000px" y="1.000px"/>
  <g stroke="green">
    <line stroke-width="5" x1="100.000px" x2="300.000px" y1="300.000px" y2="100.000px"/>
    <line stroke-width="10" x1="300.000px" x2="500.000px" y1="300.000px" y2="100.000px"/>
    <line stroke-width="15" x1="500.000px" x2="700.000px" y1="300.000px" y2="100.000px"/>
    <line stroke-width="20" x1="700.000px" x2="900.000px" y1="300.000px" y2="100.000px"/>
    <line stroke-width="25" x1="900.000px" x2="1100.000px" y1="300.000px" y2="100.000px"/>
  </g>
</svg>
""", myF.getvalue())