c2f4dt.plugins.units.plugin
c2f4dt.plugins.units.plugin
¶
FORCE = {'N': 1.0, 'kN': 1000.0, 'MN': 1000000.0, 'lbf': 4.4482216153}
module-attribute
¶
LEN = {'m': 1.0, 'cm': 0.01, 'mm': 0.001, 'µm': 1e-06, 'in': 0.0254, 'ft': 0.3048}
module-attribute
¶
MASS = {'kg': 1.0, 'g': 0.001, 't': 1000.0, 'lb': 0.45359237}
module-attribute
¶
PRESSURE = {'Pa': 1.0, 'kPa': 1000.0, 'MPa': 1000000.0, 'GPa': 1000000000.0, 'bar': 100000.0, 'psi': 6894.757293168}
module-attribute
¶
TEMP = {'°C': ('C',), 'K': ('K',), '°F': ('F',)}
module-attribute
¶
TIME = {'s': 1.0, 'ms': 0.001, 'min': 60.0, 'h': 3600.0}
module-attribute
¶
UnitsDialog
¶
Bases: QDialog
Dialog to select units and perform quick conversions.
Source code in src/c2f4dt/plugins/units/plugin.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
UnitsOverlay
¶
Manages a fixed, screen-anchored units text overlay (bottom-right).
Source code in src/c2f4dt/plugins/units/plugin.py
viewer = viewer3d
instance-attribute
¶
show_text(units)
¶
Show/update the units text in the bottom-right corner.
Respects the font size stored in the UnitsState (overlay_font_size).
Source code in src/c2f4dt/plugins/units/plugin.py
UnitsPlugin
¶
Bases: QObject
Wires menu entry, dialog, and overlay into the host MainWindow.
Source code in src/c2f4dt/plugins/units/plugin.py
action = QtGui.QAction(QtGui.QIcon(), 'Units & Scale…', self)
instance-attribute
¶
overlay = UnitsOverlay(window.viewer3d)
instance-attribute
¶
state = UnitsState()
instance-attribute
¶
window = window
instance-attribute
¶
open_dialog(checked=False)
¶
Source code in src/c2f4dt/plugins/units/plugin.py
UnitsState
dataclass
¶
Source code in src/c2f4dt/plugins/units/plugin.py
density = 'kg/m³'
class-attribute
instance-attribute
¶
energy = 'J'
class-attribute
instance-attribute
¶
force = 'N'
class-attribute
instance-attribute
¶
length = 'm'
class-attribute
instance-attribute
¶
mass = 'kg'
class-attribute
instance-attribute
¶
overlay_font_size = 10
class-attribute
instance-attribute
¶
pressure = 'Pa'
class-attribute
instance-attribute
¶
temperature = '°C'
class-attribute
instance-attribute
¶
time = 's'
class-attribute
instance-attribute
¶
suggest_derived()
¶
Set sensible defaults for derived quantities based on base units.
Source code in src/c2f4dt/plugins/units/plugin.py
convert_linear(value, u_from, from_unit, to_unit)
¶
Generic linear factor conversion (e.g., length, force, pressure).
convert_temperature(value, from_unit, to_unit)
¶
Handle °C/°F/K non-linear conversions.