source: src/UIElements/Views/Qt4/Qt3D/GLMoleculeScene.cpp@ 029bb4

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 029bb4 was 029bb4, checked in by Frederik Heber <heber@…>, 14 years ago

Hovering is now working too.

  • signal chain installed from GLMoleculeObject::hoverChanged() through GLMoleculeObject, over GLWorldScene to GLWorldView which calls updateGL().
  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010 University of Bonn. All rights reserved.
5 * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
6 */
7
8/*
9 * GLMoleculeScene.cpp
10 *
11 * This is based on the Qt3D example "teaservice", specifically sceneobject.cpp.
12 *
13 * Created on: Aug 17, 2011
14 * Author: heber
15 */
16
17// include config.h
18#ifdef HAVE_CONFIG_H
19#include <config.h>
20#endif
21
22#include "GLMoleculeScene.hpp"
23
24#include "GLMoleculeObject.hpp"
25#include "GLMoleculeObject_atom.hpp"
26#include "GLMoleculeObject_bond.hpp"
27
28#include "CodePatterns/MemDebug.hpp"
29
30#include "atom.hpp"
31#include "Bond/bond.hpp"
32#include "molecule.hpp"
33
34
35GLMoleculeScene::GLMoleculeScene(QObject *parent, molecule *_mol) :
36 QObject(parent), mol(_mol)
37{
38 for (molecule::const_iterator atomiter = mol->begin();
39 atomiter != mol->end();
40 ++atomiter) {
41 // create atom objects in scene
42 GLMoleculeObject_atom *atomObject= new GLMoleculeObject_atom(this, *atomiter);
43 AtomsinMoleculeMap.insert( make_pair((*atomiter)->getId(), atomObject) );
44 connect (atomObject, SIGNAL(clicked(atomId_t)), this, SLOT(atomClicked(atomId_t)));
45 connect (atomObject, SIGNAL(hoverChanged()), this, SIGNAL(hoverChanged()));
46
47 // create its bonds
48 const BondList &bonds = (*atomiter)->getListOfBonds();
49 for (BondList::const_iterator bonditer = bonds.begin();
50 bonditer != bonds.end();
51 ++bonditer) {
52 if ((*bonditer)->leftatom->getId() == (*atomiter)->getId()) {
53 // create bond objects in scene
54 const double distance =
55 (*bonditer)->leftatom->getPosition().distance((*bonditer)->rightatom->getPosition())/2.;
56 GLMoleculeObject_bond *bondObject= new GLMoleculeObject_bond(this, *bonditer, distance, GLMoleculeObject_bond::left);
57 BondsinMoleculeMap.insert( make_pair(
58 make_pair(
59 (*bonditer)->leftatom->getId(),
60 (*bonditer)->rightatom->getId()
61 ),
62 bondObject) );
63 bondObject= new GLMoleculeObject_bond(this, *bonditer, distance, GLMoleculeObject_bond::right);
64 BondsinMoleculeMap.insert( make_pair(
65 make_pair(
66 (*bonditer)->rightatom->getId(),
67 (*bonditer)->leftatom->getId()
68 ),
69 bondObject) );
70 }
71 }
72 }
73}
74
75GLMoleculeScene::~GLMoleculeScene()
76{
77 // remove all elements
78 GLMoleculeObject::cleanMaterialMap();
79}
80
81void GLMoleculeScene::initialize(QGLView *view, QGLPainter *painter)
82{
83 // Initialize all of the mesh objects that we have as children.
84 foreach (QObject *obj, children()) {
85 GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
86 if (meshobj)
87 meshobj->initialize(view, painter);
88 }
89}
90
91void GLMoleculeScene::draw(QGLPainter *painter)
92{
93 // Draw all of the mesh objects that we have as children.
94 foreach (QObject *obj, children()) {
95 GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
96 if (meshobj)
97 meshobj->draw(painter);
98 }
99}
100
101void GLMoleculeScene::atomClicked(atomId_t no)
102{
103 qDebug("GLMoleculeScene: atom %d has been clicked inside molecule %d", no, mol->getId());
104 emit clicked(no, mol->getId());
105}
Note: See TracBrowser for help on using the repository browser.