[Kst] branches/work/kst/portto4/kst

Barth Netterfield netterfield at astro.utoronto.ca
Sat Aug 1 06:59:30 CEST 2009


SVN commit 1005451 by netterfield:

Better defaults for graphics export dialog.
Fix parenting and resizing bugs (except lines).



 M  +4 -0      devel-docs/Kst2Specs/FixedBugs  
 M  +0 -3      devel-docs/Kst2Specs/Wishlist  
 M  +23 -2     src/libkstapp/exportgraphicsdialog.cpp  
 M  +2 -2      src/libkstapp/exportgraphicsdialog.ui  
 M  +5 -5      src/libkstapp/lineitem.cpp  
 M  +3 -1      src/libkstapp/viewitem.cpp  
 M  +8 -6      src/libkstapp/viewitemdialog.cpp  
 M  +0 -3      src/widgets/dialogdefaults.cpp  
 M  +2 -0      src/widgets/dialogdefaults.h  


--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/FixedBugs #1005450:1005451
@@ -1085,3 +1085,7 @@
 selecting, then unselecting 'fix aspect ratio'.  Apply.  The plot moves, 
 but the Y label is back where it should be.  Enable apply again, and hit 
 apply.  The plot is back where it should be, with no problems.
+
+--------
+
+Reasonable/sticky defaults for the export dialog.
--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/Wishlist #1005450:1005451
@@ -45,10 +45,7 @@
 
 Export eps to vector format.
 
---------
 
-Reasonable/sticky defaults for the export dialog.
-
 --------
 
 Reasonable/sticky defaults for line widths
--- branches/work/kst/portto4/kst/src/libkstapp/exportgraphicsdialog.cpp #1005450:1005451
@@ -10,6 +10,7 @@
  ***************************************************************************/
 
 #include "exportgraphicsdialog.h"
+#include "dialogdefaults.h"
 
 #include "mainwindow.h"
 #include <QDir>
@@ -27,7 +28,7 @@
   : QDialog(parent) {
   setupUi(this);
 
-  _saveLocation->setFile(QDir::currentPath());
+  _saveLocation->setFile(_dialogDefaults->value("export/filename",QDir::currentPath()).toString());
 
   _autoSaveTimer = new QTimer(this);
 
@@ -37,8 +38,15 @@
   }
 
   _comboBoxFormats->addItems(formats);
-  _comboBoxFormats->setCurrentIndex(0);
+  _comboBoxFormats->setCurrentIndex(
+        _comboBoxFormats->findText(_dialogDefaults->value("export/format","png").toString()));
 
+  _xSize->setValue(_dialogDefaults->value("export/xsize","1024").toInt());
+  _ySize->setValue(_dialogDefaults->value("export/ysize","768").toInt());
+
+  _comboBoxSizeOption->setCurrentIndex(_dialogDefaults->value("export/sizeOption","0").toInt());
+  enableWidthHeight();
+
   _saveLocationLabel->setBuddy(_saveLocation->_fileEdit);
 
   connect(_autoSaveTimer, SIGNAL(timeout()),      this, SLOT(createFile()));
@@ -61,18 +69,26 @@
     case 0:
       _xSize->setEnabled(true);
       _ySize->setEnabled(true);
+      _widthLabel->setEnabled(true);
+      _heightLabel->setEnabled(true);
       break;
     case 1:
       _xSize->setEnabled(true);
       _ySize->setEnabled(false);
+      _widthLabel->setEnabled(true);
+      _heightLabel->setEnabled(false);
       break;
     case 2:
       _xSize->setEnabled(true);
       _ySize->setEnabled(false);
+      _widthLabel->setEnabled(true);
+      _heightLabel->setEnabled(false);
       break;
     case 3:
       _xSize->setEnabled(false);
       _ySize->setEnabled(true);
+      _widthLabel->setEnabled(false);
+      _heightLabel->setEnabled(true);
       break;
   }
 }
@@ -97,6 +113,11 @@
 
 
 void ExportGraphicsDialog::createFile() {
+  _dialogDefaults->setValue("export/filename", _saveLocation->file());
+  _dialogDefaults->setValue("export/format", _comboBoxFormats->currentText());
+  _dialogDefaults->setValue("export/xsize", _xSize->value());
+  _dialogDefaults->setValue("export/ysize", _ySize->value());
+  _dialogDefaults->setValue("export/sizeOption", _comboBoxSizeOption->currentIndex());
   emit exportGraphics(_saveLocation->file(), _comboBoxFormats->currentText(), _xSize->value(), _ySize->value(), _comboBoxSizeOption->currentIndex());
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/exportgraphicsdialog.ui #1005450:1005451
@@ -178,7 +178,7 @@
          <number>0</number>
         </property>
         <item>
-         <widget class="QLabel" name="TextLabel3">
+         <widget class="QLabel" name="_widthLabel">
           <property name="sizePolicy">
            <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
             <horstretch>0</horstretch>
@@ -216,7 +216,7 @@
          </widget>
         </item>
         <item>
-         <widget class="QLabel" name="TextLabel4">
+         <widget class="QLabel" name="_heightLabel">
           <property name="sizePolicy">
            <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
             <horstretch>0</horstretch>
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.cpp #1005450:1005451
@@ -223,14 +223,14 @@
 
 
 void LineItem::updateChildGeometry(const QRectF &oldParentRect, const QRectF &newParentRect) {
-//   qDebug() << "LineItem::updateChildGeometry" << oldParentRect << newParentRect << endl;
+   qDebug() << "LineItem::updateChildGeometry" << oldParentRect << newParentRect << endl;
 
   QRectF itemRect = rect();
 
-//   qDebug() << "Relative Top Left x" << QPointF(mapToParent(leftMidGrip().controlPointRect().center()) - oldParentRect.topLeft()).x() / oldParentRect.width();
-//   qDebug() << "Relative Top Left y" << QPointF(mapToParent(leftMidGrip().controlPointRect().center()) - oldParentRect.topLeft()).y() / oldParentRect.height();
-//   qDebug() << "Relative Bottom Right x" << QPointF(mapToParent(rightMidGrip().controlPointRect().center()) - oldParentRect.topLeft()).x() / oldParentRect.width();
-//   qDebug() << "Relative Bottom Right y" << QPointF(mapToParent(rightMidGrip().controlPointRect().center()) - oldParentRect.topLeft()).y() / oldParentRect.height();
+   qDebug() << "Relative Top Left x" << QPointF(mapToParent(leftMidGrip().controlPointRect().center()) - oldParentRect.topLeft()).x() / oldParentRect.width();
+   qDebug() << "Relative Top Left y" << QPointF(mapToParent(leftMidGrip().controlPointRect().center()) - oldParentRect.topLeft()).y() / oldParentRect.height();
+   qDebug() << "Relative Bottom Right x" << QPointF(mapToParent(rightMidGrip().controlPointRect().center()) - oldParentRect.topLeft()).x() / oldParentRect.width();
+   qDebug() << "Relative Bottom Right y" << QPointF(mapToParent(rightMidGrip().controlPointRect().center()) - oldParentRect.topLeft()).y() / oldParentRect.height();
 
   qreal relLeftX = QPointF(mapToParent(leftMidGrip().controlPointRect().center()) - oldParentRect.topLeft()).x() / oldParentRect.width();
   qreal relLeftY = QPointF(mapToParent(leftMidGrip().controlPointRect().center()) - oldParentRect.topLeft()).y() / oldParentRect.height();
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #1005450:1005451
@@ -1550,7 +1550,9 @@
     qDebug() << "ViewItem::updateChildGeometry non-Fixed Ratio" << "relativeHeight = " << relativeHeight() << "relative Width" << relativeWidth();
 #endif
 
-    QPointF newTopLeft = newParentRect.topLeft() + QPointF(newParentRect.width() * _parentRelativePosition.x(), newParentRect.height() * _parentRelativePosition.y());
+    QPointF newTopLeft = newParentRect.topLeft() - itemRect.topLeft() +
+                         QPointF(newParentRect.width() * _parentRelativePosition.x(),
+                                 newParentRect.height() * _parentRelativePosition.y());
 
     itemRect.setWidth(newWidth);
     itemRect.setHeight(newHeight);
--- branches/work/kst/portto4/kst/src/libkstapp/viewitemdialog.cpp #1005450:1005451
@@ -337,13 +337,19 @@
   Q_ASSERT(item);
   qreal parentWidth;
   qreal parentHeight;
+  qreal parentX;
+  qreal parentY;
 
   if (item->parentViewItem()) {
     parentWidth = item->parentViewItem()->width();
     parentHeight = item->parentViewItem()->height();
+    parentX = item->parentViewItem()->rect().x();
+    parentY = item->parentViewItem()->rect().y();
   } else if (item->parentView()) {
     parentWidth = item->parentView()->width();
     parentHeight = item->parentView()->height();
+    parentX = item->parentView()->rect().x();
+    parentY = item->parentView()->rect().y();
   } else {
     Q_ASSERT_X(false,"parent test", "item has no parentview item");
     parentWidth = parentHeight = 1.0;
@@ -371,13 +377,9 @@
   }
 
   if (_mode != Multiple) {
-    qreal diffX = (_dimensionsTab->x() - item->relativeCenter().x()) * parentWidth;
-    qreal diffY = (_dimensionsTab->y() - item->relativeCenter().y()) * parentHeight;
-    QPointF newLeft(item->pos().x() + diffX - item->rect().x(), item->pos().y() + diffY + item->rect().y());
-    //QPointF newLeft(item->relativePosition().x()*parentWidth + diffX, item->relativePosition().y()*parentHeight + diffY);
-    item->setPos(newLeft);
+    item->setPos(parentX + _dimensionsTab->x()*parentWidth, parentY + _dimensionsTab->y()*parentHeight);
   }
-  item->setViewRect(0, 0, width, height);
+  item->setViewRect(-width/2, -height/2, width, height);
 
   qreal rotation = _dimensionsTab->rotationDirty() ? _dimensionsTab->rotation() :item->rotationAngle();
 
--- branches/work/kst/portto4/kst/src/widgets/dialogdefaults.cpp #1005450:1005451
@@ -14,19 +14,16 @@
   QSettings *_dialogDefaults = new QSettings("kst", "dialog");
 
 void setDataVectorDefaults(DataVectorPtr V) {
-  //FIXME Do we need a V->readLock() here?
   _dialogDefaults->setValue("vector/datasource", V->filename());
 }
 
 void setGenVectorDefaults(GeneratedVectorPtr V) {
-  //FIXME Do we need a V->readLock() here? 
   _dialogDefaults->setValue("genVector/min", V->min());
   _dialogDefaults->setValue("genVector/max", V->max()); 
   _dialogDefaults->setValue("genVector/length", V->length());
 }
 
 void setDataMatrixDefaults(DataMatrixPtr M) {
-  //FIXME Do we need a M->readLock() here?
   _dialogDefaults->setValue("matrix/datasource",M->dataSource()->fileName());
 
   _dialogDefaults->setValue("matrix/xCountFromEnd",M->xCountFromEnd());
--- branches/work/kst/portto4/kst/src/widgets/dialogdefaults.h #1005450:1005451
@@ -65,3 +65,5 @@
 // spectrum/interpolateHoles bool FFToptions 
 
 // curve/xvectorfield    QString  datawizard, curvedialog
+
+// export/filename       QString  exportgraphicsdialog


More information about the Kst mailing list