Skip to content
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

Implemented rendering for OrGate #1237

Merged
merged 10 commits into from
May 31, 2023

Conversation

rren8957
Copy link

image

Copy link
Member

@LeonMontealegre LeonMontealegre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome start!
There appears to be quite a few visual issues, however:
Screenshot 2023-03-24 at 5 44 09 PM
Screenshot 2023-03-24 at 5 44 47 PM
Screenshot 2023-03-24 at 5 45 04 PM

Comment on lines 36 to 38
const p1 = this.p1;
const p2 = this.p2;
const c = this.c;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's changed this to const { p1, p2, c } = this; -- more succinct !

@@ -24,6 +25,7 @@ export class DigitalCircuitView extends CircuitView {
if (!this.assemblers) {
this.assemblers = {
"ANDGate": new ANDGateAssembler(this.circuit, this, this.selections, this.sim),
"ORGate": new ORGateAssembler(this.circuit, this, this.selections, this.sim),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: put an extra space before the new so that it's vertically aligned with the others

import {SelectionsManager} from "core/internal/impl/SelectionsManager";
import {CircuitView} from "core/internal/view/CircuitView";
import {PortAssembler} from "core/internal/view/PortAssembler";
import {QuadCurve} from "core/internal/view/rendering/prims/QuadCurve";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: spacing

import {DigitalComponentInfo} from "digital/internal/DigitalComponents";
import {DigitalSim} from "digital/internal/sim/DigitalSim";
import {Assembler} from "core/internal/view/Assembler";

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: need 2 blank lines between imports and code

Comment on lines 69 to 71
const transform = this.view.componentTransforms.get(gate.id)!;

const selected = this.selections.has(gate.id);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can put these outside of the loop since they don't depend on i

Copy link
Member

@LeonMontealegre LeonMontealegre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2023-04-13 at 5 51 00 PM

So close but it's still not working for 7/8 inputs!

Definitely try and steal from the old code as much as possible, you shouldn't need to stray from it at all, and lmk if you're encountering problems with that!

Great job so far though !

"ANDGate": new ANDGateAssembler(this.circuit, this, this.selections, this.sim),
"ORGate": new ORGateAssembler(this.circuit, this, this.selections, this.sim),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please re-order the assemblers as they were

"outputs": () => ({ origin: V(0.5, 0), dir: V(1.1, 0) }),
"inputs": (index, total) => {
const spacing = 0.5 - this.options.defaultBorderWidth/2;
return { origin: V(-0.43, spacing*((total-1)/2 - index)), dir: V(-1.3, 0), stroke: {color: "black", size: 1, lineCap: "round"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Format on multiple lines please, like:

return {
  origin: V(...),
  dir: V(...),
  stroke: {...}
};

},
});

this.portAssemblerV2 = new PortAssembler(circuit, view, selections, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see the old code for all the math for the positioners, it shouldnt be this complicated, and you shouldn't need two different ones

https://github.com/OpenCircuits/OpenCircuits/blob/master/src/app/digital/models/ports/positioners/QuadraticCurvePositioner.ts#L27


const c = V(-l, d);

if (numInputs <= 3) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this necessary ?

}

const numInputs = this.getNumInputs(gate);
if (numInputs % 2 === 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need two positioners, you can use total in the positioner to check if it's even or odd and return a different position based on that

Fixed visual issues for input port of size 7 and 8. I didn't exactly used the old code but I did simplify the code to only have 1 positioner/portAssembler.
@LeonMontealegre LeonMontealegre changed the base branch from model_refactor_api_views1 to model_refactor_api May 31, 2023 02:55
@LeonMontealegre LeonMontealegre dismissed their stale review May 31, 2023 02:55

The base branch was changed.

@LeonMontealegre LeonMontealegre merged commit bae2e90 into model_refactor_api May 31, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants