Commit cbf56a4e authored by Hans-Christian Ebke's avatar Hans-Christian Ebke
Browse files

Optionally store mesh comments as metadata in screenshots.


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@16126 383ad7c9-94d9-4d36-a494-682f7c89f535
parent fe4690d8
...@@ -53,6 +53,9 @@ ...@@ -53,6 +53,9 @@
#include <OpenFlipper/common/GlobalOptions.hh> #include <OpenFlipper/common/GlobalOptions.hh>
#include <QGLWidget> #include <QGLWidget>
#include <../ObjectTypes/TriangleMesh/TriangleMesh.hh>
#include <../ObjectTypes/PolyMesh/PolyMesh.hh>
#include "PluginFunctions.hh" #include "PluginFunctions.hh"
#include "PluginFunctionsCore.hh" #include "PluginFunctionsCore.hh"
...@@ -1093,4 +1096,34 @@ QString getSaveFileName(const QString &configProperty, ...@@ -1093,4 +1096,34 @@ QString getSaveFileName(const QString &configProperty,
return result; return result;
} }
QStringList collectObjectComments(bool visibleOnly, bool targetedOnly) {
QStringList result;
for (ObjectIterator o_it(targetedOnly ? TARGET_OBJECTS : ALL_OBJECTS, DATA_TRIANGLE_MESH|DATA_POLY_MESH) ; o_it != objectsEnd(); ++o_it) {
if (visibleOnly && !o_it->visible()) continue;
OpenMesh::BaseKernel *mesh = 0;
{
TriMeshObject * const triMeshObj = dynamic_cast<TriMeshObject*>(*o_it);
if (triMeshObj) {
mesh = triMeshObj->mesh();
}
PolyMeshObject * const polyMeshObj = dynamic_cast<PolyMeshObject*>(*o_it);
if (polyMeshObj) {
mesh = polyMeshObj->mesh();
}
}
if (mesh) {
OpenMesh::MPropHandleT<std::string> mp_comment;
if (mesh->get_property_handle(mp_comment, "COMMENT")) {
result.append(QString("Object \"%1\" Comment Begin\n%2\nObject \"%1\" Comment End\n")
.arg((*o_it)->name())
.arg(QString::fromStdString(mesh->property(mp_comment))));
}
}
}
return result;
}
} // End namespace PluginFunctions } // End namespace PluginFunctions
...@@ -385,6 +385,11 @@ void setViewObjectMarker (ViewObjectMarker *_marker); ...@@ -385,6 +385,11 @@ void setViewObjectMarker (ViewObjectMarker *_marker);
DLLEXPORT DLLEXPORT
void setDefaultViewObjectMarker (ViewObjectMarker *_marker); void setDefaultViewObjectMarker (ViewObjectMarker *_marker);
/** Collect and return COMMENT properties of all meshes.
*/
DLLEXPORT
QStringList collectObjectComments(bool visibleOnly, bool targetedOnly);
/// Get the default ViewObjectMarker /// Get the default ViewObjectMarker
DLLEXPORT DLLEXPORT
ViewObjectMarker* defaultViewObjectMarker (); ViewObjectMarker* defaultViewObjectMarker ();
......
...@@ -530,6 +530,13 @@ void CoreWidget::viewerSnapshotDialog() { ...@@ -530,6 +530,13 @@ void CoreWidget::viewerSnapshotDialog() {
}else }else
snapshotCounter_++; snapshotCounter_++;
QString comments;
if (dialog.metaData_storeComments_cb->isChecked()) {
comments = PluginFunctions::collectObjectComments(
dialog.metaData_comments_visibleOnly_cb->isChecked(),
dialog.metaData_comments_targetedOnly_cb->isChecked()).join("\n");
}
//now take the snapshot //now take the snapshot
switch ( baseLayout_->mode() ){ switch ( baseLayout_->mode() ){
...@@ -542,6 +549,8 @@ void CoreWidget::viewerSnapshotDialog() { ...@@ -542,6 +549,8 @@ void CoreWidget::viewerSnapshotDialog() {
dialog.transparent->isChecked(), dialog.hideCoordsys->isChecked(), dialog.transparent->isChecked(), dialog.hideCoordsys->isChecked(),
dialog.multisampling->isChecked() ? dialog.num_samples->value() : 1); dialog.multisampling->isChecked() ? dialog.num_samples->value() : 1);
if (!comments.isEmpty())
finalImage.setText("Mesh Comments", comments);
finalImage.save(newName); finalImage.save(newName);
break; break;
...@@ -570,6 +579,8 @@ void CoreWidget::viewerSnapshotDialog() { ...@@ -570,6 +579,8 @@ void CoreWidget::viewerSnapshotDialog() {
painter.drawImage(QRectF(img[0].width()+2, 0, img[1].width(), img[1].height()),img[1], painter.drawImage(QRectF(img[0].width()+2, 0, img[1].width(), img[1].height()),img[1],
QRectF( 0, 0, img[1].width(), img[1].height()) ); QRectF( 0, 0, img[1].width(), img[1].height()) );
if (!comments.isEmpty())
finalImage.setText("Mesh Comments", comments);
finalImage.save(newName); finalImage.save(newName);
break; break;
...@@ -611,6 +622,8 @@ void CoreWidget::viewerSnapshotDialog() { ...@@ -611,6 +622,8 @@ void CoreWidget::viewerSnapshotDialog() {
painter.drawImage(QRectF(img0.width()+2, img0.height()+2, img3.width(), img3.height()),img3, painter.drawImage(QRectF(img0.width()+2, img0.height()+2, img3.width(), img3.height()),img3,
QRectF( 0, 0, img3.width(), img3.height()) ); QRectF( 0, 0, img3.width(), img3.height()) );
if (!comments.isEmpty())
finalImage.setText("Mesh Comments", comments);
finalImage.save(newName); finalImage.save(newName);
break; break;
...@@ -653,6 +666,8 @@ void CoreWidget::viewerSnapshotDialog() { ...@@ -653,6 +666,8 @@ void CoreWidget::viewerSnapshotDialog() {
painter.drawImage(QRectF(img0.width()+2, img1.height()+img2.height()+4, img3.width(),img3.height()),img3, painter.drawImage(QRectF(img0.width()+2, img1.height()+img2.height()+4, img3.width(),img3.height()),img3,
QRectF( 0, 0, img3.width(), img3.height()) ); QRectF( 0, 0, img3.width(), img3.height()) );
if (!comments.isEmpty())
finalImage.setText("Mesh Comments", comments);
finalImage.save(newName); finalImage.save(newName);
break; break;
......
...@@ -5,14 +5,6 @@ ...@@ -5,14 +5,6 @@
<property name="windowModality"> <property name="windowModality">
<enum>Qt::ApplicationModal</enum> <enum>Qt::ApplicationModal</enum>
</property> </property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>353</width>
<height>348</height>
</rect>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Take Snapshot</string> <string>Take Snapshot</string>
</property> </property>
...@@ -235,6 +227,63 @@ Allowed values: any number between 2 and 16.</string> ...@@ -235,6 +227,63 @@ Allowed values: any number between 2 and 16.</string>
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="toolTip">
<string>Use e.g. ImageMagick (&quot;identify --verbose &lt;filename&gt;&quot;) to display the image file's meta data.</string>
</property>
<property name="title">
<string>Image Meta Data</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="metaData_storeComments_cb">
<property name="text">
<string>Store Mesh Comments (if available)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="metaData_comments_visibleOnly_cb">
<property name="text">
<string>Visible Objects Only</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="metaData_comments_targetedOnly_cb">
<property name="text">
<string>Targeted Objects Only</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<item> <item>
...@@ -266,6 +315,13 @@ Allowed values: any number between 2 and 16.</string> ...@@ -266,6 +315,13 @@ Allowed values: any number between 2 and 16.</string>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
...@@ -279,9 +335,29 @@ Allowed values: any number between 2 and 16.</string> ...@@ -279,9 +335,29 @@ Allowed values: any number between 2 and 16.</string>
<tabstop>hideCoordsys</tabstop> <tabstop>hideCoordsys</tabstop>
<tabstop>multisampling</tabstop> <tabstop>multisampling</tabstop>
<tabstop>num_samples</tabstop> <tabstop>num_samples</tabstop>
<tabstop>metaData_storeComments_cb</tabstop>
<tabstop>metaData_comments_visibleOnly_cb</tabstop>
<tabstop>metaData_comments_targetedOnly_cb</tabstop>
<tabstop>cancelButton</tabstop> <tabstop>cancelButton</tabstop>
<tabstop>okButton</tabstop> <tabstop>okButton</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections>
<connection>
<sender>metaData_storeComments_cb</sender>
<signal>toggled(bool)</signal>
<receiver>widget</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>34</x>
<y>363</y>
</hint>
<hint type="destinationlabel">
<x>26</x>
<y>390</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment