[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Tue Jan 25 15:27:47 CET 2011
SVN commit 1217053 by netterfield:
Start to implement manually surpressable borders in plots.
There are currently bugs associated to mixing manually supressed borders
with shared axis boxes.
M +1 -0 libkst/updatemanager.cpp
M +32 -0 libkstapp/axistab.cpp
M +10 -0 libkstapp/axistab.h
M +53 -19 libkstapp/axistab.ui
M +62 -0 libkstapp/plotitem.cpp
M +17 -0 libkstapp/plotitem.h
M +21 -0 libkstapp/plotitemdialog.cpp
--- branches/work/kst/portto4/kst/src/libkst/updatemanager.cpp #1217052:1217053
@@ -68,6 +68,7 @@
return;
}
+ //FIXME: should we just skip updating data sources in this case?
if (_paused && !forceImmediate) {
return;
}
--- branches/work/kst/portto4/kst/src/libkstapp/axistab.cpp #1217052:1217053
@@ -68,6 +68,9 @@
connect(_autoMinorTicks, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
connect(_autoMinorTicks, SIGNAL(stateChanged(int)), this, SLOT(updateButtons()));
+ connect(_hideBottomLeft, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
+ connect(_hideTopRight, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
+
connect(_scaleInterpret, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
connect(_scaleInterpret, SIGNAL(stateChanged(int)), this, SLOT(updateButtons()));
connect(_scaleLog, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
@@ -418,7 +421,31 @@
_rotation->setValue(rotation);
}
+bool AxisTab::hideTopRight() const {
+ return (_hideTopRight->isChecked());
+}
+bool AxisTab::hideTopRightDirty() const {
+ return _hideTopRight->checkState() != Qt::PartiallyChecked;
+}
+
+void AxisTab::setHideTopRight(bool hide) {
+ _hideTopRight->setChecked(hide);
+}
+
+bool AxisTab::hideBottomLeft() const {
+ return (_hideBottomLeft->isChecked());
+}
+
+bool AxisTab::hideBottomLeftDirty() const {
+ return _hideBottomLeft->checkState() != Qt::PartiallyChecked;
+}
+
+void AxisTab::setHideBottomLeft(bool hide) {
+ _hideBottomLeft->setChecked(hide);
+}
+
+
void AxisTab::updateButtons() {
_scaleBaseOffset->setEnabled(!(_scaleInterpret->checkState() == Qt::PartiallyChecked || _scaleAutoBaseOffset->checkState() == Qt::PartiallyChecked));
_axisMinorTickCount->setEnabled(_autoMinorTicks->checkState() != Qt::Checked);
@@ -465,6 +492,11 @@
_axisMinorTickCount->clear();
}
+void AxisTab::setAsYAxis() {
+ _hideBottomLeft->setText(i18n("Hide left"));
+ _hideTopRight->setText(i18n("Hide right"));
}
+}
+
// vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/axistab.h #1217052:1217053
@@ -116,9 +116,19 @@
bool labelRotationDirty() const;
void setLabelRotation(const int rotation);
+ bool hideTopRight() const;
+ bool hideTopRightDirty() const;
+ void setHideTopRight( bool hide);
+
+ bool hideBottomLeft() const;
+ bool hideBottomLeftDirty() const;
+ void setHideBottomLeft( bool hide);
+
void enableSingleEditOptions(bool enabled);
void clearTabValues();
+ void setAsYAxis();
+
public Q_SLOTS:
void updateButtons();
--- branches/work/kst/portto4/kst/src/libkstapp/axistab.ui #1217052:1217053
@@ -13,8 +13,10 @@
<property name="windowTitle">
<string>Form</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
<item>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
<widget class="QGroupBox" name="_scaleGroup">
<property name="title">
<string>Scale</string>
@@ -110,9 +112,49 @@
</layout>
</widget>
</item>
+ <item row="0" column="1">
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Hide Margins and Labels</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <widget class="QCheckBox" name="_hideTopRight">
+ <property name="text">
+ <string>Hide top</string>
+ </property>
+ </widget>
+ </item>
<item>
+ <widget class="QCheckBox" name="_hideBottomLeft">
+ <property name="text">
+ <string>Hide bottom</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <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>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Base / Offset Mode</string>
@@ -176,11 +218,13 @@
</layout>
</widget>
</item>
- <item>
+ <item row="1" column="1">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Label Rotation</string>
</property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_4">
@@ -199,15 +243,17 @@
</property>
</widget>
</item>
+ </layout>
+ </item>
<item>
- <spacer name="horizontalSpacer">
+ <spacer name="verticalSpacer_2">
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>40</width>
- <height>20</height>
+ <width>20</width>
+ <height>52</height>
</size>
</property>
</spacer>
@@ -455,12 +501,6 @@
</item>
<item row="2" column="0">
<widget class="QLabel" name="_axisMinorLineStyleLabel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
<property name="text">
<string>Line st&yle:</string>
</property>
@@ -484,12 +524,6 @@
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_12">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
<property name="text">
<string>Lin&e color:</string>
</property>
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #1217052:1217053
@@ -96,6 +96,10 @@
_sharedAxisBoxMenu(0),
_sharedBox(0),
_axisLabelsDirty(true),
+ _manuallyHideLeftAxisLabel(false),
+ _manuallyHideRightAxisLabel(false),
+ _manuallyHideTopAxisLabel(false),
+ _manuallyHideBottomAxisLabel(false),
_plotPixmapDirty(true),
_i_per(0)
{
@@ -337,6 +341,10 @@
xml.writeAttribute("globalfontscale", QVariant(_globalFontScale).toString());
xml.writeAttribute("globalfontcolor", QVariant(_globalFontColor).toString());
xml.writeAttribute("showlegend", QVariant(_showLegend).toString());
+ xml.writeAttribute("hidebottomaxislabel", QVariant(_manuallyHideBottomAxisLabel).toString());
+ xml.writeAttribute("hidetopaxislabel", QVariant(_manuallyHideTopAxisLabel).toString());
+ xml.writeAttribute("hideleftaxislabel", QVariant(_manuallyHideLeftAxisLabel).toString());
+ xml.writeAttribute("hiderightaxislabel", QVariant(_manuallyHideRightAxisLabel).toString());
saveNameInfo(xml, PLOTNUM);
ViewItem::save(xml);
@@ -1582,6 +1590,27 @@
}
+void PlotItem::setManuallyHideLeftAxisLabel(bool hide) {
+ _manuallyHideLeftAxisLabel = hide;
+ setLeftSuppressed(hide);
+}
+
+void PlotItem::setManuallyHideRightAxisLabel(bool hide) {
+ _manuallyHideRightAxisLabel = hide;
+ setRightSuppressed(hide);
+}
+
+void PlotItem::setManuallyHideTopAxisLabel(bool hide) {
+ _manuallyHideTopAxisLabel = hide;
+ setTopSuppressed(hide);
+}
+
+void PlotItem::setManuallyHideBottomAxisLabel(bool hide) {
+ _manuallyHideBottomAxisLabel = hide;
+ setBottomSuppressed(hide);
+}
+
+
QRectF PlotItem::projectionRect() const {
return _projectionRect;
}
@@ -1927,22 +1956,34 @@
void PlotItem::setTopSuppressed(bool suppressed) {
+ if (_manuallyHideTopAxisLabel) {
+ suppressed = true;
+ }
_topLabelDetails->setVisible(!suppressed);
}
void PlotItem::setRightSuppressed(bool suppressed) {
+ if (_manuallyHideRightAxisLabel) {
+ suppressed = true;
+ }
_rightLabelDetails->setVisible(!suppressed);
}
void PlotItem::setLeftSuppressed(bool suppressed) {
+ if (_manuallyHideLeftAxisLabel) {
+ suppressed = true;
+ }
_leftLabelDetails->setVisible(!suppressed);
_yAxis->setAxisVisible(!suppressed);
}
void PlotItem::setBottomSuppressed(bool suppressed) {
+ if (_manuallyHideBottomAxisLabel) {
+ suppressed = true;
+ }
_bottomLabelDetails->setVisible(!suppressed);
_xAxis->setAxisVisible(!suppressed);
}
@@ -3635,6 +3676,27 @@
if (!av.isNull()) {
rc->setShowLegend(QVariant(av.toString()).toBool());
}
+
+ av = attrs.value("hidebottomaxislabel");
+ if (!av.isNull()) {
+ rc->setManuallyHideBottomAxisLabel(QVariant(av.toString()).toBool());
+ }
+
+ av = attrs.value("hidetopaxislabel");
+ if (!av.isNull()) {
+ rc->setManuallyHideTopAxisLabel(QVariant(av.toString()).toBool());
+ }
+
+ av = attrs.value("hideleftaxislabel");
+ if (!av.isNull()) {
+ rc->setManuallyHideLeftAxisLabel(QVariant(av.toString()).toBool());
+ }
+
+ av = attrs.value("hiderightaxislabel");
+ if (!av.isNull()) {
+ rc->setManuallyHideRightAxisLabel(QVariant(av.toString()).toBool());
+ }
+
if (attrs.value("descriptiveNameIsManual").toString() == "true") {
rc->setDescriptiveName(attrs.value("descriptiveName").toString());
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #1217052:1217053
@@ -178,6 +178,18 @@
QString autoRightLabel() const;
QString autoTopLabel() const;
+ // These are for explicitly hiding the axis and labels and are
+ // not by being in a shared axis box or cleared by 'z' mode.
+ bool manuallyHideLeftAxisLabel() const {return _manuallyHideLeftAxisLabel;}
+ bool manuallyHideRightAxisLabel() const {return _manuallyHideRightAxisLabel;}
+ bool manuallyHideTopAxisLabel() const {return _manuallyHideTopAxisLabel;}
+ bool manuallyHideBottomAxisLabel() const {return _manuallyHideBottomAxisLabel;}
+
+ void setManuallyHideLeftAxisLabel(bool hide);
+ void setManuallyHideRightAxisLabel(bool hide);
+ void setManuallyHideTopAxisLabel(bool hide);
+ void setManuallyHideBottomAxisLabel(bool hide);
+
PlotLabel* leftLabelDetails() const { return _leftLabelDetails; }
PlotLabel* rightLabelDetails() const { return _rightLabelDetails; }
PlotLabel* topLabelDetails() const { return _topLabelDetails; }
@@ -408,6 +420,11 @@
PlotLabel* _bottomLabelDetails;
PlotLabel* _numberLabelDetails;
+ bool _manuallyHideLeftAxisLabel;
+ bool _manuallyHideRightAxisLabel;
+ bool _manuallyHideTopAxisLabel;
+ bool _manuallyHideBottomAxisLabel;
+
bool _plotRectsDirty;
QRectF _calculatedPlotRect;
QRectF _calculatedPlotAxisRect;
--- branches/work/kst/portto4/kst/src/libkstapp/plotitemdialog.cpp #1217052:1217053
@@ -94,6 +94,7 @@
connect(_xAxisTab, SIGNAL(apply()), this, SLOT(xAxisChanged()));
_yAxisTab = new AxisTab(this);
+ _yAxisTab->setAsYAxis();
DialogPage *yAxisPage = new DialogPage(this);
yAxisPage->setPageTitle(tr("Y-Axis"));
yAxisPage->addDialogTab(_yAxisTab);
@@ -287,6 +288,8 @@
_xAxisTab->setInterpret(_plotItem->xAxis()->axisInterpret());
_xAxisTab->setAxisDisplay(_plotItem->xAxis()->axisDisplay());
_xAxisTab->setAxisInterpretation(_plotItem->xAxis()->axisInterpretation());
+ _xAxisTab->setHideTopRight(_plotItem->manuallyHideTopAxisLabel());
+ _xAxisTab->setHideBottomLeft(_plotItem->manuallyHideBottomAxisLabel());
_xAxisTab->setAxisMinorTickCount(_plotItem->xAxis()->axisMinorTickCount());
_xAxisTab->setSignificantDigits(_plotItem->xAxis()->axisSignificantDigits());
_xAxisTab->setLabelRotation(_plotItem->xAxis()->axisLabelRotation());
@@ -311,6 +314,8 @@
_yAxisTab->setInterpret(_plotItem->yAxis()->axisInterpret());
_yAxisTab->setAxisDisplay(_plotItem->yAxis()->axisDisplay());
_yAxisTab->setAxisInterpretation(_plotItem->yAxis()->axisInterpretation());
+ _yAxisTab->setHideTopRight(_plotItem->manuallyHideRightAxisLabel());
+ _yAxisTab->setHideBottomLeft(_plotItem->manuallyHideLeftAxisLabel());
_yAxisTab->setAxisMinorTickCount(_plotItem->yAxis()->axisMinorTickCount());
_yAxisTab->setSignificantDigits(_plotItem->yAxis()->axisSignificantDigits());
_yAxisTab->setLabelRotation(_plotItem->yAxis()->axisLabelRotation());
@@ -698,10 +703,18 @@
PlotItem* plotItem = (PlotItem*)item;
saveAxis(plotItem->xAxis(), _xAxisTab);
plotItem->setProjectionRect(plotItem->projectionRect(), plotItem->xAxis()->isDirty());
+ if (_xAxisTab->hideBottomLeftDirty()) {
+ plotItem->setManuallyHideBottomAxisLabel(_xAxisTab->hideBottomLeft());
}
+ if (_xAxisTab->hideTopRightDirty()) {
+ plotItem->setManuallyHideTopAxisLabel(_xAxisTab->hideTopRight());
+ }
+ }
} else {
saveAxis(_plotItem->xAxis(), _xAxisTab);
_plotItem->setProjectionRect(_plotItem->projectionRect(), _plotItem->xAxis()->isDirty());
+ _plotItem->setManuallyHideBottomAxisLabel(_xAxisTab->hideBottomLeft());
+ _plotItem->setManuallyHideTopAxisLabel(_xAxisTab->hideTopRight());
}
kstApp->mainWindow()->document()->setChanged(true);
}
@@ -714,10 +727,18 @@
PlotItem* plotItem = (PlotItem*)item;
saveAxis(plotItem->yAxis(), _yAxisTab);
plotItem->setProjectionRect(plotItem->projectionRect(), plotItem->yAxis()->isDirty());
+ if (_yAxisTab->hideBottomLeftDirty()) {
+ plotItem->setManuallyHideLeftAxisLabel(_yAxisTab->hideBottomLeft());
}
+ if (_yAxisTab->hideTopRightDirty()) {
+ plotItem->setManuallyHideRightAxisLabel(_yAxisTab->hideTopRight());
+ }
+ }
} else {
saveAxis(_plotItem->yAxis(), _yAxisTab);
_plotItem->setProjectionRect(_plotItem->projectionRect(), _plotItem->yAxis()->isDirty());
+ _plotItem->setManuallyHideLeftAxisLabel(_yAxisTab->hideBottomLeft());
+ _plotItem->setManuallyHideRightAxisLabel(_yAxisTab->hideTopRight());
}
kstApp->mainWindow()->document()->setChanged(true);
}
More information about the Kst
mailing list