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

Barth Netterfield netterfield at astro.utoronto.ca
Tue Feb 15 18:10:26 CET 2011


SVN commit 1220915 by netterfield:

Start support for 'place in shared axis box' from the wizard.  This is far from done, and the
UI is hidden for now.  I am putting off finishing this to post 2.0.3

Some modifications to the label system.  I think this is an improvement,  but there are still
some issues.  To fix them requires a significant (but simple) api change, which I am ready to do.




 M             devel-docs/Kst2Specs/Automatic Labels.pdf  
 M             devel-docs/Kst2Specs/src/Automatic Labels.odt  
 M  +33 -24    src/libkst/datavector.cpp  
 M  +15 -0     src/libkstapp/datawizard.cpp  
 M  +1 -0      src/libkstapp/datawizard.h  
 M  +44 -37    src/libkstapp/datawizardpageplot.ui  
 M  +77 -77    src/libkstapp/labeltab.ui  


--- branches/work/kst/portto4/kst/src/libkst/datavector.cpp #1220914:1220915
@@ -1,5 +1,6 @@
 /***************************************************************************
-                          datavector.cpp  -  description
+                          datavector.cpp  -  a vector which gets its data from
+                          a datasource.
                              -------------------
     begin                : Fri Sep 22 2000
     copyright            : (C) 2000-2010 by C. Barth Netterfield
@@ -302,37 +303,45 @@
 }
 
 
+/**
+ * @brief Generate default label for axis associated with this vector.  
+ * Use meta-scalars "units" or "quantity" if they are defined.
+ * Otherwise use the field name.  Escape special characters in the field name.
+ * I 
+ *
+ * @return QString
+ **/
 QString DataVector::label() const {
-  // Initialize label to field name, always
-  QString label = _field;
+  QString label;
+  bool hasQuantity = _fieldStrings.contains("quantity");
+  bool hasUnits = _fieldStrings.contains("units");
 
+  if (hasQuantity && hasUnits) {
+    label = _fieldStrings.value("quantity")->value() + " \\[" + _fieldStrings.value("units")->value() + "\\]";
   // un-escape escaped special characters so they aren't escaped 2x.
+    label.replace("\\[", "[").replace("\\]", "]");
+    // now escape the special characters.
+    label.replace('[', "\\[").replace(']', "\\]");
+  } else if (hasQuantity) {
+    label = _fieldStrings.value("quantity")->value();
+    // un-escape escaped special characters so they aren't escaped 2x.
+    label.replace("\\[", "[").replace("\\]", "]");
+    // now escape the special characters.
+    label.replace('[', "\\[").replace(']', "\\]");
+  } else if (hasUnits) {
+    label = _fieldStrings.value("units")->value();
+    // un-escape escaped special characters so they aren't escaped 2x.
+    label.replace("\\[", "[").replace("\\]", "]");
+    // now escape the special characters.
+    label.replace('[', "\\[").replace(']', "\\]");
+  } else {
+    label = _field;
+    // un-escape escaped special characters so they aren't escaped 2x.
   label.replace("\\_", "_").replace("\\^","^").replace("\\[", "[").replace("\\]", "]");
   // now escape the special characters.
   label.replace('_', "\\_").replace('^', "\\^").replace('[', "\\[").replace(']', "\\]");
-
-  // If there is a meta string named "quantity", override the default label
-  if (_fieldStrings.contains("quantity")) {
-    label = _fieldStrings.value("quantity")->value();
   }
 
-  // Now add the unit if found in the metadata
-  // FIXME: the name of the metadata should be configurable!
-  if (_fieldStrings.contains("units")) {
-    QString units = _fieldStrings.value("units")->value();
-    if (!units.isEmpty()) {
-      // Apparently some people already add the square brackets in the unit name - avoid having two brackets
-      if (units.startsWith("[")) {
-        label += " " + units;
-        if (!label.endsWith("]")) {
-          label += "\\]";
-        }
-      } else {
-        label += " \\[" + units + "\\]";
-      }
-    }
-  }
-
   return label;
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/datawizard.cpp #1220914:1220915
@@ -33,6 +33,8 @@
 #include "applicationsettings.h"
 #include "updatemanager.h"
 #include "datasourcepluginmanager.h"
+#include "sharedaxisboxitem.h"
+#include "boxitem.h"
 
 
 namespace Kst {
@@ -424,6 +426,10 @@
   return _rescaleFonts->isChecked();
 }
 
+bool DataWizardPagePlot::shareAxis() const {
+  return _shareAxis->isChecked();
+}
+
 int DataWizardPagePlot::plotCount() const {
   return _plotNumber->value();
 }
@@ -450,6 +456,8 @@
   _legendsAuto->setChecked(_dialogDefaults->value("wizard/legendsAuto",false).toBool());
 
   _rescaleFonts->setChecked(_dialogDefaults->value("wizard/rescaleFonts", true).toBool());
+  _shareAxis->setChecked(_dialogDefaults->value("wizard/shareAxis", false).toBool());
+  _shareAxis->hide(); //FIXME - not done yet.
 
   if (_dialogDefaults->value("wizard/linesOnly", true).toBool()) {
     _drawLines->setChecked(true);
@@ -712,6 +720,7 @@
   _dialogDefaults->setValue("wizard/logY", _pagePlot->PSDLogY());
 
   _dialogDefaults->setValue("wizard/rescaleFonts", _pagePlot->rescaleFonts());
+  _dialogDefaults->setValue("wizard/shareAxis", _pagePlot->shareAxis());
 
   _dialogDefaults->setValue("wizard/linesOnly", _pagePlot->drawLines());
   _dialogDefaults->setValue("wizard/pointsOnly", _pagePlot->drawPoints());
@@ -1117,7 +1126,13 @@
     }
   }
 
+  if (_pagePlot->shareAxis()) {
+     //FIXME: apply shared axis
+     // also delete the line _shareAxis->hide();
+  }
+
   UpdateManager::self()->doUpdates(true);
+
   kstApp->mainWindow()->document()->setChanged(true);
   QApplication::restoreOverrideCursor();
   accept();
--- branches/work/kst/portto4/kst/src/libkstapp/datawizard.h #1220914:1220915
@@ -121,6 +121,7 @@
     bool legendsAuto() const;
 
     bool rescaleFonts() const;
+    bool shareAxis() const;
 
     CurvePlotPlacement curvePlacement() const;
     PlotItemInterface *existingPlot() const;
--- branches/work/kst/portto4/kst/src/libkstapp/datawizardpageplot.ui #1220914:1220915
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>616</width>
-    <height>360</height>
+    <width>624</width>
+    <height>376</height>
    </rect>
   </property>
   <layout class="QGridLayout" name="gridLayout_4">
@@ -140,39 +140,6 @@
      </layout>
     </widget>
    </item>
-   <item row="1" column="1">
-    <widget class="QGroupBox" name="buttonGroup7">
-     <property name="title">
-      <string>Legends</string>
-     </property>
-     <layout class="QGridLayout" name="gridLayout_3">
-      <item row="0" column="0">
-       <widget class="QRadioButton" name="_legendsOn">
-        <property name="text">
-         <string>O&amp;n</string>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="1">
-       <widget class="QRadioButton" name="_legendsOff">
-        <property name="text">
-         <string>&amp;Off</string>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="2">
-       <widget class="QRadioButton" name="_legendsAuto">
-        <property name="text">
-         <string>A&amp;uto</string>
-        </property>
-        <property name="checked">
-         <bool>true</bool>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
    <item row="2" column="0" rowspan="2">
     <widget class="QGroupBox" name="groupBox_2">
      <property name="title">
@@ -230,7 +197,7 @@
      </layout>
     </widget>
    </item>
-   <item row="2" column="1">
+   <item row="1" column="1" rowspan="2">
     <widget class="QGroupBox" name="groupBox_3">
      <property name="title">
       <string>Labels</string>
@@ -246,10 +213,17 @@
         </property>
        </widget>
       </item>
+      <item row="1" column="0">
+       <widget class="QCheckBox" name="_shareAxis">
+        <property name="text">
+         <string>Share Axis on tab</string>
+        </property>
+       </widget>
+      </item>
      </layout>
     </widget>
    </item>
-   <item row="2" column="2" rowspan="2">
+   <item row="3" column="2">
     <widget class="QGroupBox" name="buttonGroup1">
      <property name="title">
       <string>Cur&amp;ve Style</string>
@@ -318,8 +292,41 @@
      </property>
     </spacer>
    </item>
+   <item row="1" column="2" rowspan="2">
+    <widget class="QGroupBox" name="buttonGroup7">
+     <property name="title">
+      <string>Legends</string>
+     </property>
+     <layout class="QGridLayout" name="gridLayout_3">
+      <item row="0" column="0">
+       <widget class="QRadioButton" name="_legendsOn">
+        <property name="text">
+         <string>O&amp;n</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1">
+       <widget class="QRadioButton" name="_legendsOff">
+        <property name="text">
+         <string>&amp;Off</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="2">
+       <widget class="QRadioButton" name="_legendsAuto">
+        <property name="text">
+         <string>A&amp;uto</string>
+        </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
   </layout>
  </widget>
+   </item>
+  </layout>
+ </widget>
  <layoutdefault spacing="6" margin="11"/>
  <customwidgets>
   <customwidget>
--- branches/work/kst/portto4/kst/src/libkstapp/labeltab.ui #1220914:1220915
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>557</width>
-    <height>374</height>
+    <width>584</width>
+    <height>366</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -27,56 +27,16 @@
      </property>
     </widget>
    </item>
-   <item row="0" column="4">
-    <widget class="QPushButton" name="_globalLabelBold">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
+   <item row="0" column="1" colspan="2">
+    <widget class="QDoubleSpinBox" name="_globalLabelFontSize">
+     <property name="decimals">
+      <number>1</number>
      </property>
-     <property name="iconSize">
-      <size>
-       <width>22</width>
-       <height>22</height>
-      </size>
+     <property name="minimum">
+      <double>-25.000000000000000</double>
      </property>
-     <property name="shortcut">
-      <string>Alt+B</string>
-     </property>
-     <property name="checkable">
-      <bool>true</bool>
-     </property>
     </widget>
    </item>
-   <item row="0" column="5">
-    <widget class="QPushButton" name="_globalLabelItalic">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
-     </property>
-     <property name="iconSize">
-      <size>
-       <width>22</width>
-       <height>22</height>
-      </size>
-     </property>
-     <property name="shortcut">
-      <string>Alt+I</string>
-     </property>
-     <property name="checkable">
-      <bool>true</bool>
-     </property>
-    </widget>
-   </item>
-   <item row="0" column="6">
-    <widget class="Kst::ColorButton" name="_globalLabelColor"/>
-   </item>
-   <item row="1" column="1" colspan="3">
-    <widget class="QFontComboBox" name="_globalLabelFontFamily"/>
-   </item>
    <item row="2" column="1" colspan="3">
     <widget class="QCheckBox" name="_autoScaleNumberAxis">
      <property name="text">
@@ -142,14 +102,11 @@
      </property>
     </widget>
    </item>
-   <item row="6" column="6">
-    <widget class="QCheckBox" name="_topLabelAuto">
-     <property name="text">
-      <string>Auto</string>
+   <item row="6" column="1" colspan="5">
+    <widget class="Kst::LabelLineEdit" name="_topLabelText">
+     <property name="enabled">
+      <bool>false</bool>
      </property>
-     <property name="checked">
-      <bool>true</bool>
-     </property>
     </widget>
    </item>
    <item row="7" column="0">
@@ -288,6 +245,19 @@
      </item>
     </layout>
    </item>
+   <item row="12" column="2">
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
    <item row="11" column="3" colspan="4">
     <spacer>
      <property name="orientation">
@@ -301,43 +271,73 @@
      </property>
     </spacer>
    </item>
-   <item row="12" column="2">
-    <spacer name="verticalSpacer">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
+   <item row="6" column="6">
+    <widget class="QCheckBox" name="_topLabelAuto">
+     <property name="text">
+      <string>Auto</string>
      </property>
-     <property name="sizeHint" stdset="0">
+     <property name="checked">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1" colspan="6">
+    <widget class="QFontComboBox" name="_globalLabelFontFamily"/>
+   </item>
+   <item row="0" column="6">
+    <widget class="Kst::ColorButton" name="_globalLabelColor"/>
+   </item>
+   <item row="0" column="5">
+    <widget class="QPushButton" name="_globalLabelItalic">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="iconSize">
       <size>
-       <width>20</width>
-       <height>40</height>
+       <width>22</width>
+       <height>22</height>
       </size>
      </property>
-    </spacer>
+     <property name="shortcut">
+      <string>Alt+I</string>
+     </property>
+     <property name="checkable">
+      <bool>true</bool>
+     </property>
+    </widget>
    </item>
-   <item row="0" column="1">
-    <widget class="QDoubleSpinBox" name="_globalLabelFontSize">
-     <property name="decimals">
-      <number>1</number>
+   <item row="0" column="4">
+    <widget class="QPushButton" name="_globalLabelBold">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
      </property>
-     <property name="minimum">
-      <double>-25.000000000000000</double>
+     <property name="iconSize">
+      <size>
+       <width>22</width>
+       <height>22</height>
+      </size>
      </property>
+     <property name="shortcut">
+      <string>Alt+B</string>
+     </property>
+     <property name="checkable">
+      <bool>true</bool>
+     </property>
     </widget>
    </item>
-   <item row="0" column="2">
+   <item row="0" column="3">
     <widget class="QLabel" name="label">
      <property name="text">
       <string>points</string>
      </property>
     </widget>
    </item>
-   <item row="6" column="1" colspan="5">
-    <widget class="Kst::LabelLineEdit" name="_topLabelText">
-     <property name="enabled">
-      <bool>false</bool>
-     </property>
-    </widget>
-   </item>
   </layout>
  </widget>
  <customwidgets>


More information about the Kst mailing list