home products news downloads documentation support gallery online maps resellers search
TNTmips Downloads Menu

HOME

CONTACT US

CURRENT RELEASE
  TNT 2013

DEVELOPMENT VERSION
  TNT 2014

TNTmips Pro
PRIOR RELEASES
  TNT 2012

FREE SOFTWARE
  TNTmips Free
  TNTatlas
  TNTsdk

MORE DOWNLOADS
  HASP Key Driver
  Screen Recorder
  TNT Language Kits
  Sample Geodata
  TNT Scripts

DOCUMENTATION
  TNTmips Tutorials
  Tutorial Datasets
  Technical Guides
  Scripts
  Quick Guides

MORE INFO
  Download FAQs
  FTP
  Download Managers
  Find Reseller

SITE MAP


SpyGlassRaster.sml

See other examples and scripts with DataTips and GraphTips ...


# SpyGlassRaster.sml
#
# Sample Display Control Script for SpyGlass GraphTip.
#
# Group must have a raster object as the first layer.
# Circular GraphTip shows matching area from a 24-bit
# raster object that is not in the group.  SpyGlass raster
# is shown at the same scale as the current View scale.
#
# Author: 	Jeremy Johnson and Randy Smith
#				MicroImages, Inc.
#				10 December 2004


class GRE_LAYER_RASTER F_layer;
class RASTER  F, Zoom, SourceRaster; 
class POINT2D rasterUL, offset, center; 
class GRDEVICE_RAST_RGB24 rasterdev; 		## graphics rendering device in memory for drawing 
														## 24-bit raster image as GraphTip
class GRDEVICE_MEM_BINARY maskdev;			## graphics rendering device in memory for binary 
														## image buffer (for transparency mask for GraphTip)
class GC gc; 										## graphics context for drawing to GraphTip mask
numeric height, width;
numeric count = 0; 
class POINT2D SourcePoint, LayerPoint, MapPoint, SourceMapPoint, SourceObjPoint;
class RVC_GEOREFERENCE SourceGeo, FGeo;
class TRANSPARM ScreenToLayer, FMapToSourceMap;
class TRANSPARM FObjToMap, SourceMapToObj;

##########################################################################
# proc OnGroupCreateView:
# Called when any view for the group is created.
# The process gets the raster from the group's first layer.
# This raster (F) will be used for establishing a translation between the coordinates of the mouse
# and the coordinates of the desired location to be displayed in the GraphTip's view circle
##########################################################################
proc OnGroupCreateView ( 
	class GRE_GROUP group
	) {
	F_layer = group.FirstLayer; 
 	DispGetRasterFromLayer(F, F_layer);
	# open raster that is source for spyglass image
	# file should be in same directory as control script
 	string filename$ = _context.ScriptDir + "\\RalstonDOQQc.rvc";
	OpenRaster(SourceRaster, filename$, "RalstonDOQQ");
	}

##########################################################################
# Function called when the mouse is left over a position. 
# This is the primary function for creating and displaying the GraphTip.
##########################################################################
func OnViewDataTipShowRequest (
	class GRE_VIEW view,
	class POINT2D point,			# cursor position in screen coordinates
	class TOOLTIP datatip
	) {

	height = view.height/4;    # Set height and width of GraphTip area (in screen pixels as a fraction of View dimensions).
	width = view.width/4;		# Height and width should match.  Height must be > 32.

	if (height < 32 && width < 32) {
		height = width = 32;
	}	else {
		if (height > width) {
			width = height;
		} else {
			height = width;
		}
	}

	maskdev.Create(height,width);		# create memory device for mask and set all to 0
	maskdev.ClearAll();
	center.x = height/2;				# position in mask for center of circle
	center.y = height/2;

	offset.x = -height/2;			# offset GraphTip so it is centered on cursor position
	offset.y = -height/2;

	point.x = point.x + offset.x;		# reset point to upper left corner of GraphTip raster area
	point.y = point.y + offset.y;

	# create temporary raster to construct spyglass image
	CreateTempRaster(Zoom, height, width, "24-bit color RGB");

###############################################
# Set up projection transformations
###############################################
	SourceGeo.OpenLastUsed(SourceRaster);
	SourceGeo.GetTransparm(SourceMapToObj, 1, SourceGeo.GetCalibModel() );
	FMapToSourceMap.OutputCoordRefSys = SourceGeo.GetCoordRefSys();
	FGeo.OpenLastUsed(F);
	FGeo.GetTransparm(FObjToMap, 0, FGeo.GetCalibModel() );
	FMapToSourceMap.InputCoordRefSys = FGeo.GetCoordRefSys();
	ScreenToLayer = view.GetTransLayerToScreen(F_layer, 1);

	#---Copy cells from the spyglass image raster into the temp raster, repeating (if zoomed in) or excluding (if zoomed out) cells as needed
	local numeric x, y;

	for (x = 0;  x < width; x++) {
		for (y = 0; y < height; y++) {
		SourcePoint.x = point.x + x;  # increment screen position																			
		SourcePoint.y = point.y + y;
		LayerPoint  = ScreenToLayer.ConvertPoint2DFwd(SourcePoint);    # find position in lin and col of displayed raster

		MapPoint = TransPoint2D(LayerPoint, FObjToMap);						# convert to map coordinates of displayed raster  
		SourceMapPoint = FMapToSourceMap.ConvertPoint2dFwd(MapPoint);   # find map coordinates in georeference used by spyglass image raster
		SourceObjPoint = TransPoint2D(SourceMapPoint, SourceMapToObj);		# convert map coordinates to lin and col of spyglass image raster 
		Zoom[y+1,x+1] = SourceRaster[SourceObjPoint.y+1, SourceObjPoint.x+1]; 	# copy cell from spyglass source raster into the temp raster
		}
	}

	#--Create the raster device for the GraphTip and check for errors
	local numeric error = rasterdev.Create(Zoom);
	if (error < 0) {
		PopupError(error); 
		return (error);
	}

	#------create graphics for mask and draw circular image area (mask = 1)  
	gc = maskdev.CreateGC();
	gc.SetColorPixel(1);	 
	gc.FillCircle(center.y, center.x, width/2 - 2);

	#---Set up the GraphTip
	datatip.PixelDelta = 0;
	datatip.Delay = 300 ; 
	datatip.MarginHeight = 100;
		# set the temp raster as the source for the GraphTip image
	datatip.SetImageTip(rasterdev, maskdev, offset);
	DeleteTempRaster(Zoom);
	return (1); 				# in GraphTip use only what is created by script
}





Back Home ©MicroImages, Inc. 2013 Published in the United States of America
11th Floor - Sharp Tower, 206 South 13th Street, Lincoln NE 68508-2010   USA
Business & Sales: (402)477-9554  Support: (402)477-9562  Fax: (402)477-9559
Business info@microimages.com  Support support@microimages.com  Web webmaster@microimages.com

25 March 2009

page update: 26 May 11