"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/kdefrontend/dockwidgets/XYEquationCurveDock.cpp" between
labplot-2.8.1.tar.gz and labplot-2.8.2.tar.gz

About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.

XYEquationCurveDock.cpp  (labplot-2.8.1):XYEquationCurveDock.cpp  (labplot-2.8.2)
/*************************************************************************** /***************************************************************************
File : XYEquationCurveDock.cpp File : XYEquationCurveDock.cpp
Project : LabPlot Project : LabPlot
-------------------------------------------------------------------- --------------------------------------------------------------------
Copyright : (C) 2014 Alexander Semke (alexander.semke@web.de) Copyright : (C) 2014-2021 Alexander Semke (alexander.semke@web.de)
Description : widget for editing properties of equation curves Description : widget for editing properties of equation curves
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* * * *
* This program is free software; you can redistribute it and/or modify * * 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 * * it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
skipping to change at line 104 skipping to change at line 104
uiGeneralTab.pbRecalculate->setIcon(QIcon::fromTheme("run-build")); uiGeneralTab.pbRecalculate->setIcon(QIcon::fromTheme("run-build"));
uiGeneralTab.teEquation2->setExpressionType(XYEquationCurve::EquationType ::Parametric); uiGeneralTab.teEquation2->setExpressionType(XYEquationCurve::EquationType ::Parametric);
// uiGeneralTab.teEquation1->setMaximumHeight(uiGeneralTab.leName->sizeHint( ).height()*2); // uiGeneralTab.teEquation1->setMaximumHeight(uiGeneralTab.leName->sizeHint( ).height()*2);
// uiGeneralTab.teEquation2->setMaximumHeight(uiGeneralTab.leName->sizeHint( ).height()*2); // uiGeneralTab.teEquation2->setMaximumHeight(uiGeneralTab.leName->sizeHint( ).height()*2);
uiGeneralTab.teMin->setMaximumHeight(uiGeneralTab.leName->sizeHint().heig ht()); uiGeneralTab.teMin->setMaximumHeight(uiGeneralTab.leName->sizeHint().heig ht());
uiGeneralTab.teMax->setMaximumHeight(uiGeneralTab.leName->sizeHint().heig ht()); uiGeneralTab.teMax->setMaximumHeight(uiGeneralTab.leName->sizeHint().heig ht());
//Slots //Slots
connect( uiGeneralTab.leName, &QLineEdit::textChanged, this, &XYEquationC connect(uiGeneralTab.leName, &QLineEdit::textChanged, this, &XYEquationCu
urveDock::nameChanged ); rveDock::nameChanged);
connect( uiGeneralTab.leComment, &QLineEdit::textChanged, this, &XYEquati connect(uiGeneralTab.leComment, &QLineEdit::textChanged, this, &XYEquatio
onCurveDock::commentChanged ); nCurveDock::commentChanged);
connect( uiGeneralTab.chkVisible, SIGNAL(clicked(bool)), this, SLOT(visib connect(uiGeneralTab.chkVisible, &QCheckBox::clicked, this, &XYEquationCu
ilityChanged(bool)) ); rveDock::visibilityChanged);
connect( uiGeneralTab.cbType, SIGNAL(currentIndexChanged(int)), this, SLO connect(uiGeneralTab.cbType, QOverload<int>::of(&QComboBox::currentIndexC
T(typeChanged(int)) ); hanged), this, &XYEquationCurveDock::typeChanged);
connect( uiGeneralTab.teEquation1, SIGNAL(expressionChanged()), this, SLO connect(uiGeneralTab.teEquation1, &ExpressionTextEdit::expressionChanged,
T(enableRecalculate()) ); this, &XYEquationCurveDock::enableRecalculate);
connect( uiGeneralTab.teEquation2, SIGNAL(expressionChanged()), this, SLO connect(uiGeneralTab.teEquation2, &ExpressionTextEdit::expressionChanged,
T(enableRecalculate()) ); this, &XYEquationCurveDock::enableRecalculate);
connect( uiGeneralTab.tbConstants1, SIGNAL(clicked()), this, SLOT(showCon connect(uiGeneralTab.tbConstants1, &QToolButton::clicked, this, &XYEquati
stants()) ); onCurveDock::showConstants);
connect( uiGeneralTab.tbFunctions1, SIGNAL(clicked()), this, SLOT(showFun connect(uiGeneralTab.tbFunctions1, &QToolButton::clicked, this, &XYEquati
ctions()) ); onCurveDock::showFunctions);
connect( uiGeneralTab.tbConstants2, SIGNAL(clicked()), this, SLOT(showCon connect(uiGeneralTab.tbConstants2, &QToolButton::clicked, this, &XYEquati
stants()) ); onCurveDock::showConstants);
connect( uiGeneralTab.tbFunctions2, SIGNAL(clicked()), this, SLOT(showFun connect(uiGeneralTab.tbFunctions2, &QToolButton::clicked, this, &XYEquati
ctions()) ); onCurveDock::showFunctions);
connect( uiGeneralTab.teMin, SIGNAL(expressionChanged()), this, SLOT(enab connect(uiGeneralTab.teMin, &ExpressionTextEdit::expressionChanged, this,
leRecalculate()) ); &XYEquationCurveDock::enableRecalculate);
connect( uiGeneralTab.teMax, SIGNAL(expressionChanged()), this, SLOT(enab connect(uiGeneralTab.teMax, &ExpressionTextEdit::expressionChanged, this,
leRecalculate()) ); &XYEquationCurveDock::enableRecalculate);
connect( uiGeneralTab.sbCount, SIGNAL(valueChanged(int)), this, SLOT(enab connect(uiGeneralTab.sbCount, QOverload<int>::of(&QSpinBox::valueChanged)
leRecalculate()) ); , this, &XYEquationCurveDock::enableRecalculate);
connect( uiGeneralTab.pbRecalculate, SIGNAL(clicked()), this, SLOT(recalc connect(uiGeneralTab.pbRecalculate, &QPushButton::clicked, this, &XYEquat
ulateClicked()) ); ionCurveDock::recalculateClicked);
} }
/*! /*!
sets the curves. The properties of the curves in the list \c list can be edite d in this widget. sets the curves. The properties of the curves in the list \c list can be edite d in this widget.
*/ */
void XYEquationCurveDock::setCurves(QList<XYCurve*> list) { void XYEquationCurveDock::setCurves(QList<XYCurve*> list) {
m_initializing = true; m_initializing = true;
m_curvesList = list; m_curvesList = list;
m_curve = list.first(); m_curve = list.first();
m_aspect = list.first(); m_aspect = list.first();
skipping to change at line 174 skipping to change at line 174
this->typeChanged(static_cast<int>(data.type)); this->typeChanged(static_cast<int>(data.type));
uiGeneralTab.teEquation1->setText(data.expression1); uiGeneralTab.teEquation1->setText(data.expression1);
uiGeneralTab.teEquation2->setText(data.expression2); uiGeneralTab.teEquation2->setText(data.expression2);
uiGeneralTab.teMin->setText(data.min); uiGeneralTab.teMin->setText(data.min);
uiGeneralTab.teMax->setText(data.max); uiGeneralTab.teMax->setText(data.max);
uiGeneralTab.sbCount->setValue(data.count); uiGeneralTab.sbCount->setValue(data.count);
uiGeneralTab.chkVisible->setChecked( m_curve->isVisible() ); uiGeneralTab.chkVisible->setChecked( m_curve->isVisible() );
//Slots //Slots
connect(m_equationCurve, SIGNAL(aspectDescriptionChanged(const AbstractAs connect(m_equationCurve, &XYEquationCurve::aspectDescriptionChanged,
pect*)), this, &XYEquationCurveDock::curveDescriptionChanged);
this, SLOT(curveDescriptionChanged(const AbstractAspect*) connect(m_equationCurve, &XYEquationCurve::equationDataChanged,
)); this, &XYEquationCurveDock::curveEquationDataChanged);
connect(m_equationCurve, SIGNAL(equationDataChanged(XYEquationCurve::Equa
tionData)),
this, SLOT(curveEquationDataChanged(XYEquationCurve::Equa
tionData)));
} }
//************************************************************* //*************************************************************
//**** SLOTs for changes triggered in XYEquationCurveDock ***** //**** SLOTs for changes triggered in XYEquationCurveDock *****
//************************************************************* //*************************************************************
void XYEquationCurveDock::typeChanged(int index) { void XYEquationCurveDock::typeChanged(int index) {
const auto type{XYEquationCurve::EquationType(index)}; const auto type{XYEquationCurve::EquationType(index)};
if (type == XYEquationCurve::EquationType::Cartesian) { if (type == XYEquationCurve::EquationType::Cartesian) {
uiGeneralTab.lEquation1->setText("y=f(x)"); uiGeneralTab.lEquation1->setText("y=f(x)");
uiGeneralTab.lEquation2->hide(); uiGeneralTab.lEquation2->hide();
skipping to change at line 248 skipping to change at line 248
void XYEquationCurveDock::recalculateClicked() { void XYEquationCurveDock::recalculateClicked() {
XYEquationCurve::EquationData data; XYEquationCurve::EquationData data;
data.type = (XYEquationCurve::EquationType)uiGeneralTab.cbType->currentIn dex(); data.type = (XYEquationCurve::EquationType)uiGeneralTab.cbType->currentIn dex();
data.expression1 = uiGeneralTab.teEquation1->document()->toPlainText(); data.expression1 = uiGeneralTab.teEquation1->document()->toPlainText();
data.expression2 = uiGeneralTab.teEquation2->document()->toPlainText(); data.expression2 = uiGeneralTab.teEquation2->document()->toPlainText();
data.min = uiGeneralTab.teMin->document()->toPlainText(); data.min = uiGeneralTab.teMin->document()->toPlainText();
data.max = uiGeneralTab.teMax->document()->toPlainText(); data.max = uiGeneralTab.teMax->document()->toPlainText();
data.count = uiGeneralTab.sbCount->value(); data.count = uiGeneralTab.sbCount->value();
for (auto* curve : m_curvesList) for (auto* curve : m_curvesList)
dynamic_cast<XYEquationCurve*>(curve)->setEquationData(data); static_cast<XYEquationCurve*>(curve)->setEquationData(data);
uiGeneralTab.pbRecalculate->setEnabled(false); uiGeneralTab.pbRecalculate->setEnabled(false);
} }
void XYEquationCurveDock::showConstants() { void XYEquationCurveDock::showConstants() {
QMenu menu; QMenu menu;
ConstantsWidget constants(&menu); ConstantsWidget constants(&menu);
if (QObject::sender() == uiGeneralTab.tbConstants1) if (QObject::sender() == uiGeneralTab.tbConstants1)
connect(&constants, SIGNAL(constantSelected(QString)), this, SLOT (insertConstant1(QString))); connect(&constants, &ConstantsWidget::constantSelected, this, &XY EquationCurveDock::insertConstant1);
else else
connect(&constants, SIGNAL(constantSelected(QString)), this, SLOT (insertConstant2(QString))); connect(&constants, &ConstantsWidget::constantSelected, this, &XY EquationCurveDock::insertConstant2);
connect(&constants, SIGNAL(constantSelected(QString)), &menu, SLOT(close( connect(&constants, &ConstantsWidget::constantSelected, &menu, &QMenu::cl
))); ose);
connect(&constants, SIGNAL(canceled()), &menu, SLOT(close())); connect(&constants, &ConstantsWidget::canceled, &menu, &QMenu::close);
auto* widgetAction = new QWidgetAction(this); auto* widgetAction = new QWidgetAction(this);
widgetAction->setDefaultWidget(&constants); widgetAction->setDefaultWidget(&constants);
menu.addAction(widgetAction); menu.addAction(widgetAction);
if (QObject::sender() == uiGeneralTab.tbConstants1) { if (QObject::sender() == uiGeneralTab.tbConstants1) {
QPoint pos(-menu.sizeHint().width()+uiGeneralTab.tbConstants1->wi dth(),-menu.sizeHint().height()); QPoint pos(-menu.sizeHint().width()+uiGeneralTab.tbConstants1->wi dth(),-menu.sizeHint().height());
menu.exec(uiGeneralTab.tbConstants1->mapToGlobal(pos)); menu.exec(uiGeneralTab.tbConstants1->mapToGlobal(pos));
} else { } else {
QPoint pos(-menu.sizeHint().width()+uiGeneralTab.tbConstants2->wi dth(),-menu.sizeHint().height()); QPoint pos(-menu.sizeHint().width()+uiGeneralTab.tbConstants2->wi dth(),-menu.sizeHint().height());
menu.exec(uiGeneralTab.tbConstants2->mapToGlobal(pos)); menu.exec(uiGeneralTab.tbConstants2->mapToGlobal(pos));
} }
} }
void XYEquationCurveDock::showFunctions() { void XYEquationCurveDock::showFunctions() {
QMenu menu; QMenu menu;
FunctionsWidget functions(&menu); FunctionsWidget functions(&menu);
if (QObject::sender() == uiGeneralTab.tbFunctions1) if (QObject::sender() == uiGeneralTab.tbFunctions1)
connect(&functions, SIGNAL(functionSelected(QString)), this, SLOT (insertFunction1(QString))); connect(&functions, &FunctionsWidget::functionSelected, this, &XY EquationCurveDock::insertFunction1);
else else
connect(&functions, SIGNAL(functionSelected(QString)), this, SLOT (insertFunction2(QString))); connect(&functions, &FunctionsWidget::functionSelected, this, &XY EquationCurveDock::insertFunction2);
connect(&functions, SIGNAL(functionSelected(QString)), &menu, SLOT(close( connect(&functions, &FunctionsWidget::functionSelected, &menu, &QMenu::cl
))); ose);
connect(&functions, SIGNAL(canceled()), &menu, SLOT(close())); connect(&functions, &FunctionsWidget::canceled, &menu, &QMenu::close);
auto* widgetAction = new QWidgetAction(this); auto* widgetAction = new QWidgetAction(this);
widgetAction->setDefaultWidget(&functions); widgetAction->setDefaultWidget(&functions);
menu.addAction(widgetAction); menu.addAction(widgetAction);
if (QObject::sender() == uiGeneralTab.tbFunctions1) { if (QObject::sender() == uiGeneralTab.tbFunctions1) {
QPoint pos(-menu.sizeHint().width()+uiGeneralTab.tbFunctions1->wi dth(),-menu.sizeHint().height()); QPoint pos(-menu.sizeHint().width()+uiGeneralTab.tbFunctions1->wi dth(),-menu.sizeHint().height());
menu.exec(uiGeneralTab.tbFunctions1->mapToGlobal(pos)); menu.exec(uiGeneralTab.tbFunctions1->mapToGlobal(pos));
} else { } else {
QPoint pos(-menu.sizeHint().width()+uiGeneralTab.tbFunctions2->wi dth(),-menu.sizeHint().height()); QPoint pos(-menu.sizeHint().width()+uiGeneralTab.tbFunctions2->wi dth(),-menu.sizeHint().height());
skipping to change at line 344 skipping to change at line 344
} }
//************************************************************* //*************************************************************
//*********** SLOTs for changes triggered in XYCurve ********** //*********** SLOTs for changes triggered in XYCurve **********
//************************************************************* //*************************************************************
//General-Tab //General-Tab
void XYEquationCurveDock::curveDescriptionChanged(const AbstractAspect* aspect) { void XYEquationCurveDock::curveDescriptionChanged(const AbstractAspect* aspect) {
if (m_curve != aspect) if (m_curve != aspect)
return; return;
m_initializing = true; const Lock lock(m_initializing);
if (aspect->name() != uiGeneralTab.leName->text()) { if (aspect->name() != uiGeneralTab.leName->text())
uiGeneralTab.leName->setText(aspect->name()); uiGeneralTab.leName->setText(aspect->name());
} else if (aspect->comment() != uiGeneralTab.leComment->text()) { else if (aspect->comment() != uiGeneralTab.leComment->text())
uiGeneralTab.leComment->setText(aspect->comment()); uiGeneralTab.leComment->setText(aspect->comment());
}
m_initializing = false;
} }
void XYEquationCurveDock::curveEquationDataChanged(const XYEquationCurve::Equati onData& data) { void XYEquationCurveDock::curveEquationDataChanged(const XYEquationCurve::Equati onData& data) {
m_initializing = true; const Lock lock(m_initializing);
uiGeneralTab.cbType->setCurrentIndex(static_cast<int>(data.type)); uiGeneralTab.cbType->setCurrentIndex(static_cast<int>(data.type));
uiGeneralTab.teEquation1->setText(data.expression1); uiGeneralTab.teEquation1->setText(data.expression1);
uiGeneralTab.teEquation2->setText(data.expression2); uiGeneralTab.teEquation2->setText(data.expression2);
uiGeneralTab.teMin->setText(data.min); uiGeneralTab.teMin->setText(data.min);
uiGeneralTab.teMax->setText(data.max); uiGeneralTab.teMax->setText(data.max);
uiGeneralTab.sbCount->setValue(data.count); uiGeneralTab.sbCount->setValue(data.count);
m_initializing = false;
} }
 End of changes. 15 change blocks. 
56 lines changed or deleted 49 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)