File indexing completed on 2024-12-22 04:17:42

0001 /*******************F********************************************************
0002  *                                                                         *
0003  *   copyright : (C) 2007 The University of Toronto                        *
0004  *                   netterfield@astro.utoronto.ca                         *
0005  *                                                                         *
0006  *   This program is free software; you can redistribute it and/or modify  *
0007  *   it under the terms of the GNU General Public License as published by  *
0008  *   the Free Software Foundation; either version 2 of the License, or     *
0009  *   (at your option) any later version.                                   *
0010  *                                                                         *
0011  ***************************************************************************/
0012 #include "plotitemdialog.h"
0013 
0014 #include "contenttab.h"
0015 #include "axistab.h"
0016 #include "rangetab.h"
0017 #include "markerstab.h"
0018 #include "labeltab.h"
0019 #include "overridelabeltab.h"
0020 #include "dialogpage.h"
0021 #include "application.h"
0022 #include "objectstore.h"
0023 #include "mainwindow.h"
0024 #include "document.h"
0025 
0026 #include "curve.h"
0027 #include "curvedialog.h"
0028 #include "plotrenderitem.h"
0029 #include "plotitem.h"
0030 #include "image.h"
0031 #include "imagedialog.h"
0032 #include "dimensionstab.h"
0033 
0034 #include "filltab.h"
0035 #include "stroketab.h"
0036 
0037 #include "math_kst.h"
0038 #include "updateserver.h"
0039 
0040 namespace Kst {
0041 
0042 PlotItemDialog::PlotItemDialog(PlotItem *item, QWidget *parent)
0043     : ViewItemDialog(item, parent), _plotItem(item), _defaultTagString("<Auto Name>") {
0044 
0045   Q_ASSERT(_plotItem);
0046 
0047   _store = kstApp->mainWindow()->document()->objectStore();
0048 
0049   setWindowTitle(tr("Edit Plot Item"));
0050 
0051   _contentTab = new ContentTab(this, _store);
0052   connect(_contentTab, SIGNAL(apply()), this, SLOT(contentChanged()));
0053   DialogPage *contentsPage = new DialogPage(this);
0054   contentsPage->setPageTitle(tr("Contents"));
0055   contentsPage->addDialogTab(_contentTab);
0056   addDialogPage(contentsPage, true);
0057 
0058   _labelTab = new LabelTab(_plotItem, this);
0059   _topLabelTab = new OverrideLabelTab(tr("Top Font"), this);
0060   _bottomLabelTab = new OverrideLabelTab(tr("Bottom Font"), this);
0061   _leftLabelTab = new OverrideLabelTab(tr("Left Font"), this);
0062   _rightLabelTab = new OverrideLabelTab(tr("Right Font"), this);
0063   _axisLabelTab = new OverrideLabelTab(tr("Axis Font"), this);
0064 
0065   _labelPage = new DialogPageTab(this);
0066   _labelPage->setPageTitle(tr("Labels"));
0067   _labelPage->addDialogTab(_labelTab);
0068   _labelPage->addDialogTab(_topLabelTab);
0069   _labelPage->addDialogTab(_bottomLabelTab);
0070   _labelPage->addDialogTab(_leftLabelTab);
0071   _labelPage->addDialogTab(_rightLabelTab);
0072   _labelPage->addDialogTab(_axisLabelTab);
0073   addDialogPage(_labelPage, true);
0074 
0075   connect(_labelTab, SIGNAL(apply()), this, SLOT(labelsChanged()));
0076   connect(_labelTab, SIGNAL(globalFontUpdate()), this, SLOT(globalFontUpdate()));
0077 
0078   connect(_topLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useTopDefaultChanged(bool)));
0079   connect(_bottomLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useBottomDefaultChanged(bool)));
0080   connect(_leftLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useLeftDefaultChanged(bool)));
0081   connect(_rightLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useRightDefaultChanged(bool)));
0082   connect(_axisLabelTab, SIGNAL(useDefaultChanged(bool)), this, SLOT(useAxisDefaultChanged(bool)));
0083 
0084   connect(UpdateServer::self(), SIGNAL(objectListsChanged()), this, SLOT(setupContent()));
0085 
0086   _rangeTab = new RangeTab(_plotItem, this);
0087   DialogPage *rangePage = new DialogPage(this);
0088   rangePage->setPageTitle(tr("Range/Zoom"));
0089   rangePage->addDialogTab(_rangeTab);
0090   addDialogPage(rangePage, true);
0091   connect(_rangeTab, SIGNAL(apply()), this, SLOT(rangeChanged()));
0092 
0093   _xAxisTab = new AxisTab(this);
0094   _xAxisPage = new DialogPage(this);
0095   _xAxisPage->setPageTitle(tr("X-Axis"));
0096   _xAxisPage->addDialogTab(_xAxisTab);
0097   addDialogPage(_xAxisPage, true);
0098   connect(_xAxisTab, SIGNAL(apply()), this, SLOT(xAxisChanged()));
0099 
0100   _yAxisTab = new AxisTab(this);
0101   _yAxisTab->setAsYAxis();
0102   _yAxisPage = new DialogPage(this);
0103   _yAxisPage->setPageTitle(tr("Y-Axis"));
0104   _yAxisPage->addDialogTab(_yAxisTab);
0105   addDialogPage(_yAxisPage, true);
0106   connect(_yAxisTab, SIGNAL(apply()), this, SLOT(yAxisChanged()));
0107 
0108   _xMarkersTab = new MarkersTab(this);
0109   DialogPage *xMarkersPage = new DialogPage(this);
0110   xMarkersPage->setPageTitle(tr("X-Axis Markers"));
0111   xMarkersPage->addDialogTab(_xMarkersTab);
0112   addDialogPage(xMarkersPage, true);
0113   _xMarkersTab->setObjectStore(_store);
0114   connect(_xMarkersTab, SIGNAL(apply()), this, SLOT(xAxisPlotMarkersChanged()));
0115 
0116   _yMarkersTab = new MarkersTab(this);
0117   DialogPage *yMarkersPage = new DialogPage(this);
0118   yMarkersPage->setPageTitle(tr("Y-Axis Markers"));
0119   yMarkersPage->addDialogTab(_yMarkersTab);
0120   addDialogPage(yMarkersPage, true);
0121   _yMarkersTab->setObjectStore(_store);
0122   connect(yMarkersPage, SIGNAL(apply()), this, SLOT(yAxisPlotMarkersChanged()));
0123 
0124   // addRelations(); This tends to clutter the plot dialog, let's test skipping it
0125 
0126   setupContent();
0127   setupAxis();
0128   setupRange();
0129   setupLabels();
0130   setupMarkers();
0131 
0132   setSupportsMultipleEdit(true);
0133 
0134   if (_plotItem->descriptiveNameIsManual()) {
0135     setTagString(_plotItem->descriptiveName());
0136   } else {
0137     setTagString(_defaultTagString);
0138   }
0139 
0140   QList<PlotItem*> list = ViewItem::getItems<PlotItem>();
0141   clearMultipleEditOptions();
0142   foreach(PlotItem* plot, list) {
0143     addMultipleEditOption(plot->plotName(), plot->descriptionTip(), plot->shortName());
0144   }
0145   
0146   QList<QList<QListWidgetItem*> > moveItems;
0147   moveItems << _listWidget->findItems("Appearance", Qt::MatchFixedString);
0148   moveItems << _listWidget->findItems("Size/Position", Qt::MatchFixedString);
0149   foreach(const QList<QListWidgetItem*>& found, moveItems) {
0150     if (found.size() > 0) {
0151       _listWidget->addItem(_listWidget->takeItem(_listWidget->row(found.first())));
0152     }
0153   }
0154 
0155   selectDialogPage(contentsPage);
0156   _saveAsDefault->show();
0157 
0158   if (item->isInSharedAxisBox()) {
0159     _dimensionsTab->setEnabled(false);
0160   }
0161 
0162   connect(this, SIGNAL(editMultipleMode()), this, SLOT(editMultiple()));
0163   connect(this, SIGNAL(editSingleMode()), this, SLOT(editSingle()));
0164   connect(this, SIGNAL(apply()), this, SLOT(slotApply()));
0165 
0166   setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // Make sure the labels are visible, doesn't work right now :-)
0167 }
0168 
0169 
0170 PlotItemDialog::~PlotItemDialog() {
0171 }
0172 
0173 
0174 void PlotItemDialog::editMultiple() {
0175   _xAxisTab->clearTabValues();
0176   _yAxisTab->clearTabValues();
0177   _rangeTab->clearTabValues();
0178   _labelTab->clearTabValues();
0179   _labelTab->enableSingleEditOptions(false);
0180   _topLabelTab->clearTabValues();
0181   _bottomLabelTab->clearTabValues();
0182   _leftLabelTab->clearTabValues();
0183   _rightLabelTab->clearTabValues();
0184   _axisLabelTab->clearTabValues();
0185   _xMarkersTab->clearTabValues();
0186   _yMarkersTab->clearTabValues();
0187   _contentTab->setEnabled(false);
0188   //foreach(DialogPage* page, _relationPages) {
0189   //  removeDialogPage(page);
0190   //}
0191   //_relationPages.clear();
0192 }
0193 
0194 
0195 void PlotItemDialog::editSingle() {
0196   _contentTab->setEnabled(true);
0197   //updateRelations();
0198   setupContent();
0199   setupAxis();
0200   setupRange();
0201   setupLabels();
0202   setupMarkers();
0203   setAlwaysAllowApply(false);
0204 }
0205 
0206 
0207 void PlotItemDialog::slotApply() {
0208   if (editMode() == Single) {
0209     _plotItem->setDescriptiveName(tagString().remove(_defaultTagString));
0210   }
0211 
0212   //FIXME: it is not clear that slotApply must be executed last.
0213   // experimentally, it seems to be...
0214   if (_saveAsDefault->isChecked()) {
0215     _plotItem->saveAsDialogDefaults();
0216   }
0217 }
0218 
0219 
0220 void PlotItemDialog::setupLabels() {
0221   Q_ASSERT(_plotItem);
0222 
0223   _labelTab->enableSingleEditOptions(true);
0224 
0225   _labelTab->setLeftLabel(_plotItem->leftLabel());
0226   _labelTab->setBottomLabel(_plotItem->bottomLabel());
0227   _labelTab->setTopLabel(_plotItem->topLabel());
0228   _labelTab->setRightLabel(_plotItem->rightLabel());
0229 
0230   _labelTab->setAutoScaleNumbers(_plotItem->isUseAxisScale());
0231 
0232   _labelTab->setLeftLabelAuto(_plotItem->leftLabelDetails()->isAuto());
0233   _labelTab->setBottomLabelAuto(_plotItem->bottomLabelDetails()->isAuto());
0234   _labelTab->setTopLabelAuto(_plotItem->topLabelDetails()->isAuto());
0235   _labelTab->setRightLabelAuto(_plotItem->rightLabelDetails()->isAuto());
0236 
0237   _labelTab->setShowLegend(_plotItem->showLegend());
0238 
0239   _topLabelTab->enableSingleEditOptions(true);
0240   _topLabelTab->setUseDefault(_plotItem->topLabelDetails()->fontUseGlobal());
0241   _topLabelTab->setLabelFont(_plotItem->topLabelDetails()->font());
0242   _topLabelTab->setLabelFontScale(_plotItem->topLabelDetails()->fontScale());
0243   _topLabelTab->setLabelColor(_plotItem->topLabelDetails()->fontColor());
0244 
0245   _bottomLabelTab->enableSingleEditOptions(true);
0246   _bottomLabelTab->setUseDefault(_plotItem->bottomLabelDetails()->fontUseGlobal());
0247   _bottomLabelTab->setLabelFont(_plotItem->bottomLabelDetails()->font());
0248   _bottomLabelTab->setLabelFontScale(_plotItem->bottomLabelDetails()->fontScale());
0249   _bottomLabelTab->setLabelColor(_plotItem->bottomLabelDetails()->fontColor());
0250 
0251   _leftLabelTab->enableSingleEditOptions(true);
0252   _leftLabelTab->setUseDefault(_plotItem->leftLabelDetails()->fontUseGlobal());
0253   _leftLabelTab->setLabelFont(_plotItem->leftLabelDetails()->font());
0254   _leftLabelTab->setLabelFontScale(_plotItem->leftLabelDetails()->fontScale());
0255   _leftLabelTab->setLabelColor(_plotItem->leftLabelDetails()->fontColor());
0256 
0257   _rightLabelTab->enableSingleEditOptions(true);
0258   _rightLabelTab->setUseDefault(_plotItem->rightLabelDetails()->fontUseGlobal());
0259   _rightLabelTab->setLabelFont(_plotItem->rightLabelDetails()->font());
0260   _rightLabelTab->setLabelFontScale(_plotItem->rightLabelDetails()->fontScale());
0261   _rightLabelTab->setLabelColor(_plotItem->rightLabelDetails()->fontColor());
0262 
0263   _axisLabelTab->enableSingleEditOptions(true);
0264   _axisLabelTab->setUseDefault(_plotItem->numberLabelDetails()->fontUseGlobal());
0265   _axisLabelTab->setLabelFont(_plotItem->numberLabelDetails()->font());
0266   _axisLabelTab->setLabelFontScale(_plotItem->numberLabelDetails()->fontScale());
0267   _axisLabelTab->setLabelColor(_plotItem->numberLabelDetails()->fontColor());
0268 }
0269 
0270 
0271 void PlotItemDialog::setupRange() {
0272   _rangeTab->setupRange();
0273 }
0274 
0275 
0276 void PlotItemDialog::setupAxis() {
0277   Q_ASSERT(_plotItem);
0278 
0279   _xAxisTab->enableSingleEditOptions(true);
0280   _xAxisTab->setAxisMajorTickSpacing(_plotItem->xAxis()->axisMajorTickMode());
0281   _xAxisTab->setDrawAxisMajorTicks(_plotItem->xAxis()->drawAxisMajorTicks());
0282   _xAxisTab->setDrawAxisMajorGridLines(_plotItem->xAxis()->drawAxisMajorGridLines());
0283   _xAxisTab->setDrawAxisMinorTicks(_plotItem->xAxis()->drawAxisMinorTicks());
0284   _xAxisTab->setDrawAxisMinorGridLines(_plotItem->xAxis()->drawAxisMinorGridLines());
0285   _xAxisTab->setAutoMinorTickCount(_plotItem->xAxis()->axisAutoMinorTicks());
0286   _xAxisTab->setAxisMajorGridLineColor(_plotItem->xAxis()->axisMajorGridLineColor());
0287   _xAxisTab->setAxisMinorGridLineColor(_plotItem->xAxis()->axisMinorGridLineColor());
0288   _xAxisTab->setAxisMajorGridLineWidth(_plotItem->xAxis()->axisMajorGridLineWidth());
0289   _xAxisTab->setAxisMinorGridLineWidth(_plotItem->xAxis()->axisMinorGridLineWidth());
0290   _xAxisTab->setAxisMajorGridLineStyle(_plotItem->xAxis()->axisMajorGridLineStyle());
0291   _xAxisTab->setAxisMinorGridLineStyle(_plotItem->xAxis()->axisMinorGridLineStyle());
0292   _xAxisTab->setLog(_plotItem->xAxis()->axisLog());
0293   _xAxisTab->setReversed(_plotItem->xAxis()->axisReversed());
0294   _xAxisTab->setBaseOffsetMode(_plotItem->xAxis()->axisAutoBaseOffset(), _plotItem->xAxis()->axisBaseOffset());
0295   _xAxisTab->setForceOffsetMin(_plotItem->xAxis()->axisForceOffsetMin());
0296   _xAxisTab->setInterpret(_plotItem->xAxis()->axisInterpret());
0297   _xAxisTab->setAxisDisplay(_plotItem->xAxis()->axisDisplay());
0298   _xAxisTab->setAxisDisplayFormatString(_plotItem->xAxis()->axisDisplayFormatString());
0299   _xAxisTab->setAxisInterpretation(_plotItem->xAxis()->axisInterpretation());
0300   _xAxisTab->setTimezone(_plotItem->xAxis()->timezoneName());
0301   _xAxisTab->setHideTopRight(_plotItem->manuallyHideTopAxisLabel());
0302   _xAxisTab->setHideBottomLeft(_plotItem->manuallyHideBottomAxisLabel());
0303   _xAxisTab->setAxisMinorTickCount(_plotItem->xAxis()->axisMinorTickCount());
0304   _xAxisTab->setSignificantDigits(_plotItem->xAxis()->axisSignificantDigits());
0305   _xAxisTab->setLabelRotation(_plotItem->xAxis()->axisLabelRotation());
0306 
0307   _yAxisTab->enableSingleEditOptions(true);
0308   _yAxisTab->setAxisMajorTickSpacing(_plotItem->yAxis()->axisMajorTickMode());
0309   _yAxisTab->setDrawAxisMajorTicks(_plotItem->yAxis()->drawAxisMajorTicks());
0310   _yAxisTab->setDrawAxisMajorGridLines(_plotItem->yAxis()->drawAxisMajorGridLines());
0311   _yAxisTab->setDrawAxisMinorTicks(_plotItem->yAxis()->drawAxisMinorTicks());
0312   _yAxisTab->setAutoMinorTickCount(_plotItem->yAxis()->axisAutoMinorTicks());
0313   _yAxisTab->setDrawAxisMinorGridLines(_plotItem->yAxis()->drawAxisMinorGridLines());
0314   _yAxisTab->setAxisMajorGridLineColor(_plotItem->yAxis()->axisMajorGridLineColor());
0315   _yAxisTab->setAxisMinorGridLineColor(_plotItem->yAxis()->axisMinorGridLineColor());
0316   _yAxisTab->setAxisMajorGridLineWidth(_plotItem->yAxis()->axisMajorGridLineWidth());
0317   _yAxisTab->setAxisMinorGridLineWidth(_plotItem->yAxis()->axisMinorGridLineWidth());
0318   _yAxisTab->setAxisMajorGridLineStyle(_plotItem->yAxis()->axisMajorGridLineStyle());
0319   _yAxisTab->setAxisMinorGridLineStyle(_plotItem->yAxis()->axisMinorGridLineStyle());
0320   _yAxisTab->setLog(_plotItem->yAxis()->axisLog());
0321   _yAxisTab->setReversed(_plotItem->yAxis()->axisReversed());
0322   _yAxisTab->setBaseOffsetMode(_plotItem->yAxis()->axisAutoBaseOffset(), _plotItem->yAxis()->axisBaseOffset());
0323   _yAxisTab->setForceOffsetMin(_plotItem->yAxis()->axisForceOffsetMin());
0324   _yAxisTab->setInterpret(_plotItem->yAxis()->axisInterpret());
0325   _yAxisTab->setAxisDisplay(_plotItem->yAxis()->axisDisplay());
0326   _yAxisTab->setAxisDisplayFormatString(_plotItem->yAxis()->axisDisplayFormatString());
0327   _yAxisTab->setAxisInterpretation(_plotItem->yAxis()->axisInterpretation());
0328   _yAxisTab->setTimezone(_plotItem->yAxis()->timezoneName());
0329   _yAxisTab->setHideTopRight(_plotItem->manuallyHideRightAxisLabel());
0330   _yAxisTab->setHideBottomLeft(_plotItem->manuallyHideLeftAxisLabel());
0331   _yAxisTab->setAxisMinorTickCount(_plotItem->yAxis()->axisMinorTickCount());
0332   _yAxisTab->setSignificantDigits(_plotItem->yAxis()->axisSignificantDigits());
0333   _yAxisTab->setLabelRotation(_plotItem->yAxis()->axisLabelRotation());
0334 }
0335 
0336 
0337 void PlotItemDialog::setupMarkers() {
0338   Q_ASSERT(_plotItem);
0339 
0340   _xMarkersTab->enableSingleEditOptions(true);
0341   _xMarkersTab->setPlotMarkers(_plotItem->xAxis()->axisPlotMarkers());
0342   _yMarkersTab->enableSingleEditOptions(true);
0343   _yMarkersTab->setPlotMarkers(_plotItem->yAxis()->axisPlotMarkers());
0344 }
0345 
0346 
0347 void PlotItemDialog::setupContent() {
0348   QStringList displayedRelations;
0349   QStringList availableRelations;
0350   QStringList allRelations;
0351   QStringList displayedRelationTips;
0352   QStringList availableRelationTips;
0353   QStringList allRelationTips;
0354 
0355   CurveList curves = _store->getObjects<Curve>();
0356   ImageList images = _store->getObjects<Image>();
0357 
0358   foreach (RelationPtr relation, _plotItem->renderItem(PlotRenderItem::Cartesian)->relationList()) {
0359     displayedRelations.append(relation->Name());
0360     displayedRelationTips.append(relation->descriptionTip());
0361   }
0362 
0363   foreach (CurvePtr curve, curves) {
0364     allRelations.append(curve->Name());
0365     allRelationTips.append(curve->descriptionTip());
0366     if (!displayedRelations.contains(curve->Name())) {
0367       availableRelations.append(curve->Name());
0368       availableRelationTips.append(curve->descriptionTip());
0369     }
0370   }
0371 
0372   foreach (ImagePtr image, images) {
0373     allRelations.append(image->Name());
0374     allRelationTips.append(image->descriptionTip());
0375     if (!displayedRelations.contains(image->Name())) {
0376       availableRelations.append(image->Name());
0377       availableRelationTips.append(image->descriptionTip());
0378     }
0379   }
0380 
0381   _contentTab->setDisplayedRelations(displayedRelations, displayedRelationTips);
0382   _contentTab->setAvailableRelations(availableRelations, availableRelationTips);
0383 }
0384 
0385 
0386 #if 0
0387 void PlotItemDialog::addRelations() {
0388   foreach (RelationPtr relation, _plotItem->renderItem(PlotRenderItem::Cartesian)->relationList()) {
0389     if (CurvePtr curve = kst_cast<Curve>(relation)) {
0390       CurveTab* curveTab = new CurveTab(this);
0391 
0392       curveTab->setObjectStore(_store);
0393       curveTab->setXVector(curve->xVector());
0394       curveTab->setYVector(curve->yVector());
0395       if (curve->hasXError()) {
0396         curveTab->setXError(curve->xErrorVector());
0397       }
0398       if (curve->hasYError()) {
0399       curveTab->setYError(curve->yErrorVector());
0400       }
0401       if (curve->hasXMinusError()) {
0402       curveTab->setXMinusError(curve->xMinusErrorVector());
0403       }
0404       if (curve->hasYMinusError()) {
0405         curveTab->setYMinusError(curve->yMinusErrorVector());
0406       }
0407       curveTab->curveAppearance()->setColor(curve->color());
0408       curveTab->curveAppearance()->setShowPoints(curve->hasPoints());
0409       curveTab->curveAppearance()->setShowLines(curve->hasLines());
0410       curveTab->curveAppearance()->setShowBars(curve->hasBars());
0411       curveTab->curveAppearance()->setLineWidth(curve->lineWidth());
0412       curveTab->curveAppearance()->setLineStyle(curve->lineStyle());
0413       curveTab->curveAppearance()->setPointType(curve->pointType());
0414       curveTab->curveAppearance()->setPointDensity(curve->pointDensity());
0415       curveTab->curveAppearance()->setBarStyle(curve->barStyle());
0416       curveTab->hidePlacementOptions();
0417 
0418       DialogPage *curvePage = new DialogPage(this);
0419       curvePage->setPageTitle(curve->Name());
0420       curvePage->addDialogTab(curveTab);
0421       addDialogPage(curvePage, false);
0422       _relationPages.append(curvePage);
0423     } else if (ImagePtr image = kst_cast<Image>(relation)) {
0424       ImageTab* imageTab = new ImageTab(this);
0425       imageTab->setObjectStore(_store);
0426 
0427       imageTab->setMatrix(image->matrix());
0428 
0429       if (image->hasContourMap() && image->hasColorMap()) {
0430         imageTab->setColorAndContour(true);
0431         imageTab->setNumberOfContourLines(image->numContourLines());
0432         imageTab->setContourColor(image->contourColor());
0433         imageTab->setContourWeight(image->contourWeight());
0434         imageTab->setLowerThreshold(image->lowerThreshold());
0435         imageTab->setUpperThreshold(image->upperThreshold());
0436         imageTab->setRealTimeAutoThreshold(image->autoThreshold());
0437         imageTab->colorPalette()->setPalette(image->paletteName());
0438         imageTab->setUseVariableLineWeight(image->contourWeight() == -1);
0439 
0440       } else if (image->hasContourMap()) {
0441         imageTab->setContourOnly(true);
0442         imageTab->setNumberOfContourLines(image->numContourLines());
0443         imageTab->setContourColor(image->contourColor());
0444         imageTab->setContourWeight(image->contourWeight());
0445         imageTab->setUseVariableLineWeight(image->contourWeight() == -1);
0446       } else {
0447         imageTab->setColorOnly(true);
0448         imageTab->setLowerThreshold(image->lowerThreshold());
0449         imageTab->setUpperThreshold(image->upperThreshold());
0450         imageTab->setRealTimeAutoThreshold(image->autoThreshold());
0451         imageTab->colorPalette()->setPalette(image->paletteName());
0452       }
0453       imageTab->hidePlacementOptions();
0454 
0455       DialogPage *imagePage = new DialogPage(this);
0456       imagePage->setPageTitle(image->Name());
0457       imagePage->addDialogTab(imageTab);
0458       addDialogPage(imagePage, false);
0459       _relationPages.append(imagePage);
0460     }
0461   }
0462 }
0463 
0464 void PlotItemDialog::updateRelations() {
0465   foreach(DialogPage* page, _relationPages) {
0466     removeDialogPage(page);
0467   }
0468   _relationPages.clear();
0469 
0470   addRelations();
0471 }
0472 #endif
0473 
0474 
0475 
0476 void PlotItemDialog::contentChanged() {
0477 
0478   QStringList relation_names = _contentTab->displayedRelations();
0479   RelationList relations;
0480 
0481   foreach (const QString &relation_name, relation_names) {
0482     if (RelationPtr relation = kst_cast<Relation>(_store->retrieveObject(relation_name))) {
0483       relations.append(relation);
0484     }
0485   }
0486   _plotItem->renderItem(PlotRenderItem::Cartesian)->setRelationsList(relations);
0487   _plotItem->update();
0488 
0489 }
0490 
0491 #if 0
0492 
0493 void PlotItemDialog::relationChanged() {
0494   foreach(DialogPage* page, _relationPages) {
0495     if (CurvePtr curve = kst_cast<Curve>(_store->retrieveObject(page->pageTitle()))) {
0496       CurveTab* curveTab = static_cast<CurveTab*>(page->currentWidget());
0497       if (curveTab) {
0498         curve->writeLock();
0499         curve->setXVector(curveTab->xVector());
0500         curve->setYVector(curveTab->yVector());
0501         curve->setXError(curveTab->xError());
0502         curve->setYError(curveTab->yError());
0503         curve->setXMinusError(curveTab->xMinusError());
0504         curve->setYMinusError(curveTab->yMinusError());
0505         curve->setColor(curveTab->curveAppearance()->color());
0506         curve->setHasPoints(curveTab->curveAppearance()->showPoints());
0507         curve->setHasLines(curveTab->curveAppearance()->showLines());
0508         curve->setHasBars(curveTab->curveAppearance()->showBars());
0509         curve->setLineWidth(curveTab->curveAppearance()->lineWidth());
0510         curve->setLineStyle(curveTab->curveAppearance()->lineStyle());
0511         curve->setPointType(curveTab->curveAppearance()->pointType());
0512         curve->setPointDensity(curveTab->curveAppearance()->pointDensity());
0513         curve->setBarStyle(curveTab->curveAppearance()->barStyle());
0514 
0515         curve->registerChange();
0516         curve->unlock();
0517       }
0518     } else if (ImagePtr image = kst_cast<Image>(_store->retrieveObject(page->pageTitle()))) {
0519       ImageTab* imageTab = static_cast<ImageTab*>(page->currentWidget());
0520       if (imageTab) {
0521         image->writeLock();
0522         if (imageTab->colorOnly()) {
0523           image->changeToColorOnly(imageTab->matrix(),
0524               imageTab->lowerThreshold(),
0525               imageTab->upperThreshold(),
0526               imageTab->realTimeAutoThreshold(),
0527               imageTab->colorPalette()->selectedPalette());
0528         } else if (imageTab->contourOnly()) {
0529           image->changeToContourOnly(imageTab->matrix(),
0530               imageTab->numberOfContourLines(),
0531               imageTab->contourColor(),
0532               imageTab->useVariableLineWeight() ? -1 : imageTab->contourWeight());
0533         } else {
0534           image->changeToColorAndContour(imageTab->matrix(),
0535               imageTab->lowerThreshold(),
0536               imageTab->upperThreshold(),
0537               imageTab->realTimeAutoThreshold(),
0538               imageTab->colorPalette()->selectedPalette(),
0539               imageTab->numberOfContourLines(),
0540               imageTab->contourColor(),
0541               imageTab->useVariableLineWeight() ? -1 : imageTab->contourWeight());
0542         }
0543 
0544         image->registerChange();
0545         image->unlock();
0546       }
0547     }
0548   }
0549 }
0550 #endif
0551 
0552 
0553 void PlotItemDialog::rangeChanged() {
0554   Q_ASSERT(_plotItem);
0555   if (editMode() == Multiple) {
0556     foreach(ViewItem* item, selectedMultipleEditObjects()) {
0557       PlotItem* plotItem = (PlotItem*)item;
0558       saveRange(plotItem);
0559     }
0560   } else {
0561     saveRange(_plotItem);
0562   }
0563   kstApp->mainWindow()->document()->setChanged(true);
0564 }
0565 
0566 
0567 void PlotItemDialog::saveRange(PlotItem *item) {
0568   ZoomState zoomstate;
0569   double newXMin, newXMax;
0570   double newYMin, newYMax;
0571 
0572   zoomstate = item->currentZoomState();
0573 
0574   qreal xRange = _rangeTab->xRangeDirty() ? _rangeTab->xRange() :fabs(item->xMax() - item->xMin());
0575   qreal xMax = _rangeTab->xMaxDirty() ? _rangeTab->xMax() :item->xMax();
0576   qreal xMin = _rangeTab->xMinDirty() ? _rangeTab->xMin() :item->xMin();
0577 
0578   qreal yRange = _rangeTab->yRangeDirty() ? _rangeTab->yRange() :fabs(item->yMax() - item->yMin());
0579   qreal yMax = _rangeTab->yMaxDirty() ? _rangeTab->yMax() :item->yMax();
0580   qreal yMin = _rangeTab->yMinDirty() ? _rangeTab->yMin() :item->yMin();
0581 
0582   zoomstate.item = item;
0583 
0584   if ((_rangeTab->xModeDirty() && _rangeTab->xMean()) || (!_rangeTab->xModeDirty() && zoomstate.xAxisZoomMode == PlotAxis::MeanCentered)) {
0585     newXMax = xRange;
0586     newXMin = (item->xMin() + item->xMax() - newXMax)/2.0;
0587   } else {
0588     newXMin = qMin(xMax, xMin);
0589     newXMax = fabs(xMax - xMin);
0590   }
0591   if (newXMax == 0.0) newXMax = 0.2;
0592 
0593   if ((_rangeTab->yModeDirty() && _rangeTab->yMean()) || (!_rangeTab->yModeDirty() && zoomstate.yAxisZoomMode == PlotAxis::MeanCentered)) {
0594     newYMax = yRange;
0595     newYMin = (item->yMin() + item->yMax() - newYMax)/2.0;
0596   } else {
0597     newYMin = qMin(yMax, yMin);
0598     newYMax = fabs(yMax - yMin);
0599   }
0600   if (newYMax == 0.0) newYMax = 0.2;
0601 
0602    PlotAxis::ZoomMode xZoomMode = item->yAxis()->axisZoomMode();
0603    PlotAxis::ZoomMode yZoomMode = item->yAxis()->axisZoomMode();
0604   if (_rangeTab->xModeDirty()) {
0605     if (_rangeTab->xAuto()) {
0606       xZoomMode = PlotAxis::Auto;
0607     } else if (_rangeTab->xSpike()) {
0608       xZoomMode = PlotAxis::SpikeInsensitive;
0609     } else if (_rangeTab->xBorder()) {
0610       xZoomMode = PlotAxis::AutoBorder;
0611     } else if (_rangeTab->xMean()) {
0612       xZoomMode = PlotAxis::MeanCentered;
0613     } else if (_rangeTab->xFixed()) {
0614       xZoomMode = PlotAxis::FixedExpression;
0615     }
0616   }
0617 
0618   if (_rangeTab->yModeDirty()) {
0619     if (_rangeTab->yAuto()) {
0620       yZoomMode = PlotAxis::Auto;
0621     } else if (_rangeTab->ySpike()) {
0622       yZoomMode = PlotAxis::SpikeInsensitive;
0623     } else if (_rangeTab->yBorder()) {
0624       yZoomMode = PlotAxis::AutoBorder;
0625     } else if (_rangeTab->yMean()) {
0626       yZoomMode = PlotAxis::MeanCentered;
0627     } else if (_rangeTab->yFixed()) {
0628       yZoomMode = PlotAxis::FixedExpression;
0629     }
0630   }
0631 
0632   QRectF newProjectionRect(newXMin, newYMin, newXMax, newYMax);
0633   if (_rangeTab->xModeDirty()) {
0634     if (xZoomMode == PlotAxis::Auto) {
0635       item->zoomXMaximum();
0636     } else if (xZoomMode == PlotAxis::AutoBorder) {
0637       item->zoomXAutoBorder();
0638     } else if (xZoomMode == PlotAxis::SpikeInsensitive) {
0639       item->zoomXNoSpike();
0640     }
0641   }
0642   if (xZoomMode == PlotAxis::FixedExpression) {
0643     item->zoomXRange(newProjectionRect);
0644   }
0645   if (xZoomMode == PlotAxis::MeanCentered) {
0646       item->zoomXMeanCentered(_rangeTab->xRange());
0647   }
0648 
0649   if (_rangeTab->yModeDirty()) {
0650     if (yZoomMode == PlotAxis::Auto) {
0651       item->zoomYMaximum();
0652     } else if (yZoomMode == PlotAxis::AutoBorder) {
0653       item->zoomYAutoBorder();
0654     } else if (yZoomMode == PlotAxis::SpikeInsensitive) {
0655       item->zoomYNoSpike();
0656     }
0657   }
0658   if (yZoomMode == PlotAxis::FixedExpression) {
0659     item->zoomYRange(newProjectionRect);
0660   }
0661   if (yZoomMode == PlotAxis::MeanCentered) {
0662       item->zoomYMeanCentered(_rangeTab->yRange());
0663   }
0664 }
0665 
0666 
0667 void PlotItemDialog::xAxisChanged() {
0668   Q_ASSERT(_plotItem);
0669   if (editMode() == Multiple) {
0670     foreach(ViewItem* item, selectedMultipleEditObjects()) {
0671       PlotItem* plotItem = (PlotItem*)item;
0672       saveAxis(plotItem->xAxis(), _xAxisTab);
0673       plotItem->setProjectionRect(plotItem->projectionRect(), plotItem->xAxis()->isDirty());
0674       if (_xAxisTab->hideBottomLeftDirty()) {
0675         plotItem->setManuallyHideBottomAxisLabel(_xAxisTab->hideBottomLeft());
0676       }
0677       if (_xAxisTab->hideTopRightDirty()) {
0678         plotItem->setManuallyHideTopAxisLabel(_xAxisTab->hideTopRight());
0679       }
0680     }
0681   } else {
0682     saveAxis(_plotItem->xAxis(), _xAxisTab);
0683     _plotItem->setProjectionRect(_plotItem->projectionRect(), _plotItem->xAxis()->isDirty());
0684     _plotItem->setManuallyHideBottomAxisLabel(_xAxisTab->hideBottomLeft());
0685     _plotItem->setManuallyHideTopAxisLabel(_xAxisTab->hideTopRight());
0686     _plotItem->setProjectionRect(_plotItem->computedProjectionRect(), true); //need to recompute
0687   }
0688   kstApp->mainWindow()->document()->setChanged(true);
0689 }
0690 
0691 
0692 void PlotItemDialog::yAxisChanged() {
0693   Q_ASSERT(_plotItem);
0694   if (editMode() == Multiple) {
0695     foreach(ViewItem* item, selectedMultipleEditObjects()) {
0696       PlotItem* plotItem = (PlotItem*)item;
0697       saveAxis(plotItem->yAxis(), _yAxisTab);
0698       plotItem->setProjectionRect(plotItem->projectionRect(), plotItem->yAxis()->isDirty());
0699       if (_yAxisTab->hideBottomLeftDirty()) {
0700         plotItem->setManuallyHideLeftAxisLabel(_yAxisTab->hideBottomLeft());
0701       }
0702       if (_yAxisTab->hideTopRightDirty()) {
0703         plotItem->setManuallyHideRightAxisLabel(_yAxisTab->hideTopRight());
0704       }
0705     }
0706   } else {
0707     saveAxis(_plotItem->yAxis(), _yAxisTab);
0708     _plotItem->setProjectionRect(_plotItem->projectionRect(), _plotItem->yAxis()->isDirty());
0709     _plotItem->setManuallyHideLeftAxisLabel(_yAxisTab->hideBottomLeft());
0710     _plotItem->setManuallyHideRightAxisLabel(_yAxisTab->hideTopRight());
0711     _plotItem->setProjectionRect(_plotItem->computedProjectionRect(), true); //need to recompute
0712   }
0713   kstApp->mainWindow()->document()->setChanged(true);
0714 }
0715 
0716 
0717 void PlotItemDialog::saveAxis(PlotAxis *axis, AxisTab *axisTab) {
0718   Q_ASSERT(axis);
0719   if (axisTab->axisMajorTickSpacingDirty()) {
0720     axis->setAxisMajorTickMode(axisTab->axisMajorTickSpacing());
0721   }
0722   if (axisTab->drawAxisMajorTicksDirty()) {
0723     axis->setDrawAxisMajorTicks(axisTab->drawAxisMajorTicks());
0724   }
0725   if (axisTab->drawAxisMajorGridLinesDirty()) {
0726     axis->setDrawAxisMajorGridLines(axisTab->drawAxisMajorGridLines());
0727   }
0728   if (axisTab->drawAxisMinorTicksDirty()) {
0729     axis->setDrawAxisMinorTicks(axisTab->drawAxisMinorTicks());
0730   }
0731   if (axisTab->drawAxisMinorGridLinesDirty()) {
0732     axis->setDrawAxisMinorGridLines(axisTab->drawAxisMinorGridLines());
0733   }
0734   if (axisTab->axisMajorGridLineColorDirty()) {
0735     axis->setAxisMajorGridLineColor(axisTab->axisMajorGridLineColor());
0736   }
0737   if (axisTab->axisMinorGridLineColorDirty()) {
0738     axis->setAxisMinorGridLineColor(axisTab->axisMinorGridLineColor());
0739   }
0740   if (axisTab->axisMajorGridLineWidthDirty()) {
0741     axis->setAxisMajorGridLineWidth(axisTab->axisMajorGridLineWidth());
0742   }
0743   if (axisTab->axisMinorGridLineWidthDirty()) {
0744     axis->setAxisMinorGridLineWidth(axisTab->axisMinorGridLineWidth());
0745   }
0746   if (axisTab->axisMajorGridLineStyleDirty()) {
0747     axis->setAxisMajorGridLineStyle(axisTab->axisMajorGridLineStyle());
0748   }
0749   if (axisTab->axisMinorGridLineStyleDirty()) {
0750     axis->setAxisMinorGridLineStyle(axisTab->axisMinorGridLineStyle());
0751   }
0752   if (axisTab->isLogDirty()) {
0753     axis->setAxisLog(axisTab->isLog());
0754   }
0755   if (axisTab->isReversedDirty()) {
0756     axis->setAxisReversed(axisTab->isReversed());
0757   }
0758   if (axisTab->isInterpretDirty()) {
0759     axis->setAxisInterpret(axisTab->isInterpret());
0760   }
0761   if (axisTab->axisDisplayDirty()) {
0762     axis->setAxisDisplay(axisTab->axisDisplay());
0763   }
0764   if (axisTab->axisDisplayFormatStringDirty()) {
0765     axis->setAxisDisplayFormatString(axisTab->axisDisplayFormatString());
0766   }
0767   if (axisTab->axisInterpretationDirty()) {
0768     axis->setAxisInterpretation(axisTab->axisInterpretation());
0769   }
0770   if (axisTab->timezoneDirty()) {
0771     axis->setTimezoneName(axisTab->timezone());
0772   }
0773   if (axisTab->isBaseOffsetDirty()) {
0774     axis->setAxisBaseOffset(axisTab->isBaseOffset());
0775   }
0776   if (axisTab->isForceOffsetMinDirty()) {
0777     axis->setAxisForceOffsetMin(axisTab->isForceOffsetMin());
0778   }
0779   if (axisTab->axisMinorTickCountDirty()) {
0780     axis->setAxisMinorTickCount(axisTab->axisMinorTickCount());
0781   }
0782   if (axisTab->isAutoMinorTickCountDirty()) {
0783     axis->setAxisAutoMinorTicks(axisTab->isAutoMinorTickCount());
0784   }
0785   if (axisTab->significantDigitsDirty()) {
0786     axis->setAxisSignificantDigits(axisTab->significantDigits());
0787   }
0788   if (axisTab->isAutoBaseOffsetDirty()) {
0789     axis->setAxisAutoBaseOffset(axisTab->isAutoBaseOffset());
0790   }
0791   if (axisTab->labelRotationDirty()) {
0792     axis->setAxisLabelRotation(axisTab->labelRotation());
0793   }
0794 }
0795 
0796 
0797 void PlotItemDialog::labelsChanged() {
0798   Q_ASSERT(_plotItem);
0799   if (editMode() == Multiple) {
0800     foreach(ViewItem* item, selectedMultipleEditObjects()) {
0801       PlotItem* plotItem = (PlotItem*)item;
0802       saveLabels(plotItem);
0803     }
0804   } else {
0805     saveLabels(_plotItem);
0806   }
0807   kstApp->mainWindow()->document()->setChanged(true);
0808 }
0809 
0810 
0811 void PlotItemDialog::saveLabels(PlotItem *item) {
0812   QString leftLabel = _labelTab->leftLabelDirty() ? _labelTab->leftLabel() :item->leftLabel();
0813   bool leftLabelAuto = _labelTab->leftLabelAutoDirty() ? _labelTab->leftLabelAuto() :item->leftLabelDetails()->isAuto();
0814   bool leftUseDefault = _leftLabelTab->useDefaultDirty() ? _leftLabelTab->useDefault() :item->leftLabelDetails()->fontUseGlobal();
0815   QFont leftFont = _leftLabelTab->labelFontDirty() ?
0816                    _leftLabelTab->labelFont(item->leftLabelDetails()->font()) :item->leftLabelDetails()->font();
0817   qreal leftFontScale = _leftLabelTab->labelFontScaleDirty() ? _leftLabelTab->labelFontScale() :item->leftLabelDetails()->fontScale();
0818   QColor leftFontColor = _leftLabelTab->labelColorDirty() ? _leftLabelTab->labelColor() :item->leftLabelDetails()->fontColor();
0819 
0820   QString bottomLabel = _labelTab->bottomLabelDirty() ? _labelTab->bottomLabel() :item->bottomLabel();
0821   bool bottomLabelAuto = _labelTab->bottomLabelAutoDirty() ? _labelTab->bottomLabelAuto() :item->bottomLabelDetails()->isAuto();
0822   bool bottomUseDefault = _bottomLabelTab->useDefaultDirty() ? _bottomLabelTab->useDefault() :item->bottomLabelDetails()->fontUseGlobal();
0823   QFont bottomFont = _bottomLabelTab->labelFontDirty() ?
0824                      _bottomLabelTab->labelFont(item->bottomLabelDetails()->font()) :item->bottomLabelDetails()->font();
0825   qreal bottomFontScale = _bottomLabelTab->labelFontScaleDirty() ? _bottomLabelTab->labelFontScale() :item->bottomLabelDetails()->fontScale();
0826   QColor bottomFontColor = _bottomLabelTab->labelColorDirty() ? _bottomLabelTab->labelColor() :item->bottomLabelDetails()->fontColor();
0827 
0828   QString rightLabel = _labelTab->rightLabelDirty() ? _labelTab->rightLabel() :item->rightLabel();
0829   bool rightLabelAuto = _labelTab->rightLabelAutoDirty() ? _labelTab->rightLabelAuto() :item->rightLabelDetails()->isAuto();
0830   bool rightUseDefault = _rightLabelTab->useDefaultDirty() ? _rightLabelTab->useDefault() :item->rightLabelDetails()->fontUseGlobal();
0831   QFont rightFont = _rightLabelTab->labelFontDirty() ?
0832                     _rightLabelTab->labelFont(item->rightLabelDetails()->font()) :item->rightLabelDetails()->font();
0833   qreal rightFontScale = _rightLabelTab->labelFontScaleDirty() ? _rightLabelTab->labelFontScale() :item->rightLabelDetails()->fontScale();
0834   QColor rightFontColor = _rightLabelTab->labelColorDirty() ? _rightLabelTab->labelColor() :item->rightLabelDetails()->fontColor();
0835 
0836   QString topLabel = _labelTab->topLabelDirty() ? _labelTab->topLabel() :item->topLabel();
0837   bool topLabelAuto = _labelTab->topLabelAutoDirty() ? _labelTab->topLabelAuto() :item->topLabelDetails()->isAuto();
0838   bool topUseDefault = _topLabelTab->useDefaultDirty() ? _topLabelTab->useDefault() :item->topLabelDetails()->fontUseGlobal();
0839   QFont topFont = _topLabelTab->labelFontDirty() ?
0840                   _topLabelTab->labelFont(item->topLabelDetails()->font()) :item->topLabelDetails()->font();
0841   qreal topFontScale = _topLabelTab->labelFontScaleDirty() ? _topLabelTab->labelFontScale() :item->topLabelDetails()->fontScale();
0842   QColor topFontColor = _topLabelTab->labelColorDirty() ? _topLabelTab->labelColor() :item->topLabelDetails()->fontColor();
0843 
0844   bool axisUseDefault = _axisLabelTab->useDefaultDirty() ? _axisLabelTab->useDefault() :item->numberLabelDetails()->fontUseGlobal();
0845   QFont axisFont = _axisLabelTab->labelFontDirty() ?
0846                    _axisLabelTab->labelFont(item->numberLabelDetails()->font()) :item->numberLabelDetails()->font();
0847   qreal axisFontScale = _axisLabelTab->labelFontScaleDirty() ? _axisLabelTab->labelFontScale() :item->numberLabelDetails()->fontScale();
0848   QColor axisFontColor = _axisLabelTab->labelColorDirty() ? _axisLabelTab->labelColor() :item->numberLabelDetails()->fontColor();
0849 
0850   QFont globalFont = _labelTab->globalLabelFontDirty() ? _labelTab->globalLabelFont(item->globalFont()) :item->globalFont();
0851   qreal globalFontScale = _labelTab->globalLabelFontScaleDirty() ? _labelTab->globalLabelFontScale() :item->globalFontScale();
0852   QColor globalFontColor = _labelTab->globalLabelColorDirty() ? _labelTab->globalLabelColor() :item->globalFontColor();
0853   bool showLegend = _labelTab->showLegendDirty() ? _labelTab->showLegend() :item->showLegend();
0854   bool axisLabelScale = _labelTab->autoScaleNumbersDirty() ? _labelTab->autoScaleNumbers() :item->isUseAxisScale();
0855 
0856   item->leftLabelDetails()->setDetails(leftLabel, leftLabelAuto, leftUseDefault, leftFont, leftFontScale, leftFontColor);
0857   item->bottomLabelDetails()->setDetails(bottomLabel, bottomLabelAuto, bottomUseDefault, bottomFont, bottomFontScale, bottomFontColor);
0858   item->rightLabelDetails()->setDetails(rightLabel, rightLabelAuto, rightUseDefault, rightFont, rightFontScale, rightFontColor);
0859   item->topLabelDetails()->setDetails(topLabel, topLabelAuto, topUseDefault, topFont, topFontScale, topFontColor);
0860   item->numberLabelDetails()->setDetails(QString(), false, axisUseDefault, axisFont, axisFontScale, axisFontColor);
0861 
0862   item->setGlobalFont(globalFont);
0863   item->setGlobalFontScale(globalFontScale);
0864   item->setGlobalFontColor(globalFontColor);
0865   item->setUseAxisScale(axisLabelScale);
0866 
0867   item->setShowLegend(showLegend, !item->showLegend()); // reset font size if legend isn't already shown.
0868 }
0869 
0870 
0871 void PlotItemDialog::xAxisPlotMarkersChanged() {
0872   Q_ASSERT(_plotItem);
0873   if (!_xMarkersTab->markersDirty()) {
0874     return;
0875   }
0876 
0877   PlotMarkers markers = _xMarkersTab->plotMarkers();
0878   if (editMode() == Multiple) {
0879     foreach(ViewItem* item, selectedMultipleEditObjects()) {
0880       PlotItem* plotItem = (PlotItem*)item;
0881       saveMarkers(plotItem->xAxis(), markers);
0882     }
0883   } else {
0884     saveMarkers(_plotItem->xAxis(), markers);
0885   }
0886   kstApp->mainWindow()->document()->setChanged(true);
0887 }
0888 
0889 
0890 void PlotItemDialog::yAxisPlotMarkersChanged() {
0891   Q_ASSERT(_plotItem);
0892   if (!_yMarkersTab->markersDirty()) {
0893     return;
0894   }
0895 
0896   PlotMarkers markers = _yMarkersTab->plotMarkers();
0897   if (editMode() == Multiple) {
0898     foreach(ViewItem* item, selectedMultipleEditObjects()) {
0899       PlotItem* plotItem = (PlotItem*)item;
0900       saveMarkers(plotItem->yAxis(), markers);
0901     }
0902   } else {
0903     saveMarkers(_plotItem->yAxis(), markers);
0904   }
0905   kstApp->mainWindow()->document()->setChanged(true);
0906 
0907 }
0908 
0909 
0910 void PlotItemDialog::saveMarkers(PlotAxis *axis, PlotMarkers &markers) {
0911   axis->setAxisPlotMarkers(markers);
0912 }
0913 
0914 
0915 void PlotItemDialog::useTopDefaultChanged(bool use) {
0916   if (use) {
0917     _labelPage->setTabText(1, tr("Top Font"));
0918     globalFontUpdate();
0919   } else {
0920     _labelPage->setTabText(1, tr("Top Font*"));
0921   }
0922 }
0923 
0924 
0925 void PlotItemDialog::useBottomDefaultChanged(bool use) {
0926   if (use) {
0927     _labelPage->setTabText(2, tr("Bottom Font"));
0928     globalFontUpdate();
0929   } else {
0930     _labelPage->setTabText(2, tr("Bottom Font*"));
0931   }
0932 }
0933 
0934 
0935 void PlotItemDialog::useLeftDefaultChanged(bool use) {
0936   if (use) {
0937     _labelPage->setTabText(3, tr("Left Font"));
0938     globalFontUpdate();
0939   } else {
0940     _labelPage->setTabText(3, tr("Left Font*"));
0941   }
0942 }
0943 
0944 
0945 void PlotItemDialog::useRightDefaultChanged(bool use) {
0946   if (use) {
0947     _labelPage->setTabText(4, tr("Right Font"));
0948     globalFontUpdate();
0949   } else {
0950     _labelPage->setTabText(4, tr("Right Font*"));
0951   }
0952 }
0953 
0954 
0955 void PlotItemDialog::useAxisDefaultChanged(bool use) {
0956   if (use) {
0957     _labelPage->setTabText(5, tr("Axis Font"));
0958     globalFontUpdate();
0959   } else {
0960     _labelPage->setTabText(5, tr("Axis Font*"));
0961   }
0962 }
0963 
0964 
0965 void PlotItemDialog::globalFontUpdate() {
0966   qreal fontScale = _labelTab->globalLabelFontScale();
0967   QFont font = _labelTab->globalLabelFont(QFont());
0968   QColor color = _labelTab->globalLabelColor();
0969 
0970   _topLabelTab->setFontSpecsIfDefault(font, fontScale, color);
0971   _bottomLabelTab->setFontSpecsIfDefault(font, fontScale, color);
0972   _leftLabelTab->setFontSpecsIfDefault(font, fontScale, color);
0973   _rightLabelTab->setFontSpecsIfDefault(font, fontScale, color);
0974   _axisLabelTab->setFontSpecsIfDefault(font, fontScale, color);
0975 }
0976 
0977 }
0978 
0979 // vim: ts=2 sw=2 et