/** * Konstruktor. * Erzeugt ein neues Gebäudepositionierung-Werkzeug * @param doc Dokument, welches die Gebäude und das Gelände enthält * @param parent Parent-Fenter * @author Alex Letkemann */ BB_ToolBuildingPositionNew::BB_ToolBuildingPositionNew( BB_Doc * doc, QWidget* parent): BB_ToolPointNew(parent) { if( doc == NULL ) { qDebug("BB_ToolBuildingPositionNew kann nicht ohne BB_Doc initialisiert werden:"); exit(1); } m_Doc = doc; m_Building = NULL; m_Icon = QIcon( IMG_DIR() + SEPARATOR() + "toolBuildingPosition.png" ); }
int parse_get_token (char *buf, int limit) { int token_index = 0; int escape_state = FALSE; int quoted_state = FALSE; int comment_state = FALSE; int token_truncated = FALSE; char current_ch, ch; do { current_ch = get_next_char(); if (comment_state) { /* A comment is ended by an EOLN or EOF. If cont_line is not 0, we keep looking for a token (or until a EOF is hit). If it is, we return EOF or EOLN. */ if (current_ch == '\n') { if (cont_line == 0) { first_word = TRUE; return GW_EOLN; } comment_state = FALSE; } else if (current_ch == '\0') { first_word = TRUE; if (cont_line) return GW_ERRCONTINUATION; else return GW_EOF; } } else if (escape_state) { /* An escape character was hit. The next character is copied in (re-escaped) with the exception of the end of line - which is copied unescaped. If a digit follows the escape character there are supposed to be two more, but that error checking is left to the next level of parsing. */ if (current_ch == '\n') { ADD_CHAR (buf, current_ch); } else if (current_ch == 0x7F || current_ch < 0x20) { do ch = get_next_char(); while (ch != '\n' && ch != '\0'); if (ch== '\0') put_back_char (ch); first_word = TRUE; cont_line = 0; return GW_ERRILLEGALCHAR; } else { ADD_CHAR (buf, '\\'); ADD_CHAR (buf, current_ch); } escape_state = FALSE; } else if (quoted_state) { /* In the middle of a quote, escapes matter, and we don't return the enclosing quote marks. */ if (current_ch == '\\') escape_state = TRUE; else if (current_ch == '\n' || current_ch == '\0') { buf[token_index]='\0'; if (cont_line > 0) { while (cont_line > 0) { do ch = get_next_char(); while (ch != '\n' && ch != '\0'); cont_line--; } put_back_char (ch); } first_word = TRUE; cont_line = 0; return GW_ERRDANGLINGQUOTE; } else if (current_ch == '"') { buf[token_index]='\0'; return GW_MAYBE_WORD; } else if (current_ch!='\t' && (current_ch<0x20 || current_ch==0x7F)) { do ch = get_next_char(); while (ch != '\n' && ch != '\0'); first_word = TRUE; cont_line = 0; return GW_ERRILLEGALCHAR; } else { ADD_CHAR (buf, current_ch); } } else if (token_index > 0) { /* In this case, there is a token being built. It is either added to or a separating character ends it and itself may be left (e.g., a ; beginning a comment ends the previous token and is left to signal the start of the comment next time around. */ if (isspace(current_ch)&¤t_ch!='\n'&¤t_ch!='\0') { first_word = FALSE; buf[token_index]='\0'; if (current_ch== '\0') put_back_char (current_ch); return GW_MAYBE_WORD; } else if (current_ch == '\\') { escape_state = TRUE; } else if (SEPARATOR(current_ch)) { first_word = FALSE; put_back_char (current_ch); buf[token_index]='\0'; return GW_MAYBE_WORD; } else if (current_ch < 0x20 || current_ch == 0x7F) { do ch = get_next_char(); while (ch != '\n' && ch != '\0'); if (ch== '\0') put_back_char (ch); first_word = TRUE; cont_line = 0; return GW_ERRILLEGALCHAR; } else ADD_CHAR (buf, current_ch); } else /* The character is potentially the start of a token. Some of these may have been seen by the above code and returned to the input stream. */ switch (current_ch) { case ';': buf[token_index]='\0'; comment_state = TRUE; break; case '(': cont_line++; do ch = get_next_char(); while (ch != '\n' && ch != '\0'); if (ch== '\0') put_back_char (ch); first_word = FALSE; break; case ')': cont_line--; while ((ch = get_next_char()) != '\n') { if (ch == '\0') return GW_EOF; if (ch == ')') { put_back_char (ch); break; } } if (cont_line==0) { first_word = TRUE; return GW_EOLN; } if (cont_line < 0) { /* We've already read to the end of the line */ first_word = TRUE; cont_line = 0; return GW_ERRCONTINUATION; } break; case ' ': case '\t': if (first_word) { ADD_CHAR (buf, current_ch); buf[token_index]='\0'; first_word = FALSE; return GW_MAYBE_WORD; } break; case '\\': escape_state = TRUE; break; case '"': quoted_state = TRUE; break; case '\n': if (cont_line==0) { first_word = TRUE; return GW_EOLN; } break; case '\0': if (cont_line == 0) return GW_EOF; else { cont_line = 0; return GW_ERRCONTINUATION; } default: if (current_ch<0x20 || current_ch==0x7F) { do ch = get_next_char(); while (ch != '\n' && ch != '\0'); if (ch== '\0') put_back_char (ch); first_word = TRUE; cont_line = 0; return GW_ERRILLEGALCHAR; } else { ADD_CHAR (buf, current_ch); } } /* end switch body */ } while (TRUE); /* end the do-while loop */ }
int main(int argc, const char *argv[]) { RLQ_INIT_RELOCATE(rlq, RLQ_SIZE); char tmp[RLQ_SIZE] = {0}; char str[] = "This ia a test for rlq."; int num = 100; struct student victor = { "Victor", 1 }; char buf[RLQ_SIZE] = { 0 }; SEPARATOR(); printf("rlq_full(&rlq): %d\n", rlq_full(&rlq)); printf("rlq_empty(&rlq): %d\n", rlq_empty(&rlq)); SEPARATOR(); memset(tmp, 1, RLQ_SIZE); printf("rlq_enqueue(&rlq, tmp, RLQ_SIZE)\n\n"); rlq_enqueue(&rlq, tmp, RLQ_SIZE); rlq_dump(&rlq); rlq_statistics(&rlq); SEPARATOR(); printf("rlq_full(&rlq): %d\n", rlq_full(&rlq)); printf("rlq_empty(&rlq): %d\n", rlq_empty(&rlq)); SEPARATOR(); printf("rlq_clear(&rlq)\n"); rlq_clear(&rlq); printf("rlq_full(&rlq): %d\n", rlq_full(&rlq)); printf("rlq_empty(&rlq): %d\n", rlq_empty(&rlq)); SEPARATOR(); printf("rlq_enqueue(&rlq, str, strlen(str))\n\n"); rlq_enqueue(&rlq, str, strlen(str)); rlq_dump(&rlq); rlq_statistics(&rlq); SEPARATOR(); printf("rlq_enqueue(&rlq, &num, sizeof(int))\n\n"); rlq_enqueue(&rlq, &num, sizeof(int)); rlq_dump(&rlq); rlq_statistics(&rlq); SEPARATOR(); printf("rlq_enqueue(&rlq, &victor, sizeof(struct student))\n\n"); rlq_enqueue(&rlq, &victor, sizeof(struct student)); rlq_dump(&rlq); rlq_statistics(&rlq); SEPARATOR(); printf("rlq_dequeue(&rlq, buf, strlen(str))\n\n"); rlq_dequeue(&rlq, buf, strlen(str)); printf("buf: %s\n", buf); rlq_dump(&rlq); rlq_statistics(&rlq); SEPARATOR(); bzero(buf, RLQ_SIZE); printf("rlq_dequeue(&rlq, buf, sizeof(int))\n\n"); rlq_dequeue(&rlq, buf, sizeof(int)); rlq_dump(&rlq); rlq_statistics(&rlq); SEPARATOR(); bzero(buf, RLQ_SIZE); printf("rlq_dequeue(&rlq, buf, sizeof(struct student))\n\n"); rlq_dequeue(&rlq, buf, sizeof(struct student)); rlq_dump(&rlq); rlq_statistics(&rlq); rlq_free(&rlq); return 0; }
/** * Erzeugt die Dreiecke für das Dach und den Grund des Gebäudes.<br> * Die Erzeugten Dreiecke werden an den übergebenen Vektor 'triangles' angehängt. * @param triangles Vektor, an den die Dreiecke angehängt werden. * @param vector Positionsektor * @param rotation Rotation der Dreiecke * @param scale Skalierung der Dreiecke * @param height Hier keine Funktion * @author Alex Letkemann */ void BB_BuildingTriangle::createGl(QVector< C3dTriangle >& triangles, C3dVector vector, double rotation, double scale, double height) { C3dVector v1, v2, v3; double textureFactor = 0.1 * scale; // Textur-Vektore einstellen C3dVector tV1, tV2, tV3; tV1.setX( m_Pos1->getX() * textureFactor ); tV1.setY( m_Pos1->getY() * textureFactor ); tV1.setZ( 0.0 ); tV2.setX( m_Pos2->getX() * textureFactor ); tV2.setY( m_Pos2->getY() * textureFactor ); tV2.setZ( 0.0 ); tV3.setX( m_Pos3->getX() * textureFactor ); tV3.setY( m_Pos3->getY() * textureFactor ); tV3.setZ( 0.0 ); // Positions-Vektoren für die Untere Fläche einstellen v1.setX( m_Pos1->getPos().x() * scale ); v1.setZ( m_Pos1->getPos().y() * scale ); v1.setY( 0.0 ); v2.setX( m_Pos2->getPos().x() * scale ); v2.setZ( m_Pos2->getPos().y() * scale ); v2.setY( 0.0 ); v3.setX( m_Pos3->getPos().x() * scale ); v3.setZ( m_Pos3->getPos().y() * scale ); v3.setY( 0.0 ); v1 = v1.rotateVector( v_Y, rotation ); v2 = v2.rotateVector( v_Y, rotation ); v3 = v3.rotateVector( v_Y, rotation ); // v4 = v4.rotateVector( v_Y, rotation ); v1 = v1 + vector; v2 = v2 + vector; v3 = v3 + vector; // v4 = v4 + vector; C3dTriangle triangleGround ( v3, v2, v1, tV3, tV2, tV1, cl_White ); v1.setY( ( height * scale ) + vector.y() ); v2.setY( ( height * scale ) + vector.y() ); v3.setY( ( height * scale ) + vector.y() ); QImage texture; if ( texture.load( IMG_DIR() + SEPARATOR() + "buildingGround.png" ) && texture.height() != 0 && texture.width() != 0 ) { triangleGround.createTexture( texture ); } else { qDebug() << "Textur (" << IMG_DIR() + SEPARATOR() + "buildingGround.png" + ") konnte nicht geladen werden."; } C3dTriangle triangleRoof ( v1, v2, v3, tV1, tV2, tV3, cl_White ); if ( texture.load( IMG_DIR() + SEPARATOR() + "buildingRoof.png" ) && texture.height() != 0 && texture.width() != 0 ) { triangleRoof.createTexture( texture ); } else { qDebug() << "Textur (" << IMG_DIR() + SEPARATOR() + "buildingRoof.png" + ") konnte nicht geladen werden."; } // Dreiecke an Vektor anhängen triangles.append( triangleGround ); triangles.append( triangleRoof ); }
char * dn_normalize( char *dn ) { char *d, *s; int state, gotesc; gotesc = 0; state = B4TYPE; for ( d = s = dn; *s; s++ ) { switch ( state ) { case B4TYPE: if ( ! SPACE( *s ) ) { state = INTYPE; *d++ = *s; } break; case INTYPE: if ( *s == '=' ) { state = B4VALUE; *d++ = *s; } else if ( SPACE( *s ) ) { state = B4EQUAL; } else { *d++ = *s; } break; case B4EQUAL: if ( *s == '=' ) { state = B4VALUE; *d++ = *s; } else if ( ! SPACE( *s ) ) { /* not a valid dn - but what can we do here? */ *d++ = *s; } break; case B4VALUE: if ( *s == '"' ) { state = INQUOTEDVALUE; *d++ = *s; } else if ( ! SPACE( *s ) ) { state = INVALUE; *d++ = *s; } break; case INVALUE: if ( !gotesc && SEPARATOR( *s ) ) { while ( SPACE( *(d - 1) ) ) d--; state = B4TYPE; if ( *s == '+' ) { *d++ = *s; } else { *d++ = ','; } } else if ( gotesc && !NEEDSESCAPE( *s ) && !SEPARATOR( *s ) ) { *--d = *s; d++; } else { *d++ = *s; } break; case INQUOTEDVALUE: if ( !gotesc && *s == '"' ) { state = B4SEPARATOR; *d++ = *s; } else if ( gotesc && !NEEDSESCAPE( *s ) ) { *--d = *s; d++; } else { *d++ = *s; } break; case B4SEPARATOR: if ( SEPARATOR( *s ) ) { state = B4TYPE; *d++ = *s; } break; default: fprintf (stderr, "dn_normalize - unknown state %d dn:%s \n", state, dn ); break; } if ( *s == '\\' ) { gotesc = 1; } else { gotesc = 0; } } *d = '\0'; return( dn ); }
/** * Konstruktor. Erstellt ein neues Werkzeug zur Markieren von Dächern und Gründen. */ BB_ToolBuildingTriangleNew::BB_ToolBuildingTriangleNew(QWidget* parent): BB_ToolTriangleNew(parent) { m_Icon = QIcon( IMG_DIR() + SEPARATOR() + "toolTriangle.png" ); }