[Kstars-devel] branches/kstars/summer/kstars/kstars/tools
Prakash Mohan
prak902000 at gmail.com
Thu May 7 21:48:11 CEST 2009
SVN commit 965003 by prakash:
Adding, the Altitude Vs Time plot within Observation List.
CCMAIL: kstars-devel at kde.org
M +42 -3 observinglist.cpp
M +4 -2 observinglist.h
M +23 -2 observinglist.ui
--- branches/kstars/summer/kstars/kstars/tools/observinglist.cpp #965002:965003
@@ -37,6 +37,10 @@
#include <kfiledialog.h>
#include <ktemporaryfile.h>
#include <klineedit.h>
+#include <kplotobject.h>
+#include <kplotaxis.h>
+#include <kplotwidget.h>
+#include <ksnumbers.h>
#include "obslistwizard.h"
#include "kstars.h"
@@ -74,7 +78,7 @@
// ---------------------------------
ObservingList::ObservingList( KStars *_ks )
: KDialog( (QWidget*)_ks ),
- ks( _ks ), LogObject(0), m_CurrentObject(0),
+ ks( _ks ), LogObject(0), m_CurrentObject(0), PlotObject(0),
noNameStars(0), isModified(false), bIsLarge(true)
{
ui = new ObservingListUI( this );
@@ -94,7 +98,12 @@
ui->TableView->setModel( m_SortModel );
ui->TableView->horizontalHeader()->setStretchLastSection( true );
ui->TableView->horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents );
-
+ ui->View->setLimits( -12.0, 12.0, -90.0, 90.0 );
+ ui->View->axis(KPlotWidget::BottomAxis)->setTickLabelFormat( 't' );
+ ui->View->axis(KPlotWidget::BottomAxis)->setLabel( i18n( "Local Time" ) );
+ ui->View->axis(KPlotWidget::TopAxis)->setTickLabelFormat( 't' );
+ ui->View->axis(KPlotWidget::TopAxis)->setTickLabelsShown( true );
+
//Connections
connect( this, SIGNAL( closeClicked() ), this, SLOT( slotClose() ) );
connect( ui->TableView, SIGNAL( doubleClicked( const QModelIndex& ) ),
@@ -310,7 +319,8 @@
//set LogObject to the new selected object
LogObject = currentObject();
-
+ PlotObject = currentObject();
+ plot( PlotObject );
ui->NotesLabel->setEnabled( true );
ui->NotesEdit->setEnabled( true );
@@ -724,6 +734,35 @@
}
}
+void ObservingList::plot( SkyObject *o ) {
+ if( !o ) return;
+ KStarsDateTime ut = KStarsDateTime::currentDateTime().addSecs( (1.5)*86400. );
+
+ double h1 = ks->LST()->Hours();
+ if ( h1 > 12.0 ) h1 -= 24.0;
+ double h2 = h1 + 24.0;
+ ui->View->setSecondaryLimits( h1, h2, -90.0, 90.0 );
+ ui->View->update();
+ KPlotObject *po = new KPlotObject( Qt::white, KPlotObject::Lines, 2.0 );
+ for ( double h=-12.0; h<=12.0; h+=0.5 ) {
+ po->addPoint( h, findAltitude( o, h ) );
+ }
+ ui->View->addPlotObject( po );
+}
+double ObservingList::findAltitude( SkyPoint *p, double hour ) {
+ if (KStarsDateTime::currentDateTime().time().hour() > 12 )
+ hour+=24.0;
+ KStarsDateTime ut = KStarsDateTime::currentDateTime();
+ ut.setTime(QTime());
+ ut = ks->geo()->LTtoUT(ut);
+ ut= ut.addSecs( hour*3600.0 );
+ dms LST = ks->geo()->GSTtoLST( ut.gst() );
+ p->EquatorialToHorizontal( &LST, ks->geo()->lat() );
+ kDebug()<<"OL : "<<p->alt()->Degrees()<<" "<<hour;
+ return p->alt()->Degrees();
+}
+
+
void ObservingList::slotToggleSize() {
if ( isLarge() ) {
ui->MiniButton->setIcon( KIcon("view-fullscreen") );
--- branches/kstars/summer/kstars/kstars/tools/observinglist.h #965002:965003
@@ -178,6 +178,9 @@
*/
void saveCurrentUserLog();
+ void plot( SkyObject *o=NULL);
+
+ double findAltitude( SkyPoint *p=NULL, double hour=0);
protected slots:
void slotClose();
@@ -186,9 +189,8 @@
ObservingListUI *ui;
QList<SkyObject*> m_ObservingList;
// QList<SkyObject*> m_SelectedObjects;
- SkyObject *LogObject, *m_CurrentObject;
+ SkyObject *LogObject, *m_CurrentObject, *PlotObject;
uint noNameStars;
-
bool isModified, bIsLarge;
QString ListName, FileName;
--- branches/kstars/summer/kstars/kstars/tools/observinglist.ui #965002:965003
@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>500</width>
- <height>500</height>
+ <height>1000</height>
</rect>
</property>
<layout class="QVBoxLayout" >
@@ -406,6 +406,22 @@
</widget>
</item>
<item>
+ <widget class="AVTPlotWidget" name="View" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize" >
+ <size>
+ <width>400</width>
+ <height>300</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
<widget class="QLabel" name="NotesLabel" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
@@ -448,7 +464,12 @@
<extends>QTextEdit</extends>
<header>ktextedit.h</header>
</customwidget>
- </customwidgets>
+ <customwidget>
+ <class>AVTPlotWidget</class>
+ <extends>KPlotWidget</extends>
+ <header>tools/avtplotwidget.h</header>
+ </customwidget>
+ </customwidgets>
<resources/>
<connections/>
</ui>
More information about the Kstars-devel
mailing list