Changeset 739ee9


Ignore:
Timestamp:
Jan 10, 2015, 5:14:32 PM (10 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:
34e7fdb
Parents:
8c001a
git-author:
Frederik Heber <heber@…> (11/05/14 22:00:40)
git-committer:
Frederik Heber <heber@…> (01/10/15 17:14:32)
Message:

GLMoleculeObject have m_visible, settable in QtMoleculeList.

  • is connected via QtMainWindow an GLWorldView, GLWorldScene.
  • i.e. molecule's atoms and bond display can now be switched on and off.
Location:
src/UIElements
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Qt4/QtMainWindow.cpp

    r8c001a r739ee9  
    146146  settings.endGroup();
    147147
     148  qRegisterMetaType<moleculeId_t>("moleculeId_t");
     149
    148150  connect(glWorldView,SIGNAL(hoverChanged(const atom*)), infoBox,SLOT(atomHover(const atom*)));
     151  connect(moleculeList,SIGNAL(moleculesVisibilityChanged(const moleculeId_t,bool)), glWorldView, SIGNAL(moleculesVisibilityChanged(const moleculeId_t,bool)));
    149152}
    150153
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.cpp

    r8c001a r739ee9  
    8282   m_hovering = false;
    8383   m_selected = false;
     84   m_visible = true;
    8485   m_material = 0;
    8586   initStaticMaterials();
     
    328329  }
    329330}
     331
     332void GLMoleculeObject::setVisible(bool value)
     333{
     334  if (value != m_visible){
     335    m_visible = value;
     336    emit changed();
     337  }
     338}
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.hpp

    r8c001a r739ee9  
    7474   void setSelected(bool value);
    7575
     76   bool visible() const { return m_visible; }
     77   void setVisible(bool value);
     78
    7679   void initStaticMaterials();
    7780   virtual void initialize(QGLView *view, QGLPainter *painter);
     
    124127   bool m_hovering;
    125128   bool m_selected;
     129   bool m_visible;
    126130};
    127131
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp

    r8c001a r739ee9  
    7474  World::getInstance().signOn(this, World::SelectionChanged);
    7575  updateBoundingBox();
     76
     77  // initially, atoms and bonds should be visible
     78  m_visible = false;
    7679
    7780  init();
     
    256259void GLMoleculeObject_molecule::draw(QGLPainter *painter, const QVector4D &cameraPlane)
    257260{
    258    // Draw all of the mesh objects that we have as children.
    259   GLMoleculeObject::draw(painter, cameraPlane);
    260    foreach (QObject *obj, children()) {
    261      GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
    262        if (meshobj)
    263          meshobj->draw(painter, cameraPlane);
    264    }
     261  // draw either molecule's mesh or all atoms and bonds
     262  if (m_visible) {
     263    GLMoleculeObject::draw(painter, cameraPlane);
     264  } else {
     265    // Draw all of the mesh objects that we have as children.
     266    foreach (QObject *obj, children()) {
     267      GLMoleculeObject *meshobj = qobject_cast<GLMoleculeObject *>(obj);
     268      if (meshobj)
     269        meshobj->draw(painter, cameraPlane);
     270    }
     271  }
    265272}
    266273
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    r8c001a r739ee9  
    286286}
    287287
     288void GLWorldScene::moleculesVisibilityChanged(const moleculeId_t _id, bool _visible)
     289{
     290  MoleculeNodeMap::iterator iter = MoleculesinSceneMap.find(_id);
     291  ASSERT( iter != MoleculesinSceneMap.end(),
     292      "GLWorldScene::moleculeInserted() - molecule's id "+toString(_id)+" is unknown.");
     293
     294  GLMoleculeObject_molecule *molObject = iter->second;
     295  molObject->setVisible(_visible);
     296
     297  emit changed();
     298  emit changeOccured();
     299}
     300
    288301/** Adds a bond to the scene.
    289302 *
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp

    r8c001a r739ee9  
    9292  void removeShape();
    9393  void update();
     94  void moleculesVisibilityChanged(const moleculeId_t _id, bool _visible);
    9495
    9596public:
  • src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp

    r8c001a r739ee9  
    9292  //connect(this, SIGNAL(changed()), this, SLOT(updateGL()));
    9393  connect(this, SIGNAL(changed()), this, SLOT(sceneChangeSignalled()));
     94  connect(this, SIGNAL(moleculesVisibilityChanged(const moleculeId_t,bool)), worldscene, SLOT(moleculesVisibilityChanged(const moleculeId_t,bool)));
    9495
    9596  // sign on to changes in the world
  • src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp

    r8c001a r739ee9  
    6464  void ShapeAdded();
    6565  void ShapeRemoved();
     66  void moleculesVisibilityChanged(const moleculeId_t,bool);
    6667
    6768protected:
  • src/UIElements/Views/Qt4/QtMoleculeList.cpp

    r8c001a r739ee9  
    5555// these attributes are skipped so far
    5656const int QtMoleculeList::COLUMNCOUNT = COLUMNTYPES_MAX;
    57 const char *QtMoleculeList::COLUMNNAMES[QtMoleculeList::COLUMNCOUNT]={"Name","Atoms","Formula","Occurrence"/*,"Size"*/};
     57const char *QtMoleculeList::COLUMNNAMES[QtMoleculeList::COLUMNCOUNT]={"Name","Visibility", "Atoms","Formula","Occurrence"/*,"Size"*/};
    5858
    5959QtMoleculeList::QtMoleculeList(QWidget * _parent) :
     
    8181  //connect(this,SIGNAL(cellChanged(int,int)),this,SLOT(moleculeChanged(int,int)));
    8282  connect(selectionModel(),SIGNAL(selectionChanged(QItemSelection, QItemSelection)),this,SLOT(rowsSelected(QItemSelection, QItemSelection)));
    83 
     83  connect(this, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this, SLOT(visibilityChanged(QTreeWidgetItem*, int)));
    8484}
    8585
     
    128128      formula.push_back((*iter)->getFormula());
    129129      groupItem = new QTreeWidgetItem(this);
    130       groupItem->setText(0, QString("default"));
    131       groupItem->setText(1, QString::number(0));
    132       groupItem->setText(2, QString(""));
    133       groupItem->setText(3, "0");
     130      groupItem->setText(NAME, QString("default"));
     131//      groupItem->setFlags(groupItem->flags() | Qt::ItemIsUserCheckable);
     132//      groupItem->setCheckState(VISIBILITY, Qt::Checked);
     133      groupItem->setText(ATOMCOUNT, QString::number(0));
     134      groupItem->setText(FORMULA, QString(""));
     135      groupItem->setText(OCCURRENCE, "0");
    134136      groupItem->setData(0, Qt::UserRole, QVariant(-1));
    135137    }
     
    137139    // add molecule
    138140    QTreeWidgetItem *molItem = new QTreeWidgetItem(groupItem);
    139     molItem->setText(0, QString((*iter)->getName().c_str()));
    140     molItem->setText(1, QString::number((*iter)->getAtomCount()));
    141     molItem->setText(2, QString((*iter)->getFormula().toString().c_str()));
     141    molItem->setText(NAME, QString((*iter)->getName().c_str()));
     142    molItem->setFlags(groupItem->flags() | Qt::ItemIsUserCheckable);
     143    molItem->setCheckState(VISIBILITY, Qt::Unchecked);
     144    molItem->setText(ATOMCOUNT, QString::number((*iter)->getAtomCount()));
     145    molItem->setText(FORMULA, QString((*iter)->getFormula().toString().c_str()));
    142146    const int index = (*iter)->getId();
    143147    molItem->setData(0, Qt::UserRole, QVariant(index));
     
    146150
    147151    // increase group occurrence
    148     int count = groupItem->text(3).toInt() + 1;
    149     groupItem->setText(3, QString::number(count));
     152    int count = groupItem->text(4).toInt() + 1;
     153    groupItem->setText(OCCURRENCE, QString::number(count));
    150154  }
    151155  dirty = false;
     
    161165
    162166void QtMoleculeList::subjectKilled(Observable *publisher) {
     167}
     168
     169void QtMoleculeList::visibilityChanged(QTreeWidgetItem* item, int column)
     170{
     171  if (column == VISIBILITY) {
     172    const moleculeId_t molid = item->data(0, Qt::UserRole).toInt();
     173    const bool visible = item->checkState(VISIBILITY);
     174    emit moleculesVisibilityChanged(molid, visible);
     175  }
    163176}
    164177
  • src/UIElements/Views/Qt4/QtMoleculeList.hpp

    r8c001a r739ee9  
    1818#include "CodePatterns/Observer/Observer.hpp"
    1919
     20#include "types.hpp"
     21
    2022class molecule;
    2123class MoleculeListClass;
     
    3638
    3739  static const int COLUMNCOUNT;
    38   enum {NAME,ATOMCOUNT,FORMULA,OCCURRENCE,COLUMNTYPES_MAX} COLUMNTYPES;
     40  enum {NAME,VISIBILITY,ATOMCOUNT,FORMULA,OCCURRENCE,COLUMNTYPES_MAX} COLUMNTYPES;
    3941  static const char *COLUMNNAMES[];
    4042
    4143private slots:
    4244  void moleculeChanged();
     45  void visibilityChanged(QTreeWidgetItem*, int);
    4346
    4447  void rowsSelected(const QItemSelection & selected, const QItemSelection & deselected);
     
    4750  void moleculeSelected(molecule*);
    4851  void moleculeUnSelected(molecule*);
     52  void moleculesVisibilityChanged(const moleculeId_t, bool);
    4953
    5054private:
Note: See TracChangeset for help on using the changeset viewer.