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_layers(self, name, data_cube, scale, rect, label_color=white, label_font=textutils.largeFont):
        # Create title and get remaining space
        content = layout.make_titled_rect(self.screen, rect, name, label_color, self.background_color, label_font)

        # Calculate layer positions
        layer_separation = 2
        layer_rects = layout.split_rect(content, reactor.reactor_depth, self.vertical_orientation, layer_separation)

        # Draw layers
        for z in self.depth_range:
            label = "Level " + str(z + 1)
            self._draw_layer(label, data_cube, z, scale, layer_rects[z])
    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_views(self, title, views, rect, label_color=white, label_font=textutils.largeFont):
        # Create title and get remaining space
        content = layout.make_titled_rect(
            self.screen, rect, title, label_color, self.background_color, label_font, 8, 4
        )

        # Layout the views
        num = len(views)
        view_separation = 6
        height = sum(map(lambda v: v.height(), views)) + view_separation * (num - 1)
        if content.h > height:
            content.h = height
        view_rects = layout.split_rect(content, num, True, view_separation)

        # Draw views
        for i in range(0, num):
            view = views[i]
            view.draw(self.screen, view_rects[i])
    def _draw_layers(self,
                     name,
                     data_cube,
                     scale,
                     rect,
                     label_color=white,
                     label_font=textutils.largeFont):
        # Create title and get remaining space
        content = layout.make_titled_rect(self.screen, rect, name, label_color,
                                          self.background_color, label_font)

        # Calculate layer positions
        layer_separation = 2
        layer_rects = layout.split_rect(content, reactor.reactor_depth,
                                        self.vertical_orientation,
                                        layer_separation)

        # Draw layers
        for z in self.depth_range:
            label = "Level " + str(z + 1)
            self._draw_layer(label, data_cube, z, scale, layer_rects[z])
    def _draw_views(self,
                    title,
                    views,
                    rect,
                    label_color=white,
                    label_font=textutils.largeFont):
        # Create title and get remaining space
        content = layout.make_titled_rect(self.screen, rect, title,
                                          label_color, self.background_color,
                                          label_font, 8, 4)

        # Layout the views
        num = len(views)
        view_separation = 6
        height = sum(map(lambda v: v.height(),
                         views)) + view_separation * (num - 1)
        if content.h > height: content.h = height
        view_rects = layout.split_rect(content, num, True, view_separation)

        # Draw views
        for i in range(0, num):
            view = views[i]
            view.draw(self.screen, view_rects[i])