File indexing completed on 2024-04-14 03:40:35

0001 /*************************************************************************************
0002  *  Copyright (C) 2012 by Percy Camilo T. Aucahuasi <percy.camilo.ta@gmail.com>      *
0003  *                                                                                   *
0004  *  This program is free software; you can redistribute it and/or                    *
0005  *  modify it under the terms of the GNU General Public License                      *
0006  *  as published by the Free Software Foundation; either version 2                   *
0007  *  of the License, or (at your option) any later version.                           *
0008  *                                                                                   *
0009  *  This program is distributed in the hope that it will be useful,                  *
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of                   *
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                    *
0012  *  GNU General Public License for more details.                                     *
0013  *                                                                                   *
0014  *  You should have received a copy of the GNU General Public License                *
0015  *  along with this program; if not, write to the Free Software                      *
0016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA   *
0017  *************************************************************************************/
0018 
0019 #include "spaceoptions.h"
0020 #include "ui_spaceoptions.h"
0021 
0022 //KDE includes
0023 #include <kcolorutils.h>
0024 #include <KLocalizedString>
0025 
0026 //C++ includes
0027 #include <cmath>
0028 
0029 SpaceOptions::SpaceOptions(QWidget* parent): QDockWidget(parent)
0030 {
0031     m_widget = new Ui::SpaceOptionsWidget;
0032     m_widget->setupUi(this);
0033     m_widget->moreOptions->setChecked(false);
0034     setObjectName("khipu_diagram_spaceoptions_dock");
0035     
0036     //BEGIN default grid style: NONE (see too Dashboard::initializePlotsViews)
0037     m_widget->gridStyle->setCurrentIndex(0);
0038     m_widget->backgroundColor->hide();
0039     //END
0040 
0041     //BEGIN setup tick marks
0042     //NOTE always from lower to greater : from 1 to pi
0043     
0044     QString sqrtsym = QString((QChar(0x221A)));
0045     
0046     m_widget->scale->addItem("1");
0047     m_widget->scale->addItem(sqrtsym+'2');
0048     m_widget->scale->addItem(sqrtsym+'3');
0049     m_widget->scale->addItem("e");
0050     m_widget->scale->addItem(QString((QChar(0x03C0))));
0051     
0052     m_widget->scale->setCurrentIndex(0);
0053     //END
0054 
0055     //signals
0056     connect(m_widget->gridStyle, SIGNAL(currentIndexChanged(int)), SLOT(setGridStyle(int)));
0057     connect(m_widget->backgroundColor, SIGNAL(activated(QColor)), SIGNAL(updateGridColor(QColor)));
0058     connect(m_widget->horizontalLabel, SIGNAL(textChanged(QString)), SIGNAL(setXAxisLabel(QString)));
0059     connect(m_widget->verticalLabel, SIGNAL(textChanged(QString)), SIGNAL(setYAxisLabel(QString)));
0060     connect(m_widget->scale, SIGNAL(currentIndexChanged(int)), SLOT(updateScale()));
0061 
0062     connect(m_widget->marksVisible, SIGNAL(toggled(bool)), SLOT(updateTicks()));
0063     connect(m_widget->showXAxis, SIGNAL(toggled(bool)), SLOT(updateAxes()));
0064     connect(m_widget->showYAxis, SIGNAL(toggled(bool)), SLOT(updateAxes()));
0065     
0066     //3d
0067     connect(m_widget->showAxis, SIGNAL(toggled(bool)), SIGNAL(axisIsDrawn(bool)));
0068     connect(m_widget->showGrid, SIGNAL(toggled(bool)), SIGNAL(gridIsDrawn(bool)));
0069     connect(m_widget->sceneSize, SIGNAL(valueChanged(int)), SIGNAL(sceneResized(int)));
0070     
0071     //TODO too much code : set default grid color (same of plotsview2d)
0072     m_widget->backgroundColor->setColor(palette().color(QPalette::Active, QPalette::Base));
0073 }
0074 
0075 SpaceOptions::~SpaceOptions()
0076 {
0077     delete m_widget;
0078 }
0079 
0080 void SpaceOptions::reset()
0081 {}
0082 
0083 void SpaceOptions::setGridStyleIndex(int i)
0084 {
0085     m_widget->gridStyle->setCurrentIndex(i);
0086 }
0087 
0088 void SpaceOptions::setDimension(int d)
0089 {
0090     m_widget->options->setCurrentIndex(d-2); //-2 porque si dim es 2 se muestra las optiones cero (para el view2d)
0091 }
0092 
0093 void SpaceOptions::setGridStyle(int i)
0094 {
0095     emit updateGridStyle(i);
0096     
0097     m_widget->backgroundColor->setVisible(i!=0);
0098 }
0099 
0100 void SpaceOptions::updateAxes()
0101 {
0102     QFlags<Qt::Orientation> o;
0103     if(m_widget->showXAxis->checkState()==Qt::Checked)
0104         o|=Qt::Horizontal;
0105     if(m_widget->showYAxis->checkState()==Qt::Checked)
0106         o|=Qt::Vertical;
0107     emit axesShown(o);
0108 }
0109 
0110 void SpaceOptions::updateTicks()
0111 {
0112     QFlags<Qt::Orientation> o;
0113     
0114     if (m_widget->marksVisible->checkState()==Qt::Checked){
0115         o|=Qt::Horizontal;
0116         o|=Qt::Vertical;
0117     }
0118     
0119     emit ticksShown(o);
0120 }
0121 
0122 #include "moc_spaceoptions.cpp"