Skip to content

Commit

Permalink
edit vadjust
Browse files Browse the repository at this point in the history
  • Loading branch information
chgibb committed Sep 15, 2019
1 parent 050be4f commit 49b0467
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
Expand Up @@ -16,6 +16,7 @@ import {changeContigText} from "./editCache/changeContigText";
import {changeContigBodyColour} from "./editCache/changeContigBodyColour";
import {changeContigTextColour} from "./editCache/changeContigTextColour";
import {changeContigOpacity} from "./editCache/changeContigOpacity";
import { changeContigVadjust } from './editCache/changeContigVadjust';

export interface CircularGenomeBuilderViewState {
figureSelectOvelayOpen: boolean;
Expand Down Expand Up @@ -44,6 +45,7 @@ export class CircularGenomeBuilderView extends React.Component<CircularGenomeBui
protected changeContigBodyColour = changeContigBodyColour.bind(this);
protected changeContigTextColour = changeContigTextColour.bind(this);
protected changeContigOpacity = changeContigOpacity.bind(this);
protected changeContigVadjust = changeContigVadjust.bind(this);
private GenomeBuilderAppBar = GenomeBuilderAppBar.bind(this);
private GenomeBuilderOverlays = GenomeBuilderOverlays.bind(this);
public constructor(props: CircularGenomeBuilderViewProps)
Expand Down
Expand Up @@ -58,6 +58,11 @@ export function GenomeBuilderOverlays(this: CircularGenomeBuilderView, props: {
{
this.changeContigOpacity(figure,opts.contigUuid,opts.newOpacity);
}

if(opts.newVadjust !== undefined)
{
this.changeContigVadjust(figure,opts.contigUuid,opts.newVadjust);
}
}
}}
onClose={() =>
Expand Down
Expand Up @@ -20,6 +20,7 @@ export interface EditContigOverlayProps {
newTextColour?: string,
newBodyColour?: string,
newOpacity? : number;
newVadjust? : number;
}) => void;
figure: CircularFigure;
contig: Contig;
Expand All @@ -36,6 +37,7 @@ export function EditContigOverlay(props: EditContigOverlayProps): JSX.Element
let enteredTextColour: ColorResult | undefined;
let enteredBodyColour: ColorResult | undefined;
let enteredOpacity : number | undefined;
let enteredVadjust : number | undefined;
return (
<div>

Expand Down Expand Up @@ -131,6 +133,38 @@ export function EditContigOverlay(props: EditContigOverlayProps): JSX.Element
</Grid>
</div>
</GridWrapper>
<div style={{marginLeft: "2.5vh"}}>
<Grid container spacing={4} justify="flex-start">
<Typography>Vertical Adjustment:</Typography>
</Grid>
</div>
<GridWrapper>
<div style={{marginRight: "1vh", marginLeft: "1vh", marginBottom: "1vh", marginTop: "1vh"}}>
<Grid container spacing={4} justify="center">
<Grid item>
<OutlinedInput
label={props.contig.vAdjust ? props.contig.vAdjust.toString() : "0"}
inputProps={{
onChange: (event) =>
{
if(event.target.value)
{
let newVadjust : number | typeof NaN = parseInt(event.target.value);
if(isNaN(newVadjust))
{
alert("Vertical adjustment must be a number");
return;
}

enteredVadjust = newVadjust;
}
}
}}
/>
</Grid>
</Grid>
</div>
</GridWrapper>
<div style={{marginBottom:"1vh"}}>
<ColourPicker
label="Text Colour"
Expand Down Expand Up @@ -169,7 +203,8 @@ export function EditContigOverlay(props: EditContigOverlayProps): JSX.Element
newName: endteredName,
newBodyColour: enteredBodyColour ? enteredBodyColour.hex : "",
newTextColour : enteredTextColour ? enteredTextColour.hex : "",
newOpacity : enteredOpacity
newOpacity : enteredOpacity,
newVadjust : enteredVadjust
});
}}
type="advance"
Expand Down
@@ -0,0 +1,34 @@
import {CircularGenomeBuilderView} from "../circularGenomeBuilderView";
import {CircularFigure} from "../../../circularFigure/circularFigure";

export function changeContigVadjust(this: CircularGenomeBuilderView, figure: CircularFigure, contigUuid: string, vadjust: number): void
{
this.maybePushEdit(
figure, {
description: `Change contig body vadjust to ${vadjust}`,
commit: (figure: CircularFigure) =>
{
let contig = figure.contigs.find(x => x.uuid == contigUuid);

if (contig)
{
contig.vAdjust = vadjust;
}
},
afterCommit: () =>
{
this.saveFigures();
},
rollback: (newFigure: CircularFigure, oldFigure: CircularFigure) =>
{
let newContig = newFigure.contigs.find(x => x.uuid == contigUuid);
let oldContig = oldFigure.contigs.find(x => x.uuid == contigUuid);

if (newContig && oldContig)
{
newContig.vAdjust = oldContig.vAdjust;
}
}
}
);
}

0 comments on commit 49b0467

Please sign in to comment.