Esempio n. 1
0
    def OnLeftDClick(self, event):
        x, y = event.GetX(), event.GetY()

        bDrawDetail = False
        year_idx = -1
        month_idx = -1

        year_idx = self.get_clicked_year(x, y)
        if year_idx >= 0:
            bDrawDetail = True
            self.selected_year = year_idx
        else:
            month_idx = self.get_clicked_month(x, y)
            if month_idx >= 0:
                self.selected_month = month_idx
                bDrawDetail = True

        if bDrawDetail:
            tmpBuffer = wx.EmptyBitmapRGBA(self.bufferWidth, self.bufferHeight,
                                           255, 255, 255, 255)
            dc = wx.BufferedDC(None, tmpBuffer)
            if not 'Linux' in stars.APP_PLATFORM \
               and 'Darwin' != stars.APP_PLATFORM:
                dc = wx.GCDC(dc)
            dc.DrawBitmap(self.buffer, 0, 0)
            dc.SetPen(wx.TRANSPARENT_PEN)
            dc.SetBrush(wx.Brush(wx.Colour(100, 100, 100, 200)))
            dc.DrawRectangle(0, 0, self.bufferWidth, self.bufferHeight)
            if year_idx >= 0:
                self.draw_year_detail(dc, year_idx)
            elif month_idx >= 0:
                self.draw_month_detail(dc, month_idx)
            self.buffer = tmpBuffer
            #dc.Destroy()
            self.Refresh(False)
Esempio n. 2
0
 def process( self,dc,values):
     hue=values['hue']
     import wx
     src=dc.GetAsBitmap()
     w,h=dc.GetSizeTuple()
     #Fill dc with blank
     newdc=wx.MemoryDC()
     white=wx.EmptyBitmapRGBA(w,h,255,255,255,0)
     newdc.SelectObject(white)
     newdc.Brush=wx.Brush(wx.NamedColour('white'),wx.SOLID)
     newdc.DrawRectangle(0,0,w,h)
     #First apply chips mask on the pict
     mask=wx.Mask(wx.Bitmap('plugins/chips/chips_mask.png'),wx.NamedColour('white'))
     src.SetMask(mask)
     newdc.DrawBitmap(src,0,0,True)
     #Then apply chip border on the pict
     img=wx.Image('plugins/chips/chips_border.png')
     img.RotateHue(hue)
     bmp=wx.BitmapFromImage(img)
     #bmp=wx.Bitmap('plugins/chips/chips_border.png')
     mask=wx.Mask(wx.Bitmap('plugins/chips/chips_border_mask.png'),wx.NamedColour('white'))
     bmp.SetMask(mask)
     newdc.DrawBitmap(bmp,0,0,True)
     newdc.SelectObject(wx.NullBitmap)
     del newdc
     #Now, clear the old one & paste the modified bitmap
     dc.Clear()
     #dc.SetBrush(wx.Brush(wx.NamedColour('white'),wx.SOLID))
     #dc.DrawRectangle(0,0,w,h)
     #dc.DrawBitmap(white),0,0)
     dc.DrawBitmap(wx.BitmapFromImage(white.ConvertToImage()),0,0)
Esempio n. 3
0
    def add_cairo_draw(self):
        # EmptyBitmap is deprecated in wxPython 3.0.3
        # buff = wx.Bitmap.FromRGBA(*self.ClientSize)
        buff = wx.EmptyBitmapRGBA(self.ClientSize.x, self.ClientSize.y, 100, 0,
                                  50, 150)
        # buff = wx.EmptyBitmap(*self.ClientSize)
        dc = wx.MemoryDC()
        dc.SelectObject(buff)
        #
        # ctx = wxcairo.ContextFromDC(dc)
        #
        # ctx.set_line_width(3)
        # ctx.set_line_join(cairo.LINE_JOIN_MITER)
        # ctx.set_source_rgba(1.0, 0, 0, 1)
        # ctx.move_to(100, 100)
        # ctx.line_to(300, 300)
        # ctx.fill()

        del dc

        # array = numpy.zeros((self.ClientSize.x, self.ClientSize.y, 4), 'uint8')
        # alpha = 100
        # array[:,:,] = (0, 0, 255 * alpha / 255.0, alpha)
        # self.set_image(array)

        im = buff.ConvertToImage()
        # im = img.getImage("logo_delphi.png")
        im.SaveFile('test.png', wx.BITMAP_TYPE_PNG)
        self.set_image(im)
