def draw(self, surface, rect):
        value = self.data_series.latest_value()
        text = (
            self.data_series.name
            + ":  "
            + (("%0." + str(self.decimals) + "f") % value)
            + "  "
            + self.data_series.unit.name
        )

        # Draw label indicator
        surface.lock()
        m1 = 0
        m2 = 1
        s1 = rect.height - 2 * m1
        s2 = rect.height - 2 * m2
        pygame.draw.rect(surface, self.data_series.darker_color, (rect.left + m1, rect.top + m1, s1, s1))
        pygame.draw.rect(surface, self.data_series.color, (rect.left + m2, rect.top + m2, s2, s2))
        surface.unlock()

        # Draw label
        offset = rect.height + 6
        rect.left += offset
        rect.w -= offset
        textutils.drawTextInRect(surface, rect, text, self.color, self.background_color, self.font)
 def draw(self, surface, rect):
     value = getattr(self.host, self.property)
     if value:
         text = self.title + ":  " + self.true_text
         textutils.drawTextInRect(surface, rect, text, self.true_color, self.background_color, self.font)
     else:
         text = self.title + ":  " + self.false_text
         textutils.drawTextInRect(surface, rect, text, self.false_color, self.background_color, self.font)
Example #3
0
 def draw(self, surface, rect):
     value = getattr(self.host, self.property)
     if value:
         text = self.title + ":  " + self.true_text
         textutils.drawTextInRect(surface, rect, text, self.true_color,
                                  self.background_color, self.font)
     else:
         text = self.title + ":  " + self.false_text
         textutils.drawTextInRect(surface, rect, text, self.false_color,
                                  self.background_color, self.font)
Example #4
0
    def draw(self):

        # Margin sizes, in pixels
        displayMargin = 12

        # Get screen rectangle
        base = self.screen.get_rect()
        base = base.inflate(-displayMargin * 2, -displayMargin * 2)

        # Calculate view positions
        view_margin = 10
        helpH = 10
        mainH = base.h - helpH

        # Setup layout
        mainRect, helpRect = layout.split_absolute(base, (mainH, mainH), True,
                                                   view_margin)
        if self.vertical_orientation:
            # A layout where the reactor slices are placed vertically
            generalRect, sliceRect = layout.split_proportional(
                mainRect, (0.6, 0.6), False, view_margin)
            generalRect2, graphRect = layout.split_absolute(
                generalRect, (240, 240), True, view_margin)
            statusRect, pressureRect = layout.split_absolute(
                generalRect2, (260, 260), False, view_margin)
            tempRect, neutronRect = layout.split_rect(sliceRect, 2, False,
                                                      view_margin)
        else:
            # A layout where the reactor slices are placed horizontally
            generalRect, sliceRect = layout.split_proportional(
                mainRect, (0.4, 0.4), True, view_margin)
            statusRect, generalRect2 = layout.split_absolute(
                generalRect, (260, 240), False, view_margin)
            graphRect, pressureRect = layout.split_proportional(
                generalRect2, (0.7, 0.7), False, view_margin)
            tempRect, neutronRect = layout.split_rect(sliceRect, 2, True,
                                                      view_margin)

        # Draw the different views
        self._draw_views("Status", self.status_views, statusRect)
        self._draw_graph("Graphs", self.graph, graphRect)
        self._draw_layer("Pressure", self.pressure, 0, 10.0, pressureRect,
                         False, white, textutils.largeFont)
        self._draw_layers("Temperature", self.temperatures, 300.0, tempRect)
        self._draw_layers("Neutron Flux", self.neutrons, 1.0, neutronRect)
        textutils.drawTextInRect(self.screen,
                                 helpRect,
                                 self.helptext,
                                 background_color=self.background_color,
                                 font=textutils.smallFont)
    def draw(self):

        # Margin sizes, in pixels
        displayMargin = 12

        # Get screen rectangle
        base = self.screen.get_rect()
        base = base.inflate(-displayMargin * 2, -displayMargin * 2)

        # Calculate view positions
        view_margin = 10
        helpH = 10
        mainH = base.h - helpH

        # Setup layout
        mainRect, helpRect = layout.split_absolute(base, (mainH, mainH), True, view_margin)
        if self.vertical_orientation:
            # A layout where the reactor slices are placed vertically
            generalRect, sliceRect = layout.split_proportional(mainRect, (0.6, 0.6), False, view_margin)
            generalRect2, graphRect = layout.split_absolute(generalRect, (240, 240), True, view_margin)
            statusRect, pressureRect = layout.split_absolute(generalRect2, (260, 260), False, view_margin)
            tempRect, neutronRect = layout.split_rect(sliceRect, 2, False, view_margin)
        else:
            # A layout where the reactor slices are placed horizontally
            generalRect, sliceRect = layout.split_proportional(mainRect, (0.4, 0.4), True, view_margin)
            statusRect, generalRect2 = layout.split_absolute(generalRect, (260, 240), False, view_margin)
            graphRect, pressureRect = layout.split_proportional(generalRect2, (0.7, 0.7), False, view_margin)
            tempRect, neutronRect = layout.split_rect(sliceRect, 2, True, view_margin)

        # Draw the different views
        self._draw_views("Status", self.status_views, statusRect)
        self._draw_graph("Graphs", self.graph, graphRect)
        self._draw_layer("Pressure", self.pressure, 0, 10.0, pressureRect, False, white, textutils.largeFont)
        self._draw_layers("Temperature", self.temperatures, 300.0, tempRect)
        self._draw_layers("Neutron Flux", self.neutrons, 1.0, neutronRect)
        textutils.drawTextInRect(
            self.screen, helpRect, self.helptext, background_color=self.background_color, font=textutils.smallFont
        )
Example #6
0
    def draw(self, surface, rect):
        value = self.data_series.latest_value()
        text = self.data_series.name + ":  " + \
               (("%0."+str(self.decimals)+"f") % value) + "  " + \
               self.data_series.unit.name

        # Draw label indicator
        surface.lock()
        m1 = 0
        m2 = 1
        s1 = rect.height - 2 * m1
        s2 = rect.height - 2 * m2
        pygame.draw.rect(surface, self.data_series.darker_color,
                         (rect.left + m1, rect.top + m1, s1, s1))
        pygame.draw.rect(surface, self.data_series.color,
                         (rect.left + m2, rect.top + m2, s2, s2))
        surface.unlock()

        # Draw label
        offset = rect.height + 6
        rect.left += offset
        rect.w -= offset
        textutils.drawTextInRect(surface, rect, text, self.color,
                                 self.background_color, self.font)
Example #7
0
 def draw(self, surface, rect):
     value = getattr(self.host, self.property)
     text = self.title + ":  " + (
         ("%0." + str(self.decimals) + "f") % value) + "  " + self.unit
     textutils.drawTextInRect(surface, rect, text, self.color,
                              self.background_color, self.font)
Example #8
0
 def draw(self, surface, rect):
     value = str(getattr(self.host, self.property))
     text = self.title + ":  " + value + "  " + self.unit
     textutils.drawTextInRect(surface, rect, text, self.color,
                              self.background_color, self.font)
 def draw(self, surface, rect):
     value = getattr(self.host, self.property)
     text = self.title + ":  " + (("%0." + str(self.decimals) + "f") % value) + "  " + self.unit
     textutils.drawTextInRect(surface, rect, text, self.color, self.background_color, self.font)
 def draw(self, surface, rect):
     value = str(getattr(self.host, self.property))
     text = self.title + ":  " + value + "  " + self.unit
     textutils.drawTextInRect(surface, rect, text, self.color, self.background_color, self.font)