Commit 2b5ae4e6 authored by David Saxton's avatar David Saxton

Moved all plot style group boxes to a custom widget.

svn path=/trunk/KDE/kdeedu/kmplot/; revision=529025
parent 902e4ae4
......@@ -127,3 +127,10 @@ kmplot/kmplotIface.h
kmplot/MainDlgIface.h
kmplot/parseriface.h
kmplot/Viewiface.h
kmplot/kmplot_part.desktop
kmplot/kmplot_part.rc
kmplot/kmplot_part_readonly.rc
kmplot/kmplot_shell.rc
kmplot/plotstylewidget.cpp
kmplot/plotstylewidget.h
kmplot/plotstylewidget.ui
......@@ -20,6 +20,7 @@ set(kmplotpart_PART_SRCS
kminmax.cpp
kmplotio.cpp
ksliderwindow.cpp
plotstylewidget.cpp
coordsconfigdialog.cpp )
kde4_automoc(${kmplotpart_PART_SRCS})
......@@ -30,6 +31,7 @@ kde4_add_ui_files(kmplotpart_PART_SRCS
editscaling.ui
qminmax.ui
qparametereditor.ui
plotstylewidget.ui
settingspagecolor.ui
settingspageconstants.ui
settingspagefonts.ui
......
......@@ -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
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_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
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
xdg_apps_DATA = kmplot.desktop
kde_kcfg_DATA = kmplot.kcfg
......@@ -1011,6 +1011,7 @@ void View::mousePressEvent(QMouseEvent *e)
m_currentFunctionID=-1;
m_zoomMode = AboutToTranslate;
m_prevDragMousePos = e->pos();
updateCursor();
}
......@@ -1423,6 +1424,8 @@ void View::mouseReleaseEvent ( QMouseEvent * e )
if ( doDrawPlot )
drawPlot();
else
update();
updateCursor();
}
......
......@@ -312,8 +312,15 @@ void FunctionEditor::initFromCartesian()
m_parameters = f->parameters;
m_editor->cartesianEquation->setText( f->eq[0]->fstr() );
m_editor->cartesian_f_lineWidth->setValue( f->f0.lineWidth );
m_editor->cartesian_f_lineColor->setColor( f->f0.color );
m_editor->cartesian_f0->init( f->f0 );
m_editor->cartesian_f1->init( f->f1 );
m_editor->cartesian_f2->init( f->f2 );
m_editor->cartesian_integral->init( f->integral );
m_editor->showDerivative1->setChecked( f->f1.visible );
m_editor->showDerivative2->setChecked( f->f2.visible );
m_editor->precision->setValue( f->integral_precision );
m_editor->cartesianCustomMin->setChecked( f->usecustomxmin );
m_editor->cartesianMin->setText( f->dmin.expression() );
......@@ -335,18 +342,6 @@ void FunctionEditor::initFromCartesian()
m_editor->listOfSliders->setCurrentIndex( f->use_slider );
}
m_editor->showDerivative1->setChecked( f->f1.visible );
m_editor->cartesian_f1_lineWidth->setValue( f->f1.lineWidth );
m_editor->cartesian_f1_lineColor->setColor( f->f1.color );
m_editor->showDerivative2->setChecked( f->f2.visible );
m_editor->cartesian_f2_lineWidth->setValue( f->f2.lineWidth );
m_editor->cartesian_f2_lineColor->setColor( f->f2.color );
m_editor->precision->setValue( f->integral_precision );
m_editor->cartesian_F_lineWidth->setValue( f->integral.lineWidth );
m_editor->cartesian_F_lineColor->setColor( f->integral.color );
m_editor->showIntegral->setChecked( f->integral.visible );
m_editor->customPrecision->setChecked( f->integral_use_precision );
m_editor->txtInitX->setText( f->eq[0]->integralInitialX().expression() );
......@@ -374,8 +369,7 @@ void FunctionEditor::initFromPolar()
m_editor->polarMin->setText( f->dmin.expression() );
m_editor->polarCustomMax->setChecked( f->usecustomxmax );
m_editor->polarMax->setText( f->dmax.expression() );
m_editor->polarLineWidth->setValue( f->f0.lineWidth );
m_editor->polarLineColor->setColor( f->f0.color );
m_editor->polar_f0->init( f->f0 );
m_editor->stackedWidget->setCurrentIndex( 2 );
m_editor->polarEquation->setFocus();
......@@ -404,9 +398,8 @@ void FunctionEditor::initFromParametric()
m_editor->parametricMin->setText( f->dmin.expression() );
m_editor->parametricMax->setText( f->dmax.expression() );
m_editor->parametricLineWidth->setValue( f->f0.lineWidth );
m_editor->parametricLineColor->setColor( f->f0.color );
m_editor->parametric_f0->init( f->f0 );
m_editor->stackedWidget->setCurrentIndex( 1 );
m_editor->parametricName->setFocus();
......@@ -554,33 +547,21 @@ void FunctionEditor::saveCartesian()
if ( tempFunction.usecustomxmax && !ok )
return;
tempFunction.f0.lineWidth = m_editor->cartesian_f_lineWidth->value();
tempFunction.f0.color = m_editor->cartesian_f_lineColor->color();
tempFunction.f0 = m_editor->cartesian_f0->plot( (functionListItem->checkState() == Qt::Checked) );
tempFunction.f1 = m_editor->cartesian_f1->plot( m_editor->showDerivative1->isChecked() );
tempFunction.f2 = m_editor->cartesian_f2->plot( m_editor->showDerivative2->isChecked() );
tempFunction.integral = m_editor->cartesian_integral->plot( m_editor->showIntegral->isChecked() );
tempFunction.integral.visible = m_editor->showIntegral->isChecked();
tempFunction.eq[0]->setIntegralStart( m_editor->txtInitX->text(), m_editor->txtInitY->text() );
tempFunction.integral.color = m_editor->cartesian_F_lineColor->color();
tempFunction.integral_use_precision = m_editor->customPrecision->isChecked();
tempFunction.integral_precision = m_editor->precision->value();
tempFunction.integral.lineWidth = m_editor->cartesian_F_lineWidth->value();
if ( functionListItem )
tempFunction.f0.visible = (functionListItem->checkState() == Qt::Checked);
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;
tempFunction.f1.visible = m_editor->showDerivative1->isChecked();
tempFunction.f1.lineWidth = m_editor->cartesian_f1_lineWidth->value();
tempFunction.f1.color = m_editor->cartesian_f1_lineColor->color();
tempFunction.f2.visible = m_editor->showDerivative2->isChecked();
tempFunction.f2.lineWidth = m_editor->cartesian_f2_lineWidth->value();
tempFunction.f2.color = m_editor->cartesian_f1_lineColor->color();
if ( f_str.contains('y') != 0 && ( tempFunction.f0.visible || tempFunction.f1.visible || tempFunction.f2.visible) )
{
......@@ -652,10 +633,7 @@ void FunctionEditor::savePolar()
QString f_str = m_editor->polarEquation->text();
XParser::self()->fixFunctionName( f_str, Equation::Polar, f->id );
Function tempFunction( Function::Polar ); //all settings are saved here until we know that no errors have appeared
if ( functionListItem )
tempFunction.f0.visible = (functionListItem->checkState() == Qt::Checked);
Function tempFunction( Function::Polar ); // all settings are saved here until we know that no errors have appeared
tempFunction.usecustomxmin = m_editor->polarCustomMin->isChecked();
bool ok = tempFunction.dmin.updateExpression( m_editor->polarMin->text() );
......@@ -676,8 +654,8 @@ void FunctionEditor::savePolar()
return;
}
tempFunction.f0.lineWidth = m_editor->polarLineWidth->value();
tempFunction.f0.color = m_editor->polarLineColor->color();
tempFunction.f0 = m_editor->polar_f0->plot( (functionListItem->checkState() == Qt::Checked) );
tempFunction.use_slider = -1;
if ( !tempFunction.eq[0]->setFstr( f_str ) )
......@@ -737,8 +715,6 @@ void FunctionEditor::saveParametric()
}
Function tempFunction( Function::Parametric );
if ( functionListItem )
tempFunction.f0.visible = (functionListItem->checkState() == Qt::Checked);
tempFunction.usecustomxmin = true;
bool ok = tempFunction.dmin.updateExpression( m_editor->parametricMin->text() );
......@@ -757,10 +733,8 @@ void FunctionEditor::saveParametric()
// m_editor->min->selectAll();
return;
}
tempFunction.f0.lineWidth = m_editor->parametricLineWidth->value();
tempFunction.f0.color = m_editor->parametricLineColor->color();
tempFunction.f1.color = tempFunction.f2.color = tempFunction.integral.color = tempFunction.f0.color;
tempFunction.f0 = m_editor->parametric_f0->plot( (functionListItem->checkState() == Qt::Checked) );
if ( !tempFunction.eq[0]->setFstr( parametricXPrefix() ) )
return;
......
This diff is collapsed.
/*
* 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 "plotstylewidget.h"
//BEGIN class PlotStyleWidget
PlotStyleWidget::PlotStyleWidget( QWidget * parent )
: QGroupBox( parent )
{
setupUi(this);
}
void PlotStyleWidget::init( const Plot & plot )
{
color->setColor( plot.color );
lineWidth->setValue( plot.lineWidth );
}
Plot PlotStyleWidget::plot( bool visible )
{
Plot p;
p.color = color->color();
p.lineWidth = lineWidth->value();
p.visible = visible;
return p;
}
//END class PlotStyleWidget
#include "plotstylewidget.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 _PLOTSTYLEWIDGET_H
#define _PLOTSTYLEWIDGET_H
#include <QGroupBox>
#include "ui_plotstylewidget.h"
class Plot;
class PlotStyleWidget : public QGroupBox, public Ui_PlotStyleWidet
{
Q_OBJECT
public:
PlotStyleWidget( QWidget * parent );
/**
* Initializes the contents of the widgets to the settings in \p plot.
*/
void init( const Plot & plot );
/**
* \return A plot with appearance configured by this widget.
* \param visible Whether the plot is visible (this widget does not
* control that aspect of a Plot).
*/
Plot plot( bool visible );
};
#endif
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>PlotStyleWidet</class>
<widget class="QWidget" name="PlotStyleWidet" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>327</width>
<height>76</height>
</rect>
</property>
<property name="windowTitle" >
<string>Plot Style</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="KColorButton" name="color" >
<property name="toolTip" >
<string>color of the plot line</string>
</property>
<property name="whatsThis" >
<string>Click this button to choose a color for the plot line.</string>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QDoubleSpinBox" name="lineWidth" >
<property name="alignment" >
<set>Qt::AlignRight</set>
</property>
<property name="suffix" >
<string> mm</string>
</property>
<property name="decimals" >
<number>1</number>
</property>
<property name="minimum" >
<double>0.1</double>
</property>
<property name="singleStep" >
<double>0.1</double>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="textLabel1_3" >
<property name="text" >
<string>Line &amp;width:</string>
</property>
<property name="buddy" >
<cstring>lineWidth</cstring>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="textLabel2" >
<property name="text" >
<string>Co&amp;lor:</string>
</property>
<property name="buddy" >
<cstring>color</cstring>
</property>
</widget>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<customwidgets>
<customwidget>
<class>KColorButton</class>
<extends></extends>
<header>kcolorbutton.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment