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

Mike Fenton mike at staikos.net
Mon Nov 26 17:29:07 CET 2007


SVN commit 741868 by fenton:

Integration of PlotRenderItem Content options into the ViewItemDialog layout.
Addition of Content Option functionality.


 A             contenttab.cpp   [License: GPL (v2+)]
 A             contenttab.h   [License: GPL (v2+)]
 A             contenttab.ui  
 M  +3 -1      libkstapp.pro  
 M  +46 -252   plotrenderitemdialog.cpp  
 M  +13 -26    plotrenderitemdialog.h  
 D             plotrenderitemdialog.ui  


--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #741867:741868
@@ -31,6 +31,7 @@
     changedatasampledialog.cpp \
     changefiledialog.cpp \
     choosecolordialog.cpp \
+    contenttab.cpp \
     csddialog.cpp \
     curvedialog.cpp \
     databutton.cpp \
@@ -116,6 +117,7 @@
     changedatasampledialog.h \
     changefiledialog.h \
     choosecolordialog.h \
+    contenttab.h \
     csddialog.h \
     curvedialog.h \
     databutton.h \
@@ -197,6 +199,7 @@
     changedatasampledialog.ui \
     changefiledialog.ui \
     choosecolordialog.ui \
+    contenttab.ui \
     csdtab.ui \
     curvetab.ui \
     datamanager.ui \
@@ -220,7 +223,6 @@
     layouttab.ui \
     matrixeditordialog.ui \
     matrixtab.ui \
-    plotrenderitemdialog.ui \
     powerspectrumtab.ui \
     scalareditordialog.ui \
     scalartab.ui \
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitemdialog.cpp #741867:741868
@@ -11,105 +11,33 @@
 
 #include "plotrenderitemdialog.h"
 
-#include "settings.h"
-#include "plotdefines.h"
-#include "linestyle.h"
+#include "contenttab.h"
+#include "dialogpage.h"
+#include "application.h"
+#include "objectstore.h"
+#include "mainwindow.h"
+#include "document.h"
+
 #include "curve.h"
-#include "scalar.h"
-#include "dataobjectcollection.h"
-#include "datacollection.h"
+#include "plotrenderitem.h"
+#include "plotitem.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);
+    : ViewItemDialog(item, parent), _plotItem(item) {
 
-  //TODO Need icons.
-  _add->setText("Add");
-  _remove->setText("Remove");
-  _up->setText("Up");
-  _down->setText("Down");
+  _store = kstApp->mainWindow()->document()->objectStore();
 
-  connect(_checkBoxXInterpret, SIGNAL(toggled(bool)), this, SLOT(xAxisInterpretToggled(bool)));
-  connect(_checkBoxYInterpret, SIGNAL(toggled(bool)), this, SLOT(yAxisInterpretToggled(bool)));
-  connect(_xTransformTop, SIGNAL(toggled(bool)), this, SLOT(xTransformTopToggled(bool)));
-  connect(_yTransformRight, SIGNAL(toggled(bool)), this, SLOT(yTransformRightToggled(bool)));
-  connect(_xMinorTicksAuto, SIGNAL(toggled(bool)), this, SLOT(xMinorTicksAutoToggled(bool)));
-  connect(_yMinorTicksAuto, SIGNAL(toggled(bool)), this, SLOT(yMinorTicksAutoToggled(bool)));
+  _contentTab = new ContentTab(this);
+  connect(_contentTab, SIGNAL(apply()), this, SLOT(contentChanged()));
 
-  connect(_xMeanCentered, SIGNAL(toggled(bool)), this, SLOT(xMeanCenteredToggled(bool)));
-  connect(_yMeanCentered, SIGNAL(toggled(bool)), this, SLOT(yMeanCenteredToggled(bool)));
-  connect(_xExpression, SIGNAL(toggled(bool)), this, SLOT(xExpressionToggled(bool)));
-  connect(_yExpression, SIGNAL(toggled(bool)), this, SLOT(yExpressionToggled(bool)));
+  DialogPage *page = new DialogPage(this);
+  page->setPageTitle(tr("Content"));
+  page->addDialogTab(_contentTab);
+  addDialogPage(page);
 
-  connect(_useCurveCheckBox, SIGNAL(toggled(bool)), this, SLOT(useCurveToggled(bool)));
-  connect(_useVectorCheckBox, SIGNAL(toggled(bool)), this, SLOT(useVectorToggled(bool)));
-
-  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();
+  setupContent();
 }
 
 
@@ -117,180 +45,46 @@
 }
 
 
-void PlotRenderItemDialog::exec() {
-  QDialog::exec();
-}
+void PlotRenderItemDialog::setupContent() {
+  QStringList displayedCurves;
+  QStringList availableCurves;
 
+  CurveList curves = _store->getObjects<Curve>();
 
-void PlotRenderItemDialog::xAxisInterpretToggled(bool checked) {
-  _comboBoxXInterpret->setEnabled(checked);
-  _comboBoxXDisplay->setEnabled(checked);
-  _textLabelXDisplayAs->setEnabled(checked);
-}
+  foreach (RelationPtr relation, _plotItem->relationList()) {
+    displayedCurves.append(relation->tag().displayString());
+  }
 
+  foreach (CurvePtr curve, curves) {
+    if (!displayedCurves.contains(curve->tag().displayString())) {
+      availableCurves.append(curve->tag().displayString());
+    }
+  }
 
-void PlotRenderItemDialog::yAxisInterpretToggled(bool checked) {
-  _comboBoxYInterpret->setEnabled(checked);
-  _comboBoxYDisplay->setEnabled(checked);
-  _textLabelYDisplayAs->setEnabled(checked);
+  _contentTab->setDisplayedCurves(displayedCurves);
+  _contentTab->setAvailableCurves(availableCurves);
 }
 
 
-void PlotRenderItemDialog::xTransformTopToggled(bool checked) {
-  _xTransformTopExp->setEnabled(checked);
-}
-
-
-void PlotRenderItemDialog::yTransformRightToggled(bool checked) {
-  _yTransformRightExp->setEnabled(checked);
-}
-
-
-void PlotRenderItemDialog::xMinorTicksAutoToggled(bool checked) {
-  _xMinorTicks->setEnabled(!checked);
-}
-
-
-void PlotRenderItemDialog::yMinorTicksAutoToggled(bool checked) {
-  _yMinorTicks->setEnabled(!checked);
-}
-
-
-void PlotRenderItemDialog::xMeanCenteredToggled(bool checked) {
-  _xRange->setEnabled(checked);
-}
-
-
-void PlotRenderItemDialog::yMeanCenteredToggled(bool checked) {
-  _yRange->setEnabled(checked);
-}
-
-
-void PlotRenderItemDialog::xExpressionToggled(bool checked) {
-  _xExpressionMin->setEnabled(checked);
-  _xExpressionMax->setEnabled(checked);
-  _scalarSelectorX1->setEnabled(checked);
-  _scalarSelectorX2->setEnabled(checked);
-}
-
-
-void PlotRenderItemDialog::yExpressionToggled(bool checked) {
-  _yExpressionMin->setEnabled(checked);
-  _yExpressionMax->setEnabled(checked);
-  _scalarSelectorY1->setEnabled(checked);
-  _scalarSelectorY2->setEnabled(checked);
-}
-
-
-void PlotRenderItemDialog::useCurveToggled(bool checked) {
-  _curveCombo->setEnabled(checked);
-  _textLabelCreateMarkersOn->setEnabled(checked);
-  _markersRisingEdge->setEnabled(checked);
-  _markersFallingEdge->setEnabled(checked);
-  _markersBoth->setEnabled(checked);
-}
-
-
-void PlotRenderItemDialog::useVectorToggled(bool checked) {
-  _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; //FIXME // = 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 sl; //FIXME = scalarList.list();
-
-  qSort(sl);
-  for (ScalarList::ConstIterator i = sl.begin(); i != sl.end(); ++i) {
-    (*i)->readLock();
-    QString n = (*i)->tag().displayString();
-    (*i)->unlock();
-    _scalarList->addItem(n);
-    _scalarSelectorX1->addItem(n);
-    _scalarSelectorX2->addItem(n);
-    _scalarSelectorY1->addItem(n);
-    _scalarSelectorY2->addItem(n);
+void PlotRenderItemDialog::contentChanged() {
+  QStringList currentCurves;
+  foreach (RelationPtr relation, _plotItem->relationList()) {
+    currentCurves.append(relation->tag().displayString());
   }
-}
 
+  QStringList displayedCurves = _contentTab->displayedCurves();
 
-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);
+  foreach (QString curveTag, displayedCurves) {
+    if (!currentCurves.contains(curveTag)) {
+      CurvePtr curve = kst_cast<Curve>(_store->retrieveObject(ObjectTag::fromString(curveTag)));
+      if (curve) {
+        _plotItem->addRelation(curve);
+        _plotItem->plotItem()->update();
+      }
+    }
   }
-
-  _comboMarkerLineStyle->setCurrentIndex(currentIndex);
 }
 
 }
+
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitemdialog.h #741867:741868
@@ -12,47 +12,34 @@
 #ifndef PLOTRENDERITEMDIALOG_H
 #define PLOTRENDERITEMDIALOG_H
 
-#include <QDialog>
+#include "viewitemdialog.h"
 
-#include "plotrenderitem.h"
-
-#include "ui_plotrenderitemdialog.h"
-
 #include "kst_export.h"
 
 namespace Kst {
 
-class KST_EXPORT PlotRenderItemDialog : public QDialog, Ui::PlotRenderItemDialog
+class ContentTab;
+class ObjectStore;
+class PlotRenderItem;
+
+class KST_EXPORT PlotRenderItemDialog : public ViewItemDialog
 {
   Q_OBJECT
   public:
     PlotRenderItemDialog(PlotRenderItem *item, QWidget *parent = 0);
     virtual ~PlotRenderItemDialog();
 
-    void exec();
+  private Q_SLOTS:
+    void contentChanged();
 
   private:
-    QPointer<PlotRenderItem> _item;
+    void setupContent();
 
-    void update();
-    void fillMarkerLineCombo();
+  private:
+    ContentTab *_contentTab;
+    PlotRenderItem* _plotItem;
 
-  private Q_SLOTS:
-    void xAxisInterpretToggled(bool checked);
-    void yAxisInterpretToggled(bool checked);
-    void xMinorTicksAutoToggled(bool checked);
-    void yMinorTicksAutoToggled(bool checked);
-    void xTransformTopToggled(bool checked);
-    void yTransformRightToggled(bool checked);
-    void xMeanCenteredToggled(bool checked);
-    void yMeanCenteredToggled(bool checked);
-    void xExpressionToggled(bool checked);
-    void yExpressionToggled(bool checked);
-    void useCurveToggled(bool checked);
-    void useVectorToggled(bool checked);
-    void updateAxesButtons();
-
-    void updateScalarCombo();
+    ObjectStore* _store;
 };
 
 }


More information about the Kst mailing list