Add unti support to Sketcher

This commit is contained in:
jriegel
2013-12-15 22:47:25 +01:00
parent 2b10890a04
commit d5d9ea9c30
17 changed files with 296 additions and 230 deletions

View File

@@ -361,8 +361,8 @@ static void yy_fatal_error (yyconst char msg[] );
*yy_cp = '\0'; \
(yy_c_buf_p) = yy_cp;
#define YY_NUM_RULES 95
#define YY_END_OF_BUFFER 96
#define YY_NUM_RULES 96
#define YY_END_OF_BUFFER 97
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -370,26 +370,26 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static yyconst flex_int16_t yy_accept[167] =
static yyconst flex_int16_t yy_accept[168] =
{ 0,
0, 0, 0, 0, 96, 94, 4, 5, 36, 38,
6, 74, 75, 25, 94, 94, 65, 29, 94, 49,
94, 94, 94, 63, 1, 94, 94, 94, 77, 94,
19, 24, 94, 94, 15, 13, 94, 94, 94, 94,
22, 21, 94, 94, 94, 3, 95, 2, 5, 74,
0, 74, 75, 68, 0, 28, 51, 0, 66, 53,
0, 0, 0, 0, 97, 95, 4, 5, 36, 38,
6, 75, 76, 25, 95, 95, 65, 29, 95, 49,
95, 95, 95, 63, 1, 95, 95, 95, 78, 95,
19, 24, 95, 95, 15, 13, 95, 95, 95, 95,
22, 21, 95, 95, 95, 3, 96, 2, 5, 75,
0, 75, 76, 68, 0, 28, 51, 0, 66, 53,
0, 64, 69, 0, 0, 0, 0, 34, 11, 0,
0, 0, 12, 0, 37, 0, 35, 27, 50, 0,
20, 14, 0, 43, 0, 26, 30, 52, 0, 18,
42, 10, 0, 7, 45, 76, 0, 0, 0, 0,
42, 10, 0, 7, 45, 77, 0, 0, 0, 0,
0, 46, 0, 0, 32, 0, 16, 8, 41, 0,
0, 73, 56, 55, 0, 67, 84, 0, 0, 0,
82, 47, 70, 83, 72, 54, 62, 48, 44, 86,
0, 40, 23, 85, 33, 88, 61, 71, 89, 0,
91, 0, 0, 31, 0, 17, 9, 57, 78, 79,
80, 0, 0, 90, 93, 92, 39, 0, 0, 81,
87, 58, 59, 0, 60, 0
0, 46, 0, 0, 32, 0, 16, 8, 41, 70,
0, 0, 74, 56, 55, 0, 67, 85, 0, 0,
0, 83, 47, 71, 84, 73, 54, 62, 48, 44,
87, 0, 40, 23, 86, 33, 89, 61, 72, 90,
0, 92, 0, 0, 31, 0, 17, 9, 57, 79,
80, 81, 0, 0, 91, 94, 93, 39, 0, 0,
82, 88, 58, 59, 0, 60, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
@@ -412,9 +412,9 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
51, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 52, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 51, 1, 1, 1, 1,
52, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 53, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -424,126 +424,126 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1
} ;
static yyconst flex_int32_t yy_meta[53] =
static yyconst flex_int32_t yy_meta[54] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1
1, 1, 1
} ;
static yyconst flex_int16_t yy_base[168] =
static yyconst flex_int16_t yy_base[169] =
{ 0,
0, 0, 50, 51, 219, 220, 220, 215, 47, 220,
220, 54, 63, 220, 194, 195, 220, 220, 66, 177,
187, 173, 199, 167, 220, 52, 52, 30, 162, 164,
168, 220, 168, 80, 55, 112, 168, 155, 54, 177,
67, 57, 88, 173, 151, 220, 220, 220, 198, 105,
128, 144, 153, 220, 173, 220, 220, 172, 220, 220,
155, 153, 220, 152, 155, 159, 166, 220, 220, 148,
146, 157, 220, 148, 220, 149, 220, 220, 220, 160,
220, 220, 150, 73, 151, 220, 220, 220, 143, 220,
90, 220, 111, 220, 220, 220, 135, 145, 139, 129,
0, 0, 51, 52, 221, 222, 222, 217, 48, 222,
222, 55, 64, 222, 196, 197, 222, 222, 67, 179,
189, 175, 201, 169, 222, 53, 53, 31, 164, 166,
170, 222, 170, 81, 56, 113, 170, 157, 55, 179,
68, 58, 89, 175, 53, 222, 222, 222, 201, 106,
129, 145, 154, 222, 176, 222, 222, 175, 222, 222,
158, 156, 222, 155, 158, 162, 169, 222, 222, 151,
149, 160, 222, 151, 222, 152, 222, 222, 222, 163,
222, 222, 154, 74, 155, 222, 222, 222, 146, 222,
91, 222, 112, 222, 222, 222, 138, 149, 153, 142,
124, 220, 121, 118, 220, 111, 220, 220, 220, 148,
162, 167, 220, 220, 106, 220, 220, 102, 105, 104,
220, 220, 220, 220, 220, 220, 220, 220, 220, 132,
90, 220, 220, 220, 220, 220, 220, 220, 97, 83,
89, 76, 76, 220, 68, 220, 220, 220, 220, 220,
96, 95, 60, 220, 220, 220, 220, 45, 27, 220,
220, 220, 220, 17, 220, 220, 54
127, 222, 130, 128, 222, 121, 222, 222, 222, 222,
149, 163, 168, 222, 222, 116, 222, 222, 108, 111,
108, 222, 222, 222, 222, 222, 222, 222, 222, 222,
135, 101, 222, 222, 222, 222, 222, 222, 222, 109,
89, 98, 83, 81, 222, 83, 222, 222, 222, 222,
222, 109, 100, 65, 222, 222, 222, 222, 46, 28,
222, 222, 222, 222, 18, 222, 222, 55
} ;
static yyconst flex_int16_t yy_def[168] =
static yyconst flex_int16_t yy_def[169] =
{ 0,
166, 1, 167, 167, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
167, 1, 168, 168, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 0, 166
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 0, 167
} ;
static yyconst flex_int16_t yy_nxt[273] =
static yyconst flex_int16_t yy_nxt[276] =
{ 0,
6, 7, 8, 9, 10, 11, 11, 12, 13, 13,
13, 13, 14, 15, 6, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 6, 26, 6, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
39, 6, 40, 41, 42, 43, 6, 6, 44, 6,
6, 45, 47, 47, 46, 50, 50, 50, 50, 165,
72, 51, 50, 50, 50, 50, 52, 73, 51, 164,
52, 53, 53, 53, 53, 48, 48, 51, 56, 64,
65, 68, 84, 103, 51, 57, 58, 163, 96, 69,
104, 70, 78, 97, 85, 66, 67, 98, 71, 79,
6, 6, 45, 47, 47, 46, 50, 50, 50, 50,
166, 72, 51, 50, 50, 50, 50, 52, 73, 51,
165, 52, 53, 53, 53, 53, 48, 48, 51, 56,
64, 65, 68, 84, 103, 51, 57, 58, 164, 96,
69, 104, 70, 78, 97, 85, 66, 67, 98, 71,
80, 100, 162, 161, 128, 105, 160, 159, 101, 106,
129, 102, 81, 50, 50, 50, 50, 82, 158, 51,
107, 157, 156, 83, 86, 108, 132, 155, 133, 87,
154, 88, 153, 89, 111, 51, 112, 112, 112, 112,
134, 152, 151, 150, 90, 149, 91, 135, 148, 92,
143, 93, 50, 50, 50, 50, 52, 142, 51, 141,
52, 53, 53, 53, 53, 144, 140, 139, 138, 145,
112, 112, 112, 112, 51, 112, 112, 112, 112, 137,
146, 136, 131, 130, 127, 147, 126, 125, 124, 123,
122, 121, 120, 119, 118, 117, 116, 115, 114, 113,
79, 80, 100, 110, 111, 129, 105, 163, 162, 101,
106, 130, 102, 81, 50, 50, 50, 50, 82, 161,
51, 107, 160, 159, 83, 86, 108, 133, 158, 134,
87, 157, 88, 156, 89, 112, 51, 113, 113, 113,
113, 135, 155, 154, 153, 90, 152, 91, 136, 151,
92, 150, 93, 50, 50, 50, 50, 52, 149, 51,
144, 52, 53, 53, 53, 53, 145, 143, 142, 141,
146, 113, 113, 113, 113, 51, 113, 113, 113, 113,
140, 147, 139, 138, 137, 132, 148, 131, 128, 127,
126, 125, 124, 123, 122, 121, 120, 119, 118, 117,
49, 110, 109, 99, 95, 94, 77, 76, 75, 74,
63, 62, 61, 60, 59, 55, 54, 49, 166, 5,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166
116, 115, 114, 49, 109, 99, 95, 94, 77, 76,
75, 74, 63, 62, 61, 60, 59, 55, 54, 49,
167, 5, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167
} ;
static yyconst flex_int16_t yy_chk[273] =
static yyconst flex_int16_t yy_chk[276] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 3, 4, 167, 9, 9, 9, 9, 164,
28, 9, 12, 12, 12, 12, 13, 28, 12, 159,
13, 13, 13, 13, 13, 3, 4, 9, 19, 26,
26, 27, 35, 42, 12, 19, 19, 158, 39, 27,
42, 27, 34, 39, 35, 26, 26, 39, 27, 34,
1, 1, 1, 3, 4, 168, 9, 9, 9, 9,
165, 28, 9, 12, 12, 12, 12, 13, 28, 12,
160, 13, 13, 13, 13, 13, 3, 4, 9, 19,
26, 26, 27, 35, 42, 12, 19, 19, 159, 39,
27, 42, 27, 34, 39, 35, 26, 26, 39, 27,
34, 41, 153, 152, 84, 43, 151, 145, 41, 43,
84, 41, 34, 50, 50, 50, 50, 34, 143, 50,
43, 142, 141, 34, 36, 43, 91, 140, 91, 36,
139, 36, 131, 36, 51, 50, 51, 51, 51, 51,
93, 130, 120, 119, 36, 118, 36, 93, 115, 36,
106, 36, 52, 52, 52, 52, 53, 104, 52, 103,
53, 53, 53, 53, 53, 110, 101, 100, 99, 110,
111, 111, 111, 111, 52, 112, 112, 112, 112, 98,
110, 97, 89, 85, 83, 110, 80, 76, 74, 72,
71, 70, 67, 66, 65, 64, 62, 61, 58, 55,
34, 34, 41, 45, 45, 84, 43, 154, 153, 41,
43, 84, 41, 34, 50, 50, 50, 50, 34, 152,
50, 43, 146, 144, 34, 36, 43, 91, 143, 91,
36, 142, 36, 141, 36, 51, 50, 51, 51, 51,
51, 93, 140, 132, 131, 36, 121, 36, 93, 120,
36, 119, 36, 52, 52, 52, 52, 53, 116, 52,
106, 53, 53, 53, 53, 53, 111, 104, 103, 101,
111, 112, 112, 112, 112, 52, 113, 113, 113, 113,
100, 111, 99, 98, 97, 89, 111, 85, 83, 80,
76, 74, 72, 71, 70, 67, 66, 65, 64, 62,
49, 45, 44, 40, 38, 37, 33, 31, 30, 29,
24, 23, 22, 21, 20, 16, 15, 8, 5, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 166, 166, 166,
166, 166
61, 58, 55, 49, 44, 40, 38, 37, 33, 31,
30, 29, 24, 23, 22, 21, 20, 16, 15, 8,
5, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
167, 167, 167, 167, 167
} ;
static yy_state_type yy_last_accepting_state;
@@ -811,13 +811,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 167 )
if ( yy_current_state >= 168 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_current_state != 166 );
while ( yy_current_state != 167 );
yy_cp = (yy_last_accepting_cpos);
yy_current_state = (yy_last_accepting_state);
@@ -1191,17 +1191,17 @@ yylval = Quantity::Degree; return UNIT; // degree (internal
case 71:
YY_RULE_SETUP
#line 123 "QuantityParser.l"
yylval = Quantity::Radian; return UNIT; // radian
yylval = Quantity::Degree; return UNIT; // degree (internal standard angle)
YY_BREAK
case 72:
YY_RULE_SETUP
#line 124 "QuantityParser.l"
yylval = Quantity::Gon; return UNIT; // gon
yylval = Quantity::Radian; return UNIT; // radian
YY_BREAK
case 73:
YY_RULE_SETUP
#line 126 "QuantityParser.l"
{for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;}
#line 125 "QuantityParser.l"
yylval = Quantity::Gon; return UNIT; // gon
YY_BREAK
case 74:
YY_RULE_SETUP
@@ -1211,109 +1211,114 @@ YY_RULE_SETUP
case 75:
YY_RULE_SETUP
#line 128 "QuantityParser.l"
{yylval = atof( yytext ); return NUM;}
{for(char* c=yytext;*c!='\0';c++)if(*c==',')*c='.'; yylval = atof( yytext ); return NUM;}
YY_BREAK
case 76:
YY_RULE_SETUP
#line 130 "QuantityParser.l"
{yylval = M_PI ; return NUM;} // constant pi
#line 129 "QuantityParser.l"
{yylval = atof( yytext ); return NUM;}
YY_BREAK
case 77:
YY_RULE_SETUP
#line 131 "QuantityParser.l"
{yylval = M_E ; return NUM;} // constant e
{yylval = M_PI ; return NUM;} // constant pi
YY_BREAK
case 78:
YY_RULE_SETUP
#line 133 "QuantityParser.l"
return ACOS;
#line 132 "QuantityParser.l"
{yylval = M_E ; return NUM;} // constant e
YY_BREAK
case 79:
YY_RULE_SETUP
#line 134 "QuantityParser.l"
return ASIN;
return ACOS;
YY_BREAK
case 80:
YY_RULE_SETUP
#line 135 "QuantityParser.l"
return ATAN;
return ASIN;
YY_BREAK
case 81:
YY_RULE_SETUP
#line 136 "QuantityParser.l"
return ATAN2;
return ATAN;
YY_BREAK
case 82:
YY_RULE_SETUP
#line 137 "QuantityParser.l"
return COS;
return ATAN2;
YY_BREAK
case 83:
YY_RULE_SETUP
#line 138 "QuantityParser.l"
return EXP;
return COS;
YY_BREAK
case 84:
YY_RULE_SETUP
#line 139 "QuantityParser.l"
return ABS;
return EXP;
YY_BREAK
case 85:
YY_RULE_SETUP
#line 140 "QuantityParser.l"
return MOD;
return ABS;
YY_BREAK
case 86:
YY_RULE_SETUP
#line 141 "QuantityParser.l"
return LOG;
return MOD;
YY_BREAK
case 87:
YY_RULE_SETUP
#line 142 "QuantityParser.l"
return LOG10;
return LOG;
YY_BREAK
case 88:
YY_RULE_SETUP
#line 143 "QuantityParser.l"
return POW;
return LOG10;
YY_BREAK
case 89:
YY_RULE_SETUP
#line 144 "QuantityParser.l"
return SIN;
return POW;
YY_BREAK
case 90:
YY_RULE_SETUP
#line 145 "QuantityParser.l"
return SINH;
return SIN;
YY_BREAK
case 91:
YY_RULE_SETUP
#line 146 "QuantityParser.l"
return TAN;
return SINH;
YY_BREAK
case 92:
YY_RULE_SETUP
#line 147 "QuantityParser.l"
return TANH;
return TAN;
YY_BREAK
case 93:
YY_RULE_SETUP
#line 148 "QuantityParser.l"
return SQRT;
return TANH;
YY_BREAK
case 94:
YY_RULE_SETUP
#line 150 "QuantityParser.l"
return *yytext;
#line 149 "QuantityParser.l"
return SQRT;
YY_BREAK
case 95:
YY_RULE_SETUP
#line 151 "QuantityParser.l"
return *yytext;
YY_BREAK
case 96:
YY_RULE_SETUP
#line 152 "QuantityParser.l"
ECHO;
YY_BREAK
#line 1317 "QuantityLexer.c"
#line 1322 "QuantityLexer.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(C_COMMENT):
yyterminate();
@@ -1607,7 +1612,7 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 167 )
if ( yy_current_state >= 168 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1635,11 +1640,11 @@ static int yy_get_next_buffer (void)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 167 )
if ( yy_current_state >= 168 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 166);
yy_is_jam = (yy_current_state == 167);
return yy_is_jam ? 0 : yy_current_state;
}
@@ -2272,4 +2277,4 @@ void yyfree (void * ptr )
#define YYTABLES_NAME "yytables"
#line 151 "QuantityParser.l"
#line 152 "QuantityParser.l"

