- 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)
- Location:
- src/UIElements/Views/Qt4/Qt3D
- Files:
-
- 4 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 } -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject.hpp
rc67518 r3b229e 57 57 58 58 QGLMaterial *material() const { return m_material; } 59 void setMaterial(QGLMaterial *value) 60 { m_material = value; m_hoverMaterial = value; } 61 62 QGLMaterial *hoverMaterial() const { return m_hoverMaterial; } 63 void setHoverMaterial(QGLMaterial *value) { m_hoverMaterial = value; } 64 65 QGLMaterial *selectionMaterial() const { return m_selectionMaterial; } 66 void setSelectionMaterial(QGLMaterial *value) { m_selectionMaterial = value; } 59 void setMaterial(QGLMaterial *value) { m_material = value; } 67 60 68 61 QGLAbstractEffect *effect() const { return m_effect; } … … 75 68 void setSelected(bool value); 76 69 70 void initStaticMaterials(); 77 71 void initialize(QGLView *view, QGLPainter *painter); 78 72 void draw(QGLPainter *painter); … … 106 100 QVector3D m_rotationVector; 107 101 QGLMaterial *m_material; 108 QGLMaterial *m_hoverMaterial; 109 QGLMaterial *m_selectionMaterial; 102 static QGLMaterial *m_hoverMaterial; 103 static QGLMaterial *m_selectionMaterial; 104 static QGLMaterial *m_selectionBoxMaterial; 110 105 QGLAbstractEffect *m_effect; 111 106 int m_objectId; -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_atom.cpp
rc67518 r3b229e 106 106 "GLMoleculeObject_atom::GLMoleculeObject_atom() - QGLMaterial ref from getter function is NULL."); 107 107 setMaterial(elementmaterial); 108 QGLMaterial *hovermaterial = getMaterial(0); // 0 is the hover material109 ASSERT(hovermaterial != NULL,110 "GLMoleculeObject_atom::GLMoleculeObject_atom() - QGLMaterial ref from getter function for hover is NULL.");111 setHoverMaterial(hovermaterial);112 QGLMaterial *selectionmaterial = getMaterial(65536); // 65536 is the selection material113 ASSERT(selectionmaterial != NULL,114 "GLMoleculeObject_atom::GLMoleculeObject_atom() - QGLMaterial ref from getter function for selection is NULL.");115 setSelectionMaterial(selectionmaterial);116 108 117 109 // set scale -
src/UIElements/Views/Qt4/Qt3D/GLMoleculeObject_molecule.cpp
rc67518 r3b229e 63 63 setPosition(QVector3D(0,0,0)); 64 64 setScale(5.0f); 65 QGLMaterial *selectionmaterial = getMaterial(65536); // 65536 is the selection material 66 setMaterial(selectionmaterial); 67 setSelectionMaterial(selectionmaterial); 65 setMaterial(getMaterial(1)); 68 66 } 69 67
Note:
See TracChangeset
for help on using the changeset viewer.