Example #1
0
    def open(self, filename=None):
        if filename is not None:
            self.filename = filename
        else:
            from global_vars import CAIDWorkGroupwildcard
            # Create an open file dialog
            dialog = wx.FileDialog(None\
                                   , style = wx.OPEN\
                                   , wildcard=CAIDWorkGroupwildcard)
            # Show the dialog and get user input
            if dialog.ShowModal() == wx.ID_OK:
                self.filename = dialog.GetPath()
            # The user did not select anything
            else:
                print('Nothing was selected.')
            # Destroy the dialog
            dialog.Destroy()

        from caid.cad_geometry import cad_geometry
        from caid.io import XML
        from geometry import geometry
        io = XML()

        from xml.dom.minidom import parse
        doc = parse(self.filename)
        rootElt = doc.documentElement

        # read attributs
        # get camera attributs
        eye = strtoArray(rootElt.getAttribute("eye"))
        self.viewer.lookAt.SetEye(eye)
        center = strtoArray(rootElt.getAttribute("center"))
        self.viewer.lookAt.SetCenter(center)
        up = strtoArray(rootElt.getAttribute("up"))
        self.viewer.lookAt.SetUp(up)
        # get colors attributs

        # ...
        try:
            self.viewer.theme.load(rootElt=rootElt)
        except:
            print("Theme can not be loaded. Dark theme will be used.")
            self.viewer.theme.set_theme("dark")
        # ...

        for geoElt in rootElt.getElementsByTagName("geometry"):
            geo = cad_geometry()
            io.xmltogeo(geo, doc, geoElt)
            _geo = geometry(geo)
            _geo.load_attributs()
            self.add_geometry(_geo)

        self.Refresh()

        # sets the temporary file for auto-save
        tmp = self.filename.split('/')[-1]
        basedir = self.filename.split(tmp)[0]
        self.tmp_filename = basedir + "~" + tmp
Example #2
0
    def open(self, filename=None):
        if filename is not None:
            self.filename = filename
        else:
            from global_vars import CAIDWorkGroupwildcard
            # Create an open file dialog
            dialog = wx.FileDialog(None\
                                   , style = wx.OPEN\
                                   , wildcard=CAIDWorkGroupwildcard)
            # Show the dialog and get user input
            if dialog.ShowModal() == wx.ID_OK:
                self.filename = dialog.GetPath()
            # The user did not select anything
            else:
                print('Nothing was selected.')
            # Destroy the dialog
            dialog.Destroy()

        from caid.cad_geometry import cad_geometry
        from caid.io import XML
        from geometry import geometry
        io = XML()

        from xml.dom.minidom import parse
        doc = parse(self.filename)
        rootElt = doc.documentElement

        # read attributs
        # get camera attributs
        eye = strtoArray(rootElt.getAttribute("eye"))
        self.viewer.lookAt.SetEye(eye)
        center = strtoArray(rootElt.getAttribute("center"))
        self.viewer.lookAt.SetCenter(center)
        up = strtoArray(rootElt.getAttribute("up"))
        self.viewer.lookAt.SetUp(up)
        # get colors attributs

        # ...
        try:
            self.viewer.theme.load(rootElt=rootElt)
        except:
            print("Theme can not be loaded. Dark theme will be used.")
            self.viewer.theme.set_theme("dark")
        # ...

        for geoElt in rootElt.getElementsByTagName("geometry"):
            geo = cad_geometry()
            io.xmltogeo(geo, doc, geoElt)
            _geo = geometry(geo)
            _geo.load_attributs()
            self.add_geometry(_geo)

        self.Refresh()

        # sets the temporary file for auto-save
        tmp = self.filename.split('/')[-1]
        basedir = self.filename.split(tmp)[0]
        self.tmp_filename = basedir+"~"+tmp
Example #3
0
 def load_attributs(self):
     patch = self.patch
     # color nurbs
     try:
         self._NurbsColor = strtoArray(patch.get_attribut("color-nurbs"))
     except:
         self._NurbsColor = None
Example #4
0
 def load_attributs(self):
     patch = self.patch
     # color nurbs
     try:
         self._NurbsColor = strtoArray(patch.get_attribut('color-nurbs'))
     except:
         self._NurbsColor = None
Example #5
0
    def load_attributs(self):
        # color nurbs
        self.NurbsColor = strtoArray(self.get_attribut("color-nurbs"))

        # Hide/Show geometry
        try:
            self._show = self.get_attribut("show")
            if self._show is None:
                self._show = True
        except:
            self._show = False
Example #6
0
    def load_attributs(self):
        # color nurbs
        self.NurbsColor = strtoArray(self.get_attribut('color-nurbs'))

        # Hide/Show geometry
        try:
            self._show = self.get_attribut('show')
            if self._show is None:
                self._show = True
        except:
            self._show = False
Example #7
0
    def load(self, filename=None, rootElt=None):
        """
        loads the current theme in xml format from filename if specified.
        """

        if (rootElt is None) and (filename is None):
            print("rootElt and filename can not be both None")
            raise

        if (rootElt is not None) and (filename is not None):
            print("rootElt and filename can not be both specified")
            raise

        if filename is not None:
            from xml.dom.minidom import parse
            doc = parse(filename)
            themeElt = doc.documentElement
        else:
            themeElt = rootElt.getElementsByTagName("theme")[0]


        # ...
        value = float(themeElt.getAttribute("alpha"))
        self.set_alpha(value)

        value = float(themeElt.getAttribute("beta"))
        self.set_beta(value)

        value = float(themeElt.getAttribute("alpha-background"))
        self.set_alpha_bg(value)

        txt = themeElt.getAttribute("enable-blend")
        if txt.lower() == "true":
            value = True
        if txt.lower() == "false":
            value = False
        self.set_enable_blend(value)
        # ...

        # RGB colors
        color = strtoArray(themeElt.getAttribute("color-selectedGeoMesh"))
        self.set_color_selected_geometry("mesh",color)

        color = strtoArray(themeElt.getAttribute("color-selectedGeoNurbs"))
        self.set_color_selected_geometry("nurbs",color)

        color = strtoArray(themeElt.getAttribute("color-selectedGeoPoints"))
        self.set_color_selected_geometry("points",color)

        # RGB colors
        color = strtoArray(themeElt.getAttribute("color-selectedPatchMesh"))
        self.set_color_selected_patch("mesh",color)

        color = strtoArray(themeElt.getAttribute("color-selectedPatchNurbs"))
        self.set_color_selected_patch("nurbs",color)

        color = strtoArray(themeElt.getAttribute("color-selectedPatchPoints"))
        self.set_color_selected_patch("points",color)

        # RGB colors
        color = strtoArray(themeElt.getAttribute("color-background"))
        self.set_color_viewer("background",color)

        color = strtoArray(themeElt.getAttribute("color-grid"))
        self.set_color_viewer("grid",color)

        value = float(themeElt.getAttribute("size-grid"))
        self.set_size_points("grid",value)


        color = strtoArray(themeElt.getAttribute("color-selectedPoints"))
        self.set_color_viewer("selection_points",color)

        value = float(themeElt.getAttribute("size-selectedPoints"))
        self.set_size_points("selection_points",value)


        color = strtoArray(themeElt.getAttribute("color-markerPoints"))
        self.set_color_viewer("marker_points",color)

        value = float(themeElt.getAttribute("size-markerPoints"))
        self.set_size_points("marker_points",value)


        color = strtoArray(themeElt.getAttribute("color-default_geometry"))
        self.set_color_viewer("default_geometry",color)

        color = strtoArray(themeElt.getAttribute("color-default_patch"))
        self.set_color_viewer("default_patch",color)

        color = strtoArray(themeElt.getAttribute("color-default_mesh"))
        self.set_color_viewer("default_mesh",color)

        color = strtoArray(themeElt.getAttribute("color-default_points"))
        self.set_color_viewer("default_points",color)

        color = strtoArray(themeElt.getAttribute("color-selection"))
        self.set_color_viewer("selection",color)


        value = float(themeElt.getAttribute("size-geometryPoints"))
        self.set_size_points("geometry",value)

        value = float(themeElt.getAttribute("size-patchPoints"))
        self.set_size_points("patch",value)