mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 22:35:27 +00:00
Remove the ticks on the Axis, we never used them on the old profile.
This patch just cleans a bit the Cartesian Axis, we never used ticks on it, just the grid lines ( that I need to animate a bit. ) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
592ee31326
commit
cd3867d46a
2 changed files with 3 additions and 34 deletions
|
@ -50,24 +50,11 @@ void DiveCartesianAxis::updateTicks()
|
||||||
double steps = (max - min) / interval;
|
double steps = (max - min) / interval;
|
||||||
double currValue = min;
|
double currValue = min;
|
||||||
|
|
||||||
if (!showTicks && !ticks.empty()){
|
|
||||||
qDeleteAll(ticks);
|
|
||||||
ticks.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!showText && !labels.empty()){
|
if(!showText && !labels.empty()){
|
||||||
qDeleteAll(labels);
|
qDeleteAll(labels);
|
||||||
labels.clear();
|
labels.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the uneeded Ticks / Texts.
|
|
||||||
if (showTicks && !ticks.isEmpty() && ticks.size() > steps) {
|
|
||||||
while (ticks.size() > steps) {
|
|
||||||
DiveLineItem *removedLine = ticks.takeLast();
|
|
||||||
removedLine->animatedHide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!labels.isEmpty() && labels.size() > steps) {
|
if (!labels.isEmpty() && labels.size() > steps) {
|
||||||
while (labels.size() > steps) {
|
while (labels.size() > steps) {
|
||||||
DiveTextItem *removedText = labels.takeLast();
|
DiveTextItem *removedText = labels.takeLast();
|
||||||
|
@ -92,7 +79,7 @@ void DiveCartesianAxis::updateTicks()
|
||||||
}
|
}
|
||||||
stepSize = stepSize / steps;
|
stepSize = stepSize / steps;
|
||||||
|
|
||||||
for (int i = 0, count = ticks.size(); i < count; i++, currValue += interval) {
|
for (int i = 0, count = labels.size(); i < count; i++, currValue += interval) {
|
||||||
qreal childPos;
|
qreal childPos;
|
||||||
if (orientation == TopToBottom || orientation == LeftToRight) {
|
if (orientation == TopToBottom || orientation == LeftToRight) {
|
||||||
childPos = begin + i * stepSize;
|
childPos = begin + i * stepSize;
|
||||||
|
@ -101,30 +88,22 @@ void DiveCartesianAxis::updateTicks()
|
||||||
}
|
}
|
||||||
labels[i]->setText(textForValue(currValue));
|
labels[i]->setText(textForValue(currValue));
|
||||||
if ( orientation == LeftToRight || orientation == RightToLeft) {
|
if ( orientation == LeftToRight || orientation == RightToLeft) {
|
||||||
ticks[i]->animateMoveTo(childPos, m.y1() + tickSize);
|
|
||||||
labels[i]->animateMoveTo(childPos, m.y1() + tickSize);
|
labels[i]->animateMoveTo(childPos, m.y1() + tickSize);
|
||||||
} else {
|
} else {
|
||||||
ticks[i]->animateMoveTo(m.x1() - tickSize, childPos);
|
|
||||||
labels[i]->animateMoveTo(m.x1() - tickSize, childPos);
|
labels[i]->animateMoveTo(m.x1() - tickSize, childPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add's the rest of the needed Ticks / Text.
|
// Add's the rest of the needed Ticks / Text.
|
||||||
for (int i = ticks.size(); i < steps; i++, currValue += interval) {
|
for (int i = labels.size(); i < steps; i++, currValue += interval) {
|
||||||
qreal childPos;
|
qreal childPos;
|
||||||
if (orientation == TopToBottom || orientation == LeftToRight) {
|
if (orientation == TopToBottom || orientation == LeftToRight) {
|
||||||
childPos = begin + i * stepSize;
|
childPos = begin + i * stepSize;
|
||||||
} else {
|
} else {
|
||||||
childPos = begin - i * stepSize;
|
childPos = begin - i * stepSize;
|
||||||
}
|
}
|
||||||
DiveLineItem *item = NULL;
|
|
||||||
DiveTextItem *label = NULL;
|
DiveTextItem *label = NULL;
|
||||||
|
|
||||||
if (showTicks){
|
|
||||||
item = new DiveLineItem(this);
|
|
||||||
item->setPen(pen());
|
|
||||||
ticks.push_back(item);
|
|
||||||
}
|
|
||||||
if (showText){
|
if (showText){
|
||||||
label = new DiveTextItem(this);
|
label = new DiveTextItem(this);
|
||||||
label->setText(textForValue(currValue));
|
label->setText(textForValue(currValue));
|
||||||
|
@ -132,22 +111,13 @@ void DiveCartesianAxis::updateTicks()
|
||||||
}
|
}
|
||||||
labels.push_back(label);
|
labels.push_back(label);
|
||||||
if (orientation == RightToLeft || orientation == LeftToRight) {
|
if (orientation == RightToLeft || orientation == LeftToRight) {
|
||||||
if (showTicks){
|
|
||||||
item->setLine(0, 0, 0, tickSize);
|
|
||||||
item->setPos(scene()->sceneRect().width() + 10, m.y1() + tickSize); // position it outside of the scene
|
|
||||||
item->animateMoveTo(childPos, m.y1() + tickSize); // anim it to scene.
|
|
||||||
}
|
|
||||||
if(showText){
|
if(showText){
|
||||||
label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
|
label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
|
||||||
label->setPos(scene()->sceneRect().width() + 10, m.y1() + tickSize); // position it outside of the scene);
|
label->setPos(scene()->sceneRect().width() + 10, m.y1() + tickSize); // position it outside of the scene);
|
||||||
label->animateMoveTo(childPos, m.y1() + tickSize);
|
label->animateMoveTo(childPos, m.y1() + tickSize);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(showTicks){
|
|
||||||
item->setLine(0, 0, tickSize, 0);
|
|
||||||
item->setPos(m.x1() - tickSize, scene()->sceneRect().height() + 10);
|
|
||||||
item->animateMoveTo(m.x1() - tickSize, childPos);
|
|
||||||
}
|
|
||||||
if(showText){
|
if(showText){
|
||||||
label->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
|
label->setAlignment(Qt::AlignVCenter| Qt::AlignRight);
|
||||||
label->setPos(m.x1() - tickSize, scene()->sceneRect().height() + 10);
|
label->setPos(m.x1() - tickSize, scene()->sceneRect().height() + 10);
|
||||||
|
|
|
@ -38,7 +38,6 @@ protected:
|
||||||
virtual QString textForValue(double value);
|
virtual QString textForValue(double value);
|
||||||
|
|
||||||
Orientation orientation;
|
Orientation orientation;
|
||||||
QList<DiveLineItem*> ticks;
|
|
||||||
QList<DiveTextItem*> labels;
|
QList<DiveTextItem*> labels;
|
||||||
double min;
|
double min;
|
||||||
double max;
|
double max;
|
||||||
|
|
Loading…
Add table
Reference in a new issue