[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kst-plot] src/libkstapp: Add --pngHeight and --pngWidth to the command line.
From:       Barth Netterfield <netterfield () astro ! utoronto ! ca>
Date:       2016-08-20 18:45:57
Message-ID: E1bbBHJ-0003rW-9C () code ! kde ! org
[Download RAW message or body]

Git commit 38ef82ee5d3235403ef136037c1b58f6ec4815a8 by Barth Netterfield.
Committed on 20/08/2016 at 01:52.
Pushed by netterfield into branch 'master'.

Add --pngHeight and --pngWidth to the command line.

Now you can set the size of the output images.

M  +7    -1    src/libkstapp/commandlineparser.cpp
M  +4    -0    src/libkstapp/commandlineparser.h
M  +10   -1    src/libkstapp/mainwindow.cpp

http://commits.kde.org/kst-plot/38ef82ee5d3235403ef136037c1b58f6ec4815a8

diff --git a/src/libkstapp/commandlineparser.cpp \
b/src/libkstapp/commandlineparser.cpp index da4a593..dbc322b 100644
--- a/src/libkstapp/commandlineparser.cpp
+++ b/src/libkstapp/commandlineparser.cpp
@@ -66,6 +66,8 @@ namespace Kst {
 "      --Letter                 Print to Letter sized paper.\n"
 "      --A4                     Print to A4 sized paper.\n"
 "      --png <filename>         Render to a png image, and exit.\n"
+"      --pngHeight <height>     Height of png image (pixels)\n"
+"      --pngWidth <width>       Width of png image (pixels)\n"
 "File Options:\n"
 "      -f <startframe>          default: 'end' counts from end.\n"
 "      -n <numframes>           default: 'end' reads to end of file\n"
@@ -166,7 +168,7 @@ CommandLineParser::CommandLineParser(Document *doc, MainWindow* \
                mw) :
       _useLines(true), _usePoints(false), _overrideStyle(false), _sampleRate(1.0), 
       _numFrames(-1), _startFrame(-1),
       _skip(0), _plotName(), _errorField(), _fileName(), _xField(QString("INDEX")),
-      _pngFile(QString()), _printFile(QString()), _landscape(false), _plotItem(0),
+      _pngFile(QString()), _pngWidth(-1), _pngHeight(-1), _printFile(QString()), \
                _landscape(false), _plotItem(0),
       _num_cols(0), _asciiFirstLine(-1), _asciiFieldLine(-1), \
_asciiNoFieldNames(false),  _asciiUnitsLine(-1), _asciiNoUnits(false), \
_asciiSpaceDelim(false),  _asciiDelim('\0'), _asciiFixedWidth(-1), \
_asciiNoFixedWidth(false), @@ -717,6 +719,10 @@ bool \
CommandLineParser::processCommandLine(bool *ok) {  _asciiDecimalComma = true;
     } else if (arg == "--png") {
       *ok = _setStringArg(_pngFile, tr("Usage: --png <filename>\n"));
+    } else if (arg == "--pngWidth") {
+      *ok = _setIntArg(&_pngWidth, tr("Usage: --pngWidth <width>\n"));
+    } else if (arg == "--pngHeight") {
+      *ok = _setIntArg(&_pngHeight, tr("Usage: --pngHeight <height>\n"));
 #ifndef KST_NO_PRINTER
     } else if (arg == "--print") {
       *ok = _setStringArg(_printFile, tr("Usage: --print <filename>\n"));
diff --git a/src/libkstapp/commandlineparser.h b/src/libkstapp/commandlineparser.h
index 5c0cf60..dd6093e 100644
--- a/src/libkstapp/commandlineparser.h
+++ b/src/libkstapp/commandlineparser.h
@@ -37,6 +37,8 @@ public:
   bool processCommandLine(bool *ok);
   QString kstFileName();
   QString pngFile() const {return _pngFile;}
+  int pngWidth() const {return _pngWidth;}
+  int pngHeight() const {return _pngHeight;}
   QString printFile() const {return _printFile;}
   //bool landscape() const {return _landscape;}
 
@@ -58,6 +60,8 @@ private:
   QString _fileName;
   QString _xField;
   QString _pngFile;
+  int _pngWidth;
+  int _pngHeight;
   QString _printFile;
   bool _landscape;
 #ifndef KST_NO_PRINTER
diff --git a/src/libkstapp/mainwindow.cpp b/src/libkstapp/mainwindow.cpp
index 15549f7..4acf205 100644
--- a/src/libkstapp/mainwindow.cpp
+++ b/src/libkstapp/mainwindow.cpp
@@ -472,7 +472,16 @@ bool MainWindow::initFromCommandLine() {
 
   bool ok = _doc->initFromCommandLine(&P);
   if (!P.pngFile().isEmpty()) {
-    exportGraphicsFile(P.pngFile(), "png", 1280, 1024, 0, true);
+    int w = 1280;
+    int h = 1024;
+
+    if (P.pngWidth()>1) {
+      w = P.pngWidth();
+    }
+    if (P.pngHeight()>1) {
+      h = P.pngHeight();
+    }
+    exportGraphicsFile(P.pngFile(), "png", w, h, 2, true);
     ok = false;
   }
   if (!P.printFile().isEmpty()) {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic