Example #1
0
    def GetPPM(self):
        """Get pixel per meter

        .. todo::
            now computed every time, is it necessary?

        .. todo::
            enable user to specify ppm (and store it in UserSettings)
        """
        # TODO: need to be fixed...
        # screen X region problem
        # user should specify ppm
        dc = wx.ScreenDC()
        dpSizePx = wx.DisplaySize()   # display size in pixels
        dpSizeMM = wx.DisplaySizeMM()  # display size in mm (system)
        dpSizeIn = (dpSizeMM[0] / 25.4, dpSizeMM[1] / 25.4)  # inches
        sysPpi = dc.GetPPI()
        comPpi = (dpSizePx[0] / dpSizeIn[0],
                  dpSizePx[1] / dpSizeIn[1])

        ppi = comPpi                  # pixel per inch
        ppm = ((ppi[0] / 2.54) * 100,  # pixel per meter
               (ppi[1] / 2.54) * 100)

        Debug.msg(4, "MapFrameBase.GetPPM(): size: px=%d,%d mm=%f,%f "
                  "in=%f,%f ppi: sys=%d,%d com=%d,%d; ppm=%f,%f" %
                  (dpSizePx[0], dpSizePx[1], dpSizeMM[0], dpSizeMM[1],
                   dpSizeIn[0], dpSizeIn[1],
                   sysPpi[0], sysPpi[1], comPpi[0], comPpi[1],
                   ppm[0], ppm[1]))

        return ppm
Example #2
0
    def OnInit(self):

        Dw, Dh = wx.DisplaySize()
        Dw_mm, Dh_mm =  wx.DisplaySizeMM()

        Dw_i = Dw_mm / 25.4
        Dh_i = Dh_mm / 25.4

        print("The display is %i by %i pixels" %(Dw, Dh))
        print("The display is %i by %i inches" %(Dw_i, Dh_i))
        print("resulting in %i by %i ppi" %(Dw / Dw_i, Dh / Dh_i))

        dc = wx.ScreenDC()
        print(" The system reports : %s PPI" %dc.GetPPI())

        return True
Example #3
0
    def OnInit(self):

        Dw, Dh = wx.DisplaySize()
        Dw_mm, Dh_mm =  wx.DisplaySizeMM()

        Dw_i = Dw_mm / 25.4
        Dh_i = Dh_mm / 25.4

        print("The display is %i by %i pixels" %(Dw, Dh))
        print("The display is %i by %i inches" %(Dw_i, Dh_i))
        print("resulting in %i by %i ppi" %(Dw / Dw_i, Dh / Dh_i))


        frame = MainWindow(None, -1, "Clock")
        self.SetTopWindow(frame)

        return True
Example #4
0
    def __init__(self, *args, **kwargs):
        """Note: The MicroscopeViewport is not fully initialised until setView()
        has been called.
        """
        # Call parent constructor at the end, because it needs the legend panel
        super(MicroscopeViewport, self).__init__(*args, **kwargs)

        # Bind on EVT_SLIDER to update even while the user is moving
        self.bottom_legend.Bind(wx.EVT_LEFT_UP, self.OnSlider)
        self.bottom_legend.Bind(wx.EVT_SLIDER, self.OnSlider)

        # Find out screen pixel density for "magnification" value. This works
        # only with monitors/OS which report correct values. It's unlikely to
        # work with a projector!
        # The 24" @ 1920x1200 screens from Dell have an mpp value of 0.00027 m/px
        self._mpp_screen = 1e-3 * wx.DisplaySizeMM()[0] / wx.DisplaySize()[0]

        # This attribute is set to True if this object (i.e. 'self') was responsible for chaning
        # the HFW value
        self.self_set_hfw = False
        self._fov_va = None # (hardware) VA to follow for HFW
Example #5
0
    def __init__(self, *args, **kwargs):
        """Note: The MicroscopeViewport is not fully initialised until setView()
        has been called.
        """
        # Call parent constructor at the end, because it needs the legend panel
        super(MicroscopeViewport, self).__init__(*args, **kwargs)

        if self.bottom_legend:
            # Bind on EVT_SLIDER to update even while the user is moving
            self.bottom_legend.Bind(wx.EVT_LEFT_UP, self.OnSlider)
            self.bottom_legend.Bind(wx.EVT_SLIDER, self.OnSlider)

        # Find out screen pixel density for "magnification" value. This works
        # only with monitors/OS which report correct values. It's unlikely to
        # work with a projector!
        # The 24" @ 1920x1200 screens from Dell have an mpp value of 0.00027 m/px
        self._mpp_screen = 1e-3 * wx.DisplaySizeMM()[0] / wx.DisplaySize()[0]

        # Set the following attributes to `True` to prevent local mpp/hfw setting loops
        self.self_set_fov = False
        self.self_set_mpp = False

        self.stage_limit_overlay = None
Example #6
0
def DisplayInfo():
    pp = wx.GetDisplayPPI()
    size_pix = wx.GetDisplaySize()
    size_mm = wx.DisplaySizeMM()
    logger.info("---> Display Info: pixel size: {} mm: ~{} ? pp: {}".format(
        size_pix, size_mm, pp))