Changeset 06ebf5 for src


Ignore:
Timestamp:
Oct 6, 2011, 3:06:16 PM (13 years ago)
Author:
Frederik Heber <heber@…>
Branches:
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
Children:
029bb4
Parents:
907636
git-author:
Frederik Heber <heber@…> (08/26/11 16:26:42)
git-committer:
Frederik Heber <heber@…> (10/06/11 15:06:16)
Message:

Clicking on atoms works.

  • GLMoleculeObject_atom, GLMoleculeScene, GLWorldScene have a signal/slot chain that is gradually enriched with ids of clicked atom part of clicked molecule.
Location:
src/UIElements/Views/Qt4/Qt3D
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp

    r907636 r06ebf5  
    2828#include "CodePatterns/Assert.hpp"
    2929
    30 #include "atom.hpp"
    3130#include "element.hpp"
    3231#include "LinearAlgebra/Vector.hpp"
     
    4241}
    4342
    44 GLMoleculeObject_atom::GLMoleculeObject_atom(QObject *parent, const atom *_atom) :
    45   GLMoleculeObject(createAtom(parent), parent)
     43GLMoleculeObject_atom::GLMoleculeObject_atom(QObject *parent, const atom *atomref) :
     44  GLMoleculeObject(createAtom(parent), parent), _atom(atomref)
    4645{
    4746  const Vector Position = _atom->getPosition();
     
    6867
    6968  std::cout << "Created sphere at " << Position << " with elementno " << elementno << "." << endl;
     69
     70  connect( this, SIGNAL(clicked()), this, SLOT(wasClicked()));
    7071}
     72
     73void GLMoleculeObject_atom::wasClicked()
     74{
     75  qDebug("GLMoleculeObject_atom: atom %d has been clicked", _atom->getId());
     76  emit clicked(_atom->getId());
     77}
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.hpp

    r907636 r06ebf5  
    1616#include "GLMoleculeObject.hpp"
    1717
    18 class atom;
     18#include "atom.hpp"
    1919
    2020class GLMoleculeObject_atom : public GLMoleculeObject
    2121{
    22    Q_OBJECT
     22  Q_OBJECT
    2323public:
    24    GLMoleculeObject_atom(QObject *parent, const atom *atomref);
    25    ~GLMoleculeObject_atom() {}
     24  GLMoleculeObject_atom(QObject *parent, const atom *atomref);
     25  ~GLMoleculeObject_atom() {}
     26
     27private slots:
     28  void wasClicked();
     29
     30signals:
     31  void clicked(atomId_t);
    2632
    2733private:
    28   atom *_atom;
     34  const atom *_atom;
    2935};
    3036
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.cpp

    r907636 r06ebf5  
    4848}
    4949
    50 GLMoleculeObject_bond::GLMoleculeObject_bond(QObject *parent, bond *_bond, double distance, enum SideOfBond side) :
    51   GLMoleculeObject(createBond(parent, distance), parent)
     50GLMoleculeObject_bond::GLMoleculeObject_bond(QObject *parent, const bond *bondref, double distance, enum SideOfBond side) :
     51  GLMoleculeObject(createBond(parent, distance), parent), _bond(bondref)
    5252{
    5353  Vector Position;
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_bond.hpp

    r907636 r06ebf5  
    2020class GLMoleculeObject_bond : public GLMoleculeObject
    2121{
    22    Q_OBJECT
     22  Q_OBJECT
    2323public:
    24    enum SideOfBond { left, right };
     24  enum SideOfBond { left, right };
    2525
    26    GLMoleculeObject_bond(QObject *parent, bond *bondref, double distance, enum SideOfBond side);
    27    ~GLMoleculeObject_bond() {}
     26  GLMoleculeObject_bond(QObject *parent, const bond *bondref, double distance, enum SideOfBond side);
     27  ~GLMoleculeObject_bond() {}
    2828
    2929
    3030private:
    31   bond *_bond;
     31  const bond *_bond;
    3232};
    3333
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeScene.cpp

    r907636 r06ebf5  
    4242    GLMoleculeObject_atom *atomObject= new GLMoleculeObject_atom(this, *atomiter);
    4343    AtomsinMoleculeMap.insert( make_pair((*atomiter)->getId(), atomObject) );
     44    connect (atomObject, SIGNAL(clicked(atomId_t)), this, SLOT(atomClicked(atomId_t)));
    4445
    4546    // create its bonds
     
    8384     GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
    8485       if (meshobj)
    85            meshobj->initialize(view, painter);
     86         meshobj->initialize(view, painter);
    8687   }
    8788}
     
    9394     GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
    9495       if (meshobj)
    95            meshobj->draw(painter);
     96         meshobj->draw(painter);
    9697   }
    9798}
    9899
     100void GLMoleculeScene::atomClicked(atomId_t no)
     101{
     102   qDebug("GLMoleculeScene: atom %d has been clicked inside molecule %d", no, mol->getId());
     103   emit clicked(no, mol->getId());
     104}
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeScene.hpp

    r907636 r06ebf5  
    1919#include <Qt3D/qglpainter.h>
    2020
    21 class molecule;
     21#include "atom.hpp"
     22#include "molecule.hpp"
     23
    2224class QGLView;
    2325class GLMoleculeObject_atom;
     
    3032class GLMoleculeScene : public QObject
    3133{
    32    Q_OBJECT
     34  Q_OBJECT
    3335public:
    34    explicit GLMoleculeScene(QObject *parent, molecule *_mol);
    35    virtual ~GLMoleculeScene();
     36  explicit GLMoleculeScene(QObject *parent, molecule *_mol);
     37  virtual ~GLMoleculeScene();
    3638
    37    virtual void initialize(QGLView *view, QGLPainter *painter);
    38    virtual void draw(QGLPainter *painter);
     39  virtual void initialize(QGLView *view, QGLPainter *painter);
     40  virtual void draw(QGLPainter *painter);
     41
     42private slots:
     43  void atomClicked(atomId_t no);
     44
     45signals:
     46  void pressed();
     47  void released();
     48  void clicked();
     49  void clicked(atomId_t, moleculeId_t);
     50  void doubleClicked();
     51  void hoverChanged();
    3952
    4053private:
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    r907636 r06ebf5  
    5757      GLMoleculeScene * const molObject = new GLMoleculeScene(this, *Runner);
    5858      MoleculeSceneList.push_back(molObject);
     59      connect (molObject, SIGNAL(clicked(atomId_t, moleculeId_t)), this, SLOT(molClicked(atomId_t, moleculeId_t)));
    5960    }
    6061  }
     
    7980  }
    8081}
    81 //
    82 ///** create an atom object in the scene.
    83 // * \param molObject Object of the molecule in the scene to set as parent
    84 // * \param _atom ref to the atom to create
    85 // */
    86 //void GLWorldScene::makeAtom(GLMoleculeObject *&molObject, const atom *&_atom)
    87 //{
    88 //  // create object (hand over getMaterial as callback function)
    89 //  GLMoleculeObject_atom *newatom = new GLMoleculeObject_atom(molObject, _atom, &getMaterial);
    90 //
    91 //  // connect signal
    92 //  connect(newatom, SIGNAL(hoverChanged()), this, SIGNAL(changed()));
    93 //
    94 //  // add to nodes map
    95 //  AtomsinSceneMap.insert( make_pair(_atom->getId(), newatom) );
    96 //}
    97 //
    98 ///** Create a bond object in the scene.
    99 // * \param molObject Object of the molecule in the scene to set as parent
    100 // * \param _bond ref to the bond to create
    101 // */
    102 //void GLWorldScene::makeCylinder(GLMoleculeObject *&molObject, const bond *_bond)
    103 //    //const Vector &x, const Vector &y, double radius, double height, const size_t elementno)
    104 //{
    105 //  // create object
    106 //  QGLMoleculeObject_bond *newbond = new QGLMoleculeObject_bond(molObject, _bond, &getMaterial)
    107 //
    108 //  // nothing to connect here
    109 //
    110 //  // add to nodes map
    111 //  BondsinSceneMap.insert(
    112 //      make_pair(
    113 //          make_pair(
    114 //              _bond->leftatom->getId(),
    115 //              _bond->rightatom->getId()
    116 //              ),
    117 //      newatom) );
    118 //}
    119 //
    120 //
    121 //
    122 //QGLSceneNode* GLMoleculeView::getAtom(size_t no)
    123 //{
    124 //  // first some sensibility checks
    125 //  ASSERT(World::getInstance().getAtom(AtomById(no)) != NULL,
    126 //      "GLMoleculeView::getAtom() - desired atom "
    127 //      +toString(no)+" not present in the World.");
    128 //  ASSERT(AtomsinSceneMap.find(no) != AtomsinSceneMap.end(),
    129 //      "GLMoleculeView::getAtom() - desired atom "
    130 //      +toString(no)+" not present in the AtomsinSceneMap.");
    131 //
    132 //  return AtomsinSceneMap[no];
    133 //}
    134 //
    135 //QGLSceneNode* GLMoleculeView::getBond(size_t leftno, size_t rightno)
    136 //{
    137 //  // first some sensibility checks
    138 //  ASSERT(World::getInstance().getAtom(AtomById(leftno)) != NULL,
    139 //      "GLMoleculeView::getAtom() - desired atom "
    140 //      +toString(leftno)+" of bond not present in the World.");
    141 //  ASSERT(World::getInstance().getAtom(AtomById(rightno)) != NULL,
    142 //      "GLMoleculeView::getAtom() - desired atom "
    143 //      +toString(rightno)+" of bond not present in the World.");
    144 //  ASSERT(AtomsinSceneMap.find(leftno) != AtomsinSceneMap.end(),
    145 //      "GLMoleculeView::getAtom() - desired atom "
    146 //      +toString(leftno)+" of bond not present in the AtomsinSceneMap.");
    147 //  ASSERT(AtomsinSceneMap.find(rightno) != AtomsinSceneMap.end(),
    148 //      "GLMoleculeView::getAtom() - desired atom "
    149 //      +toString(rightno)+" of bond not present in the AtomsinSceneMap.");
    150 //  ASSERT(leftno == rightno,
    151 //      "GLMoleculeView::getAtom() - bond must not be between the same atom: "
    152 //      +toString(leftno)+" == "+toString(rightno)+".");
    153 //
    154 //  // then return with smaller index first
    155 //  if (leftno > rightno)
    156 //    return AtomsinSceneMap[ make_pair(rightno, leftno) ];
    157 //  else
    158 //    return AtomsinSceneMap[ make_pair(leftno, rightno) ];
    159 //}
    16082
    161 void GLWorldScene::atomClicked()
     83void GLWorldScene::molClicked(atomId_t atom_no, moleculeId_t mol_no)
    16284{
    163    qDebug("atom clicked");
     85   qDebug("WorldScene: atom %d of molecule %d has been clicked", atom_no, mol_no);
    16486}
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp

    r907636 r06ebf5  
    1717
    1818#include <Qt/qobject.h>
     19
     20#include "atom.hpp"
     21#include "molecule.hpp"
    1922
    2023class QGLPainter;
     
    5255
    5356private slots:
    54   void atomClicked();
     57  void molClicked(atomId_t atom_no, moleculeId_t mol_no);
    5558
    5659private:
  • src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp

    r907636 r06ebf5  
    2626class GLWorldView : public QGLView
    2727{
    28    Q_OBJECT
     28  Q_OBJECT
    2929public:
    30    GLWorldView(QWidget *parent=0);
    31    virtual ~GLWorldView();
     30  GLWorldView(QWidget *parent=0);
     31  virtual ~GLWorldView();
    3232
    3333public slots:
    3434
    3535protected:
    36    void initializeGL(QGLPainter *painter);
    37    void paintGL(QGLPainter *painter);
    38    void keyPressEvent(QKeyEvent *e);
     36  void initializeGL(QGLPainter *painter);
     37  void paintGL(QGLPainter *painter);
     38  void keyPressEvent(QKeyEvent *e);
    3939
    4040private:
    41    GLWorldScene *worldscene;
     41  GLWorldScene *worldscene;
    4242};
    4343
Note: See TracChangeset for help on using the changeset viewer.