File indexing completed on 2024-12-22 04:17:26
0001 /*************************************************************************** 0002 * * 0003 * copyright : (C) 2012 Barth Netterfield * 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 "circledimensionstab.h" 0013 #include "plotitem.h" 0014 #include <QDebug> 0015 0016 namespace Kst { 0017 CircleDimensionsTab::CircleDimensionsTab(ViewItem* viewItem, QWidget *parent) 0018 : DialogTab(parent), _viewItem(viewItem) { 0019 setupUi(this); 0020 0021 connect(_lockPosToData, SIGNAL(clicked(bool)), this, SLOT(fillDimensions(bool))); 0022 } 0023 0024 void CircleDimensionsTab::fillDimensions(bool lock_pos_to_data) { 0025 if (lock_pos_to_data) { 0026 _x->setRange(-1E308, 1E308); 0027 _y->setRange(-1E308, 1E308); 0028 _radius->setRange(0,1E308); 0029 _x->setValue(_viewItem->dataRelativeRect().center().x()); 0030 _y->setValue(_viewItem->dataRelativeRect().center().y()); 0031 _radius->setValue(0.5*_viewItem->dataRelativeRect().width()); 0032 } else { 0033 _x->setRange(0, 1); 0034 _y->setRange(0, 1); 0035 _radius->setRange(0,1); 0036 _x->setValue(_viewItem->relativeCenter().x()); 0037 _y->setValue(_viewItem->relativeCenter().y()); 0038 _radius->setValue(0.5*_viewItem->relativeWidth()); 0039 } 0040 } 0041 0042 void CircleDimensionsTab::setupDimensions() { 0043 0044 fillDimensions(_viewItem->dataPosLockable() && _viewItem->lockPosToData()); 0045 0046 _lockPosToData->setChecked(_viewItem->lockPosToData()); 0047 if (_viewItem->dataPosLockable()) { 0048 _lockPosToData->show(); 0049 } else { 0050 _lockPosToData->hide(); 0051 } 0052 } 0053 0054 0055 void CircleDimensionsTab::modified() { 0056 emit tabModified(); 0057 } 0058 0059 0060 void CircleDimensionsTab::clearTabValues() { 0061 _radius->clear(); 0062 _lockPosToData->setCheckState(Qt::PartiallyChecked); 0063 } 0064 0065 0066 void CircleDimensionsTab::enableSingleEditOptions(bool enabled) { 0067 _x->setEnabled(enabled); 0068 _y->setEnabled(enabled); 0069 } 0070 0071 0072 bool CircleDimensionsTab::radiusDirty() const { 0073 return (!_radius->text().isEmpty()); 0074 } 0075 0076 0077 bool CircleDimensionsTab::lockPosToDataDirty() const { 0078 return _lockPosToData->checkState() != Qt::PartiallyChecked; 0079 } 0080 0081 }