Example #1
0
    def update_labels(self):
        Canvas = self.canvas
        try:
            Canvas.RemoveObject(self.labelGroup)
        except ValueError:
            pass
        self.labelGroup = FloatCanvas.Group()
        for room in self.sim.hospital.layout.values():
            #draw output for allocation room
            if isinstance(room, BedAllocationRoom):
                settings = ROOM_SETTINGS['room_mapping'][type(room)]
                timeToIBA = room.get_time_to_initial_bed_assignment()
                numClosedBeds = room.get_num_closed_beds_by_category()[1]
                self.labelGroup.AddObject(
                    FloatCanvas.ScaledText(
                        "t to IBA = {}({})".format(timeToIBA[0], timeToIBA[1]),
                        (room.guiCoords[0],
                         room.guiCoords[1] - settings[HEIGHT] / 2.0 -
                         ROOM_SETTINGS['name_text_size']),
                        Position="tc",
                        Size=ROOM_SETTINGS['name_text_size']))
                self.labelGroup.AddObject(
                    FloatCanvas.ScaledText(
                        "Num Closed Beds = {}".format(numClosedBeds),
                        (room.guiCoords[0],
                         room.guiCoords[1] - settings[HEIGHT] / 2.0 -
                         2 * ROOM_SETTINGS['name_text_size']),
                        Position="tc",
                        Size=ROOM_SETTINGS['name_text_size']))

        Canvas.AddObject(self.labelGroup)
        Canvas.Draw()
    def test_lib_floatcanvas_fc_scaledtext(self):
        fccanvas = fc.FloatCanvas(self.frame)

        obj = fc.ScaledText("some text", (2, 2), 100)

        fccanvas.AddObject(obj)
        fccanvas.Destroy()
Example #3
0
    def __init__(self,
                 Label,
                 XY,
                 Diameter,
                 TextColor="Black",
                 LineColor="Black",
                 LineStyle="Solid",
                 LineWidth=1,
                 FillColor=None,
                 FillStyle="Solid",
                 InForeground=False,
                 IsVisible=True):
        self.XY = np.asarray(XY, np.float).reshape(2, )

        Label = FC.ScaledText(
            Label,
            self.XY,
            Size=Diameter / 2.0,
            Color=TextColor,
            Position='cc',
        )
        self.Circle = FC.Circle(
            self.XY,
            Diameter,
            FillColor=FillColor,
            LineStyle=None,
        )
        FC.Group.__init__(self, [self.Circle, Label], InForeground, IsVisible)
Example #4
0
    def draw_generic_patient(self, gender, number, observedCP, patientCoords):
        settings = PATIENT_SETTINGS
        group = FloatCanvas.Group()

        if gender == MALE:
            lineColor = settings['line_color_male']
        else:
            lineColor = settings['line_color_female']

        MRSAStr = observedCP[0] and "M+" or "M-"
        VREStr = observedCP[1] and "V+" or "V-"
        group.AddObject(
            FloatCanvas.Circle(patientCoords,
                               settings['radius'] * 2,
                               LineWidth=settings['line_width'],
                               LineColor=lineColor,
                               FillStyle="Solid"))
        group.AddObject(
            FloatCanvas.ScaledText("x {0}".format(number),
                                   patientCoords,
                                   Position="cc",
                                   Size=settings['id_text_size'],
                                   Weight=wx.BOLD))
        group.AddObject(
            FloatCanvas.ScaledText(str(MRSAStr),
                                   (patientCoords[0] - settings['radius'],
                                    patientCoords[1] + settings['radius']),
                                   Position="cc",
                                   Size=settings['acuity_text_size'],
                                   Weight=wx.BOLD))
        group.AddObject(
            FloatCanvas.ScaledText(str(VREStr),
                                   (patientCoords[0] + settings['radius'],
                                    patientCoords[1] + settings['radius']),
                                   Position="cc",
                                   Size=settings['acuity_text_size'],
                                   Weight=wx.BOLD))

        return group
Example #5
0
 def __init__(
     self,
     Label,
     XY,
     WH,
     BackgroundColor="Yellow",
     TextColor="Black",
     InForeground=False,
     IsVisible=True,
 ):
     XY = N.asarray(XY, N.float).reshape(2)
     WH = N.asarray(WH, N.float).reshape(2)
     Label = FC.ScaledText(Label, XY, Size=WH[1] / 2.0, Color=TextColor, Position="cc")
     self.Ellipse = FC.Ellipse((XY - WH / 2.0), WH, FillColor=BackgroundColor, LineStyle=None)
     FC.Group.__init__(self, [self.Ellipse, Label], InForeground, IsVisible)
Example #6
0
    def __init__(self, node, config, InForeground=False, IsVisible=True):
        Label = node.name
        location = config.Point(node)
        self.connectors = sets.Set([])

        BackgroundColor = config.getNodeColor(node)
        TextColor = config.getNodeTextColor(node)
        shape = config.getNodeShape(node)
        locationArray = N.asarray(location, N.float).reshape(2, )
        WH = N.asarray(config.getRectangleSize(), N.float).reshape(2, )
        #print "Node %s: Location = %s, WH = %s"%(Label, locationArray, WH)
        self.Node = node
        scaler = 1. + len(Label) / 7.0
        self.Label = FC.ScaledText(
            Label,
            locationArray,
            Size=WH[1] / scaler,
            Color=TextColor,
            Position='cc',
        )
        if shape == "rectangle":
            self.Shape = FC.Rectangle(
                (locationArray - WH / 2.0),
                WH,
                FillColor=BackgroundColor,
                LineStyle=None,
            )
        elif shape == "ellipse":
            self.Shape = FC.Ellipse(
                (locationArray - WH / 2.0),
                WH,
                FillColor=BackgroundColor,
                LineStyle=None,
            )
        else:
            print "Error. Unknown shape: %s" % (shape, )
        FC.Group.__init__(self, [self.Shape, self.Label], InForeground,
                          IsVisible)
Example #7
0
 def create_text(self, caption):
   "Creates a floatcanvas.Text control with calculated position (over shape)."""
   
   self.text = fc.ScaledText(caption, self.get_text_left_top(), Size =  FONT_SIZE, Color = "Black", BackgroundColor = "#B0B0B0", Family = wx.SWISS, Style = wx.NORMAL,
     Weight = wx.BOLD, Underlined = False, Position = 'bc', InForeground = False, Font = None)
Example #8
0
    def draw_patient(self, patient, patientCoords):
        settings = PATIENT_SETTINGS
        group = FloatCanvas.Group()
        if isinstance(patient, CleaningPatient):
            fillColor = settings['fill_color_cleaning']
            lineWidth = settings['line_width']
            lineColor = settings['line_color_cleaning']
        else:
            if patient.gender == MALE:
                lineColor = settings['line_color_male']
            else:
                lineColor = settings['line_color_female']

            patID = patient.id
            fillColor = None
            lineWidth = patient.acuity
            if isinstance(patient, PhantomPatient):
                fillColor = settings['fill_color_phantom']
                patID = patient.realPatient.id

        group.AddObject(
            FloatCanvas.Circle(patientCoords,
                               settings['radius'] * 2,
                               LineWidth=lineWidth,
                               LineColor=lineColor,
                               FillColor=fillColor,
                               FillStyle="Solid"))

        if isinstance(patient, BasePatient):
            #id num
            group.AddObject(
                FloatCanvas.ScaledText(str(patID),
                                       patientCoords,
                                       Position="cc",
                                       Size=settings['id_text_size'],
                                       Weight=wx.BOLD))
            #acuity num
            group.AddObject(
                FloatCanvas.ScaledText(str(patient.acuity),
                                       (patientCoords[0] - settings['radius'],
                                        patientCoords[1] - settings['radius']),
                                       Position="cc",
                                       Size=settings['acuity_text_size'],
                                       Weight=wx.BOLD))
            #service
            group.AddObject(
                FloatCanvas.ScaledText(str(patient.service),
                                       (patientCoords[0] + settings['radius'],
                                        patientCoords[1] - settings['radius']),
                                       Position="cc",
                                       Size=settings['acuity_text_size'],
                                       Weight=wx.BOLD))
            #MRSA VRE
            MRSAStr = patient.has_observed_MRSA() and "M+" or "M-"
            VREStr = patient.has_observed_VRE() and "V+" or "V-"
            group.AddObject(
                FloatCanvas.ScaledText(str(MRSAStr),
                                       (patientCoords[0] - settings['radius'],
                                        patientCoords[1] + settings['radius']),
                                       Position="cc",
                                       Size=settings['acuity_text_size'],
                                       Weight=wx.BOLD))
            group.AddObject(
                FloatCanvas.ScaledText(str(VREStr),
                                       (patientCoords[0] + settings['radius'],
                                        patientCoords[1] + settings['radius']),
                                       Position="cc",
                                       Size=settings['acuity_text_size'],
                                       Weight=wx.BOLD))
        else:
            group.AddObject(
                FloatCanvas.ScaledText("C",
                                       patientCoords,
                                       Position="cc",
                                       Size=settings['id_text_size'],
                                       Weight=wx.BOLD))

        return group