Commit d8637ae4 authored by Barth Netterfield's avatar Barth Netterfield

Fix multi-page printing and exporting.

Delete more cruft.



git-svn-id: svn://anonsvn.kde.org/home/kde/branches/work/kst/portto4/kst@1032137 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
parent a82a4989
This diff is collapsed.
Installation Notes for Kst 2.0.0
Installation Notes for Kst 2.0.0 beta 3
*********************************************
Linux
*********************************************
Preliminaries:
1. Download or otherwise install Qt 4.5 or greater.
2. Make sure your QTDIR is set to that Qt installation.
3. Optionally update your ./config.pri has the appropriate settings for your machine.
4. ./build-kst
5. ./run-kst
3. Optionally update your ./config.pri (you probably don't need to do this).
Notes:
To build in debug mode debug can be added as a parameter to build-kst
ie. ./build-kst debug
To configure the output directory, set OUTPUT_DIR or include it after the command line argument for debug.
ie. ./build-kst release /home/kst
Default Build mode is release
Globally installed build/install:
1-3 above
4. ./install-kst [release|debug [INSTALL_PREFIX [INSTALL_LIBDIR [OUTPUT_DIR]]]]
5. kst2
How To Build and Install:
Locally installed debug build:
1-3 above
4. ./build-kst
5. ./run-kst
kst2 will be installed into ./build
1. Follow Steps 1 - 3 for building.
2. Setup install locations by exporting
Command line options for install-kst (all optional)
INSTALL_PREFIX - Installation location - Defaults to '/usr'
INSTALL_LIBDIR - Library Installation Directory name - Defaults to 'lib'
3. ./install-kst
Note: It is recommended that all installable builds be release as release mode does not set the RPATH directories which
in a distribution system could result in a security hole.
Note: install-kst can also automatically configure INSTALL_PREFIX and INSTALL_LIBDIR from the command line
ie. install-kst (debug/release) INSTALL_PREFIX INSTALL_LIBDIR OUTPUT_DIR
Any or all of the values can be provided, defaults will be provided for the omitted values.
release - optimized build (eg, -O2) for release: this is the default
debug - debug mode rather than release mode (eg, -g, no optimizations)
Note: It is recommended that all installable builds be "release", since
release mode does not set the RPATH directories. Setting RPATH can
result in a security hole. The default for ./install-kst is release
Note: build-kst and install-kst both build in ./build, so ./build should be [re-]moved
before running ./install-kst if a debug build from ./build-kst already exists.
Note: installation likely requires root privilidges. You can separate the build and install
steps (only if you really want to) by, eg:
./build-kst release
sudo ./install-kst release
Examples:
Build and run debug version.
1. Follow Linux build steps 1 - 3.
2. ./build-kst debug
2. ./build-kst
3. ./run-kst
Build and install to /usr/bin /usr/lib
1. Follow Linux build steps 1 - 3.
2. ./install-kst
......@@ -50,18 +54,19 @@ Build and install to specific location (/usr/local/bin /usr/local/libXX)
2. ./install-kst release /usr/local libXX
*********************************************
Mac OS
Notes:
*********************************************
#0. Not currently supported due to lack of a mac. We'd love some help here!
#1. Same as the steps for Linux with some modifications required.
#2. The qmake command line needs to be updated to include -spec macx-g++.
#3. An error has been observed compiling view.cpp, view.h may need to be updated to change QXmlStreamWriter to QCoreXmlStreamWriter on line 45.
Windows using Qt Creator Bundle (Preferred Options)
*********************************************
Windows
*********************************************
Using Qt Creator Bundle (Prefered method)
1. Download or otherwise install the Qt Creator bundle including mingw
2. Open Kst.pro
3. Verify build settings
......@@ -69,6 +74,7 @@ Windows using Qt Creator Bundle (Preferred Options)
-------------------------------------------------------------
The following methods are not being activly tested, but might work.
Windows using mingw
Note: This process must be done using the windows shell directly. It cannot be done within cygwin or msys and neither can be included in the path.
......@@ -88,7 +94,6 @@ Note: This process must be done using the windows shell directly. It cannot be
Notes: Be careful to ensure there's nothing else in path that might interfere. Cygwin, msys and various other things all have individual make and sh executables that are slightly incompatible.
qtvars.bat - mingw - Update directories to match machine configuration.
-------------------------------------------------------------
@echo off
rem
......@@ -110,7 +115,6 @@ set QMAKESPEC=win32-g++
-------------------------------------------------------------
Windows using Visual Studio
Note: This has only been build using Visual Studio & Cygwin. The following steps
......@@ -135,7 +139,6 @@ are used on the current Windows build machine used for testing, but may vary.
qtvars.bat - Visual Studio - Update directories to match machine configuration.
-------------------------------------------------------------
@echo off
rem
......@@ -166,8 +169,8 @@ rem Don't launch batch with --login so it doesn't prepend /usr/bin to the path;
call "C:\cygwin\Cygwin.bat" -i
:ENDBASH
-------------------------------------------------------------
-------------------------------------------------------------
Windows Installation
No installer exists for windows currently. To distribute / move locations.
......
Please place porting todo items in this file categorized by lib/module
**** qmake build system ****
A. Need to port over all the configure checks found in configure.in.in
**** libkst ****:
A. Numerous changes WRT Qt4's threading package
Probably should get rid of own threading classes and use Qt4's versions...
KstRWLock -> QReadWriteLock etc, etc
B. Rename kstdebug classes as they really are loggers and should be named as such.
......@@ -7,13 +7,13 @@ export BUILDDIR=$PWD/build
echo "Building Kst from $SCRIPTDIR into $BUILDDIR"
if [ "$1" = "debug" ]
if [ "$1" = "release" ]
then
echo "Building in Debug mode"
export KST_DEBUG_MODE=1
else
echo "Building in Release mode"
export KST_DEBUG_MODE=0
else
echo "Building in Debug mode"
export KST_DEBUG_MODE=1
fi
if [ "$2" ]
......
......@@ -13,6 +13,6 @@ DESTDIR = $$OUTPUT_DIR/plugin
INCLUDEPATH += \
tmp \
$$TOPLEVELDIR/src/libkst \
$$TOPLEVELDIR/src/libkst
LIBS += -L$$OUTPUT_DIR/lib -lkst
......@@ -1115,3 +1115,10 @@ sensibly set 1st plot default.
Probably need to set defaults in the plot dialog *Changed fields (?).
But need to figure out order - we want to also save the viewItemDialog
set fields.
-------------------------------------------------------------------------------------
Fixed after beta 3
-------------------------------------------------------------------------------------
Multi-page printing:
The code is in place and commented out, because it gets the size wrong for pages other than the current tab.
This bug is also hit in the export widget.
......@@ -39,12 +39,6 @@ Edit multiple for other view objects (arrow, line, label...)
--------
Multi-page printing:
The code is in place and commented out, because it gets the size wrong for pages other than the current tab.
This bug is also hit in the export widget.
--------
Export eps to vector format.
kst 1.x did this by printing to file a .ps file, and then modifying it by adding the bounding box.
......
......@@ -4,6 +4,7 @@ Create and Update Branch
1. Update code from SVN (svn update)
2. Create branch for release (svn cp)
eg, svn cp https://svn.kde.org/home/kde/branches/work/kst/portto4 https://svn.kde.org/home/kde/branches/work/kst/2.0.0-beta3
3. In the branch, update the RELEASE.NOTES (kst/RELEASE.NOTES)
4. Update the version number in config.h and kst.pri
[NOTE: This step should be moved to immediately after the release and be done in the working directory, not the branch]
......@@ -39,3 +40,4 @@ Test, Distribute and Announce the Release
4. Update the windows binary zip file available on the website with the build package.
5. Login to kde-apps.org and update the version and upload the file.
6. E-mail the kst List notifying everyone of the release.
#-------------------------------------------------------------------------
#
#
# The Boomerange LDB idealized data frame
#
#
#-------------------------------------------------------------------------
BEGIN
00d0
RA LINCOM 1 ra 0.0054931641 0
DEC LINCOM 1 dec 0.0054931641 0
BOLO LINCOM 1 bolo 3.05175781E-4 -10.0
END 0 0
Index: kstvcurve.cpp
===================================================================
--- kstvcurve.cpp (revision 476102)
+++ kstvcurve.cpp (working copy)
@@ -565,18 +565,45 @@
}
+/*
+ Fast interpolation replacement for KstVectors, good for inner loops.
+ This lacks error checking that can be done outside these loops. It can
+ crash if:
+ in_i >= ns_i
+ in_i < 0
+ _size <= 1
+ _v == 0
+ */
+inline double fastInterpolate(double *_v, int in_i, int ns_i, int _size) {
+ if (ns_i == _size) { /* no extrapolating or decimating needed */
+ return _v[in_i];
+ }
+ double fj = in_i * double(_size - 1) / double(ns_i - 1); /* scaled index */
+ int j = int(floor(fj)); /* index of sample one lower */
+ if (_v[j + 1] != _v[j + 1] || _v[j] != _v[j]) {
+ return KST::NOPOINT;
+ }
+ double fdj = fj - float(j); /* fdj is fraction between _v[j] and _v[j+1] */
+ return _v[j + 1] * fdj + _v[j] * (1.0 - fdj);
+}
+
+
inline int indexNearX(double x, KstVectorPtr& xv, int NS) {
// monotonically rising: we can do a binary search
// should be reasonably fast
if (xv->isRising()) {
int i_top = NS - 1;
int i_bot = 0;
-
+ int xvSize = xv->length();
+ if (KDE_ISUNLIKELY(xvSize < 2)) {
+ return 0;
+ }
+ double *const xvV = xv->value();
// don't pre-check for x outside of the curve since this is not
// the common case. It will be correct - just slightly slower...
while (i_bot + 1 < i_top) {
int i0 = (i_top + i_bot)/2;
- double rX = xv->interpolate(i0, NS);
+ double rX = fastInterpolate(xvV, i0, NS, xvSize);
if (x < rX) {
i_top = i0;
} else {
@@ -596,9 +623,14 @@
double rX = xv->interpolate(0, NS);
double dx0 = fabs(x - rX);
int i0 = 0;
+ int xvSize = xv->length();
+ if (KDE_ISUNLIKELY(xvSize < 2)) {
+ return 0;
+ }
+ double *const xvV = xv->value();
for (int i = 1; i < NS; ++i) {
- rX = xv->interpolate(i, NS);
+ rX = fastInterpolate(xvV, i, NS, xvSize);
double dx = fabs(x - rX);
if (dx < dx0) {
dx0 = dx;
@@ -789,6 +821,12 @@
benchtmp.start();
#endif
+ double *const xvV = xv->value();
+ double *const yvV = yv->value();
+ int xvSize = xv->length();
+ int yvSize = yv->length();
+
+ // FIXME: if xvSize < 2 || yvSize < 2 we can't call fastInterpolate
if (sampleCount() > 0) {
Qt::PenStyle style = KstLineStyle[lineStyle()];
int i0, iN;
@@ -824,13 +862,13 @@
// cachegrind backs this up.
#undef isnan
#define isnan(x) (x != x)
- rX = xv->interpolate(i0, NS);
- rY = yv->interpolate(i0, NS);
+ rX = fastInterpolate(xvV, i0, NS, xvSize);
+ rY = fastInterpolate(yvV, i0, NS, yvSize);
// if invalid point then look backward for the last valid point.
while (i0 > 0 && (isnan(rX) || isnan(rY))) {
--i0;
- rX = xv->interpolate(i0, NS);
- rY = yv->interpolate(i0, NS);
+ rX = fastInterpolate(xvV, i0, NS, xvSize);
+ rY = fastInterpolate(yvV, i0, NS, yvSize);
}
// if invalid point then look forward for the next valid point...
@@ -838,8 +876,8 @@
i0 = i0Start;
while (i0 < iN && (isnan(rX) || isnan(rY))) {
++i0;
- rX = xv->interpolate(i0, NS);
- rY = yv->interpolate(i0, NS);
+ rX = fastInterpolate(xvV, i0, NS, xvSize);
+ rY = fastInterpolate(yvV, i0, NS, yvSize);
}
}
@@ -859,8 +897,8 @@
Y2 = last_y1;
++i_pt;
- rX = xv->interpolate(i_pt, NS);
- rY = yv->interpolate(i_pt, NS);
+ rX = fastInterpolate(xvV, i_pt, NS, xvSize);
+ rY = fastInterpolate(yvV, i_pt, NS, yvSize);
bool foundNan = false;
// if necessary continue looking for the first valid point...
@@ -868,8 +906,8 @@
#undef isnan
foundNan = true;
++i_pt;
- rX = xv->interpolate(i_pt, NS);
- rY = yv->interpolate(i_pt, NS);
+ rX = fastInterpolate(xvV, i_pt, NS, xvSize);
+ rY = fastInterpolate(yvV, i_pt, NS, yvSize);
}
if (KDE_ISUNLIKELY(foundNan)) {
@@ -1123,8 +1161,8 @@
if (exv) {
drX = exv->interpolate(i_pt, NS);
}
- rX = xv->interpolate(i_pt, NS);
- rY = yv->interpolate(i_pt, NS);
+ rX = fastInterpolate(xvV, i_pt, NS, xvSize);
+ rY = fastInterpolate(yvV, i_pt, NS, yvSize);
rX -= drX/2.0;
rX2 = rX + drX;
if (_xLog) {
@@ -1228,8 +1266,8 @@
QPoint pt;
const int lineWidth = this->lineWidth();
for (i_pt = i0; i_pt <= iN; ++i_pt) {
- rX = xv->interpolate(i_pt, NS);
- rY = yv->interpolate(i_pt, NS);
+ rX = fastInterpolate(xvV, i_pt, NS, xvSize);
+ rY = fastInterpolate(yvV, i_pt, NS, yvSize);
if (_xLog) {
rX = logX(rX);
}
@@ -1247,8 +1285,8 @@
} else {
const int lineWidth = this->lineWidth();
for (i_pt = i0; i_pt <= iN; ++i_pt) {
- rX = xv->interpolate(i_pt, NS);
- rY = yv->interpolate(i_pt, NS);
+ rX = fastInterpolate(xvV, i_pt, NS, xvSize);
+ rY = fastInterpolate(yvV, i_pt, NS, yvSize);
if (_xLog) {
rX = logX(rX);
}
@@ -1285,8 +1323,8 @@
do_low_flag = true;
do_high_flag = true;
- rX = xv->interpolate(i_pt, NS);
- rY = yv->interpolate(i_pt, NS);
+ rX = fastInterpolate(xvV, i_pt, NS, xvSize);
+ rY = fastInterpolate(yvV, i_pt, NS, yvSize);
if (errorSame) {
rEX = fabs(exv->interpolate(i_pt, NS));
if (_xLog) {
@@ -1376,8 +1414,8 @@
do_low_flag = true;
do_high_flag = true;
- rX = xv->interpolate(i_pt, NS);
- rY = yv->interpolate(i_pt, NS);
+ rX = fastInterpolate(xvV, i_pt, NS, xvSize);
+ rY = fastInterpolate(yvV, i_pt, NS, yvSize);
if (errorSame) {
rEY = eyv->interpolate(i_pt, NS);
if (_yLog) {
......@@ -5,4 +5,4 @@ cd `dirname $0`
export SCRIPTDIR=$PWD
export BUILDDIR=$PWD/build
$BUILDDIR/bin/kst "$@"
$BUILDDIR/bin/kst2 "$@"
include($$PWD/../../kst.pri)
TEMPLATE = app
TARGET = kst
TARGET = kst2
DESTDIR = $$OUTPUT_DIR/bin
! isEmpty(INSTALL_PREFIX) {
......
......@@ -243,7 +243,8 @@ void MainWindow::openFile(const QString &file) {
}
void MainWindow::exportGraphicsFile(const QString &filename, const QString &format, int width, int height, int display) {
void MainWindow::exportGraphicsFile(
const QString &filename, const QString &format, int width, int height, int display) {
int viewCount = 0;
foreach (View *view, _tabWidget->views()) {
QSize size;
......@@ -270,10 +271,12 @@ void MainWindow::exportGraphicsFile(const QString &filename, const QString &form
QPainter painter(&image);
QSize currentSize(view->size());
view->resize(size);
view->processResize(size);
view->setPrinting(true);
view->render(&painter);
view->setPrinting(false);
view->resize(currentSize);
view->processResize(currentSize);
QString file = filename;
if (viewCount != 0) {
......@@ -304,26 +307,25 @@ void MainWindow::print() {
QPainter painter(&printer);
QList<View*> pages;
// FIXME: multi-page printing doesn't work. Fix it, then re-enable...
// switch (printer.printRange()) {
// case QPrinter::PageRange:
// if (printer.fromPage()>0) {
// for (int i_page = printer.fromPage(); i_page<=printer.toPage(); i_page++) {
// pages.append(_tabWidget->views().at(i_page-1));
// }
// }
// break;
// case QPrinter::AllPages:
// foreach (View *view, _tabWidget->views()) {
// pages.append(view);
// }
// break;
// case QPrinter::Selection:
// default:
// pages.append(_tabWidget->currentView());
// break;
// }
pages.append(_tabWidget->currentView()); // FIXME: remove once above is fixed.
switch (printer.printRange()) {
case QPrinter::PageRange:
if (printer.fromPage()>0) {
for (int i_page = printer.fromPage(); i_page<=printer.toPage(); i_page++) {
pages.append(_tabWidget->views().at(i_page-1));
}
}
break;
case QPrinter::AllPages:
foreach (View *view, _tabWidget->views()) {
pages.append(view);
}
break;
case QPrinter::Selection:
default:
pages.append(_tabWidget->currentView());
break;
}
QSize printerPageSize = printer.pageRect().size();
for (int i = 0; i < printer.numCopies(); ++i) {
......@@ -331,11 +333,13 @@ void MainWindow::print() {
View *view = pages.at(i_page);
QSize currentSize(view->size());
view->resize(printerPageSize);
view->processResize(printerPageSize);
view->setPrinting(true);
view->render(&painter);
view->setPrinting(false);
view->resize(currentSize);
if (i_page<pages.count()-1)
view->processResize(currentSize);
if (i_page<pages.count()-1)
printer.newPage();
}
......@@ -1070,7 +1074,8 @@ void MainWindow::showDebugDialog() {
void MainWindow::showExportGraphicsDialog() {
if (!_exportGraphics) {
_exportGraphics = new ExportGraphicsDialog(this);
connect(_exportGraphics, SIGNAL(exportGraphics(const QString &, const QString &, int, int, int)), this, SLOT(exportGraphicsFile(const QString &, const QString &, int, int, int)));
connect(_exportGraphics, SIGNAL(exportGraphics(const QString &, const QString &, int, int, int)),
this, SLOT(exportGraphicsFile(const QString &, const QString &, int, int, int)));
}
if (_exportGraphics->isVisible()) {
_exportGraphics->raise();
......
......@@ -340,8 +340,37 @@ void View::appendToLayout(CurvePlacement::Layout layout, ViewItem* item, int col
}
void View::processResize(QSize size) {
setPlotBordersDirty(true);
if (size != sceneRect().size()) {
QRectF oldSceneRect = sceneRect();
viewport()->resize(size);
setSceneRect(QRectF(0.0, 0.0, size.width() - 4.0, size.height() - 4.0));
updateBrush();
setCacheMode(QGraphicsView::CacheBackground);
foreach (QGraphicsItem *item, items()) {
if (item->parentItem())
continue;
ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
Q_ASSERT(viewItem);
viewItem->updateChildGeometry(oldSceneRect, sceneRect());
}
}
updateFont();
}
void View::resizeEvent(QResizeEvent *event) {
QGraphicsView::resizeEvent(event);
if (event) {
QGraphicsView::resizeEvent(event);
}
setPlotBordersDirty(true);
if (size() != sceneRect().size()) {
QRectF oldSceneRect = sceneRect();
......
......@@ -113,11 +113,11 @@ class KST_EXPORT View : public QGraphicsView
void createCustomLayout();
void viewChanged();
void forceChildResize(QRectF oldRect, QRectF newRect);
void processResize(QSize size);
protected:
bool event(QEvent *event);
bool eventFilter(QObject *obj, QEvent *event);
void resizeEvent(QResizeEvent *event);
void resizeEvent(QResizeEvent *event=NULL);
void drawBackground(QPainter *painter, const QRectF &rect);
void addTitle(QMenu *menu) const;
......
......@@ -3,26 +3,26 @@ include($$PWD/../../kst.pri)
QT += gui
TEMPLATE = lib
CONFIG += designer plugin
CONFIG += designer
TARGET = kstwidgets
DESTDIR = $$OUTPUT_DIR/lib
win32:CONFIG += staticlib
! isEmpty(INSTALL_PREFIX) {
target.path = $$INSTALL_PREFIX/$$INSTALL_LIBDIR/kst
INSTALLS += target
!isEmpty(INSTALL_PREFIX) {
target.path = $$INSTALL_PREFIX/$$INSTALL_LIBDIR
INSTALLS += target
}
DESTDIR = $$OUTPUT_DIR/plugin
INCLUDEPATH += \
tmp \
INCLUDEPATH += tmp \
$$TOPLEVELDIR/src/libkst \
$$TOPLEVELDIR/src/libkstmath \
$$OUTPUT_DIR/src/widgets/tmp
win32:LIBS += -L$$OUTPUT_DIR/lib -lkstmath -lkst
!win32:LIBS += -L$$OUTPUT_DIR/lib -lkst -lkstmath
win32:LIBS += -L$$OUTPUT_DIR/lib \
-L$$OUTPUT_DIR/plugin \
-lkstmath \
-lkst
!win32:LIBS += -L$$OUTPUT_DIR/lib \
-L$$OUTPUT_DIR/plugin \
-lkst \
-lkstmath
SOURCES += \
colorbutton.cpp \
......
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