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

Mike Fenton mike at staikos.net
Mon Oct 29 19:34:36 CET 2007


SVN commit 730815 by fenton:

Add initial combo values and other loaded values.


 M  +168 -0    plotrenderitemdialog.cpp  
 M  +6 -0      plotrenderitemdialog.h  
 M  +3 -11     plotrenderitemdialog.ui  


--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitemdialog.cpp #730814:730815
@@ -11,8 +11,30 @@
 
 #include "plotrenderitemdialog.h"
 
+#include "settings.h"
+#include "plotdefines.h"
+#include "linestyle.h"
+#include "curve.h"
+#include "scalar.h"
+#include "dataobjectcollection.h"
+#include "datacollection.h"
+
 namespace Kst {
 
+struct MajorTickSpacing {
+  const char *label;
+  int majorTickDensity;
+};
+
+const MajorTickSpacing MajorTickSpacings[] = {
+      { "Coarse", 2 },
+      { "Default", 5 },
+      { "Fine", 10 },
+      { "Very fine", 15 }
+    };
+
+const unsigned int numMajorTickSpacings = sizeof( MajorTickSpacings ) / sizeof( MajorTickSpacing );
+
 PlotRenderItemDialog::PlotRenderItemDialog(PlotRenderItem *item, QWidget *parent)
   : QDialog(parent), _item(item) {
    setupUi(this);
@@ -41,6 +63,53 @@
   connect(_cancel, SIGNAL(clicked()), this, SLOT(reject()));
   connect(_OK, SIGNAL(clicked()), this, SLOT(accept()));
   connect(_apply, SIGNAL(clicked()), this, SLOT(accept()));
+
+  connect(_xMajorGrid, SIGNAL(clicked()), this, SLOT(updateAxesButtons()));
+  connect(_yMajorGrid, SIGNAL(clicked()), this, SLOT(updateAxesButtons()));
+  connect(_xMinorGrid, SIGNAL(clicked()), this, SLOT(updateAxesButtons()));
+  connect(_yMinorGrid, SIGNAL(clicked()), this, SLOT(updateAxesButtons()));
+
+  connect(_xMinorTicksAuto, SIGNAL(clicked()), this, SLOT(updateAxesButtons()));
+  connect(_yMinorTicksAuto, SIGNAL(clicked()), this, SLOT(updateAxesButtons()));
+  connect(_checkBoxDefaultMajorGridColor, SIGNAL(clicked()), this, SLOT(updateAxesButtons()));
+  connect(_checkBoxDefaultMinorGridColor, SIGNAL(clicked()), this, SLOT(updateAxesButtons()));
+
+
+  for (unsigned i = 0; i < numMajorTickSpacings; i++) {
+    _xMajorTickSpacing->addItem(i18n(MajorTickSpacings[i].label));
+    _yMajorTickSpacing->addItem(i18n(MajorTickSpacings[i].label));
+  }
+
+  _xMajorTickSpacing->setCurrentIndex(1);
+  _yMajorTickSpacing->setCurrentIndex(1);
+
+
+  for (unsigned i = 0; i < numAxisInterpretations; i++) {
+    _comboBoxXInterpret->addItem(i18n(AxisInterpretations[i].label));
+    _comboBoxYInterpret->addItem(i18n(AxisInterpretations[i].label));
+  }
+  for (unsigned i = 0; i < numAxisDisplays; i++) {
+    _comboBoxXDisplay->addItem(i18n(AxisDisplays[i].label));
+    _comboBoxYDisplay->addItem(i18n(AxisDisplays[i].label));
+  }
+
+  QColor defaultColor((Settings::globalSettings()->foregroundColor.red() + Settings::globalSettings()->backgroundColor.red())/2,
+                      (Settings::globalSettings()->foregroundColor.green() + Settings::globalSettings()->backgroundColor.green())/2,
+                      (Settings::globalSettings()->foregroundColor.blue() + Settings::globalSettings()->backgroundColor.blue())/2);
+  _majorGridColor->setColor(defaultColor);
+  _minorGridColor->setColor(defaultColor);
+
+  _plotColors->setColor(Settings::globalSettings()->backgroundColor);
+
+  _comboBoxTopLabelJustify->addItem("Left");
+  _comboBoxTopLabelJustify->addItem("Right");
+  _comboBoxTopLabelJustify->addItem("Center");
+
+  _colorMarker->setColor(QColor("black"));
+
+  fillMarkerLineCombo();
+
+  update();
 }
 
 
@@ -126,5 +195,104 @@
   _vectorForMarkers->setEnabled(checked);
 }
 
+
+void PlotRenderItemDialog::updateAxesButtons() {
+  bool major = _xMajorGrid->isChecked() || _yMajorGrid->isChecked();
+  bool minor = _xMinorGrid->isChecked() || _yMinorGrid->isChecked();
+
+  _checkBoxDefaultMajorGridColor->setEnabled(major);
+  _checkBoxDefaultMinorGridColor->setEnabled(minor);
+  _majorGridColor->setEnabled(major && !_checkBoxDefaultMajorGridColor->isChecked());
+  _minorGridColor->setEnabled(minor && !_checkBoxDefaultMinorGridColor->isChecked());
+  _majorPenWidth->setEnabled(major);
+  _minorPenWidth->setEnabled(minor);
+  _majorPenWidthLabel->setEnabled(major);
+  _minorPenWidthLabel->setEnabled(minor);
+  _xMinorTicks->setEnabled(!_xMinorTicksAuto->isChecked());
+  _yMinorTicks->setEnabled(!_yMinorTicksAuto->isChecked());
 }
