Exemple #1
0
    def testFABasicNoPlot(self):

        f = vcs.createfillarea()
        self.assertTrue(vcs.queries.isfillarea(f))

        self.check_values_setting(
            f, "style", [f, 0, 1, 2, 3, "hatch", "pattern", "hallow"],
            [-1, 4, "foo", [], {}, (), None])
        self.check_values_setting(f, "index", [
            None,
            f,
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
        ], [0, 21, "foo", [], (), {}])
        self.check_values_setting(f, "color", range(256))
        self.check_values_setting(
            f, "color",
            [f, "red", [2, 3, 4], [
                [2, 3, 4],
            ], [
                [1, 2, 3, 5],
            ], None], [-1, 256, [
                [2, 3, 4, 6, 5],
            ]])
        self.check_values_setting(f, ["x", "y"], [
            None,
            [1, 2, 3],
        ], [1, "sdf", [1, 2, "3"], [[1, 2, 3], 2]])
        b = vcs.createfillarea("self.check_f_ok", f.name)
        self.assertEqual(b.name, "self.check_f_ok")
        self.assertEqual(b.style, [
            "hallow",
        ])
        self.assertEqual(b.index, [
            20,
        ])
        self.assertEqual(b.color, [[0., 0., 0., 100.]])
        self.assertEqual(f.x, [1, 2, 3])
        self.assertEqual(f.y, [1, 2, 3])
Exemple #2
0
 def setFillObject(self, fillobject):
     self.fillobj = fillobject
     tmpobj = vcs.createfillarea(source=self.fillobj)
     tmpobj.x = [.25, .25, .75, .75]
     tmpobj.y = [.25, .75, .75, .25]
     self.clear()
     self.plot(tmpobj)
def test_preview():

    prev = FillPreviewWidget()
    fill = vcs.createfillarea()
    prev.setFillObject(fill)
    assert prev.fillobj == fill

    fill.style = "hatch"
    prev.update()

    assert prev.fillobj.style == ["hatch"]
Exemple #4
0
def test_preview():

    prev = FillPreview.FillPreviewWidget()
    fill = vcs.createfillarea()
    prev.setFillObject(fill)
    assert prev.fillobj == fill

    fill.style = "hatch"
    prev.update()

    assert prev.fillobj.style == ["hatch"]
Exemple #5
0
    def testVCSreset1only(self):
        for gtype in vcs.listelements():
            b0 = vcs.listelements(gtype)
            if gtype == 'colormap':
                b = vcs.createcolormap()
                xtra = vcs.createisofill()
                untouched = vcs.listelements("isofill")
            elif gtype == "template":
                b = vcs.createtemplate()
            elif gtype == "textcombined":
                b = vcs.createtextcombined()
            elif gtype == "textorientation":
                b = vcs.createtextorientation()
            elif gtype == "texttable":
                b = vcs.createtexttable()
            elif gtype == "fillarea":
                b = vcs.createfillarea()
            elif gtype == "projection":
                b = vcs.createprojection()
            elif gtype == "marker":
                b = vcs.createmarker()
            elif gtype == "line":
                b = vcs.createline()
            elif gtype in ["display", "font", "fontNumber", "list", "format"]:
                vcs.manageElements.reset()
                continue
            else:
                b = vcs.creategraphicsmethod(gtype)
            if gtype != "colormap":
                xtra = vcs.createcolormap()
                untouched = vcs.listelements("colormap")
            b1 = vcs.listelements(gtype)
            self.assertNotEqual(b0, b1)
            vcs.manageElements.reset(gtype)
            b2 = vcs.listelements(gtype)
            self.assertEqual(b0, b2)
            if gtype == "colormap":
                self.assertEqual(untouched, vcs.listelements("isofill"))
            else:
                self.assertEqual(untouched, vcs.listelements("colormap"))
            vcs.manageElements.reset()
            if gtype == "colormap":
                self.assertNotEqual(untouched, vcs.listelements("isofill"))
            else:
                self.assertNotEqual(untouched, vcs.listelements("colormap"))

        # case for 1d weirdness
        sc = vcs.createscatter()
        vcs.manageElements.reset()
Exemple #6
0
import vcs,numpy,os,sys
src=sys.argv[1]
if os.path.exists("test_vcs_dump_json.json"):
    os.remove("test_vcs_dump_json.json")

b = vcs.createboxfill("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createisofill("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createisoline("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createmeshfill("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createoneD("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createfillarea("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createtext("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createline("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createmarker("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createtemplate("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")
b = vcs.createprojection("Charles.Doutriaux")
b.script("test_vcs_dump_json","a")

assert(filecmp.cmp("test_vcs_dump_json.json",src))

import vcs
import sys
import os

baseline = sys.argv[1]

pth = os.path.join(os.path.dirname(__file__), "..")
sys.path.append(pth)
import checkimage

canvas = vcs.init()
canvas.setantialiasing(0)
canvas.setbgoutputdimensions(792, 611, units="pixels")
canvas.drawlogooff()

fillarea = vcs.createfillarea()
fillarea.x = [[0, .33, .33, 0], [.33, .67, .67, .33], [.67, 1, 1, .67]]
fillarea.y = [[0, 0, 1, 1]] * 3
fillarea.style = ["solid", "pattern", "hatch"]
fillarea.index = [1, 5, 5]
fillarea.color = [50, 50, 50]

canvas.plot(fillarea, bg=1)

testImage = os.path.abspath("test_vcs_large_pattern_hatch.png")
canvas.png(testImage)

ret = checkimage.check_result_image(testImage, baseline,
                                    checkimage.defaultThreshold)

sys.exit(ret)
Exemple #8
0
def editor():
    editor = FillAreaEditor.FillAreaEditorWidget()
    fill = vcs.createfillarea()
    editor.setFillObject(fill)
    return editor
Exemple #9
0

# draw line around the cnavas
ln = vcs.createline()
ln.width = 6
ln.x = [0, 1, 1, 0, 0]
ln.y = [0, 0, 1, 1, 0]
canvas.plot(ln)

# Viewport coordinates
text("[0,0] [Canvas Bottom/Left Viewport Origin]", 0.01, 0.01, "left",
     "bottom")
text("[Canvas Top/Right Viewport Origin] [1, 1]", 0.99, .99, "right", "top")

# create the "viewport" area section
fa = vcs.createfillarea()
fa.x = [vp[0], vp[1], vp[1], vp[0]]
fa.y = [vp[2], vp[2], vp[3], vp[3]]
fa.color = "lightgrey"
canvas.plot(fa)

# Viewport Coordinates
text("[.2,.2] [Object Bottom/Left Viewport]", 0.2, 0.2, "right", "top")
text("[Object Top/Right Viewport] [.8, .8]", 0.8, .8, "left", "bottom")
# World Coordinates
text("(-180., -90.) [Object Bottom/Left World]",
     0.2,
     0.2,
     "left",
     "bottom",
     color="red")
def editor():
    editor = FillAreaEditor.FillAreaEditorWidget()
    fill = vcs.createfillarea()
    editor.setFillObject(fill)
    return editor
Exemple #11
0
t_dud.data.priority = 1

templates = [t] + [t_dud] * (len(variables) - 1)
colors = [
    "#D00000", "#E1CA96", "#3EC300", "#B7FDFE", "#14213D", "#8E5572",
    "#F5BB00", "#694873"
]
rgbs = []
for c in colors:
    r = int(c[1:3], 16) / 2.56
    g = int(c[3:5], 16) / 2.56
    b = int(c[5:], 16) / 2.56
    rgbs.append([r, g, b])
colors = rgbs[:len(variables)]

legend = vcs.createfillarea()
legend.x = []
legend.y = []
legend.color = []
legend.viewport = [.1, .9, .05, t.xlabel1.y - .05]

legend_labels = vcs.createtext()
legend_labels.x = []
legend_labels.y = []
legend_labels.string = []
legend_labels.valign = "top"
legend_labels.halign = "center"
legend_labels.color = "black"
legend_labels.viewport = legend.viewport
oned.markersize = 5
for i, c, v, t in zip(range(len(variables)), colors, variables, templates):
Exemple #12
0
import vcs, numpy, os, sys
src = sys.argv[1]
if os.path.exists("test_vcs_dump_json.json"):
    os.remove("test_vcs_dump_json.json")

b = vcs.createboxfill("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createisofill("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createisoline("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createmeshfill("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.create1d("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createfillarea("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createvector("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createtext("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createline("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createmarker("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createtemplate("vcs_instance")
b.script("test_vcs_dump_json", "a")
b = vcs.createprojection("vcs_instance")
b.script("test_vcs_dump_json", "a")

print "Comparing:", os.path.realpath("test_vcs_dump_json.json"), src
Exemple #13
0
import vcs, os, filecmp
import vcs, numpy, os, sys
src = sys.argv[1]
if os.path.exists("test_vcs_dump_json.json"):
    os.remove("test_vcs_dump_json.json")

b = vcs.createboxfill("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createisofill("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createisoline("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createmeshfill("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createoneD("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createfillarea("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createtext("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createline("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createmarker("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createtemplate("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")
b = vcs.createprojection("Charles.Doutriaux")
b.script("test_vcs_dump_json", "a")

assert (filecmp.cmp("test_vcs_dump_json.json", src))
import vcs,numpy,os,sys
src = sys.argv[1]
if os.path.exists("test_vcs_dump_json.json"):
    os.remove("test_vcs_dump_json.json")

b = vcs.createboxfill("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createisofill("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createisoline("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createmeshfill("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.create1d("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createfillarea("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createvector("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createtext("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createline("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createmarker("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createtemplate("vcs_instance")
b.script("test_vcs_dump_json","a")
b = vcs.createprojection("vcs_instance")
b.script("test_vcs_dump_json","a")

assert(filecmp.cmp("test_vcs_dump_json.json", src))
Exemple #15
0
import vcs, cdms2

x = vcs.init()
fa = vcs.createfillarea()
fa.x = [[0.1, 0.15, 0.1], [0.2, 0.25, 0.2], [0.3, 0.35, 0.3]]
fa.y = [[0.2, 0.15, 0.1], [0.2, 0.15, 0.1], [0.2, 0.15, 0.1]]
fa.style = ["solid", "pattern", "hatch"]
fa.color = [20, 40, 60]
fa.index = [1, 5, 10]
x.plot(fa)

pattern = vcs.createfillarea()
pattern.x = [[0.2, 0.25, 0.2]]
pattern.y = [[0.3, 0.25, 0.2]]
pattern.style = "pattern"
pattern.color = [40]
pattern.index = [5]
x.plot(pattern)


hatch = vcs.createfillarea()
hatch.x = [[0.3, 0.35, 0.3]]
hatch.y = [[0.3, 0.25, 0.2]]
hatch.style = "hatch"
hatch.color = 60
hatch.index = 10
x.plot(hatch)

raw_input("Enter")