boblsturm@0: %Used for the plot drawing function boblsturm@0: function drawClickCallBack(src,callbackdata, action) boblsturm@0: matlabVer = version; boblsturm@0: handles = guidata(src); boblsturm@0: ah = handles.axes2; boblsturm@0: if(strcmp(matlabVer, '9.0.0.341360 (R2016a)')) boblsturm@0: xAxisProps = get(ah, 'XAxis'); boblsturm@0: xLimits = get(xAxisProps, 'Limits') boblsturm@0: else boblsturm@0: xAxisProps = get(ah, 'Xlim'); boblsturm@0: xLimits = xAxisProps boblsturm@0: end boblsturm@0: boblsturm@0: acts = handles.SynthesisObject.Activations; boblsturm@0: boblsturm@0: yMax = size(acts, 1); boblsturm@0: xMax = size(acts, 2); boblsturm@0: boblsturm@0: xUnit = xLimits/size(acts, 2); boblsturm@0: boblsturm@0: sliderHandle = handles.sld_actstrength; boblsturm@0: boblsturm@0: paintBrush = handles.grp_paintbrush.SelectedObject.String; boblsturm@0: paintBrushSize = 0; boblsturm@0: boblsturm@0: if(strcmp(paintBrush, 'Large Brush')) boblsturm@0: paintBrushSize = 1; boblsturm@0: else(strcmp(paintBrush, 'Small Brush')) boblsturm@0: paintBrushSize = 0; boblsturm@0: end boblsturm@0: boblsturm@0: if(strcmp(action, 'Draw')) boblsturm@0: src.Pointer = 'cross'; boblsturm@0: fillValue = get(sliderHandle, 'Value') boblsturm@0: elseif(strcmp(action, 'Erase')) boblsturm@0: src.Pointer = 'circle'; boblsturm@0: fillValue = 0; boblsturm@0: end boblsturm@0: boblsturm@0: cp = ah.CurrentPoint; boblsturm@0: cx = cp(1,1)/xUnit(2) boblsturm@0: cy = cp(1,2) boblsturm@0: boblsturm@0: drawXMax = (ceil(cx) + paintBrushSize); boblsturm@0: drawYMax = (ceil(cy) + paintBrushSize); boblsturm@0: drawXMin = (ceil(cx) - paintBrushSize); boblsturm@0: drawYMin = (ceil(cy) - paintBrushSize); boblsturm@0: boblsturm@0: if(drawXMax >= xMax) boblsturm@0: drawXMax = xMax; boblsturm@0: end boblsturm@0: boblsturm@0: if(drawYMax >= yMax) boblsturm@0: drawYMax = yMax; boblsturm@0: end boblsturm@0: boblsturm@0: if(drawXMin <=0) boblsturm@0: drawXMin = 1; boblsturm@0: end boblsturm@0: boblsturm@0: if(drawYMin <=0) boblsturm@0: drawYMin = 1; boblsturm@0: end boblsturm@0: boblsturm@0: acts(drawYMin:drawYMax, drawXMin:drawXMax) = fillValue; boblsturm@0: handles.SynthesisObject.Activations = acts; boblsturm@0: size(acts, 1) boblsturm@0: guidata(src, handles); boblsturm@0: boblsturm@0: src.WindowButtonMotionFcn = @dragCallBack; boblsturm@0: src.WindowButtonUpFcn = @releaseCallBack; boblsturm@0: boblsturm@0: function dragCallBack(src, callbackdata) boblsturm@0: cp = ah.CurrentPoint; boblsturm@0: cx = cp(1,1)/xUnit(2); boblsturm@0: cy = cp(1,2); boblsturm@0: boblsturm@0: drawXMax = (ceil(cx) + paintBrushSize); boblsturm@0: drawYMax = (ceil(cy) + paintBrushSize); boblsturm@0: drawXMin = (ceil(cx) - paintBrushSize); boblsturm@0: drawYMin = (ceil(cy) - paintBrushSize); boblsturm@0: boblsturm@0: if(drawXMax >= xMax) boblsturm@0: drawXMax = xMax; boblsturm@0: end boblsturm@0: boblsturm@0: if(drawYMax >= yMax) boblsturm@0: drawYMax = yMax; boblsturm@0: end boblsturm@0: boblsturm@0: if(drawXMin <=0) boblsturm@0: drawXMin = 1; boblsturm@0: end boblsturm@0: boblsturm@0: if(drawYMin <=0) boblsturm@0: drawYMin = 1; boblsturm@0: end boblsturm@0: boblsturm@0: % fprintf('X: %u Y: %u', ceil(cy), ceil(cx)) boblsturm@0: acts(drawYMin:drawYMax, drawXMin:drawXMax) = fillValue; boblsturm@0: handles.SynthesisObject.Activations = acts; boblsturm@0: guidata(src, handles); boblsturm@0: end boblsturm@0: boblsturm@0: function releaseCallBack(src, callbackdata) boblsturm@0: controller('switchPlot', handles); boblsturm@0: src.Pointer = 'arrow'; boblsturm@0: src.WindowButtonMotionFcn = ''; boblsturm@0: src.WindowButtonUpFcn = ''; boblsturm@0: end boblsturm@0: end