View File

@@ -119,6 +119,7 @@ ID [a-z][a-z0-9]*
"CV" yylval = Quantity::WattSecond; return UNIT; //
"Ws" yylval = Quantity::WattSecond; return UNIT; // W*s = Joule
"\xC2\xB0" yylval = Quantity::Degree; return UNIT; // degree (internal standard angle)
"deg" yylval = Quantity::Degree; return UNIT; // degree (internal standard angle)
"rad" yylval = Quantity::Radian; return UNIT; // radian
"gon" yylval = Quantity::Gon; return UNIT; // gon

View File

@@ -16,7 +16,7 @@ std::string QuantityPy::representation(void) const
{
std::stringstream ret;
ret << getQuantityPtr()->getValue() << " ";
ret << getQuantityPtr()->getUnit().getString();
ret << getQuantityPtr()->getUnit().getString().toLatin1().constData();
return ret.str();
}

View File

@@ -158,12 +158,12 @@ Unit& Unit::operator = (const Unit &New)
return *this;
}
std::string Unit::getString(void) const
QString Unit::getString(void) const
{
std::stringstream ret;
if(isEmpty())
return "";
return QString();
if( Sig.Length > 0 ||
Sig.Mass > 0 ||
@@ -312,28 +312,28 @@ std::string Unit::getString(void) const
if (nnom > 1) ret << ')';
}
return ret.str();
return QString::fromUtf8(ret.str().c_str());
}
std::string Unit::getTypeString(void) const
QString Unit::getTypeString(void) const
{
if(*this == Unit::Length ) return "Length"; else
if(*this == Unit::Area ) return "Area"; else
if(*this == Unit::Volume ) return "Volume"; else
if(*this == Unit::Mass ) return "Mass"; else
if(*this == Unit::Angle ) return "Angle"; else
if(*this == Unit::TimeSpan ) return "TimeSpan"; else
if(*this == Unit::Velocity ) return "Velocity"; else
if(*this == Unit::Acceleration ) return "Acceleration"; else
if(*this == Unit::Temperature ) return "Temperature"; else
if(*this == Unit::ElectricCurrent ) return "ElectricCurrent"; else
if(*this == Unit::AmountOfSubstance ) return "AmountOfSubstance"; else
if(*this == Unit::LuminoseIntensity ) return "LuminoseIntensity"; else
if(*this == Unit::Pressure ) return "Pressure"; else
if(*this == Unit::Force ) return "Force"; else
if(*this == Unit::Work ) return "Work"; else
if(*this == Unit::Power ) return "Power"; else
return "";
if(*this == Unit::Length ) return QString::fromLatin1("Length"); else
if(*this == Unit::Area ) return QString::fromLatin1("Area"); else
if(*this == Unit::Volume ) return QString::fromLatin1("Volume"); else
if(*this == Unit::Mass ) return QString::fromLatin1("Mass"); else
if(*this == Unit::Angle ) return QString::fromLatin1("Angle"); else
if(*this == Unit::TimeSpan ) return QString::fromLatin1("TimeSpan"); else
if(*this == Unit::Velocity ) return QString::fromLatin1("Velocity"); else
if(*this == Unit::Acceleration ) return QString::fromLatin1("Acceleration"); else
if(*this == Unit::Temperature ) return QString::fromLatin1("Temperature"); else
if(*this == Unit::ElectricCurrent ) return QString::fromLatin1("ElectricCurrent"); else
if(*this == Unit::AmountOfSubstance ) return QString::fromLatin1("AmountOfSubstance"); else
if(*this == Unit::LuminoseIntensity ) return QString::fromLatin1("LuminoseIntensity"); else
if(*this == Unit::Pressure ) return QString::fromLatin1("Pressure"); else
if(*this == Unit::Force ) return QString::fromLatin1("Force"); else
if(*this == Unit::Work ) return QString::fromLatin1("Work"); else
if(*this == Unit::Power ) return QString::fromLatin1("Power"); else
return QString();
}

View File

@@ -26,6 +26,7 @@
#ifdef _MSC_VER
# include <boost/cstdint.hpp>
# include <QString>
#else
# include <stdint.h>
#endif
@@ -74,9 +75,9 @@ public:
const UnitSignature & getSignature(void)const {return Sig;}
bool isEmpty(void)const;
std::string getString(void) const;
QString getString(void) const;
/// get the type as an string such as "Area", "Length" or "Pressure".
std::string getTypeString(void) const;
QString getTypeString(void) const;
/** Predefined Unit types. */
//@{

View File

@@ -16,7 +16,7 @@ std::string UnitPy::representation(void) const
const UnitSignature & Sig = getUnitPtr()->getSignature();
std::stringstream ret;
ret << "Unit: ";
ret << getUnitPtr()->getString() << " (";
ret << getUnitPtr()->getString().toLatin1().constData() << " (";
ret << Sig.Length << ",";
ret << Sig.Mass << ",";
ret << Sig.Time << ",";
@@ -25,7 +25,7 @@ std::string UnitPy::representation(void) const
ret << Sig.AmountOfSubstance << ",";
ret << Sig.LuminoseIntensity << ",";
ret << Sig.Angle << ")";
std::string type = getUnitPtr()->getTypeString();
std::string type = getUnitPtr()->getTypeString().toLatin1();
if(! type.empty())
ret << " [" << type << "]";
@@ -178,7 +178,7 @@ PyObject* UnitPy::richCompare(PyObject *v, PyObject *w, int op)
Py::String UnitPy::getType(void) const
{
return Py::String(getUnitPtr()->getTypeString());
return Py::String(getUnitPtr()->getTypeString().toLatin1());
}

View File

@@ -69,10 +69,10 @@ QString UnitsSchemaImperial1::schemaTranslate(Base::Quantity quant,double &facto
unitString = QString::fromLatin1("thou");
factor = 0.0254;
}else if(UnitValue < 304.8){
unitString = QString::fromLatin1("in");
unitString = QString::fromLatin1("\"");
factor = 25.4;
}else if(UnitValue < 914.4){
unitString = QString::fromLatin1("ft");
unitString = QString::fromLatin1("\'");
factor = 304.8;
}else if(UnitValue < 1609344.0){
unitString = QString::fromLatin1("yd");
@@ -112,7 +112,7 @@ QString UnitsSchemaImperial1::schemaTranslate(Base::Quantity quant,double &facto
}
}else{
// default action for all cases without special treatment:
unitString = QString::fromLatin1(quant.getUnit().getString().c_str());
unitString = quant.getUnit().getString();
factor = 1.0;
}
return QString::fromLatin1("%1 %2").arg(UnitValue / factor).arg(unitString);

View File

@@ -48,7 +48,7 @@ QString UnitsSchemaInternal::schemaTranslate(Base::Quantity quant,double &factor
unitString = QString::fromLatin1("nm");
factor = 0.000001;
}else if(UnitValue < 1.0){
unitString = QString::fromLatin1("ym");
unitString = QString::fromUtf8("\xC2\xB5m");
factor = 0.001;
}else if(UnitValue < 10000.0){
unitString = QString::fromLatin1("mm");
@@ -66,12 +66,17 @@ QString UnitsSchemaInternal::schemaTranslate(Base::Quantity quant,double &factor
}else if (unit == Unit::Area){
// TODO Cascade for the Areas
// default action for all cases without special treatment:
unitString = QString::fromLatin1(quant.getUnit().getString().c_str());
unitString = quant.getUnit().getString();
factor = 1.0;
}else if (unit == Unit::Angle){
// TODO Cascade for the Areas
// default action for all cases without special treatment:
unitString = QString::fromUtf8("\xC2\xB0");
factor = 1.0;
}else if (unit == Unit::Mass){
// TODO Cascade for the wights
// default action for all cases without special treatment:
unitString = QString::fromLatin1(quant.getUnit().getString().c_str());
unitString = quant.getUnit().getString();
factor = 1.0;
}else if (unit == Unit::Pressure){
if(UnitValue < 10.0){// Pa is the smallest
@@ -89,9 +94,9 @@ QString UnitsSchemaInternal::schemaTranslate(Base::Quantity quant,double &factor
}
}else{
// default action for all cases without special treatment:
unitString = QString::fromLatin1(quant.getUnit().getString().c_str());
unitString = quant.getUnit().getString();
factor = 1.0;
}
return QString::fromLatin1("%1 %2").arg(UnitValue / factor).arg(unitString);
return QString::fromUtf8("%1 %2").arg(UnitValue / factor).arg(unitString);
}

View File

@@ -48,7 +48,7 @@ QString UnitsSchemaMKS::schemaTranslate(Base::Quantity quant,double &factor,QStr
unitString = QString::fromLatin1("nm");
factor = 0.000001;
}else if(UnitValue < 1.0){
unitString = QString::fromLatin1("ym");
unitString = QString::fromUtf8("\xC2\xB5m");
factor = 0.001;
}else if(UnitValue < 100.0){
unitString = QString::fromLatin1("mm");
@@ -66,12 +66,12 @@ QString UnitsSchemaMKS::schemaTranslate(Base::Quantity quant,double &factor,QStr
}else if (unit == Unit::Area){
// TODO Cascade for the Areas
// default action for all cases without special treatment:
unitString = QString::fromLatin1(quant.getUnit().getString().c_str());
unitString = quant.getUnit().getString();
factor = 1.0;
}else if (unit == Unit::Mass){
// TODO Cascade for the wights
// default action for all cases without special treatment:
unitString = QString::fromLatin1(quant.getUnit().getString().c_str());
unitString = quant.getUnit().getString();
factor = 1.0;
}else if (unit == Unit::Pressure){
if(UnitValue < 10.0){// Pa is the smallest
@@ -89,8 +89,8 @@ QString UnitsSchemaMKS::schemaTranslate(Base::Quantity quant,double &factor,QStr
}
}else{
// default action for all cases without special treatment:
unitString = QString::fromLatin1(quant.getUnit().getString().c_str());
unitString = quant.getUnit().getString();
factor = 1.0;
}
return QString::fromLatin1("%1 %2").arg(UnitValue / factor).arg(unitString);
return QString::fromUtf8("%1 %2").arg(UnitValue / factor).arg(unitString);
}