"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/arrowdlg.cpp" between
kpl-4.1.tar.gz and kpl-5.0.tar.gz

About: Kpl is a KDE program for two- and three-dimensional graphical presentation (plots) of data sets and functions. Multidimensional nonlinear parameter and general linear least square parameter fits can be performed.

arrowdlg.cpp  (kpl-4.1):arrowdlg.cpp  (kpl-5.0)
/*************************************************************************** /***************************************************************************
arrowdlg.cpp - description arrowdlg.cpp - description
------------------- -------------------
begin : Sat Apr 14 2001 begin : Sat Apr 14 2001
copyright : (C) 2015 by Werner Stille copyright : (C) 2017 by Werner Stille
email : stille@uni-freiburg.de email : kpl@werner-stille.de
***************************************************************************/ ***************************************************************************/
/*************************************************************************** /***************************************************************************
* * * *
* 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. *
* * * *
***************************************************************************/ ***************************************************************************/
#include <math.h> #include <math.h>
#include <QtMath>
#include <QButtonGroup>
#include <QCheckBox> #include <QCheckBox>
#include <QDesktopServices>
#include <QDialogButtonBox>
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#include <QLabel> #include <QLabel>
#include <QLayout> #include <QLayout>
#include <QRadioButton> #include <QRadioButton>
#include <KButtonGroup> #include <QUndoStack>
#include <KColorButton> #include <KColorButton>
#include <KLocalizedString> #include <KLocalizedString>
#include <KUndoStack>
#include "arrowdlg.h" #include "arrowdlg.h"
#include "arrowitem.h" #include "arrowitem.h"
#include "kpldoc.h" #include "kpldoc.h"
#include "spinbox.h" #include "spinbox.h"
#include "symboldlg.h"
ArrowDlg::ArrowDlg(QWidget* parent, KplDoc* model, ArrowItem* ai0, ArrowDlg::ArrowDlg(QWidget* parent, KplDoc* model, ArrowItem* ai0,
const QPoint& pos) : const QPoint& pos) :
DecoDlg(parent, i18n("Arrow"), "SEC-ARROW", model, ai0, pos), koord(0), DecoDlg(parent, i18n("Arrow"), model, ai0, pos), koord(0), ai(ai0)
ai(ai0)
{ {
initPolarEntries(ai, grid, &eDir, &eLen); initPolarEntries(ai, grid, &eDir, &eLen);
grid->addWidget(new QLabel(i18n("Coordinates")), 1, 0); grid->addWidget(new QLabel(i18n("Coordinates")), 1, 0);
KButtonGroup* bg = new KButtonGroup; QHBoxLayout* hbox = new QHBoxLayout;
grid->addWidget(bg, 1, 1, 1, 6); grid->addLayout(hbox, 1, 1, 1, 6);
bg->setFlat(true); hbox->addItem(new QSpacerItem(10, 10));
QHBoxLayout* hbox = new QHBoxLayout(bg); QButtonGroup* bg = new QButtonGroup;
hbox->addWidget(new QRadioButton(i18n("Head"))); QRadioButton* rb;
hbox->addWidget(new QRadioButton(i18n("Center"))); int i = 0;
hbox->addWidget(new QRadioButton(i18n("End"))); hbox->addWidget(rb = new QRadioButton(i18n("Head")));
bg->addButton(rb, i++);
rb->setChecked(true);
hbox->addWidget(rb = new QRadioButton(i18n("Center")));
bg->addButton(rb, i++);
hbox->addWidget(rb = new QRadioButton(i18n("End")));
bg->addButton(rb, i);
hbox->addItem(new QSpacerItem(20, 10, QSizePolicy::Expanding)); hbox->addItem(new QSpacerItem(20, 10, QSizePolicy::Expanding));
bg->setSelected(0);
initEntries(2); initEntries(2);
grid->addWidget(dbl = new QCheckBox(i18n("Double headed")), 4, 0, 1, 7); grid->addWidget(new QLabel(i18n("Type")), 4, 0);
grid->addWidget(symb = new SpinBox(ai->symbol(), 1, 9), 4, 1);
grid->addWidget(new SymbolButton(symb, true, false), 4, 2);
grid->addWidget(dbl = new QCheckBox(i18n("Double headed")), 4, 4, 1, 1);
dbl->setChecked(ai->doubleHeaded()); dbl->setChecked(ai->doubleHeaded());
connect(bg, SIGNAL(changed(int)), SLOT(slotSetCoord(int))); connect(bg, SIGNAL(buttonClicked(int)), SLOT(slotSetCoord(int)));
connect(eDir, SIGNAL(valueChanged(const QString&)), SLOT(slotEdited())); connect(eDir, SIGNAL(valueChanged(const QString&)), SLOT(slotEdited()));
connect(eLen, SIGNAL(valueChanged(const QString&)), SLOT(slotEdited())); connect(eLen, SIGNAL(valueChanged(const QString&)), SLOT(slotEdited()));
connect(symb, SIGNAL(valueChanged(int)), SLOT(slotEdited()));
connect(dbl, SIGNAL(toggled(bool)), SLOT(slotEdited())); connect(dbl, SIGNAL(toggled(bool)), SLOT(slotEdited()));
connect(buttonBox, SIGNAL(clicked(QAbstractButton*)),
SLOT(slotButtonClicked(QAbstractButton*)));
} }
ArrowDlg::~ArrowDlg() ArrowDlg::~ArrowDlg()
{ {
} }
void ArrowDlg::initPolarEntries(const VectorItem* ai, QGridLayout* gr, void ArrowDlg::initPolarEntries(const VectorItem* ai, QGridLayout* gr,
QDoubleSpinBox** eD, QDoubleSpinBox** eL) QDoubleSpinBox** eD, QDoubleSpinBox** eL)
{ {
gr->addWidget(new QLabel(i18n("Direction")), 0, 0); gr->addWidget(new QLabel(i18n("Direction")), 0, 0);
gr->addWidget(*eD = new QDoubleSpinBox, 0, 1); gr->addWidget(*eD = new QDoubleSpinBox, 0, 1);
(*eD)->setRange(-360, 360); (*eD)->setRange(-360, 360);
(*eD)->setSuffix("\260"); (*eD)->setSuffix(QString::fromUtf8("\302\260"));
(*eD)->setValue(ai->dir()); (*eD)->setValue(ai->dir());
gr->addWidget(new QLabel(i18n("Length")), 0, 3); gr->addWidget(new QLabel(i18n("Length")), 0, 3);
gr->addWidget(*eL = new QDoubleSpinBox, 0, 4); gr->addWidget(*eL = new QDoubleSpinBox, 0, 4);
(*eL)->setMaximum(200); (*eL)->setMaximum(200);
(*eL)->setSingleStep(0.1); (*eL)->setSingleStep(0.1);
(*eL)->setSuffix(" cm"); (*eL)->setSuffix(" cm");
(*eL)->setValue(ai->length()); (*eL)->setValue(ai->length());
} }
void ArrowDlg::calcCoord(double* x, double* y, double dx, double dy) void ArrowDlg::calcCoord(double* x, double* y, double dx, double dy)
skipping to change at line 91 skipping to change at line 105
case 1: case 1:
*x += 0.5 * dx; *x += 0.5 * dx;
*y += 0.5 * dy; *y += 0.5 * dy;
break; break;
case 2: case 2:
*x += dx; *x += dx;
*y += dy; *y += dy;
} }
} }
void ArrowDlg::slotButtonClicked(int button) void ArrowDlg::slotButtonClicked(QAbstractButton* button)
{ {
switch (button) { int id = buttonBox->standardButton(button);
case Apply: switch (id) {
enableButtonApply(false); case QDialogButtonBox::Apply:
enableButtonOk(false); buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false);
case Ok: { buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
case QDialogButtonBox::Ok: {
ArrowItem* aiNew = new ArrowItem(*ai); ArrowItem* aiNew = new ArrowItem(*ai);
getValues(aiNew); getValues(aiNew);
aiNew->setSymbol(KplItem::Symbol(symb->value()));
aiNew->setDoubleHeaded(dbl->isChecked()); aiNew->setDoubleHeaded(dbl->isChecked());
double dir = eDir->value(); double dir = eDir->value();
aiNew->setDir(dir); aiNew->setDir(dir);
double len = eLen->value(); double len = eLen->value();
aiNew->setLength(len); aiNew->setLength(len);
dir *= KplItem::Deg2rad; dir = qDegreesToRadians(dir);
double x0 = aiNew->x0(); double x0 = aiNew->x0();
double y0 = aiNew->y0(); double y0 = aiNew->y0();
calcCoord(&x0, &y0, len * cos(dir), len * sin(dir)); calcCoord(&x0, &y0, len * cos(dir), len * sin(dir));
aiNew->setX0(0.01 * qRound(100 * x0)); aiNew->setX0(0.01 * qRound(100 * x0));
aiNew->setY0(0.01 * qRound(100 * y0)); aiNew->setY0(0.01 * qRound(100 * y0));
m->undoStack()->push(new EditCommand(aiNew, ai, m)); m->undoStack()->push(new EditCommand(aiNew, ai, m));
ai = aiNew; ai = aiNew;
if (button == Ok) if (id == QDialogButtonBox::Ok)
accept(); accept();
break; break;
} }
default: case QDialogButtonBox::Help:
KDialog::slotButtonClicked(button); QDesktopServices::openUrl(QUrl(QStringLiteral("help:/kpl/arrow.html")));
break;
case QDialogButtonBox::Cancel:
reject();
} }
} }
void ArrowDlg::slotSetCoord(int id) void ArrowDlg::slotSetCoord(int id)
{ {
if (id != koord) { if (id != koord) {
double dir = KplItem::Deg2rad * eDir->value(); double dir = qDegreesToRadians(eDir->value());
double len = eLen->value(); double len = eLen->value();
double dx = len * cos(dir); double dx = len * cos(dir);
double dy = len * sin(dir); double dy = len * sin(dir);
double x0 = ex0->value(); double x0 = ex0->value();
double y0 = ey0->value(); double y0 = ey0->value();
calcCoord(&x0, &y0, dx, dy); calcCoord(&x0, &y0, dx, dy);
koord = id; koord = id;
calcCoord(&x0, &y0, -dx, -dy); calcCoord(&x0, &y0, -dx, -dy);
disconnect(ex0, SIGNAL(valueChanged(const QString&)),
this, SLOT(slotEdited()));
ex0->setValue(x0); ex0->setValue(x0);
connect(ex0, SIGNAL(valueChanged(const QString&)), SLOT(slotEdited()));
disconnect(ey0, SIGNAL(valueChanged(const QString&)), this,
SLOT(slotEdited()));
ey0->setValue(y0); ey0->setValue(y0);
connect(ey0, SIGNAL(valueChanged(const QString&)), SLOT(slotEdited()));
} }
} }
 End of changes. 24 change blocks. 
28 lines changed or deleted 53 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS