Add oscilloscope charge plotting for capacitors#248
Add oscilloscope charge plotting for capacitors#248pfalstad merged 2 commits intopfalstad:v3-devfrom
Conversation
Add VAL_CHARGE and UNITS_C to Scope so users can view stored charge (Q=CV) on the oscilloscope for capacitor elements. Adds a "Show Charge" checkbox in scope properties when the scope is attached to a capacitor. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
When you check "Show Charge" it doesn't show the voltage/current anymore but they are still checked. Then if you uncheck Voltage and check it again, it shows the voltage and not the charge, even though charge is still checked. |
…Current() to AnalogMuxElm - Reverted all charge plotting additions (VAL_CHARGE, UNITS_C, canShowCharge, showcharge) from Scope.java, ScopePropertiesDialog.java, and CapacitorElm.java. Charge plotting is handled separately in PR pfalstad#248. - Added calculateCurrent() to AnalogMuxElm to compute pin currents for correct current animation and wire current behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The Show Charge checkbox was calling setValue(VAL_CHARGE) which replaced all existing plots (voltage, current) with just a charge plot. Now uses a new showCharge() method that additively adds/removes a charge plot without affecting other plots. Also updates showingVoltageAndMaybeCurrent() to allow charge plots alongside voltage/current, and adds chargeBox state tracking in the scope properties dialog. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Fixed charge plotting toggle — Show Charge now works independently alongside Show Voltage and Show Current. All three can be displayed simultaneously without interfering with each other. |
|
Fixed charge plotting toggle: The root cause was that handleMenu(showcharge) called setValue(VAL_CHARGE), which replaced the entire plots vector -- destroying voltage and current plots. Now uses a new showCharge(boolean) method that additively adds/removes the charge plot without affecting other plots. Also updated showingVoltageAndMaybeCurrent() to allow charge alongside voltage/current, preventing the destroy-on-recheck behavior. All three (voltage, current, charge) can now be displayed simultaneously and toggled independently. |
Summary
VAL_CHARGEandUNITS_Cconstants in Scope.javagetScopeValue()/getScopeUnits()for charge displayTest plan
Fixes #202
🤖 Generated with Claude Code