ctkCoordinatesWidget.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkCoordinatesWidget_h
  15. #define __ctkCoordinatesWidget_h
  16. // Qt includes
  17. #include <QWidget>
  18. // CTK includes
  19. #include "ctkWidgetsExport.h"
  20. /// \ingroup Widgets
  21. ///
  22. /// ctkCoordinatesWidget is a simple container of dimension coordinates.
  23. /// For each coordinate a double spinbox is associated, everytime a value is
  24. /// modified, the signal valueChanged is fired.
  25. /// TODO: use pimpl
  26. class CTK_WIDGETS_EXPORT ctkCoordinatesWidget : public QWidget
  27. {
  28. Q_OBJECT
  29. Q_PROPERTY(int decimals READ decimals WRITE setDecimals)
  30. Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep STORED false)
  31. Q_PROPERTY(int dimension READ dimension WRITE setDimension)
  32. Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
  33. Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
  34. Q_PROPERTY(QString coordinates READ coordinatesAsString WRITE setCoordinatesAsString)
  35. public:
  36. explicit ctkCoordinatesWidget(QWidget* parent = 0);
  37. virtual ~ctkCoordinatesWidget();
  38. ///
  39. /// Set/Get the dimension of the point
  40. /// The default dimension is 3
  41. void setDimension(int dim);
  42. int dimension() const;
  43. ///
  44. /// Set/Get the number of decimals of each coordinate QDoubleSpinBoxes
  45. /// The default single step is 3
  46. void setDecimals(int decimals);
  47. int decimals() const;
  48. ///
  49. /// Set/Get the single step of each coordinate QDoubleSpinBoxes
  50. /// The default single step is 1.
  51. void setSingleStep(double step);
  52. double singleStep() const;
  53. ///
  54. /// Set/Get the minimum value of each coordinate QDoubleSpinBoxes
  55. /// The default minimum is -100000.
  56. void setMinimum(double minimum);
  57. double minimum() const;
  58. ///
  59. /// Set/Get the maximum value of each coordinate QDoubleSpinBoxes
  60. /// The default maximum is 100000.
  61. void setMaximum(double minimum);
  62. double maximum() const;
  63. ///
  64. /// Set/Get the coordinates. Use commas between numbers
  65. /// i.e. "0,0.0,0."
  66. void setCoordinatesAsString(QString pos);
  67. QString coordinatesAsString()const;
  68. ///
  69. /// Set/Get the coordinates
  70. /// The default values are 0.
  71. void setCoordinates(double* pos);
  72. double const * coordinates()const;
  73. Q_SIGNALS:
  74. ///
  75. /// valueChanged is fired anytime a coordinate is modified, the returned
  76. /// value is the point coordinates
  77. /// TODO: Don't fire the signal if the new values are not changed
  78. void coordinatesChanged(double* pos);
  79. protected Q_SLOTS:
  80. void updateCoordinate(double);
  81. void updateCoordinates();
  82. protected:
  83. void addSpinBox();
  84. int Decimals;
  85. double SingleStep;
  86. double Minimum;
  87. double Maximum;
  88. int Dimension;
  89. double* Coordinates;
  90. };
  91. #endif