-
-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Shortcuts to Analog #1236
base: master
Are you sure you want to change the base?
Changes from 33 commits
7004762
7d5c4a6
da564d6
f9b294a
f5282b2
aff01e3
23072db
eb234c2
f65b28b
f32d841
ac829df
e92c6b4
26ed986
7e47c19
d4e3bfb
ea3bc05
1d0063c
f6723fd
fee73d8
f7f9260
c9ef735
c935eee
fc748c9
d9917bf
baede46
306a2a2
356eaef
2e2f64b
f0e7fea
edbb90b
07129e3
5366f66
16ade67
f7676e0
dc58924
9363902
a946c42
378fa44
7ffdb05
80a69c9
61c11d9
c324979
3261af5
d5ab908
bcfab3c
7ac5c3a
0216058
f1decfd
463c21e
c8d4807
babad5c
065af2d
c97919f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# DC Analysis | ||
1. Performing Analysis when DC Sources are Used | ||
* DC sources mean all sources should be applying a constant current/voltage. | ||
* This Analysis would be similar to running with "DC Operating Point" in LTSpice | ||
2. This Analysis Can Not be Validly Performed with Time-Varying Signals | ||
* Output results should be invalid as it makes no sense to have time-varying signals in a DC Analysis. | ||
3. Linear (IV-curve) Components Have their Properties Determined According to Simple Linear Equations | ||
* These include Resistors whose properties are dictated by Ohm's Law (V = I*R). | ||
4. Nonlinear Components Could have their DC Steady State Values Reported | ||
* These components include Inductors and Capacitors whose voltages/currents will change with time even as a DC signal is applied to them | ||
* A DC Analysis essentially take the limit as time goes to infinity in these instances, resulting in reporting the "DC Steady States" of these components. These will be DC values that reflect the values which properties of these components wil always be moving closer towards. | ||
5. DC Analysis Results can Simply be Output in a new Window or Text Box | ||
* Using an Oscilloscope to plot DC values would only result in a bunch of straight lines. Instead of this the output can simply be the calulated values themselves (rounded to a reasonable number of significant digits) with there associated component or node. | ||
* The voltages for each node can be reported along with the currents through each component. | ||
* If the node was labeled by the user, then this label should show up in in the report as well. This should only be applied to labeled nodes as it allows the user to isolate certain nodes for their analysis. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Future Quality of Life Improvements | ||
1. Example Circuits | ||
* Updated Example Analog Circuits would help get new users started | ||
* These circuits could be loaded in for users to be able to mess around with running the simulation | ||
* We included samples of Voltage Divider, Series RC (Resistor-Capacitor), Series RL (Resistor-Inductor), and Series RLC (Resistor-Capacitor-Inductor) circuits. | ||
|
||
Circuit 1: Voltage Divider/ Nodal Analysis Example: | ||
|
||
<img width="214" alt="image" src="https://user-images.githubusercontent.com/62410569/221334248-90228e65-eeb7-4834-9a55-b96002d1caaf.png"> | ||
Circuit 2: RC(Resistor-Capacitor) Example Circuit (Series) | ||
|
||
<img width="217" alt="image" src="https://user-images.githubusercontent.com/62410569/221334297-ad60b34e-ce39-4fb9-86dd-90a81ecd22a0.png"> | ||
Circuit 3: RL(Resistor-Inductor) Example Circuit (Series) | ||
|
||
<img width="218" alt="image" src="https://user-images.githubusercontent.com/62410569/221334315-f2560146-a974-47a8-bff1-359fd890e0a8.png"> | ||
Circuit 4: RLC(Resistor-Inductor-Capacitor) Example Circuit (Series) | ||
|
||
<img width="219" alt="image" src="https://user-images.githubusercontent.com/62410569/221334332-ac3f7c30-49a7-4453-bd17-b4a8e5588695.png"> | ||
|
||
2. Implementing Keyboard Shortcuts | ||
* Users would be able to quickly and easily bring up commonly used components using keyboard shortcuts | ||
* These shortcuts should correspond with their associated components (i.e. "v" for Voltage Source) | ||
3. Display Component Values Next to Their Models | ||
* Resistances, capacitance values, inductance values, and all values for sources should be shown next to or near the associatedd components | ||
4. Wires and Components Should Automatically Snap into Positions | ||
* Wires should naturally snap to 90 degree angles so wirings for more complicated circuits can be less confusing | ||
5. Deleting the Oscilloscope | ||
* Currently, removing the Oscilloscope also deletes all attached wires which should not be the case. | ||
6. Uploading Your Own Components/Models | ||
* Expand functionalities and component libraries by allowing users to uploaded pre-formatted circuit component files that can be parsed into actual usable models. | ||
* This can include modeling specific real-world components if the data reflects that components (expected) behaviors. | ||
7. Component Information Does Not Work | ||
* Currently, clicking on the "learn about this component" button does nothing for all of the components. Can fix this by linking a wikipedia page to the button. | ||
<img width="149" alt="image" src="https://user-images.githubusercontent.com/62410569/222838727-b0379451-c131-4c4e-ba7e-cc0a6652cf8e.png"> | ||
|
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ import {DragDropHandlers} from "shared/components/DragDroppable/DragDropHandlers | |
import {Draggable} from "shared/components/DragDroppable/Draggable"; | ||
|
||
import styles from "./index.scss"; | ||
import { boolean } from "yargs"; | ||
|
||
|
||
export type ItemNavItem = { | ||
|
@@ -53,13 +54,16 @@ type Props<D> = { | |
info: CircuitInfo; | ||
config: ItemNavConfig; | ||
additionalData?: D; | ||
shortcuts: string[][]; | ||
getImgSrc: (c: Component) => string; | ||
onStart?: () => void; | ||
onFinish?: (cancelled: boolean) => void; | ||
onDelete?: (section: ItemNavSection, item: ItemNavItem) => boolean; | ||
additionalPreview?: (data: D, curItemID: string) => React.ReactNode; | ||
} | ||
export const ItemNav = <D,>({ info, config, additionalData, getImgSrc, onDelete, | ||
let shortcut_flag:boolean = false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No no, gotta make a React state variable for this, look at Also please make sure to follow the style guidelines that the rest of OpenCircuits uses, i.e. camelCase naming |
||
|
||
export const ItemNav = <D,>({ info, config, additionalData, getImgSrc, shortcuts, onDelete, | ||
onStart, onFinish, additionalPreview }: Props<D>) => { | ||
const { isOpen, isEnabled, isHistoryBoxOpen, curItemID } = useSharedSelector( | ||
(state) => ({ ...state.itemNav }) | ||
|
@@ -86,6 +90,7 @@ export const ItemNav = <D,>({ info, config, additionalData, getImgSrc, onDelete, | |
// State to keep track of drag'n'drop preview current image | ||
const [curItemImg, setCurItemImg] = useState(""); | ||
|
||
|
||
// Keep track of a separate 'currentlyPressedObj' in tandem with `info.currentlyPressedObj` so that | ||
// we can use it to potentially delete the object if its dragged over to the ItemNav (issue #478) | ||
const [currentlyPressedObj, setCurPressedObj] = useState(undefined as (Selectable | undefined)); | ||
|
@@ -94,6 +99,24 @@ export const ItemNav = <D,>({ info, config, additionalData, getImgSrc, onDelete, | |
if (info.currentlyPressedObject) | ||
setCurPressedObj(info.currentlyPressedObject); | ||
}); | ||
// Loops through the shorcuts 2d array in AnalogItemNav to see if any shortcuts | ||
useDocEvent("keydown", (ev) => { | ||
// Loop through each of the input shortcuts | ||
for (var short of shortcuts){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Never use var, use |
||
if (ev.key === short[0]){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add space between |
||
const id = short[1]; | ||
const section = config.sections.find((s) => (s.items.find((i) => i.id === id))); | ||
dispatch(SetCurItem(id)); | ||
setNumClicks(id.toLowerCase() === curItemID ? numClicks+1 : 1); | ||
setCurItemImg(`/${config.imgRoot}/${section?.id}/${id.toLowerCase().concat(".svg")}`) | ||
onStart && onStart(); | ||
shortcut_flag = true | ||
ev.stopPropagation(); | ||
} | ||
} | ||
|
||
|
||
}) | ||
useDocEvent("mouseup", () => setCurPressedObj(undefined)); | ||
useDocEvent("mouseleave", () => setCurPressedObj(undefined)); | ||
function handleItemNavDrag() { // Issue #478 | ||
|
@@ -118,6 +141,17 @@ export const ItemNav = <D,>({ info, config, additionalData, getImgSrc, onDelete, | |
|
||
// Drop the current item on click (or on touch end) | ||
useDocEvent("click", (ev) => { | ||
// If keyboard shorcut used to bring up component then allow to drop until "Esc" pressed | ||
if(shortcut_flag){ | ||
julianchen215 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
DragDropHandlers.drop(V(ev.x, ev.y), curItemID, 1, additionalData); | ||
const section = config.sections.find((s) => (s.items.find((i) => i.id === curItemID))); | ||
dispatch(SetCurItem(curItemID)); | ||
setNumClicks(1); | ||
setCurItemImg(`/${config.imgRoot}/${section?.id}/${curItemID.toLowerCase().concat(".svg")}`) | ||
onStart && onStart(); | ||
return; | ||
} | ||
|
||
// If holding shift then drop only a single item (issue #1043) | ||
if (isShiftDown && numClicks > 1) { | ||
DragDropHandlers.drop(V(ev.x, ev.y), curItemID, 1, additionalData); | ||
|
@@ -163,6 +197,7 @@ export const ItemNav = <D,>({ info, config, additionalData, getImgSrc, onDelete, | |
// Cancel placing when pressing escape | ||
useWindowKeyDownEvent("Escape", () => { | ||
reset(true); | ||
shortcut_flag = false | ||
}); | ||
|
||
// Also cancel on Right Click | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?