Changeset 3927ef for src


Ignore:
Timestamp:
Apr 6, 2012, 11:57:59 AM (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:
53059e
Parents:
1ce04b
git-author:
Michael Ankele <ankele@…> (04/04/12 14:00:53)
git-committer:
Frederik Heber <heber@…> (04/06/12 11:57:59)
Message:

GL: molecule selection boxes

  • only instantiated for selected molecules
  • no size/position changes tracked yet!
Location:
src/UIElements/Views/Qt4/Qt3D
Files:
7 edited

Legend:

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

    r1ce04b r3927ef  
    9797  painter->setFaceMaterial(QGL::AllFaces, m_selectionBoxMaterial);
    9898  QVector3DArray array;
    99   qreal radius = 0.3f;
     99  qreal radius = 1.0;
    100100  array.append(-radius, -radius, -radius); array.append( radius, -radius, -radius);
    101101  array.append( radius, -radius, -radius); array.append( radius,  radius, -radius);
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp

    r1ce04b r3927ef  
    4141{
    4242  QGLBuilder builder;
    43   builder << QGLSphere(0.5);
     43  builder << QGLSphere(2.0);
    4444  QGLSceneNode *n = builder.finalizedSceneNode();
    4545  n->setParent(parent);
     
    114114    radius = 0.5;
    115115  }
    116   setScale( radius );
     116  setScale( radius / 4. );
    117117}
    118118
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp

    r1ce04b r3927ef  
    6060  molref->signOn(this, AtomObservable::ElementChanged);
    6161  molref->signOn(this, AtomObservable::BondsAdded);*/
     62  setMaterial(getMaterial(1));
    6263  World::getInstance().signOn(this, World::SelectionChanged);
    63   setPosition(QVector3D(0,0,0));
    64   setScale(5.0f);
    65   setMaterial(getMaterial(1));
     64  Shape shape = _molecule->getBoundingShape();
     65  Vector v = shape.getCenter();
     66  setPosition(QVector3D(v[0], v[1], v[2]));
     67  setScale(shape.getRadius() + 0.3); // getBoundingShape() only sees atoms as points, so make the box a bit bigger
    6668}
    6769
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    r1ce04b r3927ef  
    7575        Runner != molecules.end();
    7676        Runner++) {
    77 
    78       // create molecule
    79       moleculeInserted(*Runner);
    8077
    8178      for (molecule::const_iterator atomiter = (*Runner)->begin();
     
    140137}
    141138
    142 /** Adds a molecule to the scene.
    143  *
    144  * @param _molecule molecule to add
    145  */
    146 void GLWorldScene::moleculeInserted(const molecule*_molecule)
    147 {
    148   LOG(3, "INFO: GLWorldScene: Received signal moleculeInserted for atom "+toString(_molecule->getId())+".");
    149   GLMoleculeObject_molecule *molObject = new GLMoleculeObject_molecule(this, _molecule);
     139/** ....
     140 *
     141 */
     142void GLWorldScene::worldSelectionChanged()
     143{
     144  LOG(3, "INFO: GLWorldScene: Received signal selectionChanged.");
     145
     146  const std::vector<molecule*> &molecules = World::getInstance().getAllMolecules();
     147
     148  if (molecules.size() > 0) {
     149    for (std::vector<molecule*>::const_iterator Runner = molecules.begin();
     150        Runner != molecules.end();
     151        Runner++) {
     152
     153      MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find((*Runner)->getId());
     154      bool isSelected = World::getInstance().isSelected(*Runner);
     155
     156      // molecule selected but not in scene?
     157      if (isSelected && (iter == MoleculesinSceneMap.end())){
     158        // -> create new mesh
     159        GLMoleculeObject_molecule *molObject = new GLMoleculeObject_molecule(this, *Runner);
     160        MoleculesinSceneMap.insert( make_pair((*Runner)->getId(), molObject) );
     161        connect (molObject, SIGNAL(changed()), this, SIGNAL(changed()));
     162        connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
     163        connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
     164        emit changed();
     165        emit changeOccured();
     166      }
     167
     168      // molecule not selected but in scene?
     169      if (!isSelected && (iter != MoleculesinSceneMap.end())){
     170        // -> remove from scene
     171        moleculeRemoved(*Runner);
     172      }
     173
     174    }
     175  }
     176}
     177
     178/** Removes a molecule from the scene.
     179 *
     180 * @param _molecule molecule to remove
     181 */
     182void GLWorldScene::moleculeRemoved(const molecule *_molecule)
     183{
     184  LOG(3, "INFO: GLWorldScene: Received signal moleculeRemoved for molecule "+toString(_molecule->getId())+".");
    150185  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molecule->getId());
    151   ASSERT(iter == MoleculesinSceneMap.end(),
    152       "GLWorldScene::moleculeInserted() - same molecule "+_molecule->getName()+" added again.");
    153   MoleculesinSceneMap.insert( make_pair(_molecule->getId(), molObject) );
    154   connect (molObject, SIGNAL(changed()), this, SIGNAL(changed()));
    155   connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
    156   connect (molObject, SIGNAL(selectionChanged()), this, SIGNAL(changed()));
    157   emit changeOccured();
    158 }
    159 
    160 /** Removes a molecule from the scene.
    161  *
    162  * @param _molecule molecule to remove
    163  */
    164 void GLWorldScene::moleculeRemoved(const molecule *_molecule)
    165 {
    166   LOG(3, "INFO: GLWorldScene: Received signal moleculeRemoved for atom "+toString(_molecule->getId())+".");
    167   MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_molecule->getId());
    168   ASSERT(iter != MoleculesinSceneMap.end(),
    169       "GLWorldScene::moleculeRemoved() - molecule "+_molecule->getName()+" not on display.");
    170   GLMoleculeObject_molecule *molObject = iter->second;
    171   molObject->disconnect();
    172   MoleculesinSceneMap.erase(iter);
    173   delete molObject;
    174   emit changeOccured();
     186
     187  // only remove if the molecule is in the scene
     188  //  (= is selected)
     189  if (iter != MoleculesinSceneMap.end()){
     190    GLMoleculeObject_molecule *molObject = iter->second;
     191    molObject->disconnect();
     192    MoleculesinSceneMap.erase(iter);
     193    delete molObject;
     194    emit changed();
     195    emit changeOccured();
     196  }
    175197}
    176198
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp

    r1ce04b r3927ef  
    7272  void atomInserted(const atom *_atom);
    7373  void atomRemoved(const atom *_atom);
    74   void moleculeInserted(const molecule *_molecule);
    7574  void moleculeRemoved(const molecule *_molecule);
     75  void worldSelectionChanged();
    7676  void bondInserted(const bond *_bond, const GLMoleculeObject_bond::SideOfBond side);
    7777  void bondRemoved(const atomId_t leftnr, const atomId_t rightnr);
  • src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp

    r1ce04b r3927ef  
    4242  connect(this, SIGNAL(atomInserted(const atom *)), worldscene, SLOT(atomInserted(const atom *)));
    4343  connect(this, SIGNAL(atomRemoved(const atom *)), worldscene, SLOT(atomRemoved(const atom *)));
    44   connect(this, SIGNAL(moleculeInserted(const molecule *)), worldscene, SLOT(moleculeInserted(const molecule *)));
     44  connect(this, SIGNAL(worldSelectionChanged()), worldscene, SLOT(worldSelectionChanged()));
    4545  connect(this, SIGNAL(moleculeRemoved(const molecule *)), worldscene, SLOT(moleculeRemoved(const molecule *)));
    4646  connect(this, SIGNAL(changed()), this, SLOT(updateGL()));
     
    5151  World::getInstance().signOn(this, World::AtomRemoved);
    5252  World::getInstance().signOn(this, World::AtomPositionChanged);
    53   World::getInstance().signOn(this, World::MoleculeInserted);
    5453  World::getInstance().signOn(this, World::MoleculeRemoved);
     54  World::getInstance().signOn(this, World::SelectionChanged);
    5555}
    5656
     
    6161  World::getInstance().signOff(this, World::AtomRemoved);
    6262  World::getInstance().signOff(this, World::AtomPositionChanged);
    63   World::getInstance().signOff(this, World::MoleculeInserted);
    6463  World::getInstance().signOff(this, World::MoleculeRemoved);
     64  World::getInstance().signOff(this, World::SelectionChanged);
    6565  delete worldscene;
    6666}
     
    115115      break;
    116116    }
    117     case World::MoleculeInserted:
     117    case World::SelectionChanged:
    118118    {
    119       const molecule *_molecule = World::getInstance().lastChanged<molecule>();
    120119#ifdef LOG_OBSERVER
    121       observerLog().addMessage() << "++ Observer " << observerLog().getName(this) << " received notification that molecule "+toString(_molecule->getId())+" has been inserted.";
     120      observerLog().addMessage() << "++ Observer " << observerLog().getName(this) << " received notification that selection has changed.";
    122121#endif
    123       emit moleculeInserted(_molecule);
     122      emit worldSelectionChanged();
    124123      break;
    125124    }
  • src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp

    r1ce04b r3927ef  
    4747  void atomInserted(const atom *_atom);
    4848  void atomRemoved(const atom *_atom);
    49   void moleculeInserted(const molecule *_molecule);
    5049  void moleculeRemoved(const molecule *_molecule);
     50  void worldSelectionChanged();
    5151
    5252protected:
     
    5959
    6060  bool changesPresent;
     61  bool processingSelectionChanged; // workaround to prevent a loop in (atom_iterator <-> observer)
    6162};
    6263
Note: See TracChangeset for help on using the changeset viewer.