+
+
+void PlotRenderItemDialog::update() {
+  _vectorForMarkers->update();
+  _scalarSelectorX1->update();
+  _scalarSelectorY1->update();
+  _scalarSelectorX2->update();
+  _scalarSelectorY2->update();
+
+  CurveList curves = ObjectSubList<DataObject, Curve>(dataObjectList);
+
+  _displayedCurveList->clear();
+  _availableCurveList->clear();
+
+  //TODO  Populate the curve list.
+
+  updateScalarCombo();
+
+  // TODO Update with plot/view details.
+}
+
+
+
+void PlotRenderItemDialog::updateScalarCombo() {
+  _scalarList->clear();
+  _scalarSelectorX1->clear();
+  _scalarSelectorX2->clear();
+  _scalarSelectorY1->clear();
+  _scalarSelectorY2->clear();
+
+  scalarList.lock().readLock();
+  ScalarList sl = scalarList.list();
+  scalarList.lock().unlock();
+
+  qSort(sl);
+  for (ScalarList::ConstIterator i = sl.begin(); i != sl.end(); ++i) {
+    (*i)->readLock();
+    QString n = (*i)->tagLabel();
+    (*i)->unlock();
+    _scalarList->addItem(n);
+    _scalarSelectorX1->addItem(n);
+    _scalarSelectorX2->addItem(n);
+    _scalarSelectorY1->addItem(n);
+    _scalarSelectorY2->addItem(n);
+  }
+}
+
+
+void PlotRenderItemDialog::fillMarkerLineCombo() {
+  QStyleOptionComboBox option;
+  option.initFrom(_comboMarkerLineStyle);
+  option.currentIcon = _comboMarkerLineStyle->itemIcon(_comboMarkerLineStyle->currentIndex());
+  option.currentText = _comboMarkerLineStyle->itemText(_comboMarkerLineStyle->currentIndex());
+  option.editable = _comboMarkerLineStyle->isEditable();
+  option.frame = _comboMarkerLineStyle->hasFrame();
+  option.iconSize = _comboMarkerLineStyle->iconSize();
+
+  QRect rect = _comboMarkerLineStyle->style()->subControlRect(
+                 QStyle::CC_ComboBox, &option, QStyle::SC_ComboBoxEditField, _comboMarkerLineStyle);
+  rect.setLeft(rect.left() + 2);
+  rect.setRight(rect.right() - 2);
+  rect.setTop(rect.top() + 2);
+  rect.setBottom(rect.bottom() - 2);
+
+  // fill the point type dialog with point types
+  QPixmap ppix(rect.width(), rect.height());
+  QPainter pp(&ppix);
+  QPen pen(QColor("black"), 0);
+
+  int currentIndex = _comboMarkerLineStyle->currentIndex();
+  _comboMarkerLineStyle->clear();
+
+  for (int style = 0; style < (int)LINESTYLE_MAXTYPE; style++) {
+    pen.setStyle(LineStyle[style]);
+    pp.setPen(pen);
+    pp.fillRect( pp.window(), QColor("white"));
+    pp.drawLine(1,ppix.height()/2,ppix.width()-1, ppix.height()/2);
+    _comboMarkerLineStyle->addItem(QIcon(ppix), QString::null);
+  }
+
+  _comboMarkerLineStyle->setCurrentIndex(currentIndex);
+}
+
+}
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitemdialog.h #730814:730815
@@ -34,6 +34,9 @@
   private:
     QPointer<PlotRenderItem> _item;
 
+    void update();
+    void fillMarkerLineCombo();
+
   private Q_SLOTS:
     void xAxisInterpretToggled(bool checked);
     void yAxisInterpretToggled(bool checked);
@@ -47,7 +50,10 @@
     void yExpressionToggled(bool checked);
     void useCurveToggled(bool checked);
     void useVectorToggled(bool checked);
+    void updateAxesButtons();
 
+    void updateScalarCombo();
+    void updatePlotMarkers();
 };
 
 }
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitemdialog.ui #730814:730815
@@ -3197,13 +3197,10 @@
           </widget>
          </item>
          <item>
-          <widget class="Q3ListBox" name="PlotMarkerList" >
+          <widget class="QListWidget" name="_plotMarkerList" >
            <property name="whatsThis" >
             <string>The list of defined plot markers.  Use the Add, Remove, and Remove All buttons to modify the list.  Changes to the list are not saved until the plot dialog settings are applied.</string>
            </property>
-           <property name="selectionMode" >
-            <enum>Q3ListBox::Extended</enum>
-           </property>
           </widget>
          </item>
         </layout>
@@ -3366,12 +3363,7 @@
  <layoutdefault spacing="6" margin="11" />
  <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
  <customwidgets>
-  <customwidget>
-   <class>Q3ListBox</class>
-   <extends>Q3Frame</extends>
-   <header>q3listbox.h</header>
-  </customwidget>
-  <customwidget>
+<customwidget>
    <class>Kst::VectorSelector</class>
    <extends>QWidget</extends>
    <header>vectorselector.h</header>
@@ -3392,7 +3384,7 @@
   <tabstop>TabWidget</tabstop>
   <tabstop>NewPlotMarker</tabstop>
   <tabstop>AddPlotMarker</tabstop>
-  <tabstop>PlotMarkerList</tabstop>
+  <tabstop>_plotMarkerList</tabstop>
   <tabstop>RemovePlotMarker</tabstop>
   <tabstop>RemoveAllPlotMarkers</tabstop>
   <tabstop>_useCurveCheckBox</tabstop>


More information about the Kst mailing list