def fillControls(self): ScrollView.fillControls(self) if self.addPrinterFaxList(): self.addGroupHeading("files_to_print", self.__tr("File(s) to Print")) self.addFileList() self.addGroupHeading("options", self.__tr("Print Options")) self.addCopies() self.addPageRange() self.addPageSet() self.job_storage_avail = self.cur_device.mq['job-storage'] == JOB_STORAGE_ENABLE if self.job_storage_avail: self.addGroupHeading("jobstorage", self.__tr("Job Storage and Secure Printing")) self.addJobStorage() self.addGroupHeading("space1", "") self.printButton = self.addActionButton("bottom_nav", self.__tr("Print File(s)"), self.printButton_clicked, 'print.png', 'print.png', self.__tr("Close"), self.funcButton_clicked) self.printButton.setEnabled(False) self.maximizeControl() else: QApplication.restoreOverrideCursor() self.form.FailureUI("<b>Print is disabled.</b><p>No CUPS print queue found for this device.") self.funcButton_clicked()
def onDeviceChange(self, cur_device=None): ScrollView.onDeviceChange(self, cur_device) self.dev = copier.PMLCopyDevice(device_uri=self.cur_device.device_uri, printer_name=self.cur_printer) self.scan_style = self.dev.mq.get('scan-style', SCAN_STYLE_FLATBED) self.copy_type = self.dev.mq.get('copy-type', COPY_TYPE_DEVICE) if self.scan_style == SCAN_STYLE_SCROLLFED: self.fitToPageCheckBox.setEnabled(False) self.fit_to_page = pml.COPIER_FIT_TO_PAGE_DISABLED self.getDeviceSettings()
def __init__(self, service, num_copies=None, contrast=None, quality=None, reduction=None, fit_to_page=None, parent=None, form=None, name=None, fl=0): ScrollView.__init__(self, service, parent, name, fl) self.form = form self.num_copies = num_copies self.contrast = contrast self.quality = quality self.reduction = reduction self.fit_to_page = fit_to_page self.update_queue = Queue.Queue() # UI updates from copy thread self.event_queue = Queue.Queue() # UI events to copy thread
def __init__(self, service, parent=None, form=None, name=None, fl=0): ScrollView.__init__(self, service, parent, name, fl) self.initJobStorage() self.form = form self.file_list = [] self.pages_button_group = 0 self.prev_selected_file_index = 0 self.allowable_mime_types = cups.getAllowableMIMETypes() log.debug(self.allowable_mime_types) self.MIME_TYPES_DESC = \ { "application/pdf" : (self.__tr("PDF Document"), '.pdf'), "application/postscript" : (self.__tr("Postscript Document"), '.ps'), "application/vnd.hp-HPGL" : (self.__tr("HP Graphics Language File"), '.hgl, .hpg, .plt, .prn'), "application/x-cshell" : (self.__tr("C Shell Script"), '.csh, .sh'), "application/x-csource" : (self.__tr("C Source Code"), '.c'), "text/cpp": (self.__tr("C++ Source Code"), '.cpp, .cxx'), "application/x-perl" : (self.__tr("Perl Script"), '.pl'), "application/x-python" : (self.__tr("Python Program"), '.py'), "application/x-shell" : (self.__tr("Shell Script"), '.sh'), "application/x-sh" : (self.__tr("Shell Script"), '.sh'), "text/plain" : (self.__tr("Plain Text"), '.txt, .log, etc'), "text/html" : (self.__tr("HTML Dcoument"), '.htm, .html'), "image/gif" : (self.__tr("GIF Image"), '.gif'), "image/png" : (self.__tr("PNG Image"), '.png'), "image/jpeg" : (self.__tr("JPEG Image"), '.jpg, .jpeg'), "image/tiff" : (self.__tr("TIFF Image"), '.tif, .tiff'), "image/x-bitmap" : (self.__tr("Bitmap (BMP) Image"), '.bmp'), "image/x-bmp" : (self.__tr("Bitmap (BMP) Image"), '.bmp'), "image/x-photocd" : (self.__tr("Photo CD Image"), '.pcd'), "image/x-portable-anymap" : (self.__tr("Portable Image (PNM)"), '.pnm'), "image/x-portable-bitmap" : (self.__tr("Portable B&W Image (PBM)"), '.pbm'), "image/x-portable-graymap" : (self.__tr("Portable Grayscale Image (PGM)"), '.pgm'), "image/x-portable-pixmap" : (self.__tr("Portable Color Image (PPM)"), '.ppm'), "image/x-sgi-rgb" : (self.__tr("SGI RGB"), '.rgb'), "image/x-xbitmap" : (self.__tr("X11 Bitmap (XBM)"), '.xbm'), "image/x-xpixmap" : (self.__tr("X11 Pixmap (XPM)"), '.xpm'), "image/x-sun-raster" : (self.__tr("Sun Raster Format"), '.ras'), }
def fillControls(self): ScrollView.fillControls(self) self.addGroupHeading("copies", self.__tr("Number of Copies")) self.addCopies() self.addGroupHeading("reduction", self.__tr("Enlargement, Reduction and Fit to Page")) self.addEnlargementReduction() self.addGroupHeading("contrast", self.__tr("Copy Contrast")) self.addContrast() self.addGroupHeading("quality", self.__tr("Copy Quality")) self.addQuality() self.addGroupHeading("space1", "") self.copyButton = self.addActionButton("bottom_nav", self.__tr("Make Copies(s)"), self.copyButton_clicked, 'print.png', 'print.png', self.__tr("Close"), self.funcButton_clicked)
def build(self): main_scroll = ScrollView(do_scroll_x=False) main_grid = GridLayout(cols=1, spacing=100, padding=[0, 50, 0, 50], size_hint_y=None) main_grid.bind(minimum_height=main_grid.setter('height')) main_scroll.add_widget(main_grid) scroll_count = 4 for _ in range(scroll_count): scroll = ScrollView(size_hint_y=None, height=300, do_scroll_y=False) grid = GridLayout(rows=1, spacing=1, size_hint=(None, 1)) grid.bind(minimum_width=grid.setter('width')) scroll.add_widget(grid) for r in range(0, 50): bt = Button(text='Button ' + str(r), size_hint_x=None, width=cm(2)) bt.bind(on_press=self.print_btn) grid.add_widget(bt) main_grid.add_widget(scroll) return main_scroll
border_width=3, border_radius=10, font_kwargs={"bold": True, "italic": True}, dest=(0.1, 0.1, 0.1, 0.1), # position within parent on_click=lambda self, event: self.run_hook("NAVIGATE_TO", "level_select"), ), ScrollView( dest=(0.6, 0.1, 0.35, 0.4), canvas_size_factors=(1.0, 3.0), border_width=3, aspect_ratio=1, children=[ View(bg_color=GREEN, dest=(0.1, 0.0, 0.2, 1.0), margins=(0, 10, 0, 10)), Button(bg_color=RED, dest=(0.4, 0.1, 0.2, 0.2), text="!", on_click=lambda s, e: print("HI")), View(bg_color=BLUE, dest=(0.4, 0.4, 0.2, 0.2)), View(bg_color=MAGENTA, dest=(0.8, 0.6, 0.2, 0.2)), ScrollView( border_width=1, dest=(0.4, 0.7, 0.3, 0.2), canvas_size_factors=(2.0, 2.0), children=[ Image(image=test_image_source) ] ) ] ), ScrollView( dest=(0.1, 0.7, 0.4, 0.2), canvas_size_factors=(2.0, 1.0), border_width=3, children=[ Text(
import matplotlib.pyplot as plt import numpy as np import imageio import os import SimpleITK as sitk from scrollview import ScrollView #image = sitk.ReadImage(r'C:\Users\s166646\Downloads\Capita Selecta\results2\result.0.mhd') image = sitk.ReadImage( r'C:\Users\s166646\Downloads\TrainingData\TrainingData\p102\mr_bffe.mhd') #image = sitk.ReadImage(r'C:\Users\s166646\Downloads\TrainingData\TrainingData\p102\prostaat.mhd') image_array = sitk.GetArrayFromImage(image) #print(image_array) #print(np.max(image_array)) fig, ax = plt.subplots() ScrollView(image_array).plot(ax) #fixed_image = sitk.ReadImage(r'C:\Users\s166646\Downloads\ImagesforPractical\ImagesforPractical\chest_xrays\fixed_image.mhd') #moving_image = sitk.ReadImage(r'C:\Users\s166646\Downloads\ImagesforPractical\ImagesforPractical\chest_xrays\moving_image.mhd') #fixed_image_path = sitk.GetArrayFromImage(fixed_image) #moving_image_path = sitk.GetArrayFromImage(moving_image) #fig, ax = plt.subplots(1, 3, figsize=(20, 5)) #ax[0].imshow(fixed_image_path) #ax[1].imshow(moving_image_path) #ax[2].imshow(image_array[24], cmap='gray') plt.show()
#path_to_transformed_image = T.transform_image(im1, output_dir='results') # ## Get the Jacobian matrix #path_to_jacobian_matrix = T.jacobian_matrix(output_dir='results') # ## Get the Jacobian determinant #path_to_jacobian_determinant = T.jacobian_determinant(output_dir='results') # ## Get the full deformation field #path_to_deformation_field = T.deformation_field(output_dir='results') # from scrollview import ScrollView #image = np.load('path/to/image') #aspect_ratio = [2.3, 0.95, 0.95] # i.e. the ElementSpacing aspect_ratio = [2.3, 2.3, 2.3] # i.e. the ElementSpacing # Define viewers for every axis viewer1 = ScrollView(im_arr1) viewer2 = ScrollView(im_arr2) viewer3 = ScrollView(im_arrres) #viewer2 = ScrollView(im.transpose(1, 0, 2)) #viewer3 = ScrollView(im.transpose(2, 0, 1)) # Make three Matplotlib supblots, and populate them with the viewers objects # The aspect ratios of the different axes need to be defined here as well. fig, ax = plt.subplots(1, 3) viewer1.plot(ax[0], cmap='gray', aspect=aspect_ratio[1] / aspect_ratio[2]) viewer2.plot(ax[1], cmap='gray', aspect=aspect_ratio[0] / aspect_ratio[2]) viewer3.plot(ax[2], cmap='gray', aspect=aspect_ratio[0] / aspect_ratio[1]) plt.show()
def fillControls(self): QApplication.setOverrideCursor(QApplication.waitCursor) ScrollView.fillControls(self) self.loading = True cups.resetOptions() cups.openPPD(self.cur_printer) cur_outputmode = "" #if 1: try: if 1: #try: current_options = dict(cups.getOptions()) if not self.cur_device.device_type == DEVICE_TYPE_FAX: self.addGroupHeading("basic", self.__tr("Basic")) log.debug("Group: Basic") # Basic # PageSize (in PPD section) # orientation-requested # sides # outputorder # Collate current = current_options.get('orientation-requested', '3') self.addItem("basic", "orientation-requested", self.__tr("Page Orientation"), cups.PPD_UI_PICKONE, current, [('3', self.__tr('Portrait')), ('4', self.__tr('Landscape')), ('5', self.__tr('Reverse landscape')), ('6', self.__tr('Reverse portrait'))], '3') log.debug("Option: orientation-requested") log.debug("Current value: %s" % current) duplexer = self.cur_device.dq.get('duplexer', 0) log.debug("Duplexer = %d" % duplexer) if duplexer: current = current_options.get('sides', 'one-sided') self.addItem( "basic", "sides", self.__tr( "Duplex (Print on both sides of the page)"), cups.PPD_UI_PICKONE, current, [('one-sided', self.__tr('Single sided')), ('two-sided-long-edge', self.__tr('Two sided (long edge)')), ('two-sided-short-edge', self.__tr('Two sided (short edge)'))], 'one-sided') log.debug("Option: sides") log.debug("Current value: %s" % current) current = current_options.get('outputorder', 'normal') self.addItem( "basic", "outputorder", self.__tr("Output Order (Print last page first)"), cups.PPD_UI_PICKONE, current, [('normal', self.__tr('Normal (Print first page first)')), ('reverse', self.__tr('Reversed (Print last page first)'))], 'normal') log.debug("Option: outputorder") log.debug("Current value: %s" % current) current = utils.to_bool(current_options.get( 'Collate', '0')) self.addItem( "basic", "Collate", self.__tr("Collate (Group together multiple copies)"), cups.PPD_UI_BOOLEAN, current, [], 0) log.debug("Option: Collate") log.debug("Current value: %s" % current) groups = cups.getGroupList() for g in groups: log.debug("Group: %s" % repr(g)) if 'jobretention' in g.lower(): log.debug("HPJobRetention skipped.") continue text, num_subgroups = cups.getGroup(g) read_only = 'install' in g.lower() try: text = text.decode('utf-8') except UnicodeDecodeError: pass if g.lower() == 'printoutmode': text = self.__tr("Quality") self.addGroupHeading(g, text, read_only) log.debug(" Text: %s" % repr(text)) log.debug("Num subgroups: %d" % num_subgroups) options = cups.getOptionList(g) for o in options: log.debug(" Option: %s" % repr(o)) if 'pageregion' in o.lower(): log.debug("Page Region skipped.") continue option_text, defchoice, conflicted, ui = cups.getOption( g, o) try: option_text = option_text.decode('utf-8') except UnicodeDecodeError: pass if o.lower() == 'quality': option_text = self.__tr("Quality") log.debug(" Text: %s" % repr(option_text)) log.debug(" Defchoice: %s" % repr(defchoice)) choices = cups.getChoiceList(g, o) value = None choice_data = [] for c in choices: log.debug(" Choice: %s" % repr(c)) # TODO: Add custom paper size controls if 'pagesize' in o.lower() and 'custom' in c.lower( ): log.debug("Skipped.") continue choice_text, marked = cups.getChoice(g, o, c) try: choice_text = choice_text.decode('utf-8') except UnicodeDecodeError: pass log.debug(" Text: %s" % repr(choice_text)) if marked: value = c choice_data.append((c, choice_text)) if o.lower() == 'outputmode': if value is not None: cur_outputmode = value else: cur_outputmode = defchoice self.addItem(g, o, option_text, ui, value, choice_data, defchoice, read_only) ## if 'pagesize' in o.lower(): # and 'custom' in c.lower(): ## current = 0.0 ## width_widget = self.addItem("custom", "custom-width", self.__tr("Custom Paper Width"), cups.UI_UNITS_SPINNER, ## current, (0.0, 0.0), 0.0) ## ## current = 0.0 ## height_widget = self.addItem("custom", "custom-height", self.__tr("Custom Paper Height"), cups.UI_UNITS_SPINNER, ## current, (0.0, 0.0), 0.0) ## ## if value.lower() == 'custom': ## pass # N-Up # number-up # number-up-layout # page-border self.addGroupHeading( "nup", self.__tr( "N-Up (Multiple document pages per printed page)")) log.debug("Group: N-Up") current = current_options.get('number-up', '1') self.addItem("nup", "number-up", self.__tr("Pages per Sheet"), cups.PPD_UI_PICKONE, current, [('1', self.__tr('1 page per sheet')), ('2', self.__tr('2 pages per sheet')), ('4', self.__tr('4 pages per sheet'))], '1') log.debug(" Option: number-up") log.debug(" Current value: %s" % current) current = current_options.get('number-up-layout', 'lrtb') self.addItem( "nup", "number-up-layout", self.__tr("Layout"), cups.PPD_UI_PICKONE, current, [('btlr', self.__tr('Bottom to top, left to right')), ('btrl', self.__tr('Bottom to top, right to left')), ('lrbt', self.__tr('Left to right, bottom to top')), ('lrtb', self.__tr('Left to right, top to bottom')), ('rlbt', self.__tr('Right to left, bottom to top')), ('rltb', self.__tr('Right to left, top to bottom')), ('tblr', self.__tr('Top to bottom, left to right')), ('tbrl', self.__tr('Top to bottom, right to left'))], 'lrtb') log.debug(" Option: number-up-layout") log.debug(" Current value: %s" % current) current = current_options.get('page-border', 'none') self.addItem("nup", "page-border", self.__tr("Printed Border Around Each Page"), cups.PPD_UI_PICKONE, current, [('double', self.__tr("Two thin borders")), ("double-thick", self.__tr("Two thick borders")), ("none", self.__tr("No border")), ("single", self.__tr("One thin border")), ("single-thick", self.__tr("One thick border"))], 'none') log.debug(" Option: page-border") log.debug(" Current value: %s" % current) # Adjustment # brightness # gamma if not self.cur_device.device_type == DEVICE_TYPE_FAX: self.addGroupHeading("adjustment", self.__tr("Printout Appearance")) current = int(current_options.get('brightness', 100)) log.debug(" Option: brightness") log.debug(" Current value: %s" % current) self.addItem("adjustment", "brightness", self.__tr("Brightness"), cups.UI_SPINNER, current, (0, 200), 100, suffix=" %") current = int(current_options.get('gamma', 1000)) log.debug(" Option: gamma") log.debug(" Current value: %s" % current) self.addItem("adjustment", "gamma", self.__tr("Gamma"), cups.UI_SPINNER, current, (1, 10000), 1000) # Margins (pts) # page-left # page-right # page-top # page-bottom ## if 0: ## # TODO: cupsPPDPageSize() fails on LaserJets. How do we get margins in this case? Defaults? ## # PPD file for LJs has a HWMargin entry... ## page, page_width, page_len, left, bottom, right, top = cups.getPPDPageSize() ## ## right = page_width - right ## top = page_len - top ## ## self.addGroupHeading("margins", self.__tr("Margins")) ## current_top = current_options.get('page-top', 0) # pts ## current_bottom = current_options.get('page-bottom', 0) # pts ## current_left = current_options.get('page-left', 0) # pts ## current_right = current_options.get('page-right', 0) # pts ## ## log.debug(" Option: page-top") ## log.debug(" Current value: %s" % current_top) ## ## self.addItem("margins", "page-top", self.__tr("Top margin"), ## cups.UI_UNITS_SPINNER, current_top, ## (0, page_len), top) ## ## self.addItem("margins", "page-bottom", self.__tr("Bottom margin"), ## cups.UI_UNITS_SPINNER, current_bottom, ## (0, page_len), bottom) ## ## self.addItem("margins", "page-left", self.__tr("Right margin"), ## cups.UI_UNITS_SPINNER, current_left, ## (0, page_width), left) ## ## self.addItem("margins", "page-right", self.__tr("Left margin"), ## cups.UI_UNITS_SPINNER, current_right, ## (0, page_width), right) # Image Printing # position # natural-scaling # saturation # hue self.addGroupHeading("image", self.__tr("Image Printing")) current = utils.to_bool(current_options.get( 'fitplot', 'false')) self.addItem("image", "fitplot", self.__tr("Fit to Page"), cups.PPD_UI_BOOLEAN, current, [], 0) current = current_options.get('position', 'center') self.addItem("image", "position", self.__tr("Position on Page"), cups.PPD_UI_PICKONE, current, [('center', self.__tr('Centered')), ('top', self.__tr('Top')), ('left', self.__tr('Left')), ('right', self.__tr('Right')), ('top-left', self.__tr('Top left')), ('top-right', self.__tr('Top right')), ('bottom', self.__tr('Bottom')), ('bottom-left', self.__tr('Bottom left')), ('bottom-right', self.__tr('Bottom right'))], 'center') log.debug(" Option: position") log.debug(" Current value: %s" % current) if not self.cur_device.device_type == DEVICE_TYPE_FAX: current = int(current_options.get('saturation', 100)) log.debug(" Option: saturation") log.debug(" Current value: %s" % current) self.addItem("image", "saturation", self.__tr("Saturation"), cups.UI_SPINNER, current, (0, 200), 100, suffix=" %") current = int(current_options.get('hue', 0)) log.debug(" Option: hue") log.debug(" Current value: %s" % current) self.addItem("image", "hue", self.__tr("Hue (color shift/rotation)"), cups.UI_SPINNER, current, (-100, 100), 0) current = int(current_options.get('natural-scaling', 100)) log.debug(" Option: natural-scaling") log.debug(" Current value: %s" % current) self.addItem( "image", "natural-scaling", self.__tr('"Natural" Scaling (relative to image)'), cups.UI_SPINNER, current, (1, 800), 100, suffix=" %") current = int(current_options.get('scaling', 100)) log.debug(" Option: scaling") log.debug(" Current value: %s" % current) self.addItem("image", "scaling", self.__tr("Scaling (relative to page)"), cups.UI_SPINNER, current, (1, 800), 100, suffix=" %") # Misc # PrettyPrint # job-sheets # mirror self.addGroupHeading("misc", self.__tr("Miscellaneous")) log.debug("Group: Misc") current = utils.to_bool(current_options.get( 'prettyprint', '0')) self.addItem( "misc", "prettyprint", self.__tr( '"Pretty Print" Text Documents (Add headers and formatting)' ), cups.PPD_UI_BOOLEAN, current, [], 0) log.debug(" Option: prettyprint") log.debug(" Current value: %s" % current) if not self.cur_device.device_type == DEVICE_TYPE_FAX: current = current_options.get('job-sheets', 'none').split(',') try: start = current[0] except IndexError: start = 'none' try: end = current[1] except IndexError: end = 'none' # TODO: Look for locally installed banner pages beyond the default CUPS ones? self.addItem("misc", "job-sheets", self.__tr("Banner Pages"), cups.UI_BANNER_JOB_SHEETS, (start, end), [("none", self.__tr("No banner page")), ('classified', self.__tr("Classified")), ('confidential', self.__tr("Confidential")), ('secret', self.__tr("Secret")), ('standard', self.__tr("Standard")), ('topsecret', self.__tr("Top secret")), ('unclassified', self.__tr("Unclassified"))], ('none', 'none')) log.debug(" Option: job-sheets") log.debug(" Current value: %s,%s" % (start, end)) current = utils.to_bool(current_options.get('mirror', '0')) self.addItem("misc", "mirror", self.__tr('Mirror Printing'), cups.PPD_UI_BOOLEAN, current, [], 0) log.debug(" Option: mirror") log.debug(" Current value: %s" % current) #Summary #color input #quality quality_attr_name = "OutputModeDPI" cur_outputmode_dpi = cups.findPPDAttribute( quality_attr_name, cur_outputmode) if cur_outputmode_dpi is not None: log.debug("Adding Group: Summary outputmode is : %s" % cur_outputmode) log.debug("Adding Group: Summary outputmode dpi is : %s" % unicode(cur_outputmode_dpi)) self.addGroupHeading("summry", self.__tr("Summary")) self.addItem("summry", "colorinput", self.__tr('Color Input / Black Render'), cups.UI_INFO, cur_outputmode_dpi, [], 0) self.addItem("summry", "quality", self.__tr('Print Quality'), cups.UI_INFO, cur_outputmode, [], 0) self.job_storage_avail = self.cur_device.mq[ 'job-storage'] == JOB_STORAGE_ENABLE #print current_options if self.job_storage_avail: self.addGroupHeading( "jobstorage", self.__tr("Job Storage and Secure Printing")) self.addJobStorage(current_options) #except Exception, e: #log.exception() # pass finally: cups.closePPD() self.loading = False QApplication.restoreOverrideCursor()
def __init__(self, service, parent=None, name=None, fl=0): ScrollView.__init__(self, service, parent, name, fl) self.initJobStorage(True)
num_rows = NUM_LEVELS // LEVELS_PER_ROW level_select_layout = [ level_select_buttons[row * LEVELS_PER_ROW:(row + 1) * LEVELS_PER_ROW] for row in range(NUM_LEVELS // LEVELS_PER_ROW) ] level_select_screen = View(children=[ Text(LEVELS_PER_ROW, 0.5, text="Levels", dest=(0.25, 0.0, 0.5, 0.1), **menu_h2_style), # TODO: some sort of border or bg-color change to differentiate this region ScrollView( children=[GridView(level_select_layout, margins=(12, 0) * 2)], canvas_size_factors=(1.0, 2.0), dest=(0.1, 0.1, 0.8, 0.7), ), Button(text="Back", dest=(0.4, 0.85, 0.2, 0.1), on_click=lambda self, event: self.run_hook("NAVIGATE_BACK"), **menu_button_style) ]) # --- Settings Screen --- # # TODO # --- Credits Screen --- # # TODO hoster = Hoster(
def fillControls(self): QApplication.setOverrideCursor(QApplication.waitCursor) ScrollView.fillControls(self) self.loading = True cups.resetOptions() cups.openPPD(self.cur_printer) cur_outputmode = "" #if 1: try: if 1: #try: current_options = dict(cups.getOptions()) if not self.cur_device.device_type == DEVICE_TYPE_FAX: self.addGroupHeading("basic", self.__tr("Basic")) log.debug("Group: Basic") # Basic # PageSize (in PPD section) # orientation-requested # sides # outputorder # Collate current = current_options.get('orientation-requested', '3') self.addItem("basic", "orientation-requested", self.__tr("Page Orientation"), cups.PPD_UI_PICKONE, current, [('3', self.__tr('Portrait')), ('4', self.__tr('Landscape')), ('5', self.__tr('Reverse landscape')), ('6', self.__tr('Reverse portrait'))], '3') log.debug("Option: orientation-requested") log.debug("Current value: %s" % current) duplexer = self.cur_device.dq.get('duplexer', 0) log.debug("Duplexer = %d" % duplexer) if duplexer: current = current_options.get('sides', 'one-sided') self.addItem("basic", "sides", self.__tr("Duplex (Print on both sides of the page)"), cups.PPD_UI_PICKONE, current, [('one-sided',self.__tr('Single sided')), ('two-sided-long-edge', self.__tr('Two sided (long edge)')), ('two-sided-short-edge', self.__tr('Two sided (short edge)'))], 'one-sided') log.debug("Option: sides") log.debug("Current value: %s" % current) current = current_options.get('outputorder', 'normal') self.addItem("basic", "outputorder", self.__tr("Output Order (Print last page first)"), cups.PPD_UI_PICKONE, current, [('normal', self.__tr('Normal (Print first page first)')), ('reverse', self.__tr('Reversed (Print last page first)'))], 'normal') log.debug("Option: outputorder") log.debug("Current value: %s" % current) current = utils.to_bool(current_options.get('Collate', '0')) self.addItem("basic", "Collate", self.__tr("Collate (Group together multiple copies)"), cups.PPD_UI_BOOLEAN, current, [], 0) log.debug("Option: Collate") log.debug("Current value: %s" % current) groups = cups.getGroupList() for g in groups: log.debug("Group: %s" % repr(g)) if 'jobretention' in g.lower(): log.debug("HPJobRetention skipped.") continue text, num_subgroups = cups.getGroup(g) read_only = 'install' in g.lower() try: text = text.decode('utf-8') except UnicodeDecodeError: pass if g.lower() == 'printoutmode': text = self.__tr("Quality") self.addGroupHeading(g, text, read_only) log.debug(" Text: %s" % repr(text)) log.debug("Num subgroups: %d" % num_subgroups) options = cups.getOptionList(g) for o in options: log.debug(" Option: %s" % repr(o)) if 'pageregion' in o.lower(): log.debug("Page Region skipped.") continue option_text, defchoice, conflicted, ui = cups.getOption(g, o) try: option_text = option_text.decode('utf-8') except UnicodeDecodeError: pass if o.lower() == 'quality': option_text = self.__tr("Quality") log.debug(" Text: %s" % repr(option_text)) log.debug(" Defchoice: %s" % repr(defchoice)) choices = cups.getChoiceList(g, o) value = None choice_data = [] for c in choices: log.debug(" Choice: %s" % repr(c)) # TODO: Add custom paper size controls if 'pagesize' in o.lower() and 'custom' in c.lower(): log.debug("Skipped.") continue choice_text, marked = cups.getChoice(g, o, c) try: choice_text = choice_text.decode('utf-8') except UnicodeDecodeError: pass log.debug(" Text: %s" % repr(choice_text)) if marked: value = c choice_data.append((c, choice_text)) if o.lower() == 'outputmode': if value is not None: cur_outputmode = value else: cur_outputmode = defchoice self.addItem(g, o, option_text, ui, value, choice_data, defchoice, read_only) ## if 'pagesize' in o.lower(): # and 'custom' in c.lower(): ## current = 0.0 ## width_widget = self.addItem("custom", "custom-width", self.__tr("Custom Paper Width"), cups.UI_UNITS_SPINNER, ## current, (0.0, 0.0), 0.0) ## ## current = 0.0 ## height_widget = self.addItem("custom", "custom-height", self.__tr("Custom Paper Height"), cups.UI_UNITS_SPINNER, ## current, (0.0, 0.0), 0.0) ## ## if value.lower() == 'custom': ## pass # N-Up # number-up # number-up-layout # page-border self.addGroupHeading("nup", self.__tr("N-Up (Multiple document pages per printed page)")) log.debug("Group: N-Up") current = current_options.get('number-up', '1') self.addItem("nup", "number-up", self.__tr("Pages per Sheet"), cups.PPD_UI_PICKONE, current, [('1', self.__tr('1 page per sheet')), ('2', self.__tr('2 pages per sheet')), ('4', self.__tr('4 pages per sheet'))], '1') log.debug(" Option: number-up") log.debug(" Current value: %s" % current) current = current_options.get('number-up-layout', 'lrtb') self.addItem("nup", "number-up-layout", self.__tr("Layout"), cups.PPD_UI_PICKONE, current, [('btlr', self.__tr('Bottom to top, left to right')), ('btrl', self.__tr('Bottom to top, right to left')), ('lrbt', self.__tr('Left to right, bottom to top')), ('lrtb', self.__tr('Left to right, top to bottom')), ('rlbt', self.__tr('Right to left, bottom to top')), ('rltb', self.__tr('Right to left, top to bottom')), ('tblr', self.__tr('Top to bottom, left to right')), ('tbrl', self.__tr('Top to bottom, right to left')) ], 'lrtb') log.debug(" Option: number-up-layout") log.debug(" Current value: %s" % current) current = current_options.get('page-border', 'none') self.addItem("nup", "page-border", self.__tr("Printed Border Around Each Page"), cups.PPD_UI_PICKONE, current, [('double', self.__tr("Two thin borders")), ("double-thick", self.__tr("Two thick borders")), ("none", self.__tr("No border")), ("single", self.__tr("One thin border")), ("single-thick", self.__tr("One thick border"))], 'none') log.debug(" Option: page-border") log.debug(" Current value: %s" % current) # Adjustment # brightness # gamma if not self.cur_device.device_type == DEVICE_TYPE_FAX: self.addGroupHeading("adjustment", self.__tr("Printout Appearance")) current = int(current_options.get('brightness', 100)) log.debug(" Option: brightness") log.debug(" Current value: %s" % current) self.addItem("adjustment", "brightness", self.__tr("Brightness"), cups.UI_SPINNER, current, (0, 200), 100, suffix=" %") current = int(current_options.get('gamma', 1000)) log.debug(" Option: gamma") log.debug(" Current value: %s" % current) self.addItem("adjustment", "gamma", self.__tr("Gamma"), cups.UI_SPINNER, current, (1, 10000), 1000) # Margins (pts) # page-left # page-right # page-top # page-bottom ## if 0: ## # TODO: cupsPPDPageSize() fails on LaserJets. How do we get margins in this case? Defaults? ## # PPD file for LJs has a HWMargin entry... ## page, page_width, page_len, left, bottom, right, top = cups.getPPDPageSize() ## ## right = page_width - right ## top = page_len - top ## ## self.addGroupHeading("margins", self.__tr("Margins")) ## current_top = current_options.get('page-top', 0) # pts ## current_bottom = current_options.get('page-bottom', 0) # pts ## current_left = current_options.get('page-left', 0) # pts ## current_right = current_options.get('page-right', 0) # pts ## ## log.debug(" Option: page-top") ## log.debug(" Current value: %s" % current_top) ## ## self.addItem("margins", "page-top", self.__tr("Top margin"), ## cups.UI_UNITS_SPINNER, current_top, ## (0, page_len), top) ## ## self.addItem("margins", "page-bottom", self.__tr("Bottom margin"), ## cups.UI_UNITS_SPINNER, current_bottom, ## (0, page_len), bottom) ## ## self.addItem("margins", "page-left", self.__tr("Right margin"), ## cups.UI_UNITS_SPINNER, current_left, ## (0, page_width), left) ## ## self.addItem("margins", "page-right", self.__tr("Left margin"), ## cups.UI_UNITS_SPINNER, current_right, ## (0, page_width), right) # Image Printing # position # natural-scaling # saturation # hue self.addGroupHeading("image", self.__tr("Image Printing")) current = utils.to_bool(current_options.get('fitplot', 'false')) self.addItem("image", "fitplot", self.__tr("Fit to Page"), cups.PPD_UI_BOOLEAN, current, [], 0) current = current_options.get('position', 'center') self.addItem("image", "position", self.__tr("Position on Page"), cups.PPD_UI_PICKONE, current, [('center', self.__tr('Centered')), ('top', self.__tr('Top')), ('left', self.__tr('Left')), ('right', self.__tr('Right')), ('top-left', self.__tr('Top left')), ('top-right', self.__tr('Top right')), ('bottom', self.__tr('Bottom')), ('bottom-left', self.__tr('Bottom left')), ('bottom-right', self.__tr('Bottom right'))], 'center') log.debug(" Option: position") log.debug(" Current value: %s" % current) if not self.cur_device.device_type == DEVICE_TYPE_FAX: current = int(current_options.get('saturation', 100)) log.debug(" Option: saturation") log.debug(" Current value: %s" % current) self.addItem("image", "saturation", self.__tr("Saturation"), cups.UI_SPINNER, current, (0, 200), 100, suffix=" %") current = int(current_options.get('hue', 0)) log.debug(" Option: hue") log.debug(" Current value: %s" % current) self.addItem("image", "hue", self.__tr("Hue (color shift/rotation)"), cups.UI_SPINNER, current, (-100, 100), 0) current = int(current_options.get('natural-scaling', 100)) log.debug(" Option: natural-scaling") log.debug(" Current value: %s" % current) self.addItem("image", "natural-scaling", self.__tr('"Natural" Scaling (relative to image)'), cups.UI_SPINNER, current, (1, 800), 100, suffix=" %") current = int(current_options.get('scaling', 100)) log.debug(" Option: scaling") log.debug(" Current value: %s" % current) self.addItem("image", "scaling", self.__tr("Scaling (relative to page)"), cups.UI_SPINNER, current, (1, 800), 100, suffix=" %") # Misc # PrettyPrint # job-sheets # mirror self.addGroupHeading("misc", self.__tr("Miscellaneous")) log.debug("Group: Misc") current = utils.to_bool(current_options.get('prettyprint', '0')) self.addItem("misc", "prettyprint", self.__tr('"Pretty Print" Text Documents (Add headers and formatting)'), cups.PPD_UI_BOOLEAN, current, [], 0) log.debug(" Option: prettyprint") log.debug(" Current value: %s" % current) if not self.cur_device.device_type == DEVICE_TYPE_FAX: current = current_options.get('job-sheets', 'none').split(',') try: start = current[0] except IndexError: start = 'none' try: end = current[1] except IndexError: end = 'none' # TODO: Look for locally installed banner pages beyond the default CUPS ones? self.addItem("misc", "job-sheets", self.__tr("Banner Pages"), cups.UI_BANNER_JOB_SHEETS, (start, end), [("none", self.__tr("No banner page")), ('classified', self.__tr("Classified")), ('confidential', self.__tr("Confidential")), ('secret', self.__tr("Secret")), ('standard', self.__tr("Standard")), ('topsecret', self.__tr("Top secret")), ('unclassified', self.__tr("Unclassified"))], ('none', 'none')) log.debug(" Option: job-sheets") log.debug(" Current value: %s,%s" % (start, end)) current = utils.to_bool(current_options.get('mirror', '0')) self.addItem("misc", "mirror", self.__tr('Mirror Printing'), cups.PPD_UI_BOOLEAN, current, [], 0) log.debug(" Option: mirror") log.debug(" Current value: %s" % current) #Summary #color input #quality quality_attr_name = "OutputModeDPI" cur_outputmode_dpi = cups.findPPDAttribute(quality_attr_name, cur_outputmode) if cur_outputmode_dpi is not None: log.debug("Adding Group: Summary outputmode is : %s" % cur_outputmode) log.debug("Adding Group: Summary outputmode dpi is : %s" % unicode (cur_outputmode_dpi)) self.addGroupHeading("summry", self.__tr("Summary")) self.addItem("summry", "colorinput", self.__tr('Color Input / Black Render'), cups.UI_INFO, cur_outputmode_dpi, [], 0) self.addItem("summry", "quality", self.__tr('Print Quality'), cups.UI_INFO, cur_outputmode, [], 0) self.job_storage_avail = self.cur_device.mq['job-storage'] == JOB_STORAGE_ENABLE #print current_options if self.job_storage_avail: self.addGroupHeading("jobstorage", self.__tr("Job Storage and Secure Printing")) self.addJobStorage(current_options) #except Exception, e: #log.exception() # pass finally: cups.closePPD() self.loading = False QApplication.restoreOverrideCursor()
patients2 = ['p116', 'p117', 'p119', 'p120', 'p125'] patients3 = ['p127', 'p128', 'p129', 'p133', 'p135'] # load images and masks images_org = [ sitk.GetArrayFromImage(sitk.ReadImage(os.path.join(patient, "mr_bffe.mhd"))) for patient in patients1 ] # normalize images images_norm = normalization(images_org) fig, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(1, 5, figsize=(25, 5)) ScrollView(images_norm[0]).plot(ax1, cmap='gray') ScrollView(images_norm[1]).plot(ax2, cmap='gray') ScrollView(images_norm[2]).plot(ax3, cmap='gray') ScrollView(images_norm[3]).plot(ax4, cmap='gray') ScrollView(images_norm[4]).plot(ax5, cmap='gray') ax3.set_title("genormaliseerd") fig, (ax6, ax7, ax8, ax9, ax10) = plt.subplots(1, 5, figsize=(25, 5)) ScrollView(images_org[0]).plot(ax6, cmap='gray') ScrollView(images_org[1]).plot(ax7, cmap='gray') ScrollView(images_org[2]).plot(ax8, cmap='gray') ScrollView(images_org[3]).plot(ax9, cmap='gray') ScrollView(images_org[4]).plot(ax10, cmap='gray') ax8.set_title("origineel") plt.show()
def onDeviceChange(self, cur_device=None): self.file_list = [] ScrollView.onDeviceChange(self, cur_device)
itk_image_opr = sitk.ReadImage(opr_image_path) image_array_opr = sitk.GetArrayFromImage(itk_image_opr) pr_image_path = os.path.join(patient, 'prostaat.mhd') itk_image_pr = sitk.ReadImage(pr_image_path) image_array_pr = sitk.GetArrayFromImage(itk_image_pr) mr_image_path = os.path.join(patient, 'mr_bffe.mhd') itk_image_mr = sitk.ReadImage(mr_image_path) image_array_mr = sitk.GetArrayFromImage(itk_image_mr) overlay = image_array_mr - 7000 * image_array_pr fig, (ax1, ax2, ax3, ax4, ax5) = plt.subplots(1, 5, figsize=(25, 5)) ScrollView(image_array_unseen).plot(ax1, cmap='gray') ScrollView(overlay).plot(ax2, cmap='gray') ax1.set_title('Unseen') ax2.set_title('Prostate overlay') # Define a new elastix object 'el' with the correct path to elastix el = elastix.ElastixInterface(elastix_path=ELASTIX_PATH) # Execute the registration. Make sure the paths below are correct, and # that the results folder exists from where you are running this script el.register(fixed_image=unseen_image_path, moving_image=mr_image_path, parameters=[ os.path.join('parameterfiles', 'parameters_affine.txt'), os.path.join('parameterfiles', 'parameters_bspline142.txt') ],
ax.scatter(pos_fixed[0], pos_fixed[1], pos_fixed[2], c='black') ax.set_title('Fixed') ax = fig.add_subplot(1, 3, 2, projection='3d') ax.scatter(pos_moving[0], pos_moving[1], pos_moving[2], c='black') ax.set_title('Moving') ax = fig.add_subplot(1, 3, 3, projection='3d') ax.scatter(pos_transformed[0], pos_transformed[1], pos_transformed[2], c='black') ax.set_title('Transformed') plt.show() ''' #3d beeld test fig, ax = plt.subplots() ScrollView(fixed_img).plot(ax) #resultaat geeft maar een beeld waarmee niet doorheen te scrollen is met touchpad plt.show() ''' ################################################################################################### #quantifying the results #using dice score dice2 = ((2.0 * np.sum(np.logical_and(t_seg_img, fixed_mask))) / (np.sum(t_seg_img) + np.sum(fixed_mask))) print('Dice similarity score 2 is {}'.format(dice2))