ctkMaterialPropertyWidget.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 __ctkMaterialPropertyWidget_h
  15. #define __ctkMaterialPropertyWidget_h
  16. // Qt includes
  17. #include <QWidget>
  18. // CTK includes
  19. #include "ctkWidgetsExport.h"
  20. class ctkMaterialPropertyWidgetPrivate;
  21. class QListWidgetItem;
  22. class CTK_WIDGETS_EXPORT ctkMaterialPropertyWidget : public QWidget
  23. {
  24. Q_OBJECT
  25. Q_PROPERTY(QColor color READ color WRITE setColor);
  26. Q_PROPERTY(double opacity READ opacity WRITE setOpacity);
  27. Q_PROPERTY(double ambient READ ambient WRITE setAmbient);
  28. Q_PROPERTY(double diffuse READ diffuse WRITE setDiffuse);
  29. Q_PROPERTY(double specular READ specular WRITE setSpecular);
  30. Q_PROPERTY(double specularPower READ specularPower WRITE setSpecularPower);
  31. Q_PROPERTY(bool backfaceCulling READ backfaceCulling WRITE setBackfaceCulling);
  32. public:
  33. /// Superclass typedef
  34. typedef QWidget Superclass;
  35. /// Constructor
  36. explicit ctkMaterialPropertyWidget(QWidget* parent = 0);
  37. /// Destructor
  38. virtual ~ctkMaterialPropertyWidget();
  39. QColor color()const;
  40. double opacity()const;
  41. double ambient()const;
  42. double diffuse()const;
  43. double specular()const;
  44. double specularPower()const;
  45. bool backfaceCulling()const;
  46. void addPreset(const QColor& color, double opacity,
  47. double ambient, double diffuse,
  48. double specular, double power,
  49. const QString& label);
  50. public slots:
  51. void setColor(const QColor& newColor);
  52. void setOpacity(double newOpacity);
  53. void setAmbient(double newAmbient);
  54. void setDiffuse(double newDiffuse);
  55. void setSpecular(double newSpecular);
  56. void setSpecularPower(double newSpecularPower);
  57. void setBackfaceCulling(bool enable);
  58. signals:
  59. void colorChanged(QColor newColor);
  60. void opacityChanged(double newOpacity);
  61. void ambientChanged(double newAmbient);
  62. void diffuseChanged(double newDiffuse);
  63. void specularChanged(double newSpecular);
  64. void specularPowerChanged(double newSpecularPower);
  65. void backfaceCullingChanged(bool newBackfaceCulling);
  66. protected slots:
  67. virtual void onColorChanged(const QColor& newColor);
  68. virtual void onOpacityChanged(double newOpacity);
  69. virtual void onAmbientChanged(double newAmbient);
  70. virtual void onDiffuseChanged(double newDiffuse);
  71. virtual void onSpecularChanged(double newSpecular);
  72. virtual void onSpecularPowerChanged(double newSpecularPower);
  73. virtual void onBackfaceCullingChanged(bool newBackFaceCulling);
  74. void selectPreset(QListWidgetItem*);
  75. protected:
  76. QScopedPointer<ctkMaterialPropertyWidgetPrivate> d_ptr;
  77. virtual void resizeEvent(QResizeEvent* resize);
  78. private:
  79. Q_DECLARE_PRIVATE(ctkMaterialPropertyWidget);
  80. Q_DISABLE_COPY(ctkMaterialPropertyWidget);
  81. };
  82. #endif