[Commits] r1797 - in sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt: data widgets

commits at geoext.org commits at geoext.org
Thu Jan 21 20:22:11 CET 2010


Author: ahocevar
Date: 2010-01-21 20:22:10 +0100 (Thu, 21 Jan 2010)
New Revision: 1797

Modified:
   sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/data/PrintPage.js
   sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/widgets/PrintExtent.js
Log:
shift-key to constrain rotation to 45?\194?\176 steps

Modified: sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/data/PrintPage.js
===================================================================
--- sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/data/PrintPage.js	2010-01-21 12:53:45 UTC (rev 1796)
+++ sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/data/PrintPage.js	2010-01-21 19:22:10 UTC (rev 1797)
@@ -40,9 +40,9 @@
      */
     feature: null,
     
-    /** api: property[handle]
+    /** private: property[handles]
      *  Array(``OpenLayers.Feature.Vector``) Features providing the four
-     *  scale/rotation handles for the page. Read-only.
+     *  scale/rotation handles for the page.
      */
     handles: null,
     
@@ -206,7 +206,7 @@
         this.setScale(loose && contains ? looseScale : scale, units);
     },
 
-    /** api: method[updateByHandle]
+    /** private: method[updateByHandle]
      *  :param handle: ``OpenLayers.Feature.Vector`` the handle to use.
      *  :param updateHandles: ``Boolean`` If set to false, only the feature
      *      will be updated, but the handles will not be aligned. Defaults to
@@ -216,7 +216,8 @@
      *  method is useful for drag handlers on the handle geometry, when
      *  displayed on a layer.
      */
-    updateByHandle: function(handle, updateHandles) {
+    updateByHandle: function(handle, updateHandles, rotationIncrement) {
+        rotationIncrement = rotationIncrement || 1;
         var handles = this.handles;
         handle = handle || handles[0];
         var handleIndex = handles.indexOf(handle);
@@ -272,7 +273,9 @@
         if(rotate) {
             var dx = topCenter.lon - origin.x;
             var dy = topCenter.lat - origin.y;
-            rotation = Math.round(Math.atan2(dx, dy) * 180 / Math.PI);
+            rotation = Math.round(
+                Math.atan2(dx, dy) * 180 / Math.PI / rotationIncrement) *
+                rotationIncrement;
             geom.rotate(-rotation, geom.getCentroid());
         }
         
@@ -303,13 +306,6 @@
         this.fireEvent("change", this);
     },
     
-    /** api: method[updateHandles]
-     *      
-     *  Updates the handle positions to align with the page feature. Useful
-     *  for drag handlers on the page feature to update the handles while
-     *  dragging, and for drag handlers on the handle features to re-align the
-     *  handles with the page feature after dragging.
-     */
     /** private: method[updateHandles]
      *  :param geometry: ``OpenLayers.Geometry.Polygon`` Optional. If provided,
      *      handle geometries will be taken from the vertices of the provided

Modified: sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/widgets/PrintExtent.js
===================================================================
--- sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/widgets/PrintExtent.js	2010-01-21 12:53:45 UTC (rev 1796)
+++ sandbox/ahocevar/playground/trunk/geoext/lib/GeoExt/widgets/PrintExtent.js	2010-01-21 19:22:10 UTC (rev 1797)
@@ -192,7 +192,8 @@
                     } else if(geom instanceof OpenLayers.Geometry.Point) {
                         // a scale/rotation handle was dragged
                         for(var i=0, len=pages.length; i<len; ++i) {
-                            pages[i].updateByHandle(feature);
+                            pages[i].updateByHandle(feature, false,
+                                this.handlers.drag.evt.shiftKey && 45);
                         }
                     }
                 },



More information about the Commits mailing list