Commit a8b93d06 authored by David Saxton's avatar David Saxton

Moved the grouped widgets for editing parameters to a custom widget; this will

allow easy addition to Parametric and Polar plots.

svn path=/trunk/KDE/kdeedu/kmplot/; revision=529269
parent 90fac660
......@@ -134,3 +134,6 @@ kmplot/kmplot_shell.rc
kmplot/plotstylewidget.cpp
kmplot/plotstylewidget.h
kmplot/plotstylewidget.ui
kmplot/parameterswidget.cpp
kmplot/parameterswidget.h
kmplot/parameterswidget.ui
......@@ -21,6 +21,7 @@ set(kmplotpart_PART_SRCS
kmplotio.cpp
ksliderwindow.cpp
plotstylewidget.cpp
parameterswidget.cpp
coordsconfigdialog.cpp )
kde4_automoc(${kmplotpart_PART_SRCS})
......@@ -37,6 +38,7 @@ kde4_add_ui_files(kmplotpart_PART_SRCS
settingspagefonts.ui
settingspagegeneral.ui
sliderwindow.ui
parameterswidget.ui
)
kde4_add_dcop_skels(kmplotpart_PART_SRCS MainDlgIface.h parseriface.h Viewiface.h )
......
......@@ -44,7 +44,7 @@ shellrc_DATA = kmplot_shell.rc
kde_module_LTLIBRARIES = libkmplotpart.la
# the Part's source, library search path, and link libraries
libkmplotpart_la_SOURCES = functioneditorwidget.ui functioneditor.cpp parser.cpp xparser.cpp diagr.cpp View.cpp MainDlg.cpp kprinterdlg.cpp settings.kcfgc settingspagecolor.ui kconstanteditor.cpp qparametereditor.ui kparametereditor.cpp editcoords.ui settingspageconstants.ui settingspagefonts.ui editscaling.ui settingspagegeneral.ui qminmax.ui kminmax.cpp kmplotio.cpp sliderwindow.ui ksliderwindow.cpp MainDlgIface.skel parseriface.skel Viewiface.skel coordsconfigdialog.cpp function.cpp equationedit.cpp plotstylewidget.cpp plotstylewidget.ui
libkmplotpart_la_SOURCES = functioneditorwidget.ui functioneditor.cpp parser.cpp xparser.cpp diagr.cpp View.cpp MainDlg.cpp kprinterdlg.cpp settings.kcfgc settingspagecolor.ui kconstanteditor.cpp qparametereditor.ui kparametereditor.cpp editcoords.ui settingspageconstants.ui settingspagefonts.ui editscaling.ui settingspagegeneral.ui qminmax.ui kminmax.cpp kmplotio.cpp sliderwindow.ui ksliderwindow.cpp MainDlgIface.skel parseriface.skel Viewiface.skel coordsconfigdialog.cpp function.cpp equationedit.cpp plotstylewidget.cpp plotstylewidget.ui parameterswidget.cpp parameterswidget.ui
libkmplotpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
libkmplotpart_la_LIBADD = $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET) $(LIB_KDEPRINT)
......@@ -56,7 +56,7 @@ partdesktop_DATA = kmplot_part.desktop
partrcdir = $(kde_datadir)/kmplot
partrc_DATA = kmplot_part.rc kmplot_part_readonly.rc
EXTRA_DIST = kmplot.desktop functioneditor.h MainDlg.cpp MainDlg.h View.h diagr.cpp diagr.h xparser.h parser.h kprinterdlg.h ksliderwindow.h kconstanteditor.h kparametereditor.h kmplotio.h kminmax.h coordsconfigdialog.h function.h plotstylewidget.h
EXTRA_DIST = kmplot.desktop functioneditor.h MainDlg.cpp MainDlg.h View.h diagr.cpp diagr.h xparser.h parser.h kprinterdlg.h ksliderwindow.h kconstanteditor.h kparametereditor.h kmplotio.h kminmax.h coordsconfigdialog.h function.h plotstylewidget.h parameterswidget.h
xdg_apps_DATA = kmplot.desktop
kde_kcfg_DATA = kmplot.kcfg
......@@ -26,11 +26,11 @@
#include "equationedit.h"
#include "functioneditor.h"
#include "ui_functioneditorwidget.h"
#include "kmplotio.h"
#include "kparametereditor.h"
#include "View.h"
#include "MainDlg.h"
#include "parameterswidget.h"
#include "ui_functioneditorwidget.h"
#include "View.h"
#include "xparser.h"
#include <kaction.h>
......@@ -91,13 +91,9 @@ FunctionEditor::FunctionEditor( KMenu * createNewPlotsMenu, QWidget * parent )
for ( unsigned i = 0; i < 3; ++i )
m_editor->stackedWidget->widget(i)->layout()->setMargin( 0 );
for( int number = 0; number < SLIDER_COUNT; number++ )
m_editor->listOfSliders->addItem( i18n( "Slider No. %1", number +1) );
connect( m_editor->deleteButton, SIGNAL(clicked()), this, SLOT(deleteCurrent()) );
connect( m_functionList, SIGNAL(currentItemChanged( QListWidgetItem *, QListWidgetItem * )), this, SLOT(functionSelected( QListWidgetItem* )) );
connect( m_functionList, SIGNAL(itemClicked( QListWidgetItem * )), this, SLOT(save()) ); // user might have checked or unchecked the item
connect( m_editor->editParameterListButton, SIGNAL(clicked()), this, SLOT(editParameterList()) );
//BEGIN connect up all editing widgets
QList<QLineEdit *> lineEdits = m_editor->findChildren<QLineEdit *>();
......@@ -127,6 +123,8 @@ FunctionEditor::FunctionEditor( KMenu * createNewPlotsMenu, QWidget * parent )
QList<QComboBox *> comboBoxes = m_editor->findChildren<QComboBox *>();
foreach ( QComboBox * w, comboBoxes )
connect( w, SIGNAL(currentIndexChanged(int)), this, SLOT(save()) );
connect( m_editor->cartesianParameters, SIGNAL( parameterListChanged() ), this, SLOT(save()) );
//END connect up all editing widgets
connect( XParser::self(), SIGNAL(functionAdded(int)), this, SLOT(functionsChanged()) );
......@@ -309,8 +307,6 @@ void FunctionEditor::initFromCartesian()
return;
}
m_parameters = f->parameters;
m_editor->cartesianEquation->setText( f->eq[0]->fstr() );
m_editor->cartesian_f0->init( f->f0 );
m_editor->cartesian_f1->init( f->f1 );
......@@ -328,19 +324,7 @@ void FunctionEditor::initFromCartesian()
m_editor->cartesianCustomMax->setChecked( f->usecustomxmax );
m_editor->cartesianMax->setText( f->dmax.expression() );
if( f->use_slider == -1 )
{
m_editor->listOfSliders->setCurrentIndex( f->use_slider );
if ( f->parameters.isEmpty() )
m_editor->cartesianDisableParameters->setChecked( true );
else
m_editor->cartesianParametersList->setChecked( true );
}
else
{
m_editor->cartesianParameterSlider->setChecked( true );
m_editor->listOfSliders->setCurrentIndex( f->use_slider );
}
m_editor->cartesianParameters->init( f );
m_editor->showIntegral->setChecked( f->integral.visible );
m_editor->customPrecision->setChecked( f->integral_use_precision );
......@@ -554,12 +538,6 @@ void FunctionEditor::saveCartesian()
tempFunction.integral_use_precision = m_editor->customPrecision->isChecked();
tempFunction.integral_precision = m_editor->precision->value();
tempFunction.parameters = m_parameters;
if( m_editor->cartesianParameterSlider->isChecked() )
tempFunction.use_slider = m_editor->listOfSliders->currentIndex(); //specify which slider that will be used
else
tempFunction.use_slider = -1;
if ( f_str.contains('y') != 0 && ( tempFunction.f0.visible || tempFunction.f1.visible || tempFunction.f2.visible) )
{
......@@ -567,13 +545,16 @@ void FunctionEditor::saveCartesian()
return;
}
if ( ( (!m_parameters.isEmpty() &&
m_editor->cartesianParametersList->isChecked() ) ||
m_editor->cartesianParameterSlider->isChecked() ) &&
!cartesianHasTwoArguments( f_str ) )
{
fixCartesianArguments( & f_str ); //adding an extra argument for the parameter value
}
m_editor->cartesianParameters->save( & tempFunction );
/// \todo Work out what this is suppose to do and fix it
// if ( ( (!m_parameters.isEmpty() &&
// m_editor->cartesianParametersList->isChecked() ) ||
// m_editor->cartesianParameterSlider->isChecked() ) &&
// !cartesianHasTwoArguments( f_str ) )
// {
// fixCartesianArguments( & f_str ); //adding an extra argument for the parameter value
// }
if ( !tempFunction.eq[0]->setFstr( f_str ) )
return;
......@@ -761,14 +742,6 @@ QString FunctionEditor::parametricYPrefix() const
{
return 'y' + m_editor->parametricName->text() + "(t)=" + m_editor->parametricY->text();
}
void FunctionEditor::editParameterList()
{
KParameterEditor * dlg = new KParameterEditor( XParser::self(), & m_parameters );
dlg->exec();
saveCartesian();
}
//END class FunctionEditor
......
......@@ -94,10 +94,6 @@ class FunctionEditor : public QDockWidget
* Called when the user changes a function widget.
*/
void save();
/**
* Called when the "Edit [parameter] List" button is clicked.
*/
void editParameterList();
/**
* Updates the list of functions (called when a function is added or
* removed from Parser).
......@@ -181,11 +177,6 @@ class FunctionEditor : public QDockWidget
* necessary changes first.
*/
QTimer * m_syncFunctionListTimer;
/**
* If we are currently editing a cartesian function, this will be set
* to its parameter list.
*/
QList<Value> m_parameters;
/**
* The list of functions.
*/
......
......@@ -8,8 +8,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>510</width>
<height>647</height>
<width>483</width>
<height>595</height>
</rect>
</property>
<property name="windowTitle" >
......@@ -81,7 +81,7 @@
<item>
<widget class="QStackedWidget" name="stackedWidget" >
<property name="currentIndex" >
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="page" >
<layout class="QVBoxLayout" >
......@@ -128,80 +128,10 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="cartesianParameters" >
<widget class="ParametersWidget" name="cartesianParameters" >
<property name="title" >
<string>Parameter Values</string>
<string>Parameters</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item rowspan="2" row="0" column="0" colspan="2" >
<widget class="QRadioButton" name="cartesianDisableParameters" >
<property name="text" >
<string>Disable</string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QRadioButton" name="cartesianParametersList" >
<property name="toolTip" >
<string>read parameter values from a list</string>
</property>
<property name="whatsThis" >
<string>Check this to let KmPlot use parameter values given in a list. Edit this list by clicking the button on the right.</string>
</property>
<property name="text" >
<string>From a list:</string>
</property>
</widget>
</item>
<item row="3" column="1" >
<widget class="QComboBox" name="listOfSliders" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="toolTip" >
<string>Select a slider</string>
</property>
<property name="whatsThis" >
<string>Select one of the sliders to change the parameter value dynamically. The values vary from 0 (left) to 100 (right).</string>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QRadioButton" name="cartesianParameterSlider" >
<property name="toolTip" >
<string>change parameter value by moving a slider</string>
</property>
<property name="whatsThis" >
<string>Check this to change the parameter value by moving a slider. Select the slider from the list box on the right. The values vary from 0 (left) to 100 (right).</string>
</property>
<property name="text" >
<string>Use a slider:</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="KPushButton" name="editParameterListButton" >
<property name="enabled" >
<bool>false</bool>
</property>
<property name="toolTip" >
<string>Edit the list of parameters</string>
</property>
<property name="whatsThis" >
<string>Click here to open a list of parameter values. Here you can add, remove, and change them.</string>
</property>
<property name="text" >
<string>Edit List...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
......@@ -933,9 +863,9 @@ Example: loop(angle)=ln(angle)</string>
<pixmapfunction></pixmapfunction>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<class>KDoubleNumInput</class>
<extends></extends>
<header>klineedit.h</header>
<header>knuminput.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
......@@ -947,23 +877,23 @@ Example: loop(angle)=ln(angle)</string>
<pixmap></pixmap>
</customwidget>
<customwidget>
<class>KDoubleNumInput</class>
<extends></extends>
<header>knuminput.h</header>
<class>EquationEdit</class>
<extends>KLineEdit</extends>
<header>equationedit.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
<customwidget>
<class>KPushButton</class>
<extends></extends>
<header>kpushbutton.h</header>
<class>ParametersWidget</class>
<extends>QGroupBox</extends>
<header>parameterswidget.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
<customwidget>
<class>EquationEdit</class>
<extends>KLineEdit</extends>
<header>equationedit.h</header>
<class>KLineEdit</class>
<extends></extends>
<header>klineedit.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
......@@ -975,6 +905,31 @@ Example: loop(angle)=ln(angle)</string>
<pixmap></pixmap>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>functionList</tabstop>
<tabstop>deleteButton</tabstop>
<tabstop>createNewPlot</tabstop>
<tabstop>tabWidget</tabstop>
<tabstop>cartesianEquation</tabstop>
<tabstop>cartesianCustomMin</tabstop>
<tabstop>cartesianMin</tabstop>
<tabstop>cartesianCustomMax</tabstop>
<tabstop>cartesianMax</tabstop>
<tabstop>showDerivative1</tabstop>
<tabstop>showDerivative2</tabstop>
<tabstop>showIntegral</tabstop>
<tabstop>txtInitX</tabstop>
<tabstop>txtInitY</tabstop>
<tabstop>customPrecision</tabstop>
<tabstop>parametricName</tabstop>
<tabstop>parametricX</tabstop>
<tabstop>parametricY</tabstop>
<tabstop>parametricMin</tabstop>
<tabstop>parametricMax</tabstop>
<tabstop>polarEquation</tabstop>
<tabstop>polarMin</tabstop>
<tabstop>polarMax</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
......@@ -984,8 +939,8 @@ Example: loop(angle)=ln(angle)</string>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>110</x>
<y>297</y>
<x>119</x>
<y>258</y>
</hint>
<hint type="destinationlabel" >
<x>110</x>
......@@ -1000,8 +955,8 @@ Example: loop(angle)=ln(angle)</string>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>212</x>
<y>370</y>
<x>119</x>
<y>258</y>
</hint>
<hint type="destinationlabel" >
<x>255</x>
......@@ -1016,12 +971,12 @@ Example: loop(angle)=ln(angle)</string>
<slot>setText(QString)</slot>
<hints>
<hint type="sourcelabel" >
<x>241</x>
<y>292</y>
<x>108</x>
<y>224</y>
</hint>
<hint type="destinationlabel" >
<x>41</x>
<y>324</y>
<x>50</x>
<y>224</y>
</hint>
</hints>
</connection>
......@@ -1032,44 +987,12 @@ Example: loop(angle)=ln(angle)</string>
<slot>setText(QString)</slot>
<hints>
<hint type="sourcelabel" >
<x>276</x>
<y>292</y>
</hint>
<hint type="destinationlabel" >
<x>41</x>
<y>355</y>
</hint>
</hints>
</connection>
<connection>
<sender>cartesianParametersList</sender>
<signal>toggled(bool)</signal>
<receiver>editParameterListButton</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>155</x>
<y>391</y>
</hint>
<hint type="destinationlabel" >
<x>470</x>
<y>394</y>
</hint>
</hints>
</connection>
<connection>
<sender>cartesianParameterSlider</sender>
<signal>toggled(bool)</signal>
<receiver>listOfSliders</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>168</x>
<y>423</y>
<x>108</x>
<y>224</y>
</hint>
<hint type="destinationlabel" >
<x>470</x>
<y>423</y>
<x>50</x>
<y>224</y>
</hint>
</hints>
</connection>
......@@ -1080,12 +1003,12 @@ Example: loop(angle)=ln(angle)</string>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>93</x>
<y>297</y>
<x>104</x>
<y>258</y>
</hint>
<hint type="destinationlabel" >
<x>63</x>
<y>365</y>
<x>74</x>
<y>258</y>
</hint>
</hints>
</connection>
......@@ -1096,8 +1019,8 @@ Example: loop(angle)=ln(angle)</string>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>108</x>
<y>297</y>
<x>119</x>
<y>258</y>
</hint>
<hint type="destinationlabel" >
<x>113</x>
......@@ -1112,12 +1035,12 @@ Example: loop(angle)=ln(angle)</string>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel" >
<x>139</x>
<y>297</y>
<x>119</x>
<y>258</y>
</hint>
<hint type="destinationlabel" >
<x>139</x>
<y>449</y>
<x>119</x>
<y>258</y>
</hint>
</hints>
</connection>
......@@ -1129,11 +1052,11 @@ Example: loop(angle)=ln(angle)</string>
<hints>
<hint type="sourcelabel" >
<x>90</x>
<y>491</y>
<y>344</y>
</hint>
<hint type="destinationlabel" >
<x>409</x>
<y>491</y>
<x>442</x>
<y>344</y>
</hint>
</hints>
</connection>
......@@ -1145,11 +1068,11 @@ Example: loop(angle)=ln(angle)</string>
<hints>
<hint type="sourcelabel" >
<x>90</x>
<y>522</y>
<y>375</y>
</hint>
<hint type="destinationlabel" >
<x>409</x>
<y>522</y>
<x>442</x>
<y>375</y>
</hint>
</hints>
</connection>
......
/*
* KmPlot - a math. function plotter for the KDE-Desktop
*
* Copyright (C) 2006 David Saxton <david@bluehaze.org>
*
* This file is part of the KDE Project.
* KmPlot is part of the KDE-EDU Project.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "function.h"
#include "kparametereditor.h"
#include "parameterswidget.h"
#include "xparser.h"
#include <klocale.h>
//BEGIN class ParametersWidget
ParametersWidget::ParametersWidget( QWidget * parent )
: QGroupBox( parent )
{
setupUi(this);
for( int number = 0; number < SLIDER_COUNT; number++ )
listOfSliders->addItem( i18n( "Slider No. %1", number +1) );
connect( editParameterListButton, SIGNAL(clicked()), this, SLOT(editParameterList()) );
}
void ParametersWidget::init( Function * function )
{
m_parameters = function->parameters;
if( function->use_slider == -1 )
{
listOfSliders->setCurrentIndex( function->use_slider );
if ( function->parameters.isEmpty() )
disableParameters->setChecked( true );
else
parametersList->setChecked( true );
}
else
{
parameterSlider->setChecked( true );
listOfSliders->setCurrentIndex( function->use_slider );
}
}
void ParametersWidget::save( Function * function )
{
function->parameters = m_parameters;
if ( parameterSlider->isChecked() )
function->use_slider = listOfSliders->currentIndex(); //specify which slider that will be used
else
function->use_slider = -1;
}
void ParametersWidget::editParameterList()
{
KParameterEditor * dlg = new KParameterEditor( XParser::self(), & m_parameters );
dlg->exec();
emit parameterListChanged();
}
//END class ParametersWidget
#include "parameterswidget.moc"
/*
* KmPlot - a math. function plotter for the KDE-Desktop
*
* Copyright (C) 2006 David Saxton <david@bluehaze.org>
*
* This file is part of the KDE Project.
* KmPlot is part of the KDE-EDU Project.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef _PARAMETERSWIDGET_H
#define _PARAMETERSWIDGET_H
#include <QGroupBox>
#include <QList>
#include "ui_parameterswidget.h"
class ParametersWidget : public QGroupBox, public Ui_ParametersWidget
{
Q_OBJECT
public:
ParametersWidget( QWidget * parent );