[Kstars-devel] KDE/kdeedu/kstars/kstars
Jasem Mutlaq
mutlaqja at ikarustech.com
Sat Sep 8 00:33:31 CEST 2007
SVN commit 709610 by mutlaqja:
Fixed crash condition in telescope wizard autocan. Using KUndoStack
instead of K3Command in the FITS Viewer. Simplified LX200 Basic layout.
The QA Wiki is great. I added a few tests and will hopefully finish most
of the list soon.
CCMAIL:kstars-devel at kde.org
M +5 -4 fitshistogram.cpp
M +6 -6 fitshistogram.h
M +16 -4 fitsimage.cpp
M +33 -20 fitsviewer.cpp
M +5 -4 fitsviewer.h
M +8 -11 indi/CMakeLists.txt
M +3 -2 indi/drivers/telescope/lx200basic.cpp
M +1 -5 indi/drivers/video/v4ldriver.cpp
M +7 -3 indidriver.cpp
M +16 -1 indiproperty.cpp
M +1 -0 indiproperty.h
M +6 -2 telescopewizardprocess.cpp
M +1 -1 widgets/fitshistogramdraw.cpp
--- trunk/KDE/kdeedu/kstars/kstars/fitshistogram.cpp #709609:709610
@@ -32,6 +32,7 @@
#include <QMouseEvent>
#include <QPaintEvent>
+#include <KUndoStack>
#include <kdebug.h>
#include <klineedit.h>
#include <klocale.h>
@@ -121,7 +122,7 @@
histC = new FITSHistogramCommand(viewer, this, type, min, max);
- viewer->history->addCommand(histC);
+ viewer->history->push(histC);
}
void FITSHistogram::constructHistogram(int hist_width, int hist_height)
@@ -243,7 +244,7 @@
//delete (oldImage);
}
-void FITSHistogramCommand::execute()
+void FITSHistogramCommand::redo()
{
float val, bufferVal;
@@ -323,7 +324,7 @@
viewer->fitsChange();
}
-void FITSHistogramCommand::unexecute()
+void FITSHistogramCommand::undo()
{
FITSImage *image = viewer->image;
@@ -337,7 +338,7 @@
}
-QString FITSHistogramCommand::name() const
+QString FITSHistogramCommand::text() const
{
switch (type)
--- trunk/KDE/kdeedu/kstars/kstars/fitshistogram.h #709609:709610
@@ -19,8 +19,8 @@
#define FITSHISTOGRAM
#include "ui_fitshistogramui.h"
-#include <k3command.h>
+#include <QUndoCommand>
#include <QPixmap>
#include <QMouseEvent>
#include <QPaintEvent>
@@ -78,15 +78,15 @@
};
- class FITSHistogramCommand : public K3Command
+ class FITSHistogramCommand : public QUndoCommand
{
public:
FITSHistogramCommand(QWidget * parent, FITSHistogram *inHisto, int newType, int lmin, int lmax);
- ~FITSHistogramCommand();
+ virtual ~FITSHistogramCommand();
- void execute();
- void unexecute();
- QString name() const;
+ virtual void redo();
+ virtual void undo();
+ virtual QString text() const;
private:
--- trunk/KDE/kdeedu/kstars/kstars/fitsimage.cpp #709609:709610
@@ -314,6 +314,7 @@
{
float val=0;
double bscale, bzero;
+ QAction *toolAction = NULL;
// Get Min Max failed, scaling is not possible
if (type == ZOOM_KEEP_LEVEL)
@@ -370,7 +371,11 @@
currentHeight = stats.dim[1] * (currentZoom / ZOOM_DEFAULT);
if (currentZoom <= ZOOM_MIN)
- viewer->actionCollection()->action("view_zoom_out")->setEnabled (false);
+ {
+ toolAction = viewer->actionCollection()->action("view_zoom_out");
+ if (toolAction != NULL)
+ toolAction->setEnabled (false);
+ }
image_frame->resize( (int) currentWidth, (int) currentHeight);
@@ -412,15 +417,22 @@
void FITSImage::fitsZoomIn()
{
-
+ QAction *toolAction = NULL;
+
if (currentZoom < ZOOM_DEFAULT)
currentZoom += ZOOM_LOW_INCR;
else
currentZoom += ZOOM_HIGH_INCR;
- viewer->actionCollection()->action("view_zoom_out")->setEnabled (true);
+ toolAction = viewer->actionCollection()->action("view_zoom_out");
+ if (toolAction != NULL)
+ toolAction->setEnabled (true);
if (currentZoom >= ZOOM_MAX)
- viewer->actionCollection()->action("view_zoom_in")->setEnabled (false);
+ {
+ toolAction = viewer->actionCollection()->action("view_zoom_in");
+ if (toolAction != NULL)
+ toolAction->setEnabled (false);
+ }
currentWidth = stats.dim[0] * (currentZoom / ZOOM_DEFAULT);
currentHeight = stats.dim[1] * (currentZoom / ZOOM_DEFAULT);
--- trunk/KDE/kdeedu/kstars/kstars/fitsviewer.cpp #709609:709610
@@ -31,11 +31,10 @@
#include <ktemporaryfile.h>
#include <kmenubar.h>
#include <kstatusbar.h>
-#include <k3command.h>
#include <klineedit.h>
#include <kicon.h>
+#include <KUndoStack>
-
#include <QFile>
#include <QCursor>
#include <QRadioButton>
@@ -48,6 +47,8 @@
#include <QHeaderView>
#include <QApplication>
+
+
#include <math.h>
#include <unistd.h>
#include <stdlib.h>
@@ -67,16 +68,17 @@
{
image = NULL;
currentURL = *url;
- histo = NULL;
+ histogram = NULL;
Dirty = 0;
- /* Initiliaze menu actions */
- history = new K3CommandHistory(actionCollection());
+ history = new KUndoStack();
history->setUndoLimit(10);
- history->setRedoLimit(10);
- history->documentSaved();
- connect(history, SIGNAL(documentRestored()), this, SLOT(fitsRestore()));
+ history->clear();
+ connect(history, SIGNAL(cleanChanged(bool)), this, SLOT(fitsRestore(bool)));
+ history->createUndoAction(actionCollection());
+ history->createRedoAction(actionCollection());
+
/* Setup image widget */
image = new FITSImage(this);
setCentralWidget(image);
@@ -182,7 +184,10 @@
if ( ans == KMessageBox::Yes )
fileSave();
else if ( ans == KMessageBox::No )
+ {
+ history->clear();
fitsRestore();
+ }
}
if (Dirty == 0)
@@ -201,7 +206,10 @@
if ( ans == KMessageBox::Yes )
fileSave();
else if ( ans == KMessageBox::No )
+ {
+ history->clear();
fitsRestore();
+ }
}
if (Dirty == 0)
@@ -223,7 +231,10 @@
if ( ans == KMessageBox::Yes )
fileSave();
else if ( ans == KMessageBox::No )
+ {
+ history->clear();
fitsRestore();
+ }
}
KUrl fileURL = KFileDialog::getOpenUrl( QDir::homePath(), "*.fits *.fit *.fts|Flexible Image Transport System");
@@ -235,11 +246,11 @@
currentURL = fileURL;
// Close FITS if open and delete it
- if (histo != NULL)
+ if (histogram != NULL)
{
- histo->close();
- delete (histo);
- histo = NULL;
+ histogram->close();
+ delete (histogram);
+ histogram = NULL;
}
initFITS();
@@ -323,22 +334,24 @@
void FITSViewer::imageHistogram()
{
- if (histo == NULL)
+ if (histogram == NULL)
{
- histo = new FITSHistogram(this);
- histo->show();
+ histogram = new FITSHistogram(this);
+ histogram->show();
}
else
- histo->show();
+ histogram->show();
}
-void FITSViewer::fitsRestore()
+void FITSViewer::fitsRestore(bool clean)
{
-
- Dirty = 0;
- setWindowTitle(currentURL.fileName());
+ if (clean)
+ {
+ Dirty = 0;
+ setWindowTitle(currentURL.fileName());
}
+}
void FITSViewer::fitsChange()
{
--- trunk/KDE/kdeedu/kstars/kstars/fitsviewer.h #709609:709610
@@ -32,10 +32,11 @@
#define INITIAL_W 640
#define INITIAL_H 480
-class K3CommandHistory;
+class KUndoStack;
class FITSImage;
class FITSHistogram;
+
class FITSViewer : public KXmlGuiWindow
{
Q_OBJECT
@@ -63,7 +64,7 @@
void fileSave();
void fileSaveAs();
void fitsCOPY();
- void fitsRestore();
+ void fitsRestore(bool clean=true);
void fitsStatistics();
void fitsHeader();
void slotClose();
@@ -73,9 +74,9 @@
bool initFITS();
FITSImage *image; /* FITS image object */
- FITSHistogram *histo; /* FITS Histogram */
+ FITSHistogram *histogram; /* FITS Histogram */
- K3CommandHistory *history; /* History for undo/redo */
+ KUndoStack *history; /* History for undo/redo */
int Dirty; /* Document modified? */
KUrl currentURL; /* FITS File name and path */
--- trunk/KDE/kdeedu/kstars/kstars/indi/CMakeLists.txt #709609:709610
@@ -253,21 +253,18 @@
install(TARGETS indi_lx200generic DESTINATION ${BIN_INSTALL_DIR} )
-## Make symbolic links to lx200generic ##
-## FIXME this actually doesn't work, it never ends up installing _any_ symlinks, what's wrong? ##
+ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_BUILD COMMAND rm ARGS -f ${BIN_INSTALL_DIR}/indi_lx200classic)
+ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_BUILD COMMAND ln ARGS -s indi_lx200generic ${BIN_INSTALL_DIR}/indi_lx200classic)
-ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_INSTALL COMMAND rm ARGS -f ${BIN_INSTALL_DIR}/indi_lx200classic)
-ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_INSTALL COMMAND ln ARGS -s lx200generic ${BIN_INSTALL_DIR}/indi_lx200classic)
+ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_BUILD COMMAND rm ARGS -f ${BIN_INSTALL_DIR}/indi_lx200autostar)
+ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_BUILD COMMAND ln ARGS -s indi_lx200generic ${BIN_INSTALL_DIR}/indi_lx200autostar)
-ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_INSTALL COMMAND rm ARGS -f ${BIN_INSTALL_DIR}/indi_lx200autostar)
-ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_INSTALL COMMAND ln ARGS -s lx200generic ${BIN_INSTALL_DIR}/indi_lx200autostar)
+ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_BUILD COMMAND rm ARGS -f ${BIN_INSTALL_DIR}/indi_lx200_16)
+ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_BUILD COMMAND ln ARGS -s indi_lx200generic ${BIN_INSTALL_DIR}/indi_lx200_16)
-ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_INSTALL COMMAND rm ARGS -f ${BIN_INSTALL_DIR}/indi_lx200_16)
-ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_INSTALL COMMAND ln ARGS -s lx200generic ${BIN_INSTALL_DIR}/indi_lx200_16)
+ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_BUILD COMMAND rm ARGS -f ${BIN_INSTALL_DIR}/indi_lx200gps)
+ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_BUILD COMMAND ln ARGS -s indi_lx200generic ${BIN_INSTALL_DIR}/indi_lx200gps)
-ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_INSTALL COMMAND rm ARGS -f ${BIN_INSTALL_DIR}/lx200gps)
-ADD_CUSTOM_COMMAND(TARGET indi_lx200generic POST_INSTALL COMMAND ln ARGS -s lx200generic ${BIN_INSTALL_DIR}/indi_lx200gps)
-
#################################################################################
########### Celestron GPS ############
--- trunk/KDE/kdeedu/kstars/kstars/indi/drivers/telescope/lx200basic.cpp #709609:709610
@@ -48,6 +48,7 @@
extern char* me;
#define BASIC_GROUP "Main Control"
+#define OPTIONS_GROUP "Options"
#define currentRA EqN[0].value
#define currentDEC EqN[1].value
@@ -173,11 +174,11 @@
IUFillNumber(&SlewPrecisionN[0], "SlewRA", "RA (arcmin)", "%10.6m", 0., 60., 1., 3.0);
IUFillNumber(&SlewPrecisionN[1], "SlewDEC", "Dec (arcmin)", "%10.6m", 0., 60., 1., 3.0);
- IUFillNumberVector(&SlewPrecisionNP, SlewPrecisionN, NARRAY(SlewPrecisionN), mydev, "Slew Precision", "", BASIC_GROUP, IP_RW, 0, IPS_IDLE);
+ IUFillNumberVector(&SlewPrecisionNP, SlewPrecisionN, NARRAY(SlewPrecisionN), mydev, "Slew Precision", "", OPTIONS_GROUP, IP_RW, 0, IPS_IDLE);
IUFillNumber(&TrackPrecisionN[0], "TrackRA", "RA (arcmin)", "%10.6m", 0., 60., 1., 3.0);
IUFillNumber(&TrackPrecisionN[1], "TrackDEC", "Dec (arcmin)", "%10.6m", 0., 60., 1., 3.0);
- IUFillNumberVector(&TrackPrecisionNP, TrackPrecisionN, NARRAY(TrackPrecisionN), mydev, "Tracking Precision", "", BASIC_GROUP, IP_RW, 0, IPS_IDLE);
+ IUFillNumberVector(&TrackPrecisionNP, TrackPrecisionN, NARRAY(TrackPrecisionN), mydev, "Tracking Precision", "", OPTIONS_GROUP, IP_RW, 0, IPS_IDLE);
--- trunk/KDE/kdeedu/kstars/kstars/indi/drivers/video/v4ldriver.cpp #709609:709610
@@ -418,17 +418,13 @@
{
frameCount++;
- // Drop some frames
- /*if (FrameN[2].value > 160)
- {* FIXME find an optimal solution to drop frame rates */
dropLarge--;
if (dropLarge == 0)
{
- dropLarge = (int) (5.0 * (FrameN[2].value / 160.0));
+ dropLarge = (int) (((ImageTypeS[0].s == ISS_ON) ? 5.0 : 15.0) * (FrameN[2].value / 160.0));
updateStream();
return;
}
-
}
else if (ExposeTimeNP.s == IPS_BUSY)
{
--- trunk/KDE/kdeedu/kstars/kstars/indidriver.cpp #709609:709610
@@ -398,11 +398,14 @@
tmpAction = ksw->actionCollection()->action("capture_sequence");
- if (!tmpAction)
- kDebug() << "Warning: capture_sequence action not found";
- else
+ if (tmpAction != NULL)
tmpAction->setEnabled(activeImaging);
+ tmpAction = NULL;
+ tmpAction = ksw->actionCollection()->action("indi_cpl");
+ if (tmpAction != NULL)
+ tmpAction->setEnabled(activeDevice);
+#if 0
/* FIXME The following seems to cause a crash in KStars when we use
the telescope wizard to automatically search for scopes. I can't
find any correlation! */
@@ -414,6 +417,7 @@
else
tmpAction->setEnabled(activeDevice);
// Troubled Code END
+#endif
}
--- trunk/KDE/kdeedu/kstars/kstars/indiproperty.cpp #709609:709610
@@ -47,6 +47,7 @@
#include <unistd.h>
#include <stdlib.h>
+ #include <assert.h>
/*******************************************************************
** INDI Property: contains widgets, labels, and their status
@@ -263,10 +264,24 @@
}
}
+void INDI_P::newComboBoxItem(const QString &item)
+{
+ foreach(INDI_E *lp, el)
+ {
+ if (lp->push_w->text() == item)
+ {
+ newSwitch(lp);
+ break;
+ }
+ }
+}
+
void INDI_P::newSwitch(INDI_E *lp)
{
QFont buttonFont;
+ assert(lp != NULL);
+
switch (guitype)
{
case PG_MENU:
@@ -684,7 +699,7 @@
PHBox->addWidget(om_w);
PHBox->addItem(HorSpacer);
- QObject::connect(om_w, SIGNAL(activated(int)), this, SLOT(newSwitch(int)));
+ QObject::connect(om_w, SIGNAL( activated ( const QString &)), this, SLOT(newComboBoxItem( const QString &)));
return (0);
}
--- trunk/KDE/kdeedu/kstars/kstars/indiproperty.h #709609:709610
@@ -99,6 +99,7 @@
void newText();
void newSwitch(INDI_E *lp);
void newAbstractButton(QAbstractButton *button);
+ void newComboBoxItem(const QString &item);
void newBlob();
/*void actionTriggered(QAction* action);*/
--- trunk/KDE/kdeedu/kstars/kstars/telescopewizardprocess.cpp #709609:709610
@@ -311,7 +311,8 @@
Options::setIndiMessages( INDIMessageBar );
- pp->newSwitch(0);
+ lp = pp->findElement("CONNECT");
+ pp->newSwitch(lp);
timeOutCount = 0;
@@ -365,8 +366,11 @@
pp = indiDev->findProp("CONNECTION");
if (!pp) return;
- pp->newSwitch(0);
+ lp = pp->findElement("CONNECT");
+ if (!lp) return;
+ pp->newSwitch(lp);
+
}
void telescopeWizardProcess::linkSuccess()
--- trunk/KDE/kdeedu/kstars/kstars/widgets/fitshistogramdraw.cpp #709609:709610
@@ -107,7 +107,7 @@
void histDrawArea::mouseMoveEvent ( QMouseEvent * event )
{
- int event_x = event->x() - CIRCLE_DIM / 2.;
+ int event_x = (int) (event->x() - CIRCLE_DIM / 2.);
if (event->buttons() & Qt::LeftButton)
{
More information about the Kstars-devel
mailing list