Skip to content
Snippets Groups Projects
Commit 141e95bd authored by John Schihada's avatar John Schihada
Browse files

Fixed json-payload for OnLineFacts and LineFacts + Adjustments so that...

Fixed json-payload for OnLineFacts and LineFacts + Adjustments so that SupplementaryAngles-Scroll works again + Adjusted GET on Scroll/List-endpoint in DisplayScrolls so that it tries several times, because server mostly returns a 500 on first try
parent e7981250
No related branches found
No related tags found
No related merge requests found
fileFormatVersion: 2
guid: a0c4434eeba6ca8468299bff4e83713a
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 079d1201662889d418e53b525d0ce704
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
......@@ -10,8 +10,10 @@ public class ParsingDictionary {
{MMTURIs.Point, PointFact.parseFact},
{MMTURIs.Metric, LineFact.parseFact},
{MMTURIs.Angle, AngleFact.parseFact},
{MMTURIs.LineType, RayFact.parseFact},
{MMTURIs.OnLine, OnLineFact.parseFact},
//90Degree-Angle
{MMTURIs.Ded, AngleFact.parseFact}
{MMTURIs.Eq, AngleFact.parseFact}
};
}
......@@ -192,7 +194,7 @@ public LineFact(int i, int pid1, int pid2)
//Label is currently set to Fact.setId
//Set Label to StringConcatenation of Points
this.Label = pf1.Label + pf2.Label;
this.Label = "|" + pf1.Label + pf2.Label + "|";
string p1URI = pf1.backendURI;
string p2URI = pf2.backendURI;
......@@ -273,42 +275,6 @@ public override int GetHashCode()
}
}
public class OpenLineFact : Fact
{
//R: this is called RayFact for now (see below), feel free to change
//an infinite Line through the Points Pid1 and Pid2
public int Pid1, Pid2;
public override Boolean hasDependentFacts()
{
return true;
}
public override int[] getDependentFactIds()
{
return new int[] { Pid1, Pid2 };
}
public override bool Equals(System.Object obj)
{
//Check for null and compare run-time types.
if ((obj == null) || !this.GetType().Equals(obj.GetType()))
{
return false;
}
else
{
OpenLineFact o = (OpenLineFact)obj;
return this.Pid1.Equals(o.Pid1) && this.Pid2.Equals(o.Pid2);
}
}
public override int GetHashCode()
{
return this.Pid1 ^ this.Pid2;
}
}
public class RayFact : Fact
{
//Id's of the 2 Point-Facts that are connected
......@@ -326,20 +292,53 @@ public RayFact(int i, int pid1, int pid2)
PointFact pf2 = CommunicationEvents.Facts.Find((x => x.Id == pid2)) as PointFact;
string p1URI = pf1.backendURI;
string p2URI = pf2.backendURI;
//TODO: fix body
string body = @"{ ""base"":""" + p1URI + @"""," + @"""second"":""" + p2URI + @"""" + "}";
AddFactResponse res = AddFactResponse.sendAdd(CommunicationEvents.ServerAdress+"/fact/add/line", body);
//Set Label to StringConcatenation of Points
this.Label = pf1.Label + pf2.Label;
List<MMTTerm> arguments = new List<MMTTerm>
{
new OMS(p1URI),
new OMS(p2URI)
};
//OMS constructor generates full URI
MMTTerm tp = new OMS(MMTURIs.LineType);
MMTTerm df = new OMA(new OMS(MMTURIs.LineOf), arguments);
//TODO: rework fact list + labeling
MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
string body = MMTSymbolDeclaration.ToJson(mmtDecl);
AddFactResponse res = AddFactResponse.sendAdd(CommunicationEvents.ServerAdress + "/fact/add", body);
this.backendURI = res.uri;
// this.backendValueURI = res.factValUri;
Debug.Log(this.backendURI);
}
public RayFact(int i, int pid1, int pid2, string uri, string valuri)
public RayFact(int pid1, int pid2, string uri)
{
this.Id = i;
this.Pid1 = pid1;
this.Pid2 = pid2;
this.backendURI = uri;
this.backendValueURI = valuri;
}
public static RayFact parseFact(Scroll.ScrollFact fact)
{
String uri = fact.@ref.uri;
String pointAUri = ((OMS)((OMA)((Scroll.ScrollSymbolFact)fact).df).arguments[0]).uri;
String pointBUri = ((OMS)((OMA)((Scroll.ScrollSymbolFact)fact).df).arguments[1]).uri;
if (CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(pointAUri)) &&
CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(pointBUri)))
{
int pid1 = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(pointAUri)).Id;
int pid2 = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(pointBUri)).Id;
return new RayFact(pid1, pid2, uri);
}
//If dependent facts do not exist return null
else
{
return null;
}
}
public override Boolean hasDependentFacts()
......@@ -375,23 +374,69 @@ public override int GetHashCode()
public class OnLineFact : Fact
{
//Id's of the Point , and the Id of the Line it sits on
public int Pid, Lid;
//Id's of the Point and the Line it's on
public int Pid, Rid;
public OnLineFact(int i, int pid, int lid)
public OnLineFact(int i, int pid, int rid)
{
this.Id = i;
this.Pid = pid;
this.Lid = lid;
this.Rid = rid;
PointFact pf = CommunicationEvents.Facts.Find((x => x.Id == pid)) as PointFact;
RayFact lf = CommunicationEvents.Facts.Find((x => x.Id == lid)) as RayFact;
RayFact rf = CommunicationEvents.Facts.Find((x => x.Id == rid)) as RayFact;
string pURI = pf.backendURI;
string lURI = lf.backendURI;
string body = @"{ ""vector"":""" + pURI + @"""," + @"""line"":""" + lURI + @"""" + "}";
AddFactResponse res = AddFactResponse.sendAdd(CommunicationEvents.ServerAdress+"/fact/add/onLine", body);
string rURI = rf.backendURI;
//Set Label to StringConcatenation of Points
this.Label = pf.Label + " ∊ " + rf.Label;
List<MMTTerm> innerArguments = new List<MMTTerm>
{
new OMS(rURI),
new OMS(pURI)
};
List<MMTTerm> outerArguments = new List<MMTTerm>
{
new OMA(new OMS(MMTURIs.OnLine), innerArguments)
};
//OMS constructor generates full URI
MMTTerm tp = new OMA(new OMS(MMTURIs.Ded), outerArguments);
MMTTerm df = null;
//TODO: rework fact list + labeling
MMTSymbolDeclaration mmtDecl = new MMTSymbolDeclaration(this.Label, tp, df);
string body = MMTSymbolDeclaration.ToJson(mmtDecl);
AddFactResponse res = AddFactResponse.sendAdd(CommunicationEvents.ServerAdress + "/fact/add", body);
this.backendURI = res.uri;
// this.backendValueURI = res.factValUri;
Debug.Log("created onLine" + this.backendURI + " " + this.backendValueURI);
Debug.Log(this.backendURI);
}
public OnLineFact(int pid, int rid, string uri) {
this.Pid = pid;
this.Rid = rid;
this.backendURI = uri;
}
public static OnLineFact parseFact(Scroll.ScrollFact fact)
{
String uri = fact.@ref.uri;
String lineUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[0]).uri;
String pointUri = ((OMS)((OMA)((OMA)((Scroll.ScrollSymbolFact)fact).tp).arguments[0]).arguments[1]).uri;
if (CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(lineUri)) &&
CommunicationEvents.Facts.Exists(x => x.backendURI.Equals(pointUri)))
{
int pid = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(pointUri)).Id;
int rid = CommunicationEvents.Facts.Find(x => x.backendURI.Equals(lineUri)).Id;
return new OnLineFact(pid, rid, uri);
}
//If dependent facts do not exist return null
else
{
return null;
}
}
public override Boolean hasDependentFacts()
......@@ -401,7 +446,7 @@ public override Boolean hasDependentFacts()
public override int[] getDependentFactIds()
{
return new int[] { Pid, Lid };
return new int[] { Pid, Rid };
}
public override bool Equals(System.Object obj)
......@@ -414,13 +459,13 @@ public override bool Equals(System.Object obj)
else
{
OnLineFact o = (OnLineFact)obj;
return this.Pid.Equals(o.Pid) && this.Lid.Equals(o.Lid);
return this.Pid.Equals(o.Pid) && this.Rid.Equals(o.Rid);
}
}
public override int GetHashCode()
{
return this.Pid ^ this.Lid;
return this.Pid ^ this.Rid;
}
}
......
......@@ -47,14 +47,14 @@ public LineFact AddLineFact(int pid1, int pid2, int id)
return Facts.Find(x => x.Id == id) as LineFact;
}
public RayFact AddRayFact(int pid1, int pid2, int id)
public List<Fact> AddRayFact(int pid1, int pid2, int id)
{
Facts.Insert(id, new RayFact(id, pid1, pid2));
var oLid = GetFirstEmptyID();
Facts.Insert(oLid, new OnLineFact(oLid, pid1, id));
oLid = GetFirstEmptyID();
Facts.Insert(oLid, new OnLineFact(oLid, pid2, id));
var oLid1 = GetFirstEmptyID();
Facts.Insert(oLid1, new OnLineFact(oLid1, pid1, id));
var oLid2 = GetFirstEmptyID();
Facts.Insert(oLid2, new OnLineFact(oLid2, pid2, id));
var p1 = Facts.Find(x => x.Id == pid1);
var p2 = Facts.Find(x => x.Id == pid2);
......@@ -83,7 +83,7 @@ public RayFact AddRayFact(int pid1, int pid2, int id)
if (typeof(OnLineFact).IsInstanceOfType(fact))
{
OnLineFact oLFact = (OnLineFact)fact;
if ((oLFact.Lid == id && oLFact.Pid == hit.transform.gameObject.GetComponent<FactObject>().Id))
if ((oLFact.Rid == id && oLFact.Pid == hit.transform.gameObject.GetComponent<FactObject>().Id))
{
exists = true;
break;
......@@ -94,15 +94,19 @@ public RayFact AddRayFact(int pid1, int pid2, int id)
if (!exists)
{
oLid = GetFirstEmptyID();
var olF = new OnLineFact(oLid, hit.transform.gameObject.GetComponent<FactObject>().Id, id);
Facts.Insert(oLid, olF);
var anotherOLid = GetFirstEmptyID();
var olF = new OnLineFact(anotherOLid, hit.transform.gameObject.GetComponent<FactObject>().Id, id);
Facts.Insert(anotherOLid, olF);
}
}
return Facts.Find(x => x.Id == id) as RayFact;
List<Fact> returnedFacts = new List<Fact>();
returnedFacts.Add(Facts.Find(x => x.Id == id) as RayFact);
returnedFacts.Add(Facts.Find(x => x.Id == oLid1) as OnLineFact);
returnedFacts.Add(Facts.Find(x => x.Id == oLid2) as OnLineFact);
return returnedFacts;
}
......
......@@ -48,7 +48,10 @@ public override void OnHit(RaycastHit hit)
//Create LineFact
//Check if exactly the same line/distance already exists
if (!FactManager.factAlreadyExists(new int[] { this.LineModeFirstPointSelected.Id, tempFact.Id }))
CommunicationEvents.AddFactEvent.Invoke(FactManager.AddRayFact(this.LineModeFirstPointSelected.Id, tempFact.Id, FactManager.GetFirstEmptyID()));
{
List<Fact> returnedFacts = FactManager.AddRayFact(this.LineModeFirstPointSelected.Id, tempFact.Id, FactManager.GetFirstEmptyID());
returnedFacts.ForEach(CommunicationEvents.AddFactEvent.Invoke);
}
this.ResetGadget();
}
......
......@@ -15,13 +15,6 @@ void Awake()
this.UiName = "Point Mode";
}
/*
public override void activate() {
this.activated = true;
this.Cursor.setLayerMask(this.layerMask);
}
*/
void OnEnable()
{
this.Cursor.setLayerMask(~this.ignoreLayerMask.value);
......@@ -37,6 +30,7 @@ public override void OnHit(RaycastHit hit)
var oLid = FactManager.GetFirstEmptyID();
Facts.Insert(oLid, new OnLineFact(oLid, pid, hit.transform.GetComponent<FactObject>().Id));
CommunicationEvents.AddFactEvent.Invoke(Facts.Find(x => x.Id == oLid) as OnLineFact);
}
}
......
......@@ -91,7 +91,7 @@ private GameObject CreateDisplay(Transform transform, Fact fact)
{
var obj = Instantiate(prefab_OnLine, Vector3.zero, Quaternion.identity, transform);
obj.transform.GetChild(0).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[f.Pid].Id);
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[f.Lid].Id);
obj.transform.GetChild(1).gameObject.GetComponent<TextMeshProUGUI>().text = "" + getLetter(CommunicationEvents.Facts[f.Rid].Id);
obj.GetComponent<FactWrapper>().fact = f;
return obj;
}
......
......@@ -8,6 +8,7 @@
public class DisplayScrolls : MonoBehaviour
{
public string preferredStartScrollName;
public int tryScrollListTimes = 2;
public List<Scroll> scrolls;
public GameObject[] ScrollButtons;
......@@ -61,8 +62,21 @@ IEnumerator getScrollsfromServer() {
UnityWebRequest request = UnityWebRequest.Get(CommunicationEvents.ServerAdress + "/scroll/list");
//Postman-Echo-Mock
//UnityWebRequest request = UnityWebRequest.Get("https://019a8ea5-843a-498b-8d0c-778669aef987.mock.pstmn.io/get");
for (int i = 0; i < this.tryScrollListTimes; i++) {
request = UnityWebRequest.Get(CommunicationEvents.ServerAdress + "/scroll/list");
request.method = UnityWebRequest.kHttpVerbGET;
yield return request.Send();
if (request.isNetworkError || request.isHttpError)
{
Debug.LogWarning(request.error);
Debug.Log("GET Scroll/list failed. Attempt: " + (i+1).ToString());
}
else {
break;
}
}
if (request.isNetworkError || request.isHttpError)
{
Debug.LogWarning(request.error);
......
......@@ -75,7 +75,7 @@ public override String getType() {
if (this.tp is OMS)
return ((OMS)this.tp).uri;
else if (this.tp is OMA)
return ((OMS)((OMA)this.tp).applicant).uri;
return ((OMS)((OMA)((OMA)this.tp).arguments[0]).applicant).uri;
else
return null;
}
......
......@@ -10,8 +10,9 @@ public class MMTURICollection
{
public string Point = "http://mathhub.info/MitM/core/geometry?3DGeometry?point";
public string Tuple = "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Tuple";
public string Line_type = "http://mathhub.info/MitM/core/geometry?Geometry?Common?line_type";
public string LineOf = "http://mathhub.info/MitM/core/geometry?Geometry?Common?lineOf";
public string LineType = "http://mathhub.info/MitM/core/geometry?Geometry/Common?line_type";
public string LineOf = "http://mathhub.info/MitM/core/geometry?Geometry/Common?lineOf";
public string OnLine = "http://mathhub.info/MitM/core/geometry?Geometry/Common?onLine";
public string Ded = "http://mathhub.info/MitM/Foundation?Logic?ded";
public string Eq = "http://mathhub.info/MitM/Foundation?Logic?eq";
public string Metric = "http://mathhub.info/MitM/core/geometry?Geometry/Common?metric";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment