ctkMaterialPropertyPreviewLabel.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. // Freely inspired from KWWidgets: vtkKWMaterialPropertyWidget
  15. #ifndef __ctkMaterialPropertyPreviewLabel_h
  16. #define __ctkMaterialPropertyPreviewLabel_h
  17. // Qt includes
  18. #include <QFrame>
  19. // CTK includes
  20. #include "ctkWidgetsExport.h"
  21. class ctkMaterialPropertyPreviewLabelPrivate;
  22. /// \ingroup Widgets
  23. class CTK_WIDGETS_EXPORT ctkMaterialPropertyPreviewLabel : public QFrame
  24. {
  25. Q_OBJECT
  26. Q_PROPERTY(double ambient READ ambient WRITE setAmbient)
  27. Q_PROPERTY(double diffuse READ diffuse WRITE setDiffuse)
  28. Q_PROPERTY(double specular READ specular WRITE setSpecular)
  29. Q_PROPERTY(double specularPower READ specularPower WRITE setSpecularPower)
  30. Q_PROPERTY(QColor color READ color WRITE setColor)
  31. Q_PROPERTY(double opacity READ opacity WRITE setOpacity)
  32. Q_PROPERTY(double gridOpacity READ gridOpacity WRITE setGridOpacity)
  33. public :
  34. ctkMaterialPropertyPreviewLabel(QWidget *parent = 0);
  35. ctkMaterialPropertyPreviewLabel(const QColor& color, double opacity,
  36. double ambient, double diffuse, double specular, double specularPower,
  37. QWidget *parent = 0);
  38. virtual ~ctkMaterialPropertyPreviewLabel();
  39. double ambient()const;
  40. double diffuse()const;
  41. double specular()const;
  42. double specularPower()const;
  43. QColor color()const;
  44. double opacity()const;
  45. double gridOpacity()const;
  46. /// Reimplemented to make it square
  47. virtual int heightForWidth(int w)const;
  48. virtual QSize sizeHint()const;
  49. public Q_SLOTS:
  50. /// Valid range: [0,1]
  51. void setAmbient(double newAbient);
  52. /// Valid range: [0,1]
  53. void setDiffuse(double newDiffuse);
  54. /// Valid range: [0,1]
  55. void setSpecular(double newSpecular);
  56. /// Valid range: [1,inf[
  57. void setSpecularPower(double newSpecularPower);
  58. void setColor(const QColor& newColor);
  59. /// Valid range: [0, 1]
  60. void setOpacity(double newOpacity);
  61. void setGridOpacity(double newGridOpacity);
  62. protected:
  63. void paintEvent(QPaintEvent *);
  64. void draw(QImage& image);
  65. QScopedPointer<ctkMaterialPropertyPreviewLabelPrivate> d_ptr;
  66. private :
  67. Q_DECLARE_PRIVATE(ctkMaterialPropertyPreviewLabel);
  68. Q_DISABLE_COPY(ctkMaterialPropertyPreviewLabel);
  69. };
  70. #endif