Changeset 3b229e for src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.cpp
- Timestamp:
- Apr 6, 2012, 11:57:23 AM (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:
- 225cf5
- Parents:
- c67518
- git-author:
- Michael Ankele <ankele@…> (04/02/12 10:48:10)
- git-committer:
- Frederik Heber <heber@…> (04/06/12 11:57:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.cpp
rc67518 r3b229e 41 41 42 42 #include "CodePatterns/MemDebug.hpp" 43 44 QGLMaterial *GLMoleculeObject::m_hoverMaterial = NULL; 45 QGLMaterial *GLMoleculeObject::m_selectionMaterial = NULL; 46 QGLMaterial *GLMoleculeObject::m_selectionBoxMaterial = NULL; 43 47 44 48 … … 55 59 m_selected = false; 56 60 m_material = 0; 57 m_hoverMaterial = 0; 58 m_selectionMaterial = 0; 61 initStaticMaterials(); 59 62 } 60 63 … … 72 75 m_selected = false; 73 76 m_material = 0; 74 m_hoverMaterial = 0; 75 m_selectionMaterial = 0; 77 initStaticMaterials(); 76 78 } 77 79 … … 107 109 else 108 110 material = m_material; 111 112 ASSERT(material, "GLMoleculeObject::draw: chosen material is NULL"); 113 109 114 painter->setColor(material->diffuseColor()); 110 115 painter->setFaceMaterial(QGL::AllFaces, material); … … 123 128 124 129 if (m_selected){ 130 painter->setFaceMaterial(QGL::AllFaces, m_selectionBoxMaterial); 125 131 QVector3DArray array; 126 132 qreal radius = 0.3f; … … 190 196 QGLMaterial* GLMoleculeObject::getMaterial(size_t no) 191 197 { 192 ASSERT( (no > = 0) && (no < MAX_ELEMENTS) || (no == 65536),198 ASSERT( (no > 0) && (no < MAX_ELEMENTS), 193 199 "GLMoleculeView::getMaterial() - Element no "+toString(no)+" is invalid."); 194 200 if (ElementNoMaterialMap.find(no) != ElementNoMaterialMap.end()){ … … 200 206 QGLMaterial *newmaterial = new QGLMaterial(NULL); 201 207 202 if (no == 0) { // create hover material 203 newmaterial->setAmbientColor( QColor(0, 128, 128) ); 204 } else if (no == 65536) { // create selection material 205 newmaterial->setAmbientColor( QColor(255, 50, 50) ); 206 } else { // create material for element 207 periodentafel *periode = World::getInstance().getPeriode(); 208 const element *desiredelement = periode->FindElement(no); 209 ASSERT(desiredelement != NULL, 210 "GLMoleculeView::getMaterial() - desired element "+toString(no)+" not present in periodentafel."); 211 const unsigned char* color = desiredelement->getColor(); 212 LOG(1, "Creating new material with color " << (int)color[0] << "," << (int)color[1] << "," << (int)color[2] << "."); 213 newmaterial->setAmbientColor( QColor((int)color[0], (int)color[1], (int)color[2]) ); 214 } 208 // create material for element 209 periodentafel *periode = World::getInstance().getPeriode(); 210 const element *desiredelement = periode->FindElement(no); 211 ASSERT(desiredelement != NULL, 212 "GLMoleculeView::getMaterial() - desired element "+toString(no)+" not present in periodentafel."); 213 const unsigned char* color = desiredelement->getColor(); 214 LOG(1, "Creating new material with color " << (int)color[0] << "," << (int)color[1] << "," << (int)color[2] << "."); 215 newmaterial->setAmbientColor( QColor((int)color[0], (int)color[1], (int)color[2]) ); 215 216 newmaterial->setSpecularColor( QColor(60, 60, 60) ); 216 217 newmaterial->setShininess( 128 ); … … 218 219 219 220 return newmaterial; 221 } 222 } 223 224 /** Create the 3 materials shared by all objects. 225 * 226 */ 227 void GLMoleculeObject::initStaticMaterials() 228 { 229 if (!m_hoverMaterial){ 230 m_hoverMaterial = new QGLMaterial(NULL); 231 m_hoverMaterial->setAmbientColor( QColor(0, 128, 128) ); 232 m_hoverMaterial->setSpecularColor( QColor(60, 60, 60) ); 233 m_hoverMaterial->setShininess( 128 ); 234 } 235 if (!m_selectionMaterial){ 236 m_selectionMaterial = new QGLMaterial(NULL); 237 m_selectionMaterial->setAmbientColor( QColor(255, 50, 50) ); 238 m_selectionMaterial->setSpecularColor( QColor(60, 60, 60) ); 239 m_selectionMaterial->setShininess( 128 ); 240 } 241 if (!m_selectionBoxMaterial){ 242 m_selectionBoxMaterial = new QGLMaterial(NULL); 243 m_selectionBoxMaterial->setAmbientColor( QColor(0, 0, 0) ); 244 m_selectionBoxMaterial->setDiffuseColor( QColor(0, 0, 0) ); 245 m_selectionBoxMaterial->setEmittedLight( QColor(155, 50, 50) ); 220 246 } 221 247 }
Note:
See TracChangeset
for help on using the changeset viewer.