Commit ebd8e454 authored by Mike Kremer's avatar Mike Kremer

Added option to hide coordsys node when capturing screenshots.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9923 383ad7c9-94d9-4d36-a494-682f7c89f535
parent b821a271
......@@ -1361,6 +1361,18 @@ void Core::setDescriptions(){
" in snap.png in the current directory. For every snapshot"
" a counter is added to the filename."), QStringList(QString("viewerId;width;height;alpha").split(";")),
QStringList(QString("Id of viewer (default is 0);Width of image;Height of image;Transparent background").split(";")));
emit setSlotDescription("snapshot(uint,int,int,bool,bool)", tr("Make a snapshot of the viewer with id viewerId."
" Pass 0 as viewerId parameter to capture the current viewer. "
" The captured image will have the specified dimensions. "
" If 0 is passed as either width or height parameter, the value will "
" automatically be set to hold the right aspect ratio, respectively. "
" If 0 is passed for both width and height values, the viewport's current "
" dimension is used. Set alpha to true if you want the background to be transparent. "
" The fifth parameter is used to hide the coordinate system in the upper right corner of the screen. "
" If no filename was set using snapshotBaseFileName() the snapshot is stored"
" in snap.png in the current directory. For every snapshot"
" a counter is added to the filename."), QStringList(QString("viewerId;width;height;alpha;hideCoordsys").split(";")),
QStringList(QString("Id of viewer (default is 0);Width of image;Height of image;Transparent background;Hide coordsys node").split(";")));
emit setSlotDescription("resizeViewer(int,int)", tr("Resize the viewer"),
QString(tr("width,height")).split(","),
QString(tr("new width for the viewer,new height for the viewer")).split(","));
......
......@@ -418,7 +418,8 @@ void CoreWidget::viewerSnapshotDialog() {
QImage finalImage;
examiner_widgets_[PluginFunctions::activeExaminer()]->snapshot(finalImage,
dialog.snapWidth->value(), dialog.snapHeight->value(), dialog.transparent->isChecked());
dialog.snapWidth->value(), dialog.snapHeight->value(),
dialog.transparent->isChecked(), dialog.hideCoordsys->isChecked());
finalImage.save(newName);
......@@ -436,10 +437,14 @@ void CoreWidget::viewerSnapshotDialog() {
QImage img0,img1,img2,img3;
examiner_widgets_[0]->snapshot(img0, (int)((double)w * relSizeW), (int)((double)h * relSizeH), dialog.transparent->isChecked());
examiner_widgets_[1]->snapshot(img1, (int)((double)w * (1.0 - relSizeW)), (int)((double)h * relSizeH), dialog.transparent->isChecked());
examiner_widgets_[2]->snapshot(img2, (int)((double)w * relSizeW), (int)((double)h * (1.0 - relSizeH)), dialog.transparent->isChecked());
examiner_widgets_[3]->snapshot(img3, (int)((double)w * (1.0 - relSizeW)), (int)((double)h * (1.0 - relSizeH)), dialog.transparent->isChecked());
examiner_widgets_[0]->snapshot(img0, (int)((double)w * relSizeW), (int)((double)h * relSizeH),
dialog.transparent->isChecked(), dialog.hideCoordsys->isChecked());
examiner_widgets_[1]->snapshot(img1, (int)((double)w * (1.0 - relSizeW)), (int)((double)h * relSizeH),
dialog.transparent->isChecked(), dialog.hideCoordsys->isChecked());
examiner_widgets_[2]->snapshot(img2, (int)((double)w * relSizeW), (int)((double)h * (1.0 - relSizeH)),
dialog.transparent->isChecked(), dialog.hideCoordsys->isChecked());
examiner_widgets_[3]->snapshot(img3, (int)((double)w * (1.0 - relSizeW)), (int)((double)h * (1.0 - relSizeH)),
dialog.transparent->isChecked(), dialog.hideCoordsys->isChecked());
img0.save("/home/kremer/multsnap0.png");
img1.save("/home/kremer/multsnap1.png");
......@@ -479,10 +484,14 @@ void CoreWidget::viewerSnapshotDialog() {
QImage img0,img1,img2,img3;
examiner_widgets_[0]->snapshot(img0, (int)((double)w * relSizeW), h, dialog.transparent->isChecked());
examiner_widgets_[1]->snapshot(img1, (int)((double)w * (1.0 - relSizeW)), relSizeH1 * (double)h, dialog.transparent->isChecked());
examiner_widgets_[2]->snapshot(img2, (int)((double)w * (1.0 - relSizeW)), relSizeH2 * (double)h, dialog.transparent->isChecked());
examiner_widgets_[3]->snapshot(img3, (int)((double)w * (1.0 - relSizeW)), relSizeH3 * (double)h, dialog.transparent->isChecked());
examiner_widgets_[0]->snapshot(img0, (int)((double)w * relSizeW), h,
dialog.transparent->isChecked(), dialog.hideCoordsys->isChecked());
examiner_widgets_[1]->snapshot(img1, (int)((double)w * (1.0 - relSizeW)), relSizeH1 * (double)h,
dialog.transparent->isChecked(), dialog.hideCoordsys->isChecked());
examiner_widgets_[2]->snapshot(img2, (int)((double)w * (1.0 - relSizeW)), relSizeH2 * (double)h,
dialog.transparent->isChecked(), dialog.hideCoordsys->isChecked());
examiner_widgets_[3]->snapshot(img3, (int)((double)w * (1.0 - relSizeW)), relSizeH3 * (double)h,
dialog.transparent->isChecked(), dialog.hideCoordsys->isChecked());
QImage finalImage(img0.width() + img1.width() +2, img0.height(), QImage::Format_ARGB32_Premultiplied);
......
......@@ -2032,7 +2032,7 @@ void glViewer::slotPropertiesUpdated() {
updateGL();
}
void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha) {
void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha, bool _hideCoordsys) {
int w = 0, h = 0, bak_w = 0, bak_h = 0, left = 0, bottom = 0;
......@@ -2076,6 +2076,18 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha) {
ACG::Vec4f backColorBak;
ACG::Vec4f newBack;
// Hide coordsys node if demanded
if(_hideCoordsys) {
// Find coordsys node
ACG::SceneGraph::BaseNode* node = 0;
node = sceneGraphRoot_->find("Core Coordsys Node");
if(node != 0) {
node->hide();
} else {
emit statusMessage(QString(tr("Could not find coordsys node, thus it will appear in the snapshot anyway.")));
}
}
backColorBak = properties()->backgroundColor();
newBack = ACG::Vec4f(backColorBak[0], backColorBak[1], backColorBak[2], (_alpha ? 0.0f : 1.0f));
properties()->backgroundColor(newBack);
......@@ -2096,6 +2108,15 @@ void glViewer::snapshot(QImage& _image, int _width, int _height, bool _alpha) {
// Reset viewport to former size
glstate_->viewport(left, bottom, bak_w, bak_h);
}
if(_hideCoordsys) {
// Find coordsys node
ACG::SceneGraph::BaseNode* node = 0;
node = sceneGraphRoot_->find("Core Coordsys Node");
if(node != 0) {
node->show();
}
}
}
void glViewer::snapshot( int _width, int _height, bool _alpha )
......
......@@ -768,7 +768,7 @@ private:
virtual void snapshot(int _width = 0, int _height = 0, bool _alpha = false);
/// Take a snapshot and store it in the given image
virtual void snapshot(QImage& _image, int _width = 0, int _height = 0, bool _alpha = false);
virtual void snapshot(QImage& _image, int _width = 0, int _height = 0, bool _alpha = false, bool _hideCoordsys = false);
/** @} */
......
......@@ -136,6 +136,13 @@
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QCheckBox" name="hideCoordsys">
<property name="text">
<string>Hide coordinate system</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
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