[prev in list] [next in list] [prev in thread] [next in thread]
List: kstars-devel
Subject: Re: [Kstars-devel] Continuation of implementation for bug#178232
From: Abhijit Apte <abhijit.apte () gmail ! com>
Date: 2010-04-11 14:40:59
Message-ID: z2nf7c0912c1004110728y2e0ff288g69e8aade1264c43d () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Hi Alexey,
Pl. find the updated patch, sorry it took a month :D
Also find my comments inlined below.
Rgds
-Abhi
== List of easily detectable bugs ==
>
> 1. Open popup menu with right click then click somewhere on the map to
> close
> it. In about half of cases rectangle appears.
>
> Fixed.
> 2. Once mouse cursor is moved away from skymap rectangle is stuck.
>
I didn't notice this after fixing issue mentioned in 1.
>
> == Comments ==
>
> 1, I think there is no need store SkyPoints for rectangle angles inside of
> SkyMap. It's better to calculate them from scree coordinates when mouse
> button
> is released and pass them into showObjectsInRect as parameters.
>
> But I think we'll still have to store first right click position (into
firstRClickPos)
> 2. instead of scary ladder of ifs in mouseMoveEvents you can use following
> code (if I get you intent correctly)
> > FindObjectsRect = QRect( firstRClickPos, e->pos() ).normalized();
> > update();
> Much shorter and easier to understand.
>
Yes, thanks for this comment, I tried this instead of the ladder and it
works.
>
> == Minor notes ==
> * QRect in drawBox should be passed as const reference.
Did this change
> * There is function QPainter::drawRect(const QRect&).
>
In the drawBox() implementation, modified the call p.drawRect( box.x(),
box.y()... ) with the above i.e. p.drawRect(box)
[Attachment #5 (text/html)]
Hi Alexey,<br><br>Pl. find the updated patch, sorry it took a month :D<br>Also find \
my comments inlined below.<br><br>Rgds<br>-Abhi<br><br> <div \
class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid \
rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">== List of easily \
detectable bugs ==<br> <br>
1. Open popup menu with right click then click somewhere on the map to close<br>
it. In about half of cases rectangle appears.<br>
<br></blockquote><div>Fixed. <br></div><div> </div><blockquote class="gmail_quote" \
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; \
padding-left: 1ex;"> 2. Once mouse cursor is moved away from skymap rectangle is \
stuck.<br></blockquote><div>I didn't notice this after fixing issue mentioned in \
1.<br> <br></div><blockquote class="gmail_quote" style="border-left: 1px solid \
rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
== Comments ==<br>
<br>
1, I think there is no need store SkyPoints for rectangle angles inside of<br>
SkyMap. It's better to calculate them from scree coordinates when mouse \
button<br> is released and pass them into showObjectsInRect as parameters.<br>
<br></blockquote><div>But I think we'll still have to store first right click \
position (into firstRClickPos) <br></div><div> </div><blockquote class="gmail_quote" \
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; \
padding-left: 1ex;">
2. instead of scary ladder of ifs in mouseMoveEvents you can use following<br>
code (if I get you intent correctly)<br>
> FindObjectsRect = QRect( firstRClickPos, e->pos() ).normalized();<br>
> update();<br>
Much shorter and easier to understand.<br></blockquote><div>Yes, thanks for this \
comment, I tried this instead of the ladder and it works.<br> </div><blockquote \
class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt \
0pt 0.8ex; padding-left: 1ex;">
<br>
== Minor notes ==<br>
* QRect in drawBox should be passed as const reference.</blockquote><div>Did this \
change <br></div><blockquote class="gmail_quote" style="border-left: 1px solid \
rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
* There is function QPainter::drawRect(const QRect&).<br></blockquote><div>In the \
drawBox() implementation, modified the call p.drawRect( box.x(), box.y()... ) with \
the above i.e. p.drawRect(box)<br><br> <br></div></div> <br><br>
--0016e6d77c45672db00483f6d952--
["patch11apr.diff" (text/x-patch)]
Index: skymap.cpp
===================================================================
--- skymap.cpp (revision 1113224)
+++ skymap.cpp (working copy)
@@ -152,6 +152,7 @@
m_Scale = 1.0;
ZoomRect = QRect();
+ FindObjectsRect = QRect();
setDefaultMouseCursor(); // set the cross cursor
@@ -1467,6 +1468,36 @@
return p.x() < -100000.0;
}
+void SkyMap::showObjectsInRectangle()
+{
+ if( (secondRClickPos-firstRClickPos).manhattanLength() < \
QApplication::startDragDistance() ) + {
+ if( clickedObject() )
+ // Rightclick release happened within the drag limits
+ // Got to populate info about a single clicked object
+ clickedObject()->showPopupMenu( pmenu, QCursor::pos() );
+ else
+ {
+ // Rightclick release happened within the drag limits
+ // Got to populate info with unknown object since there was
+ // no clicked object in the region
+ SkyObject object(
+ SkyObject::TYPE_UNKNOWN,
+ clickedPoint()->ra().Hours(),
+ clickedPoint()->dec().Degrees() );
+
+ pmenu->createEmptyMenu( &object );
+ pmenu->popup( QCursor::pos() );
+ }
+ }
+ else
+ {
+ QList<SkyObject*> objList = data->skyComposite()->findObjectsInArea( \
firstPoint, secondPoint ); + for( QList<SkyObject*>::const_iterator it = \
objList.constBegin(); it != objList.constEnd(); it++ ) + kDebug() << \
(*it)->name() << endl; + }
+}
+
#ifdef HAVE_XPLANET
void SkyMap::startXplanet( const QString & outputFile ) {
QString year, month, day, hour, minute, seconde, fov;
Index: skymap.h
===================================================================
--- skymap.h (revision 1113224)
+++ skymap.h (working copy)
@@ -438,6 +438,9 @@
* @note the labelObjects list is managed by the SkyMapComponents class
*/
void drawObjectLabels( QList<SkyObject*>& labelObjects, QPainter &psky );
+
+ /**@short show objects in rectangle */
+ void showObjectsInRectangle();
public slots:
//DEBUG_KIO_JOB
@@ -730,11 +733,12 @@
void drawObservingList( QPainter &psky );
/**
- *@short Draw a dotted-line rectangle which traces the potential new \
field-of-view in ZoomBox mode. + *@short Draw a dotted-line rectangle
+ *@param box reference to the QRect which should be drawn
*@param psky reference to the QPainter on which to draw (this should be the Sky \
pixmap).
*/
- void drawZoomBox( QPainter &psky );
-
+ void drawBox( const QRect& box, QPainter &psky );
+
/**
*@short Draw a dotted-line rectangle which traces the potential new \
field-of-view in ZoomBox mode.
*@param psky reference to the QPainter on which to draw (this should be the Sky \
pixmap). @@ -851,7 +855,11 @@
SkyLine AngularRuler; //The line for measuring angles in the map
QRect ZoomRect; //The manual-focus circle.
+ QRect FindObjectsRect; // rectangle to find objects in
+ QPoint firstRClickPos, secondRClickPos;
+ SkyPoint firstPoint, secondPoint;
+
//data for transient object labels
QTimer TransientTimer, HoverTimer;
QColor TransientColor;
Index: skymapdraw.cpp
===================================================================
--- skymapdraw.cpp (revision 1113224)
+++ skymapdraw.cpp (working copy)
@@ -142,7 +142,8 @@
}
drawTelescopeSymbols( p );
drawObservingList( p );
- drawZoomBox( p );
+ drawBox( ZoomRect, p );
+ drawBox( FindObjectsRect, p );
if ( transientObject() )
drawTransientLabel( p );
@@ -159,11 +160,11 @@
toScreen( AngularRuler.point(1) ) );
}
-void SkyMap::drawZoomBox( QPainter &p ) {
+void SkyMap::drawBox( const QRect& box, QPainter &p ) {
//draw the manual zoom-box, if it exists
- if ( ZoomRect.isValid() ) {
+ if ( box.isValid() ) {
p.setPen( QPen( Qt::white, 1.0, Qt::DotLine ) );
- p.drawRect( ZoomRect.x(), ZoomRect.y(), ZoomRect.width(), ZoomRect.height() \
); + p.drawRect( box );
}
}
Index: skymapevents.cpp
===================================================================
--- skymapevents.cpp (revision 1113224)
+++ skymapevents.cpp (working copy)
@@ -457,6 +457,12 @@
}
}
+ if( FindObjectsRect.isValid() )
+ {
+ FindObjectsRect = QRect( firstRClickPos, e->pos() ).normalized();
+ update();
+ }
+
if ( unusablePoint( e->pos() ) ) return; // break if point is unusable
//determine RA, Dec of mouse pointer
@@ -531,7 +537,27 @@
zoomOutOrMagStep( e->modifiers() );
}
-void SkyMap::mouseReleaseEvent( QMouseEvent * ) {
+void SkyMap::mouseReleaseEvent( QMouseEvent * e ) {
+ kDebug() << Q_FUNC_INFO << endl;
+
+ if ( e->button() == Qt::RightButton ) {
+ secondRClickPos = QCursor::pos();
+ // The new point after drag has to be recorded and saved for future use
+ setMousePoint( fromScreen( e->pos(), data->lst(), data->geo()->lat() ) );
+ mousePoint()->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+ setClickedPoint( mousePoint() );
+ clickedPoint()->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+ secondPoint = ClickedPoint;
+
+ showObjectsInRectangle();
+
+ if( FindObjectsRect.isValid() ) {
+ FindObjectsRect = QRect();
+ }
+
+ return;
+ }
+
if ( ZoomRect.isValid() ) {
//Zoom in on center of Zoom Circle, by a factor equal to the ratio
//of the sky pixmap's width to the Zoom Circle's diameter
@@ -552,7 +578,7 @@
setDefaultMouseCursor();
ZoomRect = QRect(); //just in case user Ctrl+clicked + released w/o \
dragging... }
-
+
if (mouseMoveCursor) setDefaultMouseCursor(); // set default cursor
if (mouseButtonDown) { //false if double-clicked, because it's unset there.
mouseButtonDown = false;
@@ -605,6 +631,10 @@
setClickedPoint( mousePoint() );
clickedPoint()->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
+ // Store this skypoint for future use
+ // in case mouse is right-click dragged
+ firstPoint = ClickedPoint;
+
//Find object nearest to clickedPoint()
double maxrad = 1000.0/Options::zoomFactor();
SkyObject* obj = data->skyComposite()->objectNearest( clickedPoint(), maxrad \
); @@ -628,14 +658,10 @@
// Compute angular distance.
slotEndAngularDistance();
} else {
- // Show popup menu
- if( clickedObject() ) {
- clickedObject()->showPopupMenu( pmenu, QCursor::pos() );
- } else {
- SkyObject o( SkyObject::TYPE_UNKNOWN, \
clickedPoint()->ra().Hours(), clickedPoint()->dec().Degrees() );
- pmenu->createEmptyMenu( &o );
- pmenu->popup( QCursor::pos() );
- }
+ firstRClickPos = QCursor::pos();
+ FindObjectsRect.moveTopLeft( firstRClickPos );
+ FindObjectsRect.setTopLeft( firstRClickPos );
+ FindObjectsRect.setBottomRight( firstRClickPos );
}
break;
default: ;
_______________________________________________
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