| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 | 
							- /*=========================================================================
 
-   Library:   CTK
 
-   Copyright (c) Kitware Inc.
 
-   Licensed under the Apache License, Version 2.0 (the "License");
 
-   you may not use this file except in compliance with the License.
 
-   You may obtain a copy of the License at
 
-       http://www.commontk.org/LICENSE
 
-   Unless required by applicable law or agreed to in writing, software
 
-   distributed under the License is distributed on an "AS IS" BASIS,
 
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
-   See the License for the specific language governing permissions and
 
-   limitations under the License.
 
- =========================================================================*/
 
- // Qt includes
 
- #include <QApplication>
 
- #include <QTimer>
 
- // CTK includes
 
- #include "ctkSliderWidget.h"
 
- // STD includes
 
- #include <cstdlib>
 
- #include <iostream>
 
- //-----------------------------------------------------------------------------
 
- int ctkSliderWidgetTest1(int argc, char * argv [] )
 
- {
 
-   QApplication app(argc, argv);
 
-   ctkSliderWidget sliderSpinBox;
 
-   // the first part of the tests infer 2 decimals
 
-   if (sliderSpinBox.decimals() != 2)
 
-     {
 
-     std::cerr << "ctkSliderWidget::decimals default value failed."
 
-               << sliderSpinBox.decimals() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }
 
-   sliderSpinBox.setValue(32.12);
 
-   if (!qFuzzyCompare(sliderSpinBox.value(), 32.12))
 
-     {
 
-     std::cerr << "ctkSliderWidget::setValue failed."
 
-               << sliderSpinBox.value() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }
 
-   sliderSpinBox.setMinimum(10.0123);
 
-   if (!qFuzzyCompare(sliderSpinBox.minimum(), 10.01) || 
 
-       !qFuzzyCompare(sliderSpinBox.value(), 32.12))
 
-     {
 
-     std::cerr << "ctkSliderWidget::setMinimum failed."
 
-               << sliderSpinBox.minimum() << " "
 
-               << sliderSpinBox.value() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }
 
-   
 
-   sliderSpinBox.setMaximum(2050.9876);
 
-   if (!qFuzzyCompare(sliderSpinBox.maximum(), 2050.99) || 
 
-       !qFuzzyCompare(sliderSpinBox.value(), 32.12))
 
-     {
 
-     std::cerr << "ctkSliderWidget::setMaximum failed."
 
-               << sliderSpinBox.maximum() << " "
 
-               << sliderSpinBox.value() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }
 
-   sliderSpinBox.setSingleStep(0.1);
 
-   if (!qFuzzyCompare(sliderSpinBox.singleStep(), 0.1) || 
 
-       !qFuzzyCompare(sliderSpinBox.value(), 32.12))
 
-     {
 
-     std::cerr << "ctkSliderWidget::setSingleStep failed."
 
-               << sliderSpinBox.singleStep() << " "
 
-               << sliderSpinBox.value() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }
 
-   sliderSpinBox.setDecimals(1);
 
-   if (sliderSpinBox.decimals() != 1 || 
 
-       !qFuzzyCompare(sliderSpinBox.value(), 32.1) ||
 
-       !qFuzzyCompare(sliderSpinBox.minimum(), 10.0) ||
 
-       !qFuzzyCompare(sliderSpinBox.maximum(), 2051.0))
 
-     {
 
-     std::cerr << "ctkSliderWidget::setDecimals failed."
 
-               << sliderSpinBox.decimals() << " "
 
-               << sliderSpinBox.value() << " " 
 
-               << sliderSpinBox.minimum() << " " 
 
-               << sliderSpinBox.maximum() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }  
 
-   sliderSpinBox.setValue(77.777);
 
-   if (!qFuzzyCompare(sliderSpinBox.value(), 77.8))
 
-     {
 
-     std::cerr << "ctkSliderWidget::setValue failed."
 
-               << sliderSpinBox.value() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }  
 
-   sliderSpinBox.setTickInterval(0.1);
 
-   if (!qFuzzyCompare(sliderSpinBox.tickInterval(), 0.1) || 
 
-       !qFuzzyCompare(sliderSpinBox.value(), 77.8))
 
-     {
 
-     std::cerr << "ctkSliderWidget::setTickInterval failed."
 
-               << sliderSpinBox.tickInterval() << " "
 
-               << sliderSpinBox.value() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }
 
-   
 
-   sliderSpinBox.setMinimum(80.5678);
 
-   if (!qFuzzyCompare(sliderSpinBox.minimum(), 80.6) || 
 
-       !qFuzzyCompare(sliderSpinBox.value(), 80.6))
 
-     {
 
-     std::cerr << "ctkSliderWidget::setMinimum failed."
 
-               << sliderSpinBox.minimum() << " "
 
-               << sliderSpinBox.value() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }
 
-   sliderSpinBox.reset();
 
-   if (!qFuzzyCompare(sliderSpinBox.value(), 80.6))
 
-     {
 
-     std::cerr << "ctkSliderWidget::reset failed."
 
-               << sliderSpinBox.value() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }
 
-   
 
-   sliderSpinBox.setSpinBoxAlignment(Qt::AlignRight);
 
-   if (sliderSpinBox.spinBoxAlignment() != Qt::AlignRight || 
 
-       !qFuzzyCompare(sliderSpinBox.value(), 80.6))
 
-     {
 
-     std::cerr << "ctkSliderWidget::setSpinBoxAlignment failed."
 
-               << sliderSpinBox.spinBoxAlignment() << " "
 
-               << sliderSpinBox.value() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }
 
-   sliderSpinBox.setAutoSpinBoxWidth(false);
 
-   if (sliderSpinBox.isAutoSpinBoxWidth() != false || 
 
-       !qFuzzyCompare(sliderSpinBox.value(), 80.6))
 
-     {
 
-     std::cerr << "ctkSliderWidget::setAutoSpinBoxWidth failed."
 
-               << sliderSpinBox.isAutoSpinBoxWidth() << " "
 
-               << sliderSpinBox.value() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }
 
-   sliderSpinBox.setPrefix("$");
 
-   if (sliderSpinBox.prefix() != "$" || 
 
-       !qFuzzyCompare(sliderSpinBox.value(), 80.6))
 
-     {
 
-     std::cerr << "ctkSliderWidget::setPrefix failed."
 
-               << sliderSpinBox.prefix().toLatin1().data() << " "
 
-               << sliderSpinBox.value() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }
 
-   sliderSpinBox.setSuffix("mm");
 
-   if (sliderSpinBox.suffix() != "mm" || 
 
-       !qFuzzyCompare(sliderSpinBox.value(), 80.6))
 
-     {
 
-     std::cerr << "ctkSliderWidget::setSuffix failed."
 
-               << sliderSpinBox.suffix().toLatin1().data() << " "
 
-               << sliderSpinBox.value() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }
 
-   sliderSpinBox.setDecimals(0);
 
-   if (!qFuzzyCompare(sliderSpinBox.value(), 81) ||
 
-       !qFuzzyCompare(sliderSpinBox.minimum(), 81) ||
 
-       !qFuzzyCompare(sliderSpinBox.maximum(), 2051))
 
-     {
 
-     std::cerr << "ctkSliderWidget::setDecimals failed."
 
-               << sliderSpinBox.value() << " " 
 
-               << sliderSpinBox.minimum() << " " 
 
-               << sliderSpinBox.maximum() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }
 
-   sliderSpinBox.setPageStep(1.);
 
-   if (sliderSpinBox.pageStep() != 1.)
 
-     {
 
-     std::cerr << "ctkSliderWidget::setPageStep(1.) failed"
 
-               << " val: " << sliderSpinBox.pageStep() << std::endl;
 
-     return EXIT_FAILURE;
 
-     }
 
-   // FIXME check that the correct signals are sent.
 
-   sliderSpinBox.show();
 
-   if (argc < 2 || QString(argv[1]) != "-I" )
 
-     {
 
-     QTimer::singleShot(100, &app, SLOT(quit()));
 
-     }
 
-   return app.exec();
 
- }
 
 
  |