     var cutter: IMPCropFilter!
     var warp: IMPWarpFilter!
     
+    var points = [NSPoint]()
+    
+    override func mouseDown(theEvent: NSEvent) {
+        let event_location = theEvent.locationInWindow
+        let local_point = self.imageView.convertPoint(event_location,fromView:nil)
+        
+        points.append(local_point)
+        
+        let w = self.imageView.frame.size.width.float
+        let h = self.imageView.frame.size.height.float
+        
+        if points.count == 4 {
+            var left_bottom = points[0]
+ 
+            warp.sourceQuad.left_bottom.x = left_bottom.x.float / w - 1
+            warp.sourceQuad.left_bottom.y = left_bottom.y.float / h - 1
+            
+            var left_top = points[1]
+            
+            warp.sourceQuad.left_top.x = left_top.x.float / w - 1
+            warp.sourceQuad.left_top.y = left_top.y.float / h
+
+            let right_bottom = points[3]
+            
+            warp.sourceQuad.right_bottom.x = right_bottom.x.float / w
+            warp.sourceQuad.right_bottom.y = right_bottom.y.float / h - 1
+            
+            let right_top = points[2]
+            
+            warp.sourceQuad.right_top.x = right_top.x.float / w
+            warp.sourceQuad.right_top.y = right_top.y.float / h
+            
+            NSLog(" .... \(warp.sourceQuad, local_point)")
+
+            points.removeAll()
+        }
+    }
+
     override func viewDidLoad() {
         
         super.viewDidLoad()

        fatalError("init(coder:) has not been implemented")
    }
}

class ViewController: NSViewController {
    

        filter.addFilter(photoCutter)
        filter.addFilter(cutter)
        

        //warp.destinationQuad.left_bottom.x = -1
        //warp.destinationQuad.right_bottom.x = 1
        
        imageView = IMPImageView(context: context, frame: view.bounds)
        imageView.filter = filter
        imageView.backgroundColor = IMPColor(color: IMPPrefs.colors.background)
        
        transformer.addMatrixModelObserver { (destination, model, a) in
        }
        
        view.addSubview(imageView)
        imageView.translatesAutoresizingMaskIntoConstraints = false
        
