Ignore:
Timestamp:
Jan 11, 2015, 4:42:43 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:
d7cad1
Parents:
f115cc
git-author:
Frederik Heber <heber@…> (12/05/14 23:06:53)
git-committer:
Frederik Heber <heber@…> (01/11/15 16:42:43)
Message:

GLWorldView's view may be changed via keyboard (especially zoom).

  • Zoom and keys distance change scaled by eye-center distance.
File:
1 edited

Legend:

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

    rf115cc rb6d92e  
    7171  setOption(QGLView::ObjectPicking, true);
    7272  setOption(QGLView::CameraNavigation, false);
     73  setFocusPolicy(Qt::StrongFocus);
    7374  setCameraControlMode(Rotate);
    7475  defaultEyeSeparation = 4.0;
     
    499500void GLWorldView::keyPressEvent(QKeyEvent *e)
    500501{
     502  // Find the distance between the eye and focus point.
     503  QVector3D d = camera()->eye() - camera()->center();
     504//  LOG(1, "Distance vector eye and center is "
     505//      << d.x() << "," << d.y() << "," << d.z());
     506  // scale the move unit by the eye <-> domain center distance
     507  const double key_move_unit = 0.04*(d.length()/50.);
     508
    501509  if (e->key() == Qt::Key_Tab) {
    502510    // The Tab key turns the ShowPicking option on and off,
     
    504512    setOption(QGLView::ShowPicking, ((options() & QGLView::ShowPicking) == 0));
    505513    updateGL();
     514  } else if ((e->key() == Qt::Key_Minus) || (e->key() == Qt::Key_Plus)) {
     515    // Scale the distance.
     516    if (e->key() == Qt::Key_Minus)
     517      d *= 1.2;
     518    else if (e->key() == Qt::Key_Plus)
     519      d /= 1.2;
     520    // Set new eye position.
     521    camera()->setEye(camera()->center() + d);
     522  } else if ((e->key() == Qt::Key_Left) || (e->key() == Qt::Key_Right)) {
     523    // Translate the camera.
     524    const double d = (e->key() == Qt::Key_Left) ? -key_move_unit : key_move_unit;
     525    camera()->translateCenter( d, 0., 0);
     526    camera()->translateEye( d, 0., 0);
     527  } else if ((e->key() == Qt::Key_Up) || (e->key() == Qt::Key_Down)) {
     528    // Translate the camera.
     529    const double d = (e->key() == Qt::Key_Up) ? -key_move_unit : key_move_unit;
     530    camera()->translateCenter( 0., d, 0);
     531    camera()->translateEye( 0., d, 0);
     532  } else if ((e->key() == Qt::Key_PageUp) || (e->key() == Qt::Key_PageDown)) {
     533    // Translate the camera.
     534    const double d = (e->key() == Qt::Key_PageUp) ? -key_move_unit : key_move_unit;
     535    camera()->translateCenter( 0., 0., d);
     536    camera()->translateEye( 0., 0., d);
    506537  }
    507538  QGLView::keyPressEvent(e);
Note: See TracChangeset for help on using the changeset viewer.