Exemple #1
0
    def save(self, filename):
        # ... create xml doc
        from xml.dom.minidom import Document
        # Create the minidom document
        doc = Document()
        # Create the <caid> base element
        rootElt = doc.createElement("field")
        # set camera attributs
    #    eye = self.viewer.lookAt.GetEye()
    #    rootElt.setAttribute("eye", str(eye))

        doc.appendChild(rootElt)
        from caid.io import XML
        io = XML()
        # ... geometry
        geoElt = doc.createElement("geometry")
        geo = self.geometry
        doc = io.geotoxml(geo, doc, geoElt)
        rootElt.appendChild(geoElt)
        # ... geometry
        valuesElt = doc.createElement("values")
        values = self.values
        doc = io.geotoxml(values, doc, valuesElt)
        rootElt.appendChild(valuesElt)

        if filename is not None:
            f = open(filename, 'wr')
            s = doc.toprettyxml()
            f.write(s)
            f.close()
        else:
            print("No file was specified")
Exemple #2
0
    def save(self, filename):
        # ... create xml doc
        from xml.dom.minidom import Document
        # Create the minidom document
        doc = Document()
        # Create the <caid> base element
        rootElt = doc.createElement("field")
        # set camera attributs
        #    eye = self.viewer.lookAt.GetEye()
        #    rootElt.setAttribute("eye", str(eye))

        doc.appendChild(rootElt)
        from caid.io import XML
        io = XML()
        # ... geometry
        geoElt = doc.createElement("geometry")
        geo = self.geometry
        doc = io.geotoxml(geo, doc, geoElt)
        rootElt.appendChild(geoElt)
        # ... geometry
        valuesElt = doc.createElement("values")
        values = self.values
        doc = io.geotoxml(values, doc, valuesElt)
        rootElt.appendChild(valuesElt)

        if filename is not None:
            f = open(filename, 'wr')
            s = doc.toprettyxml()
            f.write(s)
            f.close()
        else:
            print("No file was specified")
Exemple #3
0
    def save(self, filename=None):
        if filename is None:
            filename = self.filename
        # this means that self.filename is also None
        if filename is None:
            # Create a save file dialog
            from global_vars import CAIDWorkGroupwildcard
            dialog = wx.FileDialog ( None\
                                    , style = wx.SAVE | wx.OVERWRITE_PROMPT\
                                    , wildcard=CAIDWorkGroupwildcard)
            # Show the dialog and get user input
            if dialog.ShowModal() == wx.ID_OK:
                filename = dialog.GetPath()
                self.filename = filename
            # The user did not select anything
            else:
                print('Nothing was selected.')
            # Destroy the dialog
            dialog.Destroy()

        # ... create xml doc
        from xml.dom.minidom import Document
        # Create the minidom document
        doc = Document()
        # Create the <theme> base element
        rootElt = self.viewer.theme.save(doc=doc)

        # Create the <caid> base element
        rootElt = doc.createElement("caid")
        # set camera attributs
        eye = self.viewer.lookAt.GetEye()
        rootElt.setAttribute("eye", str(eye))
        center = self.viewer.lookAt.GetCenter()
        rootElt.setAttribute("center", str(center))
        up = self.viewer.lookAt.GetUp()
        rootElt.setAttribute("up", str(up))

        doc.appendChild(rootElt)
        # ...

        # ...
        themeElt, doc = self.viewer.theme.save(doc=doc)
        rootElt.appendChild(themeElt)
        # ...

        # ...
        from caid.io import XML
        io = XML()
        for geo in self.list_geo:
            geo.save_attributs()
            geoElt = doc.createElement("geometry")
            doc = io.geotoxml(geo, doc, geoElt)
            rootElt.appendChild(geoElt)
        # ...

        if filename is not None:
            with open(filename, 'w') as f:
                f.write(doc.toprettyxml())
        else:
            print("No file was specified")
Exemple #4
0
    def save(self, filename=None):
        if filename is None:
            filename = self.filename
        # this means that self.filename is also None
        if filename is None:
            # Create a save file dialog
            from global_vars import CAIDWorkGroupwildcard
            dialog = wx.FileDialog ( None\
                                    , style = wx.SAVE | wx.OVERWRITE_PROMPT\
                                    , wildcard=CAIDWorkGroupwildcard)
            # Show the dialog and get user input
            if dialog.ShowModal() == wx.ID_OK:
                filename = dialog.GetPath()
                self.filename = filename
            # The user did not select anything
            else:
                print('Nothing was selected.')
            # Destroy the dialog
            dialog.Destroy()

        # ... create xml doc
        from xml.dom.minidom import Document
        # Create the minidom document
        doc = Document()
        # Create the <theme> base element
        rootElt = self.viewer.theme.save(doc=doc)

        # Create the <caid> base element
        rootElt = doc.createElement("caid")
        # set camera attributs
        eye = self.viewer.lookAt.GetEye()
        rootElt.setAttribute("eye", str(eye))
        center = self.viewer.lookAt.GetCenter()
        rootElt.setAttribute("center", str(center))
        up = self.viewer.lookAt.GetUp()
        rootElt.setAttribute("up", str(up))

        doc.appendChild(rootElt)
        # ...

        # ...
        themeElt, doc = self.viewer.theme.save(doc=doc)
        rootElt.appendChild(themeElt)
        # ...

        # ...
        from caid.io import XML
        io = XML()
        for geo in self.list_geo:
            geo.save_attributs()
            geoElt = doc.createElement("geometry")
            doc = io.geotoxml(geo, doc, geoElt)
            rootElt.appendChild(geoElt)
        # ...

        if filename is not None:
            with open( filename, 'w' ) as f:
                f.write( doc.toprettyxml() )
        else:
            print("No file was specified")