chunkstream version fixedleaselication
git-svn-id: svn://db.shs.com.ru/libs@3 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -8,5 +8,5 @@ if (NOT DEFINED MINGW_DIR)
|
|||||||
message(STATUS "Find MinGW binary path = ${MINGW_BIN}")
|
message(STATUS "Find MinGW binary path = ${MINGW_BIN}")
|
||||||
message(STATUS "Find MinGW include path = ${MINGW_INCLUDE}")
|
message(STATUS "Find MinGW include path = ${MINGW_INCLUDE}")
|
||||||
message(STATUS "Find MinGW library path = ${MINGW_LIB}")
|
message(STATUS "Find MinGW library path = ${MINGW_LIB}")
|
||||||
endif ()
|
endif ()
|
||||||
endif (${MINGW})
|
endif (${MINGW})
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "kx_pult.h"
|
#include "kx_pult.h"
|
||||||
#include "ui_kx_pult.h"
|
#include "ui_kx_pult.h"
|
||||||
@@ -186,7 +187,8 @@ void KX_Pult::timerEvent(QTimerEvent * e) {
|
|||||||
static QString sPI = QString::number(atan(1) * 4., 'f', 14).leftJustified(14);
|
static QString sPI = QString::number(atan(1) * 4., 'f', 14).leftJustified(14);
|
||||||
static int cnt = 0;
|
static int cnt = 0;
|
||||||
int si = qMax<int>(cnt - 6, 0);
|
int si = qMax<int>(cnt - 6, 0);
|
||||||
cnt = (++cnt) % 23;
|
++cnt;
|
||||||
|
cnt %= 23;
|
||||||
ui->labelWait->setText(QString(si, QChar(' ')) + sPI.mid(cnt - 6, 6).trimmed());
|
ui->labelWait->setText(QString(si, QChar(' ')) + sPI.mid(cnt - 6, 6).trimmed());
|
||||||
if (!coeffs.isReady()) return;
|
if (!coeffs.isReady()) return;
|
||||||
//ui->table->setK(coeffsK.k()->data(), coeffsK.count());
|
//ui->table->setK(coeffsK.k()->data(), coeffsK.count());
|
||||||
@@ -399,7 +401,7 @@ void KX_Pult::on_buttonSetDesc_clicked() {
|
|||||||
QString ret = QFileDialog::getOpenFileName(this, trUtf8("Select *.h file with K description"), kdesc_file, "C/C++ header files(*.h *.hpp);;All files(*)");
|
QString ret = QFileDialog::getOpenFileName(this, trUtf8("Select *.h file with K description"), kdesc_file, "C/C++ header files(*.h *.hpp);;All files(*)");
|
||||||
if (ret.isEmpty()) return;
|
if (ret.isEmpty()) return;
|
||||||
kdesc_file = QDir::current().relativeFilePath(ret);
|
kdesc_file = QDir::current().relativeFilePath(ret);
|
||||||
updateKDesc();
|
updateKDesc(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -478,7 +480,7 @@ void KX_Pult::updateDiag() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KX_Pult::updateKDesc() {
|
void KX_Pult::updateKDesc(bool ask_move) {
|
||||||
kdesc.clear();
|
kdesc.clear();
|
||||||
QFile f(kdesc_file);
|
QFile f(kdesc_file);
|
||||||
if (!f.open(QIODevice::ReadOnly)) {
|
if (!f.open(QIODevice::ReadOnly)) {
|
||||||
@@ -532,7 +534,10 @@ void KX_Pult::updateKDesc() {
|
|||||||
ui->spinSize->setValue(cind);
|
ui->spinSize->setValue(cind);
|
||||||
ui->spinSize->setStyleSheet("background-color: rgb(220, 220, 255);");
|
ui->spinSize->setStyleSheet("background-color: rgb(220, 220, 255);");
|
||||||
}
|
}
|
||||||
updateTree();
|
bool move = false;
|
||||||
|
if (ask_move)
|
||||||
|
move = (QMessageBox::question(this, "KX Pult", "Save values at associated names?", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes);
|
||||||
|
updateTree(move);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -542,12 +547,21 @@ bool stringComp(const QString & s1, const QString & s2) {
|
|||||||
return s1 > s2;
|
return s1 > s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KX_Pult::updateTree() {
|
|
||||||
|
void KX_Pult::updateTree(bool move) {
|
||||||
int sp = ui->treeK->verticalScrollBar()->value();
|
int sp = ui->treeK->verticalScrollBar()->value();
|
||||||
ui->treeK->clear();
|
|
||||||
ui->treeK->setUpdatesEnabled(false);
|
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
//qDebug() << "fill tree ...";
|
//qDebug() << "fill tree ...";
|
||||||
|
QMap<QString, QString> prev_val;
|
||||||
|
if (move) {
|
||||||
|
for (int i = 0; i < ui->treeK->topLevelItemCount(); ++i) {
|
||||||
|
QTreeWidgetItem * ti = ui->treeK->topLevelItem(i);
|
||||||
|
if (!ti->text(1).isEmpty())
|
||||||
|
prev_val[ti->text(1)] = ti->text(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui->treeK->clear();
|
||||||
|
ui->treeK->setUpdatesEnabled(false);
|
||||||
eval.clearCustomVariables();
|
eval.clearCustomVariables();
|
||||||
for (int i = 0; i < K.size_s(); ++i) {
|
for (int i = 0; i < K.size_s(); ++i) {
|
||||||
QTreeWidgetItem * ti = new QTreeWidgetItem();
|
QTreeWidgetItem * ti = new QTreeWidgetItem();
|
||||||
@@ -562,6 +576,10 @@ void KX_Pult::updateTree() {
|
|||||||
knames_sort << kd.name;
|
knames_sort << kd.name;
|
||||||
eval.content.addVariable(kd.name, 0., false);
|
eval.content.addVariable(kd.name, 0., false);
|
||||||
}
|
}
|
||||||
|
if (move && !kd.name.isEmpty()) {
|
||||||
|
if (prev_val.contains(kd.name))
|
||||||
|
coeffs.setFormula(i, Q2PIString(prev_val[kd.name]));
|
||||||
|
}
|
||||||
ti->setText(0, QString::number(i));
|
ti->setText(0, QString::number(i));
|
||||||
ti->setText(1, kd.name);
|
ti->setText(1, kd.name);
|
||||||
ti->setText(2, PI2QString(coeffs.formula(i)));
|
ti->setText(2, PI2QString(coeffs.formula(i)));
|
||||||
|
|||||||
@@ -118,8 +118,8 @@ private slots:
|
|||||||
void saving(QPIConfig & conf);
|
void saving(QPIConfig & conf);
|
||||||
void updateGraph();
|
void updateGraph();
|
||||||
void updateDiag();
|
void updateDiag();
|
||||||
void updateKDesc();
|
void updateKDesc(bool ask_move = false);
|
||||||
void updateTree();
|
void updateTree(bool move = false);
|
||||||
void filterTree();
|
void filterTree();
|
||||||
void calculate();
|
void calculate();
|
||||||
void renew();
|
void renew();
|
||||||
@@ -138,7 +138,7 @@ private slots:
|
|||||||
void on_buttonWrite_clicked();
|
void on_buttonWrite_clicked();
|
||||||
void on_buttonResize_clicked();
|
void on_buttonResize_clicked();
|
||||||
void on_buttonSetDesc_clicked();
|
void on_buttonSetDesc_clicked();
|
||||||
void on_buttonReparseDesc_clicked() {updateKDesc();}
|
void on_buttonReparseDesc_clicked() {updateKDesc(true);}
|
||||||
void on_buttonCalculate_clicked() {calculate();}
|
void on_buttonCalculate_clicked() {calculate();}
|
||||||
void on_buttonApply_clicked() {renew();}
|
void on_buttonApply_clicked() {renew();}
|
||||||
void on_spinSize_valueChanged(int);
|
void on_spinSize_valueChanged(int);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
cmake .
|
#cmake .
|
||||||
make install $@
|
#make install $@
|
||||||
for d in 'qad_widgets' 'qad_utils' 'qad_graphic' 'qad_sql_table' 'qad_application' 'qad_blockview' 'touch_widgets'; do
|
for d in 'qad_widgets' 'qad_utils' 'qad_graphic' 'qad_sql_table' 'qad_application' 'qad_blockview' 'touch_widgets'; do
|
||||||
cd $d
|
cd $d
|
||||||
qmake
|
qmake
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ ConnectionEdit::~ConnectionEdit() {
|
|||||||
|
|
||||||
|
|
||||||
void ConnectionEdit::accept() {
|
void ConnectionEdit::accept() {
|
||||||
bool ok = false;
|
//bool ok = false;
|
||||||
QList<BlockItem * > bl = ui->blockView->allDevices();
|
QList<BlockItem * > bl = ui->blockView->allDevices();
|
||||||
foreach (BlockItem * i, bl)
|
foreach (BlockItem * i, bl)
|
||||||
foreach (BlockItem * j, bl)
|
foreach (BlockItem * j, bl)
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ ETabWidget::ETabWidget(QWidget* parent): QTabWidget(parent) {
|
|||||||
|
|
||||||
void ETabWidget::retranslate() {
|
void ETabWidget::retranslate() {
|
||||||
for (int i = 0; i < buttons.size(); ++i)
|
for (int i = 0; i < buttons.size(); ++i)
|
||||||
buttons[i].toolTip = QApplication::translate("MainWindow", buttons[i].srcToolTip.toUtf8(), 0, QCoreApplication::UnicodeUTF8);
|
buttons[i].toolTip = QApplication::translate("MainWindow", buttons[i].srcToolTip.toUtf8(), 0/*, QCoreApplication::UnicodeUTF8*/);
|
||||||
QList<QToolButton * > bl = findChildren<QToolButton * >();
|
QList<QToolButton * > bl = findChildren<QToolButton * >();
|
||||||
foreach (QToolButton * i, bl)
|
foreach (QToolButton * i, bl)
|
||||||
i->setToolTip(QApplication::translate("MainWindow", i->property("sourceToolTip").toString().toUtf8(), 0, QCoreApplication::UnicodeUTF8));
|
i->setToolTip(QApplication::translate("MainWindow", i->property("sourceToolTip").toString().toUtf8(), 0/*, QCoreApplication::UnicodeUTF8*/));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ private:
|
|||||||
void tabRemoved(int) {emit countChanged();}
|
void tabRemoved(int) {emit countChanged();}
|
||||||
|
|
||||||
struct TabButton {
|
struct TabButton {
|
||||||
TabButton(int r, const QIcon & i, const QString & t) {role = r; icon = i; visible = true; srcToolTip = t; toolTip = QApplication::translate("MainWindow", t.toUtf8(), 0, QCoreApplication::UnicodeUTF8);}
|
TabButton(int r, const QIcon & i, const QString & t) {role = r; icon = i; visible = true; srcToolTip = t; toolTip = QApplication::translate("MainWindow", t.toUtf8(), 0/*, QCoreApplication::UnicodeUTF8*/);}
|
||||||
int role;
|
int role;
|
||||||
bool visible;
|
bool visible;
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ QSingleApplication::QSingleApplication(const QString & app_name): QThread() {
|
|||||||
shm.attach();
|
shm.attach();
|
||||||
shm.lock();
|
shm.lock();
|
||||||
void * d = shm.data();
|
void * d = shm.data();
|
||||||
if (d) qMemSet(d, 0, sizeof(quint32));
|
if (d) memset(d, 0, sizeof(quint32));
|
||||||
shm.unlock();
|
shm.unlock();
|
||||||
start();
|
start();
|
||||||
//qDebug() << "start listen";
|
//qDebug() << "start listen";
|
||||||
@@ -49,11 +49,11 @@ void QSingleApplication::sendMessage(const QByteArray & m) {
|
|||||||
quint32 num(0), size = m.size();
|
quint32 num(0), size = m.size();
|
||||||
void * d = shm.data();
|
void * d = shm.data();
|
||||||
if (d) {
|
if (d) {
|
||||||
qMemCopy(&num, d, sizeof(quint32));
|
memcpy(&num, d, sizeof(quint32));
|
||||||
num++;
|
num++;
|
||||||
qMemCopy(d, &num, sizeof(quint32));
|
memcpy(d, &num, sizeof(quint32));
|
||||||
qMemCopy((((char*)d) + sizeof(quint32)), &size, sizeof(quint32));
|
memcpy((((char*)d) + sizeof(quint32)), &size, sizeof(quint32));
|
||||||
qMemCopy((((char*)d) + sizeof(quint32) + sizeof(quint32)), m.constData(), size);
|
memcpy((((char*)d) + sizeof(quint32) + sizeof(quint32)), m.constData(), size);
|
||||||
}
|
}
|
||||||
shm.unlock();
|
shm.unlock();
|
||||||
}
|
}
|
||||||
@@ -65,15 +65,15 @@ void QSingleApplication::run() {
|
|||||||
shm.lock();
|
shm.lock();
|
||||||
const void * d = shm.constData();
|
const void * d = shm.constData();
|
||||||
if (d) {
|
if (d) {
|
||||||
qMemCopy(&num, d, sizeof(quint32));
|
memcpy(&num, d, sizeof(quint32));
|
||||||
if (pnum != num) {
|
if (pnum != num) {
|
||||||
pnum = num;
|
pnum = num;
|
||||||
//qDebug() << "new message" << num;
|
//qDebug() << "new message" << num;
|
||||||
qMemCopy(&size, (((const char*)d) + sizeof(quint32)), sizeof(quint32));
|
memcpy(&size, (((const char*)d) + sizeof(quint32)), sizeof(quint32));
|
||||||
if (size <= int(QSA_MSGSIZE)) {
|
if (size <= int(QSA_MSGSIZE)) {
|
||||||
QByteArray msg;
|
QByteArray msg;
|
||||||
msg.resize(size);
|
msg.resize(size);
|
||||||
qMemCopy(msg.data(), (((const char*)d) + sizeof(quint32) + sizeof(quint32)), size);
|
memcpy(msg.data(), (((const char*)d) + sizeof(quint32) + sizeof(quint32)), size);
|
||||||
emit messageReceived(msg);
|
emit messageReceived(msg);
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "[QSingleApplication] Invalid message size:" << size;
|
qDebug() << "[QSingleApplication] Invalid message size:" << size;
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public:
|
|||||||
QList<QGraphicsItem * > decors() const {return decors_;}
|
QList<QGraphicsItem * > decors() const {return decors_;}
|
||||||
QList<BlockBusItem * > connectedBuses() const;
|
QList<BlockBusItem * > connectedBuses() const;
|
||||||
BlockItemPin * pinByText(const QString & t) const;
|
BlockItemPin * pinByText(const QString & t) const;
|
||||||
BlockItemPin * pinAtBus(BlockBusItem * bus) const; /// TODO return list of connected pins
|
BlockItemPin * pinAtBus(BlockBusItem * bus) const;
|
||||||
QColor color() const {return col;}
|
QColor color() const {return col;}
|
||||||
void setColor(QColor c) {col = c; _resize(size());}
|
void setColor(QColor c) {col = c; _resize(size());}
|
||||||
QSizeF size() const {return g_main.rect().size();}
|
QSizeF size() const {return g_main.rect().size();}
|
||||||
|
|||||||
@@ -456,13 +456,13 @@ void Graphic::setHistorySize(double val) {
|
|||||||
history = val;
|
history = val;
|
||||||
double x;
|
double x;
|
||||||
for (int i = 0; i < graphics.size(); ++i) {
|
for (int i = 0; i < graphics.size(); ++i) {
|
||||||
QPolygonF & pol(graphics[i].polyline);
|
QList<QPointF> & pol(graphics[i].polyline);
|
||||||
if (pol.isEmpty()) continue;
|
if (pol.isEmpty()) continue;
|
||||||
x = pol.back().x() - history;
|
x = pol.back().x() - history;
|
||||||
for (int j = pol.size() - 2; j >= 0 ; --j)
|
for (int j = pol.size() - 2; j >= 0 ; --j)
|
||||||
if (pol[j].x() < x) {
|
if (pol[j].x() < x) {
|
||||||
//qDebug() << pol.size() << j;
|
//qDebug() << pol.size() << j;
|
||||||
pol.remove(0, j);
|
pol.erase(pol.begin(), pol.begin() + j);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -529,26 +529,26 @@ void Graphic::setButtonsPosition(Graphic::Alignment a) {
|
|||||||
void Graphic::addPoint(const QPointF & p, int graphic, bool update_) {
|
void Graphic::addPoint(const QPointF & p, int graphic, bool update_) {
|
||||||
if (graphic >= graphics.size() || graphic < 0) return;
|
if (graphic >= graphics.size() || graphic < 0) return;
|
||||||
if (graphics.at(graphic).polyline.size() == 0) graphics[graphic].max_x = p.x();
|
if (graphics.at(graphic).polyline.size() == 0) graphics[graphic].max_x = p.x();
|
||||||
graphics[graphic].polyline.push_back(p);
|
graphics[graphic].polyline << p;
|
||||||
if (graphics.at(graphic).max_x < p.x()) graphics[graphic].max_x = p.x();
|
if (graphics.at(graphic).max_x < p.x()) graphics[graphic].max_x = p.x();
|
||||||
tick(graphic, true, update_);
|
tick(graphic, true, update_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Graphic::setGraphicData(const QVector<QPointF> & g, int graphic) {
|
void Graphic::setGraphicData(const QVector<QPointF> & g, int graphic, bool update_) {
|
||||||
if (graphic >= graphics.size() || graphic < 0) return;
|
if (graphic >= graphics.size() || graphic < 0) return;
|
||||||
graphics[graphic].polyline.clear();
|
graphics[graphic].polyline.clear();
|
||||||
graphics[graphic].polyline = QPolygonF(g);
|
graphics[graphic].polyline = g.toList();
|
||||||
if (graphics.at(graphic).polyline.size() == 0) {
|
if (graphics.at(graphic).polyline.size() == 0) {
|
||||||
graphics[graphic].max_x = 0.;
|
graphics[graphic].max_x = 0.;
|
||||||
tick(graphic, false);
|
tick(graphic, false, update_);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
graphics[graphic].max_x = graphics.at(graphic).polyline[0].x();
|
graphics[graphic].max_x = graphics.at(graphic).polyline[0].x();
|
||||||
for (int i = 1; i < graphics.at(graphic).polyline.size(); ++i)
|
for (int i = 1; i < graphics.at(graphic).polyline.size(); ++i)
|
||||||
if (graphics.at(graphic).max_x < graphics.at(graphic).polyline[i].x())
|
if (graphics.at(graphic).max_x < graphics.at(graphic).polyline[i].x())
|
||||||
graphics[graphic].max_x = graphics.at(graphic).polyline[i].x();
|
graphics[graphic].max_x = graphics.at(graphic).polyline[i].x();
|
||||||
tick(graphic, false);
|
tick(graphic, false, update_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -662,7 +662,7 @@ void Graphic::setHistogramData(const QVector<float> & g, int graphic) {
|
|||||||
//if (ci >= ic) ci = ic - 1;
|
//if (ci >= ic) ci = ic - 1;
|
||||||
hist[ci]++;
|
hist[ci]++;
|
||||||
}
|
}
|
||||||
QPolygonF & cpol(graphics[graphic].polyline);
|
QList<QPointF> & cpol(graphics[graphic].polyline);
|
||||||
if (hist.size() == 1 || range == 0.) {
|
if (hist.size() == 1 || range == 0.) {
|
||||||
cpol << QPointF(min - 0.5, 0.) << QPointF(min - 0.25, 0.);
|
cpol << QPointF(min - 0.5, 0.) << QPointF(min - 0.25, 0.);
|
||||||
cpol << QPointF(min - 0.25, hist[0]) << QPointF(min + 0.25, hist[0]);
|
cpol << QPointF(min - 0.25, hist[0]) << QPointF(min + 0.25, hist[0]);
|
||||||
@@ -684,7 +684,7 @@ void Graphic::findGraphicsRect(double start_x, double end_x, double start_y, dou
|
|||||||
bool isRangeX = (start_x != end_x), isRangeY = (start_y != end_y);
|
bool isRangeX = (start_x != end_x), isRangeY = (start_y != end_y);
|
||||||
bool isEmpty = true, anyVisible = false, isTimeLimit = (visible_time > 0.) && !(isRangeX || isRangeY);
|
bool isEmpty = true, anyVisible = false, isTimeLimit = (visible_time > 0.) && !(isRangeX || isRangeY);
|
||||||
foreach (const GraphicType & t, graphics) {
|
foreach (const GraphicType & t, graphics) {
|
||||||
const QPolygonF & pol(pause_ ? t.polyline_pause : t.polyline);
|
const QList<QPointF> & pol(pause_ ? t.polyline_pause : t.polyline);
|
||||||
if (!pol.isEmpty()) {
|
if (!pol.isEmpty()) {
|
||||||
isEmpty = false;
|
isEmpty = false;
|
||||||
break;
|
break;
|
||||||
@@ -704,7 +704,7 @@ void Graphic::findGraphicsRect(double start_x, double end_x, double start_y, dou
|
|||||||
vx -= visible_time;
|
vx -= visible_time;
|
||||||
foreach (const GraphicType & t, graphics) {
|
foreach (const GraphicType & t, graphics) {
|
||||||
if (!t.visible) continue;
|
if (!t.visible) continue;
|
||||||
const QPolygonF & pol(pause_ ? t.polyline_pause : t.polyline);
|
const QList<QPointF> & pol(pause_ ? t.polyline_pause : t.polyline);
|
||||||
for (int i = 0; i < pol.size(); i++) {
|
for (int i = 0; i < pol.size(); i++) {
|
||||||
cx = pol[i].x();
|
cx = pol[i].x();
|
||||||
cy = pol[i].y();
|
cy = pol[i].y();
|
||||||
@@ -869,10 +869,10 @@ void Graphic::drawGraphics() {
|
|||||||
QTransform mat = painter->transform();
|
QTransform mat = painter->transform();
|
||||||
painter->resetTransform();
|
painter->resetTransform();
|
||||||
painter->setWorldMatrixEnabled(false);
|
painter->setWorldMatrixEnabled(false);
|
||||||
QPolygonF cpol;
|
QList<QPointF> cpol;
|
||||||
for (int i = 0; i < graphics.size(); ++i) {
|
for (int i = 0; i < graphics.size(); ++i) {
|
||||||
GraphicType & t(graphics[i]);
|
GraphicType & t(graphics[i]);
|
||||||
QPolygonF & rpol(pause_ ? t.polyline_pause : t.polyline);
|
QList<QPointF> & rpol(pause_ ? t.polyline_pause : t.polyline);
|
||||||
if (t.visible && !rpol.isEmpty()) {
|
if (t.visible && !rpol.isEmpty()) {
|
||||||
pw = t.pen.widthF();
|
pw = t.pen.widthF();
|
||||||
if (t.lines) {
|
if (t.lines) {
|
||||||
@@ -883,16 +883,16 @@ void Graphic::drawGraphics() {
|
|||||||
painter->setBrush(t.fill_color);
|
painter->setBrush(t.fill_color);
|
||||||
//cpol.push_front(QPointF(cpol.front().x(), 0.));
|
//cpol.push_front(QPointF(cpol.front().x(), 0.));
|
||||||
//cpol.push_back(QPointF(cpol.back().x(), 0.));
|
//cpol.push_back(QPointF(cpol.back().x(), 0.));
|
||||||
painter->drawPolygon(mat.map(cpol));
|
painter->drawPolygon(mat.map(QPolygonF(cpol.toVector())));
|
||||||
} else
|
} else
|
||||||
painter->drawPolyline(mat.map(rpol));
|
painter->drawPolyline(mat.map(QPolygonF(rpol.toVector())));
|
||||||
}
|
}
|
||||||
if (t.points) {
|
if (t.points) {
|
||||||
if (qRound(t.pointWidth) == t.pointWidth) t.pen.setWidth(qRound(t.pointWidth));
|
if (qRound(t.pointWidth) == t.pointWidth) t.pen.setWidth(qRound(t.pointWidth));
|
||||||
else t.pen.setWidthF(t.pointWidth);
|
else t.pen.setWidthF(t.pointWidth);
|
||||||
t.pen.setCosmetic(true);
|
t.pen.setCosmetic(true);
|
||||||
painter->setPen(t.pen);
|
painter->setPen(t.pen);
|
||||||
painter->drawPoints(mat.map(rpol));
|
painter->drawPoints(mat.map(QPolygonF(rpol.toVector())));
|
||||||
if (qRound(pw) == pw) t.pen.setWidth(qRound(pw));
|
if (qRound(pw) == pw) t.pen.setWidth(qRound(pw));
|
||||||
else t.pen.setWidthF(pw);
|
else t.pen.setWidthF(pw);
|
||||||
}
|
}
|
||||||
@@ -1067,13 +1067,13 @@ void Graphic::tick(int index, bool slide, bool update_) {
|
|||||||
if (slide) {
|
if (slide) {
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
GraphicType & t(graphics[index]);
|
GraphicType & t(graphics[index]);
|
||||||
if (t.polyline.size() > 1) if (fabs(t.polyline.back().x() - t.polyline.front().x()) > history) {
|
while (t.polyline.size() > 1) {
|
||||||
|
if (fabs(t.polyline.back().x() - t.polyline.front().x()) <= history) break;
|
||||||
t.polyline.pop_front();
|
t.polyline.pop_front();
|
||||||
if (t.polyline.size() > 1) if (fabs(t.polyline.back().x() - t.polyline.front().x()) > history) t.polyline.pop_front();
|
|
||||||
if (t.polyline.size() > 1) if (fabs(t.polyline.back().x() - t.polyline.front().x()) > history) t.polyline.pop_front();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!update_) {
|
if (!update_) {
|
||||||
|
findGraphicsRect();
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1093,7 +1093,7 @@ void Graphic::on_buttonAutofit_clicked() {
|
|||||||
isFit = true;
|
isFit = true;
|
||||||
bool isEmpty = true;
|
bool isEmpty = true;
|
||||||
foreach (const GraphicType & t, graphics) {
|
foreach (const GraphicType & t, graphics) {
|
||||||
const QPolygonF & pol(pause_ ? t.polyline_pause : t.polyline);
|
const QList<QPointF> & pol(pause_ ? t.polyline_pause : t.polyline);
|
||||||
if (!pol.isEmpty()) {
|
if (!pol.isEmpty()) {
|
||||||
isEmpty = false;
|
isEmpty = false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ public slots:
|
|||||||
void addPoint(double x, double y, bool update = true) {addPoint(QPointF(x, y), update);}
|
void addPoint(double x, double y, bool update = true) {addPoint(QPointF(x, y), update);}
|
||||||
void addPoint(double y, int graphic, bool update = true) {addPoint(QPointF(graphics.at(graphic).max_x + inc_x, y), graphic, update);}
|
void addPoint(double y, int graphic, bool update = true) {addPoint(QPointF(graphics.at(graphic).max_x + inc_x, y), graphic, update);}
|
||||||
void addPoint(double y, bool update = true) {addPoint(QPointF(graphics[curGraphic].max_x + inc_x, y), update);}
|
void addPoint(double y, bool update = true) {addPoint(QPointF(graphics[curGraphic].max_x + inc_x, y), update);}
|
||||||
void setGraphicData(const QVector<QPointF> & g, int graphic);
|
void setGraphicData(const QVector<QPointF> & g, int graphic, bool update_ = true);
|
||||||
void setGraphicData(const QVector<QPointF> & g) {setGraphicData(g, curGraphic);}
|
void setGraphicData(const QVector<QPointF> & g) {setGraphicData(g, curGraphic);}
|
||||||
void setGraphicProperties(const QString & name, const QColor & color = Qt::darkRed, Qt::PenStyle style = Qt::SolidLine, double width = 0., bool visible = true) {setGraphicProperties(curGraphic, name, color, style, width, visible);}
|
void setGraphicProperties(const QString & name, const QColor & color = Qt::darkRed, Qt::PenStyle style = Qt::SolidLine, double width = 0., bool visible = true) {setGraphicProperties(curGraphic, name, color, style, width, visible);}
|
||||||
void setGraphicProperties(int graphic, const QString & name, const QColor & color = Qt::darkRed, Qt::PenStyle style = Qt::SolidLine, double width = 0., bool visible = true);
|
void setGraphicProperties(int graphic, const QString & name, const QColor & color = Qt::darkRed, Qt::PenStyle style = Qt::SolidLine, double width = 0., bool visible = true);
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ struct GraphicType {
|
|||||||
}
|
}
|
||||||
//~GraphicType() {delete pb;}
|
//~GraphicType() {delete pb;}
|
||||||
QString name;
|
QString name;
|
||||||
QPolygonF polyline;
|
QList<QPointF> polyline;
|
||||||
QPolygonF polyline_pause;
|
QList<QPointF> polyline_pause;
|
||||||
QPen pen;
|
QPen pen;
|
||||||
QColor fill_color;
|
QColor fill_color;
|
||||||
bool lines;
|
bool lines;
|
||||||
|
|||||||
@@ -2,18 +2,21 @@
|
|||||||
|
|
||||||
|
|
||||||
void ChunkStream::setSource(const QByteArray & data) {
|
void ChunkStream::setSource(const QByteArray & data) {
|
||||||
|
stream_.setVersion(QDataStream::Qt_4_8);
|
||||||
data_ = const_cast<QByteArray*>(&data);
|
data_ = const_cast<QByteArray*>(&data);
|
||||||
_init();
|
_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ChunkStream::setSource(QByteArray * data) {
|
void ChunkStream::setSource(QByteArray * data) {
|
||||||
|
stream_.setVersion(QDataStream::Qt_4_8);
|
||||||
data_ = (data ? data : &tmp_data);
|
data_ = (data ? data : &tmp_data);
|
||||||
_init();
|
_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ChunkStream::setSource(QDataStream & str) {
|
void ChunkStream::setSource(QDataStream & str) {
|
||||||
|
stream_.setVersion(QDataStream::Qt_4_8);
|
||||||
str >> tmp_data;
|
str >> tmp_data;
|
||||||
data_ = &tmp_data;
|
data_ = &tmp_data;
|
||||||
_init();
|
_init();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public:
|
|||||||
int read() {stream_ >> last_id >> last_data; return last_id;}
|
int read() {stream_ >> last_id >> last_data; return last_id;}
|
||||||
int getID() {return last_id;}
|
int getID() {return last_id;}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T getData() const {T ret; QDataStream s(last_data); s >> ret; return ret;}
|
T getData() const {T ret; QDataStream s(last_data); s.setVersion(QDataStream::Qt_4_8); s >> ret; return ret;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _init();
|
void _init();
|
||||||
@@ -48,6 +48,7 @@ template <typename T>
|
|||||||
ChunkStream & operator <<(ChunkStream & s, const ChunkStream::Chunk<T> & c) {
|
ChunkStream & operator <<(ChunkStream & s, const ChunkStream::Chunk<T> & c) {
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
QDataStream bas(&ba, QIODevice::WriteOnly);
|
QDataStream bas(&ba, QIODevice::WriteOnly);
|
||||||
|
bas.setVersion(QDataStream::Qt_4_8);
|
||||||
bas << c.data;
|
bas << c.data;
|
||||||
s.dataStream() << c.id << ba;
|
s.dataStream() << c.id << ba;
|
||||||
return s;
|
return s;
|
||||||
|
|||||||
@@ -24,7 +24,13 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) {
|
|||||||
completer.setHeaderHidden(true);
|
completer.setHeaderHidden(true);
|
||||||
completer.installEventFilter(this);
|
completer.installEventFilter(this);
|
||||||
completer.header()->setDefaultAlignment(Qt::AlignCenter);
|
completer.header()->setDefaultAlignment(Qt::AlignCenter);
|
||||||
completer.header()->setResizeMode(QHeaderView::ResizeToContents);
|
completer.header()->
|
||||||
|
#if (QT_VERSION >= 0x050000)
|
||||||
|
setSectionResizeMode
|
||||||
|
#else
|
||||||
|
setResizeMode
|
||||||
|
#endif
|
||||||
|
(QHeaderView::ResizeToContents);
|
||||||
completer.header()->setStretchLastSection(true);
|
completer.header()->setStretchLastSection(true);
|
||||||
//completer.setColumnWidth(0, 180);
|
//completer.setColumnWidth(0, 180);
|
||||||
completer.resize(500, 200);
|
completer.resize(500, 200);
|
||||||
@@ -129,8 +135,8 @@ bool QCodeEdit::matchWritten(QString s, QString w) {
|
|||||||
QChar wc(w[i].toLower());
|
QChar wc(w[i].toLower());
|
||||||
bool ns = false, bl = true;
|
bool ns = false, bl = true;
|
||||||
while (sp < s.size()) {
|
while (sp < s.size()) {
|
||||||
if (ns || s[sp].toAscii() == '_') {
|
if (ns || s[sp].toLatin1() == '_') {
|
||||||
if (s[sp].toAscii() == '_') {sp++; bl = false; continue;}
|
if (s[sp].toLatin1() == '_') {sp++; bl = false; continue;}
|
||||||
if (s[sp].isLower() && bl) {sp++; continue;}
|
if (s[sp].isLower() && bl) {sp++; continue;}
|
||||||
if (s[sp].toLower() != wc) return false;
|
if (s[sp].toLower() != wc) return false;
|
||||||
}
|
}
|
||||||
@@ -265,7 +271,7 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
|||||||
completer.hide();
|
completer.hide();
|
||||||
QMetaObject::invokeMethod(this, "invokeAutoCompletition", Qt::QueuedConnection, Q_ARG(bool, false));
|
QMetaObject::invokeMethod(this, "invokeAutoCompletition", Qt::QueuedConnection, Q_ARG(bool, false));
|
||||||
} else {
|
} else {
|
||||||
if ((kc.isLetterOrNumber() || kc.toAscii() == '_') && completer.isVisible())
|
if ((kc.isLetterOrNumber() || kc.toLatin1() == '_') && completer.isVisible())
|
||||||
QMetaObject::invokeMethod(this, "invokeAutoCompletition", Qt::QueuedConnection, Q_ARG(bool, false));
|
QMetaObject::invokeMethod(this, "invokeAutoCompletition", Qt::QueuedConnection, Q_ARG(bool, false));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -694,7 +700,7 @@ void QCodeEdit::commitCompletition() {
|
|||||||
tc.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
tc.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
||||||
}
|
}
|
||||||
if (!tc.selectedText().isEmpty())
|
if (!tc.selectedText().isEmpty())
|
||||||
if (tc.selectedText()[0].toAscii() == '(')
|
if (tc.selectedText()[0].toLatin1() == '(')
|
||||||
ins_br = false;
|
ins_br = false;
|
||||||
}
|
}
|
||||||
if (ins.contains("("))
|
if (ins.contains("("))
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ void QPIConsole::applyFormat(QLabel * l, QPIConsole::Formats f) {
|
|||||||
if (f.testFlag(QPIConsole::BackCyan)) bcol = Qt::cyan;
|
if (f.testFlag(QPIConsole::BackCyan)) bcol = Qt::cyan;
|
||||||
if (f.testFlag(QPIConsole::BackWhite)) bcol = Qt::white;
|
if (f.testFlag(QPIConsole::BackWhite)) bcol = Qt::white;
|
||||||
if (f.testFlag(QPIConsole::BackLighter)) bcol = bcol.lighter(150);
|
if (f.testFlag(QPIConsole::BackLighter)) bcol = bcol.lighter(150);
|
||||||
if (f.testFlag(QPIConsole::BackDarker)) bcol = bcol.darker(150);
|
//if (f.testFlag(QPIConsole::BackDarker)) bcol = bcol.darker(150);
|
||||||
|
|
||||||
if (f.testFlag(QPIConsole::Inverse)) {
|
if (f.testFlag(QPIConsole::Inverse)) {
|
||||||
QColor tc = fcol;
|
QColor tc = fcol;
|
||||||
|
|||||||
@@ -53,8 +53,8 @@ public:
|
|||||||
Scientific = 0x10000000,
|
Scientific = 0x10000000,
|
||||||
Lighter = 0x20000000,
|
Lighter = 0x20000000,
|
||||||
Darker = 0x40000000,
|
Darker = 0x40000000,
|
||||||
BackLighter = 0x80000000,
|
BackLighter = 0x80000000
|
||||||
BackDarker = 0x100000000};
|
};
|
||||||
|
|
||||||
Q_DECLARE_FLAGS(Formats, Format)
|
Q_DECLARE_FLAGS(Formats, Format)
|
||||||
Q_FLAGS(Formats)
|
Q_FLAGS(Formats)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ find_package(Qt4 REQUIRED)
|
|||||||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${QT_INCLUDES})
|
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${QT_INCLUDES})
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -Wall")
|
||||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
|
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||||
|
|
||||||
add_definitions(-DGL_GLEXT_PROTOTYPES)
|
add_definitions(-DGL_GLEXT_PROTOTYPES)
|
||||||
@@ -12,7 +12,7 @@ set(LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} qad_wid
|
|||||||
if (${WIN32})
|
if (${WIN32})
|
||||||
list(APPEND LIBS opengl32 glu32)
|
list(APPEND LIBS opengl32 glu32)
|
||||||
else (${WIN32})
|
else (${WIN32})
|
||||||
list(APPEND LIBS GL GLU)
|
list(APPEND LIBS GL GLU glut GLEW)
|
||||||
endif (${WIN32})
|
endif (${WIN32})
|
||||||
|
|
||||||
file(GLOB MOCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
|
file(GLOB MOCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
|
||||||
|
|||||||
@@ -56,6 +56,7 @@
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
#elif defined(__APPLE__) || defined(__APPLE_CC__)
|
#elif defined(__APPLE__) || defined(__APPLE_CC__)
|
||||||
#define GL_GLEXT_LEGACY
|
#define GL_GLEXT_LEGACY
|
||||||
#include <OpenGL/gl.h>
|
#include <OpenGL/gl.h>
|
||||||
|
|||||||
@@ -81,7 +81,9 @@ void GLFramebuffer::bind() {
|
|||||||
if (fbo == 0) return;
|
if (fbo == 0) return;
|
||||||
glFlush();
|
glFlush();
|
||||||
glGetIntegerv(GL_VIEWPORT, prev_view);
|
glGetIntegerv(GL_VIEWPORT, prev_view);
|
||||||
|
//glClearError();
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||||
|
//qDebug() << QString::number(glGetError(), 16);
|
||||||
QVector<GLenum> buffers;
|
QVector<GLenum> buffers;
|
||||||
for (int i = 0; i < colors.size(); ++i)
|
for (int i = 0; i < colors.size(); ++i)
|
||||||
buffers << GL_COLOR_ATTACHMENT0 + i;
|
buffers << GL_COLOR_ATTACHMENT0 + i;
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ public:
|
|||||||
GLenum colorFormat() const {return color_format;}
|
GLenum colorFormat() const {return color_format;}
|
||||||
GLuint depthTexture() const {return tex_d;}
|
GLuint depthTexture() const {return tex_d;}
|
||||||
GLenum target() const {return target_;}
|
GLenum target() const {return target_;}
|
||||||
|
int width() const {return wid;}
|
||||||
|
int height() const {return hei;}
|
||||||
|
QSize size() const {return QSize(wid, hei);}
|
||||||
|
|
||||||
void resize(int width, int height);
|
void resize(int width, int height);
|
||||||
void bind();
|
void bind();
|
||||||
|
|||||||
@@ -29,6 +29,16 @@ void GLPrimitivePoint::draw(bool simplest) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void GLPrimitiveLine::draw(bool simplest) {
|
||||||
|
glColor3f(material_.color_diffuse.redF(), material_.color_diffuse.greenF(), material_.color_diffuse.blueF());
|
||||||
|
glBegin(GL_LINES);
|
||||||
|
glVertex3d(p0.x(), p0.y(), p0.z());
|
||||||
|
glVertex3d(p1.x(), p1.y(), p1.z());
|
||||||
|
glEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GLPrimitiveCube::GLPrimitiveCube(double width, double length, double height, QVector3D pos): GLObjectBase() {
|
GLPrimitiveCube::GLPrimitiveCube(double width, double length, double height, QVector3D pos): GLObjectBase() {
|
||||||
geom_prim = Quads;
|
geom_prim = Quads;
|
||||||
w = width;
|
w = width;
|
||||||
@@ -101,3 +111,75 @@ void GLPrimitiveCube::init() {
|
|||||||
is_init = true;
|
is_init = true;
|
||||||
vbo.rebuffer();
|
vbo.rebuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GLPrimitiveEllipsoid::GLPrimitiveEllipsoid(double width, double length, double height, int seg_wl, int seg_h, QVector3D pos) {
|
||||||
|
geom_prim = GLObjectBase::Triangles;
|
||||||
|
w = width;
|
||||||
|
l = length;
|
||||||
|
h = height;
|
||||||
|
swl = seg_wl;
|
||||||
|
sh = seg_h;
|
||||||
|
moveTo(pos);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLPrimitiveEllipsoid::putTriangle(const QVector3D & v0, const QVector3D & v1, const QVector3D & v2) {
|
||||||
|
vbo.vertices() << v0.x() << v0.y() << v0.z() << v1.x() << v1.y() << v1.z() << v2.x() << v2.y() << v2.z();
|
||||||
|
QVector3D n = QVector3D::normal(v1 - v0, v2 - v0);
|
||||||
|
for (int i = 0; i < 3; ++i)
|
||||||
|
vbo.normals() << n.x() << n.y() << n.z();
|
||||||
|
return;
|
||||||
|
QVector3D s(w, l, h);
|
||||||
|
n = (v0 * s).normalized(); vbo.normals() << n.x() << n.y() << n.z();
|
||||||
|
n = (v1 * s).normalized(); vbo.normals() << n.x() << n.y() << n.z();
|
||||||
|
n = (v2 * s).normalized(); vbo.normals() << n.x() << n.y() << n.z();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GLPrimitiveEllipsoid::init() {
|
||||||
|
QVector<QVector3D> points;
|
||||||
|
vbo.clear();
|
||||||
|
vbo.init();
|
||||||
|
|
||||||
|
int ret = 0, hseg = sh + 1, wlseg = swl + 1;
|
||||||
|
double crw, crl, a, ch, twl;
|
||||||
|
QVector3D cp(0., 0., -h / 2.);
|
||||||
|
points << cp;
|
||||||
|
for (int i = 1; i < hseg; i++) {
|
||||||
|
ch = -cos((double)i / hseg * M_PI);
|
||||||
|
cp.setZ(ch * h / 2.);
|
||||||
|
twl = sqrt(1. - ch * ch) / 2.;
|
||||||
|
crw = twl * w;
|
||||||
|
crl = twl * l;
|
||||||
|
for (int j = 0; j < wlseg * 2; j++) {
|
||||||
|
a = (double)j / wlseg * M_PI;
|
||||||
|
cp.setY(crw * sin(a));
|
||||||
|
cp.setX(crl * cos(a));
|
||||||
|
points << cp;
|
||||||
|
ret = points.size() - 1;
|
||||||
|
if (i == 1)
|
||||||
|
if (j > 0) putTriangle(points[0], points[ret], points[ret - 1]);
|
||||||
|
if (j > 0) {
|
||||||
|
if (i > 1) {
|
||||||
|
putTriangle(points[ret - wlseg * 2 - 1], points[ret], points[ret - 1]);
|
||||||
|
putTriangle(points[ret - wlseg * 2], points[ret], points[ret - wlseg * 2 - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == 1) putTriangle(points[0], points[ret - wlseg * 2 + 1], points[ret]);
|
||||||
|
else {
|
||||||
|
putTriangle(points[ret - wlseg * 2 + 1], points[ret], points[ret - wlseg * 2]);
|
||||||
|
putTriangle(points[ret - wlseg * 2 + 1], points[ret - wlseg * 2], points[ret - wlseg * 4 + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
points << QVector3D(0., 0., h / 2.);
|
||||||
|
ret = points.size() - 1;
|
||||||
|
putTriangle(points[ret - 1], points[ret - wlseg * 2], points[ret]);
|
||||||
|
for (int j = 1; j < wlseg * 2; j++)
|
||||||
|
if (j > 0) putTriangle(points[ret - wlseg * 2 + j - 1], points[ret - wlseg * 2 + j], points[ret]);
|
||||||
|
|
||||||
|
is_init = true;
|
||||||
|
vbo.rebuffer();
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "globject.h"
|
#include "globject.h"
|
||||||
|
|
||||||
|
|
||||||
class GLPrimitivePoint: public GLObjectBase
|
class GLPrimitivePoint: public GLObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -30,6 +31,21 @@ private:
|
|||||||
double sz;
|
double sz;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GLPrimitiveLine: public GLObjectBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GLPrimitiveLine(QVector3D p0_ = QVector3D(), QVector3D p1_ = QVector3D()) {p0 = p0_; p1 = p1_;}
|
||||||
|
virtual void draw(bool simplest = false);
|
||||||
|
private:
|
||||||
|
QVector3D p0, p1;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class GLPrimitiveCube: public GLObjectBase
|
class GLPrimitiveCube: public GLObjectBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -39,4 +55,19 @@ private:
|
|||||||
double w, l, h;
|
double w, l, h;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class GLPrimitiveEllipsoid: public GLObjectBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GLPrimitiveEllipsoid(double width = 1., double length = 1., double height = 1., int seg_wl = 10, int seg_h = 10, QVector3D pos = QVector3D());
|
||||||
|
virtual void init();
|
||||||
|
private:
|
||||||
|
void putTriangle(const QVector3D & v0, const QVector3D & v1, const QVector3D & v2);
|
||||||
|
double w, l, h;
|
||||||
|
int swl, sh;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // GLPRIMITIVE_CUBE_H
|
#endif // GLPRIMITIVE_CUBE_H
|
||||||
|
|||||||
@@ -70,8 +70,12 @@ void createGLTexture(GLuint & tex, int width, int height, const GLenum & format,
|
|||||||
//glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
//glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_COMPONENT16 || format == GL_DEPTH_COMPONENT24 || format == GL_DEPTH_COMPONENT32)
|
if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_COMPONENT16 || format == GL_DEPTH_COMPONENT24 || format == GL_DEPTH_COMPONENT32)
|
||||||
glTexImage2D(target, 0, format, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
|
glTexImage2D(target, 0, format, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0);
|
||||||
else
|
else {
|
||||||
glTexImage2D(target, 0, format, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
|
int t = GL_UNSIGNED_BYTE;
|
||||||
|
if (format == GL_RGB32F || format == GL_RGB16F)
|
||||||
|
t = GL_FLOAT;
|
||||||
|
glTexImage2D(target, 0, format, width, height, 0, GL_RGBA, t, 0);
|
||||||
|
}
|
||||||
//qDebug() << QString::number(glGetError(), 16);
|
//qDebug() << QString::number(glGetError(), 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,14 @@
|
|||||||
#if __QNX__ || __QNXNTO__
|
#if __QNX__ || __QNXNTO__
|
||||||
# define QNX
|
# define QNX
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef __APPLE__
|
||||||
|
# define MAC
|
||||||
|
#endif
|
||||||
#ifndef WINDOWS
|
#ifndef WINDOWS
|
||||||
# ifndef QNX
|
# ifndef QNX
|
||||||
# define LINUX
|
# ifndef MAC
|
||||||
|
# define LINUX
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#if __GNUC__
|
#if __GNUC__
|
||||||
@@ -39,10 +44,16 @@
|
|||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
# include "GLee.h"
|
# include "GLee.h"
|
||||||
#else
|
#else
|
||||||
# include <GL/gl.h>
|
# ifdef MAC
|
||||||
# include <GL/glext.h>
|
# include <OpenGL/gl.h>
|
||||||
|
# include <OpenGL/glu.h>
|
||||||
|
# include <GLUT/glut.h>
|
||||||
|
# else
|
||||||
|
# include <GL/gl.h>
|
||||||
|
# include <GL/glext.h>
|
||||||
|
# include <GL/glu.h>
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#include <GL/glu.h>
|
|
||||||
#include <qgl.h>
|
#include <qgl.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
@@ -79,6 +90,10 @@
|
|||||||
#define M_2PI 6.28318530717958647692
|
#define M_2PI 6.28318530717958647692
|
||||||
#define M_PI_3 1.04719755119659774615
|
#define M_PI_3 1.04719755119659774615
|
||||||
|
|
||||||
|
#ifndef GL_RGBA16F
|
||||||
|
# define GL_RGBA16F GL_RGBA16F_ARB
|
||||||
|
#endif
|
||||||
|
|
||||||
using std::complex;
|
using std::complex;
|
||||||
|
|
||||||
#ifndef PIP_VERSION
|
#ifndef PIP_VERSION
|
||||||
@@ -270,7 +285,6 @@ public:
|
|||||||
QVector3D angles() const {return QVector3D(angle_xy, angle_roll, angle_z);}
|
QVector3D angles() const {return QVector3D(angle_xy, angle_roll, angle_z);}
|
||||||
QVector3D direction() const {return (aim_ - pos_).normalized();}
|
QVector3D direction() const {return (aim_ - pos_).normalized();}
|
||||||
QVector3D directionXY() const {QVector3D tv = aim_ - pos_; return QVector3D(tv.x(), tv.y(), 0.).normalized();}
|
QVector3D directionXY() const {QVector3D tv = aim_ - pos_; return QVector3D(tv.x(), tv.y(), 0.).normalized();}
|
||||||
QVector3D pointFromViewport(int x, int y, double z = 0.);
|
|
||||||
double FOV() const {return fov_;}
|
double FOV() const {return fov_;}
|
||||||
double distance() const {return (pos_ - aim_).length();}
|
double distance() const {return (pos_ - aim_).length();}
|
||||||
double angleZ() const {return angle_z;}
|
double angleZ() const {return angle_z;}
|
||||||
@@ -285,8 +299,9 @@ public:
|
|||||||
void anglesFromPoints();
|
void anglesFromPoints();
|
||||||
void apply(const GLdouble & aspect = 1.);
|
void apply(const GLdouble & aspect = 1.);
|
||||||
void assign(const Camera & c) {pos_ = c.pos_; aim_ = c.aim_; fov_ = c.fov_; angle_z = c.angle_z; angle_xy = c.angle_xy; angle_roll = c.angle_roll; angle_limit_lower_xy = c.angle_limit_lower_xy; angle_limit_upper_xy = c.angle_limit_upper_xy;}
|
void assign(const Camera & c) {pos_ = c.pos_; aim_ = c.aim_; fov_ = c.fov_; angle_z = c.angle_z; angle_xy = c.angle_xy; angle_roll = c.angle_roll; angle_limit_lower_xy = c.angle_limit_lower_xy; angle_limit_upper_xy = c.angle_limit_upper_xy;}
|
||||||
|
QVector3D pointFromViewport(int x_, int y_, double z_);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QVector3D pos_;
|
QVector3D pos_;
|
||||||
QVector3D aim_;
|
QVector3D aim_;
|
||||||
GLdouble fov_;
|
GLdouble fov_;
|
||||||
@@ -297,11 +312,11 @@ private:
|
|||||||
GLdouble angle_roll;
|
GLdouble angle_roll;
|
||||||
GLdouble angle_limit_lower_xy;
|
GLdouble angle_limit_lower_xy;
|
||||||
GLdouble angle_limit_upper_xy;
|
GLdouble angle_limit_upper_xy;
|
||||||
|
GLdouble modelview[16], projection[16];
|
||||||
|
GLint viewport[4];
|
||||||
bool mirror_x;
|
bool mirror_x;
|
||||||
bool mirror_y;
|
bool mirror_y;
|
||||||
GLint viewport[4];
|
|
||||||
GLdouble projection[16];
|
|
||||||
GLdouble modelview[16];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Camera * currentCamera;
|
extern Camera * currentCamera;
|
||||||
@@ -490,7 +505,7 @@ class QGLViewBase
|
|||||||
public:
|
public:
|
||||||
QGLViewBase() {}
|
QGLViewBase() {}
|
||||||
Camera & camera() {return camera_;}
|
Camera & camera() {return camera_;}
|
||||||
void setCamera(const Camera &cam) {camera_ = cam;}
|
void setCamera(const Camera & camera) {camera_ = camera;}
|
||||||
protected:
|
protected:
|
||||||
virtual void collectLights() = 0;
|
virtual void collectLights() = 0;
|
||||||
Camera camera_;
|
Camera camera_;
|
||||||
|
|||||||
@@ -18,15 +18,92 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCleanlooksStyle>
|
#include <QCleanlooksStyle>
|
||||||
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include "mainwindow.h"
|
#include <GL/glew.h>
|
||||||
|
//#include "mainwindow.h"
|
||||||
|
#include "unistd.h"
|
||||||
|
#include <GL/freeglut.h>
|
||||||
|
|
||||||
|
/*void display ()
|
||||||
|
{
|
||||||
|
qDebug() << (const char*)glGetString(GLUT_VERSION);
|
||||||
|
qDebug() << (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
|
||||||
|
usleep(200000);
|
||||||
|
}*/
|
||||||
|
template <typename T, int N>
|
||||||
|
struct garray {
|
||||||
|
garray(T * _i) {for (int i = 0; i < N; ++i) _c[i] = &(_i[i]);}
|
||||||
|
T * _c[N];
|
||||||
|
garray<T, N> & operator =(const garray<T, N> & o) {for (int i = 0; i < N; ++i) *_c[i] = *(o._c[i]); return *this;};
|
||||||
|
template <int ON>
|
||||||
|
garray<T, N> & operator =(const garray<T, ON> & o) {for (int i = 0; i < qMin(N, ON); ++i) *_c[i] = *(o._c[i]); return *this;};
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
class gvec3 {
|
||||||
|
public:
|
||||||
|
gvec3(T def = T()) {x = y = z = def;}
|
||||||
|
union {
|
||||||
|
T xyz[3];
|
||||||
|
struct {T x, y, z;};
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
T _c[3];
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
QDebug operator<<(QDebug d, const gvec3<T> & c) {
|
||||||
|
d.nospace() << "(" << c.x << ", " << c.y << ", " << c.z << ")";
|
||||||
|
return d.space();
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef gvec3<float> vec3;
|
||||||
|
typedef gvec3<int> ivec3;
|
||||||
|
|
||||||
int main(int argc, char ** argv) {
|
int main(int argc, char ** argv) {
|
||||||
|
/*float f[3] = {0., 1., 2.};
|
||||||
|
float f2[3] = {-1., -1., -1.};
|
||||||
|
garray<float, 3> gar(f2);
|
||||||
|
qDebug() << f2[0] << f2[1] << f2[2];
|
||||||
|
gar = garray<float, 3>((float[3]){f[2], f[1], f[0]});
|
||||||
|
qDebug() << f2[0] << f2[1] << f2[2];*/
|
||||||
|
/*vec3 v0, v1(20);
|
||||||
|
v0.y = 10;
|
||||||
|
qDebug() << v0 << v1;*/
|
||||||
|
|
||||||
|
/*glutInit ( &argc, argv );
|
||||||
|
glutInitDisplayMode ( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
|
||||||
|
glutInitWindowSize ( 500, 500 );
|
||||||
|
|
||||||
|
// prepare context for 3.3
|
||||||
|
glutInitContextVersion ( 3, 3 );
|
||||||
|
glutInitContextFlags ( GLUT_FORWARD_COMPATIBLE | GLUT_DEBUG );
|
||||||
|
glutInitContextProfile ( GLUT_CORE_PROFILE );
|
||||||
|
glutCreateWindow ( "Geometry shader example - particles" );
|
||||||
|
glutDisplayFunc ( display );
|
||||||
|
glewInit ();
|
||||||
|
if ( !GLEW_VERSION_3_3 )
|
||||||
|
{
|
||||||
|
printf ( "OpenGL 3.3 not supported.\n" );
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
glutMainLoop();
|
||||||
|
*/
|
||||||
|
return 0;
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
/*QGLFormat f;
|
||||||
|
f.setVersion(3, 3);
|
||||||
|
f.setSampleBuffers(true);
|
||||||
|
f.setProfile(QGLFormat::CoreProfile);
|
||||||
|
QGLFormat::setDefaultFormat(f);*/
|
||||||
//QApplication::setStyle(new QCleanlooksStyle());
|
//QApplication::setStyle(new QCleanlooksStyle());
|
||||||
QDir::setCurrent(a.applicationDirPath());
|
QDir::setCurrent(a.applicationDirPath());
|
||||||
//a.setWindowIcon(QIcon(":/icons/peri4_paint.png"));
|
//a.setWindowIcon(QIcon(":/icons/peri4_paint.png"));
|
||||||
MainWindow w;
|
//MainWindow w;
|
||||||
w.show();
|
//w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,15 +19,19 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <QGraphicsRectItem>
|
#include <QGraphicsRectItem>
|
||||||
|
|
||||||
|
#define EARTH_H 6356863.019 // m
|
||||||
|
#define EARTH_WL 6378245.000 // m
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow() {
|
MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow() {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
colorHalo->setColor(view->selectionHaloColor());
|
colorHalo->setColor(view->selectionHaloColor());
|
||||||
|
|
||||||
sel_obj = 0;
|
sel_obj = 0;
|
||||||
treeProperties->assignObject(view);
|
treeProperties->assignObject(view);
|
||||||
//spinSliderShine->setDecimals(2);
|
//spinSliderShine->setDecimals(2);
|
||||||
view->setFrameShape(QFrame::NoFrame);
|
view->setFrameShape(QFrame::NoFrame);
|
||||||
view->setRenderer(new RendererDeferredShading(view));
|
//view->setRenderer(new RendererDeferredShading(view));
|
||||||
|
view->setRenderer(new RendererSimple(view));
|
||||||
view->setMouseSelectionEnabled(true);
|
view->setMouseSelectionEnabled(true);
|
||||||
view->setMouseRotateEnabled(true);
|
view->setMouseRotateEnabled(true);
|
||||||
view->setBackColor(Qt::lightGray);
|
view->setBackColor(Qt::lightGray);
|
||||||
@@ -36,10 +40,10 @@ MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow()
|
|||||||
o->setWindowOpacity(.666);
|
o->setWindowOpacity(.666);
|
||||||
view->addObject(o, Qt::Window);*/
|
view->addObject(o, Qt::Window);*/
|
||||||
view->start(-1);
|
view->start(-1);
|
||||||
obj = loadFrom3DSFile("data/test.3DS", 0.15);
|
/**obj = loadFrom3DSFile("data/test.3DS", 0.15);
|
||||||
m.reflectivity = 1;
|
m.reflectivity = 1;
|
||||||
m.reflection.loadPathesFromDirectory("data/e");
|
m.reflection.loadPathesFromDirectory("data/e");
|
||||||
obj->child("sphere001")->setMaterial(m);
|
obj->child("sphere001")->setMaterial(m);*/
|
||||||
|
|
||||||
|
|
||||||
//m.shine = 40;
|
//m.shine = 40;
|
||||||
@@ -55,16 +59,41 @@ MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow()
|
|||||||
//obj->child("teapot")->setRenderMode(GLObjectBase::Point);
|
//obj->child("teapot")->setRenderMode(GLObjectBase::Point);
|
||||||
//obj->child("teapot")->setLineWidth(2.);
|
//obj->child("teapot")->setLineWidth(2.);
|
||||||
//obj->child("cone")->setRenderMode(GLObjectBase::Line);
|
//obj->child("cone")->setRenderMode(GLObjectBase::Line);
|
||||||
|
///view->camera().setAim(obj->child("sphere001")->pos());
|
||||||
|
|
||||||
|
obj = new GLPrimitiveEllipsoid(EARTH_WL / 1E+6, EARTH_WL / 1E+6, EARTH_H / 1E+6, 500, 500);//GLPrimitiveCube();
|
||||||
view->addObject(obj);
|
view->addObject(obj);
|
||||||
view->camera().setAim(obj->child("sphere001")->pos());
|
|
||||||
|
double al = 7.;
|
||||||
|
obj = new GLPrimitiveLine(QVector3D(0, 0, -al), QVector3D(0, 0, al));
|
||||||
|
obj->material().color_diffuse = Qt::darkBlue; obj->setAcceptLight(false);
|
||||||
|
view->addObject(obj);
|
||||||
|
obj = new GLPrimitiveLine(QVector3D(-al, 0, 0), QVector3D(al, 0, 0));
|
||||||
|
obj->material().color_diffuse = Qt::darkRed; obj->setAcceptLight(false);
|
||||||
|
view->addObject(obj);
|
||||||
|
obj = new GLPrimitiveLine(QVector3D(0, -al, 0), QVector3D(0, al, 0));
|
||||||
|
obj->material().color_diffuse = Qt::darkGreen; obj->setAcceptLight(false);
|
||||||
|
view->addObject(obj);
|
||||||
|
|
||||||
|
double lat = deg2rad*(-85.), lng = deg2rad*(15.);
|
||||||
|
obj = new GLPrimitiveLine(QVector3D(), QVector3D(cos(lng)*cos(lat), sin(lng)*cos(lat), sin(lat)/*(EARTH_H/EARTH_WL)*/)*5);
|
||||||
|
view->addObject(obj);
|
||||||
|
|
||||||
view->camera().setPos(QVector3D(10, -20, 20));
|
view->camera().setPos(QVector3D(10, -20, 20));
|
||||||
|
view->camera().setAim(QVector3D());
|
||||||
view->camera().flyToDistance(10);
|
view->camera().flyToDistance(10);
|
||||||
|
view->setMouseSelectionEnabled(false);
|
||||||
|
view->setSelectionHaloEnabled(false);
|
||||||
|
view->setHoverHaloEnabled(false);
|
||||||
|
Light * l = new Light(view->camera().pos());
|
||||||
|
l->intensity = 0.8;
|
||||||
|
view->addObject(l);
|
||||||
//view->light(0)->light_type = Light::Omni;
|
//view->light(0)->light_type = Light::Omni;
|
||||||
//obj = loadFrom3DSFile("34.3DS", 0.03);
|
//obj = loadFrom3DSFile("34.3DS", 0.03);
|
||||||
//view->addObject(obj);
|
//view->addObject(obj);
|
||||||
//view->camera().moveUp(5, true);
|
//view->camera().moveUp(5, true);
|
||||||
|
|
||||||
ps = new GLParticlesSystem(QVector3D(0,0,5));
|
/**ps = new GLParticlesSystem(QVector3D(0,0,5));
|
||||||
ps->setEmitterType(GLParticlesSystem::Box);
|
ps->setEmitterType(GLParticlesSystem::Box);
|
||||||
ps->setBirthRate(5);
|
ps->setBirthRate(5);
|
||||||
ps->setSize(1.);
|
ps->setSize(1.);
|
||||||
@@ -74,17 +103,17 @@ MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow()
|
|||||||
ps->setSpeedDirectionJitter(1);
|
ps->setSpeedDirectionJitter(1);
|
||||||
//ps->setTextureScale(2, 2);
|
//ps->setTextureScale(2, 2);
|
||||||
ps->setAddVerticalFaceEnabled(true);
|
ps->setAddVerticalFaceEnabled(true);
|
||||||
ps->addForce(QVector3D(0,0,-0.98/20));
|
ps->addForce(QVector3D(0,0,-0.98/20));*/
|
||||||
//ps->material().diffuse.bitmap_path = "expl_07.png";
|
//ps->material().diffuse.bitmap_path = "expl_07.png";
|
||||||
//view->addObject(ps);
|
//view->addObject(ps);
|
||||||
|
|
||||||
box = new GLPrimitiveCube();
|
/**box = new GLPrimitiveCube();
|
||||||
box->setSelectable(false);
|
box->setSelectable(false);
|
||||||
box->setRenderMode(GLObjectBase::Line);
|
box->setRenderMode(GLObjectBase::Line);
|
||||||
box->setLineWidth(2.);
|
box->setLineWidth(2.);
|
||||||
view->addObject(box);
|
view->addObject(box);
|
||||||
box->hide();
|
box->hide();*/
|
||||||
while (view->lightsCount() >= 3) view->removeLight(view->lightsCount() - 1);
|
while (view->lightsCount() >= 5) view->removeLight(view->lightsCount() - 1);
|
||||||
//view->addObject(box);
|
//view->addObject(box);
|
||||||
|
|
||||||
//obj = obj->clone(true);
|
//obj = obj->clone(true);
|
||||||
@@ -103,7 +132,7 @@ MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow()
|
|||||||
}*/
|
}*/
|
||||||
startTimer(1000/60);
|
startTimer(1000/60);
|
||||||
|
|
||||||
connect(view, SIGNAL(hoverChanged(GLObjectBase*,GLObjectBase*)), this, SLOT(hoverChanged(GLObjectBase*,GLObjectBase*)));
|
//connect(view, SIGNAL(hoverChanged(GLObjectBase*,GLObjectBase*)), this, SLOT(hoverChanged(GLObjectBase*,GLObjectBase*)));
|
||||||
connect(view, SIGNAL(selectionChanged(GLObjectBase*,GLObjectBase*)), this, SLOT(selectionChanged(GLObjectBase*,GLObjectBase*)));
|
connect(view, SIGNAL(selectionChanged(GLObjectBase*,GLObjectBase*)), this, SLOT(selectionChanged(GLObjectBase*,GLObjectBase*)));
|
||||||
connect(view, SIGNAL(glInitializeDone()), this, SLOT(glInit()));
|
connect(view, SIGNAL(glInitializeDone()), this, SLOT(glInit()));
|
||||||
connect(matEditor, SIGNAL(changed()), this, SLOT(materialChanged()));
|
connect(matEditor, SIGNAL(changed()), this, SLOT(materialChanged()));
|
||||||
@@ -114,7 +143,7 @@ MainWindow::MainWindow(QWidget * parent): QMainWindow(parent), Ui::MainWindow()
|
|||||||
|
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
delete ps;
|
//delete ps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -129,6 +158,8 @@ void MainWindow::changeEvent(QEvent * e) {
|
|||||||
|
|
||||||
void MainWindow::timerEvent(QTimerEvent * ) {
|
void MainWindow::timerEvent(QTimerEvent * ) {
|
||||||
static double t = 0.;
|
static double t = 0.;
|
||||||
|
view->light(0)->setPos(view->camera().pos());
|
||||||
|
((RendererSimple*)(view->renderer()))->mpos = view->mapFromGlobal(QCursor::pos());
|
||||||
/*obj->child("tor")->rotateX(0.5);
|
/*obj->child("tor")->rotateX(0.5);
|
||||||
obj->child("tor")->rotateZ(0.1);
|
obj->child("tor")->rotateZ(0.1);
|
||||||
obj->child("cone")->rotateZ(1);
|
obj->child("cone")->rotateZ(1);
|
||||||
@@ -169,7 +200,7 @@ void MainWindow::selectionChanged(GLObjectBase * cur, GLObjectBase * prev) {
|
|||||||
sel_obj = cur;
|
sel_obj = cur;
|
||||||
//qDebug() << "selected" << (cur != 0 ? cur->name() : "0");
|
//qDebug() << "selected" << (cur != 0 ? cur->name() : "0");
|
||||||
labelName->setText(cur != 0 ? cur->name() : "");
|
labelName->setText(cur != 0 ? cur->name() : "");
|
||||||
if (cur == 0) box->hide();
|
/**if (cur == 0) box->hide();
|
||||||
else {
|
else {
|
||||||
box->setScale(cur->boundingBox().size());
|
box->setScale(cur->boundingBox().size());
|
||||||
box->setPos(cur->boundingBox().pos());
|
box->setPos(cur->boundingBox().pos());
|
||||||
@@ -178,7 +209,7 @@ void MainWindow::selectionChanged(GLObjectBase * cur, GLObjectBase * prev) {
|
|||||||
ps->setEmitterRect(b);
|
ps->setEmitterRect(b);
|
||||||
cur->addChild(box);
|
cur->addChild(box);
|
||||||
box->show();
|
box->show();
|
||||||
}
|
}*/
|
||||||
objectEditor->setObject(sel_obj);
|
objectEditor->setObject(sel_obj);
|
||||||
if (sel_obj == 0) return;
|
if (sel_obj == 0) return;
|
||||||
matEditor->setMaterial(sel_obj->material());
|
matEditor->setMaterial(sel_obj->material());
|
||||||
|
|||||||
@@ -19,8 +19,25 @@
|
|||||||
#include "renderer_simple.h"
|
#include "renderer_simple.h"
|
||||||
|
|
||||||
|
|
||||||
RendererSimple::RendererSimple(QGLView * view_): GLRendererBase(view_), fbo(2) {
|
RendererSimple::RendererSimple(QGLView * view_): GLRendererBase(view_), fbo(2)
|
||||||
|
, fbo_c(1, true, GL_RGBA32F) /// WARNING
|
||||||
|
{
|
||||||
shader_fxaa = 0;
|
shader_fxaa = 0;
|
||||||
|
shader = 0; /// WARNING
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RendererSimple::reloadShaders() {
|
||||||
|
if (shader_fxaa == 0) shader_fxaa = new QGLShaderProgram(view.context());
|
||||||
|
loadShaders(shader_fxaa, "FXAA", "shaders");
|
||||||
|
if (shader == 0) shader = new QGLShaderProgram(view.context()); /// WARNING
|
||||||
|
loadShaders(shader, "test", "shaders"); /// WARNING
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RendererSimple::resizeFBO(int w, int h) {
|
||||||
|
fbo.resize(w, h);
|
||||||
|
fbo_c.resize(w, h); /// WARNING
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -52,9 +69,25 @@ void RendererSimple::renderScene() {
|
|||||||
}
|
}
|
||||||
view.camera().apply(view.aspect);
|
view.camera().apply(view.aspect);
|
||||||
setupLights(l, 8);
|
setupLights(l, 8);
|
||||||
//glEnable(GL_MULTISAMPLE);
|
|
||||||
|
|
||||||
|
fbo_c.bind();
|
||||||
|
glClearFramebuffer();
|
||||||
|
shader->bind(); /// WARNING
|
||||||
renderObjects(GLObjectBase::Solid, l, 0, true, true, view.isFogEnabled());
|
renderObjects(GLObjectBase::Solid, l, 0, true, true, view.isFogEnabled());
|
||||||
renderObjects(GLObjectBase::Transparent, l, 0, true, true, view.isFogEnabled());
|
shader->release(); /// WARNING
|
||||||
|
if (QRect(QPoint(), fbo_c.size()).contains(mpos)) {
|
||||||
|
//qDebug() << mpos;
|
||||||
|
GLfloat data[4] = {0, 0, 0, 0};
|
||||||
|
glReadPixels(mpos.x(), fbo_c.height() - mpos.y(), 1, 1, GL_RGBA, GL_FLOAT, data);
|
||||||
|
qDebug() << QVector3D(data[0], data[1], data[2]);
|
||||||
|
}
|
||||||
|
fbo_c.release();
|
||||||
|
renderObjects(GLObjectBase::Solid, l, 0, true, true, view.isFogEnabled());
|
||||||
|
|
||||||
|
|
||||||
|
//renderObjects(GLObjectBase::Solid, l, 0, true, true, view.isFogEnabled());
|
||||||
|
//renderObjects(GLObjectBase::Transparent, l, 0, true, true, view.isFogEnabled());
|
||||||
if (passes > 1) {
|
if (passes > 1) {
|
||||||
glSetLightEnabled(false);
|
glSetLightEnabled(false);
|
||||||
glSetCapEnabled(GL_BLEND);
|
glSetCapEnabled(GL_BLEND);
|
||||||
|
|||||||
@@ -28,15 +28,19 @@ public:
|
|||||||
virtual ~RendererSimple() {if (shader_fxaa != 0) delete shader_fxaa;}
|
virtual ~RendererSimple() {if (shader_fxaa != 0) delete shader_fxaa;}
|
||||||
|
|
||||||
virtual void renderScene();
|
virtual void renderScene();
|
||||||
|
|
||||||
|
QPoint mpos;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void init(int width, int height) {fbo.resize(width, height);}
|
virtual void init(int width, int height) {resizeFBO(width, height);}
|
||||||
virtual void resize(int width, int height) {fbo.resize(width, height);}
|
virtual void resize(int width, int height) {resizeFBO(width, height);}
|
||||||
virtual void reloadShaders() {if (shader_fxaa == 0) shader_fxaa = new QGLShaderProgram(view.context()); loadShaders(shader_fxaa, "FXAA", "shaders");}
|
virtual void reloadShaders();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GLFramebuffer fbo;
|
void resizeFBO(int w, int h);
|
||||||
QGLShaderProgram * shader_fxaa;
|
|
||||||
|
GLFramebuffer fbo , fbo_c;
|
||||||
|
QGLShaderProgram * shader_fxaa , * shader;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user