4 @brief wxGUI 3D view mode (ctypes-based classes)
6 This module implements 3D visualization mode for map display (ctypes
12 - wxnviz::ImageTexture
15 (C) 2008-2011 by the GRASS Development Team
17 This program is free software under the GNU General Public License
18 (>=v2). Read the file COPYING that comes with GRASS for details.
20 @author Martin Landa <landa.martin gmail.com> (Google SoC 2008/2010)
21 @author Pythonized by Glynn Clements
22 @author Anna Kratochvilova <KratochAnna seznam.cz> (Google SoC 2011)
30 from numpy
import matrix
32 msg = _(
"This module requires the NumPy module, which could not be "
33 "imported. It probably is not installed (it's not part of the "
34 "standard Python distribution). See the Numeric Python site "
35 "(http://numpy.scipy.org) for information on downloading source or "
37 print >> sys.stderr,
"wxnviz.py: " + msg
48 except ImportError, e:
49 sys.stderr.write(_(
"3D view mode: %s\n") % e)
58 """!Redirect stderr"""
68 """!Redirect progress info"""
71 progress.SetValue(value)
77 errtype = CFUNCTYPE(UNCHECKED(c_int), String, c_int)
79 pertype = CFUNCTYPE(UNCHECKED(c_int), c_int)
84 """!Initialize Nviz class instance
86 @param log logging area
87 @param gprogress progressbar
89 global errfunc, perfunc, log, progress
108 Debug.msg(1,
"Nviz::Nviz()")
111 """!Destroy Nviz class instance"""
119 """!Initialize window"""
120 locale.setlocale(locale.LC_NUMERIC,
'C')
128 """!GL canvas resized
130 @param width window width
131 @param height window height
134 @return 0 on failure (window resized by default to 20x20 px)
138 Debug.msg(3,
"Nviz::ResizeWindow(): width=%d height=%d",
143 """!Get longest dimension, used for initial size of north arrow"""
147 """!Set default view (based on loaded data)
149 @return z-exag value, default, min and max height
161 Debug.msg(1,
"Nviz::SetViewDefault(): hdef=%f, hmin=%f, hmax=%f",
162 hdef.value, hmin.value, hmax.value)
164 return (z_exag, hdef.value, hmin.value, hmax.value)
166 def SetView(self, x, y, height, persp, twist):
167 """!Change view settings
170 @param persp perpective
178 Debug.msg(3,
"Nviz::SetView(): x=%f, y=%f, height=%f, persp=%f, twist=%f",
179 x, y, height, persp, twist)
188 return (x.value, y.value, h.value)
191 """!Look here feature
192 @param x,y screen coordinates
196 Debug.msg(3,
"Nviz::LookHere(): x=%f, y=%f", x, y)
199 """!Center view at center of displayed surface"""
201 Debug.msg(3,
"Nviz::LookAtCenter()")
205 Debug.msg(3,
"Nviz::GetFocus()")
211 return x.value, y.value, z.value
217 Debug.msg(3,
"Nviz::SetFocus()")
222 Debug.msg(3,
"Nviz::GetViewdir()")
223 dir = (c_float * 3)()
226 return dir[0], dir[1], dir[2]
230 Debug.msg(3,
"Nviz::SetViewdir(): x=%f, y=%f, z=%f" % (x, y, z))
231 dir = (c_float * 3)()
232 for i, coord
in enumerate((x, y, z)):
243 Debug.msg(3,
"Nviz::SetZExag(): z_exag=%f", z_exag)
246 def Draw(self, quick, quick_mode):
255 @param quick if true draw in wiremode
256 @param quick_mode quick mode
258 Debug.msg(3,
"Nviz::Draw(): quick=%d", quick)
268 """!Erase map display (with background color)
270 Debug.msg(1,
"Nviz::EraseMap()")
274 """!Initialize view"""
287 Debug.msg(1,
"Nviz::InitView()")
290 """!Set background color
292 @param color_str color string
296 def SetLight(self, x, y, z, color, bright, ambient, w = 0, lid = 1):
297 """!Change lighting settings
298 @param x,y,z position
299 @param color light color (as string)
300 @param bright light brightness
301 @param ambient light ambient
302 @param w local coordinate (default to 0)
310 """!Load raster map (surface)
312 @param name raster map name
313 @param color_name raster map for color (None for color_value)
314 @param color_value color string (named color or RGB triptet)
317 @return -1 on failure
321 G_warning(_(
"Raster map <%s> not found"), name)
332 G_warning(_(
"Raster map <%s> not found"), color_name)
356 Debug.msg(1,
"Nviz::LoadRaster(): name=%s -> id=%d", name, id)
361 """!Add new constant surface"""
369 Debug.msg(1,
"Nviz::AddConstant(): id=%d", id)
383 Debug.msg(1,
"Nviz::UnloadSurface(): id=%d", id)
391 """!Load vector map overlay
393 @param name vector map name
394 @param points if true load 2d points rather then 2d lines
396 @return object id, id of base surface (or -1 if it is not loaded)
397 @return -1 on failure
407 mapset = G_find_vector2 (name,
"")
409 G_warning(_(
"Vector map <%s> not found"),
421 Debug.msg(1,
"Nviz::LoadVector(): name=%s -> id=%d", name, id)
426 """!Unload vector set
428 @param id vector set id
429 @param points vector points or lines set
434 Debug.msg(1,
"Nviz::UnloadVector(): id=%d", id)
450 """!Check if surface is selected (currently unused)
453 @param sid surface id
455 @return True if selected
456 @return False if not selected
459 Debug.msg(1,
"Nviz::VectorSurfaceSelected(): vid=%s, sid=%d -> selected=%d", vid, sid, selected)
463 """!Load 3d raster map (volume)
465 @param name 3d raster map name
466 @param color_name 3d raster map for color (None for color_value)
467 @param color_value color string (named color or RGB triptet)
470 @return -1 on failure
474 G_warning(_(
"3d raster map <%s> not found"),
486 G_warning(_(
"3d raster map <%s> not found"),
503 Debug.msg(1,
"Nviz::LoadVolume(): name=%s -> id=%d", name, id)
518 Debug.msg(1,
"Nviz::UnloadVolume(): id=%d", id)
526 """!Set surface topography
529 @param map if true use map otherwise constant
530 @param value map name of value
533 @return -1 surface not found
534 @return -2 setting attributes failed
539 """!Set surface color
542 @param map if true use map otherwise constant
543 @param value map name or value
546 @return -1 surface not found
547 @return -2 setting attributes failed
557 @param invert if true invert mask
558 @param value map name of value
561 @return -1 surface not found
562 @return -2 setting attributes failed
572 @param map if true use map otherwise constant
573 @param value map name of value
576 @return -1 surface not found
577 @return -2 setting attributes failed
582 """!Set surface shininess
585 @param map if true use map otherwise constant
586 @param value map name of value
589 @return -1 surface not found
590 @return -2 setting attributes failed
595 """!Set surface emission (currently unused)
598 @param map if true use map otherwise constant
599 @param value map name of value
602 @return -1 surface not found
603 @return -2 setting attributes failed
608 """!Set surface attribute
611 @param attr attribute desc
612 @param map if true use map otherwise constant
613 @param value map name of value
616 @return -1 surface not found
617 @return -2 setting attributes failed
624 value, -1.0, self.
data)
626 if attr == ATT_COLOR:
632 None, val, self.
data)
634 Debug.msg(3,
"Nviz::SetSurfaceAttr(): id=%d, attr=%d, map=%d, value=%s",
635 id, attr, map, value)
643 """!Unset surface mask
648 @return -1 surface not found
649 @return -2 setting attributes failed
650 @return -1 on failure
655 """!Unset surface transparency
660 @return -1 surface not found
661 @return -2 setting attributes failed
666 """!Unset surface emission (currently unused)
671 @return -1 surface not found
672 @return -2 setting attributes failed
677 """!Unset surface attribute
680 @param attr attribute descriptor
683 @return -1 surface not found
684 @return -2 setting attributes failed
689 Debug.msg(3,
"Nviz::UnsetSurfaceAttr(): id=%d, attr=%d",
700 """!Set surface resolution
703 @param fine x/y fine resolution
704 @param coarse x/y coarse resolution
707 @return -1 surface not found
708 @return -2 setting attributes failed
710 Debug.msg(3,
"Nviz::SetSurfaceRes(): id=%d, fine=%d, coarse=%d",
738 @param id surface id (<= 0 for all)
739 @param style draw style
742 @return -1 surface not found
743 @return -2 setting attributes failed
745 Debug.msg(3,
"Nviz::SetSurfaceStyle(): id=%d, style=%d",
763 """!Set color of wire
767 @param surface id (< 0 for all)
768 @param color color string (R:G:B)
771 @return -1 surface not found
772 @return -2 setting attributes failed
776 Debug.msg(3,
"Nviz::SetWireColor(): id=%d, color=%s",
789 for i
in xrange(nsurfs.value):
799 """!Get surface position
804 @return zero-length vector on error
809 x, y, z = c_float(), c_float(), c_float()
812 Debug.msg(3,
"Nviz::GetSurfacePosition(): id=%d, x=%f, y=%f, z=%f",
813 id, x.value, y.value, z.value)
815 return [x.value, y.value, z.value]
818 """!Set surface position
821 @param x,y,z translation values
824 @return -1 surface not found
825 @return -2 setting position failed
830 Debug.msg(3,
"Nviz::SetSurfacePosition(): id=%d, x=%f, y=%f, z=%f",
838 """!Set mode of vector line overlay
841 @param color_str color string
842 @param width line width
843 @param flat display flat or on surface
845 @return -1 vector set not found
846 @return -2 on failure
852 Debug.msg(3,
"Nviz::SetVectorMode(): id=%d, color=%s, width=%d, flat=%d",
853 id, color_str, width, flat)
864 """!Set vector height above surface (lines)
866 @param id vector set id
869 @return -1 vector set not found
875 Debug.msg(3,
"Nviz::SetVectorLineHeight(): id=%d, height=%f",
883 """!Set reference surface of vector set (lines)
885 @param id vector set id
886 @param surf_id surface id
889 @return -1 vector set not found
890 @return -2 surface not found
891 @return -3 on failure
905 """!Unset reference surface of vector set (lines)
907 @param id vector set id
908 @param surf_id surface id
911 @return -1 vector set not found
912 @return -2 surface not found
913 @return -3 on failure
927 """!Set mode of vector point overlay
930 @param color_str color string
931 @param width line width
934 @return -1 vector set not found
943 Debug.msg(3,
"Nviz::SetVectorPointMode(): id=%d, color=%s, "
944 "width=%d, size=%f, marker=%d",
945 id, color_str, width, size, marker)
955 """!Set vector height above surface (points)
957 @param id vector set id
960 @return -1 vector set not found
966 Debug.msg(3,
"Nviz::SetVectorPointHeight(): id=%d, height=%f",
974 """!Set reference surface of vector set (points)
976 @param id vector set id
977 @param surf_id surface id
980 @return -1 vector set not found
981 @return -2 surface not found
982 @return -3 on failure
996 """!Read vector colors
998 @param name vector map name
999 @mapset mapset name ("" for search path)
1002 @return 0 if color table missing
1003 @return 1 on success (color table found)
1005 return Vect_read_colors(name, mapset, self.
color)
1008 """!Check if color table exists.
1010 @param id vector set id
1011 @param type vector set type (lines/points)
1013 @return 1 color table exists
1014 @return 0 no color table found
1016 @return -2 vector set not found
1020 if type ==
'points':
1022 elif type ==
'lines':
1031 """!Unset reference surface of vector set (points)
1033 @param id vector set id
1034 @param surf_id surface id
1036 @return 1 on success
1037 @return -1 vector set not found
1038 @return -2 surface not found
1039 @return -3 on failure
1053 """!Add new isosurface
1056 @param level isosurface level (topography)
1058 @return -1 on failure
1059 @return 1 on success
1064 if isosurf_id
is not None:
1066 if num < 0
or isosurf_id != num:
1082 @return -1 on failure
1083 @return number of slices
1088 if slice_id
is not None:
1090 if num < 0
or slice_id != num:
1099 """!Delete isosurface
1102 @param isosurf_id isosurface id
1104 @return 1 on success
1105 @return -1 volume not found
1106 @return -2 isosurface not found
1107 @return -3 on failure
1126 @param slice_id slice id
1128 @return 1 on success
1129 @return -1 volume not found
1130 @return -2 slice not found
1131 @return -3 on failure
1147 """!Move isosurface up/down in the list
1150 @param isosurf_id isosurface id
1151 @param up if true move up otherwise down
1153 @return 1 on success
1154 @return -1 volume not found
1155 @return -2 isosurface not found
1156 @return -3 on failure
1175 """!Move slice up/down in the list
1178 @param slice_id slice id
1179 @param up if true move up otherwise down
1181 @return 1 on success
1182 @return -1 volume not found
1183 @return -2 slice not found
1184 @return -3 on failure
1203 """!Set isosurface level
1206 @param isosurf_id isosurface id (0 - MAX_ISOSURFS)
1207 @param map if true use map otherwise constant
1208 @param value map name of value
1210 @return 1 on success
1211 @return -1 volume not found
1212 @return -2 isosurface not found
1213 @return -3 on failure
1218 """!Set isosurface color
1221 @param isosurf_id isosurface id (0 - MAX_ISOSURFS)
1222 @param map if true use map otherwise constant
1223 @param value map name of value
1225 @return 1 on success
1226 @return -1 volume not found
1227 @return -2 isosurface not found
1228 @return -3 on failure
1233 """!Set isosurface mask
1238 @param isosurf_id isosurface id (0 - MAX_ISOSURFS)
1239 @param invert true for invert mask
1240 @param value map name to be used for mask
1242 @return 1 on success
1243 @return -1 volume not found
1244 @return -2 isosurface not found
1245 @return -3 on failure
1250 """!Set isosurface transparency
1253 @param isosurf_id isosurface id (0 - MAX_ISOSURFS)
1254 @param map if true use map otherwise constant
1255 @param value map name of value
1257 @return 1 on success
1258 @return -1 volume not found
1259 @return -2 isosurface not found
1260 @return -3 on failure
1265 """!Set isosurface shininess
1268 @param isosurf_id isosurface id (0 - MAX_ISOSURFS)
1269 @param map if true use map otherwise constant
1270 @param value map name of value
1272 @return 1 on success
1273 @return -1 volume not found
1274 @return -2 isosurface not found
1275 @return -3 on failure
1280 """!Set isosurface emission (currently unused)
1283 @param isosurf_id isosurface id (0 - MAX_ISOSURFS)
1284 @param map if true use map otherwise constant
1285 @param value map name of value
1287 @return 1 on success
1288 @return -1 volume not found
1289 @return -2 isosurface not found
1290 @return -3 on failure
1295 """!Set isosurface attribute
1298 @param isosurf_id isosurface id (0 - MAX_ISOSURFS)
1299 @param attr attribute desc
1300 @param map if true use map otherwise constant
1301 @param value map name of value
1303 @return 1 on success
1304 @return -1 volume not found
1305 @return -2 isosurface not found
1306 @return -3 setting attributes failed
1317 if attr == ATT_COLOR:
1324 Debug.msg(3,
"Nviz::SetIsosurfaceAttr(): id=%d, isosurf=%d, "
1325 "attr=%d, map=%s, value=%s",
1326 id, isosurf_id, attr, map, value)
1334 """!Unset isosurface mask
1337 @param isosurf_id isosurface id (0 - MAX_ISOSURFS)
1339 @return 1 on success
1340 @return -1 volume not found
1341 @return -2 isosurface not found
1342 @return -3 setting attributes failed
1347 """!Unset isosurface transparency
1350 @param isosurf_id isosurface id (0 - MAX_ISOSURFS)
1352 @return 1 on success
1353 @return -1 volume not found
1354 @return -2 isosurface not found
1355 @return -3 setting attributes failed
1360 """!Unset isosurface emission (currently unused)
1363 @param isosurf_id isosurface id (0 - MAX_ISOSURFS)
1365 @return 1 on success
1366 @return -1 volume not found
1367 @return -2 isosurface not found
1368 @return -3 setting attributes failed
1373 """!Unset surface attribute
1375 @param id surface id
1376 @param isosurf_id isosurface id (0 - MAX_ISOSURFS)
1377 @param attr attribute descriptor
1379 @return 1 on success
1380 @return -1 volume not found
1381 @return -2 isosurface not found
1382 @return -2 on failure
1390 Debug.msg(3,
"Nviz::UnsetSurfaceAttr(): id=%d, isosurf_id=%d, attr=%d",
1391 id, isosurf_id, attr)
1401 """!Set draw mode for isosurfaces
1405 @return 1 on success
1406 @return -1 volume set not found
1407 @return -2 on failure
1420 """!Set draw mode for slices
1424 @return 1 on success
1425 @return -1 volume set not found
1426 @return -2 on failure
1439 """!Set draw resolution for isosurfaces
1441 @param res resolution value
1443 @return 1 on success
1444 @return -1 volume set not found
1445 @return -2 on failure
1458 """!Set draw resolution for slices
1460 @param res resolution value
1462 @return 1 on success
1463 @return -1 volume set not found
1464 @return -2 on failure
1477 """!Set slice position
1480 @param slice_id slice id
1481 @param x1,x2,y1,y2,z1,z2 slice coordinates
1484 @return 1 on success
1485 @return -1 volume not found
1486 @return -2 slice not found
1487 @return -3 on failure
1503 """!Set slice transparency
1506 @param slice_id slice id
1507 @param x1,x2,y1,y2,z1,z2 slice coordinates
1508 @param value transparency value (0 - 255)
1510 @return 1 on success
1511 @return -1 volume not found
1512 @return -2 slice not found
1513 @return -3 on failure
1532 @param inout mode true/false
1534 @return 1 on success
1535 @return -1 volume set not found
1536 @return -2 isosurface not found
1537 @return -3 on failure
1553 """!Get volume position
1558 @return zero-length vector on error
1563 x, y, z = c_float(), c_float(), c_float()
1566 Debug.msg(3,
"Nviz::GetVolumePosition(): id=%d, x=%f, y=%f, z=%f",
1567 id, x.value, y.value, z.value)
1569 return [x.value, y.value, z.value]
1572 """!Set volume position
1575 @param x,y,z translation values
1577 @return 1 on success
1578 @return -1 volume not found
1579 @return -2 setting position failed
1584 Debug.msg(3,
"Nviz::SetVolumePosition(): id=%d, x=%f, y=%f, z=%f",
1595 """!Returns number of cutting planes"""
1599 """!Returns rotation parameters of current cutting plane"""
1600 x, y, z = c_float(), c_float(), c_float()
1605 return x.value, y.value, z.value
1608 """!Returns translation parameters of current cutting plane"""
1609 x, y, z = c_float(), c_float(), c_float()
1614 return x.value, y.value, z.value
1617 """!Set current clip plane rotation
1619 @param x,y,z rotation parameters
1626 """!Set current clip plane translation
1628 @param x,y,z translation parameters
1633 Debug.msg(3,
"Nviz::SetCPlaneTranslation(): id=%d, x=%f, y=%f, z=%f",
1644 return None,
None,
None
1648 """!Select cutting plane
1650 @param index index of cutting plane
1655 """!Unselect cutting plane
1657 @param index index of cutting plane
1662 """!Select current cutting plane
1664 @param index type of fence - from 0 (off) to 4
1674 min, max = c_float(), c_float()
1676 return min.value, max.value
1678 def SaveToFile(self, filename, width = 20, height = 20, itype = 'ppm'):
1679 """!Save current GL screen to ppm/tif file
1681 @param filename file name
1682 @param width image width
1683 @param height image height
1684 @param itype image type ('ppm' or 'tif')
1686 widthOrig = self.
width
1691 self.
Draw(
False, -1)
1700 """!Draw lighting model"""
1708 def SetFringe(self, sid, color, elev, nw = False, ne = False, sw = False, se = False):
1711 @param sid surface id
1713 @param elev elevation (height)
1714 @param nw,ne,sw,se fringe edges (turn on/off)
1716 scolor = str(color[0]) +
':' + str(color[1]) +
':' + str(color[2])
1719 elev, int(nw), int(ne), int(sw), int(se))
1722 """!Draw north arrow
1727 """!Set north arrow from canvas coordinates
1729 @param sx,sy canvas coordinates
1730 @param size arrow length
1731 @param color arrow color
1736 """!Delete north arrow
1741 """!Set scale bar from canvas coordinates
1743 @param sx,sy canvas coordinates
1744 @param id scale bar id
1745 @param size scale bar length
1746 @param color scale bar color
1761 """!Get point on surface
1763 @param sx,sy canvas coordinates (LL)
1769 Debug.msg(5,
"Nviz::GetPointOnSurface(): sx=%d sy=%d" % (sx, sy))
1772 return (
None,
None,
None,
None)
1774 return (sid.value, x.value, y.value, z.value)
1777 """!Query surface map
1779 @param sx,sy canvas coordinates (LL)
1785 catstr = create_string_buffer(256)
1786 valstr = create_string_buffer(256)
1790 return {
'id' : sid,
1794 'elevation' : catstr.value.replace(
'(',
'').replace(
')',
''),
1795 'color' : valstr.value }
1798 """!Get distance measured along surface"""
1802 byref(d), int(useExag))
1807 """!Get rotation parameters (angle, x, y, z axes)
1809 @param dx,dy difference from previous mouse drag event
1811 modelview = (c_double * 16)()
1814 angle = sqrt(dx*dx+dy*dy)/float(self.
width+1)*180.0
1817 for i, item
in enumerate(modelview):
1823 ax, ay, az = dy, dx, 0.
1824 x = inv[0,0]*ax + inv[1,0]*ay + inv[2,0]*az
1825 y = inv[0,1]*ax + inv[1,1]*ay + inv[2,1]*az
1826 z = inv[0,2]*ax + inv[1,2]*ay + inv[2,2]*az
1828 return angle, x, y, z
1831 """!Set rotation parameters
1832 Rotate scene (difference from current state).
1835 @param x,y,z axis coordinate
1840 """!Stop rotating the scene"""
1844 """!Reset scene rotation"""
1848 """!Get rotation matrix"""
1849 matrix = (c_double * 16)()
1853 returnMatrix.append(item)
1857 """!Set rotation matrix"""
1858 mtrx = (c_double * 16)()
1859 for i
in range(len(matrix)):
1867 """!Fly through the scene
1869 @param flyInfo fly parameters
1870 @param mode 0 or 1 for different fly behaviour
1871 @param exagInfo parameters changing fly speed
1873 fly = (c_float * 3)()
1874 for i, item
in enumerate(flyInfo):
1876 exag = (c_int * 2)()
1877 exag[0] = int(exagInfo[
'move'])
1878 exag[1] = int(exagInfo[
'turn'])
1882 """!Class representing OpenGL texture"""
1884 """!Load image to texture
1886 @param filepath path to image file
1887 @param overlayId id of overlay (1 for legend, 101 and more for text)
1888 @param coords image coordinates
1891 self.
image = wx.Image(filepath, wx.BITMAP_TYPE_ANY)
1900 if not self.image.HasAlpha():
1901 self.image.InitAlpha()
1917 """!Delete texture"""
1920 grass.try_remove(self.
path)
1923 """!Resize image to match 2^n"""
1925 while self.
width > pow(2,n):
1927 while self.
height > pow(2,m):
1929 self.image.Resize(size = (pow(2,n), pow(2,m)), pos = (0, 0))
1930 self.
width = self.image.GetWidth()
1931 self.
height = self.image.GetHeight()
1934 """!Load image to texture"""
1935 if self.image.HasAlpha():
1940 rev_val = self.
height - 1
1941 im = (c_ubyte * bytes)()
1944 imageData = struct.unpack(str(bytes3) +
'B', self.image.GetData())
1945 if self.image.HasAlpha():
1946 alphaData = struct.unpack(str(bytes1) +
'B', self.image.GetAlphaData())
1949 wx.BeginBusyCursor()
1952 im[(j + i * self.
width) * bytesPerPixel + 0] = imageData[( j + (rev_val - i) * self.
width) * 3 + 0]
1953 im[(j + i * self.
width) * bytesPerPixel + 1] = imageData[( j + (rev_val - i) * self.
width) * 3 + 1]
1954 im[(j + i * self.
width) * bytesPerPixel + 2] = imageData[( j + (rev_val - i) * self.
width) * 3 + 2]
1955 if self.image.HasAlpha():
1956 im[(j + i * self.
width) * bytesPerPixel + 3] = alphaData[( j + (rev_val - i) * self.
width)]
1964 """!Draw texture as an image"""
1969 """!Set Bounding Rectangle"""
1973 copy = wx.Rect(*self.
bounds)
1974 copy.Inflate(radius, radius)
1975 return copy.ContainsXY(x, y)
1978 """!Move texture on the screen"""
1981 self.bounds.OffsetXY(dx, dy)
1984 """!Set coordinates"""
1985 dx = coords[0] - self.
coords[0]
1986 dy = coords[1] - self.
coords[1]
1990 """!Returns image id."""
2000 """!Class representing OpenGL texture as an overlay image"""
2002 """!Load image to texture
2004 @param filepath path to image file
2005 @param overlayId id of overlay (1 for legend)
2006 @param coords image coordinates
2007 @param cmd d.legend command
2009 Texture.__init__(self, filepath = filepath, overlayId = overlayId, coords = coords)
2014 """!Returns overlay command."""
2018 return sorted(self.
GetCmd()) == sorted(item.GetCmd())
2021 """!Class representing OpenGL texture as a text label"""
2022 def __init__(self, filepath, overlayId, coords, textDict):
2023 """!Load image to texture
2025 @param filepath path to image file
2026 @param overlayId id of overlay (101 and more for text)
2027 @param coords text coordinates
2028 @param textDict text properties
2030 Texture.__init__(self, filepath = filepath, overlayId = overlayId, coords = coords)
2035 """!Returns text properties."""
2041 for prop
in t.keys():
2042 if prop
in (
'coords',
'bbox'):
continue
2043 if t[prop] != item[prop]: