ctkCoordinatesWidget.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 2010 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 spinbox is associated, everytime a value is modified
  23. /// the signal valueChanged is fired.
  24. class CTK_WIDGETS_EXPORT ctkCoordinatesWidget : public QWidget
  25. {
  26. Q_OBJECT
  27. Q_PROPERTY(int Dimension READ dimension WRITE setDimension)
  28. Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
  29. Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
  30. Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep STORED false)
  31. Q_PROPERTY(QString coordinates READ coordinatesAsString WRITE setCoordinatesAsString)
  32. public:
  33. explicit ctkCoordinatesWidget(QWidget* parent = 0);
  34. virtual ~ctkCoordinatesWidget();
  35. ///
  36. /// Set/Get the dimension of the point (3D by default)
  37. void setDimension(int dim);
  38. int dimension() const;
  39. ///
  40. /// Set/Get the single step of the QDoubleSpinBoxes
  41. void setSingleStep(double step);
  42. double singleStep() const;
  43. ///
  44. /// Set/Get the minimum value of the QDoubleSpinBoxes
  45. void setMinimum(double minimum);
  46. double minimum() const;
  47. ///
  48. /// Set/Get the maximum value of the QDoubleSpinBoxes
  49. void setMaximum(double minimum);
  50. double maximum() const;
  51. ///
  52. /// Set/Get the coordinates. Use commas between numbers
  53. void setCoordinatesAsString(QString pos);
  54. QString coordinatesAsString()const;
  55. ///
  56. /// Set/Get the coordinates
  57. void setCoordinates(double* pos);
  58. double* coordinates()const;
  59. signals:
  60. ///
  61. /// valueChanged is fired anytime one coordinate is modified
  62. void valueChanged(double* pos);
  63. protected slots:
  64. void coordinateChanged(double);
  65. void coordinatesChanged();
  66. protected:
  67. void addSpinBox();
  68. double Minimum;
  69. double Maximum;
  70. double SingleStep;
  71. int Dimension;
  72. double* Coordinates;
  73. };
  74. #endif