/// <summary> /// Runs the Parse and back-end computations. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void BackgroundWorker_ParseToAST(object sender, DoWorkEventArgs e) { UIDebugPublisher.clearWindow(); UIDebugPublisher.publishString("Starting Parse Process..."); // Execute Front-End Parse parser.Parse(); foreach (GeometryTutorLib.Area_Based_Analyses.Atomizer.AtomicRegion ar in parser.backendParser.GetAtomicRegions()) { UIDebugPublisher.publishString(ar.ToString()); } analyzer = new GeometryTutorLib.UIFigureAnalyzerMain(parser.backendParser.MakeProblemDescription(manageGivensWindow.GetGivens())); List <GeometryTutorLib.ProblemAnalyzer.Problem <GeometryTutorLib.Hypergraph.EdgeAnnotation> > problems = analyzer.AnalyzeFigure(); // Acquire access to the backend hypergraph hypergraph = analyzer.GetHypergraphWrapper(); foreach (GeometryTutorLib.ConcreteAST.GroundedClause gc in manageGivensWindow.GetGivens()) { UIDebugPublisher.publishString("Given: " + gc.ToString()); } //Example of UI Output to AI Window foreach (GeometryTutorLib.ProblemAnalyzer.Problem <GeometryTutorLib.Hypergraph.EdgeAnnotation> problem in problems) { UIDebugPublisher.publishString(problem.ConstructProblemAndSolution(analyzer.graph).ToString()); } enterSolutionWindow.problem = problems[0]; UIDebugPublisher.publishString("Parse Complete."); }
/// <summary> /// Give the window critical data and then display the window. /// Call this method instead of the inherited Show(). /// </summary> /// <param name="parser">A Drawing Parser initialized with the current drawing. (This method will call Parse)</param> /// <param name="currentGivens">A list of all the current givens.</param> public void Show(DrawingParserMain parser, List <GroundedClause> currentGivens) { this.parser = parser; this.currentGivens = currentGivens; parser.Parse(); OnShow(); Show(); }
void StartRegionShading() { if (!ShadingMode) { UpdateShadingMode(true); //Parse and set atoms DrawingParserMain parser = new DrawingParserMain(drawingHost.CurrentDrawing); parser.Parse(); DynamicGeometry.UI.RegionShading.ShadedRegionCreator.Atoms = parser.backendParser.GetAtomicRegions(); } }
/// <summary> /// This event executes when the check solution button is clicked. /// Will perform a solution check and update the checkbox. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CheckSolutionBtn_Click(object sender, RoutedEventArgs e) { bool correctSolution = false; if (currentJust.Count > 0 && currentSolution.Values.Count > 0) { //System.Diagnostics.Debug.Assert(problem != null && wrapper != null); List <GroundedClause> solutions = new List <GroundedClause>(currentSolution.Values); List <JustificationSwitch.DeductionJustType> justifications = new List <JustificationSwitch.DeductionJustType>(); currentJust.ForEach <String>(justStr => justifications.Add(justWindow[justStr])); var parser = new DrawingParserMain(drawingHost.CurrentDrawing); parser.Parse(); //TODO: Perform checks here. Update the correctSolution variable to true if all checks pass. //Use solutions and justifications lists /* List<GroundedClause> passed = new List<GroundedClause>(); * GroundedClause hint = null; * foreach (GroundedClause step in solutions) * { * if (wrapper.QueryNodeInGraph(step)) * { * passed.Add(step); * } * else * { * hint = wrapper.QueryHint(problem, passed); * break; * } * }*/ } //Provide feedback if (correctSolution) { checkSolutionResult.Text = "Correct!"; } else { checkSolutionResult.Text = "Stuck?\nAsk for a hint."; } }