UltraScan III
Namespaces
Classes
Files
File List
File Members
gui
us_images.cpp
Go to the documentation of this file.
1
#include "
us_images.h
"
3
4
// Get image as a pixmap
5
QPixmap
US_Images::getImage
(
const
QString& bname )
6
{
7
return
QPixmap(
expanded_name
( bname) );
8
}
9
10
// Get image as a pixmap from type flag
11
QPixmap
US_Images::getImage
(
int
itype )
12
{
13
return
US_Images::getImage
(
image_name
( itype ) );
14
}
15
16
// Get image as an icon
17
QIcon
US_Images::getIcon
(
const
QString& bname )
18
{
19
return
QIcon(
US_Images::getImage
( bname ) );
20
}
21
22
// Get image as an icon from type flag
23
QIcon
US_Images::getIcon
(
int
itype )
24
{
25
return
QIcon(
US_Images::getImage
( itype ) );
26
}
27
28
29
// Private method to find a base image name for an image type
30
const
QString
US_Images::image_name
(
int
itype )
31
{
32
struct
nameMap
33
{
34
ImagesType
itype;
35
QString iname;
36
};
37
38
static
const
struct
nameMap nameMaps[] =
39
{
40
{
US3_SPLASH
,
"us3-splash"
},
41
{
CHECK
,
"check"
},
42
{
ARROW_BLUE
,
"bluearrow"
},
43
{
ARROW_GREEN
,
"greenarrow"
},
44
{
ARROW_RED
,
"redarrow"
},
45
{
AXES_BOX
,
"box"
},
46
{
AXES_FRAME
,
"frame"
},
47
{
AXES_NONE
,
"none"
},
48
{
FILE_CELL
,
"filecell"
},
49
{
FILE_OPEN
,
"fileopen"
},
50
{
FLOOR_DATA
,
"floordata"
},
51
{
FLOOR_EMPTY
,
"floorempty"
},
52
{
FLOOR_ISO
,
"flooriso"
},
53
{
FLOOR_MESH
,
"floormesh"
},
54
{
GRID_NONE
,
"grid"
},
55
{
GRID_BACK
,
"gridb"
},
56
{
GRID_CEILING
,
"gridc"
},
57
{
GRID_FLOOR
,
"gridf"
},
58
{
GRID_FRONT
,
"gridfr"
},
59
{
GRID_LEFT
,
"gridl"
},
60
{
GRID_RIGHT
,
"gridr"
},
61
{
MESH_FILLED
,
"filledmesh"
},
62
{
MESH_HIDDEN
,
"hiddenline"
},
63
{
MESH_NODATA
,
"nodata"
},
64
{
MESH_NORMALS
,
"normals"
},
65
{
MESH_POLYGON
,
"polygon"
},
66
{
MESH_SCATTERED
,
"scattered"
},
67
{
MESH_WIRE
,
"wireframe"
},
68
{
MOVIE
,
"movie"
},
69
{
SAVE_CONTENT
,
"savecontent"
},
70
{
ICON_PROP
,
"icon"
},
71
{
QWTPLOT
,
"qwtplot"
},
72
{
US3_ICON
,
"us3-icon-32x32"
},
73
{
ARROW_LEFT
,
"arrow_left"
},
74
{
ARROW_RIGHT
,
"arrow_right"
}
75
};
76
77
static
const
int
nimages =
sizeof
( nameMaps ) /
sizeof
( nameMaps[ 0 ] );
78
79
Q_ASSERT( itype >= 0 && itype < nimages );
80
81
QString iname(
"_NOT_FOUND_"
);
82
83
for
(
int
jj = 0; jj < nimages; jj++ )
84
{
// Find a match to the given type
85
if
( (
ImagesType
)itype == nameMaps[ jj ].itype )
86
{
// When a match is found, return the corresponding base image name
87
iname = nameMaps[ jj ].iname;
88
break
;
89
}
90
}
91
92
return
iname;
93
}
94
95
// Private method to get a full expanded embedded image name from a base name
96
const
QString
US_Images::expanded_name
(
const
QString& bname )
97
{
98
QString iname = bname;
99
iname = iname.replace(
"\\"
,
"/"
);
// Insure forward slashes in name
100
101
if
( ! iname.contains(
"/"
) )
102
{
103
iname =
":/images/"
+ bname;
// Add the standard embedded prefix
104
}
105
106
if
( ! iname.contains(
"."
) )
107
{
108
iname = iname +
".png"
;
// Add the PNG extension
109
}
110
111
return
iname;
112
}
113
Generated on Sun Jun 21 2015 11:40:42 for UltraScan III by
1.8.3.1-20130324