• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kstars

timestepbox.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           timestepbox.cpp  -  description
00003                              -------------------
00004     begin                : Sat Apr 13 2002
00005     copyright            : (C) 2002 by Jason Harris
00006     email                : kstars@30doradus.org
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include <stdlib.h>
00019 #include <qtooltip.h>
00020 #include <qwhatsthis.h>
00021 #include <kdebug.h>
00022 #include <klocale.h>
00023 
00024 #include "timestepbox.h"
00025 
00026 TimeStepBox::TimeStepBox( QWidget *parent, const char* name, bool daysonly )
00027     : QFrame( parent, name ) {
00028 
00029     timeBox = new TimeSpinBox( this, "timebox", daysonly );
00030     unitBox = new TimeUnitBox( this, "unitbox", daysonly );
00031 
00032     QToolTip::add( timeBox, i18n( "Adjust time step" ) );
00033     QToolTip::add( unitBox, i18n( "Adjust time step units" ) );
00034 
00035     QWhatsThis::add( this, i18n( "Set the timescale for the simulation clock.  A setting of \"1 sec\" means the clock advances in real-time, keeping up perfectly with your CPU clock.  Higher values make the simulation clock run faster, lower values make it run slower.  Negative values make it run backwards."
00036 "\n\n"
00037 "There are two pairs of up/down buttons.  The left pair will cycle through all available timesteps in sequence.  Since there are a large number of timesteps, the right pair is provided to skip to the next higher/lower unit of time.  For example, if the timescale is currently \"1 min\", the right up button will make it \"1 hour\", and the right down button will make it \"1 sec\"" ) );
00038     hlay = new QHBoxLayout( this, 2, 0 );
00039     hlay->addWidget( timeBox );
00040     hlay->addWidget( unitBox );
00041     hlay->activate();
00042 
00043     timeBox->setValue( 4 ); //real-time
00044 
00045     connect( unitBox, SIGNAL( valueChanged( int ) ), this, SLOT( changeUnits() ) );
00046     connect( timeBox, SIGNAL( valueChanged( int ) ), this, SLOT( syncUnits( int ) ) );
00047     connect( timeBox, SIGNAL( scaleChanged( float ) ), this, SIGNAL( scaleChanged( float ) ) );
00048 
00049 }
00050 
00051 void TimeStepBox::changeUnits( void ) {
00052     timeBox->setValue( unitBox->unitValue() );
00053 }
00054 
00055 void TimeStepBox::syncUnits( int tstep ) {
00056     int i;
00057     for ( i=unitbox()->maxValue(); i>=unitbox()->minValue(); --i )
00058         if ( abs(tstep) >= unitBox->getUnitValue( i ) ) break;
00059 
00060 //don't want setValue to trigger changeUnits()...
00061     disconnect( unitBox, SIGNAL( valueChanged( int ) ), this, SLOT( changeUnits() ) );
00062     unitBox->setValue( tstep < 0 ? -i : i );
00063     connect( unitBox, SIGNAL( valueChanged( int ) ), this, SLOT( changeUnits() ) );
00064 }
00065 
00066 void TimeStepBox::setDaysOnly( bool daysonly ) {
00067     tsbox()->setDaysOnly( daysonly );
00068     unitbox()->setDaysOnly( daysonly );
00069 }
00070 
00071 #include "timestepbox.moc"

kstars

Skip menu "kstars"
  • Main Page
  • Modules
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • keduca
  • kstars
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal