Beispiel #1
0
    def insert_class(self, class_id):
        """Create gui elements for the class_id and insert them
        into the gui
        """
        cls = self.classification
        self.color_buttons.insert(class_id,
                                  ColorButton(cls.get_color(class_id)))
        self.color_buttons[class_id].connect('color-set', self.color_button_cb,
                                             class_id)
        symbol = cls.get_symbol(class_id)
        if symbol is not None:
            sym_menu = pguMenuFactory(MENU_FACTORY_OPTION_MENU)
            entries = []
            for i in range(len(gvogrfsgui.ogrfs_symbol_names)):
                sym_name = gvogrfsgui.ogrfs_symbol_names[i]
                sym_img = gvogrfsgui.ogrfs_symbols[sym_name][1]
                a = '<image:' + sym_img + '>'
                entries.append((a, None, self.symbol_change, class_id,
                                gvogrfsgui.ogrfs_symbols[sym_name][0]))
            sym_menu.add_entries(entries)
            sym_menu.set_usize(70, 30)
            sym_menu.set_history(int(symbol[8:]))
            self.sym_menus.insert(class_id, sym_menu)

            scale = cls.get_scale(class_id)
            adj = gtk.GtkAdjustment(value=scale,
                                    lower=0.0,
                                    upper=100.0,
                                    step_incr=0.11,
                                    page_incr=1.0,
                                    page_size=1.0)
            scale_spin = gtk.GtkSpinButton(adj)
            scale_spin.set_editable(TRUE)
            adj.connect('value-changed', self.scale_change, class_id)
            self.scale_spinners.insert(class_id, scale_spin)
        else:
            self.sym_menus.insert(class_id, None)
            self.scale_spinners.insert(class_id, None)

        self.ranges.insert(class_id, pguEntry())
        rng = cls.get_range(class_id)
        rng_txt = str(rng[0])
        if rng[1] != '' and cls.get_type() != CLASSIFY_DISCRETE:
            rng_txt = rng_txt + "-" + str(rng[1])
        self.ranges[class_id].set_text(rng_txt)
        self.ranges[class_id].connect('changed', self.range_changed_cb,
                                      class_id)
        self.labels.insert(class_id, pguEntry())
        self.labels[class_id].set_text(cls.get_name(class_id))
        self.labels[class_id].connect('changed', self.label_changed_cb,
                                      class_id)
        self.add_classification_item(self.color_buttons[class_id],
                                     self.sym_menus[class_id],
                                     self.scale_spinners[class_id],
                                     self.ranges[class_id],
                                     self.labels[class_id])
        self.class_list.show_all()
Beispiel #2
0
    def __init__(self,
                 ok_cb=None,
                 cancel_cb=None,
                 cb_data=None,
                 classify_type=CLASSIFY_EQUAL_INTERVAL):
        gtk.GtkWindow.__init__(self)
        self.set_title('Classification')
        self.user_ok_cb = ok_cb
        self.user_cancel_cb = cancel_cb
        self.user_cb_data = cb_data
        self.classify_type = classify_type
        self.set_border_width(6)
        #main vertical box
        vbox = gtk.GtkVBox(spacing=6)
        type_box = gtk.GtkHBox(spacing=6)
        type_box.pack_start(gtk.GtkLabel('Type:'), expand=gtk.FALSE)
        opt_menu = gtk.GtkOptionMenu()
        type_menu = gtk.GtkMenu()

        #using classification_types dictionary from gvclassification
        for i in range(len(classification_types)):
            for type in classification_types.iteritems():
                if type[1] == i:
                    item = gtk.GtkMenuItem(type[0])
                    item.connect('activate', self.type_menu_cb,
                                 classification_types[type[0]])
                    type_menu.append(item)

        opt_menu.set_menu(type_menu)
        opt_menu.set_history(classify_type)
        opt_menu.resize_children()
        type_box.pack_start(opt_menu)
        vbox.pack_start(type_box, expand=gtk.FALSE)
        #Number of classes
        classes_box = gtk.GtkHBox(spacing=6)
        classes_box.pack_start(gtk.GtkLabel('Number of classes:'))
        adj = gtk.GtkAdjustment(5, 2, 80, 1, 5, 5, 0)
        self.spinner = gtk.GtkSpinButton(adj)
        self.spinner.set_snap_to_ticks(gtk.TRUE)
        self.spinner.set_digits(0)
        classes_box.pack_start(self.spinner)
        vbox.pack_start(classes_box, expand=gtk.FALSE)
        #add the ok and cancel buttons
        button_box = gtk.GtkHButtonBox()
        ok_button = gtk.GtkButton("OK")
        ok_button.connect('clicked', self.ok_cb, cb_data)
        cancel_button = gtk.GtkButton("Cancel")
        cancel_button.connect('clicked', self.cancel_cb, cb_data)
        button_box.pack_start(ok_button)
        button_box.pack_start(cancel_button)
        vbox.pack_start(button_box, expand=gtk.FALSE)
        vbox.show_all()
        self.add(vbox)
        ok_button.set_flags(gtk.CAN_DEFAULT)
        ok_button.grab_default()
Beispiel #3
0
    def __init__(self):
        gtk.GtkTable.__init__(self, rows=2, cols=2)

        self.hadj = gtk.GtkAdjustment()
        self.vadj = gtk.GtkAdjustment()

        self._hscroll = gtk.GtkHScrollbar(adj=self.hadj)
        self._vscroll = gtk.GtkVScrollbar(adj=self.vadj)
        self._area = gtk.GtkDrawingArea()
        #set events for scrolling (not defined in GDK
        #self._area.set_events(1 << 21)
        self.contents = []
        self.max_width = 0
        self.max_length = 0
        self.height = 0
        self.line_height = 0
        self.start_line = 0
        self.start_col = 0
        self.freeze_count = 0
        self.updating = gtk.FALSE

        frm = gtk.GtkFrame()
        frm.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
        frm.add(self._area)
        self.attach(frm, 0, 1, 0, 1)
        self.attach(self._vscroll, 1, 2, 0, 1, xoptions=gtk.SHRINK)
        self.attach(self._hscroll, 0, 1, 1, 2, yoptions=gtk.SHRINK)

        self.show_all()

        self._area.connect('expose-event', self.expose)
        self.connect('configure-event', self.configure)
        self.hadj.connect('value-changed', self.changed)
        self.vadj.connect('value-changed', self.changed)
        self._area.connect("scroll-event", self.event)
        self.connect('style-set', self.expose)
Beispiel #4
0
glarea.size(300, 300)

glarea.connect("realize", init)
glarea.connect("size_allocate", reshape)
glarea.connect("expose_event", draw)

gtk.idle_add(idle)

table.attach(glarea, 0,2, 0,1)
glarea.show()

for row, label, start, cb in ((1,'X Rotation', view_rotx, xchange),
			      (2,'Y Rotation', view_roty, ychange),
			      (3,'Z Rotation', view_rotz, zchange)):
	l = gtk.GtkLabel(label)
	table.attach(l, 0,1, row,row+1, xoptions=0, yoptions=gtk.FILL)
	l.show()

	adj = gtk.GtkAdjustment(start, 0, 360, 5, 5, 0)
	adj.connect("value_changed", cb)

	scale = gtk.GtkHScale(adj)
	table.attach(scale, 1,2, row,row+1, yoptions=gtk.FILL)
	scale.show()

win.show()

gtk.mainloop()

glarea.destroy()
Beispiel #5
0
    def __init__(self, editable=1):

        self._editable = editable
        if self._editable == 1:
            gtk.GtkTable.__init__(self, rows=3, cols=2)
        else:
            gtk.GtkTable.__init__(self, rows=2, cols=2)

        self.hadj = gtk.GtkAdjustment()
        self.vadj = gtk.GtkAdjustment()

        self._hscroll = gtk.GtkHScrollbar(adj=self.hadj)
        self._vscroll = gtk.GtkVScrollbar(adj=self.vadj)
        self._area = gtk.GtkDrawingArea()
        self._pixmap = None
        #this mask also seems to enable scrolling???
        evt_mask = gtk.GDK.BUTTON_PRESS_MASK | gtk.GDK.BUTTON_RELEASE_MASK | \
                   gtk.GDK.KEY_PRESS_MASK | gtk.GDK.KEY_RELEASE_MASK
        self._area.set_events(evt_mask)

        if self._editable == 1:
            self._entry = gtk.GtkEntry()
            self._entry.set_sensitive(gtk.FALSE)
            self._entry.connect('changed', self.entry_changed)

        #the data source
        self.source = None
        self.source_changed_id = None
        self.subset = []

        # indices/info for sorting (indices maps source index to nRow; inv_indices
        # maps nRow to source index, and similar for subindices).
        self.indices = None
        self.inv_indices = None
        self.subindices = None
        self.inv_subindices = None
        self.sort_reverse = 0

        #string values to use as titles
        self.titles = []

        #fonts for drawing titles and cells put here
        self.title_font = None
        self.cell_font = None

        #the overall size of the data set
        self.n_rows = 0
        self.n_cols = 0

        #the height of a single row and title row
        self.row_height = 0
        self.title_height = 0

        #the row/col to put in the top left corner
        self.start_row = 0
        self.start_col = 0

        #the current row/col selected (when we support clicking :)
        self.current_row = 0  # current row in display widget coordinates
        self.current_row_src = -1  # current row in source coordinates (source index)
        self.current_col = 0

        self.col_widths = []

        #the number of pixels around each cell
        self.cell_half = 4
        self.cell_full = (self.cell_half) * 2 + 1

        self.max_width = 0
        self.max_height = 0

        #flag to recalculate the adjustments
        self.bCalcAdjustments = gtk.TRUE

        # list of indices of currently selected shapes (NOT the same as the
        # currently editable cell)
        self.selected_shapes = None

        #set to true if changing some value that would end up causing multiple
        #expose events or an endless loop even.
        self.updating = gtk.FALSE

        frm = gtk.GtkFrame()
        frm.set_shadow_type(gtk.SHADOW_ETCHED_OUT)
        frm.add(self._area)

        if self._editable == 1:
            self.attach(self._entry,
                        0,
                        1,
                        0,
                        1,
                        xoptions=gtk.FILL,
                        yoptions=gtk.SHRINK)
            self.attach(frm, 0, 1, 1, 2, xoptions=gtk.FILL, yoptions=gtk.FILL)
            self.attach(self._vscroll, 1, 2, 1, 2, xoptions=gtk.SHRINK)
            self.attach(self._hscroll, 0, 1, 2, 3, yoptions=gtk.SHRINK)
        else:
            self.attach(frm, 0, 1, 0, 1, xoptions=gtk.FILL, yoptions=gtk.FILL)
            self.attach(self._vscroll, 1, 2, 0, 1, xoptions=gtk.SHRINK)
            self.attach(self._hscroll, 0, 1, 1, 2, yoptions=gtk.SHRINK)

        self.show_all()

        # signals: Note that the right-click (button 3) event
        # is a special case used internally to select cells for
        # editing.
        self.publish('clicked-selected-row')
        self.publish('clicked-unselected-row')
        self.publish('title-clicked')

        self._area.connect('expose-event', self.expose)
        self._area.connect('configure-event', self.configure)
        self._area.connect('button-press-event', self.click)
        self.hadj.connect('value-changed', self.changed)
        self.vadj.connect('value-changed', self.changed)
        self.connect('style-set', self.expose)
Beispiel #6
0
		def __init__(self, default=0, bounds=(0, 100, 5)):
			import gtk
			self.adj = gtk.GtkAdjustment(default, bounds[0],
						     bounds[1], bounds[2],
						     bounds[2], bounds[2])
			gtk.GtkSpinButton.__init__(self, self.adj, 1, 0)
Beispiel #7
0
		def __init__(self, default=0, bounds=(0, 100, 5)):
			import gtk
			self.adj = gtk.GtkAdjustment(default, bounds[0],
						     bounds[1], bounds[2],
						     bounds[2], bounds[2])
			gtk.GtkHScale.__init__(self, self.adj)
Beispiel #8
0
if not gtkgl.query():
    print "OpenGL not supported.  Bye."
    raise SystemExit

win = gtk.GtkWindow()
win.connect("destroy", gtk.mainquit)
win.set_title("Cone")

table = gtk.GtkTable(2, 3)
table.set_border_width(5)
table.set_col_spacings(5)
table.set_row_spacings(5)
win.add(table)
table.show()

vadj = gtk.GtkAdjustment(250, 0, 360, 5, 5, 0)
vscale = gtk.GtkVScale(vadj)
table.attach(vscale, 1, 2, 0, 1, xoptions=gtk.FILL)
vscale.show()

hadj = gtk.GtkAdjustment(0, 0, 360, 5, 5, 0)
hscale = gtk.GtkHScale(hadj)
table.attach(hscale, 0, 1, 1, 2, yoptions=gtk.FILL)
hscale.show()

vadj.connect("value_changed", vchanged)
hadj.connect("value_changed", hchanged)

glarea = gtkgl.GtkGLArea((gtkgl.RGBA, gtkgl.DOUBLEBUFFER, gtkgl.DEPTH_SIZE, 1))
glarea.size(300, 300)
Beispiel #9
0
        def createGUI(self):
            mainbox = gtk.GtkVBox(spacing=5)
            mainbox.set_border_width(5)
            self.add(mainbox)

            # RGB source
            frame = gtk.GtkFrame("Setup")
            mainbox.add(frame, expand=FALSE)

            vbox = gtk.GtkVBox(spacing=5)
            vbox.set_border_width(5)
            frame.add(vbox)

            box = gtk.GtkHBox(spacing=5)
            vbox.add(box, expand=FALSE)

            box.add(gtk.GtkLabel('RGB:'), expand=FALSE)
            self.rgbCB = gtk.GtkCombo()
            self.rgbCB.set_popdown_strings(self.rgbDict.keys())
            box.add(self.rgbCB)

            # Pan source
            box = gtk.GtkHBox(spacing=5)
            vbox.add(box, expand=FALSE)
            box.add(gtk.GtkLabel('Pan:'), expand=FALSE)

            self.panCB = gtk.GtkCombo()
            self.panCB.set_popdown_strings(self.panDict.keys())
            box.add(self.panCB)

            # output
            box = gtk.GtkHBox(spacing=5)
            vbox.add(box, expand=FALSE)
            box.add(gtk.GtkLabel('Format:'), expand=FALSE)
            self.formatCB = gtk.GtkCombo()
            wDrvs = filter(lambda drv: 'DCAP_CREATE' in drv.GetMetadata(),
                           gdal.GetDriverList())
            drivers = map(lambda d: d.ShortName, wDrvs)
            drivers.sort()
            self.formatCB.set_popdown_strings(drivers)
            self.formatCB.entry.set_text('GTiff')
            self.tips.set_tip(self.formatCB.entry,
                              'Output formats. Some may not work.')
            box.add(self.formatCB, expand=FALSE)

            box = gtk.GtkHBox(spacing=5)
            vbox.add(box, expand=FALSE)
            box.add(gtk.GtkLabel('Output file:'), expand=FALSE)
            self.outTE = gtk.GtkEntry()
            box.add(self.outTE)

            # warp options
            box = gtk.GtkHBox(spacing=5)
            box.set_border_width(5)
            vbox.add(box, expand=FALSE)
            box.add(gtk.GtkLabel('Resampling'), expand=FALSE)
            self.algCB = gtk.GtkCombo()
            self.tips.set_tip(
                self.algCB.entry,
                'Resampling algorithm. Cubic Spline is recommended for best results'
            )
            box.add(self.algCB, expand=FALSE)
            self.algCB.set_popdown_strings(
                ['Nearest Neighbor', 'Bilinear', 'Cubic', 'Cubic Spline'])

            box = gtk.GtkHBox(spacing=5)
            vbox.add(box, expand=FALSE)
            box.add(gtk.GtkLabel('Create options:'), expand=FALSE)
            self.coptTE = gtk.GtkEntry()
            self.coptTE.set_text('tiled=yes')
            box.add(self.coptTE)

            box = gtk.GtkHBox(homogeneous=TRUE, spacing=5)
            vbox.add(box, expand=FALSE)

            box.add(gtk.GtkLabel('Pixel: '), expand=FALSE)
            self.xoffTE = gtk.GtkEntry()
            self.xoffTE.set_usize(50, -1)
            box.add(self.xoffTE, expand=FALSE)

            box.add(gtk.GtkLabel('Line:'), expand=FALSE)
            self.yoffTE = gtk.GtkEntry()
            self.yoffTE.set_usize(50, -1)
            box.add(self.yoffTE, expand=FALSE)

            box = gtk.GtkHBox(homogeneous=TRUE, spacing=5)
            vbox.add(box, expand=FALSE)

            box.add(gtk.GtkLabel('Width: '), expand=FALSE)
            self.widthTE = gtk.GtkEntry()
            self.widthTE.set_usize(50, -1)
            box.add(self.widthTE, expand=FALSE)

            box.add(gtk.GtkLabel('Height:'), expand=FALSE)
            self.heightTE = gtk.GtkEntry()
            self.heightTE.set_usize(50, -1)
            box.add(self.heightTE, expand=FALSE)

            box = gtk.GtkHBox(homogeneous=TRUE, spacing=5)
            vbox.add(box, expand=FALSE)

            box.add(gtk.GtkLabel('X offset: '), expand=FALSE)
            self.panXoffTE = gtk.GtkEntry()
            self.panXoffTE.set_usize(50, -1)
            self.panXoffTE.set_text('0')
            self.tips.set_tip(self.panXoffTE, 'Pan X offset')
            box.add(self.panXoffTE, expand=FALSE)

            box.add(gtk.GtkLabel('Y offset:'), expand=FALSE)
            self.panYoffTE = gtk.GtkEntry()
            self.panYoffTE.set_usize(50, -1)
            self.panYoffTE.set_text('0')
            self.tips.set_tip(self.panYoffTE, 'Pan Y offset')
            box.add(self.panYoffTE, expand=FALSE)

            box = gtk.GtkHBox(spacing=5)
            vbox.add(box)

            self.swapTO = gtk.GtkCheckButton(label='Swap R-B')
            self.tips.set_tip(self.swapTO,
                              'Swap Red and Blue bands. Used for Quickbird.')
            box.add(self.swapTO)

            box.add(gtk.GtkLabel('Datatype:'), expand=FALSE)
            self.sat0RB = gtk.GtkRadioButton(label='Byte')
            box.add(self.sat0RB)
            self.sat1RB = gtk.GtkRadioButton(label='UInt16', group=self.sat0RB)
            box.add(self.sat1RB)

            box = gtk.GtkHBox(spacing=5)
            vbox.add(box)

            box.add(gtk.GtkLabel('Resize:'), expand=FALSE)
            self.reszFn0CB = gtk.GtkRadioButton(label='Gdalwarp')
            box.add(self.reszFn0CB)
            self.reszFn1CB = gtk.GtkRadioButton(label='gdal.py',
                                                group=self.reszFn0CB)
            box.add(self.reszFn1CB)

            # Params
            frame = gtk.GtkFrame('Fusion Method')
            mainbox.add(frame, expand=FALSE)
            vbox = gtk.GtkVBox(spacing=3)
            vbox.set_border_width(5)
            frame.add(vbox)
            box = gtk.GtkHBox(spacing=5)
            vbox.add(box)

            self.met0RB = gtk.GtkRadioButton(label='IHS')
            tipTxt = 'Standard Intensity-Hue-Saturation merging. '
            tipTxt += 'Sharpness setting has no effect. '
            self.tips.set_tip(self.met0RB, tipTxt)
            box.add(self.met0RB)

            self.met1RB = gtk.GtkRadioButton(label='Kernel', group=self.met0RB)
            tipTxt = 'Pan is run through a convolution kernel and added to RGB. '
            tipTxt += 'Recommended sharpness: 0.15-0.25 for Ikonos and Quickbird, '
            tipTxt += '0.3-0.5 for Landsat and SPOT. '
            tipTxt += 'Can be set higher if imagery is enhanced.'
            self.tips.set_tip(self.met1RB, tipTxt)
            box.add(self.met1RB)

            # params
            vbox2 = gtk.GtkVBox(spacing=5)
            vbox2.set_border_width(5)
            vbox.add(vbox2)

            box = gtk.GtkHBox(spacing=5)
            vbox2.add(box)
            box.add(gtk.GtkLabel('Sharpness:'), expand=FALSE)
            self.adjSharp = gtk.GtkAdjustment(0.15, 0.0, 1.0, 0.01, 0.1)
            slider = gtk.GtkHScale(self.adjSharp)
            slider.set_digits(2)
            box.add(slider)

            # Buttons
            box = gtk.GtkHBox(homogeneous=1, spacing=5)
            mainbox.add(box, expand=FALSE)

            mergeBT = gtk.GtkButton("Merge")
            mergeBT.connect("clicked", self.compute, 'merge')
            self.tips.set_tip(mergeBT, 'Proceed with merging')
            box.add(mergeBT)

            pviewBT = gtk.GtkButton("Preview")
            pviewBT.connect("clicked", self.compute, 'pview')
            self.tips.set_tip(pviewBT, 'Preview merging')
            box.add(pviewBT)

            closeBT = gtk.GtkButton("Close")
            closeBT.connect("clicked", self.close)
            box.add(closeBT)

            # do the connects last so events are not fired during init
            self.panCB.entry.connect('changed', self.panChanged)
            self.rgbCB.entry.connect('changed', self.rgbChanged)
            self.formatCB.entry.connect('changed', self.formatChanged)
            return TRUE