ctkCoordinatesWidget.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.commontk.org/LICENSE
  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. ///
  21. /// ctkCoordinatesWidget is a simple container of dimension coordinates.
  22. /// For each coordinate a double spinbox is associated, everytime a value is
  23. /// modified, the signal valueChanged is fired.
  24. /// TODO: use pimpl
  25. class CTK_WIDGETS_EXPORT ctkCoordinatesWidget : public QWidget
  26. {
  27. Q_OBJECT
  28. Q_PROPERTY(int decimals READ decimals WRITE setDecimals)
  29. Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep STORED false)
  30. Q_PROPERTY(int dimension READ dimension WRITE setDimension)
  31. Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
  32. Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
  33. Q_PROPERTY(QString coordinates READ coordinatesAsString WRITE setCoordinatesAsString)
  34. public:
  35. explicit ctkCoordinatesWidget(QWidget* parent = 0);
  36. virtual ~ctkCoordinatesWidget();
  37. ///
  38. /// Set/Get the dimension of the point
  39. /// The default dimension is 3
  40. void setDimension(int dim);
  41. int dimension() const;
  42. ///
  43. /// Set/Get the number of decimals of each coordinate QDoubleSpinBoxes
  44. /// The default single step is 3
  45. void setDecimals(int decimals);
  46. int decimals() const;
  47. ///
  48. /// Set/Get the single step of each coordinate QDoubleSpinBoxes
  49. /// The default single step is 1.
  50. void setSingleStep(double step);
  51. double singleStep() const;
  52. ///
  53. /// Set/Get the minimum value of each coordinate QDoubleSpinBoxes
  54. /// The default minimum is -100000.
  55. void setMinimum(double minimum);
  56. double minimum() const;
  57. ///
  58. /// Set/Get the maximum value of each coordinate QDoubleSpinBoxes
  59. /// The default maximum is 100000.
  60. void setMaximum(double minimum);
  61. double maximum() const;
  62. ///
  63. /// Set/Get the coordinates. Use commas between numbers
  64. /// i.e. "0,0.0,0."
  65. void setCoordinatesAsString(QString pos);
  66. QString coordinatesAsString()const;
  67. ///
  68. /// Set/Get the coordinates
  69. /// The default values are 0.
  70. void setCoordinates(double* pos);
  71. double const * coordinates()const;
  72. signals:
  73. ///
  74. /// valueChanged is fired anytime a coordinate is modified, the returned
  75. /// value is the point coordinates
  76. /// TODO: Don't fire the signal if the new values are not changed
  77. void coordinatesChanged(double* pos);
  78. protected slots:
  79. void updateCoordinate(double);
  80. void updateCoordinates();
  81. protected:
  82. void addSpinBox();
  83. int Decimals;
  84. double SingleStep;
  85. double Minimum;
  86. double Maximum;
  87. int Dimension;
  88. double* Coordinates;
  89. };
  90. #endif