| [d238e7] | 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| [0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
|---|
| [5aaa43] | 5 | * Copyright (C) 2013 Frederik Heber. All rights reserved.
|
|---|
| [94d5ac6] | 6 | *
|
|---|
| 7 | *
|
|---|
| 8 | * This file is part of MoleCuilder.
|
|---|
| 9 | *
|
|---|
| 10 | * MoleCuilder is free software: you can redistribute it and/or modify
|
|---|
| 11 | * it under the terms of the GNU General Public License as published by
|
|---|
| 12 | * the Free Software Foundation, either version 2 of the License, or
|
|---|
| 13 | * (at your option) any later version.
|
|---|
| 14 | *
|
|---|
| 15 | * MoleCuilder is distributed in the hope that it will be useful,
|
|---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 18 | * GNU General Public License for more details.
|
|---|
| 19 | *
|
|---|
| 20 | * You should have received a copy of the GNU General Public License
|
|---|
| 21 | * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| [d238e7] | 22 | */
|
|---|
| 23 |
|
|---|
| 24 | /*
|
|---|
| 25 | * GLWorldView.cpp
|
|---|
| 26 | *
|
|---|
| 27 | * Created on: Aug 1, 2010
|
|---|
| 28 | * Author: heber
|
|---|
| 29 | */
|
|---|
| 30 |
|
|---|
| 31 | // include config.h
|
|---|
| 32 | #ifdef HAVE_CONFIG_H
|
|---|
| 33 | #include <config.h>
|
|---|
| 34 | #endif
|
|---|
| 35 |
|
|---|
| 36 | #include "GLWorldView.hpp"
|
|---|
| 37 |
|
|---|
| 38 | #include <Qt/qevent.h>
|
|---|
| [0e5d14] | 39 | #include <Qt/qaction.h>
|
|---|
| [8e7dd9] | 40 | #include <QtGui/QMenu>
|
|---|
| [0e5d14] | 41 | #include <QtGui/QToolBar>
|
|---|
| [8e7dd9] | 42 | #include <QtGui/QToolButton>
|
|---|
| [585f78] | 43 | #include <Qt/qtimer.h>
|
|---|
| [c7e000] | 44 | #include <Qt/qsettings.h>
|
|---|
| [26ed25] | 45 | #include <Qt3D/qglbuilder.h>
|
|---|
| 46 | #include <Qt3D/qglscenenode.h>
|
|---|
| 47 | #include <Qt3D/qglsphere.h>
|
|---|
| 48 | #include <Qt3D/qglcylinder.h>
|
|---|
| [02b2d3] | 49 | #include <Qt3D/qglcube.h>
|
|---|
| [d238e7] | 50 |
|
|---|
| [907636] | 51 | #include "GLWorldScene.hpp"
|
|---|
| [d238e7] | 52 |
|
|---|
| 53 | #include "CodePatterns/MemDebug.hpp"
|
|---|
| 54 |
|
|---|
| [53059e] | 55 | #include "Atom/AtomObserver.hpp"
|
|---|
| 56 | #include "Atom/atom_observable.hpp"
|
|---|
| [1d02c2d] | 57 | #include "Box.hpp"
|
|---|
| [7188b1] | 58 | #include "CodePatterns/Log.hpp"
|
|---|
| [02ce36] | 59 | #include "CodePatterns/Observer/Notification.hpp"
|
|---|
| [856d05] | 60 | #include "CodePatterns/Observer/ObserverLog.hpp"
|
|---|
| [1d02c2d] | 61 | #include "molecule.hpp"
|
|---|
| [284551] | 62 | #include "Shapes/ShapeRegistry.hpp"
|
|---|
| [7188b1] | 63 | #include "World.hpp"
|
|---|
| [89b992] | 64 | #include "WorldTime.hpp"
|
|---|
| [7188b1] | 65 |
|
|---|
| [d238e7] | 66 | GLWorldView::GLWorldView(QWidget *parent)
|
|---|
| [585f78] | 67 | : QGLView(parent), Observer("GLWorldView"), worldscene(NULL), changesPresent(false), needsRedraw(false)
|
|---|
| [d238e7] | 68 | {
|
|---|
| [65487f] | 69 | worldscene = new GLWorldScene(this);
|
|---|
| [d238e7] | 70 |
|
|---|
| [65487f] | 71 | setOption(QGLView::ObjectPicking, true);
|
|---|
| [8880c9] | 72 | setOption(QGLView::CameraNavigation, false);
|
|---|
| 73 | setCameraControlMode(Rotate);
|
|---|
| [8e7dd9] | 74 | defaultEyeSeparation = 4.0;
|
|---|
| [d238e7] | 75 |
|
|---|
| [26ed25] | 76 | createDomainBox();
|
|---|
| 77 | createDreiBein();
|
|---|
| [e8c636] | 78 | //changeMaterials(false);
|
|---|
| 79 |
|
|---|
| [c48ac12] | 80 | qRegisterMetaType<atomicNumber_t>("atomicNumber_t");
|
|---|
| 81 |
|
|---|
| [8481f5] | 82 | connect(this, SIGNAL(ShapeAdded()), worldscene, SLOT(addShape()));
|
|---|
| 83 | connect(this, SIGNAL(ShapeRemoved()), worldscene, SLOT(removeShape()));
|
|---|
| [ce4126] | 84 | connect(this, SIGNAL(TimeChanged()), worldscene, SIGNAL(updated()));
|
|---|
| [65487f] | 85 | connect(worldscene, SIGNAL(changeOccured()), this, SLOT(changeSignalled()));
|
|---|
| 86 | connect(worldscene, SIGNAL(changed()), this, SIGNAL(changed()));
|
|---|
| [407638e] | 87 | connect(worldscene, SIGNAL(hoverChanged(const atom *)), this, SLOT(sceneHoverSignalled(const atom *)));
|
|---|
| [beadd0] | 88 | connect(this, SIGNAL(atomInserted(const atomicNumber_t)), worldscene, SLOT(atomInserted(const atomicNumber_t)));
|
|---|
| [c48ac12] | 89 | connect(this, SIGNAL(atomRemoved(const atomicNumber_t)), worldscene, SLOT(atomRemoved(const atomicNumber_t)));
|
|---|
| [3927ef] | 90 | connect(this, SIGNAL(worldSelectionChanged()), worldscene, SLOT(worldSelectionChanged()));
|
|---|
| [c67518] | 91 | connect(this, SIGNAL(moleculeRemoved(const molecule *)), worldscene, SLOT(moleculeRemoved(const molecule *)));
|
|---|
| [30cd0d] | 92 | //connect(this, SIGNAL(moleculeInserted(const molecule *)), worldscene, SLOT(moleculeInserted(const molecule *)));
|
|---|
| [585f78] | 93 | //connect(this, SIGNAL(changed()), this, SLOT(updateGL()));
|
|---|
| 94 | connect(this, SIGNAL(changed()), this, SLOT(sceneChangeSignalled()));
|
|---|
| [7188b1] | 95 |
|
|---|
| [65487f] | 96 | // sign on to changes in the world
|
|---|
| 97 | World::getInstance().signOn(this);
|
|---|
| [02ce36] | 98 | World::getInstance().signOn(this, World::AtomInserted);
|
|---|
| 99 | World::getInstance().signOn(this, World::AtomRemoved);
|
|---|
| [53059e] | 100 | World::getInstance().signOn(this, World::MoleculeInserted);
|
|---|
| [c67518] | 101 | World::getInstance().signOn(this, World::MoleculeRemoved);
|
|---|
| [3927ef] | 102 | World::getInstance().signOn(this, World::SelectionChanged);
|
|---|
| [89b992] | 103 | WorldTime::getInstance().signOn(this, WorldTime::TimeChanged);
|
|---|
| [53059e] | 104 | AtomObserver::getInstance().signOn(this, AtomObservable::PositionChanged);
|
|---|
| [585f78] | 105 |
|
|---|
| [284551] | 106 | ShapeRegistry::getInstance().signOn(this);
|
|---|
| [85c36d] | 107 | ShapeRegistry::getInstance().signOn(this, ShapeRegistry::ShapeInserted);
|
|---|
| [284551] | 108 | ShapeRegistry::getInstance().signOn(this, ShapeRegistry::ShapeRemoved);
|
|---|
| 109 | ShapeRegistry::getInstance().signOn(this, ShapeRegistry::SelectionChanged);
|
|---|
| 110 |
|
|---|
| [585f78] | 111 | redrawTimer = new QTimer(this);
|
|---|
| [d238e7] | 112 | }
|
|---|
| 113 |
|
|---|
| [04f017] | 114 | GLWorldView::~GLWorldView()
|
|---|
| 115 | {
|
|---|
| [592d42] | 116 | QSettings settings;
|
|---|
| 117 | settings.beginGroup("WorldView");
|
|---|
| 118 | settings.setValue("domainBoxEnabled", (meshDomainBox->options() & QGLSceneNode::HideNode) == 0);
|
|---|
| 119 | settings.setValue("dreiBeinEnabled", (meshDreiBein->options() & QGLSceneNode::HideNode) == 0);
|
|---|
| 120 | settings.endGroup();
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| [9c18e4] | 123 | World::getInstance().signOff(this);
|
|---|
| [02ce36] | 124 | World::getInstance().signOff(this, World::AtomInserted);
|
|---|
| 125 | World::getInstance().signOff(this, World::AtomRemoved);
|
|---|
| [53059e] | 126 | World::getInstance().signOff(this, World::MoleculeInserted);
|
|---|
| [c67518] | 127 | World::getInstance().signOff(this, World::MoleculeRemoved);
|
|---|
| [3927ef] | 128 | World::getInstance().signOff(this, World::SelectionChanged);
|
|---|
| [89b992] | 129 | WorldTime::getInstance().signOff(this, WorldTime::TimeChanged);
|
|---|
| [53059e] | 130 | AtomObserver::getInstance().signOff(this, AtomObservable::PositionChanged);
|
|---|
| [284551] | 131 | ShapeRegistry::getInstance().signOff(this);
|
|---|
| [85c36d] | 132 | ShapeRegistry::getInstance().signOff(this, ShapeRegistry::ShapeInserted);
|
|---|
| [284551] | 133 | ShapeRegistry::getInstance().signOff(this, ShapeRegistry::ShapeRemoved);
|
|---|
| 134 | ShapeRegistry::getInstance().signOff(this, ShapeRegistry::SelectionChanged);
|
|---|
| [04f017] | 135 | delete worldscene;
|
|---|
| [e8c636] | 136 |
|
|---|
| 137 | delete(domainBoxMaterial);
|
|---|
| 138 | for (int i=0;i<3;i++)
|
|---|
| 139 | delete(dreiBeinMaterial[i]);
|
|---|
| [04f017] | 140 | }
|
|---|
| 141 |
|
|---|
| [0e5d14] | 142 |
|
|---|
| 143 | /**
|
|---|
| 144 | * Add some widget specific actions to the toolbar:
|
|---|
| 145 | * - camera rotation/translation mode
|
|---|
| 146 | * - camera fit to domain
|
|---|
| 147 | */
|
|---|
| 148 | void GLWorldView::addToolBarActions(QToolBar *toolbar)
|
|---|
| 149 | {
|
|---|
| [f31b34] | 150 | // camera control mode
|
|---|
| [0e5d14] | 151 | toolbar->addSeparator();
|
|---|
| 152 | QAction *transAction = new QAction(QIcon::fromTheme("forward"), tr("camera translation mode"), this);
|
|---|
| 153 | connect(transAction, SIGNAL(triggered()), this, SLOT(setCameraControlModeTranslation()));
|
|---|
| 154 | toolbar->addAction(transAction);
|
|---|
| 155 | QAction *rotAction = new QAction(QIcon::fromTheme("object-rotate-left"), tr("camera rotation mode"), this);
|
|---|
| 156 | connect(rotAction, SIGNAL(triggered()), this, SLOT(setCameraControlModeRotation()));
|
|---|
| 157 | toolbar->addAction(rotAction);
|
|---|
| 158 | QAction *fitAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("camera fit to domain"), this);
|
|---|
| 159 | connect(fitAction, SIGNAL(triggered()), this, SLOT(fitCameraToDomain()));
|
|---|
| 160 | toolbar->addAction(fitAction);
|
|---|
| [8e7dd9] | 161 |
|
|---|
| [f31b34] | 162 | // stereo mode
|
|---|
| [8e7dd9] | 163 | QToolButton *stereoButton = new QToolButton(toolbar);
|
|---|
| 164 | QMenu *stereoMenu = new QMenu();
|
|---|
| [a8fc70] | 165 | QAction *stereoDisableAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("disable"), this);
|
|---|
| 166 | connect(stereoDisableAction, SIGNAL(triggered()), this, SLOT(setCameraStereoModeDisable()));
|
|---|
| 167 | stereoMenu->addAction(stereoDisableAction);
|
|---|
| [8e7dd9] | 168 | QAction *stereoHardwareAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("hardware"), this);
|
|---|
| 169 | connect(stereoHardwareAction, SIGNAL(triggered()), this, SLOT(setCameraStereoModeHardware()));
|
|---|
| 170 | stereoMenu->addAction(stereoHardwareAction);
|
|---|
| 171 | QAction *stereoLeftRightAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("left right"), this);
|
|---|
| 172 | connect(stereoLeftRightAction, SIGNAL(triggered()), this, SLOT(setCameraStereoModeLeftRight()));
|
|---|
| 173 | stereoMenu->addAction(stereoLeftRightAction);
|
|---|
| 174 | QAction *stereoRightLeftAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("right left"), this);
|
|---|
| 175 | connect(stereoRightLeftAction, SIGNAL(triggered()), this, SLOT(setCameraStereoModeRightLeft()));
|
|---|
| 176 | stereoMenu->addAction(stereoRightLeftAction);
|
|---|
| 177 | QAction *stereoTopBottomAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("top bottom"), this);
|
|---|
| 178 | connect(stereoTopBottomAction, SIGNAL(triggered()), this, SLOT(setCameraStereoModeTopBottom()));
|
|---|
| 179 | stereoMenu->addAction(stereoTopBottomAction);
|
|---|
| 180 | QAction *stereoBottomTopAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("bottom top"), this);
|
|---|
| 181 | connect(stereoBottomTopAction, SIGNAL(triggered()), this, SLOT(setCameraStereoModeBottomTop()));
|
|---|
| 182 | stereoMenu->addAction(stereoBottomTopAction);
|
|---|
| 183 | QAction *stereoAnaglyphAction = new QAction(QIcon::fromTheme("zoom-best-fit"), tr("anaglyph"), this);
|
|---|
| 184 | connect(stereoAnaglyphAction, SIGNAL(triggered()), this, SLOT(setCameraStereoModeAnaglyph()));
|
|---|
| 185 | stereoMenu->addAction(stereoAnaglyphAction);
|
|---|
| 186 | stereoButton->setMenu(stereoMenu);
|
|---|
| [5b991a] | 187 | stereoButton->setIcon(QIcon(QPixmap(":/icon_view_stereo.png")));
|
|---|
| [8e7dd9] | 188 | stereoButton->setPopupMode(QToolButton::InstantPopup);
|
|---|
| 189 | toolbar->addWidget(stereoButton);
|
|---|
| [f31b34] | 190 |
|
|---|
| 191 | // selection mode
|
|---|
| 192 | toolbar->addSeparator();
|
|---|
| [5b991a] | 193 | QAction *selAtomAction = new QAction(QIcon(QPixmap(":/icon_select_atom.png")), tr("select atom by clicking"), this);
|
|---|
| [f31b34] | 194 | connect(selAtomAction, SIGNAL(triggered()), worldscene, SLOT(setSelectionModeAtom()));
|
|---|
| 195 | toolbar->addAction(selAtomAction);
|
|---|
| [5b991a] | 196 | QAction *selMolAction = new QAction(QIcon(QPixmap(":/icon_select_molecule.png")), tr("select molecule by clicking"), this);
|
|---|
| [f31b34] | 197 | connect(selMolAction, SIGNAL(triggered()), worldscene, SLOT(setSelectionModeMolecule()));
|
|---|
| 198 | toolbar->addAction(selMolAction);
|
|---|
| [592d42] | 199 |
|
|---|
| 200 | // dreiBein/domain enabler
|
|---|
| 201 | toolbar->addSeparator();
|
|---|
| 202 | QAction *seldreiBein = new QAction(QIcon(QPixmap(":/icon_dreiBein.png")), tr("enable/disable dreiBein"), this);
|
|---|
| 203 | connect(seldreiBein, SIGNAL(triggered()), this, SLOT(changeDreiBein()));
|
|---|
| 204 | toolbar->addAction(seldreiBein);
|
|---|
| 205 | QAction *seldomain = new QAction(QIcon(QPixmap(":/icon_domain.png")), tr("enable/disable domain box"), this);
|
|---|
| 206 | connect(seldomain, SIGNAL(triggered()), this, SLOT(changeDomain()));
|
|---|
| 207 | toolbar->addAction(seldomain);
|
|---|
| [0e5d14] | 208 | }
|
|---|
| 209 |
|
|---|
| [26ed25] | 210 | void GLWorldView::createDomainBox()
|
|---|
| 211 | {
|
|---|
| [c7e000] | 212 | QSettings settings;
|
|---|
| 213 | settings.beginGroup("WorldView");
|
|---|
| 214 | QColor colorFrame = settings.value("domainBoxColorFrame", QColor(150,160,200,255)).value<QColor>();
|
|---|
| 215 | QColor colorAmbient = settings.value("domainBoxColorAmbient", QColor(50,60,100,255)).value<QColor>();
|
|---|
| 216 | QColor colorDiffuse = settings.value("domainBoxColorDiffuse", QColor(150,160,200,180)).value<QColor>();
|
|---|
| 217 | settings.setValue("domainBoxColorFrame", colorFrame);
|
|---|
| 218 | settings.setValue("domainBoxColorAmbient", colorAmbient);
|
|---|
| 219 | settings.setValue("domainBoxColorDiffuse", colorDiffuse);
|
|---|
| [592d42] | 220 | const bool status = settings.value("domainBoxEnabled").toBool();
|
|---|
| [c7e000] | 221 | settings.endGroup();
|
|---|
| 222 |
|
|---|
| [02b2d3] | 223 | domainBoxMaterial = new QGLMaterial;
|
|---|
| 224 | domainBoxMaterial->setAmbientColor(QColor(0,0,0,255));
|
|---|
| 225 | domainBoxMaterial->setDiffuseColor(QColor(0,0,0,255));
|
|---|
| [c7e000] | 226 | domainBoxMaterial->setEmittedLight(colorFrame);
|
|---|
| [02b2d3] | 227 |
|
|---|
| [26ed25] | 228 |
|
|---|
| [02b2d3] | 229 | QGLMaterial *material = new QGLMaterial;
|
|---|
| [c7e000] | 230 | material->setAmbientColor(colorAmbient);
|
|---|
| 231 | material->setDiffuseColor(colorDiffuse);
|
|---|
| [02b2d3] | 232 |
|
|---|
| 233 | QGLBuilder builder;
|
|---|
| 234 | builder << QGL::Faceted;
|
|---|
| 235 | builder << QGLCube(-1.0); // "inverted" => inside faces are used as front.
|
|---|
| 236 | meshDomainBox = builder.finalizedSceneNode();
|
|---|
| 237 | QMatrix4x4 mat;
|
|---|
| 238 | mat.translate(0.5f, 0.5f, 0.5f);
|
|---|
| 239 | meshDomainBox->setLocalTransform(mat);
|
|---|
| 240 | meshDomainBox->setMaterial(material);
|
|---|
| [592d42] | 241 |
|
|---|
| 242 | setDomainStatus( status );
|
|---|
| [26ed25] | 243 | }
|
|---|
| 244 |
|
|---|
| 245 | void GLWorldView::createDreiBein()
|
|---|
| 246 | {
|
|---|
| [c7e000] | 247 | QSettings settings;
|
|---|
| 248 | settings.beginGroup("WorldView");
|
|---|
| 249 | QColor colorX = settings.value("dreiBeinColorX", QColor(255,50,50,255)).value<QColor>();
|
|---|
| 250 | QColor colorY = settings.value("dreiBeinColorY", QColor(50,255,50,255)).value<QColor>();
|
|---|
| 251 | QColor colorZ = settings.value("dreiBeinColorZ", QColor(50,50,255,255)).value<QColor>();
|
|---|
| 252 | settings.setValue("dreiBeinColorX", colorX);
|
|---|
| 253 | settings.setValue("dreiBeinColorY", colorY);
|
|---|
| 254 | settings.setValue("dreiBeinColorZ", colorZ);
|
|---|
| [592d42] | 255 | const bool status = settings.value("dreiBeinEnabled").toBool();
|
|---|
| [c7e000] | 256 | settings.endGroup();
|
|---|
| 257 |
|
|---|
| [02b2d3] | 258 | // Create 3 color for the 3 axes.
|
|---|
| [26ed25] | 259 | dreiBeinMaterial[0] = new QGLMaterial;
|
|---|
| [c7e000] | 260 | dreiBeinMaterial[0]->setColor(colorX);
|
|---|
| [26ed25] | 261 | dreiBeinMaterial[1] = new QGLMaterial;
|
|---|
| [c7e000] | 262 | dreiBeinMaterial[1]->setColor(colorY);
|
|---|
| [26ed25] | 263 | dreiBeinMaterial[2] = new QGLMaterial;
|
|---|
| [c7e000] | 264 | dreiBeinMaterial[2]->setColor(colorZ);
|
|---|
| [26ed25] | 265 |
|
|---|
| [02b2d3] | 266 | // Create the basic meshes (cylinder and cone).
|
|---|
| [26ed25] | 267 | QGLBuilder builderCyl;
|
|---|
| [37e910] | 268 | builderCyl << QGLCylinder(.15,.15,1.6,16);
|
|---|
| [26ed25] | 269 | QGLSceneNode *cyl = builderCyl.finalizedSceneNode();
|
|---|
| 270 |
|
|---|
| 271 | QGLBuilder builderCone;
|
|---|
| 272 | builderCone << QGLCylinder(0,.4,0.4,16);
|
|---|
| 273 | QGLSceneNode *cone = builderCone.finalizedSceneNode();
|
|---|
| 274 | {
|
|---|
| 275 | QMatrix4x4 mat;
|
|---|
| 276 | mat.translate(0.0f, 0.0f, 1.0f);
|
|---|
| 277 | cone->setLocalTransform(mat);
|
|---|
| 278 | }
|
|---|
| 279 |
|
|---|
| [02b2d3] | 280 | // Create a scene node from the 3 axes.
|
|---|
| [26ed25] | 281 | meshDreiBein = new QGLSceneNode(this);
|
|---|
| 282 |
|
|---|
| 283 | // X-direction
|
|---|
| 284 | QGLSceneNode *node = new QGLSceneNode(meshDreiBein);
|
|---|
| 285 | node->setMaterial(dreiBeinMaterial[0]);
|
|---|
| 286 | node->addNode(cyl);
|
|---|
| [37e910] | 287 | node->setPosition(QVector3D(.8f, 0.f, 0.f));
|
|---|
| [26ed25] | 288 | node->addNode(cone);
|
|---|
| 289 | {
|
|---|
| 290 | QMatrix4x4 mat;
|
|---|
| 291 | mat.rotate(90, 0.0f, 1.0f, 0.0f);
|
|---|
| 292 | node->setLocalTransform(mat);
|
|---|
| 293 | }
|
|---|
| 294 |
|
|---|
| 295 | // Y-direction
|
|---|
| 296 | node = new QGLSceneNode(meshDreiBein);
|
|---|
| 297 | node->setMaterial(dreiBeinMaterial[1]);
|
|---|
| 298 | node->addNode(cyl);
|
|---|
| 299 | node->addNode(cone);
|
|---|
| 300 | {
|
|---|
| 301 | QMatrix4x4 mat;
|
|---|
| 302 | mat.rotate(-90, 1.0f, 0.0f, 0.0f);
|
|---|
| 303 | node->setLocalTransform(mat);
|
|---|
| 304 | }
|
|---|
| [37e910] | 305 | node->setPosition(QVector3D(0.f, .8f, 0.f));
|
|---|
| [26ed25] | 306 |
|
|---|
| 307 | // Z-direction
|
|---|
| 308 | node = new QGLSceneNode(meshDreiBein);
|
|---|
| 309 | node->setMaterial(dreiBeinMaterial[2]);
|
|---|
| 310 | node->addNode(cyl);
|
|---|
| 311 | node->addNode(cone);
|
|---|
| [37e910] | 312 | node->setPosition(QVector3D(0.f, 0.f, .8f));
|
|---|
| [592d42] | 313 |
|
|---|
| 314 | setdreiBeinStatus( status );
|
|---|
| [26ed25] | 315 | }
|
|---|
| 316 |
|
|---|
| [7188b1] | 317 | /**
|
|---|
| 318 | * Update operation which can be invoked by the observable (which should be the
|
|---|
| 319 | * change tracker here).
|
|---|
| 320 | */
|
|---|
| 321 | void GLWorldView::update(Observable *publisher)
|
|---|
| 322 | {
|
|---|
| 323 | emit changed();
|
|---|
| 324 | }
|
|---|
| 325 |
|
|---|
| 326 | /**
|
|---|
| 327 | * The observable can tell when it dies.
|
|---|
| 328 | */
|
|---|
| 329 | void GLWorldView::subjectKilled(Observable *publisher) {}
|
|---|
| 330 |
|
|---|
| 331 | /** Listen to specific changes to the world.
|
|---|
| 332 | *
|
|---|
| 333 | * @param publisher ref to observable.
|
|---|
| 334 | * @param notification type of notification
|
|---|
| 335 | */
|
|---|
| 336 | void GLWorldView::recieveNotification(Observable *publisher, Notification_ptr notification)
|
|---|
| 337 | {
|
|---|
| [53059e] | 338 | if (static_cast<World *>(publisher) == World::getPointer()) {
|
|---|
| 339 | switch (notification->getChannelNo()) {
|
|---|
| 340 | case World::AtomInserted:
|
|---|
| 341 | {
|
|---|
| [beadd0] | 342 | const atomicNumber_t _id = World::getInstance().lastChanged<atom>()->getId();
|
|---|
| [53059e] | 343 | #ifdef LOG_OBSERVER
|
|---|
| [beadd0] | 344 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been inserted.";
|
|---|
| [53059e] | 345 | #endif
|
|---|
| [beadd0] | 346 | emit atomInserted(_id);
|
|---|
| [53059e] | 347 | break;
|
|---|
| 348 | }
|
|---|
| 349 | case World::AtomRemoved:
|
|---|
| 350 | {
|
|---|
| [c48ac12] | 351 | const atomicNumber_t _id = World::getInstance().lastChanged<atom>()->getId();
|
|---|
| [53059e] | 352 | #ifdef LOG_OBSERVER
|
|---|
| [beadd0] | 353 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_id)+" has been removed.";
|
|---|
| [53059e] | 354 | #endif
|
|---|
| [c48ac12] | 355 | emit atomRemoved(_id);
|
|---|
| [53059e] | 356 | break;
|
|---|
| 357 | }
|
|---|
| 358 | case World::SelectionChanged:
|
|---|
| 359 | {
|
|---|
| 360 | #ifdef LOG_OBSERVER
|
|---|
| [708277] | 361 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that selection has changed.";
|
|---|
| [53059e] | 362 | #endif
|
|---|
| 363 | emit worldSelectionChanged();
|
|---|
| 364 | break;
|
|---|
| 365 | }
|
|---|
| 366 | case World::MoleculeInserted:
|
|---|
| 367 | {
|
|---|
| 368 | const molecule *_molecule = World::getInstance().lastChanged<molecule>();
|
|---|
| 369 | #ifdef LOG_OBSERVER
|
|---|
| [708277] | 370 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_molecule->getId())+" has been removed.";
|
|---|
| [53059e] | 371 | #endif
|
|---|
| 372 | emit moleculeInserted(_molecule);
|
|---|
| 373 | break;
|
|---|
| 374 | }
|
|---|
| 375 | case World::MoleculeRemoved:
|
|---|
| 376 | {
|
|---|
| 377 | const molecule *_molecule = World::getInstance().lastChanged<molecule>();
|
|---|
| 378 | #ifdef LOG_OBSERVER
|
|---|
| [708277] | 379 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that molecule "+toString(_molecule->getId())+" has been removed.";
|
|---|
| [53059e] | 380 | #endif
|
|---|
| 381 | emit moleculeRemoved(_molecule);
|
|---|
| 382 | break;
|
|---|
| 383 | }
|
|---|
| 384 | default:
|
|---|
| [89b992] | 385 | ASSERT(0, "GLWorldView::recieveNotification() - we cannot get here for World.");
|
|---|
| [53059e] | 386 | break;
|
|---|
| [7188b1] | 387 | }
|
|---|
| [89b992] | 388 | } else if (static_cast<WorldTime *>(publisher) == WorldTime::getPointer()) {
|
|---|
| 389 | switch (notification->getChannelNo()) {
|
|---|
| 390 | case WorldTime::TimeChanged:
|
|---|
| 391 | {
|
|---|
| 392 | #ifdef LOG_OBSERVER
|
|---|
| 393 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that WorldTime's time has changed.";
|
|---|
| 394 | #endif
|
|---|
| 395 | emit changed();
|
|---|
| [ce4126] | 396 | emit TimeChanged();
|
|---|
| [89b992] | 397 | break;
|
|---|
| 398 | }
|
|---|
| 399 | default:
|
|---|
| 400 | ASSERT(0, "GLWorldView::recieveNotification() - we cannot get here for WorldTime.");
|
|---|
| 401 | break;
|
|---|
| 402 | }
|
|---|
| 403 | } else if (dynamic_cast<AtomObservable *>(publisher) != NULL) {
|
|---|
| [53059e] | 404 | switch (notification->getChannelNo()) {
|
|---|
| 405 | case AtomObservable::PositionChanged:
|
|---|
| 406 | {
|
|---|
| 407 | #ifdef LOG_OBSERVER
|
|---|
| [89b992] | 408 | const atom *_atom = dynamic_cast<const atom *>(publisher);
|
|---|
| [708277] | 409 | observerLog().addMessage() << "++ Observer " << observerLog().getName(static_cast<Observer *>(this)) << " received notification that atom "+toString(_atom->getId())+" has changed its position.";
|
|---|
| [53059e] | 410 | #endif
|
|---|
| 411 | emit changed();
|
|---|
| 412 | break;
|
|---|
| 413 | }
|
|---|
| 414 | default:
|
|---|
| [89b992] | 415 | ASSERT(0, "GLWorldView::recieveNotification() - we cannot get here for AtomObservable.");
|
|---|
| [53059e] | 416 | break;
|
|---|
| [7188b1] | 417 | }
|
|---|
| [284551] | 418 | } else if (static_cast<ShapeRegistry*>(publisher) == ShapeRegistry::getPointer()) {
|
|---|
| 419 | switch (notification->getChannelNo()) {
|
|---|
| [85c36d] | 420 | case ShapeRegistry::ShapeInserted:
|
|---|
| 421 | {
|
|---|
| [4d6662] | 422 | emit ShapeAdded();
|
|---|
| [85c36d] | 423 | break;
|
|---|
| 424 | }
|
|---|
| [284551] | 425 | case ShapeRegistry::ShapeRemoved:
|
|---|
| 426 | {
|
|---|
| [4d6662] | 427 | emit ShapeRemoved();
|
|---|
| [284551] | 428 | break;
|
|---|
| 429 | }
|
|---|
| 430 | case ShapeRegistry::SelectionChanged:
|
|---|
| 431 | {
|
|---|
| [85c36d] | 432 | worldscene->updateSelectedShapes();
|
|---|
| [284551] | 433 | break;
|
|---|
| 434 | }
|
|---|
| 435 | default:
|
|---|
| [89b992] | 436 | ASSERT(0, "GLWorldView::recieveNotification() - we cannot get here for ShapeRegistry.");
|
|---|
| [284551] | 437 | break;
|
|---|
| 438 | }
|
|---|
| [53059e] | 439 | } else
|
|---|
| 440 | ASSERT(0, "GLWorldView::recieveNotification() - received notification from unknown source.");
|
|---|
| [7188b1] | 441 | }
|
|---|
| [04f017] | 442 |
|
|---|
| [585f78] | 443 | void GLWorldView::checkChanges()
|
|---|
| 444 | {
|
|---|
| 445 | updateGL();
|
|---|
| 446 | needsRedraw = false;
|
|---|
| 447 | }
|
|---|
| 448 |
|
|---|
| [592d42] | 449 | void GLWorldView::changeDreiBein()
|
|---|
| 450 | {
|
|---|
| 451 | // invert to new status
|
|---|
| 452 | const bool status = ((meshDreiBein->options() & QGLSceneNode::HideNode) == 0);
|
|---|
| 453 | setdreiBeinStatus(!status);
|
|---|
| 454 | // realize
|
|---|
| 455 | updateGL();
|
|---|
| 456 | needsRedraw = true;
|
|---|
| 457 | }
|
|---|
| 458 |
|
|---|
| 459 | void GLWorldView::setdreiBeinStatus(const bool status)
|
|---|
| 460 | {
|
|---|
| 461 | if (status)
|
|---|
| 462 | meshDreiBein->setOptions( meshDreiBein->options() & (255-QGLSceneNode::HideNode) );
|
|---|
| 463 | else
|
|---|
| 464 | meshDreiBein->setOptions( meshDreiBein->options() | QGLSceneNode::HideNode );
|
|---|
| 465 | }
|
|---|
| 466 |
|
|---|
| 467 | void GLWorldView::changeDomain()
|
|---|
| 468 | {
|
|---|
| 469 | // invert to new status
|
|---|
| 470 | const bool status = ((meshDomainBox->options() & QGLSceneNode::HideNode) == 0);
|
|---|
| 471 | setDomainStatus(!status);
|
|---|
| 472 | // realize
|
|---|
| 473 | updateGL();
|
|---|
| 474 | needsRedraw = true;
|
|---|
| 475 | }
|
|---|
| 476 |
|
|---|
| 477 | void GLWorldView::setDomainStatus(const bool status)
|
|---|
| 478 | {
|
|---|
| 479 | if (status)
|
|---|
| 480 | meshDomainBox->setOptions( meshDomainBox->options() & (255-QGLSceneNode::HideNode) );
|
|---|
| 481 | else
|
|---|
| 482 | meshDomainBox->setOptions( meshDomainBox->options() | QGLSceneNode::HideNode );
|
|---|
| 483 | }
|
|---|
| 484 |
|
|---|
| [585f78] | 485 | void GLWorldView::sceneChangeSignalled()
|
|---|
| 486 | {
|
|---|
| 487 | if (!needsRedraw){
|
|---|
| 488 | redrawTimer->singleShot(0, this, SLOT(checkChanges()));
|
|---|
| 489 | needsRedraw = true;
|
|---|
| 490 | redrawTimer->start();
|
|---|
| 491 | }
|
|---|
| 492 | }
|
|---|
| 493 |
|
|---|
| [d238e7] | 494 | void GLWorldView::initializeGL(QGLPainter *painter)
|
|---|
| 495 | {
|
|---|
| [65487f] | 496 | worldscene->initialize(this, painter);
|
|---|
| 497 | changesPresent = false;
|
|---|
| [d238e7] | 498 | }
|
|---|
| 499 |
|
|---|
| 500 | void GLWorldView::paintGL(QGLPainter *painter)
|
|---|
| 501 | {
|
|---|
| [65487f] | 502 | if (changesPresent) {
|
|---|
| 503 | initializeGL(painter);
|
|---|
| 504 | changesPresent = false;
|
|---|
| 505 | }
|
|---|
| [72a4c1] | 506 |
|
|---|
| 507 | QVector3D cameraDir = camera()->center() - camera()->eye();
|
|---|
| 508 | cameraDir.normalize();
|
|---|
| 509 | QVector4D cameraPlane(cameraDir, QVector3D::dotProduct(cameraDir, camera()->eye()));
|
|---|
| 510 | worldscene->draw(painter, cameraPlane);
|
|---|
| [e8c636] | 511 |
|
|---|
| 512 | drawDreiBein(painter);
|
|---|
| [02b2d3] | 513 |
|
|---|
| 514 | // Domain box has to be last because of its transparency.
|
|---|
| 515 | drawDomainBox(painter);
|
|---|
| [907636] | 516 | }
|
|---|
| [d238e7] | 517 |
|
|---|
| [907636] | 518 | void GLWorldView::keyPressEvent(QKeyEvent *e)
|
|---|
| 519 | {
|
|---|
| [65487f] | 520 | if (e->key() == Qt::Key_Tab) {
|
|---|
| 521 | // The Tab key turns the ShowPicking option on and off,
|
|---|
| 522 | // which helps show what the pick buffer looks like.
|
|---|
| 523 | setOption(QGLView::ShowPicking, ((options() & QGLView::ShowPicking) == 0));
|
|---|
| 524 | updateGL();
|
|---|
| 525 | }
|
|---|
| 526 | QGLView::keyPressEvent(e);
|
|---|
| 527 | }
|
|---|
| 528 |
|
|---|
| 529 | void GLWorldView::changeSignalled()
|
|---|
| 530 | {
|
|---|
| 531 | changesPresent = true;
|
|---|
| [d238e7] | 532 | }
|
|---|
| 533 |
|
|---|
| 534 |
|
|---|
| [0e5d14] | 535 | /**
|
|---|
| 536 | * Set the current camera control mode.
|
|---|
| 537 | */
|
|---|
| [e13b34] | 538 | void GLWorldView::setCameraControlMode(GLWorldView::CameraControlModeType mode)
|
|---|
| 539 | {
|
|---|
| 540 | cameraControlMode = mode;
|
|---|
| 541 | }
|
|---|
| 542 |
|
|---|
| 543 | void GLWorldView::setCameraControlModeRotation()
|
|---|
| 544 | {
|
|---|
| 545 | setCameraControlMode(Rotate);
|
|---|
| 546 | }
|
|---|
| 547 |
|
|---|
| 548 | void GLWorldView::setCameraControlModeTranslation()
|
|---|
| 549 | {
|
|---|
| 550 | setCameraControlMode(Translate);
|
|---|
| 551 | }
|
|---|
| 552 |
|
|---|
| [0e5d14] | 553 | /**
|
|---|
| 554 | * Returns the current camera control mode.
|
|---|
| 555 | * This needs to be invertable (rotation - translation), if the shift key is pressed.
|
|---|
| 556 | */
|
|---|
| [e13b34] | 557 | GLWorldView::CameraControlModeType GLWorldView::getCameraControlMode(bool inverted)
|
|---|
| 558 | {
|
|---|
| 559 | if (inverted){
|
|---|
| 560 | if (cameraControlMode == Rotate)
|
|---|
| 561 | return Translate;
|
|---|
| 562 | if (cameraControlMode == Translate)
|
|---|
| 563 | return Rotate;
|
|---|
| 564 | return Rotate;
|
|---|
| 565 | }else
|
|---|
| 566 | return cameraControlMode;
|
|---|
| 567 | }
|
|---|
| 568 |
|
|---|
| [8880c9] | 569 | /**
|
|---|
| 570 | * Set the camera so it can oversee the whole domain.
|
|---|
| 571 | */
|
|---|
| [e13b34] | 572 | void GLWorldView::fitCameraToDomain()
|
|---|
| 573 | {
|
|---|
| [8880c9] | 574 | // Move the camera focus point to the center of the domain box.
|
|---|
| [3f48c2] | 575 | Vector v = World::getInstance().getDomain().translateIn(Vector(0.5, 0.5, 0.5));
|
|---|
| 576 | camera()->setCenter(QVector3D(v[0], v[1], v[2]));
|
|---|
| 577 |
|
|---|
| [8880c9] | 578 | // Guess some eye distance.
|
|---|
| [3f48c2] | 579 | double dist = v.Norm() * 3;
|
|---|
| 580 | camera()->setEye(QVector3D(v[0], v[1], v[2] + dist));
|
|---|
| 581 | camera()->setUpVector(QVector3D(0, 1, 0));
|
|---|
| [e13b34] | 582 | }
|
|---|
| 583 |
|
|---|
| [8e7dd9] | 584 | void GLWorldView::setCameraStereoModeDisable()
|
|---|
| 585 | {
|
|---|
| 586 | setStereoType(QGLView::Hardware);
|
|---|
| 587 | camera()->setEyeSeparation(0.0);
|
|---|
| 588 | updateGL();
|
|---|
| 589 | }
|
|---|
| 590 |
|
|---|
| 591 | void GLWorldView::setCameraStereoModeHardware()
|
|---|
| 592 | {
|
|---|
| 593 | setStereoType(QGLView::Hardware);
|
|---|
| 594 | camera()->setEyeSeparation(defaultEyeSeparation);
|
|---|
| 595 | updateGL();
|
|---|
| 596 | }
|
|---|
| 597 |
|
|---|
| 598 | void GLWorldView::setCameraStereoModeLeftRight()
|
|---|
| 599 | {
|
|---|
| 600 | setStereoType(QGLView::LeftRight);
|
|---|
| 601 | camera()->setEyeSeparation(defaultEyeSeparation);
|
|---|
| 602 | updateGL();
|
|---|
| 603 | }
|
|---|
| 604 |
|
|---|
| 605 | void GLWorldView::setCameraStereoModeRightLeft()
|
|---|
| 606 | {
|
|---|
| 607 | setStereoType(QGLView::RightLeft);
|
|---|
| 608 | camera()->setEyeSeparation(defaultEyeSeparation);
|
|---|
| 609 | updateGL();
|
|---|
| 610 | }
|
|---|
| 611 |
|
|---|
| 612 | void GLWorldView::setCameraStereoModeTopBottom()
|
|---|
| 613 | {
|
|---|
| 614 | setStereoType(QGLView::TopBottom);
|
|---|
| 615 | camera()->setEyeSeparation(defaultEyeSeparation);
|
|---|
| 616 | updateGL();
|
|---|
| 617 | }
|
|---|
| 618 |
|
|---|
| 619 | void GLWorldView::setCameraStereoModeBottomTop()
|
|---|
| 620 | {
|
|---|
| 621 | setStereoType(QGLView::BottomTop);
|
|---|
| 622 | camera()->setEyeSeparation(defaultEyeSeparation);
|
|---|
| 623 | updateGL();
|
|---|
| 624 | }
|
|---|
| 625 |
|
|---|
| 626 | void GLWorldView::setCameraStereoModeAnaglyph()
|
|---|
| 627 | {
|
|---|
| 628 | setStereoType(QGLView::RedCyanAnaglyph);
|
|---|
| 629 | camera()->setEyeSeparation(defaultEyeSeparation);
|
|---|
| 630 | updateGL();
|
|---|
| 631 | }
|
|---|
| 632 |
|
|---|
| [8880c9] | 633 | void GLWorldView::mousePressEvent(QMouseEvent *event)
|
|---|
| 634 | {
|
|---|
| 635 | QGLView::mousePressEvent(event);
|
|---|
| 636 |
|
|---|
| 637 | // Reset the saved mouse position.
|
|---|
| 638 | lastMousePos = event->posF();
|
|---|
| 639 | }
|
|---|
| 640 |
|
|---|
| 641 | /**
|
|---|
| 642 | * Handle a mouse move event.
|
|---|
| 643 | * This is used to control the camera (rotation and translation) when the left button is being pressed.
|
|---|
| 644 | */
|
|---|
| 645 | void GLWorldView::mouseMoveEvent(QMouseEvent *event)
|
|---|
| 646 | {
|
|---|
| 647 | if (event->buttons() & Qt::LeftButton){
|
|---|
| 648 | // Find the mouse distance since the last event.
|
|---|
| 649 | QPointF d = event->posF() - lastMousePos;
|
|---|
| 650 | lastMousePos = event->posF();
|
|---|
| 651 |
|
|---|
| 652 | // Rotate or translate? (inverted by shift key)
|
|---|
| 653 | CameraControlModeType mode = getCameraControlMode(event->modifiers() & Qt::ShiftModifier);
|
|---|
| 654 |
|
|---|
| 655 | if (mode == Rotate){
|
|---|
| 656 | // Rotate the camera.
|
|---|
| 657 | d *= 0.3;
|
|---|
| 658 | camera()->tiltPanRollCenter(- d.y(), - d.x(), 0);
|
|---|
| 659 | }else if (mode == Translate){
|
|---|
| 660 | // Translate the camera.
|
|---|
| 661 | d *= 0.02;
|
|---|
| 662 | camera()->translateCenter(- d.x(), d.y(), 0);
|
|---|
| 663 | camera()->translateEye(- d.x(), d.y(), 0);
|
|---|
| 664 | }
|
|---|
| 665 | }else{
|
|---|
| 666 | // Without this Qt would not test for hover events (i.e. mouse over an atom).
|
|---|
| 667 | QGLView::mouseMoveEvent(event);
|
|---|
| 668 | }
|
|---|
| 669 | }
|
|---|
| 670 |
|
|---|
| 671 | /**
|
|---|
| 672 | * When the mouse wheel is used, zoom in or out.
|
|---|
| 673 | */
|
|---|
| 674 | void GLWorldView::wheelEvent(QWheelEvent *event)
|
|---|
| 675 | {
|
|---|
| 676 | // Find the distance between the eye and focus point.
|
|---|
| 677 | QVector3D d = camera()->eye() - camera()->center();
|
|---|
| 678 |
|
|---|
| 679 | // Scale the distance.
|
|---|
| 680 | if (event->delta() < 0)
|
|---|
| 681 | d *= 1.2;
|
|---|
| 682 | else if (event->delta() > 0)
|
|---|
| 683 | d /= 1.2;
|
|---|
| 684 |
|
|---|
| 685 | // Set new eye position.
|
|---|
| 686 | camera()->setEye(camera()->center() + d);
|
|---|
| 687 | }
|
|---|
| 688 |
|
|---|
| [02b2d3] | 689 | /**
|
|---|
| 690 | * Draw a transparent cube representing the domain.
|
|---|
| 691 | */
|
|---|
| [e8c636] | 692 | void GLWorldView::drawDomainBox(QGLPainter *painter) const
|
|---|
| 693 | {
|
|---|
| [02b2d3] | 694 | // Apply the domain matrix.
|
|---|
| [e8c636] | 695 | RealSpaceMatrix m = World::getInstance().getDomain().getM();
|
|---|
| 696 | painter->modelViewMatrix().push();
|
|---|
| 697 | painter->modelViewMatrix() *= QMatrix4x4(m.at(0,0), m.at(0,1), m.at(0,2), 0.0,
|
|---|
| 698 | m.at(1,0), m.at(1,1), m.at(1,2), 0.0,
|
|---|
| 699 | m.at(2,0), m.at(2,1), m.at(2,2), 0.0,
|
|---|
| 700 | 0.0, 0.0, 0.0, 1.0);
|
|---|
| 701 |
|
|---|
| [02b2d3] | 702 | // Draw the transparent cube.
|
|---|
| [073a2ff] | 703 | painter->setStandardEffect(QGL::LitMaterial);
|
|---|
| [02b2d3] | 704 | glCullFace(GL_BACK);
|
|---|
| 705 | glEnable(GL_CULL_FACE);
|
|---|
| 706 | glEnable(GL_BLEND);
|
|---|
| 707 | glDepthMask(0);
|
|---|
| 708 | //glDisable(GL_DEPTH_TEST);
|
|---|
| 709 | meshDomainBox->draw(painter);
|
|---|
| 710 | //glEnable(GL_DEPTH_TEST);
|
|---|
| 711 | glDepthMask(1);
|
|---|
| 712 | glDisable(GL_BLEND);
|
|---|
| 713 | glDisable(GL_CULL_FACE);
|
|---|
| 714 |
|
|---|
| [592d42] | 715 | // Draw the outlines (if we have drawn the box itself)
|
|---|
| 716 | if ((meshDomainBox->options() & QGLSceneNode::HideNode) == 0) {
|
|---|
| 717 | painter->setFaceMaterial(QGL::AllFaces, domainBoxMaterial);
|
|---|
| 718 | //glEnable(GL_LINE_SMOOTH);
|
|---|
| 719 | QVector3DArray array;
|
|---|
| 720 | array.append(0, 0, 0); array.append(1, 0, 0);
|
|---|
| 721 | array.append(1, 0, 0); array.append(1, 1, 0);
|
|---|
| 722 | array.append(1, 1, 0); array.append(0, 1, 0);
|
|---|
| 723 | array.append(0, 1, 0); array.append(0, 0, 0);
|
|---|
| 724 |
|
|---|
| 725 | array.append(0, 0, 1); array.append(1, 0, 1);
|
|---|
| 726 | array.append(1, 0, 1); array.append(1, 1, 1);
|
|---|
| 727 | array.append(1, 1, 1); array.append(0, 1, 1);
|
|---|
| 728 | array.append(0, 1, 1); array.append(0, 0, 1);
|
|---|
| 729 |
|
|---|
| 730 | array.append(0, 0, 0); array.append(0, 0, 1);
|
|---|
| 731 | array.append(1, 0, 0); array.append(1, 0, 1);
|
|---|
| 732 | array.append(0, 1, 0); array.append(0, 1, 1);
|
|---|
| 733 | array.append(1, 1, 0); array.append(1, 1, 1);
|
|---|
| 734 | painter->clearAttributes();
|
|---|
| 735 | painter->setVertexAttribute(QGL::Position, array);
|
|---|
| 736 | painter->draw(QGL::Lines, 24);
|
|---|
| 737 | }
|
|---|
| [02b2d3] | 738 |
|
|---|
| [e8c636] | 739 | painter->modelViewMatrix().pop();
|
|---|
| 740 | }
|
|---|
| 741 |
|
|---|
| 742 | void GLWorldView::drawDreiBein(QGLPainter *painter)
|
|---|
| 743 | {
|
|---|
| 744 | painter->modelViewMatrix().push();
|
|---|
| 745 | painter->modelViewMatrix().translate(camera()->center());
|
|---|
| [073a2ff] | 746 | painter->setStandardEffect(QGL::LitMaterial);
|
|---|
| [02b2d3] | 747 | painter->setFaceMaterial(QGL::FrontFaces, NULL);
|
|---|
| [26ed25] | 748 | meshDreiBein->draw(painter);
|
|---|
| [e8c636] | 749 | painter->modelViewMatrix().pop();
|
|---|
| 750 | }
|
|---|
| 751 |
|
|---|
| [407638e] | 752 | void GLWorldView::sceneHoverSignalled(const atom *_atom)
|
|---|
| 753 | {
|
|---|
| 754 | emit hoverChanged(_atom);
|
|---|
| 755 | }
|
|---|