Changeset 8880c9 for src/UIElements/Views/Qt4
- Timestamp:
- Jul 17, 2012, 12:17:22 PM (13 years ago)
- 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:
- 45ea59
- Parents:
- 3f48c2
- git-author:
- Michael Ankele <ankele@…> (05/03/12 10:46:33)
- git-committer:
- Michael Ankele <ankele@…> (07/17/12 12:17:22)
- Location:
- src/UIElements/Views/Qt4/Qt3D
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLWorldView.cpp
r3f48c2 r8880c9 41 41 42 42 setOption(QGLView::ObjectPicking, true); 43 setOption(QGLView::CameraNavigation, false); 44 setCameraControlMode(Rotate); 43 45 44 46 connect(worldscene, SIGNAL(changeOccured()), this, SLOT(changeSignalled())); … … 248 250 } 249 251 252 /** 253 * Set the camera so it can oversee the whole domain. 254 */ 250 255 void GLWorldView::fitCameraToDomain() 251 256 { 252 // move the camera focus point to the center of the domain box257 // Move the camera focus point to the center of the domain box. 253 258 Vector v = World::getInstance().getDomain().translateIn(Vector(0.5, 0.5, 0.5)); 254 259 camera()->setCenter(QVector3D(v[0], v[1], v[2])); 255 260 256 // guess some eye distance261 // Guess some eye distance. 257 262 double dist = v.Norm() * 3; 258 263 camera()->setEye(QVector3D(v[0], v[1], v[2] + dist)); 259 264 camera()->setUpVector(QVector3D(0, 1, 0)); 260 265 } 266 267 void GLWorldView::mousePressEvent(QMouseEvent *event) 268 { 269 QGLView::mousePressEvent(event); 270 271 // Reset the saved mouse position. 272 lastMousePos = event->posF(); 273 } 274 275 /** 276 * Handle a mouse move event. 277 * This is used to control the camera (rotation and translation) when the left button is being pressed. 278 */ 279 void GLWorldView::mouseMoveEvent(QMouseEvent *event) 280 { 281 if (event->buttons() & Qt::LeftButton){ 282 // Find the mouse distance since the last event. 283 QPointF d = event->posF() - lastMousePos; 284 lastMousePos = event->posF(); 285 286 // Rotate or translate? (inverted by shift key) 287 CameraControlModeType mode = getCameraControlMode(event->modifiers() & Qt::ShiftModifier); 288 289 if (mode == Rotate){ 290 // Rotate the camera. 291 d *= 0.3; 292 camera()->tiltPanRollCenter(- d.y(), - d.x(), 0); 293 }else if (mode == Translate){ 294 // Translate the camera. 295 d *= 0.02; 296 camera()->translateCenter(- d.x(), d.y(), 0); 297 camera()->translateEye(- d.x(), d.y(), 0); 298 } 299 }else{ 300 // Without this Qt would not test for hover events (i.e. mouse over an atom). 301 QGLView::mouseMoveEvent(event); 302 } 303 } 304 305 /** 306 * When the mouse wheel is used, zoom in or out. 307 */ 308 void GLWorldView::wheelEvent(QWheelEvent *event) 309 { 310 // Find the distance between the eye and focus point. 311 QVector3D d = camera()->eye() - camera()->center(); 312 313 // Scale the distance. 314 if (event->delta() < 0) 315 d *= 1.2; 316 else if (event->delta() > 0) 317 d /= 1.2; 318 319 // Set new eye position. 320 camera()->setEye(camera()->center() + d); 321 } 322 261 323 262 324 //#include <GL/glu.h> -
src/UIElements/Views/Qt4/Qt3D/GLWorldView.hpp
r3f48c2 r8880c9 58 58 void initializeGL(QGLPainter *painter); 59 59 void paintGL(QGLPainter *painter); 60 void keyPressEvent(QKeyEvent *e); 60 61 // input functions 62 void mousePressEvent(QMouseEvent *event); 63 void mouseMoveEvent(QMouseEvent *event); 64 void keyPressEvent(QKeyEvent *event); 65 void wheelEvent(QWheelEvent *event); 61 66 62 67 // camera functions … … 81 86 bool changesPresent; 82 87 bool processingSelectionChanged; // workaround to prevent a loop in (atom_iterator <-> observer) 88 89 QPointF lastMousePos; 83 90 }; 84 91
Note:
See TracChangeset
for help on using the changeset viewer.