/****************************************************************************** * Handles the mouse events for a Viewport. ******************************************************************************/ void PickParticlePlaneInputMode::mouseReleaseEvent(Viewport* vp, QMouseEvent* event) { if(event->button() == Qt::LeftButton) { if(_pickedParticles.size() >= 3) { _pickedParticles.clear(); vp->dataset()->viewportConfig()->updateViewports(); } PickResult pickResult; if(pickParticle(vp, event->pos(), pickResult)) { // Do not select the same particle twice. bool ignore = false; if(_pickedParticles.size() >= 1 && _pickedParticles[0].worldPos.equals(pickResult.worldPos, FLOATTYPE_EPSILON)) ignore = true; if(_pickedParticles.size() >= 2 && _pickedParticles[1].worldPos.equals(pickResult.worldPos, FLOATTYPE_EPSILON)) ignore = true; if(!ignore) { _pickedParticles.push_back(pickResult); vp->dataset()->viewportConfig()->updateViewports(); if(_pickedParticles.size() == 3) { // Get the slice modifier that is currently being edited. SliceModifier* mod = dynamic_object_cast<SliceModifier>(_editor->editObject()); if(mod) alignPlane(mod); _pickedParticles.clear(); } } } } ViewportInputMode::mouseReleaseEvent(vp, event); }
/****************************************************************************** * Handles the mouse up events for a Viewport. ******************************************************************************/ void ParticleInformationInputMode::mouseReleaseEvent(Viewport* vp, QMouseEvent* event) { if(event->button() == Qt::LeftButton) { PickResult pickResult; pickParticle(vp, event->pos(), pickResult); if(!event->modifiers().testFlag(Qt::ControlModifier)) _pickedParticles.clear(); if(pickResult.objNode) { // Don't select the same particle twice. bool alreadySelected = false; for(auto p = _pickedParticles.begin(); p != _pickedParticles.end(); ++p) { if(p->objNode == pickResult.objNode && p->particleIndex == pickResult.particleIndex) { alreadySelected = true; _pickedParticles.erase(p); break; } } if(!alreadySelected) _pickedParticles.push_back(pickResult); } _applet->updateInformationDisplay(); vp->dataset()->viewportConfig()->updateViewports(); } ViewportInputMode::mouseReleaseEvent(vp, event); }
void NBodyWorldApp::eventHandling ( const SDL_Event& event ){ //printf( "NBodyWorldApp::eventHandling() \n" ); switch( event.type ){ case SDL_MOUSEBUTTONDOWN: switch( event.button.button ){ case SDL_BUTTON_LEFT: //printf( "left button pressed !!!! " ); pickParticle( world.picked ); break; } break; case SDL_MOUSEBUTTONUP: switch( event.button.button ){ case SDL_BUTTON_LEFT: //printf( "left button pressed !!!! " ); world.picked = NULL; break; } break; }; AppSDL2OGL::eventHandling( event ); }