Search in sources :

Example 6 with Demonstration

use of edu.cmu.cs.hcii.cogtool.model.Demonstration in project cogtool by cogtool.

the class SEFrameChooserController method setHandLocationAction.

protected void setHandLocationAction(final HandLocation handLoc) {
    final Demonstration demo = taskApp.getDemonstration();
    final boolean mouseHand = demo.getMouseHand();
    final DefaultModelGeneratorState initialState = demo.getInitialState();
    final HandLocation oldLoc = initialState.getHandLocation(mouseHand);
    initialState.setHandLocation(mouseHand, handLoc);
    demo.alertInitialStateChange();
    undoMgr.addEdit(new AUndoableEdit(SEFrameChooserLID.SetHandLocation) {

        @Override
        public String getPresentationName() {
            return setHandLocation;
        }

        @Override
        public void redo() {
            super.redo();
            initialState.setHandLocation(mouseHand, handLoc);
            demo.alertInitialStateChange();
        }

        @Override
        public void undo() {
            super.undo();
            initialState.setHandLocation(mouseHand, oldLoc);
            demo.alertInitialStateChange();
        }
    });
}
Also used : HandLocation(edu.cmu.cs.hcii.cogtool.model.HandLocation) AUndoableEdit(edu.cmu.cs.hcii.cogtool.util.AUndoableEdit) Demonstration(edu.cmu.cs.hcii.cogtool.model.Demonstration) DefaultModelGeneratorState(edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)

Example 7 with Demonstration

use of edu.cmu.cs.hcii.cogtool.model.Demonstration in project cogtool by cogtool.

the class SEFrameChooserController method createSetStartFrameAction.

protected IListenerAction createSetStartFrameAction() {
    return new IListenerAction() {

        public Class<?> getParameterClass() {
            return Frame.class;
        }

        public boolean performAction(Object prms) {
            final Frame startFrame = (Frame) prms;
            if (startFrame != null) {
                final Demonstration demo = taskApp.getDemonstration();
                final Frame oldStartFrame = demo.getStartFrame();
                if (startFrame == oldStartFrame) {
                    return true;
                }
                demo.setStartFrame(startFrame);
                undoMgr.addEdit(new AUndoableEdit(SEFrameChooserLID.SetStartFrame) {

                    @Override
                    public String getPresentationName() {
                        return setStartFrame;
                    }

                    @Override
                    public void redo() {
                        super.redo();
                        demo.setStartFrame(startFrame);
                    }

                    @Override
                    public void undo() {
                        super.undo();
                        demo.setStartFrame(oldStartFrame);
                    }
                });
                return true;
            }
            interaction.protestNoSelection();
            return false;
        }
    };
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) AUndoableEdit(edu.cmu.cs.hcii.cogtool.util.AUndoableEdit) Demonstration(edu.cmu.cs.hcii.cogtool.model.Demonstration)

Example 8 with Demonstration

use of edu.cmu.cs.hcii.cogtool.model.Demonstration in project cogtool by cogtool.

the class SEFrameChooserController method setMouseHandAction.

protected void setMouseHandAction(final boolean mouseHand) {
    final Demonstration demo = taskApp.getDemonstration();
    final boolean oldMouseHand = demo.getMouseHand();
    final DefaultModelGeneratorState initialState = demo.getInitialState();
    final HandLocation mouseHandLoc = initialState.getHandLocation(oldMouseHand);
    demo.setMouseHand(mouseHand);
    initialState.setHandLocation(mouseHand, mouseHandLoc);
    initialState.setHandLocation(!mouseHand, HandLocation.OnKeyboard);
    undoMgr.addEdit(new AUndoableEdit(SEFrameChooserLID.SetMouseHand) {

        @Override
        public String getPresentationName() {
            return setMouseHand;
        }

        @Override
        public void redo() {
            super.redo();
            initialState.setHandLocation(mouseHand, mouseHandLoc);
            initialState.setHandLocation(!mouseHand, HandLocation.OnKeyboard);
            // Do this last as it will alert
            demo.setMouseHand(mouseHand);
        }

        @Override
        public void undo() {
            super.undo();
            initialState.setHandLocation(oldMouseHand, mouseHandLoc);
            initialState.setHandLocation(!oldMouseHand, HandLocation.OnKeyboard);
            // Do this last as it will alert
            demo.setMouseHand(oldMouseHand);
        }
    });
}
Also used : HandLocation(edu.cmu.cs.hcii.cogtool.model.HandLocation) AUndoableEdit(edu.cmu.cs.hcii.cogtool.util.AUndoableEdit) Demonstration(edu.cmu.cs.hcii.cogtool.model.Demonstration) DefaultModelGeneratorState(edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)

Example 9 with Demonstration

use of edu.cmu.cs.hcii.cogtool.model.Demonstration in project cogtool by cogtool.

the class SNIFACTCmd method setUpTaskApplication.

/**
     * Generates a script using the given generator and situates the task
     * application in the project.
     * Assumes the demonstration in the task application already contains a list
     * of script steps.
     */
public static void setUpTaskApplication(Project project, TaskApplication ta, CognitiveModelGenerator gen) {
    Design design = ta.getDesign();
    Demonstration demo = ta.getDemonstration();
    DemoStateManager.getStateManager(project, design).trackEdits(demo);
    Script s = new Script(demo, gen);
    // Scripts generated by the SNIF-ACT algorithm are not editable!
    demo.setEditable(false);
    Iterator<AScriptStep> newDemoSteps = demo.getStepsAt(0);
    List<DefaultModelGeneratorState> newStepStates = new ArrayList<DefaultModelGeneratorState>();
    List<String> errorLines = new ArrayList<String>();
    DefaultModelGeneratorState stepState = demo.getInitialState();
    while (newDemoSteps.hasNext()) {
        AScriptStep newDemoStep = newDemoSteps.next();
        stepState = gen.generateScriptSteps(newDemoStep, stepState, errorLines, newStepStates);
    }
    s.replaceStepStates(0, newStepStates);
    ta.setScript(gen, s);
    project.setTaskApplication(ta);
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) ITaskDesign(edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign) Script(edu.cmu.cs.hcii.cogtool.model.Script) ArrayList(java.util.ArrayList) Demonstration(edu.cmu.cs.hcii.cogtool.model.Demonstration) AScriptStep(edu.cmu.cs.hcii.cogtool.model.AScriptStep) DefaultModelGeneratorState(edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)

Example 10 with Demonstration

use of edu.cmu.cs.hcii.cogtool.model.Demonstration in project cogtool by cogtool.

the class ResultDisplayPolicy method getTaskApplicationCell.