Esempio n. 4
0
    def __init__(self, parent):
        super(InfoBox, self).__init__(parent)
        self.SetBackgroundColour('#FFFF80')

        self.sizer = wx.GridBagSizer(5, 5)
        self.SetSizer(self.sizer)

        self.attentionBitmap = wx.Bitmap(resources.getPathForImage('attention.png'))
        self.errorBitmap = wx.Bitmap(resources.getPathForImage('error.png'))
        self.readyBitmap = wx.Bitmap(resources.getPathForImage('ready.png'))
        self.busyBitmap = [
            wx.Bitmap(resources.getPathForImage('busy-0.png')),
            wx.Bitmap(resources.getPathForImage('busy-1.png')),
            wx.Bitmap(resources.getPathForImage('busy-2.png')),
            wx.Bitmap(resources.getPathForImage('busy-3.png'))
        ]

        self.bitmap = wx.StaticBitmap(self, -1, wx.EmptyBitmapRGBA(24, 24, red=255, green=255, blue=255, alpha=1))
        self.text = wx.StaticText(self, -1, '')
        self.extraInfoButton = wx.Button(self, -1, 'i', style=wx.BU_EXACTFIT)
        self.sizer.Add(self.bitmap, pos=(0, 0), flag=wx.ALL, border=5)
        self.sizer.Add(self.text, pos=(0, 1), flag=wx.TOP | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL, border=5)
        self.sizer.Add(self.extraInfoButton, pos=(0,2), flag=wx.ALL|wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, border=5)
        self.sizer.AddGrowableCol(1)

        self.extraInfoButton.Show(False)

        self.extraInfoUrl = ''
        self.busyState = None
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.doBusyUpdate, self.timer)
        self.Bind(wx.EVT_BUTTON, self.doExtraInfo, self.extraInfoButton)
        self.timer.Start(100)
Esempio n. 5
0
    def __init__(self, parent):
        super(InfoBox, self).__init__(parent)
        self.SetBackgroundColour('#FFFF80')

        self.sizer = wx.GridBagSizer(5, 5)
        self.SetSizer(self.sizer)

        self.attentionBitmap = toolbarUtil.getBitmapImage('attention.png')
        self.errorBitmap = toolbarUtil.getBitmapImage('error.png')
        self.readyBitmap = toolbarUtil.getBitmapImage('ready.png')
        self.busyBitmap = [
            toolbarUtil.getBitmapImage('busy-0.png'),
            toolbarUtil.getBitmapImage('busy-1.png'),
            toolbarUtil.getBitmapImage('busy-2.png'),
            toolbarUtil.getBitmapImage('busy-3.png')
        ]

        self.bitmap = wx.StaticBitmap(
            self, -1,
            wx.EmptyBitmapRGBA(24, 24, red=255, green=255, blue=255, alpha=1))
        self.text = wx.StaticText(self, -1, '')
        self.sizer.Add(self.bitmap, pos=(0, 0), flag=wx.ALL, border=5)
        self.sizer.Add(self.text,
                       pos=(0, 1),
                       flag=wx.TOP | wx.BOTTOM | wx.ALIGN_CENTER_VERTICAL,
                       border=5)

        self.busyState = None
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.doBusyUpdate, self.timer)
        self.timer.Start(100)
Esempio n. 6
0
	def __init__(self, parent):
		super(workingIndicatorWindow, self).__init__(parent, title='YouMagine', style=wx.FRAME_TOOL_WINDOW|wx.FRAME_FLOAT_ON_PARENT|wx.FRAME_NO_TASKBAR|wx.CAPTION)
		self._panel = wx.Panel(self)
		self.SetSizer(wx.BoxSizer())
		self.GetSizer().Add(self._panel, 1, wx.EXPAND)

		self._busyBitmaps = [
			wx.Bitmap(getPathForImage('busy-0.png')),
			wx.Bitmap(getPathForImage('busy-1.png')),
			wx.Bitmap(getPathForImage('busy-2.png')),
			wx.Bitmap(getPathForImage('busy-3.png'))
		]

		self._indicatorBitmap = wx.StaticBitmap(self._panel, -1, wx.EmptyBitmapRGBA(24, 24, red=255, green=255, blue=255, alpha=1))
		self._statusText = wx.StaticText(self._panel, -1, '...')
		self._progress = wx.Gauge(self._panel, -1)
		self._progress.SetRange(1000)
		self._progress.SetMinSize((250, 30))

		self._panel._sizer = wx.GridBagSizer(2, 2)
		self._panel.SetSizer(self._panel._sizer)
		self._panel._sizer.Add(self._indicatorBitmap, (0, 0), flag=wx.ALL, border=5)
		self._panel._sizer.Add(self._statusText, (0, 1), flag=wx.ALIGN_CENTER_VERTICAL|wx.ALL, border=5)
		self._panel._sizer.Add(self._progress, (1, 0), span=(1,2), flag=wx.EXPAND|wx.ALL, border=5)

		self._busyState = 0
		self._busyTimer = wx.Timer(self)
		self.Bind(wx.EVT_TIMER, self._busyUpdate, self._busyTimer)
		self._busyTimer.Start(100)
Esempio n. 7
0
 def process(self, dc, values):
     from math import cos, sin, radians, pi
     olddc = dc
     w, h = olddc.GetSizeTuple()
     width = 1  #values['width']
     fill = True  #values['Fill']
     scale = values['Scale']
     dc = wx.MemoryDC()
     white = wx.EmptyBitmapRGBA(w, h, 255, 255, 255, 0)
     dc.SelectObject(white)
     #Fill with white
     dc.SetBrush(wx.Brush(wx.NamedColour('white'), wx.SOLID))
     dc.DrawRectangle(0, 0, w, h)
     minimum = min(h, w) / 2
     minimum *= scale
     dc.SetBrush(wx.Brush("black", wx.SOLID))
     dc.DrawCircle(w / 2, h / 2, minimum)
     #Done with the drawing.
     dc.SelectObject(wx.NullBitmap)
     mask = wx.Mask(white, wx.NamedColour('white'))
     bmp = olddc.GetAsBitmap()
     bmp.SetMask(mask)
     dc = olddc
     dc.SetBrush(wx.Brush(wx.NamedColour('white'), wx.SOLID))
     dc.DrawRectangle(0, 0, w, h)
     dc.DrawBitmap(bmp, 0, 0, True)
Esempio n. 8
0
    def _init_canvas(self):
        w, h = self._size
        self._array = np.zeros((h, w, 4), dtype=np.uint8)

        self._cv_image = converters.np_rgba_to_vtk(self._array)

        self.mapper = vtk.vtkImageMapper()
        self.mapper.SetInputData(self._cv_image)
        self.mapper.SetColorWindow(255)
        self.mapper.SetColorLevel(128)

        self.actor = vtk.vtkActor2D()
        self.actor.SetPosition(0, 0)
        self.actor.SetMapper(self.mapper)
        self.actor.GetProperty().SetOpacity(0.99)

        self.canvas_renderer.AddActor2D(self.actor)

        self.rgb = np.zeros((h, w, 3), dtype=np.uint8)
        self.alpha = np.zeros((h, w, 1), dtype=np.uint8)

        self.bitmap = wx.EmptyBitmapRGBA(w, h)
        try:
            self.image = wx.Image(w, h, self.rgb, self.alpha)
        except TypeError:
            self.image = wx.ImageFromBuffer(w, h, self.rgb, self.alpha)
Esempio n. 9
0
 def __init__(self, parent, geo, w_obj):
     wx.Panel.__init__(self,parent,size=(600,600))
     self.status = parent.CreateStatusBar(3)
     self.status.SetStatusWidths([-1,-2,-2])
     self.status.SetStatusText('No Selection',0)
     self.Bind(wx.EVT_SIZE, self.onSize)
     self.Bind(wx.EVT_PAINT, self.onPaint)
     self.Bind(wx.EVT_MOUSE_EVENTS, self.onMouse)
     self.trns = 0
     self.background = (255,255,255,255)
     w,h = self.GetSize()
     self.buffer = wx.EmptyBitmapRGBA(w,h,alpha=self.trns)
     self.geo = geo
     if geo.type == pysal.cg.shapes.Polygon:
         self.drawfunc = self.drawpoly
         self.locator = pysal.cg.PolygonLocator(geo)
     elif geo.type == pysal.cg.shapes.Point:
         self.drawfunc = self.drawpt
         self.locator = pysal.cg.PointLocator(geo)
     else:
         raise TypeError("Unsupported Type: %r"%(geo.type))
     self.w = w_obj
     self._ids = list(range(self.w.n))
     self.transform = WorldToViewTransform(geo.bbox,w,h)
     self.selection = None
Esempio n. 10
0
    def OnInit(self):
        # The wx.StandardPaths aren't available until this is set.
        self.SetAppName('CellProfiler2.0')

        wx.InitAllImageHandlers()

        if self.show_splashbox:
            # If the splash image has alpha, it shows up transparently on
            # windows, so we blend it into a white background.
            splashbitmap = wx.EmptyBitmapRGBA(CellProfilerSplash.GetWidth(),
                                              CellProfilerSplash.GetHeight(),
                                              255, 255, 255, 255)
            dc = wx.MemoryDC()
            dc.SelectObject(splashbitmap)
            dc.DrawBitmap(wx.BitmapFromImage(CellProfilerSplash), 0, 0)
            dc.SelectObject(wx.NullBitmap)
            dc.Destroy()  # necessary to avoid a crash in splashscreen
            self.splash = wx.SplashScreen(
                splashbitmap,
                wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_NO_TIMEOUT, 2000, None,
                -1)
            self.splash_timer = wx.Timer()
            self.splash_timer.Bind(wx.EVT_TIMER, self.destroy_splash_screen)
            self.splash_timer.Start(milliseconds=2000, oneShot=True)
        else:
            self.splash = None

        if self.check_for_new_version:
            self.new_version_check()

        from cellprofiler.gui.cpframe import CPFrame
        self.frame = CPFrame(None, -1, "Cell Profiler")
        self.destroy_splash_screen()
        self.frame.start(self.workspace_path, self.pipeline_path)
        if self.abort_initialization:
            return 0

        # set up error dialog for uncaught exceptions
        def show_errordialog(type, exc, tb):
            def doit():
                cpp.cancel_progress()
                display_error_dialog(
                    self.frame,
                    exc,
                    None,
                    tb=tb,
                    continue_only=True,
                    message="Exception in CellProfiler core processing")
                # continue is really the only choice

            wx.CallAfter(doit)

        # replace default hook with error dialog
        self.orig_excepthook = sys.excepthook
        sys.excepthook = show_errordialog
        self.SetTopWindow(self.frame)
        self.frame.Show()
        if self.frame.startup_blurb_frame.IsShownOnScreen():
            self.frame.startup_blurb_frame.Raise()
        return 1
Esempio n. 11
0
 def draw_popup(self, dc, region=None):
     if self.popupTrendGraph != None:
         self.popupTrendGraph.Close(True)
         self.popupTrendGraph = None
         
     if len(self.selected_shape_ids) == 0:
         return
     
     selected_ids = []
     if self.layer.name in self.selected_shape_ids:
         selected_ids = self.selected_shape_ids[self.layer.name]
         
         
     self.popupTrendGraph = SubTrendGraph(
         self.parent, 
         self.layer, 
         [self.trendgraph_data, selected_ids, self.interval_labels, self.tick, self.time_gstar,self.time_gstar_z, self.t_neighbors]
         )
     self.popupTrendGraph.Hide()
   
     # start draw a popup within window
     if region:
         x,y = region[2],region[3]
     else:
         x,y = self.layer.centroids[selected_ids[0]][0]
         x,y = self.view.view_to_pixel(x,y)
         x,y = int(x),int(y)
     w = int(math.ceil(self.bufferWidth * 0.5))
     if w < 300: w = 300
     if w > 450: w = 450
     h = w * 0.7
     if x + w > self.bufferWidth: 
         if x - w > 0:
             x = x - w
         else:
             x = self.bufferWidth - w
     if y + h > self.bufferHeight: 
         if y - h > 0:
             y = y - h
         else:
             y = self.bufferHeight - h
     
     dc.SetPen(wx.TRANSPARENT_PEN)
     dc.SetBrush(wx.Brush(wx.Color(120,120,120,160)))
     dc.DrawRectangle(x+5,y+h, w, 5)
     dc.DrawRectangle(x+w,y+5, 5, h)
     dc.SetPen(wx.Pen(wx.Color(100,100,100,100)))
     dc.SetBrush(wx.TRANSPARENT_BRUSH)
     dc.DrawRectangle(x,y,w,h)
     
     self.popupTrendGraph.bufferWidth = w
     self.popupTrendGraph.bufferHeight = h
     self.popupTrendGraph.buffer = wx.EmptyBitmapRGBA(w,h,255,255,255,222)
     tmp_dc = wx.BufferedDC(None, self.popupTrendGraph.buffer)
     if not 'Linux' in stars.APP_PLATFORM \
        and 'Darwin' != stars.APP_PLATFORM:
         tmp_dc = wx.GCDC(tmp_dc)
     self.popupTrendGraph.DoDraw(tmp_dc)
     dc.DrawBitmap(self.popupTrendGraph.buffer,x,y)
Esempio n. 12
0
    def GetMongooseLogo(self):
        this_script_filename = os.path.join(os.getcwd(), __file__)
        mongoose_logo_filename = os.path.dirname(os.path.dirname(this_script_filename)) + "/resources/mongoose_small.png"

        if os.path.exists(mongoose_logo_filename):
            return wx.Bitmap(mongoose_logo_filename, wx.BITMAP_TYPE_PNG)
        else:
            return wx.EmptyBitmapRGBA(10, 10)
