Revision 6771 trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/CADToolAdapter.java
CADToolAdapter.java | ||
---|---|---|
35 | 35 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
36 | 36 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
37 | 37 |
import com.iver.cit.gvsig.fmap.edition.EditionEvent; |
38 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
|
39 | 38 |
import com.iver.cit.gvsig.fmap.edition.UtilFunctions; |
40 | 39 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
41 | 40 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
... | ... | |
45 | 44 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
46 | 45 |
import com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener; |
47 | 46 |
import com.iver.cit.gvsig.gui.View; |
47 |
import com.iver.cit.gvsig.gui.cad.snapping.FinalPointSnapper; |
|
48 | 48 |
import com.iver.cit.gvsig.gui.cad.snapping.ISnapper; |
49 |
import com.iver.cit.gvsig.gui.cad.snapping.FinalPointSnapper; |
|
49 |
import com.iver.cit.gvsig.gui.cad.snapping.ISnapperRaster; |
|
50 |
import com.iver.cit.gvsig.gui.cad.snapping.ISnapperVectorial; |
|
50 | 51 |
import com.iver.cit.gvsig.gui.cad.snapping.NearestPointSnapper; |
52 |
import com.iver.cit.gvsig.gui.cad.snapping.PixelSnapper; |
|
51 | 53 |
import com.iver.cit.gvsig.gui.cad.snapping.SnappingVisitor; |
52 | 54 |
import com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool; |
53 | 55 |
import com.iver.cit.gvsig.layers.ILayerEdited; |
... | ... | |
198 | 200 |
// DE CONFIGURACI?N DEL SNAPPING |
199 | 201 |
FinalPointSnapper defaultSnap = new FinalPointSnapper(); |
200 | 202 |
NearestPointSnapper nearestSnap = new NearestPointSnapper(); |
203 |
PixelSnapper pixSnap = new PixelSnapper(); |
|
201 | 204 |
snappers.clear(); |
202 | 205 |
snappers.add(defaultSnap); |
203 | 206 |
snappers.add(nearestSnap); |
207 |
snappers.add(pixSnap); |
|
204 | 208 |
|
205 | 209 |
double mapTolerance = vp.toMapDistance(SelectionCADTool.tolerance); |
206 | 210 |
double minDist = mapTolerance; |
... | ... | |
235 | 239 |
if (theSnapper.getPriority() < usedSnap.getPriority()) |
236 | 240 |
break; |
237 | 241 |
} |
242 |
SnappingVisitor snapVisitor = null; |
|
243 |
Point2D theSnappedPoint = null; |
|
244 |
if (theSnapper instanceof ISnapperVectorial) |
|
245 |
{ |
|
246 |
snapVisitor = new SnappingVisitor((ISnapperVectorial) theSnapper, point, mapTolerance, lastPoint); |
|
247 |
// System.out.println("Cache size = " + cache.size()); |
|
248 |
cache.query(e, snapVisitor); |
|
249 |
theSnappedPoint = snapVisitor.getSnapPoint(); |
|
250 |
} |
|
251 |
if (theSnapper instanceof ISnapperRaster) |
|
252 |
{ |
|
253 |
ISnapperRaster snapRaster = (ISnapperRaster) theSnapper; |
|
254 |
theSnappedPoint = snapRaster.getSnapPoint(getMapControl(), point, mapTolerance, lastPoint); |
|
255 |
} |
|
256 |
|
|
238 | 257 |
|
239 |
SnappingVisitor snapVisitor = new SnappingVisitor(theSnapper, point, mapTolerance, lastPoint); |
|
240 |
// System.out.println("Cache size = " + cache.size()); |
|
241 |
cache.query(e, snapVisitor); |
|
242 |
|
|
243 |
if (snapVisitor.getSnapPoint() != null) { |
|
244 |
if (minDist > snapVisitor.getMinDist()) |
|
258 |
if (theSnappedPoint != null) { |
|
259 |
double distAux = theSnappedPoint.distance(point); |
|
260 |
if (minDist > distAux) |
|
245 | 261 |
{ |
246 |
minDist = snapVisitor.getMinDist();
|
|
262 |
minDist = distAux;
|
|
247 | 263 |
usedSnap = theSnapper; |
248 |
mapHandlerAdjustedPoint.setLocation(snapVisitor.getSnapPoint());
|
|
264 |
mapHandlerAdjustedPoint.setLocation(theSnappedPoint);
|
|
249 | 265 |
} |
250 | 266 |
} |
251 | 267 |
} |
Also available in: Unified diff