Skip to content

Commit

Permalink
Synphne track and recreate implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
nczakaria committed Aug 19, 2015
1 parent 331a995 commit abcf6b7
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ package sg.edu.smu.ksketch2.canvas.components.popup
_closeButton.initSkin();
_closeButton.addEventListener(MouseEvent.CLICK, _continue);

_dialogPopUp.buttonComponent.addElement(_retryButton);
_dialogPopUp.buttonComponent.addElement(_closeButton);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
private var HEADER_GAP:Number = 20 * KSketchGlobals.SCALE;
private var HEADER_WIDTH:Number = 100 * KSketchGlobals.SCALE;
private var INST_BUTTONDIMENSION = 50 * KSketchGlobals.SCALE;
private var _canvasView:KSketch_CanvasView;
private var _dialogPopUp:KSketch_DialogBox_Skin;
Expand Down Expand Up @@ -197,7 +198,6 @@
private function startTiming(event:TimerEvent):void {
_kAlertBox.close();
_canvasView.autoPlayAnimation();
_activityControl.autoSelectObjectToAnimate();
_canvasView.startTimer();
}
Expand Down Expand Up @@ -299,9 +299,9 @@
<s:layout>
<s:HorizontalLayout gap="{HEADER_GAP}" horizontalAlign="center" verticalAlign="middle"/>
</s:layout>
<buttons:KSketch_ListButton id="activityButton_Prev" click="previousActivity()"/>
<buttons:KSketch_ListButton id="activityButton_Prev" width="{INST_BUTTONDIMENSION}" height="{INST_BUTTONDIMENSION}" click="previousActivity()"/>
<s:Label width="{HEADER_WIDTH}" id="activityHeader" textAlign="center"/>
<buttons:KSketch_ListButton id="activityButton_Next" click="nextActvity()"/>
<buttons:KSketch_ListButton id="activityButton_Next" width="{INST_BUTTONDIMENSION}" height="{INST_BUTTONDIMENSION}" click="nextActvity()"/>
</s:Group>


Expand All @@ -315,9 +315,9 @@
<s:layout>
<s:HorizontalLayout gap="{HEADER_GAP}" horizontalAlign="center" verticalAlign="middle"/>
</s:layout>
<buttons:KSketch_ListButton id="instructionButton_Prev" click="previousInstruction()"/>
<buttons:KSketch_ListButton id="instructionButton_Prev" width="{INST_BUTTONDIMENSION}" height="{INST_BUTTONDIMENSION}" click="previousInstruction()"/>
<s:Label width="{HEADER_WIDTH}" id="instructionHeader" text="Default" textAlign="center"/>
<buttons:KSketch_ListButton id="instructionButton_Next" click="nextInstruction()"/>
<buttons:KSketch_ListButton id="instructionButton_Next" width="{INST_BUTTONDIMENSION}" height="{INST_BUTTONDIMENSION}" click="nextInstruction()"/>
</s:Group>

<s:Label id="instructionMessage" text="This is the default text. {'\n'}Set message according to activity."/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@
titleAccuracyMax.setStyle("fontSize", KSketchGlobals.FONT_SIZE_18);
closeButton.init("Close");
menuTopButton.init("Top");
menuLeftButton.init("Left");
menuRightButton.init("Right");
closeButton.initSkin();
menuTopButton.initSkin();
menuLeftButton.initSkin();
menuRightButton.initSkin();
}
Expand Down Expand Up @@ -439,12 +441,16 @@
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<buttons:KSketch_DialogButton id="menuTopButton" click="_menuTop()"/>
<buttons:KSketch_DialogButton id="menuLeftButton" click="_menuLeft()"/>
<buttons:KSketch_DialogButton id="menuRightButton" click="_menuRight()"/>
</s:Group>
</s:Group>

<s:Group id="optionItems">
<s:layout>
<s:VerticalLayout paddingLeft="{CONTENT_PADDING}"/>
</s:layout>
<s:Group>
<s:layout>
<s:HorizontalLayout paddingLeft="{CONTENT_PADDING}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@
//KSKETCH-SYNPHNE
if(KSketch_CanvasView.isSynphne)
{
buttonContainer.removeElementAt(13);
buttonContainer.removeElementAt(12);
buttonContainer.removeElementAt(10);
buttonContainer.removeElementAt(4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,18 +376,11 @@
//KSKETCH-SYNPHNE
_kInstructions = new KInstructions(new XML(_currentDocument.fileData.activities));
_instructionsBox.init(this, _kInstructions, _kAlertBox, _activityControl, _resultControl);
_activityControl.isNewSketch = true;
synphne_component.visible = true;
}
}
}
else
{
if(isSynphne)
{
//KSKETCH-SYNPHNE
_activityControl.isNewSketch = true;
instructionsButton.visible = false;
}
}
data = null;
}
Expand Down Expand Up @@ -700,7 +693,6 @@
public function autoPlayAnimation():void
{
playButton.playToggle(true);
_activityControl.autoSelectObjectToAnimate();
}
public function setAnimationPlaying(value:Boolean):void
Expand Down Expand Up @@ -939,7 +931,7 @@
<transformWidget2:KSketch_Widget_Component id="widget" visible="false"/>

<!-- KSKETCH-SYNPHNE -->
<s:Group id="synphne_component" width="100%" depth="0">
<s:Group id="synphne_component" width="100%" depth="0" visible="false">
<s:layout>
<s:HorizontalLayout paddingTop="{SYNPHNE_PADDINGTOP}" verticalAlign="middle" horizontalAlign="center"/>
</s:layout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ package sg.edu.smu.ksketch2.canvas.components.view.objects

override public function eraseIfHit(xPoint:Number, yPoint:Number, time:Number, op:KCompositeOperation):void
{
if(hitTestPoint(xPoint, yPoint, true))
//if(hitTestPoint(xPoint, yPoint, true))
//KSKETCH-SYNPHNE
if(hitTestPoint(xPoint, yPoint, true) && !_object.template)
{
//do a check if object belongs to a group and if all the objects in the group are erased at that time
var parent:KGroup = _object.parent;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sg.edu.smu.ksketch2.canvas.controls
{
import flash.display.DisplayObject;
import flash.geom.Point;

import sg.edu.smu.ksketch2.KSketch2;
import sg.edu.smu.ksketch2.canvas.components.popup.KSketch_InstructionsBox;
Expand Down Expand Up @@ -53,11 +54,11 @@ package sg.edu.smu.ksketch2.canvas.controls
_setObjectProperties(false, false, false);
}
_canvasView.resetTimeControl();
_interactionControl.selection = null;

if(activity == "INTRO")
{
_activityType = "INTRO";
_discardSketchedObjects();
_hideObjects(true);
startIntroductionAnimation();
_isAnimationPlaying = true;
Expand All @@ -79,11 +80,29 @@ package sg.edu.smu.ksketch2.canvas.controls
else if(activity == "TRACK")
{
_activityType = "TRACK";
trace("before");
_currentManipulateObject = _getCurrentObjectToTrack(false);

trace("after");
//If there is no sketched object to track, then duplicate copy of the original
if(!_currentManipulateObject)
{
_currentManipulateObject = _duplicateObject(_currentTemplateObject as KStroke);
trace("Implement duplicate object for track without trace");
}
_setObjectProperties(false, false, true);
_hideObjects(true);
processTrack(_currentManipulateObject as KStroke);
}
else if(activity == "RECREATE")
{
_interactionControl.selection = null;
_activityType = "RECREATE";
_currentManipulateObject = null; //_getCurrentObjectToTrack(false);
_setObjectProperties(false, false, false);
_hideObjects(false);
//processTrack(_currentManipulateObject as KStroke);
}
}

private function _setObjectProperties(isRecall:Boolean, isTrace:Boolean, isTrack:Boolean):void
Expand Down Expand Up @@ -132,6 +151,7 @@ package sg.edu.smu.ksketch2.canvas.controls
_canvasView.setRegionVisibility(true);
_hideObjects(false);
}
_interactionControl.selection = null;
}

public function processRecall(correctRecall:Boolean):void
Expand All @@ -152,6 +172,7 @@ package sg.edu.smu.ksketch2.canvas.controls
_instructionsBox.open(_canvasView, false);
_instructionsBox.startStopActivity();
}
_interactionControl.selection = null;
}

public function incrementRecallCounter():void
Expand All @@ -170,11 +191,13 @@ package sg.edu.smu.ksketch2.canvas.controls
currObj.originalId = _currentObjectID;
}
}

_interactionControl.selection = null;
}

