/// <summary> /// Request the list of detected found objects. /// Callback will never be called while request is still pending. /// </summary> /// <param name="queryFilter">Filter used to customize query results.</param> /// <param name="callback"> /// Callback used to report query results. /// Callback MLResult code will never be <c>MLResult.Code.Pending</c>. /// </param> /// <returns> /// MLResult.Result inside callback will be <c>MLResult.Code.Ok</c> if successful. /// MLResult.Result inside callback will be <c>MLResult.Code.InvalidParam</c> if failed due to invalid input parameter. /// MLResult.Result inside callback will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to internal error. /// </returns> public static MLResult GetObjectsAsync(Query.Filter queryFilter, QueryResultsDelegate callback) { if (MLFoundObjects.IsValidInstance()) { // Don't allow null callbacks to be registered. if (callback == null) { MLPluginLog.Error("MLFoundObjects.GetObjects failed. Reason: Passed input callback is null."); return(MLResult.Create(MLResult.Code.InvalidParam)); } MLThreadDispatch.ScheduleWork(() => { _instance.BeginObjectQueryAsync(queryFilter, callback); return(true); }); return(MLResult.Create(MLResult.Code.Ok)); } else { MLPluginLog.ErrorFormat("MLFoundObjects.GetObjects failed. Reason: No Instance for MLFoundObjects"); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "MLFoundObjects.GetFoundObjects failed. Reason: No Instance for MLFoundObjects")); } }
/// <summary> /// Begin querying for found objects. /// </summary> /// <param name="filter">Filter to use for this query.</param> /// <param name="callback">Callback used to report query results.</param> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if successful. /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if failed due to invalid input parameter. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to internal error. /// </returns> private MLResult BeginObjectQueryAsync(Query.Filter filter, QueryResultsDelegate callback) { try { if (!MagicLeapNativeBindings.MLHandleIsValid(_instance.handle)) { MLPluginLog.Error("MLFoundObjects.BeginObjectQuery failed to request found objects. Reason: Tracker handle is invalid"); return(MLResult.Create(MLResult.Code.InvalidParam)); } NativeBindings.QueryFilterNative nativeQueryFilter = new NativeBindings.QueryFilterNative(); nativeQueryFilter.Data = filter; MLResult.Code resultCode = NativeBindings.MLFoundObjectQuery(_instance.handle, ref nativeQueryFilter, out ulong queryHandle); MLResult result = MLResult.Create(resultCode); if (!result.IsOk) { MLPluginLog.ErrorFormat("MLFoundObjects.BeginObjectQuery failed to request objects. Reason: {0}", resultCode); return(result); } // Add query to the list of pendingQueries. Query query = Query.Create(callback, filter); MLFoundObjects._instance.pendingQueries.TryAdd(queryHandle, query); return(result); } catch (System.EntryPointNotFoundException) { MLPluginLog.Error("MLFoundObjects.BeginObjectQuery failed. Reason: API symbols not found"); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "MLFoundObjects.BeginObjectQuery failed. Reason: API symbols not found")); } }
// deprecated public void LoadTimelineData(GameObject submittedCell) { isContextTimeline = false; if (submittedCell.GetComponent <ViRMA_Cell>()) { // deep clone query filters for timeline API call List <Query.Filter> cellFiltersForTimeline = ObjectExtensions.Copy(globals.queryController.activeFilters); // get cell data and currently active viz axes labels timelineCellData = submittedCell.GetComponent <ViRMA_Cell>().thisCellData; activeVizLabels = globals.vizController.activeAxesLabels; // if X axis exits, find location of submitted call on it and grab data if (activeVizLabels.X != null) { int cellXPosition = (int)timelineCellData.Coordinates.x - 1; int cellXAxisId = activeVizLabels.X.Labels[cellXPosition].Id; string cellXAxisType = activeVizLabels.X.Type; Query.Filter projFilterX = new Query.Filter(cellXAxisType, new List <int>() { cellXAxisId }); cellFiltersForTimeline.Add(projFilterX); } // if Y axis exits, find location of submitted call on it and grab data if (activeVizLabels.Y != null) { int cellYPosition = (int)timelineCellData.Coordinates.y - 1; int cellYAxisId = activeVizLabels.Y.Labels[cellYPosition].Id; string cellYAxisType = activeVizLabels.Y.Type; Query.Filter projFilterY = new Query.Filter(cellYAxisType, new List <int>() { cellYAxisId }); cellFiltersForTimeline.Add(projFilterY); } // if Z axis exits, find location of submitted call on it and grab data if (activeVizLabels.Z != null) { int cellZPosition = (int)timelineCellData.Coordinates.z - 1; int cellZAxisId = activeVizLabels.Z.Labels[cellZPosition].Id; string cellZAxisType = activeVizLabels.Z.Type; Query.Filter projFilterZ = new Query.Filter(cellZAxisType, new List <int>() { cellZAxisId }); cellFiltersForTimeline.Add(projFilterZ); } // get timeline image data from server and load it StartCoroutine(ViRMA_APIController.GetTimeline(cellFiltersForTimeline, (results) => { cellContentResults = results; if (cellContentResults.Count > 0) { if (cellContentResults.Count >= resultsRenderSize) { if (cellContentResults.Count % resultsRenderSize == 0) { totalTimeLineSections = (cellContentResults.Count / resultsRenderSize); } else { totalTimeLineSections = (cellContentResults.Count / resultsRenderSize) + 1; } } else { totalTimeLineSections = 1; } LoadTimelineSection(0, totalTimeLineSections); } })); } }