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->widgetLeft->hide();
|
||||||
ui->widgetRight->hide();
|
ui->widgetRight->hide();
|
||||||
QList<QToolButton *> btnlist = {ui->graphic_buttonAutofit,
|
QList<QToolButton *> btnlist = {ui->graphic_buttonAutofit,
|
||||||
ui->graphic_checkGrid,
|
|
||||||
ui->graphic_checkGuides,
|
ui->graphic_checkGuides,
|
||||||
ui->graphic_buttonFullscreen,
|
ui->graphic_buttonFullscreen,
|
||||||
ui->graphic_checkBorderInputs,
|
ui->graphic_checkBorderInputs,
|
||||||
ui->graphic_checkLegend,
|
ui->graphic_checkLegend,
|
||||||
ui->graphic_checkPause,
|
ui->graphic_checkPause,
|
||||||
ui->graphic_buttonConfigure,
|
ui->graphic_buttonConfigure,
|
||||||
ui->graphic_buttonSave,
|
|
||||||
ui->graphic_buttonExport,
|
|
||||||
ui->graphic_buttonRecord,
|
ui->graphic_buttonRecord,
|
||||||
ui->graphic_buttonClear,
|
ui->graphic_buttonClear,
|
||||||
ui->graphic_buttonClose};
|
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_buttonAutofit->addAction(ui->graphic_actionExpandY);
|
||||||
ui->graphic_buttonSaveMenu->addAction(ui->graphic_actionSaveImage);
|
ui->graphic_buttonSaveMenu->addAction(ui->graphic_actionSaveImage);
|
||||||
ui->graphic_buttonSaveMenu->addAction(ui->graphic_actionExportCSV);
|
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_min.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||||
line_x_max.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
line_x_max.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||||
((QBoxLayout *)ui->widgetLY->layout())->insertWidget(0, &line_y_min);
|
((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_buttonConfigure->setVisible(b.testFlag(Configure));
|
||||||
ui->graphic_buttonSaveMenu->setVisible(b.testFlag(Save) || b.testFlag(Export));
|
ui->graphic_buttonSaveMenu->setVisible(b.testFlag(Save) || b.testFlag(Export));
|
||||||
ui->graphic_actionExportCSV->setVisible(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_actionSaveImage->setVisible(b.testFlag(Save));
|
||||||
ui->graphic_buttonClose->setVisible(b.testFlag(Close));
|
ui->graphic_buttonClose->setVisible(b.testFlag(Close));
|
||||||
ui->graphic_checkPause->setVisible(b.testFlag(Pause));
|
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;
|
ppath = filename;
|
||||||
QFile f(filename);
|
QFile f(filename);
|
||||||
if (!f.open(QIODevice::ReadWrite)) {
|
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 << ";" << (g.name + " " + (label_x.isEmpty() ? "X" : label_x)) << ";" << (g.name + " " + (label_y.isEmpty() ? "Y" : label_y));
|
||||||
}
|
}
|
||||||
ts << "\n";
|
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;
|
bool has_data = true;
|
||||||
int ind = 0;
|
int ind = 0;
|
||||||
QString line;
|
QString line;
|
||||||
@@ -1167,8 +1180,8 @@ void Graphic::exportGraphics(QString filename, QChar decimal_point) {
|
|||||||
has_data = false;
|
has_data = false;
|
||||||
line.clear();
|
line.clear();
|
||||||
line += QString::number(ind + 1);
|
line += QString::number(ind + 1);
|
||||||
for (int i = 0; i < graphics.size(); ++i) {
|
for (int i = 0; i < source->size(); ++i) {
|
||||||
GraphicType & g(graphics[i]);
|
const GraphicType & g(source->at(i));
|
||||||
if (!g.visible) continue;
|
if (!g.visible) continue;
|
||||||
if (ind >= g.polyline.size()) {
|
if (ind >= g.polyline.size()) {
|
||||||
line += ";;";
|
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() {
|
void Graphic::drawGraphics() {
|
||||||
if (isHover && ui->status->isVisible()) {
|
if (isHover && ui->status->isVisible()) {
|
||||||
ui->status->setText(tr("Cursor: ") + pointCoords(canvas2real(QPointF(curpos))));
|
ui->status->setText(tr("Cursor: ") + pointCoords(canvas2real(QPointF(curpos))));
|
||||||
@@ -2307,14 +2332,12 @@ void Graphic::on_graphic_actionSaveImage_triggered() {
|
|||||||
|
|
||||||
|
|
||||||
void Graphic::on_graphic_actionExportCSV_triggered() {
|
void Graphic::on_graphic_actionExportCSV_triggered() {
|
||||||
QString f = QFileDialog::getSaveFileName(this, tr("Export graphics"), ppath, "CSV(*.csv)");
|
askForExport(false);
|
||||||
if (f.isEmpty()) return;
|
}
|
||||||
QStringList items;
|
|
||||||
items << "."
|
|
||||||
<< ",";
|
void Graphic::on_graphic_actionExportCSV_View_triggered() {
|
||||||
bool ok;
|
askForExport(true);
|
||||||
QString item = QInputDialog::getItem(this, tr("Select decimal point"), tr("Decimal point:"), items, 0, false, &ok);
|
|
||||||
if (ok && !item.isEmpty()) exportGraphics(f, item.front());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -372,7 +372,7 @@ public slots:
|
|||||||
void setDefaultRect(const QRectF & rect);
|
void setDefaultRect(const QRectF & rect);
|
||||||
void autofit();
|
void autofit();
|
||||||
void saveImage(QString filename);
|
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 clear();
|
||||||
void update();
|
void update();
|
||||||
void updateGraphics();
|
void updateGraphics();
|
||||||
@@ -432,6 +432,7 @@ protected:
|
|||||||
QString pointCoords(QPointF point, bool x = true, bool y = true);
|
QString pointCoords(QPointF point, bool x = true, bool y = true);
|
||||||
QPair<QString, QString> gridMark(double v) const;
|
QPair<QString, QString> gridMark(double v) const;
|
||||||
void fillDateFormats();
|
void fillDateFormats();
|
||||||
|
void askForExport(bool view_only);
|
||||||
|
|
||||||
Ui::Graphic * ui;
|
Ui::Graphic * ui;
|
||||||
UGLWidget * canvas_gl;
|
UGLWidget * canvas_gl;
|
||||||
@@ -498,6 +499,7 @@ protected slots:
|
|||||||
void on_graphic_buttonFullscreen_clicked();
|
void on_graphic_buttonFullscreen_clicked();
|
||||||
void on_graphic_actionSaveImage_triggered();
|
void on_graphic_actionSaveImage_triggered();
|
||||||
void on_graphic_actionExportCSV_triggered();
|
void on_graphic_actionExportCSV_triggered();
|
||||||
|
void on_graphic_actionExportCSV_View_triggered();
|
||||||
void on_graphic_buttonRecord_clicked(bool checked);
|
void on_graphic_buttonRecord_clicked(bool checked);
|
||||||
void on_graphic_checkGuides_toggled(bool checked);
|
void on_graphic_checkGuides_toggled(bool checked);
|
||||||
void on_graphic_actionExpandX_triggered(bool checked);
|
void on_graphic_actionExpandX_triggered(bool checked);
|
||||||
|
|||||||
@@ -468,6 +468,18 @@
|
|||||||
<string>Export to CSV...</string>
|
<string>Export to CSV...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</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>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|||||||
Reference in New Issue
Block a user