Ignore:
Timestamp:
Aug 5, 2015, 5:32:11 PM (9 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:
a39d72
Parents:
e5a477
git-author:
Frederik Heber <heber@…> (07/19/15 07:08:38)
git-committer:
Frederik Heber <heber@…> (08/05/15 17:32:11)
Message:

QtMainWindow uses QtSelectionChangedAgent.

  • QtMoleculeListView and GLWorldView receive its signals. The latter passes it on to GLWorldScene.
  • QtMoleculeList has new MoleculeIdToIndex to allow QtMoleculeListView to (un)select specific rows on a given index.
  • GLWorldScene passes atom and molecule selection to GLMoleculeObject_molecule.
  • GLMoleculeObject_molecule passes atom selection to respective GLMoleculeObject_atom.
Location:
src/UIElements/Views/Qt4/MoleculeList
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.cpp

    re5a477 r015f8c  
    178178}
    179179
     180const QModelIndex QtMoleculeList::MoleculeIdToIndex(const moleculeId_t _id) const
     181{
     182  boost::recursive_mutex::scoped_lock lock(refill_mutex);
     183  QtMoleculeItem * const item = MoleculeIdToItem(_id);
     184  ASSERT(item != NULL,
     185      "QtMoleculeList::MoleculeIdToIndex() - could not find item to "
     186      +toString(_id));
     187  return indexFromItem(item);
     188}
    180189
    181190const moleculeId_t QtMoleculeList::IndexToMoleculeId(const QModelIndex &_index) const
  • src/UIElements/Views/Qt4/MoleculeList/QtMoleculeList.hpp

    re5a477 r015f8c  
    8686  bool isMoleculeItemPresent(const moleculeId_t _molid) const;
    8787  QtMoleculeItem * MoleculeIdToItem(const moleculeId_t _molid) const;
     88  const moleculeId_t ItemToMoleculeId(const QtMoleculeItem * const _item) const;
     89  const QModelIndex MoleculeIdToIndex(const moleculeId_t _id) const;
    8890  const moleculeId_t IndexToMoleculeId(const QModelIndex &_index) const;
    89   const moleculeId_t ItemToMoleculeId(const QtMoleculeItem * const _item) const;
    9091  QtMoleculeItem * getSpecificMoleculeItem(
    9192      const QtMoleculeItem * const _item,
  • src/UIElements/Views/Qt4/MoleculeList/QtMoleculeListView.cpp

    re5a477 r015f8c  
    3737#include "UIElements/Views/Qt4/MoleculeList/QtMoleculeList.hpp"
    3838#include "UIElements/Views/Qt4/MoleculeList/QtMoleculeItem.hpp"
     39#include "UIElements/Views/Qt4/QtSelectionChangedAgent.hpp"
    3940
    4041#include "CodePatterns/MemDebug.hpp"
     
    5354{
    5455  setSelectionMode(QAbstractItemView::MultiSelection);
    55 
    56   World::getInstance().signOn(this, World::SelectionChanged);
    5756}
    5857
    5958QtMoleculeListView::~QtMoleculeListView()
    60 {
    61   World::getInstance().signOff(this, World::SelectionChanged);
    62 }
     59{}
    6360
    6461void QtMoleculeListView::setModel(QtMoleculeList *_moleculelist)
     
    6966      selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
    7067      this, SLOT(rowsSelected(const QItemSelection &, const QItemSelection &)), Qt::DirectConnection);
     68}
     69
     70
     71void QtMoleculeListView::setSelectionChangedAgent(QtSelectionChangedAgent *agent)
     72{
     73  connect(agent, SIGNAL(moleculeSelected(const moleculeId_t)),
     74      this, SLOT(MoleculeSelected(const moleculeId_t)));
     75  connect(agent, SIGNAL(moleculeUnselected(const moleculeId_t)),
     76      this, SLOT(MoleculeUnselected(const moleculeId_t)));
    7177}
    7278
     
    148154  selecting = false;
    149155}
     156
     157void QtMoleculeListView::MoleculeSelected(const moleculeId_t _id)
     158{
     159  if (selecting)
     160    return;
     161
     162  selecting = true;
     163
     164  const QtMoleculeList *moleculelist = dynamic_cast<const QtMoleculeList *>(model());
     165  QModelIndex index = moleculelist->MoleculeIdToIndex(_id);
     166  ASSERT( !selectionModel()->isSelected(index),
     167      "QtMoleculeListView::MoleculeSelected() - row to molecule "
     168      +toString(_id)+" is already selected.");
     169
     170  // select the full row
     171  expand(index);
     172  selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
     173
     174  selecting = false;
     175}
     176
     177void QtMoleculeListView::MoleculeUnselected(const moleculeId_t _id)
     178{
     179  if (selecting)
     180    return;
     181
     182  selecting = true;
     183
     184  const QtMoleculeList *moleculelist = dynamic_cast<const QtMoleculeList *>(model());
     185  QModelIndex index = moleculelist->MoleculeIdToIndex(_id);
     186  ASSERT( selectionModel()->isSelected(index),
     187      "QtMoleculeListView::MoleculeSelected() - row to molecule "
     188      +toString(_id)+" is already unselected.");
     189
     190  // unselect the full row
     191  expand(index);
     192  selectionModel()->select(index, QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
     193
     194  selecting = false;
     195}
     196
    150197
    151198void QtMoleculeListView::recieveNotification(Observable *publisher, Notification_ptr notification)
  • src/UIElements/Views/Qt4/MoleculeList/QtMoleculeListView.hpp

    re5a477 r015f8c  
    1919#include "CodePatterns/Observer/Observer.hpp"
    2020
     21#include "types.hpp"
     22
    2123class QtMoleculeList;
     24class QtSelectionChangedAgent;
    2225
    2326class QtMoleculeListView : public QTreeView, public Observer
     
    3134  void setModel(QtMoleculeList *_moleculelist);
    3235
     36  void setSelectionChangedAgent(QtSelectionChangedAgent *agent);
     37
    3338public slots:
    3439  void rowsSelected(const QItemSelection&, const QItemSelection&);
     40
     41  void MoleculeSelected(const moleculeId_t _id);
     42  void MoleculeUnselected(const moleculeId_t _id);
    3543
    3644protected:
Note: See TracChangeset for help on using the changeset viewer.