public static String getTaskApplicationCell(Project project, TaskApplication taskApp, CognitiveModelGenerator gen, boolean forCell, String withSecs) {
    if ((gen == null) || (taskApp == null) || ((!taskApp.hasComputedResult()) && (!taskApp.hasComputableScript())) || (taskApp.getScript(gen) == null)) {
        // has a TaskApp, but no Script for the current algorithm
        return "";
    }
    Demonstration demo = taskApp.getDemonstration();
    IPredictionAlgo alg = taskApp.determineActiveAlgorithm(project);
    APredictionResult r = taskApp.getResult(gen, alg);
    int resultState = (r == null) ? APredictionResult.NOT_COMPUTED : r.getResultState();
    //  ??  means the demonstration is invalid or script needs regeneration
    if (forCell) {
        if (demo.isInvalid() || demo.isObsolete()) {
            return "?? ";
        }
        if ((resultState == APredictionResult.NOT_COMPUTED) || (alg.requiresDemonstration() && !demo.isStartFrameChosen())) {
            // No result yet computed for the associated script
            return "-- ";
        }
        if (resultState == APredictionResult.COMPUTATION_IN_PROGRESS) {
            // Result is being computed
            return "(><) ";
        }
        if (resultState == APredictionResult.COMPUTE_FAILED) {
            // Has a result for this algorithm, but it failed
            return "XX ";
        }
        double timing = getComputationResult(r);
        if (timing < 0.0) {
            return "~~";
        }
        updateDigits();
        String result = cellNumberFormat.format(timing);
        if (CogToolPref.KLM_RESULT_RANGE.getBoolean() && withSecs != null && withSecs.length() > 0) {
            result += " (" + cellNumberFormat.format(0.9 * timing);
            result += ", " + cellNumberFormat.format(1.1 * timing);
            result += ")";
        }
        result += withSecs;
        return result;
    //            return (timing >= 0.0)
    ////                        ? (cellNumberFormat.format(timing) + withSecs)
    //                        ? (cellNumberFormat.format(timing) + withSecs + " ±10%")
    //                        : "~~";
    }
    // Long form task application state descriptions, used for tooltips
    // "" means no task application or no computable script for alg
    // -- / "" means computable, not computed, and demo is valid
    // -- / X  means not computed and demo is invalid
    // -- / ?  means not computed and script needs regeneration
    // NN / "" means computed and demo is valid
    // NN / X  means computed and demo is invalid
    // NN / ?  means computed and script needs regeneration
    // ## / "" means computation failed and demo is valid
    // ## / X  means computation failed and demo is invalid
    // ## / ?  means computation failed, script needs regeneration
    // (><) / ... means result is being computed
    // ~~ / ... means result resulted in a negative number (??)
    String demoState;
    if (demo.isInvalid()) {
        // " / X ";
        demoState = " / INVALID";
    } else if (demo.isObsolete()) {
        // " / ? ";
        demoState = " / OBSOLETE";
    } else {
        // " /   ";
        demoState = "";
    }
    if ((resultState == APredictionResult.NOT_COMPUTED) || !demo.isStartFrameChosen()) {
        // No result yet computed for the associated script
        return "NOT COMPUTED" + /* "--" */
        demoState;
    }
    if (resultState == APredictionResult.COMPUTE_FAILED) {
        // Has a result for this algo, but it failed
        return "COMPUTE FAILED" + /* "##" */
        demoState;
    }
    if (resultState == APredictionResult.COMPUTATION_IN_PROGRESS) {
        // Result is being computed
        return "BEING COMPUTED" + /* "(><)" */
        demoState;
    }
    double timing = getComputationResult(r);
    updateDigits();
    return (timing >= 0.0) ? (cellNumberFormat.format(timing) + withSecs + demoState) : ("~~" + demoState);
}
Also used : IPredictionAlgo(edu.cmu.cs.hcii.cogtool.model.IPredictionAlgo) APredictionResult(edu.cmu.cs.hcii.cogtool.model.APredictionResult) Demonstration(edu.cmu.cs.hcii.cogtool.model.Demonstration)

Aggregations

Demonstration (edu.cmu.cs.hcii.cogtool.model.Demonstration)24 TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)11 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)9 DefaultModelGeneratorState (edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)9 AUndoableEdit (edu.cmu.cs.hcii.cogtool.util.AUndoableEdit)9 AScriptStep (edu.cmu.cs.hcii.cogtool.model.AScriptStep)8 ComputationUndoRedo (edu.cmu.cs.hcii.cogtool.controller.DemoScriptCmd.ComputationUndoRedo)7 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)7 Design (edu.cmu.cs.hcii.cogtool.model.Design)6 Script (edu.cmu.cs.hcii.cogtool.model.Script)6 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)6 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)4 HandLocation (edu.cmu.cs.hcii.cogtool.model.HandLocation)4 ThinkScriptStep (edu.cmu.cs.hcii.cogtool.model.ThinkScriptStep)4 APredictionResult (edu.cmu.cs.hcii.cogtool.model.APredictionResult)3 CognitiveModelGenerator (edu.cmu.cs.hcii.cogtool.model.CognitiveModelGenerator)3 IPredictionAlgo (edu.cmu.cs.hcii.cogtool.model.IPredictionAlgo)3 ITaskDesign (edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign)3 TaskGroup (edu.cmu.cs.hcii.cogtool.model.TaskGroup)3 GraphicsUtil (edu.cmu.cs.hcii.cogtool.util.GraphicsUtil)3