1 /**************************************************************************\ 2 * Copyright (c) Kongsberg Oil & Gas Technologies AS 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * Redistributions of source code must retain the above copyright notice, 10 * this list of conditions and the following disclaimer. 11 * 12 * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * Neither the name of the copyright holder nor the names of its 17 * contributors may be used to endorse or promote products derived from 18 * this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 \**************************************************************************/ 32 33 #ifndef SOQT_MATERIALEDITOR_H 34 #define SOQT_MATERIALEDITOR_H 35 36 #include <Inventor/Qt/SoQtComponent.h> 37 #include <qwidget.h> 38 39 class _SoQtColorSlider; 40 class _SoQtColorEditor; 41 class SoQtMaterialList; 42 class SoMaterial; 43 class QPopupMenu; 44 class QButton; 45 class QRadioButton; 46 class QCheckBox; 47 class SoGLMaterialSphere; 48 class QColorSelection; 49 class SoMFColor; 50 51 52 typedef void SoQtMaterialEditorCB(void *userData, const SoMaterial *mtl); 53 54 class SOQT_DLL_API SoQtMaterialEditor : public SoQtComponent 55 { 56 Q_OBJECT 57 public: 58 59 enum UpdateFrequency { 60 CONTINUOUS, 61 AFTER_ACCEPT 62 }; 63 64 SoQtMaterialEditor(QWidget *parent = NULL, 65 const char *name =NULL, 66 SbBool buildInsideParent = TRUE); 67 ~SoQtMaterialEditor(); 68 69 void attach(SoMaterial *material, int index = 0); 70 void detach(); 71 72 SbBool isAttached(); 73 74 void addMaterialChangedCallback(SoQtMaterialEditorCB *f, 75 void *userData = NULL); 76 void removeMaterialChangedCallback(SoQtMaterialEditorCB *f, 77 void *userData = NULL); 78 79 void setUpdateFrequency(UpdateFrequency freq); 80 UpdateFrequency getUpdateFrequency(); 81 82 void setMaterial(const SoMaterial &mtl); 83 const SoMaterial& getMaterial() const; 84 85 86 public slots: 87 void material_list(); 88 void continuous(); 89 void manual(); 90 void accept(); 91 void menu_popup(); 92 void colorChanged(QColor&); 93 void rButtonPressed(); 94 void cButtonPressed(); 95 void setMaterial(SoMaterial *); 96 void clearAllButtons(); 97 98 signals: 99 void materialChanged(); 100 101 protected: 102 const char* componentClassName() const; 103 104 private: 105 SoMaterial* material; 106 SoMFColor* colors[4]; 107 int index; 108 int contId; 109 int manuId; 110 111 QWidget *acceptButton; 112 QCheckBox *checkButtons[4]; 113 QRadioButton *radioButtons[4]; 114 QPopupMenu *menu; 115 QButton *menuButton; 116 117 UpdateFrequency updatefreq; 118 119 QWidget* mgrWidget; 120 121 _SoQtColorEditor *colorEditor; 122 _SoQtColorSlider *sliders[6]; 123 QColorSelection *colorSelection; 124 125 QWidget* editColor; 126 SoGLMaterialSphere* ball; 127 SoMaterial* dummyMaterial; 128 SoQtMaterialList* materialList; 129 130 void connectUpdaters(bool connect = true); 131 }; 132 133 #endif // ! SOQT_MATERIALEDITOR_H 134