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

Zoom & other bugs #54

Merged
merged 8 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-img-mapper": "^1.3.0",
"react-zoom-pan-pinch": "^2.1.3",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
23 changes: 11 additions & 12 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
grid-area: viewPort;
box-shadow: inset 0px 6px 10px black;
}
.NavBar{
padding-top: 2vh;
overflow: hidden;
background-color: #1c2224;
text-align: center;
width: 200px;
grid-area: navBar;
z-index: 1;
height: 95vh;
}

.InteractivePane{
grid-area: interactivePane;
Expand Down Expand Up @@ -52,8 +42,8 @@
grid-template-columns: auto minmax(0, 1fr);
display:grid;
grid-template-areas:
'navBar viewPort interactivePane'
'navBar viewPort interactivePane'
'viewport viewPort interactivePane'
'viewport viewPort interactivePane'
}

::-webkit-scrollbar{
Expand Down Expand Up @@ -100,6 +90,10 @@
left: 140px;
}

.transform-component-module_wrapper__1_Fgj{
overflow: visible !important;
}

#InteractiveOpened{
position: fixed;
z-index: 2;
Expand All @@ -111,3 +105,8 @@
#buttonGridViewPort{
display: none;
}

/*Not Ideal but can't figure out why height = 0 */
#img-mapper{
height:2343px !important;
}
126 changes: 41 additions & 85 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,19 @@
import './App.css';
import Mapper from './Componets/Mapper'
import NavButton from './Componets/NavButton';
import Slider from './Componets/Slider';
import ScrollButton from './Componets/ScrollButton';
import AnimationPane from './Componets/AnimationPane';
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
import { ClosedDrawer, OpenedDrawer } from './Componets/DrawerButton';
import { useEffect, useState } from 'react';


function App(props) {
const [ Zoom, setZoom] = useState(1);
const [ posx, setPosx] = useState(0);
const [ posy, setPosy] = useState(0);

//const [ mainViewInteraction, setMainViewInteraction ] = useState(null);

const shouldRender = false;
//const shouldRender = false;

function setRadarView(){
setZoom(40)
setPosy(-10)
setPosx(-88)
}
function setSystemView(){
setZoom(50)
setPosy(30)
setPosx(-168)
}
function setDisplayView(){
setZoom(40)
setPosy(-26)
setPosx(10)
}
function setNavView(){
setZoom(30)
setPosy(-12)
setPosx(-130)
}
function setWideView(){
setZoom(1)
setPosy(30)
setPosx(6)
}
function hideNavBar() {
if (document.getElementById('navBar').style.width != '0px'){
document.getElementById('navBar').style.width = '0px'
document.getElementById('nav-toggle-container').style.display = 'block'
document.getElementById('NavBarOpened').style.display = 'none'
document.getElementById('buttonGridViewPort').style.display = 'grid'
}
else {
document.getElementById('navBar').style.width = '200px'
document.getElementById('nav-toggle-container').style.display = 'none'
document.getElementById('NavBarOpened').style.display = 'block'
document.getElementById('buttonGridViewPort').style.display = 'none'
}
}
function hideHydrolic() {
if (document.getElementById('interactivePane').style.display == 'none') {
if (document.getElementById('interactivePane').style.display === 'none') {
document.getElementById('interactivePane').style.display = 'block'
document.getElementById('int-toggle-container').style.display = 'none'
document.getElementById('InteractiveOpened').style.display = 'block'
Expand All @@ -68,51 +27,48 @@ function App(props) {
}
}

useEffect(()=> {
if(shouldRender){
//This is for passind area info from mapper to sim
//function onButtonClicked(area){
// setMainViewInteraction(area.name);
//}

}
})
// useEffect(()=> {
// if(shouldRender){
// setMainViewInteraction(null);
// }
// })

return (

<div className="App grid-container">
<div className="int-toggle-container" id="int-toggle-container">
<ClosedDrawer onChange={() => hideHydrolic()} id="InteractiveClosed" />
</div>
<div className="nav-toggle-container" id="nav-toggle-container">
<ClosedDrawer onChange={() => hideNavBar()} id="NavBarClosed" />
</div>
<div className="NavBar" id="navBar">
<NavButton onChange={()=>setRadarView()}tag="Radar Controls"/>
<NavButton onChange={()=>setSystemView()}tag="System Information"/>
<NavButton onChange={()=>setDisplayView()}tag="Flight Display"/>
<NavButton onChange={()=>setNavView()}tag="Navigation Controls"/>
<NavButton onChange={() => setWideView()} tag="Wide View" />
<Slider onSlider={(i)=>setZoom(i)}></Slider>
<div className="button-grid-container">
<ScrollButton onChange={()=>setPosx(posx + 2)} id='UP' />
<ScrollButton onChange={()=>setPosx(posx - 2)} id='DOWN'/>
<ScrollButton onChange={()=>setPosy(posy + 2)} id='LEFT'/>
<ScrollButton onChange={()=>setPosy(posy - 2)} id='RIGHT'/>
<TransformWrapper
initialScale ={.5}
initialPositionX={200}
initialPositionY={0}
minScale = {.5}
limitToBounds = {false}
centerOnInit = {true}

>
{({ resetTransform, ...rest }) => (
<div className="App grid-container">
<div className="int-toggle-container" id="int-toggle-container">
<ClosedDrawer onChange={() => hideHydrolic()} id="InteractiveClosed" />
</div>
<OpenedDrawer onChange={() => hideNavBar()} id="NavBarOpened" />
</div>
<div className = "ViewPort">
<Mapper Zoom={Zoom} posx={posx} posy={posy} id="mapper" />
<div className="button-grid-container" id="buttonGridViewPort">
<ScrollButton onChange={()=>setPosx(posx + 2)} id='UP' />
<ScrollButton onChange={()=>setPosx(posx - 2)} id='DOWN'/>
<ScrollButton onChange={()=>setPosy(posy + 2)} id='LEFT'/>
<ScrollButton onChange={()=>setPosy(posy - 2)} id='RIGHT'/>
<div className = "ViewPort">
<div className="tools">
<NavButton tag= "Reset View" transform = {() => resetTransform()}></NavButton>
</div>
<TransformComponent>
<Mapper id="mapper" />
</TransformComponent>
</div>
<div className='InteractivePane' id = 'interactivePane'>
<AnimationPane />
<OpenedDrawer onChange={() => hideHydrolic()} id="InteractiveOpened" />
</div>
</div>
<div className='InteractivePane' id = 'interactivePane'>
<AnimationPane />
<OpenedDrawer onChange={() => hideHydrolic()} id="InteractiveOpened" />
</div>
</div>

)}
</TransformWrapper>
);
}

Expand Down
14 changes: 10 additions & 4 deletions src/Componets/AnimationPane.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { React , useState } from 'react'
import { React , useEffect, useState } from 'react'
import "./Styles/AnimationPane.css"
import HydrolicSystem from './HydrolicSystem'
import InteractiveDiagramHydrolic from "../Assets/result.jsx"
Expand All @@ -8,6 +8,8 @@ import NoninteractiveDiagramHydrolic from "../Assets/hydrolics.png"
const AnimationPane = (props) => {
const [displayType, setDisplayType] = useState(true);

const shouldRender = true;

const handelChange = () => {
setDisplayType(!displayType);
if(displayType){
Expand All @@ -18,9 +20,13 @@ const AnimationPane = (props) => {
document.getElementById("HydrolicPng").style.display = "none";
}


}

useEffect(()=>{
if(shouldRender){
//console.log(props.buttonPressed);
//This is redacted for this build but this gets info on buttons if passed in
}
})
return(
<>
<div className="AnimationContainer grid-element grid-container">
Expand All @@ -33,7 +39,7 @@ const AnimationPane = (props) => {
<InteractiveDiagramHydrolic/>
</div>
<div className="InfoProcessing grid-element">
<HydrolicSystem />
<HydrolicSystem buttonPressed = {props.buttonPressed}/>
</div>
</>
)
Expand Down
7 changes: 7 additions & 0 deletions src/Componets/HydrolicSystem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class HydrolicSystem extends Component {
super(props);
//Simulation Variables / Default values
this.state = {psi: 1500 , PsiColor: 'green',LHV: "Open", RHV: "Open", LHF: false, RHF: false, HYD: false, HydPress:"Norm", PRV:"Working", LeftEngine:"Functioning", RightEngine:"Functioning", LeftFilter:"Flowing", RightFilter:"Flowing", TopFilter:"Flowing"};
this.initialState = this.state;
this.handleChange = this.handleChange.bind(this);
this.updateSimVariables = this.updateSimVariables.bind(this);
}
Expand All @@ -21,6 +22,9 @@ class HydrolicSystem extends Component {

event.preventDefault();

if(event.target.id === 'RESET'){
await this.setState(this.initialState);
}
if(event.target.id === 'LV'){ //ID: LV and LVENG both open and close the left valve.
await this.setState({ LHV: this.state.LHV === "Open" ? "Closed" : "Open"});
}
Expand Down Expand Up @@ -329,6 +333,9 @@ class HydrolicSystem extends Component {
<button className='sim-button-filter' onClick={this.updateSimVariables} id='RF'>Right Filter: {this.state.RightFilter}</button>
<button className='sim-button-filter' onClick={this.updateSimVariables} id='TF'>Return Filter: {this.state.TopFilter}</button>
</div>
<div id= "RESET">
<button className='sim-button-reset' onClick={this.updateSimVariables} id="RESET">RESET</button>
</div>
</>)
}
}
Expand Down
21 changes: 8 additions & 13 deletions src/Componets/Mapper.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { Hidden } from '@mui/material';
import React, { useEffect, useState } from 'react';
import React from 'react';
import ImageMapper from 'react-img-mapper';
import url from '../Assets/img.png';
import area from '../Assets/MAP.json';


const Mapper = (props) =>{

const [ WIDTH, setWidth] = useState((props.Zoom * 40) + 800);

useEffect(()=>{
setWidth((props.Zoom * 40) + 800)
})

const URL = url;
const MAP = {
name: 'my-map',
Expand All @@ -21,17 +14,19 @@ const Mapper = (props) =>{
return (
<div id='map-container' style={{
position: "relative",
left: `${props.posy}vw`,
top: `${props.posx}vh`,
width: '100%',
height: '100%',
'zindex': '2',
}}>
<ImageMapper
src = {URL}
map = {MAP}
imgWidth = {3500}
imgWidth = {4200}
responsive = {true}
parentWidth = {WIDTH}
onClick={(area) => { console.log(area.name)}}
imgheight = {3500}
parentWidth = {2000}
natural = {true}
onClick={(area) => {/*props.onButtonClicked(area)*/ console.log(area.name)}}
/>
</div>

Expand Down
10 changes: 5 additions & 5 deletions src/Componets/NavButton.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import zIndex from '@mui/material/styles/zIndex'
import React from 'react'
import "./Styles/Button.css"

const NavButton = (props) => {

function Change(event) {
props.onChange();
console.log(props.tag)
};
function transform(event) {
props.transform()
};

return(
<div onClick={(i)=>Change(i)} className='Button'>
<div onClick={(i)=> transform(i) } className='Button' style = {{position: 'absolute', zIndex: '1'}}>
<p style={{ userSelect: 'none'}}>{props.tag}</p>
</div>
)
Expand Down
Loading