def __init__(self, parent=None):
        super(ObjectWidget, self).__init__(parent)

        l_nbr_steps = QtGui.QLabel("Nbr Steps ")
        self.nbr_steps = QtGui.QSpinBox()
        self.nbr_steps.setMinimum(3)
        self.nbr_steps.setMaximum(100)
        self.nbr_steps.setValue(6)
        self.nbr_steps.valueChanged.connect(self.update_param)

        l_cmap = QtGui.QLabel("Cmap ")
        self.cmap = list(get_colormaps().keys())
        self.combo = QtGui.QComboBox(self)
        self.combo.addItems(self.cmap)
        self.combo.currentIndexChanged.connect(self.update_param)

        gbox = QtGui.QGridLayout()
        gbox.addWidget(l_cmap, 0, 0)
        gbox.addWidget(self.combo, 0, 1)
        gbox.addWidget(l_nbr_steps, 1, 0)
        gbox.addWidget(self.nbr_steps, 1, 1)

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(gbox)
        vbox.addStretch(1.0)

        self.setLayout(vbox)
Esempio n. 2
0
    def __init__(self, parent=None):
        super(ObjectWidget, self).__init__(parent)

        l_nbr_steps = QtGui.QLabel("Nbr Steps ")
        self.nbr_steps = QtGui.QSpinBox()
        self.nbr_steps.setMinimum(3)
        self.nbr_steps.setMaximum(100)
        self.nbr_steps.setValue(6)
        self.nbr_steps.valueChanged.connect(self.update_param)

        l_cmap = QtGui.QLabel("Cmap ")
        self.cmap = list(get_colormaps().keys())
        self.combo = QtGui.QComboBox(self)
        self.combo.addItems(self.cmap)
        self.combo.currentIndexChanged.connect(self.update_param)

        gbox = QtGui.QGridLayout()
        gbox.addWidget(l_cmap, 0, 0)
        gbox.addWidget(self.combo, 0, 1)
        gbox.addWidget(l_nbr_steps, 1, 0)
        gbox.addWidget(self.nbr_steps, 1, 1)

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(gbox)
        vbox.addStretch(1.0)

        self.setLayout(vbox)
Esempio n. 3
0
    def __init__(self, parent=None, param=None):
        super(SphereWidget, self).__init__(parent)

        if param is None:
            self.param = SphereParam()
        else:
            self.param = param

        gbC_lay = QVBoxLayout()

        l_cmap = QLabel("Cmap ")
        self.cmap = list(get_colormaps().keys())
        self.combo = QComboBox(self)
        self.combo.addItems(self.cmap)
        self.combo.currentIndexChanged.connect(self.updateParam)
        self.param.dict["colormap"] = self.cmap[0]
        hbox = QHBoxLayout()
        hbox.addWidget(l_cmap)
        hbox.addWidget(self.combo)
        gbC_lay.addLayout(hbox)

        self.sp = []
        # subdiv
        lL = QLabel("subdiv")
        self.sp.append(QSpinBox())
        self.sp[-1].setMinimum(0)
        self.sp[-1].setMaximum(6)
        self.sp[-1].setValue(self.param.dict["subdiv"])
        # Layout
        hbox = QHBoxLayout()
        hbox.addWidget(lL)
        hbox.addWidget(self.sp[-1])
        gbC_lay.addLayout(hbox)
        # signal's
        self.sp[-1].valueChanged.connect(self.updateParam)
        # Banded
        self.gbBand = QGroupBox(u"Banded")
        self.gbBand.setCheckable(True)
        hbox = QGridLayout()
        lL = QLabel("nbr band", self.gbBand)
        self.sp.append(QSpinBox(self.gbBand))
        self.sp[-1].setMinimum(0)
        self.sp[-1].setMaximum(100)
        # Layout
        hbox = QHBoxLayout()
        hbox.addWidget(lL)
        hbox.addWidget(self.sp[-1])
        self.gbBand.setLayout(hbox)
        gbC_lay.addWidget(self.gbBand)
        # signal's
        self.sp[-1].valueChanged.connect(self.updateParam)
        self.gbBand.toggled.connect(self.updateParam)

        gbC_lay.addStretch(1.0)

        hbox = QHBoxLayout()
        hbox.addLayout(gbC_lay)

        self.setLayout(hbox)
        self.updateMenu()
Esempio n. 4
0
class Image(Layer):
    """Image layer.

    Parameters
    ----------
    image : np.ndarray
        Image data.
    meta : dict
        Image metadata.
    """
    _colormaps = get_colormaps()

    default_cmap = 'hot'
    default_interpolation = 'nearest'

    def __init__(self, image, meta):
        visual = ImageNode(None, method='auto')
        super().__init__(visual)

        self._image = image
        self._meta = meta
        self.cmap = Image.default_cmap
        self.interpolation = Image.default_interpolation

        # update flags
        self._need_display_update = False
        self._need_visual_update = False

    @property
    def image(self):
        """np.ndarray: Image data.
        """
        return self._image

    @image.setter
    def image(self, image):
        self._image = image

        self.refresh()

    @property
    def meta(self):
        """dict: Image metadata.
        """
        return self._meta

    @meta.setter
    def meta(self, meta):
        self._meta = meta

        self.refresh()

    @property
    def data(self):
        """tuple of np.ndarray, dict: Image data and metadata.
        """
        return self.image, self.meta

    @data.setter
    def data(self, data):
        self._image, self._meta = data
        self.refresh()

    def _get_shape(self):
        if self.multichannel:
            return self.image.shape[:-1]
        return self.image.shape

    def _update(self):
        """Update the underlying visual.
        """
        if self._need_display_update:
            self._need_display_update = False

            self.viewer._child_layer_changed = True
            self.viewer._update()

            self._node._need_colortransform_update = True
            self._set_view_slice(self.viewer.indices)

        if self._need_visual_update:
            self._need_visual_update = False
            self._node.update()

    def _refresh(self):
        """Fully refresh the underlying visual.
        """
        self._need_display_update = True
        self._update()

    def _set_view_slice(self, indices):
        """Sets the view given the indices to slice with.

        Parameters
        ----------
        indices : sequence of int or slice
            Indices to slice with.
        """
        ndim = self.ndim

        indices = list(indices)
        indices = indices[:ndim]

        for dim in range(len(indices)):
            max_dim_index = self.image.shape[dim] - 1

            try:
                if indices[dim] > max_dim_index:
                    indices[dim] = max_dim_index
            except TypeError:
                pass

        sliced_image = self.image[tuple(indices)]

        self._node.set_data(sliced_image)

        self._need_visual_update = True
        self._update()

    @property
    def multichannel(self):
        """bool: Whether the image is multichannel.
        """
        return is_multichannel(self.meta)

    @multichannel.setter
    def multichannel(self, val):
        if val == self.multichannel:
            return

        self.meta['itype'] = 'multi'

        self._need_display_update = True
        self._update()

    @property
    def interpolation_index(self):
        """int: Index of the current interpolation method equipped.
        """
        return self._interpolation_index

    @interpolation_index.setter
    def interpolation_index(self, interpolation_index):
        intp_index = interpolation_index % len(interpolation_names)
        self._interpolation_index = intp_index
        self._node.interpolation = _index_to_name(intp_index)

    @property
    def colormap(self):
        """string or ColorMap: Colormap to use for luminance images.
        """
        return self.cmap

    @colormap.setter
    def colormap(self, colormap):
        self.cmap = colormap

    @property
    def colormaps(self):
        """tuple of str: Colormap names.
        """
        # TODO: achieve this by wrapping DictKeys
        return tuple(self._colormaps.keys())

    # wrap visual properties:

    @property
    def clim(self):
        """string or tuple of float: Limits to use for the colormap.
        Can be 'auto' to auto-set bounds to the min and max of the data.
        """
        return self._node.clim

    @clim.setter
    def clim(self, clim):
        self._node.clim = clim

    @property
    def cmap(self):
        """string or ColorMap: Colormap to use for luminance images.
        """
        return self._node.cmap

        for name, obj in Image._colormaps.items():
            if obj == cmap:
                return name
        else:
            return cmap

    @cmap.setter
    def cmap(self, cmap):
        try:
            cmap = Image._colormaps[cmap]
        except KeyError:
            pass

        self._node.cmap = cmap

    @property
    def method(self):
        """string: Selects method of rendering image in case of non-linear
        transforms. Each method produces similar results, but may trade
        efficiency and accuracy. If the transform is linear, this parameter
        is ignored and a single quad is drawn around the area of the image.

            * 'auto': Automatically select 'impostor' if the image is drawn
              with a nonlinear transform; otherwise select 'subdivide'.
            * 'subdivide': ImageVisual is represented as a grid of triangles
              with texture coordinates linearly mapped.
            * 'impostor': ImageVisual is represented as a quad covering the
              entire view, with texture coordinates determined by the
              transform. This produces the best transformation results, but may
              be slow.
        """
        return self._node.method

    @method.setter
    def method(self):
        self._node.method = method

    @property
    def interpolation(self):
        """string: Equipped interpolation method's name.
        """
        return _index_to_name(self.interpolation_index)

    @interpolation.setter
    def interpolation(self, interpolation):
        self.interpolation_index = _name_to_index(interpolation)

    @property
    def interpolation_functions(self):
        return tuple(interpolation_names)
Esempio n. 5
0
    def __init__(self, project, iface=None, data=None, mins=None, maxes=None, linelayer=None, aoi=None, trafo=None):
        Scatter3D = scene.visuals.create_visual_node(visuals.MarkersVisual)
        Line3D = scene.visuals.create_visual_node(visuals.LineVisual)
        self.widg = QtWidgets.QWidget()
        self.canvas = scene.SceneCanvas(bgcolor=(1,1,1), parent=self.widg, resizable=True)
        #self.canvas.events.mouse_press.connect(self.canvasClicked)
        self.view = self.canvas.central_widget.add_view()
        self.view.camera = 'turntable'  # or try 'turntable', 'arcball'

        self.view.camera.fov = 45
        self.view.camera.pan_factor = 1000
        self.view.padding = 10

        self.p1 = Scatter3D(parent=self.view.scene)
        self.p1.picking = True
        self.p1.interactive = True
        self.l1 = Line3D(parent=self.view.scene, method='gl')
        self.l1.antialias = True
        self.p1.antialias = True
        self.p1.set_gl_state('translucent', blend=True, depth_test=True, blend_func=('src_alpha', 'one_minus_src_alpha'))

        self.project = project
        self.iface = iface
        self.data = data
        self.mins = mins
        self.maxes = maxes
        for coord in ['X', 'Y', 'Z']:
            self.mins[coord] = np.min(self.data[coord])
            self.maxes[coord] = np.max(self.data[coord])
        self.lines = None
        if linelayer and trafo:
            avgZ = np.mean(self.data['Z'])
            X1 = trafo[0].GetPoint(0)[0]
            Y1 = trafo[0].GetPoint(0)[1]
            transX = -X1
            transY = -Y1
            X2 = trafo[0].GetPoint(1)[0]
            Y2 = trafo[0].GetPoint(1)[1]
            phi = np.arctan2((Y2 - Y1), (X2 - X1))
            rot = np.array([[np.cos(phi), np.sin(phi)], [-np.sin(phi), np.cos(phi)]])
            x2 = trafo[1].GetPoint(0)[0]
            y2 = trafo[1].GetPoint(0)[1]
            self.lines = []
            self.connections = []
            nodecount = 0
            aoirect = QgsGeometry()
            aoirect.fromWkb(aoi.ExportToWkb())
            aoirect = aoirect.boundingBox()
            req = QgsFeatureRequest(aoirect)
            for feat in linelayer.getFeatures(req):
                geom = feat.geometry()
                wkb = geom.asWkb().data()
                ogeom = ogr.CreateGeometryFromWkb(wkb)
                usegeom = ogeom.Intersection(aoi.Buffer(2))
                if not usegeom:
                    print(ogeom.Intersection(aoi))
                    continue
                linelist = []
                if usegeom.GetGeometryType() in [ogr.wkbMultiLineString, ogr.wkbMultiLineString25D]:
                    for lineId in range(usegeom.GetGeometryCount()):
                        linelist.append(usegeom.GetGeometryRef(lineId))
                else:
                    linelist = [usegeom]

                for line in linelist:
                    for i in range(line.GetPointCount()):
                        pi = line.GetPoint(i)
                        xi = pi[0]
                        yi = pi[1]
                        zi = pi[2] if len(pi) > 2 else 0
                        p_loc = np.dot(rot, (np.array([xi, yi]).T + np.array([transX, transY]).T)) + np.array(
                            [x2, y2]).T
                        x_loc = p_loc[0]
                        y_loc = p_loc[1]
                        self.lines.append([x_loc, y_loc, zi])
                        self.connections.append([nodecount, nodecount + 1])
                        nodecount += 1
                    if self.connections:
                        self.connections.pop()
            self.lines = np.array(self.lines)
        self.ui = self.getUI()

        self.CM = None
        for cm_name in sorted(colormap.get_colormaps()):
            if not self.CM:
                self.CM = colormap.get_colormap(cm_name)
            self.CMbox.addItem(cm_name)
        self.CMbox.addItem('classes')
        self.CMbox.currentIndexChanged.connect(self.cmChanged)

        self.markerBox.addItems(["disc", "arrow", "ring", "clobber", "square", "diamond",
                                 "vbar", "hbar", "cross", "tailed_arrow",
                                 "x", "triangle_up", "triangle_down", "star"])
        self.markerBox.setCurrentIndex(0)
        self.markerBox.currentIndexChanged.connect(self.draw_new_plot)

        self.attrBox.addItems(sorted([m for m in self.data]))
        self.attrBox.currentIndexChanged.connect(self.attrChanged)
        self.attrBox.setCurrentIndex(self.attrBox.count()-1)
Esempio n. 6
0
    def __init__(self, parent=None):
        super(PropertiesWidget, self).__init__(parent)

        l_cmap = QtGui.QLabel("Colormap")
        self.cmap = list(get_colormaps().keys())
        #print(self.cmap)
        self.combo = QtGui.QComboBox(self)
        self.combo.addItems(self.cmap)
        self.combo.setCurrentIndex(self.combo.count() - 1)
        self.combo.currentIndexChanged.connect(self.update_param)

        self.curCheckBox = QtGui.QCheckBox()
        self.curCheckBox.stateChanged.connect(self.toggleCursor)
        self.curSelectLabel = QtGui.QLabel("Cursor Activation", self)

        # HLine
        self.hline0 = QtGui.QFrame()
        self.hline0.setFrameShape(QtGui.QFrame.HLine)
        self.hline0.setFrameShadow(QtGui.QFrame.Sunken)

        # Start Directory
        self.dirname = "/automount/radar/dwd/rx/2014/2014-06/2014-06-08/"
        self.dirLabel = LongLabel(self.dirname)
        self.filelist = sorted(glob.glob(os.path.join(self.dirname, "raa01*")))
        self.frames = len(self.filelist)
        self.actualFrame = 0

        attrs, meta = wrl.io.read_RADOLAN_composite(self.filelist[0])
        self.data0ranges =[(0,100)]

        self.data0ComboBox = QtGui.QComboBox()
        self.data0ComboBox.addItem(meta['producttype'])
        self.data0ComboBox.setCurrentIndex(0)
        self.data0ComboBox.currentIndexChanged.connect(self.update_data)

        # Sliders
        self.slider = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.slider.setMinimum(1)
        self.slider.setMaximum(self.frames)
        self.slider.setTickInterval(1)
        self.slider.setSingleStep(1)
        self.slider.valueChanged.connect(self.update_slider)
        self.dateLabel = QtGui.QLabel("Date", self)
        self.date = QtGui.QLabel("1900-01-01", self)
        self.timeLabel = QtGui.QLabel("Time", self)
        self.sliderLabel = QtGui.QLabel("00:00", self)

        # Button
        self.createButton()

        # SpeedSlider
        self.speed = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.speed.setMinimum(0)
        self.speed.setMaximum(1000)
        self.speed.setTickInterval(10)
        self.speed.setSingleStep(10)
        self.speed.valueChanged.connect(self.speed_changed)

        self.gbox1 = QtGui.QGridLayout()
        self.srcbox = QtGui.QGridLayout()
        mbox = QtGui.QGridLayout()
        gbox2 = QtGui.QGridLayout()

        vbox = QtGui.QVBoxLayout()
        vbox.addLayout(self.gbox1)
        vbox.addLayout(self.srcbox)
        vbox.addLayout(mbox)
        vbox.addLayout(gbox2)
        vbox.addStretch(0)

        # Misc Properties
        self.gbox1.addWidget(l_cmap, 0, 0)
        self.gbox1.addWidget(self.combo, 0, 2)
        self.gbox1.addWidget(self.curCheckBox,3,1)
        self.gbox1.addWidget(self.curSelectLabel,3,0)
        self.gbox1.addWidget(self.hline0,7,0,1,3)

        # Data Source Control
        self.srcbox.addWidget(self.dirLabel, 0, 1)
        self.dirLabel.setFixedSize(220,14)
        self.srcbox.addWidget(self.dirButton, 0, 0)
        self.srcbox.addWidget(self.data0ComboBox, 1, 1)

        # Media Control
        mbox.addWidget(self.dateLabel,0,0)
        mbox.addWidget(self.date,0,4)
        mbox.addWidget(self.timeLabel,1,0)
        mbox.addWidget(self.sliderLabel,1,4)
        mbox.addWidget(self.playPauseButton, 2,0)
        mbox.addWidget(self.fwdButton, 2,2)
        mbox.addWidget(self.rewButton, 2,1)
        mbox.addWidget(self.slider,2,3,1,4)
        mbox.addWidget(self.speed,3,0,1,7)

        # Mouse Properties
        # HLine
        self.hline = QtGui.QFrame()
        self.hline.setFrameShape(QtGui.QFrame.HLine)
        self.hline.setFrameShadow(QtGui.QFrame.Sunken)
        radolan = wrl.georef.get_radolan_grid()
        self.r0 = radolan[0,0]
        self.mousePointLabel = QtGui.QLabel("Mouse Position", self)
        self.mousePointXYLabel = QtGui.QLabel("XY", self)
        self.mousePointLLLabel = QtGui.QLabel("LL", self)
        self.mousePointXY = QtGui.QLabel("", self)
        self.mousePointLL = QtGui.QLabel("", self)

        gbox2.addWidget(self.hline,0,0,1,3)
        gbox2.addWidget(self.mousePointLabel,1,0)
        gbox2.addWidget(self.mousePointXYLabel,1,1)
        gbox2.addWidget(self.mousePointXY,1,2)
        gbox2.addWidget(self.mousePointLLLabel,2,1)
        gbox2.addWidget(self.mousePointLL,2,2)

        self.hline1 = QtGui.QFrame()
        self.hline1.setFrameShape(QtGui.QFrame.HLine)
        self.hline1.setFrameShadow(QtGui.QFrame.Sunken)

        self.setLayout(vbox)