• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • widgets
timestepbox.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  timestepbox.cpp - description
3  -------------------
4  begin : Sat Apr 13 2002
5  copyright : (C) 2002 by Jason Harris
6  email : kstars@30doradus.org
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "timestepbox.h"
19 
20 #include <cstdlib>
21 
22 #include <QHBoxLayout>
23 
24 #include <kdebug.h>
25 #include <klocale.h>
26 
27 TimeStepBox::TimeStepBox( QWidget *parent, bool daysonly )
28  : QWidget( parent ) {
29 
30  timeBox = new TimeSpinBox( this, daysonly );
31  unitBox = new TimeUnitBox( this, daysonly );
32 
33  timeBox->setToolTip( i18n( "Adjust time step" ) );
34  unitBox->setToolTip( i18n( "Adjust time step units" ) );
35 
36  this->setWhatsThis( 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."
37  "\n\n"
38  "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\"" ) );
39  hlay = new QHBoxLayout( this );
40  hlay->setMargin( 0 );
41  hlay->setSpacing( 0 );
42  hlay->addWidget( timeBox );
43  hlay->addWidget( unitBox );
44  hlay->activate();
45 
46  timeBox->setValue( 4 ); //real-time
47 
48  connect( unitBox, SIGNAL( valueChanged( int ) ), this, SLOT( changeUnits() ) );
49  connect( timeBox, SIGNAL( valueChanged( int ) ), this, SLOT( syncUnits( int ) ) );
50  connect( timeBox, SIGNAL( scaleChanged( float ) ), this, SIGNAL( scaleChanged( float ) ) );
51 
52 }
53 
54 void TimeStepBox::changeUnits( void ) {
55  timeBox->setValue( unitBox->unitValue() );
56 }
57 
58 void TimeStepBox::syncUnits( int tstep ) {
59  int i;
60  for ( i=unitbox()->maxValue(); i>=unitbox()->minValue(); --i )
61  if ( abs(tstep) >= unitBox->getUnitValue( i ) ) break;
62 
63  //don't want setValue to trigger changeUnits()...
64  disconnect( unitBox, SIGNAL( valueChanged( int ) ), this, SLOT( changeUnits() ) );
65  unitBox->setValue( tstep < 0 ? -i : i );
66  connect( unitBox, SIGNAL( valueChanged( int ) ), this, SLOT( changeUnits() ) );
67 }
68 
69 void TimeStepBox::setDaysOnly( bool daysonly ) {
70  tsbox()->setDaysOnly( daysonly );
71  unitbox()->setDaysOnly( daysonly );
72 }
73 
74 #include "timestepbox.moc"
TimeSpinBox
Custom spinbox to handle selection of timestep values with variable units.
Definition: timespinbox.h:32
QWidget
TimeUnitBox::getUnitValue
int getUnitValue(int)
the same as unitValue, except you can get the UnitStep for any value, not just the current one...
Definition: timeunitbox.cpp:139
TimeSpinBox::setDaysOnly
void setDaysOnly(bool daysonly)
Definition: timespinbox.cpp:70
TimeUnitBox::unitValue
int unitValue()
Definition: timeunitbox.cpp:132
TimeStepBox::TimeStepBox
TimeStepBox(QWidget *parent=0, bool daysonly=false)
Constructor.
Definition: timestepbox.cpp:27
TimeStepBox::setDaysOnly
void setDaysOnly(bool daysonly)
Definition: timestepbox.cpp:69
timestepbox.h
TimeStepBox::tsbox
TimeSpinBox * tsbox() const
Definition: timestepbox.h:43
TimeUnitBox::setValue
void setValue(int value)
Set the value which describes which time-unit is displayed in the TimeSpinBox.
Definition: timeunitbox.h:63
TimeUnitBox::setDaysOnly
void setDaysOnly(bool daysonly)
Definition: timeunitbox.cpp:91
TimeUnitBox
A pair of buttons, arranged one above the other, labeled "+"/"-".
Definition: timeunitbox.h:45
TimeStepBox::unitbox
TimeUnitBox * unitbox() const
Definition: timestepbox.h:46
TimeStepBox::scaleChanged
void scaleChanged(float)
TimeUnitBox::minValue
int minValue() const
Definition: timeunitbox.h:77
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:21 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

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

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal