Changeset 07136a for src


Ignore:
Timestamp:
Aug 5, 2015, 5:32:12 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:
a9161d
Parents:
369cb1
git-author:
Frederik Heber <heber@…> (07/20/15 09:16:27)
git-committer:
Frederik Heber <heber@…> (08/05/15 17:32:12)
Message:

FIX: Fixing display of shapes in GLWorldView.

  • we propagate shape name via S/S system such that we may lookup the name in ShapeRegistry and do not have to rely on probably already deallocated lastchanged() shape. This affects ShapeAdded() and ShapeRemoved().
  • GLMoleculeObject_shape now copies the shape, ensuring that its present while its surface is tesselated.
Location:
src/UIElements/Views/Qt4/Qt3D
Files:
6 edited

Legend:

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

    r369cb1 r07136a  
    5050#include "CodePatterns/Log.hpp"
    5151
    52 #include "Shapes/Shape.hpp"
    5352#include "Shapes/ShapeFactory.hpp"
    5453#include "LinearAlgebra/Vector.hpp"
  • src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_shape.hpp

    r369cb1 r07136a  
    2323#include "GLMoleculeObject.hpp"
    2424
    25 class Shape;
     25#include "Shapes/Shape.hpp"
    2626
    2727/** This class represents a triangulated Shape.
     
    4141private:
    4242
    43    Shape &m_shape;
     43   Shape m_shape;
    4444   bool m_enabled;
    4545};
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.cpp

    r369cb1 r07136a  
    362362/** Adds a shape to the scene.
    363363 *
    364  * uses ShapeRegistry::lastChanged()
    365  *
    366  */
    367 void GLWorldScene::addShape()
    368 {
    369   Shape &shape = *ShapeRegistry::getInstance().lastChanged();
    370   GLMoleculeObject_shape *shapeObject = new GLMoleculeObject_shape(shape, this);
    371   ShapeNodeMap::iterator iter = ShapesinSceneMap.find(shape.getName());
    372   ASSERT(iter == ShapesinSceneMap.end(),
    373       "GLWorldScene::addShape() - same shape "+shape.getName()+" added again.");
    374   ShapesinSceneMap.insert( make_pair(shape.getName(), shapeObject) );
    375 }
    376 
    377 void GLWorldScene::removeShape()
    378 {
    379   Shape &shape = *ShapeRegistry::getInstance().lastChanged();
    380   ShapeNodeMap::iterator iter = ShapesinSceneMap.find(shape.getName());
     364 */
     365void GLWorldScene::addShape(const std::string &_name)
     366{
     367  Shape * const shape = ShapeRegistry::getInstance().getByName(_name);
     368  if (shape != NULL) {
     369    GLMoleculeObject_shape *shapeObject = new GLMoleculeObject_shape(*shape, this);
     370    ShapeNodeMap::iterator iter = ShapesinSceneMap.find(_name);
     371    ASSERT(iter == ShapesinSceneMap.end(),
     372        "GLWorldScene::addShape() - same shape "+_name+" added again.");
     373    ShapesinSceneMap.insert( make_pair(_name, shapeObject) );
     374  } else
     375    ELOG(2, "GLWorldScene::addShape() - shape disappeared before we could draw it.");
     376
     377  emit changed();
     378}
     379
     380void GLWorldScene::removeShape(const std::string &_name)
     381{
     382  ShapeNodeMap::iterator iter = ShapesinSceneMap.find(_name);
    381383  ASSERT(iter != ShapesinSceneMap.end(),
    382       "GLWorldScene::removeShape() - shape "+shape.getName()+" not in scene.");
     384      "GLWorldScene::removeShape() - shape "+_name+" not in scene.");
    383385  ShapesinSceneMap.erase(iter);
    384386  delete(iter->second);
     387
     388  emit changed();
    385389}
    386390
     
    393397      }
    394398  }
     399
     400  emit changed();
    395401}
    396402
  • src/UIElements/Views/Qt4/Qt3D/GLWorldScene.hpp

    r369cb1 r07136a  
    9292  void setSelectionModeAtom();
    9393  void setSelectionModeMolecule();
    94   void addShape();
    95   void removeShape();
     94  void addShape(const std::string &_name);
     95  void removeShape(const std::string &_name);
    9696//  void update();
    9797  void moleculesVisibilityChanged(const moleculeId_t _id, bool _visible);
  • src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp

    r369cb1 r07136a  
    8383  qRegisterMetaType<moleculeId_t>("moleculeId_t");
    8484
    85   connect(this, SIGNAL(ShapeAdded()), worldscene, SLOT(addShape()));
    86   connect(this, SIGNAL(ShapeRemoved()), worldscene, SLOT(removeShape()));
     85  connect(this, SIGNAL(ShapeAdded(const std::string &)), worldscene, SLOT(addShape(const std::string &)));
     86  connect(this, SIGNAL(ShapeRemoved(const std::string &)), worldscene, SLOT(removeShape(const std::string &)));
    8787//  connect(this, SIGNAL(TimeChanged()), worldscene, SIGNAL(updated()));
    8888  connect(worldscene, SIGNAL(changeOccured()), this, SLOT(changeSignalled()));
     
    477477      case ShapeRegistry::ShapeInserted:
    478478      {
    479         emit ShapeAdded();
     479        emit ShapeAdded(ShapeRegistry::getInstance().lastChanged()->getName());
    480480        break;
    481481      }
    482482      case ShapeRegistry::ShapeRemoved:
    483483      {
    484         emit ShapeRemoved();
     484        emit ShapeRemoved(ShapeRegistry::getInstance().lastChanged()->getName());
    485485        break;
    486486      }
  • src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp

    r369cb1 r07136a  
    6969  void hoverChanged(const atomId_t _id);
    7070  void hoverChanged(const moleculeId_t _id, int);
    71   void ShapeAdded();
    72   void ShapeRemoved();
     71  void ShapeAdded(const std::string &);
     72  void ShapeRemoved(const std::string &);
    7373  void moleculesVisibilityChanged(const moleculeId_t,bool);
    7474
Note: See TracChangeset for help on using the changeset viewer.