android fix, add export to CSV current view
This commit is contained in:
@@ -98,15 +98,12 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
|
||||
ui->widgetLeft->hide();
|
||||
ui->widgetRight->hide();
|
||||
QList<QToolButton *> btnlist = {ui->graphic_buttonAutofit,
|
||||
ui->graphic_checkGrid,
|
||||
ui->graphic_checkGuides,
|
||||
ui->graphic_buttonFullscreen,
|
||||
ui->graphic_checkBorderInputs,
|
||||
ui->graphic_checkLegend,
|
||||
ui->graphic_checkPause,
|
||||
ui->graphic_buttonConfigure,
|
||||
ui->graphic_buttonSave,
|
||||
ui->graphic_buttonExport,
|
||||
ui->graphic_buttonRecord,
|
||||
ui->graphic_buttonClear,
|
||||
ui->graphic_buttonClose};
|
||||
@@ -132,6 +129,7 @@ Graphic::Graphic(QWidget * parent): QFrame(parent), canvas(0), line_x_min(this),
|
||||
ui->graphic_buttonAutofit->addAction(ui->graphic_actionExpandY);
|
||||
ui->graphic_buttonSaveMenu->addAction(ui->graphic_actionSaveImage);
|
||||
ui->graphic_buttonSaveMenu->addAction(ui->graphic_actionExportCSV);
|
||||
ui->graphic_buttonSaveMenu->addAction(ui->graphic_actionExportCSV_View);
|
||||
line_x_min.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
line_x_max.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
((QBoxLayout *)ui->widgetLY->layout())->insertWidget(0, &line_y_min);
|
||||
@@ -927,6 +925,7 @@ void Graphic::setButtons(Graphic::Buttons b) {
|
||||
ui->graphic_buttonConfigure->setVisible(b.testFlag(Configure));
|
||||
ui->graphic_buttonSaveMenu->setVisible(b.testFlag(Save) || b.testFlag(Export));
|
||||
ui->graphic_actionExportCSV->setVisible(b.testFlag(Export));
|
||||
ui->graphic_actionExportCSV_View->setVisible(b.testFlag(Export));
|
||||
ui->graphic_actionSaveImage->setVisible(b.testFlag(Save));
|
||||
ui->graphic_buttonClose->setVisible(b.testFlag(Close));
|
||||
ui->graphic_checkPause->setVisible(b.testFlag(Pause));
|
||||
@@ -1143,7 +1142,7 @@ void Graphic::saveImage(QString filename) {
|
||||
}
|
||||
|
||||
|
||||
void Graphic::exportGraphics(QString filename, QChar decimal_point) {
|
||||
void Graphic::exportGraphics(QString filename, QChar decimal_point, bool view_only) {
|
||||
ppath = filename;
|
||||
QFile f(filename);
|
||||
if (!f.open(QIODevice::ReadWrite)) {
|
||||
@@ -1160,6 +1159,20 @@ void Graphic::exportGraphics(QString filename, QChar decimal_point) {
|
||||
ts << ";" << (g.name + " " + (label_x.isEmpty() ? "X" : label_x)) << ";" << (g.name + " " + (label_y.isEmpty() ? "Y" : label_y));
|
||||
}
|
||||
ts << "\n";
|
||||
QVector<GraphicType> view_gr;
|
||||
auto * source = &graphics;
|
||||
if (view_only) {
|
||||
for (const auto & g: graphics) {
|
||||
GraphicType gt;
|
||||
gt.visible = g.visible;
|
||||
gt.polyline.reserve(g.polyline.size() / 8);
|
||||
for (const auto & i: g.polyline) {
|
||||
if (selrect.contains(i)) gt.polyline << i;
|
||||
}
|
||||
view_gr << gt;
|
||||
}
|
||||
source = &view_gr;
|
||||
}
|
||||
bool has_data = true;
|
||||
int ind = 0;
|
||||
QString line;
|
||||
@@ -1167,8 +1180,8 @@ void Graphic::exportGraphics(QString filename, QChar decimal_point) {
|
||||
has_data = false;
|
||||
line.clear();
|
||||
line += QString::number(ind + 1);
|
||||
for (int i = 0; i < graphics.size(); ++i) {
|
||||
GraphicType & g(graphics[i]);
|
||||
for (int i = 0; i < source->size(); ++i) {
|
||||
const GraphicType & g(source->at(i));
|
||||
if (!g.visible) continue;
|
||||
if (ind >= g.polyline.size()) {
|
||||
line += ";;";
|
||||
@@ -1679,6 +1692,18 @@ void Graphic::fillDateFormats() {
|
||||
}
|
||||
|
||||
|
||||
void Graphic::askForExport(bool view_only) {
|
||||
QString f = QFileDialog::getSaveFileName(this, tr("Export graphics"), ppath, "CSV(*.csv)");
|
||||
if (f.isEmpty()) return;
|
||||
QStringList items;
|
||||
items << "."
|
||||
<< ",";
|
||||
bool ok;
|
||||
QString item = QInputDialog::getItem(this, tr("Select decimal point"), tr("Decimal point:"), items, 0, false, &ok);
|
||||
if (ok && !item.isEmpty()) exportGraphics(f, item.front(), view_only);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::drawGraphics() {
|
||||
if (isHover && ui->status->isVisible()) {
|
||||
ui->status->setText(tr("Cursor: ") + pointCoords(canvas2real(QPointF(curpos))));
|
||||
@@ -1997,34 +2022,34 @@ void Graphic::addDateTime(QDateTime & dt, int * c, qint64 mul) {
|
||||
|
||||
|
||||
double Graphic::canvas2realX(double px) const {
|
||||
int gbx = gridborder.x() + margins_.left();
|
||||
int wid = lastw - gbx - margins_.width();
|
||||
double cx = px - gbx;
|
||||
int gbx = gridborder.x() + margins_.left();
|
||||
int wid = lastw - gbx - margins_.width();
|
||||
double cx = px - gbx;
|
||||
double sclx = selrect.width() / (double)wid;
|
||||
return cx * sclx + selrect.x();
|
||||
}
|
||||
|
||||
|
||||
double Graphic::canvas2realY(double py) const {
|
||||
int gby = gridborder.y() + margins_.top();
|
||||
int hei = lasth - gby - margins_.height();
|
||||
double cy = lasth - py - gby;
|
||||
int gby = gridborder.y() + margins_.top();
|
||||
int hei = lasth - gby - margins_.height();
|
||||
double cy = lasth - py - gby;
|
||||
double scly = selrect.height() / (double)hei;
|
||||
return cy * scly + selrect.y();
|
||||
}
|
||||
|
||||
|
||||
double Graphic::real2canvasX(double px) const {
|
||||
int gbx = gridborder.x() + margins_.left();
|
||||
int wid = lastw - gbx - margins_.width();
|
||||
int gbx = gridborder.x() + margins_.left();
|
||||
int wid = lastw - gbx - margins_.width();
|
||||
double sclx = selrect.width() / (double)wid;
|
||||
return (px - selrect.x()) / sclx + gbx;
|
||||
}
|
||||
|
||||
|
||||
double Graphic::real2canvasY(double py) const {
|
||||
int gby = gridborder.y() + margins_.top();
|
||||
int hei = lasth - gby - margins_.height();
|
||||
int gby = gridborder.y() + margins_.top();
|
||||
int hei = lasth - gby - margins_.height();
|
||||
double scly = selrect.height() / (double)hei;
|
||||
return lasth - gby - (py - selrect.y()) / scly;
|
||||
}
|
||||
@@ -2307,14 +2332,12 @@ void Graphic::on_graphic_actionSaveImage_triggered() {
|
||||
|
||||
|
||||
void Graphic::on_graphic_actionExportCSV_triggered() {
|
||||
QString f = QFileDialog::getSaveFileName(this, tr("Export graphics"), ppath, "CSV(*.csv)");
|
||||
if (f.isEmpty()) return;
|
||||
QStringList items;
|
||||
items << "."
|
||||
<< ",";
|
||||
bool ok;
|
||||
QString item = QInputDialog::getItem(this, tr("Select decimal point"), tr("Decimal point:"), items, 0, false, &ok);
|
||||
if (ok && !item.isEmpty()) exportGraphics(f, item.front());
|
||||
askForExport(false);
|
||||
}
|
||||
|
||||
|
||||
void Graphic::on_graphic_actionExportCSV_View_triggered() {
|
||||
askForExport(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ public:
|
||||
GraphicsData graphicsData() const;
|
||||
QByteArray graphicsDataRaw() const;
|
||||
QWidget * viewport() const { return canvas; }
|
||||
|
||||
|
||||
QByteArray save();
|
||||
void load(QByteArray ba);
|
||||
|
||||
@@ -372,7 +372,7 @@ public slots:
|
||||
void setDefaultRect(const QRectF & rect);
|
||||
void autofit();
|
||||
void saveImage(QString filename);
|
||||
void exportGraphics(QString filename, QChar decimal_point);
|
||||
void exportGraphics(QString filename, QChar decimal_point, bool view_only = false);
|
||||
void clear();
|
||||
void update();
|
||||
void updateGraphics();
|
||||
@@ -432,6 +432,7 @@ protected:
|
||||
QString pointCoords(QPointF point, bool x = true, bool y = true);
|
||||
QPair<QString, QString> gridMark(double v) const;
|
||||
void fillDateFormats();
|
||||
void askForExport(bool view_only);
|
||||
|
||||
Ui::Graphic * ui;
|
||||
UGLWidget * canvas_gl;
|
||||
@@ -498,6 +499,7 @@ protected slots:
|
||||
void on_graphic_buttonFullscreen_clicked();
|
||||
void on_graphic_actionSaveImage_triggered();
|
||||
void on_graphic_actionExportCSV_triggered();
|
||||
void on_graphic_actionExportCSV_View_triggered();
|
||||
void on_graphic_buttonRecord_clicked(bool checked);
|
||||
void on_graphic_checkGuides_toggled(bool checked);
|
||||
void on_graphic_actionExpandX_triggered(bool checked);
|
||||
|
||||
@@ -468,6 +468,18 @@
|
||||
<string>Export to CSV...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="graphic_actionExportCSV_View">
|
||||
<property name="icon">
|
||||
<iconset resource="../blockview/qad_blockview.qrc">
|
||||
<normaloff>:/icons/document-edit.png</normaloff>:/icons/document-edit.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Export to CSV current view ...</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Export to CSV current view</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
||||
Reference in New Issue
Block a user