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


timezone.sml


# 2 Aug 2004 written by Merri Skrdla and Cindy Robbins
# This control script displays a GraphTip showing current local time at the cursor position
#Data: timezonesINTL.rvc timezones20 vector object, group also uses polbnda from bnd.rvc in the World Data Set
# use mask to make the square area around the clock face transparent

class GRDEVICE_MEM_BINARY maskdev;
class GRDEVICE_MEM_RGB24 imagedev;
class GC gc;
class POINT2D offset;
class GRE_LAYER_VECTOR  timezone_layer;
class VECTOR Vect;
class GRE_GROUP group;
class TRANSPARM trans;
class POINT2D cursorPt;
class GEOREF georef;
class COLOR color;

proc OnInitialize () {
	imagedev.Create(100,100);
	maskdev.Create(100,100);
	gc = maskdev.CreateGC();
	gc.SetColorPixel(1);
	gc.FillCircle(50,50,40);
#	gc.SetColorPixel(0);
#	gc.FillCircle(50,50,3);
	offset.x = -50;
	offset.y = -50;
}

proc OnGroupCreateView (class GRE_GROUP group) {
   timezone_layer = group.FirstLayer;
   DispGetVectorFromLayer (Vect, timezone_layer);
   georef = GetLastUsedGeorefObject(Vect);
}

func OnViewDataTipShowRequest (
	class GRE_VIEW view,
	class POINT2D point,
	class TOOLTIP datatip
	) {

   trans = view.GetTransLayerToScreen(timezone_layer, 1);
   cursorPt = trans.ConvertPoint2DFwd (point);

	numeric closestPoly = FindClosestPoly(Vect,cursorPt.x, cursorPt.y, georef);
	local class DATETIME now;
	now.SetCurrent();

	numeric currentHour = now.GetHour();
	numeric currentMin = now.GetMin();

	numeric x=Vect.poly[closestPoly].timeznp020[1].Central_OffsetH; #number of hours offset  from Central Standard time (my time zone)

	numeric minOffset = (x % 1) * 60;
	numeric hourOffset= int (x);

	if ((currentMin + minOffset) >= 60)
		hourOffset = hourOffset + 1;

	numeric modifiedMin = (currentMin + minOffset) % 60;
	numeric modifiedHour = (hourOffset + currentHour) ;

	gc = imagedev.CreateGC();

	if (((modifiedHour%24) >=22) or ((modifiedHour%24) < 8)) #clock face color
		gc.SetColorName("misty rose"); #10p.m. to 7:59 a.m.
	else gc.SetColorName("sea foam"); #8 a.m. to 9:59 p.m.
	gc.FillCircle(50,50, 40);
	gc.SetColorName("black");
	gc.DrawCircle(50,50,40);
	gc.MoveTo(50,50);


	local numeric h = ((modifiedHour% 12) +modifiedMin/60)* 30 - 90;	# hrs to deg
	local numeric m = modifiedMin * 6 - 90;	# min to deg


	gc.DrawTo(20*cosd(h) + 50 , 20*sind(h) + 50); #draw hour hand; length is 20; add 50 so all are positive numbers
	gc.MoveTo(50,50);
	gc.DrawTo(30*cosd(m) + 50, 30*sind(m) + 50); # draw minute hand; length is 30

#add numbers to clock face
gc.DrawTextSetFont("ARIAL.TTF");
gc.DrawTextSetHeightPixels(9); 
color.Name="black"; 
gc.SetColor(color);
gc.DrawTextSetColors(color);
gc.DrawTextSimple("12",47,20);
gc.DrawTextSimple("6",49,88);
gc.DrawTextSimple("3",82,52);
gc.DrawTextSimple("9",13,52);


#add tick marks to clock face
numeric tick1, tick2, tick4, tick5, tick7, tick8, tick10, tick11;
tick1=1 * 30 - 90;
tick2=2 * 30 - 90;
tick4=4* 30 -90;
tick5=5* 30 -90;
tick7=7* 30 -90;
tick8=8* 30 -90;
tick10=10* 30 -90;
tick11=11* 30 -90;

gc.MoveTo(50,50);
gc.MoveTo(35 *cosd(tick1) + 50, 35*sind(tick1) + 50);
gc.DrawTo(50 *cosd(tick1) + 50, 50*sind(tick1) + 50);

gc.MoveTo(50,50);
gc.MoveTo(35 *cosd(tick2) + 50, 35*sind(tick2) + 50);
gc.DrawTo(50 *cosd(tick2) + 50, 50*sind(tick2) + 50);

gc.MoveTo(50,50);
gc.MoveTo(35 *cosd(tick4) + 50, 35*sind(tick4) + 50);
gc.DrawTo(50 *cosd(tick4) + 50, 50*sind(tick4) + 50);

gc.MoveTo(50,50);
gc.MoveTo(35 *cosd(tick5) + 50, 35*sind(tick5) + 50);
gc.DrawTo(50 *cosd(tick5) + 50, 50*sind(tick5) + 50);

gc.MoveTo(50,50);
gc.MoveTo(35 *cosd(tick7) + 50, 35*sind(tick7) + 50);
gc.DrawTo(50 *cosd(tick7) + 50, 50*sind(tick7) + 50);

gc.MoveTo(50,50);
gc.MoveTo(35 *cosd(tick8) + 50, 35*sind(tick8) + 50);
gc.DrawTo(50 *cosd(tick8) + 50, 50*sind(tick8) + 50);

gc.MoveTo(50,50);
gc.MoveTo(35 *cosd(tick10) + 50, 35*sind(tick10) + 50);
gc.DrawTo(50 *cosd(tick10) + 50, 50*sind(tick10) + 50);

gc.MoveTo(50,50);
gc.MoveTo(35 *cosd(tick11) + 50, 35*sind(tick11) + 50);
gc.DrawTo(50 *cosd(tick11) + 50, 50*sind(tick11) + 50);




#draw the GraphTip
datatip.SetImageTip(imagedev, maskdev, offset);
return (true);
	}


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