StelObjectMgr.cpp   StelObjectMgr.cpp 
skipping to change at line 26 skipping to change at line 26
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelObjectModule.hpp" #include "StelObjectModule.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "Projector.hpp" #include "StelProjector.hpp"
#include "MovementMgr.hpp" #include "StelMovementMgr.hpp"
#include <QMouseEvent> #include <QMouseEvent>
#include <QString> #include <QString>
#include <QDebug> #include <QDebug>
#include <QStringList> #include <QStringList>
StelObjectMgr::StelObjectMgr() StelObjectMgr::StelObjectMgr()
{ {
setObjectName("StelObjectMgr"); setObjectName("StelObjectMgr");
objectPointerVisibility = true; objectPointerVisibility = true;
} }
skipping to change at line 55 skipping to change at line 55
*************************************************************************/ *************************************************************************/
void StelObjectMgr::handleMouseClicks(QMouseEvent* event) void StelObjectMgr::handleMouseClicks(QMouseEvent* event)
{ {
// Deselect the selected object // Deselect the selected object
if (event->button()==Qt::RightButton && event->type()==QEvent::Mouse ButtonRelease) if (event->button()==Qt::RightButton && event->type()==QEvent::Mouse ButtonRelease)
{ {
unSelect(); unSelect();
event->accept(); event->accept();
return; return;
} }
MovementMgr* mvmgr = (MovementMgr*)GETSTELMODULE("MovementMgr"); StelMovementMgr* mvmgr = (StelMovementMgr*)GETSTELMODULE("StelMoveme ntMgr");
if (event->button()==Qt::LeftButton && event->type()==QEvent::MouseB uttonRelease && !mvmgr->getHasDragged()) if (event->button()==Qt::LeftButton && event->type()==QEvent::MouseB uttonRelease && !mvmgr->getHasDragged())
{ {
#ifdef MACOSX #ifdef MACOSX
// CTRL + left clic = right clic for 1 button mouse // CTRL + left clic = right clic for 1 button mouse
if (event->modifiers().testFlag(Qt::ControlModifier)) if (event->modifiers().testFlag(Qt::ControlModifier))
{ {
unSelect(); unSelect();
event->accept(); event->accept();
return; return;
} }
skipping to change at line 162 skipping to change at line 162
StelObjectP tempselect = cleverFind(core, x, y); StelObjectP tempselect = cleverFind(core, x, y);
return setSelectedObject(tempselect, action); return setSelectedObject(tempselect, action);
} }
// Find an object in a "clever" way, v in J2000 frame // Find an object in a "clever" way, v in J2000 frame
StelObjectP StelObjectMgr::cleverFind(const StelCore* core, const Vec3d& v) const StelObjectP StelObjectMgr::cleverFind(const StelCore* core, const Vec3d& v) const
{ {
StelObjectP sobj; StelObjectP sobj;
QList<StelObjectP> candidates; QList<StelObjectP> candidates;
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000)
;
// Field of view for a 30 pixel diameter circle on screen // Field of view for a 30 pixel diameter circle on screen
float fov_around = core->getProjection()->getFov()/qMin(core->getPro jection()->getViewportWidth(), core->getProjection()->getViewportHeight()) * 30.f; float fov_around = core->getMovementMgr()->getCurrentFov()/qMin(prj- >getViewportWidth(), prj->getViewportHeight()) * 30.f;
// Collect the objects inside the range // Collect the objects inside the range
for (QList<StelObjectModule*>::const_iterator iteromgr=objectsModule .begin();iteromgr!=objectsModule.end();++iteromgr) for (QList<StelObjectModule*>::const_iterator iteromgr=objectsModule .begin();iteromgr!=objectsModule.end();++iteromgr)
{ {
candidates += (*iteromgr)->searchAround(v, fov_around, core) ; candidates += (*iteromgr)->searchAround(v, fov_around, core) ;
} }
// Now select the object minimizing the function y = distance(in pix el) + magnitude // Now select the object minimizing the function y = distance(in pix el) + magnitude
Vec3d winpos; Vec3d winpos;
core->getProjection()->setCurrentFrame(Projector::FrameJ2000); prj->project(v, winpos);
core->getProjection()->project(v, winpos);
float xpos = winpos[0]; float xpos = winpos[0];
float ypos = winpos[1]; float ypos = winpos[1];
float best_object_value; float best_object_value;
best_object_value = 100000.f; best_object_value = 100000.f;
QList<StelObjectP>::iterator iter = candidates.begin(); QList<StelObjectP>::iterator iter = candidates.begin();
while (iter != candidates.end()) while (iter != candidates.end())
{ {
core->getProjection()->project((*iter)->getObsJ2000Pos(core- >getNavigation()), winpos); prj->project((*iter)->getJ2000EquatorialPos(core->getNavigat or()), winpos);
float distance = sqrt((xpos-winpos[0])*(xpos-winpos[0]) + (y pos-winpos[1])*(ypos-winpos[1])); float distance = sqrt((xpos-winpos[0])*(xpos-winpos[0]) + (y pos-winpos[1])*(ypos-winpos[1]));
float priority = (*iter)->getSelectPriority(core->getNaviga float priority = (*iter)->getSelectPriority(core->getNaviga
tion()); tor());
// qDebug() << (*iter).getShortInfoString(core->getNavigatio // qDebug() << (*iter).getShortInfoString(core->getNavigator
n()) << ": " << priority << " " << distance; ()) << ": " << priority << " " << distance;
if (distance + priority < best_object_value) if (distance + priority < best_object_value)
{ {
best_object_value = distance + priority; best_object_value = distance + priority;
sobj = *iter; sobj = *iter;
} }
++iter; ++iter;
} }
return sobj; return sobj;
} }
/************************************************************************* /*************************************************************************
Find in a "clever" way an object from its equatorial position Find in a "clever" way an object from its equatorial position
*************************************************************************/ *************************************************************************/
StelObjectP StelObjectMgr::cleverFind(const StelCore* core, int x, int y) c onst StelObjectP StelObjectMgr::cleverFind(const StelCore* core, int x, int y) c onst
{ {
Vec3d v; Vec3d v;
core->getProjection()->setCurrentFrame(Projector::FrameJ2000); core->getProjection(StelCore::FrameJ2000)->unProject(x,y,v);
core->getProjection()->unProject(x,y,v);
return cleverFind(core, v); return cleverFind(core, v);
} }
/************************************************************************* /*************************************************************************
Notify that we want to unselect any object Notify that we want to unselect any object
*************************************************************************/ *************************************************************************/
void StelObjectMgr::unSelect(void) void StelObjectMgr::unSelect(void)
{ {
lastSelectedObjects.clear(); lastSelectedObjects.clear();
 End of changes. 8 change blocks. 
13 lines changed or deleted 14 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/