Esempio n. 13
0
 def removeImage(self):
     panelWidth, panelHeight = self.imagePanel.GetSizeTuple()
     image_blank = wx.EmptyBitmapRGBA(panelWidth,
                                      panelHeight,
                                      red=255,
                                      blue=255,
                                      green=255)
     wx.StaticBitmap(self.imagePanel, wx.ID_ANY, image_blank)
     self.imagePanel.Refresh()
Esempio n. 14
0
    def flag(self):
        import eg
        import wx

        flag = os.path.join(eg.folderPath.imagesDir, 'flags', self.iso_country + '.png')
        if os.path.exists(flag):
            return wx.Bitmap(flag, wx.BITMAP_TYPE_PNG)
        else:
            return wx.EmptyBitmapRGBA(24, 16)
Esempio n. 15
0
def EmptyBitmapRGBA(width, height):
    """Create an empty bitmap with an alpha channel"""
    if hasattr(wx, 'EmptyBitmapRGBA'):
        bmp = wx.EmptyBitmapRGBA(width, height, alpha=0)
    else:
        bmp = wx.EmptyBitmap(width, height, -1)
        if hasattr(bmp, 'UseAlpha'):
            bmp.UseAlpha()
    return bmp
    def display_page(self, pagenum):
        """Sets up UI so that all images on the pagenum are displayed.
        """
        #assert self.imgpaths
        start_idx = (self.num_rows * self.num_cols) * pagenum
        assert start_idx <= len(self.imgpaths)
        i, j = 0, 0
        for idx in range(start_idx,
                         start_idx + (self.num_rows * self.num_cols)):
            if idx >= len(self.imgpaths):
                # No more images to display, just display empty panels.
                cellpanel = self.cells[i][j]
                cellpanel.is_dummy = True
                if self.cell_width == None:
                    # Means only empty pages. Default cell_width to, say, 100.
                    self.cell_width = 100

                dummybitmap = wx.EmptyBitmapRGBA(self.cell_width,
                                                 self.cell_height,
                                                 red=0,
                                                 green=0,
                                                 blue=0)
                cellpanel.set_bitmap(dummybitmap, 1.0)
                cellpanel.set_txtlabel('No image.')
                cellpanel.imgpath = None
            else:
                imgpath = self.imgpaths[idx]
                img = wx.Image(imgpath, wx.BITMAP_TYPE_PNG)  # assume PNG
                if img.GetHeight() != self.cell_height:
                    c = img.GetHeight() / float(self.cell_height)
                    new_w = int(round(img.GetWidth() / c))
                    if self.cell_width == None:
                        self.cell_width = new_w
                    img.Rescale(new_w,
                                self.cell_height,
                                quality=wx.IMAGE_QUALITY_HIGH)
                else:
                    c = 1.0
                    self.cell_width = img.GetWidth()
                cellpanel = self.cells[i][j]
                cellpanel.is_dummy = False
                cellpanel.set_bitmap(wx.BitmapFromImage(img), c)
                imgname = os.path.split(imgpath)[1]
                parentdir = os.path.split(os.path.split(imgpath)[0])[1]
                cellpanel.set_txtlabel(os.path.join(parentdir, imgname))
                cellpanel.imgpath = imgpath
            j += 1
            if j >= self.num_cols:
                j = 0
                i += 1
        self.gridsizer.Layout()
        self.Layout()
        self.SetupScrolling()

        self.Refresh()
Esempio n. 17
0
def rounded_rectangle_region(width, height, radius):
    """
  Returns a rounded rectangle wx.Region
  """
    bmp = wx.EmptyBitmapRGBA(width, height)  # Mask color is #000000
    dc = wx.MemoryDC(bmp)
    dc.Brush = wx.Brush((255, ) * 3)  # Any non-black would do
    dc.DrawRoundedRectangle(0, 0, width, height, radius)
    dc.SelectObject(wx.NullBitmap)
    bmp.SetMaskColour((0, ) * 3)
    return wx.RegionFromBitmap(bmp)
Esempio n. 18
0
    def generate_tile(self):

        size = self.tip.GetTileSize()

        bmp = wx.EmptyBitmapRGBA(size[0],
                                 size[1],
                                 red=random.randint(0, 255),
                                 blue=random.randint(0, 255),
                                 green=random.randint(0, 255),
                                 alpha=255)
        return bmp
Esempio n. 19
0
    def Draw(self, dc):
        self.draw_count += 1

        if self.am.surf is not None:
            h = self.am.surf.get_height()
            w = self.am.surf.get_width()
            # self._Buffer = wx.BitmapFromBufferRGBA(w,h,self.surf.get_data())
            self._Buffer = wx.EmptyBitmapRGBA(w, h)
            self._Buffer.CopyFromBuffer(self.am.surf.get_data(),
                                        format=wx.BitmapBufferFormat_ARGB32)
            dc.SelectObject(self._Buffer)
Esempio n. 20
0
    def MakeHistogramBmp(self, size=None):
        #need to expand the number of points to fill the client size...
        if self.histogram is None:
            return

        if size is None:
            w, h = self.GetClientSize()
        else:
            w, h = size

        n_bins = self.histogram.shape[0]

        #scale the histogram (used for the tooltip)
        indexes = (numpy.arange(w, dtype=numpy.float) * float(n_bins) /
                   float(w)).astype(numpy.int)
        self.histogram_scaled = numpy.take(self.histogram, indexes)

        rect_list = numpy.zeros((n_bins, 4))
        w_rect = int(float(w) / (n_bins))
        missing = w - w_rect * n_bins

        hist = self.histogram / self.histogram_max * h
        y = h
        x = 0
        for i in range(n_bins):
            w_temp = w_rect
            if missing > 0:
                w_temp += 1
                missing -= 1

            rect_list[i, :] = [x, h - hist[i], w_temp, h]
            x += w_temp

        #White image, black columns, will use black as the mask
        buffer = wx.EmptyBitmapRGBA(w, h, 255, 255, 255, 255)

        dc = wx.BufferedDC(None, buffer)
        dc.SetPen(wx.Pen("BLACK", 1))
        dc.SetBrush(wx.Brush("BLACK"))
        dc.DrawRectangleList(rect_list)
        dc.EndDrawing()

        #This avoids the following error:
        #wx._core.PyAssertionError: C++ assertion "!bitmap.GetSelectedInto()" failed
        #at ..\..\src\msw\bitmap.cpp(1509) in wxMask::Create():
        #bitmap can't be selected in another DC
        del dc

        mask = wx.Mask(buffer, wx.BLACK)
        buffer.SetMask(mask)

        self.bmp_histogram = buffer
Esempio n. 21
0
    def OnInit(self):
        '''Initialize CPA
        '''
        '''List of tables created by the user during this session'''
        self.user_tables = []

        # splashscreen
        splashimage = icons.cpa_splash.ConvertToBitmap()
        # If the splash image has alpha, it shows up transparently on
        # windows, so we blend it into a white background.
        splashbitmap = wx.EmptyBitmapRGBA(splashimage.GetWidth(),
                                          splashimage.GetHeight(), 255, 255,
                                          255, 255)
        dc = wx.MemoryDC()
        dc.SelectObject(splashbitmap)
        dc.DrawBitmap(splashimage, 0, 0)
        dc.Destroy()  # necessary to avoid a crash in splashscreen
        splash = wx.SplashScreen(
            splashbitmap, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, 2000,
            None, -1)
        self.splash = splash

        p = Properties.getInstance()
        if not p.is_initialized():
            from guiutils import show_load_dialog
            splash.Destroy()
            if not show_load_dialog():
                logging.error(
                    'CellProfiler Analyst requires a properties file. Exiting.'
                )
                return False
        self.frame = MainGUI(p, None, size=(860, -1))
        self.frame.Show(True)
        db = dbconnect.DBConnect.getInstance()
        db.register_gui_parent(self.frame)

        try:
            if __version__ != -1:
                import cellprofiler.utilities.check_for_updates as cfu
                cfu.check_for_updates('http://cellprofiler.org/CPAupdate.html',
                                      max(__version__,
                                          cpaprefs.get_skip_version()),
                                      new_version_cb,
                                      user_agent='CPAnalyst/2.0.%d' %
                                      (__version__))
        except ImportError:
            logging.warn(
                "CPA was unable to check for updates. Could not import cellprofiler.utilities.check_for_updates."
            )

        return True
Esempio n. 22
0
    def ExportMovie(self, path, duration=3):
        from stars.visualization.utils.images2gif import writeGif, writeBmps2Gif

        Y, M, D = self.start_date.year, self.start_date.month, self.start_date.day  # python.DateTime
        start_date = wx.DateTime.Today()
        start_date.Year, start_date.Month, start_date.Day = Y, M, D

        tick = self.tick
        movie_bmps = []
        for i in range(self.n):
            self.tick = i
            tmp_bmp = wx.EmptyBitmapRGBA(self.bufferWidth, self.bufferHeight,
                                         255, 255, 255, 255)
            dc = wx.MemoryDC()
            dc.SelectObject(tmp_bmp)
            self.isResizing = True
            self.DoDraw(dc)
            self.isResizing = False

            # draw lables
            if i < self.n - 1:
                end_date = wx.DateTime.Today()
                end_date.Set(start_date.Day, start_date.Month, start_date.Year)

                if self.step_by == 'Day':
                    end_date += wx.DateSpan(days=self.step)
                elif self.step_by == 'Month':
                    end_date += wx.DateSpan(months=self.step)
                elif self.step_by == 'Year':
                    end_date += wx.DateSpan(years=self.step)

                label = '(%d/%d) %s/%s/%s - %s/%s/%s (%s %s period)' % \
                      (i+1,self.n, start_date.Month,start_date.Day,start_date.Year,
                       end_date.Month,  end_date.Day,  end_date.Year,self.step, self.step_by
                       )
                start_date.Year, start_date.Day = end_date.Year, end_date.Day
                start_date.SetMonth(end_date.Month)
            else:
                label = '(%d/%d) %s/%s/%s - %s/%s/%s (%s %s period)' % \
                      (i+1,self.n, start_date.Month,start_date.Day,start_date.Year,
                       self.end_date.month,  self.end_date.day,  self.end_date.year,self.step, self.step_by
                       )

            dc.DrawText(label, 5, 5)
            #dc.Destroy()
            movie_bmps.append(tmp_bmp)
        writeBmps2Gif(path, movie_bmps, duration=duration, dither=0)
        self.tick = tick
        self.ShowMsgBox("Movie file (GIF) created successfully.",
                        mtype='CAST information',
                        micon=wx.ICON_INFORMATION)
Esempio n. 23
0
 def _start(self):
     self.size = self.widget.GetSize()
     if not self.size[0] or not self.size[1]:
         self.pdc = wx.PaintDC(self.widget)
     elif const.IS_MSW and self.widget.IsDoubleBuffered():
         self.widget.buffer = wx.EmptyBitmapRGBA(*self.size)
         self.pdc = wx.BufferedPaintDC(self.widget, self.widget.buffer)
     else:
         self.pdc = wx.PaintDC(self.widget)
     try:
         self.dc = wx.GCDC(self.pdc)
     except Exception:
         self.dc = self.pdc
     self.dc.BeginDrawing()
Esempio n. 24
0
    def showPreview(self, pnl):
        sb = wx.StaticBox(pnl, label=" Preview ")

        panel = wx.Panel(pnl, size=(100, 100))
        panel.SetInitialSize()

        sizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
        sizer.Add(panel, 0, wx.EXPAND | wx.ALL | wx.SIMPLE_BORDER, border=1)
        pnl.SetSizer(sizer)

        screenImage = wx.EmptyBitmapRGBA(100, 40, 255, 255, 255, alpha=0)
        self.screenMap = wx.StaticBitmap(panel, bitmap=screenImage)

        self.span = panel
Esempio n. 25
0
def composite_bmp(size, bmps):
	w, h = size
	ret = wx.EmptyBitmapRGBA(w, h, 0, 255, 0, 255)
	position = 0
	dc = wx.MemoryDC()
	dc.SelectObject(ret)
	for bmp in bmps:
		w = bmp.GetSize()[0]
		dc.DrawBitmap(bmp, position, 0, True)
		position += w
	dc.SelectObject(wx.NullBitmap)
	image = ret.ConvertToImage()
	image.SetMaskColour(0, 255, 0)
	return image.ConvertToBitmap()
Esempio n. 26
0
    def _resize_canvas(self, w, h):
        self._array = np.zeros((h, w, 4), dtype=np.uint8)
        self._cv_image = converters.np_rgba_to_vtk(self._array)
        self.mapper.SetInputData(self._cv_image)
        self.mapper.Update()

        self.rgb = np.zeros((h, w, 3), dtype=np.uint8)
        self.alpha = np.zeros((h, w, 1), dtype=np.uint8)

        self.bitmap = wx.EmptyBitmapRGBA(w, h)
        try:
            self.image = wx.Image(w, h, self.rgb, self.alpha)
        except TypeError:
            self.image = wx.ImageFromBuffer(w, h, self.rgb, self.alpha)

        self.modified = True
Esempio n. 27
0
    def OnInit(self):
        # The wx.StandardPaths aren't available until this is set.
        self.SetAppName('CellProfiler2.0')

        wx.InitAllImageHandlers()

        if self.show_splashbox:
            # If the splash image has alpha, it shows up transparently on
            # windows, so we blend it into a white background.
            splashbitmap = wx.EmptyBitmapRGBA(CellProfilerSplash.GetWidth(),
                                              CellProfilerSplash.GetHeight(),
                                              255, 255, 255, 255)
            dc = wx.MemoryDC()
            dc.SelectObject(splashbitmap)
            dc.DrawBitmap(wx.BitmapFromImage(CellProfilerSplash), 0, 0)
            dc.Destroy()  # necessary to avoid a crash in splashscreen
            self.splash = wx.SplashScreen(
                splashbitmap, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT,
                2000, None, -1)

        if self.check_for_new_version:
            self.new_version_check()

        from cellprofiler.gui.cpframe import CPFrame
        self.frame = CPFrame(None, -1, "Cell Profiler")

        # set up error dialog for uncaught exceptions
        def show_errordialog(type, exc, tb):
            def doit():
                display_error_dialog(
                    self.frame,
                    exc,
                    None,
                    tb=tb,
                    continue_only=True,
                    message="Exception in CellProfiler core processing")
                # continue is really the only choice

            wx.CallAfter(doit)

        # replace default hook with error dialog
        self.orig_excepthook = sys.excepthook
        sys.excepthook = show_errordialog

        self.SetTopWindow(self.frame)
        self.frame.Show()
        return 1
Esempio n. 28
0
    def grid_to_buffer1(self):
        """
        Draw GRID based Density Map to wxBitmap. 
        
        Here, directly drawing GRID map onto a RGBA Bitmap.
        Then, this Bitmap will be draw to self.buffer.
        """
        if self.grid.max() == 0:
            return wx.EmptyBitmapRGBA(self.rows, self.cols, 255, 255, 255)

        self.setup_bitmap()

        # make Byte Array
        arr = np.zeros((self.rows, self.cols, 4), np.uint8)
        R, G, B, A = range(4)

        # tranfer 0~1 value to 0~255 pixel values,
        self.raster = self.grid
        rows, cols = self.rows, self.cols
        raster_min, raster_max = self.raster.min(), self.raster.max()
        raster_scaled = (self.raster - raster_min) / (raster_max - raster_min)

        red_matrix, blue_matrix, green_matrix, opaque_matrix = np.zeros((rows,cols)),\
                 np.zeros((rows, cols)), np.zeros((rows,cols)), np.ones((rows,cols))*self.opaque* (255/100.0)

        for i, row in enumerate(raster_scaled):
            for j, item in enumerate(row):
                clr = self.gradient_color.get_color_at(item)

                red_matrix[i][j] = clr.red
                green_matrix[i][j] = clr.green
                blue_matrix[i][j] = clr.blue
                if item < 0.15:
                    opaque_matrix[i][j] = 0

        arr[:, :, R] = (red_matrix).astype("B")
        arr[:, :, G] = (green_matrix).astype("B")
        arr[:, :, B] = (blue_matrix).astype("B")
        arr[:, :, A] = (opaque_matrix).astype("B")  #self.opaque #alpha

        # for export gif
        self.img_array_rgb = arr

        # use the array to create a bitmap
        return wx.BitmapFromBufferRGBA(cols, rows, arr)
Esempio n. 29
0
    def showColor(self, pnl):
        sb = wx.StaticBox(pnl, label=" Color ")

        panel = wx.Panel(pnl, size=(140, 100))
        panel.SetInitialSize()

        sizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
        sizer.Add(panel, 0, wx.EXPAND | wx.ALL | wx.SIMPLE_BORDER, border=1)
        pnl.SetSizer(sizer)
        colorImage = wx.EmptyBitmapRGBA(140, 40, 255, 255, 255, alpha=0)
        self.colorMap = wx.StaticBitmap(panel, -1, bitmap=colorImage)
        self.colorPos = wx.StaticText(panel, -1, 'X: 0, Y: 0', pos=(0, 65))
        self.colorData = wx.StaticText(panel, -1, 'RGB: 0, 0, 0', pos=(0, 45))
        self.colorHint = wx.StaticText(panel,
                                       -1,
                                       'Grab with Ctrl+G',
                                       pos=(0, 85))
        self.cpan = panel
Esempio n. 30
0
    def InitDlg(self):
        self._btbox = DLGButtonPanel(self,style=wx.SUNKEN_BORDER)
      
        self.pnl_bcb = wx.Panel(self)   
        self.cdb_label_list = WX_CDB.getColourList()  
        self.cdb_info_list  = WX_CDB.getColourInfoList()  #

        bcb = BitmapComboBox(self.pnl_bcb,size=(140,-1))
        size_h_w = 16
        slidx=0
        for c in self.color_list:

            idx = self.cdb_label_list.index(c.upper())
            (r,g,b) = self.cdb_info_list[idx][1:]
            bmp = wx.EmptyBitmapRGBA(size_h_w, size_h_w,red=r,green=g,blue=b,alpha= wx.ALPHA_OPAQUE)
            bcb.Append(c, bmp, c)
            self.Bind(wx.EVT_COMBOBOX,self.OnCombo,bcb)
            if ( self.selected_color_label == c ):
               bcb.SetSelection( bcb.GetCount() -1)