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

nens / ThreeDiToolbox / #2575

01 Sep 2025 02:58PM UTC coverage: 35.211% (-0.02%) from 35.234%
#2575

push

coveralls-python

web-flow
Merge 048baa677 into 180713118

3 of 20 new or added lines in 4 files covered. (15.0%)

4851 of 13777 relevant lines covered (35.21%)

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✔
15
        super().__init__(parent)
×
16
        self.showGrid(True, True, 0.5)
×
17
        self.fraction_model = fraction_model
×
18
        self.result_model = result_model
×
19
        self.item_map = {}
×
20
        self.setLabel("bottom", "Time", "hrs")
×
21
        self.setLabel("left", "Concentration", "")
×
22
        self.getAxis("left").enableAutoSIPrefix(False)
×
23

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

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

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

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

61
            prev_plot = plot
×
62

NEW
63
        self.setLabel("left", "Concentration", "m<sup>3</sup>" if volume else substance_unit)
×
64
        self.plotItem.vb.menu.viewAll.triggered.emit()
×
65

66
    def reduce_saturation(self, plot_color):
1✔
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