git-svn-id: svn://db.shs.com.ru/libs@386 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -18,7 +18,7 @@ CDType::CDType() {
|
||||
cd_type_ = cdNull;
|
||||
parent = 0;
|
||||
avg_size = 1;
|
||||
mode_ = X_Current;
|
||||
mode_ = rmode_ = X_Current;
|
||||
// debug_cnt = cdtype_debug_cnt;
|
||||
// cdtype_debug_cnt++;
|
||||
// piCout << "[CDType]" << "create Null" << debug_cnt;
|
||||
@@ -41,7 +41,7 @@ CDType::CDType(int i, const PIString & n, const PIString & t, const PIString & v
|
||||
calculated = x_enabled = false;
|
||||
parent = 0;
|
||||
avg_size = 1;
|
||||
mode_ = X_Current;
|
||||
mode_ = rmode_ = X_Current;
|
||||
if (type_ == "e") {
|
||||
enum_values = parseEnumComment(comment_);
|
||||
// piCout << enum_values.size() << enum_values;
|
||||
@@ -122,7 +122,8 @@ PIStringList CDType::pathString() const {
|
||||
void CDType::readX(PIByteArray & ba) {
|
||||
if (ba.size() < 5) return;
|
||||
uchar t(0); ba >> t;
|
||||
switch ((XMode)t) {
|
||||
rmode_ = (XMode)t;
|
||||
switch (rmode_) {
|
||||
case X_Current:
|
||||
ba >> value_d;
|
||||
break;
|
||||
|
||||
@@ -59,6 +59,7 @@ public:
|
||||
void setXMode(XMode mode) {mode_ = mode;}
|
||||
void setAvg(int avg) {avg_size = avg;}
|
||||
XMode xmode() const {return mode_;}
|
||||
XMode xmode_rec() const {return rmode_;}
|
||||
int avg() const {return avg_size;}
|
||||
bool isSelectedX() const {return x_enabled;}
|
||||
void readX(PIByteArray & ba);
|
||||
@@ -81,7 +82,7 @@ protected:
|
||||
bool value_b, calculated, x_enabled;
|
||||
PIVector<double> avg_h;
|
||||
int avg_size;
|
||||
XMode mode_;
|
||||
XMode mode_, rmode_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -44,6 +44,11 @@ PIVector<PIDeque<int> > XInterface::enabledList() const {
|
||||
}
|
||||
|
||||
|
||||
void XInterface::setEnabledList(const PIVector<PIDeque<int> > & l) {
|
||||
CDCore::instance()->x_selected = l;
|
||||
}
|
||||
|
||||
|
||||
void XInterface::lock() {
|
||||
CDCore::instance()->x_mutex.lock();
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
void setEnabled(const CDType & x, bool en);
|
||||
void setDisabled(const CDType & x, bool dis) {setEnabled(x, !dis);}
|
||||
PIVector<PIDeque<int> > enabledList() const;
|
||||
void setEnabledList(const PIVector<PIDeque<int> > & l);
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
|
||||
@@ -16,6 +16,24 @@
|
||||
using namespace CDUtils;
|
||||
|
||||
|
||||
QStringList CDUtils::getList(const PIVector<PIDeque<int> > & x_list) {
|
||||
QStringList ret;
|
||||
piForeachC (PIDeque<int> & p, x_list)
|
||||
ret << PI2QString(CDCore::pathToString(p));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
PIVector<PIDeque<int> > CDUtils::setList(const QStringList & l) {
|
||||
PIVector<PIDeque<int> > ret;
|
||||
foreach (QString s, l)
|
||||
ret << CDCore::stringToPath(Q2PIString(s));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
GDockWidget::GDockWidget(QString title, QMainWindow * p): QDockWidget(title, p) {
|
||||
da = p;
|
||||
menu = new QMenu(this);
|
||||
@@ -56,6 +74,33 @@ void GDockWidget::drawX(const PIMap<PIString, PIVector<double> > & data) {
|
||||
}
|
||||
|
||||
|
||||
QByteArray GDockWidget::save() const {
|
||||
ChunkStream cs;
|
||||
cs.add(1, windowTitle())
|
||||
.add(2, getList(x_list))
|
||||
.add(3, graphic->graphic->save())
|
||||
.add(4, graphic->evalHistory->expression())
|
||||
.add(5, graphic->evalVisible->expression());
|
||||
return cs.data();
|
||||
}
|
||||
|
||||
|
||||
void GDockWidget::load(QByteArray ba) {
|
||||
if (ba.isEmpty()) return;
|
||||
ChunkStream cs(ba);
|
||||
while (!cs.atEnd()) {
|
||||
switch (cs.read()) {
|
||||
case 1: setWindowTitle(cs.getData<QString>()); break;
|
||||
case 2: x_list = setList(cs.getData<QStringList>()); break;
|
||||
case 3: graphic->graphic->load(cs.getData<QByteArray>()); break;
|
||||
case 4: graphic->evalHistory->setExpression(cs.getData<QString>()); break;
|
||||
case 5: graphic->evalVisible->setExpression(cs.getData<QString>()); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool GDockWidget::eventFilter(QObject * o, QEvent * e) {
|
||||
//if (o == graphic->viewport()) {
|
||||
switch (e->type()) {
|
||||
@@ -151,6 +196,52 @@ CDGraphics::~CDGraphics() {
|
||||
|
||||
|
||||
void CDGraphics::reset() {
|
||||
qDeleteAll(docks);
|
||||
docks.clear();
|
||||
}
|
||||
|
||||
|
||||
QByteArray CDGraphics::save() const {
|
||||
ChunkStream cs;
|
||||
QVector<QByteArray> dstates;
|
||||
foreach (GDockWidget * d, docks) {
|
||||
dstates << d->save();
|
||||
}
|
||||
cs.add(1, docks.size())
|
||||
.add(2, dstates)
|
||||
.add(3, da->saveState());
|
||||
X.lock();
|
||||
cs.add(4, getList(X.enabledList()));
|
||||
X.unlock();
|
||||
return cs.data();
|
||||
}
|
||||
|
||||
|
||||
void CDGraphics::load(QByteArray ba) {
|
||||
reset();
|
||||
if (ba.isEmpty()) return;
|
||||
ChunkStream cs(ba);
|
||||
while (!cs.atEnd()) {
|
||||
switch (cs.read()) {
|
||||
case 1: {
|
||||
int s = cs.getData<int>();
|
||||
piForTimes (s)
|
||||
addGraphic();
|
||||
} break;
|
||||
case 2: {
|
||||
QVector<QByteArray> dstates = cs.getData<QVector<QByteArray> >();
|
||||
for (int i = 0; i < piMini(dstates.size(), docks.size()); ++i)
|
||||
docks[i]->load(dstates[i]);
|
||||
} break;
|
||||
case 3: da->restoreState(cs.getData<QByteArray>()); break;
|
||||
case 4:
|
||||
X.lock();
|
||||
X.setEnabledList(setList(cs.getData<QStringList>()));
|
||||
X.unlock();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -168,6 +259,8 @@ void CDGraphics::addGraphic() {
|
||||
connect(dw, SIGNAL(removeRequest()), this, SLOT(removeGraphic()));
|
||||
da->addDockWidget(Qt::RightDockWidgetArea, dw);
|
||||
docks << dw;
|
||||
for (int i = 0; i < docks.size(); ++i)
|
||||
docks[i]->setObjectName(QString("dock_%1").arg(i));
|
||||
}
|
||||
|
||||
|
||||
@@ -178,13 +271,14 @@ void CDGraphics::receivedX() {
|
||||
PIVector<double> ch;
|
||||
piForeachC (PIDeque<int> & p, x_list) {
|
||||
CDType & t(X[p]);
|
||||
if (t.xmode() == CDType::X_Current)
|
||||
ch.resize(1, t.toDouble());
|
||||
if (t.xmode_rec() == CDType::X_Current)
|
||||
ch.resize(1).fill(t.toDouble());
|
||||
else
|
||||
ch = t.history;
|
||||
t.history.clear();
|
||||
data[CDCore::pathToString(t.path())] = ch;
|
||||
}
|
||||
//piCout << data;
|
||||
X.unlock();
|
||||
foreach (GDockWidget * d, docks)
|
||||
d->drawX(data);
|
||||
@@ -196,6 +290,8 @@ void CDGraphics::removeGraphic() {
|
||||
if (!d) return;
|
||||
docks.removeAll(d);
|
||||
d->deleteLater();
|
||||
for (int i = 0; i < docks.size(); ++i)
|
||||
docks[i]->setObjectName(QString("dock_%1").arg(i));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
namespace CDUtils {
|
||||
class CDType;
|
||||
class CDSection;
|
||||
QStringList getList(const PIVector<PIDeque<int> > & x_list);
|
||||
PIVector<PIDeque<int> > setList(const QStringList & l);
|
||||
}
|
||||
|
||||
class QMainWindow;
|
||||
@@ -26,6 +28,8 @@ public:
|
||||
|
||||
void addX(const CDUtils::CDType & t);
|
||||
void drawX(const PIMap<PIString, PIVector<double> > & data);
|
||||
QByteArray save() const;
|
||||
void load(QByteArray ba);
|
||||
|
||||
CDGraphicWidget * graphic;
|
||||
|
||||
@@ -59,6 +63,8 @@ public:
|
||||
~CDGraphics();
|
||||
|
||||
void reset();
|
||||
QByteArray save() const;
|
||||
void load(QByteArray ba);
|
||||
|
||||
private:
|
||||
GDockWidget * graphicDock(Graphic * o) const;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "edockwidget.h"
|
||||
#include "cdpultwindow.h"
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_core.h"
|
||||
#include "cdutils_k.h"
|
||||
#include "cdutils_x.h"
|
||||
#include "qcd_core.h"
|
||||
#include "qcd_view.h"
|
||||
#include "qcd_model.h"
|
||||
@@ -79,6 +80,7 @@ bool CDPultWindow::load(const QString & path) {
|
||||
checkHasK->setChecked(conf.getValue("has_k"));
|
||||
checkHasX->setChecked(conf.getValue("has_x"));
|
||||
checkHasC->setChecked(conf.getValue("has_c"));
|
||||
session_gr = conf.getValue("session_gr", QByteArray());
|
||||
setChanged(false);
|
||||
file_name = path;
|
||||
return true;
|
||||
@@ -86,6 +88,7 @@ bool CDPultWindow::load(const QString & path) {
|
||||
|
||||
|
||||
bool CDPultWindow::save(const QString & path) {
|
||||
session_gr = widgetGraphics->save();
|
||||
QPIConfig conf(path, QIODevice::ReadWrite);
|
||||
conf.clear();
|
||||
conf.setValue("file_k", editFileK->value().value<QAD::File>().file);
|
||||
@@ -96,6 +99,7 @@ bool CDPultWindow::save(const QString & path) {
|
||||
conf.setValue("has_k", checkHasK->isChecked());
|
||||
conf.setValue("has_x", checkHasX->isChecked());
|
||||
conf.setValue("has_c", checkHasC->isChecked());
|
||||
conf.setValue("session_gr", session_gr);
|
||||
file_name = path;
|
||||
return true;
|
||||
|
||||
@@ -156,6 +160,7 @@ void CDPultWindow::on_editFileK_valueChanged(const QVariant & p) {
|
||||
|
||||
|
||||
void CDPultWindow::on_buttonSessionApply_clicked() {
|
||||
// with session or not
|
||||
widgetK->setFile(editFileK->value().value<QAD::File>().file);
|
||||
widgetX->setFile(editFileX->value().value<QAD::File>().file);
|
||||
widgetC->setFile(editFileC->value().value<QAD::File>().file);
|
||||
@@ -163,6 +168,14 @@ void CDPultWindow::on_buttonSessionApply_clicked() {
|
||||
dockCDXView->setVisible(checkHasX->isChecked());
|
||||
dockCDCView->setVisible(checkHasC->isChecked());
|
||||
widgetX->view->startX();
|
||||
widgetGraphics->load(session_gr);
|
||||
X.lock();
|
||||
PIVector<PIDeque<int> > x_list = X.enabledList();
|
||||
X.unlock();
|
||||
piForeachC (PIDeque<int> & p, x_list)
|
||||
X.enable(X[p]);
|
||||
((CDItemModel*)widgetX->view->model())->updateModel();
|
||||
widgetX->view->expandAll();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ private:
|
||||
|
||||
Ribbon * ribbon;
|
||||
QMap<CDViewWidget::LogIcon, QIcon> log_icons;
|
||||
QByteArray session_gr;
|
||||
|
||||
private slots:
|
||||
void addToLog(CDViewWidget::LogIcon icon, const QString & msg);
|
||||
|
||||
@@ -300,6 +300,7 @@ void CDView::cd_receivedX() {
|
||||
//piCout << t.path();
|
||||
if (t.cd_type() != CDType::cdX) continue;
|
||||
update(model_->indexByPath(t.path(), cValue));
|
||||
//piCout << CDCore::pathToString(t.path()) << t.toDouble() << "model";
|
||||
//qDebug() << "val" << model_->data(model_->indexByPath(t.path(), cValue), Qt::DisplayRole).toDouble();
|
||||
}
|
||||
X.unlock();
|
||||
|
||||
Reference in New Issue
Block a user