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 #include <Inventor/nodes/SoSeparator.h>
34 #include <Inventor/nodes/SoMaterial.h>
35 #include <Inventor/nodes/SoCube.h>
36 #include <Inventor/nodes/SoTranslation.h>
37 #include <Inventor/nodes/SoRotationXYZ.h>
38
39 #include <Inventor/Qt/SoQt.h>
40 #include <Inventor/Qt/SoQtColorEditor.h>
41 #include <Inventor/Qt/nodes/SoGuiColorEditor.h>
42 #include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
43
44 static SoMaterial * material;
45
46 SoSeparator *
makescene(void)47 makescene(void)
48 {
49 SoSeparator * root = new SoSeparator;
50 root->addChild(material = new SoMaterial);
51 root->addChild(new SoCube);
52 return root;
53 }
54
55 int
main(int argc,char ** argv)56 main(int argc, char ** argv)
57 {
58 QWidget * w = SoQt::init(argc, argv, "SoQtColorEditor");
59 SoQtExaminerViewer * viewer = new SoQtExaminerViewer(w);
60 SoSeparator * root;
61 viewer->setSceneGraph(root = makescene());
62 viewer->show();
63
64 // we want ColorEditor in scene
65 SoSeparator * editorscene = new SoSeparator;
66 SoTranslation * trans = new SoTranslation;
67 trans->translation.setValue(SbVec3f(2.0f, 0.0f, 0.0f));
68 SoRotationXYZ * rot = new SoRotationXYZ;
69 SoMaterial * mat = new SoMaterial;
70 mat->diffuseColor.setValue(0.8, 0.8, 0.8);
71 rot->axis = SoRotationXYZ::Y;
72 rot->angle = 0.5;
73 editorscene->addChild(trans);
74 editorscene->addChild(rot);
75 editorscene->addChild(mat);
76 SoGuiColorEditor * inscene = new SoGuiColorEditor;
77 inscene->wysiwyg.setValue(TRUE);
78 inscene->color.connectFrom(&(material->diffuseColor));
79 inscene->color.getValue(); // update field
80 material->diffuseColor.connectFrom(&(inscene->color));
81 editorscene->addChild(inscene);
82 root->insertChild(editorscene, 0);
83
84 #if 0
85 SoQtColorEditor * editor = new SoQtColorEditor;
86 editor->attach(&(material->diffuseColor));
87 editor->show();
88 #endif
89
90 SoQt::show(w);
91 SoQt::mainLoop();
92 return 0;
93 }
94