mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add export for depths of images taken
This adds an option to the export dialog to write an ascii file containing filenames of image files a tab and the depth at the time of the image taken. [Dirk Hohndel: whitespace cleanup] Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d7150818dc
commit
2282035a4d
3 changed files with 119 additions and 66 deletions
|
@ -74,6 +74,8 @@ void DiveLogExportDialog::showExplanation()
|
|||
ui->description->setText(tr("HTML export of the dive locations, visualized on a world map."));
|
||||
} else if (ui->exportSubsurfaceXML->isChecked()) {
|
||||
ui->description->setText(tr("Subsurface native XML format."));
|
||||
} else if (ui->exportImageDepths->isChecked()) {
|
||||
ui->description->setText(tr("Write depths of images to file."));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,6 +259,10 @@ void DiveLogExportDialog::on_buttonBox_accepted()
|
|||
QByteArray bt = QFile::encodeName(filename);
|
||||
save_dives_logic(bt.data(), ui->exportSelected->isChecked());
|
||||
}
|
||||
} else if (ui->exportImageDepths->isChecked()) {
|
||||
filename = QFileDialog::getSaveFileName(this, tr("Save image depths"), lastDir);
|
||||
if (!filename.isNull() && !filename.isEmpty())
|
||||
export_depths(filename.toUtf8().data(), ui->exportSelected->isChecked());
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
|
@ -278,3 +284,39 @@ void DiveLogExportDialog::on_buttonBox_accepted()
|
|||
export_dives_xslt(filename.toUtf8(), ui->exportSelected->isChecked(), stylesheet.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
void DiveLogExportDialog::export_depths(const char *filename, const bool selected_only)
|
||||
{
|
||||
FILE *f;
|
||||
struct dive *dive;
|
||||
depth_t depth;
|
||||
int i;
|
||||
const char **unit;
|
||||
|
||||
struct membuffer buf = { 0 };
|
||||
|
||||
for_each_dive (i, dive) {
|
||||
if (selected_only && !dive->selected)
|
||||
continue;
|
||||
|
||||
FOR_EACH_PICTURE (dive) {
|
||||
int n = dive->dc.samples;
|
||||
struct sample *s = dive->dc.sample;
|
||||
depth.mm = 0;
|
||||
while (--n >= 0 && s->time.seconds <= picture->offset.seconds) {
|
||||
depth.mm = s->depth.mm;
|
||||
s++;
|
||||
}
|
||||
put_format(&buf, "%s\t%.1f%s\n", picture->filename, get_depth_units(depth.mm, NULL, unit), *unit);
|
||||
}
|
||||
}
|
||||
|
||||
f = subsurface_fopen(filename, "w+");
|
||||
if (!f) {
|
||||
report_error(tr("Can't open file %s").toUtf8().data(), filename);
|
||||
} else {
|
||||
flush_buffer(&buf, f); /*check for writing errors? */
|
||||
fclose(f);
|
||||
}
|
||||
free_buffer(&buf);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ private:
|
|||
void exportHTMLsettings(const QString &filename);
|
||||
void exportHTMLstatistics(const QString &filename);
|
||||
void copy_and_overwrite(const QString &fileName, const QString &newName);
|
||||
void export_depths(const char *filename, const bool selected_only);
|
||||
};
|
||||
|
||||
#endif // DIVELOGEXPORTDIALOG_H
|
||||
|
|
|
@ -29,6 +29,76 @@
|
|||
<string>General export</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="description">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="exportSelection">
|
||||
<property name="title">
|
||||
<string>Selection</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="exportSelected">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Selected dives</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="exportAll">
|
||||
<property name="text">
|
||||
<string>All dives</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="exportFormat">
|
||||
<property name="title">
|
||||
|
@ -103,79 +173,19 @@
|
|||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="exportSelection">
|
||||
<property name="title">
|
||||
<string>Selection</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="exportSelected">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QRadioButton" name="exportImageDepths">
|
||||
<property name="text">
|
||||
<string>Selected dives</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="exportAll">
|
||||
<property name="text">
|
||||
<string>All dives</string>
|
||||
<string>Image depths</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">exportGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="description">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="HTML_tab">
|
||||
|
@ -420,7 +430,7 @@
|
|||
</connection>
|
||||
</connections>
|
||||
<buttongroups>
|
||||
<buttongroup name="exportGroup"/>
|
||||
<buttongroup name="buttonGroup"/>
|
||||
<buttongroup name="exportGroup"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
|
Loading…
Add table
Reference in a new issue