[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kstars-devel
Subject:    [Kstars-devel] Half a bug fix for Asteroid display bug.
From:       "Akarsh Simha" <akarshsimha () gmail ! com>
Date:       2007-05-30 21:52:02
Message-ID: c00c02910705301451sd123eeei79a8a8ce9ca9ce61 () mail ! gmail ! com
[Download RAW message or body]

Hi all.

This is a problem with asteroid limiting magnitude.
We displayed all asteroids which are brighter than the magnitude limit
set in the options tool. But we had not restricted the user from
searching such Asteroids, and you could still right click and find it
though it is not at all drawn.

The workaround for the latter bug was easy and as Jason suggested, I
overrided ListComponent::objectNearest by a
AsteroidsComponent::objectNearest that took the magnitude filter into
consideration.

The former bug, i.e. exclusion of these asteroids from the Find Tool
is something I don't know how to do.

I have these possible alternatives:

1. We include a method bool SkyComponent::Findable or something which
returns true by default and override it for various child classes as
we wish, so that we may include or exclude a certain item from the
list.

2. We include messy if( this object is an asteroid ) then check for
limiting magnitude types of statements in the Find Tool.

In either case, we will have to forfeit the simple and fast use of the
+= operator to concatenate the lists, thus making the population of
the list even slower.

Any suggestions or ideas?

The patch for the prevention of right click on an asteroid is attached.

Thanks.

-- 
Regards,
     Akarsh
http://www.bas.org.in
http://www.nascent-technologies.com

["asteroidfix.patch" (text/x-patch)]

Index: detaildialog.cpp
===================================================================
--- detaildialog.cpp	(revision 669942)
+++ detaildialog.cpp	(working copy)
@@ -247,6 +247,7 @@
 	}
 
 	//Common to all types:
+	
 	Data->Constellation->setText( ksw->data()->skyComposite()->constellation( selectedObject ) );
 }
 
Index: kswizard.cpp
===================================================================
--- kswizard.cpp	(revision 669942)
+++ kswizard.cpp	(working copy)
@@ -152,7 +152,9 @@
 		if ( loc->fullName() == ksw->data()->geo()->fullName() ) {
 			index = ksw->data()->geoList.indexOf( loc );
 			Geo = loc;
+
 		}
+
 	}
 
 	//Sort alphabetically
Index: skycomponents/asteroidscomponent.cpp
===================================================================
--- skycomponents/asteroidscomponent.cpp	(revision 669942)
+++ skycomponents/asteroidscomponent.cpp	(working copy)
@@ -75,6 +75,7 @@
 					psky.setPen( QColor( ks->data()->colorScheme()->colorNamed( "PNameColor" ) ) );
 					ast->drawNameLabel( psky, o.x(), o.y(), scale );
 				}
+
 			}
 		}
 	}
@@ -117,3 +118,21 @@
 		}
 	}
 }
+
+SkyObject* AsteroidsComponent::objectNearest( SkyPoint *p, double &maxrad ) {
+	SkyObject *oBest = 0;
+
+	foreach ( SkyObject *o, objectList() ) {
+
+		KSAsteroid *ast = (KSAsteroid*)o;
+		if ( ast->mag() > Options::magLimitAsteroid() ) continue;
+
+		double r = o->angularDistanceTo( p ).Degrees();
+		if ( r < maxrad ) {
+			oBest = o;
+			maxrad = r;
+		}
+	}
+
+	return oBest;
+}
\ No newline at end of file
Index: skycomponents/asteroidscomponent.h
===================================================================
--- skycomponents/asteroidscomponent.h	(revision 669942)
+++ skycomponents/asteroidscomponent.h	(working copy)
@@ -76,6 +76,8 @@
 		*@li 94-98 Magnitude [double]
 		*/
 		virtual void init( KStarsData *data );
+
+		SkyObject* objectNearest( SkyPoint *, double & );
 };
 
 #endif
Index: kspopupmenu.cpp
===================================================================
--- kspopupmenu.cpp	(revision 669942)
+++ kspopupmenu.cpp	(working copy)
@@ -146,7 +146,6 @@
 		aType->setDefaultWidget( labType );
 		addAction( aType );
 	}
-
 	labConstellation = new QLabel( "<b>"+ks->data()->skyComposite()->constellation( obj )+"</b>", this );
 	labConstellation->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
 	aConstellation = new KAction( this );


_______________________________________________
Kstars-devel mailing list
Kstars-devel@kde.org
https://mail.kde.org/mailman/listinfo/kstars-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic