From acfd1e1b19eeffc62f66f9ff52605303fd0eb2d5 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Sat, 3 Sep 2011 06:30:48 +0200 Subject: More de-Qt-ify diff --git a/src/CSGTermEvaluator.cc b/src/CSGTermEvaluator.cc index aaf96ef..b75babe 100644 --- a/src/CSGTermEvaluator.cc +++ b/src/CSGTermEvaluator.cc @@ -90,7 +90,9 @@ static CSGTerm *evaluate_csg_term_from_ps(const State &state, const ModuleInstantiation *modinst, const AbstractPolyNode &node) { - CSGTerm *t = new CSGTerm(ps, state.matrix(), state.color(), QString("%1%2").arg(node.name().c_str()).arg(node.index())); + std::stringstream stream; + stream << node.name() << node.index(); + CSGTerm *t = new CSGTerm(ps, state.matrix(), state.color(), stream.str()); if (modinst->tag_highlight) highlights.push_back(t->link()); if (modinst->tag_background) { diff --git a/src/csgterm.cc b/src/csgterm.cc index 179381e..c615a58 100644 --- a/src/csgterm.cc +++ b/src/csgterm.cc @@ -26,6 +26,7 @@ #include "csgterm.h" #include "polyset.h" +#include /*! \class CSGTerm @@ -46,7 +47,7 @@ */ -CSGTerm::CSGTerm(PolySet *polyset, const double matrix[16], const double color[4], QString label) +CSGTerm::CSGTerm(PolySet *polyset, const double matrix[16], const double color[4], const std::string &label) { this->type = TYPE_PRIMITIVE; this->polyset = polyset; @@ -176,28 +177,33 @@ void CSGTerm::unlink() } } -QString CSGTerm::dump() +std::string CSGTerm::dump() { + std::stringstream dump; + if (type == TYPE_UNION) - return QString("(%1 + %2)").arg(left->dump(), right->dump()); - if (type == TYPE_INTERSECTION) - return QString("(%1 * %2)").arg(left->dump(), right->dump()); - if (type == TYPE_DIFFERENCE) - return QString("(%1 - %2)").arg(left->dump(), right->dump()); - return label; + dump << "(" << left->dump() << " + " << right->dump() << ")"; + else if (type == TYPE_INTERSECTION) + dump << "(" << left->dump() << " * " << right->dump() << ")"; + else if (type == TYPE_DIFFERENCE) + dump << "(" << left->dump() << " - " << right->dump() << ")"; + else + dump << this->label; + + return dump.str(); } CSGChain::CSGChain() { } -void CSGChain::add(PolySet *polyset, double *m, double *color, CSGTerm::type_e type, QString label) +void CSGChain::add(PolySet *polyset, double *m, double *color, CSGTerm::type_e type, std::string label) { - polysets.append(polyset); - matrices.append(m); - colors.append(color); - types.append(type); - labels.append(label); + polysets.push_back(polyset); + matrices.push_back(m); + colors.push_back(color); + types.push_back(type); + labels.push_back(label); } void CSGChain::import(CSGTerm *term, CSGTerm::type_e type) @@ -210,24 +216,24 @@ void CSGChain::import(CSGTerm *term, CSGTerm::type_e type) } } -QString CSGChain::dump() +std::string CSGChain::dump() { - QString text; + std::stringstream dump; + for (int i = 0; i < types.size(); i++) { if (types[i] == CSGTerm::TYPE_UNION) { - if (i != 0) - text += "\n"; - text += "+"; + if (i != 0) dump << "\n"; + dump << "+"; } else if (types[i] == CSGTerm::TYPE_DIFFERENCE) - text += " -"; + dump << " -"; else if (types[i] == CSGTerm::TYPE_INTERSECTION) - text += " *"; - text += labels[i]; + dump << " *"; + dump << labels[i]; } - text += "\n"; - return text; + dump << "\n"; + return dump.str(); } BoundingBox CSGChain::getBoundingBox() const diff --git a/src/csgterm.h b/src/csgterm.h index b0fffe4..2a89ef1 100644 --- a/src/csgterm.h +++ b/src/csgterm.h @@ -1,8 +1,8 @@ #ifndef CSGTERM_H_ #define CSGTERM_H_ -#include -#include +#include +#include #include "polyset.h" class CSGTerm @@ -17,14 +17,14 @@ public: type_e type; PolySet *polyset; - QString label; + std::string label; CSGTerm *left; CSGTerm *right; double m[16]; double color[4]; int refcounter; - CSGTerm(PolySet *polyset, const double matrix[16], const double color[4], QString label); + CSGTerm(PolySet *polyset, const double matrix[16], const double color[4], const std::string &label); CSGTerm(type_e type, CSGTerm *left, CSGTerm *right); CSGTerm *normalize(); @@ -32,23 +32,23 @@ public: CSGTerm *link(); void unlink(); - QString dump(); + std::string dump(); }; class CSGChain { public: - QVector polysets; - QVector matrices; - QVector colors; - QVector types; - QVector labels; + std::vector polysets; + std::vector matrices; + std::vector colors; + std::vector types; + std::vector labels; CSGChain(); - void add(PolySet *polyset, double *m, double *color, CSGTerm::type_e type, QString label); + void add(PolySet *polyset, double *m, double *color, CSGTerm::type_e type, std::string label); void import(CSGTerm *term, CSGTerm::type_e type = CSGTerm::TYPE_UNION); - QString dump(); + std::string dump(); BoundingBox getBoundingBox() const; }; diff --git a/src/mainwin.cc b/src/mainwin.cc index c82f5f1..6408418 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -1345,7 +1345,7 @@ void MainWindow::actionDisplayCSGProducts() e->setTabStopWidth(30); e->setWindowTitle("CSG Products Dump"); e->setReadOnly(true); - e->setPlainText(QString("\nCSG before normalization:\n%1\n\n\nCSG after normalization:\n%2\n\n\nCSG rendering chain:\n%3\n\n\nHighlights CSG rendering chain:\n%4\n\n\nBackground CSG rendering chain:\n%5\n").arg(root_raw_term ? root_raw_term->dump() : "N/A", root_norm_term ? root_norm_term->dump() : "N/A", root_chain ? root_chain->dump() : "N/A", highlights_chain ? highlights_chain->dump() : "N/A", background_chain ? background_chain->dump() : "N/A")); + e->setPlainText(QString("\nCSG before normalization:\n%1\n\n\nCSG after normalization:\n%2\n\n\nCSG rendering chain:\n%3\n\n\nHighlights CSG rendering chain:\n%4\n\n\nBackground CSG rendering chain:\n%5\n").arg(root_raw_term ? QString::fromStdString(root_raw_term->dump()) : "N/A", root_norm_term ? QString::fromStdString(root_norm_term->dump()) : "N/A", root_chain ? QString::fromStdString(root_chain->dump()) : "N/A", highlights_chain ? QString::fromStdString(highlights_chain->dump()) : "N/A", background_chain ? QString::fromStdString(background_chain->dump()) : "N/A")); e->show(); e->resize(600, 400); clearCurrentOutput(); diff --git a/src/value.cc b/src/value.cc index 139bd1c..740cb3d 100644 --- a/src/value.cc +++ b/src/value.cc @@ -377,9 +377,3 @@ std::ostream &operator<<(std::ostream &stream, const Value &value) return stream; } -std::ostream &operator<<(std::ostream &stream, const QString &str) -{ - stream << str.toStdString(); - return stream; -} - diff --git a/src/value.h b/src/value.h index 9140912..2003460 100644 --- a/src/value.h +++ b/src/value.h @@ -69,8 +69,4 @@ private: std::ostream &operator<<(std::ostream &stream, const Value &value); -// FIXME: Doesn't belong here.. -#include -std::ostream &operator<<(std::ostream &stream, const QString &str); - #endif -- cgit v0.10.1