summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-09-03 04:30:48 (GMT)
committerMarius Kintel <marius@kintel.net>2011-09-03 04:30:48 (GMT)
commitacfd1e1b19eeffc62f66f9ff52605303fd0eb2d5 (patch)
tree5d23bd8744d23d6f9542c0d03b5048fdb8a141cf
parent6f632190a05417d44193e3b16a7b3000b2cc1145 (diff)
More de-Qt-ify
-rw-r--r--src/CSGTermEvaluator.cc4
-rw-r--r--src/csgterm.cc54
-rw-r--r--src/csgterm.h24
-rw-r--r--src/mainwin.cc2
-rw-r--r--src/value.cc6
-rw-r--r--src/value.h4
6 files changed, 46 insertions, 48 deletions
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 <sstream>
/*!
\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 <QString>
-#include <QVector>
+#include <string>
+#include <vector>
#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<PolySet*> polysets;
- QVector<double*> matrices;
- QVector<double*> colors;
- QVector<CSGTerm::type_e> types;
- QVector<QString> labels;
+ std::vector<PolySet*> polysets;
+ std::vector<double*> matrices;
+ std::vector<double*> colors;
+ std::vector<CSGTerm::type_e> types;
+ std::vector<std::string> 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 <QString>
-std::ostream &operator<<(std::ostream &stream, const QString &str);
-
#endif
contact: Jan Huwald // Impressum