TNTmips

HOME

FREE PRODUCTS
  TNTlite
  TNTatlas
  TNTsim3D

DOWNLOADS
  Release Version
  Development Version
  FTP
  Language Kits
  Sample Geodata
  Reseller Resources
  Promotional

DOCUMENTATION
  Tutorials
  Technical Guides
  Quick Guides

SITE MAP


pointsel.sml

See other examples of Tool and Macro scripts ...


#  POINTSEL.SML - Allows user to select and highlight a vector point.
#  Created by: Mark Smith
#  Most recent revision: 9-2001

# The following symbols are predefined
#    class VIEW View            {use to access the view the tool script is attached to}
#    class GROUP Group          {use to access the group being viewed if the script is run from a group view}
#    class LAYOUT Layout        {use to access the layout being viewed if the script is run from a layout view} 
# 
# The following values are also predefined and are valid when the various On...() 
# functions are called which deal with pointer and keyboard events. 
#    number PointerX            Pointer X coordinate within view in pixels 
#    number PointerY            Pointer Y coordinate within view in pixels 

# Variable declarations
class GRE_LAYER_VECTOR vectorLayer;
class Vector targetVector;
class GRE_GROUP activegroup;

# Checks layer to see if it is valid.
func checkLayer() {
	local numeric valid = true;

	# Get names layers if usable.  If not output error messages.
	# Get name of active layer if it is usable.  If not output an error message.
	if (activegroup.ActiveLayer.Type == "") {
		PopupMessage("Group has no layers!");
		valid = false;
		}
	else if (activegroup.ActiveLayer.Type == "Vector") {
		vectorLayer = activegroup.ActiveLayer;
		DispGetVectorFromLayer(targetVector, vectorLayer);
		if (targetVector.$Info.NumPoints < 1) {
			PopupMessage("No points!");
			valid = false;
			}
		}
	else {
		PopupMessage("Not a vector!");
		valid = false;
		}
	return valid;
	}

# Called when user presses 'left' pointer/mouse button. 
func OnLeftButtonPress () { 
	# If the selected layer is not valid, don't do anything.
	if (checkLayer()) {
		# Set local variables
		local class POINT2D point;

		# Check point.
		point.x = PointerX;
		point.y = PointerY;

		point = TransPoint2D(point, ViewGetTransViewToScreen(View, 1));
		point = TransPoint2D(point, ViewGetTransMapToView(View, vectorLayer.Projection, 1));

		local numeric elementNum = FindClosestPoint(targetVector, point.x, point.y, GetLastUsedGeorefObject(targetVector));

		if (elementNum > 0)
			vectorLayer.Point.HighlightSingle(elementNum);
		}
	}  # end of OnLeftButtonPress 

# Callback for when the active group changes.
proc cbGroup() {
	activegroup = Layout.ActiveGroup;
	}

# Called the first time the tool is activated.
# If the tool implements a dialog it should be created (but not displayed) here.
func OnInitialize () {
	if (Layout) {
		WidgetAddCallback(Layout.GroupSelectedCallback, cbGroup);
		activegroup = Layout.ActiveGroup;
		}
	else
		activegroup = Group;
	}  # end of OnInitialize 

 


Back Home ©MicroImages, Inc. 2008 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

9 May 2008

page update: 10 Aug 07