399 str value () const { return m_val; } |
398 str value () const { return m_val; } |
400 private: |
399 private: |
401 str m_val; |
400 str m_val; |
402 }; |
401 }; |
403 |
402 |
404 // Formatter function |
|
405 str DoFormat (vector<StringFormatArg> args); |
|
406 #ifndef IN_IDE_PARSER |
|
407 #define fmt(...) DoFormat ({__VA_ARGS__}) |
|
408 #else |
|
409 str fmt (const char* fmtstr, ...); |
|
410 #endif |
|
411 |
|
412 // ============================================================================= |
403 // ============================================================================= |
413 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
404 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
414 // ============================================================================= |
405 // ============================================================================= |
415 // File |
406 // File |
416 // |
407 // |
465 QTextStream* m_textstream; |
456 QTextStream* m_textstream; |
466 iterator m_endIterator; |
457 iterator m_endIterator; |
467 }; |
458 }; |
468 |
459 |
469 // ============================================================================= |
460 // ============================================================================= |
470 // bbox |
461 // LDBoundingBox |
471 // |
462 // |
472 // The bounding box is the box that encompasses a given set of objects. |
463 // The bounding box is the box that encompasses a given set of objects. |
473 // v0 is the minimum vertex, v1 is the maximum vertex. |
464 // v0 is the minimum vertex, v1 is the maximum vertex. |
474 // ============================================================================= |
465 // ============================================================================= |
475 class bbox { |
466 class LDBoundingBox { |
476 READ_PROPERTY (bool, empty, setEmpty) |
467 READ_PROPERTY (bool, empty, setEmpty) |
477 READ_PROPERTY (vertex, v0, setV0) |
468 READ_PROPERTY (vertex, v0, setV0) |
478 READ_PROPERTY (vertex, v1, setV1) |
469 READ_PROPERTY (vertex, v1, setV1) |
479 |
470 |
480 public: |
471 public: |
481 bbox(); |
472 LDBoundingBox(); |
482 void reset(); |
473 void reset(); |
483 void calculate(); |
474 void calculate(); |
484 double size() const; |
475 double size() const; |
485 void calcObject (LDObject* obj); |
476 void calcObject (LDObject* obj); |
486 void calcVertex (const vertex& v); |
477 void calcVertex (const vertex& v); |
487 vertex center() const; |
478 vertex center() const; |
488 |
479 |
489 bbox& operator<< (LDObject* obj) { |
480 LDBoundingBox& operator<< (LDObject* obj); |
490 calcObject (obj); |
481 LDBoundingBox& operator<< (const vertex& v); |
491 return *this; |
482 }; |
492 } |
483 |
493 |
484 // Formatter function |
494 bbox& operator<< (const vertex& v) { |
485 str DoFormat (vector<StringFormatArg> args); |
495 calcVertex (v); |
486 |
496 return *this; |
487 // printf replacement |
497 } |
488 void doPrint (File& f, initlist<StringFormatArg> args); |
498 }; |
489 void doPrint (FILE* f, initlist<StringFormatArg> args); // heh |
|
490 |
|
491 // log() - universal access to the message log. Defined here so that I don't have |
|
492 // to include messagelog.h here and recompile everything every time that file changes. |
|
493 void DoLog( std::initializer_list<StringFormatArg> args ); |
|
494 |
|
495 // Macros to access these functions |
|
496 # ifndef IN_IDE_PARSER |
|
497 #define fmt(...) DoFormat ({__VA_ARGS__}) |
|
498 # define print(...) doPrint (g_file_stdout, {__VA_ARGS__}) |
|
499 # define fprint(F, ...) doPrint (F, {__VA_ARGS__}) |
|
500 # define log(...) DoLog({ __VA_ARGS__ }); |
|
501 #else |
|
502 str fmt (const char* fmtstr, ...); |
|
503 void print (const char* fmtstr, ...); |
|
504 void fprint (File& f, const char* fmtstr, ...); |
|
505 void log( const char* fmtstr, ... ); |
|
506 #endif |
|
507 |
|
508 extern File g_file_stdout; |
|
509 extern File g_file_stderr; |
|
510 extern const vertex g_origin; // Vertex at (0, 0, 0) |
|
511 extern const matrix g_identity; // Identity matrix |
|
512 |
|
513 static const double pi = 3.14159265358979323846f; |
499 |
514 |
500 #endif // TYPES_H |
515 #endif // TYPES_H |