[Kstars-devel] Refined patch for wishlist 178232: List all objects within a rectangle

Khudyakov Alexey alexey.skladnoy at gmail.com
Thu Feb 4 21:53:50 CET 2010


В сообщении от Четверг 04 февраля 2010 10:00:25 Abhijit Apte написал:
> Hi,
> 
> There is one candidate for separate patch already. It is code for searching
> 
> > for objects.
> 
> I've attached the patch for this candidate. It searches the objects in
> rectangle using the approach that you suggested and finally prints the
> results of the search on console (upon right-click drag).
> I've implemented objectsInArea() only for StarComponent and
> DeepSkyComponent, for now. Still got to figure out logic for searching
> planets, moons, comets etc.
> 
> Please review and let me know your comments.
> 

1. Please change signature of findObjectInArea to 
findObjectInArea(const SkyPoint&, const SkyPoint&)
It will make obvious to caller that points are not going to be changed.

This may require copying but it's not a problem.


2. I'm not sure that SkyMapComposite::skyRegion is eligible for separate 
function. It's as simple as

SkyPoint p3( p1.ra(), p2.dec() );
SkyPoint p4( p2.ra(), p1.dec() ); // Or other way around
QList<SkyPoint*> list;
// "<<" is overloaded for QList<T>
list << &p1 << &p3 << &p2 << &p4;
const SkyRegion& region = m_skyMesh->indexPoly( &list );

Please note that there is no need to create temporary variables. Also `dms' 
has size of double since it's double in fancy wrapping.


3. It doesn't seem very reasonable to leave out nameless stars. They are vast 
majority after all. This will require to set up some magnitude cut-off to 
remove faint stars at low zoom. 

This is difficult task and separate from object finding so it's fine as it is by 
now.


4. If object doesn't visible it shouldn't get listed. You can use `selected()' 
to determine whether component visible.


More information about the Kstars-devel mailing list