comparison layer/SliceLayer.cpp @ 216:34bbbcb3c01f sv1-1.0pre1

* Make getPropertyRangeAndValue return the default separately from the current value. Previously some contexts were incorrectly treating the current value as a default.
author Chris Cannam
date Fri, 02 Mar 2007 14:00:12 +0000
parents 45e995ed84d9
children 8dc50f57d480
comparison
equal deleted inserted replaced
215:d2334a77db73 216:34bbbcb3c01f
514 return QString(); 514 return QString();
515 } 515 }
516 516
517 int 517 int
518 SliceLayer::getPropertyRangeAndValue(const PropertyName &name, 518 SliceLayer::getPropertyRangeAndValue(const PropertyName &name,
519 int *min, int *max) const 519 int *min, int *max, int *deflt) const
520 { 520 {
521 int deft = 0; 521 int val = 0;
522 522
523 int garbage0, garbage1; 523 int garbage0, garbage1, garbage2;
524 if (!min) min = &garbage0; 524 if (!min) min = &garbage0;
525 if (!max) max = &garbage1; 525 if (!max) max = &garbage1;
526 if (!deflt) deflt = &garbage1;
526 527
527 if (name == "Gain") { 528 if (name == "Gain") {
528 529
529 *min = -50; 530 *min = -50;
530 *max = 50; 531 *max = 50;
532 *deflt = 0;
531 533
532 std::cerr << "gain is " << m_gain << ", mode is " << m_samplingMode << std::endl; 534 std::cerr << "gain is " << m_gain << ", mode is " << m_samplingMode << std::endl;
533 535
534 deft = lrint(log10(m_gain) * 20.0); 536 val = lrint(log10(m_gain) * 20.0);
535 if (deft < *min) deft = *min; 537 if (val < *min) val = *min;
536 if (deft > *max) deft = *max; 538 if (val > *max) val = *max;
537 539
538 } else if (name == "Normalize") { 540 } else if (name == "Normalize") {
539 541
540 deft = (m_normalize ? 1 : 0); 542 val = (m_normalize ? 1 : 0);
543 *deflt = 0;
541 544
542 } else if (name == "Colour") { 545 } else if (name == "Colour") {
543 546
544 if (m_plotStyle == PlotFilledBlocks) { 547 if (m_plotStyle == PlotFilledBlocks) {
545 548
546 *min = 0; 549 *min = 0;
547 *max = ColourMapper::getColourMapCount() - 1; 550 *max = ColourMapper::getColourMapCount() - 1;
548 551 *deflt = 0;
549 deft = m_colourMap; 552
553 val = m_colourMap;
550 554
551 } else { 555 } else {
552 556
553 *min = 0; 557 *min = 0;
554 *max = 5; 558 *max = 5;
555 559 *deflt = 0;
556 if (m_colour == Qt::black) deft = 0; 560
557 else if (m_colour == Qt::darkRed) deft = 1; 561 if (m_colour == Qt::black) val = 0;
558 else if (m_colour == Qt::darkBlue) deft = 2; 562 else if (m_colour == Qt::darkRed) val = 1;
559 else if (m_colour == Qt::darkGreen) deft = 3; 563 else if (m_colour == Qt::darkBlue) val = 2;
560 else if (m_colour == QColor(200, 50, 255)) deft = 4; 564 else if (m_colour == Qt::darkGreen) val = 3;
561 else if (m_colour == QColor(255, 150, 50)) deft = 5; 565 else if (m_colour == QColor(200, 50, 255)) val = 4;
566 else if (m_colour == QColor(255, 150, 50)) val = 5;
562 } 567 }
563 568
564 } else if (name == "Scale") { 569 } else if (name == "Scale") {
565 570
566 *min = 0; 571 *min = 0;
567 *max = 2; 572 *max = 2;
568 573 *deflt = (int)dBScale;
569 deft = (int)m_energyScale; 574
575 val = (int)m_energyScale;
570 576
571 } else if (name == "Sampling Mode") { 577 } else if (name == "Sampling Mode") {
572 578
573 *min = 0; 579 *min = 0;
574 *max = 2; 580 *max = 2;
575 581 *deflt = (int)SampleMean;
576 deft = (int)m_samplingMode; 582
583 val = (int)m_samplingMode;
577 584
578 } else if (name == "Plot Type") { 585 } else if (name == "Plot Type") {
579 586
580 *min = 0; 587 *min = 0;
581 *max = 3; 588 *max = 3;
582 589 *deflt = (int)PlotSteps;
583 deft = (int)m_plotStyle; 590
591 val = (int)m_plotStyle;
584 592
585 } else if (name == "Bin Scale") { 593 } else if (name == "Bin Scale") {
586 594
587 *min = 0; 595 *min = 0;
588 *max = 2; 596 *max = 2;
597 *deflt = (int)LinearBins;
589 // *max = 1; // I don't think we really do want to offer inverted log 598 // *max = 1; // I don't think we really do want to offer inverted log
590 599
591 deft = (int)m_binScale; 600 val = (int)m_binScale;
592 601
593 } else { 602 } else {
594 deft = Layer::getPropertyRangeAndValue(name, min, max); 603 val = Layer::getPropertyRangeAndValue(name, min, max, deflt);
595 } 604 }
596 605
597 return deft; 606 return val;
598 } 607 }
599 608
600 QString 609 QString
601 SliceLayer::getPropertyValueLabel(const PropertyName &name, 610 SliceLayer::getPropertyValueLabel(const PropertyName &name,
602 int value) const 611 int value) const