"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/arcitem.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.

arcitem.cpp  (kpl-4.1):arcitem.cpp  (kpl-5.0)
/*************************************************************************** /***************************************************************************
arcitem.cpp - description arcitem.cpp - description
------------------- -------------------
begin : Sam Aug 17 2002 begin : Sam Aug 17 2002
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 <KConfigGroup> #include <KConfigGroup>
#include "arcitem.h" #include "arcitem.h"
#include "kplscene.h" #include "kplscene.h"
ArcItem::ArcItem(double x0, double y0, unsigned color, ArcItem::ArcItem(double x0, double y0, unsigned color,
QGraphicsItem* parent, double width, double height, QGraphicsItem* parent, double width, double height,
bool visible, double start, double span, double relSize, bool visible, double start, double span, Symbol symbol,
double dir) : double relSize, double dir) :
DecoItem(color, x0, y0, relSize), QGraphicsPathItem(parent), m_width(width), DecoItem(color, x0, y0, relSize), QGraphicsPathItem(parent), m_width(width),
m_height(height), m_dir(dir), m_start(start), m_span(span) m_height(height), m_dir(dir), m_start(start), m_span(span), myDashOffset(0),
m_symbol(symbol)
{ {
if (!visible) if (!visible)
hide(); hide();
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
} }
ArcItem::ArcItem(const ArcItem& a) : ArcItem::ArcItem(const ArcItem& a) :
DecoItem(a), QGraphicsPathItem(), m_width(a.m_width), m_height(a.m_height), DecoItem(a), QGraphicsPathItem(), m_width(a.m_width), m_height(a.m_height),
m_dir(a.m_dir), m_start(a.m_start), m_span(a.m_span) m_dir(a.m_dir), m_start(a.m_start), m_span(a.m_span),
myDashOffset(a.myDashOffset), m_symbol(a.m_symbol)
{ {
setZValue(a.zValue()); setZValue(a.zValue());
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
setSelected(a.isSelected()); setSelected(a.isSelected());
setVisible(a.isVisible()); setVisible(a.isVisible());
} }
ArcItem::ArcItem(const KConfigGroup* plo, unsigned color, ArcItem::ArcItem(const KConfigGroup* plo, unsigned color,
QGraphicsItem* parent) : QGraphicsItem* parent) :
DecoItem(plo, color), QGraphicsPathItem(parent) DecoItem(plo, color), QGraphicsPathItem(parent), myDashOffset(0)
{ {
if (!plo->readEntry("active", true)) if (!plo->readEntry("active", true))
hide(); hide();
m_width = plo->readEntry("width", 3.0); m_width = plo->readEntry("width", 3.0);
m_height = plo->readEntry("height", 2.0); m_height = plo->readEntry("height", 2.0);
m_dir = plo->readEntry("dir", 0.0); m_dir = plo->readEntry("dir", 0.0);
m_start = plo->readEntry("a", 0.0); m_start = plo->readEntry("a", 0.0);
m_span = plo->readEntry("alen", 90.0); m_span = plo->readEntry("alen", 90.0);
m_symbol = Symbol(plo->readEntry("symb", int(SolidLine)));
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
} }
ArcItem::~ArcItem() ArcItem::~ArcItem()
{ {
} }
QPixmap ArcItem::pixmap() const QPixmap ArcItem::pixmap() const
{ {
return KplItem::pixmap(pen()); return KplItem::pixmap(pen(), m_symbol);
}
void ArcItem::setDashOffset()
{
if (m_symbol != 1) {
QPen p = pen();
myDashOffset = m_dashOffset;
p.setDashOffset(m_dashOffset);
double s = 0;
foreach (double d, p.dashPattern())
s += d;
m_dashOffset += QGraphicsPathItem::path().length() / p.widthF();
m_dashOffset -= int(m_dashOffset / s) * s;
setPen(p);
}
} }
void ArcItem::setPenWidth() void ArcItem::setPenWidth()
{ {
QPen p = pen(); QPen p = pen();
double w = penWidth(this); double w = penWidth(this);
if (p.widthF() != w) { if (p.widthF() != w) {
prepareGeometryChange(); prepareGeometryChange();
setPen(changePenWidth(p, w)); setPen(changePenWidth(p, w));
} }
skipping to change at line 99 skipping to change at line 117
void ArcItem::writePlo(KConfigGroup* plo) const void ArcItem::writePlo(KConfigGroup* plo) const
{ {
plo->writeEntry("Type", "ARCITEM"); plo->writeEntry("Type", "ARCITEM");
DecoItem::writePlo(plo, isVisible()); DecoItem::writePlo(plo, isVisible());
plo->writeEntry("width", m_width); plo->writeEntry("width", m_width);
plo->writeEntry("height", m_height); plo->writeEntry("height", m_height);
plo->writeEntry("dir", m_dir); plo->writeEntry("dir", m_dir);
plo->writeEntry("a", m_start); plo->writeEntry("a", m_start);
plo->writeEntry("alen", m_span); plo->writeEntry("alen", m_span);
plo->writeEntry("symb", int(m_symbol));
} }
void ArcItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) void ArcItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{ {
QGraphicsPathItem::mouseReleaseEvent(event); QGraphicsPathItem::mouseReleaseEvent(event);
((KplScene*)scene())->updatePos(this); ((KplScene*)scene())->updatePos(this);
} }
void ArcItem::setProperties() void ArcItem::setProperties()
{ {
setPos(m_matrix.map(QPointF(m_x0, m_y0))); setPos(m_matrix.map(QPointF(m_x0, m_y0)));
#if QT_VERSION < 0x040600
setTransform(QTransform().rotate(-m_dir));
#else
setRotation(-m_dir); setRotation(-m_dir);
#endif QPen p = createPen(this, m_color, DataPen, m_symbol);
setPen(createPen(this, m_color)); p.setDashOffset(myDashOffset);
setPen(p);
double w = m_matrix.m11() * m_width; double w = m_matrix.m11() * m_width;
double h = m_matrix.m22() * m_height; double h = m_matrix.m22() * m_height;
QRectF r(-0.5 * w, -0.5 * h, w, h); QRectF r(-0.5 * w, -0.5 * h, w, h);
QPainterPath path; QPainterPath path;
path.arcMoveTo(r, -m_start); path.arcMoveTo(r, -m_start);
path.arcTo(r, -m_start, -m_span); path.arcTo(r, -m_start, -m_span);
setPath(path); setPath(path);
} }
 End of changes. 10 change blocks. 
13 lines changed or deleted 30 lines changed or added

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