작업 조건 분석 기능 개발
This commit is contained in:
123
Assets/Chart And Graph/Tutorials/Zoom/GraphRectZoom.cs
Normal file
123
Assets/Chart And Graph/Tutorials/Zoom/GraphRectZoom.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(CustomChartPointer))]
|
||||
public class GraphRectZoom : MonoBehaviour
|
||||
{
|
||||
public RectTransform Marker;
|
||||
public int MinMarkerPixels = 20;
|
||||
CustomChartPointer mPointer;
|
||||
RectTransform mRect;
|
||||
bool mIsDown = false;
|
||||
Vector2 mStart;
|
||||
bool mIsZoomed = false;
|
||||
bool mIsUp = true;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
mRect = GetComponent<RectTransform>();
|
||||
mPointer = GetComponent<CustomChartPointer>();
|
||||
Marker.gameObject.SetActive(false);
|
||||
}
|
||||
void OnMarkerStart()
|
||||
{
|
||||
mIsDown = true;
|
||||
mStart = mPointer.ScreenPosition;
|
||||
Marker.gameObject.SetActive(true);
|
||||
}
|
||||
void OnMarkerMove()
|
||||
{
|
||||
Vector3 end = mPointer.ScreenPosition;
|
||||
Vector3 min = new Vector3(Mathf.Min(mStart.x, end.x), Mathf.Min(mStart.y, end.y));
|
||||
Vector3 max = new Vector3(Mathf.Max(mStart.x, end.x), Mathf.Max(mStart.y, end.y));
|
||||
Marker.position = min;
|
||||
Marker.sizeDelta = max - min;
|
||||
}
|
||||
void OnMarkerEnd()
|
||||
{
|
||||
mIsDown = false;
|
||||
Marker.gameObject.SetActive(false);
|
||||
}
|
||||
bool CheckBounds()
|
||||
{
|
||||
Vector2 v = mPointer.ScreenPosition - mStart;
|
||||
if (Math.Abs(v.x) < MinMarkerPixels || Math.Abs(v.y) < MinMarkerPixels)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
void SetGraphZoom()
|
||||
{
|
||||
if (CheckBounds() == false)
|
||||
return;
|
||||
var graph = GetComponent<GraphChart>();
|
||||
double x1, y1;
|
||||
double x2, y2;
|
||||
if(graph.PointToClient(mStart,out x1,out y1))
|
||||
{
|
||||
if(graph.PointToClient(mPointer.ScreenPosition,out x2,out y2))
|
||||
{
|
||||
mIsZoomed = true;
|
||||
graph.DataSource.AutomaticHorizontalView = false;
|
||||
graph.DataSource.AutomaticVerticallView = false;
|
||||
|
||||
DoubleVector2 min = new DoubleVector2(Math.Min(x1, x2), Math.Min(y1, y2));
|
||||
DoubleVector2 max = new DoubleVector2(Math.Max(x1, x2), Math.Max(y1, y2));
|
||||
graph.HorizontalScrolling = min.x;
|
||||
graph.VerticalScrolling = min.y;
|
||||
graph.DataSource.HorizontalViewSize = max.x - min.x;
|
||||
graph.DataSource.VerticalViewSize = max.y - min.y;
|
||||
graph.DataSource.HorizontalViewOrigin = 0;
|
||||
graph.DataSource.VerticalViewOrigin = 0;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(mIsZoomed && mPointer.IsMouseDown)
|
||||
{
|
||||
mIsZoomed = false;
|
||||
var graph = GetComponent<GraphChart>();
|
||||
graph.DataSource.AutomaticHorizontalView = true;
|
||||
graph.DataSource.AutomaticVerticallView = true;
|
||||
graph.HorizontalScrolling = 0;
|
||||
graph.VerticalScrolling = 0;
|
||||
mIsUp = false;
|
||||
return;
|
||||
}
|
||||
if (mIsUp == false && mPointer.IsMouseDown)
|
||||
return;
|
||||
mIsUp = true;
|
||||
Vector2 pointerPos = mPointer.ScreenPosition;
|
||||
|
||||
if (mIsDown == false)
|
||||
{
|
||||
if (mPointer.IsMouseDown == true) // the mouse is clicked in this frame
|
||||
{
|
||||
OnMarkerStart(); //start the marker
|
||||
OnMarkerMove();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (mPointer.IsMouseDown == false) // the mouse is up this frame
|
||||
{
|
||||
OnMarkerEnd(); // end the marker
|
||||
if (mPointer.IsOut == false)
|
||||
SetGraphZoom(); // set graph zoom
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
OnMarkerMove(); // the mouse is being held
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Chart And Graph/Tutorials/Zoom/GraphRectZoom.cs.meta
Normal file
11
Assets/Chart And Graph/Tutorials/Zoom/GraphRectZoom.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ed044aea80a33e4ba36faf5a4f82bad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
99
Assets/Chart And Graph/Tutorials/Zoom/GraphZoom.cs
Normal file
99
Assets/Chart And Graph/Tutorials/Zoom/GraphZoom.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using ChartAndGraph;
|
||||
using UnityEngine.UI;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// this is an example of zoom using mouse for the graph chart
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(GraphChart))]
|
||||
public class GraphZoom : MonoBehaviour
|
||||
{
|
||||
GraphChart graph;
|
||||
Vector3 mZoomBasePosition;
|
||||
DoubleVector3 mZoomBaseChartSpace;
|
||||
DoubleVector3 InitalScrolling;
|
||||
DoubleVector3 InitalViewSize;
|
||||
DoubleVector3 InitalViewDirection;
|
||||
DoubleVector3 InitialOrigin;
|
||||
public float errorMargin = 5f;
|
||||
public float ZoomSpeed = 20f;
|
||||
public float MaxViewSize = 10f;
|
||||
public float MinViewSize = 0.1f;
|
||||
float totalZoom = 0;
|
||||
|
||||
// Use this for initialization
|
||||
void Start ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
graph = GetComponent<GraphChart>();
|
||||
}
|
||||
|
||||
void ResetZoomAnchor()
|
||||
{
|
||||
totalZoom = 0;
|
||||
InitalScrolling = new DoubleVector3(graph.HorizontalScrolling, graph.VerticalScrolling);
|
||||
InitalViewSize = new DoubleVector3(graph.DataSource.HorizontalViewSize, graph.DataSource.VerticalViewSize);
|
||||
InitalViewDirection = new DoubleVector3(Math.Sign(InitalViewSize.x), Math.Sign(InitalViewSize.y));
|
||||
InitialOrigin = new DoubleVector3(graph.DataSource.HorizontalViewOrigin, graph.DataSource.VerticalViewOrigin);
|
||||
|
||||
}
|
||||
bool CompareWithError(Vector3 a,Vector3 b)
|
||||
{
|
||||
if (Mathf.Abs(a.x - b.x) > errorMargin)
|
||||
return false;
|
||||
if (Mathf.Abs(a.y - b.y) > errorMargin)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update ()
|
||||
{
|
||||
if (graph == null) // no graph attached to this script for some reason
|
||||
return;
|
||||
Vector2 mousePos = Input.mousePosition;
|
||||
double mouseX, mouseY;
|
||||
graph.PointToClient(mousePos, out mouseX, out mouseY);
|
||||
if (CompareWithError(mousePos, mZoomBasePosition) == false) // the mouse has moved beyond the erroo
|
||||
{
|
||||
mZoomBasePosition = mousePos;
|
||||
graph.PointToClient(mousePos, out mouseX, out mouseY);
|
||||
mZoomBaseChartSpace = new DoubleVector3(mouseX, mouseY);
|
||||
ResetZoomAnchor();
|
||||
}
|
||||
else
|
||||
{
|
||||
mousePos = mZoomBasePosition;
|
||||
}
|
||||
|
||||
//#if ENABLE_INPUT_SYSTEM
|
||||
// float delta = Input.mouseScrollDelta.y;
|
||||
//#else
|
||||
float delta = Input.mouseScrollDelta.y;
|
||||
// #endif
|
||||
totalZoom += delta; //accumilate the delta change for the currnet positions
|
||||
|
||||
if (delta!=0 && graph.PointToClient(mousePos, out mouseX, out mouseY))
|
||||
{
|
||||
DoubleVector3 ViewCenter = InitialOrigin + InitalScrolling;
|
||||
DoubleVector3 trans = new DoubleVector3((mZoomBaseChartSpace.x - ViewCenter.x), (mZoomBaseChartSpace.y - ViewCenter.y));
|
||||
float growFactor = Mathf.Pow(2,totalZoom/ZoomSpeed);
|
||||
double hSize = InitalViewSize.x * growFactor;
|
||||
double vSize = InitalViewSize.y * growFactor;
|
||||
if (hSize * InitalViewDirection.x < MaxViewSize && hSize * InitalViewDirection.x > MinViewSize && vSize * InitalViewDirection.y < MaxViewSize && vSize * InitalViewDirection.y > MinViewSize )
|
||||
{
|
||||
graph.HorizontalScrolling = InitalScrolling.x + trans.x - (trans.x * growFactor);
|
||||
graph.VerticalScrolling = InitalScrolling.y + trans.y - (trans.y * growFactor);
|
||||
graph.DataSource.HorizontalViewSize = hSize;
|
||||
graph.DataSource.VerticalViewSize = vSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Assets/Chart And Graph/Tutorials/Zoom/GraphZoom.cs.meta
Normal file
12
Assets/Chart And Graph/Tutorials/Zoom/GraphZoom.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3dc21a745b760064c816e20fb5a7f709
|
||||
timeCreated: 1553945584
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1010
Assets/Chart And Graph/Tutorials/Zoom/graph 1.unity
Normal file
1010
Assets/Chart And Graph/Tutorials/Zoom/graph 1.unity
Normal file
File diff suppressed because it is too large
Load Diff
8
Assets/Chart And Graph/Tutorials/Zoom/graph 1.unity.meta
Normal file
8
Assets/Chart And Graph/Tutorials/Zoom/graph 1.unity.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37bc33121528f8846bcb70ae9011da67
|
||||
timeCreated: 1553945564
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!850595691 &4890085278179872738
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: graph 1Settings
|
||||
serializedVersion: 6
|
||||
m_GIWorkflowMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 1
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 0
|
||||
m_BakeBackend: 0
|
||||
m_LightmapMaxSize: 1024
|
||||
m_BakeResolution: 40
|
||||
m_Padding: 2
|
||||
m_LightmapCompression: 3
|
||||
m_AO: 1
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 1
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 2
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherRayCount: 256
|
||||
m_FinalGatherFiltering: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVREnvironmentSampleCount: 512
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRMinBounces: 2
|
||||
m_PVREnvironmentImportanceSampling: 0
|
||||
m_PVRFilteringMode: 0
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_PVRTiledBaking: 0
|
||||
m_NumRaysToShootPerTexel: -1
|
||||
m_RespectSceneVisibilityWhenBakingGI: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f13b75edbef13444ae5f0c383fe0cde
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 4890085278179872738
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1135
Assets/Chart And Graph/Tutorials/Zoom/graphRectZoom.unity
Normal file
1135
Assets/Chart And Graph/Tutorials/Zoom/graphRectZoom.unity
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d10cadfe4e40fed438b0d293de01cf51
|
||||
timeCreated: 1553945564
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!850595691 &4890085278179872738
|
||||
LightingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: graphRectZoomSettings
|
||||
serializedVersion: 6
|
||||
m_GIWorkflowMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 1
|
||||
m_RealtimeEnvironmentLighting: 1
|
||||
m_BounceScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_UsingShadowmask: 0
|
||||
m_BakeBackend: 0
|
||||
m_LightmapMaxSize: 1024
|
||||
m_BakeResolution: 40
|
||||
m_Padding: 2
|
||||
m_LightmapCompression: 3
|
||||
m_AO: 1
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAO: 0
|
||||
m_MixedBakeMode: 1
|
||||
m_LightmapsBakeMode: 1
|
||||
m_FilterMode: 1
|
||||
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_RealtimeResolution: 2
|
||||
m_ForceWhiteAlbedo: 0
|
||||
m_ForceUpdates: 0
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherRayCount: 256
|
||||
m_FinalGatherFiltering: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVREnvironmentSampleCount: 512
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_PVRBounces: 2
|
||||
m_PVRMinBounces: 2
|
||||
m_PVREnvironmentImportanceSampling: 0
|
||||
m_PVRFilteringMode: 0
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_PVRTiledBaking: 0
|
||||
m_NumRaysToShootPerTexel: -1
|
||||
m_RespectSceneVisibilityWhenBakingGI: 0
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16ce19adbfb094a4c8a3765939a6effc
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 4890085278179872738
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user