public function processTrack(currObj:KStroke):void
{
if(currObj) //if there is a sketched object
if(currObj)
{
//unhide current object and disable it as a template
var tempArr:Array = new Array(_KSketch.root.children.length());
Expand Down Expand Up @@ -203,11 +226,15 @@ package sg.edu.smu.ksketch2.canvas.controls
{
if(currObj is KStroke && currObj.id != currObj.originalId && currObj.originalId == _currentObjectID)
break;
else
currObj = null;
}
else
{
if(currObj is KStroke && currObj.id == currObj.originalId && currObj.originalId == _currentObjectID)
break;
else
currObj = null;
}
}

Expand Down Expand Up @@ -291,7 +318,7 @@ package sg.edu.smu.ksketch2.canvas.controls
var view:IObjectView = _canvasView.modelDisplay.viewsTable[currObj];
(view as DisplayObject).visible = false;

trace("hide this view and obj " + currObj.id);
//trace("hide this view and obj " + currObj.id);
/*This portion will delete the stroke/view
var view:IObjectView = _canvasView.modelDisplay.viewsTable[currObj];
var op:KCompositeOperation = new KCompositeOperation();
Expand All @@ -318,12 +345,14 @@ package sg.edu.smu.ksketch2.canvas.controls
_KSketch.dispatchEvent(new KSketchEvent(KSketchEvent.EVENT_MODEL_UPDATED));
}

public function duplicateObject(currObj:KStroke):KObject
private function _duplicateObject(currObj:KStroke):KObject
{
_interactionControl.begin_interaction_operation();

var op:KCompositeOperation = new KCompositeOperation();
var newStroke:KStroke = new KStroke(0, currObj.points, currObj.color, currObj.thickness);
var newStroke:KStroke = _KSketch.object_Add_Stroke(currObj.points, _KSketch.time, currObj.color, currObj.thickness, op);
(newStroke as KObject).originalId = (currObj as KObject).id;

_interactionControl.end_interaction_operation();

return (newStroke as KObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ package sg.edu.smu.ksketch2.canvas.controls
import sg.edu.smu.ksketch2.utils.KInteractionOperation;
import sg.edu.smu.ksketch2.utils.KSelection;

//KSKETCH-SYNPHNE
import sg.edu.smu.ksketch2.canvas.components.view.KSketch_CanvasView;

/**
* The KInteractionControl class serves as the concrete class for
* interaction control in K-Sketch.
Expand Down Expand Up @@ -101,6 +104,16 @@ package sg.edu.smu.ksketch2.canvas.controls
{
if(newSelection)
{
//KSKETCH-SYNPHNE
if(KSketch_CanvasView.isSynphne)
{
if(newSelection.objects.getObjectAt(0) != null)
{
if(newSelection.objects.getObjectAt(0).template)
return;
}
}

if(newSelection.objects.length() == 0)
newSelection = null;
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ package sg.edu.smu.ksketch2.canvas.controls.interactors
}
else
{
trace("recognise synphne");
_recogniseTapSynphne(event);
}

Expand All @@ -311,6 +310,19 @@ package sg.edu.smu.ksketch2.canvas.controls.interactors
*/
private function _recogniseDraw(event:GestureEvent):void
{
//KSKETCH-SYNPHNE
if(KSketch_CanvasView.isSynphne)
{
if(_activityControl.activityType == "INTRO")
return;

if(_activityControl.activityType == "RECALL")
{
_activityControl.incrementRecallCounter();
return;
}
}

KSketch_CanvasView.tracker.trackPageview( "/canvas/draw" );
if(_interactionControl.currentInteraction)
return;
Expand Down Expand Up @@ -396,10 +408,8 @@ package sg.edu.smu.ksketch2.canvas.controls.interactors

private function _recogniseTapIntro(tapLocation:Point):void
{
trace("tap detected " + KSketch_CanvasView_Preferences.tapAnywhere);
if(KSketch_CanvasView_Preferences.tapAnywhere == "TAPANYWHERE_ON")
{
trace("tap ok");
_activityControl.stopIntroductionAnimation();
_activityControl.processIntro(true);
}
Expand All @@ -415,7 +425,6 @@ package sg.edu.smu.ksketch2.canvas.controls.interactors
selectionArea.graphics.endFill();
_modelDisplay.addChild(selectionArea);
if (selectionArea.hitTestObject(view as DisplayObject)) {
trace("hit");
_activityControl.stopIntroductionAnimation();
_activityControl.processIntro(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package sg.edu.smu.ksketch2.canvas.controls.interactors.transitions
import sg.edu.smu.ksketch2.canvas.controls.KInteractionControl;
import sg.edu.smu.ksketch2.model.data_structures.KModelObjectList;
import sg.edu.smu.ksketch2.operators.operations.KCompositeOperation;
import sg.edu.smu.ksketch2.canvas.controls.interactors.widgetstates.KWidgetInteractorManager;
import sg.edu.smu.ksketch2.utils.KSelection;

public class KTransitionInteractor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ package sg.edu.smu.ksketch2.canvas.controls.interactors.widgetstates

//KSKETCH-SYNPHNE
private var _activityControl:KActivityControl;
private var _widgetHighlight:Boolean = false;

/**
* The main constructor for the KWidgetInteractorManager class.
Expand Down Expand Up @@ -278,6 +279,9 @@ package sg.edu.smu.ksketch2.canvas.controls.interactors.widgetstates
*/
public function updateWidget(event:Event):void
{
//KSKETCH-SYNPHNE
_widgetHighlight = false;

_widget.visible = false;

if(event.type == KInteractionControl.EVENT_INTERACTION_BEGIN)
Expand All @@ -295,7 +299,7 @@ package sg.edu.smu.ksketch2.canvas.controls.interactors.widgetstates
_widget.visible = false;
activeMode = defaultMode;
_contextMenu.close();
return;
return;
}

if(!_isInteracting)
Expand Down Expand Up @@ -328,6 +332,19 @@ package sg.edu.smu.ksketch2.canvas.controls.interactors.widgetstates
*/
public function updateMovingWidget(event:Event):void
{
//KSKETCH-SYNPHNE
if(_activityControl && !_widgetHighlight)
{
if(_activityControl.activityType == "TRACK")
{
//select the object to track and set it to demonstration mode
transitionMode = KSketch2.TRANSITION_DEMONSTRATED;
_activityControl.autoSelectObjectToAnimate();
_widget.visible = true;
_widgetHighlight = true;
}
}

if(_interactionControl.selection)
{
_widget.visible = true;
Expand Down

0 comments on commit abcf6b7

Please sign in to comment.