• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nens / ThreeDiToolbox / #2515

08 May 2025 10:15AM UTC coverage: 35.003% (-0.3%) from 35.309%
#2515

push

coveralls-python

web-flow
Merge 2d1953d12 into 065250262

145 of 528 new or added lines in 9 files covered. (27.46%)

4739 of 13539 relevant lines covered (35.0%)

0.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

27.08
/tool_fraction_analysis/fraction_plot.py
1
from qgis.PyQt.QtGui import QColor
1✔
2

3
import pyqtgraph as pg
1✔
4

5

6
pg.setConfigOption("background", "w")
1✔
7
pg.setConfigOption("foreground", "k")
1✔
8
from PyQt5.QtCore import Qt
1✔
9
from threedi_results_analysis.threedi_plugin_model import ThreeDiPluginModel
1✔
10
from threedi_results_analysis.tool_fraction_analysis.fraction_model import FractionModel
1✔
11

12

13
class FractionPlot(pg.PlotWidget):
1✔
14
    def __init__(self, parent, result_model: ThreeDiPluginModel, fraction_model: FractionModel):
1✔
NEW
15
        super().__init__(parent)
×
NEW
16
        self.showGrid(True, True, 0.5)
×
NEW
17
        self.fraction_model = fraction_model
×
NEW
18
        self.result_model = result_model
×
NEW
19
        self.item_map = {}
×
NEW
20
        self.setLabel("bottom", "Time", "hrs")
×
NEW
21
        self.setLabel("left", "Concentration", "")
×
NEW
22
        self.getAxis("left").enableAutoSIPrefix(False)
×
23

24
    def clear_plot(self):
1✔
NEW
25
        self.clear()
×
NEW
26
        self.item_map.clear()
×
NEW
27
        self.setLabel("left", "Concentration", "")
×
28

29
    def item_changed(self, model_item):
1✔
NEW
30
        substance = model_item.data()
×
NEW
31
        for plot in self.item_map[substance]:
×
NEW
32
            plot.setVisible(model_item.checkState() == Qt.Checked)
×
33

34
    def fraction_selected(self, feature_id, substance_unit: str, time_unit: str, stacked: bool):
1✔
35
        """
36
        Retrieve info from model and create plots
37
        """
NEW
38
        self.clear_plot()
×
NEW
39
        plots = self.fraction_model.create_plots(feature_id, time_unit, stacked)
×
NEW
40
        prev_plot = None
×
NEW
41
        for substance, plot in plots:
×
NEW
42
            self.item_map[substance] = [plot]
×
NEW
43
            plot.setZValue(100)
×
NEW
44
            self.addItem(plot)
×
45

NEW
46
            if stacked:
×
47
                # Add fill between consecutive plots
NEW
48
                plot_color = plot.opts['pen'].color()
×
49
                # Reduce saturation for fill
NEW
50
                fill_color = self.reduce_saturation(plot_color)
×
NEW
51
                if not prev_plot:
×
52
                    # this is the first, just fill downward to axis
NEW
53
                    plot.setFillLevel(0)
×
NEW
54
                    plot.setFillBrush(pg.mkBrush(fill_color))
×
55
                else:
NEW
56
                    fill = pg.FillBetweenItem(plot, prev_plot, pg.mkBrush(fill_color))
×
NEW
57
                    fill.setZValue(20)
×
NEW
58
                    self.addItem(fill)
×
NEW
59
                    self.item_map[substance].append(fill)
×
60

NEW
61
            prev_plot = plot
×
62

NEW
63
        self.setLabel("left", "Concentration", substance_unit)
×
NEW
64
        self.plotItem.vb.menu.viewAll.triggered.emit()
×
65

66
    def reduce_saturation(self, plot_color):
1✔
NEW
67
        return QColor.fromHsvF(plot_color.hueF(), plot_color.saturationF()/2.0, plot_color.valueF())
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc