-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPTcolors.h
98 lines (84 loc) · 2.24 KB
/
PTcolors.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/** @file PTcolors.h
*
* @author marco corvi
* @date march 2010
*
* @brief match between PocketTopo colors and therion lines and points
*
*/
#ifndef PT_COLORS_H
#define PT_COLORS_H
#include <ctype.h>
#include <stdlib.h>
/** number of PocketTopo colors
*/
#define PT_COLORS 7
#include "ThPointType.h"
#include "ThLineType.h"
class PTcolors
{
private:
int point[ PT_COLORS ];
int line[ PT_COLORS ];
public:
PTcolors()
{
for (int i=0; i<PT_COLORS; ++i ) {
point[i] = i;
line[i] = i;
}
}
/** set the map colors-therion_point_types
* @param points string listing the therion_points indices (@see ThPointType.h)
*/
void setPoints( const char * points )
{
if ( points == NULL ) return;
const char * ch = points;
for (int i=0; i<PT_COLORS; ++i ) {
while( *ch && isspace(*ch) ) ++ch;
if ( *ch == 0 || ! isdigit(*ch) ) break;
point[i] = '0' + *ch;
++ch;
while ( *ch != 0 && isdigit(*ch) ) {
point[i] = 10*point[i] + ('0' + *ch);
}
}
}
/** set the map colors-therion_line_types
* @param points string listing the therion_lines indices (@see ThLineType.h)
*/
void setLines( const char * lines )
{
if ( lines == NULL ) return;
const char * ch = lines;
for (int i=0; i<PT_COLORS; ++i ) {
while( *ch && isspace(*ch) ) ++ch;
if ( *ch == 0 || ! isdigit(*ch) ) break;
line[i] = '0' + *ch;
++ch;
while ( *ch != 0 && isdigit(*ch) ) {
line[i] = 10*line[i] + ('0' + *ch);
}
}
}
/** get the therion-point index for a given color
* @param k color index (as in PocketTopo)
* @return the therion point index
*/
Therion::PointType thPoint( size_t k ) const
{
if ( k >= PT_COLORS ) return Therion::THP_PLACEMARK;
return (Therion::PointType)point[k];
}
/** get the therion-line index for a given color
* @param k color index (as in PocketTopo)
* @return the therion line index
*/
Therion::LineType thLine( size_t k ) const
{
if ( k >= PT_COLORS ) return Therion::THL_PLACEMARK;
return (Therion::LineType)line[k];
}
};
#endif