[Kst] kdeextragear-2/kst/kst
Andrew Walker
arwalker at sumusltd.com
Tue Jun 15 18:04:42 CEST 2004
CVS commit by arwalker:
Can now read in old style .kst files.
M +19 -1 kst2dplot.cpp 1.87
M +5 -0 kst2dplot.h 1.35
M +34 -1 kstdoc.cpp 1.87
M +1 -0 kstviewobject.cpp 1.62
--- kdeextragear-2/kst/kst/kst2dplot.cpp #1.86:1.87
@@ -87,4 +87,9 @@ Kst2DPlot::Kst2DPlot(const QString& in_t
double xmin_in, double ymin_in,
double xmax_in, double ymax_in) : KstPlotBase("Kst2DPlot") {
+ _pos_x = 0;
+ _pos_y = 0;
+ _width = 0;
+ _height = 0;
+
commonConstructor(in_tag, yscale_in, xscale_in, xmin_in, ymin_in,
xmax_in, ymax_in);
@@ -104,4 +109,9 @@ Kst2DPlot::Kst2DPlot(QDomElement& e) : K
bool x_log = false, y_log = false;
+ _pos_x = 0;
+ _pos_y = 0;
+ _width = 0;
+ _height = 0;
+
/* parse the DOM tree */
QDomNode n = e.firstChild();
@@ -109,5 +119,13 @@ Kst2DPlot::Kst2DPlot(QDomElement& e) : K
QDomElement el = n.toElement(); // try to convert the node to an element.
if (!el.isNull()) { // the node was really an element.
- if (el.tagName() == "xscalemode") {
+ if (el.tagName() == "width") {
+ _width = el.text().toInt();
+ } else if (el.tagName() == "height") {
+ _height = el.text().toInt();
+ } else if (el.tagName() == "pos_x") {
+ _pos_x = el.text().toInt();
+ } else if (el.tagName() == "pos_y") {
+ _pos_x = el.text().toInt();
+ } else if (el.tagName() == "xscalemode") {
xscale_in = (KstScaleModeType) el.text().toInt();
} else if (el.tagName() == "yscalemode") {
--- kdeextragear-2/kst/kst/kst2dplot.h #1.34:1.35
@@ -136,4 +136,9 @@ public:
KstLegend *Legend;
+ int _width;
+ int _height;
+ int _pos_x;
+ int _pos_y;
+
/** Arbitrary Labels */
KstLabelList labelList;
--- kdeextragear-2/kst/kst/kstdoc.cpp #1.86:1.87
@@ -299,4 +299,37 @@ bool KstDoc::openDocument(const KURL& ur
}
+ //
+ // if we have anything left in plotHolderWhileOpeningDocument then
+ // we are most likely reading an old style document, so we create
+ // a default view and fill it with whatever is left...
+ //
+ if (KstApp::inst()->plotHolderWhileOpeningDocument().count() > 0) {
+ if (!KstApp::inst()->activeWindow()) {
+ Kst2DPlotMap::Iterator it;
+ Kst2DPlotPtr plot;
+ KstViewWindow *pWindow;
+ QString strWindow;
+
+ strWindow = KstApp::inst()->newWindow(QString::null);
+ pWindow = dynamic_cast<KstViewWindow*>(KstApp::inst()->findWindow(strWindow));
+
+ if (pWindow) {
+ for ( it = KstApp::inst()->plotHolderWhileOpeningDocument().begin();
+ it != KstApp::inst()->plotHolderWhileOpeningDocument().end(); ++it ) {
+ plot = *it;
+
+ if (plot->_width != 0 && plot->_height != 0 ) {
+ pWindow->view()->appendChild(plot.data(), true);
+
+ plot->resizeFromAspect( (double)plot->_pos_x / (double)plot->_width,
+ (double)plot->_pos_y / (double)plot->_height,
+ 1.0 / (double)plot->_width,
+ 1.0 / (double)plot->_height );
+ }
+ }
+ }
+ }
+ }
+
KstApp::inst()->plotHolderWhileOpeningDocument().clear();
--- kdeextragear-2/kst/kst/kstviewobject.cpp #1.61:1.62
@@ -107,4 +107,5 @@ void KstViewObject::loadChildren(QDomEle
appendChild(plot.data(), true);
plot->loadChildren(el);
+ KstApp::inst()->plotHolderWhileOpeningDocument().erase(in_tag);
}
}
More information about the Kst
mailing list