##// END OF EJS Templates
Add more themes to piechartcustomization
Add more themes to piechartcustomization

File last commit:

r554:7777ba21b3a6
r658:6c43bf929dc5
Show More
domain.cpp
185 lines | 3.9 KiB | text/x-c | CppLexer
Michal Klocek
Refactors qchart , adds line animation...
r131 #include "domain_p.h"
QTCOMMERCIALCHART_BEGIN_NAMESPACE
Michal Klocek
Refactor domain model...
r439 Domain::Domain(QObject* parent):QObject(parent),
m_minX(0),
m_maxX(0),
m_minY(0),
Michal Klocek
Adds scroll support...
r531 m_maxY(0),
m_tickXCount(5),
m_tickYCount(5)
Michal Klocek
Refactors qchart , adds line animation...
r131 {
}
Domain::~Domain()
{
}
Michal Klocek
Refactor domain model...
r439 void Domain::setRange(qreal minX, qreal maxX, qreal minY, qreal maxY)
{
bool changed = false;
Michal Klocek
Adds missing ticks hadnling
r554 if(m_minX!=minX || m_maxX!=maxX)
Michal Klocek
Refactor domain model...
r439 {
m_minX=minX;
m_maxX=maxX;
changed=true;
Michal Klocek
Adds scroll support...
r531 emit rangeXChanged(minX,maxX, m_tickXCount);
Michal Klocek
Refactor domain model...
r439 }
Michal Klocek
Adds missing ticks hadnling
r554 if(m_minY!=minY || m_maxY!=maxY){
Michal Klocek
Refactor domain model...
r439 m_minY=minY;
m_maxY=maxY;
changed=true;
Michal Klocek
Adds scroll support...
r531 emit rangeYChanged(minY,maxY, m_tickYCount);
Michal Klocek
Refactor domain model...
r439 }
if(changed){
emit domainChanged(m_minX, m_maxX, m_minY, m_maxY);
}
}
void Domain::setRangeX(qreal min, qreal max)
{
setRange(min,max,m_minY, m_maxY);
}
void Domain::setRangeY(qreal min, qreal max)
{
setRange(m_minX, m_maxX, min, max);
}
void Domain::setMinX(qreal min)
{
setRange(min, m_maxX, m_minY, m_maxY);
}
void Domain::setMaxX(qreal max)
{
setRange(m_minX, max, m_minY, m_maxY);
}
void Domain::setMinY(qreal min)
{
setRange(m_minX, m_maxX, min, m_maxY);
}
void Domain::setMaxY(qreal max)
{
setRange(m_minX, m_maxX, m_minY, max);
}
Michal Klocek
Refactors qchart , adds line animation...
r131 qreal Domain::spanX() const
{
Michal Klocek
Refactor domain model...
r439 Q_ASSERT(m_maxX >= m_minX);
return m_maxX - m_minX;
Michal Klocek
Refactors qchart , adds line animation...
r131 }
qreal Domain::spanY() const
{
Michal Klocek
Refactor domain model...
r439 Q_ASSERT(m_maxY >= m_minY);
return m_maxY - m_minY;
Michal Klocek
Refactors qchart , adds line animation...
r131 }
Michal Klocek
Adds isEmpty to domain
r388 bool Domain::isEmpty() const
{
return spanX()==0 || spanY()==0;
}
Michal Klocek
Refactor domain model...
r439 void Domain::zoomIn(const QRectF& rect, const QSizeF& size)
Michal Klocek
Refactors qchart , adds line animation...
r131 {
Michal Klocek
Refactor domain model...
r439 qreal dx = spanX() / size.width();
qreal dy = spanY() / size.height();
Michal Klocek
Refactors qchart , adds line animation...
r131
Michal Klocek
Refactor domain model...
r439 m_maxX = m_minX + dx * rect.right();
m_minX = m_minX + dx * rect.left();
m_minY = m_maxY - dy * rect.bottom();
m_maxY = m_maxY - dy * rect.top();
emit domainChanged(m_minX, m_maxX, m_minY, m_maxY);
Michal Klocek
Adds scroll support...
r531 emit rangeXChanged(m_minX, m_maxX, m_tickXCount);
emit rangeYChanged(m_minY, m_maxY, m_tickYCount);
Michal Klocek
Refactor domain model...
r439 }
void Domain::zoomOut(const QRectF& rect, const QSizeF& size)
{
qreal dx = spanX() / rect.width();
qreal dy = spanY() / rect.height();
Michal Klocek
Refactors qchart , adds line animation...
r131
Michal Klocek
Refactor domain model...
r439 m_minX = m_maxX - dx * rect.right();
m_maxX = m_minX + dx * size.width();
m_maxY = m_minY + dy * rect.bottom();
m_minY = m_maxY - dy * size.height();
Michal Klocek
Refactors qchart , adds line animation...
r131
Michal Klocek
Refactor domain model...
r439 emit domainChanged(m_minX, m_maxX, m_minY, m_maxY);
Michal Klocek
Adds scroll support...
r531 emit rangeXChanged(m_minX, m_maxX, m_tickXCount);
emit rangeYChanged(m_minY, m_maxY, m_tickYCount);
}
void Domain::move(int dx,int dy,const QSizeF& size)
{
qreal x = spanX() / size.width();
qreal y = spanY() / size.height();
if(dx!=0){
m_minX = m_minX + x * dx;
m_maxX = m_maxX + x * dx;
emit rangeXChanged(m_minX, m_maxX, m_tickXCount);
}
if(dy!=0){
m_minY = m_minY + y * dy;
m_maxY = m_maxY + y * dy;
emit rangeYChanged(m_minY, m_maxY, m_tickYCount);
}
emit domainChanged(m_minX, m_maxX, m_minY, m_maxY);
Michal Klocek
Refactor domain model...
r439 }
Michal Klocek
Adds missing ticks hadnling
r554 void Domain::handleAxisRangeXChanged(qreal min,qreal max)
{
setRange(min,max,m_minY, m_maxY);
}
void Domain::handleAxisRangeYChanged(qreal min,qreal max)
Michal Klocek
Refactor domain model...
r439 {
Michal Klocek
Adds missing ticks hadnling
r554 setRange(m_minX, m_maxX, min, max);
Michal Klocek
Refactor domain model...
r439 }
Michal Klocek
Adds missing ticks hadnling
r554 void Domain::handleAxisXTicksCountChanged(int tickCount)
Michal Klocek
Refactor domain model...
r439 {
Michal Klocek
Adds missing ticks hadnling
r554 if(m_tickXCount!=tickCount){
m_tickXCount=tickCount;
emit rangeXChanged(m_minX,m_maxX, m_tickXCount);
}
}
void Domain::handleAxisYTicksCountChanged(int tickCount)
{
if(m_tickYCount!=tickCount){
m_tickYCount=tickCount;
emit rangeYChanged(m_minY,m_maxY, m_tickYCount);
}
Michal Klocek
Refactors qchart , adds line animation...
r131 }
Michal Klocek
Add overloaded comparison operators to domain
r220
bool operator== (const Domain &domain1, const Domain &domain2)
{
return (domain1.m_maxX == domain2.m_maxX &&
Michal Klocek
Refactor domain model...
r439 domain1.m_maxY == domain2.m_maxY &&
domain1.m_minX == domain2.m_minX &&
domain1.m_minY == domain2.m_minY);
Michal Klocek
Add overloaded comparison operators to domain
r220 }
bool operator!= (const Domain &domain1, const Domain &domain2)
{
return !(domain1 == domain2);
}
Michal Klocek
Adds debug operator to domain
r222 QDebug operator<<(QDebug dbg, const Domain &domain)
{
dbg.nospace() << "Domain("<<domain.m_minX<<','<<domain.m_maxX<<','<<domain.m_minY<<','<<domain.m_maxY<<')';
return dbg.maybeSpace();
}
Michal Klocek
Refactor domain model...
r439 #include "moc_domain_p.cpp"
Michal Klocek
Refactors qchart , adds line animation...
r131 QTCOMMERCIALCHART_END_NAMESPACE